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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Representation of containers in netedit
19 /****************************************************************************/
21 #include <netedit/GNENet.h>
22 #include <netedit/GNEUndoList.h>
23 #include <netedit/GNEViewNet.h>
25 #include <utils/gui/div/GLHelper.h>
28 #include <utils/xml/NamespaceIDs.h>
29 
30 #include "GNEContainer.h"
31 #include "GNERouteHandler.h"
32 
33 // ===========================================================================
34 // FOX callback mapping
35 // ===========================================================================
36 
37 FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[] = {
39 };
40 
41 FXDEFMAP(GNEContainer::GNESelectedContainersPopupMenu) selectedContainersPopupMenuMap[] = {
43 };
44 
45 // Object implementation
46 FXIMPLEMENT(GNEContainer::GNEContainerPopupMenu, GUIGLObjectPopupMenu, containerPopupMenuMap, ARRAYNUMBER(containerPopupMenuMap))
47 FXIMPLEMENT(GNEContainer::GNESelectedContainersPopupMenu, GUIGLObjectPopupMenu, selectedContainersPopupMenuMap, ARRAYNUMBER(selectedContainersPopupMenuMap))
48 
49 // ===========================================================================
50 // GNEContainer::GNEContainerPopupMenu
51 // ===========================================================================
52 
54  GUIGLObjectPopupMenu(app, parent, *container),
55  myContainer(container),
56  myTransformToContainer(nullptr),
57  myTransformToContainerFlow(nullptr) {
58  // build header
59  myContainer->buildPopupHeader(this, app);
60  // build menu command for center button and copy cursor position to clipboard
61  myContainer->buildCenterPopupEntry(this);
62  myContainer->buildPositionCopyEntry(this, app);
63  // build menu commands for names
64  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
65  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myContainer->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
66  new FXMenuSeparator(this);
67  // build selection and show parameters menu
68  myContainer->getNet()->getViewNet()->buildSelectionACPopupEntry(this, myContainer);
69  myContainer->buildShowParamsPopupEntry(this);
70  // add transform functions only in demand mode
71  if (myContainer->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
72  // create menu pane for transform operations
73  FXMenuPane* transformOperation = new FXMenuPane(this);
74  this->insertMenuPaneChild(transformOperation);
75  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
76  // Create menu comands for all transformations
77  myTransformToContainer = GUIDesigns::buildFXMenuCommand(transformOperation, "Container", GUIIconSubSys::getIcon(GUIIcon::CONTAINER), this, MID_GNE_CONTAINER_TRANSFORM);
78  myTransformToContainerFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "ContainerFlow", GUIIconSubSys::getIcon(GUIIcon::CONTAINERFLOW), this, MID_GNE_CONTAINER_TRANSFORM);
79  // check what menu command has to be disabled
80  if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINER) {
81  myTransformToContainer->disable();
82  } else if (myContainer->getTagProperty().getTag() == SUMO_TAG_CONTAINERFLOW) {
83  myTransformToContainerFlow->disable();
84  }
85  }
86 }
87 
88 
90 
91 
92 long
93 GNEContainer::GNEContainerPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
94  if (obj == myTransformToContainer) {
96  } else if (obj == myTransformToContainerFlow) {
98  }
99  return 1;
100 }
101 
102 
103 // ===========================================================================
104 // GNEContainer::GNESelectedContainersPopupMenu
105 // ===========================================================================
106 
107 GNEContainer::GNESelectedContainersPopupMenu::GNESelectedContainersPopupMenu(GNEContainer* container, const std::vector<GNEContainer*>& selectedContainer, GUIMainWindow& app, GUISUMOAbstractView& parent) :
108  GUIGLObjectPopupMenu(app, parent, *container),
109  myContainerTag(container->getTagProperty().getTag()),
110  mySelectedContainers(selectedContainer),
111  myTransformToContainer(nullptr),
112  myTransformToContainerFlow(nullptr) {
113  // build header
114  container->buildPopupHeader(this, app);
115  // build menu command for center button and copy cursor position to clipboard
116  container->buildCenterPopupEntry(this);
117  container->buildPositionCopyEntry(this, app);
118  // build menu commands for names
119  GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
120  GUIDesigns::buildFXMenuCommand(this, ("Copy " + container->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
121  new FXMenuSeparator(this);
122  // build selection and show parameters menu
123  container->getNet()->getViewNet()->buildSelectionACPopupEntry(this, container);
124  container->buildShowParamsPopupEntry(this);
125  // add transform functions only in demand mode
126  if (container->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
127  // create menu pane for transform operations
128  FXMenuPane* transformOperation = new FXMenuPane(this);
129  this->insertMenuPaneChild(transformOperation);
130  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
131  // Create menu comands for all transformations
134  }
135 }
136 
137 
139 
140 
141 long
143  // iterate over all selected containers
144  for (const auto& container : mySelectedContainers) {
145  if ((obj == myTransformToContainer) &&
146  (container->getTagProperty().getTag() == myContainerTag)) {
148  } else if ((obj == myTransformToContainerFlow) &&
149  (container->getTagProperty().getTag() == myContainerTag)) {
151  }
152  }
153  return 1;
154 }
155 
156 // ===========================================================================
157 // member method definitions
158 // ===========================================================================
159 
162  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
163 GNEDemandElementFlow(this) {
164  // reset default values
166  // set end and container per hours as default flow values
169 }
170 
171 
172 GNEContainer::GNEContainer(SumoXMLTag tag, GNENet* net, GNEDemandElement* pType, const SUMOVehicleParameter& containerparameters) :
173  GNEDemandElement(containerparameters.id, net, (tag == SUMO_TAG_CONTAINERFLOW) ? GLO_CONTAINERFLOW : GLO_CONTAINER, tag,
175  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {pType}, {}),
176 GNEDemandElementFlow(this, containerparameters) {
177  // set manually vtypeID (needed for saving)
178  vtypeid = pType->getID();
179 }
180 
181 
183 
184 
187  // check first container plan
188  if (getChildDemandElements().front()->getTagProperty().isPlanStopContainer()) {
189  return nullptr;
190  } else {
191  // get lane
192  const GNELane* lane = getChildDemandElements().front()->getParentEdges().front()->getLaneByAllowedVClass(getVClass());
193  // declare departPos
194  double posOverLane = 0;
195  if (canParse<double>(getDepartPos())) {
196  posOverLane = parse<double>(getDepartPos());
197  }
198  // return move operation
199  return new GNEMoveOperation(this, lane, posOverLane, false);
200  }
201 }
202 
203 
204 void
206  // attribute VType musn't be written if is DEFAULT_PEDTYPE_ID
208  // unset VType parameter
210  // write container attributes (VType will not be written)
212  // set VType parameter again
214  } else {
215  // write container attributes, including VType
217  }
218  // write flow attributes
219  writeFlowAttributes(this, device);
220  // write parameters
221  writeParams(device);
222  // write child demand elements associated to this container (Rides, Walks...)
223  for (const auto& containerPlan : getChildDemandElements()) {
224  containerPlan->writeDemandElement(device);
225  }
226  // close container tag
227  device.closeTag();
228 }
229 
230 
233  if (getChildDemandElements().size() == 0) {
234  return Problem::NO_PLANS;
235  } else {
236  return Problem::OK;
237  }
238 }
239 
240 
241 std::string
243  if (getChildDemandElements().size() == 0) {
244  return "Container needs at least one plan";
245  } else {
246  return "";
247  }
248 }
249 
250 
251 void
253  // nothing to fix
254 }
255 
256 
259  return getParentDemandElements().front()->getVClass();
260 }
261 
262 
263 const RGBColor&
265  return color;
266 }
267 
268 
269 void
271  // only update geometry of childrens
272  for (const auto& demandElement : getChildDemandElements()) {
273  demandElement->updateGeometry();
274  }
275 }
276 
277 
278 Position
281 }
282 
283 
286  // return a GNEContainerPopupMenu
287  return new GNEContainerPopupMenu(this, app, parent);
288 }
289 
290 
291 std::string
293  return getParentDemandElements().front()->getID();
294 }
295 
296 
297 double
299  return s.containerSize.getExaggeration(s, this, 80);
300 }
301 
302 
303 Boundary
305  Boundary containerBoundary;
306  if (getChildDemandElements().size() > 0) {
307  if (getChildDemandElements().front()->getTagProperty().isPlanStopContainer()) {
308  // use boundary of stop center
309  return getChildDemandElements().front()->getCenteringBoundary();
310  } else {
311  containerBoundary.add(getPositionInView());
312  }
313  } else {
314  containerBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
315  }
316  containerBoundary.grow(20);
317  return containerBoundary;
318 }
319 
320 
321 void
322 GNEContainer::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
323  // geometry of this element cannot be splitted
324 }
325 
326 
327 void
329  bool drawContainer = true;
330  // check if container can be drawn
332  drawContainer = false;
334  drawContainer = false;
336  drawContainer = false;
337  } else if (getChildDemandElements().empty()) {
338  drawContainer = false;
339  }
340  // continue if container can be drawn
341  if (drawContainer) {
342  // obtain exaggeration (and add the special containerExaggeration)
343  const double exaggeration = getExaggeration(s) + 10;
344  // get detail level
345  const auto d = s.getDetailLevel(exaggeration);
346  // obtain position
347  const Position containerPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
348  // draw geometry only if we'rent in drawForObjectUnderCursor mode
349  if (!s.drawForViewObjectsHandler) {
350  // obtain img file
351  const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
352  // push draw matrix
354  // Start with the drawing of the area traslating matrix to origin
356  // translate and rotate
357  glTranslated(containerPosition.x(), containerPosition.y(), 0);
358  glRotated(90, 0, 0, 1);
359  // set container color
361  // set scale
362  glScaled(exaggeration, exaggeration, 1);
363  // draw container depending of detail level
364  switch (s.containerQuality) {
365  case 0:
366  case 1:
367  case 2:
369  break;
370  case 3:
371  default:
373  break;
374  }
375  // pop matrix
377  // draw line between junctions if container plan isn't valid
378  for (const auto& containerPlan : getChildDemandElements()) {
379  if (containerPlan->getTagProperty().isPlanContainer() && (containerPlan->getParentJunctions().size() > 0) && !myNet->getPathManager()->isPathValid(containerPlan)) {
380  drawJunctionLine(containerPlan);
381  }
382  }
383  // draw stack label
384  if (myStackedLabelNumber > 0) {
385  drawStackLabel(myStackedLabelNumber, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
386  } else if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_STOPCONTAINER_CONTAINERSTOP) {
387  // declare counter for stacked containers over stops
388  int stackedCounter = 0;
389  // get stoppingPlace
390  const auto stoppingPlace = getChildDemandElements().front()->getParentAdditionals().front();
391  // get stacked containers
392  for (const auto& stopContainer : stoppingPlace->getChildDemandElements()) {
393  if (stopContainer->getTagProperty().getTag() == GNE_TAG_STOPCONTAINER_CONTAINERSTOP) {
394  // get container parent
395  const auto containerParent = stopContainer->getParentDemandElements().front();
396  // check if the stop if the first container plan parent
397  if (stopContainer->getPreviousChildDemandElement(containerParent) == nullptr) {
398  stackedCounter++;
399  }
400  }
401  }
402  // if we have more than two stacked elements, draw label
403  if (stackedCounter > 1) {
404  drawStackLabel(stackedCounter, "container", Position(containerPosition.x() - 2.5, containerPosition.y() - 0.8), -90, 1.3, 5, getExaggeration(s));
405  }
406  }
407  // draw flow label
408  if (myTagProperty.isFlow()) {
409  drawFlowLabel(Position(containerPosition.x() - 1, containerPosition.y() - 4.25), -90, 1.8, 2, getExaggeration(s));
410  }
411  // draw name
412  drawName(containerPosition, s.scale, s.containerName, s.angle);
413  if (s.personValue.show(this)) {
414  Position containerValuePosition = containerPosition + Position(0, 0.6 * s.containerName.scaledSize(s.scale));
415  const double value = getColorValue(s, s.containerColorer.getActive());
416  GLHelper::drawTextSettings(s.personValue, toString(value), containerValuePosition, s.scale, s.angle, GLO_MAX - getType());
417  }
418  // draw lock icon
420  // draw dotted contour
422  }
423  // calculate contour
424  myContainerContour.calculateContourRectangleShape(s, d, this, containerPosition, 0.5, 0.2, -2.5, 0, 0, exaggeration);
425  }
426 }
427 
428 
429 void
431  // compute all container plan children (because aren't computed in "computeDemandElements()")
432  for (const auto& demandElement : getChildDemandElements()) {
433  demandElement->computePathElement();
434  }
435 }
436 
437 
438 void
439 GNEContainer::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
440  // Stops don't use drawJunctionPartialGL
441 }
442 
443 
444 void
445 GNEContainer::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
446  // Stops don't use drawJunctionPartialGL
447 }
448 
449 
450 GNELane*
452  // use path lane of first container plan
453  return getChildDemandElements().front()->getFirstPathLane();
454 }
455 
456 
457 GNELane*
459  // use path lane of first container plan
460  return getChildDemandElements().front()->getLastPathLane();
461 }
462 
463 
464 std::string
466  // declare string error
467  std::string error;
468  switch (key) {
469  case SUMO_ATTR_ID:
470  return getMicrosimID();
471  case SUMO_ATTR_TYPE:
472  return getTypeParent()->getID();
473  case SUMO_ATTR_COLOR:
474  if (wasSet(VEHPARS_COLOR_SET)) {
475  return toString(color);
476  } else {
478  }
479  case SUMO_ATTR_DEPARTPOS:
481  return getDepartPos();
482  } else {
484  }
485  // Other
486  case GNE_ATTR_SELECTED:
488  case GNE_ATTR_PARAMETERS:
489  return getParametersStr();
490  default:
491  return getFlowAttribute(key);
492  }
493 }
494 
495 
496 double
498  switch (key) {
499  case SUMO_ATTR_DEPARTPOS:
500  return STEPS2TIME(depart);
501  default:
502  return getFlowAttributeDouble(key);
503  }
504 }
505 
506 
507 Position
509  switch (key) {
510  case SUMO_ATTR_DEPARTPOS: {
511  // first check number of child demand elements
512  if (getChildDemandElements().empty()) {
513  return Position();
514  }
515  // get person plan
516  const GNEDemandElement* personPlan = getChildDemandElements().front();
517  // first check if first person plan is a stop
518  if (personPlan->getTagProperty().isPlanStopContainer()) {
519  // stop center
520  return personPlan->getPositionInView();
521  } else if (personPlan->getTagProperty().planFromTAZ()) {
522  // TAZ
523  return personPlan->getParentAdditionals().front()->getPositionInView();
524  } else if (personPlan->getTagProperty().planFromJunction()) {
525  // juncrtion
526  return personPlan->getParentJunctions().front()->getPositionInView();
527  } else {
529  }
530  }
531  default:
532  throw InvalidArgument(getTagStr() + " doesn't have a Position attribute of type '" + toString(key) + "'");
533  }
534 }
535 
536 
537 void
538 GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
539  switch (key) {
540  case SUMO_ATTR_ID:
541  case SUMO_ATTR_TYPE:
542  case SUMO_ATTR_COLOR:
543  case SUMO_ATTR_DEPARTPOS:
544  // Other
545  case GNE_ATTR_PARAMETERS:
546  case GNE_ATTR_SELECTED:
547  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
548  break;
549  default:
550  setFlowAttribute(this, key, value, undoList);
551  break;
552  }
553 }
554 
555 
556 bool
557 GNEContainer::isValid(SumoXMLAttr key, const std::string& value) {
558  // declare string error
559  std::string error;
560  switch (key) {
561  case SUMO_ATTR_ID:
563  case SUMO_ATTR_TYPE:
564  return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) == nullptr);
565  case SUMO_ATTR_COLOR:
566  return canParse<RGBColor>(value);
567  case SUMO_ATTR_DEPARTPOS: {
568  double dummyDepartPos;
569  DepartPosDefinition dummyDepartPosProcedure;
570  parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
571  // if error is empty, given value is valid
572  return error.empty();
573  }
574  // Other
575  case GNE_ATTR_SELECTED:
576  return canParse<bool>(value);
577  case GNE_ATTR_PARAMETERS:
578  return Parameterised::areParametersValid(value);
579  default:
580  return isValidFlowAttribute(this, key, value);
581  }
582 }
583 
584 
585 void
587  enableFlowAttribute(this, key, undoList);
588 }
589 
590 
591 void
593  disableFlowAttribute(this, key, undoList);
594 }
595 
596 
597 bool
599  return isFlowAttributeEnabled(key);
600 }
601 
602 
603 std::string
605  return getTagStr();
606 }
607 
608 
609 std::string
611  // special case for Trips and flow
613  // check if we're inspecting a Edge
614  if (myNet->getViewNet()->getInspectedAttributeCarriers().front() &&
615  myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
616  // check if edge correspond to a "from", "to" or "via" edge
618  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
619  } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
620  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
621  } else {
622  // iterate over via
623  for (const auto& i : via) {
624  if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
625  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
626  }
627  }
628  }
629  }
630  }
631  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
632 }
633 
634 
635 const Parameterised::Map&
637  return getParametersMap();
638 }
639 
640 // ===========================================================================
641 // protected
642 // ===========================================================================
643 
644 void
646  // obtain width and length
647  const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
648  const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
649  // draw pedestrian shape
650  glScaled(length * 0.2, width * 0.2, 1);
651  glBegin(GL_QUADS);
652  glVertex2d(0, 0.5);
653  glVertex2d(0, -0.5);
654  glVertex2d(-1, -0.5);
655  glVertex2d(-1, 0.5);
656  glEnd();
657  GLHelper::setColor(GLHelper::getColor().changedBrightness(-30));
658  glTranslated(0, 0, .045);
659  glBegin(GL_QUADS);
660  glVertex2d(-0.1, 0.4);
661  glVertex2d(-0.1, -0.4);
662  glVertex2d(-0.9, -0.4);
663  glVertex2d(-0.9, 0.4);
664  glEnd();
665 }
666 
667 
668 void
670  const std::string& file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
671  // obtain width and length
672  const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
673  const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
674  if (file != "") {
675  // @todo invent an option for controlling whether images should be rotated or not
676  //if (getVehicleType().getGuiShape() == SVS_CONTAINER) {
677  // glRotated(RAD2DEG(getAngle() + M_PI / 2.), 0, 0, 1);
678  //}
679  int textureID = GUITexturesHelper::getTextureID(file);
680  if (textureID > 0) {
681  const double exaggeration = s.personSize.getExaggeration(s, this);
682  const double halfLength = length / 2.0 * exaggeration;
683  const double halfWidth = width / 2.0 * exaggeration;
684  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, -halfLength, halfWidth, halfLength);
685  }
686  } else {
687  // fallback if no image is defined
689  }
690 }
691 
692 // ===========================================================================
693 // private
694 // ===========================================================================
695 
697  containerPlan(_containerPlan),
698  edge(nullptr),
699  arrivalPos(-1) {
700 }
701 
702 
704  containerPlan(nullptr),
705  edge(nullptr),
706  arrivalPos(-1) {
707 }
708 
709 
710 void
711 GNEContainer::setAttribute(SumoXMLAttr key, const std::string& value) {
712  // declare string error
713  std::string error;
714  switch (key) {
715  case SUMO_ATTR_ID:
716  // update microsimID
717  setDemandElementID(value);
718  // update id
719  id = value;
720  break;
721  case SUMO_ATTR_TYPE:
722  if (getID().size() > 0) {
724  // set manually vtypeID (needed for saving)
725  vtypeid = value;
726  }
727  break;
728  case SUMO_ATTR_COLOR:
729  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
730  color = parse<RGBColor>(value);
731  // mark parameter as set
733  } else {
734  // set default value
735  color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
736  // unset parameter
738  }
739  break;
740  case SUMO_ATTR_DEPARTPOS:
741  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
743  // mark parameter as set
745  } else {
746  // set default value
748  // unset parameter
750  }
751  // compute container
752  updateGeometry();
753  break;
754  // Others
755  case GNE_ATTR_SELECTED:
756  if (parse<bool>(value)) {
758  } else {
760  }
761  break;
762  case GNE_ATTR_PARAMETERS:
763  setParametersStr(value);
764  break;
765  default:
766  setFlowAttribute(this, key, value);
767  break;
768  }
769 }
770 
771 
772 void
774  // toggle flow attributes
775  toggleFlowAttribute(key, value);
776 }
777 
778 
779 void GNEContainer::setMoveShape(const GNEMoveResult& moveResult) {
780  // change departPos
782  departPos = moveResult.newFirstPos;
783  // update geometry
784  updateGeometry();
785 }
786 
787 
788 void
790  undoList->begin(this, "departPos of " + getTagStr());
791  // now set departPos
792  setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
793  undoList->end();
794 }
795 
796 /****************************************************************************/
FXDEFMAP(GNEContainer::GNEContainerPopupMenu) containerPopupMenuMap[]
@ MID_GNE_CONTAINER_TRANSFORM
transform container to another container type (ej: container to containerflow)
Definition: GUIAppEnum.h:1382
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:453
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:451
@ 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
#define STEPS2TIME(x)
Definition: SUMOTime.h:55
const std::string DEFAULT_CONTAINERTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int VEHPARS_COLOR_SET
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_VTYPE_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_CONTAINERFLOW
@ GNE_TAG_STOPCONTAINER_CONTAINERSTOP
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ 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.
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ GNE_ATTR_SELECTED
element is selected
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINERSPERHOUR
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_END
weights: time range end
@ 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:319
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:654
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:660
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:787
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
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
void resetDefaultValues()
reset attribute carrier to their default values
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
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
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
Position getAttributePosition(SumoXMLAttr key) const
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
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_ToggleAttribute)
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 drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
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 drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
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
obtain VClass related with this demand element
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.
GNEContour myContainerContour
variable used for contours
Definition: GNEContainer.h:279
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)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double scale) const
calculate contour (for rectangled elements)
Definition: GNEContour.cpp:103
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:265
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
std::string getFlowAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual std::string getAttribute(SumoXMLAttr key) const =0
void setDemandElementID(const std::string &newID)
set demand element id
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
int myStackedLabelNumber
stacked label number
virtual Position getPositionInView() const =0
Returns position of demand element in view.
Problem
enum class for demandElement problems
virtual Position getAttributePosition(SumoXMLAttr key) const =0
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
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
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
move operation
move result
double newFirstPos
new first position
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, 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:122
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:134
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
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
bool planFromJunction() const
return true if tag correspond to a plan that starts in junction
bool isFlow() const
return true if tag correspond to a flow element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isPlanStopContainer() const
return true if tag correspond to a container stop plan
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool planFromTAZ() const
return true if tag correspond to a plan that starts in TAZ
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
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...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:715
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:538
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:721
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
Definition: GUIDesigns.cpp:42
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:203
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 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:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
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
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
int containerQuality
The quality of container drawing.
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationSizeSettings personSize
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationTextSettings containerName
GUIColorer containerColorer
The container colorer.
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
Definition: NamespaceIDs.h:53
static const std::vector< SumoXMLTag > containers
containers namespace
Definition: NamespaceIDs.h:65
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
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 x() const
Returns the x-position.
Definition: Position.h:55
double y() const
Returns the y-position.
Definition: Position.h:60
Structure representing possible vehicle parameter.
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.
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.
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
bool wasSet(int what) const
Returns whether the given parameter was set.
std::string getDepartPos() const
obtain depart pos parameter in string format
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.
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 GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, 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 segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size