1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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; }
90 /* User event logics */
92 void ConstructTypeChanged( int theType );
93 void OnArgumentTabChanged();
94 void OnStartSelection( const QList<TopAbs_ShapeEnum>& theModes );
95 void OnStopSelection();
96 void SelectionIntoArgument();
97 void OnSelectionDone();
103 void StartLocalEditing();
104 void StopLocalEditing();
106 /* Construction of preview and interaction */
108 Handle(AIS_Dimension) CreateDimension();
109 GEOM::GeomObjPtr GetTopLevel( const GEOM::GeomObjPtr& theObject );
110 bool AddDimensionToOwner();
113 BaseSelectorPane* ActiveArgs();
116 QString GenerateName( const QString& thePrefix );
119 GEOM::GeomObjPtr myParentObj;
120 LengthPane* myLengthArgs;
121 DiameterPane* myDiameterArgs;
122 AnglePane* myAngleArgs;
123 QList<TopAbs_ShapeEnum> mySelectionModes;
124 MeasureGUI_DimensionInteractor* myDimensionInteractor;
125 Handle(AIS_Dimension) myDimension;
126 SOCC_Viewer* myEditingViewer;
130 //=================================================================================
131 // class : MeasureGUI_CreateDimensionDlg::BaseSelectorPane
132 // purpose : Base selector pane handles events of switching the selector controls
133 // and changing argument tabs
134 //=================================================================================
135 class MeasureGUI_CreateDimensionDlg::BaseSelectorPane : public QWidget
140 typedef QList<TopAbs_ShapeEnum> SelectionModes;
143 BaseSelectorPane( QWidget* theParent );
146 void StartSelection( const QList<TopAbs_ShapeEnum>& theModes );
147 void StopSelection();
148 void SelectionDone();
152 void Reset( bool theOpenDefaultTab = false );
153 int ActiveTab() const;
154 void SelectionIntoArguments( const GEOM::GeomObjPtr& theSelected );
155 GEOM::GeomObjPtr GetSelection( QLineEdit* theSelector ) const;
158 void OnSelectorClicked();
162 void SetTabWidget( QTabWidget* theTabs );
164 /* Register geometry selector controls at base level to provide
165 automatic handling of button clicks, selector switching and
166 sending start selection events to dialog.
167 - theSelectorEdit : line edit control with selected geometry name.
168 - theSelectorButton: selector activation button.
169 - theSelectorModes : shape selection modes allowed for the selection.
170 - theTab : the tab index on which the controls are located. */
171 void RegisterSelector( QLineEdit* theSelectorEdit,
172 QPushButton* theSelectorButton,
173 const SelectionModes& theSelectorModes,
174 const int theTab = 0 );
178 QMap< int, QList<QLineEdit*> > mySelectors;
179 QMap<QLineEdit*, QPushButton*> mySelectionButtons;
180 QMap<QLineEdit*, SelectionModes> mySelectionModes;
181 QMap<QLineEdit*, GEOM::GeomObjPtr> mySelectedShapes;
182 QPixmap mySelectorIcon;
183 QLineEdit* myCurrentSelector;
186 //=================================================================================
187 // class : MeasureGUI_CreateDimensionDlg::LengthPane
188 // purpose : Layout for length arguments pane
189 //=================================================================================
190 class MeasureGUI_CreateDimensionDlg::LengthPane : public BaseSelectorPane
203 LengthPane( QWidget* theParent );
204 GEOM::GeomObjPtr GetSingleEdge() const { return GetSelection( mySingleEdgeSelectors->LineEdit1 ); }
205 GEOM::GeomObjPtr GetPoint1() const { return GetSelection( myTwoPointsSelectors->LineEdit1 ); }
206 GEOM::GeomObjPtr GetPoint2() const { return GetSelection( myTwoPointsSelectors->LineEdit2 ); }
207 GEOM::GeomObjPtr GetEdge1() const { return GetSelection( myParallelEdgesSelectors->LineEdit1 ); }
208 GEOM::GeomObjPtr GetEdge2() const { return GetSelection( myParallelEdgesSelectors->LineEdit2 ); }
212 MeasureGUI_1Sel_Frame* mySingleEdgeSelectors;
213 MeasureGUI_2Sel_Frame* myTwoPointsSelectors;
214 MeasureGUI_2Sel_Frame* myParallelEdgesSelectors;
217 //=================================================================================
218 // class : MeasureGUI_CreateDimensionDlg::DiameterPane
219 // purpose : Layout for diameter arguments pane
220 //=================================================================================
221 class MeasureGUI_CreateDimensionDlg::DiameterPane : public BaseSelectorPane
226 DiameterPane( QWidget* theParent );
227 GEOM::GeomObjPtr GetShape() const { return GetSelection( myShapeSelector->LineEdit1 ); }
230 MeasureGUI_1Sel_Frame* myShapeSelector;
233 //=================================================================================
234 // class : MeasureGUI_CreateDimensionDlg::AnglePane
235 // purpose : Layout for angle arguments pane
236 //=================================================================================
237 class MeasureGUI_CreateDimensionDlg::AnglePane : public BaseSelectorPane
249 AnglePane( QWidget* theParent );
250 GEOM::GeomObjPtr GetEdge1() const { return GetSelection( myTwoEdgesSelectors->LineEdit1 ); }
251 GEOM::GeomObjPtr GetEdge2() const { return GetSelection( myTwoEdgesSelectors->LineEdit2 ); }
252 GEOM::GeomObjPtr GetPoint1() const { return GetSelection( myThreePointsSelectors->LineEdit1 ); }
253 GEOM::GeomObjPtr GetPoint2() const { return GetSelection( myThreePointsSelectors->LineEdit2 ); }
254 GEOM::GeomObjPtr GetPoint3() const { return GetSelection( myThreePointsSelectors->LineEdit3 ); }
258 MeasureGUI_2Sel_Frame* myTwoEdgesSelectors;
259 MeasureGUI_3Sel_Frame* myThreePointsSelectors;