Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Applet.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Applet_INCLUDE_ONCE
33 #define Applet_INCLUDE_ONCE
34 
39 #include <vlGraphics/Rendering.hpp>
41 
42 namespace vl
43 {
44 //-----------------------------------------------------------------------------
45 // Applet
46 //-----------------------------------------------------------------------------
61  {
63 
64  public:
66  Applet();
67 
72  void initialize();
73 
74  // --- UIEventListener ---
75 
76  virtual void addedListenerEvent(OpenGLContext* openglContext);
77 
78  virtual void removedListenerEvent(OpenGLContext*);
79 
80  virtual void keyReleaseEvent(unsigned short, EKey key);
81 
82  virtual void destroyEvent();
83 
84  virtual void updateEvent();
85 
86  virtual void resizeEvent(int, int);
87 
88  virtual void initEvent() {}
89 
90  virtual void enableEvent(bool) {}
91 
92  virtual void mouseMoveEvent(int, int) {}
93 
94  virtual void mouseUpEvent(EMouseButton, int, int) {}
95 
96  virtual void mouseDownEvent(EMouseButton, int, int) {}
97 
98  virtual void mouseWheelEvent(int) {}
99 
100  virtual void keyPressEvent(unsigned short, EKey) {}
101 
102  virtual void fileDroppedEvent(const std::vector<String>&) {}
103 
104  virtual void visibilityEvent(bool) {}
105 
106  // --- --- ---
107 
109  RenderingAbstract* rendering() { return mRendering.get(); }
110 
112  const RenderingAbstract* rendering() const { return mRendering.get(); }
113 
115  void setRendering(RenderingAbstract* rendering) { mRendering = rendering; }
116 
118  SceneManagerActorTree* sceneManager() { return mSceneManagerActorTree.get(); }
119 
121  const SceneManagerActorTree* sceneManager() const { return mSceneManagerActorTree.get(); }
122 
125 
128  const GhostCameraManipulator* ghostCameraManipulator() const { return mFly.get(); }
129 
131  void setTrackball(TrackballManipulator* trackball) { mTrackball = trackball; }
132 
134  TrackballManipulator* trackball() { return mTrackball.get(); }
135  const TrackballManipulator* trackball() const { return mTrackball.get(); }
136 
138  double fps() const { return mFPS; }
139 
146  virtual void updateScene() {}
147 
149  void setAppletName(const String& app_name) { mAppletName = app_name; }
150 
152  const String& appletName() const { return mAppletName; }
153 
154  protected:
155  void bindManipulators(Camera* camera);
156 
157  protected:
164  double mStartTime;
165  double mFPS;
167  };
168 }
169 
170 #endif
TrackballManipulator * trackball()
TrackballManipulator used by the applet, activated by the "T" key.
Definition: Applet.hpp:134
virtual void mouseUpEvent(EMouseButton, int, int)
Event generated when one of the mouse buttons is released.
Definition: Applet.hpp:94
GhostCameraManipulator * ghostCameraManipulator()
GhostCameraManipulator used by the applet, activated by the "F" key.
Definition: Applet.hpp:127
The UIEventListener class listens to the events emitted by an OpenGLContext.
The RenderingAbstract class is the base of all the rendering related sub-classes. ...
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
SceneManagerActorTree * sceneManager()
The scene manager used by the default rendering.
Definition: Applet.hpp:118
virtual void enableEvent(bool)
Event generated whenever setEnabled() is called.
Definition: Applet.hpp:90
double mFPS
Definition: Applet.hpp:165
This class lets you rotate a Camera or a Transform node using a virtual trackball.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
void setGhostCameraManipulator(GhostCameraManipulator *gcm)
GhostCameraManipulator used by the applet, activated by the "F" key.
Definition: Applet.hpp:124
const TrackballManipulator * trackball() const
Definition: Applet.hpp:135
const GhostCameraManipulator * ghostCameraManipulator() const
Definition: Applet.hpp:128
ref< SceneManagerActorTree > mSceneManagerActorTree
Definition: Applet.hpp:161
virtual void keyPressEvent(unsigned short, EKey)
Event generated when a key is pressed.
Definition: Applet.hpp:100
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
Visualization Library main namespace.
virtual void fileDroppedEvent(const std::vector< String > &)
Event generated when one or more files are dropped on the bound OpenGLContext&#39;s area.
Definition: Applet.hpp:102
void setRendering(RenderingAbstract *rendering)
Sets the rendering used by the Applet, by default a Rendering.
Definition: Applet.hpp:115
virtual void mouseDownEvent(EMouseButton, int, int)
Event generated when one of the mouse buttons is pressed.
Definition: Applet.hpp:96
String mAppletName
Definition: Applet.hpp:163
int mFrameCount
Definition: Applet.hpp:166
RenderingAbstract * rendering()
The rendering used by the Applet, by default a Rendering.
Definition: Applet.hpp:109
EMouseButton
The GhostCameraManipulator class is an UIEventListener that controls the position and orientation of ...
void setAppletName(const String &app_name)
Sets the applet name, used for the window title and for naming screenshots.
Definition: Applet.hpp:149
The Applet class is an utilitly UIEventListener that features a ghost manipulator, trackball manipulator, an FPS counter and a simple rendering pipeline.
Definition: Applet.hpp:60
const String & appletName() const
The applet name, used for the window title and for naming screenshots.
Definition: Applet.hpp:152
double fps() const
Current average frames per second (updated every 500ms).
Definition: Applet.hpp:138
double mStartTime
Definition: Applet.hpp:164
ref< RenderingAbstract > mRendering
Definition: Applet.hpp:158
ref< ReadPixels > mReadPixels
Definition: Applet.hpp:162
ref< TrackballManipulator > mTrackball
Definition: Applet.hpp:160
virtual void mouseMoveEvent(int, int)
Event generated when the mouse moves.
Definition: Applet.hpp:92
const SceneManagerActorTree * sceneManager() const
The scene manager used by the default rendering.
Definition: Applet.hpp:121
virtual void mouseWheelEvent(int)
Event generated when the mouse wheel rotated.
Definition: Applet.hpp:98
virtual void initEvent()
Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound ...
Definition: Applet.hpp:88
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
virtual void updateScene()
Override this to update the content of your scene.
Definition: Applet.hpp:146
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49
virtual void visibilityEvent(bool)
Event generated when the bound OpenGLContext is shown or hidden.
Definition: Applet.hpp:104
ref< GhostCameraManipulator > mFly
Definition: Applet.hpp:159
void setTrackball(TrackballManipulator *trackball)
TrackballManipulator used by the applet, activated by the "T" key.
Definition: Applet.hpp:131
const RenderingAbstract * rendering() const
The rendering used by the Applet, by default a Rendering.
Definition: Applet.hpp:112
A SceneManagerBVH that implements its spatial partitioning strategy using an ActorTree.