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-2017 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 double getRotation() const;
78 
80  virtual double getXPos() const;
81 
83  virtual double getYPos() const;
84 
86  virtual double getZoom() const;
87 
89  virtual double getZPos() const;
90 
92  virtual double zoom2ZPos(double zoom) const;
93 
95  virtual double zPos2Zoom(double zPos) const;
96 
98  void centerTo(const Position& pos, double radius, bool applyZoom = true);
99 
101  void setViewport(double zoom, double xPos, double yPos);
102 
104  void setViewportFrom(double xPos, double yPos, double zPos);
105 
106  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
107  * view intact (by showing more / less instead of zooming)
108  * The canvass is clipped/enlarged on the left side of the screen
109  *
110  * @param[in] change The horizontal change in canvas size in pixels
111  */
112  void changeCanvasSizeLeft(int change);
113 
114  /* @brief avoid unwanted flicker
115  * @param[in] delay The minimum time delay in nanoseconds after
116  * mouseDown after which mouse-movements should be interpreted as zoom/drag
117  */
118  void setDragDelay(FXTime delay) {
119  myDragDelay = delay;
120  }
121 
122 private:
123  /* Performs the view movement
124  * @param[in] xdiff the change to myViewCenter in pixel
125  * @param[in] ydiff the change to myViewCenter in pixel
126  */
127  void move(int xdiff, int ydiff);
128 
130  void zoom(double factor);
131 
133  void rotate(int diff);
134 
135 private:
138 
140  double myRotation;
141 
144 
147 
150 
152  FXTime myDragDelay;
154 
155 
156 private:
159 
162 
163 };
164 
165 
166 #endif
167 
168 /****************************************************************************/
169 
double myRotation
the current rotation
virtual double getXPos() const
Returns the x-offset of the field to show stored in this changer.
virtual double getZoom() const
Returns the zoom factor computed stored in this changer.
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
void onRightBtnPress(void *data)
called when user press right button
bool onLeftBtnRelease(void *data)
called when user releases left button
long onKeyPress(void *data)
called when user press a key
void zoom(double factor)
Performs the zooming of the view.
Position myZoomBase
the network location on which to zoom using right click+drag
void setViewport(double zoom, double xPos, double yPos)
Sets the viewport.
void rotate(int diff)
Performs the rotation of the view.
void setViewportFrom(double xPos, double yPos, double zPos)
Alternative method for setting the viewport.
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
virtual double getYPos() const
Returns the y-offset of the field to show stored in this changer.
void onLeftBtnPress(void *data)
mouse functions
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void onMouseWheel(void *data)
called when user changes mouse wheel
bool onRightBtnRelease(void *data)
called when user releases right button
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
double myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom ...
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
int myMouseButtonState
the current mouse state
void onMouseMove(void *data)
called when user moves mouse
void centerTo(const Position &pos, double radius, bool applyZoom=true)
Centers the view to the given position, setting it to a size that covers the radius.
virtual double getZPos() const
Returns the camera height corresponding to the current zoom factor.
virtual double zoom2ZPos(double zoom) const
Returns the camera height at which the given zoom level is reached.
virtual double getRotation() const
Returns the rotation of the canvas stored in this changer.
virtual double zPos2Zoom(double zPos) const
Returns the zoom level that is achieved at a given camera height.