1 // Copyright (C) 2004-2023 CEA, EDF
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 // GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
21 // File : GHS3DPluginGUI_HypothesisCreator.h
22 // Author : Michael Zorin
23 // Module : GHS3DPlugin
25 #ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
26 #define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
29 #if defined GHS3DPluginGUI_EXPORTS
30 #define GHS3DPLUGINGUI_EXPORT __declspec( dllexport )
32 #define GHS3DPLUGINGUI_EXPORT __declspec( dllimport )
35 #define GHS3DPLUGINGUI_EXPORT
38 #include <SMESHGUI_Hypotheses.h>
39 #include <GeomSelectionTools.h>
40 #include <TopAbs_ShapeEnum.hxx>
42 #include <QItemDelegate>
46 #include <GEOM_Client.hxx>
47 #include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
48 #include CORBA_SERVER_HEADER(SMESH_Gen)
49 #include CORBA_SERVER_HEADER(SMESH_Mesh)
58 class QTableWidgetItem;
62 class GHS3DPluginGUI_AdvWidget;
63 class LightApp_SelectionMgr;
64 class SMESHGUI_SpinBox;
65 class SUIT_SelectionFilter;
66 class SalomeApp_IntSpinBox;
67 class StdMeshersGUI_ObjectReferenceParamWdg;
73 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
76 bool operator == (const QTEnfVertex* other) const {
78 if (this->coords.size() && other->coords.size())
79 return (this->coords == other->coords);
81 return (this->geomEntry == other->geomEntry);
90 std::vector<double> coords;
93 typedef QList< QTEnfVertex* > QEnfVertexList;
98 std::string geomEntry;
100 std::vector<double> coords;
101 std::string groupName;
105 struct CompareEnfVertices
107 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
109 if (e1->coords.size() && e2->coords.size())
110 return (e1->coords < e2->coords);
112 return (e1->geomEntry < e2->geomEntry);
118 // List of enforced vertices
119 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
126 std::string groupName;
129 struct CompareEnfMeshes
131 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
133 if (e1->entry == e2->entry)
134 return (e1->elementType < e2->elementType);
136 return (e1->entry < e2->entry);
142 // List of enforced meshes
143 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
147 int myOptimizationLevel;
148 double myMinSize, myMaxSize, myMinSizeDefault, myMaxSizeDefault;
150 int myNbProximityLayers;
151 bool myUseMinSize, myUseMaxSize, myUseGradation, myUseProximity;
152 bool myToMeshHoles, myToMakeGroupsOfDomains;
153 bool myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
154 myKeepFiles,myLogInStandardOutput, myRemoveLogOnSuccess;
155 float myInitialMemory, myMaximumMemory;
156 QString myName,myWorkingDir;
157 short myVerboseLevel;
158 TEnfVertexList myEnforcedVertices;
159 TEnfMeshList myEnforcedMeshes;
160 short myAlgorithm, myNumOfThreads, myPthreadMode, myParallelMode;
161 bool myUseNumOfThreads;
163 int myOptimization, mySplitOverConstrained, myPThreadsMode, myNumberOfThreads;
164 bool mySmoothOffSlivers;
166 } GHS3DHypothesisData;
169 \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
171 class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
176 GHS3DPluginGUI_HypothesisCreator( const QString& );
177 virtual ~GHS3DPluginGUI_HypothesisCreator();
179 virtual bool checkParams(QString& msg) const;
180 virtual QString helpPage() const;
183 virtual QFrame* buildFrame ();
184 virtual void retrieveParams() const;
185 virtual QString storeParams () const;
187 virtual QString caption() const;
188 virtual QPixmap icon() const;
189 virtual QString type() const;
193 void onToMeshHoles(bool);
194 void onDirBtnClicked();
195 void updateWidgets();
197 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
198 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
199 bool isCompound = false);
200 void onAddEnforcedVertex();
201 void onRemoveEnforcedVertex();
202 void synchronizeCoords();
203 void updateEnforcedVertexValues(QTableWidgetItem* );
204 void onSelectEnforcedVertex();
205 void clearEnforcedVertexWidgets();
206 void checkVertexIsDefined();
207 void clearEnfVertexSelection();
209 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
210 void onAddEnforcedMesh();
211 void onRemoveEnforcedMesh();
212 //void synchronizeEnforcedMesh();
213 void checkEnfMeshIsDefined();
214 void onRadioButtonSelect();
215 void onNumOfThreadsCheck();
218 void vertexDefined(bool);
219 void enfMeshDefined(bool);
222 bool readParamsFromHypo( GHS3DHypothesisData& ) const;
223 bool readParamsFromWidgets( GHS3DHypothesisData& ) const;
224 bool storeParamsToHypo( const GHS3DHypothesisData& ) const;
225 GeomSelectionTools* getGeomSelectionTool();
226 GEOM::GEOM_Gen_var getGeomEngine();
227 bool isOptimization() const;
233 QComboBox* myOptimizationLevelCombo;
234 QCheckBox* myMinSizeCheck;
235 QCheckBox* myMaxSizeCheck;
236 SMESHGUI_SpinBox* myMinSizeSpin;
237 SMESHGUI_SpinBox* myMaxSizeSpin;
238 QCheckBox* myNumOfThreadsCheck;
239 SalomeApp_IntSpinBox* myNumOfThreadsSpin;
240 mutable double myMinSizeDefault, myMaxSizeDefault;
242 QCheckBox* myGradationCheck;
243 SMESHGUI_SpinBox* myGradationSpin;
244 QGroupBox* myUseProximityGroup;
245 SalomeApp_IntSpinBox* myNbProximityLayers;
247 QCheckBox* myToMakeGroupsOfDomains;
248 QCheckBox* myToMeshHolesCheck;
250 QComboBox* myOptimizationCombo;
251 QComboBox* mySplitOverConstrainedCombo;
252 QComboBox* myPThreadsModeCombo;
253 SalomeApp_IntSpinBox* myNumberOfThreadsSpin;
254 QCheckBox* mySmoothOffSliversCheck;
255 QCheckBox* myCreateNewNodesCheck;
256 QComboBox* myPthreadMode;
257 QComboBox* myParallelMode;
258 QButtonGroup* myRadioBottomGroup;
261 GHS3DPluginGUI_AdvWidget* myAdvWidget;
262 mutable GHS3DPlugin::string_array_var myOptions, myCustomOptions;
266 QPixmap iconVertex, iconCompound;
267 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
268 GEOM::GEOM_Object_var myEnfVertex;
269 QTableWidget* myEnforcedTableWidget;
270 SMESHGUI_SpinBox* myXCoord;
271 SMESHGUI_SpinBox* myYCoord;
272 SMESHGUI_SpinBox* myZCoord;
273 SMESHGUI_SpinBox* mySizeValue;
274 QLineEdit* myGroupName;
275 QPushButton* addVertexButton;
276 QPushButton* removeVertexButton;
278 QWidget* myEnfMeshGroup;
279 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
280 QComboBox* myEnfMeshConstraint;
281 QStringList myEnfMeshConstraintLabels;
282 QTableWidget* myEnforcedMeshTableWidget;
283 QLineEdit* myMeshGroupName;
284 QPushButton* addEnfMeshButton;
285 QPushButton* removeEnfMeshButton;
287 GeomSelectionTools* GeomToolSelected;
290 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
295 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
297 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
298 const QModelIndex &index) const;
300 void setEditorData(QWidget *editor, const QModelIndex &index) const;
301 void setModelData(QWidget *editor, QAbstractItemModel *model,
302 const QModelIndex &index) const;
304 void updateEditorGeometry(QWidget *editor,
305 const QStyleOptionViewItem &option, const QModelIndex &index) const;
307 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
310 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
315 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
317 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
318 const QModelIndex &index) const;
320 void setEditorData(QWidget *editor, const QModelIndex &index) const;
321 void setModelData(QWidget *editor, QAbstractItemModel *model,
322 const QModelIndex &index) const;
324 void updateEditorGeometry(QWidget *editor,
325 const QStyleOptionViewItem &option, const QModelIndex &index) const;