Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Measurements.h
1 // Copyright (C) 2007-2011  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 //  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 SUIT_SelectionFilter;
36 class SALOME_Actor;
37 class SMESH_Actor;
38 class SMESHGUI_IdValidator;
39
40 #include <SALOMEconfig.h>
41 #include CORBA_SERVER_HEADER(SMESH_Mesh)
42
43 class SMESHGUI_EXPORT SMESHGUI_MinDistance : public QWidget
44 {
45   Q_OBJECT;
46
47   enum { NoTgt, FirstTgt, SecondTgt };
48   enum { OriginTgt, NodeTgt, ElementTgt, ObjectTgt };
49
50 public:
51   SMESHGUI_MinDistance( QWidget* = 0 );
52   ~SMESHGUI_MinDistance();
53
54   bool eventFilter( QObject*, QEvent* );
55   void updateSelection();
56   void deactivate();
57
58 private: 
59   void setTarget( int );
60   void erasePreview();
61   void displayPreview();
62   void createPreview( double, double, double, double, double, double );
63
64 private slots:
65   void selectionChanged();
66   void firstChanged();
67   void secondChanged();
68   void firstEdited();
69   void secondEdited();
70   void compute();
71   void clear();
72
73 private:
74   QButtonGroup*             myFirst;
75   QButtonGroup*             mySecond;
76   QLineEdit*                myFirstTgt;
77   QLineEdit*                mySecondTgt;
78   QLineEdit*                myDX;
79   QLineEdit*                myDY;
80   QLineEdit*                myDZ;
81   QLineEdit*                myDistance;
82   int                       myCurrentTgt;
83   SMESH::SMESH_IDSource_var myFirstSrc;
84   SMESH::SMESH_IDSource_var mySecondSrc;
85   SMESH_Actor*              myFirstActor;
86   SMESH_Actor*              mySecondActor;
87   SMESHGUI_IdValidator*     myValidator;
88   SUIT_SelectionFilter*     myFilter;
89   SALOME_Actor*             myPreview;
90 };
91
92 class SMESHGUI_EXPORT SMESHGUI_BoundingBox : public QWidget
93 {
94   Q_OBJECT;
95
96   enum { ObjectsSrc, NodesSrc, ElementsSrc };
97   
98 public:
99   SMESHGUI_BoundingBox( QWidget* = 0 );
100   ~SMESHGUI_BoundingBox();
101
102   void updateSelection();
103   void deactivate();
104
105 private:
106   void erasePreview();
107   void displayPreview();
108   void createPreview( double, double, double, double, double, double );
109
110 private slots:
111   void selectionChanged();
112   void sourceChanged();
113   void sourceEdited();
114   void compute();
115   void clear();
116
117 private:
118   typedef QList<SMESH::SMESH_IDSource_var> SourceList;
119   QButtonGroup*             mySourceMode;
120   QLineEdit*                mySource;
121   QLineEdit*                myXmin;
122   QLineEdit*                myXmax;
123   QLineEdit*                myDX;
124   QLineEdit*                myYmin;
125   QLineEdit*                myYmax;
126   QLineEdit*                myDY;
127   QLineEdit*                myZmin;
128   QLineEdit*                myZmax;
129   QLineEdit*                myDZ;
130   SourceList                mySrc;
131   SMESH_Actor*              myActor;
132   SMESHGUI_IdValidator*     myValidator;
133   QString                   myIDs;
134   SUIT_SelectionFilter*     myFilter;
135   SALOME_Actor*             myPreview;
136 };
137
138 class SMESHGUI_EXPORT SMESHGUI_MeasureDlg : public QDialog
139
140   Q_OBJECT;
141
142   enum { NodeMode, ElemMode };
143
144 public:
145   //! Measurement type
146   enum { 
147     MinDistance,   //!< minimum distance
148     BoundingBox    //!< bounding box
149   };
150
151   SMESHGUI_MeasureDlg( QWidget* = 0, int = MinDistance );
152   ~SMESHGUI_MeasureDlg();
153
154   void reject();
155
156 protected:
157   void keyPressEvent( QKeyEvent* );
158   void enterEvent( QEvent* );
159
160 private slots:
161   void help();
162   void updateSelection();
163   void activate();
164   void deactivate();
165
166 private:
167   QTabWidget*           myTabWidget;
168   SMESHGUI_MinDistance* myMinDist;   
169   SMESHGUI_BoundingBox* myBndBox;
170 };
171
172 #endif // SMESHGUI_MEASUREMENTS_H