Salome HOME
initial implementation of automatic rotation in SHAPER's OCC viewer mbs/35158_auto_rotate 13/head
authormbs <martin.bernhard@opencascade.com>
Tue, 4 Jul 2023 16:36:40 +0000 (17:36 +0100)
committermbs <martin.bernhard@opencascade.com>
Tue, 24 Oct 2023 15:05:35 +0000 (16:05 +0100)
doc/gui/General/Introduction.rst
src/ModuleBase/ModuleBase_msg_fr.ts
src/PartSet/PartSet_Module.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI_SalomeViewer.cpp

index 8da63702fd841157ebb5bb854b4eb6678ad6a264..33e78472faf6df743442c255d9472f8b0003f634 100644 (file)
@@ -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
 
index 55870dd641f8fa1ac766116368c7f6faffbb9cba..ec1b6b2fde19aac8b5035f2a472da02326b4945a 100644 (file)
         <source>Keep trihedron arrows view size constant</source>
         <translation>Maintenir la taille de la vue des flèches trièdres constante</translation>
     </message>
+    <message>
+        <source>Enable automatic rotation</source>
+        <translation>Activer la rotation automatique</translation>
+    </message>
     <message>
         <source>General</source>
         <translation>Général</translation>
index 73113c0066ee5a3db32218dfd89d467381d73b2c..405bd8c74a87ffdbc94312f7a1aac8b4b6b77594 100644 (file)
@@ -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");
 
index eebf6e6c422ece0e69c5544973008316ad1b99ba..52e6230b2e38d063307655c91d0d4bf200eb6383 100644 (file)
@@ -49,6 +49,7 @@
 
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewManager.h>
 
 #include <SUIT_Selector.h>
 #include <SUIT_Desktop.h>
@@ -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<OCCViewer_ViewManager*>(*it);
+        if (aVMgr) {
+          aVMgr->setAutoRotation(aAutoRotation);
+        }
+      }
+    }
   }
   else if (theSection == ModuleBase_Preferences::GENERAL_SECTION && theParam == "create_init_part") {
     bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue(
index 78eba333450859e8075dea6cb937efd0391aae66..3533bcd947ec970f55ebc249a5da5f7720f6e694 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <OCCViewer_ViewPort3d.h>
 #include <OCCViewer_ViewFrame.h>
+#include <OCCViewer_ViewManager.h>
 #include <SOCC_ViewModel.h>
 #include <SUIT_ViewManager.h>
 
@@ -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<OCCViewer_ViewManager*>(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<OCCViewer_ViewManager*>(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);
     }
   }
 }