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