Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.cxx
index e0dfda434566994cda13652263df5710dec001f1..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 ;
 }
 
@@ -206,7 +207,8 @@ bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
     RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ;
   }
-  cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() << endl;
+  cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize()
+             << " _Valid " << _Valid << " _Executable " << _Executable << " RetVal " << RetVal << endl;
   return RetVal ;
 }
 
@@ -347,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() ) {
@@ -445,6 +451,7 @@ bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
                                      const GraphBase::ListOfSLinks &aListOfLinks ) {
   bool RetVal = true ;
+  bool RetAddLink ;
   cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
 //  MESSAGE( "GraphEditor::OutNode::LoadLinks" );
   int i , j ;
@@ -458,21 +465,16 @@ bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
            << aLink.ToServiceParameterName.c_str() << " )" << endl ;
     if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
          Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
-//      GraphBase::ComputingNode * aFromNode = (GraphBase::ComputingNode * ) Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) ;
-//      const GraphBase::OutPort * anOutPort = aFromNode->GetOutPort( aLink.FromServiceParameterName.c_str() ) ;
-      RetVal = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
-                        aLink.FromServiceParameterName.c_str() ,
-                        Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
-                        aLink.ToServiceParameterName.c_str() ) ;
-//                        , *anOutPort->Value() ) ;
+//JR 08.02.2005 : Rule of CEA : a bad graph may be stored in a xml
+      RetAddLink = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
+                            aLink.FromServiceParameterName.c_str() ,
+                            Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
+                            aLink.ToServiceParameterName.c_str() ) ;
     }
     else {
       RetVal = false ;
     }
-//                      aLink.aLinkValue ) ;
-    if ( !RetVal )
-      break ;
-    else {
+    if ( RetVal && RetAddLink ) {
       for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
         RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
                                         aLink.FromServiceParameterName.c_str() ,
@@ -488,13 +490,14 @@ bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
     delete aLinkFromNodeName ;
     delete aLinkToNodeName ;
   }
-  cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
+  cdebug_out << "GraphEditor::OutNode::LoadLinks " << RetVal << endl ;
   return RetVal ;
 }
 
 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
                                      const GraphBase::ListOfSLinks &aListOfDatas ) {
   bool RetVal = true ;
+  bool RetAddLink ;
   cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
 //  MESSAGE( "GraphEditor::OutNode::LoadDatas" );
   int i ;
@@ -509,15 +512,15 @@ bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
 //           << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
 //      cout << "          " << aLink.ToNodeName.c_str() << " "
 //           << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
-    RetVal = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
-                                    aLink.ToServiceParameterName.c_str() ,
-                                    aLink.aLinkValue ) ;
+    RetAddLink = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
+                                        aLink.ToServiceParameterName.c_str() ,
+                                        aLink.aLinkValue ) ;
     delete aLinkFromNodeName ;
     delete aLinkToNodeName ;
     if ( !RetVal )
       break ;
   }
-  cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
+  cdebug_out << "GraphEditor::OutNode::LoadDatas " << RetVal << endl ;
   return RetVal ;
 }
 
@@ -540,7 +543,7 @@ bool GraphEditor::OutNode::SaveXml(const char* filename) {
 //    cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
 //    f << xml << endl ;
 //  }
-  cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
+  cdebug_out << "GraphEditor::OutNode::SaveXml " << test << endl;
   return test;
 }
 
