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 /****************************************************************************/
16 // A virtual class that allows to steer the visual output in dependence to
17 /****************************************************************************/
18 #ifndef GUIPerspectiveChanger_h
19 #define GUIPerspectiveChanger_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <fx.h>
28 #include <utils/geom/Boundary.h>
29 #include <utils/geom/Position.h>
30 #include "GUISUMOAbstractView.h"
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
53 public:
55  enum MouseState {
59  MOUSEBTN_MIDDLE = 4
60  };
61 
63  GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
64 
66  virtual ~GUIPerspectiveChanger();
67 
69 
70  virtual void onLeftBtnPress(void* data);
72 
74  virtual bool onLeftBtnRelease(void* data);
75 
77  virtual void onRightBtnPress(void* data);
78 
80  virtual bool onRightBtnRelease(void* data);
81 
83  virtual void onDoubleClicked(void* data);
84 
86  virtual void onMouseWheel(void* data);
87 
89  virtual void onMouseMove(void* data);
90 
92  virtual long onKeyPress(void* data);
93 
95  virtual long onKeyRelease(void* data);
97 
99  virtual double getRotation() const = 0;
100 
102  virtual double getXPos() const = 0;
103 
105  virtual double getYPos() const = 0;
106 
108  virtual double getZoom() const = 0;
109 
111  virtual double getZPos() const = 0;
112 
114  virtual double zoom2ZPos(double zoom) const = 0;
115 
117  virtual double zPos2Zoom(double zPos) const = 0;
118 
120  virtual void centerTo(const Position& pos, double radius, bool applyZoom = true) = 0;
121 
123  virtual void setViewport(double zoom, double xPos, double yPos) = 0;
124 
126  virtual void setViewportFrom(double xPos, double yPos, double zPos) = 0;
127 
129  virtual void setRotation(double rotation) = 0;
130 
132  FXint getMouseXPosition() const;
133 
135  FXint getMouseYPosition() const;
136 
137  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
138  * view intact (by showing more / less instead of zooming)
139  * The canvass is clipped/enlarged on the left side of the screen
140  *
141  * @param[in] change The horizontal change in canvas size in pixels
142  */
143  virtual void changeCanvasSizeLeft(int change) = 0;
144 
146  Boundary getViewport(bool fixRatio = true);
147 
149  void setViewport(const Boundary& viewPort);
150 
151 protected:
154 
157 
160 
161 
162 private:
165 
166 
167 private:
170 
173 };
174 
175 
176 #endif
177 
178 /****************************************************************************/
179 
GUIPerspectiveChanger
Definition: GUIPerspectiveChanger.h:52
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:159
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:97
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GUIPerspectiveChanger::GUIPerspectiveChanger
GUIPerspectiveChanger(const GUIPerspectiveChanger &)
Invalidated copy constructor.
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:54
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
@ MOUSEBTN_LEFT
Definition: GUIPerspectiveChanger.h:57
GUIPerspectiveChanger::onMouseMove
virtual void onMouseMove(void *data)
called when user moves mouse
Definition: GUIPerspectiveChanger.cpp:74
GUIPerspectiveChanger::getViewport
Boundary getViewport(bool fixRatio=true)
get viewport
Definition: GUIPerspectiveChanger.cpp:103
GUIPerspectiveChanger::onKeyPress
virtual long onKeyPress(void *data)
called when user press a key
Definition: GUIPerspectiveChanger.cpp:79
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:38
GUISUMOAbstractView.h
GUIPerspectiveChanger::onRightBtnRelease
virtual bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIPerspectiveChanger.cpp:59
GUIPerspectiveChanger::MOUSEBTN_MIDDLE
@ MOUSEBTN_MIDDLE
Definition: GUIPerspectiveChanger.h:59
GUIPerspectiveChanger::changeCanvasSizeLeft
virtual void changeCanvasSizeLeft(int change)=0
GUIPerspectiveChanger::MOUSEBTN_NONE
@ MOUSEBTN_NONE
Definition: GUIPerspectiveChanger.h:56
GUIPerspectiveChanger::getMouseXPosition
FXint getMouseXPosition() const
Returns the last mouse x-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:91
GUIPerspectiveChanger::onKeyRelease
virtual long onKeyRelease(void *data)
called when user releases a key
Definition: GUIPerspectiveChanger.cpp:85
GUIPerspectiveChanger::onMouseWheel
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIPerspectiveChanger.cpp:69
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUIPerspectiveChanger::patchedViewPort
Boundary patchedViewPort()
patched viewPort with the same aspect ratio as the canvas
Definition: GUIPerspectiveChanger.cpp:119
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
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:55
GUIPerspectiveChanger::onLeftBtnPress
virtual void onLeftBtnPress(void *data)
mouse functions
Definition: GUIPerspectiveChanger.cpp:43
GUIPerspectiveChanger::myMouseYPosition
FXint myMouseYPosition
Definition: GUIPerspectiveChanger.h:156
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:156
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
@ MOUSEBTN_RIGHT
Definition: GUIPerspectiveChanger.h:58
GUIPerspectiveChanger::GUIPerspectiveChanger
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
Definition: GUIPerspectiveChanger.cpp:32
GUIPerspectiveChanger::onDoubleClicked
virtual void onDoubleClicked(void *data)
called when user click two times
Definition: GUIPerspectiveChanger.cpp:64
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:48
GUIPerspectiveChanger::myCallback
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
Definition: GUIPerspectiveChanger.h:153