Salome HOME
*** empty log message ***
[modules/superv.git] / src / GraphEditor / DataFlowEditor_OutNode.hxx
1 //  SUPERV GraphEditor : contains classes that permit edition of graphs
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowEditor_OutNode.hxx
25 //  Module : SUPERV
26
27 #ifndef _DATAFLOWEDITOR_OUTNODE_HXX
28 #define _DATAFLOWEDITOR_OUTNODE_HXX
29
30 #include "DataFlowBase_Graph.hxx"
31
32 #include "DataFlowEditor_InNode.hxx"
33
34 namespace GraphEditor {
35
36   class OutNode : public GraphBase::Graph {
37     
38     private :
39
40       bool _Imported ;
41
42       bool _Valid ;
43
44       bool _Executable ;
45
46       CORBA::ORB_ptr _Orb;
47
48       bool Valid() ;
49       bool Executable() ;
50
51       bool LoadNodes( map< string , int > & aMapOfNodes ,
52                       const GraphBase::ListOfNodes &aNodes ) ;
53       bool LoadLinks( map< string , int > & aMapOfNodes ,
54                       const GraphBase::ListOfLinks &aLinks ) ;
55       bool LoadDatas( map< string , int > & aMapOfNodes ,
56                       const GraphBase::ListOfLinks &aDatas ) ;
57
58 //      bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
59       bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
60                                               GraphBase::SLink aLink ,
61                                               bool wdata ) const ;
62 //      bool SaveXML(ostream &f ) ;QDomDocument & Graph 
63       bool SaveXML(QDomDocument & Graph ) ;
64
65       bool GraphEditor::OutNode::LinkSavePY( ostream &f ,
66                                              const char *aGraphName ,
67                                              GraphBase::SLink aLink ,
68                                              bool intervar ,
69                                              bool wdata ) const;
70       bool SavePY(ostream &f ) ;
71
72       void DateModification() ;
73
74     public:
75
76       OutNode();
77       OutNode( CORBA::ORB_ptr ORB,
78                SALOME_NamingService* ptrNamingService ,
79                const char *DataFlowName ,
80                const char * DebugFileName );
81       OutNode( CORBA::ORB_ptr ORB,
82                SALOME_NamingService* ptrNamingService ,
83                const SALOME_ModuleCatalog::Service& DataFlowService ,
84                const char *DataFlowComponentName ,
85                const char *DataFlowInterfaceName ,
86                const char *DataFlowName ,
87                const SUPERV::KindOfNode DataFlowkind ,
88                const SUPERV::SDate DataFlowFirstCreation ,
89                const SUPERV::SDate DataFlowLastModification ,
90                const char * DataFlowEditorRelease ,
91                const char * DataFlowAuthor ,
92                const char * DataFlowComputer ,
93                const char * DataFlowComment ,
94                const char * DebugFileName ) ;
95       virtual ~OutNode();
96
97 //      SALOME_NamingService* NamingService() const {
98 //            return _theNamingService ; } ;
99
100       bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
101       bool LoadXml( const char* myFileName ) ;
102       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
103
104       bool SaveXml(const char* myFileName ) ;
105
106       bool SavePy(const char* myFileName ) ;
107
108 // get all DataFlow informations (for a .XML file) :
109       GraphBase::SGraph * GetDataFlow() ;
110
111 //    void DateModification() ;
112
113       GraphEditor::InNode * AddNode(
114                         const SALOME_ModuleCatalog::Service& NodeService ,
115                         GraphBase::ListOfFuncName aFuncName ,
116                         GraphBase::ListOfPythonFunctions aPythonFunction ,
117                         const char* NodeComponentName ,
118                         const char* NodeInterfaceName ,
119                         const char* NodeName ,
120                         const SUPERV::KindOfNode NodeKindOfNode ,
121                         const SUPERV::SDate NodeFirstCreation ,
122                         const SUPERV::SDate NodeLastModification ,
123                         const char * NodeEditorRelease ,
124                         const char * NodeAuthor ,
125                         const char * NodeComputer ,
126                         const char * NodeComment ,
127                         const int NodeX ,
128                         const int NodeY ) ;
129       GraphEditor::InNode * GetNode( const char* NodeName ) {
130                const GraphBase::Graph::ComputingNode * aNode = GraphBase::Graph::GetGraphNode( NodeName ) ;
131                if ( aNode ) {
132                  return (GraphEditor::InNode * ) (aNode->GetInNode()) ;
133                }
134                else {
135                  return (GraphEditor::InNode * ) NULL ;
136                } } ;
137       bool RemoveNode( const char* NodeName ) {
138            DateModification() ;
139            _Valid = false ;
140            return GraphBase::Graph::RemoveNode( NodeName ) ; } ;
141       bool ReNameNode( const char* OldNodeName ,
142                        const char* NewNodeName ) {
143            DateModification() ;
144            _Valid = false ;
145            return GraphBase::Graph::ReNameNode( OldNodeName , NewNodeName ) ; } ;
146
147       void Coordinates( const int X , const int Y ) {
148            return GraphBase::Graph::Coordinates( X , Y ) ; } ;
149       const int XCoordinate() {
150            return GraphBase::Graph::XCoordinate() ; } ;
151       const int YCoordinate() {
152            return GraphBase::Graph::YCoordinate() ; } ;
153       void Coordinates( const char* NodeName , const int X , const int Y ) ;
154       const int XCoordinate( const char* NodeName ) ;
155       const int YCoordinate( const char* NodeName ) ;
156
157       const GraphBase::InPort *GetInPort( const char *name ) {
158             return GraphBase::PortsOfNode::GetInPort( name ) ; } ;
159       const GraphBase::OutPort *GetOutPort( const char *name ) {
160             return GraphBase::PortsOfNode::GetOutPort( name ) ; } ;
161       GraphBase::InPort *GetChangeInPort( const char *name ) {
162             return GraphBase::PortsOfNode::GetChangeInPort( name ) ; } ;
163       GraphBase::OutPort *GetChangeOutPort( const char *name ) {
164             return GraphBase::PortsOfNode::GetChangeOutPort( name ) ; } ;
165
166       bool HasInput(const char * ToServiceParameterName ) {
167            return GraphBase::ComputingNode::HasInput( ToServiceParameterName ) ;
168          }
169
170       bool AddLink( const char* FromNodeName ,
171                     const char* FromServiceParameterName ,
172                     const char* ToNodeName ,
173                     const char* ToServiceParameterName ,
174                     const CORBA::Any aValue ) {
175            DateModification() ;
176            _Valid = false ;
177            return GraphBase::Graph::AddLink(
178                                     FromNodeName , FromServiceParameterName ,
179                                     ToNodeName , ToServiceParameterName ,
180                                     aValue ) ; } ;
181
182       bool RemoveLink( const char* FromNodeName ,
183                        const char* FromServiceParameterName ,
184                        const char* ToNodeName ,
185                        const char* ToServiceParameterName ) {
186            bool RetVal = GraphBase::Graph::RemoveLink(
187                                                  FromNodeName ,
188                                                  FromServiceParameterName , 
189                                                  ToNodeName ,
190                                                  ToServiceParameterName ) ;
191            if ( RetVal )
192              DateModification() ;
193            _Valid = false ;
194            return RetVal ; } ;
195
196       bool GetLink(const char* ToNodeName ,
197                    const char* ToServiceParameterName ,
198                    char** FromNodeName ,
199                    char** FromServiceParameterName ) {
200            return GraphBase::Graph::GetLink( ToNodeName ,
201                                              ToServiceParameterName ,
202                                              FromNodeName ,
203                                              FromServiceParameterName ) ; } ;
204
205       bool AddLinkCoord( const char* FromNodeName ,
206                          const char* FromServiceParameterName ,
207                          const char* ToNodeName ,
208                          const char* ToServiceParameterName ,
209                          const int nXY ,
210                          const int* X ,
211                          const int* Y ) ;
212       bool AddLinkCoord( const char* FromNodeName ,
213                          const char* FromServiceParameterName ,
214                          const char* ToNodeName ,
215                          const char* ToServiceParameterName ,
216                          const int index ,
217                          const int X ,
218                          const int Y ) ;
219       bool ChangeLinkCoord( const char* FromNodeName ,
220                             const char* FromServiceParameterName ,
221                             const char* ToNodeName ,
222                             const char* ToServiceParameterName ,
223                             const int index ,
224                             const int X ,
225                             const int Y ) ;
226       bool RemoveLinkCoord( const char* FromNodeName ,
227                             const char* FromServiceParameterName ,
228                             const char* ToNodeName ,
229                             const char* ToServiceParameterName ,
230                             const int index ) ;
231       int GetLinkCoordSize( const char* FromNodeName ,
232                             const char* FromServiceParameterName ,
233                             const char* ToNodeName ,
234                             const char* ToServiceParameterName ) ;
235       bool GetLinkCoord( const char* FromNodeName ,
236                          const char* FromServiceParameterName ,
237                          const char* ToNodeName ,
238                          const char* ToServiceParameterName ,
239                          int *X , int *Y ) ;
240       bool GetLinkCoord( const char* FromNodeName ,
241                          const char* FromServiceParameterName ,
242                          const char* ToNodeName ,
243                          const char* ToServiceParameterName ,
244                          const int index , long &X , long &Y ) ;
245
246       bool AddInputData( const char* ToNodeName1 ,
247                          const char* ToParameterName1 ,
248                          const char* ToNodeName2 ,
249                          const char* ToParameterName2 ) ;
250
251       bool IsValid() {
252            if ( !_Valid )
253              Valid() ;
254            return _Valid ; } ;
255       bool IsNotValid() const {
256            return !_Valid ; } ;
257       bool UnValid() {
258            bool RetVal = _Valid ;
259            _Valid = false ;
260            return RetVal ; } ;
261
262       bool IsExecutable() {
263            if ( !_Valid )
264              Valid() ;
265            if ( _Valid ) {
266              if ( !_Executable )
267                Executable() ;
268            }
269            else
270              _Executable = false ;
271            return _Executable ; } ;
272       bool IsNotExecutable() const {
273            return !_Executable ; } ;
274
275       const CORBA::Any *GetInData( const char *ToNodeName ,
276                                    const char *ToParameterName ) ;
277       const CORBA::Any *GetOutData( const char *FromNodeName ,
278                                     const char *FromParameterName ) ;
279   } ;
280
281 };
282
283 ostream & operator << (ostream &,const GraphEditor::OutNode & G);
284 ostream & operator << (ostream &,const SUPERV::SDate &);
285
286 #endif
287
288
289