SUMO - Simulation of Urban MObility
GUIPerspectiveChanger.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A class that allows to steer the visual output in dependence to user
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 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "GUISUMOAbstractView.h"
34 #include "GUIPerspectiveChanger.h"
35 
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
41  myCallback(callBack),
42  myViewPort(viewPort) {
43 }
44 
45 
47 }
48 
49 
50 void
52 }
53 
54 
55 bool
57  return false;
58 }
59 
60 
61 void
63 }
64 
65 
66 bool
68  return false;
69 }
70 
71 void
73 }
74 
75 
76 void
78 }
79 
80 
81 void
83 }
84 
85 
86 long
88  return 0;
89 }
90 
91 
92 long
94  return 0;
95 }
96 
97 
98 FXint
100  return myMouseXPosition;
101 }
102 
103 
104 FXint
106  return myMouseYPosition;
107 }
108 
109 
110 Boundary
112  if (fixRatio) {
113  return patchedViewPort();
114  } else {
115  return myViewPort;
116  }
117 }
118 
119 
120 void
122  myViewPort = viewPort;
123 }
124 
125 
126 Boundary
128  // avoid division by zero
129  if (myCallback.getHeight() == 0 ||
130  myCallback.getWidth() == 0 ||
131  myViewPort.getHeight() == 0 ||
132  myViewPort.getWidth() == 0) {
133  return myViewPort;
134  }
135  Boundary result = myViewPort;
136  double canvasRatio = (double)myCallback.getWidth() / myCallback.getHeight();
137  double ratio = result.getWidth() / result.getHeight();
138  if (ratio < canvasRatio) {
139  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
140  } else {
141  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
142  }
143  return result;
144 }
145 
146 /****************************************************************************/
147 
FXint getMouseYPosition() const
Returns the last mouse y-position an event occured at.
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:162
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.
FXint getMouseXPosition() const
Returns the last mouse x-position an event occured at.
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
virtual bool onRightBtnRelease(void *data)
called when user releases right button
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:250
virtual void onLeftBtnPress(void *data)
mouse functions
Boundary getViewport(bool fixRatio=true)
get viewport
Boundary myViewPort
the intended viewport
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:168
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
virtual long onKeyPress(void *data)
called when user press a key
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:243
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 long onKeyRelease(void *data)
called when user releases a key
virtual ~GUIPerspectiveChanger()
Destructor.