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