+ // Object shape
+ HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
+ // create if needed
+ if ( !anObjShape ) {
+ anObjShape = createShape( aViewerId, aCtx, theObject );
+ if ( anObjShape ) {
+ anObjShape->setIsToUpdate( true );
+ }
+ }
+
+ // Process the shape
+ if ( anObjShape ) {
+ // update if needed
+ if ( anObjShape->getIsToUpdate() || theIsForced ) {
+ anObjShape->update( false, false );
+ }
+
+ // Set visibility
+ bool anIsVisible = module()->isObjectVisible( aViewerId, theObject );
+ anObjShape->setVisible( anIsVisible, false );
+
+ aRes = true;
+ }
+
+ return aRes;
+}
+
+void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer,
+ const Handle(HYDROData_Entity)& theObject,
+ const int theZLayerId )
+{
+ if ( !theViewer || ( theZLayerId < 0 ) ) {
+ return;
+ }
+
+ // Get interactive context
+ Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
+ if( aCtx.IsNull() ) {
+ return;
+ }
+
+ // Get viewer id
+ size_t aViewerId = (size_t)theViewer;
+
+ // Get object shape
+ HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
+
+ // Set Z layer
+ if ( anObjShape ) {
+ aCtx->SetZLayer( anObjShape->getAISObject(), theZLayerId );
+ }
+}
+
+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();
+
+ int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
+ QList<HYDROGUI_Shape*> aShapes = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY );
+
+ bool isDisplayColorScale = !aShapes.empty();
+ Standard_Real anXPos = 0.05; //TODO
+ Standard_Real anYPos = 0.1; //TODO
+ Standard_Real aWidth = 0.2; //TODO
+ Standard_Real aHeight = 0.5; //TODO
+ Standard_Integer aTextHeight = 14; //TODO
+ Standard_Integer aNbIntervals = 20; //TODO
+ TCollection_ExtendedString aColorScaleTitle = "";//TODO
+
+ Standard_Real aColorScaleMin = 0, aColorScaleMax = 1, aMin, aMax;
+ bool isFirst = true;
+ foreach( HYDROGUI_Shape* aShape, aShapes )
+ {
+ HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
+ if( !aBathShape || !aBathShape->isVisible() )
+ continue;
+
+ aBathShape->GetRange( aMin, aMax );
+
+ if( isFirst || aMin < aColorScaleMin )
+ aColorScaleMin = aMin;
+ if( isFirst || aMax > aColorScaleMax )
+ aColorScaleMax = aMax;
+
+ isFirst = false;
+ }
+
+ if( isDisplayColorScale )
+ {
+ Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
+ if( !aColorScale.IsNull() )
+ {
+ aColorScale->SetXPosition( anXPos );
+ aColorScale->SetYPosition( anYPos );
+ aColorScale->SetWidth( aWidth );
+ aColorScale->SetHeight( aHeight );
+
+ aColorScale->SetTextHeight( aTextHeight );
+ aColorScale->SetNumberOfIntervals( aNbIntervals );
+
+ aColorScale->SetTitle( aColorScaleTitle );
+ aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
+
+ foreach( HYDROGUI_Shape* aShape, aShapes )
+ {
+ HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
+ if( !aBathShape || !aBathShape->isVisible() )
+ continue;
+
+ aBathShape->UpdateWithColorScale( aColorScale );
+ }
+ }
+ if( !aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleDisplay();
+ }
+ else
+ {
+ if( aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleErase();
+ }
+
+ myToUpdateColorScale = false;
+}