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 const SUPERV::KindOfNode aKindOfNode ) {
52 // Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
53 Set_prof_debug( ORB , DebugFileName ) ;
54 cdebug_in << "GraphEditor::OutNode::OutNode(" ;
56 cdebug << DataFlowName ;
58 cdebug << ")" << endl;
60 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
62 // _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
63 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName ,
64 _prof_debug , _fdebug ) ;
66 else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
67 // _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
68 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName ,
69 _prof_debug , _fdebug ) ;
70 _Graph = _StreamGraph ;
72 _Orb = CORBA::ORB::_duplicate( ORB ) ;
77 cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
80 GraphEditor::OutNode::OutNode(
82 SALOME_NamingService * ptrNamingService ,
83 const SALOME_ModuleCatalog::Service& DataFlowService ,
84 const char * DataFlowComponentName ,
85 const char * DataFlowInterfaceName ,
86 const char * DataFlowName ,
87 const SUPERV::KindOfNode DataFlowkind ,
88 const SUPERV::SDate DataFlowFirstCreation ,
89 const SUPERV::SDate DataFlowLastModification ,
90 const char * DataFlowEditorRelease ,
91 const char * DataFlowAuthor ,
92 const char * DataFlowComputer ,
93 const char * DataFlowComment ,
94 const char * DebugFileName ) {
95 // Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
96 // DataFlowInterfaceName , DataFlowName , DataFlowkind ,
97 // DataFlowFirstCreation , DataFlowLastModification ,
98 // DataFlowEditorRelease , DataFlowAuthor ,
99 // DataFlowComputer , DataFlowComment , DebugFileName ) {
100 Set_prof_debug( ORB , DebugFileName ) ;
102 if ( DataFlowkind == SUPERV::DataFlowGraph ) {
103 _StreamGraph = NULL ;
104 _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
105 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
106 DataFlowFirstCreation , DataFlowLastModification ,
107 DataFlowEditorRelease , DataFlowAuthor ,
108 DataFlowComputer , DataFlowComment ,
109 _prof_debug , _fdebug ) ;
110 // DataFlowComputer , DataFlowComment , DebugFileName ) ;
112 else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
113 _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
114 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
115 DataFlowFirstCreation , DataFlowLastModification ,
116 DataFlowEditorRelease , DataFlowAuthor ,
117 DataFlowComputer , DataFlowComment ,
118 _prof_debug , _fdebug ) ;
119 // DataFlowComputer , DataFlowComment , DebugFileName ) ;
120 _Graph = _StreamGraph ;
122 _Orb = CORBA::ORB::_duplicate( ORB ) ;
125 _Executable = false ;
129 GraphEditor::OutNode::~OutNode() {
130 // delete _DataFlowNode ;
131 // delete _DataFlowDatas ;
135 void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
136 const char * DebugFileName ) {
137 _Graph_prof_debug = 0 ;
139 if ( DebugFileName ) {
140 _fdebug = new ofstream( DebugFileName );
141 SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
142 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
146 bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) {
147 bool RetVal = false ;
148 cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << aDataFlow->Info.theName.c_str()
149 << " GraphNodesSize " << Graph()->GraphNodesSize() << endl;
151 RetVal = LoadInfo( aDataFlow->Info ) ;
154 else if ( Graph()->IsDataStreamNode() || aDataFlow->Info.theKind == SUPERV::DataFlowGraph ) {
157 cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl;
159 map< string , int > aMapOfNodes ;
161 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl;
162 RetVal = LoadNodes( aMapOfNodes , aDataFlow->Nodes ) ;
165 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl;
166 RetVal = LoadLinks( aMapOfNodes , aDataFlow->Links ) ;
170 cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl;
171 RetVal = LoadDatas( aMapOfNodes , aDataFlow->Datas ) ;
173 cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() << endl;
177 bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
178 bool RetVal = false ;
179 GraphBase::SGraph aDataFlow ;
180 if ( myFileName == NULL ) {
181 cdebug << "GraphEditor::OutNode::LoadXml() No file" << endl;
185 else if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) {
186 cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl;
187 RetVal = LoadDataFlow( &aDataFlow ) ;
188 cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl;
193 bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
194 bool RetVal = false ;
195 cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
197 // MESSAGE( "GraphEditor::OutNode::LoadDataFlow" );
198 // ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
199 // InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
200 if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) {
201 Graph()->Name( aDataFlowInfo.theName.c_str() ) ;
202 // Graph()->Kind( aDataFlowInfo.theKind ) ;
203 cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
204 << " Kind() " << Graph()->Kind() << endl ;
205 if ( Graph()->IsDataStreamNode() ) {
206 Graph()->Kind( SUPERV::DataStreamGraph ) ;
207 StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
210 Graph()->Kind( SUPERV::DataFlowGraph ) ;
212 Graph()->SetService( aDataFlowInfo.theService ) ;
213 Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
214 Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
215 Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
216 Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ;
217 // Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ;
218 Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ;
219 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
220 // Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
224 Graph()->Kind( aDataFlowInfo.theKind ) ;
225 cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind
226 << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ;
228 cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ;
232 bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
233 const GraphBase::ListOfNodes &aListOfNodes ) {
234 GraphEditor::InNode * anInNode ;
235 cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ;
237 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
238 GraphBase::SNode aNode = aListOfNodes[ i ] ;
239 const char * aNodeName = aNode.theName.c_str() ;
240 cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
241 << aNode.theListOfInDataStreams.size() << " InDataStreams "
242 << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
243 << " _prof_debug " << _prof_debug << endl ;
244 cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " "
245 << aNode.theListOfInDataStreams.size() << " InDataStreams "
246 << aNode.theListOfOutDataStreams.size() << " OutDataStreams "
248 if ( aNode.theListOfFuncName.size() == 0 ) {
249 aNode.theListOfFuncName.resize( 1 ) ;
250 aNode.theListOfFuncName[ 0 ] = "" ;
251 aNode.theListOfPythonFunctions.resize( 1 ) ;
252 aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
254 if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) {
255 aNodeName = NULLSTRING ;
258 aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ;
259 aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ;
261 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
262 aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
263 aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
264 aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
266 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
267 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
268 aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
269 aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ;
272 anInNode = AddNode( aNode.theService ,
273 aNode.theListOfFuncName ,
274 aNode.theListOfPythonFunctions ,
275 aNode.theComponentName.c_str() ,
276 aNode.theInterfaceName.c_str() , aNodeName ,
278 aNode.theFirstCreation , aNode.theLastModification ,
279 aNode.theEditorRelease.c_str() ,
280 aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
281 aNode.theComment.c_str() ,
282 aNode.theCoords.theX , aNode.theCoords.theY ) ;
283 string * aNodetheName = new string( aNode.theName ) ;
284 aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ;
285 if ( anInNode->IsOneOfInLineNodes() ) {
286 anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
287 _Orb , aNode.theService , anInNode->NamePtr() ,
289 _prof_debug , _fdebug ) ;
290 GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
291 GraphBase::LoopNode * aLNode = NULL ;
292 if ( aINode->IsLoopNode() ) {
293 aLNode = anInNode->LoopNode() ;
294 aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
295 *aNode.theListOfPythonFunctions[ 0 ] ) ;
296 aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
297 *aNode.theListOfPythonFunctions[ 1 ] ) ;
298 aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
299 *aNode.theListOfPythonFunctions[ 2 ] ) ;
301 else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
302 aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
303 aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
304 *aNode.theListOfPythonFunctions[ 0 ] ) ;
308 for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
309 GraphBase::InPort * anInPort ;
310 if ( anInNode->IsOneOfInLineNodes() ) {
311 anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
312 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
313 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
314 SUPERV::DataStreamParameter ) ;
317 anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ;
319 ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
320 aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
321 aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
323 for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
324 GraphBase::OutPort * anOutPort ;
325 if ( anInNode->IsOneOfInLineNodes() ) {
326 anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
327 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
328 aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
329 SUPERV::DataStreamParameter ) ;
332 anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ;
334 ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
336 delete aNodetheName ;
341 for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
342 GraphBase::SNode aNode = aListOfNodes[ i ] ;
343 cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
344 << aNode.theCoupledNode.c_str() << endl ;
345 anInNode = (GraphEditor::InNode * ) Graph()->GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
346 if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
347 GraphBase::GOTONode * aCoupledNode ;
348 aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ;
349 aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
352 cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
356 bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
357 const GraphBase::ListOfLinks &aListOfLinks ) {
359 cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
360 // MESSAGE( "GraphEditor::OutNode::LoadLinks" );
362 for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
363 GraphBase::SLink aLink = aListOfLinks[ i ] ;
364 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
365 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
366 cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( "
367 << aLink.FromServiceParameterName.c_str() << " ) --> "
368 << aLinkToNodeName->c_str() << "( "
369 << aLink.ToServiceParameterName.c_str() << " )" << endl ;
370 if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) &&
371 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) {
372 GraphBase::ComputingNode * aFromNode = (GraphBase::ComputingNode * ) Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) ;
373 const GraphBase::OutPort * anOutPort = aFromNode->GetOutPort( aLink.FromServiceParameterName.c_str() ) ;
374 RetVal = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
375 aLink.FromServiceParameterName.c_str() ,
376 Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
377 aLink.ToServiceParameterName.c_str() ,
378 *anOutPort->Value() ) ;
383 // aLink.aLinkValue ) ;
387 for ( j = 0 ; j < (int ) aLink.aListOfCoords.size() ; j++ ) {
388 RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
389 aLink.FromServiceParameterName.c_str() ,
390 Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
391 aLink.ToServiceParameterName.c_str() ,
393 aLink.aListOfCoords[j].theX ,
394 aLink.aListOfCoords[j].theY ) ;
399 delete aLinkFromNodeName ;
400 delete aLinkToNodeName ;
402 cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
406 bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
407 const GraphBase::ListOfLinks &aListOfDatas ) {
409 cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
410 // MESSAGE( "GraphEditor::OutNode::LoadDatas" );
412 for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
413 GraphBase::SLink aLink = aListOfDatas[ i ] ;
414 if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) ) {
415 cdebug << "GraphEditor::OutNode::LoadDatas Warning "
416 << aLink.FromNodeName.c_str()
417 << " and " << aLink.ToNodeName.c_str() << " differents from " << Graph()->Name()
420 string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
421 string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
422 // cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
423 // << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
424 // cout << " " << aLink.ToNodeName.c_str() << " "
425 // << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
426 RetVal = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
427 aLink.ToServiceParameterName.c_str() ,
429 delete aLinkFromNodeName ;
430 delete aLinkToNodeName ;
434 cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
438 bool GraphEditor::OutNode::SaveXml(const char* filename) {
440 cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
441 ofstream f(filename);
443 // test = SaveXML( f );
445 test = SaveXML( Graph );
447 QString xml = Graph.toString() ;
448 // cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
451 cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
456 bool GraphEditor::OutNode::SavePy( const char* filename ) {
458 cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
459 ofstream f( filename ) ;
462 cdebug_out << "GraphEditor::OutNode::SavePy" << endl;
466 GraphBase::SGraph * GraphEditor::OutNode::GetDataFlow() {
467 GraphBase::SGraph * aDataFlow = new GraphBase::SGraph;
468 if ( Graph()->IsDataFlowNode() ) {
469 aDataFlow->Info = *Graph()->GetInfo() ;
470 aDataFlow->Nodes = *Graph()->GetNodes() ;
471 aDataFlow->Links = *Graph()->GetLinks( true ) ;
472 aDataFlow->Datas = *Graph()->GetDatas() ;
475 aDataFlow->Info = *StreamGraph()->GetInfo() ;
476 aDataFlow->Nodes = *StreamGraph()->GetNodes() ;
477 aDataFlow->Links = *StreamGraph()->GetLinks( true ) ;
478 aDataFlow->Datas = *StreamGraph()->GetDatas() ;
483 void GraphEditor::OutNode::DateModification() {
484 time_t T = time(NULL);
485 struct tm * Tm = localtime(&T);
486 SUPERV::SDate aLastModificationDate ;
488 aLastModificationDate.Second = Tm->tm_sec;
489 aLastModificationDate.Minute = Tm->tm_min;
490 aLastModificationDate.Hour = Tm->tm_hour;
491 aLastModificationDate.Day = Tm->tm_mday;
492 aLastModificationDate.Month = Tm->tm_mon + 1;
493 aLastModificationDate.Year = Tm->tm_year + 1900;
494 Graph()->LastModification( aLastModificationDate ) ;
497 void GraphEditor::OutNode::Coordinates( const char* NodeName ,
500 ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
503 const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
504 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ;
507 const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
508 return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ;
511 GraphEditor::InNode * GraphEditor::OutNode::AddNode(
512 const SALOME_ModuleCatalog::Service& NodeService ,
513 GraphBase::ListOfFuncName aFuncName ,
514 GraphBase::ListOfPythonFunctions aPythonFunction ,
515 const char * NodeComponentName ,
516 const char * NodeInterfaceName ,
517 const char * theNodeName ,
518 const SUPERV::KindOfNode NodeKindOfNode ,
519 const SUPERV::SDate NodeFirstCreation ,
520 const SUPERV::SDate NodeLastModification ,
521 const char * NodeEditorRelease ,
522 const char * NodeAuthor ,
523 const char * NodeComputer ,
524 const char * NodeComment ,
527 cdebug_in << "GraphEditor::OutNode::AddNode( " ;
528 if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) {
529 cdebug << "Component('" << NodeComponentName << "') , Node('" ;
532 cdebug << "NodeComponentName[NULL] )" << endl;
534 if ( theNodeName == NULL ) {
535 theNodeName = NULLSTRING ;
537 if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) {
538 cdebug << theNodeName << "' )" ;
541 cdebug << "NodeName[NULLSTRING]' )" ;
543 cdebug << " " << NodeKindOfNode << endl ;
544 char * RetVal = NULLSTRING ;
545 GraphEditor::InNode *Nd = NULL ;
546 char * aNodeName = NULL ;
547 bool GeneratedName = false ;
548 if ( NodeKindOfNode == SUPERV::InLineNode ||
549 NodeKindOfNode == SUPERV::LoopNode ||
550 NodeKindOfNode == SUPERV::EndLoopNode ||
551 NodeKindOfNode == SUPERV::SwitchNode ||
552 NodeKindOfNode == SUPERV::EndSwitchNode ||
553 NodeKindOfNode == SUPERV::GOTONode ) {
554 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
555 if ( NodeKindOfNode == SUPERV::InLineNode ) {
556 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
558 else if ( NodeKindOfNode == SUPERV::LoopNode ) {
559 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
561 else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
562 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
564 else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
565 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
567 else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
568 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
570 else if ( NodeKindOfNode == SUPERV::GOTONode ) {
571 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
575 ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
577 theNodeName = NULLSTRING ;
579 if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) {
580 aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
581 strcpy( aNodeName , NodeService.ServiceName ) ;
582 if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) {
583 GeneratedName = true ;
584 while ( Graph()->GetGraphNode( aNodeName ) ) {
586 delete [] aNodeName ;
588 int num = Graph()->GetServiceNameNumber( NodeService ) ;
590 astr << num << ends ;
591 const char * n_instance = astr.str().c_str() ;
592 int lname = strlen( NodeService.ServiceName ) + 1 +
593 strlen( n_instance ) + 1 ;
594 aNodeName = new char[lname] ;
595 strcpy( aNodeName , NodeService.ServiceName ) ;
596 strcat( aNodeName , "_" ) ;
597 strcat( aNodeName , n_instance ) ;
602 if ( Graph()->GetGraphNode( theNodeName ) == NULL ) {
603 aNodeName = new char[ strlen( theNodeName )+1 ] ;
604 strcpy( aNodeName , theNodeName ) ;
607 if ( aNodeName != NULLSTRING ) {
608 Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() ,
609 aFuncName , aPythonFunction , NodeService ,
610 NodeComponentName , NodeInterfaceName ,
611 aNodeName , NodeKindOfNode ,
612 NodeFirstCreation , NodeLastModification ,
613 NodeEditorRelease , NodeAuthor ,
614 NodeComputer , NodeComment , GeneratedName ,
616 _prof_debug , _fdebug ) ;
617 // MESSAGE( "GraphEditor::OutNode::AddNode " << hex << (void *) Nd << dec );
618 // if ( GraphBase::Graph::AddNode( Nd ) ) {
620 if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) {
622 for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) {
623 GraphBase::InDataStreamPort * aDataStreamPort ;
624 aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort(
625 my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) ,
626 NodeService.ServiceinDataStreamParameter[i].Parametertype ,
627 NodeService.ServiceinDataStreamParameter[i].Parameterdependency ,
628 SUPERV::DataStreamParameter ) ;
630 for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) {
631 GraphBase::OutDataStreamPort * aDataStreamPort ;
632 aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort(
633 my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) ,
634 NodeService.ServiceoutDataStreamParameter[i].Parametertype ,
635 NodeService.ServiceoutDataStreamParameter[i].Parameterdependency ,
636 SUPERV::DataStreamParameter ) ;
640 if ( Graph()->AddNode( Nd->ComputingNode() ) ) {
642 RetVal = Nd->Name() ;
645 cdebug << "NodeName already exists." << endl ;
649 cdebug << "ERROR NodeName is NULL or already exists." << endl ;
651 // delete [] aNodeName ;
652 cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
657 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
658 const char* FromServiceParameterName ,
659 const char* ToNodeName ,
660 const char* ToServiceParameterName ,
664 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
665 ToServiceParameterName ) ;
666 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
667 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
669 if ( anInPort->IsEndSwitch() ) {
670 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
672 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
675 return anInPort->AddCoord( nXY , X , Y ) ;
681 bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
682 const char* FromServiceParameterName ,
683 const char* ToNodeName ,
684 const char* ToServiceParameterName ,
688 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
689 ToServiceParameterName ) ;
690 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
691 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
693 if ( anInPort->IsEndSwitch() ) {
694 // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
696 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
699 return anInPort->AddCoord( index , X , Y ) ;
705 bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
706 const char* FromServiceParameterName ,
707 const char* ToNodeName ,
708 const char* ToServiceParameterName ,
712 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
713 ToServiceParameterName ) ;
714 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
715 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
717 if ( anInPort->IsEndSwitch() ) {
718 // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
720 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
723 return anInPort->ChangeCoord( index , X , Y ) ;
729 bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
730 const char* FromServiceParameterName ,
731 const char* ToNodeName ,
732 const char* ToServiceParameterName ,
734 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
735 ToServiceParameterName ) ;
736 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
737 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
739 if ( anInPort->IsEndSwitch() ) {
740 // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
742 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
745 return anInPort->RemoveCoord( index ) ;
751 int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
752 const char* FromServiceParameterName ,
753 const char* ToNodeName ,
754 const char* ToServiceParameterName ) {
755 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
756 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
757 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
759 if ( anInPort->IsEndSwitch() ) {
760 // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
762 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
765 return anInPort->GetCoord() ;
771 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
772 const char* FromServiceParameterName ,
773 const char* ToNodeName ,
774 const char* ToServiceParameterName ,
776 const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ;
777 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
778 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
780 if ( anInPort->IsEndSwitch() ) {
781 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
783 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
786 return anInPort->GetCoord( X , Y ) ;
792 bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
793 const char* FromServiceParameterName ,
794 const char* ToNodeName ,
795 const char* ToServiceParameterName ,
796 const int index , long &X , long &Y ) {
797 GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName ,
798 ToServiceParameterName ) ;
799 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
800 // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
802 if ( anInPort->IsEndSwitch() ) {
803 // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
805 return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
808 return anInPort->GetCoord( index , X , Y ) ;
814 bool GraphEditor::OutNode::AddInputData( const char* ToNodeName1 ,
815 const char* ToParameterName1 ,
816 const char* ToNodeName2 ,
817 const char* ToParameterName2 ) {
818 cdebug_in << "GraphEditor::OutNode::AddInputData" << endl;
819 bool RetVal = Graph()->AddInputData( ToNodeName1 ,
823 cdebug_out << "GraphEditor::OutNode::AddInputData" << endl;
828 bool GraphEditor::OutNode::Valid() {
832 cdebug_in << "GraphEditor::OutNode::Valid" << endl;
833 _Executable = false ;
835 Graph()->CreateService() ;
837 int SubStreamGraphsNumber = 0 ;
838 if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
839 cdebug << "This DataFlow is not valid." << endl ;
842 if ( Graph()->IsDataStreamNode() ) {
843 StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
848 Graph()->InLineServices() ;
850 Graph()->ComputingNodes() ;
854 cdebug_out << "GraphEditor::OutNode::Valid" << endl;
858 bool GraphEditor::OutNode::Executable() {
859 cdebug_in << "GraphEditor::OutNode::Executable" << endl;
861 if ( Graph()->LinkLoopNodes( NewLink ) ) {
867 cdebug << "This DataFlow is not executable." << endl ;
868 _Executable = false ;
876 if ( Graph()->DataServerNodes() )
879 cdebug << "This DataFlow is not executable." << endl ;
880 _Executable = false ;
883 if ( _Executable && Graph()->IsDataStreamNode() ) {
884 StreamGraph()->CreateStreamTopology( "/tmp/" ) ;
887 cdebug_out << "GraphEditor::OutNode::Executable" << endl;
891 const CORBA::Any *GraphEditor::OutNode::GetInData(
892 const char * ToNodeName ,
893 const char * ToParameterName ) {
894 // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName
895 // << " " << ToParameterName << endl ;
896 const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ;
897 // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ;
901 const CORBA::Any *GraphEditor::OutNode::GetOutData(
902 const char * FromNodeName ,
903 const char * FromParameterName ) {
904 // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName
905 // << " " << FromParameterName << endl ;
906 const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ;
907 // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ;
911 //bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
912 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
913 GraphBase::SLink aLink ,
915 cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
916 << "(" << aLink.FromServiceParameterName << ") --> "
917 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ;
918 QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
920 if ( strlen( aLink.FromNodeName.c_str() ) ) {
921 // f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
922 // << "</fromnode-name>" << endl ;
923 aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
926 // f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
927 aField = Graph.createTextNode( "?" ) ;
929 link.appendChild( fromnodename ) ;
930 fromnodename.appendChild( aField ) ;
932 // f << Tabs << "<fromserviceparameter-name>"
933 // << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
935 QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
936 aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
937 link.appendChild( fromserviceparametername ) ;
938 fromserviceparametername.appendChild( aField ) ;
940 QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
941 if ( strlen( aLink.ToNodeName.c_str() ) ) {
942 // f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
943 // << "</tonode-name>" << endl ;
944 aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
947 // f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
948 aField = Graph.createTextNode( "?" ) ;
950 link.appendChild( tonodename ) ;
951 tonodename.appendChild( aField ) ;
953 // f << Tabs << "<toserviceparameter-name>"
954 // << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
956 QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
957 aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
958 link.appendChild( toserviceparametername ) ;
959 toserviceparametername.appendChild( aField ) ;
962 // f << Tabs << "<data-value>" << endl ;
963 QDomElement datavalue = Graph.createElement( "data-value" ) ;
964 link.appendChild( datavalue ) ;
965 // f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
966 // << "</value-type>" << endl ;
967 QDomElement valuetype = Graph.createElement( "value-type" ) ;
969 aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
970 aField = Graph.createTextNode( aKind ) ;
971 datavalue.appendChild( valuetype ) ;
972 valuetype.appendChild( aField ) ;
973 switch (aLink.aLinkValue.type()->kind()) {
974 case CORBA::tk_string: {
976 aLink.aLinkValue >>= retstr;
977 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
978 QDomElement value = Graph.createElement( "value" ) ;
979 aField = Graph.createTextNode( retstr ) ;
980 datavalue.appendChild( value ) ;
981 value.appendChild( aField ) ;
982 // MESSAGE( "ToString( string ) " << retstr );
985 case CORBA::tk_double: {
987 aLink.aLinkValue >>= d;
988 // f << Tabs << " <value>" << d << "</value>" << endl ;
989 QDomElement value = Graph.createElement( "value" ) ;
991 aKind = aKind.setNum( d ) ;
992 aField = Graph.createTextNode( aKind ) ;
993 datavalue.appendChild( value ) ;
994 value.appendChild( aField ) ;
995 // MESSAGE( "ToString( double ) " << d );
998 case CORBA::tk_long: {
1000 aLink.aLinkValue >>= l;
1001 // f << Tabs << " <value>" << l << "</value>" << endl ;
1002 QDomElement value = Graph.createElement( "value" ) ;
1004 aKind = aKind.setNum( l ) ;
1005 aField = Graph.createTextNode( aKind ) ;
1006 datavalue.appendChild( value ) ;
1007 value.appendChild( aField ) ;
1008 // MESSAGE( "ToString( long ) " << l );
1011 case CORBA::tk_objref: {
1013 CORBA::Object_ptr obj ;
1014 aLink.aLinkValue >>= obj ;
1015 retstr = _Orb->object_to_string(obj );
1016 // f << Tabs << " <value>" << retstr << "</value>" << endl ;
1017 QDomElement value = Graph.createElement( "value" ) ;
1018 aField = Graph.createTextNode( retstr ) ;
1019 datavalue.appendChild( value ) ;
1020 value.appendChild( aField ) ;
1021 // MESSAGE( "ToString( object ) " << retstr );
1025 // f << Tabs << " <value>?</value>" << endl ;
1026 QDomElement value = Graph.createElement( "value" ) ;
1027 aField = Graph.createTextNode( "?" ) ;
1028 datavalue.appendChild( value ) ;
1029 value.appendChild( aField ) ;
1030 // MESSAGE( "Unknown CORBA::Any Type" );
1034 // f << Tabs << "</data-value>" << endl ;
1036 // f << Tabs << "<coord-list>" << endl ;
1037 QDomElement coordlist = Graph.createElement( "coord-list" ) ;
1038 link.appendChild( coordlist ) ;
1041 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1042 // f << Tabs << " <coord>" << endl ;
1043 QDomElement coord = Graph.createElement( "coord" ) ;
1044 coordlist.appendChild( coord ) ;
1045 // f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
1046 QDomElement x = Graph.createElement( "x" ) ;
1048 ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
1049 aField = Graph.createTextNode( ax ) ;
1050 coord.appendChild( x ) ;
1051 x.appendChild( aField ) ;
1052 // f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
1053 QDomElement y = Graph.createElement( "y" ) ;
1055 ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
1056 aField = Graph.createTextNode( ay ) ;
1057 coord.appendChild( y ) ;
1058 y.appendChild( aField ) ;
1059 // f << Tabs << " </coord>" << endl ;
1061 // f << Tabs << "</coord-list>" << endl ;
1062 cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName
1063 << "(" << aLink.FromServiceParameterName << ") --> "
1064 << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")"
1069 bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
1070 GraphBase::SLink aLink ,
1071 bool fromparam , bool toparam ,
1072 bool wdata ) const {
1074 // if ( intervar ) {
1075 // f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1077 // << aLink.FromNodeName.c_str() << ".GetOutPort( '"
1078 // << aLink.FromServiceParameterName.c_str()
1079 // << "' )" << endl ;
1081 f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1082 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ;
1083 if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) {
1084 f << " = " << aGraphName << ".StreamLink( " ;
1087 f << " = " << aGraphName << ".Link( " ;
1089 // if ( !fromparam ) {
1092 f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ;
1093 // if ( !toparam ) {
1096 f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ;
1099 f << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
1100 // << " = " << aLink.ToNodeName.c_str() << ".Input( '"
1101 // << aLink.ToServiceParameterName.c_str() << "' , " ;
1103 switch (aLink.aLinkValue.type()->kind()) {
1104 case CORBA::tk_string: {
1106 aLink.aLinkValue >>= retstr;
1107 f << "'" << retstr << "'" ;
1110 case CORBA::tk_double: {
1112 aLink.aLinkValue >>= d;
1116 case CORBA::tk_long: {
1118 aLink.aLinkValue >>= l;
1122 case CORBA::tk_objref: {
1124 CORBA::Object_ptr obj ;
1125 aLink.aLinkValue >>= obj ;
1126 retstr = _Orb->object_to_string(obj );
1127 f << "'" << retstr << "'" ;
1132 // MESSAGE( "Unknown CORBA::Any Type" );
1139 for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) {
1140 f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
1141 << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
1142 << aLink.aListOfCoords[ i ].theX << " , "
1143 << aLink.aListOfCoords[ i ].theY << " )" << endl ;
1148 //bool GraphEditor::OutNode::SaveXML(ostream & f ) {
1149 bool GraphEditor::OutNode::SaveXML(QDomDocument & GraphQDom ) {
1151 // f << "<?xml version='1.0' encoding='us-ascii' ?>" << endl << endl ;
1152 // f << "<!-- XML Dataflow -->" << endl << endl ;
1153 // f << "<!-- Dataflow information -->" << endl ;
1154 QString Dataflow("Dataflow") ;
1155 GraphQDom = QDomDocument(Dataflow) ;
1156 // f << "<dataflow>" << endl ;
1157 QDomElement dataflow = GraphQDom.createElement( "dataflow" ) ;
1158 GraphQDom.appendChild( dataflow ) ;
1159 // f << " <info-list>" << endl ;
1160 QDomElement info = GraphQDom.createElement( "info-list" ) ;
1161 dataflow.appendChild( info ) ;
1163 // f << " <node>" << endl ;
1165 // GraphBase::DataNode::SaveXML( f , " " , 0 , 0 ) ;
1166 Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ;
1168 // f << " </node>" << endl ;
1170 // f << " </info-list>" << endl << endl ;
1172 // f << " <node-list>" << endl ;
1173 QDomElement nodelist = GraphQDom.createElement( "node-list" ) ;
1174 dataflow.appendChild( nodelist ) ;
1175 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1176 // f << " <node>" << endl ;
1177 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1178 // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
1180 ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1181 Graph()->GraphNodes( i )->XCoordinate() ,
1182 Graph()->GraphNodes( i )->YCoordinate() ) ;
1184 else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1185 // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
1187 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1188 Graph()->GraphNodes( i )->XCoordinate() ,
1189 Graph()->GraphNodes( i )->YCoordinate() ) ;
1191 else if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1192 // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
1194 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1195 Graph()->GraphNodes( i )->XCoordinate() ,
1196 Graph()->GraphNodes( i )->YCoordinate() ) ;
1198 else if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1199 // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
1201 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1202 Graph()->GraphNodes( i )->XCoordinate() ,
1203 Graph()->GraphNodes( i )->YCoordinate() ) ;
1205 else if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1206 // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
1208 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1209 Graph()->GraphNodes( i )->XCoordinate() ,
1210 Graph()->GraphNodes( i )->YCoordinate() ) ;
1212 else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) {
1213 // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
1215 ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1216 Graph()->GraphNodes( i )->XCoordinate() ,
1217 Graph()->GraphNodes( i )->YCoordinate() ) ;
1219 else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1220 // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1222 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1223 Graph()->GraphNodes( i )->XCoordinate() ,
1224 Graph()->GraphNodes( i )->YCoordinate() ) ;
1226 else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) {
1227 // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
1229 ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist ,
1230 Graph()->GraphNodes( i )->XCoordinate() ,
1231 Graph()->GraphNodes( i )->YCoordinate() ) ;
1233 // f << " </node>" << endl ;
1236 // f << " </node-list>" << endl << endl ;
1238 // f << " <link-list>" << endl ;
1239 QDomElement linklist = GraphQDom.createElement( "link-list" ) ;
1240 dataflow.appendChild( linklist ) ;
1241 const GraphBase::ListOfLinks * Links = Graph()->GetLinks( true ) ;
1242 for ( i = 0 ; i < (int ) Links->size() ; i++ ) {
1243 // f << " <link>" << endl ;
1244 QDomElement link = GraphQDom.createElement( "link" ) ;
1245 linklist.appendChild( link ) ;
1246 // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
1247 LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ;
1248 // f << " </link>" << endl ;
1250 // f << " </link-list>" << endl << endl ;
1252 // f << " <data-list>" << endl ;
1253 QDomElement datalist = GraphQDom.createElement( "data-list" ) ;
1254 dataflow.appendChild( datalist ) ;
1255 const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ;
1256 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1257 // f << " <data>" << endl ;
1258 QDomElement data = GraphQDom.createElement( "data" ) ;
1259 datalist.appendChild( data ) ;
1260 // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
1261 LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ;
1262 // f << " </data>" << endl ;
1265 // const GraphEditor::OutNode * aDataNode = (GraphEditor::OutNode *) this ;
1266 // if ( aDataNode ) {
1268 // for ( i = 0 ; i < aDataNode->GetNodeOutPortsSize() ; i++ ) {
1269 // const GraphBase::InPort *aLink = aDataNode->GetNodeOutPort(i)->GetLink() ;
1271 // f << " <data>" << endl ;
1272 // aLink->SaveXML( f , " " ) ;
1273 // f << " </data>" << endl ;
1276 // for ( i = 0 ; i < aDataNode->GetNodeInPortsSize() ; i++ ) {
1277 // const GraphBase::InPort *aLink = aDataNode->GetNodeInPort(i)->GetLink() ;
1279 // f << " <data>" << endl ;
1280 // aLink->SaveXML( f , " " ) ;
1281 // f << " </data>" << endl ;
1288 f << " </data-list>" << endl << endl ;
1289 f << "</dataflow>" << endl ;
1295 bool GraphEditor::OutNode::SavePY( ostream & f ) {
1298 f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ;
1300 f << "from SuperV import *" << endl ;
1302 f << "# Graph creation " << endl ;
1303 Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ;
1305 f << endl << "# Creation of Factory Nodes" << endl ;
1306 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1307 if ( Graph()->GraphNodes( i )->IsFactoryNode() ) {
1309 ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1310 Graph()->GraphNodes( i )->XCoordinate() ,
1311 Graph()->GraphNodes( i )->YCoordinate() ) ;
1316 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1317 if ( Graph()->GraphNodes( i )->IsComputingNode() ) {
1319 f << endl << "# Creation of Computing Nodes" << endl ;
1325 ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1326 Graph()->GraphNodes( i )->XCoordinate() ,
1327 Graph()->GraphNodes( i )->YCoordinate() ) ;
1332 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1333 if ( Graph()->GraphNodes( i )->IsInLineNode() ) {
1335 f << endl << "# Creation of InLine Nodes" << endl ;
1341 ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1342 Graph()->GraphNodes( i )->XCoordinate() ,
1343 Graph()->GraphNodes( i )->YCoordinate() ) ;
1348 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1349 if ( Graph()->GraphNodes( i )->IsLoopNode() ) {
1351 f << endl << "# Creation of Loop Nodes" << endl ;
1357 ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1358 Graph()->GraphNodes( i )->XCoordinate() ,
1359 Graph()->GraphNodes( i )->YCoordinate() ) ;
1364 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1365 if ( Graph()->GraphNodes( i )->IsSwitchNode() ) {
1367 f << endl << "# Creation of Switch Nodes" << endl ;
1373 ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1374 Graph()->GraphNodes( i )->XCoordinate() ,
1375 Graph()->GraphNodes( i )->YCoordinate() ) ;
1380 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1381 if ( Graph()->GraphNodes( i )->IsGOTONode() ) {
1383 f << endl << "# Creation of GOTO Nodes" << endl ;
1389 ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() ,
1390 Graph()->GraphNodes( i )->XCoordinate() ,
1391 Graph()->GraphNodes( i )->YCoordinate() ) ;
1395 const GraphBase::ListOfLinks * Links = Graph()->GetLinks() ;
1397 // map< string , int > aMapOfOutPorts ;
1399 for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
1400 for ( j = 0 ; j < (int ) Links->size() ; j++ ) {
1401 if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) {
1404 << "# Creation of Links"
1411 // char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) +
1412 // strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ;
1413 // strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ;
1414 // strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ;
1415 // if ( aMapOfOutPorts[ NodePort ] == 0 ) {
1416 // aMapOfOutPorts[ NodePort ] = j + 1 ;
1417 // intervar = true ;
1420 // intervar = false ;
1422 bool fromparam = false ;
1423 if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) {
1426 bool toparam = false ;
1427 if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) {
1430 LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ;
1431 // delete [] NodePort ;
1436 const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ;
1438 for ( i = 0 ; i < (int ) Datas->size() ; i++ ) {
1440 f << endl << "# Input datas" << endl ;
1443 bool fromparam = true ;
1444 bool toparam = true ;
1445 LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ;
1449 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ;
1450 for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) {
1451 string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
1452 const char * aParam = _aParam.c_str() ;
1456 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1457 if ( aParam[ j ] == '\\' ) {
1458 aNodeName = new char[ j+1 ] ;
1459 strncpy( aNodeName , aParam , j ) ;
1460 aNodeName[ j ] = '\0' ;
1461 aPortName = new char[ strlen( aParam ) - j ] ;
1462 strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1466 const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ;
1467 if ( !anInPort->IsDataConnected() ) {
1469 f << endl << "# Input Ports of the graph" << endl ;
1472 f << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '"
1473 << aPortName << "' )" << endl ;
1475 delete [] aNodeName ;
1476 delete [] aPortName ;
1479 f << endl << "# Output Ports of the graph" << endl ;
1480 const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ;
1481 for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) {
1482 string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
1483 const char * aParam = _aParam.c_str() ;
1487 for ( j = 0 ; j < (int ) strlen( aParam ) ; j++ ) {
1488 if ( aParam[ j ] == '\\' ) {
1489 aNodeName = new char[ j+1 ] ;
1490 strncpy( aNodeName , aParam , j ) ;
1491 aNodeName[ j ] = '\0' ;
1492 aPortName = new char[ strlen( aParam ) - j ] ;
1493 strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
1497 f << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '"
1498 << aPortName << "' )" << endl ;
1499 delete [] aNodeName ;
1500 delete [] aPortName ;
1507 ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) {
1508 f << (GraphBase::ComputingNode ) *(G.Graph()) ;
1511 f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node"
1512 << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl;
1515 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1517 // << hex << (void *) G.Graph().GraphNodes( i ) << dec << " "
1518 << (G.Graph())->GraphNodes( i ) << endl;
1521 f << " Links : " << endl ;
1522 for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) {
1523 (G.Graph())->GraphNodes( i )->ListLinks( f ) ;
1526 f << " Datas : " << endl ;
1527 (G.Graph())->ListDatas( f ) ;
1529 f << "DataFlow " << (G.Graph())->Name() << " is " ;
1530 if ( G.IsNotValid() )
1532 f << "valid and is " ;
1533 if ( G.IsNotExecutable() )
1535 f << "executable." << endl ;
1542 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
1544 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1546 fOut << D.Day << "/"
1553 // cdebug_out << "operator<< GraphEditor::Date" << endl;