1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : MeasureGUI_CreateDimensionDlg.h
25 // Author : Anton POLETAEV, Open CASCADE S.A.S.
27 #ifndef MEASUREGUI_CREATEDIMENSIONDLG_H
28 #define MEASUREGUI_CREATEDIMENSIONDLG_H
30 #include "MeasureGUI_Widgets.h"
31 #include "MeasureGUI_DimensionInteractor.h"
34 #include <GEOMBase_Skeleton.h>
35 #include <GEOM_GenericObjPtr.h>
38 #include <SOCC_ViewModel.h>
41 #include <AIS_Dimension.hxx>
44 class MeasureGUI_1Sel_Frame;
45 class MeasureGUI_2Sel_Frame;
46 class MeasureGUI_3Sel_Frame;
47 class QAbstractButton;
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
62 class BaseSelectorPane;
68 // Enumerate dimension type radio buttons
71 TypeButtonID_Length = 0,
72 TypeButtonID_Diameter = 1,
73 TypeButtonID_Angle = 2
77 MeasureGUI_CreateDimensionDlg( const GEOM::GeomObjPtr&, GeometryGUI*, QWidget* );
78 ~MeasureGUI_CreateDimensionDlg();
81 Handle(AIS_Dimension) GetCreatedDimension() { return myDimension; }
86 /* User event logics */
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();
99 void StartLocalEditing();
100 void StopLocalEditing();
102 /* Construction of preview and interaction */
104 Handle(AIS_Dimension) CreateDimension();
105 GEOM::GeomObjPtr GetTopLevel( const GEOM::GeomObjPtr& theObject );
106 bool AddDimensionToOwner();
109 BaseSelectorPane* ActiveArgs();
112 QString GenerateName( const QString& thePrefix );
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;
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
136 typedef QList<TopAbs_ShapeEnum> SelectionModes;
139 BaseSelectorPane( QWidget* theParent );
142 void StartSelection( const QList<TopAbs_ShapeEnum>& theModes );
143 void StopSelection();
144 void SelectionDone();
148 void Reset( bool theOpenDefaultTab = false );
149 int ActiveTab() const;
150 void SelectionIntoArguments( const GEOM::GeomObjPtr& theSelected );
151 GEOM::GeomObjPtr GetSelection( QLineEdit* theSelector ) const;
154 void OnSelectorClicked();
158 void SetTabWidget( QTabWidget* theTabs );
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 );
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;
182 //=================================================================================
183 // class : MeasureGUI_CreateDimensionDlg::LengthPane
184 // purpose : Layout for length arguments pane
185 //=================================================================================
186 class MeasureGUI_CreateDimensionDlg::LengthPane : public BaseSelectorPane
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 ); }
208 MeasureGUI_1Sel_Frame* mySingleEdgeSelectors;
209 MeasureGUI_2Sel_Frame* myTwoPointsSelectors;
210 MeasureGUI_2Sel_Frame* myParallelEdgesSelectors;
213 //=================================================================================
214 // class : MeasureGUI_CreateDimensionDlg::DiameterPane
215 // purpose : Layout for diameter arguments pane
216 //=================================================================================
217 class MeasureGUI_CreateDimensionDlg::DiameterPane : public BaseSelectorPane
222 DiameterPane( QWidget* theParent );
223 GEOM::GeomObjPtr GetShape() const { return GetSelection( myShapeSelector->LineEdit1 ); }
226 MeasureGUI_1Sel_Frame* myShapeSelector;
229 //=================================================================================
230 // class : MeasureGUI_CreateDimensionDlg::AnglePane
231 // purpose : Layout for angle arguments pane
232 //=================================================================================
233 class MeasureGUI_CreateDimensionDlg::AnglePane : public BaseSelectorPane
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 ); }
254 MeasureGUI_2Sel_Frame* myTwoEdgesSelectors;
255 MeasureGUI_3Sel_Frame* myThreePointsSelectors;