Salome HOME
Feature #86: The hierarchy in the Object Browser (T 19).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Displayer.cxx
index c28de63f9e4b7cf0926fc03c70b5148b00a24961..045b7db3c5e904f43d05d5d7f27497ac51058f89 100644 (file)
@@ -34,7 +34,7 @@
 #include <GraphicsView_ViewPort.h>
 
 HYDROGUI_Displayer::HYDROGUI_Displayer( HYDROGUI_Module* theModule )
-: myModule( theModule )
+: HYDROGUI_AbstractDisplayer( theModule )
 {
 }
 
@@ -45,7 +45,7 @@ HYDROGUI_Displayer::~HYDROGUI_Displayer()
 void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
                                       const int theViewerId )
 {
-  GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+  GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
 
@@ -65,18 +65,9 @@ void HYDROGUI_Displayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs
   }
 }
 
-void HYDROGUI_Displayer::UpdateAll( const int theViewerId,
-                                    const bool theIsInit,
-                                    const bool theIsForced )
-{
-  if( theIsInit )
-    EraseAll( theViewerId );
-  DisplayAll( theViewerId, theIsForced );
-}
-
 void HYDROGUI_Displayer::EraseAll( const int theViewerId )
 {
-  GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+  GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
 
@@ -95,43 +86,10 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId )
   }
 }
 
-void HYDROGUI_Displayer::DisplayAll( const int theViewerId,
-                                     const bool theIsForced )
-{
-  HYDROData_SequenceOfObjects aSeq;
-  HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
-  Update( aSeq, theViewerId, theIsForced );
-}
-
-void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs,
-                                 const int theViewerId,
-                                 const bool theIsForced )
-{
-  // First of all, kill all bad presentations
-  purgeObjects( theViewerId );
-
-  // Now dig in the data model
-  HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay;
-
-  for( int i = 1, n = theObjs.Length(); i <= n; i++ )
-  {
-    const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
-    if( anObj.IsNull() )
-      anObjectsToErase.Append( anObj );
-    else
-      anObjectsToDisplay.Append( anObj );
-  }
-
-  if( anObjectsToErase.Length() )
-    Erase( anObjectsToErase, theViewerId );
-  if( anObjectsToDisplay.Length() )
-    Display( anObjectsToDisplay, theViewerId, theIsForced );
-}
-
 void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
                                 const int theViewerId )
 {
-  GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+  GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
 
@@ -139,7 +97,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
   if( !aViewPort )
     return;
 
-  HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel();
+  HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)module()->dataModel();
   if( aModel ) 
   {
     GraphicsView_ObjectList anObjectList = HYDROGUI_Tool::GetPrsList( aViewPort );
@@ -150,6 +108,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
       if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) )
       {
         aViewPort->removeItem( aPrs );
+        anObjectList.removeAll( aPrs );
         delete aPrs;
       }
     }
@@ -158,9 +117,10 @@ 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 = myModule->getViewer( theViewerId );
+  GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
 
@@ -190,18 +150,21 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs,
 
     if( aPrs )
     {
-      bool anIsVisible = myModule->isObjectVisible( (size_t)aViewer, anObj );
+      bool anIsVisible = module()->isObjectVisible( (size_t)aViewer, anObj );
       aPrs->setVisible( anIsVisible );
     }
   }
 
   aViewPort->onBoundingRectChanged(); // specific of HYDRO module
-  aViewPort->fitAll();
+  if ( theDoFitAll )
+  {
+    aViewPort->fitAll();
+  }
 }
 
 void HYDROGUI_Displayer::purgeObjects( const int theViewerId )
 {
-  GraphicsView_Viewer* aViewer = myModule->getViewer( theViewerId );
+  GraphicsView_Viewer* aViewer = module()->getViewer( theViewerId );
   if( !aViewer )
     return;
 
@@ -254,3 +217,8 @@ HYDROGUI_PrsDriver* HYDROGUI_Displayer::getDriver( const Handle(HYDROData_Entity
 
   return aDriver;
 }
+
+QString HYDROGUI_Displayer::GetType() const
+{
+  return GraphicsView_Viewer::Type();
+}