Salome HOME
Copyright update: 2016
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2016  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   QString  myTextOptions;
59   HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps;
60   int      myNbLayers;
61   double   myFirstLayerSize;
62   bool     myDirection;
63   double   myGrowth;
64   std::vector<int> myFacesWithLayers;
65   std::vector<int> myImprintedFaces;
66 } HexoticHypothesisData;
67
68 /*!
69  * \brief Class for creation of MG-Hexa hypotheses
70 */
71 class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
72 {
73   Q_OBJECT
74
75 public:
76   HexoticPluginGUI_HypothesisCreator( const QString& );
77   virtual ~HexoticPluginGUI_HypothesisCreator();
78
79   virtual bool checkParams(QString&) const;
80   virtual QString  helpPage() const;
81
82 protected:
83   virtual QFrame*  buildFrame    ();
84   virtual void     retrieveParams() const;
85   virtual QString  storeParams   () const;
86   
87   virtual QString  caption() const;
88   virtual QPixmap  icon() const;
89   virtual QString  type() const;
90   
91 private:
92   bool readParamsFromHypo( HexoticHypothesisData& ) const;
93   bool readParamsFromWidgets( HexoticHypothesisData& ) const;
94   bool readSizeMapsFromWidgets( HexoticHypothesisData& ) const;
95   void insertLocalSizeInWidget( std::string entry, std::string shapeName, double size, int row ) const;
96   bool storeParamsToHypo( const HexoticHypothesisData& ) const;
97   void resizeEvent(QResizeEvent *event);
98   void printData(HexoticHypothesisData&) const;
99   
100   GEOM::GEOM_Object_var entryToObject( std::string entry) const;
101
102 private:
103
104 //  QWidget*            myStdGroup;
105   QLineEdit*    myName;
106   HexoticPluginGUI_StdWidget*            myStdWidget;
107   HexoticPluginGUI_SizeMapsWidget*       mySmpWidget;
108   HexoticPluginGUI_ViscousLayersWidget*  myVLWidget;
109   StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg;
110
111   bool                           myIs3D;
112   std::vector< std::string >     mySizeMapsToRemove;
113   QVariant                       myNotModifiedSize;
114  
115 protected slots:
116   void             onAddLocalSize();
117   void             onRemoveLocalSize();
118   void             onTabChanged(int);
119   
120 };
121
122 class SizeMapsTableWidgetDelegate : public QItemDelegate
123 {
124     Q_OBJECT
125
126 public:
127   SizeMapsTableWidgetDelegate(QObject *parent = 0);
128
129   QWidget *createEditor(QWidget *parent, 
130                         const QStyleOptionViewItem &option,
131                         const QModelIndex &index) const;
132
133   void setEditorData(QWidget *editor, 
134                      const QModelIndex &index) const;
135                      
136   void setModelData(QWidget *editor, 
137                     QAbstractItemModel *model,
138                     const QModelIndex &index) const;
139
140   void updateEditorGeometry(QWidget *editor, 
141                             const QStyleOptionViewItem &option,
142                             const QModelIndex &index) const;
143 };
144
145 #endif