]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #437, #438 -- performance of the bathymetry
authorasl <asl@opencascade.com>
Fri, 29 Aug 2014 11:49:38 +0000 (11:49 +0000)
committerasl <asl@opencascade.com>
Fri, 29 Aug 2014 11:49:38 +0000 (11:49 +0000)
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.h
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx
src/HYDROGUI/HYDROGUI_ShapeBathymetry.h

index c8cf6c697c21963061de7bd8eb9041dea72bc1e2..8ff07424d67870783edf56dcb97e32190f55bf2f 100644 (file)
@@ -51,6 +51,7 @@
 HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
 : HYDROGUI_AbstractDisplayer( theModule )
 {
+  myToUpdateColorScale = false;
 }
 
 HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer()
@@ -161,7 +162,7 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
   if( theObject->IsKind( STANDARD_TYPE( HYDROData_Image ) ) )
     aResShape = new HYDROGUI_ShapeImage( theContext, Handle_HYDROData_Image::DownCast( theObject ) );
   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) )
-    aResShape = new HYDROGUI_ShapeBathymetry( theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) );
+    aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) );
   else
     aResShape = new HYDROGUI_Shape( theContext, theObject );
 
@@ -367,7 +368,6 @@ bool HYDROGUI_OCCDisplayer::Display( const Handle(HYDROData_Entity)& theObject,
     aRes = true;
   }
 
-  UpdateColorScale( theViewer );
   return aRes;
 }
 
@@ -397,8 +397,16 @@ void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer,
   }
 }
 
