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_OutNode.hxx"
31 #include "DataFlowBase_EndOfLoopNode.hxx"
32 #include "DataFlowBase_EndOfSwitchNode.hxx"
34 // Implementation de la classe GraphEditor::Graph
36 GraphEditor::OutNode::OutNode() :
38 cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
44 cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
47 GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
48 SALOME_NamingService * ptrNamingService ,
49 const char * DataFlowName ,
50 const char * DebugFileName ) :
51 Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
52 cdebug_in << "GraphEditor::OutNode::OutNode(" ;
54 cdebug << DataFlowName ;
56 cdebug << ")" << endl;
58 _Orb = CORBA::ORB::_duplicate( ORB ) ;
63 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
66 GraphEditor::OutNode::OutNode(
68 SALOME_NamingService * ptrNamingService ,
69 const SALOME_ModuleCatalog::Service& DataFlowService ,
70 const char * DataFlowComponentName ,
71 const char * DataFlowInterfaceName ,
72 const char * DataFlowName ,
73 const SUPERV::KindOfNode DataFlowkind ,
74 const SUPERV::SDate DataFlowFirstCreation ,
75 const SUPERV::SDate DataFlowLastModification ,
76 const char * DataFlowEditorRelease ,
77 const char * DataFlowAuthor ,
78 const char * DataFlowComputer ,
79 const char * DataFlowComment ,
80 const char * DebugFileName ) :
81 Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
82 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
83 DataFlowFirstCreation , DataFlowLastModification ,
84 DataFlowEditorRelease , DataFlowAuthor ,
85 DataFlowComputer , DataFlowComment , DebugFileName ) {
87 _Orb = CORBA::ORB::_duplicate( ORB ) ;
94 GraphEditor::OutNode::~OutNode() {
95 // delete _DataFlowNode ;
96 // delete _DataFlowDatas ;
100 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) {
101 bool RetVal = false ;
102 cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << aDataFlow->Info.theName.c_str()
105 RetVal = LoadInfo( aDataFlow->Info ) ;
112 map< string , int > aMapOfNodes ;
114 RetVal = LoadNodes( aMapOfNodes , aDataFlow->Nodes ) ;
116 RetVal = LoadLinks( aMapOfNodes , aDataFlow->Links ) ;
119 RetVal = LoadDatas( aMapOfNodes , aDataFlow->Datas ) ;
121 cdebug_out << "GraphEditor::OutNode::LoadDataFlow" << endl;
125 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
126 bool RetVal = false ;
127 GraphBase::SGraph aDataFlow ;
128 if ( myFileName == NULL ) {
129 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
133 else if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) {
134 cdebug_in << "GraphEditor::OutNode::LoadXml() " << endl;
135 RetVal = LoadDataFlow( &aDataFlow ) ;
136 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
141 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
142 cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
144 // MESSAGE( "GraphEditor::OutNode::LoadDataFlow" );
145 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
146 // InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
147 Name( aDataFlowInfo.theName.c_str() ) ;
148 Kind( aDataFlowInfo.theKind ) ;
149 Service( aDataFlowInfo.theService ) ;
150 FirstCreation( aDataFlowInfo.theFirstCreation ) ;
151 LastModification( aDataFlowInfo.theLastModification ) ;
152 EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
153 Author( aDataFlowInfo.theAuthor.c_str() ) ;
154 // Computer( aDataFlowInfo.theContainer.c_str() ) ;
155 Comment( aDataFlowInfo.theComment.c_str() ) ;
156 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
157 // Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
158 cdebug_out << "GraphEditor::OutNode::LoadInfo" << endl ;
162 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
163 const GraphBase::ListOfNodes &aListOfNodes ) {
164 GraphEditor::InNode * anInNode ;
165 cdebug_in << "GraphEditor::OutNode::LoadNodes" << endl ;
167 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
168 GraphBase::SNode aNode = aListOfNodes[ i ] ;
169 const char * aNodeName = aNode.theName.c_str() ;
170 if ( aNode.theListOfFuncName.size() == 0 ) {
171 aNode.theListOfFuncName.resize( 1 ) ;
172 aNode.theListOfFuncName[ 0 ] = "" ;
173 aNode.theListOfPythonFunctions.resize( 1 ) ;
174 aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
176 if ( GetGraphNode( aNode.theName.c_str() ) ) {
179 anInNode = AddNode( aNode.theService ,
180 aNode.theListOfFuncName ,
181 aNode.theListOfPythonFunctions ,
182 aNode.theComponentName.c_str() ,
183 aNode.theInterfaceName.c_str() , aNodeName ,
185 aNode.theFirstCreation , aNode.theLastModification ,
186 aNode.theEditorRelease.c_str() ,
187 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
188 aNode.theComment.c_str() ,
189 aNode.theCoords.theX , aNode.theCoords.theY ) ;
190 string * aNodetheName = new string( aNode.theName ) ;
191 aMapOfNodes[ *aNodetheName ] = GetGraphNodeIndex( anInNode->Name() ) ;
192 if ( anInNode->IsOneOfInLineNodes() ) {
193 anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
194 _Orb , aNode.theService , anInNode->NamePtr() ,
196 Graph_prof_debug() , Graph_fdebug() ) ;
197 GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
198 GraphBase::LoopNode * aLNode = NULL ;
199 if ( aINode->IsLoopNode() ) {
200 aLNode = anInNode->LoopNode() ;
201 aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
202 *aNode.theListOfPythonFunctions[ 0 ] ) ;
203 aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
204 *aNode.theListOfPythonFunctions[ 1 ] ) ;
205 aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
206 *aNode.theListOfPythonFunctions[ 2 ] ) ;
208 else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
209 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
210 aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
211 *aNode.theListOfPythonFunctions[ 0 ] ) ;
214 delete aNodetheName ;
219 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
220 GraphBase::SNode aNode = aListOfNodes[ i ] ;
221 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
222 << aNode.theCoupledNode.c_str() << endl ;
223 anInNode = (GraphEditor::InNode * ) GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
224 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
225 GraphBase::GOTONode * aCoupledNode ;
226 aCoupledNode = (GraphBase::GOTONode * ) GetGraphNode( aNode.theName.c_str() ) ;
227 aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
230 cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
234 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
235 const GraphBase::ListOfLinks &aListOfLinks ) {
237 cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
238 // MESSAGE( "GraphEditor::OutNode::LoadLinks" );
240 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
241 GraphBase::SLink aLink = aListOfLinks[ i ] ;
242 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
243 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
244 cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
245 << aLink.FromServiceParameterName.c_str() << " ) --> "
246 << aLinkToNodeName->c_str() << "( "
247 << aLink.FromServiceParameterName.c_str() << " )" << endl ;
248 if ( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
249 GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
250 RetVal = AddLink( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
251 aLink.FromServiceParameterName.c_str() ,
252 GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
253 aLink.ToServiceParameterName.c_str() ,
254 *((GraphBase::ComputingNode *) GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ))->GetOutPort( aLink.FromServiceParameterName.c_str() )->Value() ) ;
259 // aLink.aLinkValue ) ;
263 for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
264 RetVal = AddLinkCoord( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
265 aLink.FromServiceParameterName.c_str() ,
266 GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
267 aLink.ToServiceParameterName.c_str() ,
269 aLink.aListOfCoords[j].theX ,
270 aLink.aListOfCoords[j].theY ) ;
275 delete aLinkFromNodeName ;
276 delete aLinkToNodeName ;
278 cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
282 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
283 const GraphBase::ListOfLinks &aListOfDatas ) {
285 cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
286 // MESSAGE( "GraphEditor::OutNode::LoadDatas" );
288 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
289 GraphBase::SLink aLink = aListOfDatas[ i ] ;
290 if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) ) {
291 cdebug << "GraphEditor::OutNode::LoadDatas Warning "
292 << aLink.FromNodeName.c_str()
293 << " and " << aLink.ToNodeName.c_str() << " differents from " << Name()
296 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
297 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
298 // cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
299 // << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
300 // cout << " " << aLink.ToNodeName.c_str() << " "
301 // << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
302 RetVal = GraphBase::Graph::AddInputData( GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
303 aLink.ToServiceParameterName.c_str() ,
305 delete aLinkFromNodeName ;
306 delete aLinkToNodeName ;
310 cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
314 bool GraphEditor::OutNode::SaveXml(const char* filename) {
316 cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
317 ofstream f(filename);
319 // test = SaveXML( f );
321 test = SaveXML( Graph );
323 QString xml = Graph.toString() ;
324 // cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
327 cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
332 bool GraphEditor::OutNode::SavePy( const char* filename ) {
334 cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
335 ofstream f( filename ) ;
338 cdebug_out << "GraphEditor::OutNode::SavePy" << endl;
342 GraphBase::SGraph * GraphEditor::OutNode::GetDataFlow() {
343 GraphBase::SGraph * aDataFlow = new GraphBase::SGraph;
344 aDataFlow->Info = *GetInfo() ;
345 aDataFlow->Nodes = *GetNodes() ;
346 aDataFlow->Links = *GetLinks( true ) ;
347 aDataFlow->Datas = *GetDatas() ;
351 void GraphEditor::OutNode::DateModification() {
352 time_t T = time(NULL);
353 struct tm * Tm = localtime(&T);
354 SUPERV::SDate aLastModificationDate ;
356 aLastModificationDate.Second = Tm->tm_sec;
357 aLastModificationDate.Minute = Tm->tm_min;
358 aLastModificationDate.Hour = Tm->tm_hour;
359 aLastModificationDate.Day = Tm->tm_mday;
360 aLastModificationDate.Month = Tm->tm_mon + 1;
361 aLastModificationDate.Year = Tm->tm_year + 1900;
362 LastModification( aLastModificationDate ) ;
365 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
368 ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
371 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
372 return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->XCoordinate() ;
375 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
376 return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->YCoordinate() ;
379 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
380 const SALOME_ModuleCatalog::Service& NodeService ,
381 GraphBase::ListOfFuncName aFuncName ,
382 GraphBase::ListOfPythonFunctions aPythonFunction ,
383 const char * NodeComponentName ,
384 const char * NodeInterfaceName ,
385 const char * theNodeName ,
386 const SUPERV::KindOfNode NodeKindOfNode ,
387 const SUPERV::SDate NodeFirstCreation ,
388 const SUPERV::SDate NodeLastModification ,
389 const char * NodeEditorRelease ,
390 const char * NodeAuthor ,
391 const char * NodeComputer ,
392 const char * NodeComment ,
395 cdebug_in << "GraphEditor::OutNode::AddNode( " ;
396 if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
397 cdebug << NodeComponentName << " , " ;
400 cdebug << "NodeComponentName[NULL] )" << endl;
402 if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
403 cdebug << theNodeName << " )" << endl;
406 cdebug << "NodeName[NULL] )" << endl;
408 char * RetVal = NULLSTRING ;
409 GraphEditor::InNode *Nd = NULL ;
410 char * aNodeName = NULL ;
411 bool GeneratedName = false ;
412 if ( NodeKindOfNode == SUPERV::InLineNode ||
413 NodeKindOfNode == SUPERV::LoopNode ||
414 NodeKindOfNode == SUPERV::EndLoopNode ||
415 NodeKindOfNode == SUPERV::SwitchNode ||
416 NodeKindOfNode == SUPERV::EndSwitchNode ||
417 NodeKindOfNode == SUPERV::GOTONode ) {
418 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
419 if ( NodeKindOfNode == SUPERV::InLineNode ) {
420 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
422 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
423 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
425 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
426 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
428 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
429 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
431 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
432 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
434 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
435 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
439 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
441 theNodeName = NULLSTRING ;
443 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
444 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
445 strcpy( aNodeName , NodeService.ServiceName ) ;
446 if ( GetGraphNode( NodeService.ServiceName ) ) {
447 GeneratedName = true ;
448 while ( GetGraphNode( aNodeName ) ) {
450 delete [] aNodeName ;
452 int num = GetServiceNameNumber( NodeService.ServiceName ) ;
454 astr << num << ends ;
455 const char * n_instance = astr.str().c_str() ;
456 int lname = strlen( NodeService.ServiceName ) + 1 +
457 strlen( n_instance ) + 1 ;
458 aNodeName = new char[lname] ;
459 strcpy( aNodeName , NodeService.ServiceName ) ;
460 strcat( aNodeName , "_" ) ;
461 strcat( aNodeName , n_instance ) ;
466 if ( GetGraphNode( theNodeName ) == NULL ) {
467 aNodeName = new char[ strlen( theNodeName )+1 ] ;
468 strcpy( aNodeName , theNodeName ) ;
471 if ( aNodeName != NULLSTRING ) {
472 Nd = new GraphEditor::InNode( _Orb , NamingService() ,
473 aFuncName , aPythonFunction , NodeService ,
474 NodeComponentName , NodeInterfaceName ,
475 aNodeName , NodeKindOfNode ,
476 NodeFirstCreation , NodeLastModification ,
477 NodeEditorRelease , NodeAuthor ,
478 NodeComputer , NodeComment , GeneratedName ,
480 Graph_prof_debug() , Graph_fdebug() ) ;
481 // MESSAGE( "GraphEditor::OutNode::AddNode " << hex << (void *) Nd << dec );
482 // if ( GraphBase::Graph::AddNode( Nd ) ) {
483 if ( GraphBase::Graph::AddNode( Nd->ComputingNode() ) ) {
485 RetVal = Nd->Name() ;
488 cdebug << "NodeName already exists." << endl ;
492 cdebug << "NodeName is NULL or already exists." << endl ;
494 // delete [] aNodeName ;
495 cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
500 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
501 const char* FromServiceParameterName ,
502 const char* ToNodeName ,
503 const char* ToServiceParameterName ,
507 GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
508 ToServiceParameterName ) ;
509 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
510 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
512 if ( anInPort->IsEndSwitch() ) {
513 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
515 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
518 return anInPort->AddCoord( nXY , X , Y ) ;
524 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
525 const char* FromServiceParameterName ,
526 const char* ToNodeName ,
527 const char* ToServiceParameterName ,
531 GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
532 ToServiceParameterName ) ;
533 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
534 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
536 if ( anInPort->IsEndSwitch() ) {
537 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
539 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
542 return anInPort->AddCoord( index , X , Y ) ;
548 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
549 const char* FromServiceParameterName ,
550 const char* ToNodeName ,
551 const char* ToServiceParameterName ,
555 GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
556 ToServiceParameterName ) ;
557 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
558 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
560 if ( anInPort->IsEndSwitch() ) {
561 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
563 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
566 return anInPort->ChangeCoord( index , X , Y ) ;
572 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
573 const char* FromServiceParameterName ,
574 const char* ToNodeName ,
575 const char* ToServiceParameterName ,
577 GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
578 ToServiceParameterName ) ;
579 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
580 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
582 if ( anInPort->IsEndSwitch() ) {
583 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
585 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
588 return anInPort->RemoveCoord( index ) ;
594 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
595 const char* FromServiceParameterName ,
596 const char* ToNodeName ,
597 const char* ToServiceParameterName ) {
598 const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
599 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
600 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
602 if ( anInPort->IsEndSwitch() ) {
603 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
605 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
608 return anInPort->GetCoord() ;
614 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
615 const char* FromServiceParameterName ,
616 const char* ToNodeName ,
617 const char* ToServiceParameterName ,
619 const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
620 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
621 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
623 if ( anInPort->IsEndSwitch() ) {
624 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
626 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
629 return anInPort->GetCoord( X , Y ) ;
635 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
636 const char* FromServiceParameterName ,
637 const char* ToNodeName ,
638 const char* ToServiceParameterName ,
639 const int index , long &X , long &Y ) {
640 GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
641 ToServiceParameterName ) ;
642 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
643 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
645 if ( anInPort->IsEndSwitch() ) {
646 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
648 return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
651 return anInPort->GetCoord( index , X , Y ) ;
657 bool GraphEditor::OutNode::AddInputData( const char* ToNodeName1 ,
658 const char* ToParameterName1 ,
659 const char* ToNodeName2 ,
660 const char* ToParameterName2 ) {
661 cdebug_in << "GraphEditor::OutNode::AddInputData" << endl;
662 bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 ,
666 cdebug_out << "GraphEditor::OutNode::AddInputData" << endl;
671 bool GraphEditor::OutNode::Valid() {
675 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
676 _Executable = false ;
681 cdebug << "This DataFlow is not valid." << endl ;
694 cdebug_out << "GraphEditor::OutNode::Valid" << endl;
698 bool GraphEditor::OutNode::Executable() {
699 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
701 if ( LinkLoopNodes( NewLink ) ) {
707 cdebug << "This DataFlow is not executable." << endl ;
708 _Executable = false ;
716 if ( DataServerNodes() )
719 cdebug << "This DataFlow is not executable." << endl ;
720 _Executable = false ;
723 cdebug_out << "GraphEditor::OutNode::Executable" << endl;
727 const CORBA::Any *GraphEditor::OutNode::GetInData(
728 const char * ToNodeName ,
729 const char * ToParameterName ) {
730 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
731 // << " " << ToParameterName << endl ;
732 const CORBA::Any * retdata = PortInData( ToNodeName , ToParameterName ) ;
733 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
737 const CORBA::Any *GraphEditor::OutNode::GetOutData(
738 const char * FromNodeName ,
739 const char * FromParameterName ) {
740 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
741 // << " " << FromParameterName << endl ;
742 const CORBA::Any * retdata = PortOutData( FromNodeName , FromParameterName ) ;
743 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
747 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
748 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
749 GraphBase::SLink aLink ,
751 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
753 if ( strlen( aLink.FromNodeName.c_str() ) ) {
754 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
755 // << "</fromnode-name>" << endl ;
756 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
759 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
760 aField = Graph.createTextNode( "?" ) ;
762 link.appendChild( fromnodename ) ;
763 fromnodename.appendChild( aField ) ;
765 // f << Tabs << "<fromserviceparameter-name>"
766 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
768 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
769 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
770 link.appendChild( fromserviceparametername ) ;
771 fromserviceparametername.appendChild( aField ) ;
773 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
774 if ( strlen( aLink.ToNodeName.c_str() ) ) {
775 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
776 // << "</tonode-name>" << endl ;
777 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
780 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
781 aField = Graph.createTextNode( "?" ) ;
783 link.appendChild( tonodename ) ;
784 tonodename.appendChild( aField ) ;
786 // f << Tabs << "<toserviceparameter-name>"
787 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
789 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
790 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
791 link.appendChild( toserviceparametername ) ;
792 toserviceparametername.appendChild( aField ) ;
795 // f << Tabs << "<data-value>" << endl ;
796 QDomElement datavalue = Graph.createElement( "data-value" ) ;
797 link.appendChild( datavalue ) ;
798 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
799 // << "</value-type>" << endl ;
800 QDomElement valuetype = Graph.createElement( "value-type" ) ;
802 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
803 aField = Graph.createTextNode( aKind ) ;
804 datavalue.appendChild( valuetype ) ;
805 valuetype.appendChild( aField ) ;
806 switch (aLink.aLinkValue.type()->kind()) {
807 case CORBA::tk_string: {
809 aLink.aLinkValue >>= retstr;
810 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
811 QDomElement value = Graph.createElement( "value" ) ;
812 aField = Graph.createTextNode( retstr ) ;
813 datavalue.appendChild( value ) ;
814 value.appendChild( aField ) ;
815 // MESSAGE( "ToString( string ) " << retstr );
818 case CORBA::tk_double: {
820 aLink.aLinkValue >>= d;
821 // f << Tabs << " <value>" << d << "</value>" << endl ;
822 QDomElement value = Graph.createElement( "value" ) ;
824 aKind = aKind.setNum( d ) ;
825 aField = Graph.createTextNode( aKind ) ;
826 datavalue.appendChild( value ) ;
827 value.appendChild( aField ) ;
828 // MESSAGE( "ToString( double ) " << d );
831 case CORBA::tk_long: {
833 aLink.aLinkValue >>= l;
834 // f << Tabs << " <value>" << l << "</value>" << endl ;
835 QDomElement value = Graph.createElement( "value" ) ;
837 aKind = aKind.setNum( l ) ;
838 aField = Graph.createTextNode( aKind ) ;
839 datavalue.appendChild( value ) ;
840 value.appendChild( aField ) ;
841 // MESSAGE( "ToString( long ) " << l );
844 case CORBA::tk_objref: {
846 CORBA::Object_ptr obj ;
847 aLink.aLinkValue >>= obj ;
848 retstr = _Orb->object_to_string(obj );
849 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
850 QDomElement value = Graph.createElement( "value" ) ;
851 aField = Graph.createTextNode( retstr ) ;
852 datavalue.appendChild( value ) ;
853 value.appendChild( aField ) ;
854 // MESSAGE( "ToString( object ) " << retstr );
858 // f << Tabs << " <value>?</value>" << endl ;
859 QDomElement value = Graph.createElement( "value" ) ;
860 aField = Graph.createTextNode( "?" ) ;
861 datavalue.appendChild( value ) ;
862 value.appendChild( aField ) ;
863 // MESSAGE( "Unknown CORBA::Any Type" );
867 // f << Tabs << "</data-value>" << endl ;
869 // f << Tabs << "<coord-list>" << endl ;
870 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
871 link.appendChild( coordlist ) ;
874 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
875 // f << Tabs << " <coord>" << endl ;
876 QDomElement coord = Graph.createElement( "coord" ) ;
877 coordlist.appendChild( coord ) ;
878 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
879 QDomElement x = Graph.createElement( "x" ) ;
881 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
882 aField = Graph.createTextNode( ax ) ;
883 coord.appendChild( x ) ;
884 x.appendChild( aField ) ;
885 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
886 QDomElement y = Graph.createElement( "y" ) ;
888 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
889 aField = Graph.createTextNode( ay ) ;
890 coord.appendChild( y ) ;
891 y.appendChild( aField ) ;
892 // f << Tabs << " </coord>" << endl ;
894 // f << Tabs << "</coord-list>" << endl ;
898 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
899 GraphBase::SLink aLink ,
900 bool intervar , bool wdata ) const {
903 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
905 << aLink.FromNodeName.c_str() << ".Port( '"
906 << aLink.FromServiceParameterName.c_str()
909 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
910 << " = " << aGraphName << ".Link( " << aLink.FromNodeName.c_str()
911 << aLink.FromServiceParameterName.c_str() << " , "
912 << aLink.ToNodeName.c_str() << ".Port( '"
913 << aLink.ToServiceParameterName.c_str() << "' ) )" << endl ;
916 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
917 << " = " << aLink.ToNodeName.c_str() << ".Input( '"
918 << aLink.ToServiceParameterName.c_str() << "' , " ;
919 switch (aLink.aLinkValue.type()->kind()) {
920 case CORBA::tk_string: {
922 aLink.aLinkValue >>= retstr;
923 f << "'" << retstr << "'" ;
926 case CORBA::tk_double: {
928 aLink.aLinkValue >>= d;
932 case CORBA::tk_long: {
934 aLink.aLinkValue >>= l;
938 case CORBA::tk_objref: {
940 CORBA::Object_ptr obj ;
941 aLink.aLinkValue >>= obj ;
942 retstr = _Orb->object_to_string(obj );
943 f << "'" << retstr << "'" ;
948 // MESSAGE( "Unknown CORBA::Any Type" );
955 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
956 f << aLink.ToNodeName.c_str()
957 << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
958 << aLink.aListOfCoords[ i ].theX << " , "
959 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
964 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
965 bool GraphEditor::OutNode::SaveXML(QDomDocument & Graph ) {
967 // f << "<?xml version='1.0' encoding='us-ascii' ?>" << endl << endl ;
968 // f << "<!-- XML Dataflow -->" << endl << endl ;
969 // f << "<!-- Dataflow information -->" << endl ;
970 QString Dataflow("Dataflow") ;
971 Graph = QDomDocument(Dataflow) ;
972 // f << "<dataflow>" << endl ;
973 QDomElement dataflow = Graph.createElement( "dataflow" ) ;
974 Graph.appendChild( dataflow ) ;
975 // f << " <info-list>" << endl ;
976 QDomElement info = Graph.createElement( "info-list" ) ;
977 dataflow.appendChild( info ) ;
979 // f << " <node>" << endl ;
981 // GraphBase::DataNode::SaveXML( f , " " , 0 , 0 ) ;
982 GraphBase::DataNode::SaveXML( Graph , info , 0 , 0 ) ;
984 // f << " </node>" << endl ;
986 // f << " </info-list>" << endl << endl ;
988 // f << " <node-list>" << endl ;
989 QDomElement nodelist = Graph.createElement( "node-list" ) ;
990 dataflow.appendChild( nodelist ) ;
991 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
992 // f << " <node>" << endl ;
993 if ( GraphNodes( i )->IsComputingNode() ) {
994 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
996 ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( Graph , nodelist ,
997 GraphNodes( i )->XCoordinate() ,
998 GraphNodes( i )->YCoordinate() ) ;
1000 else if ( GraphNodes( i )->IsFactoryNode() ) {
1001 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1003 ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1004 GraphNodes( i )->XCoordinate() ,
1005 GraphNodes( i )->YCoordinate() ) ;
1007 else if ( GraphNodes( i )->IsInLineNode() ) {
1008 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1010 ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1011 GraphNodes( i )->XCoordinate() ,
1012 GraphNodes( i )->YCoordinate() ) ;
1014 else if ( GraphNodes( i )->IsGOTONode() ) {
1015 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1017 ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1018 GraphNodes( i )->XCoordinate() ,
1019 GraphNodes( i )->YCoordinate() ) ;
1021 else if ( GraphNodes( i )->IsLoopNode() ) {
1022 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1024 ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1025 GraphNodes( i )->XCoordinate() ,
1026 GraphNodes( i )->YCoordinate() ) ;
1028 else if ( GraphNodes( i )->IsEndLoopNode() ) {
1029 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1031 ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1032 GraphNodes( i )->XCoordinate() ,
1033 GraphNodes( i )->YCoordinate() ) ;
1035 else if ( GraphNodes( i )->IsSwitchNode() ) {
1036 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1038 ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1039 GraphNodes( i )->XCoordinate() ,
1040 GraphNodes( i )->YCoordinate() ) ;
1042 else if ( GraphNodes( i )->IsEndSwitchNode() ) {
1043 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1045 ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
1046 GraphNodes( i )->XCoordinate() ,
1047 GraphNodes( i )->YCoordinate() ) ;
1049 // f << " </node>" << endl ;
1052 // f << " </node-list>" << endl << endl ;
1054 // f << " <link-list>" << endl ;
1055 QDomElement linklist = Graph.createElement( "link-list" ) ;
1056 dataflow.appendChild( linklist ) ;
1057 const GraphBase::ListOfLinks * Links = GetLinks( true ) ;
1058 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1059 // f << " <link>" << endl ;
1060 QDomElement link = Graph.createElement( "link" ) ;
1061 linklist.appendChild( link ) ;
1062 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1063 LinkSaveXML( Graph , link , (*Links)[ i ] , false ) ;
1064 // f << " </link>" << endl ;
1066 // f << " </link-list>" << endl << endl ;
1068 // f << " <data-list>" << endl ;
1069 QDomElement datalist = Graph.createElement( "data-list" ) ;
1070 dataflow.appendChild( datalist ) ;
1071 const GraphBase::ListOfLinks * Datas = GetDatas() ;
1072 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1073 // f << " <data>" << endl ;
1074 QDomElement data = Graph.createElement( "data" ) ;
1075 datalist.appendChild( data ) ;
1076 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1077 LinkSaveXML( Graph , data , (*Datas)[ i ] , true ) ;
1078 // f << " </data>" << endl ;
1081 // const GraphEditor::OutNode * aDataNode = (GraphEditor::OutNode *) this ;
1082 // if ( aDataNode ) {
1084 // for ( i = 0 ; i < aDataNode->GetNodeOutPortsSize() ; i++ ) {
1085 // const GraphBase::InPort *aLink = aDataNode->GetNodeOutPort(i)->GetLink() ;
1087 // f << " <data>" << endl ;
1088 // aLink->SaveXML( f , " " ) ;
1089 // f << " </data>" << endl ;
1092 // for ( i = 0 ; i < aDataNode->GetNodeInPortsSize() ; i++ ) {
1093 // const GraphBase::InPort *aLink = aDataNode->GetNodeInPort(i)->GetLink() ;
1095 // f << " <data>" << endl ;
1096 // aLink->SaveXML( f , " " ) ;
1097 // f << " </data>" << endl ;
1104 f << " </data-list>" << endl << endl ;
1105 f << "</dataflow>" << endl ;
1111 bool GraphEditor::OutNode::SavePY( ostream & f ) {
1114 f << endl << "# Generated python file of Graph " << Name() << endl << endl ;
1116 f << "from SuperV import *" << endl ;
1118 f << "# Graph creation " << endl ;
1119 GraphBase::DataNode::SavePY( f , Name() , 0 , 0 ) ;
1121 f << endl << "# Creation of Factory Nodes" << endl ;
1122 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1123 if ( GraphNodes( i )->IsFactoryNode() ) {
1125 ((GraphBase::FactoryNode * ) GraphNodes( i ))->SavePY( f , Name() ,
1126 GraphNodes( i )->XCoordinate() ,
1127 GraphNodes( i )->YCoordinate() ) ;
1132 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1133 if ( GraphNodes( i )->IsComputingNode() ) {
1135 f << endl << "# Creation of Computing Nodes" << endl ;
1141 ((GraphBase::ComputingNode * ) GraphNodes( i ))->SavePY( f , Name() ,
1142 GraphNodes( i )->XCoordinate() ,
1143 GraphNodes( i )->YCoordinate() ) ;
1148 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1149 if ( GraphNodes( i )->IsInLineNode() ) {
1151 f << endl << "# Creation of InLine Nodes" << endl ;
1157 ((GraphBase::InLineNode * ) GraphNodes( i ))->SavePY( f , Name() ,
1158 GraphNodes( i )->XCoordinate() ,
1159 GraphNodes( i )->YCoordinate() ) ;
1164 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1165 if ( GraphNodes( i )->IsLoopNode() ) {
1167 f << endl << "# Creation of Loop Nodes" << endl ;
1173 ((GraphBase::LoopNode * ) GraphNodes( i ))->SavePY( f , Name() ,
1174 GraphNodes( i )->XCoordinate() ,
1175 GraphNodes( i )->YCoordinate() ) ;
1180 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1181 if ( GraphNodes( i )->IsSwitchNode() ) {
1183 f << endl << "# Creation of Switch Nodes" << endl ;
1189 ((GraphBase::SwitchNode * ) GraphNodes( i ))->SavePY( f , Name() ,
1190 GraphNodes( i )->XCoordinate() ,
1191 GraphNodes( i )->YCoordinate() ) ;
1196 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1197 if ( GraphNodes( i )->IsGOTONode() ) {
1199 f << endl << "# Creation of GOTO Nodes" << endl ;
1205 ((GraphBase::GOTONode * ) GraphNodes( i ))->SavePY( f , Name() ,
1206 GraphNodes( i )->XCoordinate() ,
1207 GraphNodes( i )->YCoordinate() ) ;
1211 const GraphBase::ListOfLinks * Links = GetLinks() ;
1213 map< string , int > aMapOfOutPorts ;
1215 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1216 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1217 if ( !strcmp( GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1220 << "# Creation of Links"
1227 char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1228 strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1229 strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1230 strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1231 if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1232 aMapOfOutPorts[ NodePort ] = j + 1 ;
1238 LinkSavePY( f , Name() , (*Links)[ j ] , intervar , false ) ;
1239 delete [] NodePort ;
1246 for ( i = 0 ; i < Links->size() ; i++ ) {
1247 if ( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsSwitchNode() ||
1248 GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsSwitchNode() ||
1249 GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsEndSwitchNode() ||
1250 GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsEndSwitchNode() ) {
1253 << "# Creation of Switch Links"
1257 char * NodePort = new char [ strlen( (*Links)[ i ].FromNodeName.c_str() ) +
1258 strlen( (*Links)[ i ].FromServiceParameterName.c_str() ) + 1 ] ;
1259 strcpy( NodePort , (*Links)[ i ].FromNodeName.c_str() ) ;
1260 strcat( NodePort , (*Links)[ i ].FromServiceParameterName.c_str() ) ;
1261 if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1262 aMapOfOutPorts[ NodePort ] = i + 1 ;
1268 LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ;
1269 delete [] NodePort ;
1274 for ( i = 0 ; i < Links->size() ; i++ ) {
1275 if ( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsGOTONode() &&
1276 GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsInLineNode() ) {
1279 << "# Creation of intermediate Output variables and of Loop Links"
1283 char * NodePort = new char [ strlen( (*Links)[ i ].FromNodeName.c_str() ) +
1284 strlen( (*Links)[ i ].FromServiceParameterName.c_str() ) + 1 ] ;
1285 strcpy( NodePort , (*Links)[ i ].FromNodeName.c_str() ) ;
1286 strcat( NodePort , (*Links)[ i ].FromServiceParameterName.c_str() ) ;
1287 if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1288 aMapOfOutPorts[ NodePort ] = i + 1 ;
1294 LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ;
1295 delete [] NodePort ;
1300 const GraphBase::ListOfLinks * Datas = GetDatas() ;
1302 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1304 f << endl << "# Creation of Input datas" << endl ;
1307 LinkSavePY( f , Name() , (*Datas)[ i ] , false , true ) ;
1311 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = ServiceInParameter() ;
1312 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1313 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1314 const char * aParam = _aParam.c_str() ;
1318 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1319 if ( aParam[ j ] == '\\' ) {
1320 aNodeName = new char[ j+1 ] ;
1321 strncpy( aNodeName , aParam , j ) ;
1322 aNodeName[ j ] = '\0' ;
1323 aPortName = new char[ strlen( aParam ) - j ] ;
1324 strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1328 if ( !GetChangeGraphNode( aNodeName )->GetInPort( aPortName )->IsDataConnected() ) {
1330 f << endl << "# Missing Input datas" << endl ;
1333 f << aNodeName << aPortName << " = " << aNodeName << ".Port( '"
1334 << aPortName << "' )" << endl ;
1336 delete [] aNodeName ;
1337 delete [] aPortName ;
1340 f << endl << "# Creation of Output variables" << endl ;
1341 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = ServiceOutParameter() ;
1342 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1343 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1344 const char * aParam = _aParam.c_str() ;
1348 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1349 if ( aParam[ j ] == '\\' ) {
1350 aNodeName = new char[ j+1 ] ;
1351 strncpy( aNodeName , aParam , j ) ;
1352 aNodeName[ j ] = '\0' ;
1353 aPortName = new char[ strlen( aParam ) - j ] ;
1354 strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1358 f << aNodeName << aPortName << " = " << aNodeName << ".Port( '"
1359 << aPortName << "' )" << endl ;
1360 delete [] aNodeName ;
1361 delete [] aPortName ;
1368 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1369 f << (GraphBase::ComputingNode ) G ;
1372 f << " Nodes : " << G.GraphNodesSize() << " node"
1373 << (G.GraphNodesSize() > 1 ? "s" : "") << endl;
1376 for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) {
1378 // << hex << (void *) G.GraphNodes( i ) << dec << " "
1379 << *G.GraphNodes( i ) << endl;
1382 f << " Links : " << endl ;
1383 for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) {
1384 G.GraphNodes( i )->ListLinks( f ) ;
1387 f << " Datas : " << endl ;
1390 f << "DataFlow " << G.Name() << " is " ;
1391 if ( G.IsNotValid() )
1393 f << "valid and is " ;
1394 if ( G.IsNotExecutable() )
1396 f << "executable." << endl ;
1403 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1405 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1407 fOut << D.Day << "/"
1414 // cdebug_out << "operator<< GraphEditor::Date" << endl;