]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #51: unnecessary fit all after show-hide object
authorrkv <rkv@opencascade.com>
Mon, 18 Nov 2013 06:07:59 +0000 (06:07 +0000)
committerrkv <rkv@opencascade.com>
Mon, 18 Nov 2013 06:07:59 +0000 (06:07 +0000)
src/HYDROGUI/HYDROGUI_Displayer.cxx
src/HYDROGUI/HYDROGUI_Displayer.h
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.h
src/HYDROGUI/HYDROGUI_ShowHideOp.cxx
src/HYDROGUI/HYDROGUI_UpdateFlags.h

index d42b31423cc094855c8bf18a243f2a7626bf62de..006c64c4318718f60d3f652e5309016628ee92ed 100644 (file)
@@ -116,7 +116,8 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
 
 void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
                                   const int theViewerId,
-                                  const bool theIsForced )
+                                  const bool theIsForced,
+                                  const bool theDoFitAll)
 {
   GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
@@ -154,7 +155,10 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
   }
 
   aViewPort->onBoundingRectChanged(); // specific of HYDRO module
-  aViewPort->fitAll();
+  if ( theDoFitAll )
+  {
+    aViewPort->fitAll();
+  }
 }
 
 void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
index 17e23c9ab520fecbeb6ad22cb3f9ecac9d361e4a..4d80827278c9bb17e7418691da3b06da2863a0e9 100644 (file)
@@ -78,10 +78,12 @@ protected:
    * \param theObjs sequence of objects to display
    * \param theViewerId viewer identifier
    * \param theIsForced flag used to update all objects, including the unchanged ones
+   * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
    */
   void                            Display( const HYDROData_SequenceOfObjects& theObjs,
                                            const int theViewerId,
-                                           const bool theIsForced );
+                                           const bool theIsForced,
+                                           const bool theDoFitAll );
 
   /**
    * \brief Purge all invalid objects in the viewer.
index 06129f95d9ecbcd973fc321ece4e66c748ea716e..db43680470e477aaf2a6aea29d3ba5ae2f71195c 100644 (file)
@@ -398,11 +398,13 @@ void HYDROGUI_Module::update( const int flags )
 
   if( ( flags & UF_Viewer ) )
     updateGV( flags & UF_GV_Init,
-              flags & UF_GV_Forced );
+              flags & UF_GV_Forced,
+              flags & UF_FitAll );
 
   if( ( flags & UF_OCCViewer ) )
     updateOCCViewer( flags & UF_OCC_Init,
-                     flags & UF_OCC_Forced );
+                     flags & UF_OCC_Forced,
+                     flags & UF_FitAll );
 
   if( ( flags & UF_Model ) && getDataModel() && getApp() )
   {
@@ -798,7 +800,8 @@ void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
 }
 
 void HYDROGUI_Module::updateGV( const bool theIsInit,
-                                const bool theIsForced )
+                                const bool theIsForced,
+                                const bool theDoFitAll )
 {
   if( !getDisplayer() )
     return;
@@ -820,11 +823,12 @@ void HYDROGUI_Module::updateGV( const bool theIsInit,
 
   QListIterator<int> anIdIter( aViewManagerIdList );
   while( anIdIter.hasNext() )
-    getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
+    getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
 }
 
 void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
-                                       const bool theIsForced )
+                                       const bool theIsForced,
+                                       const bool theDoFitAll )
 {
   HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
   if( !anOCCDisplayer )
@@ -847,7 +851,7 @@ void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
 
   QListIterator<int> anIdIter( aViewManagerIdList );
   while( anIdIter.hasNext() )
-    anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
+    anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
 }
 
 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
index 3561ed1c9b82048d45cbaa6b356db06ac36592d8..b34dda4de30b2263390e9c892322602b2fd6a806 100644 (file)
@@ -152,10 +152,12 @@ protected slots:
 
 private:
   void                            updateGV( const bool theIsInit = false, 
-                                            const bool theIsForced = false );
+                                            const bool theIsForced = false,
+                                            const bool theDoFitAll = false );
 
   void                            updateOCCViewer( const bool theIsInit = false, 
-                                                   const bool theIsForced = false );
+                                                   const bool theIsForced = false,
+                                                   const bool theDoFitAll = false );
 
   void                            createSelector( SUIT_ViewManager* viewMgr );
 
index 61a78ac4c5f580df2af36282b7284e01303c2a61..fe5fe68b6b82efa0adcbb5a7c5bce05eb5ec5cf7 100644 (file)
@@ -115,7 +115,8 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
 
 void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
                                      const int                          theViewerId,
-                                     const bool                         theIsForced )
+                                     const bool                         theIsForced,
+                                     const bool theDoFitAll )
 {
   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
   if( !aViewer )
@@ -149,15 +150,18 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
     }
   }
 
-  OCCViewer_ViewManager* aViewManager
-    = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
-  if ( aViewManager )
+  if ( theDoFitAll )
   {
-    OCCViewer_ViewWindow* aViewWindow = 
-      ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
-    if ( aViewWindow )
+    OCCViewer_ViewManager* aViewManager
+      = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
+    if ( aViewManager )
     {
-      aViewWindow->onFitAll();
+      OCCViewer_ViewWindow* aViewWindow = 
+        ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
+      if ( aViewWindow )
+      {
+        aViewWindow->onFitAll();
+      }
     }
   }
 }
index 410ee7766d4dde7c09eb13e7baf4e0dde2247896..69b976ee0adecc353f58a747073e39d01a6aab63 100644 (file)
@@ -75,10 +75,12 @@ protected:
    * \param theObjs sequence of objects to display
    * \param theViewerId viewer identifier
    * \param theIsForced flag used to update all objects, including the unchanged ones
+   * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default
    */
   void                            Display( const HYDROData_SequenceOfObjects& theObjs,
                                            const int theViewerId,
-                                           const bool theIsForced );
+                                           const bool theIsForced,
+                                           const bool theDoFitAll );
 
   /**
    * \brief Purge all invalid objects in the viewer.
index 543fe3bcd3ebdab8ed667e223c007bb7aec73427..b1ddd661d2bc8c6f2a36dff2c22675f9439fdd56 100644 (file)
@@ -114,6 +114,11 @@ void HYDROGUI_ShowHideOp::startOperation()
 
   int anUpdateFlags = 0;
 
+  if ( myId == ShowOnlyId || myId == ShowId || myId == ShowAllId )
+  {
+    anUpdateFlags = UF_FitAll;
+  }
+
   SUIT_ViewManager* aViewMgr = module()->getApp()->activeViewManager();
   if ( aViewMgr )
   {
index b01da33503e14026fd35c480ef32736499bf1d34..14ef92ef13124e83280acaa4e388f9de8e5c4805 100644 (file)
@@ -42,6 +42,8 @@ typedef enum
   UF_OCC_Init      = 0x00000100, //!< initial update (used with UF_OCCViewer)
   UF_OCC_Forced    = 0x00000200, //!< to force recomputing all presentations (used with UF_OCCViewer)
   
+  UF_FitAll        = 0x00000400, //!< to do fit all (used with UF_Viewer or UF_OCCViewer)
+
   UF_All           = UF_Base | UF_GV_Init | UF_GV_Forced | UF_OCCViewer | UF_OCC_Init | UF_OCC_Forced//!< all update flags
 } HYDRO_UpdateFlags;