Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIDanielPerspectiveChanger Class Reference

#include <GUIDanielPerspectiveChanger.h>

Inheritance diagram for GUIDanielPerspectiveChanger:
[legend]
Collaboration diagram for GUIDanielPerspectiveChanger:
[legend]

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.
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

GUISUMOAbstractViewmyCallback
 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)
GUIDanielPerspectiveChangeroperator= (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

Detailed Description

This changer has the following behaviour:

  • zooming by pressing the right mouse button and moving the mouse vertically
  • rotation by pressing the right mouse button and moving the mouse horizontally
  • network movement by pressing the left mouse button and moving the mouse

Definition at line 48 of file GUIDanielPerspectiveChanger.h.

Member Enumeration Documentation

◆ MouseState

mouse states

Enumerator
MOUSEBTN_NONE 
MOUSEBTN_LEFT 
MOUSEBTN_RIGHT 
MOUSEBTN_MIDDLE 

Definition at line 53 of file GUIPerspectiveChanger.h.

Constructor & Destructor Documentation

◆ GUIDanielPerspectiveChanger() [1/2]

GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger ( GUISUMOAbstractView & callBack,
const Boundary & viewPort )

Definition at line 36 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::GUIPerspectiveChanger(), GUIPerspectiveChanger::MOUSEBTN_NONE, myDragDelay, myMouseButtonState, myMoveOnClick, myOrigHeight, myOrigWidth, myRotation, and myZoomBase.

Referenced by GUIDanielPerspectiveChanger(), and operator=().

Here is the caller graph for this function:

◆ ~GUIDanielPerspectiveChanger()

GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger ( )

Destructor.

Definition at line 49 of file GUIDanielPerspectiveChanger.cpp.

◆ GUIDanielPerspectiveChanger() [2/2]

GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger ( const GUIDanielPerspectiveChanger & )
private

Invalidated copy constructor.

References GUIDanielPerspectiveChanger().

Member Function Documentation

◆ centerTo()

void GUIDanielPerspectiveChanger::centerTo ( const Position & pos,
double radius,
bool applyZoom = true )
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 getXPos(), getYPos(), GUIPerspectiveChanger::myViewPort, Position::x(), and Position::y().

◆ changeCanvasSizeLeft()

void GUIDanielPerspectiveChanger::changeCanvasSizeLeft ( int change)
virtual

◆ getMouseXPosition()

FXint GUIPerspectiveChanger::getMouseXPosition ( ) const
inherited

Returns the last mouse x-position an event occurred at.

Definition at line 112 of file GUIPerspectiveChanger.cpp.

References myMouseXPosition.

◆ getMouseYPosition()

FXint GUIPerspectiveChanger::getMouseYPosition ( ) const
inherited

Returns the last mouse y-position an event occurred at.

Definition at line 118 of file GUIPerspectiveChanger.cpp.

References myMouseYPosition.

◆ getRotation()

double GUIDanielPerspectiveChanger::getRotation ( ) const
virtual

Returns the rotation of the canvas stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 87 of file GUIDanielPerspectiveChanger.cpp.

References myRotation.

◆ getViewport()

Boundary GUIPerspectiveChanger::getViewport ( bool fixRatio = true)
inherited

get viewport

Definition at line 124 of file GUIPerspectiveChanger.cpp.

References myViewPort, and patchedViewPort().

◆ getXPos()

double GUIDanielPerspectiveChanger::getXPos ( ) const
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 GUIPerspectiveChanger::myViewPort.

Referenced by centerTo().

Here is the caller graph for this function:

◆ getYPos()

double GUIDanielPerspectiveChanger::getYPos ( ) const
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 GUIPerspectiveChanger::myViewPort.

Referenced by centerTo().

Here is the caller graph for this function:

◆ getZoom()

double GUIDanielPerspectiveChanger::getZoom ( ) const
virtual

Returns the zoom factor computed stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 105 of file GUIDanielPerspectiveChanger.cpp.

References myOrigWidth, and GUIPerspectiveChanger::myViewPort.

◆ getZPos()

double GUIDanielPerspectiveChanger::getZPos ( ) const
virtual

Returns the camera height corresponding to the current zoom factor.

Implements GUIPerspectiveChanger.

Definition at line 111 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myViewPort.

◆ move()

void GUIDanielPerspectiveChanger::move ( int xdiff,
int ydiff )
private

Definition at line 53 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myCallback, and GUIPerspectiveChanger::myViewPort.

Referenced by onMouseMove().

Here is the caller graph for this function:

◆ onDoubleClicked()

void GUIPerspectiveChanger::onDoubleClicked ( void * data)
virtualinherited

called when user click two times

Definition at line 80 of file GUIPerspectiveChanger.cpp.

◆ onKeyPress()

long GUIDanielPerspectiveChanger::onKeyPress ( void * data)
virtual

called when user press a key

Reimplemented from GUIPerspectiveChanger.

Definition at line 313 of file GUIDanielPerspectiveChanger.cpp.

References gSchemeStorage, GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, myZoomBase, and zoom().

◆ onKeyRelease()

long GUIPerspectiveChanger::onKeyRelease ( void * data)
virtualinherited

called when user releases a key

Definition at line 105 of file GUIPerspectiveChanger.cpp.

◆ onLeftBtnPress()

void GUIDanielPerspectiveChanger::onLeftBtnPress ( void * data)
virtual

◆ onLeftBtnRelease()

bool GUIDanielPerspectiveChanger::onLeftBtnRelease ( void * data)
virtual

◆ onMiddleBtnPress()

void GUIDanielPerspectiveChanger::onMiddleBtnPress ( void * data)
virtual

◆ onMiddleBtnRelease()

bool GUIDanielPerspectiveChanger::onMiddleBtnRelease ( void * data)
virtual

◆ onMouseMove()

◆ onMouseWheel()

void GUIDanielPerspectiveChanger::onMouseWheel ( void * data)
virtual

called when user changes mouse wheel

Reimplemented from GUIPerspectiveChanger.

Definition at line 209 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myCallback, myZoomBase, and zoom().

◆ onRightBtnPress()

void GUIDanielPerspectiveChanger::onRightBtnPress ( void * data)
virtual

◆ onRightBtnRelease()

bool GUIDanielPerspectiveChanger::onRightBtnRelease ( void * data)
virtual

◆ operator=()

GUIDanielPerspectiveChanger & GUIDanielPerspectiveChanger::operator= ( const GUIDanielPerspectiveChanger & )
private

Invalidated assignment operator.

References GUIDanielPerspectiveChanger().

◆ patchedViewPort()

Boundary GUIPerspectiveChanger::patchedViewPort ( )
privateinherited

patched viewPort with the same aspect ratio as the canvas

Definition at line 140 of file GUIPerspectiveChanger.cpp.

References myCallback, and myViewPort.

Referenced by getViewport().

Here is the caller graph for this function:

◆ rotate()

void GUIDanielPerspectiveChanger::rotate ( int diff)
private

Performs the rotation of the view.

Definition at line 76 of file GUIDanielPerspectiveChanger.cpp.

Referenced by onMouseMove().

Here is the caller graph for this function:

◆ setDragDelay()

void GUIDanielPerspectiveChanger::setDragDelay ( FXTime delay)
inline

Definition at line 114 of file GUIDanielPerspectiveChanger.h.

References myDragDelay.

◆ setRotation()

void GUIDanielPerspectiveChanger::setRotation ( double rotation)
virtual

Sets the rotation.

Implements GUIPerspectiveChanger.

Definition at line 298 of file GUIDanielPerspectiveChanger.cpp.

References myRotation.

◆ setViewport() [1/2]

void GUIPerspectiveChanger::setViewport ( const Boundary & viewPort)
virtual

set viewport

Reimplemented from GUIPerspectiveChanger.

Definition at line 153 of file GUIPerspectiveChanger.cpp.

◆ setViewport() [2/2]

void GUIDanielPerspectiveChanger::setViewport ( double zoom,
double xPos,
double yPos )
virtual

Sets the viewport.

Implements GUIPerspectiveChanger.

Definition at line 280 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myCallback, myOrigHeight, myOrigWidth, GUIPerspectiveChanger::myViewPort, and zoom().

Referenced by setViewportFrom().

Here is the caller graph for this function:

◆ setViewportFrom()

void GUIDanielPerspectiveChanger::setViewportFrom ( double xPos,
double yPos,
double zPos )
virtual

Alternative method for setting the viewport.

Implements GUIPerspectiveChanger.

Definition at line 292 of file GUIDanielPerspectiveChanger.cpp.

References setViewport(), and zPos2Zoom().

◆ zoom()

void GUIDanielPerspectiveChanger::zoom ( double factor)
private

Performs the zooming of the view.

Definition at line 60 of file GUIDanielPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myCallback, GUIPerspectiveChanger::myViewPort, and myZoomBase.

Referenced by onKeyPress(), onMouseMove(), onMouseWheel(), setViewport(), and zoom2ZPos().

Here is the caller graph for this function:

◆ zoom2ZPos()

double GUIDanielPerspectiveChanger::zoom2ZPos ( double zoom) const
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().

◆ zPos2Zoom()

double GUIDanielPerspectiveChanger::zPos2Zoom ( double zPos) const
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().

Here is the caller graph for this function:

Field Documentation

◆ myCallback

◆ myDragDelay

FXTime GUIDanielPerspectiveChanger::myDragDelay
private

avoid flicker

Definition at line 148 of file GUIDanielPerspectiveChanger.h.

Referenced by GUIDanielPerspectiveChanger(), onMouseMove(), and setDragDelay().

◆ myMouseButtonState

int GUIDanielPerspectiveChanger::myMouseButtonState
private

◆ myMouseDownTime

FXlong GUIDanielPerspectiveChanger::myMouseDownTime
private

◆ myMouseXPosition

◆ myMouseYPosition

◆ myMoveOnClick

bool GUIDanielPerspectiveChanger::myMoveOnClick
private

Information whether the user has moved the cursor while pressing a mouse button.

Definition at line 142 of file GUIDanielPerspectiveChanger.h.

Referenced by GUIDanielPerspectiveChanger(), onLeftBtnPress(), onLeftBtnRelease(), onMiddleBtnPress(), onMiddleBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().

◆ myOrigHeight

double GUIDanielPerspectiveChanger::myOrigHeight
private

Definition at line 133 of file GUIDanielPerspectiveChanger.h.

Referenced by GUIDanielPerspectiveChanger(), and setViewport().

◆ myOrigWidth

double GUIDanielPerspectiveChanger::myOrigWidth
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(), GUIDanielPerspectiveChanger(), setViewport(), zoom2ZPos(), and zPos2Zoom().

◆ myRotation

double GUIDanielPerspectiveChanger::myRotation
private

the current rotation

Definition at line 136 of file GUIDanielPerspectiveChanger.h.

Referenced by getRotation(), GUIDanielPerspectiveChanger(), onMouseMove(), and setRotation().

◆ myViewPort

◆ myZoomBase

Position GUIDanielPerspectiveChanger::myZoomBase
private

the network location on which to zoom using right click+drag

Definition at line 145 of file GUIDanielPerspectiveChanger.h.

Referenced by GUIDanielPerspectiveChanger(), onKeyPress(), onMiddleBtnPress(), onMouseWheel(), onRightBtnPress(), and zoom().


The documentation for this class was generated from the following files: