Salome HOME
Bug fix: don't set "Loading" state for MacroNodes in InitialState() function (called...
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Service.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_Service.h
25 //  Author : Francis KLOSS
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Service_H
29 #define SUPERVGUI_Service_H
30
31 using namespace std;
32 #include "SUPERVGUI_Def.h"
33 #include <qtabwidget.h>
34 #include <qhgroupbox.h>
35 #include <qwidgetstack.h>
36
37
38 //*****************************************************
39 //  Pane for Python script editing
40 //*****************************************************
41 class SUPERVGUI_PythonEditPane: public QFrame {
42   Q_OBJECT
43
44  public:
45   SUPERVGUI_PythonEditPane(QWidget* theParent);
46   ~SUPERVGUI_PythonEditPane() {};
47   
48   QString getFuncName();
49
50   bool isDefined()
51     { return (myText->paragraphs() > 1); }
52
53   SUPERV_Strings getFunction();
54   void setFunction(SUPERV_Strings theStr);
55     
56  public slots:
57   void loadFile();
58   void readFunction();
59
60  private:
61   QTextEdit*   myText;
62   QPushButton* myNextBtn;
63
64   // fills myPyFunctions list.  called from loadFile() after user selects a file.
65   void         initPyFunctions( QTextStream& );
66
67   // list of Python functions.  filled in loadFile(), strings (functions) retrieved 
68   // in readFunction()
69   QStringList  myPyFunctions; 
70
71   // index of currently displayed Python function
72   int          myPyIndex;
73 };
74
75
76 //*****************************************************
77 //  Dialog box for node creation
78 //*****************************************************
79
80 class SUPERVGUI_Service: public QDialog {
81   Q_OBJECT
82
83   public:
84     SUPERVGUI_Service(SALOME_NamingService* ns);
85     ~SUPERVGUI_Service();
86
87     void choose();
88
89  protected:
90     void showEvent(QShowEvent* theEvent);
91
92   private:
93     void initialise();
94
95   private slots:
96     void tabChanged(QWidget *);
97     void addComputeNode();
98     void addFactoryNode();
99     void addInlineNode();
100     void addMacroNode();
101     void typeNodeSelected(int theRow);
102     void loadGraph();
103
104   private:
105     QListView*            components;
106     SALOME_NamingService* naming;
107     int myX, myY;
108     QWidgetStack* myStackWidget;
109     int myLoopId;
110     int myOtherId;
111
112     SUPERVGUI_PythonEditPane* myScriptPane;
113
114     SUPERVGUI_PythonEditPane* myInitPane;
115     SUPERVGUI_PythonEditPane* myMorePane;
116     SUPERVGUI_PythonEditPane* myNextPane;
117
118     QListView* myMacroPane;
119     QFile*     myMFile;        
120
121     QTabWidget* myTabPane;
122     bool myIsInline;
123
124     QComboBox* myTypeCombo;
125 };
126
127 /*!
128  * Edit Python dialog
129  */
130 class SUPERVGUI_EditPythonDlg: public QDialog {
131   Q_OBJECT
132     
133  public:
134   SUPERVGUI_EditPythonDlg(bool isLoop = false);
135   ~SUPERVGUI_EditPythonDlg() {};
136
137   // Not Loop functions
138   QString getFuncName()
139     { return myEditPane->getFuncName(); }
140
141   bool isDefined()
142     { return myEditPane->isDefined(); }
143
144   SUPERV_Strings getFunction()
145     { return myEditPane->getFunction(); }
146
147   void setFunction(SUPERV_Strings theStr)
148     { myEditPane->setFunction(theStr); }
149
150   // Init functions
151   QString getInitFuncName()
152     { return myInitPane->getFuncName(); }
153
154   SUPERV_Strings getInitFunction()
155     { return myInitPane->getFunction(); }
156
157   void setInitFunction(SUPERV_Strings theStr)
158     { myInitPane->setFunction(theStr); }
159
160   // More functions
161   QString getMoreFuncName()
162     { return myMorePane->getFuncName(); }
163
164   SUPERV_Strings getMoreFunction()
165     { return myMorePane->getFunction(); }
166
167   void setMoreFunction(SUPERV_Strings theStr)
168     { myMorePane->setFunction(theStr); }
169
170   // Next functions
171   QString getNextFuncName()
172     { return myNextPane->getFuncName(); }
173
174   SUPERV_Strings getNextFunction()
175     { return myNextPane->getFunction(); }
176
177   void setNextFunction(SUPERV_Strings theStr)
178     { myNextPane->setFunction(theStr); }
179
180  private:
181   SUPERVGUI_PythonEditPane* myEditPane;
182   SUPERVGUI_PythonEditPane* myInitPane;
183   SUPERVGUI_PythonEditPane* myMorePane;
184   SUPERVGUI_PythonEditPane* myNextPane;
185 };
186
187 #endif