Blue Brain BioExplorer
InspectCenterManipulator.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  *
4  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
5  * scientific data from visualization
6  *
7  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
8  *
9  * This program is free software: you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License as published by the Free Software
11  * Foundation, either version 3 of the License, or (at your option) any later
12  * version.
13  *
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License along with
20  * this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
23 
25 
28 
29 namespace core
30 {
32  : AbstractManipulator{camera, handler}
33 {
34  _keyboardHandler.registerKeyboardShortcut('a', "Rotate left",
35  std::bind(&InspectCenterManipulator::_rotateLeft, this));
36  _keyboardHandler.registerKeyboardShortcut('d', "Rotate right",
37  std::bind(&InspectCenterManipulator::_rotateRight, this));
38  _keyboardHandler.registerKeyboardShortcut('w', "Rotate up", std::bind(&InspectCenterManipulator::_rotateUp, this));
39  _keyboardHandler.registerKeyboardShortcut('s', "Rotate down",
40  std::bind(&InspectCenterManipulator::_rotateDown, this));
41 
43  std::bind(&InspectCenterManipulator::_turnLeft, this));
45  std::bind(&InspectCenterManipulator::_turnRight, this));
46  _keyboardHandler.registerSpecialKey(SpecialKey::UP, "Turn up", std::bind(&InspectCenterManipulator::_turnUp, this));
48  std::bind(&InspectCenterManipulator::_turnDown, this));
49 }
50 
52 {
57 
62 }
63 
64 void InspectCenterManipulator::dragLeft(const Vector2i& to, const Vector2i& from)
65 {
66  const float du = (to.x - from.x) * DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER * getRotationSpeed();
67  const float dv = (to.y - from.y) * DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER * getRotationSpeed();
69 }
70 
71 void InspectCenterManipulator::dragRight(const Vector2i& to, const Vector2i& from)
72 {
73  const float distance = -(to.y - from.y) * DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER * getMotionSpeed();
74  if (distance < glm::length(_camera.getTarget() - _camera.getPosition()))
75  translate(Vector3f(0, 0, -1) * distance);
76 }
77 
78 void InspectCenterManipulator::dragMiddle(const Vector2i& to, const Vector2i& from)
79 {
80  const float x = (to.x - from.x) * DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER * getMotionSpeed();
81  const float y = (to.y - from.y) * DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER * getMotionSpeed();
82  const Vector3d translation(-x, y, 0);
83  translate(translation);
84  _camera.setTarget(_camera.getTarget() + glm::rotate(_camera.getOrientation(), translation));
85 }
86 
87 void InspectCenterManipulator::wheel(const Vector2i& /*position*/, float delta)
88 {
89  delta *= getWheelSpeed();
90  if (delta < glm::length(_camera.getTarget() - _camera.getPosition()))
91  translate(Vector3f(0, 0, -1) * delta);
92 }
93 
94 void InspectCenterManipulator::_rotateLeft()
95 {
97 }
98 
99 void InspectCenterManipulator::_rotateRight()
100 {
102 }
103 
104 void InspectCenterManipulator::_rotateUp()
105 {
107 }
108 
109 void InspectCenterManipulator::_rotateDown()
110 {
112 }
113 
114 void InspectCenterManipulator::_turnLeft()
115 {
117 }
118 
119 void InspectCenterManipulator::_turnRight()
120 {
122 }
123 
124 void InspectCenterManipulator::_turnUp()
125 {
127 }
128 
129 void InspectCenterManipulator::_turnDown()
130 {
132 }
133 } // namespace core
constexpr float DEFAULT_MOUSE_MOTION_SPEED_MULTIPLIER
void rotate(const Vector3d &pivot, double du, double dv, AxisMode axisMode)
KeyboardHandler & _keyboardHandler
void translate(const Vector3d &v)
The Camera class is an abstract interface for a camera in a 3D graphics application....
Definition: Camera.h:41
PLATFORM_API void setTarget(const Vector3d &target)
Sets the camera target.
Definition: Camera.h:101
PLATFORM_API const Vector3d & getTarget() const
Gets the camera target.
Definition: Camera.h:115
PLATFORM_API const Vector3d & getPosition() const
Gets the camera position.
Definition: Camera.h:108
PLATFORM_API const Quaterniond & getOrientation() const
Gets the camera orientation quaternion.
Definition: Camera.h:133
InspectCenterManipulator(Camera &camera, KeyboardHandler &handler)
The KeyboardHandler class manages keyboard shortcuts and special keys.
void registerSpecialKey(const SpecialKey key, const std::string &description, std::function< void()> functor)
Registers a special key.
void registerKeyboardShortcut(const unsigned char key, const std::string &description, std::function< void()> functor)
Registers a keyboard shortcut.
void unregisterKeyboardShortcut(const unsigned char key)
Unregisters a keyboard shortcut.
void unregisterSpecialKey(const SpecialKey key)
Unregisters a special key.
glm::vec3 Vector3f
Definition: MathTypes.h:137
glm::vec< 2, int32_t > Vector2i
Definition: MathTypes.h:130
glm::vec< 3, double > Vector3d
Definition: MathTypes.h:143