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#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
26
28
29// ===========================================================================
30// member method definitions
31// ===========================================================================
32
36
37
39 GNEAdditional(VSSParent, GNE_TAG_VSS_SYMBOL, "") {
40 // set parents
41 setParent<GNELane*>(lane);
42 setParent<GNEAdditional*>(VSSParent);
43 // update centering boundary without updating grid
45}
46
47
50
51
54 // GNEVariableSpeedSignSymbols cannot be moved
55 return nullptr;
56}
57
58
60 // nothing to write
61}
62
63
64bool
68
69
70std::string
74
75
76void
80
81
82bool
86
87
88void
90 // update additional geometry
91 myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
92}
93
94
95void
97 // nothing to do
98}
99
100
105
106
107void
108GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
109 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
110 // nothing to split
111}
112
113
114std::string
116 return getParentAdditionals().at(0)->getID();
117}
118
119
120void
122 // first check if additional has to be drawn
124 (myAdditionalGeometry.getShape().size() > 0) &&
126 // Obtain exaggeration of the draw
127 const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
128 // get detail level
129 const auto d = s.getDetailLevel(VSSExaggeration);
130 // draw geometry only if we'rent in drawForObjectUnderCursor mode
132 // draw variable speed sign symbol
133 drawVSSSymbol(s, d, VSSExaggeration);
134 // draw parent and child lines
136 // draw dotted contour
138 }
139 // calculate contour circle
141 VSSExaggeration, getParentLanes().front()->getParentEdge());
142 }
143}
144
145
146std::string
148 switch (key) {
149 case SUMO_ATTR_ID:
150 case SUMO_ATTR_LANE:
151 return getParentLanes().front()->getID();
152 default:
153 return getCommonAttribute(nullptr, key);
154 }
155}
156
157
158double
162
163
168
169
170void
171GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
172 setCommonAttribute(key, value, undoList);
173}
174
175
176bool
177GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr key, const std::string& value) {
178 return isCommonValid(key, value);
179}
180
181
182std::string
184 return getParentLanes().front()->getPopUpID();
185}
186
187
188std::string
190 return getParentLanes().front()->getHierarchyName();
191}
192
193// ===========================================================================
194// private
195// ===========================================================================
196
197void
199 const double exaggeration) const {
200 // start drawing symbol
202 // translate to front
203 getParentAdditionals().front()->drawInLayer(GLO_VSS);
204 // translate to position
205 glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
206 // rotate over lane
208 // scale
209 glScaled(exaggeration, exaggeration, 1);
210 // set color
211 RGBColor color;
214 } else {
216 }
217 // draw circle
219 // draw details
221 // move to front
222 glTranslated(0, 0, 0.1);
223 // set color
226 } else {
228 }
229 // draw another circle
231 // move to front
232 glTranslated(0, 0, 0.1);
233 // draw speed
237 } else {
238 GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
239 }
240 }
241 }
242 // Pop symbol matrix
244}
245
246
247void
249 setCommonAttribute(this, key, value);
250}
251
252
253void
255 // nothing to do
256}
257
258void
260 // nothing to do
261}
262
263/****************************************************************************/
@ 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:653
static void popMatrix()
pop matrix
Definition GLHelper.cpp:135
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:538
static void pushMatrix()
push matrix
Definition GLHelper.cpp:122
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:747
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
std::string getCommonAttribute(const Parameterised *parameterised, SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GNENet * myNet
pointer to net
bool isCommonValid(SumoXMLAttr key, const std::string &value) 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
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
move operation
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2195
Position getPositionInView() const
Returns position of additional in view.
bool checkDrawMoveContour() const
check if draw move contour (red)
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)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void drawVSSSymbol(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw VSS symbol
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
GNEMoveOperation * getMoveOperation()
get move operation
double getAttributeDouble(SumoXMLAttr key) const
GNEVariableSpeedSignSymbol(GNENet *net)
default Constructor
std::string getAttribute(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
const Parameterised::Map & getACParametersMap() const
get parameters map
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void updateGeometry()
update pre-computed geometry information
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
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)
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.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value 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 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