SUMO - Simulation of Urban MObility
GUIDanielPerspectiveChanger Class Reference

#include <GUIDanielPerspectiveChanger.h>

Inheritance diagram for GUIDanielPerspectiveChanger:
Inheritance graph
Collaboration diagram for GUIDanielPerspectiveChanger:
Collaboration graph

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. More...
 
void changeCanvasSizeLeft (int change)
 
FXint getMouseXPosition () const
 Returns the last mouse x-position an event occured at. More...
 
FXint getMouseYPosition () const
 Returns the last mouse y-position an event occured at. More...
 
virtual double getRotation () const
 Returns the rotation of the canvas stored in this changer. More...
 
Boundary getViewport (bool fixRatio=true)
 get viewport More...
 
virtual double getXPos () const
 Returns the x-offset of the field to show stored in this changer. More...
 
virtual double getYPos () const
 Returns the y-offset of the field to show stored in this changer. More...
 
virtual double getZoom () const
 Returns the zoom factor computed stored in this changer. More...
 
virtual double getZPos () const
 Returns the camera height corresponding to the current zoom factor. More...
 
 GUIDanielPerspectiveChanger (GUISUMOAbstractView &callBack, const Boundary &viewPort)
 
long onKeyPress (void *data)
 called when user press a key More...
 
void onLeftBtnPress (void *data)
 mouse functions More...
 
bool onLeftBtnRelease (void *data)
 called when user releases left button More...
 
void onMouseMove (void *data)
 called when user moves mouse More...
 
void onMouseWheel (void *data)
 called when user changes mouse wheel More...
 
void onRightBtnPress (void *data)
 called when user press right button More...
 
bool onRightBtnRelease (void *data)
 called when user releases right button More...
 
void setDragDelay (FXTime delay)
 
void setViewport (double zoom, double xPos, double yPos)
 Sets the viewport. More...
 
void setViewport (const Boundary &viewPort)
 set viewport More...
 
void setViewportFrom (double xPos, double yPos, double zPos)
 Alternative method for setting the viewport. More...
 
virtual double zoom2ZPos (double zoom) const
 Returns the camera height at which the given zoom level is reached. More...
 
virtual double zPos2Zoom (double zPos) const
 Returns the zoom level that is achieved at a given camera height. More...
 
 ~GUIDanielPerspectiveChanger ()
 Destructor. More...
 
virtual void onDoubleClicked (void *data)
 called when user click two times More...
 
virtual long onKeyRelease (void *data)
 called when user releases a key More...
 

Protected Attributes

GUISUMOAbstractViewmyCallback
 The parent window (canvas to scale) More...
 
FXint myMouseXPosition
 the current mouse position More...
 
FXint myMouseYPosition
 
Boundary myViewPort
 the intended viewport More...
 

Private Member Functions

 GUIDanielPerspectiveChanger (const GUIDanielPerspectiveChanger &)
 Invalidated copy constructor. More...
 
void move (int xdiff, int ydiff)
 
GUIDanielPerspectiveChangeroperator= (const GUIDanielPerspectiveChanger &)
 Invalidated assignment operator. More...
 
void rotate (int diff)
 Performs the rotation of the view. More...
 
void zoom (double factor)
 Performs the zooming of the view. More...
 

Private Attributes

FXTime myDragDelay
 avoid flicker More...
 
int myMouseButtonState
 the current mouse state More...
 
FXlong myMouseDownTime
 
bool myMoveOnClick
 Information whether the user has moved the cursor while pressing a mouse button. More...
 
double myOrigHeight
 
double myOrigWidth
 the original viewport dimensions in m which serve as the reference point for 100% zoom More...
 
double myRotation
 the current rotation More...
 
Position myZoomBase
 the network location on which to zoom using right click+drag More...
 

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 58 of file GUIDanielPerspectiveChanger.h.

Member Enumeration Documentation

◆ MouseState

mouse states

Enumerator
MOUSEBTN_NONE 
MOUSEBTN_LEFT 
MOUSEBTN_RIGHT 
MOUSEBTN_MIDDLE 

Definition at line 63 of file GUIPerspectiveChanger.h.

Constructor & Destructor Documentation

◆ GUIDanielPerspectiveChanger() [1/2]

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

Definition at line 44 of file GUIDanielPerspectiveChanger.cpp.

◆ ~GUIDanielPerspectiveChanger()

GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger ( )

Destructor.

Definition at line 57 of file GUIDanielPerspectiveChanger.cpp.

◆ GUIDanielPerspectiveChanger() [2/2]

GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger ( const GUIDanielPerspectiveChanger )
private

Invalidated copy constructor.

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 137 of file GUIDanielPerspectiveChanger.cpp.

References Boundary::add(), getXPos(), getYPos(), Boundary::grow(), Boundary::moveby(), 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 occured at.

Definition at line 99 of file GUIPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myMouseXPosition.

◆ getMouseYPosition()

FXint GUIPerspectiveChanger::getMouseYPosition ( ) const
inherited

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

Definition at line 105 of file GUIPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myMouseYPosition.

◆ getRotation()

double GUIDanielPerspectiveChanger::getRotation ( ) const
virtual

Returns the rotation of the canvas stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 95 of file GUIDanielPerspectiveChanger.cpp.

References myRotation.

◆ getViewport()

◆ getXPos()

double GUIDanielPerspectiveChanger::getXPos ( ) const
virtual

Returns the x-offset of the field to show stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 101 of file GUIDanielPerspectiveChanger.cpp.

