Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVehicle.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-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/****************************************************************************/
18// Representation of vehicles in netedit
19/****************************************************************************/
20
26#include <netedit/GNENet.h>
27#include <netedit/GNESegment.h>
29#include <netedit/GNEUndoList.h>
36
37#include "GNEVehicle.h"
38#include "GNERoute.h"
39#include "GNERouteHandler.h"
40
41// ===========================================================================
42// FOX callback mapping
43// ===========================================================================
44
48
52
53// Object implementation
54FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
55FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
56
57// ===========================================================================
58// GNEVehicle::GNESingleVehiclePopupMenu
59// ===========================================================================
60
62 GUIGLObjectPopupMenu(app, parent, vehicle),
63 myVehicle(vehicle) {
64 // build common options
65 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
66 // route length
67 vehicle->buildMenuCommandRouteLength(this);
68 // add transform functions only in demand mode
69 if (myVehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
70 // add reverse
71 vehicle->buildMenuAddReverse(this);
72 // continue depending of type
73 if (myVehicle->getTagProperty()->vehicleJunctions()) {
74 // create menu pane for transform operations
75 FXMenuPane* transformOperation = new FXMenuPane(this);
76 this->insertMenuPaneChild(transformOperation);
77 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
78 // Create menu commands for all transform
79 GUIDesigns::buildFXMenuCommand(transformOperation,
80 TL("Trip (over junctions)"),
82 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_JUNCTIONS));
83 GUIDesigns::buildFXMenuCommand(transformOperation,
84 TL("Flow (over junctions)"),
86 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_JUNCTIONS));
87 } else if (myVehicle->getTagProperty()->vehicleTAZs()) {
88 // create menu pane for transform operations
89 FXMenuPane* transformOperation = new FXMenuPane(this);
90 this->insertMenuPaneChild(transformOperation);
91 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
92 // Create menu commands for all transform
93 GUIDesigns::buildFXMenuCommand(transformOperation,
94 TL("Trip (over TAZs)"),
96 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_TAZS));
97 GUIDesigns::buildFXMenuCommand(transformOperation,
98 TL("Flow (over TAZs)"),
100 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_TAZS));
101 } else {
102 // create menu pane for transform operations
103 FXMenuPane* transformOperation = new FXMenuPane(this);
104 this->insertMenuPaneChild(transformOperation);
105 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
106 // Create menu commands for all transform
107 GUIDesigns::buildFXMenuCommand(transformOperation,
108 TL("Vehicle"),
110 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_VEHICLE));
111 GUIDesigns::buildFXMenuCommand(transformOperation,
112 TL("Vehicle (embedded route)"),
114 (myVehicle->getTagProperty()->getTag() == GNE_TAG_VEHICLE_WITHROUTE));
115 GUIDesigns::buildFXMenuCommand(transformOperation,
116 TL("RouteFlow"),
118 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_ROUTE));
119 GUIDesigns::buildFXMenuCommand(transformOperation,
120 TL("RouteFlow (embedded route)"),
122 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_WITHROUTE));
123 GUIDesigns::buildFXMenuCommand(transformOperation,
124 TL("Trip"),
126 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_TRIP));
127 GUIDesigns::buildFXMenuCommand(transformOperation,
128 TL("Flow"),
130 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_FLOW));
131 }
132 }
133}
134
135
137
138
139long
141 switch (FXSELID(sel)) {
144 break;
147 break;
149 GNERouteHandler::transformToVehicle(myVehicle, false);
150 break;
153 break;
156 break;
159 break;
162 break;
165 break;
168 break;
171 break;
172 default:
173 break;
174 }
175 return 1;
176}
177
178// ===========================================================================
179// GNEVehicle::GNESelectedVehiclesPopupMenu
180// ===========================================================================
181
182GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
183 GUIGLObjectPopupMenu(app, parent, vehicle),
184 mySelectedVehicles(selectedVehicle),
185 myVehicleTag(vehicle->getTagProperty()->getTag()) {
186 // build common options
187 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
188 // route length
189 vehicle->buildMenuCommandRouteLength(this);
190 // add transform functions only in demand mode
192 // add reverse
193 vehicle->buildMenuAddReverse(this);
194 // continue depending of type
195 if (vehicle->getTagProperty()->vehicleJunctions()) {
196 // create menu pane for transform operations
197 FXMenuPane* transformOperation = new FXMenuPane(this);
198 this->insertMenuPaneChild(transformOperation);
199 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
200 // Create menu commands for restricted transforms
202 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
205 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
207 // create separator
208 new FXMenuSeparator(transformOperation);
209 // Create menu commands for all transform
210 GUIDesigns::buildFXMenuCommand(transformOperation,
211 TL("Trips (over junctions)"),
213 GUIDesigns::buildFXMenuCommand(transformOperation,
214 TL("Flows (over junctions)"),
216 } else if (vehicle->getTagProperty()->vehicleTAZs()) {
217 // create menu pane for transform operations
218 FXMenuPane* transformOperation = new FXMenuPane(this);
219 this->insertMenuPaneChild(transformOperation);
220 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
221 // Create menu commands for all transform
223 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
226 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
228 // create separator
229 new FXMenuSeparator(transformOperation);
230 // Create menu commands for all transform
231 GUIDesigns::buildFXMenuCommand(transformOperation,
232 TL("Trips (over TAZs)"),
234 GUIDesigns::buildFXMenuCommand(transformOperation,
235 TL("Flows (over TAZs)"),
237 } else {
238 // create menu pane for transform operations
239 FXMenuPane* transformOperation = new FXMenuPane(this);
240 this->insertMenuPaneChild(transformOperation);
241 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
242 // Create menu commands for all transform
244 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
247 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
250 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
253 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
256 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
259 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
261 // create separator
262 new FXMenuSeparator(transformOperation);
263 // Create menu commands for all transform
264 GUIDesigns::buildFXMenuCommand(transformOperation,
265 TL("Vehicles"),
267 GUIDesigns::buildFXMenuCommand(transformOperation,
268 TL("Vehicles (embedded route)"),
270 GUIDesigns::buildFXMenuCommand(transformOperation,
271 TL("RouteFlows"),
273 GUIDesigns::buildFXMenuCommand(transformOperation,
274 TL("RouteFlows (embedded route)"),
276 GUIDesigns::buildFXMenuCommand(transformOperation,
277 TL("Trips"),
279 GUIDesigns::buildFXMenuCommand(transformOperation,
280 TL("Flows"),
282 }
283 }
284}
285
286
288
289
290long
291GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
292 // iterate over all selected vehicles
293 for (const auto& vehicle : mySelectedVehicles) {
294 switch (FXSELID(sel)) {
296 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
297 if (myRestrictedMenuCommands.count(obj) > 0) {
298 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
300 }
301 } else {
303 }
304 }
305 break;
307 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
308 if (myRestrictedMenuCommands.count(obj) > 0) {
309 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
311 }
312 } else {
314 }
315 }
316 break;
318 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
319 if (myRestrictedMenuCommands.count(obj) > 0) {
320 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
322 }
323 } else {
325 }
326 }
327 break;
329 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
330 if (myRestrictedMenuCommands.count(obj) > 0) {
331 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
333 }
334 } else {
336 }
337 }
338 break;
340 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
341 if (myRestrictedMenuCommands.count(obj) > 0) {
342 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
344 }
345 } else {
347 }
348 }
349 break;
351 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
352 if (myRestrictedMenuCommands.count(obj) > 0) {
353 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
355 }
356 } else {
358 }
359 }
360 break;
362 if (vehicle->getTagProperty()->vehicleJunctions()) {
363 if (myRestrictedMenuCommands.count(obj) > 0) {
364 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
366 }
367 } else {
369 }
370 }
371 break;
373 if (vehicle->getTagProperty()->vehicleJunctions()) {
374 if (myRestrictedMenuCommands.count(obj) > 0) {
375 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
377 }
378 } else {
380 }
381 }
382 break;
384 if (vehicle->getTagProperty()->vehicleTAZs()) {
385 if (myRestrictedMenuCommands.count(obj) > 0) {
386 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
388 }
389 } else {
391 }
392 }
393 break;
395 if (vehicle->getTagProperty()->vehicleTAZs()) {
396 if (myRestrictedMenuCommands.count(obj) > 0) {
397 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
399 }
400 } else {
402 }
403 }
404 break;
405 default:
406 break;
407 }
408 }
409 return 1;
410}
411
412// ===========================================================================
413// member method definitions
414// ===========================================================================
415#ifdef _MSC_VER
416#pragma warning(push)
417#pragma warning(disable: 4355) // mask warning about "this" in initializers
418#endif
422 // set end and vehPerHours as default flow values
425}
426
427
428GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename,
429 GNEDemandElement* vehicleType, GNEDemandElement* route) :
430 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
432 // set parents
433 setParents<GNEDemandElement*>({vehicleType, route});
434 // SUMOVehicleParameter ID has to be set manually
435 id = vehicleID;
436 // set manually vtypeID (needed for saving)
437 vtypeid = vehicleType->getID();
438}
439
440
441GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEDemandElement* route,
442 const SUMOVehicleParameter& vehicleParameters) :
443 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
444 GNEDemandElementFlow(this, vehicleParameters) {
445 // set parents
446 setParents<GNEDemandElement*>({vehicleType, route});
447 // SUMOVehicleParameter ID has to be set manually
448 id = vehicleParameters.id;
449 // set manually vtypeID (needed for saving)
450 vtypeid = vehicleType->getID();
451}
452
453
454GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
455 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
456 GNEDemandElementFlow(this, vehicleParameters) {
457 // set parents
458 setParent<GNEDemandElement*>(vehicleType);
459 // SUMOVehicleParameter ID has to be set manually
460 id = vehicleParameters.id;
461 // reset routeid
462 routeid.clear();
463 // set manually vtypeID (needed for saving)
464 vtypeid = vehicleType->getID();
465}
466
467
468GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType,
469 GNEEdge* fromEdge, GNEEdge* toEdge) :
470 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
472 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, departPos, toEdge, arrivalPos)) {
473 // set parents
474 setParents<GNEEdge*>({fromEdge, toEdge});
475 setParent<GNEDemandElement*>(vehicleType);
476}
477
478
479GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
480 const SUMOVehicleParameter& vehicleParameters) :
481 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
482 GNEDemandElementFlow(this, vehicleParameters),
483 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, departPos, toEdge, arrivalPos)) {
484 // set parents
485 setParents<GNEEdge*>({fromEdge, toEdge});
486 setParent<GNEDemandElement*>(vehicleType);
487}
488
489
490GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
491 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
493 // set parents
494 setParents<GNEJunction*>({fromJunction, toJunction});
495 setParent<GNEDemandElement*>(vehicleType);
496}
497
498
499GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
500 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
501 GNEDemandElementFlow(this, vehicleParameters) {
502 // set parents
503 setParents<GNEJunction*>({fromJunction, toJunction});
504 setParent<GNEDemandElement*>(vehicleType);
505}
506
507
508GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
509 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
510 GNEDemandElementFlow(this, vehicleParameters) {
511 // set parents
512 setParents<GNEAdditional*>({fromTAZ, toTAZ});
513 setParent<GNEDemandElement*>(vehicleType);
514 // mark taz parameters as set
517 fromTaz = fromTAZ->getID();
518 toTaz = toTAZ->getID();
519}
520#ifdef _MSC_VER
521#pragma warning(pop)
522#endif
523
524
526
527
532
533
536 return this;
537}
538
539
540const Parameterised*
542 return this;
543}
544
545
546void
548 // attribute VType must not be written if is DEFAULT_VTYPE_ID
550 // unset VType parameter
551 parametersSet &= ~VEHPARS_VTYPE_SET;
552 // write vehicle attributes (VType will not be written)
554 // set VType parameter again
556 } else {
557 // write vehicle attributes, including type/distribution
559 }
560 // write specific attribute depending of tag property
562 // write route
564 }
565 // write from, to and edge vias
567 // write manually from/to edges (it correspond to front and back parent edges)
568 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
569 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
570 // only write via if there isn't empty
571 if (via.size() > 0) {
572 device.writeAttr(SUMO_ATTR_VIA, via);
573 }
574 }
575 // write from and to junctions
577 // write manually from/to junctions (it correspond to front and back parent junctions)
580 }
581 // write parameters
582 writeParams(device);
583 // write route elements associated to this vehicle (except for calibrator FLows)
584 if ((getChildDemandElements().size() > 0) && !myTagProperty->isCalibrator()) {
585 if (getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
586 // write embedded route
587 getChildDemandElements().front()->writeDemandElement(device);
588 // write stops
589 for (const auto& demandElement : getChildDemandElements()) {
590 if (demandElement->getTagProperty()->isVehicleStop()) {
591 demandElement->writeDemandElement(device);
592 }
593 }
594 } else {
595 for (const auto& route : getChildDemandElements()) {
596 route->writeDemandElement(device);
597 }
598 }
599 }
600 // close vehicle tag
601 device.closeTag();
602}
603
604
607 // check conditions
608 if (myTagProperty->vehicleTAZs()) {
609 // vehicles and flows over tazs are always valid
610 return Problem::OK;
611 } else if (myTagProperty->vehicleEdges()) {
612 // check vehicles and flows paths
613 if (getParentEdges().front() == getParentEdges().back()) {
614 return Problem::OK;
615 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
616 return Problem::OK;
617 } else {
619 }
620 } else if (myTagProperty->vehicleJunctions()) {
621 // check vehicles and flows paths
622 if (getParentJunctions().front() == getParentJunctions().back()) {
623 return Problem::OK;
624 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
625 return Problem::OK;
626 } else {
628 }
629 } else if (myTagProperty->vehicleRoute()) {
630 // check if exist a valid path using route parent edges
632 return Problem::OK;
633 } else {
635 }
636 } else if (myTagProperty->vehicleRouteEmbedded()) {
637 // check if exist a valid path using route child edges
639 return Problem::OK;
640 } else {
642 }
643 } else {
645 }
646}
647
648
649std::string
651 // only trips or flows can have problems
653 // check if exist at least a connection between every edge
654 for (int i = 1; i < (int)getParentEdges().size(); i++) {
656 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
657 }
658 }
659 // if there are connections between all edges, then all is ok
660 return "";
661 } else if (myTagProperty->vehicleJunctions()) {
662 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
663 } else if (myTagProperty->vehicleRoute()) {
664 // get route parent edges
665 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
666 // check if exist at least a connection between every edge
667 for (int i = 1; i < (int)routeEdges.size(); i++) {
668 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
669 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
670 }
671 }
672 // if there are connections between all edges, then all is ok
673 return "";
674 } else if (myTagProperty->vehicleRouteEmbedded()) {
675 // get route parent edges
676 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
677 // check if exist at least a connection between every edge
678 for (int i = 1; i < (int)routeEdges.size(); i++) {
679 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
680 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
681 }
682 }
683 // if there are connections between all edges, then all is ok
684 return "";
685 } else {
686 return "";
687 }
688}
689
690
691void
695
696
699 return getParentDemandElements().front()->getVClass();
700}
701
702
703const RGBColor&
705 return color;
706}
707
708
709void
711 if (getParentJunctions().size() > 0) {
712 // calculate rotation between both junctions
713 const Position posA = getParentJunctions().front()->getPositionInView();
714 const Position posB = getParentJunctions().back()->getPositionInView();
715 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
716 // update Geometry
717 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
718 } else if (getParentAdditionals().size() > 0) {
719 // calculate rotation between both TAZs
720 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
721 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
722 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
723 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
724 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
725 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
726 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
727 // update Geometry
729 } else {
730 // get first path lane
731 const GNELane* firstPathLane = getFirstPathLane();
732 // check path lane
733 if (firstPathLane) {
734 // declare departPos
735 double posOverLane = 0;
737 posOverLane = departPos;
738 }
739 // update Geometry
740 myDemandElementGeometry.updateGeometry(firstPathLane->getLaneShape(), posOverLane, 0 /*myMovingLateralOffset*/);
741 // compute route embedded associated with this vehicle
742 for (const auto& demandElement : getChildDemandElements()) {
743 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
744 demandElement->computePathElement();
745 }
746 demandElement->updateGeometry();
747 }
748 }
749 }
750}
751
752
757
758
759bool
761 // get edit modes
762 const auto& editModes = myNet->getViewNet()->getEditModes();
763 // check if we're editing a type
764 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
766 return true;
767 }
768 // check opened popup
769 if (myNet->getViewNet()->getPopup()) {
770 return myNet->getViewNet()->getPopup()->getGLObject() == this;
771 }
772 return false;
773}
774
775
779 // obtain all selected vehicles
780 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
781 std::vector<GNEVehicle*> selectedVehicles;
782 selectedVehicles.reserve(selectedDemandElements.size());
783 for (const auto& selectedDemandElement : selectedDemandElements) {
784 if (selectedDemandElement->getTagProperty()->isVehicle()) {
785 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
786 }
787 }
788 // return a GNESelectedVehiclesPopupMenu
789 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
790 } else {
791 // return a GNESingleVehiclePopupMenu
792 return new GNESingleVehiclePopupMenu(this, app, parent);
793 }
794}
795
796
797std::string
800 return getRouteParent()->getID();
801 } else if (myTagProperty->vehicleEdges()) {
802 return getParentEdges().front()->getID();
803 } else if (myTagProperty->vehicleJunctions()) {
804 return getParentJunctions().front()->getID();
805 } else if (myTagProperty->vehicleTAZs()) {
806 return getParentAdditionals().front()->getID();
807 } else {
808 throw ProcessError(TL("Invalid vehicle tag"));
809 }
810}
811
812
813double
817
818
821 Boundary vehicleBoundary;
822 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
823 vehicleBoundary.grow(20);
824 return vehicleBoundary;
825}
826
827
828void
829GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
830 // geometry of this element cannot be splitted
831}
832
833
834void
836 // only drawn in super mode demand
840 // declare common attributes
842 const double exaggeration = getExaggeration(s);
843 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
844 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
845 // obtain Position an rotation (depending of draw spread vehicles)
846 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
847 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
848 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
849 // check that position is valid
850 if (vehiclePosition == Position::INVALID) {
851 return;
852 }
853 // get detail level
854 const auto d = s.getDetailLevel(exaggeration);
855 // draw geometry only if we'rent in drawForObjectUnderCursor mode
858 // push draw matrix
860 // Start with the drawing of the area translating matrix to origin
862 // translate to drawing position
863 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
864 glRotated(vehicleRotation, 0, 0, -1);
865 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
866 glTranslated(0, (-1) * length * exaggeration, 0);
867 // set lane color
869 double upscaleLength = exaggeration;
870 if ((exaggeration > 1) && (length > 5)) {
871 // reduce the length/width ratio because this is not useful at high zoom
872 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
873 }
874 glScaled(exaggeration, upscaleLength, 1);
875 // draw the vehicle depending of detail level
882 }
883 // check if min gap has to be drawn
884 if (s.drawMinGap) {
885 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
886 glColor3d(0., 1., 0.);
887 glBegin(GL_LINES);
888 glVertex2d(0., 0);
889 glVertex2d(0., minGap);
890 glVertex2d(-.5, minGap);
891 glVertex2d(.5, minGap);
892 glEnd();
893 }
894 // drawing name at GLO_MAX fails unless translating z
895 glTranslated(0, MIN2(length / 2, double(5)), -getType());
896 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
897 glRotated(-vehicleRotation, 0, 0, -1);
899 // draw line
900 if (s.vehicleName.show(this) && line != "") {
901 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
903 }
904 // pop draw matrix
906 // draw line between junctions if path isn't valid
907 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
908 drawJunctionLine(this);
909 }
910 // draw lock icon
911 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
912 // draw stack label
913 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
914 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
915 }
916 // draw flow label
917 if (myTagProperty->isFlow()) {
918 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
919 }
920 // draw dotted contour
922 }
923 // draw squared shape
924 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
925 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
926 }
927 }
928}
929
930
931void
933 // calculate path (only for flows and trips)
935 // calculate path
937 } else if (myTagProperty->vehicleEdges()) {
938 // save edges in wich this vehicle has to stop
939 std::vector<GNEEdge*> edgeStops;
940 // iterate over child demand elements
941 for (const auto& demandElement : getChildDemandElements()) {
942 // extract lanes
943 if (demandElement->getTagProperty()->isVehicleStop()) {
944 GNEEdge* edgeStop = nullptr;
945 if (demandElement->getParentAdditionals().size() > 0) {
946 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
947 } else {
948 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
949 }
950 if (edgeStop) {
951 // avoid double edge stops
952 if (stops.empty()) {
953 edgeStops.push_back(edgeStop);
954 } else if (edgeStops.back() != edgeStop) {
955 edgeStops.push_back(edgeStop);
956 }
957 }
958 }
959 }
960 // declare edge vector
961 std::vector<GNEEdge*> edgePath;
962 // get first and last lanes
963 const auto firstLane = getFirstPathLane();
964 const auto lastLane = getLastPathLane();
965 // check first and last lanes
966 if (firstLane && lastLane) {
967 // add first lane
968 edgePath.push_back(firstLane->getParentEdge());
969 // give more priority to stops instead via
970 if (edgeStops.size() > 0) {
971 // add stops only if they're accesibles
972 for (const auto& edgeStop : edgeStops) {
973 // check if exist a valid path that includes the last edge
974 auto edgePathStop = edgePath;
975 edgePathStop.push_back(edgeStop);
976 edgePathStop.push_back(lastLane->getParentEdge());
978 if (path.size() > 0) {
979 edgePath.push_back(edgeStop);
980 }
981 }
982 } else {
983 // add via lanes
984 for (const auto& edgeViaID : via) {
985 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
986 if (edgeVia) {
987 // check if exist a valid path that includes the last edge
988 auto edgePathStop = edgePath;
989 edgePathStop.push_back(edgeVia);
990 edgePathStop.push_back(lastLane->getParentEdge());
991 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
992 edgePath.push_back(edgeVia);
993 }
994 }
995 }
996 }
997 // add last lane
998 edgePath.push_back(lastLane->getParentEdge());
999 // calculate path
1000 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1001 }
1002 }
1003 // update geometry
1005}
1006
1007
1008void
1009GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1010 // conditions for draw always in network mode
1011 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1014 // conditions for draw always in demand mode
1015 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1017 // conditions for draw if is selected
1018 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1020 // conditions for draw if is inspected
1021 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1023 // check drawing conditions
1024 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1026 // get detail level
1027 const auto d = s.getDetailLevel(1);
1028 // calculate width
1029 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1030 // calculate startPos
1031 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1032 // get endPos
1033 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1034 // declare path geometry
1035 GUIGeometry vehicleGeometry;
1036 // update pathGeometry depending of first and last segment
1037 if (segment->isFirstSegment() && segment->isLastSegment()) {
1038 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1039 geometryDepartPos,
1041 geometryEndPos,
1043 } else if (segment->isFirstSegment()) {
1044 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1045 geometryDepartPos,
1047 -1,
1049 } else if (segment->isLastSegment()) {
1050 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1051 -1,
1053 geometryEndPos,
1055 } else {
1056 vehicleGeometry = segment->getLane()->getLaneGeometry();
1057 }
1058 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1060 // obtain color
1062 // Add a draw matrix
1064 // Start with the drawing of the area translating matrix to origin
1065 glTranslated(0, 0, getType() + offsetFront);
1066 // Set color
1067 GLHelper::setColor(pathColor);
1068 // draw geometry
1069 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1070 // show index over every edge
1071 if (isInspected && s.showRouteIndex) {
1072 const double textSize = s.vehicleName.size / s.scale;
1073 std::string label = toString(segment->getLaneIndex());
1074 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
1075 GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
1076 }
1077 // Pop last matrix
1079 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1080 if (segment->getNextLane()) {
1081 // push draw matrix
1083 // Start with the drawing of the area translating matrix to origin
1085 // Set red color
1087 // get firstPosition (last position of current lane shape)
1088 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1089 // get lastPosition (first position of next lane shape)
1090 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1091 // draw box line
1092 GLHelper::drawBoxLine(arrivalPosition,
1093 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1094 firstPosition.distanceTo2D(arrivalPosition), .05);
1095 // pop draw matrix
1097 }
1098 // check if this is the last segment
1099 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1100 // get geometryEndPos
1101 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1102 // check if endPos can be drawn
1104 // push draw matrix
1106 // Start with the drawing of the area translating matrix to origin
1108 // translate to geometryEndPos
1109 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1110 // Set person plan color
1111 GLHelper::setColor(pathColor);
1112 // resolution of drawn circle depending of the zoom (To improve smoothness)
1114 // pop draw matrix
1116 }
1117 }
1118 // draw dotted contour
1119 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1120 }
1121 // calculate contour and draw dotted geometry
1122 if (segment->isFirstSegment() || segment->isLastSegment()) {
1123 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1124 0, segment, segment->getLane()->getParentEdge());
1125 } else {
1126 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1127 0, segment, segment->getLane()->getParentEdge());
1128 }
1129 // check if add this path element to redraw buffer
1130 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1132 }
1133 }
1134}
1135
1136
1137void
1138GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1139 // conditions for draw always in network mode
1140 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1143 // conditions for draw always in demand mode
1144 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1146 // conditions for draw if is selected
1147 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1149 // conditions for draw if is inspected
1150 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1152 // check drawing conditions
1153 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1155 // get detail level
1156 const auto d = s.getDetailLevel(1);
1157 // calculate width
1158 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1159 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1161 // Add a draw matrix
1163 // Start with the drawing of the area translating matrix to origin
1164 glTranslated(0, 0, getType() + offsetFront);
1165 // Set color of the base
1166 if (drawUsingSelectColor()) {
1168 } else {
1170 }
1171 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1172 if (segment->getPreviousLane() && segment->getNextLane()) {
1173 // draw lane2lane
1175 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1176 // draw line between center of junction and last lane shape
1177 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1178 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1179 // draw line between center of junction and first lane shape
1180 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1181 }
1182 // Pop last matrix
1184 // draw dotted contour
1185 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1186 }
1187 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1188 if (segment->getPreviousLane() && segment->getNextLane()) {
1189 // calculate contour and draw dotted geometry
1191 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1192 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1193 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1194 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1195 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1196 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1197 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1198 }
1199 // check if add this path element to redraw buffer
1200 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1202 }
1203 }
1204}
1205
1206
1207GNELane*
1209 // declare first edge
1210 GNEEdge* firstEdge = nullptr;
1211 // continue depending of tags
1212 if (myTagProperty->vehicleRoute()) {
1213 // check departEdge
1214 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1215 // use departEdge
1216 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1217 } else {
1218 // use first route edge
1219 firstEdge = getRouteParent()->getParentEdges().front();
1220 }
1221 } else if (myTagProperty->vehicleRouteEmbedded()) {
1222 // check if embedded route exist (due during loading embedded route doesn't exist)
1223 if (getChildDemandElements().empty()) {
1224 return nullptr;
1225 }
1226 // check departEdge
1227 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1228 // use depart edge
1229 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1230 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1231 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1232 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1233 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1234 } else {
1235 return nullptr;
1236 }
1237 } else if (getParentEdges().size() > 0) {
1238 // use first parent edge
1239 firstEdge = getParentEdges().front();
1240 } else {
1241 // defined over junctions
1242 return nullptr;
1243 }
1244 // get departLane index
1245 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1246 // check departLane index
1247 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getChildLanes().size())) {
1248 return firstEdge->getChildLanes().at(departLaneIndex);
1249 } else {
1250 // get first allowed VClass
1251 return firstEdge->getLaneByAllowedVClass(getVClass());
1252 }
1253}
1254
1255
1256GNELane*
1258 // declare last edge
1259 GNEEdge* lastEdge = nullptr;
1260 // continue depending of tags
1261 if (myTagProperty->vehicleRoute()) {
1262 // check arrivalEdge
1263 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1264 // use arrival edge
1265 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1266 } else {
1267 // use last route edge
1268 lastEdge = getRouteParent()->getParentEdges().back();
1269 }
1270 } else if (myTagProperty->vehicleRouteEmbedded()) {
1271 // check if embedded route exist (due during loading embedded route doesn't exist)
1272 if (getChildDemandElements().empty()) {
1273 return nullptr;
1274 }
1275 // check arrivalEdge
1276 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1277 // use arrival edge
1278 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1279 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1280 // use last route edge
1281 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1282 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1283 // use lane
1284 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1285 } else {
1286 return nullptr;
1287 }
1288 } else if (getParentEdges().size() > 0) {
1289 // use last parent edge
1290 lastEdge = getParentEdges().back();
1291 } else {
1292 // defined over junctions
1293 return nullptr;
1294 }
1295 // get arrivalLane index
1296 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1297 // check arrivalLane index
1298 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getChildLanes().size())) {
1299 return lastEdge->getChildLanes().at(arrivalLaneIndex);
1300 } else {
1301 // get last allowed VClass
1302 return lastEdge->getLaneByAllowedVClass(getVClass());
1303 }
1304}
1305
1306
1307std::string
1309 switch (key) {
1310 case SUMO_ATTR_ID:
1311 return getMicrosimID();
1312 case SUMO_ATTR_TYPE:
1313 return vtypeid;
1314 case SUMO_ATTR_COLOR:
1316 return toString(color);
1317 } else {
1319 }
1322 return getDepartLane();
1323 } else {
1325 }
1328 return getDepartPos();
1329 } else {
1331 }
1334 return getDepartSpeed();
1335 } else {
1337 }
1340 return getArrivalLane();
1341 } else {
1343 }
1346 return getArrivalPos();
1347 } else {
1349 }
1352 return getArrivalSpeed();
1353 } else {
1355 }
1356 case SUMO_ATTR_LINE:
1357 if (wasSet(VEHPARS_LINE_SET)) {
1358 return line;
1359 } else {
1361 }
1364 return toString(personNumber);
1365 } else {
1367 }
1370 return toString(containerNumber);
1371 } else {
1373 }
1374 case SUMO_ATTR_REROUTE:
1376 return "true";
1377 } else {
1378 return "false";
1379 }
1382 return getDepartPosLat();
1383 } else {
1385 }
1388 return getArrivalPosLat();
1389 } else {
1391 }
1393 return getInsertionChecks();
1394 // Specific of vehicles over routes
1395 case SUMO_ATTR_ROUTE:
1396 if (getParentDemandElements().size() == 2) {
1397 return getRouteParent()->getID();
1398 } else {
1399 return "";
1400 }
1401 // Specific of from-to edge
1402 case SUMO_ATTR_FROM:
1403 return getParentEdges().front()->getID();
1404 case SUMO_ATTR_TO:
1405 return getParentEdges().back()->getID();
1406 case SUMO_ATTR_VIA:
1407 return toString(via);
1409 if (departEdge == -1) {
1410 return "";
1411 } else {
1412 return toString(departEdge);
1413 }
1415 if (arrivalEdge == -1) {
1416 return "";
1417 } else {
1418 return toString(arrivalEdge);
1419 }
1420 // Specific of from-to junctions
1422 return getParentJunctions().front()->getID();
1424 return getParentJunctions().back()->getID();
1425 // Specific of from-to tazs
1426 case SUMO_ATTR_FROM_TAZ:
1427 return getParentAdditionals().front()->getID();
1428 case SUMO_ATTR_TO_TAZ:
1429 return getParentAdditionals().back()->getID();
1430 // other
1432 return toString(parametersSet);
1433 default:
1434 return getFlowAttribute(this, key);
1435 }
1436}
1437
1438
1439double
1441 switch (key) {
1444 return departLane;
1445 } else {
1446 return -1;
1447 }
1449 // only return departPos it if is given
1451 return departPos;
1452 } else {
1453 return 0;
1454 }
1457 return arrivalLane;
1458 } else {
1459 return -1;
1460 }
1462 // only return departPos it if is given
1464 return arrivalPos;
1465 } else {
1466 return -1;
1467 }
1468 case SUMO_ATTR_WIDTH:
1469 case SUMO_ATTR_LENGTH:
1470 case SUMO_ATTR_MINGAP:
1471 return getTypeParent()->getAttributeDouble(key);
1472 default:
1473 return getFlowAttributeDouble(key);
1474 }
1475}
1476
1477
1480 switch (key) {
1482 // check if this vehicle was defined over junctions
1483 if (getParentJunctions().size() > 0) {
1484 return getParentJunctions().front()->getPositionInView();
1485 } else {
1486 // get first path lane shape
1487 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1488 // check arrivalPosProcedure
1490 if (departPos < 0) {
1491 return laneShape.front();
1492 } else if (departPos > laneShape.length2D()) {
1493 return laneShape.back();
1494 } else {
1495 return laneShape.positionAtOffset2D(departPos);
1496 }
1497 } else {
1498 return laneShape.front();
1499 }
1500 }
1501 }
1503 // check if this vehicle was defined over junctions
1504 if (getParentJunctions().size() > 0) {
1505 return getParentJunctions().back()->getPositionInView();
1506 } else {
1507 // get last path lane shape
1508 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1509 // check arrivalPosProcedure
1511 if (arrivalPos < 0) {
1512 return laneShape.front();
1513 } else if (arrivalPos > laneShape.length2D()) {
1514 return laneShape.back();
1515 } else {
1516 return laneShape.positionAtOffset2D(arrivalPos);
1517 }
1518 } else {
1519 return laneShape.back();
1520 }
1521 }
1522 }
1523 default:
1524 return getCommonAttributePosition(key);
1525 }
1526}
1527
1528
1529void
1530GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1531 if (value == getAttribute(key)) {
1532 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1533 }
1534 switch (key) {
1535 case SUMO_ATTR_ID:
1536 case SUMO_ATTR_TYPE:
1537 case SUMO_ATTR_COLOR:
1544 case SUMO_ATTR_LINE:
1547 case SUMO_ATTR_REROUTE:
1551 // Specific of vehicles over routes
1552 case SUMO_ATTR_ROUTE:
1553 // Specific of from-to edges
1554 case SUMO_ATTR_FROM:
1555 case SUMO_ATTR_TO:
1556 case SUMO_ATTR_VIA:
1559 // Specific of from-to junctions
1562 // Specific of from-to taz
1563 case SUMO_ATTR_FROM_TAZ:
1564 case SUMO_ATTR_TO_TAZ:
1565 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1566 break;
1567 default:
1568 setFlowAttribute(this, key, value, undoList);
1569 break;
1570 }
1571}
1572
1573
1574bool
1575GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1576 // get ACs
1577 const auto ACs = myNet->getAttributeCarriers();
1578 // declare string error
1579 std::string error;
1580 switch (key) {
1581 case SUMO_ATTR_ID:
1583 case SUMO_ATTR_TYPE:
1584 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1585 case SUMO_ATTR_COLOR:
1586 return canParse<RGBColor>(value);
1587 case SUMO_ATTR_DEPARTLANE: {
1588 int dummyDepartLane;
1589 DepartLaneDefinition dummyDepartLaneProcedure;
1590 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1591 // if error is empty, check if depart lane is correct
1592 if (error.empty()) {
1593 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1594 return true;
1595 } else if (isTemplate()) {
1596 return true;
1597 } else if (getParentJunctions().size() > 0) {
1598 return (dummyDepartLane == 0);
1599 } else if (getParentAdditionals().size() > 0) {
1600 return (dummyDepartLane == 0);
1601 } else {
1602 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1603 }
1604 } else {
1605 return false;
1606 }
1607 }
1608 case SUMO_ATTR_DEPARTPOS: {
1609 double dummyDepartPos;
1610 DepartPosDefinition dummyDepartPosProcedure;
1611 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1612 // if error is empty, given value is valid
1613 return error.empty();
1614 }
1615 case SUMO_ATTR_DEPARTSPEED: {
1616 double dummyDepartSpeed;
1617 DepartSpeedDefinition dummyDepartSpeedProcedure;
1618 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1619 // if error is empty, check if depart speed is correct
1620 if (error.empty()) {
1621 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1622 return true;
1623 } else if (isTemplate()) {
1624 return true;
1625 } else {
1626 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1627 }
1628 } else {
1629 return false;
1630 }
1631 }
1632 case SUMO_ATTR_ARRIVALLANE: {
1633 int dummyArrivalLane;
1634 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1635 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1636 // if error is empty, given value is valid
1637 if (error.empty()) {
1638 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1639 return true;
1640 } else if (isTemplate()) {
1641 return true;
1642 } else if (getParentJunctions().size() > 0) {
1643 return (dummyArrivalLane == 0);
1644 } else if (getParentAdditionals().size() > 0) {
1645 return (dummyArrivalLane == 0);
1646 } else {
1647 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1648 }
1649 } else {
1650 return false;
1651 }
1652 }
1653 case SUMO_ATTR_ARRIVALPOS: {
1654 double dummyArrivalPos;
1655 ArrivalPosDefinition dummyArrivalPosProcedure;
1656 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1657 // if error is empty, given value is valid
1658 return error.empty();
1659 }
1661 double dummyArrivalSpeed;
1662 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1663 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1664 // if error is empty, given value is valid
1665 return error.empty();
1666 }
1667 case SUMO_ATTR_LINE:
1668 return true;
1670 return canParse<int>(value) && parse<int>(value) >= 0;
1672 return canParse<int>(value) && parse<int>(value) >= 0;
1673 case SUMO_ATTR_REROUTE:
1674 return true; // check
1676 double dummyDepartPosLat;
1677 DepartPosLatDefinition dummyDepartPosLatProcedure;
1678 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1679 // if error is empty, given value is valid
1680 return error.empty();
1681 }
1683 double dummyArrivalPosLat;
1684 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1685 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1686 // if error is empty, given value is valid
1687 return error.empty();
1688 }
1690 return areInsertionChecksValid(value);
1691 // Specific of vehicles over routes
1692 case SUMO_ATTR_ROUTE:
1693 if (getParentDemandElements().size() == 2) {
1694 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1695 } else {
1696 return true;
1697 }
1698 // Specific of from-to edges
1699 case SUMO_ATTR_FROM:
1700 case SUMO_ATTR_TO:
1701 return (ACs->retrieveEdge(value, false) != nullptr);
1703 case SUMO_ATTR_ARRIVALEDGE: {
1704 if (value.empty()) {
1705 return true;
1706 } else if (canParse<int>(value)) {
1707 // get index
1708 const int index = parse<int>(value);
1709 // check conditions
1710 if (index < 0) {
1711 return false;
1712 } else if (myTagProperty->vehicleRoute()) {
1713 // check parent route
1714 return (index < (int)getRouteParent()->getParentEdges().size());
1715 } else {
1716 // check embedded route
1717 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1718 }
1719 } else {
1720 return false;
1721 }
1722 }
1723 case SUMO_ATTR_VIA:
1724 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1725 // Specific of from-to junctions
1728 return (ACs->retrieveJunction(value, false) != nullptr);
1729 // Specific of from-to taz
1730 case SUMO_ATTR_FROM_TAZ:
1731 case SUMO_ATTR_TO_TAZ:
1732 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1733 default:
1734 return isValidFlowAttribute(this, key, value);
1735 }
1736}
1737
1738
1739void
1741 enableFlowAttribute(this, key, undoList);
1742}
1743
1744
1745void
1747 disableFlowAttribute(this, key, undoList);
1748}
1749
1750
1751bool
1755
1756
1757std::string
1759 return getTagStr();
1760}
1761
1762
1763std::string
1765 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1766 // special case for Trips and flow
1767 if (myTagProperty->vehicleEdges()) {
1768 // check if we're inspecting a Edge
1769 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1770 // check if edge correspond to a "from", "to" or "via" edge
1771 if (inspectedElements.isACInspected(getParentEdges().front())) {
1772 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1773 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1774 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1775 } else {
1776 // iterate over via
1777 for (const auto& viaEdgeID : via) {
1778 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1779 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1780 }
1781 }
1782 }
1783 }
1784 }
1785 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1786}
1787
1788
1790GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1791 // get net and undoList
1792 const auto net = originalVehicle->getNet();
1793 auto undoList = net->getViewNet()->getUndoList();
1794 // declare new route, vehicle and embedded route
1795 GNERoute* newRoute = nullptr;
1796 GNEVehicle* newVehicle = nullptr;
1797 GNERoute* newEmbeddedRoute = nullptr;
1798 // generate new vehicle ID
1799 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1800 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1801 // extract vehicle parameters and update ID
1802 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1803 newVehicleParameters.id = newVehicleID;
1804 // create vehicle using vehicleParameters
1805 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1806 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1807 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1808 originalVehicle->getParentDemandElements().at(0), newRoute,
1809 newVehicleParameters);
1810 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1811 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1812 originalVehicle->getParentDemandElements().at(0),
1813 newVehicleParameters);
1814 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1815 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1816 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1817 originalVehicle->getParentDemandElements().at(0),
1818 originalVehicle->getParentEdges().front(),
1819 originalVehicle->getParentEdges().back(),
1820 newVehicleParameters);
1821 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1822 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1823 originalVehicle->getParentDemandElements().at(0),
1824 originalVehicle->getParentJunctions().front(),
1825 originalVehicle->getParentJunctions().back(),
1826 newVehicleParameters);
1827 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1828 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1829 originalVehicle->getParentDemandElements().at(0),
1830 originalVehicle->getParentAdditionals().front(),
1831 originalVehicle->getParentAdditionals().back(),
1832 newVehicleParameters);
1833 }
1834 // add new vehicle
1835 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1836 if (newRoute) {
1837 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1838 }
1839 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1840 if (newEmbeddedRoute) {
1841 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1842 }
1843 undoList->end();
1844 return newVehicle;
1845}
1846
1847// ===========================================================================
1848// protected
1849// ===========================================================================
1850
1853 // change color
1854 if (drawUsingSelectColor()) {
1856 } else {
1857 return getColorByScheme(s.vehicleColorer, this);
1858 }
1859}
1860
1861
1864 return *this;
1865}
1866
1867// ===========================================================================
1868// private
1869// ===========================================================================
1870
1871void
1872GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1873 // declare string error
1874 std::string error;
1875 // flag to upate stack label
1876 bool updateSpreadStackGeometry = false;
1877 switch (key) {
1878 case SUMO_ATTR_ID:
1879 // update microsimID
1880 setDemandElementID(value);
1881 // set manually vehicle ID (needed for saving)
1882 id = value;
1883 break;
1884 case SUMO_ATTR_TYPE:
1885 if (getID().size() > 0) {
1886 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1888 } else {
1890 }
1891 // set manually vtypeID (needed for saving)
1892 vtypeid = value;
1893 }
1894 break;
1895 case SUMO_ATTR_COLOR:
1896 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1897 color = parse<RGBColor>(value);
1898 // mark parameter as set
1900 } else {
1901 // set default value
1903 // unset parameter
1904 parametersSet &= ~VEHPARS_COLOR_SET;
1905 }
1906 break;
1908 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1910 // mark parameter as set
1912 } else {
1913 // set default value
1915 // unset parameter
1916 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1917 }
1918 break;
1920 if (value == toString(INVALID_DOUBLE)) {
1922 // mark parameter as set
1924 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1926 // mark parameter as set
1928 } else {
1929 // set default value
1931 // unset parameter
1932 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1933 }
1934 if (getID().size() > 0) {
1936 updateSpreadStackGeometry = true;
1937 }
1938 break;
1940 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1942 // mark parameter as set
1944 } else {
1945 // set default value
1947 // unset parameter
1948 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1949 }
1950 break;
1952 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1954 // mark parameter as set
1956 } else {
1957 // set default value
1959 // unset parameter
1960 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
1961 }
1962 break;
1964 if (value == toString(INVALID_DOUBLE)) {
1966 // mark parameter as set
1968 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1970 // mark parameter as set
1972 } else {
1973 // set default value
1975 // unset parameter
1976 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
1977 }
1978 if (getID().size() > 0) {
1980 updateSpreadStackGeometry = true;
1981 }
1982 break;
1984 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1986 // mark parameter as set
1988 } else {
1989 // set default value
1991 // unset parameter
1992 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
1993 }
1994 break;
1995 case SUMO_ATTR_LINE:
1996 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1997 line = value;
1998 // mark parameter as set
2000 } else {
2001 // set default value
2003 // unset parameter
2004 parametersSet &= ~VEHPARS_LINE_SET;
2005 }
2006 break;
2008 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2009 personNumber = parse<int>(value);
2010 // mark parameter as set
2012 } else {
2013 // set default value
2015 // unset parameter
2016 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2017 }
2018 break;
2020 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2021 containerNumber = parse<int>(value);
2022 // mark parameter as set
2024 } else {
2025 // set default value
2027 // unset parameter
2028 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2029 }
2030 break;
2031 case SUMO_ATTR_REROUTE:
2032 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2033 // mark parameter as set
2035 } else {
2036 // unset parameter
2037 parametersSet &= ~VEHPARS_ROUTE_SET;
2038 }
2039 break;
2041 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2043 // mark parameter as set
2045 } else {
2046 // set default value
2048 // unset parameter
2049 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2050 }
2051 break;
2053 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2055 // mark parameter as set
2057 } else {
2058 // set default value
2060 // unset parameter
2061 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2062 }
2064 break;
2066 if (value.empty() || (value == "all")) {
2067 // unset parameter
2068 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2069 } else {
2070 // mark parameter as set
2072 }
2074 break;
2075 // Specific of vehicles over routes
2076 case SUMO_ATTR_ROUTE:
2077 if (getParentDemandElements().size() == 2) {
2079 }
2081 updateSpreadStackGeometry = true;
2082 break;
2083 // Specific of from-to edges
2084 case SUMO_ATTR_FROM: {
2085 // change first edge
2087 // compute vehicle
2089 updateSpreadStackGeometry = true;
2090 break;
2091 }
2092 case SUMO_ATTR_TO: {
2093 // change last edge
2094 replaceLastParentEdge(value);
2095 // compute vehicle
2097 updateSpreadStackGeometry = true;
2098 break;
2099 }
2100 case SUMO_ATTR_VIA: {
2101 if (!value.empty()) {
2102 // set new via edges
2103 via = parse< std::vector<std::string> >(value);
2104 // mark parameter as set
2106 } else {
2107 // clear via
2108 via.clear();
2109 // unset parameter
2110 parametersSet &= ~VEHPARS_VIA_SET;
2111 }
2112 // compute vehicle
2114 updateSpreadStackGeometry = true;
2115 break;
2116 }
2117 case SUMO_ATTR_DEPARTEDGE: {
2118 // update depart edge
2119 if (value.empty()) {
2120 // unset parameter
2121 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2122 departEdge = -1;
2124 } else {
2125 // mark parameter as set
2127 departEdge = parse<int>(value);
2129 }
2130 // compute vehicle
2131 if (getID().size() > 0) {
2133 updateSpreadStackGeometry = true;
2134 }
2135 break;
2136 }
2137 case SUMO_ATTR_ARRIVALEDGE: {
2138 // update arrival edge
2139 if (value.empty()) {
2140 // unset parameter
2141 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2142 arrivalEdge = -1;
2144 } else {
2145 // mark parameter as set
2147 arrivalEdge = parse<int>(value);
2149 }
2150 if (getID().size() > 0) {
2151 // compute vehicle
2153 updateSpreadStackGeometry = true;
2154 }
2155 break;
2156 }
2157 // Specific of from-to junctions
2159 // change first junction
2161 // compute vehicle
2163 updateSpreadStackGeometry = true;
2164 break;
2165 }
2166 case SUMO_ATTR_TO_JUNCTION: {
2167 // change last junction
2169 // compute vehicle
2171 updateSpreadStackGeometry = true;
2172 break;
2173 }
2174 // Specific of from-to TAZs
2175 case SUMO_ATTR_FROM_TAZ: {
2176 // change first additional
2178 // set taz manually
2179 fromTaz = value;
2180 // compute vehicle
2182 updateSpreadStackGeometry = true;
2183 break;
2184 }
2185 case SUMO_ATTR_TO_TAZ: {
2186 // change last additional
2188 // set taz manually
2189 toTaz = value;
2190 // compute vehicle
2192 updateSpreadStackGeometry = true;
2193 break;
2194 }
2195 default:
2196 setFlowAttribute(this, key, value);
2197 break;
2198 }
2199 // check if stack label has to be updated
2200 if (updateSpreadStackGeometry) {
2201 if (myTagProperty->vehicleEdges()) {
2202 getParentEdges().front()->updateVehicleStackLabels();
2203 getParentEdges().front()->updateVehicleSpreadGeometries();
2204 } else if (myTagProperty->vehicleRoute()) {
2205 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2206 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2207 } else if (myTagProperty->vehicleRouteEmbedded()) {
2208 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2209 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2210 }
2211 }
2212}
2213
2214
2215void
2217 // toggle flow attributes
2218 toggleFlowAttribute(key, value);
2219}
2220
2221/****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ DEMAND_TYPE
Mode for editing types.
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_EMBEDDED
transform vehicle to flow over junctions
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_TAZS
transform vehicle to flow over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE_EMBEDDED
transform vehicle to vehicle over junctions
@ MID_GNE_VEHICLE_TRANSFORM_ROUTEFLOW
transform vehicle to flow over route
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_JUNCTIONS
transform vehicle to trip over junctions
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_TAZS
transform vehicle to trip over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_TRIP
transform vehicle to trip
@ MID_GNE_VEHICLE_TRANSFORM_FLOW
transform vehicle to flow
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE
transform vehicle to vehicle over route
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_JUNCTIONS
transform vehicle to flow over jucntions
GUIViewObjectsHandler gViewObjectsHandler
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const long long int VEHPARS_ARRIVALSPEED_SET
const long long int VEHPARS_DEPARTPOSLAT_SET
const long long int VEHPARS_ARRIVALPOSLAT_SET
const long long int VEHPARS_PERSON_NUMBER_SET
const long long int VEHPARS_DEPARTSPEED_SET
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const long long int VEHPARS_ROUTE_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
const long long int VEHPARS_COLOR_SET
const long long int VEHPARS_VIA_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_ARRIVALLANE_SET
const long long int VEHPARS_DEPARTLANE_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_ARRIVALPOS_SET
const long long int VEHPARS_ARRIVALEDGE_SET
const long long int VEHPARS_CONTAINER_NUMBER_SET
const long long int VEHPARS_FROM_TAZ_SET
const long long int VEHPARS_VTYPE_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ GIVEN
The arrival position is given.
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const long long int VEHPARS_LINE_SET
const long long int VEHPARS_DEPARTEDGE_SET
const long long int VEHPARS_INSERTION_CHECKS_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ GNE_TAG_FLOW_TAZS
a flow between TAZs
@ SUMO_TAG_ROUTE
description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_TO_JUNCTION
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ SUMO_ATTR_MINGAP
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_LINE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_CENTER
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_DEPARTLANE
@ GNE_ATTR_PLAN_GEOMETRY_ENDPOS
person/container geometry end position
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_INSERTIONCHECKS
@ SUMO_ATTR_WIDTH
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition GLHelper.cpp:348
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
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:773
virtual double getAttributeDouble(SumoXMLAttr key) const =0
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
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
const std::string & getFilename() const
get filename in which save this AC
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
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 calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
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
std::string getFlowAttribute(const GNEDemandElement *flowElement, SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
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 enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
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
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
GNELane * getLaneByAllowedVClass(const SUMOVehicleClass vClass) const
return the first lane that allow a vehicle of type vClass (or the first lane, if none was found)
Definition GNEEdge.cpp:1502
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
static const double arrivalPositionDiameter
vehicle arrival position radius
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:174
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, const SumoXMLTag tag, const bool isPlan)
check if path element geometry must be drawn in the given lane
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void calculatePath(GNEPathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToFlowJunctions(GNEVehicle *originalVehicle)
transform to flow over junctions
static void transformToTripJunctions(GNEVehicle *originalVehicle)
transform to trip over junctions
static void transformToFlowTAZs(GNEVehicle *originalVehicle)
transform to flow over TAZs
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
static void transformToTripTAZs(GNEVehicle *originalVehicle)
transform to trip over TAZs
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
int getLaneIndex() const
get lane index
bool isLastSegment() const
check if segment is the last path's segment
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...
const RGBColor & getDefaultColorValue(SumoXMLAttr attr) const
get default bool value
bool vehicleJunctions() const
return true if tag correspond to a vehicle placed over from-to junctions
bool isCalibrator() const
return true if tag correspond to a calibrator (Only used to group all detectors in the XML)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
SumoXMLTag getXMLTag() const
default values
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
const std::string & getDefaultStringValue(SumoXMLAttr attr) const
default values
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:68
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
long onCmdTransform(FXObject *obj, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
std::map< FXObject *, SumoXMLTag > myRestrictedMenuCommands
selected menu commands
Definition GNEVehicle.h:95
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:41
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
GNEMoveElementVehicle * myMoveElementVehicle
move element demand
Definition GNEVehicle.h:315
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
void computePathElement()
compute pathElement
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition GNEVehicle.h:318
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
~GNEVehicle()
destructor
Position getAttributePosition(SumoXMLAttr key) const override
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAttributeEnabled(SumoXMLAttr key) const
void updateGeometry() override
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const override
const RGBColor & getColor() const
get color
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Parameterised * getParameters() override
get parameters associated with this vehicle
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
bool isValid(SumoXMLAttr key, const std::string &value) override
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this vehicle
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
Position getPositionInView() const
Returns position of demand element in view.
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
bool isACInspected(GNEAttributeCarrier *AC) const
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationWidthSettings widthSettings
width settings
bool checkDrawVehicle(Detail d, const bool selected) const
check if draw vehicle
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
bool showRouteIndex
Information whether the route index should be shown.
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition RGBColor.h:188
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
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.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
bool areInsertionChecksValid(const std::string &value) const
check if given insertion checks are valid
double arrivalPos
(optional) The position the vehicle shall arrive on
static int parseInsertionChecks(const std::string &value)
parses insertion checks
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string getInsertionChecks() const
get insertion checks in string format
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
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.
int insertionChecks
bitset of InsertionCheck
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
#define M_PI
Definition odrSpiral.cpp:45
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
bool showAllTrips() const
check if trips has to be drawn
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
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 drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor vehicleTripColor
color for vehicle trips
RGBColor selectedVehicleColor
vehicle selection color
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