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-2024 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
35{}, {}, {}, {}, {}, {}) {
36 // reset default values
37 resetDefaultValues();
38}
39
40
43{}, {}, {lane}, {VSSParent}, {}, {}) {
44 // update centering boundary without updating grid
45 updateCenteringBoundary(false);
46}
47
48
51
52
55 // GNEVariableSpeedSignSymbols cannot be moved
56 return nullptr;
57}
58
59
61 // nothing to write
62}
63
64
65bool
69
70
71std::string
75
76
77void
81
82
83bool
87
88
89void
91 // update additional geometry
92 myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
93}
94
95
96void
98 // nothing to do
99}
100
101
106
107
108void
109GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
110 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
111 // nothing to split
112}
113
114
115std::string
117 return getParentAdditionals().at(0)->getID();
118}
119
120
121void
123 // first check if additional has to be drawn
125 (myAdditionalGeometry.getShape().size() > 0) &&
127 // Obtain exaggeration of the draw
128 const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
129 // get detail level
130 const auto d = s.getDetailLevel(VSSExaggeration);
131 // draw geometry only if we'rent in drawForObjectUnderCursor mode
133 // draw variable speed sign symbol
134 drawVSSSymbol(s, d, VSSExaggeration);
135 // draw parent and child lines
137 // draw dotted contour
139 }
140 // calculate contour circle
141 myAdditionalContour.calculateContourCircleShape(s, d, this, myAdditionalGeometry.getShape().front(), 1.3, getType(), VSSExaggeration);
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 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
154 }
155}
156
157
158double
160 throw InvalidArgument("Symbols cannot be edited");
161}
162
163
168
169
170void
171GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
172 throw InvalidArgument("Symbols cannot be edited");
173}
174
175
176bool
177GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr /*key*/, const std::string& /*value*/) {
178 throw InvalidArgument("Symbols cannot be edited");
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
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
248GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
249 throw InvalidArgument("Symbols cannot be edited");
250}
251
252
253void
255 // nothing to do
256}
257
258void
260 // nothing to do
261}
262
263/****************************************************************************/
@ GLO_VSS
a Variable Speed Sign
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ VARIABLESPEEDSIGN
@ GNE_TAG_VSS_SYMBOL
VSS Symbol.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
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:539
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
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:756
An Element which don't belong to GNENet but has influence in the simulation.
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
const std::string & getTagStr() const
get tag assigned to this object in string format
static const Parameterised::Map PARAMETERS_EMPTY
empty parameter maps (used by ACs without parameters)
GNENet * myNet
pointer to net
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale) const
calculate contour (circle elements)
void 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 std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< 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:2147
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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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
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:188
static const RGBColor BLACK
Definition RGBColor.h:193
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:185
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