Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Main.cxx
index b6fd64f03bf55ee02a517600a4d85dd58396553b..c0dd3ea434f4a7108a5fcac8b5992b326cd95bcd 100644 (file)
@@ -74,7 +74,7 @@ using namespace boost;
         SUPERV::Port_ptr aPort = aPortList[p].in(); \
         if ( !aPort->IsInput() && !aPort->IsGate() ) { \
           bool aInStudy = dynamic_cast<SUPERVGUI_CanvasPortOut*>( aMain->getCanvas()->getPort(aPort) )->isInStudy(); \
-          dynamic_cast<SUPERVGUI_CanvasPortOut*>( getCanvas()->getPort( getDataflow()->Node(aCNode->Name())->Port(aPort->Name()) ) )->setStudyState(aInStudy); \
+          dynamic_cast<SUPERVGUI_CanvasPortOut*>( getCanvas()->getPort( getDataflow()->Node(aCNode->Name())->GetOutPort(aPort->Name()) ) )->setStudyState(aInStudy); \
         } \
       } \
     }
@@ -163,13 +163,13 @@ void SUPERVGUI_Main::init(SUIT_Desktop* theDesktop) {
   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study->application() );
 
   objectBrowser = app->objectBrowser();
-    
+
   myArray = new SUPERVGUI_CanvasArray( this, resMgr() );
   myArrayView = new SUPERVGUI_ArrayView( myArray, this );
 
   myCanvas = new SUPERVGUI_Canvas( this, resMgr() );
   myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this);
-  
+
   message = app->logWindow();
   notification = new NOTIFICATION_Consumer();
 
@@ -350,6 +350,11 @@ void SUPERVGUI_Main::sync() {
   //if ( aSupMod ) aSupMod->updateObjBrowser();
   //else MESSAGE("NULL Supervision module!");
 
+  // update "Save" icon and menu state, if dataflow is published
+  _PTR(Study) aStudy = ((SalomeApp_Study*)study)->studyDS();
+  _PTR(SObject)  aSO = aStudy->FindObjectIOR(dataflow->getIOR());
+  if (aSO) SUPERVGUI_Main::setModifiedFlag();  
+
   if (myCurrentView == CANVASTABLE) {
     myArray->sync();
     myArray->update();
@@ -597,7 +602,7 @@ void SUPERVGUI_Main::onShowToolbar()
 void SUPERVGUI_Main::onObjectCreatedDeleted()
 {
   if ( study ) {
-    if ( STD_Application* app = dynamic_cast<STD_Application*>( study->application() ) ) {
+    if ( LightApp_Application* app = dynamic_cast<LightApp_Application*>( study->application() ) ) {
       ViewManagerList aVMList;
       app->viewManagers( SUPERVGraph_Viewer::Type(), aVMList );
       SUIT_ViewManager* aVM;
@@ -608,16 +613,20 @@ void SUPERVGUI_Main::onObjectCreatedDeleted()
          QObjectList* aMainList = aVW->queryList("SUPERVGUI_Main");
          if ( aMainList->count() == 1 ) {
            SUPERVGUI_Main* aMain = dynamic_cast<SUPERVGUI_Main*>( aMainList->first() );
-           if ( aMain )
-             if ( !CORBA::is_nil( aMain->getDataflow() )
-                  &&
-                  !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR()) // equal dataflows
-                  && 
-                  aMain != this ) // not equal mains
+           if ( aMain ) {
+             if (aMain != this &&
+                  !CORBA::is_nil(aMain->getDataflow()) &&
+                  !QString(aMain->getDataflow()->getIOR()).compare(getDataflow()->getIOR())) // equal dataflows
                aMain->getCanvas()->merge();
+            }
          }
        }
       }
+
+      // update "Save" icon and menu state, if dataflow is published
+      //_PTR(Study) aStudy = ((SalomeApp_Study*)study)->studyDS();
+      //_PTR(SObject)  aSO = aStudy->FindObjectIOR(dataflow->getIOR());
+      //if (aSO) SUPERVGUI_Main::setModifiedFlag();  
     }
   }
 }
@@ -649,7 +658,7 @@ void SUPERVGUI_Main::onPutInStudy( QString* theNodePortName )
          }
        }
       }
-      SUPERVGUI_Main::setModifiedFlag();  
+      //SUPERVGUI_Main::setModifiedFlag();
     }
   }
 }
