HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
: HYDROGUI_AbstractDisplayer( theModule )
{
+ myToUpdateColorScale = false;
}
HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer()
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 );
aRes = true;
}
- UpdateColorScale( theViewer );
return aRes;
}
}
}
+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();
foreach( HYDROGUI_Shape* aShape, aShapes )
{
HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
- if( !aBathShape )
+ if( !aBathShape || !aBathShape->isVisible() )
continue;
aBathShape->GetRange( aMin, aMax );
foreach( HYDROGUI_Shape* aShape, aShapes )
{
HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
- if( !aBathShape )
+ if( !aBathShape || !aBathShape->isVisible() )
continue;
aBathShape->UpdateWithColorScale( aColorScale );
if( aView->ColorScaleIsDisplayed() )
aView->ColorScaleErase();
}
+
+ myToUpdateColorScale = false;
}
void RemoveZLayer( OCCViewer_ViewManager* theMgr,
const int theLayer );
+ void SetToUpdateColorScale();
+
protected:
/**
* \brief Erase all viewer objects.
void SetZLayer( const OCCViewer_Viewer* theViewer,
const Handle(HYDROData_Entity)& theObject,
const int theZLayerId );
+
+private:
+ bool myToUpdateColorScale;
};
#endif
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;
//
#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 )
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();
+}
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();
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;
};