Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
This class lets you pan (translate) and zoom a 2D scene using the mouse. More...
#include <FlatManipulator.hpp>
Public Types | |
enum | EManipMode { NoMode, TranslationMode, ZoomMode } |
Public Member Functions | |
FlatManipulator () | |
Constructor. | |
virtual void | mouseDownEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is pressed. | |
virtual void | mouseUpEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is released. | |
virtual void | mouseMoveEvent (int x, int y) |
Event generated when the mouse moves. | |
virtual void | enableEvent (bool enabled) |
Event generated whenever setEnabled() is called. | |
virtual void | initEvent () |
Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext. | |
virtual void | destroyEvent () |
Event generated right before the bound OpenGLContext is destroyed. | |
virtual void | updateEvent () |
Event generated when the bound OpenGLContext does not have any other message to process and OpenGLContext::continuousUpdate() is set to true or somebody calls OpenGLContext::update(). | |
virtual void | addedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is bound to an OpenGLContext context. | |
virtual void | removedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is unbound from an OpenGLContext context. | |
virtual void | mouseWheelEvent (int) |
Event generated when the mouse wheel rotated. | |
virtual void | keyPressEvent (unsigned short, EKey) |
Event generated when a key is pressed. | |
virtual void | keyReleaseEvent (unsigned short, EKey) |
Event generated when a key is released. | |
virtual void | resizeEvent (int, int) |
Event generated when the bound OpenGLContext is resized. | |
virtual void | fileDroppedEvent (const std::vector< String > &) |
Event generated when one or more files are dropped on the bound OpenGLContext's area. | |
virtual void | visibilityEvent (bool) |
Event generated when the bound OpenGLContext is shown or hidden. | |
void | setCamera (Camera *camera) |
The camera through which the manipulator is used. | |
Camera * | camera () |
The camera through which the manipulator is used. | |
int | zoomButton () const |
Mouse button used to zoom. | |
void | setZoomButton (int mouse_button) |
Mouse button used to zoom. | |
int | translationButton () const |
Mouse button used to translate the view. | |
void | setTranslationButton (int mouse_button) |
Mouse button used to translate the view. | |
float | zoomSpeed () const |
Zoom speed multiplicative factor (default = 1). | |
void | setZoomSpeed (float speed) |
Zoom speed multiplicative factor (default = 1). | |
EManipMode | mode () const |
Returns the current manipulator state. | |
Protected Member Functions | |
bool | mouseInViewport (int mx, int my, int &vx, int &vy) |
Protected Attributes | |
ref< Camera > | mCamera |
vec2 | mMouseStart |
vec2 | mPixelSize |
EManipMode | mMode |
int | mTranslationButton |
int | mZoomButton |
float | mZoomSpeed |
This class lets you pan (translate) and zoom a 2D scene using the mouse.
The manipulator will perform the actions using only the camera's view matrix, so no other transform is required to be bound.
Definition at line 57 of file FlatManipulator.hpp.
Definition at line 62 of file FlatManipulator.hpp.
FlatManipulator::FlatManipulator | ( | ) |
Constructor.
Definition at line 37 of file FlatManipulator.cpp.
References VL_DEBUG_SET_OBJECT_NAME.
void FlatManipulator::mouseDownEvent | ( | EMouseButton | button, |
int | x, | ||
int | y | ||
) | [virtual] |
Event generated when one of the mouse buttons is pressed.
Implements vl::UIEventListener.
Definition at line 50 of file FlatManipulator.cpp.
References camera(), vl::Matrix4< T_Scalar >::e(), vl::Viewport::height(), mMode, mMouseStart, mode(), mouseInViewport(), mPixelSize, NoMode, NULL, vl::UIEventListener::openglContext(), vl::Camera::projectionMatrix(), translationButton(), TranslationMode, vl::Camera::viewport(), VL_CHECK, vl::Viewport::width(), vl::Vector2< T_Scalar >::x(), vl::Vector2< T_Scalar >::y(), zoomButton(), and ZoomMode.
void FlatManipulator::mouseUpEvent | ( | EMouseButton | button, |
int | x, | ||
int | y | ||
) | [virtual] |
Event generated when one of the mouse buttons is released.
Implements vl::UIEventListener.
Definition at line 119 of file FlatManipulator.cpp.
References camera(), mMode, mode(), NoMode, NULL, translationButton(), TranslationMode, zoomButton(), and ZoomMode.
void FlatManipulator::mouseMoveEvent | ( | int | x, |
int | y | ||
) | [virtual] |
Event generated when the mouse moves.
Implements vl::UIEventListener.
Definition at line 86 of file FlatManipulator.cpp.
References camera(), vl::Matrix4< float >::getScaling(), vl::Matrix4< float >::getTranslation(), mMouseStart, mode(), mPixelSize, NoMode, NULL, vl::UIEventListener::openglContext(), vl::Camera::setViewMatrix(), TranslationMode, vl::OpenGLContext::update(), vl::Camera::viewMatrix(), VL_CHECK, vl::Vector2< T_Scalar >::x(), vl::Vector2< T_Scalar >::y(), ZoomMode, and zoomSpeed().
void FlatManipulator::enableEvent | ( | bool | enabled ) | [virtual] |
Event generated whenever setEnabled() is called.
Implements vl::UIEventListener.
Definition at line 136 of file FlatManipulator.cpp.
References mMode, NoMode, vl::UIEventListener::openglContext(), vl::OpenGLContext::setContinuousUpdate(), and vl::OpenGLContext::setMouseVisible().
virtual void vl::FlatManipulator::initEvent | ( | ) | [inline, virtual] |
Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext.
Implements vl::UIEventListener.
Definition at line 77 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::destroyEvent | ( | ) | [inline, virtual] |
Event generated right before the bound OpenGLContext is destroyed.
Implements vl::UIEventListener.
Definition at line 79 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::updateEvent | ( | ) | [inline, virtual] |
Event generated when the bound OpenGLContext does not have any other message to process and OpenGLContext::continuousUpdate() is set to true
or somebody calls OpenGLContext::update().
Implements vl::UIEventListener.
Definition at line 81 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::addedListenerEvent | ( | OpenGLContext * | ) | [inline, virtual] |
Event generated whenever a listener is bound to an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 83 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::removedListenerEvent | ( | OpenGLContext * | ) | [inline, virtual] |
Event generated whenever a listener is unbound from an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 85 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::mouseWheelEvent | ( | int | n ) | [inline, virtual] |
Event generated when the mouse wheel rotated.
Implements vl::UIEventListener.
Definition at line 87 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::keyPressEvent | ( | unsigned | unicode_ch, |
EKey | key | ||
) | [inline, virtual] |
Event generated when a key is pressed.
Implements vl::UIEventListener.
Definition at line 89 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::keyReleaseEvent | ( | unsigned | unicode_ch, |
EKey | key | ||
) | [inline, virtual] |
Event generated when a key is released.
Implements vl::UIEventListener.
Definition at line 91 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::resizeEvent | ( | int | x, |
int | y | ||
) | [inline, virtual] |
Event generated when the bound OpenGLContext is resized.
Implements vl::UIEventListener.
Definition at line 93 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::fileDroppedEvent | ( | const std::vector< String > & | files ) | [inline, virtual] |
Event generated when one or more files are dropped on the bound OpenGLContext's area.
Implements vl::UIEventListener.
Definition at line 95 of file FlatManipulator.hpp.
virtual void vl::FlatManipulator::visibilityEvent | ( | bool | visible ) | [inline, virtual] |
Event generated when the bound OpenGLContext is shown or hidden.
Implements vl::UIEventListener.
Definition at line 97 of file FlatManipulator.hpp.
void FlatManipulator::setCamera | ( | Camera * | camera ) |
The camera through which the manipulator is used.
Definition at line 45 of file FlatManipulator.cpp.
Camera* vl::FlatManipulator::camera | ( | ) | [inline] |
The camera through which the manipulator is used.
Definition at line 105 of file FlatManipulator.hpp.
References vl::ref< T >::get(), and mCamera.
Referenced by mouseDownEvent(), mouseInViewport(), mouseMoveEvent(), mouseUpEvent(), and setCamera().
int vl::FlatManipulator::zoomButton | ( | ) | const [inline] |
Mouse button used to zoom.
Definition at line 108 of file FlatManipulator.hpp.
References mZoomButton.
Referenced by mouseDownEvent(), and mouseUpEvent().
void vl::FlatManipulator::setZoomButton | ( | int | mouse_button ) | [inline] |
Mouse button used to zoom.
Definition at line 111 of file FlatManipulator.hpp.
References mZoomButton.
int vl::FlatManipulator::translationButton | ( | ) | const [inline] |
Mouse button used to translate the view.
Definition at line 114 of file FlatManipulator.hpp.
References mTranslationButton.
Referenced by mouseDownEvent(), and mouseUpEvent().
void vl::FlatManipulator::setTranslationButton | ( | int | mouse_button ) | [inline] |
Mouse button used to translate the view.
Definition at line 117 of file FlatManipulator.hpp.
References mTranslationButton.
float vl::FlatManipulator::zoomSpeed | ( | ) | const [inline] |
Zoom speed multiplicative factor (default = 1).
Definition at line 120 of file FlatManipulator.hpp.
References mZoomSpeed.
Referenced by mouseMoveEvent().
void vl::FlatManipulator::setZoomSpeed | ( | float | speed ) | [inline] |
Zoom speed multiplicative factor (default = 1).
Definition at line 123 of file FlatManipulator.hpp.
References mZoomSpeed.
EManipMode vl::FlatManipulator::mode | ( | ) | const [inline] |
Returns the current manipulator state.
Definition at line 126 of file FlatManipulator.hpp.
References mMode.
Referenced by mouseDownEvent(), mouseMoveEvent(), and mouseUpEvent().
bool FlatManipulator::mouseInViewport | ( | int | mx, |
int | my, | ||
int & | vx, | ||
int & | vy | ||
) | [protected] |
Definition at line 149 of file FlatManipulator.cpp.
References camera(), vl::OpenGLContext::height(), vl::UIEventListener::openglContext(), vl::Camera::viewport(), vl::Viewport::x(), and vl::Viewport::y().
Referenced by mouseDownEvent().
ref<Camera> vl::FlatManipulator::mCamera [protected] |
Definition at line 133 of file FlatManipulator.hpp.
Referenced by camera(), and setCamera().
vec2 vl::FlatManipulator::mMouseStart [protected] |
Definition at line 134 of file FlatManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
vec2 vl::FlatManipulator::mPixelSize [protected] |
Definition at line 135 of file FlatManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
EManipMode vl::FlatManipulator::mMode [protected] |
Definition at line 136 of file FlatManipulator.hpp.
Referenced by enableEvent(), mode(), mouseDownEvent(), and mouseUpEvent().
int vl::FlatManipulator::mTranslationButton [protected] |
Definition at line 137 of file FlatManipulator.hpp.
Referenced by setTranslationButton(), and translationButton().
int vl::FlatManipulator::mZoomButton [protected] |
Definition at line 138 of file FlatManipulator.hpp.
Referenced by setZoomButton(), and zoomButton().
float vl::FlatManipulator::mZoomSpeed [protected] |
Definition at line 139 of file FlatManipulator.hpp.
Referenced by setZoomSpeed(), and zoomSpeed().