|
|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QEvent>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
@ -48,7 +49,6 @@ nmWxPebiGridViewWidget::nmWxPebiGridViewWidget(QWidget* pParent)
|
|
|
|
|
synchronizeDisplayModeFromScene();
|
|
|
|
|
resetControls();
|
|
|
|
|
setControlsEnabled(false);
|
|
|
|
|
m_pRenderContainer->showEmptyState(tr("No grid data."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nmWxPebiGridViewWidget::~nmWxPebiGridViewWidget()
|
|
|
|
|
@ -172,17 +172,6 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
pRenderLayout->addWidget(m_pToolBar);
|
|
|
|
|
pMainLayout->addWidget(pRenderArea, 1);
|
|
|
|
|
|
|
|
|
|
m_pStatusLabel = new QLabel(this);
|
|
|
|
|
m_pStatusLabel->setWordWrap(true);
|
|
|
|
|
m_pStatusLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
|
m_pStatusLabel->setStyleSheet(
|
|
|
|
|
"QLabel { color: rgb(126, 76, 0); "
|
|
|
|
|
"background-color: rgb(255, 244, 204); "
|
|
|
|
|
"border-top: 1px solid rgb(220, 190, 105); "
|
|
|
|
|
"padding: 4px 8px; }");
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
pMainLayout->addWidget(m_pStatusLabel);
|
|
|
|
|
|
|
|
|
|
// 显示模式属于当前预览窗口,业务控件不下沉到通用渲染容器。
|
|
|
|
|
QWidget* pControlBar = new QWidget(this);
|
|
|
|
|
QHBoxLayout* pControlLayout = new QHBoxLayout(pControlBar);
|
|
|
|
|
@ -215,11 +204,17 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
|
|
|
|
|
m_pGridInfoLabel = new QLabel(pControlBar);
|
|
|
|
|
m_pGridInfoLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
|
m_pStatusLabel = new QLabel(pControlBar);
|
|
|
|
|
m_pStatusLabel->setTextFormat(Qt::PlainText);
|
|
|
|
|
m_pStatusLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
// 状态文字使用底栏剩余宽度,长诊断不撑宽底栏或挤占左侧控件。
|
|
|
|
|
m_pStatusLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
|
|
|
|
m_pStatusLabel->installEventFilter(this);
|
|
|
|
|
pControlLayout->addWidget(pDisplayLabel, 0, Qt::AlignVCenter);
|
|
|
|
|
pControlLayout->addWidget(m_pDisplayModeCombo);
|
|
|
|
|
pControlLayout->addSpacing(2);
|
|
|
|
|
pControlLayout->addWidget(m_pGridInfoLabel);
|
|
|
|
|
pControlLayout->addStretch(1);
|
|
|
|
|
pControlLayout->addWidget(m_pStatusLabel, 1);
|
|
|
|
|
pMainLayout->addWidget(pControlBar);
|
|
|
|
|
|
|
|
|
|
connect(m_pDisplayModeCombo, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
@ -252,7 +247,7 @@ bool nmWxPebiGridViewWidget::setViewData(
|
|
|
|
|
tr("PEBI | %1 valid cells | XY planar grid")
|
|
|
|
|
.arg(static_cast<qlonglong>(
|
|
|
|
|
oViewData.getValidCellCount())));
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
setStatusMessage(QString());
|
|
|
|
|
m_bHasViewData = true;
|
|
|
|
|
synchronizeDisplayModeFromScene();
|
|
|
|
|
setControlsEnabled(true);
|
|
|
|
|
@ -261,26 +256,32 @@ bool nmWxPebiGridViewWidget::setViewData(
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::showLoading()
|
|
|
|
|
{
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
// 保留当前 VTK 画面,建网状态只在底栏更新。
|
|
|
|
|
m_pRenderContainer->setRotationCenterPickingEnabled(false);
|
|
|
|
|
setControlsEnabled(false);
|
|
|
|
|
m_pRenderContainer->showRenderingState(tr("Generating grid..."));
|
|
|
|
|
setStatusMessage(m_bHasViewData
|
|
|
|
|
? tr("Regenerating PEBI grid")
|
|
|
|
|
: tr("Generating PEBI grid"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::showFailure(const QString& sMessage)
|
|
|
|
|
{
|
|
|
|
|
if(m_bHasViewData) {
|
|
|
|
|
// 失败时旧网格引用保持不变,状态条明确说明当前画面并非本次成果。
|
|
|
|
|
m_pRenderContainer->setRotationCenterPickingEnabled(false);
|
|
|
|
|
m_pStatusLabel->setText(sMessage);
|
|
|
|
|
m_pStatusLabel->show();
|
|
|
|
|
setControlsEnabled(true);
|
|
|
|
|
m_pRenderContainer->showReadyState();
|
|
|
|
|
} else {
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
m_pRenderContainer->setRotationCenterPickingEnabled(false);
|
|
|
|
|
if(!m_bHasViewData) {
|
|
|
|
|
resetControls();
|
|
|
|
|
setControlsEnabled(false);
|
|
|
|
|
m_pRenderContainer->showErrorState(sMessage);
|
|
|
|
|
}
|
|
|
|
|
QString sDetails = sMessage.trimmed();
|
|
|
|
|
if(sDetails.isEmpty()) {
|
|
|
|
|
sDetails = tr("PEBI grid generation failed.");
|
|
|
|
|
}
|
|
|
|
|
const QString sStatus = sDetails.section('\n', 0, 0).trimmed();
|
|
|
|
|
if(m_bHasViewData) {
|
|
|
|
|
sDetails += "\n" + tr("Showing the last successful grid.");
|
|
|
|
|
}
|
|
|
|
|
setStatusMessage(sStatus, sDetails);
|
|
|
|
|
setControlsEnabled(m_bHasViewData);
|
|
|
|
|
// 图层提交失败时,场景控制器已回滚,重绘当前场景。
|
|
|
|
|
m_pRenderContainer->renderView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::clearView()
|
|
|
|
|
@ -289,10 +290,10 @@ void nmWxPebiGridViewWidget::clearView()
|
|
|
|
|
m_pSceneController->clear();
|
|
|
|
|
}
|
|
|
|
|
m_bHasViewData = false;
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
resetControls();
|
|
|
|
|
setControlsEnabled(false);
|
|
|
|
|
m_pRenderContainer->showEmptyState(tr("No grid data."));
|
|
|
|
|
setStatusMessage(QString());
|
|
|
|
|
m_pRenderContainer->renderView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiGridViewWidget::hasViewData() const
|
|
|
|
|
@ -313,6 +314,30 @@ void nmWxPebiGridViewWidget::setControlsEnabled(bool bEnabled)
|
|
|
|
|
{
|
|
|
|
|
m_pBoundsGridAction->setEnabled(bEnabled);
|
|
|
|
|
m_pDisplayModeCombo->setEnabled(bEnabled);
|
|
|
|
|
m_pRenderContainer->setViewCommandsAvailable(bEnabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmWxPebiGridViewWidget::eventFilter(QObject* pWatched, QEvent* pEvent)
|
|
|
|
|
{
|
|
|
|
|
if(pWatched == m_pStatusLabel && pEvent->type() == QEvent::Resize) {
|
|
|
|
|
updateStatusLabel();
|
|
|
|
|
}
|
|
|
|
|
return QWidget::eventFilter(pWatched, pEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::setStatusMessage(const QString& sMessage,
|
|
|
|
|
const QString& sDetails)
|
|
|
|
|
{
|
|
|
|
|
m_sStatusMessage = sMessage;
|
|
|
|
|
m_pStatusLabel->setToolTip(sDetails.isEmpty() ? sMessage : sDetails);
|
|
|
|
|
updateStatusLabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::updateStatusLabel()
|
|
|
|
|
{
|
|
|
|
|
m_pStatusLabel->setText(m_pStatusLabel->fontMetrics().elidedText(
|
|
|
|
|
m_sStatusMessage, Qt::ElideRight,
|
|
|
|
|
m_pStatusLabel->contentsRect().width()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::synchronizeDisplayModeFromScene()
|
|
|
|
|
|