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 /****************************************************************************/
16 // A class that allows to steer the visual output in dependence to
17 /****************************************************************************/
18 #ifndef GUIDanielPerspectiveChanger_h
19 #define GUIDanielPerspectiveChanger_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <utils/geom/Position.h>
28 #include "GUIPerspectiveChanger.h"
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class Boundary;
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
51 public:
52  /* Constructor
53  * @param[in] callBack The view to be udpated upon changes
54  */
55  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
56 
59 
60  void onLeftBtnPress(void* data);
61  bool onLeftBtnRelease(void* data);
62  void onRightBtnPress(void* data);
63  bool onRightBtnRelease(void* data);
64  void onMouseWheel(void* data);
65  void onMouseMove(void* data);
66  long onKeyPress(void* data);
67 
69  virtual double getRotation() const;
70 
72  virtual double getXPos() const;
73 
75  virtual double getYPos() const;
76 
78  virtual double getZoom() const;
79 
81  virtual double getZPos() const;
82 
84  virtual double zoom2ZPos(double zoom) const;
85 
87  virtual double zPos2Zoom(double zPos) const;
88 
90  void centerTo(const Position& pos, double radius, bool applyZoom = true);
91 
93  void setViewport(double zoom, double xPos, double yPos);
94 
96  void setViewportFrom(double xPos, double yPos, double zPos);
97 
99  void setRotation(double rotation);
100 
101  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
102  * view intact (by showing more / less instead of zooming)
103  * The canvass is clipped/enlarged on the left side of the screen
104  *
105  * @param[in] change The horizontal change in canvas size in pixels
106  */
107  void changeCanvasSizeLeft(int change);
108 
109  /* @brief avoid unwanted flicker
110  * @param[in] delay The minimum time delay in nanoseconds after
111  * mouseDown after which mouse-movements should be interpreted as zoom/drag
112  */
113  void setDragDelay(FXTime delay) {
114  myDragDelay = delay;
115  }
116 
117 private:
118  /* Performs the view movement
119  * @param[in] xdiff the change to myViewCenter in pixel
120  * @param[in] ydiff the change to myViewCenter in pixel
121  */
122  void move(int xdiff, int ydiff);
123 
125  void zoom(double factor);
126 
128  void rotate(int diff);
129 
130 private:
133 
135  double myRotation;
136 
139 
142 
145 
147  FXTime myDragDelay;
149 
150 
151 private:
154 
157 
158 };
159 
160 
161 #endif
162 
163 /****************************************************************************/
164 
GUIPerspectiveChanger
Definition: GUIPerspectiveChanger.h:52
GUIDanielPerspectiveChanger::onLeftBtnPress
void onLeftBtnPress(void *data)
mouse functions
Definition: GUIDanielPerspectiveChanger.cpp:143
GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger
~GUIDanielPerspectiveChanger()
Destructor.
Definition: GUIDanielPerspectiveChanger.cpp:50
GUIDanielPerspectiveChanger::zPos2Zoom
virtual double zPos2Zoom(double zPos) const
Returns the zoom level that is achieved at a given camera height.
Definition: GUIDanielPerspectiveChanger.cpp:124
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GUIDanielPerspectiveChanger::operator=
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
GUIDanielPerspectiveChanger::myMouseDownTime
FXlong myMouseDownTime
Definition: GUIDanielPerspectiveChanger.h:148
GUIDanielPerspectiveChanger::getRotation
virtual double getRotation() const
Returns the rotation of the canvas stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:88
GUIDanielPerspectiveChanger::myDragDelay
FXTime myDragDelay
avoid flicker
Definition: GUIDanielPerspectiveChanger.h:147
GUIDanielPerspectiveChanger::onRightBtnRelease
bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIDanielPerspectiveChanger.cpp:176
GUIDanielPerspectiveChanger::onLeftBtnRelease
bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIDanielPerspectiveChanger.cpp:154
GUIDanielPerspectiveChanger::getYPos
virtual double getYPos() const
Returns the y-offset of the field to show stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:100
GUIDanielPerspectiveChanger::myOrigHeight
double myOrigHeight
Definition: GUIDanielPerspectiveChanger.h:132
GUIDanielPerspectiveChanger::zoom
void zoom(double factor)
Performs the zooming of the view.
Definition: GUIDanielPerspectiveChanger.cpp:61
GUIDanielPerspectiveChanger::myZoomBase
Position myZoomBase
the network location on which to zoom using right click+drag
Definition: GUIDanielPerspectiveChanger.h:144
GUIDanielPerspectiveChanger::onRightBtnPress
void onRightBtnPress(void *data)
called when user press right button
Definition: GUIDanielPerspectiveChanger.cpp:164
GUIDanielPerspectiveChanger::setViewportFrom
void setViewportFrom(double xPos, double yPos, double zPos)
Alternative method for setting the viewport.
Definition: GUIDanielPerspectiveChanger.cpp:270
GUIDanielPerspectiveChanger::myMouseButtonState
int myMouseButtonState
the current mouse state
Definition: GUIDanielPerspectiveChanger.h:138
GUIPerspectiveChanger.h
GUIDanielPerspectiveChanger
Definition: GUIDanielPerspectiveChanger.h:50
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GUIDanielPerspectiveChanger::move
void move(int xdiff, int ydiff)
Definition: GUIDanielPerspectiveChanger.cpp:54
GUIDanielPerspectiveChanger::setRotation
void setRotation(double rotation)
Sets the rotation.
Definition: GUIDanielPerspectiveChanger.cpp:276
GUIDanielPerspectiveChanger::rotate
void rotate(int diff)
Performs the rotation of the view.
Definition: GUIDanielPerspectiveChanger.cpp:77
GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger
GUIDanielPerspectiveChanger(const GUIDanielPerspectiveChanger &)
Invalidated copy constructor.
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:118
GUIDanielPerspectiveChanger::setDragDelay
void setDragDelay(FXTime delay)
Definition: GUIDanielPerspectiveChanger.h:113
GUIDanielPerspectiveChanger::getZoom
virtual double getZoom() const
Returns the zoom factor computed stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:106
GUIDanielPerspectiveChanger::changeCanvasSizeLeft
void changeCanvasSizeLeft(int change)
Definition: GUIDanielPerspectiveChanger.cpp:281
config.h
GUIDanielPerspectiveChanger::getZPos
virtual double getZPos() const
Returns the camera height corresponding to the current zoom factor.
Definition: GUIDanielPerspectiveChanger.cpp:112
GUIDanielPerspectiveChanger::myRotation
double myRotation
the current rotation
Definition: GUIDanielPerspectiveChanger.h:135
GUIDanielPerspectiveChanger::setViewport
void setViewport(double zoom, double xPos, double yPos)
Sets the viewport.
Definition: GUIDanielPerspectiveChanger.cpp:258
GUIDanielPerspectiveChanger::onMouseMove
void onMouseMove(void *data)
called when user moves mouse
Definition: GUIDanielPerspectiveChanger.cpp:215
GUIDanielPerspectiveChanger::onKeyPress
long onKeyPress(void *data)
called when user press a key
Definition: GUIDanielPerspectiveChanger.cpp:291
GUIDanielPerspectiveChanger::myOrigWidth
double myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom
Definition: GUIDanielPerspectiveChanger.h:132
GUIDanielPerspectiveChanger::onMouseWheel
void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIDanielPerspectiveChanger.cpp:188
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:130
GUIDanielPerspectiveChanger::getXPos
virtual double getXPos() const
Returns the x-offset of the field to show stored in this changer.
Definition: GUIDanielPerspectiveChanger.cpp:94
GUIDanielPerspectiveChanger::myMoveOnClick
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
Definition: GUIDanielPerspectiveChanger.h:141
GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Definition: GUIDanielPerspectiveChanger.cpp:37