Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vl::FlatManipulator Class Reference

This class lets you pan (translate) and zoom a 2D scene using the mouse. More...

#include <FlatManipulator.hpp>

+ Inheritance diagram for vl::FlatManipulator:

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...
 
Cameracamera ()
 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...
 
OpenGLContextopenglContext ()
 Returns the OpenGLContext to which this UIEventListener is bound or NULL if no context is bound. More...
 
const OpenGLContextopenglContext () 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...
 
Objectoperator= (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...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () 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< CameramCamera
 
vec2 mMouseStart
 
vec2 mPixelSize
 
EManipMode mMode
 
int mTranslationButton
 
int mZoomButton
 
float mZoomSpeed
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

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.

Note
Before using a FlatManipulator you have to specify a Camera object using the function setCamera()

Definition at line 57 of file FlatManipulator.hpp.

Member Enumeration Documentation

◆ EManipMode

Enumerator
NoMode 
TranslationMode 
ZoomMode 

Definition at line 62 of file FlatManipulator.hpp.

Constructor & Destructor Documentation

◆ FlatManipulator()

FlatManipulator::FlatManipulator ( )

Constructor.

Definition at line 37 of file FlatManipulator.cpp.

Member Function Documentation

◆ addedListenerEvent()

virtual void vl::FlatManipulator::addedListenerEvent ( OpenGLContext )
inlinevirtual

Event generated whenever a listener is bound to an OpenGLContext context.

Implements vl::UIEventListener.

Definition at line 83 of file FlatManipulator.hpp.

◆ camera()

Camera* vl::FlatManipulator::camera ( )
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().

◆ destroyEvent()

virtual void vl::FlatManipulator::destroyEvent ( )
inlinevirtual

Event generated right before the bound OpenGLContext is destroyed.

Implements vl::UIEventListener.

Definition at line 79 of file FlatManipulator.hpp.

◆ enableEvent()

void FlatManipulator::enableEvent ( bool  enabled)
virtual

◆ fileDroppedEvent()

virtual void vl::FlatManipulator::fileDroppedEvent ( const std::vector< String > &  files)
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.

◆ initEvent()

virtual void vl::FlatManipulator::initEvent ( )
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.

◆ keyPressEvent()

virtual void vl::FlatManipulator::keyPressEvent ( unsigned  unicode_ch,
EKey  key 
)
inlinevirtual

Event generated when a key is pressed.

Implements vl::UIEventListener.

Definition at line 89 of file FlatManipulator.hpp.

◆ keyReleaseEvent()

virtual void vl::FlatManipulator::keyReleaseEvent ( unsigned  unicode_ch,
EKey  key 
)
inlinevirtual

Event generated when a key is released.

Implements vl::UIEventListener.

Definition at line 91 of file FlatManipulator.hpp.

◆ mode()

EManipMode vl::FlatManipulator::mode ( ) const
inline

Returns the current manipulator state.

Definition at line 126 of file FlatManipulator.hpp.

References mMode, and mouseInViewport().

Referenced by mouseDownEvent(), mouseMoveEvent(), and mouseUpEvent().

◆ mouseDownEvent()

void FlatManipulator::mouseDownEvent ( EMouseButton  button,
int  x,
int  y 
)
virtual

◆ mouseInViewport()

bool FlatManipulator::mouseInViewport ( int  mx,
int  my,
int &  vx,
int &  vy 
)
protected

◆ mouseMoveEvent()

void FlatManipulator::mouseMoveEvent ( int  x,
int  y 
)
virtual

◆ mouseUpEvent()

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.

◆ mouseWheelEvent()

virtual void vl::FlatManipulator::mouseWheelEvent ( int  n)
inlinevirtual

Event generated when the mouse wheel rotated.

Implements vl::UIEventListener.

Definition at line 87 of file FlatManipulator.hpp.

◆ removedListenerEvent()

virtual void vl::FlatManipulator::removedListenerEvent ( OpenGLContext )
inlinevirtual

Event generated whenever a listener is unbound from an OpenGLContext context.

Implements vl::UIEventListener.

Definition at line 85 of file FlatManipulator.hpp.

◆ resizeEvent()

virtual void vl::FlatManipulator::resizeEvent ( int  x,
int  y 
)
inlinevirtual

Event generated when the bound OpenGLContext is resized.

Implements vl::UIEventListener.

Definition at line 93 of file FlatManipulator.hpp.

◆ setCamera()

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().

◆ setTranslationButton()

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.

◆ setZoomButton()

void vl::FlatManipulator::setZoomButton ( int  mouse_button)
inline

Mouse button used to zoom.

Definition at line 111 of file FlatManipulator.hpp.

References mZoomButton.

◆ setZoomSpeed()

void vl::FlatManipulator::setZoomSpeed ( float  speed)
inline

Zoom speed multiplicative factor (default = 1).

Definition at line 123 of file FlatManipulator.hpp.

References mZoomSpeed.

◆ translationButton()

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().

◆ updateEvent()

virtual void vl::FlatManipulator::updateEvent ( )
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.

◆ visibilityEvent()

virtual void vl::FlatManipulator::visibilityEvent ( bool  visible)
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().

◆ zoomButton()

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().

◆ zoomSpeed()

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().

Member Data Documentation

◆ mCamera

ref<Camera> vl::FlatManipulator::mCamera
protected

Definition at line 133 of file FlatManipulator.hpp.

Referenced by camera(), and setCamera().

◆ mMode

EManipMode vl::FlatManipulator::mMode
protected

Definition at line 136 of file FlatManipulator.hpp.

Referenced by enableEvent(), mode(), mouseDownEvent(), and mouseUpEvent().

◆ mMouseStart

vec2 vl::FlatManipulator::mMouseStart
protected

Definition at line 134 of file FlatManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

◆ mPixelSize

vec2 vl::FlatManipulator::mPixelSize
protected

Definition at line 135 of file FlatManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

◆ mTranslationButton

int vl::FlatManipulator::mTranslationButton
protected

Definition at line 137 of file FlatManipulator.hpp.

Referenced by setTranslationButton(), and translationButton().

◆ mZoomButton

int vl::FlatManipulator::mZoomButton
protected

Definition at line 138 of file FlatManipulator.hpp.

Referenced by setZoomButton(), and zoomButton().

◆ mZoomSpeed

float vl::FlatManipulator::mZoomSpeed
protected

Definition at line 139 of file FlatManipulator.hpp.

Referenced by setZoomSpeed(), and zoomSpeed().


The documentation for this class was generated from the following files: