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 GraphBase::DataNode::DataNodeInfo( s ) ;
48 return CORBA::string_dup( s.str().c_str() );
51 inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
53 if ( GetGraphNode( aNodeName ) )
54 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 GraphEditor::OutNode::GetNodes() ;
104 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
105 return GraphEditor::OutNode::GetLinks() ;
108 inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
109 return GraphEditor::OutNode::GetGraphs() ;
112 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
113 return GraphEditor::OutNode::GetDatas() ;
116 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
118 return GraphEditor::OutNode::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 ( GetGraphNode( aNodeName ) ) {
192 return 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 ) {
248 CORBA::Any const * theValue = GetNode( FromNodeName )->GetOutPort( FromServiceParameterName )->Value() ; // Keep the type !
249 _EditedAfterExecution = true ;
250 return GraphEditor::OutNode::AddLink( FromNodeName ,
251 FromServiceParameterName ,
253 ToServiceParameterName ,
257 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
258 const char* ToServiceParameterName ,
259 char** FromNodeName ,
260 char** FromServiceParameterName ) {
261 return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
263 FromServiceParameterName ) ;
266 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
267 GraphBase::ComputingNode * aNode ,
268 const char* ToServiceParameterName ) {
269 return GraphBase::Graph::GetLink( aNode ,
270 aNode->GetChangeInPort( ToServiceParameterName ) ) ;
273 inline bool GraphEditor::DataFlow::AddLinkCoord(
274 const char* FromNodeName ,
275 const char* FromServiceParameterName ,
276 const char* ToNodeName ,
277 const char* ToServiceParameterName ,
281 _EditedAfterExecution = true ;
282 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
283 FromServiceParameterName ,
285 ToServiceParameterName ,
289 inline bool GraphEditor::DataFlow::AddLinkCoord(
290 const char* FromNodeName ,
291 const char* FromServiceParameterName ,
292 const char* ToNodeName ,
293 const char* ToServiceParameterName ,
297 _EditedAfterExecution = true ;
298 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
299 FromServiceParameterName ,
301 ToServiceParameterName ,
305 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
306 const char* FromNodeName ,
307 const char* FromServiceParameterName ,
308 const char* ToNodeName ,
309 const char* ToServiceParameterName ,
313 _EditedAfterExecution = true ;
314 return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
315 FromServiceParameterName ,
317 ToServiceParameterName ,
321 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
322 const char* FromNodeName ,
323 const char* FromServiceParameterName ,
324 const char* ToNodeName ,
325 const char* ToServiceParameterName ,
327 _EditedAfterExecution = true ;
328 return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
329 FromServiceParameterName ,
331 ToServiceParameterName ,
335 inline int GraphEditor::DataFlow::GetLinkCoordSize(
336 const char* FromNodeName ,
337 const char* FromServiceParameterName ,
338 const char* ToNodeName ,
339 const char* ToServiceParameterName ) {
340 return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
341 FromServiceParameterName ,
343 ToServiceParameterName ) ;
346 inline bool GraphEditor::DataFlow::GetLinkCoord(
347 const char* FromNodeName ,
348 const char* FromServiceParameterName ,
349 const char* ToNodeName ,
350 const char* ToServiceParameterName ,
352 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
353 FromServiceParameterName ,
355 ToServiceParameterName ,
359 inline bool GraphEditor::DataFlow::GetLinkCoord(
360 const char* FromNodeName ,
361 const char* FromServiceParameterName ,
362 const char* ToNodeName ,
363 const char* ToServiceParameterName ,
364 const int index , long &X , long &Y ) {
365 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
366 FromServiceParameterName ,
368 ToServiceParameterName ,
372 inline bool GraphEditor::DataFlow::RemoveLink(
373 const char* FromNodeName ,
374 const char* FromServiceParameterName ,
375 const char* ToNodeName ,
376 const char* ToServiceParameterName ) {
380 _EditedAfterExecution = true ;
381 return GraphEditor::OutNode::RemoveLink( FromNodeName ,
382 FromServiceParameterName ,
384 ToServiceParameterName ) ;
387 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
388 const char* ToParameterName ,
389 const CORBA::Any aValue ) {
391 GraphBase::Node *toNode ;
392 GraphBase::InPort *toPort ;
395 NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
396 toNode = GetChangeGraphNode( aNode ) ;
398 toPort = toNode->GetChangeInPort( aPort ) ;
399 if ( toPort && ( toPort->IsConnected() ||
400 toPort->IsDataConnected() ) ) {
401 RemoveLink( toNode->Name() , toPort->PortName() ) ;
413 return GraphBase::Graph::AddInputData( ToNodeName , ToParameterName ,
417 inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
418 const char* ToParameterName1 ,
419 const char* ToNodeName2 ,
420 const char* ToParameterName2 ) {
424 return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
425 ToNodeName2 , ToParameterName2 ) ;
428 inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
429 const char * ToNodeName ,
430 const char * ToParameterName ) {
431 return GraphEditor::OutNode::GetInData( ToNodeName ,
434 inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
435 const char * FromNodeName ,
436 const char * FromParameterName ) {
437 return GraphEditor::OutNode::GetOutData( FromNodeName ,
438 FromParameterName ) ;
441 inline bool GraphEditor::DataFlow::IsValid() {
442 return GraphEditor::OutNode::IsValid() ;
445 inline bool GraphEditor::DataFlow::IsExecutable() {
446 return GraphEditor::OutNode::IsExecutable() ;
449 inline bool GraphEditor::DataFlow::IsExecuting() {
450 if ( _DataFlowExecutor ) {
451 if ( _DataFlowExecutor->IsDone() ) {
464 inline bool GraphEditor::DataFlow::IsEditing() {
465 return !IsExecuting() ;
468 inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) {
469 _EditedAfterExecution = EditedAfterExecution ;
472 inline bool GraphEditor::DataFlow::EditedAfterExecution() {
473 return _EditedAfterExecution ;
476 inline bool GraphEditor::DataFlow::IsReadOnly() {
480 inline long GraphEditor::DataFlow::LevelMax() {
484 return GraphBase::Graph::LevelMax() ;
487 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
489 return ((SUPERV::ListOfStrings * ) NULL ) ;
491 return GraphBase::Graph::LevelNodes( aLevel ) ;
494 inline long GraphEditor::DataFlow::ThreadsMax() {
498 return GraphBase::Graph::ThreadsMax() ;
501 inline long GraphEditor::DataFlow::GraphsNumber() {
505 return GraphBase::Graph::GraphsNumber() ;
508 inline void GraphEditor::DataFlow::Executor(
509 GraphExecutor::DataFlow * DataFlowExecutor ) {
511 _DataFlowExecutor = DataFlowExecutor ;
514 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
515 return _DataFlowExecutor ;