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