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-2015 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:
62  enum MouseState {
67  };
68 
70  GUIPerspectiveChanger(GUISUMOAbstractView& callBack, const Boundary& viewPort);
71 
73  virtual ~GUIPerspectiveChanger();
74 
75  virtual void onLeftBtnPress(void* data);
76  virtual bool onLeftBtnRelease(void* data);
77  virtual void onRightBtnPress(void* data);
78  virtual bool onRightBtnRelease(void* data);
79  virtual void onMouseWheel(void* data);
80  virtual void onMouseMove(void* data);
81  virtual long onKeyPress(void* data);
82  virtual long onKeyRelease(void* data);
83 
85  virtual SUMOReal getRotation() const = 0;
86 
88  virtual SUMOReal getXPos() const = 0;
89 
91  virtual SUMOReal getYPos() const = 0;
92 
94  virtual SUMOReal getZoom() const = 0;
95 
99  virtual void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true) = 0;
100 
103  virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos) = 0;
104 
106  FXint getMouseXPosition() const;
107 
109  FXint getMouseYPosition() const;
110 
111  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
112  * view intact (by showing more / less instead of zooming)
113  * The canvass is clipped/enlarged on the left side of the screen
114  *
115  * @param[in] change The horizontal change in canvas size in pixels
116  */
117  virtual void changeCanvassLeft(int change) = 0;
118 
119 
120  Boundary getViewport(bool fixRatio = true) {
121  if (fixRatio) {
122  return patchedViewPort();
123  } else {
124  return myViewPort;
125  }
126  }
127 
128 
129  void setViewport(const Boundary& viewPort) {
130  myViewPort = viewPort;
131  }
132 
133 
134 protected:
137 
140 
143 
144 
145 private:
146  // patched viewPort with the same aspect ratio as the canvas
148 
149 
150 private:
153 
156 
157 
158 };
159 
160 
161 #endif
162 
163 /****************************************************************************/
164 
virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos)=0
Sets the viewport Used for: Adapting a new viewport.
virtual void changeCanvassLeft(int change)=0
virtual SUMOReal getZoom() const =0
Returns the zoom factor computed stored in this changer.
GUIPerspectiveChanger & operator=(const GUIPerspectiveChanger &)
Invalidated assignment operator.
void setViewport(const Boundary &viewPort)
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
virtual SUMOReal getXPos() const =0
Returns the x-offset of the field to show stored in this changer.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
virtual bool onLeftBtnRelease(void *data)
virtual bool onRightBtnRelease(void *data)
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
virtual void onLeftBtnPress(void *data)
Boundary getViewport(bool fixRatio=true)
FXint getMouseXPosition() const
Returns the last mouse x-position an event occured at.
Boundary myViewPort
the intended viewport
virtual void onMouseWheel(void *data)
virtual long onKeyPress(void *data)
FXint getMouseYPosition() const
Returns the last mouse y-position an event occured at.
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
virtual void centerTo(const Position &pos, SUMOReal 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.
#define SUMOReal
Definition: config.h:214
virtual void onMouseMove(void *data)
virtual void onRightBtnPress(void *data)
FXint myMouseXPosition
the current mouse position
virtual SUMOReal getYPos() const =0
Returns the y-offset of the field to show stored in this changer.
virtual long onKeyRelease(void *data)
virtual ~GUIPerspectiveChanger()
Destructor.
virtual SUMOReal getRotation() const =0
Returns the rotation of the canvas stored in this changer.