Easy3D 2.6.1
Loading...
Searching...
No Matches
manipulated_frame.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
38
39#ifndef EASY3D_RENDERER_MANIPULATED_FRAME_H
40#define EASY3D_RENDERER_MANIPULATED_FRAME_H
41
42#include <easy3d/renderer/frame.h>
43
44
45namespace easy3d {
46
56 class ManipulatedFrame : public Frame
57 {
58 public:
64 ~ManipulatedFrame() override = default;
76
77
80 public:
85 void setRotationSensitivity(float sensitivity) {
86 rotationSensitivity_ = sensitivity;
87 }
88
92 void setTranslationSensitivity(float sensitivity) {
93 translationSensitivity_ = sensitivity;
94 }
95
99 void setWheelSensitivity(float sensitivity) {
100 wheelSensitivity_ = sensitivity;
101 }
102
106 void setZoomSensitivity(float sensitivity) { zoomSensitivity_ = sensitivity; }
107
108 public:
118 float rotationSensitivity() const { return rotationSensitivity_; }
119
130 float translationSensitivity() const { return translationSensitivity_; }
138 float zoomSensitivity() const { return zoomSensitivity_; }
146 float wheelSensitivity() const { return wheelSensitivity_; }
148
151 public:
156 virtual void action_start();
161 virtual void action_end();
162
170
179 virtual void action_rotate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera* camera, ScreenAxis axis);
189 virtual void action_translate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera* camera, ScreenAxis axis);
195 virtual void action_zoom(int dy_wheel, Camera* camera);
196 // @}
197
198 protected:
199 /* Returns a quaternion computed according to the mouse motion. Mouse positions
200 are projected on a deformed ball, centered on (\p cx,\p cy), viewer size (\p w, \p h).*/
201 quat deformedBallQuaternion(int x, int y, int pre_x, int pre_y, float cx, float cy, int w, int h) const;
202
203 Constraint *previousConstraint_; // When manipulation is without constraint.
204
205 /* Returns a normalized wheel delta, proportional to wheelSensitivity(). */
206 float wheelDelta(int wheel_dy) const;
207
208 private:
209 // Sensitivity
210 float rotationSensitivity_;
211 float translationSensitivity_;
212 float wheelSensitivity_;
213 float zoomSensitivity_;
214
215 private:
216 friend class Viewer;
217 };
218
219}
220
221
222#endif // EASY3D_RENDERER_MANIPULATED_FRAME_H
A perspective or orthographic camera.
Definition camera.h:113
An interface class for Frame constraints.
Definition constraint.h:140
Frame()
Default constructor.
float zoomSensitivity() const
Returns the zoom sensitivity.
Definition manipulated_frame.h:138
ManipulatedFrame()
Default constructor.
void setRotationSensitivity(float sensitivity)
Sets the rotation sensitivity.
Definition manipulated_frame.h:85
float wheelSensitivity() const
Returns the wheel sensitivity.
Definition manipulated_frame.h:146
virtual void action_translate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
Translates the frame based on mouse movement.
ScreenAxis
ScreenAxis constrains rotation or translation around/along the axis.
Definition manipulated_frame.h:164
@ VERTICAL
Vertical constraint.
Definition manipulated_frame.h:167
@ HORIZONTAL
Horizontal constraint.
Definition manipulated_frame.h:166
@ ORTHOGONAL
Orthogonal constraint.
Definition manipulated_frame.h:168
@ NONE
No constraint.
Definition manipulated_frame.h:165
void setZoomSensitivity(float sensitivity)
Sets the zoom sensitivity.
Definition manipulated_frame.h:106
ManipulatedFrame(const ManipulatedFrame &mf)
Copy constructor.
float translationSensitivity() const
Returns the translation sensitivity.
Definition manipulated_frame.h:130
void setTranslationSensitivity(float sensitivity)
Sets the translation sensitivity.
Definition manipulated_frame.h:92
virtual void action_start()
Initiates the ManipulatedFrame mouse manipulation.
ManipulatedFrame & operator=(const ManipulatedFrame &mf)
Copy assignment operator.
virtual void action_rotate(int mouse_x, int mouse_y, int mouse_dx, int mouse_dy, Camera *camera, ScreenAxis axis)
Rotates the frame based on mouse movement.
float rotationSensitivity() const
Returns the rotation sensitivity.
Definition manipulated_frame.h:118
virtual void action_end()
Stops the ManipulatedFrame mouse manipulation.
~ManipulatedFrame() override=default
void setWheelSensitivity(float sensitivity)
Sets the wheel sensitivity.
Definition manipulated_frame.h:99
virtual void action_zoom(int dy_wheel, Camera *camera)
Zooms the frame based on mouse wheel movement.
Definition collider.cpp:182
Quat< float > quat
A quaternion of float type.
Definition types.h:85