SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIDanielPerspectiveChanger.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that allows to steer the visual output in dependence to
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUIDanielPerspectiveChanger_h
23 #define GUIDanielPerspectiveChanger_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utils/geom/Position.h>
36 #include "GUIPerspectiveChanger.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class Boundary;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
59 public:
60  /* Constructor
61  * @param[in] callBack The view to be udpated upon changes
62  */
63  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
64 
67 
68  void onLeftBtnPress(void* data);
69  bool onLeftBtnRelease(void* data);
70  void onRightBtnPress(void* data);
71  bool onRightBtnRelease(void* data);
72  void onMouseWheel(void* data);
73  void onMouseMove(void* data);
74 
76  virtual SUMOReal getRotation() const;
77 
79  virtual SUMOReal getXPos() const;
80 
82  virtual SUMOReal getYPos() const;
83 
85  virtual SUMOReal getZoom() const;
86 
88  void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true);
89 
91  void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
92 
93 
94  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
95  * view intact (by showing more / less instead of zooming)
96  * The canvass is clipped/enlarged on the left side of the screen
97  *
98  * @param[in] change The horizontal change in canvas size in pixels
99  */
100  void changeCanvassLeft(int change);
101 
102  /* @brief avoid unwanted flicker
103  * @param[in] delay The minimum time delay in nanoseconds after
104  * mouseDown after which mouse-movements should be interpreted as zoom/drag
105  */
106  void setDragDelay(FXTime delay) {
107  myDragDelay = delay;
108  }
109 
110 private:
111  /* Performs the view movement
112  * @param[in] xdiff the change to myViewCenter in pixel
113  * @param[in] ydiff the change to myViewCenter in pixel
114  */
115  void move(int xdiff, int ydiff);
116 
118  void zoom(SUMOReal factor);
119 
121  void rotate(int diff);
122 
123 private:
126 
129 
132 
135 
138 
140  FXTime myDragDelay;
142 
143 
144 private:
147 
150 
151 };
152 
153 
154 #endif
155 
156 /****************************************************************************/
157