SUMO - Simulation of Urban MObility
GUIDanielPerspectiveChanger.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A class that allows to steer the visual output in dependence to
18 /****************************************************************************/
19 #ifndef GUIDanielPerspectiveChanger_h
20 #define GUIDanielPerspectiveChanger_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <utils/geom/Position.h>
29 #include "GUIPerspectiveChanger.h"
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class Boundary;
36 
37 
38 // ===========================================================================
39 // class definitions
40 // ===========================================================================
52 public:
53  /* Constructor
54  * @param[in] callBack The view to be udpated upon changes
55  */
56  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
57 
60 
61  void onLeftBtnPress(void* data);
62  bool onLeftBtnRelease(void* data);
63  void onRightBtnPress(void* data);
64  bool onRightBtnRelease(void* data);
65  void onMouseWheel(void* data);
66  void onMouseMove(void* data);
67  long onKeyPress(void* data);
68 
70  virtual double getRotation() const;
71 
73  virtual double getXPos() const;
74 
76  virtual double getYPos() const;
77 
79  virtual double getZoom() const;
80 
82  virtual double getZPos() const;
83 
85  virtual double zoom2ZPos(double zoom) const;
86 
88  virtual double zPos2Zoom(double zPos) const;
89 
91  void centerTo(const Position& pos, double radius, bool applyZoom = true);
92 
94  void setViewport(double zoom, double xPos, double yPos);
95 
97  void setViewportFrom(double xPos, double yPos, double zPos);
98 
100  void setRotation(double rotation);
101 
102  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
103  * view intact (by showing more / less instead of zooming)
104  * The canvass is clipped/enlarged on the left side of the screen
105  *
106  * @param[in] change The horizontal change in canvas size in pixels
107  */
108  void changeCanvasSizeLeft(int change);
109 
110  /* @brief avoid unwanted flicker
111  * @param[in] delay The minimum time delay in nanoseconds after
112  * mouseDown after which mouse-movements should be interpreted as zoom/drag
113  */
114  void setDragDelay(FXTime delay) {
115  myDragDelay = delay;
116  }
117 
118 private:
119  /* Performs the view movement
120  * @param[in] xdiff the change to myViewCenter in pixel
121  * @param[in] ydiff the change to myViewCenter in pixel
122  */
123  void move(int xdiff, int ydiff);
124 
126  void zoom(double factor);
127 
129  void rotate(int diff);
130 
131 private:
134 
136  double myRotation;
137 
140 
143 
146 
148  FXTime myDragDelay;
150 
151 
152 private:
155 
158 
159 };
160 
161 
162 #endif
163 
164 /****************************************************************************/
165 
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:42
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 ...
void setRotation(double rotation)
Sets the rotation.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
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.