Eclipse SUMO - Simulation of Urban MObility
GNEContainer.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 // Representation of containers in NETEDIT
19 /****************************************************************************/
20 #include <cmath>
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
27 #include <utils/gui/div/GLHelper.h>
33 
34 #include "GNEContainer.h"
35 #include "GNERouteHandler.h"
36 
37 
38 // ===========================================================================
39 // FOX callback mapping
40 // ===========================================================================
41 FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[] = {
43 };
44 
45 FXDEFMAP(GNEContainer::GNESelectedContainersPopupMenu) selectedContainersPopupMenuMap[] = {
47 };
48 
49 // Object implementation
50 FXIMPLEMENT(GNEContainer::GNEContainerPopupMenu, GUIGLObjectPopupMenu, containerPopupMenuMap, ARRAYNUMBER(containerPopupMenuMap))
51 FXIMPLEMENT(GNEContainer::GNESelectedContainersPopupMenu, GUIGLObjectPopupMenu, selectedContainersPopupMenuMap, ARRAYNUMBER(selectedContainersPopupMenuMap))
52 
53 // ===========================================================================
54 // GNEContainer::GNEContainerPopupMenu
55 // ===========================================================================
56 
58  GUIGLObjectPopupMenu(app, parent, *container),
59  myContainer(container),
60  myTransformToContainer(nullptr),
61  myTransformToContainerFlow(nullptr) {
62  // build header
63  myContainer->buildPopupHeader(this, app);
64  // build menu command for center button and copy cursor position to clipboard
65  myContainer->buildCenterPopupEntry(this);
66  myContainer->buildPositionCopyEntry(this, app);
67  // buld menu commands for names
68  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
69  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
70  new FXMenuSeparator(this);
71  // build selection and show parameters menu
72  myContainer->getNet()->getViewNet()->buildSelectionACPopupEntry(this, myContainer);
73  myContainer->buildShowParamsPopupEntry(this);
74  // add transform functions only in demand mode
75  if (myContainer->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
76  // create menu pane for transform operations
77  FXMenuPane* transformOperation = new FXMenuPane(this);
78  this->insertMenuPaneChild(transformOperation);
79  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
80  // Create menu comands for all transformations
81  myTransformToContainer = GUIDesigns::buildFXMenuCommand(transformOperation, "Container", GUIIconSubSys::getIcon(GUIIcon::CONTAINER), this, MID_GNE_CONTAINER_TRANSFORM);
82  myTransformToContainerFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "ContainerFlow", GUIIconSubSys::getIcon(GUIIcon::CONTAINERFLOW), this, MID_GNE_CONTAINER_TRANSFORM);
83  // check what menu command has to be disabled
84  if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINER) {
85  myTransformToContainer->disable();
86  } else if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINERFLOW) {
87  myTransformToContainerFlow->disable();
88  }
89  }
90 }
91 
92 
94 
95 
96 long
97 GNEContainer::GNEContainerPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
98  if (obj == myTransformToContainer) {
100  } else if (obj == myTransformToContainerFlow) {
102  }
103  return 1;
104 }
105 
106 
107 // ===========================================================================
108 // GNEContainer::GNESelectedContainersPopupMenu
109 // ===========================================================================
110 
111 GNEContainer::GNESelectedContainersPopupMenu::GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent) :
112  GUIGLObjectPopupMenu(app, parent, *container),
113  myContainerTag(container->getTagProperty().getTag()),
114  mySelectedContainers(selectedContainer),
115  myTransformToContainer(nullptr),
116  myTransformToContainerFlow(nullptr) {
117  // build header
118  container->buildPopupHeader(this, app);
119  // build menu command for center button and copy cursor position to clipboard
120  container->buildCenterPopupEntry(this);
121  container->buildPositionCopyEntry(this, app);
122  // buld menu commands for names
123  GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
124  GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
125  new FXMenuSeparator(this);
126  // build selection and show parameters menu
127  container->getNet()->getViewNet()->buildSelectionACPopupEntry(this, container);
128  container->buildShowParamsPopupEntry(this);
129  // add transform functions only in demand mode
130  if (container->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
131  // create menu pane for transform operations
132  FXMenuPane* transformOperation = new FXMenuPane(this);
133  this->insertMenuPaneChild(transformOperation);
134  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
135  // Create menu comands for all transformations
138  }
139 }
140 
141 
143 
144 
145 long
147  // iterate over all selected containers
148  for (const auto& container : mySelectedContainers) {
149  if ((obj == myTransformToContainer) &&
150  (container->getTagProperty().getTag() == myContainerTag)) {
152  } else if ((obj == myTransformToContainerFlow) &&
153  (container->getTagProperty().getTag() == myContainerTag)) {
155  }
156  }
157  return 1;
158 }
159 
160 // ===========================================================================
161 // member method definitions
162 // ===========================================================================
163 
166  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}) {
167  // reset default values
168  resetDefaultValues();
169  // set end and vehPerHours
170  toggleAttribute(SUMO_ATTR_END, 1);
171  toggleAttribute(SUMO_ATTR_CONTAINERSPERHOUR, 1);
172 }
173 
174 
175 GNEContainer::GNEContainer(SumoXMLTag tag, GNENet* net, GNEDemandElement* pType, const SUMOVehicleParameter& containerparameters) :
176  GNEDemandElement(containerparameters.id, net, (tag == SUMO_TAG_CONTAINERFLOW) ? GLO_CONTAINERFLOW : GLO_CONTAINER, tag,
178  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {pType}, {}),
179 SUMOVehicleParameter(containerparameters) {
180  // set manually vtypeID (needed for saving)
181  vtypeid = pType->getID();
182  // adjust default flow attributes
184 }
185 
186 
188 
189 
192  // check first container plan
193  if (getChildDemandElements().front()->getTagProperty().isStopContainer()) {
194  return nullptr;
195  } else {
196  // get lane
197  const GNELane* lane = getChildDemandElements().front()->getParentEdges().front()->getLaneByAllowedVClass(getVClass());
198  // declare departPos
199  double posOverLane = 0;
200  if (canParse<double>(getDepartPos())) {
201  posOverLane = parse<double>(getDepartPos());
202  }
203  // return move operation
204  return new GNEMoveOperation(this, lane, posOverLane, false);
205  }
206 }
207 
208 
209 std::string
211  // obtain depart
212  std::string departStr = depart < 0 ? "0.00" : time2string(depart);
213  // we need to handle depart as a tuple of 20 numbers (format: 000000...00<departTime>)
214  departStr.reserve(20 - departStr.size());
215  // add 0s at the beginning of departStr until we have 20 numbers
216  for (int i = (int)departStr.size(); i < 20; i++) {
217  departStr.insert(departStr.begin(), '0');
218  }
219  return departStr;
220 }
221 
222 
223 void
225  // attribute VType musn't be written if is DEFAULT_PEDTYPE_ID
227  // unset VType parameter
229  // write container attributes (VType will not be written)
231  // set VType parameter again
233  } else {
234  // write container attributes, including VType
236  }
237  // write specific flow attributes
239  // write routeFlow values depending if it was set
242  }
245  }
248  }
251  }
253  device.writeAttr(SUMO_ATTR_PERIOD, "exp(" + time2string(repetitionOffset) + ")");
254  }
257  }
258  }
259  // write parameters
260  writeParams(device);
261  // write child demand elements associated to this container (Rides, Walks...)
262  for (const auto& containerPlan : getChildDemandElements()) {
263  containerPlan->writeDemandElement(device);
264  }
265  // close container tag
266  device.closeTag();
267 }
268 
269 
272  if (getChildDemandElements().size() == 0) {
273  return Problem::NO_PLANS;
274  } else {
275  return Problem::OK;
276  }
277 }
278 
279 
280 std::string
282  if (getChildDemandElements().size() == 0) {
283  return "Container needs at least one plan";
284  } else {
285  return "";
286  }
287 }
288 
289 
290 void
292  // nothing to fix
293 }
294 
295 
298  return getParentDemandElements().front()->getVClass();
299 }
300 
301 
302 const RGBColor&
304  return color;
305 }
306 
307 
308 void
310  // only update geometry of childrens
311  for (const auto& demandElement : getChildDemandElements()) {
312  demandElement->updateGeometry();
313  }
314 }
315 
316 
317 Position
320 }
321 
322 
325  // return a GNEContainerPopupMenu
326  return new GNEContainerPopupMenu(this, app, parent);
327 }
328 
329 
330 std::string
332  return getParentDemandElements().front()->getID();
333 }
334 
335 
336 double
338  return s.containerSize.getExaggeration(s, this, 80);
339 }
340 
341 
342 Boundary
344  Boundary containerBoundary;
345  if (getChildDemandElements().size() > 0) {
346  if (getChildDemandElements().front()->getTagProperty().isStopContainer()) {
347  // use boundary of stop center
348  return getChildDemandElements().front()->getCenteringBoundary();
349  } else {
350  containerBoundary.add(getPositionInView());
351  }
352  } else {
353  containerBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
354  }
355  containerBoundary.grow(20);
356  return containerBoundary;
357 }
358 
359 
360 void
361 GNEContainer::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
362  // geometry of this element cannot be splitted
363 }
364 
365 
366 void
368  bool drawContainer = true;
369  // check if container can be drawn
371  drawContainer = false;
373  drawContainer = false;
375  drawContainer = false;
376  } else if (getChildDemandElements().empty()) {
377  drawContainer = false;
378  }
379  // continue if container can be drawn
380  if (drawContainer) {
381  // obtain exaggeration (and add the special containerExaggeration)
382  const double exaggeration = getExaggeration(s) + s.detailSettings.personExaggeration;
383  // obtain width and length
384  const double length = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
385  const double width = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_WIDTH);
386  // obtain diameter around container (used to calculate distance bewteen cursor and container)
387  const double distanceSquared = pow(exaggeration * std::max(length, width), 2);
388  // obtain img file
389  const std::string file = getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_IMGFILE);
390  // obtain position
391  const Position containerPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
392  // check if container can be drawn
393  if (!(s.drawForPositionSelection && (containerPosition.distanceSquaredTo(myNet->getViewNet()->getPositionInformation()) > distanceSquared))) {
394  // push GL ID
396  // push draw matrix
398  // Start with the drawing of the area traslating matrix to origin
400  // translate and rotate
401  glTranslated(containerPosition.x(), containerPosition.y(), 0);
402  glRotated(90, 0, 0, 1);
403  // set container color
405  // set scale
406  glScaled(exaggeration, exaggeration, 1);
407  // draw container depending of detail level
408  switch (s.containerQuality) {
409  case 0:
410  case 1:
411  case 2:
413  break;
414  case 3:
415  default:
417  break;
418  }
419  // pop matrix
421  // draw line between junctions if container plan isn't valid
422  for (const auto& containerPlan : getChildDemandElements()) {
423  if (containerPlan->getTagProperty().isContainerPlan() && (containerPlan->getParentJunctions().size() > 0) && !myNet->getPathManager()->isPathValid(containerPlan)) {
424  drawJunctionLine(containerPlan);
425  }
426  }
427  // pop name
429  // draw name
430  drawName(containerPosition, s.scale, s.containerName, s.angle);
431  if (s.personValue.show(this)) {
432  Position containerValuePosition = containerPosition + Position(0, 0.6 * s.containerName.scaledSize(s.scale));
433  const double value = getColorValue(s, s.containerColorer.getActive());
434  GLHelper::drawTextSettings(s.personValue, toString(value), containerValuePosition, s.scale, s.angle, GLO_MAX - getType());
435  }
436  // check if mouse is over element
437  mouseWithinGeometry(containerPosition, 0.5, 0.2, -2.5, 0, 0);
438  // draw lock icon
440  // inspect contour
442  // draw using drawDottedSquaredShape
443  GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::INSPECT, containerPosition, 0.5, 0.2, -2.5, 0, 0, exaggeration);
444  }
445  // front element contour
446  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
447  // draw using drawDottedSquaredShape
448  GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::FRONT, containerPosition, 0.5, 0.2, -2.5, 0, 0, exaggeration);
449  }
450  // delete contour
451  if (myNet->getViewNet()->drawDeleteContour(this, this)) {
452  // draw using drawDottedSquaredShape
453  GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::REMOVE, containerPosition, 0.5, 0.2, -2.5, 0, 0, exaggeration);
454  }
455  // select contour
456  if (myNet->getViewNet()->drawSelectContour(this, this)) {
457  // draw using drawDottedSquaredShape
458  GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::SELECT, containerPosition, 0.5, 0.2, -2.5, 0, 0, exaggeration);
459  }
460  }
461  }
462 }
463 
464 
465 void
467  // compute all container plan children (because aren't computed in "computeDemandElements()")
468  for (const auto& demandElement : getChildDemandElements()) {
469  demandElement->computePathElement();
470  }
471 }
472 
473 
474 void
475 GNEContainer::drawPartialGL(const GUIVisualizationSettings& /*s*/, const GNELane* /*lane*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
476  // Stops don't use drawPartialGL
477 }
478 
479 
480 void
481 GNEContainer::drawPartialGL(const GUIVisualizationSettings& /*s*/, const GNELane* /*fromLane*/, const GNELane* /*toLane*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
482  // Stops don't use drawPartialGL
483 }
484 
485 
486 GNELane*
488  // use path lane of first container plan
489  return getChildDemandElements().front()->getFirstPathLane();
490 }
491 
492 
493 GNELane*
495  // use path lane of first container plan
496  return getChildDemandElements().front()->getLastPathLane();
497 }
498 
499 
500 std::string
502  // declare string error
503  std::string error;
504  switch (key) {
505  case SUMO_ATTR_ID:
506  return getMicrosimID();
507  case SUMO_ATTR_TYPE:
508  return getParentDemandElements().at(0)->getID();
509  case SUMO_ATTR_COLOR:
510  if (wasSet(VEHPARS_COLOR_SET)) {
511  return toString(color);
512  } else {
514  }
515  case SUMO_ATTR_DEPARTPOS:
517  return getDepartPos();
518  } else {
520  }
521  // Specific of containers
522  case SUMO_ATTR_DEPART:
524  return "triggered";
526  return "containerTriggered";
528  return "split";
529  } else if (departProcedure == DepartDefinition::NOW) {
530  return "now";
531  } else {
532  return time2string(depart);
533  }
534  // Specific of containerFlows
535  case SUMO_ATTR_BEGIN:
536  return time2string(depart);
537  case SUMO_ATTR_END:
538  return time2string(repetitionEnd);
540  return toString(3600 / STEPS2TIME(repetitionOffset));
541  case SUMO_ATTR_PERIOD:
542  case GNE_ATTR_POISSON:
544  case SUMO_ATTR_PROB:
546  case SUMO_ATTR_NUMBER:
547  return toString(repetitionNumber);
548  //
549  case GNE_ATTR_SELECTED:
551  case GNE_ATTR_PARAMETERS:
552  return getParametersStr();
553  default:
554  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
555  }
556 }
557 
558 
559 double
561  switch (key) {
562  case SUMO_ATTR_DEPARTPOS:
563  return STEPS2TIME(depart);
564  default:
565  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
566  }
567 }
568 
569 
570 Position
572  switch (key) {
573  case SUMO_ATTR_DEPARTPOS: {
574  // get container plan
575  const GNEDemandElement* containerPlan = getChildDemandElements().front();
576  // first check if first container plan is a stop
577  if (containerPlan->getTagProperty().isStopContainer()) {
578  return containerPlan->getPositionInView();
579  } else {
580  // declare lane lane
581  const GNELane* lane = containerPlan->getParentEdges().front()->getLaneByAllowedVClass(SVC_IGNORING);
582  // get position over lane shape
583  if (departPos <= 0) {
584  return lane->getLaneShape().front();
585  } else if (departPos >= lane->getLaneShape().length2D()) {
586  return lane->getLaneShape().back();
587  } else {
588  return lane->getLaneShape().positionAtOffset2D(departPos);
589  }
590  }
591  }
592  default:
593  throw InvalidArgument(getTagStr() + " doesn't have a Position attribute of type '" + toString(key) + "'");
594  }
595 }
596 
597 
598 void
599 GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
600  switch (key) {
601  case SUMO_ATTR_ID:
602  case SUMO_ATTR_TYPE:
603  case SUMO_ATTR_COLOR:
604  case SUMO_ATTR_DEPARTPOS:
605  // Specific of containers
606  case SUMO_ATTR_DEPART:
607  // Specific of containerFlows
608  case SUMO_ATTR_BEGIN:
609  case SUMO_ATTR_END:
610  case SUMO_ATTR_NUMBER:
612  case SUMO_ATTR_PERIOD:
613  case GNE_ATTR_POISSON:
614  case SUMO_ATTR_PROB:
615  //
616  case GNE_ATTR_PARAMETERS:
617  case GNE_ATTR_SELECTED:
618  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
619  break;
620  default:
621  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
622  }
623 }
624 
625 
626 bool
627 GNEContainer::isValid(SumoXMLAttr key, const std::string& value) {
628  // declare string error
629  std::string error;
630  switch (key) {
631  case SUMO_ATTR_ID:
632  // Containers and containerflows share namespace
634  (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_CONTAINER, value, false) == nullptr) &&
636  return true;
637  } else {
638  return false;
639  }
640  case SUMO_ATTR_TYPE:
642  case SUMO_ATTR_COLOR:
643  return canParse<RGBColor>(value);
644  case SUMO_ATTR_DEPARTPOS: {
645  double dummyDepartPos;
646  DepartPosDefinition dummyDepartPosProcedure;
647  parseDepartPos(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPos, dummyDepartPosProcedure, error);
648  // if error is empty, given value is valid
649  return error.empty();
650  }
651  // Specific of containers
652  case SUMO_ATTR_DEPART:
653  case SUMO_ATTR_BEGIN: {
654  SUMOTime dummyDepart;
655  DepartDefinition dummyDepartProcedure;
656  parseDepart(value, toString(SUMO_TAG_CONTAINER), id, dummyDepart, dummyDepartProcedure, error);
657  // if error is empty, given value is valid
658  return error.empty();
659  }
660  // Specific of containerflows
661  case SUMO_ATTR_END:
662  if (value.empty()) {
663  return true;
664  } else if (canParse<double>(value)) {
665  return (parse<double>(value) >= 0);
666  } else {
667  return false;
668  }
670  if (value.empty()) {
671  return true;
672  } else if (canParse<double>(value)) {
673  return (parse<double>(value) > 0);
674  } else {
675  return false;
676  }
677  case SUMO_ATTR_PERIOD:
678  case GNE_ATTR_POISSON:
679  if (value.empty()) {
680  return true;
681  } else if (canParse<double>(value)) {
682  return (parse<double>(value) > 0);
683  } else {
684  return false;
685  }
686  case SUMO_ATTR_PROB:
687  if (value.empty()) {
688  return true;
689  } else if (canParse<double>(value)) {
690  return (parse<double>(value) >= 0);
691  } else {
692  return false;
693  }
694  case SUMO_ATTR_NUMBER:
695  if (canParse<int>(value)) {
696  return (parse<int>(value) >= 0);
697  } else {
698  return false;
699  }
700  //
701  case GNE_ATTR_SELECTED:
702  return canParse<bool>(value);
703  case GNE_ATTR_PARAMETERS:
704  return Parameterised::areParametersValid(value);
705  default:
706  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
707  }
708 }
709 
710 
711 void
713  switch (key) {
714  case SUMO_ATTR_END:
715  case SUMO_ATTR_NUMBER:
717  case SUMO_ATTR_PERIOD:
718  case GNE_ATTR_POISSON:
719  case SUMO_ATTR_PROB:
720  undoList->add(new GNEChange_EnableAttribute(this, key, true, parametersSet), true);
721  return;
722  default:
723  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
724  }
725 }
726 
727 
728 void
730  switch (key) {
731  case SUMO_ATTR_END:
732  case SUMO_ATTR_NUMBER:
734  case SUMO_ATTR_PERIOD:
735  case GNE_ATTR_POISSON:
736  case SUMO_ATTR_PROB:
737  undoList->add(new GNEChange_EnableAttribute(this, key, false, parametersSet), true);
738  return;
739  default:
740  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
741  }
742 }
743 
744 
745 bool
747  switch (key) {
748  case SUMO_ATTR_END:
749  return (parametersSet & VEHPARS_END_SET) != 0;
750  case SUMO_ATTR_NUMBER:
751  return (parametersSet & VEHPARS_NUMBER_SET) != 0;
753  return (parametersSet & VEHPARS_VPH_SET) != 0;
754  case SUMO_ATTR_PERIOD:
755  return (parametersSet & VEHPARS_PERIOD_SET) != 0;
756  case GNE_ATTR_POISSON:
757  return (parametersSet & VEHPARS_POISSON_SET) != 0;
758  case SUMO_ATTR_PROB:
759  return (parametersSet & VEHPARS_PROB_SET) != 0;
760  default:
761  return true;
762  }
763 }
764 
765 
766 std::string
768  return getTagStr();
769 }
770 
771 
772 std::string
774  // special case for Trips and flow
776  // check if we're inspecting a Edge
777  if (myNet->getViewNet()->getInspectedAttributeCarriers().front() &&
778  myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
779  // check if edge correspond to a "from", "to" or "via" edge
781  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
782  } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
783  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
784  } else {
785  // iterate over via
786  for (const auto& i : via) {
787  if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
788  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
789  }
790  }
791  }
792  }
793  }
794  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
795 }
796 
797 
798 const Parameterised::Map&
800  return getParametersMap();
801 }
802 
803 // ===========================================================================
804 // protected
805 // ===========================================================================
806 
807 void
809  // obtain width and length
810  const double length = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
811  const double width = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_WIDTH);
812  // draw pedestrian shape
813  glScaled(length * 0.2, width * 0.2, 1);
814  glBegin(GL_QUADS);
815  glVertex2d(0, 0.5);
816  glVertex2d(0, -0.5);
817  glVertex2d(-1, -0.5);
818  glVertex2d(-1, 0.5);
819  glEnd();
820  GLHelper::setColor(GLHelper::getColor().changedBrightness(-30));
821  glTranslated(0, 0, .045);
822  glBegin(GL_QUADS);
823  glVertex2d(-0.1, 0.4);
824  glVertex2d(-0.1, -0.4);
825  glVertex2d(-0.9, -0.4);
826  glVertex2d(-0.9, 0.4);
827  glEnd();
828 }
829 
830 
831 void
833  const std::string& file = getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_IMGFILE);
834  // obtain width and length
835  const double length = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
836  const double width = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_WIDTH);
837  if (file != "") {
838  // @todo invent an option for controlling whether images should be rotated or not
839  //if (getVehicleType().getGuiShape() == SVS_CONTAINER) {
840  // glRotated(RAD2DEG(getAngle() + M_PI / 2.), 0, 0, 1);
841  //}
842  int textureID = GUITexturesHelper::getTextureID(file);
843  if (textureID > 0) {
844  const double exaggeration = s.personSize.getExaggeration(s, this);
845  const double halfLength = length / 2.0 * exaggeration;
846  const double halfWidth = width / 2.0 * exaggeration;
847  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, -halfLength, halfWidth, halfLength);
848  }
849  } else {
850  // fallback if no image is defined
852  }
853 }
854 
855 // ===========================================================================
856 // private
857 // ===========================================================================
858 
860  containerPlan(_containerPlan),
861  edge(nullptr),
862  arrivalPos(-1) {
863 }
864 
865 
867  containerPlan(nullptr),
868  edge(nullptr),
869  arrivalPos(-1) {
870 }
871 
872 
873 void
874 GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value) {
875  // declare string error
876  std::string error;
877  switch (key) {
878  case SUMO_ATTR_ID:
879  // update microsimID
880  setMicrosimID(value);
881  // update id
882  id = value;
883  // Change IDs of all container plans children
884  for (const auto& containerPlans : getChildDemandElements()) {
885  containerPlans->setMicrosimID(getID());
886  }
887  break;
888  case SUMO_ATTR_TYPE:
889  if (getID().size() > 0) {
891  // set manually vtypeID (needed for saving)
892  vtypeid = value;
893  }
894  break;
895  case SUMO_ATTR_COLOR:
896  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
897  color = parse<RGBColor>(value);
898  // mark parameter as set
900  } else {
901  // set default value
902  color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
903  // unset parameter
905  }
906  break;
907  case SUMO_ATTR_DEPARTPOS:
908  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
910  // mark parameter as set
912  } else {
913  // set default value
915  // unset parameter
917  }
918  // compute container
919  updateGeometry();
920  break;
921  // Specific of containers
922  case SUMO_ATTR_DEPART:
923  case SUMO_ATTR_BEGIN: {
925  break;
926  }
927  case SUMO_ATTR_END:
928  repetitionEnd = string2time(value);
929  break;
931  repetitionOffset = TIME2STEPS(3600 / parse<double>(value));
932  break;
933  case SUMO_ATTR_PERIOD:
934  case GNE_ATTR_POISSON:
935  repetitionOffset = string2time(value);
936  break;
937  case SUMO_ATTR_PROB:
938  repetitionProbability = parse<double>(value);
939  break;
940  case SUMO_ATTR_NUMBER:
941  repetitionNumber = parse<int>(value);
942  break;
943  //
944  case GNE_ATTR_SELECTED:
945  if (parse<bool>(value)) {
947  } else {
949  }
950  break;
951  case GNE_ATTR_PARAMETERS:
952  setParametersStr(value);
953  break;
954  default:
955  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
956  }
957 }
958 
959 
960 void
962  // set flow parameters
963  setFlowParameters(this, key, value);
964 }
965 
966 
967 void GNEContainer::setMoveShape(const GNEMoveResult& moveResult) {
968  // change departPos
970  departPos = moveResult.newFirstPos;
971  // update geometry
972  updateGeometry();
973 }
974 
975 
976 void
978  undoList->begin(GUIIcon::CONTAINER, "departPos of " + getTagStr());
979  // now set departPos
980  setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
981  undoList->end();
982 }
983 
984 /****************************************************************************/
FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[]
long long int SUMOTime
Definition: GUI.h:35
@ MID_GNE_CONTAINER_TRANSFORM
transform container to another container type (ej: container to containerflow)
Definition: GUIAppEnum.h:1287
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:450
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:448
@ GLO_MAX
empty max
@ GLO_CONTAINER
a container
@ GLO_CONTAINERFLOW
a person flow
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
@ CONTAINERFLOW
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
const std::string DEFAULT_CONTAINERTYPE_ID
const int VEHPARS_PROB_SET
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_COLOR_SET
const int VEHPARS_POISSON_SET
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_NUMBER_SET
const int VEHPARS_PERIOD_SET
const int VEHPARS_VTYPE_SET
DepartDefinition
Possible ways to depart.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ SPLIT
The departure is triggered by a train split.
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_CONTAINERFLOW
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_CONTAINER
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_DEPART
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ GNE_ATTR_POISSON
poisson definition (used in flow)
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINERSPERHOUR
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_PROB
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_IMGFILE
@ SUMO_ATTR_WIDTH
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:78
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:589
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:716
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_EnableAttribute
friend class GNEChange_Attribute
declare friend class
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
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
class used in GUIGLObjectPopupMenu for container transformations
Definition: GNEContainer.h:37
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current container to another container type.
class used in GUIGLObjectPopupMenu for single container transformations
Definition: GNEContainer.h:69
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current container to another container type.
GNESelectedContainersPopupMenu(GNEContainer *container, const std::vector< GNEContainer * > &selectedContainer, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
FXMenuCommand * myTransformToContainer
menu command for transform to container
Definition: GNEContainer.h:98
FXMenuCommand * myTransformToContainerFlow
menu command for transform to containerFlow
Definition: GNEContainer.h:101
Position getPositionInView() const
Returns position of demand element in view.
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
GNELane * getLastPathLane() const
get last path lane
void updateGeometry()
update pre-computed geometry information
std::string getBegin() const
get begin time of demand element
Position getAttributePosition(SumoXMLAttr key) const
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const RGBColor & getColor() const
get color
GNEContainer(SumoXMLTag tag, GNENet *net)
default constructor
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
void drawAction_drawAsPoly() const
draw container as poly
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
void computePathElement()
compute pathElement
void drawAction_drawAsImage(const GUIVisualizationSettings &s) const
draw container as image
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
~GNEContainer()
destructor
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
std::string getParentName() const
Returns the name of the parent object.
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
SUMOVehicleClass getVClass() const
GNEMoveOperation * getMoveOperation()
get move operation
double getAttributeDouble(SumoXMLAttr key) const
bool isAttributeEnabled(SumoXMLAttr key) const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
GNELane * getFirstPathLane() const
get first path lane
const Parameterised::Map & getACParametersMap() const
get parameters map
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
An Element which don't belong to GNENet but has influence in the simulation.
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual Position getPositionInView() const =0
Returns position of demand element in view.
Problem
enum class for demandElement problems
void adjustDefaultFlowAttributes(SUMOVehicleParameter *vehicleParameters)
adjust flow default attributes (called in vehicle/person/flow constructors)
void setFlowParameters(SUMOVehicleParameter *vehicleParameters, const SumoXMLAttr attribute, const bool value)
set flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
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
move operation
move result
double newFirstPos
new first position
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
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
PathElement()=delete
invalidate default constructor
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
static void transformToContainerFlow(GNEContainer *originalContainer)
transform routeFlow over an existent route
static void transformToContainer(GNEContainer *originalContainer)
transform container functions
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
bool isStopContainer() const
return true if tag correspond to a container stop element
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...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:656
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
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
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
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
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedSquaredShape(const GUIVisualizationSettings &s, const DottedContourType type, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double exaggeration)
draw dotted squared contour (used by additionals and demand elements)
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
virtual double getColorValue(const GUIVisualizationSettings &, int) const
Definition: GUIGlObject.h:198
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
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
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
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
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings containerSize
GUIVisualizationTextSettings personValue
GUIVisualizationDetailSettings detailSettings
detail settings
int containerQuality
The quality of container drawing.
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
GUIVisualizationSizeSettings personSize
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationTextSettings containerName
GUIColorer containerColorer
The container colorer.
double angle
The current view rotation angle.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition: Position.h:247
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.
Structure representing possible vehicle parameter.
double repetitionProbability
The probability for emitting a vehicle per second.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
double departPos
(optional) The position the vehicle shall depart from
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string getDepartPos() const
obtain depart pos parameter in string format
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
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
static const double personExaggeration
Exaggeration for persons (only used in NETEDIT)
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size