Salome HOME
#18314 [CEA 18312] MG-Hexa hypothesis Construction: Hypothesis construction Local...
[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 #include "HexoticPlugin_Hypothesis.hxx"
30
31 #include <SMESHGUI_Hypotheses.h>
32 #include <StdMeshersGUI_ObjectReferenceParamWdg.h>
33 #include <QItemDelegate>
34
35 #include CORBA_SERVER_HEADER(HexoticPlugin_Algorithm)
36
37 class QtxIntSpinBox;
38 class QCheckBox;
39 class QLineEdit;
40 class QTableWidgetItem;
41
42 class HexoticPluginGUI_StdWidget;
43 class HexoticPluginGUI_AdvWidget;
44 class HexoticPluginGUI_SizeMapsWidget;
45 class HexoticPluginGUI_ViscousLayersWidget;
46 class SMESH_AdvOptionsWdg;
47
48 typedef struct
49 {
50   QString  myName;
51   int      myHexesMinLevel, myHexesMaxLevel;
52   double   myMinSize, myMaxSize, myApproxAngle;
53   bool     myHexoticInvalidElements;
54   bool     myHexoticIgnoreRidges;
55   double   myHexoticSharpAngleThreshold;
56   int      myHexoticNbProc;
57   QString  myHexoticWorkingDir;
58   int      myHexoticVerbosity;
59   int      myHexoticMaxMemory;
60   int      myHexoticSdMode;
61   QString  myTextOptions;
62   bool     myKeepFiles,myLogInStandardOutput, myRemoveLogOnSuccess;
63   HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps;
64   int      myNbLayers;
65   double   myFirstLayerSize;
66   bool     myDirection;
67   double   myGrowth;
68   std::vector<int> myFacesWithLayers;
69   std::vector<int> myImprintedFaces;
70 } HexoticHypothesisData;
71
72 /*!
73  * \brief Class for creation of MG-Hexa hypotheses
74 */
75 class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
76 {
77   Q_OBJECT
78
79 public:
80   HexoticPluginGUI_HypothesisCreator( const QString& );
81   virtual ~HexoticPluginGUI_HypothesisCreator();
82
83   virtual bool checkParams(QString&) const;
84   virtual QString  helpPage() const;
85
86 protected:
87   virtual QFrame*  buildFrame    ();
88   virtual void     retrieveParams() const;
89   virtual QString  storeParams   () const;
90   
91   virtual QString  caption() const;
92   virtual QPixmap  icon() const;
93   virtual QString  type() const;
94   
95 private:
96   bool readParamsFromHypo( HexoticHypothesisData& ) const;
97   bool readParamsFromWidgets( HexoticHypothesisData& ) const;
98   bool readSizeMapsFromWidgets( HexoticHypothesisData& ) const;
99   void insertLocalSizeInWidget( std::string entry, std::string shapeName, double size, int row ) const;
100   bool storeParamsToHypo( const HexoticHypothesisData& ) const;
101   void resizeEvent(QResizeEvent *event);
102   void printData(HexoticHypothesisData&) const;
103   
104   GEOM::GEOM_Object_var entryToObject( std::string entry) const;
105
106 private:
107
108 //  QWidget*            myStdGroup;
109   QLineEdit*                              myName;
110   HexoticPluginGUI_StdWidget*             myStdWidget;
111   HexoticPluginGUI_AdvWidget*             myAdvWidget;
112   mutable HexoticPlugin::string_array_var myOptions, myCustomOptions;
113   HexoticPluginGUI_SizeMapsWidget*        mySmpWidget;
114   HexoticPluginGUI_ViscousLayersWidget*   myVLWidget;
115   StdMeshersGUI_ObjectReferenceParamWdg*  myGeomSelWdg;
116
117   bool                           myIs3D;
118   std::vector< std::string >     mySizeMapsToRemove;
119   QVariant                       myNotModifiedSize;
120  
121 protected slots:
122   void             onAddLocalSize();
123   void             onRemoveLocalSize();
124   void             onTabChanged(int);
125   void             onAddOption();
126   void             onDirBtnClicked();
127
128 };
129
130 class SizeMapsTableWidgetDelegate : public QItemDelegate
131 {
132     Q_OBJECT
133
134 public:
135   SizeMapsTableWidgetDelegate(QObject *parent = 0);
136
137   QWidget *createEditor(QWidget *parent, 
138                         const QStyleOptionViewItem &option,
139                         const QModelIndex &index) const;
140
141   void setEditorData(QWidget *editor, 
142                      const QModelIndex &index) const;
143                      
144   void setModelData(QWidget *editor, 
145                     QAbstractItemModel *model,
146                     const QModelIndex &index) const;
147
148   void updateEditorGeometry(QWidget *editor, 
149                             const QStyleOptionViewItem &option,
150                             const QModelIndex &index) const;
151 };
152
153 #endif