+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;
+}