Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

X:/dropbox/visualizationlibrary/src/vlGraphics/FlatManipulator.hpp

Go to the documentation of this file.
00001 /**************************************************************************************/
00002 /*                                                                                    */
00003 /*  Visualization Library                                                             */
00004 /*  http://www.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 FlatManipulator_INCLUDE_ONCE
00033 #define FlatManipulator_INCLUDE_ONCE
00034 
00035 #include <vlCore/Vector3.hpp>
00036 #include <vlCore/Vector4.hpp>
00037 #include <vlGraphics/UIEventListener.hpp>
00038 #include <vlGraphics/Camera.hpp>
00039 #include <vlGraphics/Geometry.hpp>
00040 
00041 // mic fixme: clean up this mess
00042 
00043 namespace vl
00044 {
00045 
00046   //------------------------------------------------------------------------------
00047   // FlatManipulator
00048   //------------------------------------------------------------------------------
00057 class FlatManipulator: public UIEventListener
00058 {
00059   VL_INSTRUMENT_CLASS(vl::FlatManipulator, UIEventListener)
00060 
00061   public:
00062     typedef enum { NoMode, TranslationMode, ZoomMode } EManipMode;
00063 
00065     FlatManipulator();
00066 
00067     // --- UIEventListener ---
00068 
00069     virtual void mouseDownEvent(EMouseButton, int x, int y);
00070 
00071     virtual void mouseUpEvent(EMouseButton, int x, int y);
00072 
00073     virtual void mouseMoveEvent(int x, int y);
00074 
00075     virtual void enableEvent(bool enabled);
00076 
00077     virtual void initEvent() {}
00078 
00079     virtual void destroyEvent() {}
00080 
00081     virtual void updateEvent() {}
00082 
00083     virtual void addedListenerEvent(OpenGLContext*) {}
00084 
00085     virtual void removedListenerEvent(OpenGLContext*) {}
00086 
00087     virtual void mouseWheelEvent(int) {}
00088 
00089     virtual void keyPressEvent(unsigned short, EKey) {}
00090 
00091     virtual void keyReleaseEvent(unsigned short, EKey) {}
00092 
00093     virtual void resizeEvent(int, int) {}
00094 
00095     virtual void fileDroppedEvent(const std::vector<String>&) {}
00096 
00097     virtual void visibilityEvent(bool) {}
00098 
00099     // --- user methods ---
00100 
00102     void setCamera(Camera* camera);
00103 
00105     Camera* camera() { return mCamera.get(); }
00106 
00108     int zoomButton() const { return mZoomButton; }
00109 
00111     void setZoomButton(int mouse_button) { mZoomButton = mouse_button; }
00112 
00114     int translationButton() const { return mTranslationButton; }
00115 
00117     void setTranslationButton(int mouse_button) { mTranslationButton = mouse_button; }
00118 
00120     float zoomSpeed() const { return mZoomSpeed; }
00121 
00123     void setZoomSpeed(float speed) { mZoomSpeed = speed; }
00124 
00126     EManipMode mode() const { return mMode; }
00127 
00128   protected:
00129 
00130     bool mouseInViewport(int mx, int my, int& vx, int& vy);
00131 
00132   protected:
00133     ref<Camera> mCamera;
00134     vec2        mMouseStart;
00135     vec2        mPixelSize;
00136     EManipMode  mMode;
00137     int         mTranslationButton;
00138     int         mZoomButton;
00139     float       mZoomSpeed;
00140   };
00141 
00143 
00155 vl::ref<vl::Geometry> makeScales(bool X = true,
00156                                  bool Y = true,
00157                                  bool Z = true,
00158                                  int numArmTicks = 50,
00159                                  float mmStep = 10,
00160                                  float mmTickSize = 4,
00161                                  vl::fvec4 color = vl::fvec4(1,1,1,1));
00162 }
00163 
00164 #endif

Visualization Library 2011.09.1160 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 2 2013 13:40:36.
Permission is granted to use this page to write and publish articles regarding Visualization Library.