Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEInstantInductionLoopDetector.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-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/****************************************************************************/
18//
19/****************************************************************************/
20#include <config.h>
21
23
26#include <netedit/GNENet.h>
29
31
32// ===========================================================================
33// member method definitions
34// ===========================================================================
35
36#ifdef _MSC_VER
37#pragma warning(push)
38#pragma warning(disable: 4355) // mask warning about "this" in initializers
39#endif
42 myMoveElementLaneSingle(new GNEMoveElementLaneSingle(this, SUMO_ATTR_POSITION, myPosOverLane, myFriendlyPos,
43 GNEMoveElementLaneSingle::PositionType::SINGLE)) {
44}
45
46
48 const double pos, const std::string& outputFilename, const std::vector<std::string>& vehicleTypes, const std::vector<std::string>& nextEdges,
49 const std::string& detectPersons, const std::string& name, const bool friendlyPos, const Parameterised::Map& parameters) :
50 GNEDetector(id, net, fileBucket, SUMO_TAG_INSTANT_INDUCTION_LOOP, 0, outputFilename,
51 vehicleTypes, nextEdges, detectPersons, name, parameters),
52 myPosOverLane(pos),
53 myFriendlyPos(friendlyPos),
54 myMoveElementLaneSingle(new GNEMoveElementLaneSingle(this, SUMO_ATTR_POSITION, myPosOverLane, myFriendlyPos,
55 GNEMoveElementLaneSingle::PositionType::SINGLE)) {
56 // set parents
57 setParent<GNELane*>(lane);
58 // update centering boundary without updating grid
60}
61#ifdef _MSC_VER
62#pragma warning(pop)
63#endif
64
65
69
70
75
76
81
82
83void
85 device.openTag(getTagProperty()->getTag());
86 // write common additional attributes
88 // write move attributes
90 // write common detector parameters
91 writeDetectorValues(device);
92 // write parameters (Always after children to avoid problems with additionals.xsd)
93 XMLHelpers::writeParams(device, *this);
94 device.closeTag();
95}
96
97
98bool
100 // only movement problems
102}
103
104
105std::string
110
111
112void
117
118
119void
121 // update geometry
123 // update centering boundary without updating grid
125}
126
127
128void
130 // check if additional has to be drawn
133 // Obtain exaggeration of the draw
134 const double E1InstantExaggeration = getExaggeration(s);
135 // get detail level
136 const auto d = s.getDetailLevel(E1InstantExaggeration);
137 // draw geometry only if we'rent in drawForObjectUnderCursor mode
139 // declare colors
140 RGBColor mainColor, secondColor, textColor;
141 // set color
142 if (drawUsingSelectColor()) {
144 secondColor = mainColor.changedBrightness(-32);
145 textColor = mainColor.changedBrightness(32);
146 } else {
147 mainColor = s.detectorSettings.E1InstantColor;
148 secondColor = RGBColor::WHITE;
149 textColor = RGBColor::BLACK;
150 }
151 // draw parent and child lines
153 // push layer matrix
155 // translate to front
157 // draw E1Instant shape
158 drawE1Shape(d, E1InstantExaggeration, mainColor, secondColor);
159 // draw E1 Logo
160 drawE1DetectorLogo(s, d, E1InstantExaggeration, "E1", textColor);
161 // pop layer matrix
163 // draw lock icon
165 E1InstantExaggeration);
166 // Draw additional ID
168 // draw additional name
170 // draw dotted contour
172 }
173 // draw dotted contour
175 myAdditionalGeometry.getShapeRotations().front(), E1InstantExaggeration, getParentLanes().front()->getParentEdge());
176 }
177}
178
179
180std::string
184
185
186double
190
191
196
197
198void
200 setDetectorAttribute(key, value, undoList);
201}
202
203
204bool
206 return isDetectorValid(key, value);
207}
208
209// ===========================================================================
210// private
211// ===========================================================================
212
213void
215 switch (key) {
216 case SUMO_ATTR_LANE:
218 break;
219 default:
220 setDetectorAttribute(key, value);
221 break;
222 }
223}
224
225/****************************************************************************/
@ GLO_E1DETECTOR_INSTANT
a E1 detector
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_POSITION
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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
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
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
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
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
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
Position getAttributePosition(SumoXMLAttr key) const override
GNEInstantInductionLoopDetector(GNENet *net)
default Constructor
void writeAdditional(OutputDevice &device) const override
write additional element into a xml file
std::string getAttribute(SumoXMLAttr key) const override
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
void updateGeometry() override
update pre-computed geometry information
GNEMoveElementLaneSingle * myMoveElementLaneSingle
move element lane single
Parameterised * getParameters() override
get parameters associated with this GNEAdditional
bool isAdditionalValid() const override
check if current additional is valid to be written into XML
bool isValid(SumoXMLAttr key, const std::string &value) override
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this GNEAdditional
std::string getAdditionalProblem() const override
return a string with the current additional problem
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void fixAdditionalProblem() override
fix additional problem
double getAttributeDouble(SumoXMLAttr key) const override
double myMovingLateralOffset
move element lateral offset
bool isMoveElementValid() const
check if current moving element is valid to be written into XML
std::string getMovingProblem() const
return a string with the current moving problem
void writeMoveAttributes(OutputDevice &device) const
write move attributes
double getFixedPositionOverLane(const bool adjustGeometryFactor) const
get fixed offset position over lane
void fixMovingProblem()
fix moving problem
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
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
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor WHITE
Definition RGBColor.h:211
static const RGBColor BLACK
Definition RGBColor.h:212
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:228
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags
bool showAdditionals() const
check if additionals has to be drawn
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 E1InstantColor
color for E1 Instant detectors
static const double segmentWidth
width of dotted contour segments