Salome HOME
Update copyrights
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Measurements.h
1 // Copyright (C) 2007-2019  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 //  File   : SMESHGUI_Measurements.h
23 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24
25 #ifndef SMESHGUI_MEASUREMENTS_H
26 #define SMESHGUI_MEASUREMENTS_H
27
28 #include "SMESH_SMESHGUI.hxx"
29
30 #include <QDialog>
31
32 class QButtonGroup;
33 class QLineEdit;
34 class QTabWidget;
35 class QGroupBox;
36 class SUIT_SelectionFilter;
37 class SALOME_Actor;
38 class SMESH_Actor;
39 class SMESHGUI_IdValidator;
40 class SMESHGUI_MeshEditPreview;
41
42 #include <SALOMEconfig.h>
43 #include CORBA_SERVER_HEADER(SMESH_Mesh)
44
45 #include <gp_Vec.hxx>
46
47 class SMESHGUI_EXPORT SMESHGUI_MinDistance : public QWidget
48 {
49   Q_OBJECT;
50
51   enum { NoTgt, FirstTgt, SecondTgt };
52   enum { OriginTgt, NodeTgt, ElementTgt, ObjectTgt };
53
54 public:
55   SMESHGUI_MinDistance( QWidget* = 0 );
56   ~SMESHGUI_MinDistance();
57
58   bool eventFilter( QObject*, QEvent* );
59   void updateSelection();
60   void deactivate();
61
62 private: 
63   void setTarget( int );
64   void erasePreview();
65   void displayPreview();
66   void createPreview( double, double, double, double, double, double );
67
68 private slots:
69   void selectionChanged();
70   void firstChanged();
71   void secondChanged();
72   void firstEdited();
73   void secondEdited();
74   void compute();
75   void clear();
76
77 private:
78   QButtonGroup*             myFirst;
79   QButtonGroup*             mySecond;
80   QLineEdit*                myFirstTgt;
81   QLineEdit*                mySecondTgt;
82   QLineEdit*                myDX;
83   QLineEdit*                myDY;
84   QLineEdit*                myDZ;
85   QLineEdit*                myDistance;
86   int                       myCurrentTgt;
87   SMESH::SMESH_IDSource_var myFirstSrc;
88   SMESH::SMESH_IDSource_var mySecondSrc;
89   SMESH_Actor*              myFirstActor;
90   SMESH_Actor*              mySecondActor;
91   SMESHGUI_IdValidator*     myValidator;
92   SUIT_SelectionFilter*     myFilter;
93   SALOME_Actor*             myPreview;
94 };
95
96 class SMESHGUI_EXPORT SMESHGUI_BoundingBox : public QWidget
97 {
98   Q_OBJECT;
99
100   enum { ObjectsSrc, NodesSrc, ElementsSrc };
101   
102 public:
103   SMESHGUI_BoundingBox( QWidget* = 0 );
104   ~SMESHGUI_BoundingBox();
105
106   void updateSelection();
107   void deactivate();
108   void erasePreview();
109
110 private:
111   void displayPreview();
112   void createPreview( double, double, double, double, double, double );
113
114 private slots:
115   void selectionChanged();
116   void sourceChanged();
117   void sourceEdited();
118   void compute();
119   void clear();
120
121 private:
122   typedef QList<SMESH::SMESH_IDSource_var> SourceList;
123   QButtonGroup*             mySourceMode;
124   QLineEdit*                mySource;
125   QLineEdit*                myXmin;
126   QLineEdit*                myXmax;
127   QLineEdit*                myDX;
128   QLineEdit*                myYmin;
129   QLineEdit*                myYmax;
130   QLineEdit*                myDY;
131   QLineEdit*                myZmin;
132   QLineEdit*                myZmax;
133   QLineEdit*                myDZ;
134   SourceList                mySrc;
135   SMESH_Actor*              myActor;
136   SMESHGUI_IdValidator*     myValidator;
137   QString                   myIDs;
138   SUIT_SelectionFilter*     myFilter;
139   SALOME_Actor*             myPreview;
140 };
141
142 class SMESHGUI_EXPORT SMESHGUI_BasicProperties : public QWidget
143 {
144   Q_OBJECT;
145   
146 public:
147   //! Property type
148   enum Mode { Length, Area, Volume };
149
150   SMESHGUI_BasicProperties( QWidget* = 0 );
151   ~SMESHGUI_BasicProperties();
152
153   void setMode( const Mode );
154
155   void updateSelection();
156   void deactivate();
157
158 private slots:
159   void selectionChanged();
160   void modeChanged( int);
161   void compute();
162   void clear();
163
164 private:
165   QButtonGroup*             myMode;
166   QLineEdit*                mySource;
167   QGroupBox*                myResultGrp;
168   QLineEdit*                myResult;
169   SMESH::SMESH_IDSource_var mySrc;
170   SUIT_SelectionFilter*     myFilter;
171 };
172
173 class SMESHGUI_EXPORT SMESHGUI_Angle : public QWidget
174 {
175   Q_OBJECT;
176   
177 public:
178
179   SMESHGUI_Angle( QWidget* = 0 );
180   ~SMESHGUI_Angle();
181
182   void deactivate();
183   void updateSelection();
184
185 private slots:
186   void selectionChanged();
187   void nodesEdited();
188   void compute();
189   void clear();
190
191 private:
192
193   bool addPointByActor( int id );
194   bool addPointByIDSource( int id );
195   gp_Vec getNormal(const gp_Vec& vec10 );
196
197   QLineEdit* myNodes;
198   QLineEdit* myResult;
199
200   SMESH::SMESH_IDSource_var myIDSrc;
201   SMESH_Actor*              myActor;
202
203   std::vector< SMESH::PointStruct > myPoints;
204   SMESHGUI_MeshEditPreview*         myPreview;
205 };
206
207 class SMESHGUI_EXPORT SMESHGUI_MeasureDlg : public QDialog
208
209   Q_OBJECT;
210
211   enum { NodeMode, ElemMode };
212
213 public:
214   //! Measurement type
215   enum { 
216     MinDistance,   //!< minimum distance
217     BoundingBox,   //!< bounding box
218     Length,        //!< length
219     Area,          //!< area
220     Volume,        //!< volume
221     Angle
222   };
223
224   SMESHGUI_MeasureDlg( QWidget* = 0, int = MinDistance );
225   ~SMESHGUI_MeasureDlg();
226
227   void reject();
228
229 protected:
230   void keyPressEvent( QKeyEvent* );
231   void enterEvent( QEvent* );
232
233 private slots:
234   void help();
235   void updateSelection();
236   void activate();
237   void deactivate();
238
239 private:
240   QTabWidget*           myTabWidget;
241   SMESHGUI_MinDistance* myMinDist;   
242   SMESHGUI_BoundingBox* myBndBox;
243   SMESHGUI_BasicProperties* myBasicProps;
244   SMESHGUI_Angle*       myAngle;
245 };
246
247 #endif // SMESHGUI_MEASUREMENTS_H