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
GUIBusStop.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A lane area vehicles can halt at (gui-version)
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 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
#ifdef _WIN32
34
#include <windows.h>
35
#endif
36
37
#include <GL/gl.h>
38
39
#include <string>
40
#include <
utils/common/MsgHandler.h
>
41
#include <
utils/geom/PositionVector.h
>
42
#include <
utils/geom/Line.h
>
43
#include <
utils/geom/Boundary.h
>
44
#include <
utils/gui/div/GLHelper.h
>
45
#include <
utils/common/ToString.h
>
46
#include <
microsim/MSNet.h
>
47
#include <
microsim/MSLane.h
>
48
#include <
microsim/MSEdge.h
>
49
#include <
guisim/GUINet.h
>
50
#include <
guisim/GUIEdge.h
>
51
#include "
GUIBusStop.h
"
52
#include <
utils/gui/globjects/GUIGLObjectPopupMenu.h
>
53
#include <
utils/gui/windows/GUIAppEnum.h
>
54
#include <
gui/GUIGlobals.h
>
55
#include <
utils/gui/div/GUIParameterTableWindow.h
>
56
#include <
gui/GUIApplicationWindow.h
>
57
#include <
utils/gui/images/GUITexturesHelper.h
>
58
#include <
microsim/logging/FunctionBinding.h
>
59
#include <
utils/gui/div/GUIGlobalSelection.h
>
60
#include <
foreign/polyfonts/polyfonts.h
>
61
#include <
utils/geom/GeomHelper.h
>
62
#include <
gui/GUIApplicationWindow.h
>
63
#include <
guisim/GUIBusStop.h
>
64
65
#ifdef CHECK_MEMORY_LEAKS
66
#include <
foreign/nvwa/debug_new.h
>
67
#endif // CHECK_MEMORY_LEAKS
68
69
70
// ===========================================================================
71
// method definitions
72
// ===========================================================================
73
GUIBusStop::GUIBusStop
(
const
std::string&
id
,
const
std::vector<std::string> &lines,
MSLane
& lane,
74
SUMOReal
frompos,
SUMOReal
topos)
75
:
MSBusStop
(id, lines, lane, frompos, topos),
76
GUIGlObject_AbstractAdd
(
"bus_stop"
,
GLO_TRIGGER
, id) {
77
myFGShape
= lane.
getShape
();
78
myFGShape
.
move2side
((
SUMOReal
) 1.65);
79
myFGShape
=
myFGShape
.
getSubpart
(frompos, topos);
80
myFGShapeRotations
.reserve(
myFGShape
.
size
() - 1);
81
myFGShapeLengths
.reserve(
myFGShape
.
size
() - 1);
82
int
e = (
int
)
myFGShape
.
size
() - 1;
83
for
(
int
i = 0; i < e; ++i) {
84
const
Position
& f =
myFGShape
[i];
85
const
Position
& s =
myFGShape
[i + 1];
86
myFGShapeLengths
.push_back(f.
distanceTo
(s));
87
myFGShapeRotations
.push_back((
SUMOReal
) atan2((s.
x
() - f.
x
()), (f.
y
() - s.
y
())) * (
SUMOReal
) 180.0 / (
SUMOReal
)
PI
);
88
}
89
PositionVector
tmp =
myFGShape
;
90
tmp.
move2side
(1.5);
91
myFGSignPos
= tmp.
getLineCenter
();
92
myFGSignRot
= 0;
93
if
(tmp.
length
() != 0) {
94
myFGSignRot
=
myFGShape
.
rotationDegreeAtLengthPosition
(
SUMOReal
((
myFGShape
.
length
() / 2.)));
95
myFGSignRot
-= 90;
96
}
97
}
98
99
100
GUIBusStop::~GUIBusStop
() {}
101
102
103
GUIGLObjectPopupMenu
*
104
GUIBusStop::getPopUpMenu
(
GUIMainWindow
& app,
105
GUISUMOAbstractView
& parent) {
106
GUIGLObjectPopupMenu
* ret =
new
GUIGLObjectPopupMenu
(app, parent, *
this
);
107
buildPopupHeader
(ret, app);
108
buildCenterPopupEntry
(ret);
109
buildNameCopyPopupEntry
(ret);
110
buildSelectionPopupEntry
(ret);
111
buildPositionCopyEntry
(ret,
false
);
112
return
ret;
113
}
114
115
116
GUIParameterTableWindow
*
117
GUIBusStop::getParameterWindow
(
GUIMainWindow
&,
118
GUISUMOAbstractView
&) {
119
return
0;
120
}
121
122
123
void
124
GUIBusStop::drawGL
(
const
GUIVisualizationSettings
& s)
const
{
125
glPushName(
getGlID
());
126
glPushMatrix();
127
RGBColor
green(76. / 255., 170. / 255., 50. / 255.);
128
RGBColor
yellow(255. / 255., 235. / 255., 0. / 255.);
129
// draw the area
130
size_t
i;
131
glTranslated(0, 0,
getType
());
132
GLHelper::setColor
(green);
133
GLHelper::drawBoxLines
(
myFGShape
,
myFGShapeRotations
,
myFGShapeLengths
, 1.0);
134
// draw details unless zoomed out to far
135
if
(s.
scale
* s.
addExaggeration
>= 10) {
136
// draw the lines
137
for
(i = 0; i !=
myLines
.size(); ++i) {
138
glPushMatrix();
139
glTranslated(
myFGSignPos
.
x
(),
myFGSignPos
.
y
(), 0);
140
glRotated(180, 1, 0, 0);
141
glRotated(
myFGSignRot
, 0, 0, 1);
142
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
143
pfSetPosition
(0, 0);
144
pfSetScale
(1.f);
145
glScaled(s.
addExaggeration
, s.
addExaggeration
, 1);
146
glTranslated(1.2, -(
double
)i, 0);
147
pfDrawString
(
myLines
[i].c_str());
148
glPopMatrix();
149
}
150
// draw the sign
151
glTranslated(
myFGSignPos
.
x
(),
myFGSignPos
.
y
(), 0);
152
int
noPoints = 9;
153
if
(s.
scale
* s.
addExaggeration
> 25) {
154
noPoints =
MIN2
((
int
)(9.0 + (s.
scale
* s.
addExaggeration
) / 10.0), 36);
155
}
156
glScaled(s.
addExaggeration
, s.
addExaggeration
, 1);
157
GLHelper::drawFilledCircle
((
SUMOReal
) 1.1, noPoints);
158
glTranslated(0, 0, .1);
159
GLHelper::setColor
(yellow);
160
GLHelper::drawFilledCircle
((
SUMOReal
) 0.9, noPoints);
161
if
(s.
scale
* s.
addExaggeration
>= 4.5) {
162
GLHelper::drawText
(
"H"
,
Position
(), .1, 1.6 * s.
addExaggeration
, green,
myFGSignRot
);
163
}
164
}
165
glPopMatrix();
166
drawName
(
getCenteringBoundary
().getCenter(), s.
scale
, s.
addName
);
167
glPopName();
168
}
169
170
171
Boundary
172
GUIBusStop::getCenteringBoundary
()
const
{
173
Boundary
b =
myFGShape
.
getBoxBoundary
();
174
b.
grow
(20);
175
return
b;
176
}
177
178
179
180
/****************************************************************************/
181
tmp
buildd
sumo-0.15.0~dfsg
src
guisim
GUIBusStop.cpp
Generated on Sun May 27 2012 14:52:04 for SUMO - Simulation of Urban MObility by
1.8.1