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-2020 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, "", false,
35 {}, {}, {lane}, {VSSParent}, {}, {}, {}, {}) {
36  // update centering boundary without updating grid
37  updateCenteringBoundary(false);
38 }
39 
40 
42 }
43 
44 
46 GNEVariableSpeedSignSymbol::getMoveOperation(const double /*shapeOffset*/) {
47  // GNEVariableSpeedSignSymbols cannot be moved
48  return nullptr;
49 }
50 
51 
52 void
54  // update additional geometry
56  // update boundary (needed for connections)
57  // add shape boundary
59  // grow
60  myBoundary.grow(10);
61  // update connections
62  getParentAdditionals().front()->updateHierarchicalConnections();
63 }
64 
65 
66 void
68  // just update geometry
70 }
71 
72 
73 void
74 GNEVariableSpeedSignSymbol::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/,
75  const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
76  // nothing to split
77 }
78 
79 
80 std::string
82  return getParentAdditionals().at(0)->getID();
83 }
84 
85 
86 void
88  // Obtain exaggeration of the draw
89  const double VSSExaggeration = s.addSize.getExaggeration(s, getParentAdditionals().front());
90  // first check if additional has to be drawn
91  if (s.drawAdditionals(VSSExaggeration) && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
92  // Start drawing adding an gl identificator (except in Move mode)
94  glPushName(getParentAdditionals().front()->getGlID());
95  }
96  // start drawing symbol
97  glPushMatrix();
98  // translate to front
100  // translate to position
101  glTranslated(myAdditionalGeometry.getShape().front().x(), myAdditionalGeometry.getShape().front().y(), 0);
102  // rotate over lane
104  // scale
105  glScaled(VSSExaggeration, VSSExaggeration, 1);
106  // set color
109  } else {
111  }
112  // draw circle
114  // draw details
115  if (!s.forceDrawForPositionSelection && (s.scale >= 5)) {
116  // move to front
117  glTranslated(0, 0, 0.1);
118  // set color
121  } else {
123  }
124  // draw another circle
126  // move to front
127  glTranslated(0, 0, 0.1);
128  // draw speed
131  } else {
132  GLHelper::drawText("S", Position(0, 0), .1, 1.2, RGBColor::YELLOW, 180);
133  }
134  }
135  // Pop symbol matrix
136  glPopMatrix();
137  // Pop VSS name
139  glPopName();
140  }
141  // check if dotted contour has to be drawn
144  }
147  }
148  }
149 }
150 
151 
152 std::string
154  switch (key) {
155  case SUMO_ATTR_LANE:
156  return getParentLanes().front()->getID();
157  default:
158  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
159  }
160 }
161 
162 
163 double
165  throw InvalidArgument("Symbols cannot be edited");
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 bool
183  return true;
184 }
185 
186 
187 std::string
189  return getParentAdditionals().at(0)->getPopUpID();
190 }
191 
192 
193 std::string
195  return getParentAdditionals().at(0)->getHierarchyName();
196 }
197 
198 // ===========================================================================
199 // private
200 // ===========================================================================
201 
202 void
203 GNEVariableSpeedSignSymbol::setAttribute(SumoXMLAttr /*key*/, const std::string& /*value*/) {
204  throw InvalidArgument("Symbols cannot be edited");
205 }
206 
207 
208 void
210  // nothing to do
211 }
212 
213 void
215  // nothing to do
216 }
217 
218 /****************************************************************************/
@ 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:44
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:446
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:347
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:498
An Element which don't belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
Boundary myBoundary
Additional Boundary.
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< 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, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
update geometry shape
Definition: GNEGeometry.cpp:81
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:45
move operation
move result
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2245
GNEMoveOperation * getMoveOperation(const double shapeOffset)
get move operation for the given shapeOffset
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
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 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:491
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:467
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, GUIGlObjectType objectType, const double extraOffset=0)
draw front attributeCarrier
GUIGlID getGlID() const
Returns the numerical id of the object.
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings addSize
bool drawDottedContour() const
check if dotted contour can be drawn
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)
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
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static const RGBColor YELLOW
Definition: RGBColor.h:183
static const RGBColor BLACK
Definition: RGBColor.h:188
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
static const RGBColor RED
named colors
Definition: RGBColor.h:180
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
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)
bool showAdditionals() const
check if additionals has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
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