Salome HOME
Access to 'Invalid value' of altitude from Bathymetry is added.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 9b13d845d165a2d23caab1db3e8ae04ad8be5e86..c355b2dfe9ea402d64e8b9364e441a9cb2ab3353 100644 (file)
@@ -33,6 +33,8 @@
 #include "HYDROGUI_Tool.h"
 #include "HYDROGUI_UpdateFlags.h"
 
+#include <HYDROData_Image.h>
+
 #include <GraphicsView_ViewFrame.h>
 #include <GraphicsView_ViewManager.h>
 #include <GraphicsView_ViewPort.h>
@@ -139,12 +141,16 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 {
   HYDROGUI_DataModel* aModel = getDataModel();
 
+  size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
+
   bool anIsSelection = false;
   bool anIsVisibleInSelection = false;
   bool anIsHiddenInSelection = false;
 
   bool anIsImage = false;
+  bool anIsCompositeImage = false;
   bool anIsPolyline = false;
+  bool anIsVisualState = false;
 
   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
@@ -154,23 +160,34 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     {
       anIsSelection = true;
 
-      bool aVisibility = anObject->GetVisibility();
+      bool aVisibility = anObject->IsVisible( aViewId );
       anIsVisibleInSelection |= aVisibility;
       anIsHiddenInSelection |= !aVisibility;
 
       if( anObject->GetKind() == KIND_IMAGE )
+      {
         anIsImage = true;
-
-      if( anObject->GetKind() == KIND_POLYLINE )
+        Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
+        if( !anImage.IsNull() )
+          anIsCompositeImage = anImage->NbReferences() > 0;
+      }
+      else if( anObject->GetKind() == KIND_POLYLINE )
         anIsPolyline = true;
+      else if( anObject->GetKind() == KIND_VISUAL_STATE )
+        anIsVisualState = true;
     }
   }
 
-  if( aSeq.Length() == 1 )
+  if( aSeq.IsEmpty() )
+  {
+    theMenu->addAction( action( SaveVisualStateId ) );
+    theMenu->addSeparator();
+  }
+  else if( anIsSelection && aSeq.Length() == 1 )
   {
     if( anIsImage )
     {
-      theMenu->addAction( action( EditImageId ) );
+      theMenu->addAction( action( anIsCompositeImage ? EditCompositeImageId : EditImportedImageId ) );
       theMenu->addAction( action( ObserveImageId ) );
       theMenu->addAction( action( ExportImageId ) );
       theMenu->addSeparator();
@@ -180,6 +197,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addAction( action( EditPolylineId ) );
       theMenu->addSeparator();
     }
+    else if( anIsVisualState )
+    {
+      theMenu->addAction( action( SaveVisualStateId ) );
+      theMenu->addAction( action( LoadVisualStateId ) );
+      theMenu->addSeparator();
+    }
   }
 
   if( anIsSelection )
@@ -188,7 +211,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
-  if( anIsSelection )
+  if( anIsSelection && ( anIsImage || anIsPolyline ) )
   {
     if( anIsHiddenInSelection )
       theMenu->addAction( action( ShowId ) );
@@ -197,6 +220,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addAction( action( HideId ) );
     theMenu->addSeparator();
   }
+
   theMenu->addAction( action( ShowAllId ) );
   theMenu->addAction( action( HideAllId ) );
   theMenu->addSeparator();