+void HYDROGUI_OCCDisplayer::SetToUpdateColorScale()
+{
+  myToUpdateColorScale = true;
+}
+
 void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer )
 {
+  if( !myToUpdateColorScale )
+    return;
+
   OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
   Handle(V3d_View) aView = aWnd->getViewPort()->getView();
 
@@ -419,7 +427,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
   foreach( HYDROGUI_Shape* aShape, aShapes )
   {
     HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
-    if( !aBathShape )
+    if( !aBathShape || !aBathShape->isVisible() )
       continue;
 
     aBathShape->GetRange( aMin, aMax );
@@ -451,7 +459,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
       foreach( HYDROGUI_Shape* aShape, aShapes )
       {
         HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
-        if( !aBathShape )
+        if( !aBathShape || !aBathShape->isVisible() )
           continue;
 
         aBathShape->UpdateWithColorScale( aColorScale );
@@ -465,4 +473,6 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
     if( aView->ColorScaleIsDisplayed() )
       aView->ColorScaleErase();
   }
+
+  myToUpdateColorScale = false;
 }
index 95b391cf2ab85dd7f94c8a928da234676b337021..62f0cd52a09595678230c52c557673024418b586 100644 (file)
@@ -76,6 +76,8 @@ public:
   void                            RemoveZLayer( OCCViewer_ViewManager* theMgr,
                                                 const int theLayer );
 
+  void SetToUpdateColorScale();
+
 protected:
   /**
    * \brief Erase all viewer objects.
@@ -144,6 +146,9 @@ private:
   void                            SetZLayer( const OCCViewer_Viewer* theViewer,
                                              const Handle(HYDROData_Entity)& theObject, 
                                              const int theZLayerId );
+
+private:
+  bool myToUpdateColorScale;
 };
 
 #endif
index 64548763669e165503aacf191ca22cc8dcfd4f3d..69ab1b174fb0e490bc362c5ec0cffddad465a733 100644 (file)
@@ -106,7 +106,7 @@ protected:
   virtual void               buildShape();
   virtual void               updateShape( const bool theToDisplay      = true,
                                           const bool theIsUpdateViewer = true );
-  void                       displayShape( const bool theIsUpdateViewer );
+  virtual void               displayShape( const bool theIsUpdateViewer );
 
   virtual QColor             getActiveColor() const;
   virtual Handle_AIS_InteractiveObject createShape() const;
index a414b3c444486d9a45e3e7692aeebf29f28bf717..2abb2879632f8d0ad5276e1458cfc88a5af9d0c7 100644 (file)
@@ -21,6 +21,7 @@
 //
 
 #include <HYDROGUI_ShapeBathymetry.h>
+#include <HYDROGUI_OCCDisplayer.h>
 #include <HYDROData_Bathymetry.h>
 
 #include <AIS_InteractiveContext.hxx>
 #include <Aspect_ColorScale.hxx>
 #include <Prs3d_PointAspect.hxx>
 
-HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( const Handle(AIS_InteractiveContext)& theContext,
+HYDROGUI_ShapeBathymetry::HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer*                theDisplayer,
+                                                    const Handle(AIS_InteractiveContext)& theContext,
                                                     const Handle_HYDROData_Bathymetry&    theBathymetry,
                                                     const int                             theZLayer )
-: HYDROGUI_Shape( theContext, theBathymetry, theZLayer )
+: HYDROGUI_Shape( theContext, theBathymetry, theZLayer ),
+  myDisplayer( theDisplayer )
 {
 }
 
 HYDROGUI_ShapeBathymetry::~HYDROGUI_ShapeBathymetry()
 {
+  myDisplayer->SetToUpdateColorScale();
 }
 
 void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivateSelection )
@@ -115,3 +119,39 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(Aspect_ColorSc
   getContext()->Redisplay( aPntCloud, Standard_False );
 }
 
+void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
+                                           const bool theIsUpdateViewer )
+{
+  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isChanged = ( isShown != theState );
+  HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
+  if( isChanged )
+    myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
+{
+  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isChanged = ( !isShown  );
+  HYDROGUI_Shape::displayShape( theIsUpdateViewer );
+  if( isChanged )
+    myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
+{
+  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isChanged = ( !isShown  );
+  HYDROGUI_Shape::display( theIsUpdateViewer );
+  if( isChanged )
+    myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
+{
+  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isChanged = ( isShown  );
+  HYDROGUI_Shape::erase( theIsUpdateViewer );
+  if( isChanged )
+    myDisplayer->SetToUpdateColorScale();
+}
index 840026ed1786b890c20121baaeacc57dc2fc7a48..c584d592557b9b0249ace9cb2f0f693d1cf2fe08 100644 (file)
 
 class Handle_HYDROData_Bathymetry;
 class Handle_Aspect_ColorScale;
+class HYDROGUI_OCCDisplayer;
 
 class HYDROGUI_ShapeBathymetry : public HYDROGUI_Shape
 {
 public:
-  HYDROGUI_ShapeBathymetry( const Handle(AIS_InteractiveContext)& theContext,
+  HYDROGUI_ShapeBathymetry( HYDROGUI_OCCDisplayer* theDisplayer,
+                            const Handle(AIS_InteractiveContext)& theContext,
                             const Handle_HYDROData_Bathymetry&    theBathymetry,
                             const int                             theZLayer = -1 );
   virtual ~HYDROGUI_ShapeBathymetry();
@@ -41,13 +43,20 @@ public:
   void GetRange( double& theMin, double& theMax ) const;
   void UpdateWithColorScale( const Handle_Aspect_ColorScale& );
 
+  virtual void display( const bool theIsUpdateViewer = true );
+  virtual void erase( const bool theIsUpdateViewer = true );
+
   virtual void               update( bool isUpdateViewer,
                                      bool isDeactivateSelection );
 
+  virtual void               setVisible( const bool theState,
+                                         const bool theIsUpdateViewer = true );
 protected:
   virtual Handle_AIS_InteractiveObject createShape() const;
+  virtual void displayShape( const bool theIsUpdateViewer );
 
 private:
+  HYDROGUI_OCCDisplayer* myDisplayer;
   Handle_TColgp_HArray1OfPnt     myCoords;
   Handle_Quantity_HArray1OfColor myColors;
 };