1 // Copyright (C) 2020-2021 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef MG_ADAPTGUI_HXX
21 #define MG_ADAPTGUI_HXX
25 #include <QTreeWidget>
26 #include <QItemDelegate>
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(MG_ADAPT)
32 #include <SALOME_GenericObj_wrap.hxx>
34 class SalomeApp_Module;
47 class QTreeWidgetItem;
51 class SMESHGUI_MgAdaptArguments;
52 class MgAdaptAdvWidgetTreeWidget;
53 class MgAdaptAdvWidget;
61 //=================================================================================
62 // class : SMESHGUI_MgAdaptDlg
64 //=================================================================================
65 class SMESHGUI_MgAdaptDlg : public QDialog
70 enum Mode { Arguments, AdvancedOptions};
71 SMESHGUI_MgAdaptDlg( SalomeApp_Module*, SMESH::MG_ADAPT_ptr, QWidget* parent= 0,bool isCreation = true );
72 ~SMESHGUI_MgAdaptDlg();
76 bool checkParams(QString& msg) ;
77 //~void setModel(MgAdapt*);
78 SMESH::MG_ADAPT_ptr getModel() const;
83 virtual bool PushOnApply();
86 virtual void PushOnHelp();
87 virtual void PushOnOK();
91 SMESHGUI_MgAdaptArguments* myArgs;
92 MgAdaptAdvWidget* myAdvOpt;
94 bool readParamsFromHypo( ) const ;
95 bool readParamsFromWidgets( ) ;
96 bool storeParamsToHypo( const SMESH::MgAdaptHypothesisData & ) const;
100 SalomeApp_Module* mySMESHGUI;
101 QTabWidget* myTabWidget;
103 SMESH::MgAdaptHypothesisData_var myData;
104 SALOME::GenericObj_wrap< SMESH::MG_ADAPT > model;
108 class SMESHGUI_MgAdaptArguments : public QWidget
113 enum Mode { Mesh, Browser};
114 enum SIZEMAP { Local, Background, Constant};
115 SMESHGUI_MgAdaptArguments( QWidget* parent);
116 ~SMESHGUI_MgAdaptArguments();
117 void setMode( const Mode, const SIZEMAP );
120 QString myFileOutDir;
121 QString myFileSizeMapDir;
123 QRadioButton* aMedfile;
124 QRadioButton* aBrowser ;
125 QLineEdit* aBrowserObject;
126 QPushButton* selectMedFilebutton ;
127 QSpacerItem* hspacer;
128 QLineEdit* selectMedFileLineEdit ;
129 QButtonGroup* meshInGroup ;
130 QGridLayout* meshIn ;
132 QGroupBox* aMeshOut ;
134 QLineEdit* meshNameLineEdit;
135 QSpacerItem* secondHspacer;
136 QCheckBox* medFileCheckBox;
137 QPushButton* selectOutMedFilebutton;
138 QLineEdit* selectOutMedFileLineEdit;
139 QSpacerItem* thirdHspacer;
140 QCheckBox* publishOut;
141 QGridLayout* meshOut ;
143 QGroupBox* sizeMapDefinition ;
144 QRadioButton* localButton;
145 QRadioButton* backgroundButton ;
146 QRadioButton* constantButton ;
147 QLabel* medFileBackground;
148 QPushButton* selectMedFileBackgroundbutton;
149 QLineEdit* selectMedFileBackgroundLineEdit;
151 QDoubleSpinBox* dvalue;
152 QButtonGroup* sizeMapDefGroup ;
153 QGridLayout* sizeMapDefGroupLayout;
156 QGroupBox* sizeMapField;
158 QComboBox* fieldNameCmb;
159 QRadioButton* noTimeStep;
160 QRadioButton* lastTimeStep ;
161 QRadioButton* chosenTimeStep;
162 QLabel* timeStepLabel;
165 QSpinBox* rankSpinBox;
166 QButtonGroup* timeStepGroup;
167 QGridLayout* sizeMapFieldGroupLayout;
170 void updateSelection();
171 void toExportMED(const char *);
172 void meshDimSignal(ADAPTATION_MODE aMode);
178 void modeChanged( int);
179 void sizeMapDefChanged(int);
180 void timeStepGroupChanged(int timeStepType, bool disableOther = false, int vmax = 0);
181 void onSelectMedFilebuttonClicked();
183 void onMedFileCheckBox(int);
184 void onPublishOut(int);
185 void onSelectOutMedFilebutton();
186 void onSelectMedFileBackgroundbutton();
187 void onLocalSelected(QString);
188 void onNoTimeStep(bool disableOther = false);
189 void onLastTimeStep(bool disableOther = false);
190 void onChosenTimeStep(bool disableOther = false, int vmax = 0);
191 void visibleTimeStepRankLabel(bool visible);
192 void valueAdaptation ();
196 QString getMedFileName(bool avertir);
199 std::map<QString, int> myFieldList;
203 OPTION_ID_COLUMN = 0,
205 OPTION_NAME_COLUMN = 0,
210 //////////////////////////////////////////
212 //////////////////////////////////////////
213 class MgAdaptAdvWidget : public QWidget
218 MgAdaptAdvWidget( QWidget* = 0, std::vector <std::string> * = nullptr, Qt::WindowFlags = 0 );
220 std::vector < std::string > *myOptions;
221 QGridLayout *gridLayout_4;
222 MgAdaptAdvWidgetTreeWidget *myOptionTable;
224 QSpacerItem *horizontalSpacer;
225 QGroupBox *logGroupBox;
226 QGridLayout *gridLayout_2;
227 QGridLayout *gridLayout;
228 QLabel *workingDirectoryLabel;
229 QLineEdit *workingDirectoryLineEdit;
230 QPushButton *workingDirectoryPushButton;
231 QLabel *verboseLevelLabel;
232 QSpinBox *verboseLevelSpin;
233 QHBoxLayout *horizontalLayout;
234 QCheckBox *logInFileCheck;
235 QCheckBox *removeLogOnSuccessCheck;
236 QCheckBox *keepWorkingFilesCheck;
238 void AddOption( const char* name_value_type, bool isCustom = false );
239 void GetOptionAndValue( QTreeWidgetItem * tblRow, QString& option, QString& value, bool& dflt );
244 void itemChanged(QTreeWidgetItem * tblRow, int column);
245 void onMeshDimChanged(ADAPTATION_MODE aMode);
247 void _onWorkingDirectoryPushButton();
249 void setOptionValue(QString& option, QString& value);
250 std::map<QString, QTreeWidgetItem *> optionTreeWidgetItem;
252 QTreeWidgetItem* getNewQTreeWidgetItem(QTreeWidget* table, const char* option, QString& name, bool isCustom);
256 enum { EDITABLE_ROLE = Qt::UserRole + 1, PARAM_NAME,
257 NAME_COL = 0, VALUE_COL
260 class ItemDelegate: public QItemDelegate
264 ItemDelegate(QObject* parent=0): QItemDelegate(parent) {}
265 QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &o, const QModelIndex &index) const;
268 class MgAdaptAdvWidgetTreeWidget : public QTreeWidget
272 MgAdaptAdvWidgetTreeWidget( QWidget* );
275 QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers );
276 void keyPressEvent( QKeyEvent* );
279 #endif // MG_ADAPTGUI_HXX