SUMO - Simulation of Urban MObility
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.dlr.de/
12 // Copyright (C) 2001-2016 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  long onKeyPress(void* data);
75 
77  virtual SUMOReal getRotation() const;
78 
80  virtual SUMOReal getXPos() const;
81 
83  virtual SUMOReal getYPos() const;
84 
86  virtual SUMOReal getZoom() const;
87 
89  void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true);
90 
92  void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
93 
94 
95  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
96  * view intact (by showing more / less instead of zooming)
97  * The canvass is clipped/enlarged on the left side of the screen
98  *
99  * @param[in] change The horizontal change in canvas size in pixels
100  */
101  void changeCanvassLeft(int change);
102 
103  /* @brief avoid unwanted flicker
104  * @param[in] delay The minimum time delay in nanoseconds after
105  * mouseDown after which mouse-movements should be interpreted as zoom/drag
106  */
107  void setDragDelay(FXTime delay) {
108  myDragDelay = delay;
109  }
110 
111 private:
112  /* Performs the view movement
113  * @param[in] xdiff the change to myViewCenter in pixel
114  * @param[in] ydiff the change to myViewCenter in pixel
115  */
116  void move(int xdiff, int ydiff);
117 
119  void zoom(SUMOReal factor);
120 
122  void rotate(int diff);
123 
124 private:
127 
130 
133 
136 
139 
141  FXTime myDragDelay;
143 
144 
145 private:
148 
151 
152 };
153 
154 
155 #endif
156 
157 /****************************************************************************/
158 
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
Position myZoomBase
the network location on which to zoom using right click+drag
virtual SUMOReal getRotation() const
Returns the rotation of the canvas stored in this changer.
void rotate(int diff)
Performs the rotation of the view.
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
SUMOReal myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom ...
virtual SUMOReal getXPos() const
Returns the x-offset of the field to show stored in this changer.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void centerTo(const Position &pos, SUMOReal radius, bool applyZoom=true)
Centers the view to the given position, setting it to a size that covers the radius.
int myMouseButtonState
the current mouse state
void zoom(SUMOReal factor)
Performs the zooming of the view.
SUMOReal myRotation
the current rotation
void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos)
Sets the viewport.
virtual SUMOReal getYPos() const
Returns the y-offset of the field to show stored in this changer.
#define SUMOReal
Definition: config.h:213
virtual SUMOReal getZoom() const
Returns the zoom factor computed stored in this changer.