]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1329
authorisn <isn@opencascade.com>
Tue, 14 Nov 2017 13:24:20 +0000 (16:24 +0300)
committerisn <isn@opencascade.com>
Tue, 14 Nov 2017 13:24:58 +0000 (16:24 +0300)
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/LightApp.xml

index f20ed70caa623502d0fc1e5f8fb384464fed807b..5ad9a3eff30dedf3aba8b90f6e1f828bd41f78d5 100644 (file)
@@ -225,7 +225,6 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
     if( occ_mgr )
       occ_mgr->setChainedOperations( true );//TODO: via preferences
 
-
     foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
     {
       OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
@@ -251,6 +250,7 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
     }
   }
 
+
 //  SUIT_DataBrowser* ob = getApp()->objectBrowser();
 //  SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
 //  treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
@@ -896,7 +896,7 @@ void HYDROGUI_Module::createPreferences()
   addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
                  LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
 
-  addPreference( tr( "PREF_VIEWER_AUTOMATIC_ZOOM" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "automatic_zoom" );
+  addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
 
   int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
   int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
@@ -956,37 +956,10 @@ void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QStri
           getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
       }
     }
-    else if (theSection == "HYDRO" && thePref == "automatic_zoom")
+    else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
     {
-      bool anAutoZoom = resMgr->booleanValue( "HYDRO", "automatic_zoom" );
-      ViewManagerList aViewManagers = getApp()->viewManagers();
-      foreach (SUIT_ViewManager* aVMgr, aViewManagers)
-      {
-        if (aVMgr)
-        {
-          QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
-          foreach (SUIT_ViewWindow* aView, aViews)
-          {
-            if (aView)
-            {
-              OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
-              if (anOCCViewFrame)
-              {
-                anOCCViewFrame->setAutomaticZoom(anAutoZoom);
-                for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
-                {
-                  OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
-                  if (aV)
-                    aV->setAutomaticZoom(anAutoZoom);
-                }
-              }
-              OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
-              if (anOCCViewWindow)
-                anOCCViewWindow->setAutomaticZoom(true);
-            }
-          }
-        }
-      }
+      bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
+      setAutoZoomToAllViewManagers(!aZoomShutoff);
     }
     else
         LightApp_Module::preferencesChanged( theSection, thePref );
@@ -1064,6 +1037,8 @@ void HYDROGUI_Module::update( const int flags )
 
   setUpdateEnabled( true );
 
+  setAutoZoomToAllViewManagers(false);
+
   QApplication::restoreOverrideCursor();
 }
 
@@ -1705,7 +1680,6 @@ void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
       aViewFrame->onTopView();
 
       HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
-
       OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
       if ( aViewPort ) {
         aViewPort->installEventFilter( this );
@@ -2038,3 +2012,38 @@ void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
 
   myOverview->setMainView( occwnd );
 }
+
+void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
+{
+  ViewManagerList aViewManagers = getApp()->viewManagers();
+  foreach (SUIT_ViewManager* aVMgr, aViewManagers)
+    setAutoZoom(aVMgr, bAutoZoom);
+}
+
+void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
+{
+  if (!aVMgr)
+    return;
+  QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
+  foreach (SUIT_ViewWindow* aView, aViews)
+  {
+    if (aView)
+    {
+      OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
+      if (anOCCViewFrame)
+      {
+        anOCCViewFrame->setAutomaticZoom(bAutoZoom);
+        for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
+        {
+          OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
+          if (aV)
+            aV->setAutomaticZoom(bAutoZoom);
+        }
+      }
+      OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
+      if (anOCCViewWindow)
+        anOCCViewWindow->setAutomaticZoom(bAutoZoom);
+    }
+  }
+}
+
index ba0f8ba5457a41d081dae1951d0127947e00a1f2..8ecc3090578579e3b14afbb7f86578e2e617ee39 100644 (file)
@@ -263,7 +263,8 @@ public:
 
 protected:
   CAM_DataModel*                  createDataModel();
-
+  void                            setAutoZoomToAllViewManagers(bool bAutoZoom);
+  void                            setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom);
 public slots:
   virtual bool                    activateModule( SUIT_Study* );
   virtual bool                    deactivateModule( SUIT_Study* );
index a2b588fe38848fbb686c905b99bb1997d4e2edcc..da5bed2d56873b32500372b911ec6bcba8e7ae02 100644 (file)
@@ -283,8 +283,8 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <translation>Make automatic fit all after show object operation</translation>
     </message>
     <message>
-      <source>PREF_VIEWER_AUTOMATIC_ZOOM</source>
-      <translation>Turn on the automatic fit-all operation when front/top/left/etc called</translation>
+      <source>PREF_VIEWER_ZOOM_SHUTOFF</source>
+      <translation>Turn on the conservation of zoom (zoom shutoff) when when front/top/left/etc called</translation>
     </message>
     <message>
       <source>PREF_GROUP_STRICKLER_TABLE</source>
index e08f4acb86f23ec274d8ac97791b1ddb241b4f61..8f8cfad9750dd21225ab1c5cc135a462662655f7 100644 (file)
@@ -29,7 +29,7 @@
     <parameter value="0" name="parameter_test" />
     <parameter name="version" value="2.0.0"/>
     <parameter value="false" name="auto_fit_all"/>
-    <parameter value="false" name="automatic_zoom"/>
+    <parameter value="true" name="zoom_shutoff"/>
     <parameter name="documentation" value="hydro_help"/>
   </section>
   <section name="hydro_help" >