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_OutNode.hxx
27 #ifndef _DATAFLOWEDITOR_OUTNODE_HXX
28 #define _DATAFLOWEDITOR_OUTNODE_HXX
30 #include "DataFlowBase_StreamGraph.hxx"
32 #include "DataFlowEditor_InNode.hxx"
34 namespace GraphEditor {
36 class OutNode : public GraphBase::Base {
40 GraphBase::StreamGraph * _StreamGraph ;
41 GraphBase::Graph * _Graph ;
43 int _Graph_prof_debug ;
53 bool Valid(bool kLoopSwitch = true ) ;
56 bool LoadNodes( map< string , int > & aMapOfNodes ,
57 const GraphBase::ListOfSNodes &aNodes ) ;
58 bool LoadLinks( map< string , int > & aMapOfNodes ,
59 const GraphBase::ListOfSLinks &aLinks ) ;
60 bool LoadDatas( map< string , int > & aMapOfNodes ,
61 const GraphBase::ListOfSLinks &aDatas ) ;
63 // bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
64 bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
65 GraphBase::SLink aLink ,
67 // bool SaveXML(ostream &f ) ;QDomDocument & Graph
68 bool SaveXML( ostream & f , QDomDocument & Graph ,
69 bool aSuperGraph , QDomElement & supergraph ) ;
71 bool GraphEditor::OutNode::LinkSavePY( ostream &f ,
72 const char *aGraphName ,
73 GraphBase::SLink aLink ,
77 bool SavePY(ostream &f , bool importSuperV ) ;
79 void DateModification() ;
81 // asv 20.09.04 added from GraphExecutor::FiniteStateMachine class (removed from there)
82 // static map< string , GraphBase::Graph * > _MapOfGraphs ;
83 // static map< string , int > _MapOfGraphNames ;
85 // GraphBase::Graph * MapGraph( const char * aGraphName ) ;
86 // bool MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) ;
87 // void EraseGraph( const char * aGraphName ) ;
88 // bool GraphName( const char * aGraphName ) ;
89 // string GraphInstanceName( const char * aGraphName ) ;
90 // end added from FiniteStateMachine
96 OutNode( CORBA::ORB_ptr ORB,
97 SALOME_NamingService* ptrNamingService ,
98 const char *DataFlowName ,
99 const char * DebugFileName ,
100 const SUPERV::KindOfNode aKindOfNode );
101 OutNode( CORBA::ORB_ptr ORB,
102 SALOME_NamingService* ptrNamingService ,
103 const SALOME_ModuleCatalog::Service& DataFlowService ,
104 const char *DataFlowComponentName ,
105 const char *DataFlowInterfaceName ,
106 const char *DataFlowName ,
107 const SUPERV::KindOfNode DataFlowkind ,
108 const SUPERV::SDate DataFlowFirstCreation ,
109 const SUPERV::SDate DataFlowLastModification ,
110 const char * DataFlowEditorRelease ,
111 const char * DataFlowAuthor ,
112 const char * DataFlowComputer ,
113 const char * DataFlowComment ,
114 const char * DebugFileName ) ;
117 bool Name( const char * aName ) ;
119 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
120 GraphBase::StreamGraph * StreamGraph() {
121 return _StreamGraph ; } ;
122 GraphBase::StreamGraph * StreamGraph() const {
123 return _StreamGraph ; } ;
124 GraphBase::Graph * Graph() {
126 const GraphBase::Graph * Graph() const {
129 bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
130 bool LoadXml( const char* myFileName , GraphBase::ListOfSGraphs & aListOfDataFlows ) ;
131 // bool LoadXml( const char* myFileName ) ;
132 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
134 bool SaveXml(const char* myFileName ) ;
136 bool SavePy(const char* myFileName ) ;
138 // get all DataFlow informations (for a .XML file) :
139 GraphBase::ListOfSGraphs * GetDataFlows( GraphBase::ListOfSGraphs * aListOfDataFlows ) ;
141 // void DateModification() ;
143 GraphEditor::InNode * AddNode(
144 const SALOME_ModuleCatalog::Service& NodeService ,
145 GraphBase::ListOfFuncName aFuncName ,
146 GraphBase::ListOfPythonFunctions aPythonFunction ,
147 const char* NodeComponentName ,
148 const char* NodeInterfaceName ,
149 const char* NodeName ,
150 const SUPERV::KindOfNode NodeKindOfNode ,
151 const SUPERV::SDate NodeFirstCreation ,
152 const SUPERV::SDate NodeLastModification ,
153 const char * NodeEditorRelease ,
154 const char * NodeAuthor ,
155 const char * NodeComputer ,
156 const char * NodeComment ,
159 GraphEditor::InNode * GetNode( const char* NodeName ) {
160 const GraphBase::Graph::ComputingNode * aNode = _Graph->GetGraphNode( NodeName ) ;
162 return (GraphEditor::InNode * ) (aNode->GetInNode()) ;
165 return (GraphEditor::InNode * ) NULL ;
167 bool RemoveNode( const char* NodeName ) {
170 return _Graph->RemoveNode( NodeName ) ; } ;
171 bool ReNameNode( const char* OldNodeName ,
172 const char* NewNodeName ) {
175 return _Graph->ReNameNode( OldNodeName , NewNodeName ) ; } ;
177 void Coordinates( const int X , const int Y ) {
178 return _Graph->Coordinates( X , Y ) ; } ;
179 const int XCoordinate() {
180 return _Graph->XCoordinate() ; } ;
181 const int YCoordinate() {
182 return _Graph->YCoordinate() ; } ;
183 void Coordinates( const char* NodeName , const int X , const int Y ) ;
184 const int XCoordinate( const char* NodeName ) ;
185 const int YCoordinate( const char* NodeName ) ;
187 const GraphBase::InPort *GetInPort( const char * InPortName ) {
188 return _Graph->GetInPort( InPortName ) ; } ;
189 const GraphBase::OutPort *GetOutPort( const char * OutPortName ) {
190 return _Graph->GetOutPort( OutPortName ) ; } ;
191 GraphBase::InPort *GetChangeInPort( const char * InPortName ) {
192 return _Graph->GetChangeInPort( InPortName ) ; } ;
193 GraphBase::OutPort *GetChangeOutPort( const char * OutPortName ) {
194 return _Graph->GetChangeOutPort( OutPortName ) ; } ;
196 bool HasInput(const char * ToServiceParameterName ) {
197 return _Graph->HasInput( ToServiceParameterName ) ;
200 bool AddLink( const char* FromNodeName ,
201 const char* FromServiceParameterName ,
202 const char* ToNodeName ,
203 const char* ToServiceParameterName ) {
204 // , const CORBA::Any aValue ) {
207 return _Graph->AddLink( FromNodeName , FromServiceParameterName ,
208 ToNodeName , ToServiceParameterName ) ; } ;
211 bool RemoveLink( const char* FromNodeName ,
212 const char* FromServiceParameterName ,
213 const char* ToNodeName ,
214 const char* ToServiceParameterName ) {
215 bool RetVal = _Graph->RemoveLink( FromNodeName ,
216 FromServiceParameterName ,
218 ToServiceParameterName ) ;
224 bool GetLink(const char* ToNodeName ,
225 const char* ToServiceParameterName ,
226 char** FromNodeName ,
227 char** FromServiceParameterName ) {
228 return _Graph->GetLink( ToNodeName ,
229 ToServiceParameterName ,
231 FromServiceParameterName ) ; } ;
233 bool AddLinkCoord( const char* FromNodeName ,
234 const char* FromServiceParameterName ,
235 const char* ToNodeName ,
236 const char* ToServiceParameterName ,
240 bool AddLinkCoord( const char* FromNodeName ,
241 const char* FromServiceParameterName ,
242 const char* ToNodeName ,
243 const char* ToServiceParameterName ,
247 bool ChangeLinkCoord( const char* FromNodeName ,
248 const char* FromServiceParameterName ,
249 const char* ToNodeName ,
250 const char* ToServiceParameterName ,
254 bool RemoveLinkCoord( const char* FromNodeName ,
255 const char* FromServiceParameterName ,
256 const char* ToNodeName ,
257 const char* ToServiceParameterName ,
259 int GetLinkCoordSize( const char* FromNodeName ,
260 const char* FromServiceParameterName ,
261 const char* ToNodeName ,
262 const char* ToServiceParameterName ) ;
263 bool GetLinkCoord( const char* FromNodeName ,
264 const char* FromServiceParameterName ,
265 const char* ToNodeName ,
266 const char* ToServiceParameterName ,
268 bool GetLinkCoord( const char* FromNodeName ,
269 const char* FromServiceParameterName ,
270 const char* ToNodeName ,
271 const char* ToServiceParameterName ,
272 const int index , long &X , long &Y ) ;
275 bool IsValid(bool kLoopSwitch = true ) {
277 Valid( kLoopSwitch ) ;
279 bool IsNotValid() const {
283 bool IsExecutable() {
291 _Executable = false ;
292 return _Executable ; } ;
293 bool IsNotExecutable() const {
294 return !_Executable ; } ;
296 // iterate through ALL links (OutPort-InPort pairs) and check if their types are
297 // compatible - IsCompatible(type1, type2).
298 // Returns true if all are compatible.
299 bool IsLinksCompatible();
301 // Returns true if an out-port of type "OutPortType" can be bound with
302 // in-port of type "InPortType". Called from IsLinksCompatible() and Link_Impl::IsValid().
303 bool IsCompatible( const char* OutPortType, const char* InPortType ) const;
305 const CORBA::Any *GetInData( const char *ToNodeName ,
306 const char *ToParameterName ) ;
307 const CORBA::Any *GetOutData( const char *FromNodeName ,
308 const char *FromParameterName ) ;
313 ostream & operator << (ostream &,const GraphEditor::OutNode & G);
314 ostream & operator << (ostream &,const SUPERV::SDate &);