SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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-sim.org/
12
// Copyright (C) 2001-2013 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
#ifdef CHECK_MEMORY_LEAKS
37
#include <
foreign/nvwa/debug_new.h
>
38
#endif // CHECK_MEMORY_LEAKS
39
40
41
// ===========================================================================
42
// method definitions
43
// ===========================================================================
44
GUIPerspectiveChanger::GUIPerspectiveChanger
(
45
GUISUMOAbstractView
& callBack,
46
const
Boundary
& viewPort) :
47
myCallback(callBack),
48
myViewPort(viewPort) {}
49
50
51
GUIPerspectiveChanger::~GUIPerspectiveChanger
() {}
52
53
54
void
55
GUIPerspectiveChanger::onLeftBtnPress
(
void
*) {}
56
57
58
bool
59
GUIPerspectiveChanger::onLeftBtnRelease
(
void
*) {
60
return
false
;
61
}
62
63
64
void
65
GUIPerspectiveChanger::onRightBtnPress
(
void
*) {}
66
67
68
bool
69
GUIPerspectiveChanger::onRightBtnRelease
(
void
*) {
70
return
false
;
71
}
72
73
74
void
75
GUIPerspectiveChanger::onMouseWheel
(
void
*) {}
76
77
78
void
79
GUIPerspectiveChanger::onMouseMove
(
void
*) {}
80
81
82
FXint
83
GUIPerspectiveChanger::getMouseXPosition
()
const
{
84
return
myMouseXPosition
;
85
}
86
87
88
FXint
89
GUIPerspectiveChanger::getMouseYPosition
()
const
{
90
return
myMouseYPosition
;
91
}
92
93
94
Boundary
95
GUIPerspectiveChanger::patchedViewPort
() {
96
// avoid division by zero
97
if
(
myCallback
.getHeight() == 0 ||
98
myCallback
.getWidth() == 0 ||
99
myViewPort
.
getHeight
() == 0 ||
100
myViewPort
.
getWidth
() == 0) {
101
return
myViewPort
;
102
}
103
Boundary
result =
myViewPort
;
104
SUMOReal
canvasRatio = (
SUMOReal
)
myCallback
.getWidth() /
myCallback
.getHeight();
105
SUMOReal
ratio = result.
getWidth
() / result.
getHeight
();
106
if
(ratio < canvasRatio) {
107
result.
growWidth
(result.
getWidth
() * (canvasRatio / ratio - 1) / 2);
108
}
else
{
109
result.
growHeight
(result.
getHeight
() * (ratio / canvasRatio - 1) / 2);
110
}
111
return
result;
112
}
113
114
/****************************************************************************/
115
build
buildd
sumo-0.18~dfsg
src
utils
gui
windows
GUIPerspectiveChanger.cpp
Generated on Wed Oct 23 2013 01:15:08 for SUMO - Simulation of Urban MObility by
1.8.4