Salome HOME
a135c0592b874483869ddcee8200a5c635ec11bd
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2019  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 class SMESH_AdvOptionsWdg;
45
46 typedef struct
47 {
48   QString  myName;
49   int      myHexesMinLevel, myHexesMaxLevel;
50   double   myMinSize, myMaxSize;
51   bool     myHexoticInvalidElements;
52   bool     myHexoticIgnoreRidges;
53   double   myHexoticSharpAngleThreshold;
54   int      myHexoticNbProc;
55   QString  myHexoticWorkingDir;
56   int      myHexoticVerbosity;
57   int      myHexoticMaxMemory;
58   int      myHexoticSdMode;
59   QString  myTextOptions;
60   HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps;
61   int      myNbLayers;
62   double   myFirstLayerSize;
63   bool     myDirection;
64   double   myGrowth;
65   std::vector<int> myFacesWithLayers;
66   std::vector<int> myImprintedFaces;
67 } HexoticHypothesisData;
68
69 /*!
70  * \brief Class for creation of MG-Hexa hypotheses
71 */
72 class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
73 {
74   Q_OBJECT
75
76 public:
77   HexoticPluginGUI_HypothesisCreator( const QString& );
78   virtual ~HexoticPluginGUI_HypothesisCreator();
79
80   virtual bool checkParams(QString&) 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 private:
93   bool readParamsFromHypo( HexoticHypothesisData& ) const;
94   bool readParamsFromWidgets( HexoticHypothesisData& ) const;
95   bool readSizeMapsFromWidgets( HexoticHypothesisData& ) const;
96   void insertLocalSizeInWidget( std::string entry, std::string shapeName, double size, int row ) const;
97   bool storeParamsToHypo( const HexoticHypothesisData& ) const;
98   void resizeEvent(QResizeEvent *event);
99   void printData(HexoticHypothesisData&) const;
100   
101   GEOM::GEOM_Object_var entryToObject( std::string entry) const;
102
103 private:
104
105 //  QWidget*            myStdGroup;
106   QLineEdit*    myName;
107   HexoticPluginGUI_StdWidget*            myStdWidget;
108   SMESH_AdvOptionsWdg*                   myAdvWidget;
109   HexoticPluginGUI_SizeMapsWidget*       mySmpWidget;
110   HexoticPluginGUI_ViscousLayersWidget*  myVLWidget;
111   StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg;
112
113   bool                           myIs3D;
114   std::vector< std::string >     mySizeMapsToRemove;
115   QVariant                       myNotModifiedSize;
116  
117 protected slots:
118   void             onAddLocalSize();
119   void             onRemoveLocalSize();
120   void             onTabChanged(int);
121   
122 };
123
124 class SizeMapsTableWidgetDelegate : public QItemDelegate
125 {
126     Q_OBJECT
127
128 public:
129   SizeMapsTableWidgetDelegate(QObject *parent = 0);
130
131   QWidget *createEditor(QWidget *parent, 
132                         const QStyleOptionViewItem &option,
133                         const QModelIndex &index) const;
134
135   void setEditorData(QWidget *editor, 
136                      const QModelIndex &index) const;
137                      
138   void setModelData(QWidget *editor, 
139                     QAbstractItemModel *model,
140                     const QModelIndex &index) const;
141
142   void updateEditorGeometry(QWidget *editor, 
143                             const QStyleOptionViewItem &option,
144                             const QModelIndex &index) const;
145 };
146
147 #endif