feat(nmNum): 支持旋转中心标记显隐控制

develop
lh 13 hours ago
parent 0eb3f6de3b
commit 9853aaf56c

Binary file not shown.

@ -5956,6 +5956,7 @@ Please check your input coordinates.</source>
<message><source>Isometric View</source><translation>等轴测视图</translation></message> <message><source>Isometric View</source><translation>等轴测视图</translation></message>
<message><source>Reset Rotation Center</source><translation>重置旋转中心</translation></message> <message><source>Reset Rotation Center</source><translation>重置旋转中心</translation></message>
<message><source>Set Rotation Center</source><translation>设置旋转中心</translation></message> <message><source>Set Rotation Center</source><translation>设置旋转中心</translation></message>
<message><source>Show Rotation Center Marker</source><translation>显示旋转中心标记</translation></message>
<message><source>Save as Image</source><translation>保存图片</translation></message> <message><source>Save as Image</source><translation>保存图片</translation></message>
<message><source>Copy Image</source><translation>复制图片</translation></message> <message><source>Copy Image</source><translation>复制图片</translation></message>
<message><source>Print</source><translation>打印</translation></message> <message><source>Print</source><translation>打印</translation></message>

@ -37,7 +37,8 @@ public:
ViewCommand_CopyImage = 0x0200, ViewCommand_CopyImage = 0x0200,
ViewCommand_Print = 0x0400, ViewCommand_Print = 0x0400,
ViewCommand_PrintPreview = 0x0800, ViewCommand_PrintPreview = 0x0800,
ViewCommand_SetRotationCenter = 0x1000 ViewCommand_SetRotationCenter = 0x1000,
ViewCommand_ShowRotationCenterMarker = 0x2000 ///< 显示或隐藏旋转中心标记。
}; };
Q_DECLARE_FLAGS(ViewCommands, ViewCommand) Q_DECLARE_FLAGS(ViewCommands, ViewCommand)
@ -76,7 +77,7 @@ private:
Q_DISABLE_COPY(nmVTKViewCommandController) Q_DISABLE_COPY(nmVTKViewCommandController)
enum { ViewCommandCount = 13 }; enum { ViewCommandCount = 14 };
/** @brief 仅供容器设置当前视图对外提供的命令集合。 */ /** @brief 仅供容器设置当前视图对外提供的命令集合。 */
void setCapabilities(ViewCommands eCommands); void setCapabilities(ViewCommands eCommands);
@ -90,6 +91,10 @@ private:
bool supports(ViewCommand eCommand) const; bool supports(ViewCommand eCommand) const;
/** @brief 仅供容器同步拾取目标、标记和交互模式的综合可用状态。 */ /** @brief 仅供容器同步拾取目标、标记和交互模式的综合可用状态。 */
void setRotationCenterPickingAvailable(bool bAvailable); void setRotationCenterPickingAvailable(bool bAvailable);
/** @brief 仅供容器同步旋转中心标记开关的可用状态。 */
void setRotationCenterMarkerAvailable(bool bAvailable);
/** @brief 仅供容器无信号地同步旋转中心标记开关状态。 */
void setRotationCenterMarkerVisible(bool bVisible);
void updateActionStates(); void updateActionStates();
nmWxVTKRenderContainerWidget* m_pContainer; ///< 非所有权命令接收者。 nmWxVTKRenderContainerWidget* m_pContainer; ///< 非所有权命令接收者。
@ -97,6 +102,7 @@ private:
ViewCommands m_eCapabilities; ViewCommands m_eCapabilities;
bool m_bViewAvailable; bool m_bViewAvailable;
bool m_bRotationCenterPickingAvailable; bool m_bRotationCenterPickingAvailable;
bool m_bRotationCenterMarkerAvailable; ///< 标记开关当前是否具备操作条件。
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(nmVTKViewCommandController::ViewCommands) Q_DECLARE_OPERATORS_FOR_FLAGS(nmVTKViewCommandController::ViewCommands)

