Salome HOME
Feature #86: The hierarchy in the Object Browser (T 19).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index b5cf925c011b4daf93cee3c070a3bbb994699919..ccaa4c0d0c7999ce5b4d42151cfa4276a857554c 100644 (file)
@@ -223,6 +223,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsSplittedImage = false;
   bool anIsMustBeUpdatedImage = false;
   bool anIsPolyline = false;
+  bool anIsProfile = false;
   bool anIsBathymetry = false;
   bool anIsCalculation = false;
   bool anIsImmersibleZone = false;
@@ -257,7 +258,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
         if( !anImage.IsNull() )
         {
-          anIsImportedImage = anImage->HasLocalPoints() && !anImage->IsSelfSplitted();
+          anIsImportedImage = anImage->HasLocalPoints();
           anIsImageHasRefs = anImage->HasReferences();
           if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
           {
@@ -280,6 +281,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
       else if( anObject->GetKind() == KIND_POLYLINE )
         anIsPolyline = true;
+      else if( anObject->GetKind() == KIND_PROFILE )
+        anIsProfile = true;
       else if( anObject->GetKind() == KIND_CALCULATION )
         anIsCalculation = true;
       else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
@@ -313,6 +316,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_POLYLINE:
           theMenu->addAction( action( CreatePolylineId ) );
           break;
+        case KIND_PROFILE:
+          theMenu->addAction( action( CreateProfileId ) );
+          break;
         case KIND_VISUAL_STATE:
           theMenu->addAction( action( SaveVisualStateId ) );
           break;
@@ -379,6 +385,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( EditPolylineId ) );
         theMenu->addSeparator();
       }
+      else if( anIsProfile )
+      {
+        theMenu->addAction( action( EditProfileId ) );
+        theMenu->addSeparator();
+      }
       else if( anIsCalculation )
       {
         theMenu->addAction( action( EditCalculationId ) );
@@ -744,7 +755,7 @@ void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId
     return;
 
   // Compute the new global Z range from the added presentation and the old global Z range.
-  double* aGlobalRange = getVTKDisplayer()->GetZRange();
+  double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
   double* aRange = theShape->getInternalZRange();
   bool anIsUpdate = false;
   if ( aRange[0] < aGlobalRange[0] )
@@ -760,7 +771,7 @@ void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId
 
   //if ( anIsUpdate )
   //{
-    updateVTKZRange( aGlobalRange );
+    updateVTKZRange( theViewId, aGlobalRange );
   //}
 
   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
@@ -791,7 +802,7 @@ void HYDROGUI_Module::removeObjectVTKPrs( const int                       theVie
 
   // Invalidate global Z range
   double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
-  getVTKDisplayer()->SetZRange( anInvalidRange );
+  getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
 }
 
 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
@@ -810,14 +821,12 @@ void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
   myVTKPrsMap.remove( theViewId );
 }
 
-void HYDROGUI_Module::updateVTKZRange( double theRange[] )
+void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
 {
-  // For all VTK viewers ...
-  QList<int> aViewIdList = myVTKPrsMap.keys();
-  foreach( int aViewId, aViewIdList )
+  if ( myVTKPrsMap.contains( theViewId ) )
   {
-    // ... update all VTK presentations ...
-    const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( aViewId );
+    // 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 )
     {
@@ -829,7 +838,7 @@ void HYDROGUI_Module::updateVTKZRange( double theRange[] )
     }
   }
   // ... and update the global color legend scalar bar.
-  getVTKDisplayer()->SetZRange( theRange );
+  getVTKDisplayer()->SetZRange( theViewId, theRange );
 }
 /////////////////// END OF VTKPrs PROCESSING
 
@@ -928,6 +937,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 );
   }
 }