Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVariableSpeedSignSymbol.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
21#include <netedit/GNENet.h>
23
25
26// ===========================================================================
27// member method definitions
28// ===========================================================================
29
33
34
36 GNEAdditional(VSSParent, GNE_TAG_VSS_SYMBOL, "") {
37 // set parents
38 setParent<GNELane*>(lane);
39 setParent<GNEAdditional*>(VSSParent);
40 // update centering boundary without updating grid
42}
43
44
47
48
51 return nullptr;
52}
53
54
59
60
61const Parameterised*
63 return nullptr;
64}
65
66
68 // nothing to write
69}
70
71
72bool
76
77
78std::string
82
83
84void
88
89
90bool
94
95
96void
98 // update additional geometry
99 myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
100}
101
102
103void
105 // nothing to do
106}
107
108
113
114
115void
116GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
117 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
118 // nothing to split
119}
120
121
122std::string
124 return getParentAdditionals().at(0)->getID();
125}
126
127
128void
130 // first check if additional has to be drawn
132 (myAdditionalGeometry.getShape().size() > 0) &&
134 // Obtain exaggeration of the draw
135 const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
136 // get detail level
137 const auto d = s.getDetailLevel(VSSExaggeration);
138 // draw geometry only if we'rent in drawForObjectUnderCursor mode
140 // draw variable speed sign symbol
141 drawVSSSymbol(s, d, VSSExaggeration);
142 // draw parent and child lines
144 // draw dotted contour
146 }
147 // calculate contour circle
149 VSSExaggeration, getParentLanes().front()->getParentEdge());
150 }
151}
152
153
154std::string
156 switch (key) {
157 case SUMO_ATTR_ID:
158 case SUMO_ATTR_LANE:
159 return getParentLanes().front()->getID();
160 default:
161 return getCommonAttribute(key);
162 }
163}
164
165
166double
170
171
176
177
182
183
184void
185GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
186 setCommonAttribute(key, value, undoList);
187}
188
189
190bool
191GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr key, const std::string& value) {
192 return isCommonAttributeValid(key, value);
193}
194
195
196std::string
198 return getParentLanes().front()->getPopUpID();
199}
200
201
202std::string
204 return getParentLanes().front()->getHierarchyName();
205}
206
207// ===========================================================================
208// private
209// ===========================================================================
210
211void
213 const double exaggeration) const {
214 // start drawing symbol
216 // translate to front
217 getParentAdditionals().front()->drawInLayer(GLO_VSS);
218 // translate to position
219 glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
220 // rotate over lane
222 // scale
223 glScaled(exaggeration, exaggeration, 1);
224 // set color
225 RGBColor color;
228 } else {
230 }
231 // draw circle
233 // draw details
235 // move to front
236 glTranslated(0, 0, 0.1);
237 // set color
240 } else {
242 }
243 // draw another circle
245 // move to front
246 glTranslated(0, 0, 0.1);
247 // draw speed
251 } else {
252 GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
253 }
254 }
255 }
256 // Pop symbol matrix
258}
259
260
261void
263 setCommonAttribute(key, value);
264}
265
266/****************************************************************************/
@ GLO_VSS
a Variable Speed Sign
@ GNE_TAG_VSS_SYMBOL
VSS Symbol.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_ID
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition GLHelper.cpp:742
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
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
double getCommonAttributeDouble(SumoXMLAttr key) const
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (circle elements)
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...)
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
Position getPositionInView() const
Returns position of additional in view.
void updateGeometry() override
update pre-computed geometry information
bool isValid(SumoXMLAttr key, const std::string &value) override
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
std::string getAdditionalProblem() const
return a string with the current additional problem (must be reimplemented in all detector children)
double getAttributeDouble(SumoXMLAttr key) const override
void drawVSSSymbol(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw VSS symbol
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
GNEVariableSpeedSignSymbol(GNENet *net)
default Constructor
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this variableSpeedSignSymbol
Position getAttributePosition(SumoXMLAttr key) const override
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
bool checkDrawMoveContour() const override
check if draw move contour (red)
Parameterised * getParameters() override
get parameters associated with this variableSpeedSignSymbol
std::string getParentName() const
Returns the name (ID) of the parent object.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAdditionalValid() const
check if current additional is valid to be written into XML (must be reimplemented in all detector ch...
void fixAdditionalProblem()
fix additional problem (must be reimplemented in all detector children)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
std::string getAttribute(SumoXMLAttr key) const override
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
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.
GUIVisualizationSizeSettings addSize
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.
Static storage of an output device and its base (abstract) implementation.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
static const RGBColor YELLOW
Definition RGBColor.h:191
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 const RGBColor RED
named colors
Definition RGBColor.h:188
bool showAdditionals() const
check if additionals has to be drawn
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values