Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.cxx
1 //  SUPERV GraphEditor : contains classes that permit edition of graphs
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowEditor_OutNode.cxx
25 //  Module : SUPERV
26
27 using namespace std;
28 #include <sstream>
29 #include <iostream>
30 #include "DataFlowEditor_OutNode.hxx"
31 #include "DataFlowBase_EndOfLoopNode.hxx"
32 #include "DataFlowBase_EndOfSwitchNode.hxx"
33
34 // Implementation de la classe GraphEditor::Graph
35
36 GraphEditor::OutNode::OutNode() {
37 //             Graph() {
38   cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
39
40   _Imported = false ;
41   _Valid = false ;
42   _Executable = false ;
43
44   cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
45 }
46
47 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
48                                SALOME_NamingService * ptrNamingService ,
49                                const char * DataFlowName ,
50                                const char * DebugFileName ,
51                                const SUPERV::KindOfNode aKindOfNode ) {
52 //             Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
53   Set_prof_debug( ORB , DebugFileName ) ;
54   cdebug_in << "GraphEditor::OutNode::OutNode(" ;
55   if ( DataFlowName ) {
56     cdebug << DataFlowName ;
57   }
58   cdebug << ")" << endl;
59
60   if ( aKindOfNode == SUPERV::DataFlowGraph ) {
61     _StreamGraph = NULL ;
62 //    _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
63     _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName ,
64                                    _prof_debug , _fdebug ) ;
65   }
66   else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
67 //    _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
68     _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName ,
69                                                _prof_debug , _fdebug ) ;
70     _Graph = _StreamGraph ;
71   }
72   _Orb = CORBA::ORB::_duplicate( ORB ) ;
73   _Imported = false ;
74   _Valid = false ;
75   _Executable = false ;
76
77   cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
78 }
79
80 GraphEditor::OutNode::OutNode(
81                      CORBA::ORB_ptr ORB ,
82                      SALOME_NamingService * ptrNamingService ,
83                      const SALOME_ModuleCatalog::Service& DataFlowService ,
84                      const char * DataFlowComponentName ,
85                      const char * DataFlowInterfaceName ,
86                      const char * DataFlowName ,
87                      const SUPERV::KindOfNode DataFlowkind ,
88                      const SUPERV::SDate DataFlowFirstCreation ,
89                      const SUPERV::SDate DataFlowLastModification ,
90                      const char * DataFlowEditorRelease ,
91                      const char * DataFlowAuthor ,
92                      const char * DataFlowComputer ,
93                      const char * DataFlowComment ,
94                      const char * DebugFileName ) {
95 //             Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
96 //                    DataFlowInterfaceName , DataFlowName , DataFlowkind ,
97 //                    DataFlowFirstCreation , DataFlowLastModification  ,
98 //                    DataFlowEditorRelease , DataFlowAuthor ,
99 //                    DataFlowComputer , DataFlowComment , DebugFileName ) {
100   Set_prof_debug( ORB , DebugFileName ) ;
101
102   if ( DataFlowkind == SUPERV::DataFlowGraph ) {
103     _StreamGraph = NULL ;
104     _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
105                                    DataFlowInterfaceName , DataFlowName , DataFlowkind ,
106                                    DataFlowFirstCreation , DataFlowLastModification  ,
107                                    DataFlowEditorRelease , DataFlowAuthor ,
108                                    DataFlowComputer , DataFlowComment ,
109                                    _prof_debug , _fdebug ) ;
110 //                                   DataFlowComputer , DataFlowComment , DebugFileName ) ;
111   }
112   else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
113     _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
114                                                DataFlowInterfaceName , DataFlowName , DataFlowkind ,
115                                                DataFlowFirstCreation , DataFlowLastModification  ,
116                                                DataFlowEditorRelease , DataFlowAuthor ,
117                                                DataFlowComputer , DataFlowComment ,
118                                                _prof_debug , _fdebug ) ;
119 //                    DataFlowComputer , DataFlowComment , DebugFileName ) ;
120     _Graph = _StreamGraph ;
121   }
122   _Orb = CORBA::ORB::_duplicate( ORB ) ;
123   _Imported = false ;
124   _Valid = false ;
125   _Executable = false ;
126
127 } ;
128
129 GraphEditor::OutNode::~OutNode() {
130 //  delete _DataFlowNode ;
131 //  delete _DataFlowDatas ;
132 //  delete _GT ;
133 }
134
135 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
136                                            const char * DebugFileName ) {
137   _Graph_prof_debug = 0 ;
138   _prof_debug = 0 ;
139   if ( DebugFileName ) {
140     _fdebug = new ofstream( DebugFileName );
141     SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
142     MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
143   }
144 }
145
146 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) {
147   bool RetVal = false ;
148   cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << aDataFlow->Info.theName.c_str()
149             << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
150   if ( !_Imported ) {
151     RetVal = LoadInfo( aDataFlow->Info ) ;
152     _Imported = true ;
153   }
154   else if ( Graph()->IsDataStreamNode() || aDataFlow->Info.theKind == SUPERV::DataFlowGraph ) {
155     RetVal = true ;
156   }
157   cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
158
159   map< string , int > aMapOfNodes ;
160   if ( RetVal ) {
161     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
162     RetVal = LoadNodes( aMapOfNodes , aDataFlow->Nodes ) ;
163   }
164   if ( RetVal ) {
165     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
166     RetVal = LoadLinks( aMapOfNodes , aDataFlow->Links ) ;
167   }
168   if ( RetVal ) {
169     Valid() ;
170     cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
171     RetVal = LoadDatas( aMapOfNodes , aDataFlow->Datas ) ;
172   }
173   cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() << endl;
174   return RetVal ;
175 }
176
177 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
178   bool RetVal = false ;
179   GraphBase::SGraph aDataFlow ;
180   if ( myFileName == NULL ) {
181     cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
182     _Imported = true ;
183     RetVal = true ;
184   }
185   else if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) {
186     cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
187     RetVal = LoadDataFlow( &aDataFlow ) ;
188     cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
189   }
190   return RetVal ;
191
192
193 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
194   bool RetVal = false ;
195   cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
196             << endl ;
197 //  MESSAGE( "GraphEditor::OutNode::LoadDataFlow" );
198 //  ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
199 //  InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
200   if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
201     Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
202 //    Graph()->Kind( aDataFlowInfo.theKind ) ;
203     cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
204            << " Kind() " << Graph()->Kind() << endl ;
205     if ( Graph()->IsDataStreamNode() ) {
206       Graph()->Kind( SUPERV::DataStreamGraph ) ;
207       StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
208     }
209     else {
210       Graph()->Kind( SUPERV::DataFlowGraph ) ;
211     }
212     Graph()->SetService( aDataFlowInfo.theService ) ;
213     Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
214     Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
215     Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
216     Graph()->Author( aDataFlowInfo.theAuthor.c_str()  ) ;
217 //    Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
218     Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
219 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
220 //    Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
221     RetVal = true ;
222   }
223   else {
224     Graph()->Kind( aDataFlowInfo.theKind ) ;
225     cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
226            << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
227   }
228   cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
229   return RetVal ;
230 }
231
232 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
233                                      const GraphBase::ListOfNodes &aListOfNodes ) {
234   GraphEditor::InNode * anInNode ;
235   cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
236   int i ;
237   for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
238     GraphBase::SNode aNode = aListOfNodes[ i ] ;
239     const char * aNodeName = aNode.theName.c_str() ;
240     cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
241          << aNode.theListOfInDataStreams.size() << " InDataStreams "
242          << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
243          << " _prof_debug " << _prof_debug << endl ;
244     cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
245            << aNode.theListOfInDataStreams.size() << " InDataStreams "
246            << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
247            << endl ;
248     if ( aNode.theListOfFuncName.size() == 0 ) {
249       aNode.theListOfFuncName.resize( 1 ) ;
250       aNode.theListOfFuncName[ 0 ] = "" ;
251       aNode.theListOfPythonFunctions.resize( 1 ) ;
252       aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
253     }
254     if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
255       aNodeName = NULLSTRING ;
256     }
257
258     aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
259     aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
260     unsigned int j ;
261     for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
262       aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
263       aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
264       aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
265     }
266     for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
267       aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
268       aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
269       aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
270     }
271
272     anInNode = AddNode( aNode.theService ,
273                         aNode.theListOfFuncName ,
274                         aNode.theListOfPythonFunctions ,
275                         aNode.theComponentName.c_str() ,
276                         aNode.theInterfaceName.c_str() , aNodeName ,
277                         aNode.theKind ,
278                         aNode.theFirstCreation , aNode.theLastModification ,
279                         aNode.theEditorRelease.c_str() ,
280                         aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
281                         aNode.theComment.c_str() ,
282                         aNode.theCoords.theX , aNode.theCoords.theY ) ;
283     string * aNodetheName = new string( aNode.theName ) ;
284     aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
285     if ( anInNode->IsOneOfInLineNodes() ) {
286       anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
287                 _Orb , aNode.theService , anInNode->NamePtr() ,
288                 anInNode->Kind() ,
289                 _prof_debug , _fdebug ) ;
290       GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
291       GraphBase::LoopNode * aLNode = NULL ;
292       if ( aINode->IsLoopNode() ) {
293         aLNode = anInNode->LoopNode() ;
294         aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
295                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
296         aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
297                                        *aNode.theListOfPythonFunctions[ 1 ] ) ;
298         aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
299                                        *aNode.theListOfPythonFunctions[ 2 ] ) ;
300       }
301       else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
302                 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
303         aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
304                                    *aNode.theListOfPythonFunctions[ 0 ] ) ;
305       }
306     }
307
308     for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
309       GraphBase::InPort * anInPort ;
310       if ( anInNode->IsOneOfInLineNodes() ) {
311         anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
312                                                                    aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
313                                                                    aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
314                                                                    SUPERV::DataStreamParameter ) ;
315       }
316       else {
317         anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
318       }
319       ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
320                                                               aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
321                                                               aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
322     }
323     for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
324       GraphBase::OutPort * anOutPort ;
325       if ( anInNode->IsOneOfInLineNodes() ) {
326         anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
327                                                                      aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
328                                                                      aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
329                                                                      SUPERV::DataStreamParameter ) ;
330       }
331       else {
332         anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
333       }
334       ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
335     }
336     delete aNodetheName ;
337     if ( !anInNode ) {
338       return false ;
339     }
340   }
341   for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
342     GraphBase::SNode aNode = aListOfNodes[ i ] ;
343     cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
344            << aNode.theCoupledNode.c_str() << endl ;
345     anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
346     if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
347       GraphBase::GOTONode * aCoupledNode ;
348       aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ;
349       aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ; 
350     }
351   }
352   cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
353   return true ;
354 }
355
356 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
357                                      const GraphBase::ListOfLinks &aListOfLinks ) {
358   bool RetVal = true ;
359   cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
360 //  MESSAGE( "GraphEditor::OutNode::LoadLinks" );
361   int i , j ;
362   for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
363     GraphBase::SLink aLink = aListOfLinks[ i ] ;
364     string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
365     string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
366     cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
367            << aLink.FromServiceParameterName.c_str() << " ) --> "
368            << aLinkToNodeName->c_str() << "( "
369            << aLink.ToServiceParameterName.c_str() << " )" << endl ;
370     if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
371          Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
372       GraphBase::ComputingNode * aFromNode = (GraphBase::ComputingNode * ) Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) ;
373       const GraphBase::OutPort * anOutPort = aFromNode->GetOutPort( aLink.FromServiceParameterName.c_str() ) ;
374       RetVal = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
375                                  aLink.FromServiceParameterName.c_str() ,
376                                  Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
377                                  aLink.ToServiceParameterName.c_str() ,
378                                  *anOutPort->Value() ) ;
379     }
380     else {
381       RetVal = false ;
382     }
383 //                      aLink.aLinkValue ) ;
384     if ( !RetVal )
385       break ;
386     else {
387       for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
388         RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
389                                         aLink.FromServiceParameterName.c_str() ,
390                                         Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
391                                         aLink.ToServiceParameterName.c_str() ,
392                                        j + 1 ,
393                                        aLink.aListOfCoords[j].theX ,
394                                        aLink.aListOfCoords[j].theY ) ;
395         if ( !RetVal )
396           break ;
397       }
398     }
399     delete aLinkFromNodeName ;
400     delete aLinkToNodeName ;
401   }
402   cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
403   return RetVal ;
404 }
405
406 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
407                                      const GraphBase::ListOfLinks &aListOfDatas ) {
408   bool RetVal = true ;
409   cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
410 //  MESSAGE( "GraphEditor::OutNode::LoadDatas" );
411   int i ;
412   for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
413     GraphBase::SLink aLink = aListOfDatas[ i ] ;
414     if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) ) {
415       cdebug << "GraphEditor::OutNode::LoadDatas Warning "
416              << aLink.FromNodeName.c_str()
417              << " and " << aLink.ToNodeName.c_str() << " differents from " << Graph()->Name()
418              << endl ;
419     }
420     string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
421     string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
422 //      cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
423 //           << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
424 //      cout << "          " << aLink.ToNodeName.c_str() << " "
425 //           << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
426     RetVal = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
427                                     aLink.ToServiceParameterName.c_str() ,
428                                     aLink.aLinkValue ) ;
429     delete aLinkFromNodeName ;
430     delete aLinkToNodeName ;
431     if ( !RetVal )
432       break ;
433   }
434   cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
435   return RetVal ;
436 }
437
438 bool GraphEditor::OutNode::SaveXml(const char* filename) {
439   bool test;
440   cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
441   ofstream f(filename);
442   IsValid() ;
443 //  test = SaveXML( f );
444   QDomDocument Graph ;
445   test = SaveXML( Graph );
446   if ( test ) {
447     QString xml = Graph.toString() ;
448 //    cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
449     f << xml << endl ;
450   }
451   cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
452   return test;
453 }
454
455
456 bool GraphEditor::OutNode::SavePy( const char* filename ) {
457   bool test;
458   cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
459   ofstream f( filename ) ;
460   IsValid() ;
461   test = SavePY( f );
462   cdebug_out << "GraphEditor::OutNode::SavePy" << endl;
463   return test;
464 }
465
466 GraphBase::SGraph * GraphEditor::OutNode::GetDataFlow() {
467   GraphBase::SGraph * aDataFlow = new GraphBase::SGraph;
468   if ( Graph()->IsDataFlowNode() ) {
469     aDataFlow->Info = *Graph()->GetInfo() ;
470     aDataFlow->Nodes = *Graph()->GetNodes() ;
471     aDataFlow->Links = *Graph()->GetLinks( true ) ;
472     aDataFlow->Datas = *Graph()->GetDatas() ;
473   }
474   else {
475     aDataFlow->Info = *StreamGraph()->GetInfo() ;
476     aDataFlow->Nodes = *StreamGraph()->GetNodes() ;
477     aDataFlow->Links = *StreamGraph()->GetLinks( true ) ;
478     aDataFlow->Datas = *StreamGraph()->GetDatas() ;
479   }
480   return aDataFlow ;
481 }
482
483 void GraphEditor::OutNode::DateModification() {
484   time_t T = time(NULL);
485   struct tm * Tm = localtime(&T);
486   SUPERV::SDate aLastModificationDate ;
487
488   aLastModificationDate.Second = Tm->tm_sec;
489   aLastModificationDate.Minute = Tm->tm_min;
490   aLastModificationDate.Hour   = Tm->tm_hour;
491   aLastModificationDate.Day    = Tm->tm_mday;
492   aLastModificationDate.Month  = Tm->tm_mon + 1;
493   aLastModificationDate.Year   = Tm->tm_year + 1900;
494   Graph()->LastModification( aLastModificationDate ) ;
495 }
496
497 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
498                                         const int X ,
499                                         const int Y ) {
500   ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
501 }
502
503 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
504   return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
505 }
506
507 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
508   return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
509 }
510
511 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
512                       const SALOME_ModuleCatalog::Service& NodeService ,
513                       GraphBase::ListOfFuncName aFuncName ,
514                       GraphBase::ListOfPythonFunctions aPythonFunction ,
515                       const char * NodeComponentName ,
516                       const char * NodeInterfaceName ,
517                       const char * theNodeName ,
518                       const SUPERV::KindOfNode NodeKindOfNode ,
519                       const SUPERV::SDate NodeFirstCreation ,
520                       const SUPERV::SDate NodeLastModification  ,
521                       const char * NodeEditorRelease ,
522                       const char * NodeAuthor ,
523                       const char * NodeComputer ,
524                       const char * NodeComment ,
525                       const int NodeX ,
526                       const int NodeY ) {
527   cdebug_in << "GraphEditor::OutNode::AddNode( " ;
528   if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
529     cdebug << "Component('" << NodeComponentName << "') , Node('" ;
530   }
531   else {
532     cdebug << "NodeComponentName[NULL] )" << endl;
533   }
534   if ( theNodeName == NULL ) {
535     theNodeName = NULLSTRING ;
536   }
537   if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
538     cdebug << theNodeName << "' )" ;
539   }
540   else {
541     cdebug << "NodeName[NULLSTRING]' )" ;
542   }
543   cdebug << " " << NodeKindOfNode << endl ;
544   char * RetVal = NULLSTRING ;
545   GraphEditor::InNode *Nd = NULL ;
546   char * aNodeName = NULL ;
547   bool   GeneratedName = false ;
548   if ( NodeKindOfNode == SUPERV::InLineNode ||
549        NodeKindOfNode == SUPERV::LoopNode ||
550        NodeKindOfNode == SUPERV::EndLoopNode ||
551        NodeKindOfNode == SUPERV::SwitchNode ||
552        NodeKindOfNode == SUPERV::EndSwitchNode ||
553        NodeKindOfNode == SUPERV::GOTONode ) {
554     if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
555       if ( NodeKindOfNode == SUPERV::InLineNode ) {
556         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
557       }
558       else if ( NodeKindOfNode == SUPERV::LoopNode ) {
559         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
560       }
561       else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
562         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
563       }
564       else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
565         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
566       }
567       else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
568         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
569       }
570       else if ( NodeKindOfNode == SUPERV::GOTONode ) {
571         ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
572       }
573     }
574     else {
575       ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
576     }
577     theNodeName = NULLSTRING ;
578   }
579   if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
580     aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
581     strcpy( aNodeName , NodeService.ServiceName ) ;
582     if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
583       GeneratedName = true ;
584       while ( Graph()->GetGraphNode( aNodeName ) ) {
585         if ( aNodeName ) {
586           delete [] aNodeName ;
587         }
588         int num = Graph()->GetServiceNameNumber( NodeService ) ;
589         ostringstream astr ;
590         astr << num << ends ;
591         const char * n_instance = astr.str().c_str() ;
592         int lname = strlen( NodeService.ServiceName ) + 1 +
593                     strlen( n_instance ) + 1 ;
594         aNodeName = new char[lname] ;
595         strcpy( aNodeName , NodeService.ServiceName ) ;
596         strcat( aNodeName , "_" ) ;
597         strcat( aNodeName , n_instance ) ;
598       }
599     }
600   }
601   else {
602     if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
603       aNodeName = new char[ strlen( theNodeName )+1 ] ;
604       strcpy( aNodeName , theNodeName ) ;
605     }
606   }
607   if ( aNodeName != NULLSTRING ) {
608     Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
609                                   aFuncName , aPythonFunction , NodeService ,
610                                   NodeComponentName , NodeInterfaceName ,
611                                   aNodeName , NodeKindOfNode ,
612                                   NodeFirstCreation , NodeLastModification ,
613                                   NodeEditorRelease , NodeAuthor ,
614                                   NodeComputer , NodeComment , GeneratedName ,
615                                   NodeX , NodeY ,
616                                   _prof_debug , _fdebug ) ;
617 //    MESSAGE( "GraphEditor::OutNode::AddNode " << hex << (void *) Nd << dec );
618 //    if ( GraphBase::Graph::AddNode( Nd ) ) {
619
620     if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
621       unsigned int i ;
622       for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
623         GraphBase::InDataStreamPort * aDataStreamPort ;
624         aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
625                                          my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
626                                          NodeService.ServiceinDataStreamParameter[i].Parametertype ,
627                                          NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
628                                          SUPERV::DataStreamParameter ) ;
629       }
630       for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
631         GraphBase::OutDataStreamPort * aDataStreamPort ;
632         aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
633                                          my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
634                                          NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
635                                          NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
636                                          SUPERV::DataStreamParameter ) ;
637       }
638     }
639
640     if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
641       DateModification() ;
642       RetVal = Nd->Name() ;
643     }
644     else {
645       cdebug << "NodeName already exists." << endl ;
646     }
647   }
648   else {
649     cdebug << "ERROR NodeName is NULL or already exists." << endl ;
650   }
651 //  delete [] aNodeName ;
652   cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
653   _Valid = false ;
654   return Nd ;
655 }
656
657 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
658                                          const char* FromServiceParameterName ,
659                                          const char* ToNodeName ,
660                                          const char* ToServiceParameterName ,
661                                          const int nXY ,
662                                          const int* X ,
663                                          const int* Y ) {
664   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
665                                                            ToServiceParameterName ) ;
666 //  cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
667 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
668   if ( anInPort ) {
669     if ( anInPort->IsEndSwitch() ) {
670 //      cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
671 //             << " )" << endl ;
672       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
673     }
674     else {
675       return anInPort->AddCoord( nXY , X , Y ) ;
676     }
677   }
678   return false ;
679 }
680
681 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
682                                          const char* FromServiceParameterName ,
683                                          const char* ToNodeName ,
684                                          const char* ToServiceParameterName ,
685                                          const int index ,
686                                          const int X ,
687                                          const int Y ) {
688   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
689                                                            ToServiceParameterName ) ;
690 //  cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
691 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
692   if ( anInPort ) {
693     if ( anInPort->IsEndSwitch() ) {
694 //      cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
695 //             << " )" << endl ;
696       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
697     }
698     else {
699       return anInPort->AddCoord( index , X , Y ) ;
700     }
701   }
702   return false ;
703 }
704
705 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
706                                             const char* FromServiceParameterName ,
707                                             const char* ToNodeName ,
708                                             const char* ToServiceParameterName ,
709                                             const int index ,
710                                             const int X ,
711                                             const int Y ) {
712   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
713                                                            ToServiceParameterName ) ;
714 //  cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
715 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
716   if ( anInPort ) {
717     if ( anInPort->IsEndSwitch() ) {
718 //      cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
719 //             << " )" << endl ;
720       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
721     }
722     else {
723       return anInPort->ChangeCoord( index , X , Y ) ;
724     }
725   }
726   return false ;
727 }
728
729 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
730                                             const char* FromServiceParameterName ,
731                                             const char* ToNodeName ,
732                                             const char* ToServiceParameterName ,
733                                             const int index ) {
734   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
735                                                            ToServiceParameterName ) ;
736 //  cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
737 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
738   if ( anInPort ) {
739     if ( anInPort->IsEndSwitch() ) {
740 //      cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
741 //             << " )" << endl ;
742       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
743     }
744     else {
745       return anInPort->RemoveCoord( index ) ;
746     }
747   }
748   return false ;
749 }
750
751 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
752                                             const char* FromServiceParameterName ,
753                                             const char* ToNodeName ,
754                                             const char* ToServiceParameterName ) {
755   const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
756 //  cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
757 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
758   if ( anInPort ) {
759     if ( anInPort->IsEndSwitch() ) {
760 //      cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
761 //             << " )" << endl ;
762       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
763     }
764     else {
765       return anInPort->GetCoord() ;
766     }
767   }
768   return 0 ;
769 }
770
771 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
772                                          const char* FromServiceParameterName ,
773                                          const char* ToNodeName ,
774                                          const char* ToServiceParameterName ,
775                                          int *X , int *Y ) {
776   const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
777 //  cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
778 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
779   if ( anInPort ) {
780     if ( anInPort->IsEndSwitch() ) {
781 //      cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
782 //             << " )" << endl ;
783       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
784     }
785     else {
786       return anInPort->GetCoord( X , Y ) ;
787     }
788   }
789   return false ;
790 }
791
792 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
793                                          const char* FromServiceParameterName ,
794                                          const char* ToNodeName ,
795                                          const char* ToServiceParameterName ,
796                                          const int index , long &X , long &Y ) {
797   GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
798                                                            ToServiceParameterName ) ;
799 //  cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
800 //         << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
801   if ( anInPort ) {
802     if ( anInPort->IsEndSwitch() ) {
803 //      cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
804 //             << " )" << endl ;
805       return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
806     }
807     else {
808       return anInPort->GetCoord( index , X , Y ) ;
809     }
810   }
811   return false ;
812 }
813
814 bool GraphEditor::OutNode::AddInputData( const char* ToNodeName1 ,
815                                          const char* ToParameterName1 ,
816                                          const char* ToNodeName2 ,
817                                          const char* ToParameterName2 ) {
818   cdebug_in << "GraphEditor::OutNode::AddInputData" << endl;
819   bool RetVal = Graph()->AddInputData( ToNodeName1 ,
820                                                 ToParameterName1 ,
821                                                 ToNodeName2 ,
822                                                 ToParameterName2 ) ;
823   cdebug_out << "GraphEditor::OutNode::AddInputData" << endl;
824   _Valid = false ;
825   return RetVal ;
826 }
827
828 bool GraphEditor::OutNode::Valid() {
829   if ( _Valid )
830     return true ;
831
832   cdebug_in << "GraphEditor::OutNode::Valid" << endl;
833   _Executable = false ;
834
835   Graph()->CreateService() ;
836   
837   int SubStreamGraphsNumber = 0 ;
838   if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
839     cdebug << "This DataFlow is not valid." << endl ;
840     return false ;
841   }
842   if ( Graph()->IsDataStreamNode() ) {
843     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
844   }
845   
846 //  CreateService() ;
847
848   Graph()->InLineServices() ;
849
850   Graph()->ComputingNodes() ;
851
852   _Valid = true ;
853
854   cdebug_out << "GraphEditor::OutNode::Valid" << endl;
855   return _Valid ;
856 }
857
858 bool GraphEditor::OutNode::Executable() {
859   cdebug_in << "GraphEditor::OutNode::Executable" << endl;
860   bool NewLink ;
861   if ( Graph()->LinkLoopNodes( NewLink ) ) {
862     if ( NewLink ) {
863       _Valid = false ;
864     }
865   }
866   else {
867     cdebug << "This DataFlow is not executable." << endl ;
868     _Executable = false ;
869   }
870   if ( !IsValid() ) {
871     Valid() ;
872   }
873   if ( !IsValid() ) {
874     return false ;
875   }
876   if ( Graph()->DataServerNodes() )
877     _Executable = true ;
878   else {
879     cdebug << "This DataFlow is not executable." << endl ;
880     _Executable = false ;
881   }
882
883   if ( _Executable && Graph()->IsDataStreamNode() ) {
884     StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
885   }
886
887   cdebug_out << "GraphEditor::OutNode::Executable" << endl;
888   return _Executable ;
889 }
890
891 const CORBA::Any *GraphEditor::OutNode::GetInData(
892                               const char * ToNodeName ,
893                               const char * ToParameterName ) {
894 //  cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
895 //            << " " << ToParameterName << endl ;
896   const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
897 //  cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
898   return retdata ;
899 }
900
901 const CORBA::Any *GraphEditor::OutNode::GetOutData(
902                               const char * FromNodeName ,
903                               const char * FromParameterName ) {
904 //  cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
905 //            << " " << FromParameterName << endl ;
906   const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
907 //  cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
908   return retdata ;
909 }
910
911 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
912 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
913                                         GraphBase::SLink aLink ,
914                                         bool wdata ) const {
915   cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
916             << "(" << aLink.FromServiceParameterName << ") --> "
917             << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
918   QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
919   QDomText aField ;
920   if ( strlen( aLink.FromNodeName.c_str() ) ) {
921 //    f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
922 //      << "</fromnode-name>" << endl ;
923     aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
924   }
925   else {
926 //    f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
927     aField = Graph.createTextNode( "?" ) ;
928   }
929   link.appendChild( fromnodename ) ;
930   fromnodename.appendChild( aField ) ;
931
932 //  f << Tabs << "<fromserviceparameter-name>"
933 //    << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
934 //    << endl ;
935   QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
936   aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
937   link.appendChild( fromserviceparametername ) ;
938   fromserviceparametername.appendChild( aField ) ;
939
940   QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
941   if ( strlen( aLink.ToNodeName.c_str() ) ) {
942 //    f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
943 //      << "</tonode-name>" << endl ;
944     aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
945   }
946   else {
947 //    f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
948     aField = Graph.createTextNode( "?" ) ;
949   }
950   link.appendChild( tonodename ) ;
951   tonodename.appendChild( aField ) ;
952
953 //  f << Tabs << "<toserviceparameter-name>"
954 //    << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
955 //    << endl ;
956   QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
957   aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
958   link.appendChild( toserviceparametername ) ;
959   toserviceparametername.appendChild( aField ) ;
960
961   if ( wdata ) {
962 //    f << Tabs << "<data-value>" << endl ;
963     QDomElement datavalue = Graph.createElement( "data-value" ) ;
964     link.appendChild( datavalue ) ;
965 //    f << Tabs << "    <value-type>" << aLink.aLinkValue.type()->kind()
966 //      << "</value-type>" << endl ;
967     QDomElement valuetype = Graph.createElement( "value-type" ) ;
968     QString aKind ;
969     aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
970     aField = Graph.createTextNode( aKind ) ;
971     datavalue.appendChild( valuetype ) ;
972     valuetype.appendChild( aField ) ;
973     switch (aLink.aLinkValue.type()->kind()) {
974       case CORBA::tk_string: {
975         char* retstr ;
976         aLink.aLinkValue >>= retstr;
977 //        f << Tabs << "        <value>" << retstr << "</value>" << endl ;
978         QDomElement value = Graph.createElement( "value" ) ;
979         aField = Graph.createTextNode( retstr ) ;
980         datavalue.appendChild( value ) ;
981         value.appendChild( aField ) ;
982 //        MESSAGE( "ToString( string ) " << retstr );
983         break ;
984       }
985       case CORBA::tk_double: {
986         double d;
987         aLink.aLinkValue >>= d;
988 //        f << Tabs << "        <value>" << d << "</value>" << endl ;
989         QDomElement value = Graph.createElement( "value" ) ;
990         QString aKind ;
991         aKind = aKind.setNum( d ) ;
992         aField = Graph.createTextNode( aKind ) ;
993         datavalue.appendChild( value ) ;
994         value.appendChild( aField ) ;
995 //        MESSAGE( "ToString( double ) " << d );
996         break ;
997       }
998       case CORBA::tk_long: {
999         long l;
1000         aLink.aLinkValue >>= l;
1001 //        f << Tabs << "        <value>" << l << "</value>" << endl ;
1002         QDomElement value = Graph.createElement( "value" ) ;
1003         QString aKind ;
1004         aKind = aKind.setNum( l ) ;
1005         aField = Graph.createTextNode( aKind ) ;
1006         datavalue.appendChild( value ) ;
1007         value.appendChild( aField ) ;
1008 //        MESSAGE( "ToString( long ) " << l );
1009         break ;
1010       }
1011       case CORBA::tk_objref: {
1012         char* retstr ;
1013         CORBA::Object_ptr obj ;
1014         aLink.aLinkValue >>= obj ;
1015         retstr = _Orb->object_to_string(obj );
1016 //        f << Tabs << "        <value>" << retstr << "</value>" << endl ;
1017         QDomElement value = Graph.createElement( "value" ) ;
1018         aField = Graph.createTextNode( retstr ) ;
1019         datavalue.appendChild( value ) ;
1020         value.appendChild( aField ) ;
1021 //        MESSAGE( "ToString( object ) " << retstr );
1022         break ;
1023       }
1024       default: {
1025 //        f << Tabs << "        <value>?</value>" << endl ;
1026         QDomElement value = Graph.createElement( "value" ) ;
1027         aField = Graph.createTextNode( "?" ) ;
1028         datavalue.appendChild( value ) ;
1029         value.appendChild( aField ) ;
1030 //        MESSAGE( "Unknown CORBA::Any Type" );
1031         break ;
1032       }
1033     }
1034 //    f << Tabs << "</data-value>" << endl ;
1035   }
1036 //  f << Tabs << "<coord-list>" << endl ;
1037   QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1038   link.appendChild( coordlist ) ;
1039   
1040   int i ;
1041   for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1042 //    f << Tabs << "    <coord>" << endl ;
1043     QDomElement coord = Graph.createElement( "coord" ) ;
1044     coordlist.appendChild( coord ) ;
1045 //    f << Tabs << "            <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1046     QDomElement x = Graph.createElement( "x" ) ;
1047     QString ax ;
1048     ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1049     aField = Graph.createTextNode( ax ) ;
1050     coord.appendChild( x ) ;
1051     x.appendChild( aField ) ;    
1052 //    f << Tabs << "            <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1053     QDomElement y = Graph.createElement( "y" ) ;
1054     QString ay ;
1055     ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1056     aField = Graph.createTextNode( ay ) ;
1057     coord.appendChild( y ) ;
1058     y.appendChild( aField ) ;    
1059 //    f << Tabs << "    </coord>" << endl ;
1060   }
1061 //  f << Tabs << "</coord-list>" << endl ;
1062   cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1063              << "(" << aLink.FromServiceParameterName << ") --> "
1064              << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1065              << endl ;
1066   return true ;
1067 }
1068
1069 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1070                                        GraphBase::SLink aLink ,
1071                                        bool fromparam , bool toparam ,
1072                                        bool wdata ) const {
1073   if ( !wdata ) {
1074 //    if ( intervar ) {
1075 //      f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1076 //        << " = "
1077 //        << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1078 //        << aLink.FromServiceParameterName.c_str()
1079 //        << "' )" << endl ;
1080 //    }
1081     f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1082       << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1083     if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1084       f << " = " << aGraphName << ".StreamLink( " ;
1085     }
1086     else {
1087       f << " = " << aGraphName << ".Link( " ;
1088     }
1089 //    if ( !fromparam ) {
1090       f << "O" ;
1091 //    }
1092     f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1093 //    if ( !toparam ) {
1094       f << "I" ;
1095 //    }
1096     f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1097   }
1098   else {
1099     f << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1100 //      << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1101 //      << aLink.ToServiceParameterName.c_str() << "' , " ;
1102       << ".Input( " ;
1103     switch (aLink.aLinkValue.type()->kind()) {
1104       case CORBA::tk_string: {
1105         char* retstr ;
1106         aLink.aLinkValue >>= retstr;
1107         f << "'" << retstr << "'" ;
1108         break ;
1109       }
1110       case CORBA::tk_double: {
1111         double d;
1112         aLink.aLinkValue >>= d;
1113         f << d ;
1114         break ;
1115       }
1116       case CORBA::tk_long: {
1117         long l;
1118         aLink.aLinkValue >>= l;
1119         f << l ;
1120         break ;
1121       }
1122       case CORBA::tk_objref: {
1123         char* retstr ;
1124         CORBA::Object_ptr obj ;
1125         aLink.aLinkValue >>= obj ;
1126         retstr = _Orb->object_to_string(obj );
1127         f << "'" << retstr << "'" ;
1128         break ;
1129       }
1130       default: {
1131         f << "?" ;
1132 //        MESSAGE( "Unknown CORBA::Any Type" );
1133         break ;
1134       }
1135     }
1136     f << " )" << endl ;
1137   }
1138   int i ;
1139   for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1140     f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1141       << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1142       << aLink.aListOfCoords[ i ].theX << " , "
1143       << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1144   }
1145   return true ;
1146 }
1147
1148 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1149 bool GraphEditor::OutNode::SaveXML(QDomDocument & GraphQDom ) {
1150   int i ;
1151 //  f << "<?xml version='1.0' encoding='us-ascii' ?>" << endl << endl ;
1152 //  f << "<!-- XML Dataflow -->" << endl << endl ;
1153 //  f << "<!-- Dataflow information -->" << endl ;
1154   QString Dataflow("Dataflow") ;
1155   GraphQDom = QDomDocument(Dataflow) ;
1156 //  f << "<dataflow>" << endl ;
1157   QDomElement dataflow = GraphQDom.createElement( "dataflow" ) ;
1158   GraphQDom.appendChild( dataflow ) ;
1159 //  f << "      <info-list>" << endl ;
1160   QDomElement info = GraphQDom.createElement( "info-list" ) ;
1161   dataflow.appendChild( info ) ;
1162
1163 //  f << "              <node>" << endl ;
1164
1165 //  GraphBase::DataNode::SaveXML( f , "                 " , 0 , 0 ) ;
1166   Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1167
1168 //  f << "              </node>" << endl ;
1169
1170 //  f << "      </info-list>" << endl << endl ;
1171
1172 //  f << "      <node-list>" << endl ;
1173   QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1174   dataflow.appendChild( nodelist ) ;
1175   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1176 //      f << "          <node>" << endl ;
1177       if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1178 //        ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1179 //                    "                 " ,
1180         ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1181                     Graph()->GraphNodes( i )->XCoordinate() ,
1182                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1183       }
1184       else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1185 //        ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1186 //                    "                 " ,
1187         ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1188                     Graph()->GraphNodes( i )->XCoordinate() ,
1189                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1190       }
1191       else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1192 //        ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1193 //                    "                 " ,
1194         ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1195                     Graph()->GraphNodes( i )->XCoordinate() ,
1196                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1197       }
1198       else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1199 //        ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1200 //                    "                 " ,
1201         ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1202                     Graph()->GraphNodes( i )->XCoordinate() ,
1203                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1204       }
1205       else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1206 //        ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1207 //                    "                 " ,
1208         ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1209                     Graph()->GraphNodes( i )->XCoordinate() ,
1210                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1211       }
1212       else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1213 //        ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1214 //                    "                 " ,
1215         ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1216                     Graph()->GraphNodes( i )->XCoordinate() ,
1217                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1218       }
1219       else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1220 //        ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1221 //                    "                 " ,
1222         ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1223                     Graph()->GraphNodes( i )->XCoordinate() ,
1224                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1225       }
1226       else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1227 //        ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1228 //                    "                 " ,
1229         ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1230                     Graph()->GraphNodes( i )->XCoordinate() ,
1231                     Graph()->GraphNodes( i )->YCoordinate() ) ;
1232       }
1233 //      f << "          </node>" << endl ;
1234 //    }
1235   }
1236 //  f << "      </node-list>" << endl << endl ;
1237
1238 //  f << "      <link-list>" << endl ;
1239   QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1240   dataflow.appendChild( linklist ) ;
1241   const GraphBase::ListOfLinks * Links = Graph()->GetLinks( true ) ;
1242   for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1243 //    f << "            <link>" << endl ;
1244     QDomElement link = GraphQDom.createElement( "link" ) ;
1245     linklist.appendChild( link ) ;
1246 //    LinkSaveXML( f , "                        " , (*Links)[ i ] , false ) ;
1247     LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1248 //    f << "            </link>" << endl ;
1249   }
1250 //  f << "      </link-list>" << endl << endl ;
1251
1252 //  f << "      <data-list>" << endl ;
1253   QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1254   dataflow.appendChild( datalist ) ;
1255   const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ;
1256   for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1257 //    f << "            <data>" << endl ;
1258     QDomElement data = GraphQDom.createElement( "data" ) ;
1259     datalist.appendChild( data ) ;
1260 //    LinkSaveXML( f , "                        " , (*Datas)[ i ] , true ) ;
1261     LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1262 //    f << "            </data>" << endl ;
1263   }
1264 //#if 0
1265 //  const GraphEditor::OutNode * aDataNode = (GraphEditor::OutNode *) this ;
1266 //  if ( aDataNode ) {
1267 //    int i ;
1268 //    for ( i = 0 ; i < aDataNode->GetNodeOutPortsSize() ; i++ ) {
1269 //      const GraphBase::InPort *aLink = aDataNode->GetNodeOutPort(i)->GetLink() ;
1270 //      if ( aLink ) {
1271 //        f << "                <data>" << endl ;
1272 //        aLink->SaveXML( f , "                 " ) ;
1273 //        f << "                </data>" << endl ;
1274 //      }
1275 //    }
1276 //    for ( i = 0 ; i < aDataNode->GetNodeInPortsSize() ; i++ ) {
1277 //      const GraphBase::InPort *aLink = aDataNode->GetNodeInPort(i)->GetLink() ;
1278 //      if ( aLink ) {
1279 //        f << "                <data>" << endl ;
1280 //        aLink->SaveXML( f , "                 " ) ;
1281 //        f << "                </data>" << endl ;
1282 //      }
1283 //    }
1284 //  }
1285 //#endif
1286
1287 #if 0
1288   f << "        </data-list>" << endl << endl ;
1289   f << "</dataflow>" << endl ;
1290 #endif
1291
1292   return true ;
1293 }
1294
1295 bool GraphEditor::OutNode::SavePY( ostream & f ) {
1296   int i ;
1297   int j ;
1298   f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1299
1300   f << "from SuperV import *" << endl ;
1301
1302   f << "# Graph creation " << endl ;
1303   Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1304
1305   f << endl << "# Creation of Factory Nodes" << endl ;
1306   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1307     if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1308       f << endl ;
1309       ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1310                 Graph()->GraphNodes( i )->XCoordinate() ,
1311                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1312     }
1313   }
1314
1315   bool first = true ;
1316   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1317     if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1318       if ( first ) {
1319         f << endl << "# Creation of Computing Nodes" << endl ;
1320         first = false ;
1321       }
1322       else {
1323         f << endl ;
1324       }
1325       ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1326                 Graph()->GraphNodes( i )->XCoordinate() ,
1327                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1328     }
1329   }
1330
1331   first = true ;
1332   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1333     if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1334       if ( first ) {
1335         f << endl << "# Creation of InLine Nodes" << endl ;
1336         first = false ;
1337       }
1338       else {
1339         f << endl ;
1340       }
1341       ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1342                 Graph()->GraphNodes( i )->XCoordinate() ,
1343                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1344     }
1345   }
1346
1347   first = true ;
1348   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1349     if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1350       if ( first ) {
1351         f << endl << "# Creation of Loop Nodes" << endl ;
1352         first = false ;
1353       }
1354       else {
1355         f << endl ;
1356       }
1357       ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1358                 Graph()->GraphNodes( i )->XCoordinate() ,
1359                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1360     }
1361   }
1362
1363   first = true ;
1364   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1365     if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1366       if ( first ) {
1367         f << endl << "# Creation of Switch Nodes" << endl ;
1368         first = false ;
1369       }
1370       else {
1371         f << endl ;
1372       }
1373       ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1374                 Graph()->GraphNodes( i )->XCoordinate() ,
1375                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1376     }
1377   }
1378
1379   first = true ;
1380   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1381     if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1382       if ( first ) {
1383         f << endl << "# Creation of GOTO Nodes" << endl ;
1384         first = false ;
1385       }
1386       else {
1387         f << endl ;
1388       }
1389       ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1390                 Graph()->GraphNodes( i )->XCoordinate() ,
1391                 Graph()->GraphNodes( i )->YCoordinate() ) ;
1392     }
1393   }
1394
1395   const GraphBase::ListOfLinks * Links = Graph()->GetLinks() ;
1396 //  bool intervar ;
1397 //  map< string , int > aMapOfOutPorts ;
1398   first = true ;
1399   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1400     for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1401       if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1402         if ( first ) {
1403           f << endl
1404             << "# Creation of Links"
1405             << endl ;
1406           first = false ;
1407         }
1408         else {
1409           f << endl ;
1410         }
1411 //        char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1412 //                                     strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1413 //        strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1414 //        strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1415 //        if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1416 //          aMapOfOutPorts[ NodePort ] = j + 1 ;
1417 //          intervar = true ;
1418 //        }
1419 //        else {
1420 //          intervar = false ;
1421 //        }
1422         bool fromparam = false ;
1423         if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1424           fromparam = true ;
1425         }
1426         bool toparam = false ;
1427         if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1428           toparam = true ;
1429         }
1430         LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1431 //        delete [] NodePort ;
1432       }
1433     }
1434   }
1435
1436   const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ;
1437   first = true ;
1438   for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1439     if ( first ) {
1440       f << endl << "# Input datas" << endl ;
1441       first = false ;
1442     }
1443     bool fromparam = true ;
1444     bool toparam = true ;
1445     LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1446   }
1447
1448   first = true ;
1449   const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1450   for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1451     string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1452     const char * aParam = _aParam.c_str() ;
1453     char * aNodeName ;
1454     char * aPortName ;
1455     int j ;
1456     for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1457       if ( aParam[ j ] == '\\' ) {
1458         aNodeName = new char[ j+1 ] ;
1459         strncpy( aNodeName , aParam , j ) ;
1460         aNodeName[ j ] = '\0' ;
1461         aPortName = new char[ strlen( aParam ) - j ] ;
1462         strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1463         break ;
1464       }
1465     }
1466     const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1467     if ( !anInPort->IsDataConnected() ) {
1468       if ( first ) {
1469         f << endl << "# Input Ports of the graph" << endl ;
1470         first = false ;
1471       }
1472       f << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1473         << aPortName << "' )" << endl ;
1474     }
1475     delete [] aNodeName ;
1476     delete [] aPortName ;
1477   }
1478
1479   f << endl << "# Output Ports of the graph" << endl ;
1480   const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1481   for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1482     string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1483     const char * aParam = _aParam.c_str() ;
1484     char * aNodeName ;
1485     char * aPortName ;
1486     int j ;
1487     for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1488       if ( aParam[ j ] == '\\' ) {
1489         aNodeName = new char[ j+1 ] ;
1490         strncpy( aNodeName , aParam , j ) ;
1491         aNodeName[ j ] = '\0' ;
1492         aPortName = new char[ strlen( aParam ) - j ] ;
1493         strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1494         break ;
1495       }
1496     }
1497     f << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1498       << aPortName << "' )" << endl ;
1499     delete [] aNodeName ;
1500     delete [] aPortName ;
1501   }
1502   return true ;
1503 }
1504
1505
1506
1507 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1508   f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1509   f << endl ;
1510
1511   f << "  Nodes : " << (G.Graph())->GraphNodesSize() << " node" 
1512     << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1513   
1514   int i ;
1515   for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1516     f
1517 //      << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1518       << (G.Graph())->GraphNodes( i ) << endl;
1519   }
1520
1521   f << "  Links : " << endl ;
1522   for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1523     (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1524   }
1525
1526   f << "  Datas : " << endl ;
1527   (G.Graph())->ListDatas( f ) ;
1528
1529   f << "DataFlow " << (G.Graph())->Name() << " is " ;
1530   if ( G.IsNotValid() )
1531     f << "not " ;
1532   f << "valid and is " ;
1533   if ( G.IsNotExecutable() )
1534     f << "not " ;
1535   f << "executable." << endl ;
1536
1537   f << endl ;
1538   
1539   return f;
1540 }
1541
1542 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1543 {
1544 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1545
1546   fOut  << D.Day << "/" 
1547         << D.Month << "/" 
1548         << D.Year << " - " 
1549         << D.Hour << ":" 
1550         << D.Minute <<  ":"  
1551         << D.Second;
1552
1553 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
1554   return fOut;
1555 }
1556
1557
1558
1559
1560
1561
1562
1563