Salome HOME
MPV: Merge V1_2d
[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     void syncOnEvent(SUPERV::GraphState theStateFromEvent);
51
52     virtual void hideAll()=0;
53     virtual void showAll()=0;
54     virtual void deleteLinks() {};
55     virtual void setNodeName(QString aName);
56
57     SUPERV_CNode getEngine() 
58       { return myNode; };
59
60     SUPERVGUI_Main* getMain()
61       { return myMain; };
62
63     bool isWarning();
64     bool isStep();
65     bool isTrace();
66     bool isVerbose();
67
68     SUPERV::KindOfNode getNodeType()
69       { return myNode->Kind(); }
70
71     SUPERV_CNode getComputingNode()
72       { return myNode; }
73
74     SUPERV_FNode getFactoryNode()
75       { return SUPERV::FNode::_narrow(myNode); }
76
77     SUPERV_INode getInlineNode()
78       { return SUPERV::INode::_narrow(myNode); }
79
80     SUPERV_GNode getGotoNode()
81       { return SUPERV::GNode::_narrow(myNode); }
82
83     SUPERV_LNode getLoopNode()
84       { return SUPERV::LNode::_narrow(myNode); }
85
86     SUPERV_ELNode getEndLoopNode()
87       { return SUPERV::ELNode::_narrow(myNode); }
88
89     SUPERV_SNode getSwitchNode()
90       { return SUPERV::SNode::_narrow(myNode); }
91
92     SUPERV_ESNode getEndSwitchNode()
93       { return SUPERV::ESNode::_narrow(myNode); }
94
95
96     SUPERV_Port createInPort();
97     SUPERV_Port createOutPort();
98
99  protected:
100     void mousePressEvent(QMouseEvent* e);
101
102   public slots:
103     void suspendResume();
104     void kill();
105     void stopRestart();
106     void configure();
107     void showPython();
108
109     virtual void rename();
110     virtual void remove();
111     void changeInformation();
112     void browse();
113
114     void setWarning(bool b);
115     void setStep(bool b);
116     void setTrace(bool b);
117     void setVerbose(bool b);
118     void showPopup(QMouseEvent* e);
119
120     virtual void addInputPort();
121     virtual void addOutputPort();
122     virtual void editFunction();
123
124  protected:
125     virtual void setState(SUPERV::GraphState theState);
126
127     SUPERV_CNode     myNode;
128     SUPERVGUI_Main*  myMain;
129     
130     //SUPERVGUI_Label* myTitle;
131     SUPERVGUI_Label* myTime;
132     SUPERVGUI_Label* myStatus;
133
134     QPopupMenu* myPopup;
135     QPopupMenu* myRunPopup;
136     int         myKillItem;
137     int         mySuspendItem;
138     int         myStopItem;
139     int         myRenameItem;
140     int         myDeleteItem;
141     int         mySeparatorId;
142     
143     SUPERVGUI_BrowseNodeDlg* aBrowseDlg;
144
145   private:
146
147     bool        warning;
148     bool        step;
149     bool        trace;
150     bool        verbose;
151
152 };
153
154
155
156 /*!
157  * Port parameters dialog definition
158  */
159 class SUPERVGUI_PortParamsDlg: public QDialog {
160   Q_OBJECT
161     
162  public:
163   SUPERVGUI_PortParamsDlg();
164   ~SUPERVGUI_PortParamsDlg() {};
165
166   QString getName() { return myNameTxt->text(); }
167   QString getType() { return myTypeTxt->currentText(); }
168
169  private:
170   QLineEdit* myNameTxt;
171   QComboBox* myTypeTxt;
172 };
173
174
175
176 #endif