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.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>
24 #include <utils/gui/div/GLHelper.h>
26 
28 
29 // ===========================================================================
30 // member method definitions
31 // ===========================================================================
32 
35 {}, {}, {}, {}, {}, {}) {
36  // reset default values
37  resetDefaultValues();
38 }
39 
40 
42  GNEAdditional(VSSParent->getNet(), GLO_VSS, GNE_TAG_VSS_SYMBOL, GUIIconSubSys::getIcon(GUIIcon::VARIABLESPEEDSIGN), "",
43 {}, {}, {lane}, {VSSParent}, {}, {}) {
44  // update centering boundary without updating grid
45  updateCenteringBoundary(false);
46 }
47 
48 
50 }
51 
52 
55  // GNEVariableSpeedSignSymbols cannot be moved
56  return nullptr;
57 }
58 
59 
61  // nothing to write
62 }
63 
64 
65 bool
67  return true;
68 }
69 
70 
71 std::string
73  return "";
74 }
75 
76 
77 void
79  // nothing to fix
80 }
81 
82 
83 bool
85  return false;
86 }
87 
88 
89 void
91  // update additional geometry
92  myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
93 }
94 
95 
96 void
98  // nothing to do
99 }
100 
101 
102 Position
105 }
106 
107 
108 void
109 GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
110  const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
111  // nothing to split
112 }
113 
114 
115 std::string
117  return getParentAdditionals().at(0)->getID();
118 }
119 
120 
121 void
123  // first check if additional has to be drawn
125  (myAdditionalGeometry.getShape().size() > 0) && (myAdditionalGeometry.getShapeRotations().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
131  if (!s.drawForViewObjectsHandler) {
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
140  myAdditionalContour.calculateContourCircleShape(s, d, this, myAdditionalGeometry.getShape().front(), 1.3, VSSExaggeration);
141  }
142 }
143 
144 
145 std::string
147  switch (key) {
148  case SUMO_ATTR_ID:
149  case SUMO_ATTR_LANE:
150  return getParentLanes().front()->getID();
151  default:
152  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
153  }
154 }
155 
156 
157 double
159  throw InvalidArgument("Symbols cannot be edited");
160 }
161 
162 
163 const Parameterised::Map&
165  return PARAMETERS_EMPTY;
166 }
167 
168 
169 void
170 GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
171  throw InvalidArgument("Symbols cannot be edited");
172 }
173 
174 
175 bool
176 GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr /*key*/, const std::string& /*value*/) {
177  throw InvalidArgument("Symbols cannot be edited");
178 }
179 
180 
181 std::string
183  return getParentLanes().front()->getPopUpID();
184 }
185 
186 
187 std::string
189  return getParentLanes().front()->getHierarchyName();
190 }
191 
192 // ===========================================================================
193 // private
194 // ===========================================================================
195 
196 void
198  const double exaggeration) const {
199  // start drawing symbol
201  // translate to front
203  // translate to position
204  glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
205  // rotate over lane
207  // scale
208  glScaled(exaggeration, exaggeration, 1);
209  // set color
210  RGBColor color;
213  } else {
215  }
216  // draw circle
217  GLHelper::drawFilledCircleDetailled(d, (double) 1.3);
218  // draw details
220  // move to front
221  glTranslated(0, 0, 0.1);
222  // set color
225  } else {
227  }
228  // draw another circle
229  GLHelper::drawFilledCircleDetailled(d, (double) 1.1);
230  // move to front
231  glTranslated(0, 0, 0.1);
232  // draw speed
236  } else {
237  GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
238  }
239  }
240  }
241  // Pop symbol matrix
243 }
244 
245 
246 void
247 GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
248  throw InvalidArgument("Symbols cannot be edited");
249 }
250 
251 
252 void
254  // nothing to do
255 }
256 
257 void
259  // nothing to do
260 }
261 
262 /****************************************************************************/
@ 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:655
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:540
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:757
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
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 scale) const
calculate contour (circle elements)
Definition: GNEContour.cpp:117
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:263
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:2056
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
Definition: GNEViewNet.cpp:727
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
Definition: GUIGeometry.cpp:59
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings addSize
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
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
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