Eclipse SUMO - Simulation of Urban MObility
GNEVariableSpeedSignSymbol.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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{}, {}, {lane}, {VSSParent}, {}, {}) {
36 // update centering boundary without updating grid
37 updateCenteringBoundary(false);
38}
39
40
42}
43
44
47 // GNEVariableSpeedSignSymbols cannot be moved
48 return nullptr;
49}
50
51
53 // nothing to write
54}
55
56
57void
59 // update additional geometry
60 myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
61}
62
63
64void
67 // add center
69 // grow
71}
72
73
77}
78
79
80void
81GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
82 const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
83 // nothing to split
84}
85
86
87std::string
89 return getParentAdditionals().at(0)->getID();
90}
91
92
93void
95 // Obtain exaggeration of the draw
96 const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
97 // first check if additional has to be drawn
98 if (s.drawAdditionals(VSSExaggeration) && myNet->getViewNet()->getDataViewOptions().showAdditionals() &&
100 // draw parent and child lines
102 // Start drawing adding an gl identificator (except in Move mode)
105 }
106 // start drawing symbol
108 // translate to front
110 // translate to position
111 glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
112 // rotate over lane
114 // scale
115 glScaled(VSSExaggeration, VSSExaggeration, 1);
116 // set color
119 } else {
121 }
122 // draw circle
124 // draw details
125 if (!s.forceDrawForPositionSelection && (s.scale >= 5)) {
126 // move to front
127 glTranslated(0, 0, 0.1);
128 // set color
131 } else {
133 }
134 // draw another circle
136 // move to front
137 glTranslated(0, 0, 0.1);
138 // draw speed
141 } else {
142 GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
143 }
144 }
145 // Pop symbol matrix
147 // Pop VSS name
150 }
151 // check if dotted contour has to be drawn
154 }
157 }
158 }
159}
160
161
162std::string
164 switch (key) {
165 case SUMO_ATTR_ID:
166 case SUMO_ATTR_LANE:
167 return getParentLanes().front()->getID();
168 default:
169 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
170 }
171}
172
173
174double
176 throw InvalidArgument("Symbols cannot be edited");
177}
178
179
182 return PARAMETERS_EMPTY;
183}
184
185
186void
187GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
188 throw InvalidArgument("Symbols cannot be edited");
189}
190
191
192bool
193GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr /*key*/, const std::string& /*value*/) {
194 throw InvalidArgument("Symbols cannot be edited");
195}
196
197
198std::string
200 return getParentLanes().front()->getPopUpID();
201}
202
203
204std::string
206 return getParentLanes().front()->getHierarchyName();
207}
208
209// ===========================================================================
210// private
211// ===========================================================================
212
213void
214GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
215 throw InvalidArgument("Symbols cannot be edited");
216}
217
218
219void
221 // nothing to do
222}
223
224void
226 // nothing to do
227}
228
229/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ 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
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
void reset()
Resets the boundary.
Definition: Boundary.cpp:66
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void popName()
pop Name
Definition: GLHelper.cpp:148
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:685
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Boundary myAdditionalBoundary
Additional Boundary.
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
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
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
Position getPositionInView() const
Returns position of additional in view.
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
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
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
GNEVariableSpeedSignSymbol(GNEAdditional *VSSParent, GNELane *lane)
Constructor.
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 of the parent object (if any)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:656
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
static void drawDottedContourCircle(const GUIVisualizationSettings &s, const DottedContourType type, const Position &pos, const double radius, const double exaggeration)
draw dotted contour for the given Position and radius (used by Juctions and POIs)
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
Definition: GUIGeometry.cpp:58
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings addSize
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
bool forceDrawForPositionSelection
flag to force draw for position selection (see drawForPositionSelection)
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
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
NetworkEditMode networkEditMode
the current Network edit mode
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values