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