]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/SUPERVGUI/SUPERVGUI.cxx
Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI.cxx
index 2442a9678132e3718b2dcb28396e6b0a3b5b889e..aced7fee3dae189f5d4a204c08d1993f7f734417 100644 (file)
@@ -17,7 +17,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -164,9 +164,9 @@ void SUPERVGUI::initialize( CAM_Application* app )
   createSupervAction( 309, "ADDNODE"       , "ICO_ADDNODE" );
   createSupervAction( 310, "STEPBYSTEP"    , "ICO_STEPBYSTEP" );
 
-  createSupervAction( 311, "POP_RENAME" );
+  createSupervAction( 311, "POP_RENAME", "", Key_F2 );
   createSupervAction( 312, "POP_DISPLAY" );
-  createSupervAction( 313, "POP_DELETE" );
+  createSupervAction( 313, "POP_DELETE", "", Key_Delete );
 
   // ----- create menu -----------------
   int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
@@ -375,43 +375,55 @@ void SUPERVGUI::onGraphClosed(SUIT_ViewWindow* theViewWindow) {
     SUPERVGraph_View* view = supervFrame->getViewWidget();
     SUPERVGUI_Main* aGraph = dynamic_cast<SUPERVGUI_Main*>(view);
     if ( aGraph ) {
+      // mkr: PAL12449 --->
+      if ( (( SalomeApp_Study* )(aGraph->getStudy()))->studyDS() && !aGraph->isDataflowInStudy() ) {
+       const int aWarnResult = QMessageBox::information(application()->desktop(), tr("MSG_INFO"),
+                                                        tr("MSG_GRAPH_UNSAVED"),
+                                                        QMessageBox::Yes, QMessageBox::No);
+       if ( aWarnResult == QMessageBox::Yes ) {
+         aGraph->addDataflowToStudy();
+         updateObjBrowser();
+       }
+      }
+      // mkr: PAL12449 <---
+      
       unregisterGraph(aGraph);
       SUPERV_Graph aDataFlow = aGraph->getDataflow();
       if ( !SUPERV_isNull( aDataFlow ) ) {
-        if ( aDataFlow->IsExecuting() ) {
-          const int aMsgResult = QMessageBox::warning(application()->desktop(),
-                                                      tr("WARNING"),
-                                                      tr("MSG_DF_RUNNING"),
-                                                      tr("MSG_DF_EXECUTION"),
-                                                      tr("MSG_DF_KILL"));
-          if ( aMsgResult == 1 ) {
-            // KILL EXECUTION
-            if ( aDataFlow->Kill() ) {
-              // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
-              // while sets myIsActive flag to false when it receives such event/state
-              // after myIsActive is false it calls QThread::exit() to terminate.
-
-              // why while() { qApp->processEvents() } ?
-              // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
-              // method using SALOME_Event paradigm, ProcessVoidEvent() function -
-              // it puts this event to the main application event loop, in which we are being now.
-              // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
-              // then we will have a deadlock of 2 threads waiting for one another
-              while (aGraph->getMyThread()->running())
-                qApp->processEvents();
-            }
-          }
-          else { // BACKGROUND EXECUTION
-            emit KillMainThread(true); // set SUPERVGUI_Thread::myIsActive to false
-            while ( aGraph->getMyThread()->running() )
-              qApp->processEvents();
-          }
-        }
-        else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
-          emit KillMainThread(true);
-          while ( aGraph->getMyThread()->running() )
-            qApp->processEvents();
-        }
+       if ( aDataFlow->IsExecuting() ) {
+         const int aMsgResult = QMessageBox::warning(application()->desktop(),
+                                                     tr("WARNING"),
+                                                     tr("MSG_DF_RUNNING"),
+                                                     tr("MSG_DF_EXECUTION"),
+                                                     tr("MSG_DF_KILL"));
+         if ( aMsgResult == 1 ) {
+           // KILL EXECUTION
+           if ( aDataFlow->Kill() ) {
+             // Kill() sends KillEvent and KillState to SUPERVGUI_Thread
+             // while sets myIsActive flag to false when it receives such event/state
+             // after myIsActive is false it calls QThread::exit() to terminate.
+             
+             // why while() { qApp->processEvents() } ?
+             // because: SUPERVGUI_Thread::run() receives events, and calls myMain->execute()
+             // method using SALOME_Event paradigm, ProcessVoidEvent() function -
+             // it puts this event to the main application event loop, in which we are being now.
+             // So if we block main GUI application thread (by calling aGraph->getMyThread()->wait() here)
+             // then we will have a deadlock of 2 threads waiting for one another
+             while (aGraph->getMyThread()->running())
+               qApp->processEvents();
+           }
+         }
+         else { // BACKGROUND EXECUTION
+           emit KillMainThread(true); // set SUPERVGUI_Thread::myIsActive to false
+           while ( aGraph->getMyThread()->running() )
+             qApp->processEvents();
+         }
+       }
+       else { // EXECUTION IS FINISHED, JUST DESTROY THE SUPERVGUI_Thread object and return.
+         emit KillMainThread(true);
+         while ( aGraph->getMyThread()->running() )
+           qApp->processEvents();
+       }
       }
     }
   }
