From 938e44e49abb1efe6754ff5bc4a0e6e2b5678b83 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 29 Aug 2014 11:49:38 +0000 Subject: [PATCH] refs #437, #438 -- performance of the bathymetry --- src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx | 18 +++++++--- src/HYDROGUI/HYDROGUI_OCCDisplayer.h | 5 +++ src/HYDROGUI/HYDROGUI_Shape.h | 2 +- src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx | 44 +++++++++++++++++++++-- src/HYDROGUI/HYDROGUI_ShapeBathymetry.h | 11 +++++- 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index c8cf6c69..8ff07424 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -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( 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( 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( 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; } diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h index 95b391cf..62f0cd52 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.h +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_Shape.h b/src/HYDROGUI/HYDROGUI_Shape.h index 64548763..69ab1b17 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.h +++ b/src/HYDROGUI/HYDROGUI_Shape.h @@ -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; diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx index a414b3c4..2abb2879 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx @@ -21,6 +21,7 @@ // #include +#include #include #include @@ -29,15 +30,18 @@ #include #include -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(); +} diff --git a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.h b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.h index 840026ed..c584d592 100644 --- a/src/HYDROGUI/HYDROGUI_ShapeBathymetry.h +++ b/src/HYDROGUI/HYDROGUI_ShapeBathymetry.h @@ -29,11 +29,13 @@ 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; }; -- 2.39.2