-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: camera manipulator for zoom moved to its own class
- Loading branch information
1 parent
96c81a0
commit 8bbb43c
Showing
5 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
#include "Camera_manip_zoom.h" | ||
|
||
|
||
Camera_manip_zoom::Camera_manip_zoom(Camera& camera) : | ||
Camera_manip(camera) | ||
{ | ||
} | ||
|
||
void Camera_manip_zoom::mouse_move_event(QMouseEvent* e) | ||
{ | ||
if (m_middle_mouse_button_down) | ||
{ | ||
auto current_mouse_pos = QVector2D(e->position()); | ||
const auto diff = current_mouse_pos - m_last_mouse_pos; | ||
|
||
const float zoom_scale_factor = 0.01f; | ||
const auto distance = zoom_scale_factor * diff.y(); | ||
m_camera.move_forward(distance); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#ifndef CAMERA_MANIP_ZOOM_H | ||
#define CAMERA_MANIP_ZOOM_H | ||
|
||
#include <qevent.h> | ||
#include <qvector2d.h> | ||
|
||
#include "Camera_manip.h" | ||
|
||
|
||
class Camera_manip_zoom : public Camera_manip | ||
{ | ||
public: | ||
Camera_manip_zoom(Camera& camera); | ||
|
||
protected: | ||
virtual void mouse_move_event(QMouseEvent* e) override; | ||
|
||
private: | ||
float m_theta = 0, m_phi = 0; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters