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