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>
24 #include <utils/gui/div/GLHelper.h>
26 
28 
29 // ===========================================================================
30 // member method definitions
31 // ===========================================================================
32 
34  GNEAdditional(VSSParent->getNet(), GLO_VSS, GNE_TAG_VSS_SYMBOL, "",
35 {}, {}, {lane}, {VSSParent}, {}, {}, {}, {},
36 std::map<std::string, std::string>()) {
37  // update centering boundary without updating grid
38  updateCenteringBoundary(false);
39 }
40 
41 
43 }
44 
45 
48  // GNEVariableSpeedSignSymbols cannot be moved
49  return nullptr;
50 }
51 
52 
54  // nothing to write
55 }
56 
57 
58 void
60  // update additional geometry
61  myAdditionalGeometry.updateGeometry(getParentLanes().front()->getLaneShape(), 1.5, 0);
62 }
63 
64 
65 void
68  // add center
70  // grow
72 }
73 
74 
78 }
79 
80 
81 void
82 GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
83  const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
84  // nothing to split
85 }
86 
87 
88 std::string
90  return getParentAdditionals().at(0)->getID();
91 }
92 
93 
94 void
96  // Obtain exaggeration of the draw
97  const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
98  // first check if additional has to be drawn
99  if (s.drawAdditionals(VSSExaggeration) && myNet->getViewNet()->getDataViewOptions().showAdditionals() &&
100  (myAdditionalGeometry.getShape().size() > 0) && (myAdditionalGeometry.getShapeRotations().size() > 0)) {
101  // draw parent and child lines
103  // Start drawing adding an gl identificator (except in Move mode)
106  }
107  // start drawing symbol
109  // translate to front
111  // translate to position
112  glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
113  // rotate over lane
115  // scale
116  glScaled(VSSExaggeration, VSSExaggeration, 1);
117  // set color
120  } else {
122  }
123  // draw circle
125  // draw details
126  if (!s.forceDrawForPositionSelection && (s.scale >= 5)) {
127  // move to front
128  glTranslated(0, 0, 0.1);
129  // set color
132  } else {
134  }
135  // draw another circle
137  // move to front
138  glTranslated(0, 0, 0.1);
139  // draw speed
142  } else {
143  GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
144  }
145  }
146  // Pop symbol matrix
148  // Pop VSS name
151  }
152  // check if dotted contour has to be drawn
155  }
158  }
159  }
160 }
161 
162 
163 std::string
165  switch (key) {
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 
174 double
176  throw InvalidArgument("Symbols cannot be edited");
177 }
178 
179 
180 void
181 GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/, GNEUndoList* /*undoList*/) {
182  throw InvalidArgument("Symbols cannot be edited");
183 }
184 
185 
186 bool
187 GNEVariableSpeedSignSymbol::isValid(SumoXMLAttr /*key*/, const std::string& /*value*/) {
188  throw InvalidArgument("Symbols cannot be edited");
189 }
190 
191 
192 bool
194  return true;
195 }
196 
197 
198 std::string
200  return getParentLanes().front()->getPopUpID();
201 }
202 
203 
204 std::string
206  return getParentLanes().front()->getHierarchyName();
207 }
208 
209 // ===========================================================================
210 // private
211 // ===========================================================================
212 
213 void
214 GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
215  throw InvalidArgument("Symbols cannot be edited");
216 }
217 
218 
219 void
221  // nothing to do
222 }
223 
224 void
226  // nothing to do
227 }
228 
229 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ GLO_VSS
a Variable Speed Sign
@ GNE_TAG_VSS_SYMBOL
VSS Symbol.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_LANE
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:77
void reset()
Resets the boundary.
Definition: Boundary.cpp:65
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
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:609
An Element which don't belongs to GNENet but has influency 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
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:1964
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 conrrespond attribute are valids
GNEVariableSpeedSignSymbol(GNEAdditional *VSSParent, GNELane *lane)
Constructor.
void writeAdditional(OutputDevice &device) const
writte 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)
bool isAttributeEnabled(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:537
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:513
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 DottedContourType type, const GUIVisualizationSettings &s, 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.
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
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:197
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