# Visualization Library

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

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

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/FlatManipulator.h

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 namespace vl
    00042 {
    00043
    00044   //------------------------------------------------------------------------------
    00045   // FlatManipulator
    00046   //------------------------------------------------------------------------------
    00055 class FlatManipulator: public UIEventListener
    00056 {
    00057   public:
    00058     typedef enum { NoMode, TranslationMode, ZoomMode } EManipMode;
    00059
    00060   public:
    00061     virtual const char* className() { return "vl::FlatManipulator"; }
    00062
    00064     FlatManipulator();
    00065
    00066     // --- UIEventListener ---
    00067
    00068     virtual void mouseDownEvent(EMouseButton, int x, int y);
    00069
    00070     virtual void mouseUpEvent(EMouseButton, int x, int y);
    00071
    00072     virtual void mouseMoveEvent(int x, int y);
    00073
    00074     virtual void enableEvent(bool enabled);
    00075
    00076     virtual void initEvent() {}
    00077
    00078     virtual void destroyEvent() {}
    00079
    00080     virtual void updateEvent() {}
    00081
    00082     virtual void addedListenerEvent(OpenGLContext*) {}
    00083
    00084     virtual void removedListenerEvent(OpenGLContext*) {}
    00085
    00086     virtual void mouseWheelEvent(int) {}
    00087
    00088     virtual void keyPressEvent(unsigned short, EKey) {}
    00089
    00090     virtual void keyReleaseEvent(unsigned short, EKey) {}
    00091
    00092     virtual void resizeEvent(int, int) {}
    00093
    00094     virtual void fileDroppedEvent(const std::vector<String>&) {}
    00095
    00096     virtual void visibilityEvent(bool) {}
    00097
    00098     // --- user methods ---
    00099
    00101     void setCamera(Camera* camera);
    00102
    00104     Camera* camera() { return mCamera.get(); }
    00105
    00107     int zoomButton() const { return mZoomButton; }
    00108
    00110     void setZoomButton(int mouse_button) { mZoomButton = mouse_button; }
    00111
    00113     int translationButton() const { return mTranslationButton; }
    00114
    00116     void setTranslationButton(int mouse_button) { mTranslationButton = mouse_button; }
    00117
    00119     float zoomSpeed() const { return mZoomSpeed; }
    00120
    00122     void setZoomSpeed(float speed) { mZoomSpeed = speed; }
    00123
    00125     EManipMode mode() const { return mMode; }
    00126
    00127   protected:
    00128
    00129     bool mouseInViewport(int mx, int my, int& vx, int& vy);
    00130
    00131   protected:
    00132     ref<Camera> mCamera;
    00133     vec2        mMouseStart;
    00134     vec2        mPixelSize;
    00135     EManipMode  mMode;
    00136     int         mTranslationButton;
    00137     int         mZoomButton;
    00138     float       mZoomSpeed;
    00139   };
    00140
    00142
    00154 vl::ref<vl::Geometry> makeScales(bool X = true,
    00155                                  bool Y = true,
    00156                                  bool Z = true,
    00157                                  int numArmTicks = 50,
    00158                                  float mmStep = 10,
    00159                                  float mmTickSize = 4,
    00160                                  vl::fvec4 color = vl::fvec4(1,1,1,1));
    00161 }
    00162
    00163 #endif // FlatManipulator_INCLUDE_ONCE

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