SUMO - Simulation of Urban MObility
GUIPerspectiveChanger.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A virtual 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-2017 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 GUIPerspectiveChanger_h
23 #define GUIPerspectiveChanger_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 <fx.h>
36 #include <utils/geom/Boundary.h>
37 #include <utils/geom/Position.h>
38 #include "GUISUMOAbstractView.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
61 public:
63  enum MouseState {
68  };
69 
71  GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
72 
74  virtual ~GUIPerspectiveChanger();
75 
77 
78  virtual void onLeftBtnPress(void* data);
80 
82  virtual bool onLeftBtnRelease(void* data);
83 
85  virtual void onRightBtnPress(void* data);
86 
88  virtual bool onRightBtnRelease(void* data);
89 
91  virtual void onDoubleClicked(void* data);
92 
94  virtual void onMouseWheel(void* data);
95 
97  virtual void onMouseMove(void* data);
98 
100  virtual long onKeyPress(void* data);
101 
103  virtual long onKeyRelease(void* data);
105 
107  virtual double getRotation() const = 0;
108 
110  virtual double getXPos() const = 0;
111 
113  virtual double getYPos() const = 0;
114 
116  virtual double getZoom() const = 0;
117 
119  virtual double getZPos() const = 0;
120 
122  virtual double zoom2ZPos(double zoom) const = 0;
123 
125  virtual double zPos2Zoom(double zPos) const = 0;
126 
128  virtual void centerTo(const Position& pos, double radius, bool applyZoom = true) = 0;
129 
131  virtual void setViewport(double zoom, double xPos, double yPos) = 0;
132 
134  virtual void setViewportFrom(double xPos, double yPos, double zPos) = 0;
135 
137  FXint getMouseXPosition() const;
138 
140  FXint getMouseYPosition() const;
141 
142  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
143  * view intact (by showing more / less instead of zooming)
144  * The canvass is clipped/enlarged on the left side of the screen
145  *
146  * @param[in] change The horizontal change in canvas size in pixels
147  */
148  virtual void changeCanvasSizeLeft(int change) = 0;
149 
151  Boundary getViewport(bool fixRatio = true);
152 
154  void setViewport(const Boundary& viewPort);
155 
156 protected:
159 
162 
165 
166 
167 private:
170 
171 
172 private:
175 
178 };
179 
180 
181 #endif
182 
183 /****************************************************************************/
184 
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:48
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:46
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.