SUMO - Simulation of Urban MObility

GUIDanielPerspectiveChanger.h

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