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 inline char * GraphEditor::DataFlow::DataFlowInfo() {
39 GraphEditor::DataFlow::DataFlow aDataFlow = *this ;
40 s << aDataFlow << ends ;
41 return CORBA::string_dup( s.str().c_str() );
44 inline char * GraphEditor::DataFlow::DataNodeInfo() {
47 Graph()->DataNodeInfo( s ) ;
48 return CORBA::string_dup( s.str().c_str() );
51 inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
53 if ( Graph()->GetGraphNode( aNodeName ) )
54 Graph()->GetGraphNode( aNodeName )->NodeInfo( s ) ;
56 s << aNodeName << " not found" << ends ;
57 return CORBA::string_dup( s.str().c_str() );
60 inline bool GraphEditor::DataFlow::LoadDataFlow( const GraphBase::SGraph * aDataFlow ) {
63 _EditedAfterExecution = true ;
64 return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ;
67 inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ,
68 GraphBase::ListOfSGraphs & aListOfDataFlows ) {
71 _EditedAfterExecution = true ;
72 return GraphEditor::OutNode::LoadXml( myFileName , aListOfDataFlows ) ;
75 inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
78 _EditedAfterExecution = true ;
79 return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ;
82 inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) {
83 return GraphEditor::OutNode::SaveXml( myFileName ) ;
86 inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
87 return GraphEditor::OutNode::SavePy( myFileName ) ;
90 // get all DataFlow informations (for a .XML file) :
91 inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetDataFlows() {
92 GraphBase::ListOfSGraphs * aListOfDataFlows = new GraphBase::ListOfSGraphs;
93 return GraphEditor::OutNode::GetDataFlows( aListOfDataFlows ) ;
96 // void DateModification() ;
98 //inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
99 // return GraphEditor::OutNode::GetInfo() ;
102 inline GraphBase::ListOfSNodes * GraphEditor::DataFlow::GetNodes() const {
103 return Graph()->GetNodes() ;
106 inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetLinks() const {
107 return Graph()->GetLinks() ;
110 inline GraphBase::ListOfSGraphs * GraphEditor::DataFlow::GetGraphs() const {
111 return Graph()->GetGraphs() ;
114 inline GraphBase::ListOfSLinks * GraphEditor::DataFlow::GetDatas() const {
115 return Graph()->GetDatas() ;
118 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
120 return Graph()->GetService() ;
123 inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
124 const SALOME_ModuleCatalog::Service& NodeService ,
125 const char* NodeComponentName ,
126 const char* NodeInterfaceName ,
127 const char* NodeName,
128 const SUPERV::KindOfNode NodeKindOfNode,
129 GraphBase::ListOfFuncName aFuncName ,
130 GraphBase::ListOfPythonFunctions aPythonFunction ,
131 const SUPERV::SDate NodeFirstCreation,
132 const SUPERV::SDate NodeLastModification,
133 const char * NodeEditorRelease,
134 const char * NodeAuthor,
135 const char * NodeComputer,
136 const char * NodeComment,
139 if ( NodeName != NULLSTRING && strlen( NodeName ) ) {
140 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" ) ;
141 // cout << "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
142 cdebug_in << "GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
145 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( NULL )" ) ;
146 // cout << "--> GraphEditor::DataFlow::AddNode( NULL )" << endl ;
147 NodeName = NULLSTRING ;
148 cdebug_in << "GraphEditor::DataFlow::AddNode( NULL )" << endl ;
151 return (GraphEditor::InNode * ) NULL ;
153 _EditedAfterExecution = true ;
154 GraphEditor::InNode * aNode = GraphEditor::OutNode::AddNode( NodeService ,
155 aFuncName , aPythonFunction ,
158 NodeName , NodeKindOfNode ,
160 NodeLastModification ,
162 NodeAuthor , NodeComputer ,
163 NodeComment , NodeX , NodeY ) ;
164 // MESSAGE( "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" ) ;
165 // cout << "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
166 cdebug_out << "GraphEditor::DataFlow::AddNode( " ;
168 cdebug << aNode->Name() << " )" ;
171 cdebug << "NULL ) Node not created" ;
177 inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
178 return GraphEditor::OutNode::GetNode( NodeName ) ;
181 inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
185 _EditedAfterExecution = true ;
186 return GraphEditor::OutNode::RemoveNode( NodeName ) ;
189 inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
190 const char* NewNodeName ) {
194 _EditedAfterExecution = true ;
195 return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ;
198 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
199 const char * aNodeName ) {
200 if ( Graph()->GetGraphNode( aNodeName ) ) {
201 return Graph()->GetGraphNode( aNodeName )->GetService() ;
206 inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
207 _EditedAfterExecution = true ;
208 return GraphEditor::OutNode::Coordinates( X , Y ) ;
211 inline const int GraphEditor::DataFlow::XCoordinate() {
212 return GraphEditor::OutNode::XCoordinate() ;
215 inline const int GraphEditor::DataFlow::YCoordinate() {
216 return GraphEditor::OutNode::YCoordinate() ;
219 inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
220 const int X , const int Y ) {
221 return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ;
224 inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
225 return GraphEditor::OutNode::XCoordinate( NodeName ) ;
228 inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
229 return GraphEditor::OutNode::YCoordinate( NodeName ) ;
232 inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
233 return GraphEditor::OutNode::GetInPort( name ) ;
235 inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
236 return GraphEditor::OutNode::GetOutPort( name ) ;
238 inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
239 return GraphEditor::OutNode::GetChangeInPort( name ) ;
241 inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
242 return GraphEditor::OutNode::GetChangeOutPort( name ) ;
245 inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
246 return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
249 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
250 const char* FromServiceParameterName ,
251 const char* ToNodeName ,
252 const char* ToServiceParameterName ) {
253 // , const CORBA::Any aValue ) {
255 GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ;
257 // GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ;
258 // if ( anOutPort ) {
259 // CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type !
260 _EditedAfterExecution = true ;
261 return GraphEditor::OutNode::AddLink( FromNodeName ,
262 FromServiceParameterName ,
264 ToServiceParameterName ) ;
272 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
273 const char* ToServiceParameterName ,
274 char** FromNodeName ,
275 char** FromServiceParameterName ) {
276 return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
278 FromServiceParameterName ) ;
281 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
282 GraphBase::ComputingNode * aNode ,
283 const char* ToServiceParameterName ) {
284 return Graph()->GetLink( aNode , aNode->GetChangeInPort( ToServiceParameterName ) ) ;
287 inline bool GraphEditor::DataFlow::AddLinkCoord(
288 const char* FromNodeName ,
289 const char* FromServiceParameterName ,
290 const char* ToNodeName ,
291 const char* ToServiceParameterName ,
295 _EditedAfterExecution = true ;
296 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
297 FromServiceParameterName ,
299 ToServiceParameterName ,
303 inline bool GraphEditor::DataFlow::AddLinkCoord(
304 const char* FromNodeName ,
305 const char* FromServiceParameterName ,
306 const char* ToNodeName ,
307 const char* ToServiceParameterName ,
311 _EditedAfterExecution = true ;
312 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
313 FromServiceParameterName ,
315 ToServiceParameterName ,
319 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
320 const char* FromNodeName ,
321 const char* FromServiceParameterName ,
322 const char* ToNodeName ,
323 const char* ToServiceParameterName ,
327 _EditedAfterExecution = true ;
328 return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
329 FromServiceParameterName ,
331 ToServiceParameterName ,
335 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
336 const char* FromNodeName ,
337 const char* FromServiceParameterName ,
338 const char* ToNodeName ,
339 const char* ToServiceParameterName ,
341 _EditedAfterExecution = true ;
342 return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
343 FromServiceParameterName ,
345 ToServiceParameterName ,
349 inline int GraphEditor::DataFlow::GetLinkCoordSize(
350 const char* FromNodeName ,
351 const char* FromServiceParameterName ,
352 const char* ToNodeName ,
353 const char* ToServiceParameterName ) {
354 return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
355 FromServiceParameterName ,
357 ToServiceParameterName ) ;
360 inline bool GraphEditor::DataFlow::GetLinkCoord(
361 const char* FromNodeName ,
362 const char* FromServiceParameterName ,
363 const char* ToNodeName ,
364 const char* ToServiceParameterName ,
366 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
367 FromServiceParameterName ,
369 ToServiceParameterName ,
373 inline bool GraphEditor::DataFlow::GetLinkCoord(
374 const char* FromNodeName ,
375 const char* FromServiceParameterName ,
376 const char* ToNodeName ,
377 const char* ToServiceParameterName ,
378 const int index , long &X , long &Y ) {
379 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
380 FromServiceParameterName ,
382 ToServiceParameterName ,
386 inline bool GraphEditor::DataFlow::RemoveLink(
387 const char* FromNodeName ,
388 const char* FromServiceParameterName ,
389 const char* ToNodeName ,
390 const char* ToServiceParameterName ) {
394 _EditedAfterExecution = true ;
395 return GraphEditor::OutNode::RemoveLink( FromNodeName ,
396 FromServiceParameterName ,
398 ToServiceParameterName ) ;
401 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
402 const char* ToParameterName ,
403 const CORBA::Any aValue ) {
407 return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ;
410 inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
411 const char * ToNodeName ,
412 const char * ToParameterName ) {
413 return GraphEditor::OutNode::GetInData( ToNodeName ,
416 inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
417 const char * FromNodeName ,
418 const char * FromParameterName ) {
419 return GraphEditor::OutNode::GetOutData( FromNodeName ,
420 FromParameterName ) ;
423 //JR Optional parameter kLoopSwitch (default = true) :
424 //In some cases we do not need to check the validity of loops and switchs
425 inline bool GraphEditor::DataFlow::IsValid(bool kLoopSwitch ) {
426 return GraphEditor::OutNode::IsValid( kLoopSwitch ) ;
429 inline bool GraphEditor::DataFlow::IsExecutable() {
430 return GraphEditor::OutNode::IsExecutable() ;
433 inline void GraphEditor::DataFlow::Executing() {
434 cdebug << "Editor::DataFlow::Executing() : set _Executing = true " << endl ;
438 inline bool GraphEditor::DataFlow::IsExecuting() {
443 inline void GraphEditor::DataFlow::Editing() {
444 cdebug << "Editor::DataFlow::Editing() : set _Executing = false " << endl ;
448 inline bool GraphEditor::DataFlow::IsEditing() {
449 return !IsExecuting() ;
452 inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) {
453 _EditedAfterExecution = EditedAfterExecution ;
456 inline bool GraphEditor::DataFlow::EditedAfterExecution() {
457 return _EditedAfterExecution ;
460 inline bool GraphEditor::DataFlow::UnValid() {
462 EditedAfterExecution( true ) ;
463 return GraphEditor::OutNode::UnValid() ;
466 inline bool GraphEditor::DataFlow::IsReadOnly() {
470 inline long GraphEditor::DataFlow::LevelMax() {
471 if ( !IsValid( false ) ) {
474 return Graph()->LevelMax() ;
477 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
478 if ( !IsValid( false ) ) {
479 return ((SUPERV::ListOfStrings * ) NULL ) ;
481 return Graph()->LevelNodes( aLevel ) ;
484 inline long GraphEditor::DataFlow::ThreadsMax() {
488 return Graph()->ThreadsMax() ;
491 inline long GraphEditor::DataFlow::SubGraphsNumber() {
495 return Graph()->SubGraphsNumber() ;
498 inline long GraphEditor::DataFlow::SubStreamGraphsNumber() {
502 return StreamGraph()->SubStreamGraphsNumber() ;
505 inline void GraphEditor::DataFlow::Executor(
506 GraphExecutor::DataFlow * DataFlowExecutor ) {
507 // _Executing = true ;
508 _DataFlowExecutor = DataFlowExecutor ;
511 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
512 return _DataFlowExecutor ;