Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/guisim/GUIInstantInductLoop.cpp
193692 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2003-2026 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GUIInstantInductLoop.cpp
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Aug 2003
19
///
20
// The gui-version of the MSInstantInductLoop
21
/****************************************************************************/
22
#include <config.h>
23
24
#include <utils/common/MsgHandler.h>
25
#include <utils/gui/globjects/GUIGlObject.h>
26
#include <utils/geom/PositionVector.h>
27
#include "GUIInstantInductLoop.h"
28
#include <utils/gui/div/GLHelper.h>
29
#include <utils/gui/div/GUIParameterTableWindow.h>
30
#include <microsim/logging/FunctionBinding.h>
31
#include <microsim/output/MSInstantInductLoop.h>
32
#include <microsim/MSLane.h>
33
#include "GUIEdge.h"
34
#include <utils/gui/globjects/GLIncludes.h>
35
36
37
// ===========================================================================
38
// method definitions
39
// ===========================================================================
40
/* -------------------------------------------------------------------------
41
* GUIInstantInductLoop-methods
42
* ----------------------------------------------------------------------- */
43
GUIInstantInductLoop::GUIInstantInductLoop(const std::string& id, OutputDevice& od,
44
MSLane* const lane, double positionInMeters,
45
const std::string name, const std::string& vTypes,
46
const std::string& nextEdges,
47
int detectPersons) :
48
MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges, detectPersons) {}
49
50
51
GUIInstantInductLoop::~GUIInstantInductLoop() {}
52
53
54
GUIDetectorWrapper*
55
GUIInstantInductLoop::buildDetectorGUIRepresentation() {
56
return new MyWrapper(*this, myPosition);
57
}
58
59
// -------------------------------------------------------------------------
60
// GUIInstantInductLoop::MyWrapper-methods
61
// -------------------------------------------------------------------------
62
63
GUIInstantInductLoop::MyWrapper::MyWrapper(GUIInstantInductLoop& detector, double pos) :
64
GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID(), GUIIconSubSys::getIcon(GUIIcon::E1INSTANT)),
65
myDetector(detector), myPosition(pos) {
66
myFGPosition = detector.getLane()->geometryPositionAtOffset(pos);
67
myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
68
myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
69
myFGRotation = -detector.getLane()->getShape().rotationDegreeAtOffset(pos);
70
}
71
72
73
GUIInstantInductLoop::MyWrapper::~MyWrapper() {}
74
75
76
double
77
GUIInstantInductLoop::MyWrapper::getExaggeration(const GUIVisualizationSettings& s) const {
78
return s.addSize.getExaggeration(s, this);
79
}
80
81
82
Boundary
83
GUIInstantInductLoop::MyWrapper::getCenteringBoundary() const {
84
Boundary b(myBoundary);
85
b.grow(20);
86
return b;
87
}
88
89
90
91
GUIParameterTableWindow*
92
GUIInstantInductLoop::MyWrapper::getParameterWindow(GUIMainWindow& app,
93
GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
94
GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
95
// add items
96
// parameter
97
ret->mkItem(TL("name"), false, myDetector.myName);
98
ret->mkItem(TL("position [m]"), false, myPosition);
99
ret->mkItem(TL("lane"), false, myDetector.getLane()->getID());
100
if (myDetector.isTyped()) {
101
ret->mkItem(TL("vTypes"), false, toString(myDetector.getVehicleTypes()));
102
}
103
// values
104
// close building
105
ret->closeBuilding(&myDetector);
106
return ret;
107
}
108
109
110
void
111
GUIInstantInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const {
112
GLHelper::pushName(getGlID());
113
double width = (double) 2.0 * s.scale;
114
glLineWidth(1.0);
115
const double exaggeration = getExaggeration(s);
116
// shape
117
glColor3d(1, 0, 1);
118
GLHelper::pushMatrix();
119
glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
120
glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
121
glRotated(myFGRotation, 0, 0, 1);
122
glScaled(exaggeration, exaggeration, 1);
123
glBegin(GL_QUADS);
124
glVertex2d(0 - 1.0, 2);
125
glVertex2d(-1.0, -2);
126
glVertex2d(1.0, -2);
127
glVertex2d(1.0, 2);
128
glEnd();
129
glTranslated(0, 0, .01);
130
glBegin(GL_LINES);
131
glVertex2d(0, 2 - .1);
132
glVertex2d(0, -2 + .1);
133
glEnd();
134
135
// outline
136
if (width * exaggeration > 1) {
137
glColor3d(1, 1, 1);
138
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
139
glBegin(GL_QUADS);
140
glVertex2d(0 - 1.0, 2);
141
glVertex2d(-1.0, -2);
142
glVertex2d(1.0, -2);
143
glVertex2d(1.0, 2);
144
glEnd();
145
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146
}
147
148
// position indicator
149
if (width * exaggeration > 1) {
150
glRotated(90, 0, 0, -1);
151
glColor3d(1, 1, 1);
152
glBegin(GL_LINES);
153
glVertex2d(0, 1.7);
154
glVertex2d(0, -1.7);
155
glEnd();
156
}
157
GLHelper::popMatrix();
158
drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
159
GLHelper::popName();
160
}
161
162
163
GUIInstantInductLoop&
164
GUIInstantInductLoop::MyWrapper::getLoop() {
165
return myDetector;
166
}
167
168
169
/****************************************************************************/
170
171