Salome HOME
Copyright update 2022
[modules/yacs.git] / src / ydfx_gui / YDFXGUIPushButtons.hxx
1 // Copyright (C) 2016-2022  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 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __YDFXGUIPUSHBUTTONS_HXX__
22 #define __YDFXGUIPUSHBUTTONS_HXX__
23
24 #include "ydfxwidgetsExport.hxx"
25
26 #include <QPushButton>
27 #include <QSettings>
28 #include <QDialog>
29 #include <QThread>
30 #include <QMutex>
31
32 class YACSEvalSession;
33 class YACSEvalYFXWrap;
34 class YDFXGUIAllPorts;
35
36 class YDFXGUIPushButton1 : public QPushButton
37 {
38   Q_OBJECT
39 public:
40   YDFXWIDGETS_EXPORT YDFXGUIPushButton1(QWidget *parent, YACSEvalYFXWrap *efx, YDFXGUIAllPorts *ports);
41 protected:
42   YACSEvalYFXWrap *_efx;
43   YDFXGUIAllPorts *_ports;
44 };
45
46 class YDFXGUIResourcePushButton : public YDFXGUIPushButton1
47 {
48   Q_OBJECT
49 public:
50   YDFXWIDGETS_EXPORT YDFXGUIResourcePushButton(QWidget *parent, YACSEvalYFXWrap *efx, YDFXGUIAllPorts *ports);
51 public slots:
52   void resourceAssignmentRequested();
53 private:
54   QSettings _settings;
55 };
56
57 class YDFXGUISeqInitButton : public YDFXGUIPushButton1
58 {
59   Q_OBJECT
60 public:
61   YDFXWIDGETS_EXPORT YDFXGUISeqInitButton(QWidget *parent, YACSEvalYFXWrap *efx, YDFXGUIAllPorts *ports);
62 public slots:
63   void sequenceInitRequested();
64 signals:
65   void sequenceWellDefined(bool);
66 private:
67   QMap<QString,QString> _state;
68 };
69
70 class YDFXGUIMachineDialog : public QDialog
71 {
72   Q_OBJECT
73 public:
74   YDFXWIDGETS_EXPORT YDFXGUIMachineDialog(QWidget *wid);
75   YDFXWIDGETS_EXPORT void setWidget(QWidget *wid) { _wid=wid; }
76 public slots:
77   void interactivityStatusChanged(bool newStatus);
78 private:
79   QWidget *_wid;
80 };
81
82 class YDFXGUIRunInfo : public QObject
83 {
84   Q_OBJECT
85 public:
86   YDFXWIDGETS_EXPORT YDFXGUIRunInfo(QObject *parent, int nbOfItems);
87   YDFXWIDGETS_EXPORT std::vector<char> getItems() const;
88   YDFXWIDGETS_EXPORT int getNbOfItems() const;
89   YDFXWIDGETS_EXPORT void setNbOfItems(int nbOfItems);
90   YDFXWIDGETS_EXPORT bool getComputationStatus() const;
91 public slots:
92   YDFXWIDGETS_EXPORT void startComputation();
93   YDFXWIDGETS_EXPORT void endComputation();
94   YDFXWIDGETS_EXPORT void sampleOK(int);
95   YDFXWIDGETS_EXPORT void sampleKO(int);
96 signals:
97   void somethingChanged();
98 private:
99   bool _computationInProgress;
100   std::vector<char> _items;
101   mutable QMutex _mut;
102 };
103
104 class YDFXGUIRunThread : public QThread
105 {
106 public:
107   YDFXWIDGETS_EXPORT YDFXGUIRunThread(QObject *parent, YACSEvalYFXWrap *efx, YACSEvalSession *session, YDFXGUIRunInfo *info);
108   YDFXWIDGETS_EXPORT ~YDFXGUIRunThread();
109   YDFXWIDGETS_EXPORT bool getReturns(int& ret1) const;
110   YDFXWIDGETS_EXPORT YACSEvalYFXWrap *getEFX() const { return _efx; }
111   YDFXWIDGETS_EXPORT YACSEvalSession *getSess() const { return _session; }
112 public:
113   YDFXWIDGETS_EXPORT void run();
114 private:
115   YACSEvalYFXWrap *_efx;
116   YACSEvalSession *_session;
117   YDFXGUIRunInfo *_info;
118   bool _ret0;
119   int _ret1;
120 };
121
122 class YDFXGUIRunningButton : public QPushButton
123 {
124   Q_OBJECT
125 public:
126   YDFXWIDGETS_EXPORT YDFXGUIRunningButton(QWidget *parent);
127   YDFXWIDGETS_EXPORT YACSEvalYFXWrap *getEFX();
128   YDFXWIDGETS_EXPORT YDFXGUIRunInfo *getInfo();
129   YDFXWIDGETS_EXPORT YACSEvalSession *getSess();
130   YDFXWIDGETS_EXPORT YDFXGUIRunThread *getThread();
131 public slots:
132   YDFXWIDGETS_EXPORT void runWizardSlot();
133   YDFXWIDGETS_EXPORT void evaluationFinished();
134 private:
135   void runEvaluation();
136 private:
137   static bool ComputeStateRes(YACSEvalYFXWrap *efx, int& nbOfSamples);
138   static bool ComputeStateSeq(YACSEvalYFXWrap *efx);
139 };
140
141 class YDFXGUIRunningPB : public QWidget
142 {
143   Q_OBJECT
144 public:
145   YDFXWIDGETS_EXPORT YDFXGUIRunningPB(QWidget *parent, YDFXGUIRunInfo *info);
146   YDFXWIDGETS_EXPORT void startComputation();
147   YDFXWIDGETS_EXPORT void paintEvent(QPaintEvent *event);
148   YDFXWIDGETS_EXPORT QSize sizeHint() const;
149   YDFXWIDGETS_EXPORT QSize minimumSizeHint() const;
150 private:
151   YDFXGUIRunInfo *_info;
152 };
153
154 class YDFXGUIRunButton : public QWidget
155 {
156   Q_OBJECT
157 public:
158   YDFXWIDGETS_EXPORT YDFXGUIRunButton(QWidget *parent, YACSEvalSession *session, YACSEvalYFXWrap *efx);
159   YDFXWIDGETS_EXPORT QSize sizeHint() const;
160   YDFXWIDGETS_EXPORT QSize minimumSizeHint() const;
161   YDFXWIDGETS_EXPORT YACSEvalYFXWrap *getEFX() { return _th->getEFX(); }
162   YDFXWIDGETS_EXPORT YDFXGUIRunInfo *getInfo() { return _info; }
163   YDFXWIDGETS_EXPORT YACSEvalSession *getSess() { return _th->getSess(); }
164   YDFXWIDGETS_EXPORT YDFXGUIRunThread *getThread() { return _th; }
165   YDFXWIDGETS_EXPORT YDFXGUIRunningButton *getPush() { return _push; }
166 public slots:
167   YDFXWIDGETS_EXPORT void update();
168   YDFXWIDGETS_EXPORT void setEnabled(bool);
169   YDFXWIDGETS_EXPORT void setDisabled(bool);
170 private:
171   YDFXGUIRunInfo *_info;
172   YDFXGUIRunThread *_th;
173   YDFXGUIRunningButton *_push;
174   YDFXGUIRunningPB *_pb;
175 };
176
177 #endif