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 ) {
70 _EditedAfterExecution = true ;
71 return GraphEditor::OutNode::LoadXml( myFileName ) ;
74 inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
77 _EditedAfterExecution = true ;
78 return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ;
81 inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) {
82 return GraphEditor::OutNode::SaveXml( myFileName ) ;
85 inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
86 return GraphEditor::OutNode::SavePy( myFileName ) ;
89 // get all DataFlow informations (for a .XML file) :
90 inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() {
91 return GraphEditor::OutNode::GetDataFlow() ;
94 // void DateModification() ;
96 //inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
97 // return GraphEditor::OutNode::GetInfo() ;
100 inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const {
101 return Graph()->GetNodes() ;
104 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
105 return Graph()->GetLinks() ;
108 inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
109 return Graph()->GetGraphs() ;
112 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
113 return Graph()->GetDatas() ;
116 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
118 return Graph()->GetService() ;
121 inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
122 const SALOME_ModuleCatalog::Service& NodeService ,
123 const char* NodeComponentName ,
124 const char* NodeInterfaceName ,
125 const char* NodeName,
126 const SUPERV::KindOfNode NodeKindOfNode,
127 GraphBase::ListOfFuncName aFuncName ,
128 GraphBase::ListOfPythonFunctions aPythonFunction ,
129 const SUPERV::SDate NodeFirstCreation,
130 const SUPERV::SDate NodeLastModification,
131 const char * NodeEditorRelease,
132 const char * NodeAuthor,
133 const char * NodeComputer,
134 const char * NodeComment,
137 if ( NodeName != NULLSTRING && strlen( NodeName ) ) {
138 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" ) ;
139 // cout << "--> GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
140 cdebug_in << "GraphEditor::DataFlow::AddNode( " << NodeName << " )" << endl ;
143 // MESSAGE( "--> GraphEditor::DataFlow::AddNode( NULL )" ) ;
144 // cout << "--> GraphEditor::DataFlow::AddNode( NULL )" << endl ;
145 NodeName = NULLSTRING ;
146 cdebug_in << "GraphEditor::DataFlow::AddNode( NULL )" << endl ;
149 return (GraphEditor::InNode * ) NULL ;
151 _EditedAfterExecution = true ;
152 GraphEditor::InNode * aNode = GraphEditor::OutNode::AddNode( NodeService ,
153 aFuncName , aPythonFunction ,
156 NodeName , NodeKindOfNode ,
158 NodeLastModification ,
160 NodeAuthor , NodeComputer ,
161 NodeComment , NodeX , NodeY ) ;
162 // MESSAGE( "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" ) ;
163 // cout << "<-- GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
164 cdebug_out << "GraphEditor::DataFlow::AddNode( " << aNode->Name() << " )" << endl ;
168 inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
169 return GraphEditor::OutNode::GetNode( NodeName ) ;
172 inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
176 _EditedAfterExecution = true ;
177 return GraphEditor::OutNode::RemoveNode( NodeName ) ;
180 inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
181 const char* NewNodeName ) {
185 _EditedAfterExecution = true ;
186 return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ;
189 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
190 const char * aNodeName ) {
191 if ( Graph()->GetGraphNode( aNodeName ) ) {
192 return Graph()->GetGraphNode( aNodeName )->GetService() ;
197 inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
198 _EditedAfterExecution = true ;
199 return GraphEditor::OutNode::Coordinates( X , Y ) ;
202 inline const int GraphEditor::DataFlow::XCoordinate() {
203 return GraphEditor::OutNode::XCoordinate() ;
206 inline const int GraphEditor::DataFlow::YCoordinate() {
207 return GraphEditor::OutNode::YCoordinate() ;
210 inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
211 const int X , const int Y ) {
212 return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ;
215 inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
216 return GraphEditor::OutNode::XCoordinate( NodeName ) ;
219 inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
220 return GraphEditor::OutNode::YCoordinate( NodeName ) ;
223 inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
224 return GraphEditor::OutNode::GetInPort( name ) ;
226 inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
227 return GraphEditor::OutNode::GetOutPort( name ) ;
229 inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
230 return GraphEditor::OutNode::GetChangeInPort( name ) ;
232 inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
233 return GraphEditor::OutNode::GetChangeOutPort( name ) ;
236 inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
237 return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
240 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
241 const char* FromServiceParameterName ,
242 const char* ToNodeName ,
243 const char* ToServiceParameterName ,
244 const CORBA::Any aValue ) {
246 GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ;
248 GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ;
250 CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type !
251 _EditedAfterExecution = true ;
252 return GraphEditor::OutNode::AddLink( FromNodeName ,
253 FromServiceParameterName ,
255 ToServiceParameterName ,
263 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
264 const char* ToServiceParameterName ,
265 char** FromNodeName ,
266 char** FromServiceParameterName ) {
267 return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
269 FromServiceParameterName ) ;
272 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
273 GraphBase::ComputingNode * aNode ,
274 const char* ToServiceParameterName ) {
275 return Graph()->GetLink( aNode , aNode->GetChangeInPort( ToServiceParameterName ) ) ;
278 inline bool GraphEditor::DataFlow::AddLinkCoord(
279 const char* FromNodeName ,
280 const char* FromServiceParameterName ,
281 const char* ToNodeName ,
282 const char* ToServiceParameterName ,
286 _EditedAfterExecution = true ;
287 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
288 FromServiceParameterName ,
290 ToServiceParameterName ,
294 inline bool GraphEditor::DataFlow::AddLinkCoord(
295 const char* FromNodeName ,
296 const char* FromServiceParameterName ,
297 const char* ToNodeName ,
298 const char* ToServiceParameterName ,
302 _EditedAfterExecution = true ;
303 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
304 FromServiceParameterName ,
306 ToServiceParameterName ,
310 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
311 const char* FromNodeName ,
312 const char* FromServiceParameterName ,
313 const char* ToNodeName ,
314 const char* ToServiceParameterName ,
318 _EditedAfterExecution = true ;
319 return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
320 FromServiceParameterName ,
322 ToServiceParameterName ,
326 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
327 const char* FromNodeName ,
328 const char* FromServiceParameterName ,
329 const char* ToNodeName ,
330 const char* ToServiceParameterName ,
332 _EditedAfterExecution = true ;
333 return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
334 FromServiceParameterName ,
336 ToServiceParameterName ,
340 inline int GraphEditor::DataFlow::GetLinkCoordSize(
341 const char* FromNodeName ,
342 const char* FromServiceParameterName ,
343 const char* ToNodeName ,
344 const char* ToServiceParameterName ) {
345 return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
346 FromServiceParameterName ,
348 ToServiceParameterName ) ;
351 inline bool GraphEditor::DataFlow::GetLinkCoord(
352 const char* FromNodeName ,
353 const char* FromServiceParameterName ,
354 const char* ToNodeName ,
355 const char* ToServiceParameterName ,
357 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
358 FromServiceParameterName ,
360 ToServiceParameterName ,
364 inline bool GraphEditor::DataFlow::GetLinkCoord(
365 const char* FromNodeName ,
366 const char* FromServiceParameterName ,
367 const char* ToNodeName ,
368 const char* ToServiceParameterName ,
369 const int index , long &X , long &Y ) {
370 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
371 FromServiceParameterName ,
373 ToServiceParameterName ,
377 inline bool GraphEditor::DataFlow::RemoveLink(
378 const char* FromNodeName ,
379 const char* FromServiceParameterName ,
380 const char* ToNodeName ,
381 const char* ToServiceParameterName ) {
385 _EditedAfterExecution = true ;
386 return GraphEditor::OutNode::RemoveLink( FromNodeName ,
387 FromServiceParameterName ,
389 ToServiceParameterName ) ;
392 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
393 const char* ToParameterName ,
394 const CORBA::Any aValue ) {
396 GraphBase::Node *toNode ;
397 GraphBase::InPort *toPort ;
400 NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
401 toNode = GetChangeGraphNode( aNode ) ;
403 toPort = toNode->GetChangeInPort( aPort ) ;
404 if ( toPort && ( toPort->IsConnected() ||
405 toPort->IsDataConnected() ) ) {
406 RemoveLink( toNode->Name() , toPort->PortName() ) ;
418 return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ;
421 inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
422 const char* ToParameterName1 ,
423 const char* ToNodeName2 ,
424 const char* ToParameterName2 ) {
428 return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
429 ToNodeName2 , ToParameterName2 ) ;
432 inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
433 const char * ToNodeName ,
434 const char * ToParameterName ) {
435 return GraphEditor::OutNode::GetInData( ToNodeName ,
438 inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
439 const char * FromNodeName ,
440 const char * FromParameterName ) {
441 return GraphEditor::OutNode::GetOutData( FromNodeName ,
442 FromParameterName ) ;
445 inline bool GraphEditor::DataFlow::IsValid() {
446 return GraphEditor::OutNode::IsValid() ;
449 inline bool GraphEditor::DataFlow::IsExecutable() {
450 return GraphEditor::OutNode::IsExecutable() ;
453 inline bool GraphEditor::DataFlow::IsExecuting() {
454 if ( _DataFlowExecutor ) {
455 if ( _DataFlowExecutor->IsDone() ) {
468 inline bool GraphEditor::DataFlow::IsEditing() {
469 return !IsExecuting() ;
472 inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) {
473 _EditedAfterExecution = EditedAfterExecution ;
476 inline bool GraphEditor::DataFlow::EditedAfterExecution() {
477 return _EditedAfterExecution ;
480 inline bool GraphEditor::DataFlow::IsReadOnly() {
484 inline long GraphEditor::DataFlow::LevelMax() {
488 return Graph()->LevelMax() ;
491 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
493 return ((SUPERV::ListOfStrings * ) NULL ) ;
495 return Graph()->LevelNodes( aLevel ) ;
498 inline long GraphEditor::DataFlow::ThreadsMax() {
502 return Graph()->ThreadsMax() ;
505 inline long GraphEditor::DataFlow::SubGraphsNumber() {
509 return Graph()->SubGraphsNumber() ;
512 inline long GraphEditor::DataFlow::SubStreamGraphsNumber() {
516 return StreamGraph()->SubStreamGraphsNumber() ;
519 inline void GraphEditor::DataFlow::Executor(
520 GraphExecutor::DataFlow * DataFlowExecutor ) {
522 _DataFlowExecutor = DataFlowExecutor ;
525 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
526 return _DataFlowExecutor ;