Salome HOME
d2d0613de3b49c605d2f667d2b1e829f5815693a
[modules/jobmanager.git] / src / genericgui / BL_CreateJobWizard.hxx
1 // Copyright (C) 2009-2016  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 "BL_Traces.hxx"
24 #include "BL_SALOMEServices.hxx"
25 #include "JM_ResourceCatalog.hxx"
26
27 #include <QWizard>
28 #include <QWizardPage>
29 #include <string>
30 #include <list>
31
32 class QGridLayout;
33 class QLabel;
34 class QLineEdit;
35 class QListWidget;
36
37 namespace Ui {
38   class ResourceRequirementsWizardPage;
39   class FilesWizardPage;
40   class AdvancedParametersWizardPage;
41 }
42
43 namespace BL {
44
45   class JobsManager_QT;
46   class JobNamePage;
47   class BatchParametersPage;
48   class CreateJobWizard: public QWizard
49   {
50     Q_OBJECT
51
52     public:
53       CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALOMEServices * salome_services);
54       virtual ~CreateJobWizard();
55
56       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
57
58       void clone(const std::string & name);
59
60     public slots:
61       void end(int result);
62
63     private:
64       BL::JobsManager_QT * _jobs_manager;
65       QListWidget * _input_files_list;
66       QListWidget * _output_files_list;
67
68       BL::JobNamePage * _job_name_page;
69       BL::BatchParametersPage * _batch_parameters_page;
70       BL::SALOMEServices * _salome_services;
71
72     public:
73       // Results
74       std::string job_name;
75       enum {YACS, COMMAND, PYTHON_SALOME} job_type;
76
77       std::string yacs_file;
78       std::string command;
79       std::string python_salome_file;
80
81       std::string env_file;
82
83       std::string batch_directory;
84
85       // For COORM
86       std::string coorm_batch_directory;
87
88       std::string maximum_duration;
89       long mem_limit;
90       BL::Job::MemReqType mem_req_type;
91       int nb_proc;
92       bool exclusive;
93
94       // Parameters for COORM
95       std::string launcher_file;
96       std::string launcher_args;
97
98       std::string result_directory;
99       std::list<std::string> input_files_list;
100       std::list<std::string> output_files_list;
101
102       std::string resource_choosed;
103       std::string batch_queue;
104       std::string wckey;
105       std::string extra_params;
106
107       bool start_job;
108       int dump_yacs_state;
109       std::string ll_jobtype;
110       std::string yacs_driver_options;
111
112     public:
113       enum {Page_JobName,
114             Page_YACSSchema,
115             Page_Command_Main_Definitions,
116             Page_PythonSalome_Main_Definitions,
117             Page_BatchParameters,
118             Page_COORM_BatchParameters,
119             Page_Files,
120             Page_Resource,
121             Page_Advanced,
122             Page_Conclusion};
123   };
124
125   class JobNamePage: public QWizardPage
126   {
127     Q_OBJECT
128
129     public:
130       JobNamePage(QWidget * parent, BL::JobsManager_QT * jobs_manager);
131       virtual ~JobNamePage();
132
133       virtual bool validatePage();
134       virtual int nextId() const ;
135       virtual void cleanupPage() {}
136
137     public slots:
138       void yacs_schema_button(bool checked);
139       void command_button(bool checked);
140       void python_salome_button(bool checked);
141
142     private:
143       BL::JobsManager_QT * _jobs_manager;
144       QLabel * _explanation;
145
146     public:
147       bool _check_name;
148   };
149
150   class ConclusionPage: public QWizardPage
151   {
152     public:
153       ConclusionPage(QWidget * parent);
154       virtual ~ConclusionPage();
155
156       virtual bool validatePage();
157       virtual int nextId() const ;
158       virtual void cleanupPage() {}
159   };
160
161   class BatchParametersPage: public QWizardPage
162   {
163     Q_OBJECT
164
165     public:
166       enum MemUnit {MB, GB};
167
168       BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
169       virtual ~BatchParametersPage();
170
171       virtual void initializePage();
172       virtual int nextId() const;
173       virtual void cleanupPage();
174
175       MemUnit getMemUnit() const;
176       void setMemUnit(MemUnit mem_unit);
177
178       BL::Job::MemReqType getMemReqType() const;
179       void setMemReqType(BL::Job::MemReqType mem_req_type);
180
181     public slots:
182       void timeChanged();
183       void memChanged();
184
185     private:
186       Ui::ResourceRequirementsWizardPage * ui;
187       BL::SALOMEServices * _salome_services;
188       std::string resource_choosed;
189   };
190
191   // For COORM
192   class COORM_BatchParametersPage: public QWizardPage
193   {
194     Q_OBJECT
195
196     public:
197       COORM_BatchParametersPage(QWidget * parent, BL::SALOMEServices * salome_services);
198       virtual ~COORM_BatchParametersPage();
199
200       virtual bool validatePage();
201       virtual int nextId() const;
202       virtual void cleanupPage();
203       virtual void initializePage();
204
205     public slots:
206       void choose_launcher_file();
207
208     private:
209       BL::SALOMEServices * _salome_services;
210       QLineEdit * _launcher_file_text;
211       QString resource_choosed;
212   };
213
214   class FilesPage: public QWizardPage
215   {
216     Q_OBJECT
217
218     public:
219       FilesPage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
220       virtual ~FilesPage();
221
222       virtual void initializePage();
223       virtual int nextId() const;
224       virtual bool isComplete() const;
225       virtual void cleanupPage() {}
226
227     public slots:
228       void choose_input_files();
229       void remove_input_files();
230       void input_itemSelectionChanged();
231       void choose_local_directory();
232
233       void add_output_file();
234       void remove_output_files();
235       void output_itemSelectionChanged();
236
237     private:
238       Ui::FilesWizardPage * ui;
239       BL::SALOMEServices * _salome_services;
240       QString resource_choosed;
241   };
242
243   class ResourcePage: public QWizardPage
244   {
245     Q_OBJECT
246
247     public:
248       ResourcePage(BL::CreateJobWizard * parent, BL::SALOMEServices * salome_services);
249       virtual ~ResourcePage();
250
251       virtual int nextId() const;
252       virtual bool validatePage();
253       virtual void initializePage();
254       virtual void cleanupPage() {}
255
256     public slots:
257       void itemSelected(QListWidgetItem * item);
258
259     private:
260       JM::ResourceCatalog * _resource_list;
261       QLineEdit * _resource_choosed;
262       BL::SALOMEServices * _salome_services;
263
264       QLabel * _ll_label;
265       QLineEdit * _ll_value;
266       QGridLayout * _main_layout;
267   };
268
269   class YACSSchemaPage: public QWizardPage
270   {
271     Q_OBJECT
272
273     public:
274       YACSSchemaPage(QWidget * parent);
275       virtual ~YACSSchemaPage();
276
277       virtual bool validatePage();
278       virtual int nextId() const ;
279       virtual void cleanupPage() {}
280
281     public slots:
282       void choose_file();
283       void choose_env_file();
284
285     private:
286       QLineEdit * _yacs_file_text;
287       QLineEdit * _line_env_file;
288   };
289
290   class CommandMainPage: public QWizardPage
291   {
292     Q_OBJECT
293
294     public:
295       CommandMainPage(QWidget * parent);
296       virtual ~CommandMainPage();
297
298       virtual bool validatePage();
299       virtual int nextId() const ;
300       virtual void cleanupPage() {}
301
302     public slots:
303       void choose_command_file();
304       void choose_env_file();
305
306     private:
307       QLineEdit * _line_command;
308       QLineEdit * _line_env_file;
309   };
310
311   class PythonSalomeMainPage: public QWizardPage
312   {
313     Q_OBJECT
314
315     public:
316       PythonSalomeMainPage(QWidget * parent);
317       virtual ~PythonSalomeMainPage();
318
319       virtual bool validatePage();
320       virtual int nextId() const ;
321       virtual void cleanupPage() {}
322
323     public slots:
324       void choose_PythonSalome_file();
325       void choose_env_file();
326
327     private:
328       QLineEdit * _line_PythonSalome;
329       QLineEdit * _line_env_file;
330   };
331
332   class AdvancedParametersPage: public QWizardPage
333   {
334     Q_OBJECT
335
336     public:
337       AdvancedParametersPage(BL::CreateJobWizard * parent);
338       virtual ~AdvancedParametersPage();
339
340       virtual int nextId() const;
341       virtual void cleanupPage() {}
342
343     private:
344       Ui::AdvancedParametersWizardPage * ui;
345
346   };
347
348 }
349
350 #endif
351