Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OCCViewer_ClipPlaneInteractor.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 #ifndef OCCVIEWER_CLIPPLANEINTERACTOR_H
24 #define OCCVIEWER_CLIPPLANEINTERACTOR_H
25 
27 
28 #include <AIS_Plane.hxx>
29 #include <Bnd_Box.hxx>
30 #include <gp_Pln.hxx>
31 #include <gp_Ax3.hxx>
32 
33 #include <QPoint>
34 
35 #include <vector>
36 
37 #include <V3d_View.hxx>
38 
47 {
48  Q_OBJECT
49 
50 public:
51  typedef std::vector<Handle(AIS_Plane)> SeqOfPlanes;
52 
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).
65  {
69  };
70 
71 public:
73 
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 );
79 
80 signals:
81  void planeClicked( const Handle_AIS_Plane& thePlane );
82  void planeDragged( const Handle_AIS_Plane& thePlane );
83 
84 protected:
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& );
98 
99 protected:
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* );
106 
107 protected:
108 
112  QPoint myDragPos;
113  QPoint myPickPos;
116  Bnd_Box myMinMax;
117  Handle(AIS_Plane) myInteractedPlane;
121 };
122 
123 #endif