@ -80,6 +80,8 @@ public:
void setRotationCenterPickTarget(vtkProp* pTarget); void setRotationCenterPickTarget(vtkProp* pTarget);
/** @brief 返回当前是否正在等待用户选择旋转中心。 */ /** @brief 返回当前是否正在等待用户选择旋转中心。 */
bool isRotationCenterPicking() const; bool isRotationCenterPicking() const;
/** @brief 返回当前窗口是否允许显示旋转中心标记。 */
bool isRotationCenterMarkerVisible() const;
/** @brief 隐藏旋转中心标记,不修改独立中心或相机且不主动渲染。 */ /** @brief 隐藏旋转中心标记,不修改独立中心或相机且不主动渲染。 */
void hideRotationCenterMarker(); void hideRotationCenterMarker();
@ -146,6 +148,8 @@ public slots:
void resetRotationCenter(); void resetRotationCenter();
/** @brief 请求开始或取消一次性旋转中心拾取模式。 */ /** @brief 请求开始或取消一次性旋转中心拾取模式。 */
void setRotationCenterPickingEnabled(bool bEnabled); void setRotationCenterPickingEnabled(bool bEnabled);
/** @brief 保存当前窗口的标记显隐偏好,并在画面变化时渲染一次。 */
void setRotationCenterMarkerVisible(bool bVisible);
protected: protected:
/** @brief 优先处理拾取事件,再处理 QVTKWidget 的右键菜单。 */ /** @brief 优先处理拾取事件,再处理 QVTKWidget 的右键菜单。 */
@ -219,6 +223,7 @@ private:
nmVTKOrientationMarkerController* m_pOrientationMarkerController; nmVTKOrientationMarkerController* m_pOrientationMarkerController;
nmVTKRotationCenterPicker* m_pRotationCenterPicker; ///< 本容器独占。 nmVTKRotationCenterPicker* m_pRotationCenterPicker; ///< 本容器独占。
nmVTKRotationCenterMarkerLayer* m_pRotationCenterMarkerLayer; ///< 系统 Scene 所有。 nmVTKRotationCenterMarkerLayer* m_pRotationCenterMarkerLayer; ///< 系统 Scene 所有。
bool m_bRotationCenterMarkerVisible; ///< 当前窗口独立保存的标记显隐偏好。
}; };
#endif // NMWXVTKRENDERCONTAINERWIDGET_H #endif // NMWXVTKRENDERCONTAINERWIDGET_H

@ -28,7 +28,8 @@ nmVTKViewCommandController::nmVTKViewCommandController(
m_pContainer(pContainer), m_pContainer(pContainer),
m_eCapabilities(0), m_eCapabilities(0),
m_bViewAvailable(false), m_bViewAvailable(false),
m_bRotationCenterPickingAvailable(false) m_bRotationCenterPickingAvailable(false),
m_bRotationCenterMarkerAvailable(false)
{ {
for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) { for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) {
m_pActions[nIndex] = nullptr; m_pActions[nIndex] = nullptr;
@ -63,6 +64,18 @@ nmVTKViewCommandController::nmVTKViewCommandController(
SLOT(setRotationCenterPickingEnabled(bool))); 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", createAction(ViewCommand_SaveImage, tr("Save as Image"), "SaveImg.png",
SLOT(saveImage())); SLOT(saveImage()));
createAction(ViewCommand_CopyImage, tr("Copy Image"), createAction(ViewCommand_CopyImage, tr("Copy Image"),
@ -160,7 +173,8 @@ void nmVTKViewCommandController::populateContextMenu(QMenu* pMenu) const
ViewCommand_Right, ViewCommand_Right,
ViewCommand_Isometric, ViewCommand_Isometric,
ViewCommand_ResetRotationCenter, ViewCommand_ResetRotationCenter,
ViewCommand_SetRotationCenter ViewCommand_SetRotationCenter,
ViewCommand_ShowRotationCenterMarker
}; };
bool bHasViewCommands = false; bool bHasViewCommands = false;
const int nViewCommandCount = const int nViewCommandCount =
@ -233,6 +247,26 @@ void nmVTKViewCommandController::setRotationCenterPicking(bool bPicking)
pAction->blockSignals(bOldBlockState); 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( QAction* nmVTKViewCommandController::createAction(
ViewCommand eCommand, ViewCommand eCommand,
const QString& sText, const QString& sText,
@ -272,6 +306,7 @@ int nmVTKViewCommandController::actionIndex(ViewCommand eCommand) const
case ViewCommand_Print: return 10; case ViewCommand_Print: return 10;
case ViewCommand_PrintPreview: return 11; case ViewCommand_PrintPreview: return 11;
case ViewCommand_SetRotationCenter: return 12; case ViewCommand_SetRotationCenter: return 12;
case ViewCommand_ShowRotationCenterMarker: return 13;
default: return -1; default: return -1;
} }
} }
@ -296,7 +331,8 @@ void nmVTKViewCommandController::updateActionStates()
ViewCommand_CopyImage, ViewCommand_CopyImage,
ViewCommand_Print, ViewCommand_Print,
ViewCommand_PrintPreview, ViewCommand_PrintPreview,
ViewCommand_SetRotationCenter ViewCommand_SetRotationCenter,
ViewCommand_ShowRotationCenterMarker
}; };
for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) { for(int nIndex = 0; nIndex < ViewCommandCount; ++nIndex) {
QAction* pAction = m_pActions[nIndex]; QAction* pAction = m_pActions[nIndex];
@ -309,6 +345,10 @@ void nmVTKViewCommandController::updateActionStates()
if(!bEnabled) { if(!bEnabled) {
setRotationCenterPicking(false); setRotationCenterPicking(false);
} }
} else if(eCommands[nIndex] ==
ViewCommand_ShowRotationCenterMarker) {
bEnabled = bEnabled &&
m_bRotationCenterMarkerAvailable;
} }
pAction->setVisible(bSupported); pAction->setVisible(bSupported);
pAction->setEnabled(bEnabled); pAction->setEnabled(bEnabled);

