From: mbs Date: Tue, 4 Jul 2023 16:36:40 +0000 (+0100) Subject: initial implementation of automatic rotation in SHAPER's OCC viewer X-Git-Tag: V9_12_0b1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a696c2ad09b16e786ca4270e89b356571acc9cf6;p=modules%2Fshaper.git initial implementation of automatic rotation in SHAPER's OCC viewer --- diff --git a/doc/gui/General/Introduction.rst b/doc/gui/General/Introduction.rst index 8da63702f..33e78472f 100644 --- a/doc/gui/General/Introduction.rst +++ b/doc/gui/General/Introduction.rst @@ -552,6 +552,7 @@ This tab defines presentation of objects displayed in OCC 3D viewer. - **Sketch fully constraint color** selects default color for a sketch with zero degrees of freedom. - **Zoom trihedron arrows** if this control is checked then arrows of a view trihedron will be scaled according to current view scale - **Axis arrow size** relative size of trihedron arrows. It has effect only in case if **Zoom trihedron arrows** is On. +- **Enable automatic rotation** enables the perpetual rotation animation in the viewer. To redefine any color click on the corresponding line to access **Select color** dialog box diff --git a/src/ModuleBase/ModuleBase_msg_fr.ts b/src/ModuleBase/ModuleBase_msg_fr.ts index 55870dd64..ec1b6b2fd 100644 --- a/src/ModuleBase/ModuleBase_msg_fr.ts +++ b/src/ModuleBase/ModuleBase_msg_fr.ts @@ -286,6 +286,10 @@ Keep trihedron arrows view size constant Maintenir la taille de la vue des flèches trièdres constante + + Enable automatic rotation + Activer la rotation automatique + General Général diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 73113c006..405bd8c74 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -267,6 +267,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) Config_PropManager::registerProp("Visualization", "zoom_trihedron_arrows", "Keep trihedron arrows view size constant", Config_Prop::Boolean, "false"); + Config_PropManager::registerProp("Visualization", "use_auto_rotation", + "Enable automatic rotation", Config_Prop::Boolean, "false"); + Config_PropManager::registerProp("Visualization", "axis_arrow_size", "Trihedron arrows constant size", Config_Prop::IntSpin, "10"); diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index eebf6e6c4..52e6230b2 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -550,6 +551,15 @@ void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr) myWorkshop->selectionActivate()->updateSelectionModes(); myWorkshop->synchronizeViewer(); } + if (theMgr->getType() == OCCViewer_Viewer::Type()) { + // Set the auto rotate flag in the new viewer based on the current preference + OCCViewer_ViewManager *aVM = (OCCViewer_ViewManager*)theMgr; + bool aAutoRotation = Config_PropManager::boolean("Visualization", "use_auto_rotation"); + aVM->setAutoRotation(aAutoRotation); + + connect(theMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)), + myProxyViewer, SLOT(onViewCreated(SUIT_ViewWindow*))); + } } //****************************************************** @@ -1057,6 +1067,19 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the } } } + if (theParam == "use_auto_rotation") { + bool aAutoRotation = Config_PropManager::boolean("Visualization", "use_auto_rotation"); + // Update the auto rotation flag in all OCC 3D view windows + ViewManagerList lst; + getApp()->viewManagers(OCCViewer_Viewer::Type(), lst); + for ( auto it = lst.begin(); it != lst.end(); ++it ) + { + OCCViewer_ViewManager *aVMgr = dynamic_cast(*it); + if (aVMgr) { + aVMgr->setAutoRotation(aAutoRotation); + } + } + } } else if (theSection == ModuleBase_Preferences::GENERAL_SECTION && theParam == "create_init_part") { bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue( diff --git a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp index 78eba3334..3533bcd94 100644 --- a/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp +++ b/src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -277,6 +278,9 @@ void SHAPERGUI_SalomeViewer::onViewCreated(SUIT_ViewWindow* theView) OCCViewer_ViewPort3d* aViewPort = aWnd->getViewPort(); if (aViewPort) connect(aViewPort, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewPortMapped())); + + OCCViewer_ViewManager* aMgr = dynamic_cast(aWnd->getViewManager()); + if (aMgr) aWnd->enableAutoRotation(aMgr->isAutoRotation()); } reconnectActions(aWnd, true); @@ -508,6 +512,8 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate) connect(aWnd, SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); reconnectActions(aWnd, true); + OCCViewer_ViewManager* aOCCMgr = dynamic_cast(aMgr); + if (aOCCMgr) aWnd->enableAutoRotation(aOCCMgr->isAutoRotation()); } } else { foreach (SUIT_ViewWindow* aView, aViews) { @@ -517,6 +523,7 @@ void SHAPERGUI_SalomeViewer::activateViewer(bool toActivate) SIGNAL(vpTransformationFinished(OCCViewer_ViewWindow::OperationType)), this, SLOT(onViewTransformed(OCCViewer_ViewWindow::OperationType))); reconnectActions(aWnd, false); + aWnd->enableAutoRotation(false); } } }