# Visualization Library

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

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

# vl::FlatManipulator Class Reference

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

`#include <FlatManipulator.h>`

Inheritance diagram for vl::FlatManipulator:

List of all members.

## Public Types

enum | EManipMode { NoMode, TranslationMode, ZoomMode }

## Public Member Functions

virtual const char * | className ()
| 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

## 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 55 of file FlatManipulator.h.

## Member Enumeration Documentation

enum vl::FlatManipulator::EManipMode

Enumerator:

  NoMode |
  TranslationMode |
  ZoomMode |

Definition at line 58 of file FlatManipulator.h.

## Constructor & Destructor Documentation

FlatManipulator::FlatManipulator | ( | ) |

Constructor.

Definition at line 37 of file FlatManipulator.cpp.

References VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::FlatManipulator::className | ( | ) | `[inline, virtual]`

Definition at line 61 of file FlatManipulator.h.

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 76 of file FlatManipulator.h.

virtual void vl::FlatManipulator::destroyEvent | ( | ) | `[inline, virtual]`

Event generated right before the bound OpenGLContext is destroyed.

Implements vl::UIEventListener.

Definition at line 78 of file FlatManipulator.h.

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 80 of file FlatManipulator.h.

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 82 of file FlatManipulator.h.

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 84 of file FlatManipulator.h.

virtual void vl::FlatManipulator::mouseWheelEvent | ( | int | n ) | `[inline, virtual]`

Event generated when the mouse wheel rotated.

Implements vl::UIEventListener.

Definition at line 86 of file FlatManipulator.h.

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 88 of file FlatManipulator.h.

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 90 of file FlatManipulator.h.

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 92 of file FlatManipulator.h.

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 94 of file FlatManipulator.h.

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 96 of file FlatManipulator.h.

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.

Camera* vl::FlatManipulator::camera | ( | ) | `[inline]`

The camera through which the manipulator is used.

Definition at line 104 of file FlatManipulator.h.

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 107 of file FlatManipulator.h.

References mZoomButton.

Referenced by mouseDownEvent(), and mouseUpEvent().

void vl::FlatManipulator::setZoomButton | ( | int | mouse_button ) | `[inline]`

Mouse button used to zoom.

Definition at line 110 of file FlatManipulator.h.

References mZoomButton.

int vl::FlatManipulator::translationButton | ( | ) | const`[inline]`

Mouse button used to translate the view.

Definition at line 113 of file FlatManipulator.h.

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 116 of file FlatManipulator.h.

References mTranslationButton.

float vl::FlatManipulator::zoomSpeed | ( | ) | const`[inline]`

Zoom speed multiplicative factor (default = 1).

Definition at line 119 of file FlatManipulator.h.

References mZoomSpeed.

Referenced by mouseMoveEvent().

void vl::FlatManipulator::setZoomSpeed | ( | float | speed ) | `[inline]`

Zoom speed multiplicative factor (default = 1).

Definition at line 122 of file FlatManipulator.h.

References mZoomSpeed.

EManipMode vl::FlatManipulator::mode | ( | ) | const`[inline]`

Returns the current manipulator state.

Definition at line 125 of file FlatManipulator.h.

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

## Member Data Documentation

ref<Camera> vl::FlatManipulator::mCamera`[protected]`

Definition at line 132 of file FlatManipulator.h.

Referenced by camera(), and setCamera().

vec2 vl::FlatManipulator::mMouseStart`[protected]`

Definition at line 133 of file FlatManipulator.h.

Referenced by mouseDownEvent(), and mouseMoveEvent().

vec2 vl::FlatManipulator::mPixelSize`[protected]`

Definition at line 134 of file FlatManipulator.h.

Referenced by mouseDownEvent(), and mouseMoveEvent().

EManipMode vl::FlatManipulator::mMode`[protected]`

Definition at line 135 of file FlatManipulator.h.

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

int vl::FlatManipulator::mTranslationButton`[protected]`

Definition at line 136 of file FlatManipulator.h.

Referenced by setTranslationButton(), and translationButton().

int vl::FlatManipulator::mZoomButton`[protected]`

Definition at line 137 of file FlatManipulator.h.

Referenced by setZoomButton(), and zoomButton().

float vl::FlatManipulator::mZoomSpeed`[protected]`

Definition at line 138 of file FlatManipulator.h.

Referenced by setZoomSpeed(), and zoomSpeed().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/FlatManipulator.h
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/FlatManipulator.cpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:35.
Permission is granted to use this page to write and publish articles regarding Visualization Library.