Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MeasureGUI_CreateDimensionDlg.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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"
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 
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 //=================================================================================
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
70  {
74  };
75 
76 public:
79 
80 public:
81  Handle(AIS_Dimension) GetCreatedDimension() { return myDimension; }
82 
83 public:
84  void Init();
85 
86 
87 signals:
88  void applyClicked();
89 
90 /* User event logics */
91 protected slots:
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();
98  void ClickOnOk();
99  bool ClickOnApply();
100 
101 /* Commands */
102 protected:
103  void StartLocalEditing();
104  void StopLocalEditing();
105 
106 /* Construction of preview and interaction */
107 protected:
108  Handle(AIS_Dimension) CreateDimension();
109  GEOM::GeomObjPtr GetTopLevel( const GEOM::GeomObjPtr& theObject );
110  bool AddDimensionToOwner();
111 
112 private:
113  BaseSelectorPane* ActiveArgs();
114 
115 private:
116  QString GenerateName( const QString& thePrefix );
117 
118 private:
123  QList<TopAbs_ShapeEnum> mySelectionModes;
125  Handle(AIS_Dimension) myDimension;
126  SOCC_Viewer* myEditingViewer;
128 };
129 
130 //=================================================================================
131 // class : MeasureGUI_CreateDimensionDlg::BaseSelectorPane
132 // purpose : Base selector pane handles events of switching the selector controls
133 // and changing argument tabs
134 //=================================================================================
136 {
137  Q_OBJECT
138 
139 public:
140  typedef QList<TopAbs_ShapeEnum> SelectionModes;
141 
142 public:
143  BaseSelectorPane( QWidget* theParent );
144 
145 signals:
146  void StartSelection( const QList<TopAbs_ShapeEnum>& theModes );
147  void StopSelection();
148  void SelectionDone();
149  void TabChanged();
150 
151 public:
152  void Reset( bool theOpenDefaultTab = false );
153  int ActiveTab() const;
154  void SelectionIntoArguments( const GEOM::GeomObjPtr& theSelected );
155  GEOM::GeomObjPtr GetSelection( QLineEdit* theSelector ) const;
156 
157 public slots:
158  void OnSelectorClicked();
159  void OnTabChanged();
160 
161 protected:
162  void SetTabWidget( QTabWidget* theTabs );
163 
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 );
175 
176 protected:
177  QTabWidget* myTabs;
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;
184 };
185 
186 //=================================================================================
187 // class : MeasureGUI_CreateDimensionDlg::LengthPane
188 // purpose : Layout for length arguments pane
189 //=================================================================================
191 {
192  Q_OBJECT
193 
194 public:
195  enum TabID
196  {
199  TabID_ParallelEdges
200  };
201 
202 public:
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 ); }
209 
210 private:
211  QTabWidget* myTabs;
215 };
216 
217 //=================================================================================
218 // class : MeasureGUI_CreateDimensionDlg::DiameterPane
219 // purpose : Layout for diameter arguments pane
220 //=================================================================================
222 {
223  Q_OBJECT
224 
225 public:
226  DiameterPane( QWidget* theParent );
227  GEOM::GeomObjPtr GetShape() const { return GetSelection( myShapeSelector->LineEdit1 ); }
228 
229 private:
231 };
232 
233 //=================================================================================
234 // class : MeasureGUI_CreateDimensionDlg::AnglePane
235 // purpose : Layout for angle arguments pane
236 //=================================================================================
238 {
239  Q_OBJECT
240 
241 public:
242  enum TabID
243  {
245  TabID_ThreePoints
246  };
247 
248 public:
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 ); }
255 
256 private:
257  QTabWidget* myTabs;
260 };
261 
262 #endif