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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A class that allows to steer the visual output in dependence to
20 /****************************************************************************/
21 #ifndef GUIDanielPerspectiveChanger_h
22 #define GUIDanielPerspectiveChanger_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <utils/geom/Position.h>
35 #include "GUIPerspectiveChanger.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class Boundary;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
58 public:
59  /* Constructor
60  * @param[in] callBack The view to be udpated upon changes
61  */
62  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
63 
66 
67  void onLeftBtnPress(void* data);
68  bool onLeftBtnRelease(void* data);
69  void onRightBtnPress(void* data);
70  bool onRightBtnRelease(void* data);
71  void onMouseWheel(void* data);
72  void onMouseMove(void* data);
73  long onKeyPress(void* data);
74 
76  virtual double getRotation() const;
77 
79  virtual double getXPos() const;
80 
82  virtual double getYPos() const;
83 
85  virtual double getZoom() const;
86 
88  virtual double getZPos() const;
89 
91  virtual double zoom2ZPos(double zoom) const;
92 
94  virtual double zPos2Zoom(double zPos) const;
95 
97  void centerTo(const Position& pos, double radius, bool applyZoom = true);
98 
100  void setViewport(double zoom, double xPos, double yPos);
101 
103  void setViewportFrom(double xPos, double yPos, double zPos);
104 
105  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
106  * view intact (by showing more / less instead of zooming)
107  * The canvass is clipped/enlarged on the left side of the screen
108  *
109  * @param[in] change The horizontal change in canvas size in pixels
110  */
111  void changeCanvasSizeLeft(int change);
112 
113  /* @brief avoid unwanted flicker
114  * @param[in] delay The minimum time delay in nanoseconds after
115  * mouseDown after which mouse-movements should be interpreted as zoom/drag
116  */
117  void setDragDelay(FXTime delay) {
118  myDragDelay = delay;
119  }
120 
121 private:
122  /* Performs the view movement
123  * @param[in] xdiff the change to myViewCenter in pixel
124  * @param[in] ydiff the change to myViewCenter in pixel
125  */
126  void move(int xdiff, int ydiff);
127 
129  void zoom(double factor);
130 
132  void rotate(int diff);
133 
134 private:
137 
139  double myRotation;
140 
143 
146 
149 
151  FXTime myDragDelay;
153 
154 
155 private:
158 
161 
162 };
163 
164 
165 #endif
166 
167 /****************************************************************************/
168 
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:47
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:45
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.