@@ -443,64 +455,76 @@ void SUPERVGUI::setMain( SUIT_ViewWindow* w) {
 }
 
 void SUPERVGUI::displayDataflow() {
-    Trace("SUPERVGUI::displayDataflow");
-    OB_Browser* aBrowser = (( SalomeApp_Application* )application())->objectBrowser();
-    SUPERV_Graph aDataFlow;
-    QString aIORName;
-
-    OB_ListItem* item = (OB_ListItem*)(aBrowser->listView()->currentItem());
-    _PTR(SObject) aObj
-      ( (( SalomeApp_Study* )(application()->activeStudy()))->studyDS()->FindObjectID(item->text(2).latin1()) );
-    _PTR(GenericAttribute) anAttr;
-    if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
-      _PTR(AttributeIOR) anIOR ( anAttr );
-      aIORName = QString(anIOR->Value().c_str());
-      if (isContains(study, aIORName)) {
-        if (QMessageBox::warning(application()->desktop(), tr("WARNING"),
-                                 tr("MSG_GRAPH_DISPLAYED").arg(""),
-                                 QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
-          return;
-      }
-      //aDataFlow = engine->getStreamGraph(anIOR->Value().c_str());
-      aDataFlow = engine->getGraph(anIOR->Value().c_str());
-      if (SUPERV_isNull(aDataFlow)) {
-        QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
+  Trace("SUPERVGUI::displayDataflow");
+
+  OB_Browser* aBrowser = getApp()->objectBrowser();
+  OB_ListItem* item = (OB_ListItem*)(aBrowser->listView()->currentItem());
+
+  SalomeApp_Study* anAppStudy = (SalomeApp_Study*)(getApp()->activeStudy());
+  _PTR(SObject) aObj (anAppStudy->studyDS()->FindObjectID(item->text(2).latin1()));
+
+  SUPERV_Graph aDataFlow;
+  QString aIORName;
+
+  _PTR(GenericAttribute) anAttr;
+  if (aObj->FindAttribute(anAttr, "AttributeIOR")) {
+    _PTR(AttributeIOR) anIOR ( anAttr );
+    aIORName = QString(anIOR->Value().c_str());
+    if (isContains(study, aIORName)) {
+      if (QMessageBox::warning(application()->desktop(), tr("WARNING"),
+                               tr("MSG_GRAPH_DISPLAYED").arg(""),
+                               QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
         return;
-      }
-      /* ASV: 20.10.04: fix for 6896
-      if (aDataFlow->IsStreamGraph()) {
-        SUPERV_StreamGraph aDataFlowStream = aDataFlow->ToStreamGraph();
-        if (SUPERV_isNull(aDataFlowStream)) {
-          QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
-          return;
-        }
-        aDataFlow = aDataFlowStream;
-      }
-      */
     }
 
-    SUPERVGraph_ViewFrame* aViewFrame;
-    if ( !myInitialViewFrame ) {
-      // first case : create a ViewFrame object
-      aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
-    }
-    else {
-      // second case : get empty initial view frame as new ViewFrame object
-      aViewFrame = myInitialViewFrame;
-      // mkr : PAL8237 : remove first "gag" Main from children
-      aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
+    //SUPERV_Graph aDataFlow = engine->getStreamGraph(anIOR->Value().c_str());
+    aDataFlow = engine->getGraph(anIOR->Value().c_str());
+    if (SUPERV_isNull(aDataFlow)) {
+      QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
+      return;
     }
 
-    if( aViewFrame ) {
-      main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aDataFlow );
-      registerGraph( aIORName, main );
-      aViewFrame->show();
+    /* ASV: 20.10.04: fix for 6896
+    if (aDataFlow->IsStreamGraph()) {
+      SUPERV_StreamGraph aDataFlowStream = aDataFlow->ToStreamGraph();
+      if (SUPERV_isNull(aDataFlowStream)) {
+        QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR"));
+        return;
+      }
+      aDataFlow = aDataFlowStream;
     }
+    */
+  }
 
-    if ( myInitialViewFrame ) {
-      myInitialViewFrame = 0;
-      myIVFBackgroundColor = QColor();
-    }
+  SUPERVGraph_ViewFrame* aViewFrame;
+  if ( !myInitialViewFrame ) {
+    // first case : create a ViewFrame object
+    aViewFrame = dynamic_cast<SUPERVGraph_ViewFrame*>( createGraph() );
+  }
+  else {
+    // second case : get empty initial view frame as new ViewFrame object
+    aViewFrame = myInitialViewFrame;
+    // mkr : IPAL12991 -->
+    SUPERVGraph_View* view = myInitialViewFrame->getViewWidget();
+    if (view)
+      unregisterGraph(dynamic_cast<SUPERVGUI_Main*>(view));
+    // mkr : IPAL12991 <--
+    // mkr : PAL8237 : remove first "gag" Main from children
+    // srn: commented as it cases on application exit "X Windows error"
+    //aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
+    delete view;
+  }
+
+  if ( aViewFrame ) {
+    main = new SUPERVGUI_Main( aViewFrame, application()->desktop(), aDataFlow );
+    registerGraph( aIORName, main );
+    aViewFrame->show();
+  }
+
+  if ( myInitialViewFrame ) {
+    myInitialViewFrame = 0;
+    myIVFBackgroundColor = QColor();
+  }
 }
 
 
@@ -538,6 +562,26 @@ void SUPERVGUI::renameDataflow() {
 
           updateObjBrowser();
           //QApplication::restoreOverrideCursor();
+
+         // mkr : PAL7037 => rename engine of the graph (i.e. corresponding SUPERV_Graph) -->
+          if ( obj->FindAttribute(anAttr, "AttributeIOR") ) {
+            _PTR(AttributeIOR) anIOR ( anAttr );
+            SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value().c_str());
+            if ( !SUPERV_isNull(aDataFlow) ) {
+              if ( aDataFlow->IsStreamGraph() ) {
+               SUPERV_StreamGraph aStreamDataFlow = aDataFlow->ToStreamGraph();
+                if ( !SUPERV_isNull(aStreamDataFlow) )
+                  aStreamDataFlow->SetName( nm.latin1() );
+              }
+              else {
+                aDataFlow->SetName( nm.latin1() );
+              }
+
+              // update "Save" icon and menu state, if dataflow is published
+              SUPERVGUI_Main::setModifiedFlag();  
+            }
+          }
+         // mkr : PAL7037 <--
         }
       }
     }
@@ -678,8 +722,16 @@ bool SUPERVGUI::createDataflow( const NEW_DF_MODE mode, bool theInitialDF ) {
   else {
     // 2. get empty initial view frame as new ViewFrame object
     aViewFrame = myInitialViewFrame;
+    // mkr : IPAL12991 -->
+    if ( myInitialViewFrame ) {
+      SUPERVGraph_View* view = myInitialViewFrame->getViewWidget();
+      if (view)
+       unregisterGraph(dynamic_cast<SUPERVGUI_Main*>(view));
+    }
+    // mkr : IPAL12991 <--
     // mkr : PAL8237 : remove first "gag" Main from children
-    aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
+    // srn: commented as it cases on application exit "X Windows error"
+    //aViewFrame->removeChild( aViewFrame->queryList("SUPERVGUI_Main")->first() );
   }
 
   if ( aViewFrame ) {
@@ -874,7 +926,7 @@ void SUPERVGUI::deleteObject() {
   if (QMessageBox::warning(application()->desktop(),
                            tr("WARNING"),
                            tr("MSG_ASK_DELETE"),
-                           QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes)
+                           QMessageBox::Yes, QMessageBox::No) != QMessageBox::Yes)
     return;
 
   SALOME_ListIteratorOfListIO It( aList );
@@ -1009,12 +1061,8 @@ void SUPERVGUI::fillInterfaceNameMap() {
       //get component
       SALOME_ModuleCatalog::Acomponent_ptr aComponent = (*aModuleCatalog)->GetComponent(aCompList[ind1]);
       if ( aComponent != NULL ) {
-        //get interface list
-        SALOME_ModuleCatalog::ListOfInterfaces_var anIntList = aComponent->GetInterfaceList();
-        for (int ind2 = 0; ind2 < anIntList->length(); ind2++) {
-          const char* anIntName = anIntList[ind2];
-          myInterfaceNameMap.insert(QString(anIntName), QString(aComponent->componentname()));
-        }
+       // mkr : PAL13135
+       myInterfaceNameMap.insert(QString(aComponent->componentusername()), QString(aComponent->componentname()));
       }
     }
   }
@@ -1023,3 +1071,20 @@ void SUPERVGUI::fillInterfaceNameMap() {
 QMap<QString, QString> SUPERVGUI::getInterfaceNameMap() const {
   return myInterfaceNameMap;
 }
+
+bool SUPERVGUI::updateDataFlowSOName( SUPERV::Graph_ptr theDataflow ) {
+  if ( !SUPERV_isNull(theDataflow) ) {
+    _PTR(Study) aStudy = (( SalomeApp_Study* )study)->studyDS();
+    _PTR(SObject) aSO ( aStudy->FindObjectIOR( theDataflow->getIOR() ) );
+
+    _PTR(GenericAttribute) anAttr;
+    if ( aSO ) // i.e. if theDataflow is in study
+      if ( aSO->FindAttribute(anAttr, "AttributeName") ) {
+        _PTR(AttributeName) aName ( anAttr );
+       aName->SetValue( theDataflow->Name() );
+       updateObjBrowser();
+       return true;
+      }    
+  }
+  return false;
+}