- if ( aLayerId >= 0 ) {
- // set Z layer
- aCtx->SetZLayer( anObjShape->getAISShape(), aLayerId );
-
- // set Z layer settings for the 3d viewer:
- // current settings
- Graphic3d_ZLayerSettings aSettings = aViewer3d->ZLayerSettings( aLayerId );
- // enable depth write
- aSettings.EnableSetting( Graphic3d_ZLayerDepthWrite );
- // disable depth clear
- aSettings.DisableSetting( Graphic3d_ZLayerDepthClear );
- if ( theIsOrdered ) {
- // disable depth test
- aSettings.DisableSetting( Graphic3d_ZLayerDepthTest );
- // disable depth offset
- aSettings.DisableSetting( Graphic3d_ZLayerDepthOffset );
- } else {
- // enable depth test
- aSettings.EnableSetting( Graphic3d_ZLayerDepthTest );
- // set depth offset
- aSettings.SetDepthOffsetPositive();
- }
-
- // set new settings
- aViewer3d->SetZLayerSettings( aLayerId, aSettings );
-
- aRes = true;
+ // 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 );