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