1 // Copyright (C) 2007-2020 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>
34 #include <SelectMgr_EntityOwner.hxx>
35 #include <NCollection_Sequence.hxx>
36 #include <AIS_ListOfInteractive.hxx>
37 #include <AIS_InteractiveObject.hxx>
38 #include <AIS_Dimension.hxx>
39 #include <V3d_View.hxx>
42 class OCCViewer_ViewManager;
43 class OCCViewer_Viewer;
44 class SUIT_ViewWindow;
46 //=================================================================================
47 // class : MeasureGUI_DimensionInteractor
48 // purpose : Interactive editor of dimension presentations
49 //=================================================================================
50 class MeasureGUI_DimensionInteractor : public QObject
57 Operation_MoveFlyoutFree,
58 Operation_MoveFlyoutInPlane,
64 MeasureGUI_DimensionInteractor( GeometryGUI*, QObject* );
65 ~MeasureGUI_DimensionInteractor();
73 * \brief Identify interactive operation by picked entity and pressed buttons with modifiers
75 * \param theEntity [in] the picked entity.
76 * \param theButtons [in] the mouse buttons.
77 * \param theKeys [in] the keyboard modifiers.
79 Operation GetOperation( const Handle(SelectMgr_EntityOwner)& theEntity,
80 const Qt::MouseButtons theButtons,
81 const Qt::KeyboardModifiers theKeys );
84 * \brief Prepare for interactive operation.
86 * \param theOp [in] the operation.
87 * \param theView [in] the interacted view.
88 * \param theX [in] the mouse position x.
89 * \param theY [in] the mouse position y.
90 * \return TRUE if operation can be started.
92 bool StartOperation( const Operation theOperation,
93 const Handle(V3d_View)& theView,
98 * \brief Perform "Operation_MoveFlyoutFree".
99 * Modify flyout of interactive dimension so as the flyout follows
100 * the mouse by its length and orientation.
102 * \param theView [in] the interacted view.
103 * \param theX [in] the mouse position x.
104 * \param theY [in] the mouse position y.
106 void MoveFlyoutFree( const Handle(V3d_View)& theView, const int theX, const int theY );
109 * \brief Perform "Operation_MoveFlyoutInPlane".
110 * Modify flyout of interactive dimension so as the flyout is extended
111 * to the mouse point location in the presentation plane.
113 * \param theView [in] the interacted view.
114 * \param theX [in] the mouse position x.
115 * \param theY [in] the mouse position y.
117 void MoveFlyoutInPlane( const Handle(V3d_View)& theView, const int theX, const int theY );
120 * \brief Perform "Operation_MoveText".
121 * Modify text of interactive dimension so as the text is moved to its fixed positions.
123 * \param theView [in] the interacted view.
124 * \param theX [in] the mouse position x.
125 * \param theY [in] the mouse position y.
127 void MoveText( const Handle(V3d_View)& theView, const int theX, const int theY );
130 void InteractionStarted( Handle_AIS_InteractiveObject theIO );
131 void InteractionFinished( Handle_AIS_InteractiveObject theIO );
134 void ConnectView( SUIT_ViewWindow* );
135 void DisconnectView( SUIT_ViewWindow* );
136 gp_Lin Projection( const Handle(V3d_View)&, const int, const int );
137 gp_Pnt ProjectPlane( const Handle(V3d_View)&,
142 Standard_Real SensitivityTolerance( const Handle(V3d_View)& );
146 * \brief Process events from OCC viewer prior to their coming into the base viewer class.
148 * It handles the events coming to viewport and identifies whether the events correspond to
149 * interactive operation on dimension. If yes, the operation is performed within the
150 * interactor class and events are "accepted". Otherwise, the events are passed to
151 * viewer subroutines.
153 * The method manages internal workflow related to starting and stopping interactive
154 * operations to modify the presentations which were passed for this interactor class.
157 virtual bool eventFilter( QObject*, QEvent* );
160 void OnViewCreated( SUIT_ViewWindow* );
161 void OnViewRemoved( SUIT_ViewWindow* );
164 typedef NCollection_Sequence<Handle(SelectMgr_EntityOwner)> SeqOfOwners;
167 GeometryGUI* myGeomGUI;
169 QPointer<OCCViewer_ViewManager> myVM;
170 OCCViewer_Viewer* myViewer;
171 Operation myOperation;
172 bool myOperationStarted;
173 gp_Pln myFreeMovePlane;
174 Handle(AIS_Dimension) myInteractedIO;
175 SeqOfOwners mySelection;