Salome HOME
sources v1.2
[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
62   //QLineEdit* myNameEdt;
63   //QLineEdit* myParamEdt;
64   QTextEdit* myText;
65   //QLineEdit* myOutParamEdt;
66   QPushButton* myNextBtn;
67
68   QTextStream* myIStream;
69   QFile* myFile;
70 };
71
72
73 //*****************************************************
74 //  Dialog box for node creation
75 //*****************************************************
76
77 class SUPERVGUI_Service: public QDialog {
78   Q_OBJECT
79
80   public:
81     SUPERVGUI_Service(SALOME_NamingService* ns);
82     ~SUPERVGUI_Service();
83
84     void choose();
85
86  protected:
87     void showEvent(QShowEvent* theEvent);
88
89   private:
90     void initialise();
91
92   private slots:
93     void tabChanged(QWidget *);
94     void addComputeNode();
95     void addFactoryNode();
96     void addInlineNode();
97     void typeNodeSelected(int theRow);
98
99   private:
100     QListView*            components;
101     SALOME_NamingService* naming;
102     int myX, myY;
103     QWidgetStack* myStackWidget;
104     int myLoopId;
105     int myOtherId;
106
107     SUPERVGUI_PythonEditPane* myScriptPane;
108
109     SUPERVGUI_PythonEditPane* myInitPane;
110     SUPERVGUI_PythonEditPane* myMorePane;
111     SUPERVGUI_PythonEditPane* myNextPane;
112
113     QTabWidget* myTabPane;
114     bool myIsInline;
115
116     QComboBox* myTypeCombo;
117 };
118
119 /*!
120  * Edit Python dialog
121  */
122 class SUPERVGUI_EditPythonDlg: public QDialog {
123   Q_OBJECT
124     
125  public:
126   SUPERVGUI_EditPythonDlg(bool isLoop = false);
127   ~SUPERVGUI_EditPythonDlg() {};
128
129   // Not Loop functions
130   QString getFuncName()
131     { return myEditPane->getFuncName(); }
132
133   bool isDefined()
134     { return myEditPane->isDefined(); }
135
136   SUPERV_Strings getFunction()
137     { return myEditPane->getFunction(); }
138
139   void setFunction(SUPERV_Strings theStr)
140     { myEditPane->setFunction(theStr); }
141
142   // Init functions
143   QString getInitFuncName()
144     { return myInitPane->getFuncName(); }
145
146   SUPERV_Strings getInitFunction()
147     { return myInitPane->getFunction(); }
148
149   void setInitFunction(SUPERV_Strings theStr)
150     { myInitPane->setFunction(theStr); }
151
152   // More functions
153   QString getMoreFuncName()
154     { return myMorePane->getFuncName(); }
155
156   SUPERV_Strings getMoreFunction()
157     { return myMorePane->getFunction(); }
158
159   void setMoreFunction(SUPERV_Strings theStr)
160     { myMorePane->setFunction(theStr); }
161
162   // Next functions
163   QString getNextFuncName()
164     { return myNextPane->getFuncName(); }
165
166   SUPERV_Strings getNextFunction()
167     { return myNextPane->getFunction(); }
168
169   void setNextFunction(SUPERV_Strings theStr)
170     { myNextPane->setFunction(theStr); }
171
172  private:
173   SUPERVGUI_PythonEditPane* myEditPane;
174   SUPERVGUI_PythonEditPane* myInitPane;
175   SUPERVGUI_PythonEditPane* myMorePane;
176   SUPERVGUI_PythonEditPane* myNextPane;
177 };
178
179 #endif