Salome HOME
Import profiles protection (Bug #203).
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 4d6b818bdfcd83e947bf4485f356516691c24dbc..fb192aff8069ee159101f1efe13eb39cc3b15918 100644 (file)
@@ -190,6 +190,7 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
   foreach ( const int anId, anObsoleteIds ) {
     myViewManagerMap.remove( anId );
     myObjectStateMap.remove( anId );
+    myObjectDisplayOrderMap.remove( anId );
     myShapesMap.remove( anId );
     myVTKPrsMap.remove( anId );
   }
@@ -609,19 +610,22 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( SetColorId ) );
         theMenu->addSeparator();
       }
-
-      // Add copy action
-      if( aModel->canCopy() ) {
-        theMenu->addAction( action( CopyId ) );
-        theMenu->addSeparator();
-      }
     } else if ( anAllAreProfiles ) {
       theMenu->addAction( action( SelectedGeoreferencementId ) );
       theMenu->addSeparator();
     }
 
+    // Add copy action
+    QAction* aCopyAction = action( CopyId );
+    if( aCopyAction && aCopyAction->isEnabled() ) {
+      theMenu->addAction( action( CopyId ) );
+      theMenu->addSeparator();
+    }
+
+    // Add delete action
     if( !anIsDummyObject3D )
       theMenu->addAction( action( DeleteId ) );
+
     theMenu->addSeparator();
 
     if( anIsImage || anIsPolyline || anIsPolyline3D || 
@@ -653,6 +657,10 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addAction( action( HideAllId ) );
     theMenu->addSeparator();
   }
+  if ( anIsOCCView ) {
+    theMenu->addSeparator();
+    theMenu->addAction( action( CopyViewerPositionId ) );
+  }
 }
 
 void HYDROGUI_Module::update( const int flags )
@@ -867,6 +875,13 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
 
     ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
     anObjectState.Visibility = theState;
+
+    // Remember the display order ( needed for Z layers assignment only )
+    QStringList& anObjectEntries = myObjectDisplayOrderMap[ theViewId ];
+    anObjectEntries.removeAll( anEntry );
+    if ( theState ) {
+      anObjectEntries.append( anEntry );
+    }
   }
 }
 
@@ -1517,4 +1532,19 @@ void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent*
       aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
     }
   }
+}
+
+/**
+ * Get the object display order. Needed for Z layers assignment only.
+ */
+int HYDROGUI_Module::getObjectDisplayOrder( 
+  const int theViewId, const Handle(HYDROData_Entity)& theObject) const
+{
+  if( theObject.IsNull() )
+    return -1;
+
+  QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
+  QStringList anObjectEntries = myObjectDisplayOrderMap.value( theViewId );
+
+  return anObjectEntries.indexOf( anEntry );
 }
\ No newline at end of file