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
GUIJunctionWrapper.cpp
Go to the documentation of this file.
1
/****************************************************************************/
11
// }
12
/****************************************************************************/
13
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14
// Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
15
/****************************************************************************/
16
//
17
// This file is part of SUMO.
18
// SUMO is free software: you can redistribute it and/or modify
19
// it under the terms of the GNU General Public License as published by
20
// the Free Software Foundation, either version 3 of the License, or
21
// (at your option) any later version.
22
//
23
/****************************************************************************/
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#ifdef _MSC_VER
30
#include <
windows_config.h
>
31
#else
32
#include <
config.h
>
33
#endif
34
35
#include <string>
36
#include <utility>
37
#ifdef HAVE_OSG
38
#include <osg/Geometry>
39
#endif
40
#include <
microsim/MSLane.h
>
41
#include <
microsim/MSJunction.h
>
42
#include <
utils/geom/Position.h
>
43
#include <
microsim/MSNet.h
>
44
#include <
microsim/MSInternalJunction.h
>
45
#include <
gui/GUIApplicationWindow.h
>
46
#include <
gui/GUIGlobals.h
>
47
#include <
utils/gui/windows/GUIAppEnum.h
>
48
#include <
utils/gui/windows/GUISUMOAbstractView.h
>
49
#include "
GUIJunctionWrapper.h
"
50
#include <
utils/gui/globjects/GUIGLObjectPopupMenu.h
>
51
#include <
utils/gui/div/GUIGlobalSelection.h
>
52
#include <
utils/gui/div/GUIParameterTableWindow.h
>
53
#include <
utils/gui/div/GLHelper.h
>
54
#include <
foreign/polyfonts/polyfonts.h
>
55
#include <
utils/gui/globjects/GLIncludes.h
>
56
57
#ifdef CHECK_MEMORY_LEAKS
58
#include <
foreign/nvwa/debug_new.h
>
59
#endif // CHECK_MEMORY_LEAKS
60
61
62
// ===========================================================================
63
// method definitions
64
// ===========================================================================
65
GUIJunctionWrapper::GUIJunctionWrapper
(
MSJunction
& junction)
66
:
GUIGlObject
(
GLO_JUNCTION
, junction.getID()),
67
myJunction(junction) {
68
if
(
myJunction
.
getShape
().size() == 0) {
69
Position
pos =
myJunction
.
getPosition
();
70
myBoundary
=
Boundary
(pos.
x
() - 1., pos.
y
() - 1., pos.
x
() + 1., pos.
y
() + 1.);
71
}
else
{
72
myBoundary
=
myJunction
.
getShape
().
getBoxBoundary
();
73
}
74
myMaxSize
=
MAX2
(
myBoundary
.
getWidth
(),
myBoundary
.
getHeight
());
75
#ifdef HAVE_INTERNAL_LANES
76
myIsInner
=
dynamic_cast<
MSInternalJunction
*
>
(&
myJunction
) != 0;
77
#else
78
myIsInner =
false
;
79
#endif
80
}
81
82
83
GUIJunctionWrapper::~GUIJunctionWrapper
() {}
84
85
86
GUIGLObjectPopupMenu
*
87
GUIJunctionWrapper::getPopUpMenu
(
GUIMainWindow
& app,
88
GUISUMOAbstractView
& parent) {
89
GUIGLObjectPopupMenu
* ret =
new
GUIGLObjectPopupMenu
(app, parent, *
this
);
90
buildPopupHeader
(ret, app);
91
buildCenterPopupEntry
(ret);
92
buildNameCopyPopupEntry
(ret);
93
buildSelectionPopupEntry
(ret);
94
buildPositionCopyEntry
(ret,
false
);
95
return
ret;
96
}
97
98
99
GUIParameterTableWindow
*
100
GUIJunctionWrapper::getParameterWindow
(
GUIMainWindow
&
/*app*/
,
101
GUISUMOAbstractView
&) {
102
return
0;
103
}
104
105
106
Boundary
107
GUIJunctionWrapper::getCenteringBoundary
()
const
{
108
Boundary
b =
myBoundary
;
109
b.
grow
(20);
110
return
b;
111
}
112
113
114
void
115
GUIJunctionWrapper::drawGL
(
const
GUIVisualizationSettings
& s)
const
{
116
// check whether it is not too small
117
if
(s.
scale
*
myMaxSize
< 1.) {
118
return
;
119
}
120
if
(!
myIsInner
&& s.
drawJunctionShape
) {
121
glPushName(
getGlID
());
122
glPushMatrix();
123
const
SUMOReal
colorValue =
static_cast<
SUMOReal
>
(s.
junctionColorer
.
getActive
() == 1 &&
gSelected
.
isSelected
(
getType
(),
getGlID
()));
124
GLHelper::setColor
(s.
junctionColorer
.
getScheme
().
getColor
(colorValue));
125
glTranslated(0, 0,
getType
());
126
if
(s.
scale
*
myMaxSize
< 40.) {
127
GLHelper::drawFilledPoly
(
myJunction
.
getShape
(),
true
);
128
}
else
{
129
GLHelper::drawFilledPolyTesselated
(
myJunction
.
getShape
(),
true
);
130
}
131
glPopMatrix();
132
}
133
if
(
myIsInner
) {
134
drawName
(
myJunction
.
getPosition
(), s.
scale
, s.
internalJunctionName
);
135
}
else
{
136
drawName
(
myJunction
.
getPosition
(), s.
scale
, s.
junctionName
);
137
}
138
glPopName();
139
}
140
141
142
#ifdef HAVE_OSG
143
void
144
GUIJunctionWrapper::updateColor(
const
GUIVisualizationSettings
& s) {
145
const
SUMOReal
colorValue =
static_cast<
SUMOReal
>
(s.
junctionColorer
.
getActive
() == 1 &&
gSelected
.
isSelected
(
getType
(),
getGlID
()));
146
const
RGBColor
& col = s.
junctionColorer
.
getScheme
().
getColor
(colorValue);
147
osg::Vec4ubArray* colors =
dynamic_cast<
osg::Vec4ubArray*
>
(myGeom->getColorArray());
148
(*colors)[0].
set
(col.
red
(), col.
green
(), col.
blue
(), col.
alpha
());
149
myGeom->setColorArray(colors);
150
}
151
#endif
152
153
154
/****************************************************************************/
155
tmp
buildd
sumo-0.21.0+dfsg
src
guisim
GUIJunctionWrapper.cpp
Generated on Thu Nov 20 2014 19:49:53 for SUMO - Simulation of Urban MObility by
1.8.1.2