Salome HOME
1187bb90ba1aaff6622fd449135a7bd6734383dc
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_CartesianParamCreator.h
1 // Copyright (C) 2007-2013  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.
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 QLineEdit;
46 class QListWidget;
47 class QListWidgetItem;
48 class QModelIndex;
49 class QString;
50 class QStyleOptionViewItem;
51 class QTreeWidget;
52 class QTreeWidgetItem;
53 class QWidget;
54 class SMESHGUI_SpinBox;
55
56 namespace StdMeshersGUI
57 {
58   void getFromItem(QTreeWidgetItem * item, double& t0, double& t1, QString& fun );
59   QTreeWidgetItem* setToItem (double  t0, double  t1, const QString& fun, QTreeWidgetItem* item=0);
60
61   double coordFromItem( QListWidgetItem * );
62   QListWidgetItem* coordToItem( double coord, QListWidgetItem * item=0);
63
64   /*!
65    * \brief Widget defining the grid in one direction
66    */
67   class GridAxisTab : public QFrame
68   {
69     Q_OBJECT
70   public:
71     GridAxisTab( QWidget* parent, const int axisIndex );
72     ~GridAxisTab() {}
73
74     void setCoordinates( SMESH::double_array_var coords );
75     void setSpacing( SMESH::string_array_var funs, SMESH::double_array_var points );
76
77     bool checkParams(QString& msg, SMESH::SMESH_Hypothesis_var& hyp) const;
78     bool isGridBySpacing() const;
79     SMESH::double_array* getCoordinates();
80     void getSpacing(SMESH::string_array_out funs, SMESH::double_array_out points) const;
81
82   private slots:
83     void onInsert();
84     void onDelete();
85     void onMode(int);
86     void onStepChange();
87     void updateButtons();
88
89   private:
90
91     int               myAxisIndex;
92     QButtonGroup*     myModeGroup;
93     QTreeWidget*      mySpacingTreeWdg;
94     QListWidget*      myCoordList;
95     QPushButton*      myInsertBtn;
96     QPushButton*      myDeleteBtn;
97     SMESHGUI_SpinBox* myStepSpin;
98     QLabel*           myStepLabel;
99     double            myStep;
100   };
101   /*
102    * \brief : Custom item delegate
103    */
104   class LineDelegate : public QItemDelegate
105   {
106     Q_OBJECT
107   public:
108     LineDelegate( QWidget* parent );
109     ~LineDelegate() {}
110
111     QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
112     void setEditorData ( QWidget * editor, const QModelIndex & index ) const;
113     void setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const;
114
115   private:
116     QTreeWidget* mySpacingTreeWdg;
117     QListWidget* myCoordList;
118   };
119 }
120
121 class STDMESHERSGUI_EXPORT StdMeshersGUI_CartesianParamCreator : public StdMeshersGUI_StdHypothesisCreator
122 {
123   Q_OBJECT
124
125 public:
126   StdMeshersGUI_CartesianParamCreator( const QString& aHypType );
127   virtual ~StdMeshersGUI_CartesianParamCreator();
128
129   virtual bool    checkParams( QString& ) const;
130   virtual QString helpPage() const;
131
132 protected:
133   virtual QFrame*  buildFrame();
134   virtual void     retrieveParams() const;
135   virtual QString  storeParams() const;
136
137 private:
138   QLineEdit*                  myName;
139   SMESHGUI_SpinBox*           myThreshold;
140   QCheckBox*                  myAddEdges;
141   StdMeshersGUI::GridAxisTab* myAxisTabs[3];
142 };
143
144 #endif // STDMESHERSGUI_CartesianParamCreator_H