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

#include <GUIOSGPerspectiveChanger.h>

Inheritance diagram for GUIOSGPerspectiveChanger:
[legend]
Collaboration diagram for GUIOSGPerspectiveChanger:
[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. Used for: Centering of vehicles and junctions *‍/.
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.
double getRotation () const
 Returns the rotation of the canvas stored in this changer.
Boundary getViewport (bool fixRatio=true)
 get viewport
double getXPos () const
 Returns the x-offset of the field to show stored in this changer.
double getYPos () const
 Returns the y-offset of the field to show stored in this changer.
double getZoom () const
 Returns the zoom factor computed stored in this changer.
double getZPos () const
 Returns the camera height corresponding to the current zoom factor.
 GUIOSGPerspectiveChanger (GUIOSGView &callBack, const Boundary &viewPort)
virtual void onDoubleClicked (void *data)
 called when user click two times
virtual long onKeyPress (void *data)
 called when user press a key
virtual long onKeyRelease (void *data)
 called when user releases a key
virtual void onLeftBtnPress (void *data)
 mouse functions
bool onLeftBtnRelease (void *data)
 mouse functions
virtual 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
virtual void onMouseWheel (void *data)
 called when user changes mouse wheel
virtual void onRightBtnPress (void *data)
 called when user press right button
bool onRightBtnRelease (void *data)
 called when user releases right button
void setRotation (double rotation)
 Sets the rotation.
void setViewport (const Boundary &viewPort)
 set viewport
void setViewport (double zoom, double xPos, double yPos)
 Sets the viewport Used for: Adapting a new viewport.
void setViewportFrom (double xPos, double yPos, double zPos)
 Alternative method for setting the viewport.
void updateViewport ()
 update the min/max coordinates of the view on the ground plane after changing the camera pos / direction
double zoom2ZPos (double zoom) const
 Returns the camera height at which the given zoom level is reached.
double zPos2Zoom (double zPos) const
 Returns the zoom level that is achieved at a given camera height.
 ~GUIOSGPerspectiveChanger ()
 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

osg::Vec3d getPositionOnGround (double x, double y)
 calculate the position on the ground (in world coordinates) given a normalised view coordinate (x,y ~ [-1;1])
 GUIOSGPerspectiveChanger (const GUIOSGPerspectiveChanger &)
 Invalidated copy constructor.
GUIOSGPerspectiveChangeroperator= (const GUIOSGPerspectiveChanger &)
 Invalidated assignment operator.
Boundary patchedViewPort ()
 patched viewPort with the same aspect ratio as the canvas
void updateViewport (osg::Vec3d &lookFrom)
 update the min/max coordinates of the view on the ground plane after changing the camera pos / direction

Private Attributes

osg::ref_ptr< osgGA::TerrainManipulator > myCameraManipulator
 the OSG camera structure to gather the view coordinates
double myOrigHeight
double myOrigWidth
 the original viewport dimensions in m which serve as the reference point for 100% zoom
double myRotation
 the current rotation

Detailed Description

Definition at line 34 of file GUIOSGPerspectiveChanger.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

◆ GUIOSGPerspectiveChanger() [1/2]

GUIOSGPerspectiveChanger::GUIOSGPerspectiveChanger ( GUIOSGView & callBack,
const Boundary & viewPort )

Definition at line 33 of file GUIOSGPerspectiveChanger.cpp.

References GUIPerspectiveChanger::GUIPerspectiveChanger(), myCameraManipulator, myOrigHeight, myOrigWidth, and myRotation.

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

Here is the caller graph for this function:

◆ ~GUIOSGPerspectiveChanger()

GUIOSGPerspectiveChanger::~GUIOSGPerspectiveChanger ( )

Destructor.

Definition at line 43 of file GUIOSGPerspectiveChanger.cpp.

◆ GUIOSGPerspectiveChanger() [2/2]

GUIOSGPerspectiveChanger::GUIOSGPerspectiveChanger ( const GUIOSGPerspectiveChanger & )
private

Invalidated copy constructor.

References GUIOSGPerspectiveChanger().

Member Function Documentation

◆ centerTo()

void GUIOSGPerspectiveChanger::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. Used for: Centering of vehicles and junctions *‍/.

Implements GUIPerspectiveChanger.

Definition at line 127 of file GUIOSGPerspectiveChanger.cpp.

References DEG2RAD, GUIPerspectiveChanger::myCallback, myCameraManipulator, myRotation, updateViewport(), Position::x(), Position::y(), and Position::z().

◆ changeCanvasSizeLeft()

void GUIOSGPerspectiveChanger::changeCanvasSizeLeft ( int change)
virtual

Implements GUIPerspectiveChanger.

Definition at line 239 of file GUIOSGPerspectiveChanger.cpp.

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

◆ getPositionOnGround()

osg::Vec3d GUIOSGPerspectiveChanger::getPositionOnGround ( double x,
double y )
private

calculate the position on the ground (in world coordinates) given a normalised view coordinate (x,y ~ [-1;1])

Definition at line 218 of file GUIOSGPerspectiveChanger.cpp.

References GUIPerspectiveChanger::myCallback.

Referenced by updateViewport().

Here is the caller graph for this function:

◆ getRotation()

double GUIOSGPerspectiveChanger::getRotation ( ) const
virtual

Returns the rotation of the canvas stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 73 of file GUIOSGPerspectiveChanger.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 GUIOSGPerspectiveChanger::getXPos ( ) const
virtual

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

Implements GUIPerspectiveChanger.

Definition at line 79 of file GUIOSGPerspectiveChanger.cpp.

References myCameraManipulator.

◆ getYPos()

double GUIOSGPerspectiveChanger::getYPos ( ) const
virtual

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

Implements GUIPerspectiveChanger.

Definition at line 87 of file GUIOSGPerspectiveChanger.cpp.

References myCameraManipulator.

◆ getZoom()

double GUIOSGPerspectiveChanger::getZoom ( ) const
virtual

Returns the zoom factor computed stored in this changer.

Implements GUIPerspectiveChanger.

Definition at line 103 of file GUIOSGPerspectiveChanger.cpp.

◆ getZPos()

double GUIOSGPerspectiveChanger::getZPos ( ) const
virtual

Returns the camera height corresponding to the current zoom factor.

Implements GUIPerspectiveChanger.

Definition at line 95 of file GUIOSGPerspectiveChanger.cpp.

References myCameraManipulator.

Referenced by zoom2ZPos().

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 GUIPerspectiveChanger::onKeyPress ( void * data)
virtualinherited

called when user press a key

Reimplemented in GUIDanielPerspectiveChanger.

Definition at line 98 of file GUIPerspectiveChanger.cpp.

◆ onKeyRelease()

long GUIPerspectiveChanger::onKeyRelease ( void * data)
virtualinherited

called when user releases a key

Definition at line 105 of file GUIPerspectiveChanger.cpp.

◆ onLeftBtnPress()

void GUIPerspectiveChanger::onLeftBtnPress ( void * data)
virtualinherited

mouse functions

called when user press left button

Reimplemented in GUIDanielPerspectiveChanger.

Definition at line 42 of file GUIPerspectiveChanger.cpp.

◆ onLeftBtnRelease()

bool GUIOSGPerspectiveChanger::onLeftBtnRelease ( void * data)
virtual

mouse functions

called when user releases left button

Reimplemented from GUIPerspectiveChanger.

Definition at line 47 of file GUIOSGPerspectiveChanger.cpp.

References updateViewport().

◆ onMiddleBtnPress()

void GUIPerspectiveChanger::onMiddleBtnPress ( void * data)
virtualinherited

called when user press middle button

Reimplemented in GUIDanielPerspectiveChanger.

Definition at line 55 of file GUIPerspectiveChanger.cpp.

◆ onMiddleBtnRelease()

bool GUIOSGPerspectiveChanger::onMiddleBtnRelease ( void * data)
virtual

called when user releases middle button

Reimplemented from GUIPerspectiveChanger.

Definition at line 61 of file GUIOSGPerspectiveChanger.cpp.

References updateViewport().

◆ onMouseMove()

void GUIOSGPerspectiveChanger::onMouseMove ( void * data)
virtual

called when user moves mouse

Reimplemented from GUIPerspectiveChanger.

Definition at line 67 of file GUIOSGPerspectiveChanger.cpp.

◆ onMouseWheel()

void GUIPerspectiveChanger::onMouseWheel ( void * data)
virtualinherited

called when user changes mouse wheel

Reimplemented in GUIDanielPerspectiveChanger.

Definition at line 86 of file GUIPerspectiveChanger.cpp.

◆ onRightBtnPress()

void GUIPerspectiveChanger::onRightBtnPress ( void * data)
virtualinherited

called when user press right button

Reimplemented in GUIDanielPerspectiveChanger.

Definition at line 68 of file GUIPerspectiveChanger.cpp.

◆ onRightBtnRelease()

bool GUIOSGPerspectiveChanger::onRightBtnRelease ( void * data)
virtual

called when user releases right button

Reimplemented from GUIPerspectiveChanger.

Definition at line 54 of file GUIOSGPerspectiveChanger.cpp.

References updateViewport().

◆ operator=()

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

Invalidated assignment operator.

References GUIOSGPerspectiveChanger().

◆ 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:

◆ setRotation()

void GUIOSGPerspectiveChanger::setRotation ( double rotation)
virtual

Sets the rotation.

Implements GUIPerspectiveChanger.

Definition at line 121 of file GUIOSGPerspectiveChanger.cpp.

References myRotation.

◆ setViewport() [1/2]

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

set viewport

Reimplemented from GUIPerspectiveChanger.

Definition at line 244 of file GUIOSGPerspectiveChanger.cpp.

References Boundary::getCenter(), setViewport(), Position::x(), and Position::y().

◆ setViewport() [2/2]

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

Sets the viewport Used for: Adapting a new viewport.

Implements GUIPerspectiveChanger.

Definition at line 161 of file GUIOSGPerspectiveChanger.cpp.

References setViewportFrom().

Referenced by setViewport().

Here is the caller graph for this function:

◆ setViewportFrom()

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

Alternative method for setting the viewport.

Implements GUIPerspectiveChanger.

Definition at line 167 of file GUIOSGPerspectiveChanger.cpp.

References myCameraManipulator, and updateViewport().

Referenced by setViewport().

Here is the caller graph for this function:

◆ updateViewport() [1/2]

void GUIOSGPerspectiveChanger::updateViewport ( )

update the min/max coordinates of the view on the ground plane after changing the camera pos / direction

Definition at line 195 of file GUIOSGPerspectiveChanger.cpp.

References myCameraManipulator, and updateViewport().

Referenced by centerTo(), onLeftBtnRelease(), onMiddleBtnRelease(), onRightBtnRelease(), setViewportFrom(), and updateViewport().

Here is the caller graph for this function:

◆ updateViewport() [2/2]

void GUIOSGPerspectiveChanger::updateViewport ( osg::Vec3d & lookFrom)
private

update the min/max coordinates of the view on the ground plane after changing the camera pos / direction

Definition at line 203 of file GUIOSGPerspectiveChanger.cpp.

References getPositionOnGround(), MAX4(), MIN4(), and GUIPerspectiveChanger::myViewPort.

◆ zoom2ZPos()

double GUIOSGPerspectiveChanger::zoom2ZPos ( double zoom) const
virtual

Returns the camera height at which the given zoom level is reached.

Implements GUIPerspectiveChanger.

Definition at line 115 of file GUIOSGPerspectiveChanger.cpp.

References getZPos().

◆ zPos2Zoom()

double GUIOSGPerspectiveChanger::zPos2Zoom ( double zPos) const
virtual

Returns the zoom level that is achieved at a given camera height.

Implements GUIPerspectiveChanger.

Definition at line 109 of file GUIOSGPerspectiveChanger.cpp.

Field Documentation

◆ myCallback

◆ myCameraManipulator

osg::ref_ptr<osgGA::TerrainManipulator> GUIOSGPerspectiveChanger::myCameraManipulator
private

the OSG camera structure to gather the view coordinates

Definition at line 121 of file GUIOSGPerspectiveChanger.h.

Referenced by centerTo(), getXPos(), getYPos(), getZPos(), GUIOSGPerspectiveChanger(), setViewportFrom(), and updateViewport().

◆ myMouseXPosition

◆ myMouseYPosition

◆ myOrigHeight

double GUIOSGPerspectiveChanger::myOrigHeight
private

Definition at line 115 of file GUIOSGPerspectiveChanger.h.

Referenced by GUIOSGPerspectiveChanger().

◆ myOrigWidth

double GUIOSGPerspectiveChanger::myOrigWidth
private

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

Definition at line 115 of file GUIOSGPerspectiveChanger.h.

Referenced by GUIOSGPerspectiveChanger().

◆ myRotation

double GUIOSGPerspectiveChanger::myRotation
private

the current rotation

Definition at line 118 of file GUIOSGPerspectiveChanger.h.

Referenced by centerTo(), getRotation(), GUIOSGPerspectiveChanger(), and setRotation().

◆ myViewPort


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