1 // Copyright (C) 2004-2020 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 // 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)
57 class QTableWidgetItem;
61 class GHS3DPluginGUI_AdvWidget;
62 class LightApp_SelectionMgr;
63 class SMESHGUI_SpinBox;
64 class SUIT_SelectionFilter;
65 class SalomeApp_IntSpinBox;
66 class StdMeshersGUI_ObjectReferenceParamWdg;
72 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
75 bool operator == (const QTEnfVertex* other) const {
77 if (this->coords.size() && other->coords.size())
78 return (this->coords == other->coords);
80 return (this->geomEntry == other->geomEntry);
89 std::vector<double> coords;
92 typedef QList< QTEnfVertex* > QEnfVertexList;
97 std::string geomEntry;
99 std::vector<double> coords;
100 std::string groupName;
104 struct CompareEnfVertices
106 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
108 if (e1->coords.size() && e2->coords.size())
109 return (e1->coords < e2->coords);
111 return (e1->geomEntry < e2->geomEntry);
117 // List of enforced vertices
118 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
125 std::string groupName;
128 struct CompareEnfMeshes
130 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
132 if (e1->entry == e2->entry)
133 return (e1->elementType < e2->elementType);
135 return (e1->entry < e2->entry);
141 // List of enforced meshes
142 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
146 int myOptimizationLevel;
147 double myMinSize, myMaxSize, myMinSizeDefault, myMaxSizeDefault;
149 int myNbProximityLayers;
150 bool myUseMinSize, myUseMaxSize, myUseGradation, myUseProximity;
151 bool myToMeshHoles, myToMakeGroupsOfDomains;
152 bool myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
153 myKeepFiles,myLogInStandardOutput, myRemoveLogOnSuccess;
154 float myInitialMemory, myMaximumMemory;
155 QString myName,myWorkingDir;
156 short myVerboseLevel;
157 TEnfVertexList myEnforcedVertices;
158 TEnfMeshList myEnforcedMeshes;
160 int myOptimization, mySplitOverConstrained, myPThreadsMode, myNumberOfThreads;
161 bool mySmoothOffSlivers;
163 } GHS3DHypothesisData;
166 \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
168 class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
173 GHS3DPluginGUI_HypothesisCreator( const QString& );
174 virtual ~GHS3DPluginGUI_HypothesisCreator();
176 virtual bool checkParams(QString& msg) const;
177 virtual QString helpPage() const;
180 virtual QFrame* buildFrame ();
181 virtual void retrieveParams() const;
182 virtual QString storeParams () const;
184 virtual QString caption() const;
185 virtual QPixmap icon() const;
186 virtual QString type() const;
190 void onToMeshHoles(bool);
191 void onDirBtnClicked();
192 void updateWidgets();
194 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
195 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
196 bool isCompound = false);
197 void onAddEnforcedVertex();
198 void onRemoveEnforcedVertex();
199 void synchronizeCoords();
200 void updateEnforcedVertexValues(QTableWidgetItem* );
201 void onSelectEnforcedVertex();
202 void clearEnforcedVertexWidgets();
203 void checkVertexIsDefined();
204 void clearEnfVertexSelection();
206 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
207 void onAddEnforcedMesh();
208 void onRemoveEnforcedMesh();
209 //void synchronizeEnforcedMesh();
210 void checkEnfMeshIsDefined();
213 void vertexDefined(bool);
214 void enfMeshDefined(bool);
217 bool readParamsFromHypo( GHS3DHypothesisData& ) const;
218 bool readParamsFromWidgets( GHS3DHypothesisData& ) const;
219 bool storeParamsToHypo( const GHS3DHypothesisData& ) const;
220 GeomSelectionTools* getGeomSelectionTool();
221 GEOM::GEOM_Gen_var getGeomEngine();
222 bool isOptimization() const;
228 QComboBox* myOptimizationLevelCombo;
229 QCheckBox* myMinSizeCheck;
230 QCheckBox* myMaxSizeCheck;
231 SMESHGUI_SpinBox* myMinSizeSpin;
232 SMESHGUI_SpinBox* myMaxSizeSpin;
233 mutable double myMinSizeDefault, myMaxSizeDefault;
235 QCheckBox* myGradationCheck;
236 SMESHGUI_SpinBox* myGradationSpin;
237 QGroupBox* myUseProximityGroup;
238 SalomeApp_IntSpinBox* myNbProximityLayers;
240 QCheckBox* myToMakeGroupsOfDomains;
241 QCheckBox* myToMeshHolesCheck;
243 QComboBox* myOptimizationCombo;
244 QComboBox* mySplitOverConstrainedCombo;
245 QComboBox* myPThreadsModeCombo;
246 SalomeApp_IntSpinBox* myNumberOfThreadsSpin;
247 QCheckBox* mySmoothOffSliversCheck;
248 QCheckBox* myCreateNewNodesCheck;
251 GHS3DPluginGUI_AdvWidget* myAdvWidget;
252 mutable GHS3DPlugin::string_array_var myOptions, myCustomOptions;
256 QPixmap iconVertex, iconCompound;
257 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
258 GEOM::GEOM_Object_var myEnfVertex;
259 QTableWidget* myEnforcedTableWidget;
260 SMESHGUI_SpinBox* myXCoord;
261 SMESHGUI_SpinBox* myYCoord;
262 SMESHGUI_SpinBox* myZCoord;
263 SMESHGUI_SpinBox* mySizeValue;
264 QLineEdit* myGroupName;
265 QPushButton* addVertexButton;
266 QPushButton* removeVertexButton;
268 QWidget* myEnfMeshGroup;
269 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
270 QComboBox* myEnfMeshConstraint;
271 QStringList myEnfMeshConstraintLabels;
272 QTableWidget* myEnforcedMeshTableWidget;
273 QLineEdit* myMeshGroupName;
274 QPushButton* addEnfMeshButton;
275 QPushButton* removeEnfMeshButton;
277 GeomSelectionTools* GeomToolSelected;
280 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
285 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
287 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
288 const QModelIndex &index) const;
290 void setEditorData(QWidget *editor, const QModelIndex &index) const;
291 void setModelData(QWidget *editor, QAbstractItemModel *model,
292 const QModelIndex &index) const;
294 void updateEditorGeometry(QWidget *editor,
295 const QStyleOptionViewItem &option, const QModelIndex &index) const;
297 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
300 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
305 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
307 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
308 const QModelIndex &index) const;
310 void setEditorData(QWidget *editor, const QModelIndex &index) const;
311 void setModelData(QWidget *editor, QAbstractItemModel *model,
312 const QModelIndex &index) const;
314 void updateEditorGeometry(QWidget *editor,
315 const QStyleOptionViewItem &option, const QModelIndex &index) const;