References Boundary::getCenter(), GUIPerspectiveChanger::myViewPort, and Position::x().

Referenced by centerTo().

◆ getYPos()

double GUIDanielPerspectiveChanger::getYPos ( ) const
virtual

Returns the y-offset of the field to show stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 107 of file GUIDanielPerspectiveChanger.cpp.

References Boundary::getCenter(), GUIPerspectiveChanger::myViewPort, and Position::y().

Referenced by centerTo().

◆ getZoom()

double GUIDanielPerspectiveChanger::getZoom ( ) const
virtual

Returns the zoom factor computed stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 113 of file GUIDanielPerspectiveChanger.cpp.

References Boundary::getWidth(), 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 119 of file GUIDanielPerspectiveChanger.cpp.

References Boundary::getWidth(), and GUIPerspectiveChanger::myViewPort.

◆ move()

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

◆ onDoubleClicked()

void GUIPerspectiveChanger::onDoubleClicked ( void *  data)
virtualinherited

called when user click two times

Definition at line 72 of file GUIPerspectiveChanger.cpp.

◆ onKeyPress()

◆ onKeyRelease()

long GUIPerspectiveChanger::onKeyRelease ( void *  data)
virtualinherited

called when user releases a key

Definition at line 93 of file GUIPerspectiveChanger.cpp.

Referenced by GUISUMOAbstractView::onKeyRelease().

◆ onLeftBtnPress()

void GUIDanielPerspectiveChanger::onLeftBtnPress ( void *  data)
virtual

◆ onLeftBtnRelease()

bool GUIDanielPerspectiveChanger::onLeftBtnRelease ( void *  data)
virtual

◆ onMouseMove()

◆ onMouseWheel()

void GUIDanielPerspectiveChanger::onMouseWheel ( void *  data)
virtual

◆ onRightBtnPress()

◆ onRightBtnRelease()

bool GUIDanielPerspectiveChanger::onRightBtnRelease ( void *  data)
virtual

◆ operator=()

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

Invalidated assignment operator.

◆ rotate()

void GUIDanielPerspectiveChanger::rotate ( int  diff)
private

Performs the rotation of the view.

Definition at line 84 of file GUIDanielPerspectiveChanger.cpp.

Referenced by onMouseMove(), and setDragDelay().

◆ setDragDelay()

void GUIDanielPerspectiveChanger::setDragDelay ( FXTime  delay)
inline

Definition at line 118 of file GUIDanielPerspectiveChanger.h.

References move(), myDragDelay, rotate(), and zoom().

◆ setViewport() [1/2]

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

◆ setViewport() [2/2]

void GUIPerspectiveChanger::setViewport ( const Boundary viewPort)
inherited

set viewport

Definition at line 121 of file GUIPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myViewPort.

◆ setViewportFrom()

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

Alternative method for setting the viewport.

Implements GUIPerspectiveChanger.

Definition at line 271 of file GUIDanielPerspectiveChanger.cpp.

References setViewport(), and zPos2Zoom().

◆ zoom()

void GUIDanielPerspectiveChanger::zoom ( double  factor)
private

◆ 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 125 of file GUIDanielPerspectiveChanger.cpp.

References myOrigWidth.

◆ 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 131 of file GUIDanielPerspectiveChanger.cpp.

References myOrigWidth.

Referenced by setViewportFrom().

Field Documentation

◆ myCallback

GUISUMOAbstractView& GUIPerspectiveChanger::myCallback
protectedinherited

◆ myDragDelay

FXTime GUIDanielPerspectiveChanger::myDragDelay
private

avoid flicker

Definition at line 152 of file GUIDanielPerspectiveChanger.h.

Referenced by onMouseMove(), and setDragDelay().

◆ myMouseButtonState

int GUIDanielPerspectiveChanger::myMouseButtonState
private

the current mouse state

Definition at line 143 of file GUIDanielPerspectiveChanger.h.

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

◆ myMouseDownTime

FXlong GUIDanielPerspectiveChanger::myMouseDownTime
private

Definition at line 153 of file GUIDanielPerspectiveChanger.h.

Referenced by onLeftBtnPress(), onMouseMove(), and onRightBtnPress().

◆ myMouseXPosition

FXint GUIPerspectiveChanger::myMouseXPosition
protectedinherited

◆ myMouseYPosition

FXint GUIPerspectiveChanger::myMouseYPosition
protectedinherited

◆ myMoveOnClick

bool GUIDanielPerspectiveChanger::myMoveOnClick
private

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

Definition at line 146 of file GUIDanielPerspectiveChanger.h.

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

◆ myOrigHeight

double GUIDanielPerspectiveChanger::myOrigHeight
private

Definition at line 137 of file GUIDanielPerspectiveChanger.h.

Referenced by setViewport().

◆ myOrigWidth

double GUIDanielPerspectiveChanger::myOrigWidth
private

the original viewport dimensions in m which serve as the reference point for 100% zoom

Definition at line 137 of file GUIDanielPerspectiveChanger.h.

Referenced by getZoom(), setViewport(), zoom2ZPos(), and zPos2Zoom().

◆ myRotation

double GUIDanielPerspectiveChanger::myRotation
private

the current rotation

Definition at line 140 of file GUIDanielPerspectiveChanger.h.

Referenced by getRotation().

◆ myViewPort

◆ myZoomBase

Position GUIDanielPerspectiveChanger::myZoomBase
private

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

Definition at line 149 of file GUIDanielPerspectiveChanger.h.

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


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