Salome HOME
0020682: EDF 1222 SMESH: 3D mesh from a skin mesh and with volumic cells
[plugins/ghs3dplugin.git] / src / GUI / GHS3DPluginGUI_HypothesisCreator.h
1 //  Copyright (C) 2004-2008  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 //  GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
20 //  File   : GHS3DPluginGUI_HypothesisCreator.h
21 //  Author : Michael Zorin
22 //  Module : GHS3DPlugin
23 //
24 #ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
25 #define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
26
27 #ifdef WIN32
28   #if defined GHS3DPluginGUI_EXPORTS
29     #define GHS3DPLUGINGUI_EXPORT __declspec( dllexport )
30   #else
31     #define GHS3DPLUGINGUI_EXPORT __declspec( dllimport )
32   #endif
33 #else
34   #define GHS3DPLUGINGUI_EXPORT
35 #endif
36
37 #include <SMESHGUI_Hypotheses.h>
38 // #include <SalomeApp_DoubleSpinBox.h>
39
40 #include <QItemDelegate>
41 #include <map>
42 #include <vector>
43 #include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
44
45 class QWidget;
46 class QComboBox;
47 class QCheckBox;
48 class QLineEdit;
49 class QSpinBox;
50 class QStandardItemModel;
51 class QTableView;
52 class QHeaderView;
53 class QDoubleSpinBox;
54
55 class LightApp_SelectionMgr;
56
57 typedef std::vector<double> GHS3DEnforcedVertex;
58 typedef std::vector<GHS3DEnforcedVertex> TEnforcedVertexValues;
59
60 typedef struct
61 {
62   bool    myToMeshHoles,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint;
63   int     myMaximumMemory,myInitialMemory,myOptimizationLevel;
64   QString myName,myWorkingDir,myTextOption;
65   short   myVerboseLevel;
66   TEnforcedVertexValues myEnforcedVertices;
67 } GHS3DHypothesisData;
68
69 /*!
70   \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
71 */
72 class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
73 {
74   Q_OBJECT
75
76 public:
77   GHS3DPluginGUI_HypothesisCreator( const QString& );
78   virtual ~GHS3DPluginGUI_HypothesisCreator();
79
80   virtual bool     checkParams(QString& msg) const;
81   virtual QString  helpPage() const;
82
83 protected:
84   virtual QFrame*  buildFrame    ();
85   virtual void     retrieveParams() const;
86   virtual QString  storeParams   () const;
87
88   virtual QString  caption() const;
89   virtual QPixmap  icon() const;
90   virtual QString  type() const;
91
92 protected slots:
93   void                onDirBtnClicked();
94   void                updateWidgets();
95   void                onVertexBtnClicked();
96   void                onRemoveVertexBtnClicked();
97   bool                checkVertexIsDefined();
98
99 signals:
100   void                vertexDefined(bool);
101
102 private:
103   bool                readParamsFromHypo( GHS3DHypothesisData& ) const;
104   bool                readParamsFromWidgets( GHS3DHypothesisData& ) const;
105   bool                storeParamsToHypo( const GHS3DHypothesisData& ) const;
106   bool                smpVertexExists(double, double, double) const;
107
108 private:
109   QWidget*            myStdGroup;
110   QLineEdit*          myName;
111   QCheckBox*          myToMeshHolesCheck;
112   QComboBox*          myOptimizationLevelCombo;
113
114   QWidget*            myAdvGroup;
115   QCheckBox*          myMaximumMemoryCheck;
116   QSpinBox*           myMaximumMemorySpin;
117   QCheckBox*          myInitialMemoryCheck;
118   QSpinBox*           myInitialMemorySpin;
119   QLineEdit*          myWorkingDir;
120   QCheckBox*          myKeepFiles;
121   QSpinBox*           myVerboseLevelSpin;
122   QCheckBox*          myToCreateNewNodesCheck;
123   QCheckBox*          myRemoveInitialCentralPointCheck;
124   QCheckBox*          myBoundaryRecoveryCheck;
125   QCheckBox*          myFEMCorrectionCheck;
126 QLineEdit*            myTextOption;
127   
128   QWidget*            myEnfGroup;
129   QStandardItemModel* mySmpModel;
130   QTableView*         myEnforcedTableView;
131   QLineEdit*          myXCoord;
132   QLineEdit*          myYCoord;
133   QLineEdit*          myZCoord;
134   QLineEdit*          mySizeValue;
135   QPushButton*        addVertexButton;
136   QPushButton*        removeVertexButton;
137   
138   LightApp_SelectionMgr*  mySelectionMgr;          /* User shape selection */
139 //   SVTK_Selector*          mySelector;
140 };
141
142 class DoubleLineEditDelegate : public QItemDelegate
143 {
144     Q_OBJECT
145
146 public:
147     DoubleLineEditDelegate(QObject *parent = 0);
148
149     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
150                         const QModelIndex &index) const;
151
152     void setEditorData(QWidget *editor, const QModelIndex &index) const;
153     void setModelData(QWidget *editor, QAbstractItemModel *model,
154                     const QModelIndex &index) const;
155
156     void updateEditorGeometry(QWidget *editor,
157         const QStyleOptionViewItem &option, const QModelIndex &index) const;
158 };
159
160 #endif