Eclipse 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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A class that allows to steer the visual output in dependence to
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <utils/geom/Position.h>
26 #include "GUIPerspectiveChanger.h"
27 
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 class Boundary;
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
49 public:
50  /* Constructor
51  * @param[in] callBack The view to be udpated upon changes
52  */
53  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
54 
57 
58  void onLeftBtnPress(void* data);
59  bool onLeftBtnRelease(void* data);
60  void onRightBtnPress(void* data);
61  bool onRightBtnRelease(void* data);
62  void onMouseWheel(void* data);
63  void onMouseMove(void* data);
64  long onKeyPress(void* data);
65 
67  virtual double getRotation() const;
68 
70  virtual double getXPos() const;
71 
73  virtual double getYPos() const;
74 
76  virtual double getZoom() const;
77 
79  virtual double getZPos() const;
80 
82  virtual double zoom2ZPos(double zoom) const;
83 
85  virtual double zPos2Zoom(double zPos) const;
86 
88  void centerTo(const Position& pos, double radius, bool applyZoom = true);
89 
91  void setViewport(double zoom, double xPos, double yPos);
92 
94  void setViewportFrom(double xPos, double yPos, double zPos);
95 
97  void setRotation(double rotation);
98 
99  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
100  * view intact (by showing more / less instead of zooming)
101  * The canvass is clipped/enlarged on the left side of the screen
102  *
103  * @param[in] change The horizontal change in canvas size in pixels
104  */
105  void changeCanvasSizeLeft(int change);
106 
107  /* @brief avoid unwanted flicker
108  * @param[in] delay The minimum time delay in nanoseconds after
109  * mouseDown after which mouse-movements should be interpreted as zoom/drag
110  */
111  void setDragDelay(FXTime delay) {
112  myDragDelay = delay;
113  }
114 
115 private:
116  /* Performs the view movement
117  * @param[in] xdiff the change to myViewCenter in pixel
118  * @param[in] ydiff the change to myViewCenter in pixel
119  */
120  void move(int xdiff, int ydiff);
121 
123  void zoom(double factor);
124 
126  void rotate(int diff);
127 
128 private:
131 
133  double myRotation;
134 
137 
140 
143 
145  FXTime myDragDelay;
147 
148 
149 private:
152 
155 
156 };
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
virtual double getRotation() const
Returns the rotation of the canvas stored in this changer.
void onRightBtnPress(void *data)
called when user press right button
int myMouseButtonState
the current mouse state
virtual double getYPos() const
Returns the y-offset of the field to show stored in this changer.
virtual double getZoom() const
Returns the zoom factor computed stored in this changer.
void onMouseWheel(void *data)
called when user changes mouse wheel
virtual double zoom2ZPos(double zoom) const
Returns the camera height at which the given zoom level is reached.
void onMouseMove(void *data)
called when user moves mouse
double myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom
virtual double getZPos() const
Returns the camera height corresponding to the current zoom factor.
virtual double getXPos() const
Returns the x-offset of the field to show stored in this changer.
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.
void setRotation(double rotation)
Sets the rotation.
Position myZoomBase
the network location on which to zoom using right click+drag
double myRotation
the current rotation
void rotate(int diff)
Performs the rotation of the view.
bool onLeftBtnRelease(void *data)
called when user releases left button
bool onRightBtnRelease(void *data)
called when user releases right button
GUIDanielPerspectiveChanger(const GUIDanielPerspectiveChanger &)
Invalidated copy constructor.
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
void onLeftBtnPress(void *data)
mouse functions
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
void zoom(double factor)
Performs the zooming of the view.
void setViewport(double zoom, double xPos, double yPos)
Sets the viewport.
long onKeyPress(void *data)
called when user press a key
virtual double zPos2Zoom(double zPos) const
Returns the zoom level that is achieved at a given camera height.
void setViewportFrom(double xPos, double yPos, double zPos)
Alternative method for setting the viewport.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36