Salome HOME
NRI : Merge from 1.2c.
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Node.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
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   : SUPERVGUI_Node.h
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Node_H
29 #define SUPERVGUI_Node_H
30
31 using namespace std;
32 #include "SUPERVGUI_Def.h"
33 #include "SUPERVGUI_Label.h"
34 #include <qvbox.h>
35 #include "SUPERVGUI_BrowseNodeDlg.h"
36 #include <qcombobox.h>
37
38
39 class SUPERVGUI_Main;
40
41 class SUPERVGUI_Node: public QFrame {
42   Q_OBJECT
43
44   public:
45     SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode);
46     virtual ~SUPERVGUI_Node();
47
48     bool eventFilter( QObject* o, QEvent* e );
49     virtual void sync();
50
51     virtual void hideAll()=0;
52     virtual void showAll()=0;
53     virtual void deleteLinks() {};
54     virtual void setNodeName(QString aName);
55
56     SUPERV_CNode getEngine() 
57       { return myNode; };
58
59     SUPERVGUI_Main* getMain()
60       { return myMain; };
61
62     bool isWarning();
63     bool isStep();
64     bool isTrace();
65     bool isVerbose();
66
67     SUPERV::KindOfNode getNodeType()
68       { return myNode->Kind(); }
69
70     SUPERV_CNode getComputingNode()
71       { return myNode; }
72
73     SUPERV_FNode getFactoryNode()
74       { return SUPERV::FNode::_narrow(myNode); }
75
76     SUPERV_INode getInlineNode()
77       { return SUPERV::INode::_narrow(myNode); }
78
79     SUPERV_GNode getGotoNode()
80       { return SUPERV::GNode::_narrow(myNode); }
81
82     SUPERV_LNode getLoopNode()
83       { return SUPERV::LNode::_narrow(myNode); }
84
85     SUPERV_ELNode getEndLoopNode()
86       { return SUPERV::ELNode::_narrow(myNode); }
87
88     SUPERV_SNode getSwitchNode()
89       { return SUPERV::SNode::_narrow(myNode); }
90
91     SUPERV_ESNode getEndSwitchNode()
92       { return SUPERV::ESNode::_narrow(myNode); }
93
94
95     SUPERV_Port createInPort();
96     SUPERV_Port createOutPort();
97
98  protected:
99     void mousePressEvent(QMouseEvent* e);
100
101   public slots:
102     void suspendResume();
103     void kill();
104     void stopRestart();
105     void configure();
106     void showPython();
107
108     virtual void rename();
109     virtual void remove();
110     void changeInformation();
111     void browse();
112
113     void setWarning(bool b);
114     void setStep(bool b);
115     void setTrace(bool b);
116     void setVerbose(bool b);
117     void showPopup(QMouseEvent* e);
118
119     virtual void addInputPort();
120     virtual void addOutputPort();
121     virtual void editFunction();
122
123  protected:
124     virtual void setState(SUPERV::GraphState theState);
125
126     SUPERV_CNode     myNode;
127     SUPERVGUI_Main*  myMain;
128     
129     //SUPERVGUI_Label* myTitle;
130     SUPERVGUI_Label* myTime;
131     SUPERVGUI_Label* myStatus;
132
133     QPopupMenu* myPopup;
134     QPopupMenu* myRunPopup;
135     int         myKillItem;
136     int         mySuspendItem;
137     int         myStopItem;
138     int         myRenameItem;
139     int         myDeleteItem;
140     int         mySeparatorId;
141     
142     SUPERVGUI_BrowseNodeDlg* aBrowseDlg;
143
144   private:
145
146     bool        warning;
147     bool        step;
148     bool        trace;
149     bool        verbose;
150 };
151
152
153
154 /*!
155  * Port parameters dialog definition
156  */
157 class SUPERVGUI_PortParamsDlg: public QDialog {
158   Q_OBJECT
159     
160  public:
161   SUPERVGUI_PortParamsDlg();
162   ~SUPERVGUI_PortParamsDlg() {};
163
164   QString getName() { return myNameTxt->text(); }
165   QString getType() { return myTypeTxt->currentText(); }
166
167  private:
168   QLineEdit* myNameTxt;
169   QComboBox* myTypeTxt;
170 };
171
172
173
174 #endif