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-2019 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 
GUIPerspectiveChanger
Definition: GUIPerspectiveChanger.h:53
GUIDanielPerspectiveChanger::onLeftBtnPress
void onLeftBtnPress(void *data)
mouse functions
Definition: GUIDanielPerspectiveChanger.cpp:144
GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger
~GUIDanielPerspectiveChanger()
Destructor.
Definition: GUIDanielPerspectiveChanger.cpp:51
GUIDanielPerspectiveChanger::zPos2Zoom
virtual double zPos2Zoom(double zPos) const
Returns the zoom level that is achieved at a given camera height.
Definition: GUIDanielPerspectiveChanger.cpp:125
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GUIDanielPerspectiveChanger::operator=
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
GUIDanielPerspectiveChanger::myMouseDownTime
FXlong myMouseDownTime
Definition: GUIDanielPerspectiveChanger.h:149
GUIDanielPerspectiveChanger::getRotation
virtual double getRotation() const
Returns the rotation of the canvas stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:89
GUIDanielPerspectiveChanger::myDragDelay
FXTime myDragDelay
avoid flicker
Definition: GUIDanielPerspectiveChanger.h:148
GUIDanielPerspectiveChanger::onRightBtnRelease
bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIDanielPerspectiveChanger.cpp:177
GUIDanielPerspectiveChanger::onLeftBtnRelease
bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIDanielPerspectiveChanger.cpp:155
GUIDanielPerspectiveChanger::getYPos
virtual double getYPos() const
Returns the y-offset of the field to show stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:101
GUIDanielPerspectiveChanger::myOrigHeight
double myOrigHeight
Definition: GUIDanielPerspectiveChanger.h:133
GUIDanielPerspectiveChanger::zoom
void zoom(double factor)
Performs the zooming of the view.
Definition: GUIDanielPerspectiveChanger.cpp:62
GUIDanielPerspectiveChanger::myZoomBase
Position myZoomBase
the network location on which to zoom using right click+drag
Definition: GUIDanielPerspectiveChanger.h:145
GUIDanielPerspectiveChanger::onRightBtnPress
void onRightBtnPress(void *data)
called when user press right button
Definition: GUIDanielPerspectiveChanger.cpp:165
GUIDanielPerspectiveChanger::setViewportFrom
void setViewportFrom(double xPos, double yPos, double zPos)
Alternative method for setting the viewport.
Definition: GUIDanielPerspectiveChanger.cpp:271
GUIDanielPerspectiveChanger::myMouseButtonState
int myMouseButtonState
the current mouse state
Definition: GUIDanielPerspectiveChanger.h:139
GUIPerspectiveChanger.h
GUIDanielPerspectiveChanger
Definition: GUIDanielPerspectiveChanger.h:51
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GUIDanielPerspectiveChanger::move
void move(int xdiff, int ydiff)
Definition: GUIDanielPerspectiveChanger.cpp:55
GUIDanielPerspectiveChanger::setRotation
void setRotation(double rotation)
Sets the rotation.
Definition: GUIDanielPerspectiveChanger.cpp:277
GUIDanielPerspectiveChanger::rotate
void rotate(int diff)
Performs the rotation of the view.
Definition: GUIDanielPerspectiveChanger.cpp:78
Position.h
GUIDanielPerspectiveChanger::zoom2ZPos
virtual double zoom2ZPos(double zoom) const
Returns the camera height at which the given zoom level is reached.
Definition: GUIDanielPerspectiveChanger.cpp:119
GUIDanielPerspectiveChanger::setDragDelay
void setDragDelay(FXTime delay)
Definition: GUIDanielPerspectiveChanger.h:114
GUIDanielPerspectiveChanger::getZoom
virtual double getZoom() const
Returns the zoom factor computed stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:107
GUIDanielPerspectiveChanger::changeCanvasSizeLeft
void changeCanvasSizeLeft(int change)
Definition: GUIDanielPerspectiveChanger.cpp:282
config.h
GUIDanielPerspectiveChanger::getZPos
virtual double getZPos() const
Returns the camera height corresponding to the current zoom factor.
Definition: GUIDanielPerspectiveChanger.cpp:113
GUIDanielPerspectiveChanger::myRotation
double myRotation
the current rotation
Definition: GUIDanielPerspectiveChanger.h:136
GUIDanielPerspectiveChanger::setViewport
void setViewport(double zoom, double xPos, double yPos)
Sets the viewport.
Definition: GUIDanielPerspectiveChanger.cpp:259
GUIDanielPerspectiveChanger::onMouseMove
void onMouseMove(void *data)
called when user moves mouse
Definition: GUIDanielPerspectiveChanger.cpp:216
GUIDanielPerspectiveChanger::onKeyPress
long onKeyPress(void *data)
called when user press a key
Definition: GUIDanielPerspectiveChanger.cpp:292
GUIDanielPerspectiveChanger::myOrigWidth
double myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom
Definition: GUIDanielPerspectiveChanger.h:133
GUIDanielPerspectiveChanger::onMouseWheel
void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIDanielPerspectiveChanger.cpp:189
GUIDanielPerspectiveChanger::centerTo
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.
Definition: GUIDanielPerspectiveChanger.cpp:131
GUIDanielPerspectiveChanger::getXPos
virtual double getXPos() const
Returns the x-offset of the field to show stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:95
GUIDanielPerspectiveChanger::myMoveOnClick
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
Definition: GUIDanielPerspectiveChanger.h:142
GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Definition: GUIDanielPerspectiveChanger.cpp:38