SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A 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 GUIDanielPerspectiveChanger_h 00023 #define GUIDanielPerspectiveChanger_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 <utils/geom/Position.h> 00036 #include "GUIPerspectiveChanger.h" 00037 00038 00039 // =========================================================================== 00040 // class declarations 00041 // =========================================================================== 00042 class Boundary; 00043 00044 00045 // =========================================================================== 00046 // class definitions 00047 // =========================================================================== 00058 class GUIDanielPerspectiveChanger : public GUIPerspectiveChanger { 00059 public: 00060 /* Constructor 00061 * @param[in] callBack The view to be udpated upon changes 00062 */ 00063 GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort); 00064 00066 ~GUIDanielPerspectiveChanger(); 00067 00068 void onLeftBtnPress(void* data); 00069 bool onLeftBtnRelease(void* data); 00070 void onRightBtnPress(void* data); 00071 bool onRightBtnRelease(void* data); 00072 void onMouseWheel(void* data); 00073 void onMouseMove(void* data); 00074 00076 virtual SUMOReal getRotation() const; 00077 00079 virtual SUMOReal getXPos() const; 00080 00082 virtual SUMOReal getYPos() const; 00083 00085 virtual SUMOReal getZoom() const; 00086 00088 void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true); 00089 00091 void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos); 00092 00093 00094 /* @brief Adapts the viewport so that a change in canvass size keeps most of the 00095 * view intact (by showing more / less instead of zooming) 00096 * The canvass is clipped/enlarged on the left side of the screen 00097 * 00098 * @param[in] change The horizontal change in canvas size in pixels 00099 */ 00100 void changeCanvassLeft(int change); 00101 00102 /* @brief avoid unwanted flicker 00103 * @param[in] delay The minimum time delay in nanoseconds after 00104 * mouseDown after which mouse-movements should be interpreted as zoom/drag 00105 */ 00106 void setDragDelay(FXTime delay) { 00107 myDragDelay = delay; 00108 } 00109 00110 private: 00111 /* Performs the view movement 00112 * @param[in] xdiff the change to myViewCenter in pixel 00113 * @param[in] ydiff the change to myViewCenter in pixel 00114 */ 00115 void move(int xdiff, int ydiff); 00116 00118 void zoom(SUMOReal factor); 00119 00121 void rotate(int diff); 00122 00123 private: 00125 SUMOReal myOrigWidth, myOrigHeight; 00126 00128 SUMOReal myRotation; 00129 00131 int myMouseButtonState; 00132 00134 bool myMoveOnClick; 00135 00137 Position myZoomBase; 00138 00140 FXTime myDragDelay; 00141 FXTime myMouseDownTime; 00142 }; 00143 00144 00145 #endif 00146 00147 /****************************************************************************/ 00148