Line data Source code
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 122 : 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 122 : int detectPersons) :
48 244 : MSInstantInductLoop(id, od, lane, positionInMeters, name, vTypes, nextEdges, detectPersons) {}
49 :
50 :
51 244 : GUIInstantInductLoop::~GUIInstantInductLoop() {}
52 :
53 :
54 : GUIDetectorWrapper*
55 110 : GUIInstantInductLoop::buildDetectorGUIRepresentation() {
56 110 : return new MyWrapper(*this, myPosition);
57 : }
58 :
59 : // -------------------------------------------------------------------------
60 : // GUIInstantInductLoop::MyWrapper-methods
61 : // -------------------------------------------------------------------------
62 :
63 110 : GUIInstantInductLoop::MyWrapper::MyWrapper(GUIInstantInductLoop& detector, double pos) :
64 : GUIDetectorWrapper(GLO_E1DETECTOR_INSTANT, detector.getID(), GUIIconSubSys::getIcon(GUIIcon::E1INSTANT)),
65 110 : myDetector(detector), myPosition(pos) {
66 110 : myFGPosition = detector.getLane()->geometryPositionAtOffset(pos);
67 110 : myBoundary.add(myFGPosition.x() + (double) 5.5, myFGPosition.y() + (double) 5.5);
68 110 : myBoundary.add(myFGPosition.x() - (double) 5.5, myFGPosition.y() - (double) 5.5);
69 110 : myFGRotation = -detector.getLane()->getShape().rotationDegreeAtOffset(pos);
70 110 : }
71 :
72 :
73 220 : GUIInstantInductLoop::MyWrapper::~MyWrapper() {}
74 :
75 :
76 : double
77 2087 : GUIInstantInductLoop::MyWrapper::getExaggeration(const GUIVisualizationSettings& s) const {
78 2087 : return s.addSize.getExaggeration(s, this);
79 : }
80 :
81 :
82 : Boundary
83 2197 : GUIInstantInductLoop::MyWrapper::getCenteringBoundary() const {
84 : Boundary b(myBoundary);
85 2197 : b.grow(20);
86 2197 : return b;
87 : }
88 :
89 :
90 :
91 : GUIParameterTableWindow*
92 0 : GUIInstantInductLoop::MyWrapper::getParameterWindow(GUIMainWindow& app,
93 : GUISUMOAbstractView& /*parent !!! recheck this - never needed?*/) {
94 0 : GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
95 : // add items
96 : // parameter
97 0 : ret->mkItem(TL("name"), false, myDetector.myName);
98 0 : ret->mkItem(TL("position [m]"), false, myPosition);
99 0 : ret->mkItem(TL("lane"), false, myDetector.getLane()->getID());
100 0 : if (myDetector.isTyped()) {
101 0 : ret->mkItem(TL("vTypes"), false, toString(myDetector.getVehicleTypes()));
102 : }
103 : // values
104 : // close building
105 0 : ret->closeBuilding(&myDetector);
106 0 : return ret;
107 : }
108 :
109 :
110 : void
111 2087 : GUIInstantInductLoop::MyWrapper::drawGL(const GUIVisualizationSettings& s) const {
112 2087 : GLHelper::pushName(getGlID());
113 2087 : double width = (double) 2.0 * s.scale;
114 2087 : glLineWidth(1.0);
115 2087 : const double exaggeration = getExaggeration(s);
116 : // shape
117 2087 : glColor3d(1, 0, 1);
118 2087 : GLHelper::pushMatrix();
119 2087 : glTranslated(0, 0, GLO_JUNCTION + 0.4); // do not draw on top of linkRules
120 2087 : glTranslated(myFGPosition.x(), myFGPosition.y(), 0);
121 2087 : glRotated(myFGRotation, 0, 0, 1);
122 2087 : glScaled(exaggeration, exaggeration, 1);
123 2087 : glBegin(GL_QUADS);
124 2087 : glVertex2d(0 - 1.0, 2);
125 2087 : glVertex2d(-1.0, -2);
126 2087 : glVertex2d(1.0, -2);
127 2087 : glVertex2d(1.0, 2);
128 2087 : glEnd();
129 2087 : glTranslated(0, 0, .01);
130 2087 : glBegin(GL_LINES);
131 2087 : glVertex2d(0, 2 - .1);
132 2087 : glVertex2d(0, -2 + .1);
133 2087 : glEnd();
134 :
135 : // outline
136 2087 : if (width * exaggeration > 1) {
137 2078 : glColor3d(1, 1, 1);
138 2078 : glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
139 2078 : glBegin(GL_QUADS);
140 2078 : glVertex2d(0 - 1.0, 2);
141 2078 : glVertex2d(-1.0, -2);
142 2078 : glVertex2d(1.0, -2);
143 2078 : glVertex2d(1.0, 2);
144 2078 : glEnd();
145 2078 : glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146 : }
147 :
148 : // position indicator
149 2087 : if (width * exaggeration > 1) {
150 2078 : glRotated(90, 0, 0, -1);
151 2078 : glColor3d(1, 1, 1);
152 2078 : glBegin(GL_LINES);
153 2078 : glVertex2d(0, 1.7);
154 2078 : glVertex2d(0, -1.7);
155 2078 : glEnd();
156 : }
157 2087 : GLHelper::popMatrix();
158 2087 : drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
159 2087 : GLHelper::popName();
160 2087 : }
161 :
162 :
163 : GUIInstantInductLoop&
164 0 : GUIInstantInductLoop::MyWrapper::getLoop() {
165 0 : return myDetector;
166 : }
167 :
168 :
169 : /****************************************************************************/
|