Eclipse SUMO - Simulation of Urban MObility
GNEPerson.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 persons 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>
29 #include <utils/xml/NamespaceIDs.h>
30 
31 #include "GNEPerson.h"
32 #include "GNERouteHandler.h"
33 
34 // ===========================================================================
35 // FOX callback mapping
36 // ===========================================================================
37 FXDEFMAP(GNEPerson::GNEPersonPopupMenu) personPopupMenuMap[] = {
39 };
40 
41 FXDEFMAP(GNEPerson::GNESelectedPersonsPopupMenu) selectedPersonsPopupMenuMap[] = {
43 };
44 
45 // Object implementation
46 FXIMPLEMENT(GNEPerson::GNEPersonPopupMenu, GUIGLObjectPopupMenu, personPopupMenuMap, ARRAYNUMBER(personPopupMenuMap))
47 FXIMPLEMENT(GNEPerson::GNESelectedPersonsPopupMenu, GUIGLObjectPopupMenu, selectedPersonsPopupMenuMap, ARRAYNUMBER(selectedPersonsPopupMenuMap))
48 
49 // ===========================================================================
50 // GNEPerson::GNEPersonPopupMenu
51 // ===========================================================================
52 
54  GUIGLObjectPopupMenu(app, parent, *person),
55  myPerson(person),
56  myTransformToPerson(nullptr),
57  myTransformToPersonFlow(nullptr) {
58  // build header
59  myPerson->buildPopupHeader(this, app);
60  // build menu command for center button and copy cursor position to clipboard
61  myPerson->buildCenterPopupEntry(this);
62  myPerson->buildPositionCopyEntry(this, app);
63  // build menu commands for names
64  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myPerson->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
65  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myPerson->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  myPerson->getNet()->getViewNet()->buildSelectionACPopupEntry(this, myPerson);
69  myPerson->buildShowParamsPopupEntry(this);
70  // add transform functions only in demand mode
71  if (myPerson->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  myTransformToPerson = GUIDesigns::buildFXMenuCommand(transformOperation, "Person", GUIIconSubSys::getIcon(GUIIcon::PERSON), this, MID_GNE_PERSON_TRANSFORM);
78  myTransformToPersonFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "PersonFlow", GUIIconSubSys::getIcon(GUIIcon::PERSONFLOW), this, MID_GNE_PERSON_TRANSFORM);
79  // check what menu command has to be disabled
80  if (myPerson->getTagProperty().getTag() == SUMO_TAG_PERSON) {
81  myTransformToPerson->disable();
82  } else if (myPerson->getTagProperty().getTag() == SUMO_TAG_PERSONFLOW) {
83  myTransformToPersonFlow->disable();
84  }
85  }
86 }
87 
88 
90 
91 
92 long
93 GNEPerson::GNEPersonPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
94  if (obj == myTransformToPerson) {
96  } else if (obj == myTransformToPersonFlow) {
98  }
99  return 1;
100 }
101 
102 
103 // ===========================================================================
104 // GNEPerson::GNESelectedPersonsPopupMenu
105 // ===========================================================================
106 
107 GNEPerson::GNESelectedPersonsPopupMenu::GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent) :
108  GUIGLObjectPopupMenu(app, parent, *person),
109  myPersonTag(person->getTagProperty().getTag()),
110  mySelectedPersons(selectedPerson),
111  myTransformToPerson(nullptr),
112  myTransformToPersonFlow(nullptr) {
113  // build header
114  person->buildPopupHeader(this, app);
115  // build menu command for center button and copy cursor position to clipboard
116  person->buildCenterPopupEntry(this);
117  person->buildPositionCopyEntry(this, app);
118  // build menu commands for names
119  GUIDesigns::buildFXMenuCommand(this, ("Copy " + person->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
120  GUIDesigns::buildFXMenuCommand(this, ("Copy " + person->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  person->getNet()->getViewNet()->buildSelectionACPopupEntry(this, person);
124  person->buildShowParamsPopupEntry(this);
125  // add transform functions only in demand mode
126  if (person->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 persons
144  for (const auto& i : mySelectedPersons) {
145  if ((obj == myTransformToPerson) &&
146  (i->getTagProperty().getTag() == myPersonTag)) {
148  } else if ((obj == myTransformToPersonFlow) &&
149  (i->getTagProperty().getTag() == myPersonTag)) {
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  // enable set and persons per hour as default flow values
169 }
170 
171 
172 GNEPerson::GNEPerson(SumoXMLTag tag, GNENet* net, GNEDemandElement* pType, const SUMOVehicleParameter& personparameters) :
173  GNEDemandElement(personparameters.id, net, (tag == SUMO_TAG_PERSONFLOW) ? GLO_PERSONFLOW : GLO_PERSON, tag,
175  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {pType}, {}),
176 GNEDemandElementFlow(this, personparameters) {
177  // set manually vtypeID (needed for saving)
178  vtypeid = pType->getID();
179 }
180 
181 
183 
184 
187  // check first person plan
188  if (getChildDemandElements().front()->getTagProperty().isPlanStopPerson()) {
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
207  if (getTypeParent()->getID() == DEFAULT_PEDTYPE_ID) {
208  // unset VType parameter
210  // write person attributes (VType will not be written)
212  // set VType parameter again
214  } else {
215  // write person 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 person (Rides, Walks...)
223  for (const auto& i : getChildDemandElements()) {
224  i->writeDemandElement(device);
225  }
226  // close person 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 "Person 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 GNEPersonPopupMenu
287  return new GNEPersonPopupMenu(this, app, parent);
288 }
289 
290 
291 std::string
293  return getParentDemandElements().front()->getID();
294 }
295 
296 
297 double
299  return s.personSize.getExaggeration(s, this, 80);
300 }
301 
302 
303 Boundary
305  Boundary personBoundary;
306  if (getChildDemandElements().size() > 0) {
307  if (getChildDemandElements().front()->getTagProperty().isPlanStopPerson()) {
308  // use boundary of stop center
309  return getChildDemandElements().front()->getCenteringBoundary();
310  } else {
311  personBoundary.add(getPositionInView());
312  }
313  } else {
314  personBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
315  }
316  personBoundary.grow(20);
317  return personBoundary;
318 }
319 
320 
321 void
322 GNEPerson::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 drawPerson = true;
330  const auto personColor = setColor(s);
331  // check if person can be drawn
333  drawPerson = false;
335  drawPerson = false;
337  drawPerson = false;
338  } else if (getChildDemandElements().empty()) {
339  drawPerson = false;
340  }
341  // continue if person can be drawn
342  if (drawPerson) {
343  // obtain exaggeration (and add the special personExaggeration)
344  const double exaggeration = getExaggeration(s) + 10;
345  // obtain position
346  const Position personPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
347  if (personPosition == Position::INVALID) {
348  return;
349  }
350  // get detail level
351  const auto d = s.getDetailLevel(exaggeration);
352  // draw geometry only if we'rent in drawForObjectUnderCursor mode
353  if (!s.drawForViewObjectsHandler) {
354  // obtain width and length
355  const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
356  const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
357  // obtain img file
358  const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
359  // push draw matrix
361  // Start with the drawing of the area traslating matrix to origin
363  // translate and rotate
364  glTranslated(personPosition.x(), personPosition.y(), 0);
365  glRotated(90, 0, 0, 1);
366  // set person color
367  GLHelper::setColor(personColor);
368  // set scale
369  glScaled(exaggeration, exaggeration, 1);
370  // draw person depending of detail level
371  if (s.personQuality >= 2) {
372  GUIBasePersonHelper::drawAction_drawAsImage(0, length, width, file, SUMOVehicleShape::PEDESTRIAN, exaggeration);
373  } else if (s.personQuality == 1) {
374  GUIBasePersonHelper::drawAction_drawAsCenteredCircle(length / 2, width / 2, s.scale * exaggeration);
375  } else if (s.personQuality == 0) {
377  }
378  // pop matrix
380  // draw stack label
381  if (myStackedLabelNumber > 0) {
382  drawStackLabel(myStackedLabelNumber, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s));
383  } else if ((getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_STOPPERSON_BUSSTOP) ||
385  // declare counter for stacked persons over stops
386  int stackedCounter = 0;
387  // get stoppingPlace
388  const auto stoppingPlace = getChildDemandElements().front()->getParentAdditionals().front();
389  // get stacked persons
390  for (const auto& stopPerson : stoppingPlace->getChildDemandElements()) {
391  if ((stopPerson->getTagProperty().getTag() == GNE_TAG_STOPPERSON_BUSSTOP) ||
392  (stopPerson->getTagProperty().getTag() == GNE_TAG_STOPPERSON_TRAINSTOP)) {
393  // get person parent
394  const auto personParent = stopPerson->getParentDemandElements().front();
395  // check if the stop if the first person plan parent
396  if (stopPerson->getPreviousChildDemandElement(personParent) == nullptr) {
397  stackedCounter++;
398  }
399  }
400  }
401  // if we have more than two stacked elements, draw label
402  if (stackedCounter > 1) {
403  drawStackLabel(stackedCounter, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s));
404  }
405  }
406  // draw flow label
407  if (myTagProperty.isFlow()) {
408  drawFlowLabel(Position(personPosition.x() - 1, personPosition.y() - 0.25), -90, 1.8, 2, getExaggeration(s));
409  }
410  // draw lock icon
411  GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), personPosition, exaggeration, s.dottedContourSettings.segmentWidth);
412  // draw name
413  drawName(personPosition, s.scale, s.personName, s.angle);
414  if (s.personValue.show(this)) {
415  Position personValuePosition = personPosition + Position(0, 0.6 * s.personName.scaledSize(s.scale));
416  const double value = getColorValue(s, s.personColorer.getActive());
417  GLHelper::drawTextSettings(s.personValue, toString(value), personValuePosition, s.scale, s.angle, GLO_MAX - getType());
418  }
419  // draw dotted contour
421  }
422  // calculate contour
423  myPersonContour.calculateContourRectangleShape(s, d, this, personPosition, 0.5, 0.5, 0, 0, 0, exaggeration);
424  }
425 }
426 
427 
428 void
430  // compute all person plan children (because aren't computed in "computeDemandElements()")
431  for (const auto& demandElement : getChildDemandElements()) {
432  demandElement->computePathElement();
433  }
434 }
435 
436 
437 void
438 GNEPerson::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
439  // Stops don't use drawJunctionPartialGL
440 }
441 
442 
443 void
444 GNEPerson::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
445  // Stops don't use drawJunctionPartialGL
446 }
447 
448 
449 GNELane*
451  // use path lane of first person plan
452  return getChildDemandElements().front()->getFirstPathLane();
453 }
454 
455 
456 GNELane*
458  // use path lane of first person plan
459  return getChildDemandElements().front()->getLastPathLane();
460 }
461 
462 
463 std::string
465  // declare string error
466  std::string error;
467  switch (key) {
468  case SUMO_ATTR_ID:
469  return getMicrosimID();
470  case SUMO_ATTR_TYPE:
471  return getTypeParent()->getID();
472  case SUMO_ATTR_COLOR:
473  if (wasSet(VEHPARS_COLOR_SET)) {
474  return toString(color);
475  } else {
477  }
478  case SUMO_ATTR_DEPARTPOS:
480  return getDepartPos();
481  } else {
483  }
484  // Others
485  case GNE_ATTR_SELECTED:
487  case GNE_ATTR_PARAMETERS:
488  return getParametersStr();
489  default:
490  return getFlowAttribute(key);
491  }
492 }
493 
494 
495 double
497  switch (key) {
498  case SUMO_ATTR_DEPARTPOS:
500  return departPos;
501  } else {
502  return 0;
503  }
504  default:
505  return getFlowAttributeDouble(key);
506  }
507 }
508 
509 
510 Position
512  switch (key) {
513  case SUMO_ATTR_DEPARTPOS: {
514  // first check number of child demand elements
515  if (getChildDemandElements().empty()) {
516  return Position();
517  }
518  // get person plan
519  const GNEDemandElement* personPlan = getChildDemandElements().front();
520  // first check if first person plan is a stop
521  if (personPlan->getTagProperty().isPlanStopPerson()) {
522  // stop center
523  return personPlan->getPositionInView();
524  } else if (personPlan->getTagProperty().planFromTAZ()) {
525  // TAZ
526  return personPlan->getParentAdditionals().front()->getPositionInView();
527  } else if (personPlan->getTagProperty().planFromJunction()) {
528  // juncrtion
529  return personPlan->getParentJunctions().front()->getPositionInView();
530  } else {
532  }
533  }
534  default:
535  throw InvalidArgument(getTagStr() + " doesn't have a Position attribute of type '" + toString(key) + "'");
536  }
537 }
538 
539 
540 void
541 GNEPerson::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
542  switch (key) {
543  case SUMO_ATTR_ID:
544  case SUMO_ATTR_TYPE:
545  case SUMO_ATTR_COLOR:
546  case SUMO_ATTR_DEPARTPOS:
547  // Other
548  case GNE_ATTR_PARAMETERS:
549  case GNE_ATTR_SELECTED:
550  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
551  break;
552  default:
553  setFlowAttribute(this, key, value, undoList);
554  break;
555  }
556 }
557 
558 
559 bool
560 GNEPerson::isValid(SumoXMLAttr key, const std::string& value) {
561  // declare string error
562  std::string error;
563  switch (key) {
564  case SUMO_ATTR_ID:
566  case SUMO_ATTR_TYPE:
567  return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) == nullptr);
568  case SUMO_ATTR_COLOR:
569  return canParse<RGBColor>(value);
570  case SUMO_ATTR_DEPARTPOS: {
571  double dummyDepartPos;
572  DepartPosDefinition dummyDepartPosProcedure;
573  parseDepartPos(value, toString(SUMO_TAG_PERSON), id, dummyDepartPos, dummyDepartPosProcedure, error);
574  // if error is empty, given value is valid
575  return error.empty();
576  }
577  // Other
578  case GNE_ATTR_SELECTED:
579  return canParse<bool>(value);
580  case GNE_ATTR_PARAMETERS:
581  return Parameterised::areParametersValid(value);
582  default:
583  return isValidFlowAttribute(this, key, value);
584  }
585 }
586 
587 
588 void
590  enableFlowAttribute(this, key, undoList);
591 }
592 
593 
594 void
596  disableFlowAttribute(this, key, undoList);
597 }
598 
599 
600 bool
602  return isFlowAttributeEnabled(key);
603 }
604 
605 
606 std::string
608  return getTagStr();
609 }
610 
611 
612 std::string
614  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
615 }
616 
617 
618 const Parameterised::Map&
620  return getParametersMap();
621 }
622 
623 // ===========================================================================
624 // protected
625 // ===========================================================================
626 
627 RGBColor
629  const GUIColorer& c = s.personColorer;
630  /*
631  if (!setFunctionalColor(c.getActive())) {
632  return c.getScheme().getColor(getColorValue(s, c.getActive()));
633  }
634  */
635  return c.getScheme().getColor(getColorValue(s, c.getActive()));
636 }
637 
638 
639 bool
640 GNEPerson::setFunctionalColor(int /* activeScheme */) const {
641  /*
642  switch (activeScheme) {
643  case 0: {
644  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
645  GLHelper::setColor(getParameter().color);
646  return true;
647  }
648  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
649  GLHelper::setColor(getVehicleType().getColor());
650  return true;
651  }
652  return false;
653  }
654  case 2: {
655  if (getParameter().wasSet(VEHPARS_COLOR_SET)) {
656  GLHelper::setColor(getParameter().color);
657  return true;
658  }
659  return false;
660  }
661  case 3: {
662  if (getVehicleType().wasSet(VTYPEPARS_COLOR_SET)) {
663  GLHelper::setColor(getVehicleType().getColor());
664  return true;
665  }
666  return false;
667  }
668  case 8: { // color by angle
669  double hue = GeomHelper::naviDegree(getAngle());
670  GLHelper::setColor(RGBColor::fromHSV(hue, 1., 1.));
671  return true;
672  }
673  case 9: { // color randomly (by pointer)
674  const double hue = (long)this % 360; // [0-360]
675  const double sat = (((long)this / 360) % 67) / 100.0 + 0.33; // [0.33-1]
676  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
677  return true;
678  }
679  default:
680  return false;
681  }
682  */
683  return false;
684 }
685 
686 // ===========================================================================
687 // private
688 // ===========================================================================
689 
691  personPlan(_personPlan),
692  edge(nullptr),
693  arrivalPos(-1) {
694 }
695 
696 
698  personPlan(nullptr),
699  edge(nullptr),
700  arrivalPos(-1) {
701 }
702 
703 
704 void
705 GNEPerson::setAttribute(SumoXMLAttr key, const std::string& value) {
706  // declare string error
707  std::string error;
708  switch (key) {
709  case SUMO_ATTR_ID:
710  // update microsimID
711  setDemandElementID(value);
712  // update id
713  id = value;
714  break;
715  case SUMO_ATTR_TYPE:
716  if (getID().size() > 0) {
718  // set manually vtypeID (needed for saving)
719  vtypeid = value;
720  }
721  break;
722  case SUMO_ATTR_COLOR:
723  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
724  color = parse<RGBColor>(value);
725  // mark parameter as set
727  } else {
728  // set default value
729  color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
730  // unset parameter
732  }
733  break;
734  case SUMO_ATTR_DEPARTPOS:
735  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
737  // mark parameter as set
739  } else {
740  // set default value
742  // unset parameter
744  }
745  // compute person
746  updateGeometry();
747  break;
748  // Other
749  case GNE_ATTR_SELECTED:
750  if (parse<bool>(value)) {
752  } else {
754  }
755  break;
756  case GNE_ATTR_PARAMETERS:
757  setParametersStr(value);
758  break;
759  default:
760  setFlowAttribute(this, key, value);
761  break;
762  }
763 }
764 
765 
766 void
767 GNEPerson::toggleAttribute(SumoXMLAttr key, const bool value) {
768  // toggle flow attributes
769  toggleFlowAttribute(key, value);
770 }
771 
772 
773 void GNEPerson::setMoveShape(const GNEMoveResult& moveResult) {
774  // change departPos
776  departPos = moveResult.newFirstPos;
777  // update geometry
778  updateGeometry();
779 }
780 
781 
782 void
783 GNEPerson::commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList) {
784  undoList->begin(this, "departPos of " + getTagStr());
785  // now set departPos
786  setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
787  undoList->end();
788 }
789 
790 /****************************************************************************/
FXDEFMAP(GNEPerson::GNEPersonPopupMenu) personPopupMenuMap[]
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:453
@ MID_GNE_PERSON_TRANSFORM
transform person to another person type (ej: person to personflow)
Definition: GUIAppEnum.h:1380
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:451
@ GLO_MAX
empty max
@ GLO_PERSON
a person
@ GLO_PERSONFLOW
a person flow
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
const std::string DEFAULT_PEDTYPE_ID
@ PEDESTRIAN
render as a pedestrian
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
@ GNE_TAG_STOPPERSON_BUSSTOP
@ SUMO_TAG_PERSON
@ GNE_TAG_STOPPERSON_TRAINSTOP
@ SUMO_TAG_PERSONFLOW
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_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
@ SUMO_ATTR_PERSONSPERHOUR
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 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
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
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
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
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2055
PathElement()=delete
invalidate default constructor
class used in GUIGLObjectPopupMenu for person transformations
Definition: GNEPerson.h:36
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current person to another person type.
Definition: GNEPerson.cpp:93
~GNEPersonPopupMenu()
Destructor.
Definition: GNEPerson.cpp:89
class used in GUIGLObjectPopupMenu for single person transformations
Definition: GNEPerson.h:68
GNESelectedPersonsPopupMenu(GNEPerson *person, const std::vector< GNEPerson * > &selectedPerson, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEPerson.cpp:107
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current person to another person type.
Definition: GNEPerson.cpp:142
FXMenuCommand * myTransformToPerson
menu command for transform to person
Definition: GNEPerson.h:97
FXMenuCommand * myTransformToPersonFlow
menu command for transform to personFlow
Definition: GNEPerson.h:100
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEPerson.cpp:328
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Definition: GNEPerson.cpp:783
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEPerson.cpp:186
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEPerson.cpp:279
void updateGeometry()
update pre-computed geometry information
Definition: GNEPerson.cpp:270
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNEPerson.cpp:298
const RGBColor & getColor() const
get color
Definition: GNEPerson.cpp:264
bool isAttributeEnabled(SumoXMLAttr key) const
Definition: GNEPerson.cpp:601
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNEPerson.cpp:205
GNELane * getLastPathLane() const
get last path lane
Definition: GNEPerson.cpp:457
Position getAttributePosition(SumoXMLAttr key) const
Definition: GNEPerson.cpp:511
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEPerson.cpp:252
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
Definition: GNEPerson.cpp:767
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
Definition: GNEPerson.cpp:773
bool setFunctionalColor(int activeScheme) const
sets the color according to the current scheme index and some vehicle function
Definition: GNEPerson.cpp:640
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
Definition: GNEPerson.cpp:628
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
Definition: GNEPerson.cpp:613
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEPerson.cpp:589
~GNEPerson()
destructor
Definition: GNEPerson.cpp:182
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEPerson.cpp:258
void computePathElement()
compute pathElement
Definition: GNEPerson.cpp:429
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEPerson.cpp:292
GNEContour myPersonContour
variable used for contours
Definition: GNEPerson.h:278
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
Definition: GNEPerson.cpp:560
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEPerson.cpp:322
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
Definition: GNEPerson.cpp:595
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
Definition: GNEPerson.cpp:541
GNEPerson(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEPerson.cpp:160
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
Definition: GNEPerson.cpp:464
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
Definition: GNEPerson.cpp:438
const Parameterised::Map & getACParametersMap() const
get parameters map
Definition: GNEPerson.cpp:619
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEPerson.cpp:304
double getAttributeDouble(SumoXMLAttr key) const
Definition: GNEPerson.cpp:496
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition: GNEPerson.cpp:232
GNELane * getFirstPathLane() const
get first path lane
Definition: GNEPerson.cpp:450
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEPerson.cpp:285
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEPerson.cpp:242
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
Definition: GNEPerson.cpp:444
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
Definition: GNEPerson.cpp:607
static void transformToPerson(GNEPerson *originalPerson)
transform person functions
static void transformToPersonFlow(GNEPerson *originalPerson)
transform routeFlow over an existent route
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
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
bool isPlanStopPerson() const
return true if tag correspond to a person stop plan
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
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:538
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:721
static void drawAction_drawAsImage(const double angle, const double length, const double width, const std::string &file, const SUMOVehicleShape guiShape, const double exaggeration)
static void drawAction_drawAsCenteredCircle(const double length, const double width, double detail)
static void drawAction_drawAsTriangle(const double angle, const double length, const double width)
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
T getColor(const double value) const
Stores the information about how to visualize structures.
GUIVisualizationTextSettings personValue
int personQuality
The quality of person drawing.
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationSizeSettings personSize
GUIColorer personColorer
The person colorer.
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 personName
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
Definition: NamespaceIDs.h:53
static const std::vector< SumoXMLTag > persons
persons namespace
Definition: NamespaceIDs.h:62
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
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
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.
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