Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00042
00043 namespace vl
00044 {
00045
00046
00047
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
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
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