Visualization Library 2.0.0
A 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. More... | |
virtual void | mouseDownEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is pressed. More... | |
virtual void | mouseUpEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is released. More... | |
virtual void | mouseMoveEvent (int x, int y) |
Event generated when the mouse moves. More... | |
virtual void | enableEvent (bool enabled) |
Event generated whenever setEnabled() is called. More... | |
virtual void | initEvent () |
Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext. More... | |
virtual void | destroyEvent () |
Event generated right before the bound OpenGLContext is destroyed. More... | |
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(). More... | |
virtual void | addedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is bound to an OpenGLContext context. More... | |
virtual void | removedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is unbound from an OpenGLContext context. More... | |
virtual void | mouseWheelEvent (int) |
Event generated when the mouse wheel rotated. More... | |
virtual void | keyPressEvent (unsigned short, EKey) |
Event generated when a key is pressed. More... | |
virtual void | keyReleaseEvent (unsigned short, EKey) |
Event generated when a key is released. More... | |
virtual void | resizeEvent (int, int) |
Event generated when the bound OpenGLContext is resized. More... | |
virtual void | fileDroppedEvent (const std::vector< String > &) |
Event generated when one or more files are dropped on the bound OpenGLContext's area. More... | |
virtual void | visibilityEvent (bool) |
Event generated when the bound OpenGLContext is shown or hidden. More... | |
void | setCamera (Camera *camera) |
The camera through which the manipulator is used. More... | |
Camera * | camera () |
The camera through which the manipulator is used. More... | |
int | zoomButton () const |
Mouse button used to zoom. More... | |
void | setZoomButton (int mouse_button) |
Mouse button used to zoom. More... | |
int | translationButton () const |
Mouse button used to translate the view. More... | |
void | setTranslationButton (int mouse_button) |
Mouse button used to translate the view. More... | |
float | zoomSpeed () const |
Zoom speed multiplicative factor (default = 1). More... | |
void | setZoomSpeed (float speed) |
Zoom speed multiplicative factor (default = 1). More... | |
EManipMode | mode () const |
Returns the current manipulator state. More... | |
Public Member Functions inherited from vl::UIEventListener | |
UIEventListener () | |
Constructor. More... | |
virtual void | setEnabled (bool enabled) |
Enables or disables a UIEventListener. More... | |
bool | isEnabled () const |
Returns whether the UIEventListener is currently enabled or not. More... | |
OpenGLContext * | openglContext () |
Returns the OpenGLContext to which this UIEventListener is bound or NULL if no context is bound. More... | |
const OpenGLContext * | openglContext () const |
Returns the OpenGLContext to which this UIEventListener is bound or NULL if no context is bound. More... | |
Public Member Functions inherited from vl::Object | |
Object () | |
Constructor. More... | |
Object (const Object &other) | |
Copy constructor: copies the name, ref count mutex and user data. More... | |
Object & | operator= (const Object &other) |
Copy operator: copies the object's name, ref count mutex and user data. More... | |
const std::string & | objectName () const |
The name of the object, by default set to the object's class name. More... | |
void | setObjectName (const char *name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setObjectName (const std::string &name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setRefCountMutex (IMutex *mutex) |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () const |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
int | referenceCount () const |
Returns the number of references of an object. More... | |
void | incReference () const |
Increments the reference count of an object. More... | |
void | decReference () |
Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More... | |
void | setAutomaticDelete (bool autodel_on) |
If set to true the Object is deleted when its reference count reaches 0. More... | |
bool | automaticDelete () const |
If set to true the Object is deleted when its reference count reaches 0. More... | |
template<class T > | |
T * | as () |
Casts an Object to the specified class. More... | |
template<class T > | |
const T * | as () const |
Casts an Object to the specified class. More... | |
Protected Member Functions | |
bool | mouseInViewport (int mx, int my, int &vx, int &vy) |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
Protected Attributes | |
ref< Camera > | mCamera |
vec2 | mMouseStart |
vec2 | mPixelSize |
EManipMode | mMode |
int | mTranslationButton |
int | mZoomButton |
float | mZoomSpeed |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
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.
Enumerator | |
---|---|
NoMode | |
TranslationMode | |
ZoomMode |
Definition at line 62 of file FlatManipulator.hpp.
FlatManipulator::FlatManipulator | ( | ) |
Constructor.
Definition at line 37 of file FlatManipulator.cpp.
|
inlinevirtual |
Event generated whenever a listener is bound to an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 83 of file FlatManipulator.hpp.
|
inline |
The camera through which the manipulator is used.
Definition at line 105 of file FlatManipulator.hpp.
References mCamera.
Referenced by mouseDownEvent(), mouseInViewport(), mouseMoveEvent(), mouseUpEvent(), setCamera(), and visibilityEvent().
|
inlinevirtual |
Event generated right before the bound OpenGLContext is destroyed.
Implements vl::UIEventListener.
Definition at line 79 of file FlatManipulator.hpp.
|
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().
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
inlinevirtual |
Event generated when a key is pressed.
Implements vl::UIEventListener.
Definition at line 89 of file FlatManipulator.hpp.
|
inlinevirtual |
Event generated when a key is released.
Implements vl::UIEventListener.
Definition at line 91 of file FlatManipulator.hpp.
|
inline |
Returns the current manipulator state.
Definition at line 126 of file FlatManipulator.hpp.
References mMode, and mouseInViewport().
Referenced by mouseDownEvent(), mouseMoveEvent(), and mouseUpEvent().
|
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.
|
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 mode(), and mouseDownEvent().
|
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().
|
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.
|
inlinevirtual |
Event generated when the mouse wheel rotated.
Implements vl::UIEventListener.
Definition at line 87 of file FlatManipulator.hpp.
|
inlinevirtual |
Event generated whenever a listener is unbound from an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 85 of file FlatManipulator.hpp.
|
inlinevirtual |
Event generated when the bound OpenGLContext is resized.
Implements vl::UIEventListener.
Definition at line 93 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.
References camera(), and mCamera.
Referenced by visibilityEvent().
|
inline |
Mouse button used to translate the view.
Definition at line 117 of file FlatManipulator.hpp.
References mTranslationButton.
|
inline |
Mouse button used to zoom.
Definition at line 111 of file FlatManipulator.hpp.
References mZoomButton.
|
inline |
Zoom speed multiplicative factor (default = 1).
Definition at line 123 of file FlatManipulator.hpp.
References mZoomSpeed.
|
inline |
Mouse button used to translate the view.
Definition at line 114 of file FlatManipulator.hpp.
References mTranslationButton.
Referenced by mouseDownEvent(), and mouseUpEvent().
|
inlinevirtual |
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.
|
inlinevirtual |
Event generated when the bound OpenGLContext is shown or hidden.
Implements vl::UIEventListener.
Definition at line 97 of file FlatManipulator.hpp.
References camera(), and setCamera().
|
inline |
Mouse button used to zoom.
Definition at line 108 of file FlatManipulator.hpp.
References mZoomButton.
Referenced by mouseDownEvent(), and mouseUpEvent().
|
inline |
Zoom speed multiplicative factor (default = 1).
Definition at line 120 of file FlatManipulator.hpp.
References mZoomSpeed.
Referenced by mouseMoveEvent().
Definition at line 133 of file FlatManipulator.hpp.
Referenced by camera(), and setCamera().
|
protected |
Definition at line 136 of file FlatManipulator.hpp.
Referenced by enableEvent(), mode(), mouseDownEvent(), and mouseUpEvent().
|
protected |
Definition at line 134 of file FlatManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
|
protected |
Definition at line 135 of file FlatManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
|
protected |
Definition at line 137 of file FlatManipulator.hpp.
Referenced by setTranslationButton(), and translationButton().
|
protected |
Definition at line 138 of file FlatManipulator.hpp.
Referenced by setZoomButton(), and zoomButton().
|
protected |
Definition at line 139 of file FlatManipulator.hpp.
Referenced by setZoomSpeed(), and zoomSpeed().
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:08.
© Copyright Michele Bosi. All rights reserved.