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