Salome HOME
Revert "Synchronize adm files"
[plugins/hexoticplugin.git] / src / GUI / HexoticPluginGUI_HypothesisCreator.h
1 // Copyright (C) 2007-2014  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
44 typedef struct
45 {
46   QString  myName;
47   int      myHexesMinLevel, myHexesMaxLevel;
48   double   myMinSize, myMaxSize;
49   bool     myHexoticInvalidElements;
50   bool     myHexoticIgnoreRidges;
51   double   myHexoticSharpAngleThreshold;
52   int      myHexoticNbProc;
53   QString  myHexoticWorkingDir;
54   int      myHexoticVerbosity;
55   int      myHexoticMaxMemory;
56   int      myHexoticSdMode;
57   HexoticPlugin_Hypothesis::THexoticSizeMaps mySizeMaps;
58 } HexoticHypothesisData;
59
60 /*!
61  * \brief Class for creation of Hexotic hypotheses
62 */
63 class HEXOTICPLUGIN_GUI_EXPORT HexoticPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
64 {
65   Q_OBJECT
66
67 public:
68   HexoticPluginGUI_HypothesisCreator( const QString& );
69   virtual ~HexoticPluginGUI_HypothesisCreator();
70
71   virtual bool checkParams(QString&) const;
72   virtual QString  helpPage() const;
73
74 protected:
75   virtual QFrame*  buildFrame    ();
76   virtual void     retrieveParams() const;
77   virtual QString  storeParams   () const;
78   
79   virtual QString  caption() const;
80   virtual QPixmap  icon() const;
81   virtual QString  type() const;
82   
83 private:
84   bool readParamsFromHypo( HexoticHypothesisData& ) const;
85   bool readParamsFromWidgets( HexoticHypothesisData& ) const;
86   bool readSizeMapsFromWidgets( HexoticHypothesisData& ) const;
87   void insertLocalSizeInWidget( std::string entry, std::string shapeName, double size, int row ) const;
88   bool storeParamsToHypo( const HexoticHypothesisData& ) const;
89   void resizeEvent(QResizeEvent *event);
90   void printData(HexoticHypothesisData&) const;
91   
92   GEOM::GEOM_Object_var entryToObject( std::string entry) const;
93
94 private:
95
96 //  QWidget*            myStdGroup;
97   QLineEdit*    myName;
98   HexoticPluginGUI_StdWidget*            myStdWidget;
99   HexoticPluginGUI_SizeMapsWidget*       mySmpWidget;
100   StdMeshersGUI_ObjectReferenceParamWdg* myGeomSelWdg;
101
102   bool                           myIs3D;
103   std::vector< std::string >     mySizeMapsToRemove;
104   QVariant                       myNotModifiedSize;
105  
106 protected slots:
107   void             onAddLocalSize();
108   void             onRemoveLocalSize();
109   
110 };
111
112 class SizeMapsTableWidgetDelegate : public QItemDelegate
113 {
114     Q_OBJECT
115
116 public:
117   SizeMapsTableWidgetDelegate(QObject *parent = 0);
118
119   QWidget *createEditor(QWidget *parent, 
120                         const QStyleOptionViewItem &option,
121                         const QModelIndex &index) const;
122
123   void setEditorData(QWidget *editor, 
124                      const QModelIndex &index) const;
125                      
126   void setModelData(QWidget *editor, 
127                     QAbstractItemModel *model,
128                     const QModelIndex &index) const;
129
130   void updateEditorGeometry(QWidget *editor, 
131                             const QStyleOptionViewItem &option,
132                             const QModelIndex &index) const;
133 };
134
135 #endif