SUMO - Simulation of Urban MObility
GUIPerspectiveChanger.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A virtual class that allows to steer the visual output in dependence to
20 /****************************************************************************/
21 #ifndef GUIPerspectiveChanger_h
22 #define GUIPerspectiveChanger_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <fx.h>
35 #include <utils/geom/Boundary.h>
36 #include <utils/geom/Position.h>
37 #include "GUISUMOAbstractView.h"
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
60 public:
62  enum MouseState {
67  };
68 
70  GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
71 
73  virtual ~GUIPerspectiveChanger();
74 
76 
77  virtual void onLeftBtnPress(void* data);
79 
81  virtual bool onLeftBtnRelease(void* data);
82 
84  virtual void onRightBtnPress(void* data);
85 
87  virtual bool onRightBtnRelease(void* data);
88 
90  virtual void onDoubleClicked(void* data);
91 
93  virtual void onMouseWheel(void* data);
94 
96  virtual void onMouseMove(void* data);
97 
99  virtual long onKeyPress(void* data);
100 
102  virtual long onKeyRelease(void* data);
104 
106  virtual double getRotation() const = 0;
107 
109  virtual double getXPos() const = 0;
110 
112  virtual double getYPos() const = 0;
113 
115  virtual double getZoom() const = 0;
116 
118  virtual double getZPos() const = 0;
119 
121  virtual double zoom2ZPos(double zoom) const = 0;
122 
124  virtual double zPos2Zoom(double zPos) const = 0;
125 
127  virtual void centerTo(const Position& pos, double radius, bool applyZoom = true) = 0;
128 
130  virtual void setViewport(double zoom, double xPos, double yPos) = 0;
131 
133  virtual void setViewportFrom(double xPos, double yPos, double zPos) = 0;
134 
136  FXint getMouseXPosition() const;
137 
139  FXint getMouseYPosition() const;
140 
141  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
142  * view intact (by showing more / less instead of zooming)
143  * The canvass is clipped/enlarged on the left side of the screen
144  *
145  * @param[in] change The horizontal change in canvas size in pixels
146  */
147  virtual void changeCanvasSizeLeft(int change) = 0;
148 
150  Boundary getViewport(bool fixRatio = true);
151 
153  void setViewport(const Boundary& viewPort);
154 
155 protected:
158 
161 
164 
165 
166 private:
169 
170 
171 private:
174 
177 };
178 
179 
180 #endif
181 
182 /****************************************************************************/
183 
virtual void centerTo(const Position &pos, double radius, bool applyZoom=true)=0
Centers the view to the given position, setting it to a size that covers the radius. Used for: Centering of vehicles and junctions */.
FXint getMouseYPosition() const
Returns the last mouse y-position an event occured at.
virtual double zoom2ZPos(double zoom) const =0
Returns the camera height at which the given zoom level is reached.
GUIPerspectiveChanger & operator=(const GUIPerspectiveChanger &)
Invalidated assignment operator.
virtual double getRotation() const =0
Returns the rotation of the canvas stored in this changer.
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
Boundary patchedViewPort()
patched viewPort with the same aspect ratio as the canvas
virtual void setViewport(double zoom, double xPos, double yPos)=0
Sets the viewport Used for: Adapting a new viewport.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
FXint getMouseXPosition() const
Returns the last mouse x-position an event occured at.
virtual double zPos2Zoom(double zPos) const =0
Returns the zoom level that is achieved at a given camera height.
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
virtual bool onRightBtnRelease(void *data)
called when user releases right button
virtual double getZoom() const =0
Returns the zoom factor computed stored in this changer.
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
virtual void onLeftBtnPress(void *data)
mouse functions
Boundary getViewport(bool fixRatio=true)
get viewport
Boundary myViewPort
the intended viewport
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
virtual long onKeyPress(void *data)
called when user press a key
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
virtual void onDoubleClicked(void *data)
called when user click two times
virtual void onMouseMove(void *data)
called when user moves mouse
virtual void onRightBtnPress(void *data)
called when user press right button
FXint myMouseXPosition
the current mouse position
virtual void setViewportFrom(double xPos, double yPos, double zPos)=0
Alternative method for setting the viewport.
virtual long onKeyRelease(void *data)
called when user releases a key
virtual ~GUIPerspectiveChanger()
Destructor.
virtual void changeCanvasSizeLeft(int change)=0
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.