Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.cxx
index 172dc214c02a7e33e1d48372b789ba401f11a816..8e60fccc48552d39238eca0a69fa888cbba18770 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
 //
 //
 //
@@ -36,14 +36,11 @@ using namespace std;
 map< string , int > _MapOfGraphNames;
 
 string GraphInstanceName( const char * aGraphName ) {
+  // mkr : PAL8004 -->
+  // For Macro nodes : names of subgraphs must be unique and differ from the main dataflow
+  // name (i.e. the dataflow with MacroLevel = 0).
+  // It is neccessary for reqursive call of LoadDataFlows(...) method for MacroNodes execution.
   int GraphInstanceNumber = _MapOfGraphNames[ aGraphName ] ;
-  if ( GraphInstanceNumber ) {
-    _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
-  }
-  else {
-    GraphInstanceNumber = 0 ;
-    _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
-  }
   string theGraphInstanceName = string( aGraphName ) ;
   if ( GraphInstanceNumber ) {
     theGraphInstanceName += "_" ;
@@ -51,6 +48,10 @@ string GraphInstanceName( const char * aGraphName ) {
     astr << GraphInstanceNumber ;
     theGraphInstanceName += astr.str() ;
   }
+  if ( theGraphInstanceName != string( aGraphName ) )
+    _MapOfGraphNames[ theGraphInstanceName ] = GraphInstanceNumber ;
+  _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
+  // mkr : PAL8004 <--
   return theGraphInstanceName ;
 }
 
@@ -348,6 +349,10 @@ bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
                         aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
                         aNode.theComment.c_str() ,
                         aNode.theCoords.theX , aNode.theCoords.theY ) ;
+
+    // insert container into < ComponentName, Container > map for corresponding component
+    Graph()->InsertToMapOfComponentNameContainer( aNode.theComponentName.c_str(), aNode.theContainer.c_str() ) ; // mkr : PAL13947
+
     string * aNodetheName = new string( aNode.theName ) ;
     aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
     if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
@@ -924,7 +929,7 @@ bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
                                          const char* FromServiceParameterName ,
                                          const char* ToNodeName ,
                                          const char* ToServiceParameterName ,
-                                         const int index , long &X , long &Y ) {
+                                         const int index , CORBA::Long &X , CORBA::Long &Y ) {
   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
                                                            ToServiceParameterName ) ;
 //  cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
@@ -1014,6 +1019,11 @@ bool GraphEditor::OutNode::Valid() {
   Graph()->ComputingNodes() ;
 #endif
 
+  if ( !Graph()->ValidGOTO() ) { // mkr : PAL12575
+    cdebug << "Editor::OutNode::Valid This DataFlow have not valid GOTO(ValidGOTO)." << endl ;
+    RetVal = false ;
+  }
+
   if ( RetVal ) {
     _Valid = true ;
   }
@@ -1046,25 +1056,31 @@ bool GraphEditor::OutNode::Executable() {
   }
 
 //JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
+  bool IsValid = true;
   int SubStreamGraphsNumber = 0 ;
   if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
     cdebug << "Editor::OutNode::Executable This DataFlow is not valid(Sort)." << endl ;
     RetVal = false ;
+    //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
+    IsValid = false ;
   }
-  if ( Graph()->IsDataStreamNode() ) {
+  if ( Graph()->IsDataStreamNode() )
     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
-  }
 
   Graph()->InLineServices() ;
-
+  
 //  if ( kLoopSwitch ) {
     if ( !Graph()->ValidLoops() ) {
       cdebug << "Editor::OutNode::Executable This DataFlow have not valid Loops(ValidLoops)." << endl ;
       RetVal = false ;
+      //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
+      IsValid = false ;
     }
     if ( !Graph()->ValidSwitchs() ) {
       cdebug << "Editor::OutNode::Executable This DataFlow have not valid Switchs(ValidSwitchs)." << endl ;
       RetVal = false ;
+      //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
+      IsValid = false ;
     }
 //  }
   
@@ -1088,6 +1104,9 @@ bool GraphEditor::OutNode::Executable() {
     RetVal = false ;
   }    
 
+  //mkr : 28.09.2005 : if dataflow is not valid => it is not executable
+  if ( !IsValid ) _Executable = false ;
+
   cdebug_out << "GraphEditor::OutNode::Executable _Executable " << _Executable << " RetVal " << RetVal
              << endl;
   return RetVal ;
@@ -1181,7 +1200,7 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin
     valuetype.appendChild( aField ) ;
     switch (aLink.aLinkValue.type()->kind()) {
       case CORBA::tk_string: {
-        char* retstr ;
+        const char* retstr ;
         aLink.aLinkValue >>= retstr;
 //        f << Tabs << "       <value>" << retstr << "</value>" << endl ;
         QDomElement value = Graph.createElement( "value" ) ;
@@ -1207,7 +1226,7 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin
         break ;
       }
       case CORBA::tk_double: {
-        double d;
+        CORBA::Double d;
         aLink.aLinkValue >>= d;
 //        f << Tabs << "       <value>" << d << "</value>" << endl ;
         QDomElement value = Graph.createElement( "value" ) ;
@@ -1220,7 +1239,7 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin
         break ;
       }
       case CORBA::tk_long: {
-        long l;
+        CORBA::Long l;
         aLink.aLinkValue >>= l;
 //        f << Tabs << "       <value>" << l << "</value>" << endl ;
         QDomElement value = Graph.createElement( "value" ) ;
@@ -1229,13 +1248,17 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin
         aField = Graph.createTextNode( aKind ) ;
         datavalue.appendChild( value ) ;
         value.appendChild( aField ) ;
-//        MESSAGE( "ToString( long ) " << l );
+//        MESSAGE( "ToString( CORBA::Long ) " << l );
         break ;
       }
       case CORBA::tk_objref: {
         char* retstr ;
         CORBA::Object_ptr obj ;
-        aLink.aLinkValue >>= obj ;
+#if OMNIORB_VERSION >= 4
+        aLink.aLinkValue >>= (CORBA::Any::to_object)obj;
+#else
+       aLink.aLinkValue >>= obj;
+#endif 
         retstr = _Orb->object_to_string(obj );
 //        f << Tabs << "       <value>" << retstr << "</value>" << endl ;
         QDomElement value = Graph.createElement( "value" ) ;
@@ -1326,19 +1349,19 @@ bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
       << ".Input( " ;
     switch (aLink.aLinkValue.type()->kind()) {
       case CORBA::tk_string: {
-        char* retstr ;
+        const char* retstr ;
         aLink.aLinkValue >>= retstr;
         f << "'" << retstr << "'" ;
         break ;
       }
       case CORBA::tk_double: {
-        double d;
+        CORBA::Double d;
         aLink.aLinkValue >>= d;
         f << d ;
         break ;
       }
       case CORBA::tk_long: {
-        long l;
+        CORBA::Long l;
         aLink.aLinkValue >>= l;
         f << l ;
         break ;
@@ -1346,7 +1369,11 @@ bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
       case CORBA::tk_objref: {
         char* retstr ;
         CORBA::Object_ptr obj ;
-        aLink.aLinkValue >>= obj ;
+#if OMNIORB_VERSION >= 4
+        aLink.aLinkValue >>= (CORBA::Any::to_object)obj;
+#else
+       aLink.aLinkValue >>= obj;
+#endif 
         retstr = _Orb->object_to_string(obj );
         f << "'" << retstr << "'" ;
         break ;