@@ -650,6 +653,11 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode(
   GraphEditor::InNode *Nd = NULL ;
   char * aNodeName = NULLSTRING ;
   bool   GeneratedName = false ;
+//PAL9048 JR Debug : a node may not have the same name as the graph
+  bool GraphNodeSameName = false ;
+  if ( theNodeName && !strcmp( Graph()->Name() , theNodeName ) ) {
+    GraphNodeSameName = true ;
+  }
   if ( NodeKindOfNode == SUPERV::InLineNode ||
        NodeKindOfNode == SUPERV::LoopNode ||
        NodeKindOfNode == SUPERV::EndLoopNode ||
@@ -681,25 +689,36 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode(
     }
     theNodeName = NULLSTRING ;
   }
-  if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
+//PAL9048 JR Debug : a node may not have the same name as the graph
+//  if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
+  if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ||
+       Graph()->GetGraphNode( theNodeName ) || GraphNodeSameName ) {
+    cdebug << "OutNode::AddNode : '" << theNodeName << "' GraphNodeSameName "
+           << GraphNodeSameName << endl;
     aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
     strcpy( aNodeName , NodeService.ServiceName ) ;
-    if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
+//    if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
+    if ( Graph()->GetGraphNode( NodeService.ServiceName ) || GraphNodeSameName ) {
       GeneratedName = true ;
-      while ( Graph()->GetGraphNode( aNodeName ) ) {
+      while ( Graph()->GetGraphNode( aNodeName ) || GraphNodeSameName ) {
+        cdebug << "OutNode::AddNode : '" << aNodeName << "' exists or GraphNodeSameName "
+               << GraphNodeSameName << endl;
         if ( aNodeName ) {
           delete [] aNodeName ;
        }
-        int num = Graph()->GetServiceNameNumber( NodeService ) ;
+//JR 09.08.2005 Debug : folowing line does not run with OMNIORB4
+//        char * aServiceName = (CORBA::String_member ) NodeService.ServiceName ;
+        int num = Graph()->GetNewServiceInstanceNumber( (CORBA::String_member ) NodeService.ServiceName ) ;
         ostringstream astr ;
         astr << num << ends ;
-        const char * n_instance = astr.str().c_str() ;
+//        const char * n_instance = astr.str().c_str() ;
         int lname = strlen( NodeService.ServiceName ) + 1 +
-                    strlen( n_instance ) + 1 ;
+                    strlen( astr.str().c_str() ) + 1 ;
         aNodeName = new char[lname] ;
         strcpy( aNodeName , NodeService.ServiceName ) ;
         strcat( aNodeName , "_" ) ;
-        strcat( aNodeName , n_instance ) ;
+        strcat( aNodeName , astr.str().c_str() ) ;
+        GraphNodeSameName = !strcmp( Graph()->Name() , aNodeName ) ;
       }
     }
   }
@@ -732,7 +751,8 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode(
       for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
         GraphBase::InDataStreamPort * aDataStreamPort ;
         aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
-                                         my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
+//JR 17.02.2005 Memory Leak                                         my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
+                                         NodeService.ServiceinDataStreamParameter[i].Parametername ,
                                          NodeService.ServiceinDataStreamParameter[i].Parametertype ,
                                          NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
                                         SUPERV::DataStreamParameter ) ;
@@ -740,7 +760,8 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode(
       for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
         GraphBase::OutDataStreamPort * aDataStreamPort ;
         aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
-                                         my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
+//JR 17.02.2005 Memory Leak                                         my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
+                                         NodeService.ServiceoutDataStreamParameter[i].Parametername ,
                                          NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
                                          NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
                                         SUPERV::DataStreamParameter ) ;
@@ -759,8 +780,13 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode(
     cdebug << "ERROR NodeName is NULL or already exists." << endl ;
   }
 //  delete [] aNodeName ;
-  cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
   _Valid = false ;
+  if ( Nd == NULL ) {
+    cdebug_out << "GraphEditor::OutNode::AddNode : NULL" << endl;
+  }
+  else {
+    cdebug_out << "GraphEditor::OutNode::AddNode : " << Nd << " " << Nd->Name() << endl;
+  }
   return Nd ;
 }
 
@@ -903,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
@@ -931,16 +957,21 @@ bool GraphEditor::OutNode::UnValid() {
   return RetVal ;
 }
 
