]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/SUPERVGUI/SUPERVGUI.cxx
Salome HOME
NRI : Merge delta [V1_2, V1_2c].
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.cxx
index 5158492d978f22422cca46d16327940701772fad..142ee04470c5f92786231fca00f633ce58daf1b7 100644 (file)
@@ -53,11 +53,10 @@ SUPERVGUI Supervision;
 
 
 SUPERVGUI::SUPERVGUI(): QObject(),
-    desktop(0),
-    study(0),
-    engine(0),
-    browser(0)
-                       //info(0)
+                       desktop(0),
+                       study(0),
+                       browser(0)
+  //info(0)
 {
     Trace("SUPERVGUI::SUPERVGUI")
     if (factory==0) {
@@ -72,8 +71,9 @@ SUPERVGUI::~SUPERVGUI() {
     Trace("SUPERVGUI::~SUPERVGUI")
     if (factory==1) {
         factory = 0;
+       //if (!engine->_is_nil()) CORBA::release(engine);         
         //info->close();
-        browser->close();
+        if (browser) browser->close();
         MESSAGE("SUPERVGUI Info : factory destroy");
     } else {
         MESSAGE("SUPERVGUI Error : another call to factory destructor");
@@ -125,8 +125,8 @@ void SUPERVGUI::loadEngine(SALOME_NamingService* namingService) {
         return;
     };
 
-    engine  = new SUPERV::SuperG_var;
-    *engine = aSuperVisionComponent;
+    //    engine  = new SUPERV::SuperG_var;
+    engine = aSuperVisionComponent;
 }
 /*
 bool SUPERVGUI::information(SUPERV_CNode node, bool isReadOnly) {
@@ -236,7 +236,7 @@ void SUPERVGUI::importDataflow() {
        return;
     }
 
-    SUPERV_Graph aGraph = (*Supervision.getEngine())->GraphE(f);
+    SUPERV_Graph aGraph = engine->GraphE(f);
     //QFileInfo aFile(f);
     //aGraph->SetName(aFile.baseName());
     if (SUPERV_isNull(aGraph)) {
@@ -274,7 +274,7 @@ void SUPERVGUI::displayDataflow() {
                                 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
          return;
       }
-      aDataFlow = (*Supervision.getEngine())->getGraph(ior);
+      aDataFlow = engine->getGraph(ior);
       if (SUPERV_isNull(aDataFlow)) {
        QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
        return;
@@ -365,7 +365,7 @@ void SUPERVGUI::modifyDataflow() {
        return;
       }
       
-      SUPERV_Graph aGraph = (*Supervision.getEngine())->Graph(f);
+      SUPERV_Graph aGraph = engine->Graph(f);
       //QFile aFile(f);
       //aGraph->SetName(aFile.name());
       if (SUPERV_isNull(aGraph)) {
@@ -455,20 +455,35 @@ void SUPERVGUI::customPopup(QPopupMenu* popup) {
     SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
     if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return;
 
-    Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject();
+    if (Sel->IObjectCount() == 1) {
+      Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject();
 
-    // insert SUPERV-specific popup items here
+      // insert SUPERV-specific popup items here
 
-    bool isDataflow, ownObj;
-    whatIsSelected(anIObj, ownObj, isDataflow);
-    
-    if (isDataflow) {
-      popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow()));
-      popup->insertItem("Display", this, SLOT(displayDataflow()));
-      popup->insertSeparator();
+      bool isDataflow, ownObj;
+      whatIsSelected(anIObj, ownObj, isDataflow);
+      
+      if (isDataflow) {
+       popup->insertItem(tr( "MSG_RENAME" ), this, SLOT(renameDataflow()));
+       popup->insertItem("Display", this, SLOT(displayDataflow()));
+       popup->insertSeparator();
+      }
+      if (ownObj)
+       popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
+    }
+    if (Sel->IObjectCount() > 1) {
+      int aIObjCount = 0;
+      SALOME_ListIteratorOfListIO It_forCheckOwner(Sel->StoredIObjects());
+      for(;It_forCheckOwner.More();It_forCheckOwner.Next()) {
+       Handle(SALOME_InteractiveObject) anIObj = It_forCheckOwner.Value();
+       bool aIsOwner, aIsDataflow;
+       whatIsSelected(anIObj, aIsOwner, aIsDataflow);
+       
+       if (aIsOwner) aIObjCount++;
+      }
+      if (aIObjCount == Sel->IObjectCount())  //all selected objects belong to Supervision
+       popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
     }
-    if (ownObj)
-      popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject()));
 }
 
  
@@ -499,7 +514,7 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b
          SALOMEDS::GenericAttribute_var anAttr;
          if (obj->FindAttribute(anAttr, "AttributeIOR")) {
            SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-           SUPERV_Graph aDataFlow = (*Supervision.getEngine())->getGraph(anIOR->Value());
+           SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value());
            if (!SUPERV_isNull(aDataFlow)) 
              theIsDataflow = true;
          }
@@ -516,43 +531,44 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b
 void SUPERVGUI::deleteObject() {
   SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() );
   if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return;
-  
-  Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject();
-  bool aIsOwner, aIsDataflow;
-  whatIsSelected(anIObj, aIsOwner, aIsDataflow);
-
-  if (!aIsOwner) return;
-
+   
   if (QMessageBox::warning(QAD_Application::getDesktop(),
                           tr("WARNING"),
                           tr("MSG_ASK_DELETE"),
                           QMessageBox::No,
                           QMessageBox::Yes) == QMessageBox::No)
     return;
-  
-  SALOMEDS::Study_var aStudy = study->getStudyDocument();
-  SALOMEDS::SObject_var  aObj = aStudy->FindObjectID( anIObj->getEntry() );
-  if (!aObj->_is_nil()) {
-    if (aIsDataflow) {
-      SALOMEDS::GenericAttribute_var anAttr;
-      if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
-       SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-       QString ior = anIOR->Value();
-       
-       SUPERVGUI_Main* aMain;
-       for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
-         if ((aMain->getStudy() == study) && (aMain->getHashCode() == ior)) {
-           aMain->setAsFromStudy(false);
-           break;
+   
+  SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+  for(;It.More();It.Next()) {
+    Handle(SALOME_InteractiveObject) anIObj = It.Value();
+    bool aIsOwner, aIsDataflow;
+    whatIsSelected(anIObj, aIsOwner, aIsDataflow);
+    
+    SALOMEDS::Study_var aStudy = study->getStudyDocument();
+    SALOMEDS::SObject_var  aObj = aStudy->FindObjectID( anIObj->getEntry() );
+    if (!aObj->_is_nil()) {
+      if (aIsDataflow) {
+       SALOMEDS::GenericAttribute_var anAttr;
+       if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
+         SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+         QString ior = anIOR->Value();
+           
+         SUPERVGUI_Main* aMain;
+         for (aMain = myGraphList.first(); aMain; aMain = myGraphList.next()) {
+           if ((aMain->getStudy() == study) && (aMain->getHashCode() == ior)) {
+             aMain->setAsFromStudy(false);
+             break;
+           }
          }
-       }
+        }
       }
+      QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
+      SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
+      op->start();
+      aBuilder->RemoveObjectWithChildren(aObj);
+      op->finish();
     }
-    QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
-    SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
-    op->start();
-    aBuilder->RemoveObjectWithChildren(aObj);
-    op->finish();
   }
   Sel->ClearIObjects() ; 
 }