#include <GUIDanielPerspectiveChanger.h>

Definition at line 55 of file GUIDanielPerspectiveChanger.h.
Public Types | |
| enum | MouseState { MOUSEBTN_NONE = 0, MOUSEBTN_LEFT = 1, MOUSEBTN_RIGHT = 2, MOUSEBTN_MIDDLE = 4 } |
Public Member Functions | |
| void | applyCanvasSize (size_t width, size_t height) |
| Informs the changer aboud the size of the canvas. | |
| void | centerTo (const Boundary &netBoundary, Boundary bound, bool applyZoom=true) |
| Centers the view to show the given boundary. | |
| void | centerTo (const Boundary &netBoundary, const Position2D &pos, SUMOReal radius, bool applyZoom=true) |
| Centers the view to the given position, setting it to a size that covers the radius. | |
| FXint | getMouseXPosition () const |
| Returns the last mouse x-position an event occured at. | |
| FXint | getMouseYPosition () const |
| Returns the last mouse y-position an event occured at. | |
| virtual SUMOReal | getRotation () const |
| Returns the rotation of the canvas stored in this changer. | |
| virtual SUMOReal | getXPos () const |
| Returns the x-offset of the field to show stored in this changer. | |
| virtual SUMOReal | getYPos () const |
| Returns the y-offset of the field to show stored in this changer. | |
| virtual SUMOReal | getZoom () const |
| Returns the zoom factor computed stored in this changer. | |
| GUIDanielPerspectiveChanger (GUISUMOAbstractView &callBack) | |
| Constructor. | |
| void | onLeftBtnPress (void *data) |
| bool | onLeftBtnRelease (void *data) |
| void | onMouseMove (void *data) |
| void | onMouseWheel (void *data) |
| void | onRightBtnPress (void *data) |
| bool | onRightBtnRelease (void *data) |
| void | recenterView () |
| recenters the view to display the whole network | |
| void | setNetSizes (size_t width, size_t height) |
| Sets the sizes of the network. | |
| void | setViewport (SUMOReal zoom, SUMOReal xPos, SUMOReal yPos) |
| Sets the viewport. | |
| ~GUIDanielPerspectiveChanger () | |
| Destructor. | |
Protected Attributes | |
| GUISUMOAbstractView & | myCallback |
| The parent window (canvas to scale). | |
| size_t | myCanvasHeight |
| size_t | myCanvasWidth |
| The sizes of the canvas. | |
| FXint | myMouseXPosition |
| the current mouse position | |
| FXint | myMouseYPosition |
| size_t | myNetHeight |
| size_t | myNetWidth |
| The sizes of the network. | |
Private Member Functions | |
| void | move (int xdiff, int ydiff) |
| Performs the view movement. | |
| void | rotate (int diff) |
| Performs the rotation of the view. | |
| void | zoom (int diff) |
| Performs the zooming of the view. | |
Private Attributes | |
| int | myHeightInPixels |
| int | myMouseButtonState |
| the current mouse state | |
| bool | myMoveOnClick |
| Information whether the user has moved the cursor while pressing a mouse button. | |
| SUMOReal | myNetScale |
| the scale of the net (the maximum size, either width or height) | |
| SUMOReal | myRotation |
| the current rotation | |
| Position2D | myViewCenter |
| the current center of the view | |
| int | myWidthInPixels |
| the sizes of the window | |
| SUMOReal | myZoom |
| the current zoom factor | |
enum GUIPerspectiveChanger::MouseState [inherited] |
Definition at line 59 of file GUIPerspectiveChanger.h.
00059 { 00060 MOUSEBTN_NONE = 0, 00061 MOUSEBTN_LEFT = 1, 00062 MOUSEBTN_RIGHT = 2, 00063 MOUSEBTN_MIDDLE = 4 00064 };
| GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger | ( | GUISUMOAbstractView & | callBack | ) |
Constructor.
Definition at line 43 of file GUIDanielPerspectiveChanger.cpp.
00045 : GUIPerspectiveChanger(callBack), 00046 myViewCenter(0, 0), myRotation(0), myZoom(100), 00047 myMouseButtonState(MOUSEBTN_NONE), myMoveOnClick(false) {}
| GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger | ( | ) |
Informs the changer aboud the size of the canvas.
Definition at line 56 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myCanvasHeight, and GUIPerspectiveChanger::myCanvasWidth.
Referenced by GUISUMOAbstractView::onConfigure().
00056 { 00057 myCanvasWidth = width; 00058 myCanvasHeight = height; 00059 }
| void GUIDanielPerspectiveChanger::centerTo | ( | const Boundary & | netBoundary, | |
| Boundary | bound, | |||
| bool | applyZoom = true | |||
| ) | [virtual] |
Centers the view to show the given boundary.
Implements GUIPerspectiveChanger.
Definition at line 130 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getCenter(), Boundary::getHeight(), Boundary::getWidth(), Position2D::mul(), myViewCenter, myZoom, Position2D::set(), Position2D::sub(), and SUMOReal.
00132 { 00133 myViewCenter.set(bound.getCenter()); 00134 myViewCenter.sub(netBoundary.getCenter()); 00135 myViewCenter.mul(-1.0); 00136 if (applyZoom) { 00137 myZoom = 00138 bound.getWidth() > bound.getHeight() ? 00139 (SUMOReal) 100.0 * (SUMOReal) netBoundary.getWidth() / (SUMOReal) bound.getWidth() : 00140 (SUMOReal) 100.0 * (SUMOReal) netBoundary.getHeight() / (SUMOReal) bound.getHeight(); 00141 } 00142 }
| void GUIDanielPerspectiveChanger::centerTo | ( | const Boundary & | netBoundary, | |
| const Position2D & | pos, | |||
| SUMOReal | 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 114 of file GUIDanielPerspectiveChanger.cpp.
References Boundary::getCenter(), Boundary::getHeight(), Boundary::getWidth(), Position2D::mul(), myViewCenter, myZoom, Position2D::set(), Position2D::sub(), and SUMOReal.
00116 { 00117 myViewCenter.set(pos); 00118 myViewCenter.sub(netBoundary.getCenter()); 00119 myViewCenter.mul(-1.0); 00120 if (applyZoom) { 00121 myZoom = 00122 netBoundary.getWidth() < netBoundary.getHeight() ? 00123 (SUMOReal) 25.0 * (SUMOReal) netBoundary.getWidth() / radius : 00124 (SUMOReal) 25.0 * (SUMOReal) netBoundary.getHeight() / radius; 00125 } 00126 }
| FXint GUIPerspectiveChanger::getMouseXPosition | ( | ) | const [inherited] |
Returns the last mouse x-position an event occured at.
Definition at line 91 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myMouseXPosition.
00091 { 00092 return myMouseXPosition; 00093 }
| FXint GUIPerspectiveChanger::getMouseYPosition | ( | ) | const [inherited] |
Returns the last mouse y-position an event occured at.
Definition at line 97 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myMouseYPosition.
00097 { 00098 return myMouseYPosition; 00099 }
| SUMOReal GUIDanielPerspectiveChanger::getRotation | ( | ) | const [virtual] |
Returns the rotation of the canvas stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 81 of file GUIDanielPerspectiveChanger.cpp.
References myRotation.
00081 { 00082 return myRotation; 00083 }
| SUMOReal GUIDanielPerspectiveChanger::getXPos | ( | ) | const [virtual] |
Returns the x-offset of the field to show stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 87 of file GUIDanielPerspectiveChanger.cpp.
References myViewCenter, and Position2D::x().
00087 { 00088 return myViewCenter.x(); 00089 }
| SUMOReal GUIDanielPerspectiveChanger::getYPos | ( | ) | const [virtual] |
Returns the y-offset of the field to show stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 93 of file GUIDanielPerspectiveChanger.cpp.
References myViewCenter, and Position2D::y().
00093 { 00094 return myViewCenter.y(); 00095 }
| SUMOReal GUIDanielPerspectiveChanger::getZoom | ( | ) | const [virtual] |
Returns the zoom factor computed stored in this changer.
Implements GUIPerspectiveChanger.
Definition at line 99 of file GUIDanielPerspectiveChanger.cpp.
References myZoom.
00099 { 00100 return myZoom; 00101 }
| void GUIDanielPerspectiveChanger::move | ( | int | xdiff, | |
| int | ydiff | |||
| ) | [private] |
Performs the view movement.
Definition at line 54 of file GUIDanielPerspectiveChanger.cpp.
References Position2D::add(), GUIPerspectiveChanger::myCallback, myViewCenter, GUISUMOAbstractView::p2m(), and SUMOReal.
Referenced by onMouseMove().
00054 { 00055 myViewCenter.add((SUMOReal) -myCallback.p2m((SUMOReal) xdiff), (SUMOReal) myCallback.p2m((SUMOReal) ydiff)); 00056 myCallback.update(); 00057 }
| void GUIDanielPerspectiveChanger::onLeftBtnPress | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 147 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_LEFT, myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
00147 { 00148 myMouseButtonState |= MOUSEBTN_LEFT; 00149 FXEvent* e = (FXEvent*) data; 00150 myMouseXPosition = e->win_x; 00151 myMouseYPosition = e->win_y; 00152 myMoveOnClick = false; 00153 }
| bool GUIDanielPerspectiveChanger::onLeftBtnRelease | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 157 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_LEFT, myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
00157 { 00158 myMouseButtonState &= !MOUSEBTN_LEFT; 00159 FXEvent* e = (FXEvent*) data; 00160 myMouseXPosition = e->win_x; 00161 myMouseYPosition = e->win_y; 00162 return myMoveOnClick; 00163 }
| void GUIDanielPerspectiveChanger::onMouseMove | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 206 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_LEFT, GUIPerspectiveChanger::MOUSEBTN_RIGHT, move(), GUIPerspectiveChanger::myCallback, myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, myMoveOnClick, rotate(), GUISUMOAbstractView::setWindowCursorPosition(), GUISUMOAbstractView::updateToolTip(), and zoom().
00206 { 00207 FXEvent* e = (FXEvent*) data; 00208 myCallback.setWindowCursorPosition(e->win_x, e->win_y); 00209 int xdiff = myMouseXPosition - e->win_x; 00210 int ydiff = myMouseYPosition - e->win_y; 00211 switch (myMouseButtonState) { 00212 case MOUSEBTN_LEFT: 00213 move(xdiff, ydiff); 00214 if (xdiff!=0||ydiff!=0) { 00215 myMoveOnClick = true; 00216 } 00217 break; 00218 case MOUSEBTN_RIGHT: 00219 zoom(ydiff); 00220 rotate(xdiff); 00221 if (xdiff!=0||ydiff!=0) { 00222 myMoveOnClick = true; 00223 } 00224 break; 00225 default: 00226 if (xdiff!=0||ydiff!=0) { 00227 myCallback.updateToolTip(); 00228 } 00229 break; 00230 } 00231 myMouseXPosition = e->win_x; 00232 myMouseYPosition = e->win_y; 00233 }
| void GUIDanielPerspectiveChanger::onMouseWheel | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 189 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myCallback, GUISUMOAbstractView::updateToolTip(), and zoom().
00189 { 00190 FXEvent* e = (FXEvent*) data; 00191 int diff = 10; 00192 if (e->state&CONTROLMASK) { 00193 diff = 5; 00194 } else if (e->state&SHIFTMASK) { 00195 diff = 20; 00196 } 00197 if (e->code < 0) { 00198 diff = -diff; 00199 } 00200 zoom(diff); 00201 myCallback.updateToolTip(); 00202 }
| void GUIDanielPerspectiveChanger::onRightBtnPress | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 167 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_RIGHT, myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
00167 { 00168 myMouseButtonState |= MOUSEBTN_RIGHT; 00169 FXEvent* e = (FXEvent*) data; 00170 myMouseXPosition = e->win_x; 00171 myMouseYPosition = e->win_y; 00172 myMoveOnClick = false; 00173 }
| bool GUIDanielPerspectiveChanger::onRightBtnRelease | ( | void * | data | ) | [virtual] |
Reimplemented from GUIPerspectiveChanger.
Definition at line 177 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::MOUSEBTN_RIGHT, myMouseButtonState, GUIPerspectiveChanger::myMouseXPosition, GUIPerspectiveChanger::myMouseYPosition, and myMoveOnClick.
00177 { 00178 myMouseButtonState &= !MOUSEBTN_RIGHT; 00179 if (data != 0) { 00180 FXEvent* e = (FXEvent*) data; 00181 myMouseXPosition = e->win_x; 00182 myMouseYPosition = e->win_y; 00183 } 00184 return myMoveOnClick; 00185 }
| void GUIDanielPerspectiveChanger::recenterView | ( | ) | [virtual] |
recenters the view to display the whole network
Implements GUIPerspectiveChanger.
Definition at line 105 of file GUIDanielPerspectiveChanger.cpp.
References myRotation, myViewCenter, myZoom, and Position2D::set().
00105 { 00106 myRotation = 0; 00107 myViewCenter.set(0, 0); 00108 myZoom = 100; 00109 }
| void GUIDanielPerspectiveChanger::rotate | ( | int | diff | ) | [private] |
Performs the rotation of the view.
Definition at line 72 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myCallback, myRotation, and SUMOReal.
Referenced by onMouseMove().
00072 { 00073 if (false) {//myCallback.allowRotation()) { 00074 myRotation += (SUMOReal) diff / (SUMOReal) 10.0; 00075 myCallback.update(); 00076 } 00077 }
Sets the sizes of the network.
Definition at line 49 of file GUIPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myNetHeight, and GUIPerspectiveChanger::myNetWidth.
00049 { 00050 myNetWidth = width; 00051 myNetHeight = height; 00052 }
| void GUIDanielPerspectiveChanger::setViewport | ( | SUMOReal | zoom, | |
| SUMOReal | xPos, | |||
| SUMOReal | yPos | |||
| ) | [virtual] |
Sets the viewport.
Implements GUIPerspectiveChanger.
Definition at line 237 of file GUIDanielPerspectiveChanger.cpp.
References myViewCenter, myZoom, and Position2D::set().
00238 { 00239 myZoom = zoom; 00240 myViewCenter.set(xPos, yPos); 00241 }
| void GUIDanielPerspectiveChanger::zoom | ( | int | diff | ) | [private] |
Performs the zooming of the view.
Definition at line 61 of file GUIDanielPerspectiveChanger.cpp.
References GUIPerspectiveChanger::myCallback, myZoom, and SUMOReal.
Referenced by onMouseMove(), and onMouseWheel().
00061 { 00062 SUMOReal zoom = (SUMOReal) myZoom 00063 + (SUMOReal) diff /(SUMOReal) 100.0 * (SUMOReal) myZoom; 00064 if (zoom>0.01&&zoom<10000000.0) { 00065 myZoom = zoom; 00066 myCallback.update(); 00067 } 00068 }
GUISUMOAbstractView& GUIPerspectiveChanger::myCallback [protected, inherited] |
The parent window (canvas to scale).
Definition at line 123 of file GUIPerspectiveChanger.h.
Referenced by move(), onMouseMove(), onMouseWheel(), rotate(), and zoom().
size_t GUIPerspectiveChanger::myCanvasHeight [protected, inherited] |
Definition at line 129 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::applyCanvasSize().
size_t GUIPerspectiveChanger::myCanvasWidth [protected, inherited] |
The sizes of the canvas.
Definition at line 129 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::applyCanvasSize().
int GUIDanielPerspectiveChanger::myHeightInPixels [private] |
Definition at line 112 of file GUIDanielPerspectiveChanger.h.
int GUIDanielPerspectiveChanger::myMouseButtonState [private] |
the current mouse state
Definition at line 124 of file GUIDanielPerspectiveChanger.h.
Referenced by onLeftBtnPress(), onLeftBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
FXint GUIPerspectiveChanger::myMouseXPosition [protected, inherited] |
the current mouse position
Definition at line 132 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseXPosition(), onLeftBtnPress(), onLeftBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
FXint GUIPerspectiveChanger::myMouseYPosition [protected, inherited] |
Definition at line 132 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::getMouseYPosition(), onLeftBtnPress(), onLeftBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
Information whether the user has moved the cursor while pressing a mouse button.
Definition at line 127 of file GUIDanielPerspectiveChanger.h.
Referenced by onLeftBtnPress(), onLeftBtnRelease(), onMouseMove(), onRightBtnPress(), and onRightBtnRelease().
size_t GUIPerspectiveChanger::myNetHeight [protected, inherited] |
Definition at line 126 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::setNetSizes().
SUMOReal GUIDanielPerspectiveChanger::myNetScale [private] |
the scale of the net (the maximum size, either width or height)
Definition at line 115 of file GUIDanielPerspectiveChanger.h.
size_t GUIPerspectiveChanger::myNetWidth [protected, inherited] |
The sizes of the network.
Definition at line 126 of file GUIPerspectiveChanger.h.
Referenced by GUIPerspectiveChanger::setNetSizes().
SUMOReal GUIDanielPerspectiveChanger::myRotation [private] |
the current rotation
Definition at line 118 of file GUIDanielPerspectiveChanger.h.
Referenced by getRotation(), recenterView(), and rotate().
the current center of the view
Definition at line 109 of file GUIDanielPerspectiveChanger.h.
Referenced by centerTo(), getXPos(), getYPos(), move(), recenterView(), and setViewport().
int GUIDanielPerspectiveChanger::myWidthInPixels [private] |
SUMOReal GUIDanielPerspectiveChanger::myZoom [private] |
the current zoom factor
Definition at line 121 of file GUIDanielPerspectiveChanger.h.
Referenced by centerTo(), getZoom(), recenterView(), setViewport(), and zoom().
1.5.6