|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // A virtual class that allows to steer the visual output in dependence to 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef GUIPerspectiveChanger_h 00020 #define GUIPerspectiveChanger_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <fx.h> 00033 #include <utils/geom/Boundary.h> 00034 #include <utils/geom/Position.h> 00035 #include "GUISUMOAbstractView.h" 00036 00037 00038 // =========================================================================== 00039 // class declarations 00040 // =========================================================================== 00041 class GUISUMOAbstractView; 00042 00043 00044 // =========================================================================== 00045 // class definitions 00046 // =========================================================================== 00057 class GUIPerspectiveChanger { 00058 public: 00059 enum MouseState { 00060 MOUSEBTN_NONE = 0, 00061 MOUSEBTN_LEFT = 1, 00062 MOUSEBTN_RIGHT = 2, 00063 MOUSEBTN_MIDDLE = 4 00064 }; 00065 00067 GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort); 00068 00070 virtual ~GUIPerspectiveChanger(); 00071 00072 virtual void onLeftBtnPress(void* data); 00073 virtual bool onLeftBtnRelease(void* data); 00074 virtual void onRightBtnPress(void* data); 00075 virtual bool onRightBtnRelease(void* data); 00076 virtual void onMouseWheel(void* data); 00077 virtual void onMouseMove(void* data); 00078 00080 virtual SUMOReal getRotation() const = 0; 00081 00083 virtual SUMOReal getXPos() const = 0; 00084 00086 virtual SUMOReal getYPos() const = 0; 00087 00089 virtual SUMOReal getZoom() const = 0; 00090 00094 virtual void centerTo(const Position& pos, SUMOReal radius, bool applyZoom=true) = 0; 00095 00098 virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos) = 0; 00099 00101 FXint getMouseXPosition() const; 00102 00104 FXint getMouseYPosition() const; 00105 00106 /* @brief Adapts the viewport so that a change in canvass size keeps most of the 00107 * view intact (by showing more / less instead of zooming) 00108 * The canvass is clipped/enlarged on the left side of the screen 00109 * 00110 * @param[in] change The horizontal change in canvas size in pixels 00111 */ 00112 virtual void changeCanvassLeft(int change) = 0; 00113 00114 00115 Boundary getViewport(bool fixRatio=true) { 00116 if (fixRatio) { 00117 return patchedViewPort(); 00118 } else { 00119 return myViewPort; 00120 } 00121 } 00122 00123 00124 void setViewport(const Boundary& viewPort) { 00125 myViewPort = viewPort; 00126 } 00127 00128 00129 protected: 00131 GUISUMOAbstractView& myCallback; 00132 00134 FXint myMouseXPosition, myMouseYPosition; 00135 00137 Boundary myViewPort; 00138 00139 private: 00140 // patched viewPort with the same aspect ratio as the canvas 00141 Boundary patchedViewPort(); 00142 }; 00143 00144 00145 #endif 00146 00147 /****************************************************************************/ 00148