1 // Copyright (C) 2007-2016 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_DimensionEditor.h
25 // Author : Anton POLETAEV, Open CASCADE S.A.S.
27 #ifndef MEASUREGUI_DIMENSIONINTERACTOR_H
28 #define MEASUREGUI_DIMENSIONINTERACTOR_H
30 #include <GeometryGUI.h>
33 #include <SelectMgr_EntityOwner.hxx>
34 #include <NCollection_Sequence.hxx>
35 #include <AIS_ListOfInteractive.hxx>
36 #include <AIS_InteractiveObject.hxx>
37 #include <AIS_Dimension.hxx>
38 #include <V3d_View.hxx>
41 class OCCViewer_ViewManager;
42 class OCCViewer_Viewer;
43 class SUIT_ViewWindow;
45 //=================================================================================
46 // class : MeasureGUI_DimensionInteractor
47 // purpose : Interactive editor of dimension presentations
48 //=================================================================================
49 class MeasureGUI_DimensionInteractor : public QObject
56 Operation_MoveFlyoutFree,
57 Operation_MoveFlyoutInPlane,
63 MeasureGUI_DimensionInteractor( GeometryGUI*, QObject* );
64 ~MeasureGUI_DimensionInteractor();
72 * \brief Identify interactive operation by picked entity and pressed buttons with modifiers
74 * \param theEntity [in] the picked entity.
75 * \param theButtons [in] the mouse buttons.
76 * \param theKeys [in] the keyboard modifiers.
78 Operation GetOperation( const Handle(SelectMgr_EntityOwner)& theEntity,
79 const Qt::MouseButtons theButtons,
80 const Qt::KeyboardModifiers theKeys );
83 * \brief Prepare for interactive operation.
85 * \param theOp [in] the operation.
86 * \param theView [in] the interacted view.
87 * \param theX [in] the mouse position x.
88 * \param theY [in] the mouse position y.
89 * \return TRUE if operation can be started.
91 bool StartOperation( const Operation theOperation,
92 const Handle(V3d_View)& theView,
97 * \brief Perform "Operation_MoveFlyoutFree".
98 * Modify flyout of interactive dimension so as the flyout follows
99 * the mouse by its length and orientation.
101 * \param theView [in] the interacted view.
102 * \param theX [in] the mouse position x.
103 * \param theY [in] the mouse position y.
105 void MoveFlyoutFree( const Handle(V3d_View)& theView, const int theX, const int theY );
108 * \brief Perform "Operation_MoveFlyoutInPlane".
109 * Modify flyout of interactive dimension so as the flyout is extended
110 * to the mouse point location in the presentation plane.
112 * \param theView [in] the interacted view.
113 * \param theX [in] the mouse position x.
114 * \param theY [in] the mouse position y.
116 void MoveFlyoutInPlane( const Handle(V3d_View)& theView, const int theX, const int theY );
119 * \brief Perform "Operation_MoveText".
120 * Modify text of interactive dimension so as the text is moved to its fixed positions.
122 * \param theView [in] the interacted view.
123 * \param theX [in] the mouse position x.
124 * \param theY [in] the mouse position y.
126 void MoveText( const Handle(V3d_View)& theView, const int theX, const int theY );
129 void InteractionStarted( Handle_AIS_InteractiveObject theIO );
130 void InteractionFinished( Handle_AIS_InteractiveObject theIO );
133 void ConnectView( SUIT_ViewWindow* );
134 void DisconnectView( SUIT_ViewWindow* );
135 gp_Lin Projection( const Handle(V3d_View)&, const int, const int );
136 gp_Pnt ProjectPlane( const Handle(V3d_View)&,
141 Standard_Real SensitivityTolerance( const Handle(V3d_View)& );
145 * \brief Process events from OCC viewer prior to their coming into the base viewer class.
147 * It handles the events coming to viewport and identifies whether the events correspond to
148 * interactive operation on dimension. If yes, the operation is performed within the
149 * interactor class and events are "accepted". Otherwise, the events are passed to
150 * viewer subroutines.
152 * The method manages internal workflow related to starting and stopping interactive
153 * operations to modify the presentations which were passed for this interactor class.
156 virtual bool eventFilter( QObject*, QEvent* );
159 void OnViewCreated( SUIT_ViewWindow* );
160 void OnViewRemoved( SUIT_ViewWindow* );
163 typedef NCollection_Sequence<Handle(SelectMgr_EntityOwner)> SeqOfOwners;
166 GeometryGUI* myGeomGUI;
168 OCCViewer_ViewManager* myVM;
169 OCCViewer_Viewer* myViewer;
170 Operation myOperation;
171 bool myOperationStarted;
172 gp_Pln myFreeMovePlane;
173 Handle(AIS_Dimension) myInteractedIO;
174 SeqOfOwners mySelection;