Salome HOME
MEDcoupling pour la dimension du maillage
[modules/smesh.git] / src / SMESHGUI / MG_ADAPTGUI.hxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE\r
2 //\r
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
5 //\r
6 // This library is free software; you can redistribute it and/or\r
7 // modify it under the terms of the GNU Lesser General Public\r
8 // License as published by the Free Software Foundation; either\r
9 // version 2.1 of the License, or (at your option) any later version.\r
10 //\r
11 // This library is distributed in the hope that it will be useful,\r
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
14 // Lesser General Public License for more details.\r
15 //\r
16 // You should have received a copy of the GNU Lesser General Public\r
17 // License along with this library; if not, write to the Free Software\r
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA\r
19 //\r
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
21 //\r
22 // SMESH SMESHGUI : GUI for the adaptation in the SMESH component\r
23 // File : MG_ADAPTGUI.hxx\r
24 //\r
25 #ifndef MG_ADAPTGUI_HXX\r
26 #define MG_ADAPTGUI_HXX\r
27 \r
28 #include <set>\r
29 // SMESH includes\r
30 \r
31 // Qt includes\r
32 #include <QDialog>\r
33 #include <QTreeWidget>\r
34 #include<QItemDelegate>\r
35 \r
36 #include "LightApp_DataOwner.h"\r
37 #include "SalomeApp_Application.h"\r
38 #include <SALOMEconfig.h>\r
39 #include <SALOME_ListIO.hxx>\r
40 #include "SalomeApp_Module.h"\r
41 #include "SalomeApp_Study.h"\r
42 #include <med.h>\r
43 #include <map>\r
44 \r
45 \r
46 // model\r
47 \r
48 \r
49 //~#include "MG_ADAPT.hxx"\r
50 \r
51 #include CORBA_SERVER_HEADER(MG_ADAPT)\r
52 \r
53 class SUIT_ViewWindow;\r
54 class SUIT_Desktop;\r
55 class SUIT_Study;\r
56 class SUIT_ResourceMgr;\r
57 \r
58 class CAM_Module;\r
59 \r
60 class SALOMEDSClient_Study;\r
61 class SALOMEDSClient_SObject;\r
62 \r
63 class SalomeApp_Study;\r
64 class SalomeApp_Module;\r
65 class LightApp_SelectionMgr;\r
66 \r
67 \r
68 class QButtonGroup;\r
69 class QLineEdit;\r
70 class QGroupBox;\r
71 class QRadioButton;\r
72 class QLabel;\r
73 class QCheckBox;\r
74 class QGridLayout;\r
75 class QTabWidget;\r
76 class QDoubleSpinBox;\r
77 class QSpinBox;\r
78 class QTreeWidget;\r
79 class QTreeWidgetItem;\r
80 class QSpacerItem;\r
81 class QHBoxLayout;\r
82 class QItemDelegate;\r
83 class QComboBox;\r
84 \r
85 // IDL includes\r
86 #include <SALOMEconfig.h>\r
87 \r
88 class SVTK_ViewWindow;\r
89 class SVTK_Selector;\r
90 class SMESHGUI_MgAdaptDlg;\r
91 class SMESHGUI_MgAdaptArguments;\r
92 class SMESHGUI_SpinBox;\r
93 class MgAdaptAdvWidgetTreeWidget;\r
94 class MgAdaptAdvWidget;\r
95 //~class MgAdapt;\r
96 class QHeaderView;\r
97 class QFileDialog;\r
98 \r
99 \r
100 std::map<QString, int> GetListeChamps(QString aFile, bool errorMessage = true);\r
101 QString lireNomMaillage(QString aFile, med_int& meshDim);\r
102 \r
103 std::string remove_extension(const std::string& filename);\r
104 \r
105 enum ADAPTATION_MODE{\r
106   SURFACE, // surface adaption when meshDim == 2\r
107   VOLUME, //\r
108   BOTH\r
109 };\r
110 //=================================================================================\r
111 // class    : SMESHGUI_MgAdaptDlg\r
112 // purpose  :\r
113 //=================================================================================\r
114 class  SMESHGUI_MgAdaptDlg : public QDialog\r
115 {\r
116   Q_OBJECT;\r
117 public:\r
118   //! Property type\r
119   enum Mode { Arguments, AdvancedOptions};\r
120   SMESHGUI_MgAdaptDlg( SalomeApp_Module*, SMESH::MG_ADAPT_ptr, QWidget* parent= 0,bool isCreation = true );\r
121   ~SMESHGUI_MgAdaptDlg();\r
122 \r
123   void buildDlg();\r
124   void reject();\r
125   bool checkParams(QString& msg) ;\r
126   //~void setModel(MgAdapt*);\r
127   SMESH::MG_ADAPT_ptr getModel() const;\r
128 \r
129 public slots:\r
130 \r
131 protected slots:\r
132   virtual bool PushOnApply();\r
133 \r
134 private slots:\r
135   virtual void PushOnHelp();\r
136   virtual void PushOnOK();\r
137 \r
138 protected :\r
139 \r
140   SMESHGUI_MgAdaptArguments* myArgs;\r
141   MgAdaptAdvWidget* myAdvOpt;\r
142   bool readParamsFromHypo( ) const ;\r
143   bool readParamsFromWidgets( ) ;\r
144   bool storeParamsToHypo( const SMESH::MgAdaptHypothesisData & ) const;\r
145 \r
146 private:\r
147 \r
148   SalomeApp_Module*              mySMESHGUI;              /* Current SMESHGUI object */\r
149   QTabWidget*           myTabWidget;\r
150 \r
151 \r
152   SMESH::MgAdaptHypothesisData* myData;\r
153   SMESH::MG_ADAPT_ptr model;\r
154 \r
155 };\r
156 \r
157 class  SMESHGUI_MgAdaptArguments : public QWidget\r
158 {\r
159   Q_OBJECT;\r
160 public:\r
161   //! Property type\r
162   enum Mode { Mesh, Browser};\r
163   enum SIZEMAP { Local, Background, Constant};\r
164   SMESHGUI_MgAdaptArguments( QWidget* parent);\r
165   ~SMESHGUI_MgAdaptArguments();\r
166   void setMode( const Mode, const SIZEMAP );\r
167   med_int getMeshDim() const;\r
168 \r
169   QString* myFileInDir;\r
170   QString* myFileOutDir;\r
171   QString* myFileSizeMapDir;\r
172   QGroupBox*    aMeshIn ;\r
173   QRadioButton* aMedfile;\r
174   QRadioButton* aBrowser ;\r
175   QLineEdit* aBrowserObject;\r
176   QPushButton* selectMedFilebutton ;\r
177   QSpacerItem* hspacer;\r
178   QLineEdit* selectMedFileLineEdit ;\r
179   QButtonGroup* meshInGroup ;\r
180   QGridLayout* meshIn ;\r
181 \r
182   QGroupBox*    aMeshOut ;\r
183   QLabel* meshName;\r
184   QLineEdit* meshNameLineEdit;\r
185   QSpacerItem* secondHspacer;\r
186   QCheckBox* medFileCheckBox;\r
187   QPushButton* selectOutMedFilebutton;\r
188   QLineEdit* selectOutMedFileLineEdit;\r
189   QSpacerItem* thirdHspacer;\r
190   QCheckBox* publishOut;\r
191   QGridLayout* meshOut ;\r
192 \r
193   QGroupBox*    sizeMapDefinition ;\r
194   QRadioButton* localButton;\r
195   QRadioButton* backgroundButton ;\r
196   QRadioButton* constantButton ;\r
197   QLabel* medFileBackground;\r
198   QPushButton* selectMedFileBackgroundbutton;\r
199   QLineEdit* selectMedFileBackgroundLineEdit;\r
200   QLabel* valueLabel;\r
201   QDoubleSpinBox* dvalue;\r
202   QButtonGroup* sizeMapDefGroup ;\r
203   QGridLayout* sizeMapDefGroupLayout;\r
204 \r
205 \r
206   QGroupBox* sizeMapField;\r
207   QLabel* fieldName;\r
208   QComboBox* fieldNameCmb;\r
209   QRadioButton* noTimeStep;\r
210   QRadioButton* lastTimeStep ;\r
211   QRadioButton* chosenTimeStep;\r
212   QLabel* timeStepLabel;\r
213   QSpinBox* timeStep;\r
214   QLabel* rankLabel;\r
215   QSpinBox* rankSpinBox;\r
216   QButtonGroup* timeStepGroup;\r
217   QGridLayout* sizeMapFieldGroupLayout;\r
218 \r
219 signals:\r
220   void updateSelection();\r
221   void toExportMED(const char *);\r
222   void meshDimSignal(ADAPTATION_MODE aMode);\r
223 public slots:\r
224 \r
225 protected slots:\r
226 \r
227 private slots:\r
228   void modeChanged( int);\r
229   void sizeMapDefChanged(int);\r
230   void timeStepGroupChanged(int timeStepType, bool disableOther = false, int vmax = 0);\r
231   void onSelectMedFilebuttonClicked();\r
232   void clear();\r
233   void onMedFileCheckBox(int);\r
234   void onPublishOut(int);\r
235   void onSelectOutMedFilebutton();\r
236   void onSelectMedFileBackgroundbutton();\r
237   void onLocalSelected(QString);\r
238   void onNoTimeStep(bool disableOther = false);\r
239   void onLastTimeStep(bool disableOther = false);\r
240   void onChosenTimeStep(bool disableOther = false, int vmax = 0);\r
241   void visibleTimeStepRankLabel(bool visible);\r
242 \r
243 private:\r
244 \r
245   QString getMedFileName(bool avertir);\r
246   LightApp_SelectionMgr* selMgr ;\r
247   med_int meshDim;\r
248   std::map<QString, int> myFieldList;\r
249 \r
250 };\r
251 enum {\r
252   OPTION_ID_COLUMN = 0,\r
253   OPTION_TYPE_COLUMN,\r
254   OPTION_NAME_COLUMN = 0,\r
255   OPTION_VALUE_COLUMN,\r
256   NB_COLUMNS,\r
257 };\r
258 \r
259 //////////////////////////////////////////\r
260 // MgAdaptAdvWidget\r
261 //////////////////////////////////////////\r
262 class  MgAdaptAdvWidget : public QWidget\r
263 {\r
264   Q_OBJECT\r
265 \r
266 public:\r
267   MgAdaptAdvWidget( QWidget* = 0, std::vector <std::string> * = nullptr, Qt::WindowFlags = 0 );\r
268   ~MgAdaptAdvWidget();\r
269   std::vector < std::string > * myOptions;\r
270   QGridLayout *gridLayout_4;\r
271   MgAdaptAdvWidgetTreeWidget *myOptionTable;\r
272   QPushButton *addBtn;\r
273   QSpacerItem *horizontalSpacer;\r
274   QGroupBox *logGroupBox;\r
275   QGridLayout *gridLayout_2;\r
276   QGridLayout *gridLayout;\r
277   QLabel *workingDirectoryLabel;\r
278   QLineEdit *workingDirectoryLineEdit;\r
279   QPushButton *workingDirectoryPushButton;\r
280   QLabel *verboseLevelLabel;\r
281   QSpinBox *verboseLevelSpin;\r
282   QHBoxLayout *horizontalLayout;\r
283   QCheckBox *logInFileCheck;\r
284   QCheckBox *removeLogOnSuccessCheck;\r
285   QCheckBox *keepWorkingFilesCheck;\r
286 \r
287   void AddOption( const char* name_value_type, bool isCustom = false );\r
288   void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt );\r
289   void setupWidget();\r
290 \r
291 public slots:\r
292   void                onAddOption();\r
293   void itemChanged(QTreeWidgetItem * tblRow, int column);\r
294   void onMeshDimChanged(ADAPTATION_MODE aMode);\r
295 private slots:\r
296   void _onWorkingDirectoryPushButton();\r
297 private:\r
298   void setOptionValue(QString& option, QString& value);\r
299   std::map<QString, QTreeWidgetItem *> optionTreeWidgetItem;\r
300 \r
301   QTreeWidgetItem* getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom);\r
302 \r
303 };\r
304 \r
305 enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME,\r
306        NAME_COL = 0, VALUE_COL\r
307      };\r
308 \r
309 class  ItemDelegate: public QItemDelegate\r
310 {\r
311 public:\r
312 \r
313   ItemDelegate(QObject* parent=0): QItemDelegate(parent) {}\r
314   QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const;\r
315 };\r
316 \r
317 class  MgAdaptAdvWidgetTreeWidget : public QTreeWidget\r
318 {\r
319   Q_OBJECT\r
320 public:\r
321   MgAdaptAdvWidgetTreeWidget( QWidget* );\r
322 \r
323 protected:\r
324   QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers );\r
325   void keyPressEvent( QKeyEvent* );\r
326 };\r
327 \r
328 #endif // MG_ADAPTGUI_HXX\r