Salome HOME
Fix compilation error (conflict of OK name between OCCT Plate_Plate.hxx and GEOM...
[modules/geom.git] / MeasureGUI / MeasureGUI_CreateDimensionDlg.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 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : MeasureGUI_CreateDimensionDlg.h
25 // Author : Anton POLETAEV, Open CASCADE S.A.S.
26 //
27 #ifndef MEASUREGUI_CREATEDIMENSIONDLG_H
28 #define MEASUREGUI_CREATEDIMENSIONDLG_H
29
30 #include "MeasureGUI_Widgets.h"
31 #include "MeasureGUI_DimensionInteractor.h"
32
33 // GEOM includes
34 #include <GEOMBase_Skeleton.h>
35 #include <GEOM_GenericObjPtr.h>
36
37 // SUIT includes
38 #include <SOCC_ViewModel.h>
39
40 // OCCT includes
41 #include <AIS_Dimension.hxx>
42 #include <gp_Pnt.hxx>
43
44 class MeasureGUI_1Sel_Frame;
45 class MeasureGUI_2Sel_Frame;
46 class MeasureGUI_3Sel_Frame;
47 class QAbstractButton;
48 class QTabWidget;
49 class Bnd_Box;
50 class SOCC_Prs;
51
52 //=================================================================================
53 // class    : MeasureGUI_CreateDimensionDlg
54 // purpose  : Dialog invoked from MeasureGUI_ManageDimensionDlg for
55 //            creating dimension presentations for the passed onwer object.
56 //            Does not use operation logics.
57 //=================================================================================
58 class MeasureGUI_CreateDimensionDlg : public GEOMBase_Skeleton
59 {
60   Q_OBJECT
61
62   class BaseSelectorPane;
63   class LengthPane;
64   class DiameterPane;
65   class AnglePane;
66
67 public:
68   // Enumerate dimension type radio buttons
69   enum TypeButtonID
70   {
71     TypeButtonID_Length   = 0,
72     TypeButtonID_Diameter = 1,
73     TypeButtonID_Angle    = 2
74   };
75
76 public:
77   MeasureGUI_CreateDimensionDlg( const GEOM::GeomObjPtr&, GeometryGUI*, QWidget* );
78   ~MeasureGUI_CreateDimensionDlg();
79
80 public:
81   Handle(AIS_Dimension)               GetCreatedDimension() { return myDimension; }
82
83 public:
84   void                                Init();
85
86 /* User event logics */
87 protected slots:
88   void                                ConstructTypeChanged( int theType );
89   void                                OnArgumentTabChanged();
90   void                                OnStartSelection( const QList<TopAbs_ShapeEnum>& theModes );
91   void                                OnStopSelection();
92   void                                SelectionIntoArgument();
93   void                                OnSelectionDone();
94   void                                ClickOnOk();
95   bool                                ClickOnApply();
96
97 /* Commands */
98 protected:
99   void                                StartLocalEditing();
100   void                                StopLocalEditing();
101
102 /* Construction of preview and interaction */
103 protected:
104   Handle(AIS_Dimension)               CreateDimension();
105   GEOM::GeomObjPtr                    GetTopLevel( const GEOM::GeomObjPtr& theObject );
106   bool                                AddDimensionToOwner();
107
108 private:
109   BaseSelectorPane*                   ActiveArgs();
110
111 private:
112   QString                             GenerateName( const QString& thePrefix );
113
114 private:
115   GEOM::GeomObjPtr                    myParentObj;
116   LengthPane*                         myLengthArgs;
117   DiameterPane*                       myDiameterArgs;
118   AnglePane*                          myAngleArgs;
119   QList<TopAbs_ShapeEnum>             mySelectionModes;
120   MeasureGUI_DimensionInteractor*     myDimensionInteractor;
121   Handle(AIS_Dimension)               myDimension;
122   SOCC_Viewer*                        myEditingViewer;
123   int                                 myEditingLayer;
124 };
125
126 //=================================================================================
127 // class    : MeasureGUI_CreateDimensionDlg::BaseSelectorPane
128 // purpose  : Base selector pane handles events of switching the selector controls
129 //            and changing argument tabs
130 //=================================================================================
131 class MeasureGUI_CreateDimensionDlg::BaseSelectorPane : public QWidget
132 {
133   Q_OBJECT
134
135 public:
136   typedef QList<TopAbs_ShapeEnum> SelectionModes;
137
138 public:
139   BaseSelectorPane( QWidget* theParent );
140
141 signals:
142   void               StartSelection( const QList<TopAbs_ShapeEnum>& theModes );
143   void               StopSelection();
144   void               SelectionDone();
145   void               TabChanged();
146
147 public:
148   void               Reset( bool theOpenDefaultTab = false );
149   int                ActiveTab() const;
150   void               SelectionIntoArguments( const GEOM::GeomObjPtr& theSelected );
151   GEOM::GeomObjPtr   GetSelection( QLineEdit* theSelector ) const;
152
153 public slots:
154   void               OnSelectorClicked();
155   void               OnTabChanged();
156
157 protected:
158   void               SetTabWidget( QTabWidget* theTabs );
159
160   /* Register geometry selector controls at base level to provide
161      automatic handling of button clicks, selector switching and
162      sending start selection events to dialog.
163      - theSelectorEdit  : line edit control with selected geometry name.
164      - theSelectorButton: selector activation button.
165      - theSelectorModes : shape selection modes allowed for the selection.
166      - theTab : the tab index on which the controls are located. */
167   void               RegisterSelector( QLineEdit* theSelectorEdit,
168                                        QPushButton* theSelectorButton,
169                                        const SelectionModes& theSelectorModes,
170                                        const int theTab = 0 );
171
172 protected:
173   QTabWidget*                         myTabs;
174   QMap< int, QList<QLineEdit*> >      mySelectors;
175   QMap<QLineEdit*, QPushButton*>      mySelectionButtons;
176   QMap<QLineEdit*, SelectionModes>    mySelectionModes;
177   QMap<QLineEdit*, GEOM::GeomObjPtr>  mySelectedShapes;
178   QPixmap                             mySelectorIcon;
179   QLineEdit*                          myCurrentSelector;
180 };
181
182 //=================================================================================
183 // class    : MeasureGUI_CreateDimensionDlg::LengthPane
184 // purpose  : Layout for length arguments pane
185 //=================================================================================
186 class MeasureGUI_CreateDimensionDlg::LengthPane : public BaseSelectorPane
187 {
188   Q_OBJECT
189
190 public:
191   enum TabID
192   {
193     TabID_SingleEdge,
194     TabID_TwoPoints,
195     TabID_ParallelEdges
196   };
197
198 public:
199   LengthPane( QWidget* theParent );
200   GEOM::GeomObjPtr  GetSingleEdge() const { return GetSelection( mySingleEdgeSelectors->LineEdit1 ); }
201   GEOM::GeomObjPtr  GetPoint1() const     { return GetSelection( myTwoPointsSelectors->LineEdit1 ); }
202   GEOM::GeomObjPtr  GetPoint2() const     { return GetSelection( myTwoPointsSelectors->LineEdit2 ); }
203   GEOM::GeomObjPtr  GetEdge1() const      { return GetSelection( myParallelEdgesSelectors->LineEdit1 ); }
204   GEOM::GeomObjPtr  GetEdge2() const      { return GetSelection( myParallelEdgesSelectors->LineEdit2 ); }
205
206 private:
207   QTabWidget* myTabs;
208   MeasureGUI_1Sel_Frame*   mySingleEdgeSelectors;
209   MeasureGUI_2Sel_Frame*   myTwoPointsSelectors;
210   MeasureGUI_2Sel_Frame*   myParallelEdgesSelectors;
211 };
212
213 //=================================================================================
214 // class    : MeasureGUI_CreateDimensionDlg::DiameterPane
215 // purpose  : Layout for diameter arguments pane
216 //=================================================================================
217 class MeasureGUI_CreateDimensionDlg::DiameterPane : public BaseSelectorPane
218 {
219   Q_OBJECT
220
221 public:
222   DiameterPane( QWidget* theParent );
223   GEOM::GeomObjPtr  GetShape() const { return GetSelection( myShapeSelector->LineEdit1 ); }
224
225 private:
226   MeasureGUI_1Sel_Frame*   myShapeSelector;
227 };
228
229 //=================================================================================
230 // class    : MeasureGUI_CreateDimensionDlg::AnglePane
231 // purpose  : Layout for angle arguments pane
232 //=================================================================================
233 class MeasureGUI_CreateDimensionDlg::AnglePane : public BaseSelectorPane
234 {
235   Q_OBJECT
236
237 public:
238   enum TabID
239   {
240     TabID_TwoEdges,
241     TabID_ThreePoints
242   };
243
244 public:
245   AnglePane( QWidget* theParent );
246   GEOM::GeomObjPtr  GetEdge1() const  { return GetSelection( myTwoEdgesSelectors->LineEdit1 ); }
247   GEOM::GeomObjPtr  GetEdge2() const  { return GetSelection( myTwoEdgesSelectors->LineEdit2 ); }
248   GEOM::GeomObjPtr  GetPoint1() const { return GetSelection( myThreePointsSelectors->LineEdit1 ); }
249   GEOM::GeomObjPtr  GetPoint2() const { return GetSelection( myThreePointsSelectors->LineEdit2 ); }
250   GEOM::GeomObjPtr  GetPoint3() const { return GetSelection( myThreePointsSelectors->LineEdit3 ); }
251
252 private:
253   QTabWidget* myTabs;
254   MeasureGUI_2Sel_Frame*   myTwoEdgesSelectors;
255   MeasureGUI_3Sel_Frame*   myThreePointsSelectors;
256 };
257
258 #endif