Salome HOME
updated copyright message
[modules/yacs.git] / src / ydfx_gui / YDFXGUISeqInit.hxx
1 // Copyright (C) 2016-2023  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 __YDFXGUISEQINIT_HXX__
22 #define __YDFXGUISEQINIT_HXX__
23
24 #include "ydfxwidgetsExport.hxx"
25
26 #include <QWidget>
27 #include <QComboBox>
28 #include <QTextEdit>
29 #include <QPushButton>
30
31 #include <vector>
32
33 class QTextEdit;
34 class QComboBox;
35 class QPushButton;
36
37 class YACSEvalYFXWrap;
38 class YACSEvalInputPort;
39
40 class YDFXGUIDoubleVectHolder
41 {
42 public:
43   YDFXWIDGETS_EXPORT YDFXGUIDoubleVectHolder() { }
44   YDFXWIDGETS_EXPORT virtual bool executeScript(int& sz) = 0;
45   YDFXWIDGETS_EXPORT void applyOnInput(YACSEvalInputPort *inp) const;
46 protected:
47   std::vector<double> _vect;
48 };
49
50 class YDFXGUISeqSetterP : public QPushButton, public YDFXGUIDoubleVectHolder
51 {
52   Q_OBJECT
53 public:
54   YDFXWIDGETS_EXPORT YDFXGUISeqSetterP(QWidget *parent=0);
55   YDFXWIDGETS_EXPORT void loadState(const QString& state);
56   YDFXWIDGETS_EXPORT QString saveState() const;
57   YDFXWIDGETS_EXPORT bool executeScript(int& sz);
58   YDFXWIDGETS_EXPORT void enterEvent(QEvent *event);
59   YDFXWIDGETS_EXPORT void leaveEvent(QEvent *event);
60   YDFXWIDGETS_EXPORT void paintEvent(QPaintEvent *event);
61 public slots:
62   YDFXWIDGETS_EXPORT void selectAFile();
63 signals:
64   void problemDetected(const QString& msg);
65 private:
66   bool _isIn;
67   QString _fileName;
68 };
69
70 class YDFXGUISeqSetterT : public QTextEdit, public YDFXGUIDoubleVectHolder
71 {
72   Q_OBJECT
73 public:
74   YDFXWIDGETS_EXPORT YDFXGUISeqSetterT(QWidget *parent=0):QTextEdit(parent) { }
75   YDFXWIDGETS_EXPORT void loadState(const QString& state);
76   YDFXWIDGETS_EXPORT QString saveState() const;
77   YDFXWIDGETS_EXPORT bool executeScript(int& sz);
78 signals:
79   void problemDetected(const QString& msg);
80 };
81
82 class YDFXGUICombo : public QComboBox
83 {
84 public:
85   YDFXWIDGETS_EXPORT YDFXGUICombo(QWidget *parent);
86   YDFXWIDGETS_EXPORT QString getName();
87   YDFXWIDGETS_EXPORT void enterEvent(QEvent *event);
88   YDFXWIDGETS_EXPORT void leaveEvent(QEvent *event);
89   YDFXWIDGETS_EXPORT void paintEvent(QPaintEvent *event);
90 private:
91   bool _isIn;
92 };
93
94 class YDFXGUISeqSetter : public QWidget
95 {
96   Q_OBJECT
97 public:
98   YDFXWIDGETS_EXPORT YDFXGUISeqSetter(QWidget *parent, const QString& name);
99   YDFXWIDGETS_EXPORT int loadState(const QString& state);
100   YDFXWIDGETS_EXPORT QString saveState() const;
101   YDFXWIDGETS_EXPORT QSize sizeHint() const;
102   YDFXWIDGETS_EXPORT QSize minimumSizeHint() const;
103   YDFXWIDGETS_EXPORT bool checkOK(int& sz);
104   YDFXWIDGETS_EXPORT void applyOnInput(YACSEvalInputPort *inp);
105 public:
106   YDFXWIDGETS_EXPORT void typeOfAssignmentChanged(int newType);
107 signals:
108   void problemDetected(const QString& msg);
109 private:
110   YDFXGUISeqSetterT *_textEdit;
111   YDFXGUISeqSetterP *_push;
112   int _curType;
113 };
114
115 class YDFXGUIStatus;
116
117 class YDFXGUISeqLine : public QWidget
118 {
119   Q_OBJECT
120 public:
121   YDFXWIDGETS_EXPORT YDFXGUISeqLine(QWidget *parent, YACSEvalInputPort *inp);
122   YDFXWIDGETS_EXPORT void loadState(const QMap<QString,QString>& state);
123   YDFXWIDGETS_EXPORT void saveState(QMap<QString,QString>& state) const;
124   YDFXWIDGETS_EXPORT QString getName() const;
125   YDFXWIDGETS_EXPORT int getPositionOfCombo() const;
126   YDFXWIDGETS_EXPORT bool checkOK(int& sz);
127   YDFXWIDGETS_EXPORT void connectToStatus(YDFXGUIStatus *status);
128   YDFXWIDGETS_EXPORT YDFXGUISeqSetter *setter() { return _setter; }
129   YDFXWIDGETS_EXPORT void applyOnInput();
130 public slots:
131   void typeOfAssignmentChanged(int newType);
132 private:
133   YDFXGUICombo *_combo;
134   YDFXGUISeqSetter *_setter;
135   YACSEvalInputPort *_inp;
136 };
137
138 class YDFXGUIStatus : public QWidget
139 {
140   Q_OBJECT
141 public:
142   YDFXWIDGETS_EXPORT YDFXGUIStatus(QWidget *parent);
143   YDFXWIDGETS_EXPORT void paintEvent(QPaintEvent *event);
144   YDFXWIDGETS_EXPORT QSize sizeHint() const;
145   YDFXWIDGETS_EXPORT QSize minimumSizeHint() const;
146 public slots:
147   YDFXWIDGETS_EXPORT void declareOK(bool);
148   YDFXWIDGETS_EXPORT void displayInfo(const QString& txt);
149 public:
150   static const char OK_STR[];
151 private:
152   QString _text;
153 };
154
155 class YDFXGUISeqInitEff : public QWidget
156 {
157   Q_OBJECT
158 public:
159   YDFXWIDGETS_EXPORT YDFXGUISeqInitEff(QWidget *parent, YACSEvalYFXWrap *efx);
160   YDFXWIDGETS_EXPORT void loadState(const QMap<QString,QString>& state);
161   YDFXWIDGETS_EXPORT QMap<QString,QString> saveState() const;
162   YDFXWIDGETS_EXPORT void connectToStatus(YDFXGUIStatus *status);
163 public slots:
164   YDFXWIDGETS_EXPORT void assignButtonClicked();
165   YDFXWIDGETS_EXPORT void applyOnEFX();
166 signals:
167   void configurationIsOK(bool);
168 private:
169   bool checkConsistency(int& sz);
170 private:
171   std::vector<YDFXGUISeqLine *> _lines;
172 };
173
174 class YDFXGUISeqInit : public QWidget
175 {
176   Q_OBJECT
177 public:
178   YDFXWIDGETS_EXPORT YDFXGUISeqInit(QWidget *parent, YACSEvalYFXWrap *efx);
179   YDFXWIDGETS_EXPORT void loadState(const QMap<QString,QString>& state);
180   YDFXWIDGETS_EXPORT QMap<QString,QString> saveState() const;
181 signals:
182   void assignButtonClicked();
183 private:
184   YDFXGUISeqInitEff *_zeWidget;
185 };
186
187 #endif