@ -55,7 +55,8 @@ nmWxVTKRenderContainerWidget::nmWxVTKRenderContainerWidget(QWidget* pParent)
m_pViewCommandController(nullptr), m_pViewCommandController(nullptr),
m_pOrientationMarkerController(nullptr), m_pOrientationMarkerController(nullptr),
m_pRotationCenterPicker(nullptr), m_pRotationCenterPicker(nullptr),
m_pRotationCenterMarkerLayer(nullptr) m_pRotationCenterMarkerLayer(nullptr),
m_bRotationCenterMarkerVisible(true)
{ {
Q_ASSERT(isGuiThread()); Q_ASSERT(isGuiThread());
@ -336,6 +337,11 @@ bool nmWxVTKRenderContainerWidget::isRotationCenterPicking() const
m_pRotationCenterPicker->isActive(); m_pRotationCenterPicker->isActive();
} }
bool nmWxVTKRenderContainerWidget::isRotationCenterMarkerVisible() const
{
return m_bRotationCenterMarkerVisible;
}
void nmWxVTKRenderContainerWidget::hideRotationCenterMarker() void nmWxVTKRenderContainerWidget::hideRotationCenterMarker()
{ {
Q_ASSERT(isGuiThread()); 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( bool nmWxVTKRenderContainerWidget::installInteractionStyle(
vtkInteractorStyle* pStyle) vtkInteractorStyle* pStyle)
{ {
@ -548,7 +578,7 @@ bool nmWxVTKRenderContainerWidget::applyRotationCenter(
return false; return false;
} }
if(bShowMarker) { if(bShowMarker) {
pMarkerLayer->setMarkerVisible(true); updateRotationCenterMarkerVisibility();
} }
} }
synchronizeRotationCenterMarker(); synchronizeRotationCenterMarker();
@ -641,7 +671,8 @@ void nmWxVTKRenderContainerWidget::updateRotationCenterMarkerVisibility()
return; return;
} }
const bool bVisible = m_pViewCommandController != nullptr && const bool bVisible = m_bRotationCenterMarkerVisible &&
m_pViewCommandController != nullptr &&
m_pViewCommandController->isViewAvailable() && m_pViewCommandController->isViewAvailable() &&
m_pViewCommandController->getCapabilities().testFlag( m_pViewCommandController->getCapabilities().testFlag(
nmVTKViewCommandController::ViewCommand_SetRotationCenter) && nmVTKViewCommandController::ViewCommand_SetRotationCenter) &&
@ -664,6 +695,11 @@ void nmWxVTKRenderContainerWidget::updateRotationCenterCommandAvailability()
m_pInteractionManager->isDefaultInteractionActive(); m_pInteractionManager->isDefaultInteractionActive();
m_pViewCommandController->setRotationCenterPickingAvailable( m_pViewCommandController->setRotationCenterPickingAvailable(
bAvailable); bAvailable);
const bool bMarkerAvailable = m_pRotationCenterPicker != nullptr &&
m_pRotationCenterPicker->hasPickTarget() &&
getRotationCenterMarkerLayer() != nullptr;
m_pViewCommandController->setRotationCenterMarkerAvailable(
bMarkerAvailable);
} }
nmVTKRotationCenterMarkerLayer* nmVTKRotationCenterMarkerLayer*

@ -81,6 +81,8 @@ void nmWxPebiGridViewWidget::createUi()
nmVTKViewCommandController::ViewCommand_Top | nmVTKViewCommandController::ViewCommand_Top |
nmVTKViewCommandController::ViewCommand_Front | nmVTKViewCommandController::ViewCommand_Front |
nmVTKViewCommandController::ViewCommand_SetRotationCenter | nmVTKViewCommandController::ViewCommand_SetRotationCenter |
nmVTKViewCommandController::
ViewCommand_ShowRotationCenterMarker |
nmVTKViewCommandController::ViewCommand_SaveImage | nmVTKViewCommandController::ViewCommand_SaveImage |
nmVTKViewCommandController::ViewCommand_CopyImage | nmVTKViewCommandController::ViewCommand_CopyImage |
nmVTKViewCommandController::ViewCommand_Print | nmVTKViewCommandController::ViewCommand_Print |

@ -456,6 +456,8 @@ void nmWxPebiResultViewWidget::createUi()
nmVTKViewCommandController::ViewCommand_Top | nmVTKViewCommandController::ViewCommand_Top |
nmVTKViewCommandController::ViewCommand_Front | nmVTKViewCommandController::ViewCommand_Front |
nmVTKViewCommandController::ViewCommand_SetRotationCenter | nmVTKViewCommandController::ViewCommand_SetRotationCenter |
nmVTKViewCommandController::
ViewCommand_ShowRotationCenterMarker |
nmVTKViewCommandController::ViewCommand_SaveImage | nmVTKViewCommandController::ViewCommand_SaveImage |
nmVTKViewCommandController::ViewCommand_CopyImage | nmVTKViewCommandController::ViewCommand_CopyImage |
nmVTKViewCommandController::ViewCommand_Print | nmVTKViewCommandController::ViewCommand_Print |

Loading…
Cancel
Save