1 // SUPERV GraphEditor : contains classes that permit edition of graphs
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowEditor_OutNode.cxx
30 #include "DataFlowEditor_DataFlow.hxx"
31 #include "DataFlowEditor_OutNode.hxx"
32 #include "DataFlowBase_EndOfLoopNode.hxx"
33 #include "DataFlowBase_EndOfSwitchNode.hxx"
35 //map< string , GraphBase::Graph * > GraphEditor::OutNode::_MapOfGraphs;
36 map< string , int > _MapOfGraphNames;
38 string GraphInstanceName( const char * aGraphName ) {
39 int GraphInstanceNumber = _MapOfGraphNames[ aGraphName ] ;
40 if ( GraphInstanceNumber ) {
41 _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
44 GraphInstanceNumber = 0 ;
45 _MapOfGraphNames[ aGraphName ] = GraphInstanceNumber + 1 ;
47 string theGraphInstanceName = string( aGraphName ) ;
48 if ( GraphInstanceNumber ) {
49 theGraphInstanceName += "_" ;
51 astr << GraphInstanceNumber ;
52 theGraphInstanceName += astr.str() ;
54 return theGraphInstanceName ;
58 // Implementation de la classe GraphEditor::Graph
60 GraphEditor::OutNode::OutNode() {
62 cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
69 cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
72 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
73 SALOME_NamingService * ptrNamingService ,
74 const char * DataFlowName ,
75 const char * DebugFileName ,
76 const SUPERV::KindOfNode aKindOfNode ) {
77 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
79 Set_prof_debug( ORB , DebugFileName ) ;
80 cdebug_in << "GraphEditor::OutNode::OutNode(" ;
82 cdebug << DataFlowName ;
84 cdebug << ")" << endl;
86 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
88 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
89 _prof_debug , _fdebug ) ;
90 // MapGraph( _Graph , _Graph->Name() ) ;
92 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
93 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
94 _prof_debug , _fdebug ) ;
95 _Graph = _StreamGraph ;
96 // MapGraph( _Graph , _Graph->Name() ) ;
98 _Orb = CORBA::ORB::_duplicate( ORB ) ;
101 _Executable = false ;
103 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
106 GraphEditor::OutNode::OutNode(
108 SALOME_NamingService * ptrNamingService ,
109 const SALOME_ModuleCatalog::Service& DataFlowService ,
110 const char * DataFlowComponentName ,
111 const char * DataFlowInterfaceName ,
112 const char * DataFlowName ,
113 const SUPERV::KindOfNode DataFlowkind ,
114 const SUPERV::SDate DataFlowFirstCreation ,
115 const SUPERV::SDate DataFlowLastModification ,
116 const char * DataFlowEditorRelease ,
117 const char * DataFlowAuthor ,
118 const char * DataFlowComputer ,
119 const char * DataFlowComment ,
120 const char * DebugFileName ) {
122 Set_prof_debug( ORB , DebugFileName ) ;
124 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
125 _StreamGraph = NULL ;
126 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
127 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
128 DataFlowFirstCreation , DataFlowLastModification ,
129 DataFlowEditorRelease , DataFlowAuthor ,
130 DataFlowComputer , DataFlowComment ,
131 _prof_debug , _fdebug ) ;
132 // MapGraph( _Graph , _Graph->Name() ) ;
134 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
135 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
136 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
137 DataFlowFirstCreation , DataFlowLastModification ,
138 DataFlowEditorRelease , DataFlowAuthor ,
139 DataFlowComputer , DataFlowComment ,
140 _prof_debug , _fdebug ) ;
141 _Graph = _StreamGraph ;
142 // MapGraph( _Graph , _Graph->Name() ) ;
144 _Orb = CORBA::ORB::_duplicate( ORB ) ;
147 _Executable = false ;
151 GraphEditor::OutNode::~OutNode() {
152 // EraseGraph( Graph->Name() ) ;
153 // delete _DataFlowNode ;
154 // delete _DataFlowDatas ;
158 bool GraphEditor::OutNode::Name( const char * aName ) {
159 bool RetVal = false ;
160 // if ( !GraphName( aName ) ) {
161 // char * aGraphName = Graph()->Name() ;
162 RetVal = Graph()->Name( aName ) ;
164 // EraseGraph( aGraphName ) ;
165 // MapGraph( Graph() , aName ) ;
171 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
172 const char * DebugFileName ) {
173 _Graph_prof_debug = 0 ;
175 if ( DebugFileName ) {
176 _fdebug = new ofstream( DebugFileName );
177 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
178 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
182 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
183 bool RetVal = false ;
184 cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << (*aDataFlow).Info.theName.c_str()
185 << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
187 RetVal = LoadInfo( (*aDataFlow).Info ) ;
190 else if ( Graph()->IsDataStreamNode() || (*aDataFlow).Info.theKind == SUPERV::DataFlowGraph ) {
193 cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
195 map< string , int > aMapOfNodes ;
197 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
198 RetVal = LoadNodes( aMapOfNodes , (*aDataFlow).Nodes ) ;
201 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
202 RetVal = LoadLinks( aMapOfNodes , (*aDataFlow).Links ) ;
206 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
207 RetVal = LoadDatas( aMapOfNodes , (*aDataFlow).Datas ) ;
209 cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() << endl;
213 bool GraphEditor::OutNode::LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) {
214 bool RetVal = false ;
215 // GraphBase::ListOfSGraphs aListOfDataFlows ;
216 if ( myFileName == NULL ) {
217 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
219 char * aDataFlowName = Graph()->Name() ;
220 // Name( Graph()->Name() ) ;
221 Name( GraphInstanceName( Graph()->Name() ).c_str() ) ;
222 // MapGraph( Graph() , Graph()->Name() ) ;
223 cdebug << "GraphEditor::OutNode::LoadXml() " << aDataFlowName << " --> " << Graph()->Name() << endl;
227 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
228 RetVal = Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ;
229 // RetVal = LoadDataFlows( &aListOfDataFlows ) ;
230 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << " " << aListOfDataFlows.size()
231 << " Graphs" << endl;
237 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
238 bool RetVal = false ;
239 GraphBase::ListOfSGraphs aListOfDataFlows ;
240 if ( myFileName == NULL ) {
241 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
245 else if ( Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ) {
246 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
247 RetVal = LoadDataFlows( &aListOfDataFlows ) ;
248 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
254 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
255 bool RetVal = false ;
256 cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
258 // MESSAGE( "GraphEditor::OutNode::LoadInfo" );
259 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
260 // InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
261 if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
262 char * aDataFlowName = Graph()->Name() ;
263 // Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
264 Graph()->Name( GraphInstanceName( aDataFlowInfo.theName.c_str() ).c_str() ) ;
265 // MapGraph( Graph() , Graph()->Name() ) ;
266 cdebug << "GraphEditor::OutNode::LoadInfo " << aDataFlowName << " --> " << Graph()->Name()
267 << " aDataFlowInfo.Kind " << aDataFlowInfo.theKind << " Kind() " << Graph()->Kind() << endl ;
268 if ( Graph()->IsDataStreamNode() ) {
269 Graph()->Kind( SUPERV::DataStreamGraph ) ;
270 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
273 Graph()->Kind( SUPERV::DataFlowGraph ) ;
275 Graph()->SetService( aDataFlowInfo.theService ) ;
276 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
277 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
278 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
279 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
280 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
281 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
282 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
283 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
287 Graph()->Kind( aDataFlowInfo.theKind ) ;
288 cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
289 << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
291 cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
295 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
296 const GraphBase::ListOfSNodes &aListOfNodes ) {
297 GraphEditor::InNode * anInNode ;
298 cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
300 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
301 GraphBase::SNode aNode = aListOfNodes[ i ] ;
302 const char * aNodeName = aNode.theName.c_str() ;
303 // cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
304 // << aNode.theService.ServiceinParameter.length() << " InParameters "
305 // << aNode.theService.ServiceoutParameter.length() << " OutParameters "
306 // << aNode.theListOfInDataStreams.size() << " InDataStreams "
307 // << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
308 // << " _prof_debug " << _prof_debug << endl ;
309 cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
310 << aNode.theService.ServiceinParameter.length() << " InParameters "
311 << aNode.theService.ServiceoutParameter.length() << " OutParameters "
312 << aNode.theListOfInDataStreams.size() << " InDataStreams "
313 << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
315 if ( aNode.theListOfFuncName.size() == 0 ) {
316 aNode.theListOfFuncName.resize( 1 ) ;
317 aNode.theListOfFuncName[ 0 ] = "" ;
318 aNode.theListOfPythonFunctions.resize( 1 ) ;
319 aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
321 if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
322 aNodeName = NULLSTRING ;
325 aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
326 aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
328 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
329 aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
330 aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
331 aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
333 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
334 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
335 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
336 aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
339 anInNode = AddNode( aNode.theService ,
340 aNode.theListOfFuncName ,
341 aNode.theListOfPythonFunctions ,
342 aNode.theComponentName.c_str() ,
343 aNode.theInterfaceName.c_str() , aNodeName ,
345 aNode.theFirstCreation , aNode.theLastModification ,
346 aNode.theEditorRelease.c_str() ,
347 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
348 aNode.theComment.c_str() ,
349 aNode.theCoords.theX , aNode.theCoords.theY ) ;
350 string * aNodetheName = new string( aNode.theName ) ;
351 aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
352 if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
353 anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
354 _Orb , aNode.theService , anInNode->NamePtr() ,
356 _prof_debug , _fdebug ) ;
357 GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
358 GraphBase::LoopNode * aLNode = NULL ;
359 if ( aINode->IsLoopNode() ) {
360 aLNode = anInNode->LoopNode() ;
361 aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
362 *aNode.theListOfPythonFunctions[ 0 ] ) ;
363 aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
364 *aNode.theListOfPythonFunctions[ 1 ] ) ;
365 aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
366 *aNode.theListOfPythonFunctions[ 2 ] ) ;
368 else if ( aINode->IsMacroNode() || aINode->IsInLineNode() || aINode->IsGOTONode() ||
369 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
370 aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
371 *aNode.theListOfPythonFunctions[ 0 ] ) ;
375 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
376 GraphBase::InPort * anInPort ;
377 if ( anInNode->IsOneOfInLineNodes() ) {
378 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
379 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
380 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
381 SUPERV::DataStreamParameter ) ;
384 anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
386 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
387 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
388 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
390 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
391 GraphBase::OutPort * anOutPort ;
392 if ( anInNode->IsOneOfInLineNodes() ) {
393 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
394 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
395 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
396 SUPERV::DataStreamParameter ) ;
399 anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
401 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
403 delete aNodetheName ;
409 // setting coupled pairs of nodes: Loop-EndLoop, Switch-EndSwitch, InLine-GOTO, MacroNode-Graph
410 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
411 GraphBase::SNode aNode = aListOfNodes[ i ] ;
412 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
413 << aNode.theCoupledNode.c_str() << endl ;
414 anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aMapOfNodes[ aNode.theName.c_str() ] )->GetInNode() ;
416 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
417 GraphBase::GOTONode * aGOTONode;
418 aGOTONode = (GraphBase::GOTONode * ) anInNode->ComputingNode() ;
420 // asv : 25.10.04 : if aNode is a MacroNode, then its coupled node (another Graph) is NOT in aMapOfNodes
421 // and we must couple MacroNode only with name to its subgraph
422 if ( aGOTONode->IsMacroNode() ) {
423 cdebug << "GraphEditor::OutNode::LoadNodes MacroNode " << aNode.theName.c_str()
424 << " is Coupled ONLY WITH NAME to its subgraph " << aNode.theCoupledNode.c_str() << endl;
425 aGOTONode->CoupledNodeName( aNode.theCoupledNode.c_str() ) ;
427 else { // coupling Loop-EndLoop, Switch-EndSwitch, InLine-GOTO
428 // asv : fix for 6822 : using map because if aNode's name is the same as some existing node's name
429 // aMap will give the correct index any way (aMap has already a different name for aNode, SNode still has old name)
430 int aCoupledNodeIndex = aMapOfNodes[ aNode.theCoupledNode.c_str() ] ;
431 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theCoupledNode.c_str()
432 << " index " << aCoupledNodeIndex << endl ;
433 GraphBase::GOTONode * aCoupledNode ;
434 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aCoupledNodeIndex ) ;
435 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str()
436 << " is now Coupled to " << aNode.theCoupledNode.c_str() << endl ;
437 aGOTONode->CoupledNode( aCoupledNode ) ;
441 cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
445 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
446 const GraphBase::ListOfSLinks &aListOfLinks ) {
448 cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
449 // MESSAGE( "GraphEditor::OutNode::LoadLinks" );
451 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
452 GraphBase::SLink aLink = aListOfLinks[ i ] ;
453 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
454 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
455 cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
456 << aLink.FromServiceParameterName.c_str() << " ) --> "
457 << aLinkToNodeName->c_str() << "( "
458 << aLink.ToServiceParameterName.c_str() << " )" << endl ;
459 if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
460 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
461 // GraphBase::ComputingNode * aFromNode = (GraphBase::ComputingNode * ) Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) ;
462 // const GraphBase::OutPort * anOutPort = aFromNode->GetOutPort( aLink.FromServiceParameterName.c_str() ) ;
463 RetVal = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
464 aLink.FromServiceParameterName.c_str() ,
465 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
466 aLink.ToServiceParameterName.c_str() ) ;
467 // , *anOutPort->Value() ) ;
472 // aLink.aLinkValue ) ;
476 for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
477 RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
478 aLink.FromServiceParameterName.c_str() ,
479 Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
480 aLink.ToServiceParameterName.c_str() ,
482 aLink.aListOfCoords[j].theX ,
483 aLink.aListOfCoords[j].theY ) ;
488 delete aLinkFromNodeName ;
489 delete aLinkToNodeName ;
491 cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
495 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
496 const GraphBase::ListOfSLinks &aListOfDatas ) {
498 cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
499 // MESSAGE( "GraphEditor::OutNode::LoadDatas" );
501 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
502 GraphBase::SLink aLink = aListOfDatas[ i ] ;
503 cdebug << "OutNode::LoadDatas " << i << aLink.FromNodeName.c_str() << "(" << aLink.FromServiceParameterName
504 << ") --> " << aLink.ToNodeName.c_str() << "(" << aLink.ToServiceParameterName << ") CORBA::tk_xxx "
505 << aLink.aLinkValue.type()->kind() << endl ;
506 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
507 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
508 // cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
509 // << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
510 // cout << " " << aLink.ToNodeName.c_str() << " "
511 // << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
512 RetVal = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
513 aLink.ToServiceParameterName.c_str() ,
515 delete aLinkFromNodeName ;
516 delete aLinkToNodeName ;
520 cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
524 bool GraphEditor::OutNode::SaveXml(const char* filename) {
526 cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
527 ofstream f(filename);
529 QDomDocument DomGraph ;
530 QDomElement Domsupergraph ;
531 cdebug << "OutNode::SaveXML("<< filename << ") ---> OutNode::SaveXML( ostream & f , QDomDocument & , true "
532 << " , QDomElement & ) " << Graph()->Name() << endl ;
533 test = SaveXML( f , DomGraph , true , Domsupergraph );
534 QString xml = DomGraph.toString() ;
537 cdebug << "OutNode::SaveXML("<< filename << ") done" << endl ;
539 // QString xml = Graph.toString() ;
540 // cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
541 // f << xml << endl ;
543 cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
548 bool GraphEditor::OutNode::SavePy( const char* filename ) {
550 cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
551 ofstream f( filename ) ;
553 test = SavePY( f , true );
554 f << endl << Graph()->Name() << " = Def" << Graph()->Name() << "()" << endl ;
555 cdebug_out << "GraphEditor::OutNode::SavePy" << endl;
559 GraphBase::ListOfSGraphs * GraphEditor::OutNode::GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
560 // GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
561 int index = aListOfDataFlows->size() ;
562 aListOfDataFlows->resize( index + 1 ) ;
563 if ( Graph()->IsDataFlowNode() ) {
564 (*aListOfDataFlows)[ index ].Info = *Graph()->GetInfo() ;
565 (*aListOfDataFlows)[ index ].Nodes = *Graph()->GetNodes() ;
566 (*aListOfDataFlows)[ index ].Links = *Graph()->GetLinks( true ) ;
567 (*aListOfDataFlows)[ index ].Datas = *Graph()->GetDatas() ;
570 (*aListOfDataFlows)[ index ].Info = *StreamGraph()->GetInfo() ;
571 (*aListOfDataFlows)[ index ].Nodes = *StreamGraph()->GetNodes() ;
572 (*aListOfDataFlows)[ index ].Links = *StreamGraph()->GetLinks( true ) ;
573 (*aListOfDataFlows)[ index ].Datas = *StreamGraph()->GetDatas() ;
576 for ( i = 0 ; i < (int ) (*aListOfDataFlows)[ index ].Nodes.size() ; i++ ) {
577 const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( (*aListOfDataFlows)[ index ].Nodes[i].theName.c_str() ) ;
578 if ( aNode->IsMacroNode() ) {
579 // string aCoupledNodeName = (*aListOfDataFlows)[ index ].Nodes[i].theCoupledNode ;
580 GraphBase::Graph * aGraph = (GraphBase::Graph * ) ((GraphBase::GOTONode * ) aNode )->CoupledNode() ;
581 // GraphBase::Graph * aGraph = MapGraph( aCoupledNodeName.c_str() ) ;
582 aGraph->GraphEditor()->GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
585 return aListOfDataFlows ;
588 void GraphEditor::OutNode::DateModification() {
589 time_t T = time(NULL);
590 struct tm * Tm = localtime(&T);
591 SUPERV::SDate aLastModificationDate ;
593 aLastModificationDate.Second = Tm->tm_sec;
594 aLastModificationDate.Minute = Tm->tm_min;
595 aLastModificationDate.Hour = Tm->tm_hour;
596 aLastModificationDate.Day = Tm->tm_mday;
597 aLastModificationDate.Month = Tm->tm_mon + 1;
598 aLastModificationDate.Year = Tm->tm_year + 1900;
599 Graph()->LastModification( aLastModificationDate ) ;
602 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
605 ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
608 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
609 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
612 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
613 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
616 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
617 const SALOME_ModuleCatalog::Service& NodeService ,
618 GraphBase::ListOfFuncName aFuncName ,
619 GraphBase::ListOfPythonFunctions aPythonFunction ,
620 const char * NodeComponentName ,
621 const char * NodeInterfaceName ,
622 const char * theNodeName ,
623 const SUPERV::KindOfNode NodeKindOfNode ,
624 const SUPERV::SDate NodeFirstCreation ,
625 const SUPERV::SDate NodeLastModification ,
626 const char * NodeEditorRelease ,
627 const char * NodeAuthor ,
628 const char * NodeComputer ,
629 const char * NodeComment ,
632 cdebug_in << "GraphEditor::OutNode::AddNode( " ;
633 if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
634 cdebug << "Component('" << NodeComponentName << "') , Node('" ;
637 cdebug << "NodeComponentName[NULL] )" << endl;
639 if ( theNodeName == NULL ) {
640 theNodeName = NULLSTRING ;
642 if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
643 cdebug << theNodeName << "' )" ;
646 cdebug << "NodeName[NULLSTRING]' )" ;
648 cdebug << " " << NodeKindOfNode << endl ;
649 char * RetVal = NULLSTRING ;
650 GraphEditor::InNode *Nd = NULL ;
651 char * aNodeName = NULLSTRING ;
652 bool GeneratedName = false ;
653 if ( NodeKindOfNode == SUPERV::InLineNode ||
654 NodeKindOfNode == SUPERV::LoopNode ||
655 NodeKindOfNode == SUPERV::EndLoopNode ||
656 NodeKindOfNode == SUPERV::SwitchNode ||
657 NodeKindOfNode == SUPERV::EndSwitchNode ||
658 NodeKindOfNode == SUPERV::GOTONode ) {
659 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
660 if ( NodeKindOfNode == SUPERV::InLineNode ) {
661 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
663 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
664 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
666 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
667 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
669 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
670 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
672 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
673 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
675 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
676 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
680 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
682 theNodeName = NULLSTRING ;
684 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 || Graph()->GetGraphNode( theNodeName ) ) {
685 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
686 strcpy( aNodeName , NodeService.ServiceName ) ;
687 if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
688 GeneratedName = true ;
689 while ( Graph()->GetGraphNode( aNodeName ) ) {
691 delete [] aNodeName ;
693 int num = Graph()->GetServiceNameNumber( NodeService ) ;
695 astr << num << ends ;
696 const char * n_instance = astr.str().c_str() ;
697 int lname = strlen( NodeService.ServiceName ) + 1 +
698 strlen( n_instance ) + 1 ;
699 aNodeName = new char[lname] ;
700 strcpy( aNodeName , NodeService.ServiceName ) ;
701 strcat( aNodeName , "_" ) ;
702 strcat( aNodeName , n_instance ) ;
707 if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
708 aNodeName = new char[ strlen( theNodeName )+1 ] ;
709 strcpy( aNodeName , theNodeName ) ;
712 aNodeName = NULLSTRING ;
715 if ( aNodeName != NULLSTRING ) {
716 Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
717 aFuncName , aPythonFunction , NodeService ,
718 NodeComponentName , NodeInterfaceName ,
719 aNodeName , NodeKindOfNode ,
720 NodeFirstCreation , NodeLastModification ,
721 NodeEditorRelease , NodeAuthor ,
722 NodeComputer , NodeComment , GeneratedName ,
724 _prof_debug , _fdebug ) ;
726 // asv: 28.09.04 fix for 6621
727 //if ( Nd->IsMacroNode() )
728 // MapGraph( Nd->GraphMacroNode(), aNodeName );
730 if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
732 for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
733 GraphBase::InDataStreamPort * aDataStreamPort ;
734 aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
735 my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
736 NodeService.ServiceinDataStreamParameter[i].Parametertype ,
737 NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
738 SUPERV::DataStreamParameter ) ;
740 for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
741 GraphBase::OutDataStreamPort * aDataStreamPort ;
742 aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
743 my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
744 NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
745 NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
746 SUPERV::DataStreamParameter ) ;
750 if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
752 RetVal = Nd->Name() ;
755 cdebug << "NodeName already exists." << endl ;
759 cdebug << "ERROR NodeName is NULL or already exists." << endl ;
761 // delete [] aNodeName ;
762 cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
767 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
768 const char* FromServiceParameterName ,
769 const char* ToNodeName ,
770 const char* ToServiceParameterName ,
774 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
775 ToServiceParameterName ) ;
776 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
777 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
779 if ( anInPort->IsEndSwitch() ) {
780 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
782 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
785 return anInPort->AddCoord( nXY , X , Y ) ;
791 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
792 const char* FromServiceParameterName ,
793 const char* ToNodeName ,
794 const char* ToServiceParameterName ,
798 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
799 ToServiceParameterName ) ;
800 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
801 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
803 if ( anInPort->IsEndSwitch() ) {
804 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
806 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
809 return anInPort->AddCoord( index , X , Y ) ;
815 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
816 const char* FromServiceParameterName ,
817 const char* ToNodeName ,
818 const char* ToServiceParameterName ,
822 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
823 ToServiceParameterName ) ;
824 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
825 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
827 if ( anInPort->IsEndSwitch() ) {
828 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
830 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
833 return anInPort->ChangeCoord( index , X , Y ) ;
839 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
840 const char* FromServiceParameterName ,
841 const char* ToNodeName ,
842 const char* ToServiceParameterName ,
844 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
845 ToServiceParameterName ) ;
846 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
847 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
849 if ( anInPort->IsEndSwitch() ) {
850 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
852 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
855 return anInPort->RemoveCoord( index ) ;
861 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
862 const char* FromServiceParameterName ,
863 const char* ToNodeName ,
864 const char* ToServiceParameterName ) {
865 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
866 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
867 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
869 if ( anInPort->IsEndSwitch() ) {
870 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
872 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
875 return anInPort->GetCoord() ;
881 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
882 const char* FromServiceParameterName ,
883 const char* ToNodeName ,
884 const char* ToServiceParameterName ,
886 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
887 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
888 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
890 if ( anInPort->IsEndSwitch() ) {
891 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
893 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
896 return anInPort->GetCoord( X , Y ) ;
902 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
903 const char* FromServiceParameterName ,
904 const char* ToNodeName ,
905 const char* ToServiceParameterName ,
906 const int index , long &X , long &Y ) {
907 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
908 ToServiceParameterName ) ;
909 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
910 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
912 if ( anInPort->IsEndSwitch() ) {
913 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
915 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
918 return anInPort->GetCoord( index , X , Y ) ;
924 bool GraphEditor::OutNode::UnValid() {
925 bool RetVal = _Valid ;
927 if ( Graph()->GraphMacroLevel() != 0 ) {
928 cdebug << "GraphEditor::OutNode::UnValid() GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
934 bool GraphEditor::OutNode::Valid() {
938 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
939 _Executable = false ;
941 if ( !Graph()->CreateService() ) {
942 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
946 if ( Graph()->GraphMacroLevel() != 0 ) {
947 cdebug << "CoupledNode " << Graph()->CoupledNode() << endl ;
948 cdebug << "GraphEditor " << Graph()->CoupledNode()->GraphEditor() << endl ;
949 cdebug << "Graph " << Graph()->CoupledNode()->GraphEditor()->Graph() << endl ;
950 cdebug << "Name " << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
951 cdebug << "Valid --> UpdateMacroPorts of " << Graph()->CoupledNodeName() << " of "
952 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name() << endl ;
953 cdebug << Graph()->CoupledNode() << endl ;
954 Graph()->CoupledNode()->UpdateMacroPorts( Graph() ) ;
955 cdebug << Graph()->CoupledNode()->Name() << " Valid --> UnValid of graph "
956 << Graph()->CoupledNode()->GraphEditor()->Graph()->Name()
957 << " GraphMacroLevel " << Graph()->CoupledNode()->GraphEditor()->Graph()->GraphMacroLevel() << endl ;
958 Graph()->CoupledNode()->GraphEditor()->UnValid() ;
961 int SubStreamGraphsNumber = 0 ;
962 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
963 cdebug_out << "This DataFlow is not valid." << endl ;
966 if ( Graph()->IsDataStreamNode() ) {
967 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
972 Graph()->InLineServices() ;
974 Graph()->ComputingNodes() ;
978 cdebug_out << "GraphEditor::OutNode::Valid " << _Valid << endl;
982 bool GraphEditor::OutNode::Executable() {
983 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
985 if ( Graph()->LinkLoopNodes( NewLink ) ) {
991 cdebug << "This DataFlow is not executable." << endl ;
992 _Executable = false ;
1000 if ( Graph()->DataServerNodes() )
1001 _Executable = true ;
1003 cdebug << "This DataFlow is not executable." << endl ;
1004 _Executable = false ;
1007 if ( _Executable && Graph()->IsDataStreamNode() ) {
1008 StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
1011 cdebug_out << "GraphEditor::OutNode::Executable" << endl;
1012 return _Executable ;
1015 const CORBA::Any *GraphEditor::OutNode::GetInData(
1016 const char * ToNodeName ,
1017 const char * ToParameterName ) {
1018 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
1019 // << " " << ToParameterName << endl ;
1020 const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
1021 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
1025 const CORBA::Any *GraphEditor::OutNode::GetOutData(
1026 const char * FromNodeName ,
1027 const char * FromParameterName ) {
1028 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
1029 // << " " << FromParameterName << endl ;
1030 const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
1031 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
1035 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
1036 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
1037 GraphBase::SLink aLink ,
1038 bool wdata ) const {
1039 cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1040 << "(" << aLink.FromServiceParameterName << ") --> "
1041 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
1042 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
1044 if ( strlen( aLink.FromNodeName.c_str() ) ) {
1045 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
1046 // << "</fromnode-name>" << endl ;
1047 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
1050 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
1051 aField = Graph.createTextNode( "?" ) ;
1053 link.appendChild( fromnodename ) ;
1054 fromnodename.appendChild( aField ) ;
1056 // f << Tabs << "<fromserviceparameter-name>"
1057 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
1059 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
1060 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
1061 link.appendChild( fromserviceparametername ) ;
1062 fromserviceparametername.appendChild( aField ) ;
1064 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
1065 if ( strlen( aLink.ToNodeName.c_str() ) ) {
1066 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
1067 // << "</tonode-name>" << endl ;
1068 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
1071 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
1072 aField = Graph.createTextNode( "?" ) ;
1074 link.appendChild( tonodename ) ;
1075 tonodename.appendChild( aField ) ;
1077 // f << Tabs << "<toserviceparameter-name>"
1078 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
1080 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
1081 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
1082 link.appendChild( toserviceparametername ) ;
1083 toserviceparametername.appendChild( aField ) ;
1086 // f << Tabs << "<data-value>" << endl ;
1087 QDomElement datavalue = Graph.createElement( "data-value" ) ;
1088 link.appendChild( datavalue ) ;
1089 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
1090 // << "</value-type>" << endl ;
1091 QDomElement valuetype = Graph.createElement( "value-type" ) ;
1093 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
1094 aField = Graph.createTextNode( aKind ) ;
1095 datavalue.appendChild( valuetype ) ;
1096 valuetype.appendChild( aField ) ;
1097 switch (aLink.aLinkValue.type()->kind()) {
1098 case CORBA::tk_string: {
1100 aLink.aLinkValue >>= retstr;
1101 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1102 QDomElement value = Graph.createElement( "value" ) ;
1103 aField = Graph.createTextNode( retstr ) ;
1104 datavalue.appendChild( value ) ;
1105 value.appendChild( aField ) ;
1106 // MESSAGE( "ToString( string ) " << retstr );
1109 case CORBA::tk_double: {
1111 aLink.aLinkValue >>= d;
1112 // f << Tabs << " <value>" << d << "</value>" << endl ;
1113 QDomElement value = Graph.createElement( "value" ) ;
1115 aKind = aKind.setNum( d ) ;
1116 aField = Graph.createTextNode( aKind ) ;
1117 datavalue.appendChild( value ) ;
1118 value.appendChild( aField ) ;
1119 // MESSAGE( "ToString( double ) " << d );
1122 case CORBA::tk_long: {
1124 aLink.aLinkValue >>= l;
1125 // f << Tabs << " <value>" << l << "</value>" << endl ;
1126 QDomElement value = Graph.createElement( "value" ) ;
1128 aKind = aKind.setNum( l ) ;
1129 aField = Graph.createTextNode( aKind ) ;
1130 datavalue.appendChild( value ) ;
1131 value.appendChild( aField ) ;
1132 // MESSAGE( "ToString( long ) " << l );
1135 case CORBA::tk_objref: {
1137 CORBA::Object_ptr obj ;
1138 aLink.aLinkValue >>= obj ;
1139 retstr = _Orb->object_to_string(obj );
1140 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1141 QDomElement value = Graph.createElement( "value" ) ;
1142 aField = Graph.createTextNode( retstr ) ;
1143 datavalue.appendChild( value ) ;
1144 value.appendChild( aField ) ;
1145 // MESSAGE( "ToString( object ) " << retstr );
1149 // f << Tabs << " <value>?</value>" << endl ;
1150 QDomElement value = Graph.createElement( "value" ) ;
1151 aField = Graph.createTextNode( "?" ) ;
1152 datavalue.appendChild( value ) ;
1153 value.appendChild( aField ) ;
1154 // MESSAGE( "Unknown CORBA::Any Type" );
1158 // f << Tabs << "</data-value>" << endl ;
1160 // f << Tabs << "<coord-list>" << endl ;
1161 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1162 link.appendChild( coordlist ) ;
1165 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1166 // f << Tabs << " <coord>" << endl ;
1167 QDomElement coord = Graph.createElement( "coord" ) ;
1168 coordlist.appendChild( coord ) ;
1169 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1170 QDomElement x = Graph.createElement( "x" ) ;
1172 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1173 aField = Graph.createTextNode( ax ) ;
1174 coord.appendChild( x ) ;
1175 x.appendChild( aField ) ;
1176 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1177 QDomElement y = Graph.createElement( "y" ) ;
1179 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1180 aField = Graph.createTextNode( ay ) ;
1181 coord.appendChild( y ) ;
1182 y.appendChild( aField ) ;
1183 // f << Tabs << " </coord>" << endl ;
1185 // f << Tabs << "</coord-list>" << endl ;
1186 cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1187 << "(" << aLink.FromServiceParameterName << ") --> "
1188 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1193 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1194 GraphBase::SLink aLink ,
1195 bool fromparam , bool toparam ,
1196 bool wdata ) const {
1198 // if ( intervar ) {
1199 // f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1201 // << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1202 // << aLink.FromServiceParameterName.c_str()
1203 // << "' )" << endl ;
1205 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1206 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1207 if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1208 f << " = " << aGraphName << ".StreamLink( " ;
1211 f << " = " << aGraphName << ".Link( " ;
1213 // if ( !fromparam ) {
1216 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1217 // if ( !toparam ) {
1220 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1223 f << " " << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1224 // << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1225 // << aLink.ToServiceParameterName.c_str() << "' , " ;
1227 switch (aLink.aLinkValue.type()->kind()) {
1228 case CORBA::tk_string: {
1230 aLink.aLinkValue >>= retstr;
1231 f << "'" << retstr << "'" ;
1234 case CORBA::tk_double: {
1236 aLink.aLinkValue >>= d;
1240 case CORBA::tk_long: {
1242 aLink.aLinkValue >>= l;
1246 case CORBA::tk_objref: {
1248 CORBA::Object_ptr obj ;
1249 aLink.aLinkValue >>= obj ;
1250 retstr = _Orb->object_to_string(obj );
1251 f << "'" << retstr << "'" ;
1256 // MESSAGE( "Unknown CORBA::Any Type" );
1263 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1264 f << " " << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1265 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1266 << aLink.aListOfCoords[ i ].theX << " , "
1267 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1272 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1273 bool GraphEditor::OutNode::SaveXML( ostream & f , QDomDocument & GraphQDom ,
1274 bool aSuperGraph , QDomElement & supergraph ) {
1275 cdebug_in << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1276 << Graph()->Name() << endl ;
1279 QDomElement dataflow ;
1280 if ( aSuperGraph ) {
1281 QString SuperGraph("SuperGraph") ;
1282 GraphQDom = QDomDocument(SuperGraph) ;
1284 supergraph = GraphQDom.createElement( "supergraph" ) ;
1285 GraphQDom.appendChild( supergraph ) ;
1287 dataflow = GraphQDom.createElement( "dataflow" ) ;
1288 supergraph.appendChild( dataflow ) ;
1291 // QString Dataflow("Dataflow") ;
1292 // GraphQDom = QDomDocument(Dataflow) ;
1294 dataflow = GraphQDom.createElement( "dataflow" ) ;
1295 supergraph.appendChild( dataflow ) ;
1298 QDomElement info = GraphQDom.createElement( "info-list" ) ;
1299 dataflow.appendChild( info ) ;
1301 Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1303 QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1304 dataflow.appendChild( nodelist ) ;
1305 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1306 // f << " <node>" << endl ;
1307 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1308 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1310 ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1311 Graph()->GraphNodes( i )->XCoordinate() ,
1312 Graph()->GraphNodes( i )->YCoordinate() ) ;
1314 else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1315 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1317 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1318 Graph()->GraphNodes( i )->XCoordinate() ,
1319 Graph()->GraphNodes( i )->YCoordinate() ) ;
1321 else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1322 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1324 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1325 Graph()->GraphNodes( i )->XCoordinate() ,
1326 Graph()->GraphNodes( i )->YCoordinate() ) ;
1328 else if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1329 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1331 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1332 Graph()->GraphNodes( i )->XCoordinate() ,
1333 Graph()->GraphNodes( i )->YCoordinate() ) ;
1335 else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1336 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1338 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1339 Graph()->GraphNodes( i )->XCoordinate() ,
1340 Graph()->GraphNodes( i )->YCoordinate() ) ;
1342 else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1343 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1345 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1346 Graph()->GraphNodes( i )->XCoordinate() ,
1347 Graph()->GraphNodes( i )->YCoordinate() ) ;
1349 else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1350 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1352 ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1353 Graph()->GraphNodes( i )->XCoordinate() ,
1354 Graph()->GraphNodes( i )->YCoordinate() ) ;
1356 else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1357 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1359 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1360 Graph()->GraphNodes( i )->XCoordinate() ,
1361 Graph()->GraphNodes( i )->YCoordinate() ) ;
1363 else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1364 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1366 ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1367 Graph()->GraphNodes( i )->XCoordinate() ,
1368 Graph()->GraphNodes( i )->YCoordinate() ) ;
1370 // f << " </node>" << endl ;
1373 // f << " </node-list>" << endl << endl ;
1375 // f << " <link-list>" << endl ;
1376 QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1377 dataflow.appendChild( linklist ) ;
1378 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ;
1379 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1380 // f << " <link>" << endl ;
1381 QDomElement link = GraphQDom.createElement( "link" ) ;
1382 linklist.appendChild( link ) ;
1383 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1384 LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1385 // f << " </link>" << endl ;
1387 // f << " </link-list>" << endl << endl ;
1389 // f << " <data-list>" << endl ;
1390 QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1391 dataflow.appendChild( datalist ) ;
1392 if ( Graph()->GraphMacroLevel() == 0 ) {
1393 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1394 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1395 // f << " <data>" << endl ;
1396 QDomElement data = GraphQDom.createElement( "data" ) ;
1397 datalist.appendChild( data ) ;
1398 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1399 LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1400 // f << " </data>" << endl ;
1404 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1405 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1406 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1407 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1408 cdebug << "OutNode::SaveXML ---> OutNode::SaveXML( ostream & f , QDomDocument & , false "
1409 << " , QDomElement & ) MacroGraph " << aMacroGraph->Name() << endl ;
1410 if ( !aMacroGraph->GraphEditor()->SaveXML( f , GraphQDom , false , supergraph ) ) {
1412 cdebug << "OutNode::SaveXML MacroGraph "<< aMacroGraph->Name() << " done" << endl ;
1417 cdebug_out << "OutNode::SaveXML( ostream & f , QDomDocument & , " << aSuperGraph << " , QDomElement & ) "
1418 << Graph()->Name() << endl ;
1423 bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) {
1426 if ( importSuperV ) {
1427 f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1429 f << "from SuperV import *" << endl << endl ;
1432 f << "# Graph creation of " << Graph()->Name() << endl ;
1433 f << "def Def" << Graph()->Name() << "() :" << endl ;
1434 Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1436 f << " " << endl << " " << "# Creation of Factory Nodes" << endl ;
1437 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1438 if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1440 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1441 Graph()->GraphNodes( i )->XCoordinate() ,
1442 Graph()->GraphNodes( i )->YCoordinate() ) ;
1447 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1448 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1450 f << " " << endl << " " << "# Creation of Computing Nodes" << endl ;
1456 ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1457 Graph()->GraphNodes( i )->XCoordinate() ,
1458 Graph()->GraphNodes( i )->YCoordinate() ) ;
1463 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1464 if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1466 f << " " << endl << " " << "# Creation of InLine Nodes" << endl ;
1472 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1473 Graph()->GraphNodes( i )->XCoordinate() ,
1474 Graph()->GraphNodes( i )->YCoordinate() ) ;
1479 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1480 if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1482 f << " " << endl << " " << "# Creation of Loop Nodes" << endl ;
1488 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1489 Graph()->GraphNodes( i )->XCoordinate() ,
1490 Graph()->GraphNodes( i )->YCoordinate() ) ;
1495 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1496 if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1498 f << " " << endl << " " << "# Creation of Switch Nodes" << endl ;
1504 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1505 Graph()->GraphNodes( i )->XCoordinate() ,
1506 Graph()->GraphNodes( i )->YCoordinate() ) ;
1511 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1512 if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1514 f << " " << endl << " " << "# Creation of GOTO Nodes" << endl ;
1520 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1521 Graph()->GraphNodes( i )->XCoordinate() ,
1522 Graph()->GraphNodes( i )->YCoordinate() ) ;
1527 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1528 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1530 f << " " << endl << " " << "# Creation of Macro Nodes" << endl ;
1536 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1537 Graph()->GraphNodes( i )->XCoordinate() ,
1538 Graph()->GraphNodes( i )->YCoordinate() ) ;
1542 const GraphBase::ListOfSLinks * Links = Graph()->GetLinks() ;
1544 // map< string , int > aMapOfOutPorts ;
1546 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1547 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1548 if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1551 << " " << "# Creation of Links"
1558 // char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1559 // strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1560 // strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1561 // strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1562 // if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1563 // aMapOfOutPorts[ NodePort ] = j + 1 ;
1564 // intervar = true ;
1567 // intervar = false ;
1569 bool fromparam = false ;
1570 if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1573 bool toparam = false ;
1574 if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1577 LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1578 // delete [] NodePort ;
1583 if ( Graph()->GraphMacroLevel() == 0 ) {
1584 const GraphBase::ListOfSLinks * Datas = Graph()->GetDatas() ;
1586 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1588 f << " " << endl << " " << "# Input datas" << endl ;
1591 bool fromparam = true ;
1592 bool toparam = true ;
1593 LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1598 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1599 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1600 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1601 const char * aParam = _aParam.c_str() ;
1605 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1606 // if ( aParam[ j ] == '\\' ) {
1607 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1608 aNodeName = new char[ j+1 ] ;
1609 strncpy( aNodeName , aParam , j ) ;
1610 aNodeName[ j ] = '\0' ;
1611 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1612 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1616 const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1617 if ( !anInPort->IsDataConnected() ) {
1619 f << " " << endl << " " << "# Input Ports of the graph" << endl ;
1622 f << " " << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1623 << aPortName << "' )" << endl ;
1625 delete [] aNodeName ;
1626 delete [] aPortName ;
1629 f << " " << endl << " # Output Ports of the graph" << endl ;
1630 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1631 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1632 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1633 const char * aParam = _aParam.c_str() ;
1637 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1638 // if ( aParam[ j ] == '\\' ) {
1639 if ( aParam[ j ] == '_' && aParam[ j+1 ] == '_' ) {
1640 aNodeName = new char[ j+1 ] ;
1641 strncpy( aNodeName , aParam , j ) ;
1642 aNodeName[ j ] = '\0' ;
1643 aPortName = new char[ strlen( aParam ) - j-1 ] ;
1644 strncpy( aPortName , &aParam[ j+2 ] , strlen( aParam ) - j-1 ) ;
1648 f << " " << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1649 << aPortName << "' )" << endl ;
1650 delete [] aNodeName ;
1651 delete [] aPortName ;
1654 f << " " << "return " << Graph()->Name() << endl << endl ;
1656 // RECURSIVE CREATION OF GRAPHS OF MACRONODES
1657 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1658 if ( Graph()->GraphNodes( i )->IsMacroNode() ) {
1659 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) Graph()->GraphNodes( i ) ;
1660 GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) aMacroNode->CoupledNode() ;
1661 cdebug << "OutNode::SavePY ---> OutNode::SavePY( ostream & f ) MacroGraph " << aMacroGraph->Name() << endl ;
1662 GraphEditor::DataFlow * aDataFlow = aMacroGraph->GraphEditor() ;
1663 cdebug << "SavePY of the Graph " << aDataFlow->Graph() << " of the MacroNode "
1664 << aMacroGraph->Name() << endl ;
1665 if ( !aDataFlow->SavePY( f , false ) ) {
1671 // f << Graph()->Name() << " = " << Graph()->Name() << "()" << endl ;
1678 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1679 f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1682 f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node"
1683 << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1686 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1688 // << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1689 << (G.Graph())->GraphNodes( i ) << endl;
1692 f << " Links : " << endl ;
1693 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1694 (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1697 f << " Datas : " << endl ;
1698 (G.Graph())->ListDatas( f ) ;
1700 f << "DataFlow " << (G.Graph())->Name() << " is " ;
1701 if ( G.IsNotValid() )
1703 f << "valid and is " ;
1704 if ( G.IsNotExecutable() )
1706 f << "executable." << endl ;
1713 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1715 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1717 fOut << D.Day << "/"
1724 // cdebug_out << "operator<< GraphEditor::Date" << endl;
1729 GraphBase::Graph * GraphEditor::OutNode::MapGraph( const char * aGraphName ) {
1730 GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
1734 bool GraphEditor::OutNode::MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) {
1735 if ( MapGraph( aGraphName ) ) {
1738 _MapOfGraphs[ aGraphName ] = aGraph ;
1742 void GraphEditor::OutNode::EraseGraph( const char * aGraphName ) {
1743 _MapOfGraphs.erase( aGraphName ) ;
1746 bool GraphEditor::OutNode::GraphName( const char * aGraphName ) {
1747 return _MapOfGraphNames[ aGraphName ] ;