1 // Copyright (C) 2007-2019 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 HYBRIDPluginGUI_AdvWidget;
61 class LightApp_SelectionMgr;
62 class SMESHGUI_SpinBox;
63 class SUIT_SelectionFilter;
64 class StdMeshersGUI_ObjectReferenceParamWdg;
65 class StdMeshersGUI_SubShapeSelectorWdg;
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 myLayersOnAllWrap, myToMeshHoles, myToMakeGroupsOfDomains,
146 myKeepFiles, myToCreateNewNodes,
147 myBoundaryRecovery, myFEMCorrection,
148 myRemoveInitialCentralPoint,
149 myLogInStandardOutput, myRemoveLogOnSuccess;
150 double myMaximumMemory,myInitialMemory;
151 int myOptimizationLevel;
153 int myBoundaryLayersGrowth;
154 int myElementGeneration;
155 QString myName,myWorkingDir,myTextOption;
157 short myVerboseLevel;
158 TEnfVertexList myEnforcedVertices;
159 TEnfMeshList myEnforcedMeshes;
160 bool myAddMultinormals,
162 double myHeightFirstLayer,
163 myBoundaryLayersProgression,
166 short myNbOfBoundaryLayers;
167 // IDs of faces with layers
168 SMESH::long_array_var myFaceWLIds;
169 // IDs of faces with imprinting
170 SMESH::long_array_var myFaceWIIds;
171 // IDs of faces with snapping
172 SMESH::long_array_var myFaceWSIds;
174 } HYBRIDHypothesisData;
177 \brief Class for creation of HYBRID 3D hypotheses
179 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
184 HYBRIDPluginGUI_HypothesisCreator( const QString& );
185 virtual ~HYBRIDPluginGUI_HypothesisCreator();
187 virtual bool checkParams(QString& msg) const;
188 virtual QString helpPage() const;
191 virtual QFrame* buildFrame ();
192 virtual void retrieveParams() const;
193 virtual QString storeParams () const;
195 virtual QString caption() const;
196 virtual QPixmap icon() const;
197 virtual QString type() const;
200 void onLayersOnAllWrap(bool);
201 void onToMeshHoles(bool);
202 void onDirBtnClicked();
203 void updateWidgets();
205 void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
206 std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
207 bool isCompound = false);
208 void onAddEnforcedVertex();
209 void onRemoveEnforcedVertex();
210 void synchronizeCoords();
211 void updateEnforcedVertexValues(QTableWidgetItem* );
212 void onSelectEnforcedVertex();
213 void clearEnforcedVertexWidgets();
214 void checkVertexIsDefined();
215 void clearEnfVertexSelection();
217 void addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
218 void onAddEnforcedMesh();
219 void onRemoveEnforcedMesh();
220 //void synchronizeEnforcedMesh();
221 void checkEnfMeshIsDefined();
222 void onTabChanged( int );
225 void vertexDefined(bool);
226 void enfMeshDefined(bool);
229 bool readParamsFromHypo( HYBRIDHypothesisData& ) const;
230 bool readParamsFromWidgets( HYBRIDHypothesisData& ) const;
231 bool storeParamsToHypo( const HYBRIDHypothesisData& ) const;
232 GeomSelectionTools* getGeomSelectionTool();
233 GEOM::GEOM_Gen_var getGeomEngine();
238 QCheckBox* myLayersOnAllWrapCheck;
239 QCheckBox* myToMeshHolesCheck;
240 QCheckBox* myToMakeGroupsOfDomains;
241 QComboBox* myOptimizationLevelCombo;
242 QComboBox* myCollisionModeCombo;
243 QComboBox* myBoundaryLayersGrowthCombo;
244 QComboBox* myElementGenerationCombo;
245 QCheckBox* myAddMultinormalsCheck;
246 QCheckBox* mySmoothNormals;
248 HYBRIDPluginGUI_AdvWidget* myAdvWidget;
251 QPixmap iconVertex, iconCompound;
252 StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
253 GEOM::GEOM_Object_var myEnfVertex;
254 QTableWidget* myEnforcedTableWidget;
255 SMESHGUI_SpinBox* myXCoord;
256 SMESHGUI_SpinBox* myYCoord;
257 SMESHGUI_SpinBox* myZCoord;
258 SMESHGUI_SpinBox* mySizeValue;
259 QLineEdit* myGroupName;
260 // QGroupBox* makeGroupsCheck;
261 // QCheckBox* myGlobalGroupName;
262 QPushButton* addVertexButton;
263 QPushButton* removeVertexButton;
265 QWidget* myEnfMeshGroup;
266 StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
267 // SMESH::SMESH_IDSource_var myEnfMesh;
268 QComboBox* myEnfMeshConstraint;
269 QStringList myEnfMeshConstraintLabels;
270 // SMESH::mesh_array_var myEnfMeshArray;
271 QTableWidget* myEnforcedMeshTableWidget;
272 QLineEdit* myMeshGroupName;
273 QPushButton* addEnfMeshButton;
274 QPushButton* removeEnfMeshButton;
276 GeomSelectionTools* GeomToolSelected;
278 SMESHGUI_SpinBox* myHeightFirstLayerSpin;
279 QSpinBox* myNbOfBoundaryLayersSpin;
280 SMESHGUI_SpinBox* myBoundaryLayersProgressionSpin;
281 SMESHGUI_SpinBox* myCoreSizeSpin;
282 SMESHGUI_SpinBox* myMultinormalsAngleSpin;
283 QCheckBox* mySmoothNormalsCheck;
286 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorLayers;
287 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorImprinting;
288 StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorSnapping;
291 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
296 EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
298 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
299 const QModelIndex &index) const;
301 void setEditorData(QWidget *editor, const QModelIndex &index) const;
302 void setModelData(QWidget *editor, QAbstractItemModel *model,
303 const QModelIndex &index) const;
305 void updateEditorGeometry(QWidget *editor,
306 const QStyleOptionViewItem &option, const QModelIndex &index) const;
308 bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
311 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
316 EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
318 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
319 const QModelIndex &index) const;
321 void setEditorData(QWidget *editor, const QModelIndex &index) const;
322 void setModelData(QWidget *editor, QAbstractItemModel *model,
323 const QModelIndex &index) const;
325 void updateEditorGeometry(QWidget *editor,
326 const QStyleOptionViewItem &option, const QModelIndex &index) const;