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() );
44 inline char * GraphEditor::DataFlow::DataNodeInfo() {
47 GraphBase::DataNode::DataNodeInfo( s ) ;
48 return CORBA::string_dup(s.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() );
60 inline bool GraphEditor::DataFlow::LoadDataFlow(
61 const GraphBase::SGraph *aDataFlow ) {
64 _EditedAfterExecution = true ;
65 return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ;
68 inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ) {
71 _EditedAfterExecution = true ;
72 return GraphEditor::OutNode::LoadXml( myFileName ) ;
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::SGraph * GraphEditor::DataFlow::GetDataFlow() {
92 return GraphEditor::OutNode::GetDataFlow() ;
95 // void DateModification() ;
97 inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
98 return GraphEditor::OutNode::GetInfo() ;
101 inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const {
102 return GraphEditor::OutNode::GetNodes() ;
105 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
106 return GraphEditor::OutNode::GetLinks() ;
109 inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
110 return GraphEditor::OutNode::GetGraphs() ;
113 inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
114 return GraphEditor::OutNode::GetDatas() ;
117 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
119 return GraphEditor::OutNode::GetService() ;
122 inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
123 const SALOME_ModuleCatalog::Service& NodeService ,
124 const char* NodeComponentName ,
125 const char* NodeInterfaceName ,
126 const char* NodeName,
127 const SUPERV::KindOfNode NodeKindOfNode,
128 GraphBase::ListOfFuncName aFuncName ,
129 GraphBase::ListOfPythonFunctions aPythonFunction ,
130 const SUPERV::SDate NodeFirstCreation,
131 const SUPERV::SDate NodeLastModification,
132 const char * NodeEditorRelease,
133 const char * NodeAuthor,
134 const char * NodeComputer,
135 const char * NodeComment,
139 return (GraphEditor::InNode * ) NULL ;
140 _EditedAfterExecution = true ;
141 return GraphEditor::OutNode::AddNode( NodeService ,
142 aFuncName , aPythonFunction ,
145 NodeName , NodeKindOfNode ,
147 NodeLastModification ,
149 NodeAuthor , NodeComputer ,
150 NodeComment , NodeX , NodeY ) ;
153 inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
154 return GraphEditor::OutNode::GetNode( NodeName ) ;
157 inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
160 _EditedAfterExecution = true ;
161 return GraphEditor::OutNode::RemoveNode( NodeName ) ;
164 inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
165 const char* NewNodeName ) {
168 _EditedAfterExecution = true ;
169 return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ;
172 inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
173 const char * aNodeName ) {
174 if ( GetGraphNode( aNodeName ) )
175 return GetGraphNode( aNodeName )->GetService() ;
179 inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
180 _EditedAfterExecution = true ;
181 return GraphEditor::OutNode::Coordinates( X , Y ) ;
184 inline const int GraphEditor::DataFlow::XCoordinate() {
185 return GraphEditor::OutNode::XCoordinate() ;
188 inline const int GraphEditor::DataFlow::YCoordinate() {
189 return GraphEditor::OutNode::YCoordinate() ;
192 inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
193 const int X , const int Y ) {
194 return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ;
197 inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
198 return GraphEditor::OutNode::XCoordinate( NodeName ) ;
201 inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
202 return GraphEditor::OutNode::YCoordinate( NodeName ) ;
205 inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
206 return GraphEditor::OutNode::GetInPort( name ) ;
208 inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
209 return GraphEditor::OutNode::GetOutPort( name ) ;
211 inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
212 return GraphEditor::OutNode::GetChangeInPort( name ) ;
214 inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
215 return GraphEditor::OutNode::GetChangeOutPort( name ) ;
218 inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
219 return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
222 inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
223 const char* FromServiceParameterName ,
224 const char* ToNodeName ,
225 const char* ToServiceParameterName ,
226 const CORBA::Any aValue ) {
229 CORBA::Any const * theValue = GetNode( FromNodeName )->GetOutPort( FromServiceParameterName )->Value() ; // Keep the type !
230 _EditedAfterExecution = true ;
231 return GraphEditor::OutNode::AddLink( FromNodeName ,
232 FromServiceParameterName ,
234 ToServiceParameterName ,
238 inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
239 const char* ToServiceParameterName ,
240 char** FromNodeName ,
241 char** FromServiceParameterName ) {
242 return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
244 FromServiceParameterName ) ;
247 inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
248 GraphBase::ComputingNode * aNode ,
249 const char* ToServiceParameterName ) {
250 return GraphBase::Graph::GetLink( aNode ,
251 aNode->GetChangeInPort( ToServiceParameterName ) ) ;
254 inline bool GraphEditor::DataFlow::AddLinkCoord(
255 const char* FromNodeName ,
256 const char* FromServiceParameterName ,
257 const char* ToNodeName ,
258 const char* ToServiceParameterName ,
262 _EditedAfterExecution = true ;
263 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
264 FromServiceParameterName ,
266 ToServiceParameterName ,
270 inline bool GraphEditor::DataFlow::AddLinkCoord(
271 const char* FromNodeName ,
272 const char* FromServiceParameterName ,
273 const char* ToNodeName ,
274 const char* ToServiceParameterName ,
278 _EditedAfterExecution = true ;
279 return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
280 FromServiceParameterName ,
282 ToServiceParameterName ,
286 inline bool GraphEditor::DataFlow::ChangeLinkCoord(
287 const char* FromNodeName ,
288 const char* FromServiceParameterName ,
289 const char* ToNodeName ,
290 const char* ToServiceParameterName ,
294 _EditedAfterExecution = true ;
295 return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
296 FromServiceParameterName ,
298 ToServiceParameterName ,
302 inline bool GraphEditor::DataFlow::RemoveLinkCoord(
303 const char* FromNodeName ,
304 const char* FromServiceParameterName ,
305 const char* ToNodeName ,
306 const char* ToServiceParameterName ,
308 _EditedAfterExecution = true ;
309 return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
310 FromServiceParameterName ,
312 ToServiceParameterName ,
316 inline int GraphEditor::DataFlow::GetLinkCoordSize(
317 const char* FromNodeName ,
318 const char* FromServiceParameterName ,
319 const char* ToNodeName ,
320 const char* ToServiceParameterName ) {
321 return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
322 FromServiceParameterName ,
324 ToServiceParameterName ) ;
327 inline bool GraphEditor::DataFlow::GetLinkCoord(
328 const char* FromNodeName ,
329 const char* FromServiceParameterName ,
330 const char* ToNodeName ,
331 const char* ToServiceParameterName ,
333 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
334 FromServiceParameterName ,
336 ToServiceParameterName ,
340 inline bool GraphEditor::DataFlow::GetLinkCoord(
341 const char* FromNodeName ,
342 const char* FromServiceParameterName ,
343 const char* ToNodeName ,
344 const char* ToServiceParameterName ,
345 const int index , long &X , long &Y ) {
346 return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
347 FromServiceParameterName ,
349 ToServiceParameterName ,
353 inline bool GraphEditor::DataFlow::RemoveLink(
354 const char* FromNodeName ,
355 const char* FromServiceParameterName ,
356 const char* ToNodeName ,
357 const char* ToServiceParameterName ) {
360 _EditedAfterExecution = true ;
361 return GraphEditor::OutNode::RemoveLink( FromNodeName ,
362 FromServiceParameterName ,
364 ToServiceParameterName ) ;
367 inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
368 const char* ToParameterName ,
369 const CORBA::Any aValue ) {
371 GraphBase::Node *toNode ;
372 GraphBase::InPort *toPort ;
375 NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
376 toNode = GetChangeGraphNode( aNode ) ;
378 toPort = toNode->GetChangeInPort( aPort ) ;
379 if ( toPort && ( toPort->IsConnected() ||
380 toPort->IsDataConnected() ) ) {
381 RemoveLink( toNode->Name() , toPort->PortName() ) ;
392 return GraphBase::Graph::AddInputData( ToNodeName , ToParameterName ,
396 inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
397 const char* ToParameterName1 ,
398 const char* ToNodeName2 ,
399 const char* ToParameterName2 ) {
402 return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
403 ToNodeName2 , ToParameterName2 ) ;
406 inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
407 const char * ToNodeName ,
408 const char * ToParameterName ) {
409 return GraphEditor::OutNode::GetInData( ToNodeName ,
412 inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
413 const char * FromNodeName ,
414 const char * FromParameterName ) {
415 return GraphEditor::OutNode::GetOutData( FromNodeName ,
416 FromParameterName ) ;
419 inline bool GraphEditor::DataFlow::IsValid() {
420 return GraphEditor::OutNode::IsValid() ;
423 inline bool GraphEditor::DataFlow::IsExecutable() {
424 return GraphEditor::OutNode::IsExecutable() ;
427 inline bool GraphEditor::DataFlow::IsExecuting() {
428 if ( _DataFlowExecutor ) {
429 if ( _DataFlowExecutor->IsDone() ) {
442 inline bool GraphEditor::DataFlow::IsEditing() {
443 return !IsExecuting() ;
446 inline void GraphEditor::DataFlow::EditedAfterExecution(bool EditedAfterExecution ) {
447 _EditedAfterExecution = EditedAfterExecution ;
450 inline bool GraphEditor::DataFlow::EditedAfterExecution() {
451 return _EditedAfterExecution ;
454 inline bool GraphEditor::DataFlow::IsReadOnly() {
458 inline long GraphEditor::DataFlow::LevelMax() {
461 return GraphBase::Graph::LevelMax() ;
464 inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
466 return ((SUPERV::ListOfStrings * ) NULL ) ;
467 return GraphBase::Graph::LevelNodes( aLevel ) ;
470 inline long GraphEditor::DataFlow::ThreadsMax() {
473 return GraphBase::Graph::ThreadsMax() ;
476 inline long GraphEditor::DataFlow::GraphsNumber() {
479 return GraphBase::Graph::GraphsNumber() ;
482 inline void GraphEditor::DataFlow::Executor(
483 GraphExecutor::DataFlow * DataFlowExecutor ) {
485 _DataFlowExecutor = DataFlowExecutor ;
488 inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
489 return _DataFlowExecutor ;