+//JR Optional parameter kLoopSwitch (default = true) :
+//In some cases we do not need to check the validity of loops and switchs
+//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
+//bool GraphEditor::OutNode::Valid(bool kLoopSwitch ) {
 bool GraphEditor::OutNode::Valid() {
-  if ( _Valid )
-    return true ;
-
+  bool RetVal = true ;
   cdebug_in << "GraphEditor::OutNode::Valid" << endl;
+//  if ( _Valid )
+//    return true ;
+
   _Executable = false ;
 
   if ( !Graph()->CreateService() ) {
-    cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
-    return false ;
+    cdebug << "GraphEditor::OutNode::Valid ERROR _Valid " << _Valid << endl;
+    RetVal = false ;
   }
   
   if ( Graph()->GraphMacroLevel() != 0 ) {
@@ -958,55 +989,109 @@ bool GraphEditor::OutNode::Valid() {
     Graph()->CoupledNode()->GraphEditor()->UnValid() ;
   }
 
+  Graph()->InLineServices() ;
+
+//JR 07.07.2005 PAL9342 : that code is now in Executable() method instead of Valid() method
+#if 0
   int SubStreamGraphsNumber = 0 ;
   if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
     cdebug_out << "This DataFlow is not valid." << endl ;
-    return false ;
+    RetVal = false ;
   }
   if ( Graph()->IsDataStreamNode() ) {
     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
   }
-  if ( !Graph()->ValidLoops() ) {
-    cdebug_out << "This DataFlow have not valid Loops." << endl ;
-    return false ;
-  }
-  
-//  CreateService() ;
 
-  Graph()->InLineServices() ;
+//JR Debug 24.08.2005 : InLineServices is needed for Export ==> it is executed above
+//  Graph()->InLineServices() ;
 
+  if ( kLoopSwitch ) {
+    if ( !Graph()->ValidLoops() ) {
+      cdebug_out << "This DataFlow have not valid Loops." << endl ;
+      RetVal = false ;
+    }
+    if ( !Graph()->ValidSwitchs() ) {
+      cdebug_out << "This DataFlow have not valid Switchs." << endl ;
+      RetVal = false ;
+    }
+  }
+  
   Graph()->ComputingNodes() ;
+#endif
 
-  _Valid = true ;
+  if ( !Graph()->ValidGOTO() ) { // mkr : PAL12575
+    cdebug << "Editor::OutNode::Valid This DataFlow have not valid GOTO(ValidGOTO)." << endl ;
+    RetVal = false ;
+  }
 
-  cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
-  return _Valid ;
+  if ( RetVal ) {
+    _Valid = true ;
+  }
+
+  cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl;
+  return RetVal ;
 }
 
 bool GraphEditor::OutNode::Executable() {
   cdebug_in << "GraphEditor::OutNode::Executable" << endl;
+  bool RetVal = true ;
   bool NewLink ;
 // LinkLoopNodes manage input values of LoopNodes and EndLoopNodes
   if ( Graph()->LinkLoopNodes( NewLink ) ) {
     if ( NewLink ) {
       _Valid = false ;
+      RetVal = false ;
     }
   }
   else {
-    cdebug << "This DataFlow is not executable." << endl ;
+    cdebug << "Editor::OutNode::Executable This DataFlow is not executable(LinkLoopNodes)." << endl ;
     _Executable = false ;
+    RetVal = false ;
   }
   if ( !IsValid() ) {
     Valid() ;
   }
   if ( !IsValid() ) {
-    return false ;
+    RetVal = false ;
+  }
+
+//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() )
+    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 ;
+    }
+//  }
+  
+  Graph()->ComputingNodes() ;
+
   if ( Graph()->DataServerNodes() )
     _Executable = true ;
   else {
-    cdebug << "This DataFlow is not executable." << endl ;
+    cdebug << "Editor::OutNode::Executable This DataFlow is not executable(DataServerNodes)." << endl ;
     _Executable = false ;
+    RetVal = false ;
   }
 
   if ( _Executable && Graph()->IsDataStreamNode() ) {
@@ -1016,28 +1101,37 @@ bool GraphEditor::OutNode::Executable() {
   // asv : 13.12.04 : introducing check for compatibility of linked ports' types.
   if ( !IsLinksCompatible() ) {
     _Executable = false;
+    RetVal = false ;
   }    
 
-  cdebug_out << "GraphEditor::OutNode::Executable" << endl;
-  return _Executable ;
+  //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 ;
 }
 
-const CORBA::Any *GraphEditor::OutNode::GetInData(
+//JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetInData(
+const CORBA::Any GraphEditor::OutNode::GetInData(
                               const char * ToNodeName ,
                               const char * ToParameterName ) {
 //  cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
 //            << " " << ToParameterName << endl ;
-  const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
+//JR 30.03.2005  const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
+  const CORBA::Any retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
 //  cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
   return retdata ;
 }
 
-const CORBA::Any *GraphEditor::OutNode::GetOutData(
+//JR 30.03.2005const CORBA::Any *GraphEditor::OutNode::GetOutData(
+const CORBA::Any GraphEditor::OutNode::GetOutData(
                               const char * FromNodeName ,
                               const char * FromParameterName ) {
 //  cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
 //            << " " << FromParameterName << endl ;
-  const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
+//JR 30.03.2005  const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
+  const CORBA::Any retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
 //  cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
   return retdata ;
 }
@@ -1106,18 +1200,33 @@ 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" ) ;
-        aField = Graph.createTextNode( retstr ) ;
+//PAL9133 Debug JR : accept void strings
+        QDomCDATASection aCDATA ;
+        int i ;
+        for ( i = 0 ; i < (int ) strlen( retstr ) ; i++ ) {
+          if ( retstr[ i ] != ' ' ) {
+            break ;
+         }
+        }
+        if ( i == (int ) strlen( retstr ) ) {
+          aCDATA = Graph.createCDATASection( "?" ) ;
+        }
+        else {
+          aCDATA = Graph.createCDATASection( retstr ) ;
+       }
+//        aField = Graph.createTextNode( retstr ) ;
         datavalue.appendChild( value ) ;
-        value.appendChild( aField ) ;
+//        datavalue.appendChild( value ) ;
+        value.appendChild( aCDATA ) ;
 //        MESSAGE( "ToString( string ) " << retstr );
         break ;
       }
       case CORBA::tk_double: {
-        double d;
+        CORBA::Double d;
         aLink.aLinkValue >>= d;
 //        f << Tabs << "       <value>" << d << "</value>" << endl ;
         QDomElement value = Graph.createElement( "value" ) ;
@@ -1130,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" ) ;
@@ -1139,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" ) ;
@@ -1236,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 ;
@@ -1256,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 ;
@@ -1433,6 +1550,7 @@ bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
   int i ;
   int j ;
+  const GraphBase::ListOfSLinks * Links ;
   if ( importSuperV ) {
     f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
 
@@ -1549,7 +1667,7 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
     }
   }
 
-  const GraphBase::ListOfSLinks * Links = Graph()->GetLinks() ;
+  Links = Graph()->GetLinks() ;
 //  bool intervar ;
 //  map< string , int > aMapOfOutPorts ;
   first = true ;
@@ -1688,23 +1806,45 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
  *  Returns true if all are compatible.
  */
 bool GraphEditor::OutNode::IsLinksCompatible() {
+  cdebug_in << "Editor::OutNode::IsLinksCompatible()" << endl ;
+  bool RetVal = true;
+  bool b ;
   const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
-  bool b = true;
-  for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
+  cdebug_in << "Editor::OutNode::IsLinksCompatible() " << Links->size() << " Links" << endl ;
+//  for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) {
+  for ( int i = 0 ; i < (int ) Links->size() ; i++ ) {
     GraphBase::SLink aLink = (*Links)[i];
     GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() );
     GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() );
     const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() );
     const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() );    
     b = IsCompatible( anOutPort->PortType(), anInPort->PortType() );
