Visualization Library 2.0.0-b3

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:

Public Member Functions

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

void bindManipulators (Camera *camera)
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

ref< RenderingAbstractmRendering
 
ref< GhostCameraManipulatormFly
 
ref< TrackballManipulatormTrackball
 
ref< SceneManagerActorTreemSceneManagerActorTree
 
ref< ReadPixelsmReadPixels
 
String mAppletName
 
double mStartTime
 
double mFPS
 
int mFrameCount
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

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:

Definition at line 60 of file Applet.hpp.

Constructor & Destructor Documentation

◆ Applet()

Applet::Applet ( )

Constructor.

Definition at line 44 of file Applet.cpp.

References vl::Time::currentTime(), mAppletName, mFPS, mFrameCount, mReadPixels, and mStartTime.

Member Function Documentation

◆ addedListenerEvent()

void Applet::addedListenerEvent ( OpenGLContext )
virtual

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

Implements vl::UIEventListener.

Definition at line 167 of file Applet.cpp.

References vl::OpenGLContext::addEventListener(), mFly, mTrackball, NULL, and VL_CHECK.

◆ appletName()

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

◆ bindManipulators()

void Applet::bindManipulators ( Camera camera)
protected

Definition at line 159 of file Applet.cpp.

References mFly, mTrackball, and NULL.

Referenced by initialize().

◆ destroyEvent()

void Applet::destroyEvent ( )
virtual

Event generated right before the bound OpenGLContext is destroyed.

Implements vl::UIEventListener.

Definition at line 190 of file Applet.cpp.

References mFly, mReadPixels, mRendering, mSceneManagerActorTree, mTrackball, NULL, vl::UIEventListener::openglContext(), and vl::OpenGLContext::removeEventListener().

◆ enableEvent()

virtual void vl::Applet::enableEvent ( bool  enabled)
inlinevirtual

Event generated whenever setEnabled() is called.

Implements vl::UIEventListener.

Definition at line 90 of file Applet.hpp.

◆ fileDroppedEvent()

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

◆ fps()

double vl::Applet::fps ( ) const
inline

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

Definition at line 138 of file Applet.hpp.

◆ ghostCameraManipulator() [1/2]

GhostCameraManipulator* vl::Applet::ghostCameraManipulator ( )
inline

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

Definition at line 127 of file Applet.hpp.

◆ ghostCameraManipulator() [2/2]

const GhostCameraManipulator* vl::Applet::ghostCameraManipulator ( ) const
inline

Definition at line 128 of file Applet.hpp.

◆ initEvent()

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

◆ initialize()

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::Rendering::camera(), vl::ref< T >::get(), mFly, mSceneManagerActorTree, mTrackball, rendering(), sceneManager(), vl::Rendering::sceneManagers(), and setRendering().

◆ keyPressEvent()

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

Event generated when a key is pressed.

Implements vl::UIEventListener.

Definition at line 100 of file Applet.hpp.

◆ keyReleaseEvent()

void Applet::keyReleaseEvent ( unsigned  unicode_ch,
EKey  key 
)
virtual

◆ mouseDownEvent()

virtual void vl::Applet::mouseDownEvent ( EMouseButton  button,
int  x,
int  y 
)
inlinevirtual

Event generated when one of the mouse buttons is pressed.

Implements vl::UIEventListener.

Definition at line 96 of file Applet.hpp.

◆ mouseMoveEvent()

virtual void vl::Applet::mouseMoveEvent ( int  x,
int  y 
)
inlinevirtual

Event generated when the mouse moves.

Implements vl::UIEventListener.

Definition at line 92 of file Applet.hpp.

◆ mouseUpEvent()

virtual void vl::Applet::mouseUpEvent ( EMouseButton  button,
int  x,
int  y 
)
inlinevirtual

Event generated when one of the mouse buttons is released.

Implements vl::UIEventListener.

Definition at line 94 of file Applet.hpp.

◆ mouseWheelEvent()

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

Event generated when the mouse wheel rotated.

Implements vl::UIEventListener.

Definition at line 98 of file Applet.hpp.

◆ removedListenerEvent()

void Applet::removedListenerEvent ( OpenGLContext )
virtual

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

Implements vl::UIEventListener.

Definition at line 178 of file Applet.cpp.

References mFly, mTrackball, and vl::OpenGLContext::removeEventListener().

◆ rendering() [1/2]

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

◆ rendering() [2/2]

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.

◆ resizeEvent()

void Applet::resizeEvent ( int  x,
int  y 
)
virtual

◆ sceneManager() [1/2]

SceneManagerActorTree* vl::Applet::sceneManager ( )
inline

The scene manager used by the default rendering.

Definition at line 118 of file Applet.hpp.

Referenced by initialize().

◆ sceneManager() [2/2]

const SceneManagerActorTree* vl::Applet::sceneManager ( ) const
inline

The scene manager used by the default rendering.

Definition at line 121 of file Applet.hpp.

◆ setAppletName()

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.

◆ setGhostCameraManipulator()

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.

◆ setRendering()

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

◆ setTrackball()

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.

◆ trackball() [1/2]

TrackballManipulator* vl::Applet::trackball ( )
inline

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

Definition at line 134 of file Applet.hpp.

◆ trackball() [2/2]

const TrackballManipulator* vl::Applet::trackball ( ) const
inline

Definition at line 135 of file Applet.hpp.

◆ updateEvent()

void Applet::updateEvent ( )
virtual

◆ updateScene()

virtual void vl::Applet::updateScene ( )
inlinevirtual

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

◆ visibilityEvent()

virtual void vl::Applet::visibilityEvent ( bool  visible)
inlinevirtual

Event generated when the bound OpenGLContext is shown or hidden.

Implements vl::UIEventListener.

Definition at line 104 of file Applet.hpp.

Member Data Documentation

◆ mAppletName

String vl::Applet::mAppletName
protected

Definition at line 163 of file Applet.hpp.

Referenced by Applet().

◆ mFly

ref<GhostCameraManipulator> vl::Applet::mFly
protected

◆ mFPS

double vl::Applet::mFPS
protected

Definition at line 165 of file Applet.hpp.

Referenced by Applet(), and updateEvent().

◆ mFrameCount

int vl::Applet::mFrameCount
protected

Definition at line 166 of file Applet.hpp.

Referenced by Applet(), and updateEvent().

◆ mReadPixels

ref<ReadPixels> vl::Applet::mReadPixels
protected

Definition at line 162 of file Applet.hpp.

Referenced by Applet(), destroyEvent(), and keyReleaseEvent().

◆ mRendering

ref<RenderingAbstract> vl::Applet::mRendering
protected

Definition at line 158 of file Applet.hpp.

Referenced by destroyEvent().

◆ mSceneManagerActorTree

ref<SceneManagerActorTree> vl::Applet::mSceneManagerActorTree
protected

Definition at line 161 of file Applet.hpp.

Referenced by destroyEvent(), and initialize().

◆ mStartTime

double vl::Applet::mStartTime
protected

Definition at line 164 of file Applet.hpp.

Referenced by Applet(), and updateEvent().

◆ mTrackball

ref<TrackballManipulator> vl::Applet::mTrackball
protected

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