]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Correct popup-menu: Delete now available only in Object Browser
authorjfa <jfa@opencascade.com>
Mon, 8 Aug 2005 08:57:16 +0000 (08:57 +0000)
committerjfa <jfa@opencascade.com>
Mon, 8 Aug 2005 08:57:16 +0000 (08:57 +0000)
src/VISUGUI/VisuGUI.cxx

index fcaf2a00f79f9f29f5cd7f0ca9843d6a9f6b2a34..01bcb137ed7e15f7da701813631456903f5eae30 100644 (file)
@@ -2571,6 +2571,9 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
 {
   SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
 
+  OB_Browser* ob = getApp()->objectBrowser();
+  bool isOBClient = (ob && theClient == ob->popupClientType());
+
   SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
   SALOME_ListIO aListIO;
   aSelectionMgr->selectedObjects(aListIO);
@@ -2584,8 +2587,6 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   SALOME_ListIteratorOfListIO It (aListIO);
   for (; It.More(); It.Next()) {
     Handle(SALOME_InteractiveObject)& anIO = It.Value();
-    /*std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
-    nbPrs += aPrsList.size();*/
 
     if (!anIO.IsNull() && anIO->hasEntry()) {
       _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
@@ -2624,7 +2625,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   theMenu->insertSeparator();
 
   // Check if some (nb > 0) removable objects selected
-  if (IsRemovableSelected(this)) {
+  if (isOBClient && IsRemovableSelected(this)) {
     action( VISU_DELETE_OBJS )->addTo(theMenu);
   }
 
@@ -2642,35 +2643,34 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   if (aType == VISU::TANIMATION) {
     action( VISU_SHOW_ANIMATION )->addTo(theMenu);
 
-  } else if (IsSObjectTable(SO)) {
-    OB_Browser* ob = getApp()->objectBrowser();
-    if (ob && theClient == ob->popupClientType()) {
+  } else if (isOBClient) {
+    if (IsSObjectTable(SO)) {
       action( VISU_SHOW_TABLE )->addTo(theMenu);
       action( VISU_CREATE_CURVES )->addTo(theMenu);
       action( VISU_EXPORT_TABLE )->addTo(theMenu);
       theMenu->insertSeparator();
-    }
-  } else {
-    if (!CORBA::is_nil(anObject)) {
-      SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
-      if (!CORBA::is_nil(aMED.in())) {
-        action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
-      }
-
-      SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
-      if (!CORBA::is_nil(aField)) {
-        action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
-      }
     } else {
-      _PTR(SObject) aSFather = SO->GetFather();
-      if (aSFather) {
-        _PTR(GenericAttribute) anAttr;
-        aSFather->FindAttribute(anAttr, "AttributeName");
-        if (anAttr) {
-          _PTR(AttributeName) aName (anAttr);
-          std::string aValue = aName->Value();
-          if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
-            action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
+      if (!CORBA::is_nil(anObject)) {
+        SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
+        if (!CORBA::is_nil(aMED.in())) {
+          action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
+        }
+
+        SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
+        if (!CORBA::is_nil(aField)) {
+          action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
+        }
+      } else {
+        _PTR(SObject) aSFather = SO->GetFather();
+        if (aSFather) {
+          _PTR(GenericAttribute) anAttr;
+          aSFather->FindAttribute(anAttr, "AttributeName");
+          if (anAttr) {
+            _PTR(AttributeName) aName (anAttr);
+            std::string aValue = aName->Value();
+            if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
+              action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
+            }
           }
         }
       }