-    cdebug << "GraphEditor::OutNode::IsLinksCompatible:  "<<aLink.FromNodeName << "("<<aLink.FromServiceParameterName
-      <<")  -->  "<<aLink.ToNodeName<<"("<<aLink.ToServiceParameterName<<") = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
-    if ( !b )
-      MESSAGE( "Graph structure ERROR: type of port \""<<aLink.FromServiceParameterName<<"\" of node \""
-             <<aLink.FromNodeName<<"\" is not compatible with type of linked port \""
-             <<aLink.ToServiceParameterName<<"\" of node \""<<aLink.ToNodeName<<"\"" ); 
-  }
-  return b;
+    cdebug << "GraphEditor::OutNode::IsLinksCompatible:  " << aLink.FromNodeName << "( "
+           << aLink.FromServiceParameterName << " " << anOutPort->PortType()
+           << " )  -->  " << aLink.ToNodeName <<"( " << aLink.ToServiceParameterName << " "
+           << anInPort->PortType() << " ) = " << (b ? "OK" : "Not compatible (ERROR)") << endl;
+    if ( !b ) {
+      RetVal = false ;
+      MESSAGE( "Graph structure ERROR: type of port \"" << aLink.FromServiceParameterName
+               << "\" of node \"" << aLink.FromNodeName
+               << "\" is not compatible with type of linked port \""
+              << aLink.ToServiceParameterName << "\" of node \"" << aLink.ToNodeName<<"\"" ) ; 
+      ostringstream aTypeOutPortstr ;
+      aTypeOutPortstr << anOutPort->PortType() ;
+      ostringstream aTypeInPortstr ;
+      aTypeInPortstr << anInPort->PortType() ;
+      string anErrorMessage = string( "PortTypes of " ) + string( aLink.FromNodeName ) +
+                              string( "( " ) + aLink.FromServiceParameterName +
+                              string( " ) " ) + aTypeOutPortstr.str() + string( " and " ) +
+                              string( aLink.ToNodeName ) + string( "( " ) +
+                              string( aLink.ToServiceParameterName ) + 
+                              string( " ) " ) + aTypeInPortstr.str() +
+                              string( " are not compatibles.\n" ) ;
+      Graph()->SetMessages( anErrorMessage ) ;
+    }
+  }
+  cdebug_out << "Editor::OutNode::IsLinksCompatible() RetVal " << RetVal << endl ;
+  return RetVal ;
 }
 
 static const char* gSimpleTypes[] =