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_DataFlow.lxx
27 #ifndef _DATAFLOWEDITOR_DATAFLOW_LXX
28 #define _DATAFLOWEDITOR_DATAFLOW_LXX
30 #include "DataFlowEditor_OutNode.hxx"
32 inline void GraphEditor::DataFlow::ReadOnly() {
36 //JR 07.07.2005 : old code from the first prototype
38 inline char * GraphEditor::DataFlow::DataFlowInfo() {
41 GraphEditor::DataFlow::DataFlow aDataFlow = *this ;
42 s << aDataFlow << ends ;
43 return CORBA::string_dup( s.str().c_str() );
46 inline char * GraphEditor::DataFlow::DataNodeInfo() {
49 Graph()->DataNodeInfo( s ) ;
50 return CORBA::string_dup( s.str().c_str() );
53 inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
55 if ( Graph()->GetGraphNode( aNodeName ) )
56 Graph()->GetGraphNode( aNodeName )->NodeInfo( s ) ;
58 s << aNodeName << " not found" << ends ;
59 return CORBA::string_dup( s.str().c_str() );
63 inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
66 _EditedAfterExecution = true ;
67 return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ;
70 inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ,
71 GraphBase::ListOfSGraphs & aListOfDataFlows ) {
74 _EditedAfterExecution = true ;
75 return GraphEditor::OutNode::LoadXml( myFileName , aListOfDataFlows ) ;
78 inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
81 _EditedAfterExecution = true ;
82 return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ;
85 inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) {
86 return GraphEditor::OutNode::SaveXml( myFileName ) ;
89 inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
90 return GraphEditor::OutNode::SavePy( myFileName ) ;
93 // get all DataFlow informations (for a .XML file) :
94 inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetDataFlows() {
95 GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
96 return GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
99 // void DateModification() ;
101 //inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
102 // return GraphEditor::OutNode::GetInfo() ;
105 inline GraphBase::ListOfSNodes * GraphEditor::DataFlow::GetNodes() const {
106 return Graph()->GetNodes() ;
109 inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetLinks() const {
110 return Graph()->GetLinks() ;
113 inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetGraphs() const {
114 return Graph()->GetGraphs() ;
117 inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetDatas() const {
118 return Graph()->GetDatas() ;
121 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
123 return Graph()->GetService() ;
126 inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
127 const SALOME_ModuleCatalog::Service& NodeService ,
128 const char* NodeComponentName ,
129 const char* NodeInterfaceName ,
130 const char* NodeName,
131 const SUPERV::KindOfNode NodeKindOfNode,
132 GraphBase::ListOfFuncName aFuncName ,
133 GraphBase::ListOfPythonFunctions aPythonFunction ,
134 const SUPERV::SDate NodeFirstCreation,
135 const SUPERV::SDate NodeLastModification,
136 const char * NodeEditorRelease,
137 const char * NodeAuthor,
138 const char * NodeComputer,
139 const char * NodeComment,
142 if ( NodeName != NULLSTRING && strlen( NodeName ) ) {
143 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" ) ;
144 // cout << "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
145 cdebug_in << "GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
148 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( NULL )" ) ;
149 // cout << "--> GraphEditor::DataFlow::AddNode( NULL )" << endl ;
150 NodeName = NULLSTRING ;
151 cdebug_in << "GraphEditor::DataFlow::AddNode( NULL )" << endl ;
154 return (GraphEditor::InNode * ) NULL ;
156 _EditedAfterExecution = true ;
157 GraphEditor::InNode * aNode = GraphEditor::OutNode::AddNode( NodeService ,
158 aFuncName , aPythonFunction ,
161 NodeName , NodeKindOfNode ,
163 NodeLastModification ,
165 NodeAuthor , NodeComputer ,
166 NodeComment , NodeX , NodeY ) ;
167 // MESSAGE( "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" ) ;
168 // cout << "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
169 cdebug_out << "GraphEditor::DataFlow::AddNode( " ;
171 cdebug << aNode->Name() << " )" ;
174 cdebug << "NULL ) Node not created" ;
180 inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
181 return GraphEditor::OutNode::GetNode( NodeName ) ;
184 inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
188 _EditedAfterExecution = true ;
189 return GraphEditor::OutNode::RemoveNode( NodeName ) ;
192 inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
193 const char* NewNodeName ) {
197 _EditedAfterExecution = true ;
198 return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ;
201 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
202 const char * aNodeName ) {
203 if ( Graph()->GetGraphNode( aNodeName ) ) {
204 return Graph()->GetGraphNode( aNodeName )->GetService() ;
209 inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
210 _EditedAfterExecution = true ;
211 return GraphEditor::OutNode::Coordinates( X , Y ) ;
214 inline const int GraphEditor::DataFlow::XCoordinate() {
215 return GraphEditor::OutNode::XCoordinate() ;
218 inline const int GraphEditor::DataFlow::YCoordinate() {
219 return GraphEditor::OutNode::YCoordinate() ;
222 inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
223 const int X , const int Y ) {
224 return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ;
227 inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
228 return GraphEditor::OutNode::XCoordinate( NodeName ) ;
231 inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
232 return GraphEditor::OutNode::YCoordinate( NodeName ) ;
235 inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
236 return GraphEditor::OutNode::GetInPort( name ) ;
238 inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
239 return GraphEditor::OutNode::GetOutPort( name ) ;
241 inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
242 return GraphEditor::OutNode::GetChangeInPort( name ) ;
244 inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
245 return GraphEditor::OutNode::GetChangeOutPort( name ) ;
248 inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
249 return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
252 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
253 const char* FromServiceParameterName ,
254 const char* ToNodeName ,
255 const char* ToServiceParameterName ) {
256 // , const CORBA::Any aValue ) {
258 GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ;
260 // GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ;
261 // if ( anOutPort ) {
262 // CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type !
263 _EditedAfterExecution = true ;
264 return GraphEditor::OutNode::AddLink( FromNodeName ,
265 FromServiceParameterName ,
267 ToServiceParameterName ) ;
275 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
276 const char* ToServiceParameterName ,
277 char** FromNodeName ,
278 char** FromServiceParameterName ) {
279 return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
281 FromServiceParameterName ) ;
284 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
285 GraphBase::ComputingNode * aNode ,
286 const char* ToServiceParameterName ) {
287 return Graph()->GetLink( aNode , aNode->GetChangeInPort( ToServiceParameterName ) ) ;
290 inline bool GraphEditor::DataFlow::AddLinkCoord(
291 const char* FromNodeName ,
292 const char* FromServiceParameterName ,
293 const char* ToNodeName ,
294 const char* ToServiceParameterName ,
298 _EditedAfterExecution = true ;
299 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
300 FromServiceParameterName ,
302 ToServiceParameterName ,
306 inline bool GraphEditor::DataFlow::AddLinkCoord(
307 const char* FromNodeName ,
308 const char* FromServiceParameterName ,
309 const char* ToNodeName ,
310 const char* ToServiceParameterName ,
314 _EditedAfterExecution = true ;
315 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
316 FromServiceParameterName ,
318 ToServiceParameterName ,
322 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
323 const char* FromNodeName ,
324 const char* FromServiceParameterName ,
325 const char* ToNodeName ,
326 const char* ToServiceParameterName ,
330 _EditedAfterExecution = true ;
331 return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
332 FromServiceParameterName ,
334 ToServiceParameterName ,
338 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
339 const char* FromNodeName ,
340 const char* FromServiceParameterName ,
341 const char* ToNodeName ,
342 const char* ToServiceParameterName ,
344 _EditedAfterExecution = true ;
345 return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
346 FromServiceParameterName ,
348 ToServiceParameterName ,
352 inline int GraphEditor::DataFlow::GetLinkCoordSize(
353 const char* FromNodeName ,
354 const char* FromServiceParameterName ,
355 const char* ToNodeName ,
356 const char* ToServiceParameterName ) {
357 return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
358 FromServiceParameterName ,
360 ToServiceParameterName ) ;
363 inline bool GraphEditor::DataFlow::GetLinkCoord(
364 const char* FromNodeName ,
365 const char* FromServiceParameterName ,
366 const char* ToNodeName ,
367 const char* ToServiceParameterName ,
369 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
370 FromServiceParameterName ,
372 ToServiceParameterName ,
376 inline bool GraphEditor::DataFlow::GetLinkCoord(
377 const char* FromNodeName ,
378 const char* FromServiceParameterName ,
379 const char* ToNodeName ,
380 const char* ToServiceParameterName ,
381 const int index , long &X , long &Y ) {
382 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
383 FromServiceParameterName ,
385 ToServiceParameterName ,
389 inline bool GraphEditor::DataFlow::RemoveLink(
390 const char* FromNodeName ,
391 const char* FromServiceParameterName ,
392 const char* ToNodeName ,
393 const char* ToServiceParameterName ) {
397 _EditedAfterExecution = true ;
398 return GraphEditor::OutNode::RemoveLink( FromNodeName ,
399 FromServiceParameterName ,
401 ToServiceParameterName ) ;
404 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
405 const char* ToParameterName ,
406 const CORBA::Any aValue ) {
410 return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ;
413 //JR 30.03.2005inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
414 inline const CORBA::Any GraphEditor::DataFlow::GetInData(
415 const char * ToNodeName ,
416 const char * ToParameterName ) {
417 return GraphEditor::OutNode::GetInData( ToNodeName ,
420 //JR 30.03.2005inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
421 inline const CORBA::Any GraphEditor::DataFlow::GetOutData(
422 const char * FromNodeName ,
423 const char * FromParameterName ) {
424 return GraphEditor::OutNode::GetOutData( FromNodeName ,
425 FromParameterName ) ;
428 //JR Optional parameter kLoopSwitch (default = true) :
429 //In some cases we do not need to check the validity of loops and switchs
430 //inline bool GraphEditor::DataFlow::IsValid(bool kLoopSwitch ) {
431 inline bool GraphEditor::DataFlow::IsValid() {
432 // return GraphEditor::OutNode::IsValid( kLoopSwitch ) ;
433 return GraphEditor::OutNode::IsValid() ;
436 inline bool GraphEditor::DataFlow::IsExecutable() {
437 return GraphEditor::OutNode::IsExecutable() ;
440 inline void GraphEditor::DataFlow::Executing() {
441 cdebug << "Editor::DataFlow::Executing() : set _Executing = true " << endl ;
445 inline bool GraphEditor::DataFlow::IsExecuting() {
450 inline void GraphEditor::DataFlow::Editing() {
451 cdebug << "Editor::DataFlow::Editing() : set _Executing = false " << endl ;
455 inline bool GraphEditor::DataFlow::IsEditing() {
456 return !IsExecuting() ;
459 inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) {
460 _EditedAfterExecution = EditedAfterExecution ;
463 inline bool GraphEditor::DataFlow::EditedAfterExecution() {
464 return _EditedAfterExecution ;
467 inline bool GraphEditor::DataFlow::UnValid() {
469 EditedAfterExecution( true ) ;
470 return GraphEditor::OutNode::UnValid() ;
473 inline bool GraphEditor::DataFlow::IsReadOnly() {
477 inline long GraphEditor::DataFlow::LevelMax() {
478 // if ( !IsValid( false ) ) {
479 if ( !IsExecutable() ) {
482 return Graph()->LevelMax() ;
485 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
486 // if ( !IsValid( false ) ) {
487 if ( !IsExecutable() ) {
488 return ((SUPERV::ListOfStrings * ) NULL ) ;
490 return Graph()->LevelNodes( aLevel ) ;
493 inline long GraphEditor::DataFlow::ThreadsMax() {
494 // if ( !IsValid() ) {
495 if ( !IsExecutable() ) {
498 return Graph()->ThreadsMax() ;
501 inline long GraphEditor::DataFlow::SubGraphsNumber() {
502 // if ( !IsValid() ) {
503 if ( !IsExecutable() ) {
506 return Graph()->SubGraphsNumber() ;
509 inline long GraphEditor::DataFlow::SubStreamGraphsNumber() {
510 // if ( !IsValid() ) {
511 if ( !IsExecutable() ) {
514 return StreamGraph()->SubStreamGraphsNumber() ;
517 inline void GraphEditor::DataFlow::Executor(
518 GraphExecutor::DataFlow * DataFlowExecutor ) {
519 // _Executing = true ;
520 _DataFlowExecutor = DataFlowExecutor ;
523 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
524 return _DataFlowExecutor ;