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
142 VSSExaggeration, getParentLanes().front()->getParentEdge());
143 }
144}
145
146
147std::string
149 switch (key) {
150 case SUMO_ATTR_ID:
151 case SUMO_ATTR_LANE:
152 return getParentLanes().front()->getID();
153 default:
154 return getCommonAttribute(key);
155 }
156}
157
158
159double
161 throw InvalidArgument("Symbols cannot be edited");
162}
163
164
169
170
171void
172GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
173 throw InvalidArgument("Symbols cannot be edited");
174}
175
176
177bool
178GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr /*key*/, const std::string& /*value*/) {
179 throw InvalidArgument("Symbols cannot be edited");
180}
181
182
183std::string
185 return getParentLanes().front()->getPopUpID();
186}
187
188
189std::string
191 return getParentLanes().front()->getHierarchyName();
192}
193
194// ===========================================================================
195// private
196// ===========================================================================
197
198void
200 const double exaggeration) const {
201 // start drawing symbol
203 // translate to front
204 getParentAdditionals().front()->drawInLayer(GLO_VSS);
205 // translate to position
206 glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
207 // rotate over lane
209 // scale
210 glScaled(exaggeration, exaggeration, 1);
211 // set color
212 RGBColor color;
215 } else {
217 }
218 // draw circle
220 // draw details
222 // move to front
223 glTranslated(0, 0, 0.1);
224 // set color
227 } else {
229 }
230 // draw another circle
232 // move to front
233 glTranslated(0, 0, 0.1);
234 // draw speed
238 } else {
239 GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
240 }
241 }
242 }
243 // Pop symbol matrix
245}
246
247
248void
249GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
250 throw InvalidArgument("Symbols cannot be edited");
251}
252
253
254void
256 // nothing to do
257}
258
259void
261 // nothing to do
262}
263
264/****************************************************************************/
@ 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
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:751
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
static const Parameterised::Map PARAMETERS_EMPTY
empty parameter maps (used by ACs without parameters)
GNENet * myNet
pointer to net
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 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:2163
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
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