SUMO - Simulation of Urban MObility
GUIPerspectiveChanger.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A class that allows to steer the visual output in dependence to user
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "GUISUMOAbstractView.h"
33 #include "GUIPerspectiveChanger.h"
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
40  myCallback(callBack),
41  myViewPort(viewPort) {
42 }
43 
44 
46 }
47 
48 
49 void
51 }
52 
53 
54 bool
56  return false;
57 }
58 
59 
60 void
62 }
63 
64 
65 bool
67  return false;
68 }
69 
70 void
72 }
73 
74 
75 void
77 }
78 
79 
80 void
82 }
83 
84 
85 long
87  return 0;
88 }
89 
90 
91 long
93  return 0;
94 }
95 
96 
97 FXint
99  return myMouseXPosition;
100 }
101 
102 
103 FXint
105  return myMouseYPosition;
106 }
107 
108 
109 Boundary
111  if (fixRatio) {
112  return patchedViewPort();
113  } else {
114  return myViewPort;
115  }
116 }
117 
118 
119 void
121  myViewPort = viewPort;
122 }
123 
124 
125 Boundary
127  // avoid division by zero
128  if (myCallback.getHeight() == 0 ||
129  myCallback.getWidth() == 0 ||
130  myViewPort.getHeight() == 0 ||
131  myViewPort.getWidth() == 0) {
132  return myViewPort;
133  }
134  Boundary result = myViewPort;
135  double canvasRatio = (double)myCallback.getWidth() / myCallback.getHeight();
136  double ratio = result.getWidth() / result.getHeight();
137  if (ratio < canvasRatio) {
138  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
139  } else {
140  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
141  }
142  return result;
143 }
144 
145 /****************************************************************************/
146 
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:161
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
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:317
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:167
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:310
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.