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 /****************************************************************************/
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 
GUIPerspectiveChanger::myViewPort
Boundary myViewPort
the intended viewport
Definition: GUIPerspectiveChanger.h:160
GUIPerspectiveChanger::getMouseYPosition
FXint getMouseYPosition() const
Returns the last mouse y-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:98
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
GUIPerspectiveChanger::onRightBtnPress
virtual void onRightBtnPress(void *data)
called when user press right button
Definition: GUIPerspectiveChanger.cpp:55
Boundary::getHeight
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:161
GUIPerspectiveChanger::onMouseMove
virtual void onMouseMove(void *data)
called when user moves mouse
Definition: GUIPerspectiveChanger.cpp:75
GUIPerspectiveChanger::getViewport
Boundary getViewport(bool fixRatio=true)
get viewport
Definition: GUIPerspectiveChanger.cpp:104
GUIPerspectiveChanger::onKeyPress
virtual long onKeyPress(void *data)
called when user press a key
Definition: GUIPerspectiveChanger.cpp:80
GUIPerspectiveChanger::~GUIPerspectiveChanger
virtual ~GUIPerspectiveChanger()
Destructor.
Definition: GUIPerspectiveChanger.cpp:39
GUISUMOAbstractView.h
GUIPerspectiveChanger::onRightBtnRelease
virtual bool onRightBtnRelease(void *data)
called when user releases right button
Definition: GUIPerspectiveChanger.cpp:60
GUIPerspectiveChanger.h
GUIPerspectiveChanger::getMouseXPosition
FXint getMouseXPosition() const
Returns the last mouse x-position an event occurred at.
Definition: GUIPerspectiveChanger.cpp:92
GUIPerspectiveChanger::onKeyRelease
virtual long onKeyRelease(void *data)
called when user releases a key
Definition: GUIPerspectiveChanger.cpp:86
GUIPerspectiveChanger::onMouseWheel
virtual void onMouseWheel(void *data)
called when user changes mouse wheel
Definition: GUIPerspectiveChanger.cpp:70
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
Boundary::getWidth
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:155
GUIPerspectiveChanger::patchedViewPort
Boundary patchedViewPort()
patched viewPort with the same aspect ratio as the canvas
Definition: GUIPerspectiveChanger.cpp:120
Boundary::growWidth
void growWidth(double by)
Increases the width of the boundary (x-axis)
Definition: Boundary.cpp:310
GUIPerspectiveChanger::onLeftBtnPress
virtual void onLeftBtnPress(void *data)
mouse functions
Definition: GUIPerspectiveChanger.cpp:44
GUIPerspectiveChanger::myMouseYPosition
FXint myMouseYPosition
Definition: GUIPerspectiveChanger.h:157
GUIPerspectiveChanger::myMouseXPosition
FXint myMouseXPosition
the current mouse position
Definition: GUIPerspectiveChanger.h:157
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:33
GUIPerspectiveChanger::onDoubleClicked
virtual void onDoubleClicked(void *data)
called when user click two times
Definition: GUIPerspectiveChanger.cpp:65
config.h
GUIPerspectiveChanger::onLeftBtnRelease
virtual bool onLeftBtnRelease(void *data)
called when user releases left button
Definition: GUIPerspectiveChanger.cpp:49
GUIPerspectiveChanger::myCallback
GUISUMOAbstractView & myCallback
The parent window (canvas to scale)
Definition: GUIPerspectiveChanger.h:154
Boundary::growHeight
void growHeight(double by)
Increases the height of the boundary (y-axis)
Definition: Boundary.cpp:317