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 #ifndef OCCVIEWER_CLIPPLANEINTERACTOR_H
24 #define OCCVIEWER_CLIPPLANEINTERACTOR_H
26 #include "OCCViewer_ViewportInputFilter.h"
28 #include <AIS_Plane.hxx>
29 #include <Bnd_Box.hxx>
37 #include <V3d_View.hxx>
40 \class OCCViewer_ClipPlaneInteractor.
41 \brief The class provides mouse dragging operations with AIS_Plane:
42 1) Sliding plane by dragging it with point
43 2) Rotating plane around one or both of the rotation axes by
44 dragging its point with "ctrl" key pressed.
46 class OCCViewer_ClipPlaneInteractor : public OCCViewer_ViewportInputFilter
51 typedef std::vector<Handle(AIS_Plane)> SeqOfPlanes;
53 // Performing interactive operation.
54 // - Slide: The picked point on plane is dragged along the normal of the plane.
55 // - Rotate: The picked point on plane is dragged around one of the specified rotation
56 // axes ("x", "y" axes of the plane coordinate system, or two orthogonal arbitrary
57 // specified ones). When starting the rotation a corresponding axis is
58 // choosen depending on the direction of dragging. The axis is selected in
59 // the following way: a virtual "arm" is constructed from center of
60 // rotation to picking point. The dragging directions are constructed for
61 // both of the rotation axes, then the direction which is "easiest to
62 // turn" is selected (e.g. the "arm" projection is largest for that axis,
63 // the direction of dragging is closer to orthogonal one for the axis).
72 OCCViewer_ClipPlaneInteractor( OCCViewer_ViewManager*, QObject* theParent );
74 const SeqOfPlanes& planes() const;
75 void setPlanes( const SeqOfPlanes& );
76 void setRotationCenter( const gp_Pnt& );
77 void setMinMax( const Bnd_Box& );
78 virtual void setEnabled( const bool );
81 void planeClicked( const Handle_AIS_Plane& thePlane );
82 void planeDragged( const Handle_AIS_Plane& thePlane );
85 bool isClickable( const Handle(AIS_Plane)& thePlane );
86 bool isDraggable( const Handle(AIS_Plane)& thePlane );
87 bool isPerforming() const;
88 bool startDragging( const QPoint& thePickPos,
89 const QPoint& theDragPos,
90 const DragOperation theOperation,
91 const Handle(AIS_Plane)& thePlane,
92 const Handle(V3d_View)& theView );
93 void performDragging( const QPoint& theDragPos,
94 const DragOperation theOperation,
95 const Handle(AIS_Plane)& thePlane,
96 const Handle(V3d_View)& theView );
97 void adjustBounds( gp_Ax3&, const Bnd_Box& );
100 virtual bool mouseMove( QMouseEvent*, OCCViewer_ViewPort3d* );
101 virtual bool mousePress( QMouseEvent*, OCCViewer_ViewPort3d* );
102 virtual bool mouseRelease( QMouseEvent*, OCCViewer_ViewPort3d* );
103 virtual bool mouseDoubleClick( QMouseEvent*, OCCViewer_ViewPort3d* );
104 virtual bool keyPress( QKeyEvent*, OCCViewer_ViewPort3d* );
105 virtual bool keyRelease( QKeyEvent*, OCCViewer_ViewPort3d* );
109 gp_Ax3 myPlaneReferenceCS;
110 gp_Ax1 myRotationAxis;
111 gp_Pln myMouseDragPln;
114 DragOperation myPerformingOp;
115 gp_Pnt myRotationCenter;
117 Handle(AIS_Plane) myInteractedPlane;
118 SeqOfPlanes myPlanes;