Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/demand/GNEPerson.cpp
185790 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GNEPerson.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date May 2019
17
///
18
// Representation of persons in netedit
19
/****************************************************************************/
20
21
#include <microsim/devices/MSDevice_BTreceiver.h>
22
#include <netedit/changes/GNEChange_Attribute.h>
23
#include <netedit/elements/moving/GNEMoveElementPlanParent.h>
24
#include <netedit/GNENet.h>
25
#include <netedit/GNETagProperties.h>
26
#include <utils/gui/div/GLHelper.h>
27
#include <utils/gui/div/GUIBasePersonHelper.h>
28
#include <utils/gui/div/GUIDesigns.h>
29
#include <utils/gui/windows/GUIAppEnum.h>
30
#include <utils/xml/NamespaceIDs.h>
31
32
#include "GNEPerson.h"
33
#include "GNERouteHandler.h"
34
35
// ===========================================================================
36
// FOX callback mapping
37
// ===========================================================================
38
39
FXDEFMAP(GNEPerson::GNEPersonPopupMenu) personPopupMenuMap[] = {
40
FXMAPFUNC(SEL_COMMAND, MID_GNE_PERSON_TRANSFORM, GNEPerson::GNEPersonPopupMenu::onCmdTransform),
41
};
42
43
FXDEFMAP(GNEPerson::GNESelectedPersonsPopupMenu) selectedPersonsPopupMenuMap[] = {
44
FXMAPFUNC(SEL_COMMAND, MID_GNE_PERSON_TRANSFORM, GNEPerson::GNESelectedPersonsPopupMenu::onCmdTransform),
45
};
46
47
// Object implementation
48
FXIMPLEMENT(GNEPerson::GNEPersonPopupMenu, GUIGLObjectPopupMenu, personPopupMenuMap, ARRAYNUMBER(personPopupMenuMap))
49
FXIMPLEMENT(GNEPerson::GNESelectedPersonsPopupMenu, GUIGLObjectPopupMenu, selectedPersonsPopupMenuMap, ARRAYNUMBER(selectedPersonsPopupMenuMap))
50
51
// ===========================================================================
52
// GNEPerson::GNEPersonPopupMenu
53
// ===========================================================================
54
55
GNEPerson::GNEPersonPopupMenu::GNEPersonPopupMenu(GNEPerson* person, GUIMainWindow& app, GUISUMOAbstractView& parent) :
56
GUIGLObjectPopupMenu(app, parent, person),
57
myPerson(person),
58
myTransformToPerson(nullptr),
59
myTransformToPersonFlow(nullptr) {
60
// build common options
61
person->buildPopUpMenuCommonOptions(this, app, person->myNet->getViewNet(), person->getTagProperty()->getTag(), person->isAttributeCarrierSelected());
62
// add transform functions only in demand mode
63
if (myPerson->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
64
// create menu pane for transform operations
65
FXMenuPane* transformOperation = new FXMenuPane(this);
66
this->insertMenuPaneChild(transformOperation);
67
new FXMenuCascade(this, "transform to", nullptr, transformOperation);
68
// Create menu comands for all transformations
69
myTransformToPerson = GUIDesigns::buildFXMenuCommand(transformOperation, "Person", GUIIconSubSys::getIcon(GUIIcon::PERSON), this, MID_GNE_PERSON_TRANSFORM);
70
myTransformToPersonFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "PersonFlow", GUIIconSubSys::getIcon(GUIIcon::PERSONFLOW), this, MID_GNE_PERSON_TRANSFORM);
71
// check what menu command has to be disabled
72
if (myPerson->getTagProperty()->getTag() == SUMO_TAG_PERSON) {
73
myTransformToPerson->disable();
74
} else if (myPerson->getTagProperty()->getTag() == SUMO_TAG_PERSONFLOW) {
75
myTransformToPersonFlow->disable();
76
}
77
}
78
}
79
80
81
GNEPerson::GNEPersonPopupMenu::~GNEPersonPopupMenu() {}
82
83
84
long
85
GNEPerson::GNEPersonPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
86
if (obj == myTransformToPerson) {
87
GNERouteHandler::transformToPerson(myPerson);
88
} else if (obj == myTransformToPersonFlow) {
89
GNERouteHandler::transformToPersonFlow(myPerson);
90
}
91
return 1;
92
}
93
94
95
// ===========================================================================
96
// GNEPerson::GNESelectedPersonsPopupMenu
97
// ===========================================================================
98
99
GNEPerson::GNESelectedPersonsPopupMenu::GNESelectedPersonsPopupMenu(GNEPerson* person, const std::vector<GNEPerson*>& selectedPerson, GUIMainWindow& app, GUISUMOAbstractView& parent) :
100
GUIGLObjectPopupMenu(app, parent, person),
101
myPersonTag(person->getTagProperty()->getTag()),
102
mySelectedPersons(selectedPerson),
103
myTransformToPerson(nullptr),
104
myTransformToPersonFlow(nullptr) {
105
// build common options
106
person->buildPopUpMenuCommonOptions(this, app, person->myNet->getViewNet(), person->myTagProperty->getTag(), person->isAttributeCarrierSelected());
107
// add transform functions only in demand mode
108
if (person->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
109
// create menu pane for transform operations
110
FXMenuPane* transformOperation = new FXMenuPane(this);
111
this->insertMenuPaneChild(transformOperation);
112
new FXMenuCascade(this, "transform to", nullptr, transformOperation);
113
// Create menu comands for all transformations
114
myTransformToPerson = GUIDesigns::buildFXMenuCommand(transformOperation, "Person", GUIIconSubSys::getIcon(GUIIcon::PERSON), this, MID_GNE_PERSON_TRANSFORM);
115
myTransformToPersonFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "PersonFlow", GUIIconSubSys::getIcon(GUIIcon::PERSONFLOW), this, MID_GNE_PERSON_TRANSFORM);
116
}
117
}
118
119
120
GNEPerson::GNESelectedPersonsPopupMenu::~GNESelectedPersonsPopupMenu() {}
121
122
123
long
124
GNEPerson::GNESelectedPersonsPopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
125
// iterate over all selected persons
126
for (const auto& i : mySelectedPersons) {
127
if ((obj == myTransformToPerson) &&
128
(i->getTagProperty()->getTag() == myPersonTag)) {
129
GNERouteHandler::transformToPerson(i);
130
} else if ((obj == myTransformToPersonFlow) &&
131
(i->getTagProperty()->getTag() == myPersonTag)) {
132
GNERouteHandler::transformToPerson(i);
133
}
134
}
135
return 1;
136
}
137
138
// ===========================================================================
139
// member method definitions
140
// ===========================================================================
141
#ifdef _MSC_VER
142
#pragma warning(push)
143
#pragma warning(disable: 4355) // mask warning about "this" in initializers
144
#endif
145
GNEPerson::GNEPerson(SumoXMLTag tag, GNENet* net) :
146
GNEDemandElement(net, tag),
147
GNEDemandElementFlow(this),
148
myMoveElementPlanParent(new GNEMoveElementPlanParent(this, departPos, departPosProcedure)) {
149
// enable set and persons per hour as default flow values
150
toggleAttribute(SUMO_ATTR_END, true);
151
toggleAttribute(SUMO_ATTR_PERSONSPERHOUR, true);
152
}
153
154
155
GNEPerson::GNEPerson(SumoXMLTag tag, GNENet* net, FileBucket* fileBucket, GNEDemandElement* pType,
156
const SUMOVehicleParameter& personparameters) :
157
GNEDemandElement(personparameters.id, net, tag, fileBucket),
158
GNEDemandElementFlow(this, personparameters),
159
myMoveElementPlanParent(new GNEMoveElementPlanParent(this, departPos, departPosProcedure)) {
160
// set parents
161
setParent<GNEDemandElement*>(pType);
162
// set manually vtypeID (needed for saving)
163
vtypeid = pType->getID();
164
}
165
#ifdef _MSC_VER
166
#pragma warning(pop)
167
#endif
168
169
GNEPerson::~GNEPerson() {}
170
171
172
GNEMoveElement*
173
GNEPerson::getMoveElement() const {
174
return myMoveElementPlanParent;
175
}
176
177
178
Parameterised*
179
GNEPerson::getParameters() {
180
return this;
181
}
182
183
184
const Parameterised*
185
GNEPerson::getParameters() const {
186
return this;
187
}
188
189
190
void
191
GNEPerson::writeDemandElement(OutputDevice& device) const {
192
// attribute VType musn't be written if is DEFAULT_PEDTYPE_ID
193
if (getTypeParent()->getID() == DEFAULT_PEDTYPE_ID) {
194
// unset VType parameter
195
parametersSet &= ~VEHPARS_VTYPE_SET;
196
// write person attributes (VType will not be written)
197
write(device, OptionsCont::getOptions(), myTagProperty->getXMLTag());
198
// set VType parameter again
199
parametersSet |= VEHPARS_VTYPE_SET;
200
} else {
201
// write person attributes, including VType
202
write(device, OptionsCont::getOptions(), myTagProperty->getXMLTag(), getTypeParent()->getID());
203
}
204
// write parameters
205
writeParams(device);
206
// write child demand elements associated to this person (Rides, Walks...)
207
for (const auto& i : getChildDemandElements()) {
208
i->writeDemandElement(device);
209
}
210
// close person tag
211
device.closeTag();
212
}
213
214
215
GNEDemandElement::Problem
216
GNEPerson::isDemandElementValid() const {
217
if (getChildDemandElements().size() == 0) {
218
return Problem::NO_PLANS;
219
} else {
220
return Problem::OK;
221
}
222
}
223
224
225
std::string
226
GNEPerson::getDemandElementProblem() const {
227
if (getChildDemandElements().size() == 0) {
228
return "Person needs at least one plan";
229
} else {
230
return "";
231
}
232
}
233
234
235
void
236
GNEPerson::fixDemandElementProblem() {
237
// nothing to fix
238
}
239
240
241
SUMOVehicleClass
242
GNEPerson::getVClass() const {
243
return getParentDemandElements().front()->getVClass();
244
}
245
246
247
const RGBColor&
248
GNEPerson::getColor() const {
249
return color;
250
}
251
252
253
void
254
GNEPerson::updateGeometry() {
255
// only update geometry of childrens
256
for (const auto& demandElement : getChildDemandElements()) {
257
demandElement->updateGeometry();
258
}
259
}
260
261
262
Position
263
GNEPerson::getPositionInView() const {
264
return getAttributePosition(SUMO_ATTR_DEPARTPOS);
265
}
266
267
268
GUIGLObjectPopupMenu*
269
GNEPerson::getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent) {
270
// return a GNEPersonPopupMenu
271
return new GNEPersonPopupMenu(this, app, parent);
272
}
273
274
275
std::string
276
GNEPerson::getParentName() const {
277
return getParentDemandElements().front()->getID();
278
}
279
280
281
double
282
GNEPerson::getExaggeration(const GUIVisualizationSettings& s) const {
283
return s.personSize.getExaggeration(s, this, 80);
284
}
285
286
287
Boundary
288
GNEPerson::getCenteringBoundary() const {
289
Boundary personBoundary;
290
if (getChildDemandElements().size() > 0) {
291
if (getChildDemandElements().front()->getTagProperty()->isPlanStopPerson()) {
292
// use boundary of stop center
293
return getChildDemandElements().front()->getCenteringBoundary();
294
} else {
295
personBoundary.add(getPositionInView());
296
}
297
} else {
298
personBoundary = Boundary(-0.1, -0.1, 0.1, 0.1);
299
}
300
personBoundary.grow(20);
301
return personBoundary;
302
}
303
304
305
void
306
GNEPerson::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
307
// geometry of this element cannot be splitted
308
}
309
310
311
void
312
GNEPerson::drawGL(const GUIVisualizationSettings& s) const {
313
bool drawPerson = true;
314
// check if person can be drawn
315
if (!myNet->getViewNet()->getNetworkViewOptions().showDemandElements()) {
316
drawPerson = false;
317
} else if (!myNet->getViewNet()->getDataViewOptions().showDemandElements()) {
318
drawPerson = false;
319
} else if (!myNet->getViewNet()->getDemandViewOptions().showNonInspectedDemandElements(this)) {
320
drawPerson = false;
321
} else if (getChildDemandElements().empty()) {
322
drawPerson = false;
323
}
324
// continue if person can be drawn
325
if (drawPerson) {
326
// obtain exaggeration (and add the special personExaggeration)
327
const double exaggeration = getExaggeration(s) + 10;
328
// obtain position
329
const Position personPosition = getAttributePosition(SUMO_ATTR_DEPARTPOS);
330
if (personPosition == Position::INVALID) {
331
return;
332
}
333
// get detail level
334
const auto d = s.getDetailLevel(exaggeration);
335
// draw geometry only if we'rent in drawForObjectUnderCursor mode
336
if (s.checkDrawPerson(d, isAttributeCarrierSelected())) {
337
// obtain width and length
338
const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
339
const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
340
// obtain img file
341
const std::string file = getTypeParent()->getAttribute(SUMO_ATTR_IMGFILE);
342
// push draw matrix
343
GLHelper::pushMatrix();
344
// Start with the drawing of the area traslating matrix to origin
345
drawInLayer(getType());
346
// translate and rotate
347
glTranslated(personPosition.x(), personPosition.y(), 0);
348
glRotated(90, 0, 0, 1);
349
// set person color
350
GLHelper::setColor(getDrawingColor(s));
351
// set scale
352
glScaled(exaggeration, exaggeration, 1);
353
// draw person depending of detail level
354
if (s.personQuality >= 2) {
355
GUIBasePersonHelper::drawAction_drawAsImage(0, length, width, file, SUMOVehicleShape::PEDESTRIAN, exaggeration);
356
} else if (s.personQuality == 1) {
357
GUIBasePersonHelper::drawAction_drawAsCenteredCircle(length / 2, width / 2, s.scale * exaggeration);
358
} else if (s.personQuality == 0) {
359
GUIBasePersonHelper::drawAction_drawAsTriangle(0, length, width);
360
}
361
// pop matrix
362
GLHelper::popMatrix();
363
// draw stack label
364
if (myStackedLabelNumber > 0) {
365
drawStackLabel(myStackedLabelNumber, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s));
366
} else if ((getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_BUSSTOP) ||
367
(getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_TRAINSTOP)) {
368
// declare counter for stacked persons over stops
369
int stackedCounter = 0;
370
// get stoppingPlace
371
const auto stoppingPlace = getChildDemandElements().front()->getParentAdditionals().front();
372
// get stacked persons
373
for (const auto& stopPerson : stoppingPlace->getChildDemandElements()) {
374
if ((stopPerson->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_BUSSTOP) ||
375
(stopPerson->getTagProperty()->getTag() == GNE_TAG_STOPPERSON_TRAINSTOP)) {
376
// get person parent
377
const auto personParent = stopPerson->getParentDemandElements().front();
378
// check if the stop if the first person plan parent
379
if (stopPerson->getPreviousChildDemandElement(personParent) == nullptr) {
380
stackedCounter++;
381
}
382
}
383
}
384
// if we have more than two stacked elements, draw label
385
if (stackedCounter > 1) {
386
drawStackLabel(stackedCounter, "person", Position(personPosition.x() - 2.5, personPosition.y()), -90, 1.3, 5, getExaggeration(s));
387
}
388
}
389
// draw flow label
390
if (myTagProperty->isFlow()) {
391
drawFlowLabel(Position(personPosition.x() - 1, personPosition.y() - 0.25), -90, 1.8, 2, getExaggeration(s));
392
}
393
// draw lock icon
394
GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), personPosition, exaggeration, s.dottedContourSettings.segmentWidth);
395
// draw name
396
drawName(personPosition, s.scale, s.personName, s.angle);
397
if (s.personValue.show(this)) {
398
Position personValuePosition = personPosition + Position(0, 0.6 * s.personName.scaledSize(s.scale));
399
const double value = getColorValue(s, s.personColorer.getActive());
400
GLHelper::drawTextSettings(s.personValue, toString(value), personValuePosition, s.scale, s.angle, GLO_MAX - getType());
401
}
402
// draw dotted contour
403
myPersonContour.drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
404
}
405
// calculate contour
406
myPersonContour.calculateContourRectangleShape(s, d, this, personPosition, 0.1, 0.2, getType(), -1.1, 0, 0, exaggeration, nullptr);
407
}
408
}
409
410
411
void
412
GNEPerson::computePathElement() {
413
// compute all person plan children (because aren't computed in "computeDemandElements()")
414
for (const auto& demandElement : getChildDemandElements()) {
415
demandElement->computePathElement();
416
}
417
}
418
419
420
void
421
GNEPerson::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
422
// Stops don't use drawJunctionPartialGL
423
}
424
425
426
void
427
GNEPerson::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNESegment* /*segment*/, const double /*offsetFront*/) const {
428
// Stops don't use drawJunctionPartialGL
429
}
430
431
432
GNELane*
433
GNEPerson::getFirstPathLane() const {
434
// use path lane of first person plan
435
return getChildDemandElements().front()->getFirstPathLane();
436
}
437
438
439
GNELane*
440
GNEPerson::getLastPathLane() const {
441
// use path lane of first person plan
442
return getChildDemandElements().front()->getLastPathLane();
443
}
444
445
446
std::string
447
GNEPerson::getAttribute(SumoXMLAttr key) const {
448
// declare string error
449
std::string error;
450
switch (key) {
451
case SUMO_ATTR_ID:
452
return getMicrosimID();
453
case SUMO_ATTR_TYPE:
454
return getTypeParent()->getID();
455
case SUMO_ATTR_COLOR:
456
if (wasSet(VEHPARS_COLOR_SET)) {
457
return toString(color);
458
} else {
459
return myTagProperty->getDefaultStringValue(SUMO_ATTR_COLOR);
460
}
461
case SUMO_ATTR_DEPARTPOS:
462
if (wasSet(VEHPARS_DEPARTPOS_SET)) {
463
return getDepartPos();
464
} else {
465
return myTagProperty->getDefaultStringValue(SUMO_ATTR_DEPARTPOS);
466
}
467
default:
468
return getFlowAttribute(this, key);
469
}
470
}
471
472
473
double
474
GNEPerson::getAttributeDouble(SumoXMLAttr key) const {
475
switch (key) {
476
case SUMO_ATTR_DEPARTPOS:
477
if (departPosProcedure == DepartPosDefinition::GIVEN) {
478
return departPos;
479
} else {
480
return 0;
481
}
482
default:
483
return getFlowAttributeDouble(key);
484
}
485
}
486
487
488
Position
489
GNEPerson::getAttributePosition(SumoXMLAttr key) const {
490
switch (key) {
491
case SUMO_ATTR_DEPARTPOS: {
492
// first check number of child demand elements
493
if (getChildDemandElements().empty()) {
494
return Position();
495
}
496
// get person plan
497
const GNEDemandElement* personPlan = getChildDemandElements().front();
498
// first check if first person plan is a stop
499
if (personPlan->getTagProperty()->isPlanStopPerson()) {
500
// stop center
501
return personPlan->getPositionInView();
502
} else if (personPlan->getTagProperty()->planFromTAZ()) {
503
// TAZ
504
if (personPlan->getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty()) {
505
return personPlan->getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID);
506
} else {
507
return personPlan->getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
508
}
509
} else if (personPlan->getTagProperty()->planFromJunction()) {
510
// juncrtion
511
return personPlan->getParentJunctions().front()->getPositionInView();
512
} else {
513
return personPlan->getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_STARTPOS);
514
}
515
}
516
default:
517
return getCommonAttributePosition(key);
518
}
519
}
520
521
522
void
523
GNEPerson::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
524
switch (key) {
525
case SUMO_ATTR_ID:
526
case SUMO_ATTR_TYPE:
527
case SUMO_ATTR_COLOR:
528
case SUMO_ATTR_DEPARTPOS:
529
GNEChange_Attribute::changeAttribute(this, key, value, undoList);
530
break;
531
default:
532
setFlowAttribute(this, key, value, undoList);
533
break;
534
}
535
}
536
537
538
bool
539
GNEPerson::isValid(SumoXMLAttr key, const std::string& value) {
540
// declare string error
541
std::string error;
542
switch (key) {
543
case SUMO_ATTR_ID:
544
return isValidDemandElementID(NamespaceIDs::persons, value);
545
case SUMO_ATTR_TYPE:
546
return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
547
case SUMO_ATTR_COLOR:
548
return canParse<RGBColor>(value);
549
case SUMO_ATTR_DEPARTPOS: {
550
double dummyDepartPos;
551
DepartPosDefinition dummyDepartPosProcedure;
552
parseDepartPos(value, toString(SUMO_TAG_PERSON), id, dummyDepartPos, dummyDepartPosProcedure, error);
553
// if error is empty, given value is valid
554
return error.empty();
555
}
556
default:
557
return isValidFlowAttribute(this, key, value);
558
}
559
}
560
561
562
void
563
GNEPerson::enableAttribute(SumoXMLAttr key, GNEUndoList* undoList) {
564
enableFlowAttribute(this, key, undoList);
565
}
566
567
568
void
569
GNEPerson::disableAttribute(SumoXMLAttr key, GNEUndoList* undoList) {
570
disableFlowAttribute(this, key, undoList);
571
}
572
573
574
bool
575
GNEPerson::isAttributeEnabled(SumoXMLAttr key) const {
576
return isFlowAttributeEnabled(key);
577
}
578
579
580
std::string
581
GNEPerson::getPopUpID() const {
582
return getTagStr();
583
}
584
585
586
std::string
587
GNEPerson::getHierarchyName() const {
588
return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
589
}
590
591
// ===========================================================================
592
// protected
593
// ===========================================================================
594
595
RGBColor
596
GNEPerson::getDrawingColor(const GUIVisualizationSettings& s) const {
597
if (isAttributeCarrierSelected()) {
598
return s.colorSettings.selectedPersonColor;
599
} else {
600
return getColorByScheme(s.personColorer, this);
601
}
602
}
603
604
// ===========================================================================
605
// private
606
// ===========================================================================
607
608
GNEPerson::personPlanSegment::personPlanSegment(GNEDemandElement* _personPlan) :
609
personPlan(_personPlan),
610
edge(nullptr),
611
arrivalPos(-1) {
612
}
613
614
615
GNEPerson::personPlanSegment::personPlanSegment() :
616
personPlan(nullptr),
617
edge(nullptr),
618
arrivalPos(-1) {
619
}
620
621
622
void
623
GNEPerson::setAttribute(SumoXMLAttr key, const std::string& value) {
624
// declare string error
625
std::string error;
626
switch (key) {
627
case SUMO_ATTR_ID:
628
// update microsimID
629
setDemandElementID(value);
630
// update id
631
id = value;
632
break;
633
case SUMO_ATTR_TYPE:
634
if (getID().size() > 0) {
635
replaceDemandElementParent(NamespaceIDs::types, value, 0);
636
// set manually vtypeID (needed for saving)
637
vtypeid = value;
638
}
639
break;
640
case SUMO_ATTR_COLOR:
641
if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
642
color = parse<RGBColor>(value);
643
// mark parameter as set
644
parametersSet |= VEHPARS_COLOR_SET;
645
} else {
646
// set default value
647
color = parse<RGBColor>(myTagProperty->getDefaultStringValue(key));
648
// unset parameter
649
parametersSet &= ~VEHPARS_COLOR_SET;
650
}
651
break;
652
case SUMO_ATTR_DEPARTPOS:
653
if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
654
parseDepartPos(value, toString(SUMO_TAG_PERSON), id, departPos, departPosProcedure, error);
655
// mark parameter as set
656
parametersSet |= VEHPARS_DEPARTPOS_SET;
657
} else {
658
// set default value
659
parseDepartPos(myTagProperty->getDefaultStringValue(key), toString(SUMO_TAG_PERSON), id, departPos, departPosProcedure, error);
660
// unset parameter
661
parametersSet &= ~VEHPARS_DEPARTPOS_SET;
662
}
663
// compute person
664
updateGeometry();
665
break;
666
default:
667
setFlowAttribute(this, key, value);
668
break;
669
}
670
}
671
672
673
void
674
GNEPerson::toggleAttribute(SumoXMLAttr key, const bool value) {
675
// toggle flow attributes
676
toggleFlowAttribute(key, value);
677
}
678
679
/****************************************************************************/
680
681