From 537686d54182ca9ca935f53563fae7d397b044fa Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 14 May 2013 11:06:03 -0700 Subject: [PATCH] Allow changing the edit voxel size using the mouse wheel. --- interface/src/Application.cpp | 19 +++++++++++++++++++ interface/src/Application.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8ce7111873..2c60113d46 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,8 @@ protected: virtual void mouseMoveEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event); + + virtual void wheelEvent(QWheelEvent* event); }; void GLCanvas::initializeGL() { @@ -116,6 +119,10 @@ void GLCanvas::mouseReleaseEvent(QMouseEvent* event) { static_cast(QCoreApplication::instance())->mouseReleaseEvent(event); } +void GLCanvas::wheelEvent(QWheelEvent* event) { + static_cast(QCoreApplication::instance())->wheelEvent(event); +} + Application::Application(int& argc, char** argv) : QApplication(argc, argv), _window(new QMainWindow(desktop())), @@ -720,6 +727,18 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { _mousePressed = false; } } + +void Application::wheelEvent(QWheelEvent* event) { + if (_mouseMode == NO_EDIT_MODE) { + event->ignore(); + return; + } + if (event->delta() > 0) { + _mouseVoxelScale *= 2; + } else { + _mouseVoxelScale /= 2; + } +} // Every second, check the frame rates and other stuff void Application::timer() { diff --git a/interface/src/Application.h b/interface/src/Application.h index c076b91a9e..035f705b41 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -34,6 +34,7 @@ class QGLWidget; class QKeyEvent; class QMainWindow; class QMouseEvent; +class QWheelEvent; class Agent; class ProgramObject; @@ -55,6 +56,8 @@ public: void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); + void wheelEvent(QWheelEvent* event); + private slots: void timer();