Eclipse SUMO - Simulation of Urban MObility
GNEOverheadWire.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 <netedit/GNENet.h>
21 #include <netedit/GNEUndoList.h>
22 #include <netedit/GNEViewNet.h>
26 #include <utils/gui/div/GLHelper.h>
29 
30 #include "GNEOverheadWire.h"
31 #include "GNEAdditionalHandler.h"
32 
33 
34 // ===========================================================================
35 // member method definitions
36 // ===========================================================================
37 
40  GUIIconSubSys::getIcon(GUIIcon::OVERHEADWIRE), "", {}, {}, {}, {}, {}, {}),
41  myStartPos(0),
42  myEndPos(0),
43 myFriendlyPosition(false) {
44  // reset default values
45  resetDefaultValues();
46 }
47 
48 
49 GNEOverheadWire::GNEOverheadWire(const std::string& id, std::vector<GNELane*> lanes, GNEAdditional* substation, GNENet* net,
50  const double startPos, const double endPos, const bool friendlyPos, const std::vector<std::string>& forbiddenInnerLanes,
51  const Parameterised::Map& parameters) :
53  GUIIconSubSys::getIcon(GUIIcon::OVERHEADWIRE), "", {}, {}, lanes, {substation}, {}, {}),
54 Parameterised(parameters),
55 myStartPos(startPos),
56 myEndPos(endPos),
57 myFriendlyPosition(friendlyPos),
58 myForbiddenInnerLanes(forbiddenInnerLanes) {
59  // update centering boundary without updating grid
60  updateCenteringBoundary(false);
61 }
62 
63 
65 }
66 
67 
70  // check modes and detector type
74  } else {
75  return nullptr;
76  }
77 }
78 
79 
80 void
83  device.writeAttr(SUMO_ATTR_ID, getID());
88  if (myFriendlyPosition) {
89  device.writeAttr(SUMO_ATTR_FRIENDLY_POS, true);
90  }
91  if (!myForbiddenInnerLanes.empty()) {
93  }
94  // write parameters
95  writeParams(device);
96  device.closeTag();
97 }
98 
99 
100 bool
102  // first check if there is connection between all consecutive lanes
104  // with friendly position enabled position are "always fixed"
105  if (myFriendlyPosition) {
106  return true;
107  } else {
108  return (myStartPos >= 0) &&
109  (myEndPos >= 0) &&
110  ((myStartPos) <= getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) &&
111  ((myEndPos) <= getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
112  }
113  } else {
114  return false;
115  }
116 }
117 
118 
119 std::string
121  // declare variable for error position
122  std::string errorFirstLanePosition, separator, errorLastLanePosition;
123  // abort if lanes aren't consecutives
125  return TL("lanes aren't consecutives");
126  }
127  // abort if lanes aren't connected
129  return TL("lanes aren't connected");
130  }
131  // check positions over first lane
132  if (myStartPos < 0) {
133  errorFirstLanePosition = (toString(SUMO_ATTR_STARTPOS) + " < 0");
134  }
135  if (myStartPos > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
136  errorFirstLanePosition = (toString(SUMO_ATTR_STARTPOS) + TL(" > lanes's length"));
137  }
138  // check positions over last lane
139  if (myEndPos < 0) {
140  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + " < 0");
141  }
142  if (myEndPos > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
143  errorLastLanePosition = (toString(SUMO_ATTR_ENDPOS) + TL(" > lanes's length"));
144  }
145  // check separator
146  if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
147  separator = TL(" and ");
148  }
149  // return error message
150  return errorFirstLanePosition + separator + errorLastLanePosition;
151 }
152 
153 
154 void
157  // build connections between all consecutive lanes
158  bool foundConnection = true;
159  int i = 0;
160  // iterate over all lanes, and stop if myE2valid is false
161  while (i < ((int)getParentLanes().size() - 1)) {
162  // change foundConnection to false
163  foundConnection = false;
164  // if a connection between "from" lane and "to" lane of connection is found, change myE2valid to true again
165  for (const auto& connection : getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
166  if ((connection->getLaneFrom() == getParentLanes().at(i)) && (connection->getLaneTo() == getParentLanes().at(i + 1))) {
167  foundConnection = true;
168  }
169  }
170  // if connection wasn't found
171  if (!foundConnection) {
172  // create new connection manually
173  NBEdge::Connection newCon(getParentLanes().at(i)->getIndex(), getParentLanes().at(i + 1)->getParentEdge()->getNBEdge(), getParentLanes().at(i + 1)->getIndex());
174  // allow to undo creation of new lane
175  myNet->getViewNet()->getUndoList()->add(new GNEChange_Connection(getParentLanes().at(i)->getParentEdge(), newCon, false, true), true);
176  }
177  // update lane iterator
178  i++;
179  }
180  } else {
181  // declare new positions
182  double newPositionOverLane = myStartPos;
183  double newEndPositionOverLane = myEndPos;
184  // fix pos and length checkAndFixDetectorPosition
186  newPositionOverLane, getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
187  newEndPositionOverLane, getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
188  // set new position and endPosition
189  setAttribute(SUMO_ATTR_STARTPOS, toString(newPositionOverLane), myNet->getViewNet()->getUndoList());
190  setAttribute(SUMO_ATTR_ENDPOS, toString(newEndPositionOverLane), myNet->getViewNet()->getUndoList());
191  }
192 }
193 
194 
195 bool
197  return false;
198 }
199 
200 
201 void
203  // compute path
205 }
206 
207 
208 Position
211 }
212 
213 
214 void
215 GNEOverheadWire::updateCenteringBoundary(const bool /* updateGrid */) {
216  // nothing to update
217 }
218 
219 
220 void
221 GNEOverheadWire::splitEdgeGeometry(const double /* splitPosition */, const GNENetworkElement* originalElement, const GNENetworkElement* newElement, GNEUndoList* undoList) {
222  // obtain new list of lanes
223  std::string newLanes = getNewListOfParents(originalElement, newElement);
224  // update Lanes
225  if (newLanes.size() > 0) {
226  setAttribute(SUMO_ATTR_LANES, newLanes, undoList);
227  }
228 }
229 
230 
231 void
233  // nothing to draw
234 }
235 
236 
237 void
239  // calculate path
241 }
242 
243 
244 void
245 GNEOverheadWire::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
246  // calculate overheadWire width
247  const double overheadWireWidth = s.addSize.getExaggeration(s, segment->getLane());
248  // check if E2 can be drawn
249  if (segment->getLane() && myNet->getViewNet()->getDataViewOptions().showAdditionals()) {
250  // get detail level
251  const auto d = s.getDetailLevel(overheadWireWidth);
252  // calculate startPos
253  const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_STARTPOS);
254  // get endPos
255  const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ENDPOS);
256  // declare path geometry
257  GUIGeometry overheadWireGeometry;
258  // update pathGeometry depending of first and last segment
259  if (segment->isFirstSegment() && segment->isLastSegment()) {
260  overheadWireGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
261  geometryDepartPos,
263  geometryEndPos,
265  } else if (segment->isFirstSegment()) {
266  overheadWireGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
267  geometryDepartPos,
269  -1,
271  } else if (segment->isLastSegment()) {
272  overheadWireGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
273  -1,
275  geometryEndPos,
277  } else {
278  overheadWireGeometry = segment->getLane()->getLaneGeometry();
279  }
280  // get both geometries
281  auto overheadWireGeometryTop = overheadWireGeometry;
282  auto overheadWireGeometryBot = overheadWireGeometry;
283  // move to sides
284  overheadWireGeometryTop.moveGeometryToSide(overheadWireWidth * 0.5);
285  overheadWireGeometryBot.moveGeometryToSide(overheadWireWidth * -0.5);
286  // draw geometry only if we'rent in drawForObjectUnderCursor mode
287  if (!s.drawForViewObjectsHandler) {
288  // obtain color
291  // push layer matrix
293  // Start with the drawing of the area traslating matrix to origin
294  glTranslated(0, 0, getType() + offsetFront);
295  // Set top color
296  GLHelper::setColor(overheadWireColorTop);
297  // draw top geometry
298  GUIGeometry::drawGeometry(d, overheadWireGeometryTop, 0.2);
299  // Set bot color
300  GLHelper::setColor(overheadWireColorBot);
301  // draw bot geometry
302  GUIGeometry::drawGeometry(d, overheadWireGeometryBot, 0.2);
303  // draw geometry points
304  if (segment->isFirstSegment() && segment->isLastSegment()) {
305  drawLeftGeometryPoint(s, d, overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
306  drawRightGeometryPoint(s, d, overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
307  } else if (segment->isFirstSegment()) {
308  drawLeftGeometryPoint(s, d, overheadWireGeometry.getShape().front(), overheadWireGeometry.getShapeRotations().front(), overheadWireColorTop, true);
309  } else if (segment->isLastSegment()) {
310  drawRightGeometryPoint(s, d, overheadWireGeometry.getShape().back(), overheadWireGeometry.getShapeRotations().back(), overheadWireColorTop, true);
311  }
312  // Pop layer matrix
314  // draw dotted contour
316  }
317  // declare trim geometry to draw
318  const auto shape = (segment->isFirstSegment() || segment->isLastSegment()) ? overheadWireGeometry.getShape() : segment->getLane()->getLaneShape();
319  // calculate contour and draw dotted geometry
320  myAdditionalContour.calculateContourExtrudedShape(s, d, this, shape, overheadWireWidth, 1, true, true, 0);
321  }
322 }
323 
324 
325 void
326 GNEOverheadWire::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
327  // calculate overheadWire width
328  const double overheadWireWidth = s.addSize.getExaggeration(s, segment->getPreviousLane());
329  // check if overhead wire can be drawn
330  if (myNet->getViewNet()->getDataViewOptions().showAdditionals() && segment->getPreviousLane() && segment->getNextLane()) {
331  // obtain color
334  // declare geometry
335  GUIGeometry overheadWireGeometry({segment->getPreviousLane()->getLaneShape().back(), segment->getNextLane()->getLaneShape().front()});
336  // get detail level
337  const auto d = s.getDetailLevel(1);
338  // check if exist connection
339  if (segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane())) {
340  overheadWireGeometry = segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane());
341  }
342  // get both geometries
343  auto overheadWireGeometryTop = overheadWireGeometry;
344  auto overheadWireGeometryBot = overheadWireGeometry;
345  // move to sides
346  overheadWireGeometryTop.moveGeometryToSide(overheadWireWidth * 0.5);
347  overheadWireGeometryBot.moveGeometryToSide(overheadWireWidth * -0.5);
348  // draw geometry only if we'rent in drawForObjectUnderCursor mode
349  if (!s.drawForViewObjectsHandler) {
350  // Add a draw matrix
352  // Start with the drawing of the area traslating matrix to origin
353  glTranslated(0, 0, getType() + offsetFront);
354  // Set top color
355  GLHelper::setColor(overheadWireColorTop);
356  // draw top geometry
357  GUIGeometry::drawGeometry(d, overheadWireGeometryTop, 0.2);
358  // Set bot color
359  GLHelper::setColor(overheadWireColorBot);
360  // draw bot geometry
361  GUIGeometry::drawGeometry(d, overheadWireGeometryBot, 0.2);
362  // Pop last matrix
364  // draw dotted contour
366  }
367  // draw contours
368  if (segment->getPreviousLane()->getLane2laneConnections().exist(segment->getNextLane())) {
369  // get shape
370  const auto& shape = segment->getPreviousLane()->getLane2laneConnections().getLane2laneGeometry(segment->getNextLane()).getShape();
371  // calculate contour and draw dotted geometry
372  myAdditionalContour.calculateContourExtrudedShape(s, d, this, shape, overheadWireWidth, 1, true, true, 0);
373  }
374  }
375 }
376 
377 
378 std::string
380  switch (key) {
381  case SUMO_ATTR_ID:
382  return getMicrosimID();
384  return getParentAdditionals().front()->getID();
385  case SUMO_ATTR_LANES:
386  return parseIDs(getParentLanes());
387  case SUMO_ATTR_STARTPOS:
388  return toString(myStartPos);
389  case SUMO_ATTR_ENDPOS:
390  return toString(myEndPos);
395  case GNE_ATTR_SELECTED:
397  case GNE_ATTR_PARAMETERS:
398  return getParametersStr();
400  return "";
401  default:
402  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
403  }
404 }
405 
406 
407 double
409  switch (key) {
410  case SUMO_ATTR_STARTPOS:
411  if (myStartPos < 0) {
412  return 0;
413  } else if (myStartPos > getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength()) {
414  return getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
415  } else {
416  return myStartPos;
417  }
418  case SUMO_ATTR_ENDPOS:
419  if (myEndPos < 0) {
420  return 0;
421  } else if (myEndPos > getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength()) {
422  return getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
423  } else {
424  return myEndPos;
425  }
426  default:
427  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
428  }
429 }
430 
431 
432 const Parameterised::Map&
434  return getParametersMap();
435 }
436 
437 
438 void
439 GNEOverheadWire::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
440  switch (key) {
441  case SUMO_ATTR_ID:
443  case SUMO_ATTR_LANES:
444  case SUMO_ATTR_STARTPOS:
445  case SUMO_ATTR_ENDPOS:
448  case GNE_ATTR_SELECTED:
449  case GNE_ATTR_PARAMETERS:
450  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
451  break;
452  default:
453  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
454  }
455 }
456 
457 
458 bool
459 GNEOverheadWire::isValid(SumoXMLAttr key, const std::string& value) {
460  switch (key) {
461  case SUMO_ATTR_ID:
462  return isValidAdditionalID(value);
464  if (value.empty()) {
465  return false;
466  } else {
467  return (myNet->getAttributeCarriers()->retrieveAdditional(SUMO_TAG_TRACTION_SUBSTATION, value, false) != nullptr);
468  }
469  case SUMO_ATTR_LANES:
470  if (value.empty()) {
471  return false;
472  } else if (canParse<std::vector<GNELane*> >(myNet, value, false)) {
473  // check if lanes are consecutives
474  return lanesConsecutives(parse<std::vector<GNELane*> >(myNet, value));
475  } else {
476  return false;
477  }
478  case SUMO_ATTR_STARTPOS:
479  return canParse<double>(value);
480  case SUMO_ATTR_ENDPOS:
481  return canParse<double>(value);
483  return canParse<bool>(value);
485  return true;
486  case GNE_ATTR_SELECTED:
487  return canParse<bool>(value);
488  case GNE_ATTR_PARAMETERS:
489  return areParametersValid(value);
490  default:
491  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
492  }
493 }
494 
495 
496 std::string
498  return getTagStr() + ": " + getID();
499 }
500 
501 
502 std::string
504  return getTagStr();
505 }
506 
507 // ===========================================================================
508 // private
509 // ===========================================================================
510 
511 void
512 GNEOverheadWire::setAttribute(SumoXMLAttr key, const std::string& value) {
513  switch (key) {
514  case SUMO_ATTR_ID:
515  // update microsimID
516  setAdditionalID(value);
517  break;
520  break;
521  case SUMO_ATTR_LANES:
523  break;
524  case SUMO_ATTR_STARTPOS:
525  myStartPos = parse<double>(value);
526  // update geometry (except for template)
527  if (getParentLanes().size() > 0) {
528  updateGeometry();
529  }
530  break;
531  case SUMO_ATTR_ENDPOS:
532  myEndPos = parse<double>(value);
533  // update geometry (except for template)
534  if (getParentLanes().size() > 0) {
535  updateGeometry();
536  }
537  break;
539  myFriendlyPosition = parse<bool>(value);
540  break;
542  myForbiddenInnerLanes = parse<std::vector<std::string> >(value);
543  break;
544  case GNE_ATTR_SELECTED:
545  if (parse<bool>(value)) {
547  } else {
549  }
550  break;
551  case GNE_ATTR_PARAMETERS:
552  setParametersStr(value);
553  break;
555  shiftLaneIndex();
556  break;
557  default:
558  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
559  }
560 }
561 
562 void
566  // change only start position
567  myStartPos = moveResult.newFirstPos;
570  // change only end position
571  myEndPos = moveResult.newFirstPos;
572  } else {
573  // change both position
574  myStartPos = moveResult.newFirstPos;
575  myEndPos = moveResult.newSecondPos;
576  }
577  // update geometry
578  updateGeometry();
579 }
580 
581 
582 void
584  // begin change attribute
585  undoList->begin(this, "position of " + getTagStr());
586  // set attributes depending of operation type
589  // set only start position
590  setAttribute(SUMO_ATTR_STARTPOS, toString(moveResult.newFirstPos), undoList);
593  // set only end position
594  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newFirstPos), undoList);
595  } else {
596  // set both positions
597  setAttribute(SUMO_ATTR_STARTPOS, toString(moveResult.newFirstPos), undoList);
598  setAttribute(SUMO_ATTR_ENDPOS, toString(moveResult.newSecondPos), undoList);
599  }
600  // end change attribute
601  undoList->end();
602 }
603 
604 
605 double
607  // get lane final and shape length
608  const double laneLength = getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
609  // get startPosition
610  double fixedPos = myStartPos;
611  // adjust fixedPos
612  if (fixedPos < 0) {
613  fixedPos += laneLength;
614  }
615  fixedPos *= getParentLanes().front()->getLengthGeometryFactor();
616  // return depending of fixedPos
617  if (fixedPos < 0) {
618  return 0;
619  } else if (fixedPos > (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
620  return (getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
621  } else {
622  return fixedPos;
623  }
624 }
625 
626 
627 double
629  // get lane final and shape length
630  const double laneLength = getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
631  // get endPosition
632  double fixedPos = myEndPos;
633  // adjust fixedPos
634  if (fixedPos < 0) {
635  fixedPos += laneLength;
636  }
637  fixedPos *= getParentLanes().back()->getLengthGeometryFactor();
638  // return depending of fixedPos
639  if (fixedPos < POSITION_EPS) {
640  return POSITION_EPS;
641  } else if (fixedPos > getParentLanes().back()->getLaneShapeLength()) {
642  return getParentLanes().back()->getLaneShapeLength();
643  } else {
644  return fixedPos;
645  }
646 }
647 
648 /****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ GLO_OVERHEAD_WIRE_SEGMENT
a segment of an overhead line
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
@ OVERHEADWIRE
#define TL(string)
Definition: MsgHandler.h:315
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_SUBSTATIONID
id of a traction substation substation
@ SUMO_ATTR_ENDPOS
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_OVERHEAD_WIRE_FORBIDDEN
forbidden lanes for overhead wire segment
@ SUMO_ATTR_LANES
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_ID
@ GNE_ATTR_SHIFTLANEINDEX
shift lane index (only used by elements over lanes)
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:654
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
GNEMoveOperation * getMoveOperationMultiLane(const double startPos, const double endPos)
get moveOperation for an element over multi lane
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const
calculate contour extruded (used in elements formed by a central shape)
Definition: GNEContour.cpp:88
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:265
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
std::string getNewListOfParents(const GNENetworkElement *currentElement, const GNENetworkElement *newNextElement) const
if use edge/parent lanes as a list of consecutive elements, obtain a list of IDs of elements after in...
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:684
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition: GNELane.cpp:208
move operation
move result
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double newSecondPos
new second position
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:122
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:134
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
void updateGeometry()
update pre-computed geometry information
void fixAdditionalProblem()
fix additional problem
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
~GNEOverheadWire()
Destructor.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
double myEndPos
end position over lane
bool checkDrawMoveContour() const
check if draw move contour (red)
const Parameterised::Map & getACParametersMap() const
get parameters map
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void computePathElement()
compute pathElement
GNEMoveOperation * getMoveOperation()
get move operation
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Position getPositionInView() const
Returns position of additional in view.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double myStartPos
start position over lane
double getAttributeDouble(SumoXMLAttr key) const
GNEOverheadWire(GNENet *net)
default Constructor
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
std::string getAdditionalProblem() const
return a string with the current additional problem
std::string getAttribute(SumoXMLAttr key) const
bool myFriendlyPosition
friendly position
std::vector< std::string > myForbiddenInnerLanes
forbidden inner lanes
bool isAdditionalValid() const
check if current additional is valid to be written into XML
const GNELane * getPreviousLane() const
get previous lane
const GNELane * getNextLane() const
get next lane
const GNELane * getLane() const
get lane associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
void calculateConsecutivePathLanes(PathElement *pathElement, const std::vector< GNELane * > lanes)
calculate consecutive path lanes
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
GNEUndoList * getUndoList() const
get the undoList object
void moveGeometryToSide(const double amount)
move current shape to side
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
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
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:254
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
Position getPolygonCenter() const
Returns the arithmetic of all corner points.
bool showAdditionals() const
check if additionals has to be drawn
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static const RGBColor overheadWireColorBot
overhead wire color bot
static const RGBColor overheadWireColorTop
overhead wire color top
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
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:201