SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUIDanielPerspectiveChanger.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that allows to steer the visual output in dependence to
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUIDanielPerspectiveChanger_h
23 #define GUIDanielPerspectiveChanger_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <utils/geom/Position.h>
36 #include "GUIPerspectiveChanger.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class Boundary;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
59 public:
60  /* Constructor
61  * @param[in] callBack The view to be udpated upon changes
62  */
63  GUIDanielPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
64 
67 
68  void onLeftBtnPress(void* data);
69  bool onLeftBtnRelease(void* data);
70  void onRightBtnPress(void* data);
71  bool onRightBtnRelease(void* data);
72  void onMouseWheel(void* data);
73  void onMouseMove(void* data);
74  long onKeyPress(void* data);
75 
77  virtual SUMOReal getRotation() const;
78 
80  virtual SUMOReal getXPos() const;
81 
83  virtual SUMOReal getYPos() const;
84 
86  virtual SUMOReal getZoom() const;
87 
89  virtual SUMOReal getZPos() const;
90 
92  virtual SUMOReal zoom2ZPos(SUMOReal zoom) const;
93 
95  virtual SUMOReal zPos2Zoom(SUMOReal zPos) const;
96 
98  void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true);
99 
101  void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos);
102 
104  void setViewportFrom(SUMOReal xPos, SUMOReal yPos, SUMOReal zPos);
105 
106  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
107  * view intact (by showing more / less instead of zooming)
108  * The canvass is clipped/enlarged on the left side of the screen
109  *
110  * @param[in] change The horizontal change in canvas size in pixels
111  */
112  void changeCanvassLeft(int change);
113 
114  /* @brief avoid unwanted flicker
115  * @param[in] delay The minimum time delay in nanoseconds after
116  * mouseDown after which mouse-movements should be interpreted as zoom/drag
117  */
118  void setDragDelay(FXTime delay) {
119  myDragDelay = delay;
120  }
121 
122 private:
123  /* Performs the view movement
124  * @param[in] xdiff the change to myViewCenter in pixel
125  * @param[in] ydiff the change to myViewCenter in pixel
126  */
127  void move(int xdiff, int ydiff);
128 
130  void zoom(SUMOReal factor);
131 
133  void rotate(int diff);
134 
135 private:
138 
141 
144 
147 
150 
152  FXTime myDragDelay;
154 
155 
156 private:
159 
162 
163 };
164 
165 
166 #endif
167 
168 /****************************************************************************/
169 
bool myMoveOnClick
Information whether the user has moved the cursor while pressing a mouse button.
void onRightBtnPress(void *data)
called when user press right button
bool onLeftBtnRelease(void *data)
called when user releases left button
long onKeyPress(void *data)
called when user press a key
Position myZoomBase
the network location on which to zoom using right click+drag
virtual SUMOReal getRotation() const
Returns the rotation of the canvas stored in this changer.
void rotate(int diff)
Performs the rotation of the view.
GUIDanielPerspectiveChanger & operator=(const GUIDanielPerspectiveChanger &)
Invalidated assignment operator.
SUMOReal myOrigWidth
the original viewport dimensions in m which serve as the reference point for 100% zoom ...
void onLeftBtnPress(void *data)
mouse functions
virtual SUMOReal getXPos() const
Returns the x-offset of the field to show stored in this changer.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void onMouseWheel(void *data)
called when user changes mouse wheel
bool onRightBtnRelease(void *data)
called when user releases right button
GUIDanielPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void centerTo(const Position &pos, SUMOReal radius, bool applyZoom=true)
Centers the view to the given position, setting it to a size that covers the radius.
int myMouseButtonState
the current mouse state
void onMouseMove(void *data)
called when user moves mouse
virtual SUMOReal getZPos() const
Returns the camera height corresponding to the current zoom factor.
virtual SUMOReal zoom2ZPos(SUMOReal zoom) const
Returns the camera height at which the given zoom level is reached.
virtual SUMOReal zPos2Zoom(SUMOReal zPos) const
Returns the zoom level that is achieved at a given camera height.
void zoom(SUMOReal factor)
Performs the zooming of the view.
SUMOReal myRotation
the current rotation
void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos)
Sets the viewport.
void setViewportFrom(SUMOReal xPos, SUMOReal yPos, SUMOReal zPos)
Alternative method for setting the viewport.
virtual SUMOReal getYPos() const
Returns the y-offset of the field to show stored in this changer.
#define SUMOReal
Definition: config.h:214
virtual SUMOReal getZoom() const
Returns the zoom factor computed stored in this changer.