Eclipse SUMO - Simulation of Urban MObility
GNEDemandElement.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 // A abstract class for demand elements
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
26 #include <utils/gui/div/GLHelper.h>
32 
33 #include "GNEDemandElement.h"
34 
35 
36 // ===========================================================================
37 // static defintions
38 // ===========================================================================
40 
41 // ===========================================================================
42 // member method definitions
43 // ===========================================================================
44 
45 // ---------------------------------------------------------------------------
46 // GNEDemandElement - methods
47 // ---------------------------------------------------------------------------
48 
49 GNEDemandElement::GNEDemandElement(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const int options,
50  const std::vector<GNEJunction*>& junctionParents,
51  const std::vector<GNEEdge*>& edgeParents,
52  const std::vector<GNELane*>& laneParents,
53  const std::vector<GNEAdditional*>& additionalParents,
54  const std::vector<GNEDemandElement*>& demandElementParents,
55  const std::vector<GNEGenericData*>& genericDataParents) :
56  GNEPathManager::PathElement(type, id, icon, options),
57  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
58  myStackedLabelNumber(0) {
59  // check if is template
60  myIsTemplate = (id == "");
61 }
62 
63 
64 GNEDemandElement::GNEDemandElement(GNEDemandElement* demandElementParent, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, const int options,
65  const std::vector<GNEJunction*>& junctionParents,
66  const std::vector<GNEEdge*>& edgeParents,
67  const std::vector<GNELane*>& laneParents,
68  const std::vector<GNEAdditional*>& additionalParents,
69  const std::vector<GNEDemandElement*>& demandElementParents,
70  const std::vector<GNEGenericData*>& genericDataParents) :
71  GNEPathManager::PathElement(type, demandElementParent->getID(), icon, options),
72  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
73  myStackedLabelNumber(0) {
74 }
75 
76 
78 
79 
80 void
81 GNEDemandElement::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
82  // currently there isn't demand elements with removable geometry points
83 }
84 
85 
88  return this;
89 }
90 
91 
92 const GUIGeometry&
95 }
96 
97 
100  // first check if there are demand elements
101  if (getChildDemandElements().empty()) {
102  return nullptr;
103  } else {
104  // find child demand element
105  auto it = std::find(getChildDemandElements().begin(), getChildDemandElements().end(), demandElement);
106  // return element or null depending of iterator
107  if (it == getChildDemandElements().end()) {
108  // in this case, we assume that the last child is the previos child
109  return getChildDemandElements().back();
110  } else if (it == getChildDemandElements().begin()) {
111  return nullptr;
112  } else {
113  return *(it - 1);
114  }
115  }
116 }
117 
118 
121  // find child demand element
122  auto it = std::find(getChildDemandElements().begin(), getChildDemandElements().end(), demandElement);
123  // return element or null depending of iterator
124  if (it == getChildDemandElements().end()) {
125  return nullptr;
126  } else if (it == (getChildDemandElements().end() - 1)) {
127  return nullptr;
128  } else {
129  return *(it + 1);
130  }
131 }
132 
133 
134 std::vector<GNEEdge*>
136  std::vector<GNEEdge*> middleEdges;
137  // there are only middle edges if there is more than two edges
138  if (getParentEdges().size() > 2) {
139  // reserve middleEdges
140  middleEdges.reserve(getParentEdges().size() - 2);
141  // iterate over second and previous last parent edge
142  for (auto i = (getParentEdges().begin() + 1); i != (getParentEdges().end() - 1); i++) {
143  middleEdges.push_back(*i);
144  }
145  }
146  return middleEdges;
147 }
148 
149 
150 void
151 GNEDemandElement::updateDemandElementGeometry(const GNELane* lane, const double posOverLane) {
153 }
154 
155 
156 void
158  myStackedLabelNumber = stack;
159 }
160 
161 
162 void
163 GNEDemandElement::updateDemandElementSpreadGeometry(const GNELane* lane, const double posOverLane) {
165 }
166 
167 
168 void
170  throw InvalidArgument(getTagStr() + " doesn't have a demand element dialog");
171 }
172 
173 
174 std::string
176  throw InvalidArgument(getTagStr() + " doesn't have a begin time");
177 }
178 
179 
182  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
183  // build header
184  buildPopupHeader(ret, app);
185  // build menu command for center button and copy cursor position to clipboard
187  buildPositionCopyEntry(ret, app);
188  // buld menu commands for names
189  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " name to clipboard", nullptr, ret, MID_COPY_NAME);
190  GUIDesigns::buildFXMenuCommand(ret, "Copy " + getTagStr() + " typed name to clipboard", nullptr, ret, MID_COPY_TYPED_NAME);
191  new FXMenuSeparator(ret);
192  // build selection and show parameters menu
195  // show option to open demand element dialog
196  if (myTagProperty.hasDialog()) {
197  GUIDesigns::buildFXMenuCommand(ret, ("Open " + getTagStr() + " Dialog").c_str(), getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
198  new FXMenuSeparator(ret);
199  }
200  GUIDesigns::buildFXMenuCommand(ret, "Cursor position in view: " + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
201  return ret;
202 }
203 
204 
207  // Create table
208  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
209  // Iterate over attributes
210  for (const auto& i : myTagProperty) {
211  // Add attribute and set it dynamic if aren't unique
212  if (i.isUnique()) {
213  ret->mkItem(i.getAttrStr().c_str(), false, getAttribute(i.getAttr()));
214  } else {
215  ret->mkItem(i.getAttrStr().c_str(), true, getAttribute(i.getAttr()));
216  }
217  }
218  // close building
219  ret->closeBuilding();
220  return ret;
221 }
222 
223 
224 bool
228  } else {
229  return true;
230  }
231 }
232 
233 
234 void
237 }
238 
239 
240 void
242  // we need an special checks due hierarchies
244  // get person/container plarent
245  GNEDemandElement* parent = getParentDemandElements().front();
246  // if this is the last person/container plan element, remove parent instead plan
247  if (parent->getChildDemandElements().size() == 1) {
248  parent->deleteGLObject();
249  } else {
251  }
252  } else if (getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
253  // remove parent demand element
254  getParentDemandElements().front()->deleteGLObject();
255  } else {
257  }
258 }
259 
260 
261 void
265  } else {
267  }
268  // update information label
270 }
271 
272 
273 void
275  updateGeometry();
276 }
277 
278 
279 double
281  // get previous person Plan
282  const GNEDemandElement* previousPersonPlan = getParentDemandElements().at(0)->getPreviousChildDemandElement(this);
283  // check if this is the first person plan
284  if (previousPersonPlan) {
285  if (previousPersonPlan->getParentAdditionals().size() > 0) {
286  if (previousPersonPlan->getTagProperty().isStopPerson()) {
287  // calculate busStop end
288  const double endPos = previousPersonPlan->getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_ENDPOS);
289  // check endPos
290  if (endPos < 0.3) {
291  return endPos;
292  } else {
293  return (endPos - 0.3);
294  }
295  } else {
296  // use busStop center
297  return previousPersonPlan->getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_CENTER);
298  }
299  } else {
300  // use arrival pos
301  return previousPersonPlan->getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
302  }
303  } else {
304  // use pedestrian departPos
305  return getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_DEPARTPOS);
306  }
307 }
308 
309 
310 Position
312  // get previous person Plan
313  const GNEDemandElement* previousPersonPlan = getParentDemandElements().at(0)->getPreviousChildDemandElement(this);
314  // check if this is the first person plan
315  if (previousPersonPlan) {
316  if (previousPersonPlan->getParentAdditionals().size() > 0) {
317  if (previousPersonPlan->getTagProperty().isStopPerson()) {
318  // get busStop
319  const GNEAdditional* busStop = previousPersonPlan->getParentAdditionals().front();
320  // get length
321  const double length = busStop->getAdditionalGeometry().getShape().length2D();
322  // check length
323  if (length < 0.3) {
324  return busStop->getAdditionalGeometry().getShape().back();
325  } else {
326  return busStop->getAdditionalGeometry().getShape().positionAtOffset2D(length - 0.3);
327  }
328  } else {
329  // use busStop center
330  return previousPersonPlan->getParentAdditionals().front()->getAdditionalGeometry().getShape().getLineCenter();
331  }
332  } else {
333  // use arrival pos
334  return previousPersonPlan->getAttributePosition(SUMO_ATTR_ARRIVALPOS);
335  }
336  } else if (getParentJunctions().size() > 0) {
337  return getParentJunctions().front()->getNBNode()->getPosition();
338  } else {
339  // use pedestrian departPos
340  return getParentDemandElements().at(0)->getAttributePosition(SUMO_ATTR_DEPARTPOS);
341  }
342 }
343 
344 
345 double
347  // check if this person plan ends in a busStop
348  if (getParentAdditionals().size() > 0) {
349  // get next person Plan
350  const GNEDemandElement* nextPersonPlan = getParentDemandElements().at(0)->getNextChildDemandElement(this);
351  // continue depending if is an stop or a person plan
352  if (nextPersonPlan && (nextPersonPlan->getTagProperty().getTag() == GNE_TAG_STOPPERSON_BUSSTOP)) {
353  // calculate busStop end
354  const double endPos = getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_ENDPOS);
355  // check endPos
356  if (endPos < 0.3) {
357  return getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_ENDPOS);
358  } else {
359  return getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_ENDPOS) - 0.3;
360  }
361  } else {
362  return getParentAdditionals().front()->getAttributeDouble(SUMO_ATTR_CENTER);
363  }
364  } else {
366  }
367 }
368 
369 
370 Position
372  // check if this person plan ends in a busStop
373  if (getParentAdditionals().size() > 0) {
374  // get next person Plan
375  const GNEDemandElement* nextPersonPlan = getParentDemandElements().at(0)->getNextChildDemandElement(this);
376  // continue depending if is an stop or a person plan
377  if (nextPersonPlan && (nextPersonPlan->getTagProperty().getTag() == GNE_TAG_STOPPERSON_BUSSTOP)) {
378  // get busStop
379  const GNEAdditional* busStop = nextPersonPlan->getParentAdditionals().front();
380  // get length
381  const double length = busStop->getAdditionalGeometry().getShape().length2D();
382  // check length
383  if (length < 0.3) {
384  return busStop->getAdditionalGeometry().getShape().back();
385  } else {
386  return busStop->getAdditionalGeometry().getShape().positionAtOffset2D(length - 0.3);
387  }
388  } else {
389  return getParentAdditionals().front()->getAdditionalGeometry().getShape().getLineCenter();
390  }
391  } else if (getParentJunctions().size() > 0) {
392  return getParentJunctions().back()->getNBNode()->getPosition();
393  } else {
395  }
396 }
397 
398 // ---------------------------------------------------------------------------
399 // GNEDemandElement - protected methods
400 // ---------------------------------------------------------------------------
401 
402 bool
403 GNEDemandElement::isValidDemandElementID(const std::string& newID) const {
405  return true;
406  } else {
407  return false;
408  }
409 }
410 
411 
412 const Position
413 GNEDemandElement::getBeginPosition(const double pedestrianDepartPos) const {
414  if (myTagProperty.isStopPerson()) {
415  return getPositionInView();
416  } else {
417  // get first lane
418  const GNELane* firstLane = myNet->getPathManager()->getFirstLane(this);
419  if (firstLane) {
420  return firstLane->getLaneShape().positionAtOffset2D(pedestrianDepartPos);
421  } else {
422  return Position(0, 0);
423  }
424  }
425 }
426 
427 
428 std::vector<GNEDemandElement*>
430  // get stops
431  std::vector<GNEDemandElement*> stops;
432  for (const auto& stop : getChildDemandElements()) {
433  if (stop->getTagProperty().getTag() == SUMO_TAG_STOP_LANE) {
434  stops.push_back(stop);
435  }
436  }
437  // check stops
438  if (stops.empty()) {
439  return stops;
440  } else {
441  // get sorted stops
442  std::vector<const GNEDemandElement*> sortedStops;
443  // continue depending of route
444  if (getTagProperty().getTag() == SUMO_TAG_ROUTE) {
445  sortedStops = getSortedStops(getParentEdges());
446  } else if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
447  sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
448  }
449  // iterate over sortedStops
450  for (const auto& sortedStop : sortedStops) {
451  const auto it = std::find(stops.begin(), stops.end(), sortedStop);
452  if (it != stops.end()) {
453  stops.erase(it);
454  }
455  }
456  // return stops not found in sortedStops
457  return stops;
458  }
459 }
460 
461 
462 bool
464  // check conditions
468  // show all person plans in network mode
469  return true;
472  // show all person plans
473  return true;
475  // show selected
476  return true;
478  // person parent is inspected
479  return true;
481  // person parent is locked
482  return true;
483  } else if (myNet->getViewNet()->getInspectedAttributeCarriers().empty()) {
484  // nothing is inspected
485  return false;
486  } else {
487  // get inspected AC
489  // check condition
491  // common person parent
492  return true;
493  } else {
494  // all conditions are false
495  return false;
496  }
497  }
498 }
499 
500 
501 bool
503  // check conditions
507  // show all container plans in network mode
508  return true;
511  // show all container plans
512  return true;
514  // show selected
515  return true;
517  // container parent is inspected
518  return true;
520  // container parent is locked
521  return true;
522  } else if (myNet->getViewNet()->getInspectedAttributeCarriers().empty()) {
523  // nothing is inspected
524  return false;
525  } else {
526  // get inspected AC
528  // check condition
530  // common container parent
531  return true;
532  } else {
533  // all conditions are false
534  return false;
535  }
536  }
537 }
538 
539 
540 void
541 GNEDemandElement::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment,
542  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const {
543  // get inspected and front flags
544  const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this);
545  // get person parent
546  const GNEDemandElement* personParent = getParentDemandElements().front();
547  // check if draw person plan element can be drawn
548  if (drawPlan && myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, lane, myTagProperty.getTag())) {
549  // get inspected attribute carriers
550  const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers();
551  // get inspected person plan
552  const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr;
553  // flag to check if width must be duplicated
554  const bool duplicateWidth = (personPlanInspected == this) || (personPlanInspected == personParent);
555  // calculate path width
556  const double pathWidth = s.addSize.getExaggeration(s, lane) * personPlanWidth * (duplicateWidth ? 2 : 1);
557  // declare path geometry
558  GUIGeometry personPlanGeometry;
559  // update pathGeometry depending of first and last segment
560  if (segment->isFirstSegment() && segment->isLastSegment()) {
561  personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
562  getPathElementDepartValue(), getPathElementArrivalValue(), // extrem positions
563  getPathElementDepartPos(), getPathElementArrivalPos()); // extra positions
564  } else if (segment->isFirstSegment()) {
565  personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
566  getPathElementDepartValue(), -1, // extrem positions
567  getPathElementDepartPos(), Position::INVALID); // extra positions
568  } else if (segment->isLastSegment()) {
569  personPlanGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
570  -1, getPathElementArrivalValue(), // extrem positions
571  Position::INVALID, getPathElementArrivalPos()); // extra positions
572  } else {
573  personPlanGeometry = lane->getLaneGeometry();
574  }
575  // get color
576  const RGBColor& pathColor = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor;
577  // Start drawing adding an gl identificator
579  // Add a draw matrix
581  // Start with the drawing of the area traslating matrix to origin
583  // Set color
584  GLHelper::setColor(pathColor);
585  // draw geometry
586  GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), personPlanGeometry, pathWidth);
587  // Pop last matrix
589  // Draw name if isn't being drawn for selecting
590  if (!s.drawForRectangleSelection) {
591  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
592  }
593  // check if this is the last segment
594  if (segment->isLastSegment()) {
595  // calculate circle width
596  const double circleRadius = (duplicateWidth ? myPersonPlanArrivalPositionDiameter : (myPersonPlanArrivalPositionDiameter / 2.0));
597  const double circleWidth = circleRadius * MIN2((double)0.5, s.laneWidthExaggeration);
598  const double circleWidthSquared = circleWidth * circleWidth;
599  // get geometryEndPos
600  const Position geometryEndPos = getPathElementArrivalPos();
601  // check if endPos can be drawn
602  if (!s.drawForRectangleSelection || (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(geometryEndPos) <= (circleWidthSquared + 2))) {
603  // push draw matrix
605  // Start with the drawing of the area traslating matrix to origin
607  // translate to pos and move to upper using GLO_PERSONTRIP (to avoid overlapping)
608  glTranslated(geometryEndPos.x(), geometryEndPos.y(), 0);
609  // Set person plan color
610  GLHelper::setColor(pathColor);
611  // resolution of drawn circle depending of the zoom (To improve smothness)
613  // pop draw matrix
615  }
616  }
617  // check if we have to draw an red arrow or line
618  if (segment->getNextSegment() && segment->getNextSegment()->getLane()) {
619  // get firstPosition (last position of current lane shape)
620  const Position from = lane->getLaneShape().back();
621  // get lastPosition (first position of next lane shape)
622  const Position to = segment->getNextSegment()->getLane()->getLaneShape().front();
623  // push draw matrix
625  // Start with the drawing of the area traslating matrix to origin
627  // draw child line
628  GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || isAttributeCarrierSelected(), .05);
629  // pop draw matrix
631  }
632  // check if we have to draw an red arrow or line
633  if (segment->getPreviousSegment() && segment->getPreviousSegment()->getLane()) {
634  // get firstPosition (last position of current lane shape)
635  const Position from = lane->getLaneShape().front();
636  // get lastPosition (first position of next lane shape)
637  const Position to = segment->getPreviousSegment()->getLane()->getLaneShape().back();
638  // push draw matrix
640  // Start with the drawing of the area traslating matrix to origin
642  // draw child line
643  GUIGeometry::drawChildLine(s, from, to, RGBColor::RED, dottedElement || isAttributeCarrierSelected(), .05);
644  // pop draw matrix
646  }
647  // Pop name
649  // declare trim geometry to draw
650  const auto shape = (segment->isFirstSegment() || segment->isLastSegment()) ? personPlanGeometry.getShape() : lane->getLaneShape();
651  // check if mouse is over element
652  mouseWithinGeometry(shape, pathWidth);
653  // check if shape dotted contour has to be drawn
654  if (dottedElement) {
655  // inspect contour
658  }
659  // front element contour
660  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
662  }
663  // delete contour
664  if (myNet->getViewNet()->drawDeleteContour(this, this)) {
666  }
667  // select contour
668  if (myNet->getViewNet()->drawSelectContour(this, this)) {
670  }
671  }
672  }
673  // draw person parent if this is the edge first edge and this is the first plan
674  if (getParentJunctions().empty() && (getFirstPathLane()->getParentEdge() == lane->getParentEdge()) &&
675  (personParent->getChildDemandElements().front() == this)) {
676  personParent->drawGL(s);
677  }
678 }
679 
680 
681 void
682 GNEDemandElement::drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* /*segment*/,
683  const double offsetFront, const double personPlanWidth, const RGBColor& personPlanColor) const {
684  // get inspected and front flags
685  const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this);
686  // check if draw person plan elements can be drawn
687  if (drawPlan && myNet->getPathManager()->getPathDraw()->drawPathGeometry(false, fromLane, toLane, myTagProperty.getTag())) {
688  // get inspected attribute carriers
689  const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers();
690  // get person parent
691  const GNEDemandElement* personParent = getParentDemandElements().front();
692  // get inspected person plan
693  const GNEAttributeCarrier* personPlanInspected = (inspectedACs.size() > 0) ? inspectedACs.front() : nullptr;
694  // flag to check if width must be duplicated
695  const bool duplicateWidth = (personPlanInspected == this) || (personPlanInspected == personParent);
696  // calculate path width
697  const double pathWidth = s.addSize.getExaggeration(s, fromLane) * personPlanWidth * (duplicateWidth ? 2 : 1);
698  // get color
699  const RGBColor& color = drawUsingSelectColor() ? s.colorSettings.selectedPersonPlanColor : personPlanColor;
700  // Start drawing adding an gl identificator
702  // push a draw matrix
704  // Start with the drawing of the area traslating matrix to origin
706  // check if draw lane2lane connection or a red line
707  if (fromLane && fromLane->getLane2laneConnections().exist(toLane)) {
708  // obtain lane2lane geometry
709  const GUIGeometry& lane2laneGeometry = fromLane->getLane2laneConnections().getLane2laneGeometry(toLane);
710  // Set person plan color
711  GLHelper::setColor(color);
712  // draw lane2lane
713  GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane2laneGeometry, pathWidth);
714  } else {
715  // Set invalid person plan color
717  // draw line between end of first shape and first position of second shape
718  GLHelper::drawBoxLines({fromLane->getLaneShape().back(), toLane->getLaneShape().front()}, (0.5 * pathWidth));
719  }
720  // Pop last matrix
722  // Pop name
724  // draw lock icon
726  // check if shape dotted contour has to be drawn
727  if (fromLane->getLane2laneConnections().exist(toLane) && dottedElement) {
728  // check if mouse is over element
730  // inspect contour
733  pathWidth, 1, false, false);
734  }
735  // front contour
736  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
738  pathWidth, 1, false, false);
739  }
740  // delete contour
741  if (myNet->getViewNet()->drawDeleteContour(this, this)) {
743  pathWidth, 1, false, false);
744  }
745  // select contour
746  if (myNet->getViewNet()->drawSelectContour(this, this)) {
748  pathWidth, 1, false, false);
749  }
750  }
751  }
752 }
753 
754 
757  // get previous child
758  const auto previousChild = getParentDemandElements().at(0)->getPreviousChildDemandElement(this);
759  if (previousChild) {
760  // get previous edge
761  GNEEdge* previousEdge = nullptr;
762  if (previousChild->getParentLanes().size() == 1) {
763  previousEdge = previousChild->getParentLanes().front()->getParentEdge();
764  } else if (previousChild->getParentAdditionals().size() == 1) {
765  previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
766  } else if (previousChild->getParentEdges().size() > 0) {
767  previousEdge = previousChild->getParentEdges().back();
768  } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
769  previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back();
770  }
771  // get first edge
772  GNEEdge* firstEdge = nullptr;
773  // check edge
774  if (getParentLanes().size() == 1) {
775  firstEdge = getParentLanes().front()->getParentEdge();
776  } else if (getParentEdges().size() > 0) {
777  firstEdge = getParentEdges().front();
778  } else if (getParentAdditionals().size() == 1) {
779  firstEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
780  } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
781  firstEdge = getParentDemandElements().at(1)->getParentEdges().front();
782  }
783  // check junctions
784  if ((previousChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) {
785  if (previousChild->getParentJunctions().back() != getParentJunctions().front()) {
787  }
788  } else if (previousEdge && (getParentJunctions().size() > 0)) {
789  if (previousEdge->getToJunction() != getParentJunctions().front()) {
791  }
792  } else if (previousEdge != firstEdge) {
794  }
795  }
796  // get next child
797  const auto nextChild = getParentDemandElements().at(0)->getNextChildDemandElement(this);
798  if (nextChild) {
799  // get previous edge
800  GNEEdge* nextEdge = nullptr;
801  if (nextChild->getParentLanes().size() == 1) {
802  nextEdge = nextChild->getParentLanes().front()->getParentEdge();
803  } else if (nextChild->getParentEdges().size() > 0) {
804  nextEdge = nextChild->getParentEdges().front();
805  } else if (nextChild->getParentAdditionals().size() == 1) {
806  nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
807  } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
808  nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front();
809  }
810  // get last edge
811  GNEEdge* lastEdge = nullptr;
812  // check edge
813  if (getParentLanes().size() == 1) {
814  lastEdge = getParentLanes().front()->getParentEdge();
815  } else if (getParentAdditionals().size() == 1) {
816  lastEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
817  } else if (getParentEdges().size() > 0) {
818  lastEdge = getParentEdges().back();
819  } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
820  lastEdge = getParentDemandElements().at(1)->getParentEdges().back();
821  }
822  // compare both edges
823  if ((nextChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) {
824  if (nextChild->getParentJunctions().front() != getParentJunctions().back()) {
826  }
827  } else if (nextEdge && (getParentJunctions().size() > 0)) {
828  if (nextEdge->getFromJunction() != getParentJunctions().back()) {
830  }
831  } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) {
832  if (lastEdge->getToJunction() != nextChild->getParentJunctions().front()) {
834  }
835  } else if (nextEdge != lastEdge) {
837  }
838  }
839  // all ok, then return true
840  return Problem::OK;
841 }
842 
843 
844 std::string
846  // get previous child
847  const auto previousChild = getParentDemandElements().at(0)->getPreviousChildDemandElement(this);
848  if (previousChild) {
849  // get previous edge
850  GNEEdge* previousEdge = nullptr;
851  if (previousChild->getParentLanes().size() == 1) {
852  previousEdge = previousChild->getParentLanes().front()->getParentEdge();
853  } else if (previousChild->getParentAdditionals().size() == 1) {
854  previousEdge = previousChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
855  } else if (previousChild->getParentEdges().size() > 0) {
856  previousEdge = previousChild->getParentEdges().back();
857  } else if (previousChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
858  previousEdge = previousChild->getParentDemandElements().at(1)->getParentEdges().back();
859  }
860  // get first edge
861  GNEEdge* firstEdge = nullptr;
862  // check edge
863  if (getParentLanes().size() == 1) {
864  firstEdge = getParentLanes().front()->getParentEdge();
865  } else if (getParentEdges().size() > 0) {
866  firstEdge = getParentEdges().front();
867  } else if (getParentAdditionals().size() == 1) {
868  firstEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
869  } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
870  firstEdge = getParentDemandElements().at(1)->getParentEdges().front();
871  }
872  // compare elements
873  if ((previousChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) {
874  return ("Junction '" + previousChild->getParentJunctions().back()->getID() +
875  "' is not consecutive with junction '" + getParentJunctions().front()->getID() + "'");
876  } else if (previousEdge && (getParentJunctions().size() > 0)) {
877  return ("edge '" + previousEdge->getID() + "' is not consecutive with junction '" + getParentJunctions().front()->getID() + "'");
878  } else if (previousEdge && firstEdge && (previousEdge != firstEdge)) {
879  return "Edge '" + previousEdge->getID() + "' is not consecutive with edge '" + firstEdge->getID() + "'";
880  }
881  }
882  // get next child
883  const auto nextChild = getParentDemandElements().at(0)->getNextChildDemandElement(this);
884  if (nextChild) {
885  // get previous edge
886  GNEEdge* nextEdge = nullptr;
887  if (nextChild->getParentLanes().size() == 1) {
888  nextEdge = nextChild->getParentLanes().front()->getParentEdge();
889  } else if (nextChild->getParentAdditionals().size() == 1) {
890  nextEdge = nextChild->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
891  } else if (nextChild->getParentEdges().size() > 0) {
892  nextEdge = nextChild->getParentEdges().front();
893  } else if (nextChild->getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
894  nextEdge = nextChild->getParentDemandElements().at(1)->getParentEdges().front();
895  }
896  // get last edge
897  GNEEdge* lastEdge = nullptr;
898  // check edge
899  if (getParentLanes().size() == 1) {
900  lastEdge = getParentLanes().front()->getParentEdge();
901  } else if (getParentAdditionals().size() == 1) {
902  lastEdge = getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
903  } else if (getParentEdges().size() > 0) {
904  lastEdge = getParentEdges().back();
905  } else if (getTagProperty().getTag() == GNE_TAG_WALK_ROUTE) {
906  lastEdge = getParentDemandElements().at(1)->getParentEdges().back();
907  }
908  // compare elements
909  if ((nextChild->getParentJunctions().size() > 0) && (getParentJunctions().size() > 0)) {
910  return ("Junction '" + nextChild->getParentJunctions().front()->getID() +
911  "' is not consecutive with junction '" + getParentJunctions().back()->getID() + "'");
912  } else if (nextEdge && (getParentJunctions().size() > 0)) {
913  return ("edge '" + nextEdge->getID() + "' is not consecutive with junction '" + getParentJunctions().back()->getID() + "'");
914  } else if (lastEdge && (nextChild->getParentJunctions().size() > 0)) {
915  return ("edge '" + lastEdge->getID() + "' is not consecutive with junction '" + nextChild->getParentJunctions().back()->getID() + "'");
916  } else if (nextEdge && lastEdge && (nextEdge != lastEdge)) {
917  return "Edge '" + lastEdge->getID() + "' is not consecutive with edge '" + nextEdge->getID() + "'";
918  }
919  }
920  // undefined problem
921  return "undefined problem";
922 }
923 
924 
925 void
927  // get two points
928  const Position posA = element->getParentJunctions().front()->getPositionInView();
929  const Position posB = element->getParentJunctions().back()->getPositionInView();
930  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
931  const double len = posA.distanceTo2D(posB);
932  // push draw matrix
934  // Start with the drawing of the area traslating matrix to origin
935  myNet->getViewNet()->drawTranslateFrontAttributeCarrier(this, element->getType() + 0.1);
936  // set trip color
938  // draw line
939  GLHelper::drawBoxLine(posA, rot, len, 0.25);
940  // pop draw matrix
942 }
943 
944 
945 void
947  replaceParentElements(this, parse<std::vector<GNEEdge*> >(getNet(), value));
948 }
949 
950 
951 void
953  replaceParentElements(this, parse<std::vector<GNELane*> >(getNet(), value));
954 }
955 
956 
957 void
959  std::vector<GNEJunction*> parentJunctions = getParentJunctions();
960  parentJunctions[0] = myNet->getAttributeCarriers()->retrieveJunction(value);
961  // replace parent junctions
962  replaceParentElements(this, parentJunctions);
963 }
964 
965 
966 void
968  std::vector<GNEJunction*> parentJunctions = getParentJunctions();
969  parentJunctions[(int)parentJunctions.size() - 1] = myNet->getAttributeCarriers()->retrieveJunction(value);
970  // replace parent junctions
971  replaceParentElements(this, parentJunctions);
972 }
973 
974 
975 void
976 GNEDemandElement::replaceFirstParentEdge(const std::string& value) {
977  std::vector<GNEEdge*> parentEdges = getParentEdges();
978  parentEdges[0] = myNet->getAttributeCarriers()->retrieveEdge(value);
979  // replace parent edges
980  replaceParentElements(this, parentEdges);
981 }
982 
983 
984 void
985 GNEDemandElement::replaceMiddleParentEdges(const std::string& value, const bool updateChildReferences) {
986  std::vector<GNEEdge*> middleEdges = parse<std::vector<GNEEdge*> >(getNet(), value);
987  middleEdges.insert(middleEdges.begin(), getParentEdges().front());
988  middleEdges.push_back(getParentEdges().back());
989  // check if we have to update references in all childs, or simply update parent edges vector
990  if (updateChildReferences) {
991  // replace parent edges
992  replaceParentElements(this, middleEdges);
993  } else {
994  myHierarchicalContainer.setParents<std::vector<GNEEdge*> >(middleEdges);
995  }
996 }
997 
998 
999 void
1000 GNEDemandElement::replaceLastParentEdge(const std::string& value) {
1001  std::vector<GNEEdge*> parentEdges = getParentEdges();
1002  parentEdges[(int)parentEdges.size() - 1] = myNet->getAttributeCarriers()->retrieveEdge(value);
1003  // replace parent edges
1004  replaceParentElements(this, parentEdges);
1005 }
1006 
1007 
1008 void
1010  std::vector<GNEAdditional*> parentAdditionals = getParentAdditionals();
1011  parentAdditionals[0] = myNet->getAttributeCarriers()->retrieveAdditional(tag, value);
1012  // replace parent additionals
1013  replaceParentElements(this, parentAdditionals);
1014 }
1015 
1016 
1017 void
1018 GNEDemandElement::replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
1019  std::vector<GNEDemandElement*> parentDemandElements = getParentDemandElements();
1020  parentDemandElements[parentIndex] = myNet->getAttributeCarriers()->retrieveDemandElement(tag, value);
1021  // replace parent demand elements
1022  replaceParentElements(this, parentDemandElements);
1023 }
1024 
1025 
1026 void
1028  std::vector<GNEDemandElement*> parents;
1029  if (value.size() > 0) {
1031  }
1032  replaceParentElements(this, parents);
1033 }
1034 
1035 
1036 bool
1038  // throw exception because this function mus be implemented in child (see GNEE3Detector)
1039  throw ProcessError("Calling non-implemented function checkChildDemandElementRestriction during saving of " + getTagStr() + ". It muss be reimplemented in child class");
1040 }
1041 
1042 
1044  edge(edge_) {
1045 }
1046 
1047 
1048 void
1050  // create first pair
1051  auto posIndexPair = std::make_pair(stop->getAttributeDouble(SUMO_ATTR_ENDPOS), stop->getAttributeDouble(SUMO_ATTR_INDEX));
1052  myStops.push_back(std::make_pair(posIndexPair, stop));
1053  // sort stops
1054  std::sort(myStops.begin(), myStops.end());
1055 }
1056 
1057 
1058 std::vector<const GNEDemandElement*>
1059 GNEDemandElement::getSortedStops(const std::vector<GNEEdge*>& edges) const {
1060  std::vector<GNEDemandElement*> stops;
1061  // get stops
1062  for (const auto& stop : getChildDemandElements()) {
1063  if (stop->getTagProperty().isStop()) {
1064  stops.push_back(stop);
1065  }
1066  }
1067  // create SortedStops
1068  std::vector<SortedStops> sortedStops;
1069  for (const auto& edge : edges) {
1070  sortedStops.push_back(SortedStops(edge));
1071  }
1072  // iterate over all stops and insert it in sortedStops
1073  for (const auto& stop : stops) {
1074  bool stopLoop = false;
1075  // iterate over sortedStops
1076  for (auto it = sortedStops.begin(); (it != sortedStops.end()) && !stopLoop; it++) {
1077  if ((stop->getParentAdditionals().size() > 0) && (stop->getParentAdditionals().front()->getParentLanes().front()->getParentEdge() == it->edge)) {
1078  it->addStop(stop);
1079  stopLoop = true;
1080  } else if ((stop->getParentLanes().size() > 0) && (stop->getParentLanes().front()->getParentEdge() == it->edge)) {
1081  it->addStop(stop);
1082  stopLoop = true;
1083  }
1084  }
1085  }
1086  // finally return sorted stops
1087  std::vector<const GNEDemandElement*> solution;
1088  for (const auto& sortedStop : sortedStops) {
1089  for (const auto& stop : sortedStop.myStops) {
1090  solution.push_back(stop.second);
1091  }
1092  }
1093  return solution;
1094 }
1095 
1096 
1097 void
1098 GNEDemandElement::setFlowParameters(SUMOVehicleParameter* vehicleParameters, const SumoXMLAttr attribute, const bool value) {
1099  // modify parameters depending of given Flow attribute
1100  if (value) {
1101  switch (attribute) {
1102  case SUMO_ATTR_END:
1103  vehicleParameters->parametersSet |= VEHPARS_END_SET;
1104  break;
1105  case SUMO_ATTR_NUMBER:
1106  vehicleParameters->parametersSet |= VEHPARS_NUMBER_SET;
1107  break;
1108  case SUMO_ATTR_VEHSPERHOUR:
1111  vehicleParameters->parametersSet |= VEHPARS_VPH_SET;
1112  break;
1113  case SUMO_ATTR_PERIOD:
1114  vehicleParameters->parametersSet |= VEHPARS_PERIOD_SET;
1115  break;
1116  case GNE_ATTR_POISSON:
1117  vehicleParameters->parametersSet |= VEHPARS_POISSON_SET;
1118  break;
1119  case SUMO_ATTR_PROB:
1120  vehicleParameters->parametersSet |= VEHPARS_PROB_SET;
1121  break;
1122  default:
1123  break;
1124  }
1125  } else {
1126  switch (attribute) {
1127  case SUMO_ATTR_END:
1128  vehicleParameters->parametersSet &= ~VEHPARS_END_SET;
1129  break;
1130  case SUMO_ATTR_NUMBER:
1131  vehicleParameters->parametersSet &= ~VEHPARS_NUMBER_SET;
1132  break;
1133  case SUMO_ATTR_VEHSPERHOUR:
1136  vehicleParameters->parametersSet &= ~VEHPARS_VPH_SET;
1137  break;
1138  case SUMO_ATTR_PERIOD:
1139  vehicleParameters->parametersSet &= ~VEHPARS_PERIOD_SET;
1140  break;
1141  case GNE_ATTR_POISSON:
1142  vehicleParameters->parametersSet &= ~VEHPARS_POISSON_SET;
1143  break;
1144  case SUMO_ATTR_PROB:
1145  vehicleParameters->parametersSet &= ~VEHPARS_PROB_SET;
1146  break;
1147  default:
1148  break;
1149  }
1150  }
1151 }
1152 
1153 
1154 void
1156  // first check that this demand element is a flow
1157  if (myTagProperty.isFlow()) {
1158  // end
1159  if ((vehicleParameters->parametersSet & VEHPARS_END_SET) == 0) {
1161  }
1162  // number
1163  if ((vehicleParameters->parametersSet & VEHPARS_NUMBER_SET) == 0) {
1165  }
1166  // vehicles/person/container per hour
1167  if (((vehicleParameters->parametersSet & VEHPARS_PERIOD_SET) == 0) &&
1168  ((vehicleParameters->parametersSet & VEHPARS_POISSON_SET) == 0) &&
1169  ((vehicleParameters->parametersSet & VEHPARS_VPH_SET) == 0)) {
1171  }
1172  // probability
1173  if ((vehicleParameters->parametersSet & VEHPARS_PROB_SET) == 0) {
1175  }
1176  // poisson
1177  if (vehicleParameters->repetitionOffset < 0) {
1180  setAttribute(GNE_ATTR_POISSON, time2string(vehicleParameters->repetitionOffset * -1));
1181  }
1182  }
1183 }
1184 
1185 
1186 void
1188  std::vector<GNEEdge*> edges;
1189  if (myTagProperty.isRoute()) {
1190  edges = getParentEdges();
1191  } else if ((getParentDemandElements().size() > 1) && getParentDemandElements().at(1)->getTagProperty().isRoute()) {
1192  edges = getParentDemandElements().at(1)->getParentEdges();
1193  } else if ((getChildDemandElements().size() > 0) && getChildDemandElements().front()->getTagProperty().isRoute()) {
1194  edges = getChildDemandElements().front()->getParentEdges();
1195  } else if (getParentEdges().size() > 0) {
1196  edges = getParentEdges();
1197  }
1198  // calculate path
1199  const auto path = myNet->getPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edges);
1200  // check path size
1201  if (path.size() > 0) {
1202  double length = 0;
1203  for (const auto& edge : path) {
1204  length += edge->getNBEdge()->getFinalLength();
1205  }
1206  for (int i = 0; i < ((int)path.size() - 1); i++) {
1207  length += path.at(i)->getLanes().front()->getLane2laneConnections().getLane2laneGeometry(path.at(i + 1)->getLanes().front()).getShape().length();
1208  }
1209  GUIDesigns::buildFXMenuCommand(ret, "Route length: " + toString(length), nullptr, ret, MID_COPY_NAME);
1210  }
1211 }
1212 
1213 /****************************************************************************/
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:450
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition: GUIAppEnum.h:460
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:448
GUIGlObjectType
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
const int VEHPARS_PROB_SET
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_POISSON_SET
const int VEHPARS_NUMBER_SET
const int VEHPARS_PERIOD_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_STOP_LANE
stop placed over a lane (used in netedit)
@ GNE_TAG_STOPPERSON_BUSSTOP
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_ROUTE_EMBEDDED
embedded route (used in NETEDIT)
@ GNE_TAG_WALK_ROUTE
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ENDPOS
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_POISSON
poisson definition (used in flow)
@ SUMO_ATTR_CONTAINERSPERHOUR
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_CENTER
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_PROB
@ SUMO_ATTR_PERSONSPERHOUR
T MIN2(T a, T b)
Definition: StdDefs.h:71
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:49
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:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:329
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:277
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:48
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool myIsTemplate
whether the current object is a template object (not drawn in the view)
virtual void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
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
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
virtual std::string getAttribute(SumoXMLAttr key) const =0
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
An Element which don't belong to GNENet but has influence in the simulation.
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandParentEdges(const std::string &value)
replace demand parent edges
virtual void updateGeometry()=0
update pre-computed geometry information
std::vector< GNEDemandElement * > getInvalidStops() const
get invalid stops
virtual SUMOVehicleClass getVClass() const =0
void updateDemandElementGeometry(const GNELane *lane, const double posOverLane)
update element stacked geometry (stacked)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
virtual std::string getBegin() const
get begin time of demand element
Problem isPersonPlanValid() const
check if person plan is valid
Position getPathElementArrivalPos() const
get path element arrival position
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual double getAttributeDouble(SumoXMLAttr key) const =0
GNEDemandElement * getNextChildDemandElement(const GNEDemandElement *demandElement) const
get next child demand element to the given demand element
void updateDemandElementStackLabel(const int stack)
update stack label
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual std::string getAttribute(SumoXMLAttr key) const =0
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
double getPathElementArrivalValue() const
get path element arrival lane pos
virtual Boundary getCenteringBoundary() const =0
Returns the boundary to which the view shall be centered in order to show the object.
void selectGLObject()
select element
bool drawContainerPlan() const
check if container plan can be drawn
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
std::string getPersonPlanProblem() const
get person plan problem
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
void setVTypeDistributionParent(const std::string &value)
set VTypeDistribution parent
void updateGLObject()
update GLObject (geometry, ID, etc.)
std::vector< const GNEDemandElement * > getSortedStops(const std::vector< GNEEdge * > &edges) const
get sorted stops
void replaceDemandParentLanes(const std::string &value)
replace demand parent lanes
virtual GNELane * getFirstPathLane() const =0
get first path lane
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
bool isGLObjectLocked()
check if element is locked
int myStackedLabelNumber
stacked label number
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void updateDemandElementSpreadGeometry(const GNELane *lane, const double posOverLane)
update element spread geometry
virtual Position getPositionInView() const =0
Returns position of demand element in view.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform demand element changes
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value)
replace additional parent
const GUIGeometry & getDemandElementGeometry()
get demand element geometry (stacked)
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
virtual bool checkChildDemandElementRestriction() const
check restriction with the number of children
const Position getBeginPosition(const double pedestrianDepartPos) const
get personPlan start position
Problem
enum class for demandElement problems
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
GNEDemandElement * getPreviousChildDemandElement(const GNEDemandElement *demandElement) const
get previous child demand element to the given demand element
Position getPathElementDepartPos() const
get path element depart position
void adjustDefaultFlowAttributes(SUMOVehicleParameter *vehicleParameters)
adjust flow default attributes (called in vehicle/person/flow constructors)
double getPathElementDepartValue() const
get path element depart lane pos
void replaceMiddleParentEdges(const std::string &value, const bool updateChildReferences)
replace middle (via) parent edges
void markAsFrontElement()
mark element as front element
void setFlowParameters(SUMOVehicleParameter *vehicleParameters, const SumoXMLAttr attribute, const bool value)
set flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawPersonPlanPartial(const bool drawPlan, const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront, const double personPlanWidth, const RGBColor &personPlanColor) const
draw person plan partial lane
bool isValidDemandElementID(const std::string &newID) const
check if a new demand element ID is valid
std::vector< GNEEdge * > getViaEdges() const
get middle (via) parent edges
static const double myPersonPlanArrivalPositionDiameter
person plans arrival position radius
virtual void drawGL(const GUIVisualizationSettings &s) const =0
Draws the object.
virtual ~GNEDemandElement()
Destructor.
virtual void openDemandElementDialog()
open DemandElement Dialog
void deleteGLObject()
delete element
bool drawPersonPlan() const
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
virtual Position getAttributePosition(SumoXMLAttr key) const =0
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
GNEJunction * getFromJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:77
GNEJunction * getToJunction() const
get from Junction (only used to increase readability)
Definition: GNEEdge.h:82
void setParents(const T &newParents)
set parents
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
GNEHierarchicalContainer myHierarchicalContainer
hierarchical container with parents and children
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
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
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:142
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:917
const GUIGeometry & getLaneGeometry() const
Definition: GNELane.cpp:136
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:124
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void deleteDemandElement(GNEDemandElement *demandElement, GNEUndoList *undoList)
remove demand element
Definition: GNENet.cpp:650
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
bool drawPathGeometry(const bool dottedElement, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
bool isRoute() const
check if pathElement is a route
Segment * getPreviousSegment() const
get previous segment
Segment * getNextSegment() const
get next segment
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
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
PathDraw * getPathDraw()
obtain instance of PathDraw
const GNELane * getFirstLane(const PathElement *pathElement) const
get first lane associated with path element
void updateInformationLabel()
update information label
SelectionInformation * getSelectionInformation() const
get modul for selection information
bool isFlow() const
return true if tag correspond to a flow element
bool isPersonPlan() const
return true if tag correspond to a person plan
bool isRoute() const
return true if tag correspond to a route element
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
bool isStopPerson() const
return true if tag correspond to a person stop element
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
bool isContainerPlan() const
return true if tag correspond to a container plan
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
void setFrontAttributeCarrier(GNEAttributeCarrier *AC)
set front attributeCarrier
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:644
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:474
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:650
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedContourShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between child and parent (used in NETEDIT)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:58
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:154
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationSizeSettings addSize
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
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:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:257
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:298
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition: RGBColor.h:185
Structure representing possible vehicle parameter.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
#define M_PI
Definition: odrSpiral.cpp:45
struct for writting sorted stops
void addStop(const GNEDemandElement *stop)
add (and sort) stop
SortedStops(GNEEdge *edge_)
constructor
bool showAllPersonPlans() const
check all person plans has to be show
const GNEDemandElement * getLockedPerson() const
get locked person
const GNEDemandElement * getLockedContainer() const
get locked container
bool showAllContainerPlans() const
check all container plans has to be show
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor selectedPersonPlanColor
person plan selection color (Rides, Walks, stopPersons...)
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values