Salome HOME
#17784 [EDF] MESH-GEMS-2.9.6 Meshers options
[plugins/hybridplugin.git] / src / GUI / HYBRIDPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : HYBRIDPluginGUI_HypothesisCreator.h
22 // Author : Christian VAN WAMBEKE (CEA)
23 // ---
24 //
25 #ifndef HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
26 #define HYBRIDPLUGINGUI_HypothesisCreator_HeaderFile
27
28 #ifdef WIN32
29   #if defined HYBRIDPluginGUI_EXPORTS
30     #define HYBRIDPLUGINGUI_EXPORT __declspec( dllexport )
31   #else
32     #define HYBRIDPLUGINGUI_EXPORT __declspec( dllimport )
33   #endif
34 #else
35   #define HYBRIDPLUGINGUI_EXPORT
36 #endif
37
38 #include <SMESHGUI_Hypotheses.h>
39 #include <GeomSelectionTools.h>
40 #include <TopAbs_ShapeEnum.hxx>
41
42 #include <QItemDelegate>
43 #include <map>
44 #include <vector>
45 #include <set>
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)
50
51 class QCheckBox;
52 class QComboBox;
53 class QHeaderView;
54 class QLineEdit;
55 class QSpinBox;
56 class QTableWidget;
57 class QTableWidgetItem;
58 class QWidget;
59
60 class HYBRIDPluginGUI_StdWidget;
61 class HYBRIDPluginGUI_AdvWidget;
62 class LightApp_SelectionMgr;
63 class SMESHGUI_SpinBox;
64 class SUIT_SelectionFilter;
65 class StdMeshersGUI_ObjectReferenceParamWdg;
66 class StdMeshersGUI_SubShapeSelectorWdg;
67
68 class QTEnfVertex
69 {
70
71 public:
72   QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
73
74 private:
75   bool operator == (const QTEnfVertex* other) const {
76     if (other) {
77       if (this->coords.size() && other->coords.size())
78         return (this->coords == other->coords);
79       else
80         return (this->geomEntry == other->geomEntry);
81     }
82   }
83   
84   QString name;
85   QString geomEntry;
86   bool isCompound;
87   QString groupName;
88   double size;
89   std::vector<double> coords;
90 };
91
92 typedef QList< QTEnfVertex* > QEnfVertexList;
93
94 // Enforced vertex
95 struct TEnfVertex{
96   std::string name;
97   std::string geomEntry;
98   bool isCompound;
99   std::vector<double> coords;
100   std::string groupName;
101   double size;
102 };
103
104 struct CompareEnfVertices
105 {
106   bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
107     if (e1 && e2) {
108       if (e1->coords.size() && e2->coords.size())
109         return (e1->coords < e2->coords);
110       else
111         return (e1->geomEntry < e2->geomEntry);
112     }
113     return false;
114   }
115 };
116
117 // List of enforced vertices
118 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
119
120 // Enforced mesh
121 struct TEnfMesh{
122   std::string name;
123   std::string entry;
124   int elementType;
125   std::string groupName;
126 };
127
128 struct CompareEnfMeshes
129 {
130   bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
131     if (e1 && e2) {
132       if (e1->entry == e2->entry)
133         return (e1->elementType < e2->elementType);
134       else
135         return (e1->entry < e2->entry);
136     }
137     else
138       return false;
139   }
140 };
141 // List of enforced meshes
142 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
143
144 typedef struct
145 {
146   bool    myHeightIsRelative, myImprinting, mySnapping, myLayersOnAllWrap,
147           myKeepFiles, myLogInStandardOutput, myRemoveLogOnSuccess;
148   int     myOptimizationLevel, myCollisionMode, myBoundaryLayersGrowth, myElementGeneration;
149   QString myName,myWorkingDir;
150   double  myGradation;
151   short   myVerboseLevel;
152   TEnfVertexList myEnforcedVertices;
153   TEnfMeshList myEnforcedMeshes;
154   double  myHeightFirstLayer,
155           myBoundaryLayersProgression,
156           myCoreSize,
157           myBoundaryLayersMaxElemAngle;
158   short   myNbOfBoundaryLayers;
159   // IDs of faces with layers
160   SMESH::long_array_var myFaceWLIds;
161   // IDs of faces with imprinting
162   SMESH::long_array_var myFaceWIIds;
163   // IDs of faces with snapping
164   SMESH::long_array_var myFaceWSIds;
165
166 } HYBRIDHypothesisData;
167
168 /*!
169   \brief Class for creation of HYBRID 3D hypotheses
170 */
171 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
172 {
173   Q_OBJECT
174
175 public:
176   HYBRIDPluginGUI_HypothesisCreator( const QString& );
177   virtual ~HYBRIDPluginGUI_HypothesisCreator();
178
179   virtual bool     checkParams(QString& msg) const;
180   virtual QString  helpPage() const;
181
182 protected:
183   virtual QFrame*  buildFrame    ();
184   virtual void     retrieveParams() const;
185   virtual QString  storeParams   () const;
186
187   virtual QString  caption() const;
188   virtual QPixmap  icon() const;
189   virtual QString  type() const;
190
191 protected slots:
192   void                onAddOption();
193   void                onDirBtnClicked();
194   void                updateWidgets();
195   
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();
207   
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();
213   void                onTabChanged( int );
214   
215 signals:
216   void                vertexDefined(bool);
217   void                enfMeshDefined(bool);
218   
219 private:
220   bool                readParamsFromHypo( HYBRIDHypothesisData& ) const;
221   bool                readParamsFromWidgets( HYBRIDHypothesisData& ) const;
222   bool                storeParamsToHypo( const HYBRIDHypothesisData& ) const;
223   GeomSelectionTools* getGeomSelectionTool();
224   GEOM::GEOM_Gen_var  getGeomEngine();
225
226 private:
227   QWidget*            myStdGroup;
228   QLineEdit*          myName;
229   HYBRIDPluginGUI_StdWidget* myStdWidget;
230   HYBRIDPluginGUI_AdvWidget* myAdvWidget;
231
232   mutable HYBRIDPlugin::string_array_var myOptions, myCustomOptions;
233
234   QWidget*            myEnfGroup;
235   QPixmap             iconVertex, iconCompound;
236   StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
237   GEOM::GEOM_Object_var myEnfVertex;
238   QTableWidget*       myEnforcedTableWidget;
239   SMESHGUI_SpinBox*   myXCoord;
240   SMESHGUI_SpinBox*   myYCoord;
241   SMESHGUI_SpinBox*   myZCoord;
242   SMESHGUI_SpinBox*   mySizeValue;
243   QLineEdit*          myGroupName;
244 //   QGroupBox*          makeGroupsCheck;
245 //   QCheckBox*          myGlobalGroupName;  
246   QPushButton*        addVertexButton;
247   QPushButton*        removeVertexButton;
248   
249   QWidget*            myEnfMeshGroup;
250   StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
251 //   SMESH::SMESH_IDSource_var myEnfMesh;
252   QComboBox*          myEnfMeshConstraint;
253   QStringList         myEnfMeshConstraintLabels;
254 //   SMESH::mesh_array_var myEnfMeshArray;
255   QTableWidget*       myEnforcedMeshTableWidget;
256   QLineEdit*          myMeshGroupName;
257   QPushButton*        addEnfMeshButton;
258   QPushButton*        removeEnfMeshButton;
259   
260   GeomSelectionTools* GeomToolSelected;
261   
262   SMESHGUI_SpinBox*   myHeightFirstLayerSpin;
263   QSpinBox*           myNbOfBoundaryLayersSpin;
264   SMESHGUI_SpinBox*   myBoundaryLayersProgressionSpin;
265   SMESHGUI_SpinBox*   myCoreSizeSpin;
266   SMESHGUI_SpinBox*   myMultinormalsAngleSpin;
267   QCheckBox*          mySmoothNormalsCheck;
268
269   QLabel* myFacesLbl;
270   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorLayers;
271   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorImprinting;
272   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorSnapping;
273 };
274
275 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
276 {
277     Q_OBJECT
278
279 public:
280   EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
281
282   QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
283                       const QModelIndex &index) const;
284
285   void setEditorData(QWidget *editor, const QModelIndex &index) const;
286   void setModelData(QWidget *editor, QAbstractItemModel *model,
287                   const QModelIndex &index) const;
288
289   void updateEditorGeometry(QWidget *editor,
290       const QStyleOptionViewItem &option, const QModelIndex &index) const;
291
292   bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
293 };
294
295 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
296 {
297     Q_OBJECT
298
299 public:
300   EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
301
302   QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
303                       const QModelIndex &index) const;
304
305   void setEditorData(QWidget *editor, const QModelIndex &index) const;
306   void setModelData(QWidget *editor, QAbstractItemModel *model,
307                   const QModelIndex &index) const;
308
309   void updateEditorGeometry(QWidget *editor,
310       const QStyleOptionViewItem &option, const QModelIndex &index) const;
311 };
312
313 #endif