Eclipse SUMO - Simulation of Urban MObility
|
#include <GUIOSGPerspectiveChanger.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. 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 | |
GUISUMOAbstractView & | myCallback |
The parent window (canvas to scale) | |
FXint | myMouseXPosition |
the current mouse position | |
FXint | myMouseYPosition |
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. | |
GUIOSGPerspectiveChanger & | operator= (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 | |
Definition at line 34 of file GUIOSGPerspectiveChanger.h.
|
inherited |
mouse states
Enumerator | |
---|---|
MOUSEBTN_NONE | |
MOUSEBTN_LEFT | |
MOUSEBTN_RIGHT | |
MOUSEBTN_MIDDLE |
Definition at line 53 of file GUIPerspectiveChanger.h.
GUIOSGPerspectiveChanger::GUIOSGPerspectiveChanger | ( | GUIOSGView & | callBack, |
const Boundary & | viewPort | ||
) |
Definition at line 33 of file GUIOSGPerspectiveChanger.cpp.
References myCameraManipulator.
GUIOSGPerspectiveChanger::~GUIOSGPerspectiveChanger | ( | ) |
Destructor.
Definition at line 43 of file GUIOSGPerspectiveChanger.cpp.
|
private |
Invalidated copy constructor.
|
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().
|
virtual |
Implements GUIPerspectiveChanger.
Definition at line 239 of file GUIOSGPerspectiveChanger.cpp.
|
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.
|
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().
|
virtual |
Returns the rotation of the canvas stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 73 of file GUIOSGPerspectiveChanger.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 79 of file GUIOSGPerspectiveChanger.cpp.
References myCameraManipulator.
|
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.
|
virtual |
Returns the zoom factor computed stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 103 of file GUIOSGPerspectiveChanger.cpp.
|
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().
|
virtualinherited |
called when user click two times
Definition at line 80 of file GUIPerspectiveChanger.cpp.
|
virtualinherited |
called when user press a key
Reimplemented in GUIDanielPerspectiveChanger.
Definition at line 98 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onKeyPress().
|
virtualinherited |
called when user releases a key
Definition at line 105 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onKeyRelease().
|
virtualinherited |
mouse functions
called when user press left button
Reimplemented in GUIDanielPerspectiveChanger.
Definition at line 42 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onLeftBtnPress(), and GNEViewNet::processClick().
|
virtual |
mouse functions
called when user releases left button
Reimplemented from GUIPerspectiveChanger.
Definition at line 47 of file GUIOSGPerspectiveChanger.cpp.
References updateViewport().
|
virtualinherited |
called when user press middle button
Reimplemented in GUIDanielPerspectiveChanger.
Definition at line 55 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onMiddleBtnPress().
|
virtual |
called when user releases middle button
Reimplemented from GUIPerspectiveChanger.
Definition at line 61 of file GUIOSGPerspectiveChanger.cpp.
References updateViewport().
|
virtual |
called when user moves mouse
Reimplemented from GUIPerspectiveChanger.
Definition at line 67 of file GUIOSGPerspectiveChanger.cpp.
|
virtualinherited |
called when user changes mouse wheel
Reimplemented in GUIDanielPerspectiveChanger.
Definition at line 86 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onMouseWheel().
|
virtualinherited |
called when user press right button
Reimplemented in GUIDanielPerspectiveChanger.
Definition at line 68 of file GUIPerspectiveChanger.cpp.
Referenced by GUISUMOAbstractView::onRightBtnPress().
|
virtual |
called when user releases right button
Reimplemented from GUIPerspectiveChanger.
Definition at line 54 of file GUIOSGPerspectiveChanger.cpp.
References updateViewport().
|
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::growHeight(), Boundary::growWidth(), GUIPerspectiveChanger::myCallback, and GUIPerspectiveChanger::myViewPort.
Referenced by GUIPerspectiveChanger::getViewport().
|
virtual |
Sets the rotation.
Implements GUIPerspectiveChanger.
Definition at line 121 of file GUIOSGPerspectiveChanger.cpp.
References myRotation.
|
virtual |
set viewport
Reimplemented from GUIPerspectiveChanger.
Definition at line 244 of file GUIOSGPerspectiveChanger.cpp.
References Boundary::getCenter(), setViewport(), Position::x(), and Position::y().
|
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().
|
virtual |
Alternative method for setting the viewport.
Implements GUIPerspectiveChanger.
Definition at line 167 of file GUIOSGPerspectiveChanger.cpp.
References myCameraManipulator, and updateViewport().
Referenced by setViewport().
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().
|
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(), GUIPerspectiveChanger::myViewPort, and Boundary::set().
|
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().
|
virtual |
Returns the zoom level that is achieved at a given camera height.
Implements GUIPerspectiveChanger.
Definition at line 109 of file GUIOSGPerspectiveChanger.cpp.
|
protectedinherited |
The parent window (canvas to scale)
Definition at line 157 of file GUIPerspectiveChanger.h.
Referenced by centerTo(), GUIDanielPerspectiveChanger::changeCanvasSizeLeft(), getPositionOnGround(), GUIDanielPerspectiveChanger::move(), GUIDanielPerspectiveChanger::onKeyPress(), GUIDanielPerspectiveChanger::onMiddleBtnPress(), GUIDanielPerspectiveChanger::onMouseMove(), GUIDanielPerspectiveChanger::onMouseWheel(), GUIDanielPerspectiveChanger::onRightBtnPress(), GUIPerspectiveChanger::patchedViewPort(), GUIDanielPerspectiveChanger::setViewport(), and GUIDanielPerspectiveChanger::zoom().
|
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().
|
protectedinherited |
the current mouse position
Definition at line 160 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseXPosition(), GUIDanielPerspectiveChanger::onLeftBtnPress(), GUIDanielPerspectiveChanger::onLeftBtnRelease(), GUIDanielPerspectiveChanger::onMiddleBtnPress(), GUIDanielPerspectiveChanger::onMiddleBtnRelease(), GUIDanielPerspectiveChanger::onMouseMove(), GUIDanielPerspectiveChanger::onRightBtnPress(), and GUIDanielPerspectiveChanger::onRightBtnRelease().
|
protectedinherited |
Definition at line 160 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseYPosition(), GUIDanielPerspectiveChanger::onLeftBtnPress(), GUIDanielPerspectiveChanger::onLeftBtnRelease(), GUIDanielPerspectiveChanger::onMiddleBtnPress(), GUIDanielPerspectiveChanger::onMiddleBtnRelease(), GUIDanielPerspectiveChanger::onMouseMove(), GUIDanielPerspectiveChanger::onRightBtnPress(), and GUIDanielPerspectiveChanger::onRightBtnRelease().
|
private |
Definition at line 115 of file GUIOSGPerspectiveChanger.h.
|
private |
the original viewport dimensions in m which serve as the reference point for 100% zoom
Definition at line 115 of file GUIOSGPerspectiveChanger.h.
|
private |
the current rotation
Definition at line 118 of file GUIOSGPerspectiveChanger.h.
Referenced by centerTo(), getRotation(), and setRotation().
|
protectedinherited |
the intended viewport
Definition at line 163 of file GUIPerspectiveChanger.h.
Referenced by GUIDanielPerspectiveChanger::centerTo(), GUIDanielPerspectiveChanger::changeCanvasSizeLeft(), GUIPerspectiveChanger::getViewport(), GUIDanielPerspectiveChanger::getXPos(), GUIDanielPerspectiveChanger::getYPos(), GUIDanielPerspectiveChanger::getZoom(), GUIDanielPerspectiveChanger::getZPos(), GUIDanielPerspectiveChanger::move(), GUIDanielPerspectiveChanger::onKeyPress(), GUIPerspectiveChanger::patchedViewPort(), GUIPerspectiveChanger::setViewport(), GUIDanielPerspectiveChanger::setViewport(), updateViewport(), and GUIDanielPerspectiveChanger::zoom().