Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIDanielPerspectiveChanger.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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>
27
28
29// ===========================================================================
30// class declarations
31// ===========================================================================
32class Boundary;
33
34
35// ===========================================================================
36// class definitions
37// ===========================================================================
49public:
50 /* Constructor
51 * @param[in] callBack The view to be updated upon changes
52 */
54
57
58 void onLeftBtnPress(void* data);
59 bool onLeftBtnRelease(void* data);
60 void onMiddleBtnPress(void* data);
61 bool onMiddleBtnRelease(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
117private:
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
130private:
133
136
139
142
145
149
150
151private:
154
157
158};
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
void onMiddleBtnPress(void *data)
called when user press middle button
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.
bool onMiddleBtnRelease(void *data)
called when user releases middle button
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
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:37