|
|
|
|
@ -7,7 +7,6 @@
|
|
|
|
|
#include "nmWxVTKRenderContainerWidget.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QIcon>
|
|
|
|
|
@ -16,7 +15,6 @@
|
|
|
|
|
#include <QSize>
|
|
|
|
|
#include <QToolBar>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
@ -34,10 +32,7 @@ nmWxPebiGridViewWidget::nmWxPebiGridViewWidget(QWidget* pParent)
|
|
|
|
|
m_pRenderContainer(nullptr),
|
|
|
|
|
m_pSceneController(nullptr),
|
|
|
|
|
m_pToolBar(nullptr),
|
|
|
|
|
m_pGridLinesAction(nullptr),
|
|
|
|
|
m_pScalarBarAction(nullptr),
|
|
|
|
|
m_pBoundsGridAction(nullptr),
|
|
|
|
|
m_pPropertyComboBox(nullptr),
|
|
|
|
|
m_pGridInfoLabel(nullptr),
|
|
|
|
|
m_pStatusLabel(nullptr),
|
|
|
|
|
m_bHasViewData(false)
|
|
|
|
|
@ -70,6 +65,7 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
pRenderLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
pRenderLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
// 公共容器独占 Renderer、相机和交互对象;本类只裁剪可见命令能力。
|
|
|
|
|
m_pRenderContainer = new nmWxVTKRenderContainerWidget(pRenderArea);
|
|
|
|
|
m_pRenderContainer->setSizePolicy(
|
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
@ -78,6 +74,7 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_ZoomOut |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Fit |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Top |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Front |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_SetRotationCenter |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_SaveImage |
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_CopyImage |
|
|
|
|
|
@ -95,17 +92,7 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
nmVTKViewCommandController* pCommandController =
|
|
|
|
|
m_pRenderContainer->getViewCommandController();
|
|
|
|
|
|
|
|
|
|
// 三个业务 QAction 与公共命令一样长期持有,并同时用于工具栏和右键菜单。
|
|
|
|
|
m_pGridLinesAction = new QAction(
|
|
|
|
|
QIcon(gridViewIconPath("Grids.png")),
|
|
|
|
|
tr("Show Grid Lines"), this);
|
|
|
|
|
m_pGridLinesAction->setToolTip(tr("Show Grid Lines"));
|
|
|
|
|
m_pGridLinesAction->setCheckable(true);
|
|
|
|
|
m_pScalarBarAction = new QAction(
|
|
|
|
|
QIcon(gridViewIconPath("NmColorScale.png")),
|
|
|
|
|
tr("Show Scalar Bar"), this);
|
|
|
|
|
m_pScalarBarAction->setToolTip(tr("Show Scalar Bar"));
|
|
|
|
|
m_pScalarBarAction->setCheckable(true);
|
|
|
|
|
// 比例网格 QAction 长期持有,并同时用于工具栏和右键菜单。
|
|
|
|
|
m_pBoundsGridAction = new QAction(
|
|
|
|
|
QIcon(gridViewIconPath("NmScaleGrid.png")),
|
|
|
|
|
tr("Scale Grid"), this);
|
|
|
|
|
@ -122,11 +109,14 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_ZoomIn);
|
|
|
|
|
QAction* pTopAction = pCommandController->getAction(
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Top);
|
|
|
|
|
QAction* pFrontAction = pCommandController->getAction(
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_Front);
|
|
|
|
|
QAction* pSetRotationCenterAction = pCommandController->getAction(
|
|
|
|
|
nmVTKViewCommandController::
|
|
|
|
|
ViewCommand_SetRotationCenter);
|
|
|
|
|
QAction* pCopyAction = pCommandController->getAction(
|
|
|
|
|
nmVTKViewCommandController::ViewCommand_CopyImage);
|
|
|
|
|
// 按“缩放、标准视角、显示、输出”分组,空组不会留下多余分隔线。
|
|
|
|
|
bool bHasPreviousGroup = false;
|
|
|
|
|
if(pZoomOutAction != nullptr) {
|
|
|
|
|
m_pToolBar->addAction(pZoomOutAction);
|
|
|
|
|
@ -141,6 +131,7 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
bHasPreviousGroup = true;
|
|
|
|
|
}
|
|
|
|
|
const bool bHasViewGroup = pTopAction != nullptr ||
|
|
|
|
|
pFrontAction != nullptr ||
|
|
|
|
|
pSetRotationCenterAction != nullptr;
|
|
|
|
|
if(bHasViewGroup && bHasPreviousGroup) {
|
|
|
|
|
m_pToolBar->addSeparator();
|
|
|
|
|
@ -149,6 +140,10 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
m_pToolBar->addAction(pTopAction);
|
|
|
|
|
bHasPreviousGroup = true;
|
|
|
|
|
}
|
|
|
|
|
if(pFrontAction != nullptr) {
|
|
|
|
|
m_pToolBar->addAction(pFrontAction);
|
|
|
|
|
bHasPreviousGroup = true;
|
|
|
|
|
}
|
|
|
|
|
if(pSetRotationCenterAction != nullptr) {
|
|
|
|
|
m_pToolBar->addAction(pSetRotationCenterAction);
|
|
|
|
|
bHasPreviousGroup = true;
|
|
|
|
|
@ -156,8 +151,6 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
if(bHasPreviousGroup) {
|
|
|
|
|
m_pToolBar->addSeparator();
|
|
|
|
|
}
|
|
|
|
|
m_pToolBar->addAction(m_pGridLinesAction);
|
|
|
|
|
m_pToolBar->addAction(m_pScalarBarAction);
|
|
|
|
|
m_pToolBar->addAction(m_pBoundsGridAction);
|
|
|
|
|
if(pCopyAction != nullptr) {
|
|
|
|
|
m_pToolBar->addSeparator();
|
|
|
|
|
@ -165,8 +158,6 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 理论上不会进入;仍保留业务动作,避免容器初始化异常时布局跳动。
|
|
|
|
|
m_pToolBar->addAction(m_pGridLinesAction);
|
|
|
|
|
m_pToolBar->addAction(m_pScalarBarAction);
|
|
|
|
|
m_pToolBar->addAction(m_pBoundsGridAction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -185,29 +176,18 @@ void nmWxPebiGridViewWidget::createUi()
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
pMainLayout->addWidget(m_pStatusLabel);
|
|
|
|
|
|
|
|
|
|
// 底栏只承担几何信息展示,不放置属性或渲染模式控件。
|
|
|
|
|
QWidget* pControlBar = new QWidget(this);
|
|
|
|
|
QHBoxLayout* pControlLayout = new QHBoxLayout(pControlBar);
|
|
|
|
|
pControlLayout->setContentsMargins(8, 5, 8, 5);
|
|
|
|
|
pControlLayout->setSpacing(6);
|
|
|
|
|
|
|
|
|
|
QLabel* pPropertyLabel = new QLabel(tr("Property:"), pControlBar);
|
|
|
|
|
m_pPropertyComboBox = new QComboBox(pControlBar);
|
|
|
|
|
m_pPropertyComboBox->setMinimumContentsLength(9);
|
|
|
|
|
pControlLayout->addWidget(pPropertyLabel);
|
|
|
|
|
pControlLayout->addWidget(m_pPropertyComboBox);
|
|
|
|
|
pControlLayout->addStretch(1);
|
|
|
|
|
|
|
|
|
|
m_pGridInfoLabel = new QLabel(pControlBar);
|
|
|
|
|
m_pGridInfoLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
|
|
|
m_pGridInfoLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
|
pControlLayout->addWidget(m_pGridInfoLabel);
|
|
|
|
|
pControlLayout->addStretch(1);
|
|
|
|
|
pMainLayout->addWidget(pControlBar);
|
|
|
|
|
|
|
|
|
|
connect(m_pPropertyComboBox, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(onPropertyChanged(int)));
|
|
|
|
|
connect(m_pGridLinesAction, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onGridLinesToggled(bool)));
|
|
|
|
|
connect(m_pScalarBarAction, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onScalarBarToggled(bool)));
|
|
|
|
|
connect(m_pBoundsGridAction, SIGNAL(toggled(bool)),
|
|
|
|
|
this, SLOT(onBoundsGridToggled(bool)));
|
|
|
|
|
connect(m_pRenderContainer, SIGNAL(contextMenuAboutToShow(QMenu*)),
|
|
|
|
|
@ -224,38 +204,21 @@ bool nmWxPebiGridViewWidget::setViewData(
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// SceneController 负责事务式绑定;失败时这里按其回滚结果同步外层状态。
|
|
|
|
|
if(!m_pSceneController->setViewData(oViewData, pError)) {
|
|
|
|
|
// 控制器回滚失败时同步清除外层标志,避免把空场景误当作旧成功网格。
|
|
|
|
|
m_bHasViewData = m_pSceneController->hasViewData();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 属性列表只登记 Builder 已确认与 CellData 单元数一致的 Material。
|
|
|
|
|
const bool bOldBlockState = m_pPropertyComboBox->blockSignals(true);
|
|
|
|
|
m_pPropertyComboBox->clear();
|
|
|
|
|
m_pPropertyComboBox->addItem(tr("No property"), QString());
|
|
|
|
|
if(oViewData.hasMaterial()) {
|
|
|
|
|
m_pPropertyComboBox->addItem(tr("Material"), QString("Material"));
|
|
|
|
|
}
|
|
|
|
|
const QString sActiveProperty = m_pSceneController->getProperty();
|
|
|
|
|
for(int nIndex = 0; nIndex < m_pPropertyComboBox->count(); ++nIndex) {
|
|
|
|
|
if(m_pPropertyComboBox->itemData(nIndex).toString() ==
|
|
|
|
|
sActiveProperty) {
|
|
|
|
|
m_pPropertyComboBox->setCurrentIndex(nIndex);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_pPropertyComboBox->blockSignals(bOldBlockState);
|
|
|
|
|
|
|
|
|
|
// Builder 只接受已提交的 PEBI 网格,因此底栏无需再显示“未知类型”。
|
|
|
|
|
m_pGridInfoLabel->setText(
|
|
|
|
|
tr("%1 cells | %2")
|
|
|
|
|
tr("PEBI | %1 valid cells | XY planar grid")
|
|
|
|
|
.arg(static_cast<qlonglong>(
|
|
|
|
|
oViewData.getValidCellCount()))
|
|
|
|
|
.arg(gridTypeText(static_cast<int>(oViewData.getGridType()))));
|
|
|
|
|
oViewData.getValidCellCount())));
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
m_bHasViewData = true;
|
|
|
|
|
setControlsEnabled(true);
|
|
|
|
|
updateScalarBarActionState();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -274,10 +237,10 @@ void nmWxPebiGridViewWidget::showFailure(const QString& sMessage)
|
|
|
|
|
m_pStatusLabel->setText(sMessage);
|
|
|
|
|
m_pStatusLabel->show();
|
|
|
|
|
setControlsEnabled(true);
|
|
|
|
|
updateScalarBarActionState();
|
|
|
|
|
m_pRenderContainer->showReadyState();
|
|
|
|
|
} else {
|
|
|
|
|
m_pStatusLabel->hide();
|
|
|
|
|
resetControls();
|
|
|
|
|
setControlsEnabled(false);
|
|
|
|
|
m_pRenderContainer->showErrorState(sMessage);
|
|
|
|
|
}
|
|
|
|
|
@ -302,80 +265,16 @@ bool nmWxPebiGridViewWidget::hasViewData() const
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::resetControls()
|
|
|
|
|
{
|
|
|
|
|
bool bBlocked = m_pPropertyComboBox->blockSignals(true);
|
|
|
|
|
m_pPropertyComboBox->clear();
|
|
|
|
|
m_pPropertyComboBox->addItem(tr("No property"), QString());
|
|
|
|
|
m_pPropertyComboBox->blockSignals(bBlocked);
|
|
|
|
|
|
|
|
|
|
bBlocked = m_pGridLinesAction->blockSignals(true);
|
|
|
|
|
m_pGridLinesAction->setChecked(true);
|
|
|
|
|
m_pGridLinesAction->blockSignals(bBlocked);
|
|
|
|
|
bBlocked = m_pScalarBarAction->blockSignals(true);
|
|
|
|
|
m_pScalarBarAction->setChecked(true);
|
|
|
|
|
m_pScalarBarAction->blockSignals(bBlocked);
|
|
|
|
|
bBlocked = m_pBoundsGridAction->blockSignals(true);
|
|
|
|
|
const bool bBlocked = m_pBoundsGridAction->blockSignals(true);
|
|
|
|
|
m_pBoundsGridAction->setChecked(false);
|
|
|
|
|
m_pBoundsGridAction->blockSignals(bBlocked);
|
|
|
|
|
m_pGridInfoLabel->setText(tr("0 cells | Unknown"));
|
|
|
|
|
m_pGridInfoLabel->setText(
|
|
|
|
|
tr("PEBI | %1 valid cells | XY planar grid").arg(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::setControlsEnabled(bool bEnabled)
|
|
|
|
|
{
|
|
|
|
|
m_pPropertyComboBox->setEnabled(bEnabled);
|
|
|
|
|
m_pGridLinesAction->setEnabled(bEnabled);
|
|
|
|
|
m_pBoundsGridAction->setEnabled(bEnabled);
|
|
|
|
|
m_pScalarBarAction->setEnabled(
|
|
|
|
|
bEnabled && m_pSceneController != nullptr &&
|
|
|
|
|
!m_pSceneController->getProperty().isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::updateScalarBarActionState()
|
|
|
|
|
{
|
|
|
|
|
if(m_pSceneController == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const bool bBlocked = m_pScalarBarAction->blockSignals(true);
|
|
|
|
|
m_pScalarBarAction->setChecked(
|
|
|
|
|
m_pSceneController->isScalarBarVisible());
|
|
|
|
|
m_pScalarBarAction->blockSignals(bBlocked);
|
|
|
|
|
m_pScalarBarAction->setEnabled(
|
|
|
|
|
m_bHasViewData &&
|
|
|
|
|
!m_pSceneController->getProperty().isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString nmWxPebiGridViewWidget::gridTypeText(int nGridType) const
|
|
|
|
|
{
|
|
|
|
|
return nGridType == static_cast<int>(NM_Grid_PEBI)
|
|
|
|
|
? QString("PEBI") : tr("Unknown");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::onPropertyChanged(int nIndex)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bHasViewData || nIndex < 0 || m_pSceneController == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const QString sPropertyName =
|
|
|
|
|
m_pPropertyComboBox->itemData(nIndex).toString();
|
|
|
|
|
if(!m_pSceneController->setProperty(sPropertyName)) {
|
|
|
|
|
const bool bBlocked = m_pPropertyComboBox->blockSignals(true);
|
|
|
|
|
m_pPropertyComboBox->setCurrentIndex(0);
|
|
|
|
|
m_pPropertyComboBox->blockSignals(bBlocked);
|
|
|
|
|
}
|
|
|
|
|
updateScalarBarActionState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::onGridLinesToggled(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
if(m_bHasViewData && m_pSceneController != nullptr) {
|
|
|
|
|
m_pSceneController->setGridLinesVisible(bVisible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::onScalarBarToggled(bool bVisible)
|
|
|
|
|
{
|
|
|
|
|
if(m_bHasViewData && m_pSceneController != nullptr) {
|
|
|
|
|
m_pSceneController->setScalarBarVisible(bVisible);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmWxPebiGridViewWidget::onBoundsGridToggled(bool bVisible)
|
|
|
|
|
@ -390,8 +289,6 @@ void nmWxPebiGridViewWidget::appendContextMenuActions(QMenu* pMenu)
|
|
|
|
|
if(pMenu == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 右键菜单与工具栏引用同三个业务 QAction,勾选状态不会发生分叉。
|
|
|
|
|
pMenu->addAction(m_pGridLinesAction);
|
|
|
|
|
pMenu->addAction(m_pScalarBarAction);
|
|
|
|
|
// 右键菜单与工具栏引用同一个比例网格 QAction,勾选状态不会发生分叉。
|
|
|
|
|
pMenu->addAction(m_pBoundsGridAction);
|
|
|
|
|
}
|
|
|
|
|
|