SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
83  virtual SUMOReal getRotation() const = 0;
84 
86  virtual SUMOReal getXPos() const = 0;
87 
89  virtual SUMOReal getYPos() const = 0;
90 
92  virtual SUMOReal getZoom() const = 0;
93 
97  virtual void centerTo(const Position& pos, SUMOReal radius, bool applyZoom = true) = 0;
98 
101  virtual void setViewport(SUMOReal zoom, SUMOReal xPos, SUMOReal yPos) = 0;
102 
104  FXint getMouseXPosition() const;
105 
107  FXint getMouseYPosition() const;
108 
109  /* @brief Adapts the viewport so that a change in canvass size keeps most of the
110  * view intact (by showing more / less instead of zooming)
111  * The canvass is clipped/enlarged on the left side of the screen
112  *
113  * @param[in] change The horizontal change in canvas size in pixels
114  */
115  virtual void changeCanvassLeft(int change) = 0;
116 
117 
118  Boundary getViewport(bool fixRatio = true) {
119  if (fixRatio) {
120  return patchedViewPort();
121  } else {
122  return myViewPort;
123  }
124  }
125 
126 
127  void setViewport(const Boundary& viewPort) {
128  myViewPort = viewPort;
129  }
130 
131 
132 protected:
135 
138 
141 
142 
143 private:
144  // patched viewPort with the same aspect ratio as the canvas
146 
147 
148 private:
151 
154 
155 
156 };
157 
158 
159 #endif
160 
161 /****************************************************************************/
162 
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)
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:218
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 ~GUIPerspectiveChanger()
Destructor.
virtual SUMOReal getRotation() const =0
Returns the rotation of the canvas stored in this changer.