# Visualization Library

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

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

Public Member Functions | Protected Member Functions

# vl::Applet Class Reference

The Applet class is an utilitly UIEventListener that features a ghost manipulator, trackball manipulator, an FPS counter and a simple rendering pipeline. More...

`#include <Applet.hpp>`

Inheritance diagram for vl::Applet:

List of all members.

## Public Member Functions

| Applet ()
| Constructor.
void | initialize ()
| Initializes the default rendering (with Rendering), the default scene manager (with SceneManagerActorTree) and camera manipulators (GhostCameraManipulator and TrackballManipulator).
virtual void | addedListenerEvent (OpenGLContext *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 | keyReleaseEvent (unsigned short, EKey key)
| Event generated when a key is released.
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 | resizeEvent (int, int)
| Event generated when the bound OpenGLContext is resized.
virtual void | initEvent ()
| Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext.
virtual void | enableEvent (bool)
| Event generated whenever setEnabled() is called.
virtual void | mouseMoveEvent (int, int)
| Event generated when the mouse moves.
virtual void | mouseUpEvent (EMouseButton, int, int)
| Event generated when one of the mouse buttons is released.
virtual void | mouseDownEvent (EMouseButton, int, int)
| Event generated when one of the mouse buttons is pressed.
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 | 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.
RenderingAbstract * | rendering ()
| The rendering used by the Applet, by default a Rendering.
const RenderingAbstract * | rendering () const
| The rendering used by the Applet, by default a Rendering.
void | setRendering (RenderingAbstract *rendering)
| Sets the rendering used by the Applet, by default a Rendering.
SceneManagerActorTree * | sceneManager ()
| The scene manager used by the default rendering.
const SceneManagerActorTree * | sceneManager () const
| The scene manager used by the default rendering.
void | setGhostCameraManipulator (GhostCameraManipulator *gcm)
| GhostCameraManipulator used by the applet, activated by the "F" key.
GhostCameraManipulator * | ghostCameraManipulator ()
| GhostCameraManipulator used by the applet, activated by the "F" key.
const GhostCameraManipulator * | ghostCameraManipulator () const
void | setTrackball (TrackballManipulator *trackball)
| TrackballManipulator used by the applet, activated by the "T" key.
TrackballManipulator * | trackball ()
| TrackballManipulator used by the applet, activated by the "T" key.
const TrackballManipulator * | trackball () const
double | fps () const
| Current average frames per second (updated every 500ms).
virtual void | updateScene ()
| Override this to update the content of your scene.
void | setAppletName (const String &app_name)
| Sets the applet name, used for the window title and for naming screenshots.
const String & | appletName () const
| The applet name, used for the window title and for naming screenshots.

## Protected Member Functions

void | bindManipulators (Camera *camera)

## Detailed Description

The Applet class is an utilitly UIEventListener that features a ghost manipulator, trackball manipulator, an FPS counter and a simple rendering pipeline.

Default key bindings:

- Key_Escape: calls openglContext()->quitApplication()
- Key_T: enables the TrackballManipulator.
- Key_F: enables the GhostCameraManipulator (fly mode).
- Key_F1: toggles fullscreen mode if supported.
- Key_F5: saves a screenshot of the current OpenGL window.
- Key_C: toggles the continuous update of the OpenGL window (see also OpenGLContext::setContinuousUpdate()).
- Key_U: updates the OpenGL window content by calling openglContext()->update().

Definition at line 60 of file Applet.hpp.

## Constructor & Destructor Documentation

Applet::Applet | ( | ) |

Constructor.

Definition at line 44 of file Applet.cpp.

References vl::Time::currentTime(), and VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

void Applet::initialize | ( | ) |

Initializes the default rendering (with Rendering), the default scene manager (with SceneManagerActorTree) and camera manipulators (GhostCameraManipulator and TrackballManipulator).

Definition at line 54 of file Applet.cpp.

References vl::Object::as(), bindManipulators(), vl::ref< T >::get(), rendering(), sceneManager(), and setRendering().

void Applet::addedListenerEvent | ( | OpenGLContext * | ) | `[virtual]`

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

Implements vl::UIEventListener.

Definition at line 168 of file Applet.cpp.

References vl::OpenGLContext::addEventListener(), vl::ref< T >::get(), NULL, and VL_CHECK.

void Applet::removedListenerEvent | ( | OpenGLContext * | ) | `[virtual]`

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

Implements vl::UIEventListener.

Definition at line 179 of file Applet.cpp.

References vl::ref< T >::get(), and vl::OpenGLContext::removeEventListener().

void Applet::keyReleaseEvent | ( | unsigned | unicode_ch,
|  | EKey | key
| ) |  | `[virtual]`

Event generated when a key is released.

Implements vl::UIEventListener.

Definition at line 107 of file Applet.cpp.

References appletName(), vl::Time::dayOfMonth(), vl::ref< T >::get(), vl::Time::hour(), vl::Key_C, vl::Key_Escape, vl::Key_F, vl::Key_F1, vl::Key_F5, vl::Key_T, vl::Key_U, vl::Time::month(), vl::RenderingAbstract::onFinishedCallbacks(), vl::UIEventListener::openglContext(), vl::Log::print(), vl::Collection< T >::push_back(), vl::OpenGLContext::quitApplication(), vl::RDB_BACK_LEFT, rendering(), vl::Time::second(), vl::OpenGLContext::setContinuousUpdate(), vl::OpenGLContext::setFullscreen(), vl::OpenGLContext::update(), and vl::Time::year().

void Applet::destroyEvent | ( | ) | `[virtual]`

Event generated right before the bound OpenGLContext is destroyed.

Implements vl::UIEventListener.

Definition at line 185 of file Applet.cpp.

References NULL.

void Applet::updateEvent | ( | ) | `[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 75 of file Applet.cpp.

References vl::Time::currentTime(), vl::UIEventListener::openglContext(), vl::RenderingAbstract::render(), rendering(), vl::RenderingAbstract::setFrameClock(), vl::OpenGLContext::swapBuffers(), updateScene(), and VL_CHECK_OGL.

void Applet::resizeEvent | ( | int | x,
|  | int | y
| ) |  | `[virtual]`

Event generated when the bound OpenGLContext is resized.

Implements vl::UIEventListener.

Definition at line 146 of file Applet.cpp.

References vl::Rendering::camera(), vl::Renderer::framebuffer(), vl::Framebuffer::height(), vl::Rendering::renderer(), rendering(), vl::Viewport::setHeight(), vl::Camera::setProjectionPerspective(), vl::Viewport::setWidth(), vl::Camera::viewport(), VL_CHECK, and vl::Framebuffer::width().

virtual void vl::Applet::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 88 of file Applet.hpp.

virtual void vl::Applet::enableEvent | ( | bool | enabled ) | `[inline, virtual]`

Event generated whenever setEnabled() is called.

Implements vl::UIEventListener.

Definition at line 90 of file Applet.hpp.

virtual void vl::Applet::mouseMoveEvent | ( | int | x,
|  | int | y
| ) |  | `[inline, virtual]`

Event generated when the mouse moves.

Implements vl::UIEventListener.

Definition at line 92 of file Applet.hpp.

virtual void vl::Applet::mouseUpEvent | ( | EMouseButton | button,
|  | int | x,
|  | int | y
| ) |  | `[inline, virtual]`

Event generated when one of the mouse buttons is released.

Implements vl::UIEventListener.

Definition at line 94 of file Applet.hpp.

virtual void vl::Applet::mouseDownEvent | ( | EMouseButton | button,
|  | int | x,
|  | int | y
| ) |  | `[inline, virtual]`

Event generated when one of the mouse buttons is pressed.

Implements vl::UIEventListener.

Definition at line 96 of file Applet.hpp.

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

Event generated when the mouse wheel rotated.

Implements vl::UIEventListener.

Definition at line 98 of file Applet.hpp.

virtual void vl::Applet::keyPressEvent | ( | unsigned | unicode_ch,
|  | EKey | key
| ) |  | `[inline, virtual]`

Event generated when a key is pressed.

Implements vl::UIEventListener.

Definition at line 100 of file Applet.hpp.

virtual void vl::Applet::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 102 of file Applet.hpp.

virtual void vl::Applet::visibilityEvent | ( | bool | visible ) | `[inline, virtual]`

Event generated when the bound OpenGLContext is shown or hidden.

Implements vl::UIEventListener.

Definition at line 104 of file Applet.hpp.

RenderingAbstract* vl::Applet::rendering | ( | ) | `[inline]`

The rendering used by the Applet, by default a Rendering.

Definition at line 109 of file Applet.hpp.

Referenced by initialize(), keyReleaseEvent(), resizeEvent(), and updateEvent().

const RenderingAbstract* vl::Applet::rendering | ( | ) | const`[inline]`

The rendering used by the Applet, by default a Rendering.

Definition at line 112 of file Applet.hpp.

void vl::Applet::setRendering | ( | RenderingAbstract * | rendering ) | `[inline]`

Sets the rendering used by the Applet, by default a Rendering.

Definition at line 115 of file Applet.hpp.

Referenced by initialize().

SceneManagerActorTree* vl::Applet::sceneManager | ( | ) | `[inline]`

The scene manager used by the default rendering.

Definition at line 118 of file Applet.hpp.

Referenced by initialize().

const SceneManagerActorTree* vl::Applet::sceneManager | ( | ) | const`[inline]`

The scene manager used by the default rendering.

Definition at line 121 of file Applet.hpp.

void vl::Applet::setGhostCameraManipulator | ( | GhostCameraManipulator * | gcm ) | `[inline]`

GhostCameraManipulator used by the applet, activated by the "F" key.

Definition at line 124 of file Applet.hpp.

GhostCameraManipulator* vl::Applet::ghostCameraManipulator | ( | ) | `[inline]`

GhostCameraManipulator used by the applet, activated by the "F" key.

Definition at line 127 of file Applet.hpp.

const GhostCameraManipulator* vl::Applet::ghostCameraManipulator | ( | ) | const`[inline]`

Definition at line 128 of file Applet.hpp.

void vl::Applet::setTrackball | ( | TrackballManipulator * | trackball ) | `[inline]`

TrackballManipulator used by the applet, activated by the "T" key.

Definition at line 131 of file Applet.hpp.

TrackballManipulator* vl::Applet::trackball | ( | ) | `[inline]`

TrackballManipulator used by the applet, activated by the "T" key.

Definition at line 134 of file Applet.hpp.

const TrackballManipulator* vl::Applet::trackball | ( | ) | const`[inline]`

Definition at line 135 of file Applet.hpp.

double vl::Applet::fps | ( | ) | const`[inline]`

Current average frames per second (updated every 500ms).

Definition at line 138 of file Applet.hpp.

virtual void vl::Applet::updateScene | ( | ) | `[inline, virtual]`

Override this to update the content of your scene.

Called by updateEvent() right before rendering()->render() and swapping opengl front/back buffers.

Note:
  Since updateScene() is called by updateEvent() this function is called only if somebody requests a OpenGLContext::update() or if OpenGLContext::continuousUpdate() is set to `true`.

Definition at line 146 of file Applet.hpp.

Referenced by updateEvent().

void vl::Applet::setAppletName | ( | const String & | app_name ) | `[inline]`

Sets the applet name, used for the window title and for naming screenshots.

Definition at line 149 of file Applet.hpp.

const String& vl::Applet::appletName | ( | ) | const`[inline]`

The applet name, used for the window title and for naming screenshots.

Definition at line 152 of file Applet.hpp.

Referenced by keyReleaseEvent().

void Applet::bindManipulators | ( | Camera * | camera ) | `[protected]`

Definition at line 160 of file Applet.cpp.

References NULL.

Referenced by initialize().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Applet.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Applet.cpp

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