1 // Copyright (C) 2007-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
21 // File : HYBRIDPluginGUI_HypothesisCreator.h
22 // Author : Christian VAN WAMBEKE (CEA)
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 myLayersOnAllWrap, myToMeshHoles, myToMakeGroupsOfDomains,
145 myKeepFiles, myToCreateNewNodes,
146 myBoundaryRecovery, myFEMCorrection,
147 myRemoveInitialCentralPoint,
148 myLogInStandardOutput, myRemoveLogOnSuccess;
149 double myMaximumMemory,myInitialMemory;
150 int myOptimizationLevel;
152 int myBoundaryLayersGrowth;
153 int myElementGeneration;
154 QString myName,myWorkingDir,myTextOption;
156 short myVerboseLevel;
157 TEnfVertexList myEnforcedVertices;
158 TEnfMeshList myEnforcedMeshes;
159 bool myAddMultinormals,
161 double myHeightFirstLayer,
162 myBoundaryLayersProgression,
164 short myNbOfBoundaryLayers;
165 } HYBRIDHypothesisData;
168 \brief Class for creation of HYBRID 3D hypotheses
170 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
175 HYBRIDPluginGUI_HypothesisCreator( const QString& );
176 virtual ~HYBRIDPluginGUI_HypothesisCreator();
178 virtual bool checkParams(QString& msg) const;
179 virtual QString helpPage() const;
182 virtual QFrame* buildFrame ();
183 virtual void retrieveParams() const;
184 virtual QString storeParams () const;
186 virtual QString caption() const;
187 virtual QPixmap icon() const;
188 virtual QString type() const;
191 void onLayersOnAllWrap(bool);
192 void onToMeshHoles(bool);
193 void onDirBtnClicked();
194 void updateWidgets();
196 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
197 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
198 bool isCompound = false);
199 void onAddEnforcedVertex();
200 void onRemoveEnforcedVertex();
201 void synchronizeCoords();
202 void updateEnforcedVertexValues(QTableWidgetItem* );
203 void onSelectEnforcedVertex();
204 void clearEnforcedVertexWidgets();
205 void checkVertexIsDefined();
206 void clearEnfVertexSelection();
208 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
209 void onAddEnforcedMesh();
210 void onRemoveEnforcedMesh();
211 //void synchronizeEnforcedMesh();
212 void checkEnfMeshIsDefined();
215 void vertexDefined(bool);
216 void enfMeshDefined(bool);
219 bool readParamsFromHypo( HYBRIDHypothesisData& ) const;
220 bool readParamsFromWidgets( HYBRIDHypothesisData& ) const;
221 bool storeParamsToHypo( const HYBRIDHypothesisData& ) const;
222 GeomSelectionTools* getGeomSelectionTool();
223 GEOM::GEOM_Gen_var getGeomEngine();
228 QCheckBox* myLayersOnAllWrapCheck;
229 QCheckBox* myToMeshHolesCheck;
230 QCheckBox* myToMakeGroupsOfDomains;
231 QComboBox* myOptimizationLevelCombo;
232 QComboBox* myCollisionModeCombo;
233 QComboBox* myBoundaryLayersGrowthCombo;
234 QComboBox* myElementGenerationCombo;
235 QCheckBox* myAddMultinormalsCheck;
236 QCheckBox* mySmoothNormals;
238 HYBRIDPluginGUI_AdvWidget* myAdvWidget;
241 QPixmap iconVertex, iconCompound;
242 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
243 GEOM::GEOM_Object_var myEnfVertex;
244 QTableWidget* myEnforcedTableWidget;
245 SMESHGUI_SpinBox* myXCoord;
246 SMESHGUI_SpinBox* myYCoord;
247 SMESHGUI_SpinBox* myZCoord;
248 SMESHGUI_SpinBox* mySizeValue;
249 QLineEdit* myGroupName;
250 // QGroupBox* makeGroupsCheck;
251 // QCheckBox* myGlobalGroupName;
252 QPushButton* addVertexButton;
253 QPushButton* removeVertexButton;
255 QWidget* myEnfMeshGroup;
256 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
257 // SMESH::SMESH_IDSource_var myEnfMesh;
258 QComboBox* myEnfMeshConstraint;
259 QStringList myEnfMeshConstraintLabels;
260 // SMESH::mesh_array_var myEnfMeshArray;
261 QTableWidget* myEnforcedMeshTableWidget;
262 QLineEdit* myMeshGroupName;
263 QPushButton* addEnfMeshButton;
264 QPushButton* removeEnfMeshButton;
266 GeomSelectionTools* GeomToolSelected;
268 SMESHGUI_SpinBox* myHeightFirstLayerSpin;
269 QSpinBox* myNbOfBoundaryLayersSpin;
270 SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin;
271 SMESHGUI_SpinBox* myMultinormalsAngleSpin;
272 QCheckBox* mySmoothNormalsCheck;
276 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
281 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
283 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
284 const QModelIndex &index) const;
286 void setEditorData(QWidget *editor, const QModelIndex &index) const;
287 void setModelData(QWidget *editor, QAbstractItemModel *model,
288 const QModelIndex &index) const;
290 void updateEditorGeometry(QWidget *editor,
291 const QStyleOptionViewItem &option, const QModelIndex &index) const;
293 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
296 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
301 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
303 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
304 const QModelIndex &index) const;
306 void setEditorData(QWidget *editor, const QModelIndex &index) const;
307 void setModelData(QWidget *editor, QAbstractItemModel *model,
308 const QModelIndex &index) const;
310 void updateEditorGeometry(QWidget *editor,
311 const QStyleOptionViewItem &option, const QModelIndex &index) const;