]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/GUI/BLSURFPluginGUI_HypothesisCreator.h
Salome HOME
63d105e276ae2d2e05c9a4459fb35aee7c2c604f
[plugins/blsurfplugin.git] / src / GUI / BLSURFPluginGUI_HypothesisCreator.h
1 //  Copyright (C) 2007-2010  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 // ---
21 // File    : BLSURFPluginGUI_HypothesisCreator.h
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 //           & Aurelien ALLEAUME (DISTENE)
24 //           Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
25 // ---
26 //
27 #ifndef BLSURFPLUGINGUI_HypothesisCreator_H
28 #define BLSURFPLUGINGUI_HypothesisCreator_H
29
30 #ifdef WIN32
31   #if defined BLSURFPLUGIN_GUI_EXPORTS || defined BLSURFPluginGUI_EXPORTS
32     #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllexport )
33   #else
34     #define BLSURFPLUGIN_GUI_EXPORT __declspec( dllimport )
35   #endif
36 #else
37   #define BLSURFPLUGIN_GUI_EXPORT
38 #endif
39
40 #ifdef WNT
41 // E.A. : On windows with python 2.6, there is a conflict
42 // E.A. : between pymath.h and Standard_math.h which define
43 // E.A. : some same symbols : acosh, asinh, ...
44 #include <Standard_math.hxx>
45 #include <pymath.h>
46 #endif
47
48 #include <Python.h>
49
50 #include <QItemDelegate>
51
52 #include <SMESHGUI_Hypotheses.h>
53 #include <SALOMEconfig.h>
54 #include <cstring>
55 #include <map>
56 #include <set>
57 #include <vector>
58 #include <TopAbs_ShapeEnum.hxx>
59 #include <GeomSelectionTools.h>
60 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
61
62 class QGroupBox;
63 class QComboBox;
64 class QCheckBox;
65 class QLineEdit;
66 class QTableWidget;
67 class QTreeWidget;
68 class QModelIndex;
69 class QSpinBox;
70 class QMenu;
71 class QAction;
72 class QTreeWidgetItem;
73
74 class SMESHGUI_SpinBox;
75 class LightApp_SelectionMgr;
76 // class DlgBlSurfHyp_Enforced;
77
78 typedef struct
79 {
80   int     myTopology, myVerbosity;
81   int     myPhysicalMesh, myGeometricMesh;
82   double  myAngleMeshS, myAngleMeshC, myGradation;
83   double  myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax;
84   bool    myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex;
85   std::set<std::vector<double> > enfVertexList;
86   std::map<std::string, std::set<std::vector<double> > > entryEnfVertexListMap;
87   /* TODO GROUPS
88   std::map<std::string, std::set<std::vector<double> > > groupNameEnfVertexListMap;
89   std::map<std::vector<double> , std::string > enfVertexGroupNameMap;
90   */
91   QString myName;
92 } BlsurfHypothesisData;
93
94
95 /*!
96  * \brief Class for creation of BLSURF hypotheses
97 */
98 class BLSURFPLUGIN_GUI_EXPORT BLSURFPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
99 {
100   Q_OBJECT
101
102 public:
103   BLSURFPluginGUI_HypothesisCreator( const QString& );
104   virtual ~BLSURFPluginGUI_HypothesisCreator();
105
106   virtual bool        checkParams() const;
107   virtual QString     helpPage() const;
108   void                insertElementType( TopAbs_ShapeEnum );
109   static LightApp_SelectionMgr* selectionMgr();
110
111 protected:
112   virtual QFrame*     buildFrame    ();
113   virtual void        retrieveParams() const;
114   virtual QString     storeParams   () const;
115   
116   virtual QString     caption() const;
117   virtual QPixmap     icon() const;
118   virtual QString     type() const;
119
120 protected slots:
121   void                onPhysicalMeshChanged();
122   void                onGeometricMeshChanged();
123   void                onAddOption();
124   void                onDeleteOption();
125   void                onOptionChosenInPopup( QAction* );
126 //  void                onAddAttractor();
127   void                onAddMapOnSurface();
128   void                onAddMapOnEdge();
129   void                onAddMapOnPoint();
130   void                onRemoveMap();
131   void                onSetSizeMap(int,int);
132
133   /* TODO GROUPS
134   void                addEnforcedVertex(std::string, std::string, double, double, double, std::string);
135   */
136   void                addEnforcedVertex(std::string, std::string, double, double, double);
137   void                onAddEnforcedVertices();
138   void                onRemoveEnforcedVertex();
139   void                synchronizeCoords();
140   void                update(QTreeWidgetItem* , int );
141
142 private:
143   bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
144   QString             readParamsFromWidgets( BlsurfHypothesisData& ) const;
145   bool                storeParamsToHypo( const BlsurfHypothesisData& ) const;
146   bool                sizeMapsValidation();
147   bool                sizeMapValidationFromRow(int,bool displayError = true);
148   bool                sizeMapValidationFromEntry(QString,bool displayError = true);
149   GeomSelectionTools* getGeomSelectionTool();
150
151 private:
152   QWidget*            myStdGroup;
153   QLineEdit*          myName;
154   QComboBox*          myPhysicalMesh;
155   SMESHGUI_SpinBox*   myPhySize;
156   SMESHGUI_SpinBox*   myPhyMin;
157   SMESHGUI_SpinBox*   myPhyMax;
158   QComboBox*          myGeometricMesh;
159   SMESHGUI_SpinBox*   myAngleMeshS;
160   SMESHGUI_SpinBox*   myAngleMeshC;
161   SMESHGUI_SpinBox*   myGeoMin;
162   SMESHGUI_SpinBox*   myGeoMax;
163   SMESHGUI_SpinBox*   myGradation;
164   QCheckBox*          myAllowQuadrangles;
165   QCheckBox*          myDecimesh;
166
167   QWidget*            myAdvGroup;
168   QComboBox*          myTopology;
169   QSpinBox*           myVerbosity;
170   QTableWidget*       myOptionTable;
171
172   QWidget             *mySmpGroup;
173   QTableWidget        *mySizeMapTable;
174   QPushButton         *addAttractorButton;
175   QPushButton         *addSurfaceButton;
176   QPushButton         *addEdgeButton;
177   QPushButton         *addPointButton;
178   QPushButton         *removeButton;
179
180   QWidget*            myEnfGroup;
181   /* TODO FACE AND VERTEX SELECTION
182   QPushButton*        selectFaceButton;
183   QLineEdit*          mySelectedFace;
184 //   GEOM::GEOM_Object_var myEnfFace;
185   QPushButton*        selectVertexButton;
186   QLineEdit*          mySelectedEnforcedVertex;
187 //   GEOM::GEOM_Object_var myEnfVertex;
188   */
189 //   DlgBlSurfHyp_Enforced* myEnforcedVertexWidget;
190   QTreeWidget*        myEnforcedTreeWidget;
191   SMESHGUI_SpinBox*   myXCoord;
192   SMESHGUI_SpinBox*   myYCoord;
193   SMESHGUI_SpinBox*   myZCoord;
194   /* TODO GROUPS
195   QLineEdit*          myGroupName;
196   QGroupBox*          makeGroupsCheck;
197   QLineEdit*          myGlobalGroupName;
198   */
199   QPushButton*        addVertexButton;
200   QPushButton*        removeVertexButton;
201
202   // map =  entry , size map
203   QMap<QString, QString>          mySMPMap;
204   QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
205   GeomSelectionTools*             GeomToolSelected;
206   LightApp_SelectionMgr*          aSel;
207
208   BLSURFPlugin::string_array_var myOptions;
209
210   PyObject *          main_mod;
211   PyObject *          main_dict;
212 };
213
214
215 class EnforcedTreeWidgetDelegate : public QItemDelegate
216 {
217     Q_OBJECT
218
219 public:
220   EnforcedTreeWidgetDelegate(QObject *parent = 0);
221
222   QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
223                         const QModelIndex &index) const;
224
225   void setEditorData(QWidget *editor, const QModelIndex &index) const;
226   void setModelData(QWidget *editor, QAbstractItemModel *model,
227                     const QModelIndex &index) const;
228
229   void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
230                     const QModelIndex &index) const;
231   
232   bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const;
233 };
234
235 #endif // BLSURFPLUGINGUI_HypothesisCreator_H