1 // Copyright (C) 2004-2016 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;
60 class GHS3DPluginGUI_AdvWidget;
61 class LightApp_SelectionMgr;
62 class SMESHGUI_SpinBox;
63 class SUIT_SelectionFilter;
64 class SalomeApp_IntSpinBox;
65 class StdMeshersGUI_ObjectReferenceParamWdg;
71 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
74 bool operator == (const QTEnfVertex* other) const {
76 if (this->coords.size() && other->coords.size())
77 return (this->coords == other->coords);
79 return (this->geomEntry == other->geomEntry);
88 std::vector<double> coords;
91 typedef QList< QTEnfVertex* > QEnfVertexList;
96 std::string geomEntry;
98 std::vector<double> coords;
99 std::string groupName;
103 struct CompareEnfVertices
105 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
107 if (e1->coords.size() && e2->coords.size())
108 return (e1->coords < e2->coords);
110 return (e1->geomEntry < e2->geomEntry);
116 // List of enforced vertices
117 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
124 std::string groupName;
127 struct CompareEnfMeshes
129 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
131 if (e1->entry == e2->entry)
132 return (e1->elementType < e2->elementType);
134 return (e1->entry < e2->entry);
140 // List of enforced meshes
141 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
145 bool myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
146 myLogInStandardOutput, myRemoveLogOnSuccess;
147 float myMaximumMemory;
148 float myInitialMemory;
149 int myOptimizationLevel;
150 QString myName,myWorkingDir,myTextOption;
152 short myVerboseLevel;
153 TEnfVertexList myEnforcedVertices;
154 TEnfMeshList myEnforcedMeshes;
156 int myOptimization, mySplitOverConstrained, myPThreadsMode, myNumberOfThreads;
157 bool mySmoothOffSlivers;
159 } GHS3DHypothesisData;
162 \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
164 class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
169 GHS3DPluginGUI_HypothesisCreator( const QString& );
170 virtual ~GHS3DPluginGUI_HypothesisCreator();
172 virtual bool checkParams(QString& msg) const;
173 virtual QString helpPage() const;
176 virtual QFrame* buildFrame ();
177 virtual void retrieveParams() const;
178 virtual QString storeParams () const;
180 virtual QString caption() const;
181 virtual QPixmap icon() const;
182 virtual QString type() const;
185 void onToMeshHoles(bool);
186 void onDirBtnClicked();
187 void updateWidgets();
189 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
190 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
191 bool isCompound = false);
192 void onAddEnforcedVertex();
193 void onRemoveEnforcedVertex();
194 void synchronizeCoords();
195 void updateEnforcedVertexValues(QTableWidgetItem* );
196 void onSelectEnforcedVertex();
197 void clearEnforcedVertexWidgets();
198 void checkVertexIsDefined();
199 void clearEnfVertexSelection();
201 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
202 void onAddEnforcedMesh();
203 void onRemoveEnforcedMesh();
204 //void synchronizeEnforcedMesh();
205 void checkEnfMeshIsDefined();
208 void vertexDefined(bool);
209 void enfMeshDefined(bool);
212 bool readParamsFromHypo( GHS3DHypothesisData& ) const;
213 bool readParamsFromWidgets( GHS3DHypothesisData& ) const;
214 bool storeParamsToHypo( const GHS3DHypothesisData& ) const;
215 GeomSelectionTools* getGeomSelectionTool();
216 GEOM::GEOM_Gen_var getGeomEngine();
217 bool isOptimization() const;
222 QCheckBox* myToMeshHolesCheck;
223 QCheckBox* myToMakeGroupsOfDomains;
224 QComboBox* myOptimizationLevelCombo;
226 QComboBox* myOptimizationCombo;
227 QComboBox* mySplitOverConstrainedCombo;
228 QComboBox* myPThreadsModeCombo;
229 SalomeApp_IntSpinBox* myNumberOfThreadsSpin;
230 QCheckBox* mySmoothOffSliversCheck;
231 QCheckBox* myCreateNewNodesCheck;
234 GHS3DPluginGUI_AdvWidget* myAdvWidget;
237 QPixmap iconVertex, iconCompound;
238 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
239 GEOM::GEOM_Object_var myEnfVertex;
240 QTableWidget* myEnforcedTableWidget;
241 SMESHGUI_SpinBox* myXCoord;
242 SMESHGUI_SpinBox* myYCoord;
243 SMESHGUI_SpinBox* myZCoord;
244 SMESHGUI_SpinBox* mySizeValue;
245 QLineEdit* myGroupName;
246 QPushButton* addVertexButton;
247 QPushButton* removeVertexButton;
249 QWidget* myEnfMeshGroup;
250 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
251 QComboBox* myEnfMeshConstraint;
252 QStringList myEnfMeshConstraintLabels;
253 QTableWidget* myEnforcedMeshTableWidget;
254 QLineEdit* myMeshGroupName;
255 QPushButton* addEnfMeshButton;
256 QPushButton* removeEnfMeshButton;
258 GeomSelectionTools* GeomToolSelected;
261 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
266 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
268 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
269 const QModelIndex &index) const;
271 void setEditorData(QWidget *editor, const QModelIndex &index) const;
272 void setModelData(QWidget *editor, QAbstractItemModel *model,
273 const QModelIndex &index) const;
275 void updateEditorGeometry(QWidget *editor,
276 const QStyleOptionViewItem &option, const QModelIndex &index) const;
278 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
281 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
286 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
288 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
289 const QModelIndex &index) const;
291 void setEditorData(QWidget *editor, const QModelIndex &index) const;
292 void setModelData(QWidget *editor, QAbstractItemModel *model,
293 const QModelIndex &index) const;
295 void updateEditorGeometry(QWidget *editor,
296 const QStyleOptionViewItem &option, const QModelIndex &index) const;