Salome HOME
Merge branch V7_3_1_BR
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_CartesianParamCreator.h
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : StdMeshersGUI_CartesianParamCreator.h
24 // Author : Open CASCADE S.A.S.
25 //
26 #ifndef STDMESHERSGUI_CartesianParamCreator_H
27 #define STDMESHERSGUI_CartesianParamCreator_H
28
29 // SMESH includes
30 #include "SMESH_StdMeshersGUI.hxx"
31
32 #include "StdMeshersGUI_StdHypothesisCreator.h"
33
34 // IDL includes
35 #include <SALOMEconfig.h>
36 #include CORBA_SERVER_HEADER(SMESH_Mesh)
37 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
38
39 #include <QFrame>
40 #include <QItemDelegate>
41
42 class QAbstractItemModel;
43 class QButtonGroup;
44 class QCheckBox;
45 class QGroupBox;
46 class QLineEdit;
47 class QListWidget;
48 class QListWidgetItem;
49 class QModelIndex;
50 class QString;
51 class QStyleOptionViewItem;
52 class QTreeWidget;
53 class QTreeWidgetItem;
54 class QWidget;
55 class SMESHGUI_MeshEditPreview;
56 class SMESHGUI_SpinBox;
57
58 namespace StdMeshersGUI
59 {
60   void getFromItem(QTreeWidgetItem * item, double& t0, double& t1, QString& fun );
61   QTreeWidgetItem* setToItem (double  t0, double  t1, const QString& fun, QTreeWidgetItem* item=0);
62
63   double coordFromItem( QListWidgetItem * );
64   QListWidgetItem* coordToItem( double coord, QListWidgetItem * item=0);
65
66   /*!
67    * \brief Widget defining the grid in one direction
68    */
69   class GridAxisTab : public QFrame
70   {
71     Q_OBJECT
72   public:
73     GridAxisTab( QWidget* parent, const int axisIndex );
74     ~GridAxisTab() {}
75
76     void setCoordinates( SMESH::double_array_var coords );
77     void setSpacing( SMESH::string_array_var funs, SMESH::double_array_var points );
78
79     bool checkParams(QString& msg, SMESH::SMESH_Hypothesis_var& hyp) const;
80     bool isGridBySpacing() const;
81     SMESH::double_array* getCoordinates();
82     void getSpacing(SMESH::string_array_out funs, SMESH::double_array_out points) const;
83
84   signals:
85     void gridModeChanged(int);
86
87   private slots:
88     void onInsert();
89     void onDelete();
90     void onMode(int);
91     void onStepChange();
92     void updateButtons();
93
94   private:
95
96     int               myAxisIndex;
97     QButtonGroup*     myModeGroup;
98     QTreeWidget*      mySpacingTreeWdg;
99     QListWidget*      myCoordList;
100     QPushButton*      myInsertBtn;
101     QPushButton*      myDeleteBtn;
102     SMESHGUI_SpinBox* myStepSpin;
103     QLabel*           myStepLabel;
104     double            myStep;
105   };
106   /*
107    * \brief : Custom item delegate
108    */
109   class LineDelegate : public QItemDelegate
110   {
111     Q_OBJECT
112   public:
113     LineDelegate( QWidget* parent );
114     ~LineDelegate() {}
115
116     QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
117     void setEditorData ( QWidget * editor, const QModelIndex & index ) const;
118     void setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const;
119
120   private:
121     QTreeWidget* mySpacingTreeWdg;
122     QListWidget* myCoordList;
123   };
124 }
125
126 class STDMESHERSGUI_EXPORT StdMeshersGUI_CartesianParamCreator : public StdMeshersGUI_StdHypothesisCreator
127 {
128   Q_OBJECT
129
130 public:
131   StdMeshersGUI_CartesianParamCreator( const QString& aHypType );
132   virtual ~StdMeshersGUI_CartesianParamCreator();
133
134   virtual bool     checkParams( QString& ) const;
135   virtual QString  helpPage() const;
136
137 protected:
138   virtual QFrame*  buildFrame();
139   virtual void     retrieveParams() const;
140   virtual QString  storeParams() const;
141
142 private slots:
143   bool             updateAxesPreview();
144   void             onOrthogonalAxes(bool);
145   void             onAxisDirChange(const QString&);
146   void             onSelectionChange();
147   void             onOptimalAxes(bool);
148   void             onResetAxes(bool);
149   void             onGridModeChanged(int);
150
151 private:
152   QLineEdit*                  myName;
153   SMESHGUI_SpinBox*           myThreshold;
154   QCheckBox*                  myAddEdges;
155
156   StdMeshersGUI::GridAxisTab* myAxisTabs[3];
157   QGroupBox*                  myFixedPointGrp;
158   SMESHGUI_SpinBox*           myPointSpin[3];
159   QCheckBox*                  myOrthogonalChk;
160   QButtonGroup*               myAxisBtnGrp;
161   SMESHGUI_SpinBox*           myXDirSpin[3];
162   SMESHGUI_SpinBox*           myYDirSpin[3];
163   SMESHGUI_SpinBox*           myZDirSpin[3];
164   SMESHGUI_MeshEditPreview*   myAxesPreview;
165   double                      myOrigin[3];
166   double                      myAxesLen;
167   int                         myDirTic[3];
168 };
169
170 #endif // STDMESHERSGUI_CartesianParamCreator_H