Salome HOME
0023102: [CEA 1486 ] Add the parameters for defining the boundary layers
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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   : HexoticPluginGUI_HypothesisCreator.h
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #ifndef HexoticPLUGINGUI_HypothesisCreator_H
26 #define HexoticPLUGINGUI_HypothesisCreator_H
27
28 #include "HexoticPluginGUI.h"
29
30 #include <SMESHGUI_Hypotheses.h>
31 #include "StdMeshersGUI_ObjectReferenceParamWdg.h"
32 #include "HexoticPlugin_Hypothesis.hxx"
33
34 #include <QItemDelegate>
35
36 class QtxIntSpinBox;
37 class QCheckBox;
38 class QLineEdit;
39 class QTableWidgetItem;
40
41 class HexoticPluginGUI_StdWidget;
42 class HexoticPluginGUI_SizeMapsWidget;
43 class HexoticPluginGUI_ViscousLayersWidget;
44
45 typedef struct
46 {
47   QString  myName;
48   int      myHexesMinLevel, myHexesMaxLevel;
49   double   myMinSize, myMaxSize;
50   bool     myHexoticInvalidElements;
51   bool     myHexoticIgnoreRidges;
52   double   myHexoticSharpAngleThreshold;
53   int      myHexoticNbProc;
54   QString  myHexoticWorkingDir;
55   int      myHexoticVerbosity;
56   int      myHexoticMaxMemory;
57   int      myHexoticSdMode;
58   HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps;
59   int      myNbLayers;
60   double   myFirstLayerSize;
61   bool     myDirection;
62   double   myGrowth;
63   std::vector<int> myFacesWithLayers;
64   std::vector<int> myImprintedFaces;
65 } HexoticHypothesisData;
66
67 /*!
68  * \brief Class for creation of MG-Hexa hypotheses
69 */
70 class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
71 {
72   Q_OBJECT
73
74 public:
75   HexoticPluginGUI_HypothesisCreator( const QString& );
76   virtual ~HexoticPluginGUI_HypothesisCreator();
77
78   virtual bool checkParams(QString&) const;
79   virtual QString  helpPage() const;
80
81 protected:
82   virtual QFrame*  buildFrame    ();
83   virtual void     retrieveParams() const;
84   virtual QString  storeParams   () const;
85   
86   virtual QString  caption() const;
87   virtual QPixmap  icon() const;
88   virtual QString  type() const;
89   
90 private:
91   bool readParamsFromHypo( HexoticHypothesisData& ) const;
92   bool readParamsFromWidgets( HexoticHypothesisData& ) const;
93   bool readSizeMapsFromWidgets( HexoticHypothesisData& ) const;
94   void insertLocalSizeInWidget( std::string entry, std::string shapeName, double size, int row ) const;
95   bool storeParamsToHypo( const HexoticHypothesisData& ) const;
96   void resizeEvent(QResizeEvent *event);
97   void printData(HexoticHypothesisData&) const;
98   
99   GEOM::GEOM_Object_var entryToObject( std::string entry) const;
100
101 private:
102
103 //  QWidget*            myStdGroup;
104   QLineEdit*    myName;
105   HexoticPluginGUI_StdWidget*            myStdWidget;
106   HexoticPluginGUI_SizeMapsWidget*       mySmpWidget;
107   HexoticPluginGUI_ViscousLayersWidget*  myVLWidget;
108   StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg;
109
110   bool                           myIs3D;
111   std::vector< std::string >     mySizeMapsToRemove;
112   QVariant                       myNotModifiedSize;
113  
114 protected slots:
115   void             onAddLocalSize();
116   void             onRemoveLocalSize();
117   void             onTabChanged(int);
118   
119 };
120
121 class SizeMapsTableWidgetDelegate : public QItemDelegate
122 {
123     Q_OBJECT
124
125 public:
126   SizeMapsTableWidgetDelegate(QObject *parent = 0);
127
128   QWidget *createEditor(QWidget *parent, 
129                         const QStyleOptionViewItem &option,
130                         const QModelIndex &index) const;
131
132   void setEditorData(QWidget *editor, 
133                      const QModelIndex &index) const;
134                      
135   void setModelData(QWidget *editor, 
136                     QAbstractItemModel *model,
137                     const QModelIndex &index) const;
138
139   void updateEditorGeometry(QWidget *editor, 
140                             const QStyleOptionViewItem &option,
141                             const QModelIndex &index) const;
142 };
143
144 #endif