Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEInductionLoopDetector.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
25#include <netedit/GNENet.h>
30
32
33// ===========================================================================
34// member method definitions
35// ===========================================================================
36
42
43
44GNEInductionLoopDetector::GNEInductionLoopDetector(const std::string& id, GNENet* net, const std::string& filename, GNELane* lane,
45 const double pos, const SUMOTime freq, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes,
46 const std::vector<std::string>& nextEdges, const std::string& detectPersons, const std::string& name, const bool friendlyPos,
47 const Parameterised::Map& parameters) :
48 GNEDetector(id, net, filename, SUMO_TAG_INDUCTION_LOOP, freq, outputFilename, vehicleTypes, nextEdges,
49 detectPersons, name, parameters),
50 myPosOverLane(pos),
51 myFriendlyPos(friendlyPos),
53 GNEMoveElementLaneSingle::PositionType::SINGLE)) {
54 // set parents
56 // update centering boundary without updating grid
58}
59
60
64
65
70
71
76
77
78void
80 device.openTag(getTagProperty()->getTag());
81 // write common additional attributes
83 // write move attributes
84 myMoveElementLaneSingle->writeMoveAttributes(device);
85 // write detector attributes
86 writeDetectorValues(device);
87 // write parameters (Always after children to avoid problems with additionals.xsd)
88 writeParams(device);
89 device.closeTag();
90}
91
92
93bool
95 // only movement problems
96 return myMoveElementLaneSingle->isMoveElementValid();
97}
98
99
100std::string
102 // only movement problems
103 return myMoveElementLaneSingle->getMovingProblem();
104}
105
106
107void
109 // only movement problems
110 myMoveElementLaneSingle->fixMovingProblem();
111}
112
113
114void
116 // update geometry
117 myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), myMoveElementLaneSingle->getFixedPositionOverLane(true), myMoveElementLaneSingle->myMovingLateralOffset);
118 // update centering boundary without updating grid
120}
121
122
123bool
125 // get TLS Attributes
126 const auto& TLSAttributes = myNet->getViewNet()->getViewParent()->getTLSEditorFrame()->getTLSAttributes();
127 // check detectors
128 if (myNet->getViewNet()->selectingDetectorsTLSMode() &&
129 (TLSAttributes->getE1Detectors().count(getParentLanes().front()->getID()) > 0) &&
130 (TLSAttributes->getE1Detectors().at(getParentLanes().front()->getID()) == getID())) {
131 return true;
132 }
133 // check opened popup
134 if (myNet->getViewNet()->getPopup()) {
135 return myNet->getViewNet()->getPopup()->getGLObject() == this;
136 }
137 return false;
138}
139
140
141void
143 // first check if additional has to be drawn
144 if (myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
145 // Obtain exaggeration of the draw
146 const double E1Exaggeration = getExaggeration(s);
147 // get detail level
148 const auto d = s.getDetailLevel(E1Exaggeration);
149 // draw geometry only if we'rent in drawForObjectUnderCursor mode
151 // declare colors
152 RGBColor mainColor, secondColor, textColor;
153 // set color
154 if (drawUsingSelectColor()) {
156 secondColor = mainColor.changedBrightness(-32);
157 textColor = mainColor.changedBrightness(32);
158 } else {
159 mainColor = s.detectorSettings.E1Color;
160 secondColor = RGBColor::WHITE;
161 textColor = RGBColor::BLACK;
162 }
163 // draw parent and child lines
165 // push layer matrix
167 // translate to front
169 // draw E1 shape
170 drawE1Shape(d, E1Exaggeration, mainColor, secondColor);
171 // draw E1 Logo
172 drawE1DetectorLogo(s, d, E1Exaggeration, "E1", textColor);
173 // pop layer matrix
175 // draw lock icon
176 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), myAdditionalGeometry.getShape().getCentroid(), E1Exaggeration);
177 // Draw additional ID
179 // draw additional name
181 // draw dotted contour
182 myAdditionalContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
183 }
184 // calculate contour rectangle
185 myAdditionalContour.calculateContourRectangleShape(s, d, this, myAdditionalGeometry.getShape().front(), 2, 1, getType(), 0, 0,
186 myAdditionalGeometry.getShapeRotations().front(), E1Exaggeration, getParentLanes().front()->getParentEdge());
187 }
188}
189
190
191std::string
195
196
197double
201
202
207
208
209void
211 setDetectorAttribute(key, value, undoList);
212}
213
214
215bool
217 return isDetectorValid(key, value);
218}
219
220// ===========================================================================
221// private
222// ===========================================================================
223
224void
226 switch (key) {
227 case SUMO_ATTR_LANE:
229 break;
230 default:
232 break;
233 }
234}
235
236/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ GLO_E1DETECTOR
a E1 detector
const std::string invalid_return< std::string >::value
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_POSITION
static void popMatrix()
pop matrix
Definition GLHelper.cpp:135
static void pushMatrix()
push matrix
Definition GLHelper.cpp:122
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
void writeAdditionalAttributes(OutputDevice &device) const
write common additional attributes
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string getID() const override
get ID (all Attribute Carriers have one)
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
Position getDetectorAttributePosition(SumoXMLAttr key) const
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void drawE1Shape(const GUIVisualizationSettings::Detail d, const double exaggeration, const RGBColor &mainColor, const RGBColor &secondColor) const
draw E1 shape
double getDetectorAttributeDouble(SumoXMLAttr key) const
GNEDetector(GNENet *net, SumoXMLTag tag)
Default constructor.
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
void updateCenteringBoundary(const bool updateGrid) override
update centering boundary (implies change in RTREE)
std::string getDetectorAttribute(SumoXMLAttr key) const
void drawE1DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E1 detector Logo
void setParent(ParentType parent)
edit parent and childrens without maintain integrity (use carefully)
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
bool isAdditionalValid() const override
check if current additional is valid to be written into XML
Parameterised * getParameters() override
get parameters associated with this GNEAdditional
void fixAdditionalProblem() override
fix additional problem
bool isValid(SumoXMLAttr key, const std::string &value) override
GNEMoveElementLaneSingle * myMoveElementLaneSingle
move element lane single
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
std::string getAttribute(SumoXMLAttr key) const override
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this GNEAdditional
double myPosOverLane
position over lane
double getAttributeDouble(SumoXMLAttr key) const override
bool myFriendlyPos
friendly position
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
GNEInductionLoopDetector(GNENet *net)
default constructor
std::string getAdditionalProblem() const override
return a string with the current additional problem
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
void updateGeometry() override
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const override
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Stores the information about how to visualize structures.
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const RGBColor WHITE
Definition RGBColor.h:195
static const RGBColor BLACK
Definition RGBColor.h:196
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E1Color
color for E1 detectors
static const double segmentWidth
width of dotted contour segments