diff --git a/Bin/Config/Lang/cn/nmNum_cn.qm b/Bin/Config/Lang/cn/nmNum_cn.qm
index 8683a625..9c073bf4 100644
Binary files a/Bin/Config/Lang/cn/nmNum_cn.qm and b/Bin/Config/Lang/cn/nmNum_cn.qm differ
diff --git a/Bin/Config/Lang/cn/nmNum_cn.ts b/Bin/Config/Lang/cn/nmNum_cn.ts
index 939b0fdd..ff1638a0 100644
--- a/Bin/Config/Lang/cn/nmNum_cn.ts
+++ b/Bin/Config/Lang/cn/nmNum_cn.ts
@@ -5956,6 +5956,7 @@ Please check your input coordinates.
Isometric View等轴测视图
Reset Rotation Center重置旋转中心
Set Rotation Center设置旋转中心
+ Show Rotation Center Marker显示旋转中心标记
Save as Image保存图片
Copy Image复制图片
Print打印
diff --git a/Include/nmNum/nmRender/nmVTKViewCommandController.h b/Include/nmNum/nmRender/nmVTKViewCommandController.h
index 3a48f5fd..7d09ef8a 100644
--- a/Include/nmNum/nmRender/nmVTKViewCommandController.h
+++ b/Include/nmNum/nmRender/nmVTKViewCommandController.h
@@ -37,7 +37,8 @@ public:
ViewCommand_CopyImage = 0x0200,
ViewCommand_Print = 0x0400,
ViewCommand_PrintPreview = 0x0800,
- ViewCommand_SetRotationCenter = 0x1000
+ ViewCommand_SetRotationCenter = 0x1000,
+ ViewCommand_ShowRotationCenterMarker = 0x2000 ///< 显示或隐藏旋转中心标记。
};
Q_DECLARE_FLAGS(ViewCommands, ViewCommand)
@@ -76,7 +77,7 @@ private:
Q_DISABLE_COPY(nmVTKViewCommandController)
- enum { ViewCommandCount = 13 };
+ enum { ViewCommandCount = 14 };
/** @brief 仅供容器设置当前视图对外提供的命令集合。 */
void setCapabilities(ViewCommands eCommands);
@@ -90,6 +91,10 @@ private:
bool supports(ViewCommand eCommand) const;
/** @brief 仅供容器同步拾取目标、标记和交互模式的综合可用状态。 */
void setRotationCenterPickingAvailable(bool bAvailable);
+ /** @brief 仅供容器同步旋转中心标记开关的可用状态。 */
+ void setRotationCenterMarkerAvailable(bool bAvailable);
+ /** @brief 仅供容器无信号地同步旋转中心标记开关状态。 */
+ void setRotationCenterMarkerVisible(bool bVisible);
void updateActionStates();
nmWxVTKRenderContainerWidget* m_pContainer; ///< 非所有权命令接收者。
@@ -97,6 +102,7 @@ private:
ViewCommands m_eCapabilities;
bool m_bViewAvailable;
bool m_bRotationCenterPickingAvailable;
+ bool m_bRotationCenterMarkerAvailable; ///< 标记开关当前是否具备操作条件。
};
Q_DECLARE_OPERATORS_FOR_FLAGS(nmVTKViewCommandController::ViewCommands)
diff --git a/Include/nmNum/nmRender/nmWxVTKRenderContainerWidget.h b/Include/nmNum/nmRender/nmWxVTKRenderContainerWidget.h
index 49b7fb4e..d3902d5c 100644
--- a/Include/nmNum/nmRender/nmWxVTKRenderContainerWidget.h
+++ b/Include/nmNum/nmRender/nmWxVTKRenderContainerWidget.h
@@ -80,6 +80,8 @@ public:
void setRotationCenterPickTarget(vtkProp* pTarget);
/** @brief 返回当前是否正在等待用户选择旋转中心。 */
bool isRotationCenterPicking() const;
+ /** @brief 返回当前窗口是否允许显示旋转中心标记。 */
+ bool isRotationCenterMarkerVisible() const;
/** @brief 隐藏旋转中心标记,不修改独立中心或相机且不主动渲染。 */
void hideRotationCenterMarker();
@@ -146,6 +148,8 @@ public slots:
void resetRotationCenter();
/** @brief 请求开始或取消一次性旋转中心拾取模式。 */
void setRotationCenterPickingEnabled(bool bEnabled);
+ /** @brief 保存当前窗口的标记显隐偏好,并在画面变化时渲染一次。 */
+ void setRotationCenterMarkerVisible(bool bVisible);
protected:
/** @brief 优先处理拾取事件,再处理 QVTKWidget 的右键菜单。 */
@@ -219,6 +223,7 @@ private:
nmVTKOrientationMarkerController* m_pOrientationMarkerController;
nmVTKRotationCenterPicker* m_pRotationCenterPicker; ///< 本容器独占。
nmVTKRotationCenterMarkerLayer* m_pRotationCenterMarkerLayer; ///< 系统 Scene 所有。
+ bool m_bRotationCenterMarkerVisible; ///< 当前窗口独立保存的标记显隐偏好。
};
#endif // NMWXVTKRENDERCONTAINERWIDGET_H
diff --git a/Src/nmNum/nmRender/nmVTKViewCommandController.cpp b/Src/nmNum/nmRender/nmVTKViewCommandController.cpp
index 6c8c5ddd..fd583936 100644
--- a/Src/nmNum/nmRender/nmVTKViewCommandController.cpp
+++ b/Src/nmNum/nmRender/nmVTKViewCommandController.cpp
@@ -28,7 +28,8 @@ nmVTKViewCommandController::nmVTKViewCommandController(
m_pContainer(pContainer),
m_eCapabilities(0),
m_bViewAvailable(false),
- m_bRotationCenterPickingAvailable(false)
+ m_bRotationCenterPickingAvailable(false),
+ m_bRotationCenterMarkerAvailable(false)
{
for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) {
m_pActions[nIndex] = nullptr;
@@ -63,6 +64,18 @@ nmVTKViewCommandController::nmVTKViewCommandController(
SLOT(setRotationCenterPickingEnabled(bool)));
}
}
+ QAction* pShowRotationCenterMarkerAction = createAction(
+ ViewCommand_ShowRotationCenterMarker,
+ tr("Show Rotation Center Marker"), QString(), nullptr);
+ if(pShowRotationCenterMarkerAction != nullptr) {
+ pShowRotationCenterMarkerAction->setCheckable(true);
+ pShowRotationCenterMarkerAction->setChecked(true);
+ if(m_pContainer != nullptr) {
+ connect(pShowRotationCenterMarkerAction, SIGNAL(toggled(bool)),
+ m_pContainer,
+ SLOT(setRotationCenterMarkerVisible(bool)));
+ }
+ }
createAction(ViewCommand_SaveImage, tr("Save as Image"), "SaveImg.png",
SLOT(saveImage()));
createAction(ViewCommand_CopyImage, tr("Copy Image"),
@@ -160,7 +173,8 @@ void nmVTKViewCommandController::populateContextMenu(QMenu* pMenu) const
ViewCommand_Right,
ViewCommand_Isometric,
ViewCommand_ResetRotationCenter,
- ViewCommand_SetRotationCenter
+ ViewCommand_SetRotationCenter,
+ ViewCommand_ShowRotationCenterMarker
};
bool bHasViewCommands = false;
const int nViewCommandCount =
@@ -233,6 +247,26 @@ void nmVTKViewCommandController::setRotationCenterPicking(bool bPicking)
pAction->blockSignals(bOldBlockState);
}
+void nmVTKViewCommandController::setRotationCenterMarkerAvailable(
+ bool bAvailable)
+{
+ m_bRotationCenterMarkerAvailable = bAvailable;
+ updateActionStates();
+}
+
+void nmVTKViewCommandController::setRotationCenterMarkerVisible(
+ bool bVisible)
+{
+ QAction* pAction = getAction(ViewCommand_ShowRotationCenterMarker);
+ if(pAction == nullptr || !pAction->isCheckable()) {
+ return;
+ }
+
+ const bool bOldBlockState = pAction->blockSignals(true);
+ pAction->setChecked(bVisible);
+ pAction->blockSignals(bOldBlockState);
+}
+
QAction* nmVTKViewCommandController::createAction(
ViewCommand eCommand,
const QString& sText,
@@ -272,6 +306,7 @@ int nmVTKViewCommandController::actionIndex(ViewCommand eCommand) const
case ViewCommand_Print: return 10;
case ViewCommand_PrintPreview: return 11;
case ViewCommand_SetRotationCenter: return 12;
+ case ViewCommand_ShowRotationCenterMarker: return 13;
default: return -1;
}
}
@@ -296,7 +331,8 @@ void nmVTKViewCommandController::updateActionStates()
ViewCommand_CopyImage,
ViewCommand_Print,
ViewCommand_PrintPreview,
- ViewCommand_SetRotationCenter
+ ViewCommand_SetRotationCenter,
+ ViewCommand_ShowRotationCenterMarker
};
for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) {
QAction* pAction = m_pActions[nIndex];
@@ -309,6 +345,10 @@ void nmVTKViewCommandController::updateActionStates()
if(!bEnabled) {
setRotationCenterPicking(false);
}
+ } else if(eCommands[nIndex] ==
+ ViewCommand_ShowRotationCenterMarker) {
+ bEnabled = bEnabled &&
+ m_bRotationCenterMarkerAvailable;
}
pAction->setVisible(bSupported);
pAction->setEnabled(bEnabled);
diff --git a/Src/nmNum/nmRender/nmWxVTKRenderContainerWidget.cpp b/Src/nmNum/nmRender/nmWxVTKRenderContainerWidget.cpp
index 16172d15..db01999b 100644
--- a/Src/nmNum/nmRender/nmWxVTKRenderContainerWidget.cpp
+++ b/Src/nmNum/nmRender/nmWxVTKRenderContainerWidget.cpp
@@ -55,7 +55,8 @@ nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
m_pViewCommandController(nullptr),
m_pOrientationMarkerController(nullptr),
m_pRotationCenterPicker(nullptr),
- m_pRotationCenterMarkerLayer(nullptr)
+ m_pRotationCenterMarkerLayer(nullptr),
+ m_bRotationCenterMarkerVisible(true)
{
Q_ASSERT(isGuiThread());
@@ -336,6 +337,11 @@ bool nmWxVTKRenderContainerWidget::isRotationCenterPicking() const
m_pRotationCenterPicker->isActive();
}
+bool nmWxVTKRenderContainerWidget::isRotationCenterMarkerVisible() const
+{
+ return m_bRotationCenterMarkerVisible;
+}
+
void nmWxVTKRenderContainerWidget::hideRotationCenterMarker()
{
Q_ASSERT(isGuiThread());
@@ -346,6 +352,30 @@ void nmWxVTKRenderContainerWidget::hideRotationCenterMarker()
}
}
+void nmWxVTKRenderContainerWidget::setRotationCenterMarkerVisible(
+ bool bVisible)
+{
+ Q_ASSERT(isGuiThread());
+ if(!isGuiThread() || m_bRotationCenterMarkerVisible == bVisible) {
+ return;
+ }
+
+ m_bRotationCenterMarkerVisible = bVisible;
+ if(m_pViewCommandController != nullptr) {
+ m_pViewCommandController->setRotationCenterMarkerVisible(bVisible);
+ }
+
+ nmVTKRotationCenterMarkerLayer* pMarkerLayer =
+ getRotationCenterMarkerLayer();
+ const bool bWasVisible = pMarkerLayer != nullptr &&
+ pMarkerLayer->isMarkerVisible();
+ updateRotationCenterMarkerVisibility();
+ if(pMarkerLayer != nullptr &&
+ bWasVisible != pMarkerLayer->isMarkerVisible()) {
+ renderView();
+ }
+}
+
bool nmWxVTKRenderContainerWidget::installInteractionStyle(
vtkInteractorStyle* pStyle)
{
@@ -548,7 +578,7 @@ bool nmWxVTKRenderContainerWidget::applyRotationCenter(
return false;
}
if(bShowMarker) {
- pMarkerLayer->setMarkerVisible(true);
+ updateRotationCenterMarkerVisibility();
}
}
synchronizeRotationCenterMarker();
@@ -641,7 +671,8 @@ void nmWxVTKRenderContainerWidget::updateRotationCenterMarkerVisibility()
return;
}
- const bool bVisible = m_pViewCommandController != nullptr &&
+ const bool bVisible = m_bRotationCenterMarkerVisible &&
+ m_pViewCommandController != nullptr &&
m_pViewCommandController->isViewAvailable() &&
m_pViewCommandController->getCapabilities().testFlag(
nmVTKViewCommandController::ViewCommand_SetRotationCenter) &&
@@ -664,6 +695,11 @@ void nmWxVTKRenderContainerWidget::updateRotationCenterCommandAvailability()
m_pInteractionManager->isDefaultInteractionActive();
m_pViewCommandController->setRotationCenterPickingAvailable(
bAvailable);
+ const bool bMarkerAvailable = m_pRotationCenterPicker != nullptr &&
+ m_pRotationCenterPicker->hasPickTarget() &&
+ getRotationCenterMarkerLayer() != nullptr;
+ m_pViewCommandController->setRotationCenterMarkerAvailable(
+ bMarkerAvailable);
}
nmVTKRotationCenterMarkerLayer*
diff --git a/Src/nmNum/nmSubWxs/nmWxPebiGridViewWidget.cpp b/Src/nmNum/nmSubWxs/nmWxPebiGridViewWidget.cpp
index 3a9665b0..b280df14 100644
--- a/Src/nmNum/nmSubWxs/nmWxPebiGridViewWidget.cpp
+++ b/Src/nmNum/nmSubWxs/nmWxPebiGridViewWidget.cpp
@@ -81,6 +81,8 @@ void nmWxPebiGridViewWidget::createUi()
nmVTKViewCommandController::ViewCommand_Top |
nmVTKViewCommandController::ViewCommand_Front |
nmVTKViewCommandController::ViewCommand_SetRotationCenter |
+ nmVTKViewCommandController::
+ ViewCommand_ShowRotationCenterMarker |
nmVTKViewCommandController::ViewCommand_SaveImage |
nmVTKViewCommandController::ViewCommand_CopyImage |
nmVTKViewCommandController::ViewCommand_Print |
diff --git a/Src/nmNum/nmSubWxs/nmWxPebiResultViewWidget.cpp b/Src/nmNum/nmSubWxs/nmWxPebiResultViewWidget.cpp
index 0c0d15a0..01b38ea1 100644
--- a/Src/nmNum/nmSubWxs/nmWxPebiResultViewWidget.cpp
+++ b/Src/nmNum/nmSubWxs/nmWxPebiResultViewWidget.cpp
@@ -456,6 +456,8 @@ void nmWxPebiResultViewWidget::createUi()
nmVTKViewCommandController::ViewCommand_Top |
nmVTKViewCommandController::ViewCommand_Front |
nmVTKViewCommandController::ViewCommand_SetRotationCenter |
+ nmVTKViewCommandController::
+ ViewCommand_ShowRotationCenterMarker |
nmVTKViewCommandController::ViewCommand_SaveImage |
nmVTKViewCommandController::ViewCommand_CopyImage |
nmVTKViewCommandController::ViewCommand_Print |