Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://visualizationlibrary.org */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #ifndef Applet_INCLUDE_ONCE 00033 #define Applet_INCLUDE_ONCE 00034 00035 #include <vlGraphics/UIEventListener.hpp> 00036 #include <vlGraphics/TrackballManipulator.hpp> 00037 #include <vlGraphics/GhostCameraManipulator.hpp> 00038 #include <vlGraphics/SceneManagerActorTree.hpp> 00039 #include <vlGraphics/Rendering.hpp> 00040 #include <vlGraphics/ReadPixels.hpp> 00041 00042 namespace vl 00043 { 00044 //----------------------------------------------------------------------------- 00045 // Applet 00046 //----------------------------------------------------------------------------- 00060 class VLGRAPHICS_EXPORT Applet: public UIEventListener 00061 { 00062 VL_INSTRUMENT_CLASS(vl::Applet, UIEventListener) 00063 00064 public: 00066 Applet(); 00067 00072 void initialize(); 00073 00074 // --- UIEventListener --- 00075 00076 virtual void addedListenerEvent(OpenGLContext* openglContext); 00077 00078 virtual void removedListenerEvent(OpenGLContext*); 00079 00080 virtual void keyReleaseEvent(unsigned short, EKey key); 00081 00082 virtual void destroyEvent(); 00083 00084 virtual void updateEvent(); 00085 00086 virtual void resizeEvent(int, int); 00087 00088 virtual void initEvent() {} 00089 00090 virtual void enableEvent(bool) {} 00091 00092 virtual void mouseMoveEvent(int, int) {} 00093 00094 virtual void mouseUpEvent(EMouseButton, int, int) {} 00095 00096 virtual void mouseDownEvent(EMouseButton, int, int) {} 00097 00098 virtual void mouseWheelEvent(int) {} 00099 00100 virtual void keyPressEvent(unsigned short, EKey) {} 00101 00102 virtual void fileDroppedEvent(const std::vector<String>&) {} 00103 00104 virtual void visibilityEvent(bool) {} 00105 00106 // --- --- --- 00107 00109 RenderingAbstract* rendering() { return mRendering.get(); } 00110 00112 const RenderingAbstract* rendering() const { return mRendering.get(); } 00113 00115 void setRendering(RenderingAbstract* rendering) { mRendering = rendering; } 00116 00118 SceneManagerActorTree* sceneManager() { return mSceneManagerActorTree.get(); } 00119 00121 const SceneManagerActorTree* sceneManager() const { return mSceneManagerActorTree.get(); } 00122 00124 void setGhostCameraManipulator(GhostCameraManipulator* gcm) { mFly = gcm; } 00125 00127 GhostCameraManipulator* ghostCameraManipulator() { return mFly.get(); } 00128 const GhostCameraManipulator* ghostCameraManipulator() const { return mFly.get(); } 00129 00131 void setTrackball(TrackballManipulator* trackball) { mTrackball = trackball; } 00132 00134 TrackballManipulator* trackball() { return mTrackball.get(); } 00135 const TrackballManipulator* trackball() const { return mTrackball.get(); } 00136 00138 double fps() const { return mFPS; } 00139 00146 virtual void updateScene() {} 00147 00149 void setAppletName(const String& app_name) { mAppletName = app_name; } 00150 00152 const String& appletName() const { return mAppletName; } 00153 00154 protected: 00155 void bindManipulators(Camera* camera); 00156 00157 private: 00158 ref<RenderingAbstract> mRendering; 00159 ref<GhostCameraManipulator> mFly; 00160 ref<TrackballManipulator> mTrackball; 00161 ref<SceneManagerActorTree> mSceneManagerActorTree; 00162 ref<ReadPixels> mReadPixels; 00163 String mAppletName; 00164 double mStartTime; 00165 double mFPS; 00166 int mFrameCount; 00167 }; 00168 } 00169 00170 #endif