1 // Copyright (C) 2004-2013 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.
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 // HYBRIDPlugin GUI: GUI for plugged-in mesher HYBRIDPlugin
21 // File : HYBRIDPluginGUI_HypothesisCreator.h
22 // Author : Michael Zorin
23 // Module : HYBRIDPlugin
25 #ifndef HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
26 #define HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
29 #if defined HYBRIDPluginGUI_EXPORTS
30 #define HYBRIDPLUGINGUI_EXPORT __declspec( dllexport )
32 #define HYBRIDPLUGINGUI_EXPORT __declspec( dllimport )
35 #define HYBRIDPLUGINGUI_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(HYBRIDPlugin_Algorithm)
48 #include CORBA_SERVER_HEADER(SMESH_Gen)
49 #include CORBA_SERVER_HEADER(SMESH_Mesh)
57 class QTableWidgetItem;
60 class SMESHGUI_SpinBox;
61 class StdMeshersGUI_ObjectReferenceParamWdg;
62 class LightApp_SelectionMgr;
63 class SUIT_SelectionFilter;
64 class HYBRIDPluginGUI_AdvWidget;
70 QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
73 bool operator == (const QTEnfVertex* other) const {
75 if (this->coords.size() && other->coords.size())
76 return (this->coords == other->coords);
78 return (this->geomEntry == other->geomEntry);
87 std::vector<double> coords;
90 typedef QList< QTEnfVertex* > QEnfVertexList;
95 std::string geomEntry;
97 std::vector<double> coords;
98 std::string groupName;
102 struct CompareEnfVertices
104 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
106 if (e1->coords.size() && e2->coords.size())
107 return (e1->coords < e2->coords);
109 return (e1->geomEntry < e2->geomEntry);
115 // List of enforced vertices
116 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
123 std::string groupName;
126 struct CompareEnfMeshes
128 bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
130 if (e1->entry == e2->entry)
131 return (e1->elementType < e2->elementType);
133 return (e1->entry < e2->entry);
139 // List of enforced meshes
140 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
144 bool myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint,
145 myLogInStandardOutput, myRemoveLogOnSuccess;
146 double myMaximumMemory,myInitialMemory;
147 int myOptimizationLevel;
148 QString myName,myWorkingDir,myTextOption;
150 short myVerboseLevel;
151 TEnfVertexList myEnforcedVertices;
152 TEnfMeshList myEnforcedMeshes;
153 bool myBoundaryLayersInward,
154 myElemGenTetraDominant,
157 double myHeightFirstLayer,
158 myBoundaryLayersProgression,
160 short myNbOfBoundaryLayers;
161 } HYBRIDHypothesisData;
164 \brief Class for creation of HYBRID2D and HYBRID3D hypotheses
166 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
171 HYBRIDPluginGUI_HypothesisCreator( const QString& );
172 virtual ~HYBRIDPluginGUI_HypothesisCreator();
174 virtual bool checkParams(QString& msg) const;
175 virtual QString helpPage() const;
178 virtual QFrame* buildFrame ();
179 virtual void retrieveParams() const;
180 virtual QString storeParams () const;
182 virtual QString caption() const;
183 virtual QPixmap icon() const;
184 virtual QString type() const;
187 void onToMeshHoles(bool);
188 void onDirBtnClicked();
189 void updateWidgets();
191 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
192 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
193 bool isCompound = false);
194 void onAddEnforcedVertex();
195 void onRemoveEnforcedVertex();
196 void synchronizeCoords();
197 void updateEnforcedVertexValues(QTableWidgetItem* );
198 void onSelectEnforcedVertex();
199 void clearEnforcedVertexWidgets();
200 void checkVertexIsDefined();
201 void clearEnfVertexSelection();
203 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
204 void onAddEnforcedMesh();
205 void onRemoveEnforcedMesh();
206 //void synchronizeEnforcedMesh();
207 void checkEnfMeshIsDefined();
210 void vertexDefined(bool);
211 void enfMeshDefined(bool);
214 bool readParamsFromHypo( HYBRIDHypothesisData& ) const;
215 bool readParamsFromWidgets( HYBRIDHypothesisData& ) const;
216 bool storeParamsToHypo( const HYBRIDHypothesisData& ) const;
217 GeomSelectionTools* getGeomSelectionTool();
218 GEOM::GEOM_Gen_var getGeomEngine();
223 QCheckBox* myToMeshHolesCheck;
224 QCheckBox* myToMakeGroupsOfDomains;
225 QComboBox* myOptimizationLevelCombo;
226 QCheckBox* myBoundaryLayersInwardCheck;
227 QCheckBox* myElemGenTetraDominantCheck;
228 QCheckBox* myAddMultinormalsCheck;
229 QCheckBox* mySmoothNormals;
231 HYBRIDPluginGUI_AdvWidget* myAdvWidget;
234 QPixmap iconVertex, iconCompound;
235 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
236 GEOM::GEOM_Object_var myEnfVertex;
237 QTableWidget* myEnforcedTableWidget;
238 SMESHGUI_SpinBox* myXCoord;
239 SMESHGUI_SpinBox* myYCoord;
240 SMESHGUI_SpinBox* myZCoord;
241 SMESHGUI_SpinBox* mySizeValue;
242 QLineEdit* myGroupName;
243 // QGroupBox* makeGroupsCheck;
244 // QCheckBox* myGlobalGroupName;
245 QPushButton* addVertexButton;
246 QPushButton* removeVertexButton;
248 QWidget* myEnfMeshGroup;
249 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
250 // SMESH::SMESH_IDSource_var myEnfMesh;
251 QComboBox* myEnfMeshConstraint;
252 QStringList myEnfMeshConstraintLabels;
253 // SMESH::mesh_array_var myEnfMeshArray;
254 QTableWidget* myEnforcedMeshTableWidget;
255 QLineEdit* myMeshGroupName;
256 QPushButton* addEnfMeshButton;
257 QPushButton* removeEnfMeshButton;
259 GeomSelectionTools* GeomToolSelected;
261 SMESHGUI_SpinBox* myHeightFirstLayerSpin;
262 QSpinBox* myNbOfBoundaryLayersSpin;
263 SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin;
264 SMESHGUI_SpinBox* myMultinormalsAngleSpin;
265 QCheckBox* mySmoothNormalsCheck;
269 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
274 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
276 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
277 const QModelIndex &index) const;
279 void setEditorData(QWidget *editor, const QModelIndex &index) const;
280 void setModelData(QWidget *editor, QAbstractItemModel *model,
281 const QModelIndex &index) const;
283 void updateEditorGeometry(QWidget *editor,
284 const QStyleOptionViewItem &option, const QModelIndex &index) const;
286 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
289 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
294 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
296 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
297 const QModelIndex &index) const;
299 void setEditorData(QWidget *editor, const QModelIndex &index) const;
300 void setModelData(QWidget *editor, QAbstractItemModel *model,
301 const QModelIndex &index) const;
303 void updateEditorGeometry(QWidget *editor,
304 const QStyleOptionViewItem &option, const QModelIndex &index) const;