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