Version: 9.16.0
OCCViewer_ClipPlaneInteractor.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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
50public:
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
71public:
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
80signals:
81 void planeClicked( const Handle_AIS_Plane& thePlane );
82 void planeDragged( const Handle_AIS_Plane& thePlane );
83
84protected:
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
99protected:
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
107protected:
108
112 QPoint myDragPos;
113 QPoint myPickPos;
116 Bnd_Box myMinMax;
117 Handle(AIS_Plane) myInteractedPlane;
121};
122
123#endif
The class provides mouse dragging operations with AIS_Plane: 1) Sliding plane by dragging it with poi...
Definition: OCCViewer_ClipPlaneInteractor.h:47
void planeClicked(const Handle_AIS_Plane &thePlane)
DragOperation
Definition: OCCViewer_ClipPlaneInteractor.h:65
@ DragOperation_Undef
Definition: OCCViewer_ClipPlaneInteractor.h:66
@ DragOperation_Slide
Definition: OCCViewer_ClipPlaneInteractor.h:67
@ DragOperation_Rotate
Definition: OCCViewer_ClipPlaneInteractor.h:68
virtual bool keyRelease(QKeyEvent *, OCCViewer_ViewPort3d *)
Handle key releasing events. Stops the event propagation if interaction with plane is in progress.
Definition: OCCViewer_ClipPlaneInteractor.cxx:680
bool startDragging(const QPoint &thePickPos, const QPoint &theDragPos, const DragOperation theOperation, const Handle(AIS_Plane)&thePlane, const Handle(V3d_View)&theView)
Checks whether it is possible to start interaction with plane.
Definition: OCCViewer_ClipPlaneInteractor.cxx:191
bool isPerforming() const
Checks whether the interactive operation is in progress.
Definition: OCCViewer_ClipPlaneInteractor.cxx:116
virtual bool keyPress(QKeyEvent *, OCCViewer_ViewPort3d *)
Handle key pressing events. Stops the event propagation if interaction with plane is in progress.
Definition: OCCViewer_ClipPlaneInteractor.cxx:650
SeqOfPlanes myPlanes
Definition: OCCViewer_ClipPlaneInteractor.h:118
gp_Pln myMouseDragPln
Definition: OCCViewer_ClipPlaneInteractor.h:111
virtual bool mousePress(QMouseEvent *, OCCViewer_ViewPort3d *)
Handle mouse press events. Starts interaction with detected plane.
Definition: OCCViewer_ClipPlaneInteractor.cxx:495
bool myIsClickable
Definition: OCCViewer_ClipPlaneInteractor.h:120
virtual bool mouseMove(QMouseEvent *, OCCViewer_ViewPort3d *)
Handle mouse move events. Performs dragging if interaction is in progress.
Definition: OCCViewer_ClipPlaneInteractor.cxx:557
void planeDragged(const Handle_AIS_Plane &thePlane)
bool isDraggable(const Handle(AIS_Plane)&thePlane)
Checks whether the interactive plane can be dragged.
Definition: OCCViewer_ClipPlaneInteractor.cxx:156
virtual bool mouseDoubleClick(QMouseEvent *, OCCViewer_ViewPort3d *)
Handle mouse double clicking events events. Stops the event propagation if interaction with plane is ...
Definition: OCCViewer_ClipPlaneInteractor.cxx:638
Handle(AIS_Plane) myInteractedPlane
void setRotationCenter(const gp_Pnt &)
Sets center of rotation for the scene.
Definition: OCCViewer_ClipPlaneInteractor.cxx:75
Bnd_Box myMinMax
Definition: OCCViewer_ClipPlaneInteractor.h:116
gp_Ax3 myPlaneReferenceCS
Definition: OCCViewer_ClipPlaneInteractor.h:109
OCCViewer_ClipPlaneInteractor(OCCViewer_ViewManager *, QObject *theParent)
Constructor.
Definition: OCCViewer_ClipPlaneInteractor.cxx:43
void adjustBounds(gp_Ax3 &, const Bnd_Box &)
Adjusts min-max bounds of the plane.
Definition: OCCViewer_ClipPlaneInteractor.cxx:471
bool myIsDraggable
Definition: OCCViewer_ClipPlaneInteractor.h:119
void performDragging(const QPoint &theDragPos, const DragOperation theOperation, const Handle(AIS_Plane)&thePlane, const Handle(V3d_View)&theView)
Performs dragging operation on the passed interactive plane.
Definition: OCCViewer_ClipPlaneInteractor.cxx:371
bool isClickable(const Handle(AIS_Plane)&thePlane)
Checks whether the interactive plane can be clicked.
Definition: OCCViewer_ClipPlaneInteractor.cxx:125
gp_Pnt myRotationCenter
Definition: OCCViewer_ClipPlaneInteractor.h:115
QPoint myDragPos
Definition: OCCViewer_ClipPlaneInteractor.h:112
std::vector< Handle(AIS_Plane)> SeqOfPlanes
Definition: OCCViewer_ClipPlaneInteractor.h:51
DragOperation myPerformingOp
Definition: OCCViewer_ClipPlaneInteractor.h:114
gp_Ax1 myRotationAxis
Definition: OCCViewer_ClipPlaneInteractor.h:110
virtual void setEnabled(const bool)
Enables or disables event processing within the viewer.
Definition: OCCViewer_ClipPlaneInteractor.cxx:94
void setPlanes(const SeqOfPlanes &)
Sets sequence of planes allowed for interaction.
Definition: OCCViewer_ClipPlaneInteractor.cxx:66
void setMinMax(const Bnd_Box &)
Sets minimum and maximum bounding of the scene. The sliding movements are limited to minimum and maxi...
Definition: OCCViewer_ClipPlaneInteractor.cxx:86
virtual bool mouseRelease(QMouseEvent *, OCCViewer_ViewPort3d *)
Handle mouse release events. Stops interaction.
Definition: OCCViewer_ClipPlaneInteractor.cxx:613
const SeqOfPlanes & planes() const
Get sequence of planes to interact with.
Definition: OCCViewer_ClipPlaneInteractor.cxx:57
QPoint myPickPos
Definition: OCCViewer_ClipPlaneInteractor.h:113
Definition: OCCViewer_ViewManager.h:33
Definition: OCCViewer_ViewPort3d.h:43
The user input filter of OCC viewports. The class can be used to introduce custom interactive operati...
Definition: OCCViewer_ViewportInputFilter.h:48
For more information see QT documentation.