Eclipse 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-2019 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 /****************************************************************************/
16 // A class that allows to steer the visual output in dependence to user
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include "GUISUMOAbstractView.h"
26 #include "GUIPerspectiveChanger.h"
27 
28 
29 // ===========================================================================
30 // method definitions
31 // ===========================================================================
33  myCallback(callBack),
34  myViewPort(viewPort) {
35 }
36 
37 
39 }
40 
41 
42 void
44 }
45 
46 
47 bool
49  return false;
50 }
51 
52 
53 void
55 }
56 
57 
58 bool
60  return false;
61 }
62 
63 void
65 }
66 
67 
68 void
70 }
71 
72 
73 void
75 }
76 
77 
78 long
80  return 0;
81 }
82 
83 
84 long
86  return 0;
87 }
88 
89 
90 FXint
92  return myMouseXPosition;
93 }
94 
95 
96 FXint
98  return myMouseYPosition;
99 }
100 
101 
102 Boundary
104  if (fixRatio) {
105  return patchedViewPort();
106  } else {
107  return myViewPort;
108  }
109 }
110 
111 
112 void
114  myViewPort = viewPort;
115 }
116 
117 
118 Boundary
120  // avoid division by zero
121  if (myCallback.getHeight() == 0 ||
122  myCallback.getWidth() == 0 ||
123  myViewPort.getHeight() == 0 ||
124  myViewPort.getWidth() == 0) {
125  return myViewPort;
126  }
127  Boundary result = myViewPort;
128  double canvasRatio = (double)myCallback.getWidth() / myCallback.getHeight();
129  double ratio = result.getWidth() / result.getHeight();
130  if (ratio < canvasRatio) {
131  result.growWidth(result.getWidth() * (canvasRatio / ratio - 1) / 2);
132  } else {
133  result.growHeight(result.getHeight() * (ratio / canvasRatio - 1) / 2);
134  }
135  return result;
136 }
137 
138 /****************************************************************************/
139 
GUIPerspectiveChanger::myViewPort
Boundary myViewPort
the intended viewport
Definition: GUIPerspectiveChanger.h:159
GUIPerspectiveChanger::getMouseYPosition
FXint getMouseYPosition() const
Returns the last mouse y-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:97
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
GUIPerspectiveChanger::onRightBtnPress
virtual void onRightBtnPress(void *data)
called when user press right button
Definition: GUIPerspectiveChanger.cpp:54
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:160
GUIPerspectiveChanger::onMouseMove
virtual void onMouseMove(void *data)
called when user moves mouse
Definition: GUIPerspectiveChanger.cpp:74
GUIPerspectiveChanger::getViewport
Boundary getViewport(bool fixRatio=true)
get viewport
Definition: GUIPerspectiveChanger.cpp:103
GUIPerspectiveChanger::onKeyPress
virtual long onKeyPress(void *data)
called when user press a key
Definition: GUIPerspectiveChanger.cpp:79
GUIPerspectiveChanger::~GUIPerspectiveChanger
virtual ~GUIPerspectiveChanger()
Destructor.
Definition: GUIPerspectiveChanger.cpp:38
GUISUMOAbstractView.h
GUIPerspectiveChanger::onRightBtnRelease
virtual bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIPerspectiveChanger.cpp:59
GUIPerspectiveChanger.h
GUIPerspectiveChanger::getMouseXPosition
FXint getMouseXPosition() const
Returns the last mouse x-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:91
GUIPerspectiveChanger::onKeyRelease
virtual long onKeyRelease(void *data)
called when user releases a key
Definition: GUIPerspectiveChanger.cpp:85
GUIPerspectiveChanger::onMouseWheel
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIPerspectiveChanger.cpp:69
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:154
GUIPerspectiveChanger::patchedViewPort
Boundary patchedViewPort()
patched viewPort with the same aspect ratio as the canvas
Definition: GUIPerspectiveChanger.cpp:119
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:309
GUIPerspectiveChanger::onLeftBtnPress
virtual void onLeftBtnPress(void *data)
mouse functions
Definition: GUIPerspectiveChanger.cpp:43
GUIPerspectiveChanger::myMouseYPosition
FXint myMouseYPosition
Definition: GUIPerspectiveChanger.h:156
GUIPerspectiveChanger::myMouseXPosition
FXint myMouseXPosition
the current mouse position
Definition: GUIPerspectiveChanger.h:156
GUIPerspectiveChanger::setViewport
virtual void setViewport(double zoom, double xPos, double yPos)=0
Sets the viewport Used for: Adapting a new viewport.
GUIPerspectiveChanger::GUIPerspectiveChanger
GUIPerspectiveChanger(GUISUMOAbstractView &callBack, const Boundary &viewPort)
Constructor.
Definition: GUIPerspectiveChanger.cpp:32
GUIPerspectiveChanger::onDoubleClicked
virtual void onDoubleClicked(void *data)
called when user click two times
Definition: GUIPerspectiveChanger.cpp:64
config.h
GUIPerspectiveChanger::onLeftBtnRelease
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIPerspectiveChanger.cpp:48
GUIPerspectiveChanger::myCallback
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
Definition: GUIPerspectiveChanger.h:153
Boundary::growHeight
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:316