@@ -728,9 +737,11 @@ void SUPERVGUI_Main::run( const bool andSuspend ) {
       myRunTime = QDateTime::currentDateTime();
       const bool result = andSuspend ? dataflow->Start() : dataflow->Run();
       if ( !result ) {
-       QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
+       // PAL12902
+       QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE") + QString(" : ") + QString(dataflow->Messages()));
        if ( dataflow->State() == SUPERV::ErrorState ) {
-         kill();
+         // PAL12902
+         if ( !dataflow->IsEditing() ) kill();
        }
       } 
       else {
@@ -754,7 +765,9 @@ void SUPERVGUI_Main::kill() {
     QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
   } 
   else if (dataflow->Kill()) {
-    getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
+    // IPAL9273, 9369, 9731 : to avoid two equal messages about killing dataflow
+    //                        execution in the Message Console
+    //getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );
     sync();
   } 
   else {
@@ -837,7 +850,7 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) {
   case CANVAS:
   case CONTROLFLOW: 
     {
-      SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasComputeNode( resMgr(), myCanvas, this, theNode);
+      SUPERVGUI_CanvasNode* aNode = SUPERVGUI_CanvasComputeNode::Create(resMgr(), myCanvas, this, theNode);
       aNode->move(theNode->X(), theNode->Y());
       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
       aNode->show();
@@ -859,7 +872,7 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
   case CANVAS:
   case CONTROLFLOW: 
     {
-      SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasGotoNode( resMgr(), myCanvas, this, theNode);
+      SUPERVGUI_CanvasNode* aNode = SUPERVGUI_CanvasGotoNode::Create(resMgr(), myCanvas, this, theNode);
       aNode->move(theNode->X(), theNode->Y());
       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
       aNode->show();
@@ -872,7 +885,8 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) {
 /**
  * Add Control node
  */
-void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) {
+void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update)
+{
   switch (myCurrentView) {
   case CANVASTABLE:
     myArray->destroy();
@@ -881,11 +895,13 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE
   case CANVAS:
   case CONTROLFLOW: 
     {
-      SUPERVGUI_CanvasStartNode* aStartNode = new SUPERVGUI_CanvasStartNode( resMgr(), myCanvas, this, theStartNode);
+      SUPERVGUI_CanvasStartNode* aStartNode =
+        SUPERVGUI_CanvasStartNode::Create(resMgr(), myCanvas, this, theStartNode);
       aStartNode->move(theStartNode->X(), theStartNode->Y());
       if (myCurrentView == CONTROLFLOW) aStartNode->hideAll();
 
-      SUPERVGUI_CanvasEndNode* aEndNode = new SUPERVGUI_CanvasEndNode( resMgr(), myCanvas, this, theEndNode, aStartNode);
+      SUPERVGUI_CanvasEndNode* aEndNode =
+        SUPERVGUI_CanvasEndNode::Create(resMgr(), myCanvas, this, theEndNode, aStartNode);
       aEndNode->move(theEndNode->X(), theEndNode->Y());
       if (myCurrentView == CONTROLFLOW) aEndNode->hideAll();
 
@@ -910,7 +926,7 @@ void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) {
   case CANVAS:
   case CONTROLFLOW: 
     {
-      SUPERVGUI_CanvasNode* aNode = new SUPERVGUI_CanvasMacroNode( resMgr(), myCanvas, this, theNode);
+      SUPERVGUI_CanvasNode* aNode = SUPERVGUI_CanvasMacroNode::Create(resMgr(), myCanvas, this, theNode);
       aNode->move(theNode->X(), theNode->Y());
       if (myCurrentView == CONTROLFLOW) aNode->hideAll();
       aNode->show();
@@ -1119,6 +1135,8 @@ void SUPERVGUI_Main::addDataflowToStudy() {
 
     if ( !myThread->running() )
       aSupMod->updateObjBrowser();
+
+    aSupMod->getApp()->updateActions();  
   }
   else {
     MESSAGE( "ERROR: failed to find or create dataflow SObject" );
@@ -1590,6 +1608,7 @@ void SUPERVGUI_Thread::main_thread_run(SUPERV_CNode& aNode, SUPERV::GraphEvent&
 {
     // in case node "said" something during changing state through notification mechanism - output it
     myMain->syncNotification();
+    myMain->sync(); // mkr : NPAL14881
     
     // "kill" or undefined event came
     if (( aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState ) ||
@@ -1614,6 +1633,7 @@ void SUPERVGUI_Thread::main_thread_run(SUPERV_CNode& aNode, SUPERV::GraphEvent&
 
     // execution is finished.  just set a "finished" message(s)
     if ( !myIsActive ) {
+      QString aMess;
       switch ( myMain->getDataflow()->State() ) {
       case SUPERV_Editing :     
        myMain->getMessage()->putMessage( myMain->getDataflow()->IsReadOnly()? 
@@ -1627,6 +1647,14 @@ void SUPERVGUI_Thread::main_thread_run(SUPERV_CNode& aNode, SUPERV::GraphEvent&
        break;  
       case SUPERV_Error :
        myMain->getMessage()->putMessage( tr("MSG_GRAPH_ABORTED") );
+       // PAL12866 -->
+       aMess = QString(myMain->getDataflow()->Messages());
+       if ( !aMess.isEmpty() ) {
+        myMain->getMessage()->putMessage( tr("MSG_DF_BADEXECUTE") + QString(" : ") + aMess );
+        QMessageBox::warning(SUIT_Session::session()->activeApplication()->desktop(), tr("ERROR"), 
+                             tr("MSG_DF_BADEXECUTE") + QString(" : ") + aMess);
+       }
+       // PAL12866 <--
        break;  
       case SUPERV_Kill:
        myMain->getMessage()->putMessage( tr("MSG_GRAPH_KILLED") );