Salome HOME
Merge Qt5 porting.
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _BL_CREATEJOBWIZARD_HXX_
21 #define _BL_CREATEJOBWIZARD_HXX_
22
23 #include <QtGlobal>
24 #include <QtGui>
25 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
26 #include <QtWidgets>
27 #endif
28
29 #include "BL_Traces.hxx"
30 #include "BL_SALOMEServices.hxx"
31 #include "JM_ResourceCatalog.hxx"
32
33 #include <string>
34 #include <list>
35
36 namespace Ui {
37   class ResourceRequirementsWizardPage;
38   class FilesWizardPage;
39   class AdvancedParametersWizardPage;
40 }
41
42 namespace BL{
43
44   class JobsManager_QT;
45   class JobNamePage;
46   class BatchParametersPage;
47   class CreateJobWizard: public QWizard
48   {
49     Q_OBJECT
50
51     public:
52       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
53       virtual ~CreateJobWizard();
54
55       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
56
57       void clone(const std::string & name);
58
59     public slots:
60       void end(int result);
61
62     private:
63       BL::JobsManager_QT * _jobs_manager;
64       QListWidget * _input_files_list;
65       QListWidget * _output_files_list;
66
67       BL::JobNamePage * _job_name_page;
68       BL::BatchParametersPage * _batch_parameters_page;
69       BL::SALOMEServices * _salome_services;
70
71     public:
72       // Results
73       std::string job_name;
74       enum {YACS, COMMAND, PYTHON_SALOME} job_type;
75
76       std::string yacs_file;
77       std::string command;
78       std::string python_salome_file;
79
80       std::string env_file;
81
82       std::string batch_directory;
83
84       // For COORM
85       std::string coorm_batch_directory;
86
87       std::string maximum_duration;
88       long mem_limit;
89       BL::Job::MemReqType mem_req_type;
90       int nb_proc;
91       bool exclusive;
92
93       // Parameters for COORM
94       std::string launcher_file;
95       std::string launcher_args;
96
97       std::string result_directory;
98       std::list<std::string> input_files_list;
99       std::list<std::string> output_files_list;
100
101       std::string resource_choosed;
102       std::string batch_queue;
103       std::string wckey;
104       std::string extra_params;
105
106       bool start_job;
107       int dump_yacs_state;
108       std::string ll_jobtype;
109
110     public:
111       enum {Page_JobName,
112             Page_YACSSchema,
113             Page_Command_Main_Definitions,
114             Page_PythonSalome_Main_Definitions,
115             Page_BatchParameters,
116             Page_COORM_BatchParameters,
117             Page_Files,
118             Page_Resource,
119             Page_Advanced,
120             Page_Conclusion};
121   };
122
123   class JobNamePage: public QWizardPage
124   {
125     Q_OBJECT
126
127     public:
128       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
129       virtual ~JobNamePage();
130
131       virtual bool validatePage();
132       virtual int nextId() const ;
133       virtual void cleanupPage() {}
134
135     public slots:
136       void yacs_schema_button(bool checked);
137       void command_button(bool checked);
138       void python_salome_button(bool checked);
139
140     private:
141       BL::JobsManager_QT * _jobs_manager;
142       QLabel * _explanation;
143
144     public:
145       bool _check_name;
146   };
147
148   class ConclusionPage: public QWizardPage
149   {
150     public:
151       ConclusionPage(QWidget * parent);
152       virtual ~ConclusionPage();
153
154       virtual bool validatePage();
155       virtual int nextId() const ;
156       virtual void cleanupPage() {}
157   };
158
159   class BatchParametersPage: public QWizardPage
160   {
161     Q_OBJECT
162
163     public:
164       enum MemUnit {MB, GB};
165
166       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
167       virtual ~BatchParametersPage();
168
169       virtual void initializePage();
170       virtual int nextId() const;
171       virtual void cleanupPage();
172
173       MemUnit getMemUnit() const;
174       void setMemUnit(MemUnit mem_unit);
175
176       BL::Job::MemReqType getMemReqType() const;
177       void setMemReqType(BL::Job::MemReqType mem_req_type);
178
179     public slots:
180       void timeChanged();
181       void memChanged();
182
183     private:
184       Ui::ResourceRequirementsWizardPage * ui;
185       BL::SALOMEServices * _salome_services;
186       std::string resource_choosed;
187   };
188
189   // For COORM
190   class COORM_BatchParametersPage: public QWizardPage
191   {
192     Q_OBJECT
193
194     public:
195       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
196       virtual ~COORM_BatchParametersPage();
197
198       virtual bool validatePage();
199       virtual int nextId() const;
200       virtual void cleanupPage();
201       virtual void initializePage();
202
203     public slots:
204       void choose_launcher_file();
205
206     private:
207       BL::SALOMEServices * _salome_services;
208       QLineEdit * _launcher_file_text;
209       QString resource_choosed;
210   };
211
212   class FilesPage: public QWizardPage
213   {
214     Q_OBJECT
215
216     public:
217       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
218       virtual ~FilesPage();
219
220       virtual void initializePage();
221       virtual int nextId() const;
222       virtual bool isComplete() const;
223       virtual void cleanupPage() {}
224
225     public slots:
226       void choose_input_files();
227       void remove_input_files();
228       void input_itemSelectionChanged();
229       void choose_local_directory();
230
231       void add_output_file();
232       void remove_output_files();
233       void output_itemSelectionChanged();
234
235     private:
236       Ui::FilesWizardPage * ui;
237       BL::SALOMEServices * _salome_services;
238       QString resource_choosed;
239   };
240
241   class ResourcePage: public QWizardPage
242   {
243     Q_OBJECT
244
245     public:
246       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
247       virtual ~ResourcePage();
248
249       virtual int nextId() const;
250       virtual bool validatePage();
251       virtual void initializePage();
252       virtual void cleanupPage() {}
253
254     public slots:
255       void itemSelected(QListWidgetItem * item);
256
257     private:
258       JM::ResourceCatalog * _resource_list;
259       QLineEdit * _resource_choosed;
260       BL::SALOMEServices * _salome_services;
261
262       QLabel * _ll_label;
263       QLineEdit * _ll_value;
264       QGridLayout * _main_layout;
265   };
266
267   class YACSSchemaPage: public QWizardPage
268   {
269     Q_OBJECT
270
271     public:
272       YACSSchemaPage(QWidget * parent);
273       virtual ~YACSSchemaPage();
274
275       virtual bool validatePage();
276       virtual int nextId() const ;
277       virtual void cleanupPage() {}
278
279     public slots:
280       void choose_file();
281       void choose_env_file();
282
283     private:
284       QLineEdit * _yacs_file_text;
285       QLineEdit * _line_env_file;
286   };
287
288   class CommandMainPage: public QWizardPage
289   {
290     Q_OBJECT
291
292     public:
293       CommandMainPage(QWidget * parent);
294       virtual ~CommandMainPage();
295
296       virtual bool validatePage();
297       virtual int nextId() const ;
298       virtual void cleanupPage() {}
299
300     public slots:
301       void choose_command_file();
302       void choose_env_file();
303
304     private:
305       QLineEdit * _line_command;
306       QLineEdit * _line_env_file;
307   };
308
309   class PythonSalomeMainPage: public QWizardPage
310   {
311     Q_OBJECT
312
313     public:
314       PythonSalomeMainPage(QWidget * parent);
315       virtual ~PythonSalomeMainPage();
316
317       virtual bool validatePage();
318       virtual int nextId() const ;
319       virtual void cleanupPage() {}
320
321     public slots:
322       void choose_PythonSalome_file();
323       void choose_env_file();
324
325     private:
326       QLineEdit * _line_PythonSalome;
327       QLineEdit * _line_env_file;
328   };
329
330   class AdvancedParametersPage: public QWizardPage
331   {
332     Q_OBJECT
333
334     public:
335       AdvancedParametersPage(BL::CreateJobWizard * parent);
336       virtual ~AdvancedParametersPage();
337
338       virtual int nextId() const;
339       virtual void cleanupPage() {}
340
341     private:
342       Ui::AdvancedParametersWizardPage * ui;
343
344   };
345
346 }
347
348 #endif
349