Salome HOME
Adding element generation with cartesian core and global physical size
[plugins/hybridplugin.git] / src / GUI / HYBRIDPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2016  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_AdvWidget;
61 class LightApp_SelectionMgr;
62 class SMESHGUI_SpinBox;
63 class SUIT_SelectionFilter;
64 class StdMeshersGUI_ObjectReferenceParamWdg;
65 class StdMeshersGUI_SubShapeSelectorWdg;
66
67 class QTEnfVertex
68 {
69
70 public:
71   QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false);
72
73 private:
74   bool operator == (const QTEnfVertex* other) const {
75     if (other) {
76       if (this->coords.size() && other->coords.size())
77         return (this->coords == other->coords);
78       else
79         return (this->geomEntry == other->geomEntry);
80     }
81   }
82   
83   QString name;
84   QString geomEntry;
85   bool isCompound;
86   QString groupName;
87   double size;
88   std::vector<double> coords;
89 };
90
91 typedef QList< QTEnfVertex* > QEnfVertexList;
92
93 // Enforced vertex
94 struct TEnfVertex{
95   std::string name;
96   std::string geomEntry;
97   bool isCompound;
98   std::vector<double> coords;
99   std::string groupName;
100   double size;
101 };
102
103 struct CompareEnfVertices
104 {
105   bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
106     if (e1 && e2) {
107       if (e1->coords.size() && e2->coords.size())
108         return (e1->coords < e2->coords);
109       else
110         return (e1->geomEntry < e2->geomEntry);
111     }
112     return false;
113   }
114 };
115
116 // List of enforced vertices
117 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
118
119 // Enforced mesh
120 struct TEnfMesh{
121   std::string name;
122   std::string entry;
123   int elementType;
124   std::string groupName;
125 };
126
127 struct CompareEnfMeshes
128 {
129   bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const {
130     if (e1 && e2) {
131       if (e1->entry == e2->entry)
132         return (e1->elementType < e2->elementType);
133       else
134         return (e1->entry < e2->entry);
135     }
136     else
137       return false;
138   }
139 };
140 // List of enforced meshes
141 typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList;
142
143 typedef struct
144 {
145   bool    myLayersOnAllWrap, myToMeshHoles, myToMakeGroupsOfDomains,
146           myKeepFiles, myToCreateNewNodes,
147           myBoundaryRecovery, myFEMCorrection,
148           myRemoveInitialCentralPoint,
149           myLogInStandardOutput, myRemoveLogOnSuccess;
150   double  myMaximumMemory,myInitialMemory;
151   int     myOptimizationLevel;
152   int     myCollisionMode;
153   int     myBoundaryLayersGrowth;
154   int     myElementGeneration;
155   QString myName,myWorkingDir,myTextOption;
156   double  myGradation;
157   short   myVerboseLevel;
158   TEnfVertexList myEnforcedVertices;
159   TEnfMeshList myEnforcedMeshes;
160   bool    myAddMultinormals,
161           mySmoothNormals;
162   double  myHeightFirstLayer,
163           myBoundaryLayersProgression,
164           myCoreSize,
165           myMultinormalsAngle;
166   short   myNbOfBoundaryLayers;
167   SMESH::long_array_var myFaceWLIds;
168
169 } HYBRIDHypothesisData;
170
171 /*!
172   \brief Class for creation of HYBRID 3D hypotheses
173 */
174 class HYBRIDPLUGINGUI_EXPORT HYBRIDPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
175 {
176   Q_OBJECT
177
178 public:
179   HYBRIDPluginGUI_HypothesisCreator( const QString& );
180   virtual ~HYBRIDPluginGUI_HypothesisCreator();
181
182   virtual bool     checkParams(QString& msg) const;
183   virtual QString  helpPage() const;
184
185 protected:
186   virtual QFrame*  buildFrame    ();
187   virtual void     retrieveParams() const;
188   virtual QString  storeParams   () const;
189
190   virtual QString  caption() const;
191   virtual QPixmap  icon() const;
192   virtual QString  type() const;
193
194 protected slots:
195   void                onLayersOnAllWrap(bool);
196   void                onToMeshHoles(bool);
197   void                onDirBtnClicked();
198   void                updateWidgets();
199   
200   void                addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0,
201                                         std::string vertexName = "", std::string geomEntry = "", std::string groupName = "",
202                                         bool isCompound = false);
203   void                onAddEnforcedVertex();
204   void                onRemoveEnforcedVertex();
205   void                synchronizeCoords();
206   void                updateEnforcedVertexValues(QTableWidgetItem* );
207   void                onSelectEnforcedVertex();
208   void                clearEnforcedVertexWidgets();
209   void                checkVertexIsDefined();
210   void                clearEnfVertexSelection();
211   
212   void                addEnforcedMesh(std::string name, std::string entry, int elementType, std::string groupName = "");
213   void                onAddEnforcedMesh();
214   void                onRemoveEnforcedMesh();
215   //void                synchronizeEnforcedMesh();
216   void                checkEnfMeshIsDefined();
217   void                onTabChanged( int );
218   
219 signals:
220   void                vertexDefined(bool);
221   void                enfMeshDefined(bool);
222   
223 private:
224   bool                readParamsFromHypo( HYBRIDHypothesisData& ) const;
225   bool                readParamsFromWidgets( HYBRIDHypothesisData& ) const;
226   bool                storeParamsToHypo( const HYBRIDHypothesisData& ) const;
227   GeomSelectionTools* getGeomSelectionTool();
228   GEOM::GEOM_Gen_var  getGeomEngine();
229
230 private:
231   QWidget*            myStdGroup;
232   QLineEdit*          myName;
233   QCheckBox*          myLayersOnAllWrapCheck;
234   QCheckBox*          myToMeshHolesCheck;
235   QCheckBox*          myToMakeGroupsOfDomains;
236   QComboBox*          myOptimizationLevelCombo;
237   QComboBox*          myCollisionModeCombo;
238   QComboBox*          myBoundaryLayersGrowthCombo;
239   QComboBox*          myElementGenerationCombo;
240   QCheckBox*          myAddMultinormalsCheck;
241   QCheckBox*          mySmoothNormals;
242   QWidget*            myAdvGroup;
243   HYBRIDPluginGUI_AdvWidget* myAdvWidget;
244   
245   QWidget*            myEnfGroup;
246   QPixmap             iconVertex, iconCompound;
247   StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg;
248   GEOM::GEOM_Object_var myEnfVertex;
249   QTableWidget*       myEnforcedTableWidget;
250   SMESHGUI_SpinBox*   myXCoord;
251   SMESHGUI_SpinBox*   myYCoord;
252   SMESHGUI_SpinBox*   myZCoord;
253   SMESHGUI_SpinBox*   mySizeValue;
254   QLineEdit*          myGroupName;
255 //   QGroupBox*          makeGroupsCheck;
256 //   QCheckBox*          myGlobalGroupName;  
257   QPushButton*        addVertexButton;
258   QPushButton*        removeVertexButton;
259   
260   QWidget*            myEnfMeshGroup;
261   StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg;
262 //   SMESH::SMESH_IDSource_var myEnfMesh;
263   QComboBox*          myEnfMeshConstraint;
264   QStringList         myEnfMeshConstraintLabels;
265 //   SMESH::mesh_array_var myEnfMeshArray;
266   QTableWidget*       myEnforcedMeshTableWidget;
267   QLineEdit*          myMeshGroupName;
268   QPushButton*        addEnfMeshButton;
269   QPushButton*        removeEnfMeshButton;
270   
271   GeomSelectionTools* GeomToolSelected;
272   
273   SMESHGUI_SpinBox*   myHeightFirstLayerSpin;
274   QSpinBox*           myNbOfBoundaryLayersSpin;
275   SMESHGUI_SpinBox*   myBoundaryLayersProgressionSpin;
276   SMESHGUI_SpinBox*   myCoreSizeSpin;
277   SMESHGUI_SpinBox*   myMultinormalsAngleSpin;
278   QCheckBox*          mySmoothNormalsCheck;
279
280   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelector;
281 };
282
283 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
284 {
285     Q_OBJECT
286
287 public:
288   EnforcedVertexTableWidgetDelegate(QObject *parent = 0);
289
290   QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
291                       const QModelIndex &index) const;
292
293   void setEditorData(QWidget *editor, const QModelIndex &index) const;
294   void setModelData(QWidget *editor, QAbstractItemModel *model,
295                   const QModelIndex &index) const;
296
297   void updateEditorGeometry(QWidget *editor,
298       const QStyleOptionViewItem &option, const QModelIndex &index) const;
299
300   bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
301 };
302
303 class EnforcedMeshTableWidgetDelegate : public QItemDelegate
304 {
305     Q_OBJECT
306
307 public:
308   EnforcedMeshTableWidgetDelegate(QObject *parent = 0);
309
310   QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
311                       const QModelIndex &index) const;
312
313   void setEditorData(QWidget *editor, const QModelIndex &index) const;
314   void setModelData(QWidget *editor, QAbstractItemModel *model,
315                   const QModelIndex &index) const;
316
317   void updateEditorGeometry(QWidget *editor,
318       const QStyleOptionViewItem &option, const QModelIndex &index) const;
319 };
320
321 #endif