Skip to content

Commit

Permalink
clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
denizdiktas committed Jul 13, 2023
1 parent 8bbb43c commit 70247a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
30 changes: 0 additions & 30 deletions Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,23 @@ Main_widget::~Main_widget()
doneCurrent();
}

void Main_widget::set_mouse_button_pressed_flag(QMouseEvent* e, bool flag)
{
switch (e->button())
{
case Qt::LeftButton:
m_left_mouse_button_down = flag;
break;

case Qt::MiddleButton:
m_middle_mouse_button_down = flag;
break;
}
}
void Main_widget::mousePressEvent(QMouseEvent* e)
{
// forward the event to the camera manipulators
m_camera_manip_rot->mousePressEvent(e);
m_camera_manip_zoom->mousePressEvent(e);

set_mouse_button_pressed_flag(e, true);
m_mouse_press_pos = m_last_mouse_pos = QVector2D(e->position());
}
void Main_widget::mouseMoveEvent(QMouseEvent* e)
{
// forward the event to the camera manipulator
m_camera_manip_rot->mouseMoveEvent(e);
m_camera_manip_zoom->mouseMoveEvent(e);

auto current_mouse_pos = QVector2D(e->position());
const auto diff = current_mouse_pos - m_last_mouse_pos;

//if(m_middle_mouse_button_down)
//{
// const float zoom_scale_factor = 0.01f;
// const auto distance = zoom_scale_factor * diff.y();
// m_camera.move_forward(distance);
//}

m_last_mouse_pos = current_mouse_pos;
}
void Main_widget::mouseReleaseEvent(QMouseEvent* e)
{
// forward the event to the camera manipulator
m_camera_manip_rot->mouseReleaseEvent(e);
m_camera_manip_zoom->mouseReleaseEvent(e);

set_mouse_button_pressed_flag(e, false);
}
void Main_widget::timerEvent(QTimerEvent*)
{
Expand Down
10 changes: 2 additions & 8 deletions Arrangement_on_surface_2/demo/earth/Main_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
~Main_widget();

protected:
void set_mouse_button_pressed_flag(QMouseEvent* e, bool flag);
void mousePressEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
void mouseReleaseEvent(QMouseEvent* e) override;
Expand Down Expand Up @@ -76,7 +75,6 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
Kml::Placemark* m_selected_country;



// Shaders
Shader_program m_sp_smooth;
Shader_program m_sp_per_vertex_color;
Expand All @@ -87,12 +85,8 @@ class Main_widget : public QOpenGLWidget, protected OpenGLFunctionsBase
std::unique_ptr<Camera_manip> m_camera_manip_rot;
std::unique_ptr<Camera_manip> m_camera_manip_zoom;

bool m_left_mouse_button_down = false;
bool m_middle_mouse_button_down = false;
QVector2D m_last_mouse_pos;
QVector2D m_mouse_press_pos;
float m_theta = 0, m_phi = 0;
int m_vp_width = 0, m_vp_height = 0;
// view-port
int m_vp_width = 0, m_vp_height = 0;

// Timer for continuous screen-updates
QBasicTimer m_timer;
Expand Down

0 comments on commit 70247a1

Please sign in to comment.