Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A virtual class that allows to steer the visual output in dependence to
18 /****************************************************************************/
19 #ifndef GUIPerspectiveChanger_h
20 #define GUIPerspectiveChanger_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <fx.h>
29 #include <utils/geom/Boundary.h>
30 #include <utils/geom/Position.h>
31 #include "GUISUMOAbstractView.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
54 public:
56  enum MouseState {
61  };
62 
64  GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
65 
67  virtual ~GUIPerspectiveChanger();
68 
70 
71  virtual void onLeftBtnPress(void* data);
73 
75  virtual bool onLeftBtnRelease(void* data);
76 
78  virtual void onRightBtnPress(void* data);
79 
81  virtual bool onRightBtnRelease(void* data);
82 
84  virtual void onDoubleClicked(void* data);
85 
87  virtual void onMouseWheel(void* data);
88 
90  virtual void onMouseMove(void* data);
91 
93  virtual long onKeyPress(void* data);
94 
96  virtual long onKeyRelease(void* data);
98 
100  virtual double getRotation() const = 0;
101 
103  virtual double getXPos() const = 0;
104 
106  virtual double getYPos() const = 0;
107 
109  virtual double getZoom() const = 0;
110 
112  virtual double getZPos() const = 0;
113 
115  virtual double zoom2ZPos(double zoom) const = 0;
116 
118  virtual double zPos2Zoom(double zPos) const = 0;
119 
121  virtual void centerTo(const Position& pos, double radius, bool applyZoom = true) = 0;
122 
124  virtual void setViewport(double zoom, double xPos, double yPos) = 0;
125 
127  virtual void setViewportFrom(double xPos, double yPos, double zPos) = 0;
128 
130  virtual void setRotation(double rotation) = 0;
131 
133  FXint getMouseXPosition() const;
134 
136  FXint getMouseYPosition() const;
137 
138  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
139  * view intact (by showing more / less instead of zooming)
140  * The canvass is clipped/enlarged on the left side of the screen
141  *
142  * @param[in] change The horizontal change in canvas size in pixels
143  */
144  virtual void changeCanvasSizeLeft(int change) = 0;
145 
147  Boundary getViewport(bool fixRatio = true);
148 
150  void setViewport(const Boundary& viewPort);
151 
152 protected:
155 
158 
161 
162 
163 private:
166 
167 
168 private:
171 
174 };
175 
176 
177 #endif
178 
179 /****************************************************************************/
180 
GUIPerspectiveChanger
Definition: GUIPerspectiveChanger.h:53
GUIPerspectiveChanger::getYPos
virtual double getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
Boundary.h
GUIPerspectiveChanger::myViewPort
Boundary myViewPort
the intended viewport
Definition: GUIPerspectiveChanger.h:160
GUIPerspectiveChanger::operator=
GUIPerspectiveChanger & operator=(const GUIPerspectiveChanger &)
Invalidated assignment operator.
GUIPerspectiveChanger::getMouseYPosition
FXint getMouseYPosition() const
Returns the last mouse y-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:98
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GUIPerspectiveChanger::getZPos
virtual double getZPos() const =0
Returns the camera height corresponding to the current zoom factor.
GUIPerspectiveChanger::onRightBtnPress
virtual void onRightBtnPress(void *data)
called when user press right button
Definition: GUIPerspectiveChanger.cpp:55
GUIPerspectiveChanger::getRotation
virtual double getRotation() const =0
Returns the rotation of the canvas stored in this changer.
GUIPerspectiveChanger::setRotation
virtual void setRotation(double rotation)=0
Sets the rotation.
GUIPerspectiveChanger::MOUSEBTN_LEFT
Definition: GUIPerspectiveChanger.h:58
GUIPerspectiveChanger::onMouseMove
virtual void onMouseMove(void *data)
called when user moves mouse
Definition: GUIPerspectiveChanger.cpp:75
GUIPerspectiveChanger::getViewport
Boundary getViewport(bool fixRatio=true)
get viewport
Definition: GUIPerspectiveChanger.cpp:104
GUIPerspectiveChanger::onKeyPress
virtual long onKeyPress(void *data)
called when user press a key
Definition: GUIPerspectiveChanger.cpp:80
GUIPerspectiveChanger::centerTo
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....
GUIPerspectiveChanger::~GUIPerspectiveChanger
virtual ~GUIPerspectiveChanger()
Destructor.
Definition: GUIPerspectiveChanger.cpp:39
GUISUMOAbstractView.h
GUIPerspectiveChanger::onRightBtnRelease
virtual bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIPerspectiveChanger.cpp:60
GUIPerspectiveChanger::MOUSEBTN_MIDDLE
Definition: GUIPerspectiveChanger.h:60
GUIPerspectiveChanger::changeCanvasSizeLeft
virtual void changeCanvasSizeLeft(int change)=0
GUIPerspectiveChanger::MOUSEBTN_NONE
Definition: GUIPerspectiveChanger.h:57
GUIPerspectiveChanger::getMouseXPosition
FXint getMouseXPosition() const
Returns the last mouse x-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:92
GUIPerspectiveChanger::onKeyRelease
virtual long onKeyRelease(void *data)
called when user releases a key
Definition: GUIPerspectiveChanger.cpp:86
GUIPerspectiveChanger::onMouseWheel
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIPerspectiveChanger.cpp:70
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUIPerspectiveChanger::patchedViewPort
Boundary patchedViewPort()
patched viewPort with the same aspect ratio as the canvas
Definition: GUIPerspectiveChanger.cpp:120
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GUIPerspectiveChanger::getZoom
virtual double getZoom() const =0
Returns the zoom factor computed stored in this changer.
Position.h
GUIPerspectiveChanger::MouseState
MouseState
mouse states
Definition: GUIPerspectiveChanger.h:56
GUIPerspectiveChanger::onLeftBtnPress
virtual void onLeftBtnPress(void *data)
mouse functions
Definition: GUIPerspectiveChanger.cpp:44
GUIPerspectiveChanger::myMouseYPosition
FXint myMouseYPosition
Definition: GUIPerspectiveChanger.h:157
GUIPerspectiveChanger::zoom2ZPos
virtual double zoom2ZPos(double zoom) const =0
Returns the camera height at which the given zoom level is reached.
GUIPerspectiveChanger::myMouseXPosition
FXint myMouseXPosition
the current mouse position
Definition: GUIPerspectiveChanger.h:157
GUIPerspectiveChanger::setViewport
virtual void setViewport(double zoom, double xPos, double yPos)=0
Sets the viewport Used for: Adapting a new viewport.
GUIPerspectiveChanger::zPos2Zoom
virtual double zPos2Zoom(double zPos) const =0
Returns the zoom level that is achieved at a given camera height.
GUIPerspectiveChanger::MOUSEBTN_RIGHT
Definition: GUIPerspectiveChanger.h:59
GUIPerspectiveChanger::GUIPerspectiveChanger
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
Definition: GUIPerspectiveChanger.cpp:33
GUIPerspectiveChanger::onDoubleClicked
virtual void onDoubleClicked(void *data)
called when user click two times
Definition: GUIPerspectiveChanger.cpp:65
config.h
GUIPerspectiveChanger::setViewportFrom
virtual void setViewportFrom(double xPos, double yPos, double zPos)=0
Alternative method for setting the viewport.
GUIPerspectiveChanger::getXPos
virtual double getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
GUIPerspectiveChanger::onLeftBtnRelease
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIPerspectiveChanger.cpp:49
GUIPerspectiveChanger::myCallback
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
Definition: GUIPerspectiveChanger.h:154