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-2018 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 /****************************************************************************/
17 // A class that allows to steer the visual output in dependence to user
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "GUISUMOAbstractView.h"
27 #include "GUIPerspectiveChanger.h"
28 
29 
30 // ===========================================================================
31 // method definitions
32 // ===========================================================================
34  myCallback(callBack),
35  myViewPort(viewPort) {
36 }
37 
38 
40 }
41 
42 
43 void
45 }
46 
47 
48 bool
50  return false;
51 }
52 
53 
54 void
56 }
57 
58 
59 bool
61  return false;
62 }
63 
64 void
66 }
67 
68 
69 void
71 }
72 
73 
74 void
76 }
77 
78 
79 long
81  return 0;
82 }
83 
84 
85 long
87  return 0;
88 }
89 
90 
91 FXint
93  return myMouseXPosition;
94 }
95 
96 
97 FXint
99  return myMouseYPosition;
100 }
101 
102 
103 Boundary
105  if (fixRatio) {
106  return patchedViewPort();
107  } else {
108  return myViewPort;
109  }
110 }
111 
112 
113 void
115  myViewPort = viewPort;
116 }
117 
118 
119 Boundary
121  // avoid division by zero
122  if (myCallback.getHeight() == 0 ||
123  myCallback.getWidth() == 0 ||
124  myViewPort.getHeight() == 0 ||
125  myViewPort.getWidth() == 0) {
126  return myViewPort;
127  }
128  Boundary result = myViewPort;
129  double canvasRatio = (double)myCallback.getWidth() / myCallback.getHeight();
130  double ratio = result.getWidth() / result.getHeight();
131  if (ratio < canvasRatio) {
132  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
133  } else {
134  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
135  }
136  return result;
137 }
138 
139 /****************************************************************************/
140 
FXint getMouseYPosition() const
Returns the last mouse y-position an event occurred at.
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:155
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
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 occurred 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:161
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.