Salome HOME
Fix for the bug #130: bathymetry sign is wrong
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 28fc93e7d9a08b2826a2f949a1c78283e94242a6..2e32038f9b523cd00cde71c8f52e68f213105d05 100644 (file)
@@ -38,6 +38,7 @@
 #include "HYDROGUI_VTKPrs.h"
 #include "HYDROGUI_VTKPrsDisplayer.h"
 #include "HYDROGUI_AbstractDisplayer.h"
+#include "HYDROGUI_PolylineOp.h"
 
 #include <HYDROData_Image.h>
 #include <HYDROData_Lambert93.h>
@@ -418,6 +419,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     }
   }
 
+  if ( anIsOCCView )
+  {
+    SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
+    HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
+    if ( aPolylineOp && aPolylineOp->deleteEnabled() )
+      theMenu->addAction( action( DeleteId ) );
+  }
+
   if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
   {
     theMenu->addAction( action( ShowAllId ) );
@@ -734,6 +743,26 @@ void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId
   if( theObject.IsNull() )
     return;
 
+  // Compute the new global Z range from the added presentation and the old global Z range.
+  double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+  double* aRange = theShape->getInternalZRange();
+  bool anIsUpdate = false;
+  if ( aRange[0] < aGlobalRange[0] )
+  {
+    aGlobalRange[0] = aRange[0];
+    anIsUpdate = true;
+  }
+  if ( aRange[1] > aGlobalRange[1] )
+  {
+    aGlobalRange[1] = aRange[1];
+    anIsUpdate = true;
+  }
+
+  //if ( anIsUpdate )
+  //{
+    updateVTKZRange( theViewId, aGlobalRange );
+  //}
+
   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
   aViewShapes.append( theShape );
 }
@@ -759,6 +788,10 @@ void HYDROGUI_Module::removeObjectVTKPrs( const int                       theVie
 
     ++i;
   }
+
+  // Invalidate global Z range
+  double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
+  getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
 }
 
 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
@@ -776,6 +809,26 @@ void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
 
   myVTKPrsMap.remove( theViewId );
 }
+
+void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
+{
+  if ( myVTKPrsMap.contains( theViewId ) )
+  {
+    // For the given viewer id update all VTK presentations ...
+    const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+    HYDROGUI_VTKPrs* aShape;
+    for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+    {
+      aShape = aViewShapes.at( i );
+      if ( aShape )
+      {
+        aShape->setZRange( theRange );
+      }
+    }
+  }
+  // ... and update the global color legend scalar bar.
+  getVTKDisplayer()->SetZRange( theViewId, theRange );
+}
 /////////////////// END OF VTKPrs PROCESSING
 
 CAM_DataModel* HYDROGUI_Module::createDataModel()
@@ -873,6 +926,16 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
         removeViewShapes( (size_t)anOCCViewer );
     }
 
+    if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
+    {
+      SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
+      if ( aVTKViewer )
+      {
+        getVTKDisplayer()->DeleteScalarBar( anId );
+        removeViewShapes( (size_t)aVTKViewer );
+      }
+    }
+
     myViewManagerMap.remove( anId );
   }
 }