![]() |
Eclipse SUMO - Simulation of Urban MObility
|
#include <GUIDanielPerspectiveChanger.h>
Public Types | |
| enum | MouseState { MOUSEBTN_NONE = 0 , MOUSEBTN_LEFT = 1 , MOUSEBTN_RIGHT = 2 , MOUSEBTN_MIDDLE = 4 } |
| mouse states More... | |
Public Member Functions | |
| 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 | changeCanvasSizeLeft (int change) |
| FXint | getMouseXPosition () const |
| Returns the last mouse x-position an event occurred at. | |
| FXint | getMouseYPosition () const |
| Returns the last mouse y-position an event occurred at. | |
| virtual double | getRotation () const |
| Returns the rotation of the canvas stored in this changer. | |
| Boundary | getViewport (bool fixRatio=true) |
| get viewport | |
| virtual double | getXPos () const |
| Returns the x-offset of the field to show stored in this changer. | |
| 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. | |
| virtual double | getZPos () const |
| Returns the camera height corresponding to the current zoom factor. | |
| GUIDanielPerspectiveChanger (GUISUMOAbstractView &callBack, const Boundary &viewPort) | |
| virtual void | onDoubleClicked (void *data) |
| called when user click two times | |
| long | onKeyPress (void *data) |
| called when user press a key | |
| virtual long | onKeyRelease (void *data) |
| called when user releases a key | |
| void | onLeftBtnPress (void *data) |
| mouse functions | |
| bool | onLeftBtnRelease (void *data) |
| called when user releases left button | |
| void | onMiddleBtnPress (void *data) |
| called when user press middle button | |
| bool | onMiddleBtnRelease (void *data) |
| called when user releases middle button | |
| void | onMouseMove (void *data) |
| called when user moves mouse | |
| void | onMouseWheel (void *data) |
| called when user changes mouse wheel | |
| void | onRightBtnPress (void *data) |
| called when user press right button | |
| bool | onRightBtnRelease (void *data) |
| called when user releases right button | |
| void | setDragDelay (FXTime delay) |
| void | setRotation (double rotation) |
| Sets the rotation. | |
| virtual void | setViewport (const Boundary &viewPort) |
| set viewport | |
| void | setViewport (double zoom, double xPos, double yPos) |
| Sets the viewport. | |
| virtual void | setViewport (double zoom, double xPos, double yPos)=0 |
| Sets the viewport Used for: Adapting a new viewport. | |
| void | setViewportFrom (double xPos, double yPos, double zPos) |
| Alternative method for setting the viewport. | |
| virtual double | zoom2ZPos (double zoom) const |
| Returns the camera height at which the given zoom level is reached. | |
| virtual double | zPos2Zoom (double zPos) const |
| Returns the zoom level that is achieved at a given camera height. | |
| ~GUIDanielPerspectiveChanger () | |
| Destructor. | |
Protected Attributes | |
| GUISUMOAbstractView & | myCallback |
| The parent window (canvas to scale) | |
| FXint | myMouseXPosition = 0 |
| the current mouse position | |
| FXint | myMouseYPosition = 0 |
| Boundary | myViewPort |
| the intended viewport | |
Private Member Functions | |
| GUIDanielPerspectiveChanger (const GUIDanielPerspectiveChanger &) | |
| Invalidated copy constructor. | |
| void | move (int xdiff, int ydiff) |
| GUIDanielPerspectiveChanger & | operator= (const GUIDanielPerspectiveChanger &) |
| Invalidated assignment operator. | |
| Boundary | patchedViewPort () |
| patched viewPort with the same aspect ratio as the canvas | |
| void | rotate (int diff) |
| Performs the rotation of the view. | |
| void | zoom (double factor) |
| Performs the zooming of the view. | |
Private Attributes | |
| FXTime | myDragDelay |
| avoid flicker | |
| int | myMouseButtonState |
| the current mouse state | |
| FXlong | myMouseDownTime |
| bool | myMoveOnClick |
| Information whether the user has moved the cursor while pressing a mouse button. | |
| double | myOrigHeight |
| double | myOrigWidth |
| the original viewport dimensions in m which serve as the reference point for 100% zoom | |
| double | myRotation |
| the current rotation | |
| Position | myZoomBase |
| the network location on which to zoom using right click+drag | |
This changer has the following behaviour:
Definition at line 48 of file GUIDanielPerspectiveChanger.h.
|
inherited |
mouse states
| Enumerator | |
|---|---|
| MOUSEBTN_NONE | |
| MOUSEBTN_LEFT | |
| MOUSEBTN_RIGHT | |
| MOUSEBTN_MIDDLE | |
Definition at line 53 of file GUIPerspectiveChanger.h.
| GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger | ( | GUISUMOAbstractView & | callBack, |
| const Boundary & | viewPort | ||
| ) |
Definition at line 36 of file GUIDanielPerspectiveChanger.cpp.
| GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger | ( | ) |
Destructor.
Definition at line 49 of file GUIDanielPerspectiveChanger.cpp.
|
private |
Invalidated copy constructor.
|
virtual |
Centers the view to the given position, setting it to a size that covers the radius.
Implements GUIPerspectiveChanger.
Definition at line 129 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::add(), getXPos(), getYPos(), Boundary::grow(), Boundary::moveby(), GUIPerspectiveChanger::myViewPort, Position::x(), and Position::y().
|
virtual |
Implements GUIPerspectiveChanger.
Definition at line 303 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, GUISUMOAbstractView::p2m(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().
|
inherited |
Returns the last mouse x-position an event occurred at.
Definition at line 112 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myMouseXPosition.
|
inherited |
Returns the last mouse y-position an event occurred at.
Definition at line 118 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myMouseYPosition.
|
virtual |
Returns the rotation of the canvas stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 87 of file GUIDanielPerspectiveChanger.cpp.
References myRotation.
|
inherited |
get viewport
Definition at line 124 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myViewPort, and GUIPerspectiveChanger::patchedViewPort().
Referenced by GUISUMOAbstractView::applyGLTransform(), GUISUMOAbstractView::getObjectsInBoundary(), GUISUMOAbstractView::getVisibleBoundary(), GUISUMOAbstractView::m2p(), GUISUMOAbstractView::makeSnapshot(), GUISUMOAbstractView::p2m(), GUISUMOAbstractView::paintGLGrid(), and GUISUMOAbstractView::screenPos2NetPos().
|
virtual |
Returns the x-offset of the field to show stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 93 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getCenter(), GUIPerspectiveChanger::myViewPort, and Position::x().
Referenced by centerTo().
|
virtual |
Returns the y-offset of the field to show stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 99 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getCenter(), GUIPerspectiveChanger::myViewPort, and Position::y().
Referenced by centerTo().
|
virtual |
Returns the zoom factor computed stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 105 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getWidth(), myOrigWidth, and GUIPerspectiveChanger::myViewPort.
|
virtual |
Returns the camera height corresponding to the current zoom factor.
Implements GUIPerspectiveChanger.
Definition at line 111 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getWidth(), and GUIPerspectiveChanger::myViewPort.
|
private |
Definition at line 53 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::moveby(), GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, and GUISUMOAbstractView::p2m().
Referenced by onMouseMove().
|
virtualinherited |
called when user click two times
Definition at line 80 of file GUIPerspectiveChanger.cpp.
|
virtual |
called when user press a key
Reimplemented from GUIPerspectiveChanger.
Definition at line 313 of file GUIDanielPerspectiveChanger.cpp.
References GUIVisualizationSettings::gaming, GUICompleteSchemeStorage::getDefault(), Boundary::getHeight(), GUISUMOAbstractView::getPositionInformation(), Boundary::getWidth(), gSchemeStorage, Boundary::moveby(), GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, myZoomBase, GUISUMOAbstractView::recenterView(), GUISUMOAbstractView::updateToolTip(), and zoom().
|
virtualinherited |
called when user releases a key
Definition at line 105 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onKeyRelease().
|
virtual |
mouse functions
called when user press left button
Reimplemented from GUIPerspectiveChanger.
Definition at line 142 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_LEFT, myMouseButtonState, myMouseDownTime, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
|
virtual |
called when user releases left button
Reimplemented from GUIPerspectiveChanger.
Definition at line 153 of file GUIDanielPerspectiveChanger.cpp.
References myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
|
virtual |
called when user press middle button
Reimplemented from GUIPerspectiveChanger.
Definition at line 163 of file GUIDanielPerspectiveChanger.cpp.
References GUISUMOAbstractView::getPositionInformation(), GUIPerspectiveChanger::MOUSEBTN_MIDDLE, GUIPerspectiveChanger::myCallback, myMouseButtonState, myMouseDownTime, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, myMoveOnClick, and myZoomBase.
|
virtual |
called when user releases middle button
Reimplemented from GUIPerspectiveChanger.
Definition at line 175 of file GUIDanielPerspectiveChanger.cpp.
References myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
|
virtual |
called when user moves mouse
Reimplemented from GUIPerspectiveChanger.
Definition at line 236 of file GUIDanielPerspectiveChanger.cpp.
References DEG2RAD, GUIVisualizationSettings::gaming, GUICompleteSchemeStorage::getDefault(), gSchemeStorage, GUIPerspectiveChanger::MOUSEBTN_LEFT, GUIPerspectiveChanger::MOUSEBTN_MIDDLE, GUIPerspectiveChanger::MOUSEBTN_RIGHT, move(), GUIPerspectiveChanger::myCallback, myDragDelay, myMouseButtonState, myMouseDownTime, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, myMoveOnClick, myRotation, rotate(), Position::rotateAround2D(), GUISUMOAbstractView::setWindowCursorPosition(), GUISUMOAbstractView::updateToolTip(), Position::x(), Position::y(), and zoom().
|
virtual |
called when user changes mouse wheel
Reimplemented from GUIPerspectiveChanger.
Definition at line 209 of file GUIDanielPerspectiveChanger.cpp.
References GUISUMOAbstractView::getPositionInformation(), GUIPerspectiveChanger::myCallback, myZoomBase, GUISUMOAbstractView::updateToolTip(), and zoom().
|
virtual |
called when user press right button
Reimplemented from GUIPerspectiveChanger.
Definition at line 185 of file GUIDanielPerspectiveChanger.cpp.
References GUISUMOAbstractView::getPositionInformation(), GUIPerspectiveChanger::MOUSEBTN_RIGHT, GUIPerspectiveChanger::myCallback, myMouseButtonState, myMouseDownTime, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, myMoveOnClick, and myZoomBase.
|
virtual |
called when user releases right button
Reimplemented from GUIPerspectiveChanger.
Definition at line 197 of file GUIDanielPerspectiveChanger.cpp.
References myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
|
private |
Invalidated assignment operator.
|
privateinherited |
patched viewPort with the same aspect ratio as the canvas
Definition at line 140 of file GUIPerspectiveChanger.cpp.
References Boundary::getHeight(), Boundary::getWidth(), Boundary::growWidth(), GUIPerspectiveChanger::myCallback, and GUIPerspectiveChanger::myViewPort.
Referenced by GUIPerspectiveChanger::getViewport().
|
private |
Performs the rotation of the view.
Definition at line 76 of file GUIDanielPerspectiveChanger.cpp.
Referenced by onMouseMove().
|
inline |
Definition at line 114 of file GUIDanielPerspectiveChanger.h.
References myDragDelay.
|
virtual |
Sets the rotation.
Implements GUIPerspectiveChanger.
Definition at line 298 of file GUIDanielPerspectiveChanger.cpp.
References myRotation.
|
virtual |
set viewport
Reimplemented from GUIPerspectiveChanger.
Definition at line 153 of file GUIPerspectiveChanger.cpp.
|
virtual |
Sets the viewport.
Implements GUIPerspectiveChanger.
Definition at line 280 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::add(), Boundary::growHeight(), Boundary::growWidth(), GUIPerspectiveChanger::myCallback, myOrigHeight, myOrigWidth, GUIPerspectiveChanger::myViewPort, and zoom().
Referenced by setViewportFrom().
|
virtual |
Sets the viewport Used for: Adapting a new viewport.
Implements GUIPerspectiveChanger.
|
virtual |
Alternative method for setting the viewport.
Implements GUIPerspectiveChanger.
Definition at line 292 of file GUIDanielPerspectiveChanger.cpp.
References setViewport(), and zPos2Zoom().
|
private |
Performs the zooming of the view.
Definition at line 60 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getCenter(), GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, myZoomBase, Position::x(), Boundary::xmax(), Boundary::xmin(), Position::y(), Boundary::ymax(), and Boundary::ymin().
Referenced by onKeyPress(), onMouseMove(), onMouseWheel(), setViewport(), and zoom2ZPos().
|
virtual |
Returns the camera height at which the given zoom level is reached.
Implements GUIPerspectiveChanger.
Definition at line 117 of file GUIDanielPerspectiveChanger.cpp.
References myOrigWidth, and zoom().
|
virtual |
Returns the zoom level that is achieved at a given camera height.
Implements GUIPerspectiveChanger.
Definition at line 123 of file GUIDanielPerspectiveChanger.cpp.
References myOrigWidth.
Referenced by setViewportFrom().
|
protectedinherited |
The parent window (canvas to scale)
Definition at line 157 of file GUIPerspectiveChanger.h.
Referenced by GUIOSGPerspectiveChanger::centerTo(), changeCanvasSizeLeft(), GUIOSGPerspectiveChanger::getPositionOnGround(), move(), onKeyPress(), onMiddleBtnPress(), onMouseMove(), onMouseWheel(), onRightBtnPress(), GUIPerspectiveChanger::patchedViewPort(), setViewport(), and zoom().
|
private |
avoid flicker
Definition at line 148 of file GUIDanielPerspectiveChanger.h.
Referenced by onMouseMove(), and setDragDelay().
|
private |
the current mouse state
Definition at line 139 of file GUIDanielPerspectiveChanger.h.
Referenced by onLeftBtnPress(), onLeftBtnRelease(), onMiddleBtnPress(), onMiddleBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
|
private |
Definition at line 149 of file GUIDanielPerspectiveChanger.h.
Referenced by onLeftBtnPress(), onMiddleBtnPress(), onMouseMove(), and onRightBtnPress().
|
protectedinherited |
the current mouse position
Definition at line 160 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseXPosition(), onLeftBtnPress(), onLeftBtnRelease(), onMiddleBtnPress(), onMiddleBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
|
protectedinherited |
Definition at line 161 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseYPosition(), onLeftBtnPress(), onLeftBtnRelease(), onMiddleBtnPress(), onMiddleBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
|
private |
Information whether the user has moved the cursor while pressing a mouse button.
Definition at line 142 of file GUIDanielPerspectiveChanger.h.
Referenced by onLeftBtnPress(), onLeftBtnRelease(), onMiddleBtnPress(), onMiddleBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
|
private |
Definition at line 133 of file GUIDanielPerspectiveChanger.h.
Referenced by setViewport().
|
private |
the original viewport dimensions in m which serve as the reference point for 100% zoom
Definition at line 133 of file GUIDanielPerspectiveChanger.h.
Referenced by getZoom(), setViewport(), zoom2ZPos(), and zPos2Zoom().
|
private |
the current rotation
Definition at line 136 of file GUIDanielPerspectiveChanger.h.
Referenced by getRotation(), onMouseMove(), and setRotation().
|
protectedinherited |
the intended viewport
Definition at line 164 of file GUIPerspectiveChanger.h.
Referenced by centerTo(), changeCanvasSizeLeft(), GUIPerspectiveChanger::getViewport(), getXPos(), getYPos(), getZoom(), getZPos(), move(), onKeyPress(), GUIPerspectiveChanger::patchedViewPort(), GUIPerspectiveChanger::setViewport(), setViewport(), GUIOSGPerspectiveChanger::updateViewport(), and zoom().
|
private |
the network location on which to zoom using right click+drag
Definition at line 145 of file GUIDanielPerspectiveChanger.h.
Referenced by onKeyPress(), onMiddleBtnPress(), onMouseWheel(), onRightBtnPress(), and zoom().