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-2026 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
27#include <netedit/GNENet.h>
28#include <netedit/GNESegment.h>
30#include <netedit/GNEUndoList.h>
37
38#include "GNEVehicle.h"
39#include "GNERoute.h"
40#include "GNERouteHandler.h"
41
42// ===========================================================================
43// FOX callback mapping
44// ===========================================================================
45
49
53
54// Object implementation
55FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
56FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
57
58// ===========================================================================
59// GNEVehicle::GNESingleVehiclePopupMenu
60// ===========================================================================
61
63 GUIGLObjectPopupMenu(app, parent, vehicle),
64 myVehicle(vehicle) {
65 // build common options
66 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
67 // route length
68 vehicle->buildMenuCommandRouteLength(this);
69 // add transform functions only in demand mode
70 if (myVehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
71 // add reverse
72 vehicle->buildMenuAddReverse(this);
73 // continue depending of type
74 if (myVehicle->getTagProperty()->vehicleJunctions()) {
75 // create menu pane for transform operations
76 FXMenuPane* transformOperation = new FXMenuPane(this);
77 this->insertMenuPaneChild(transformOperation);
78 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
79 // Create menu commands for all transform
80 GUIDesigns::buildFXMenuCommand(transformOperation,
81 TL("Trip (over junctions)"),
83 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_JUNCTIONS));
84 GUIDesigns::buildFXMenuCommand(transformOperation,
85 TL("Flow (over junctions)"),
87 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_JUNCTIONS));
88 } else if (myVehicle->getTagProperty()->vehicleTAZs()) {
89 // create menu pane for transform operations
90 FXMenuPane* transformOperation = new FXMenuPane(this);
91 this->insertMenuPaneChild(transformOperation);
92 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
93 // Create menu commands for all transform
94 GUIDesigns::buildFXMenuCommand(transformOperation,
95 TL("Trip (over TAZs)"),
97 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_TAZS));
98 GUIDesigns::buildFXMenuCommand(transformOperation,
99 TL("Flow (over TAZs)"),
101 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_TAZS));
102 } else {
103 // create menu pane for transform operations
104 FXMenuPane* transformOperation = new FXMenuPane(this);
105 this->insertMenuPaneChild(transformOperation);
106 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
107 // Create menu commands for all transform
108 GUIDesigns::buildFXMenuCommand(transformOperation,
109 TL("Vehicle"),
111 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_VEHICLE));
112 GUIDesigns::buildFXMenuCommand(transformOperation,
113 TL("Vehicle (embedded route)"),
115 (myVehicle->getTagProperty()->getTag() == GNE_TAG_VEHICLE_WITHROUTE));
116 GUIDesigns::buildFXMenuCommand(transformOperation,
117 TL("RouteFlow"),
119 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_ROUTE));
120 GUIDesigns::buildFXMenuCommand(transformOperation,
121 TL("RouteFlow (embedded route)"),
123 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_WITHROUTE));
124 GUIDesigns::buildFXMenuCommand(transformOperation,
125 TL("Trip"),
127 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_TRIP));
128 GUIDesigns::buildFXMenuCommand(transformOperation,
129 TL("Flow"),
131 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_FLOW));
132 }
133 }
134}
135
136
138
139
140long
142 switch (FXSELID(sel)) {
145 break;
148 break;
150 GNERouteHandler::transformToVehicle(myVehicle, false);
151 break;
154 break;
157 break;
160 break;
163 break;
166 break;
169 break;
172 break;
173 default:
174 break;
175 }
176 return 1;
177}
178
179// ===========================================================================
180// GNEVehicle::GNESelectedVehiclesPopupMenu
181// ===========================================================================
182
183GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
184 GUIGLObjectPopupMenu(app, parent, vehicle),
185 mySelectedVehicles(selectedVehicle),
186 myVehicleTag(vehicle->getTagProperty()->getTag()) {
187 // build common options
188 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
189 // route length
190 vehicle->buildMenuCommandRouteLength(this);
191 // add transform functions only in demand mode
193 // add reverse
194 vehicle->buildMenuAddReverse(this);
195 // continue depending of type
196 if (vehicle->getTagProperty()->vehicleJunctions()) {
197 // create menu pane for transform operations
198 FXMenuPane* transformOperation = new FXMenuPane(this);
199 this->insertMenuPaneChild(transformOperation);
200 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
201 // Create menu commands for restricted transforms
203 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
206 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
208 // create separator
209 new FXMenuSeparator(transformOperation);
210 // Create menu commands for all transform
211 GUIDesigns::buildFXMenuCommand(transformOperation,
212 TL("Trips (over junctions)"),
214 GUIDesigns::buildFXMenuCommand(transformOperation,
215 TL("Flows (over junctions)"),
217 } else if (vehicle->getTagProperty()->vehicleTAZs()) {
218 // create menu pane for transform operations
219 FXMenuPane* transformOperation = new FXMenuPane(this);
220 this->insertMenuPaneChild(transformOperation);
221 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
222 // Create menu commands for all transform
224 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
227 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
229 // create separator
230 new FXMenuSeparator(transformOperation);
231 // Create menu commands for all transform
232 GUIDesigns::buildFXMenuCommand(transformOperation,
233 TL("Trips (over TAZs)"),
235 GUIDesigns::buildFXMenuCommand(transformOperation,
236 TL("Flows (over TAZs)"),
238 } else {
239 // create menu pane for transform operations
240 FXMenuPane* transformOperation = new FXMenuPane(this);
241 this->insertMenuPaneChild(transformOperation);
242 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
243 // Create menu commands for all transform
245 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
248 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
251 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
254 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
257 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
260 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
262 // create separator
263 new FXMenuSeparator(transformOperation);
264 // Create menu commands for all transform
265 GUIDesigns::buildFXMenuCommand(transformOperation,
266 TL("Vehicles"),
268 GUIDesigns::buildFXMenuCommand(transformOperation,
269 TL("Vehicles (embedded route)"),
271 GUIDesigns::buildFXMenuCommand(transformOperation,
272 TL("RouteFlows"),
274 GUIDesigns::buildFXMenuCommand(transformOperation,
275 TL("RouteFlows (embedded route)"),
277 GUIDesigns::buildFXMenuCommand(transformOperation,
278 TL("Trips"),
280 GUIDesigns::buildFXMenuCommand(transformOperation,
281 TL("Flows"),
283 }
284 }
285}
286
287
289
290
291long
292GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
293 // iterate over all selected vehicles
294 for (const auto& vehicle : mySelectedVehicles) {
295 switch (FXSELID(sel)) {
297 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
298 if (myRestrictedMenuCommands.count(obj) > 0) {
299 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
301 }
302 } else {
304 }
305 }
306 break;
308 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
309 if (myRestrictedMenuCommands.count(obj) > 0) {
310 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
312 }
313 } else {
315 }
316 }
317 break;
319 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
320 if (myRestrictedMenuCommands.count(obj) > 0) {
321 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
323 }
324 } else {
326 }
327 }
328 break;
330 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
331 if (myRestrictedMenuCommands.count(obj) > 0) {
332 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
334 }
335 } else {
337 }
338 }
339 break;
341 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
342 if (myRestrictedMenuCommands.count(obj) > 0) {
343 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
345 }
346 } else {
348 }
349 }
350 break;
352 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
353 if (myRestrictedMenuCommands.count(obj) > 0) {
354 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
356 }
357 } else {
359 }
360 }
361 break;
363 if (vehicle->getTagProperty()->vehicleJunctions()) {
364 if (myRestrictedMenuCommands.count(obj) > 0) {
365 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
367 }
368 } else {
370 }
371 }
372 break;
374 if (vehicle->getTagProperty()->vehicleJunctions()) {
375 if (myRestrictedMenuCommands.count(obj) > 0) {
376 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
378 }
379 } else {
381 }
382 }
383 break;
385 if (vehicle->getTagProperty()->vehicleTAZs()) {
386 if (myRestrictedMenuCommands.count(obj) > 0) {
387 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
389 }
390 } else {
392 }
393 }
394 break;
396 if (vehicle->getTagProperty()->vehicleTAZs()) {
397 if (myRestrictedMenuCommands.count(obj) > 0) {
398 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
400 }
401 } else {
403 }
404 }
405 break;
406 default:
407 break;
408 }
409 }
410 return 1;
411}
412
413// ===========================================================================
414// member method definitions
415// ===========================================================================
416#ifdef _MSC_VER
417#pragma warning(push)
418#pragma warning(disable: 4355) // mask warning about "this" in initializers
419#endif
421 GNEDemandElement(net, tag),
423 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
425 // set end and vehPerHours as default flow values
428}
429
430
431GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
432 GNEDemandElement* vehicleType, GNEDemandElement* route) :
433 GNEDemandElement(vehicleID, net, tag, fileBucket),
435 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
436 SUMO_ATTR_POSITION, myPosOverView)) {
437 // set parents
438 setParents<GNEDemandElement*>({vehicleType, route});
439 // SUMOVehicleParameter ID has to be set manually
440 id = vehicleID;
441 // set manually vtypeID (needed for saving)
442 vtypeid = vehicleType->getID();
443}
444
445
447 GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
448 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
449 GNEDemandElementFlow(this, vehicleParameters),
450 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
451 SUMO_ATTR_POSITION, myPosOverView)) {
452 // set parents
453 setParents<GNEDemandElement*>({vehicleType, route});
454 // SUMOVehicleParameter ID has to be set manually
455 id = vehicleParameters.id;
456 // set manually vtypeID (needed for saving)
457 vtypeid = vehicleType->getID();
458}
459
460
462 const SUMOVehicleParameter& vehicleParameters) :
463 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
464 GNEDemandElementFlow(this, vehicleParameters),
465 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
466 SUMO_ATTR_POSITION, myPosOverView)) {
467 // set parents
468 setParent<GNEDemandElement*>(vehicleType);
469 // SUMOVehicleParameter ID has to be set manually
470 id = vehicleParameters.id;
471 // reset routeid
472 routeid.clear();
473 // set manually vtypeID (needed for saving)
474 vtypeid = vehicleType->getID();
475}
476
477
478GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
479 GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge) :
480 GNEDemandElement(vehicleID, net, tag, fileBucket),
482 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
483 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
484 SUMO_ATTR_POSITION, myPosOverView)) {
485 // set parents
486 setParents<GNEEdge*>({fromEdge, toEdge});
487 setParent<GNEDemandElement*>(vehicleType);
488}
489
490
492 GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters) :
493 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
494 GNEDemandElementFlow(this, vehicleParameters),
495 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
496 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
497 SUMO_ATTR_POSITION, myPosOverView)) {
498 // set parents
499 setParents<GNEEdge*>({fromEdge, toEdge});
500 setParent<GNEDemandElement*>(vehicleType);
501}
502
503
504GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
505 GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
506 GNEDemandElement(vehicleID, net, tag, fileBucket),
508 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
509 SUMO_ATTR_POSITION, myPosOverView)) {
510 // set parents
511 setParents<GNEJunction*>({fromJunction, toJunction});
512 setParent<GNEDemandElement*>(vehicleType);
513}
514
515
517 GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
518 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
519 GNEDemandElementFlow(this, vehicleParameters),
520 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
521 SUMO_ATTR_POSITION, myPosOverView)) {
522 // set parents
523 setParents<GNEJunction*>({fromJunction, toJunction});
524 setParent<GNEDemandElement*>(vehicleType);
525}
526
527
529 GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
530 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
531 GNEDemandElementFlow(this, vehicleParameters),
532 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
533 SUMO_ATTR_POSITION, myPosOverView)) {
534 // set parents
535 setParents<GNEAdditional*>({fromTAZ, toTAZ});
536 setParent<GNEDemandElement*>(vehicleType);
537 // mark taz parameters as set
540 fromTaz = fromTAZ->getID();
541 toTaz = toTAZ->getID();
542}
543#ifdef _MSC_VER
544#pragma warning(pop)
545#endif
546
547
549
550
555
556
559 return this;
560}
561
562
563const Parameterised*
565 return this;
566}
567
568
569void
571 // attribute VType must not be written if is DEFAULT_VTYPE_ID
573 // unset VType parameter
574 parametersSet &= ~VEHPARS_VTYPE_SET;
575 // write vehicle attributes (VType will not be written)
577 // set VType parameter again
579 } else {
580 // write vehicle attributes, including type/distribution
582 }
583 // write route
585 // write route
587 }
588 // write from, to and edge vias
590 // write manually from/to edges (it correspond to front and back parent edges)
591 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
592 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
593 // only write via if there isn't empty
594 if (via.size() > 0) {
595 device.writeAttr(SUMO_ATTR_VIA, via);
596 }
597 }
598 // write from and to junctions
600 // write manually from/to junctions (it correspond to front and back parent junctions)
603 }
604 // write parameters
605 writeParams(device);
606 // write route elements associated to this vehicle (except for calibrator FLows)
607 if ((getChildDemandElements().size() > 0) && !myTagProperty->isCalibrator()) {
608 if (getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
609 // write embedded route
610 getChildDemandElements().front()->writeDemandElement(device);
611 // write stops
612 for (const auto& demandElement : getChildDemandElements()) {
613 if (demandElement->getTagProperty()->isVehicleStop()) {
614 demandElement->writeDemandElement(device);
615 }
616 }
617 } else {
618 for (const auto& route : getChildDemandElements()) {
619 route->writeDemandElement(device);
620 }
621 }
622 }
623 // close vehicle tag
624 device.closeTag();
625}
626
627
630 // check conditions
631 if (myTagProperty->vehicleTAZs()) {
632 // vehicles and flows over tazs are always valid
633 return Problem::OK;
634 } else if (myTagProperty->vehicleEdges()) {
635 // check vehicles and flows paths
636 if (getParentEdges().front() == getParentEdges().back()) {
637 return Problem::OK;
638 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
639 return Problem::OK;
640 } else {
642 }
643 } else if (myTagProperty->vehicleJunctions()) {
644 // check vehicles and flows paths
645 if (getParentJunctions().front() == getParentJunctions().back()) {
646 return Problem::OK;
647 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
648 return Problem::OK;
649 } else {
651 }
652 } else if (myTagProperty->vehicleRoute()) {
653 // check if routeParent is a distribution
654 if (getRouteParent()->getTagProperty()->isRouteDistribution()) {
655 return Problem::OK;
656 } else {
657 // check if exist a valid path using route parent edges
659 return Problem::OK;
660 } else {
662 }
663 }
664 } else if (myTagProperty->vehicleRouteEmbedded()) {
665 // check if exist a valid path using route child edges
667 return Problem::OK;
668 } else {
670 }
671 } else {
673 }
674}
675
676
677std::string
679 // only trips or flows can have problems
681 // check if exist at least a connection between every edge
682 for (int i = 1; i < (int)getParentEdges().size(); i++) {
684 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
685 }
686 }
687 // if there are connections between all edges, then all is ok
688 return "";
689 } else if (myTagProperty->vehicleJunctions()) {
690 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
691 } else if (myTagProperty->vehicleRoute()) {
692 // get route parent edges
693 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
694 // check if exist at least a connection between every edge
695 for (int i = 1; i < (int)routeEdges.size(); i++) {
696 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
697 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
698 }
699 }
700 // if there are connections between all edges, then all is ok
701 return "";
702 } else if (myTagProperty->vehicleRouteEmbedded()) {
703 // get route parent edges
704 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
705 // check if exist at least a connection between every edge
706 for (int i = 1; i < (int)routeEdges.size(); i++) {
707 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
708 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
709 }
710 }
711 // if there are connections between all edges, then all is ok
712 return "";
713 } else {
714 return "";
715 }
716}
717
718
719void
723
724
727 return getParentDemandElements().front()->getVClass();
728}
729
730
731const RGBColor&
733 return color;
734}
735
736
737void
739 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
740 // remove vehicle from grid
742 // reset view position to 0
743 myPosOverView = Position(0, 0);
744 // continue depending if the routeDistribution have references
745 for (auto routeRef : getParentDemandElements().at(1)->getChildDemandElements()) {
746 if (routeRef->getTagProperty()->isDistributionReference()) {
747 myPosOverView = routeRef->getParentDemandElements().at(1)->getParentEdges().front()->getChildLanes().at(0)->getLaneShape().front();
748 break;
749 }
750 }
751 // update vehicle geometry
753 // add object in grid again
755 } else if (getParentJunctions().size() > 0) {
756 // calculate rotation between both junctions
757 const Position posA = getParentJunctions().front()->getPositionInView();
758 const Position posB = getParentJunctions().back()->getPositionInView();
759 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
760 // update Geometry
761 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
762 } else if (getParentAdditionals().size() > 0) {
763 // calculate rotation between both TAZs
764 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
765 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
766 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
767 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
768 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
769 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
770 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
771 // update Geometry
773 } else {
774 // get first path lane
775 const GNELane* firstPathLane = getFirstPathLane();
776 // check path lane
777 if (firstPathLane) {
778 // declare departPos
779 double posOverLane = 0;
781 posOverLane = departPos;
782 }
783 // update Geometry
784 myDemandElementGeometry.updateGeometry(firstPathLane->getLaneShape(), posOverLane, 0 /*myMovingLateralOffset*/);
785 // compute route embedded associated with this vehicle
786 for (const auto& demandElement : getChildDemandElements()) {
787 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
788 demandElement->computePathElement();
789 }
790 demandElement->updateGeometry();
791 }
792 }
793 }
794}
795
796
800 return myPosOverView;
801 } else {
802 return myDemandElementGeometry.getShape().front();
803 }
804}
805
806
807bool
809 // get edit modes
810 const auto& editModes = myNet->getViewNet()->getEditModes();
811 // check if we're editing a type
812 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
814 return true;
815 }
816 // check opened popup
817 if (myNet->getViewNet()->getPopup()) {
818 return myNet->getViewNet()->getPopup()->getGLObject() == this;
819 }
820 return false;
821}
822
823
827 // obtain all selected vehicles
828 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
829 std::vector<GNEVehicle*> selectedVehicles;
830 selectedVehicles.reserve(selectedDemandElements.size());
831 for (const auto& selectedDemandElement : selectedDemandElements) {
832 if (selectedDemandElement->getTagProperty()->isVehicle()) {
833 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
834 }
835 }
836 // return a GNESelectedVehiclesPopupMenu
837 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
838 } else {
839 // return a GNESingleVehiclePopupMenu
840 return new GNESingleVehiclePopupMenu(this, app, parent);
841 }
842}
843
844
845std::string
848 return getRouteParent()->getID();
849 } else if (myTagProperty->vehicleEdges()) {
850 return getParentEdges().front()->getID();
851 } else if (myTagProperty->vehicleJunctions()) {
852 return getParentJunctions().front()->getID();
853 } else if (myTagProperty->vehicleTAZs()) {
854 return getParentAdditionals().front()->getID();
855 } else {
856 throw ProcessError(TL("Invalid vehicle tag"));
857 }
858}
859
860
861double
865
866
869 Boundary vehicleBoundary;
870 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
871 vehicleBoundary.add(myPosOverView);
872 } else {
873 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
874 }
875 vehicleBoundary.grow(20);
876 return vehicleBoundary;
877}
878
879
880void
881GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
882 // geometry of this element cannot be splitted
883}
884
885
886void
888 // only drawn in super mode demand
892 // declare common attributes
894 const double exaggeration = getExaggeration(s);
895 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
896 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
897 // obtain Position an rotation (depending of draw spread vehicles)
898 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
899 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
900 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
901 // check that position is valid
902 if (vehiclePosition == Position::INVALID) {
903 return;
904 }
905 // get detail level
906 const auto d = s.getDetailLevel(exaggeration);
907 // draw geometry only if we'rent in drawForObjectUnderCursor mode
910 // push draw matrix
912 // Start with the drawing of the area translating matrix to origin
914 // translate to drawing position
915 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
916 glRotated(vehicleRotation, 0, 0, -1);
917 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
918 glTranslated(0, (-1) * length * exaggeration, 0);
919 // set lane color
921 double upscaleLength = exaggeration;
922 if ((exaggeration > 1) && (length > 5)) {
923 // reduce the length/width ratio because this is not useful at high zoom
924 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
925 }
926 glScaled(exaggeration, upscaleLength, 1);
927 // draw the vehicle depending of detail level
934 }
935 // check if min gap has to be drawn
936 if (s.drawMinGap) {
937 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
938 glColor3d(0., 1., 0.);
939 glBegin(GL_LINES);
940 glVertex2d(0., 0);
941 glVertex2d(0., minGap);
942 glVertex2d(-.5, minGap);
943 glVertex2d(.5, minGap);
944 glEnd();
945 }
946 // drawing name at GLO_MAX fails unless translating z
947 glTranslated(0, MIN2(length / 2, double(5)), -getType());
948 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
949 glRotated(-vehicleRotation, 0, 0, -1);
951 // draw line
952 if (s.vehicleName.show(this) && line != "") {
953 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
955 }
956 // pop draw matrix
958 // draw line between junctions if path isn't valid
959 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
960 drawJunctionLine(this);
961 }
962 // draw lock icon
963 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
964 // draw stack label
965 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
966 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
967 }
968 // draw flow label
969 if (myTagProperty->isFlow()) {
970 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
971 }
972 // draw dotted contour
974 }
975 // draw squared shape
976 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
977 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
978 }
979 }
980}
981
982
983void
985 // calculate path (only for flows and trips)
987 // calculate path
989 } else if (myTagProperty->vehicleEdges()) {
990 // save edges in wich this vehicle has to stop
991 std::vector<GNEEdge*> edgeStops;
992 // iterate over child demand elements
993 for (const auto& demandElement : getChildDemandElements()) {
994 // extract lanes
995 if (demandElement->getTagProperty()->isVehicleStop()) {
996 GNEEdge* edgeStop = nullptr;
997 if (demandElement->getParentAdditionals().size() > 0) {
998 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
999 } else {
1000 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
1001 }
1002 if (edgeStop) {
1003 // avoid double edge stops
1004 if (stops.empty()) {
1005 edgeStops.push_back(edgeStop);
1006 } else if (edgeStops.back() != edgeStop) {
1007 edgeStops.push_back(edgeStop);
1008 }
1009 }
1010 }
1011 }
1012 // declare edge vector
1013 std::vector<GNEEdge*> edgePath;
1014 // get first and last lanes
1015 const auto firstLane = getFirstPathLane();
1016 const auto lastLane = getLastPathLane();
1017 // check first and last lanes
1018 if (firstLane && lastLane) {
1019 // add first lane
1020 edgePath.push_back(firstLane->getParentEdge());
1021 // give more priority to stops instead via
1022 if (edgeStops.size() > 0) {
1023 // add stops only if they're accesibles
1024 for (const auto& edgeStop : edgeStops) {
1025 // check if exist a valid path that includes the last edge
1026 auto edgePathStop = edgePath;
1027 edgePathStop.push_back(edgeStop);
1028 edgePathStop.push_back(lastLane->getParentEdge());
1030 if (path.size() > 0) {
1031 edgePath.push_back(edgeStop);
1032 }
1033 }
1034 } else {
1035 // add via lanes
1036 for (const auto& edgeViaID : via) {
1037 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1038 if (edgeVia) {
1039 // check if exist a valid path that includes the last edge
1040 auto edgePathStop = edgePath;
1041 edgePathStop.push_back(edgeVia);
1042 edgePathStop.push_back(lastLane->getParentEdge());
1043 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1044 edgePath.push_back(edgeVia);
1045 }
1046 }
1047 }
1048 }
1049 // add last lane
1050 edgePath.push_back(lastLane->getParentEdge());
1051 // calculate path
1052 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1053 }
1054 }
1055 // update geometry
1057}
1058
1059
1060void
1061GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1062 // conditions for draw always in network mode
1063 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1066 // conditions for draw always in demand mode
1067 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1069 // conditions for draw if is selected
1070 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1072 // conditions for draw if is inspected
1073 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1075 // check drawing conditions
1076 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1078 // get detail level
1079 const auto d = s.getDetailLevel(1);
1080 // calculate width
1081 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1082 // calculate startPos
1083 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1084 // get endPos
1085 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1086 // declare path geometry
1087 GUIGeometry vehicleGeometry;
1088 // update pathGeometry depending of first and last segment
1089 if (segment->isFirstSegment() && segment->isLastSegment()) {
1090 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1091 geometryDepartPos,
1093 geometryEndPos,
1095 } else if (segment->isFirstSegment()) {
1096 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1097 geometryDepartPos,
1099 -1,
1101 } else if (segment->isLastSegment()) {
1102 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1103 -1,
1105 geometryEndPos,
1107 } else {
1108 vehicleGeometry = segment->getLane()->getLaneGeometry();
1109 }
1110 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1112 // obtain color
1114 // Add a draw matrix
1116 // Start with the drawing of the area translating matrix to origin
1117 glTranslated(0, 0, getType() + offsetFront);
1118 // Set color
1119 GLHelper::setColor(pathColor);
1120 // draw geometry
1121 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1122 // show index over every edge
1123 if (isInspected && s.showRouteIndex) {
1124 const double textSize = s.vehicleName.size / s.scale;
1125 std::string label = toString(segment->getLaneIndex());
1126 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
1127 GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
1128 }
1129 // Pop last matrix
1131 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1132 if (segment->getNextLane()) {
1133 // push draw matrix
1135 // Start with the drawing of the area translating matrix to origin
1137 // Set red color
1139 // get firstPosition (last position of current lane shape)
1140 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1141 // get lastPosition (first position of next lane shape)
1142 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1143 // draw box line
1144 GLHelper::drawBoxLine(arrivalPosition,
1145 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1146 firstPosition.distanceTo2D(arrivalPosition), .05);
1147 // pop draw matrix
1149 }
1150 // check if this is the last segment
1151 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1152 // get geometryEndPos
1153 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1154 // check if endPos can be drawn
1156 // push draw matrix
1158 // Start with the drawing of the area translating matrix to origin
1160 // translate to geometryEndPos
1161 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1162 // Set person plan color
1163 GLHelper::setColor(pathColor);
1164 // resolution of drawn circle depending of the zoom (To improve smoothness)
1166 // pop draw matrix
1168 }
1169 }
1170 // draw dotted contour
1171 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1172 }
1173 // calculate contour and draw dotted geometry
1174 if (segment->isFirstSegment() || segment->isLastSegment()) {
1175 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1176 0, segment, segment->getLane()->getParentEdge());
1177 } else {
1178 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1179 0, segment, segment->getLane()->getParentEdge());
1180 }
1181 // check if add this path element to redraw buffer
1182 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1184 }
1185 }
1186}
1187
1188
1189void
1190GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1191 // conditions for draw always in network mode
1192 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1195 // conditions for draw always in demand mode
1196 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1198 // conditions for draw if is selected
1199 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1201 // conditions for draw if is inspected
1202 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1204 // check drawing conditions
1205 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1207 // get detail level
1208 const auto d = s.getDetailLevel(1);
1209 // calculate width
1210 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1211 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1213 // Add a draw matrix
1215 // Start with the drawing of the area translating matrix to origin
1216 glTranslated(0, 0, getType() + offsetFront);
1217 // Set color of the base
1218 if (drawUsingSelectColor()) {
1220 } else {
1222 }
1223 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1224 if (segment->getPreviousLane() && segment->getNextLane()) {
1225 // draw lane2lane
1227 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1228 // draw line between center of junction and last lane shape
1229 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1230 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1231 // draw line between center of junction and first lane shape
1232 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1233 }
1234 // Pop last matrix
1236 // draw dotted contour
1237 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1238 }
1239 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1240 if (segment->getPreviousLane() && segment->getNextLane()) {
1241 // calculate contour and draw dotted geometry
1243 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1244 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1245 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1246 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1247 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1248 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1249 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1250 }
1251 // check if add this path element to redraw buffer
1252 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1254 }
1255 }
1256}
1257
1258
1259GNELane*
1261 // declare first edge
1262 GNEEdge* firstEdge = nullptr;
1263 // continue depending of tags
1264 if (myTagProperty->vehicleRoute()) {
1265 // check departEdge
1266 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1267 // use departEdge
1268 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1269 } else {
1270 // use first route edge
1271 firstEdge = getRouteParent()->getParentEdges().front();
1272 }
1273 } else if (myTagProperty->vehicleRouteEmbedded()) {
1274 // check if embedded route exist (due during loading embedded route doesn't exist)
1275 if (getChildDemandElements().empty()) {
1276 return nullptr;
1277 }
1278 // check departEdge
1279 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1280 // use depart edge
1281 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1282 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1283 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1284 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1285 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1286 } else {
1287 return nullptr;
1288 }
1289 } else if (getParentEdges().size() > 0) {
1290 // use first parent edge
1291 firstEdge = getParentEdges().front();
1292 } else {
1293 // defined over junctions
1294 return nullptr;
1295 }
1296 // get departLane index
1297 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1298 // check departLane index
1299 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getChildLanes().size())) {
1300 return firstEdge->getChildLanes().at(departLaneIndex);
1301 } else {
1302 // get first allowed VClass
1303 return firstEdge->getLaneByAllowedVClass(getVClass());
1304 }
1305}
1306
1307
1308GNELane*
1310 // declare last edge
1311 GNEEdge* lastEdge = nullptr;
1312 // continue depending of tags
1313 if (myTagProperty->vehicleRoute()) {
1314 // check arrivalEdge
1315 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1316 // use arrival edge
1317 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1318 } else {
1319 // use last route edge
1320 lastEdge = getRouteParent()->getParentEdges().back();
1321 }
1322 } else if (myTagProperty->vehicleRouteEmbedded()) {
1323 // check if embedded route exist (due during loading embedded route doesn't exist)
1324 if (getChildDemandElements().empty()) {
1325 return nullptr;
1326 }
1327 // check arrivalEdge
1328 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1329 // use arrival edge
1330 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1331 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1332 // use last route edge
1333 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1334 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1335 // use lane
1336 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1337 } else {
1338 return nullptr;
1339 }
1340 } else if (getParentEdges().size() > 0) {
1341 // use last parent edge
1342 lastEdge = getParentEdges().back();
1343 } else {
1344 // defined over junctions
1345 return nullptr;
1346 }
1347 // get arrivalLane index
1348 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1349 // check arrivalLane index
1350 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getChildLanes().size())) {
1351 return lastEdge->getChildLanes().at(arrivalLaneIndex);
1352 } else {
1353 // get last allowed VClass
1354 return lastEdge->getLaneByAllowedVClass(getVClass());
1355 }
1356}
1357
1358
1359std::string
1361 switch (key) {
1362 case SUMO_ATTR_ID:
1363 return getMicrosimID();
1364 case SUMO_ATTR_TYPE:
1365 return vtypeid;
1366 case SUMO_ATTR_COLOR:
1368 if (color.isRandom()) {
1369 return "random";
1370 } else {
1371 return toString(color);
1372 }
1373 } else {
1375 }
1378 return getDepartLane();
1379 } else {
1381 }
1384 return getDepartPos();
1385 } else {
1387 }
1390 return getDepartSpeed();
1391 } else {
1393 }
1396 return getArrivalLane();
1397 } else {
1399 }
1402 return getArrivalPos();
1403 } else {
1405 }
1408 return getArrivalSpeed();
1409 } else {
1411 }
1412 case SUMO_ATTR_LINE:
1413 if (wasSet(VEHPARS_LINE_SET)) {
1414 return line;
1415 } else {
1417 }
1420 return toString(personNumber);
1421 } else {
1423 }
1426 return toString(containerNumber);
1427 } else {
1429 }
1430 case SUMO_ATTR_REROUTE:
1432 return "true";
1433 } else {
1434 return "false";
1435 }
1438 return getDepartPosLat();
1439 } else {
1441 }
1444 return getArrivalPosLat();
1445 } else {
1447 }
1449 return getInsertionChecks();
1450 // Specific of vehicles over routes
1451 case SUMO_ATTR_ROUTE:
1452 if (getParentDemandElements().size() == 2) {
1453 return getRouteParent()->getID();
1454 } else {
1455 return "";
1456 }
1457 // Specific of from-to edge
1458 case SUMO_ATTR_FROM:
1459 return getParentEdges().front()->getID();
1460 case SUMO_ATTR_TO:
1461 return getParentEdges().back()->getID();
1462 case SUMO_ATTR_VIA:
1463 return toString(via);
1465 return getDepartEdge();
1467 return getArrivalEdge();
1468 // Specific of from-to junctions
1470 return getParentJunctions().front()->getID();
1472 return getParentJunctions().back()->getID();
1473 // Specific of from-to tazs
1474 case SUMO_ATTR_FROM_TAZ:
1475 return getParentAdditionals().front()->getID();
1476 case SUMO_ATTR_TO_TAZ:
1477 return getParentAdditionals().back()->getID();
1478 // other
1480 return toString(parametersSet);
1481 default:
1482 return getFlowAttribute(this, key);
1483 }
1484}
1485
1486
1487double
1489 switch (key) {
1492 return departLane;
1493 } else {
1494 return -1;
1495 }
1497 // only return departPos it if is given
1499 return departPos;
1500 } else {
1501 return 0;
1502 }
1505 return arrivalLane;
1506 } else {
1507 return -1;
1508 }
1510 // only return departPos it if is given
1512 return arrivalPos;
1513 } else {
1514 return -1;
1515 }
1516 case SUMO_ATTR_WIDTH:
1517 case SUMO_ATTR_LENGTH:
1518 case SUMO_ATTR_MINGAP:
1519 return getTypeParent()->getAttributeDouble(key);
1520 default:
1521 return getFlowAttributeDouble(key);
1522 }
1523}
1524
1525
1528 switch (key) {
1530 // check if this vehicle was defined over junctions
1531 if (getParentJunctions().size() > 0) {
1532 return getParentJunctions().front()->getPositionInView();
1533 } else {
1534 // get first path lane shape
1535 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1536 // check arrivalPosProcedure
1538 if (departPos < 0) {
1539 return laneShape.front();
1540 } else if (departPos > laneShape.length2D()) {
1541 return laneShape.back();
1542 } else {
1543 return laneShape.positionAtOffset2D(departPos);
1544 }
1545 } else {
1546 return laneShape.front();
1547 }
1548 }
1549 }
1551 // check if this vehicle was defined over junctions
1552 if (getParentJunctions().size() > 0) {
1553 return getParentJunctions().back()->getPositionInView();
1554 } else {
1555 // get last path lane shape
1556 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1557 // check arrivalPosProcedure
1559 if (arrivalPos < 0) {
1560 return laneShape.front();
1561 } else if (arrivalPos > laneShape.length2D()) {
1562 return laneShape.back();
1563 } else {
1564 return laneShape.positionAtOffset2D(arrivalPos);
1565 }
1566 } else {
1567 return laneShape.back();
1568 }
1569 }
1570 }
1571 default:
1572 return getCommonAttributePosition(key);
1573 }
1574}
1575
1576
1577void
1578GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1579 if (value == getAttribute(key)) {
1580 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1581 }
1582 switch (key) {
1583 case SUMO_ATTR_ID:
1584 case SUMO_ATTR_TYPE:
1585 case SUMO_ATTR_COLOR:
1592 case SUMO_ATTR_LINE:
1595 case SUMO_ATTR_REROUTE:
1599 // Specific of vehicles over routes
1600 case SUMO_ATTR_ROUTE:
1601 // Specific of from-to edges
1602 case SUMO_ATTR_FROM:
1603 case SUMO_ATTR_TO:
1604 case SUMO_ATTR_VIA:
1607 // Specific of from-to junctions
1610 // Specific of from-to taz
1611 case SUMO_ATTR_FROM_TAZ:
1612 case SUMO_ATTR_TO_TAZ:
1613 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1614 break;
1615 default:
1616 setFlowAttribute(this, key, value, undoList);
1617 break;
1618 }
1619}
1620
1621
1622bool
1623GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1624 // get ACs
1625 const auto ACs = myNet->getAttributeCarriers();
1626 // declare string error
1627 std::string error;
1628 switch (key) {
1629 case SUMO_ATTR_ID:
1631 case SUMO_ATTR_TYPE:
1632 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1633 case SUMO_ATTR_COLOR:
1634 return canParse<RGBColor>(value);
1635 case SUMO_ATTR_DEPARTLANE: {
1636 int dummyDepartLane;
1637 DepartLaneDefinition dummyDepartLaneProcedure;
1638 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1639 // if error is empty, check if depart lane is correct
1640 if (error.empty()) {
1641 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1642 return true;
1643 } else if (isTemplate()) {
1644 return true;
1645 } else if (getParentJunctions().size() > 0) {
1646 return (dummyDepartLane == 0);
1647 } else if (getParentAdditionals().size() > 0) {
1648 return (dummyDepartLane == 0);
1649 } else {
1650 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1651 }
1652 } else {
1653 return false;
1654 }
1655 }
1656 case SUMO_ATTR_DEPARTPOS: {
1657 double dummyDepartPos;
1658 DepartPosDefinition dummyDepartPosProcedure;
1659 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1660 // if error is empty, given value is valid
1661 return error.empty();
1662 }
1663 case SUMO_ATTR_DEPARTSPEED: {
1664 double dummyDepartSpeed;
1665 DepartSpeedDefinition dummyDepartSpeedProcedure;
1666 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1667 // if error is empty, check if depart speed is correct
1668 if (error.empty()) {
1669 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1670 return true;
1671 } else if (isTemplate()) {
1672 return true;
1673 } else {
1674 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1675 }
1676 } else {
1677 return false;
1678 }
1679 }
1680 case SUMO_ATTR_ARRIVALLANE: {
1681 int dummyArrivalLane;
1682 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1683 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1684 // if error is empty, given value is valid
1685 if (error.empty()) {
1686 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1687 return true;
1688 } else if (isTemplate()) {
1689 return true;
1690 } else if (getParentJunctions().size() > 0) {
1691 return (dummyArrivalLane == 0);
1692 } else if (getParentAdditionals().size() > 0) {
1693 return (dummyArrivalLane == 0);
1694 } else {
1695 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1696 }
1697 } else {
1698 return false;
1699 }
1700 }
1701 case SUMO_ATTR_ARRIVALPOS: {
1702 double dummyArrivalPos;
1703 ArrivalPosDefinition dummyArrivalPosProcedure;
1704 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1705 // if error is empty, given value is valid
1706 return error.empty();
1707 }
1709 double dummyArrivalSpeed;
1710 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1711 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1712 // if error is empty, given value is valid
1713 return error.empty();
1714 }
1715 case SUMO_ATTR_LINE:
1716 return true;
1718 return canParse<int>(value) && parse<int>(value) >= 0;
1720 return canParse<int>(value) && parse<int>(value) >= 0;
1721 case SUMO_ATTR_REROUTE:
1722 return true; // check
1724 double dummyDepartPosLat;
1725 DepartPosLatDefinition dummyDepartPosLatProcedure;
1726 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1727 // if error is empty, given value is valid
1728 return error.empty();
1729 }
1731 double dummyArrivalPosLat;
1732 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1733 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1734 // if error is empty, given value is valid
1735 return error.empty();
1736 }
1738 return areInsertionChecksValid(value);
1739 // Specific of vehicles over routes
1740 case SUMO_ATTR_ROUTE:
1741 if (getParentDemandElements().size() == 2) {
1742 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::routes, value, false) != nullptr);
1743 } else {
1744 return true;
1745 }
1746 // Specific of from-to edges
1747 case SUMO_ATTR_FROM:
1748 case SUMO_ATTR_TO:
1749 return (ACs->retrieveEdge(value, false) != nullptr);
1751 case SUMO_ATTR_ARRIVALEDGE: {
1752 if (value.empty()) {
1753 return true;
1754 } else {
1755 RouteIndexDefinition dummyDef;
1756 int dummyIndex;
1757 SUMOVehicleParameter::parseRouteIndex(value, myTagProperty->getTagStr(), id, key, dummyIndex, dummyDef, error);
1758 if (error.empty()) {
1759 if (dummyDef != RouteIndexDefinition::GIVEN) {
1760 return true;
1761 } else if (isTemplate()) {
1762 return true;
1763 } else if (myTagProperty->vehicleRoute()) {
1764 // check parent route
1765 return (dummyIndex < (int)getRouteParent()->getParentEdges().size());
1766 } else if (getChildDemandElements().size() > 0) {
1767 // check embedded route
1768 return (dummyIndex < (int)getChildDemandElements().front()->getParentEdges().size());
1769 } else {
1770 return true;
1771 }
1772 } else {
1773 return false;
1774 }
1775 }
1776 }
1777 case SUMO_ATTR_VIA:
1778 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1779 // Specific of from-to junctions
1782 return (ACs->retrieveJunction(value, false) != nullptr);
1783 // Specific of from-to taz
1784 case SUMO_ATTR_FROM_TAZ:
1785 case SUMO_ATTR_TO_TAZ:
1786 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1787 default:
1788 return isValidFlowAttribute(this, key, value);
1789 }
1790}
1791
1792
1793void
1795 enableFlowAttribute(this, key, undoList);
1796}
1797
1798
1799void
1801 disableFlowAttribute(this, key, undoList);
1802}
1803
1804
1805bool
1809
1810
1811std::string
1813 return getTagStr();
1814}
1815
1816
1817std::string
1819 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1820 // special case for Trips and flow
1821 if (myTagProperty->vehicleEdges()) {
1822 // check if we're inspecting a Edge
1823 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1824 // check if edge correspond to a "from", "to" or "via" edge
1825 if (inspectedElements.isACInspected(getParentEdges().front())) {
1826 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1827 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1828 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1829 } else {
1830 // iterate over via
1831 for (const auto& viaEdgeID : via) {
1832 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1833 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1834 }
1835 }
1836 }
1837 }
1838 }
1839 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1840}
1841
1842
1844GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1845 // get net and undoList
1846 const auto net = originalVehicle->getNet();
1847 auto undoList = net->getViewNet()->getUndoList();
1848 // declare new route, vehicle and embedded route
1849 GNERoute* newRoute = nullptr;
1850 GNEVehicle* newVehicle = nullptr;
1851 GNERoute* newEmbeddedRoute = nullptr;
1852 // generate new vehicle ID
1853 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1854 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1855 // extract vehicle parameters and update ID
1856 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1857 newVehicleParameters.id = newVehicleID;
1858 // create vehicle using vehicleParameters
1859 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1860 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1861 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1862 originalVehicle->getFileBucket(),
1863 originalVehicle->getParentDemandElements().at(0), newRoute,
1864 newVehicleParameters);
1865 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1866 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1867 originalVehicle->getFileBucket(),
1868 originalVehicle->getParentDemandElements().at(0),
1869 newVehicleParameters);
1870 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1871 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1872 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1873 originalVehicle->getFileBucket(),
1874 originalVehicle->getParentDemandElements().at(0),
1875 originalVehicle->getParentEdges().front(),
1876 originalVehicle->getParentEdges().back(),
1877 newVehicleParameters);
1878 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1879 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1880 originalVehicle->getFileBucket(),
1881 originalVehicle->getParentDemandElements().at(0),
1882 originalVehicle->getParentJunctions().front(),
1883 originalVehicle->getParentJunctions().back(),
1884 newVehicleParameters);
1885 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1886 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1887 originalVehicle->getFileBucket(),
1888 originalVehicle->getParentDemandElements().at(0),
1889 originalVehicle->getParentAdditionals().front(),
1890 originalVehicle->getParentAdditionals().back(),
1891 newVehicleParameters);
1892 }
1893 // add new vehicle
1894 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1895 if (newRoute) {
1896 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1897 }
1898 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1899 if (newEmbeddedRoute) {
1900 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1901 }
1902 undoList->end();
1903 return newVehicle;
1904}
1905
1906// ===========================================================================
1907// protected
1908// ===========================================================================
1909
1912 // change color
1913 if (drawUsingSelectColor()) {
1915 } else {
1916 return getColorByScheme(s.vehicleColorer, this);
1917 }
1918}
1919
1920
1923 return *this;
1924}
1925
1926// ===========================================================================
1927// private
1928// ===========================================================================
1929
1930void
1931GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1932 // declare string error
1933 std::string error;
1934 // flag to upate stack label
1935 bool updateSpreadStackGeometry = false;
1936 switch (key) {
1937 case SUMO_ATTR_ID:
1938 // update microsimID
1939 setDemandElementID(value);
1940 // set manually vehicle ID (needed for saving)
1941 id = value;
1942 break;
1943 case SUMO_ATTR_TYPE:
1944 if (getID().size() > 0) {
1946 // set manually vtypeID (needed for saving)
1947 vtypeid = value;
1948 }
1949 break;
1950 case SUMO_ATTR_COLOR:
1951 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1952 color = parse<RGBColor>(value);
1953 // mark parameter as set
1955 } else {
1956 // set default value
1958 // unset parameter
1959 parametersSet &= ~VEHPARS_COLOR_SET;
1960 }
1961 break;
1963 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1965 // mark parameter as set
1967 } else {
1968 // set default value
1970 // unset parameter
1971 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1972 }
1973 break;
1975 if (value == toString(INVALID_DOUBLE)) {
1977 // mark parameter as set
1979 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1981 // mark parameter as set
1983 } else {
1984 // set default value
1986 // unset parameter
1987 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1988 }
1989 if (getID().size() > 0) {
1991 updateSpreadStackGeometry = true;
1992 }
1993 break;
1995 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1997 // mark parameter as set
1999 } else {
2000 // set default value
2002 // unset parameter
2003 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
2004 }
2005 break;
2007 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2009 // mark parameter as set
2011 } else {
2012 // set default value
2014 // unset parameter
2015 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2016 }
2017 break;
2019 if (value == toString(INVALID_DOUBLE)) {
2021 // mark parameter as set
2023 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2025 // mark parameter as set
2027 } else {
2028 // set default value
2030 // unset parameter
2031 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2032 }
2033 if (getID().size() > 0) {
2035 updateSpreadStackGeometry = true;
2036 }
2037 break;
2039 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2041 // mark parameter as set
2043 } else {
2044 // set default value
2046 // unset parameter
2047 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2048 }
2049 break;
2050 case SUMO_ATTR_LINE:
2051 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2052 line = value;
2053 // mark parameter as set
2055 } else {
2056 // set default value
2058 // unset parameter
2059 parametersSet &= ~VEHPARS_LINE_SET;
2060 }
2061 break;
2063 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2064 personNumber = parse<int>(value);
2065 // mark parameter as set
2067 } else {
2068 // set default value
2070 // unset parameter
2071 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2072 }
2073 break;
2075 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2076 containerNumber = parse<int>(value);
2077 // mark parameter as set
2079 } else {
2080 // set default value
2082 // unset parameter
2083 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2084 }
2085 break;
2086 case SUMO_ATTR_REROUTE:
2087 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2088 // mark parameter as set
2090 } else {
2091 // unset parameter
2092 parametersSet &= ~VEHPARS_ROUTE_SET;
2093 }
2094 break;
2096 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2098 // mark parameter as set
2100 } else {
2101 // set default value
2103 // unset parameter
2104 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2105 }
2106 break;
2108 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2110 // mark parameter as set
2112 } else {
2113 // set default value
2115 // unset parameter
2116 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2117 }
2119 break;
2121 if (value.empty() || (value == "all")) {
2122 // unset parameter
2123 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2124 } else {
2125 // mark parameter as set
2127 }
2129 break;
2130 // Specific of vehicles over routes
2131 case SUMO_ATTR_ROUTE:
2132 if (getParentDemandElements().size() == 2) {
2134 }
2136 updateSpreadStackGeometry = true;
2137 break;
2138 // Specific of from-to edges
2139 case SUMO_ATTR_FROM: {
2140 // change first edge
2142 // compute vehicle
2144 updateSpreadStackGeometry = true;
2145 break;
2146 }
2147 case SUMO_ATTR_TO: {
2148 // change last edge
2149 replaceLastParentEdge(value);
2150 // compute vehicle
2152 updateSpreadStackGeometry = true;
2153 break;
2154 }
2155 case SUMO_ATTR_VIA: {
2156 if (!value.empty()) {
2157 // set new via edges
2158 via = parse< std::vector<std::string> >(value);
2159 // mark parameter as set
2161 } else {
2162 // clear via
2163 via.clear();
2164 // unset parameter
2165 parametersSet &= ~VEHPARS_VIA_SET;
2166 }
2167 // compute vehicle
2169 updateSpreadStackGeometry = true;
2170 break;
2171 }
2172 case SUMO_ATTR_DEPARTEDGE: {
2173 // update depart edge
2174 if (value.empty()) {
2175 // unset parameter
2176 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2177 departEdge = -1;
2179 } else {
2180 // mark parameter as set
2183 }
2184 // compute vehicle
2185 if (getID().size() > 0) {
2187 updateSpreadStackGeometry = true;
2188 }
2189 break;
2190 }
2191 case SUMO_ATTR_ARRIVALEDGE: {
2192 // update arrival edge
2193 if (value.empty()) {
2194 // unset parameter
2195 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2196 arrivalEdge = -1;
2198 } else {
2199 // mark parameter as set
2202 }
2203 if (getID().size() > 0) {
2204 // compute vehicle
2206 updateSpreadStackGeometry = true;
2207 }
2208 break;
2209 }
2210 // Specific of from-to junctions
2212 // change first junction
2214 // compute vehicle
2216 updateSpreadStackGeometry = true;
2217 break;
2218 }
2219 case SUMO_ATTR_TO_JUNCTION: {
2220 // change last junction
2222 // compute vehicle
2224 updateSpreadStackGeometry = true;
2225 break;
2226 }
2227 // Specific of from-to TAZs
2228 case SUMO_ATTR_FROM_TAZ: {
2229 // change first additional
2231 // set taz manually
2232 fromTaz = value;
2233 // compute vehicle
2235 updateSpreadStackGeometry = true;
2236 break;
2237 }
2238 case SUMO_ATTR_TO_TAZ: {
2239 // change last additional
2241 // set taz manually
2242 toTaz = value;
2243 // compute vehicle
2245 updateSpreadStackGeometry = true;
2246 break;
2247 }
2248 default:
2249 setFlowAttribute(this, key, value);
2250 break;
2251 }
2252 // check if stack label has to be updated
2253 if (updateSpreadStackGeometry) {
2254 if (myTagProperty->vehicleEdges()) {
2255 getParentEdges().front()->updateVehicleStackLabels();
2256 getParentEdges().front()->updateVehicleSpreadGeometries();
2257 } else if (myTagProperty->vehicleRoute() && !getRouteParent()->getTagProperty()->isRouteDistribution()) {
2258 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2259 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2260 } else if (myTagProperty->vehicleRouteEmbedded()) {
2261 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2262 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2263 }
2264 }
2265}
2266
2267
2268void
2270 // toggle flow attributes
2271 toggleFlowAttribute(key, value);
2272}
2273
2274/****************************************************************************/
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
RouteIndexDefinition
Possible ways to choose the departure and arrival edge.
@ 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_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
@ 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
@ SUMO_ATTR_POSITION
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:49
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 drawFilledCircleDetailed(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 drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
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
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string getID() const override
get ID (all Attribute Carriers have one)
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 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 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 replaceDemandElementParent(const std::vector< SumoXMLTag > tags, const std::string &value, const int parentIndex)
replace demand element parent
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
FileBucket * getFileBucket() const override
get reference to fileBucket in which save this AC
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:1526
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:667
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
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1449
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1459
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:198
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
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:69
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:97
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:42
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
Problem isDemandElementValid() const override
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
GNEMoveElementVehicle * myMoveElementVehicle
move element vehicle over lanes
Definition GNEVehicle.h:325
std::string getParentName() const override
Returns the name of the parent object.
std::string getDemandElementProblem() const override
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
void writeDemandElement(OutputDevice &device) const override
write demand element element into a xml file
void computePathElement() override
compute pathElement
std::string getAttribute(SumoXMLAttr key) const override
inherited from GNEAttributeCarrier
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition GNEVehicle.h:334
GNELane * getLastPathLane() const override
get last path lane
Position getPositionInView() const override
Returns position of demand element in view.
~GNEVehicle()
destructor
Position getAttributePosition(SumoXMLAttr key) const override
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList) override
void updateGeometry() override
update pre-computed geometry information
GNEMoveElementView * myMoveElementView
move element over view
Definition GNEVehicle.h:328
double getAttributeDouble(SumoXMLAttr key) const override
GNELane * getFirstPathLane() const override
get first path lane
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
std::string getHierarchyName() const override
get Hierarchy Name (Used in AC Hierarchy)
void fixDemandElementProblem() override
fix demand element problem (by default throw an exception, has to be reimplemented in children)
const RGBColor & getColor() const override
get color
Position myPosOverView
position over view
Definition GNEVehicle.h:331
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over junction.
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList) override
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList) override
split geometry
Parameterised * getParameters() override
get parameters associated with this vehicle
std::string getPopUpID() const override
get PopPup ID (Used in AC Hierarchy)
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
bool isValid(SumoXMLAttr key, const std::string &value) override
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this vehicle
void toggleAttribute(SumoXMLAttr key, const bool value) override
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
SUMOVehicleClass getVClass() const override
obtain VClass related with this demand element
bool isAttributeEnabled(SumoXMLAttr key) const override
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const override
Draws partial object over lane.
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
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
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 const std::vector< SumoXMLTag > routes
route namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
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.
bool isRandom() const
check if color is random
Definition RGBColor.cpp:130
static const RGBColor RED
named colors
Definition RGBColor.h:198
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
std::string getDepartEdge() const
obtain depart edge parameter in string format
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 getArrivalEdge() const
obtain arrival edge parameter 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 parseRouteIndex(const std::string &val, const std::string &element, const std::string &id, const SumoXMLAttr attr, int &edgeIndex, RouteIndexDefinition &rid, std::string &error)
Validates a given departEdge or arrivalEdge value.
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.
#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