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 return toString(color);
1369 } else {
1371 }
1374 return getDepartLane();
1375 } else {
1377 }
1380 return getDepartPos();
1381 } else {
1383 }
1386 return getDepartSpeed();
1387 } else {
1389 }
1392 return getArrivalLane();
1393 } else {
1395 }
1398 return getArrivalPos();
1399 } else {
1401 }
1404 return getArrivalSpeed();
1405 } else {
1407 }
1408 case SUMO_ATTR_LINE:
1409 if (wasSet(VEHPARS_LINE_SET)) {
1410 return line;
1411 } else {
1413 }
1416 return toString(personNumber);
1417 } else {
1419 }
1422 return toString(containerNumber);
1423 } else {
1425 }
1426 case SUMO_ATTR_REROUTE:
1428 return "true";
1429 } else {
1430 return "false";
1431 }
1434 return getDepartPosLat();
1435 } else {
1437 }
1440 return getArrivalPosLat();
1441 } else {
1443 }
1445 return getInsertionChecks();
1446 // Specific of vehicles over routes
1447 case SUMO_ATTR_ROUTE:
1448 if (getParentDemandElements().size() == 2) {
1449 return getRouteParent()->getID();
1450 } else {
1451 return "";
1452 }
1453 // Specific of from-to edge
1454 case SUMO_ATTR_FROM:
1455 return getParentEdges().front()->getID();
1456 case SUMO_ATTR_TO:
1457 return getParentEdges().back()->getID();
1458 case SUMO_ATTR_VIA:
1459 return toString(via);
1461 return getDepartEdge();
1463 return getArrivalEdge();
1464 // Specific of from-to junctions
1466 return getParentJunctions().front()->getID();
1468 return getParentJunctions().back()->getID();
1469 // Specific of from-to tazs
1470 case SUMO_ATTR_FROM_TAZ:
1471 return getParentAdditionals().front()->getID();
1472 case SUMO_ATTR_TO_TAZ:
1473 return getParentAdditionals().back()->getID();
1474 // other
1476 return toString(parametersSet);
1477 default:
1478 return getFlowAttribute(this, key);
1479 }
1480}
1481
1482
1483double
1485 switch (key) {
1488 return departLane;
1489 } else {
1490 return -1;
1491 }
1493 // only return departPos it if is given
1495 return departPos;
1496 } else {
1497 return 0;
1498 }
1501 return arrivalLane;
1502 } else {
1503 return -1;
1504 }
1506 // only return departPos it if is given
1508 return arrivalPos;
1509 } else {
1510 return -1;
1511 }
1512 case SUMO_ATTR_WIDTH:
1513 case SUMO_ATTR_LENGTH:
1514 case SUMO_ATTR_MINGAP:
1515 return getTypeParent()->getAttributeDouble(key);
1516 default:
1517 return getFlowAttributeDouble(key);
1518 }
1519}
1520
1521
1524 switch (key) {
1526 // check if this vehicle was defined over junctions
1527 if (getParentJunctions().size() > 0) {
1528 return getParentJunctions().front()->getPositionInView();
1529 } else {
1530 // get first path lane shape
1531 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1532 // check arrivalPosProcedure
1534 if (departPos < 0) {
1535 return laneShape.front();
1536 } else if (departPos > laneShape.length2D()) {
1537 return laneShape.back();
1538 } else {
1539 return laneShape.positionAtOffset2D(departPos);
1540 }
1541 } else {
1542 return laneShape.front();
1543 }
1544 }
1545 }
1547 // check if this vehicle was defined over junctions
1548 if (getParentJunctions().size() > 0) {
1549 return getParentJunctions().back()->getPositionInView();
1550 } else {
1551 // get last path lane shape
1552 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1553 // check arrivalPosProcedure
1555 if (arrivalPos < 0) {
1556 return laneShape.front();
1557 } else if (arrivalPos > laneShape.length2D()) {
1558 return laneShape.back();
1559 } else {
1560 return laneShape.positionAtOffset2D(arrivalPos);
1561 }
1562 } else {
1563 return laneShape.back();
1564 }
1565 }
1566 }
1567 default:
1568 return getCommonAttributePosition(key);
1569 }
1570}
1571
1572
1573void
1574GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1575 if (value == getAttribute(key)) {
1576 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1577 }
1578 switch (key) {
1579 case SUMO_ATTR_ID:
1580 case SUMO_ATTR_TYPE:
1581 case SUMO_ATTR_COLOR:
1588 case SUMO_ATTR_LINE:
1591 case SUMO_ATTR_REROUTE:
1595 // Specific of vehicles over routes
1596 case SUMO_ATTR_ROUTE:
1597 // Specific of from-to edges
1598 case SUMO_ATTR_FROM:
1599 case SUMO_ATTR_TO:
1600 case SUMO_ATTR_VIA:
1603 // Specific of from-to junctions
1606 // Specific of from-to taz
1607 case SUMO_ATTR_FROM_TAZ:
1608 case SUMO_ATTR_TO_TAZ:
1609 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1610 break;
1611 default:
1612 setFlowAttribute(this, key, value, undoList);
1613 break;
1614 }
1615}
1616
1617
1618bool
1619GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1620 // get ACs
1621 const auto ACs = myNet->getAttributeCarriers();
1622 // declare string error
1623 std::string error;
1624 switch (key) {
1625 case SUMO_ATTR_ID:
1627 case SUMO_ATTR_TYPE:
1628 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1629 case SUMO_ATTR_COLOR:
1630 return canParse<RGBColor>(value);
1631 case SUMO_ATTR_DEPARTLANE: {
1632 int dummyDepartLane;
1633 DepartLaneDefinition dummyDepartLaneProcedure;
1634 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1635 // if error is empty, check if depart lane is correct
1636 if (error.empty()) {
1637 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1638 return true;
1639 } else if (isTemplate()) {
1640 return true;
1641 } else if (getParentJunctions().size() > 0) {
1642 return (dummyDepartLane == 0);
1643 } else if (getParentAdditionals().size() > 0) {
1644 return (dummyDepartLane == 0);
1645 } else {
1646 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1647 }
1648 } else {
1649 return false;
1650 }
1651 }
1652 case SUMO_ATTR_DEPARTPOS: {
1653 double dummyDepartPos;
1654 DepartPosDefinition dummyDepartPosProcedure;
1655 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1656 // if error is empty, given value is valid
1657 return error.empty();
1658 }
1659 case SUMO_ATTR_DEPARTSPEED: {
1660 double dummyDepartSpeed;
1661 DepartSpeedDefinition dummyDepartSpeedProcedure;
1662 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1663 // if error is empty, check if depart speed is correct
1664 if (error.empty()) {
1665 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1666 return true;
1667 } else if (isTemplate()) {
1668 return true;
1669 } else {
1670 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1671 }
1672 } else {
1673 return false;
1674 }
1675 }
1676 case SUMO_ATTR_ARRIVALLANE: {
1677 int dummyArrivalLane;
1678 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1679 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1680 // if error is empty, given value is valid
1681 if (error.empty()) {
1682 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1683 return true;
1684 } else if (isTemplate()) {
1685 return true;
1686 } else if (getParentJunctions().size() > 0) {
1687 return (dummyArrivalLane == 0);
1688 } else if (getParentAdditionals().size() > 0) {
1689 return (dummyArrivalLane == 0);
1690 } else {
1691 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1692 }
1693 } else {
1694 return false;
1695 }
1696 }
1697 case SUMO_ATTR_ARRIVALPOS: {
1698 double dummyArrivalPos;
1699 ArrivalPosDefinition dummyArrivalPosProcedure;
1700 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1701 // if error is empty, given value is valid
1702 return error.empty();
1703 }
1705 double dummyArrivalSpeed;
1706 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1707 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1708 // if error is empty, given value is valid
1709 return error.empty();
1710 }
1711 case SUMO_ATTR_LINE:
1712 return true;
1714 return canParse<int>(value) && parse<int>(value) >= 0;
1716 return canParse<int>(value) && parse<int>(value) >= 0;
1717 case SUMO_ATTR_REROUTE:
1718 return true; // check
1720 double dummyDepartPosLat;
1721 DepartPosLatDefinition dummyDepartPosLatProcedure;
1722 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1723 // if error is empty, given value is valid
1724 return error.empty();
1725 }
1727 double dummyArrivalPosLat;
1728 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1729 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1730 // if error is empty, given value is valid
1731 return error.empty();
1732 }
1734 return areInsertionChecksValid(value);
1735 // Specific of vehicles over routes
1736 case SUMO_ATTR_ROUTE:
1737 if (getParentDemandElements().size() == 2) {
1738 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::routes, value, false) != nullptr);
1739 } else {
1740 return true;
1741 }
1742 // Specific of from-to edges
1743 case SUMO_ATTR_FROM:
1744 case SUMO_ATTR_TO:
1745 return (ACs->retrieveEdge(value, false) != nullptr);
1747 case SUMO_ATTR_ARRIVALEDGE: {
1748 if (value.empty()) {
1749 return true;
1750 } else {
1751 RouteIndexDefinition dummyDef;
1752 int dummyIndex;
1753 SUMOVehicleParameter::parseRouteIndex(value, myTagProperty->getTagStr(), id, key, dummyIndex, dummyDef, error);
1754 if (error.empty()) {
1755 if (dummyDef != RouteIndexDefinition::GIVEN) {
1756 return true;
1757 } else if (isTemplate()) {
1758 return true;
1759 } else if (myTagProperty->vehicleRoute()) {
1760 // check parent route
1761 return (dummyIndex < (int)getRouteParent()->getParentEdges().size());
1762 } else if (getChildDemandElements().size() > 0) {
1763 // check embedded route
1764 return (dummyIndex < (int)getChildDemandElements().front()->getParentEdges().size());
1765 } else {
1766 return true;
1767 }
1768 } else {
1769 return false;
1770 }
1771 }
1772 }
1773 case SUMO_ATTR_VIA:
1774 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1775 // Specific of from-to junctions
1778 return (ACs->retrieveJunction(value, false) != nullptr);
1779 // Specific of from-to taz
1780 case SUMO_ATTR_FROM_TAZ:
1781 case SUMO_ATTR_TO_TAZ:
1782 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1783 default:
1784 return isValidFlowAttribute(this, key, value);
1785 }
1786}
1787
1788
1789void
1791 enableFlowAttribute(this, key, undoList);
1792}
1793
1794
1795void
1797 disableFlowAttribute(this, key, undoList);
1798}
1799
1800
1801bool
1805
1806
1807std::string
1809 return getTagStr();
1810}
1811
1812
1813std::string
1815 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1816 // special case for Trips and flow
1817 if (myTagProperty->vehicleEdges()) {
1818 // check if we're inspecting a Edge
1819 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1820 // check if edge correspond to a "from", "to" or "via" edge
1821 if (inspectedElements.isACInspected(getParentEdges().front())) {
1822 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1823 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1824 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1825 } else {
1826 // iterate over via
1827 for (const auto& viaEdgeID : via) {
1828 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1829 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1830 }
1831 }
1832 }
1833 }
1834 }
1835 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1836}
1837
1838
1840GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1841 // get net and undoList
1842 const auto net = originalVehicle->getNet();
1843 auto undoList = net->getViewNet()->getUndoList();
1844 // declare new route, vehicle and embedded route
1845 GNERoute* newRoute = nullptr;
1846 GNEVehicle* newVehicle = nullptr;
1847 GNERoute* newEmbeddedRoute = nullptr;
1848 // generate new vehicle ID
1849 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1850 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1851 // extract vehicle parameters and update ID
1852 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1853 newVehicleParameters.id = newVehicleID;
1854 // create vehicle using vehicleParameters
1855 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1856 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1857 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1858 originalVehicle->getFileBucket(),
1859 originalVehicle->getParentDemandElements().at(0), newRoute,
1860 newVehicleParameters);
1861 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1862 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1863 originalVehicle->getFileBucket(),
1864 originalVehicle->getParentDemandElements().at(0),
1865 newVehicleParameters);
1866 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1867 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1868 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1869 originalVehicle->getFileBucket(),
1870 originalVehicle->getParentDemandElements().at(0),
1871 originalVehicle->getParentEdges().front(),
1872 originalVehicle->getParentEdges().back(),
1873 newVehicleParameters);
1874 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1875 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1876 originalVehicle->getFileBucket(),
1877 originalVehicle->getParentDemandElements().at(0),
1878 originalVehicle->getParentJunctions().front(),
1879 originalVehicle->getParentJunctions().back(),
1880 newVehicleParameters);
1881 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1882 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1883 originalVehicle->getFileBucket(),
1884 originalVehicle->getParentDemandElements().at(0),
1885 originalVehicle->getParentAdditionals().front(),
1886 originalVehicle->getParentAdditionals().back(),
1887 newVehicleParameters);
1888 }
1889 // add new vehicle
1890 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1891 if (newRoute) {
1892 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1893 }
1894 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1895 if (newEmbeddedRoute) {
1896 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1897 }
1898 undoList->end();
1899 return newVehicle;
1900}
1901
1902// ===========================================================================
1903// protected
1904// ===========================================================================
1905
1908 // change color
1909 if (drawUsingSelectColor()) {
1911 } else {
1912 return getColorByScheme(s.vehicleColorer, this);
1913 }
1914}
1915
1916
1919 return *this;
1920}
1921
1922// ===========================================================================
1923// private
1924// ===========================================================================
1925
1926void
1927GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1928 // declare string error
1929 std::string error;
1930 // flag to upate stack label
1931 bool updateSpreadStackGeometry = false;
1932 switch (key) {
1933 case SUMO_ATTR_ID:
1934 // update microsimID
1935 setDemandElementID(value);
1936 // set manually vehicle ID (needed for saving)
1937 id = value;
1938 break;
1939 case SUMO_ATTR_TYPE:
1940 if (getID().size() > 0) {
1942 // set manually vtypeID (needed for saving)
1943 vtypeid = value;
1944 }
1945 break;
1946 case SUMO_ATTR_COLOR:
1947 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1948 color = parse<RGBColor>(value);
1949 // mark parameter as set
1951 } else {
1952 // set default value
1954 // unset parameter
1955 parametersSet &= ~VEHPARS_COLOR_SET;
1956 }
1957 break;
1959 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1961 // mark parameter as set
1963 } else {
1964 // set default value
1966 // unset parameter
1967 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1968 }
1969 break;
1971 if (value == toString(INVALID_DOUBLE)) {
1973 // mark parameter as set
1975 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1977 // mark parameter as set
1979 } else {
1980 // set default value
1982 // unset parameter
1983 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1984 }
1985 if (getID().size() > 0) {
1987 updateSpreadStackGeometry = true;
1988 }
1989 break;
1991 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1993 // mark parameter as set
1995 } else {
1996 // set default value
1998 // unset parameter
1999 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
2000 }
2001 break;
2003 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2005 // mark parameter as set
2007 } else {
2008 // set default value
2010 // unset parameter
2011 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2012 }
2013 break;
2015 if (value == toString(INVALID_DOUBLE)) {
2017 // mark parameter as set
2019 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2021 // mark parameter as set
2023 } else {
2024 // set default value
2026 // unset parameter
2027 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2028 }
2029 if (getID().size() > 0) {
2031 updateSpreadStackGeometry = true;
2032 }
2033 break;
2035 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2037 // mark parameter as set
2039 } else {
2040 // set default value
2042 // unset parameter
2043 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2044 }
2045 break;
2046 case SUMO_ATTR_LINE:
2047 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2048 line = value;
2049 // mark parameter as set
2051 } else {
2052 // set default value
2054 // unset parameter
2055 parametersSet &= ~VEHPARS_LINE_SET;
2056 }
2057 break;
2059 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2060 personNumber = parse<int>(value);
2061 // mark parameter as set
2063 } else {
2064 // set default value
2066 // unset parameter
2067 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2068 }
2069 break;
2071 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2072 containerNumber = parse<int>(value);
2073 // mark parameter as set
2075 } else {
2076 // set default value
2078 // unset parameter
2079 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2080 }
2081 break;
2082 case SUMO_ATTR_REROUTE:
2083 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2084 // mark parameter as set
2086 } else {
2087 // unset parameter
2088 parametersSet &= ~VEHPARS_ROUTE_SET;
2089 }
2090 break;
2092 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2094 // mark parameter as set
2096 } else {
2097 // set default value
2099 // unset parameter
2100 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2101 }
2102 break;
2104 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2106 // mark parameter as set
2108 } else {
2109 // set default value
2111 // unset parameter
2112 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2113 }
2115 break;
2117 if (value.empty() || (value == "all")) {
2118 // unset parameter
2119 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2120 } else {
2121 // mark parameter as set
2123 }
2125 break;
2126 // Specific of vehicles over routes
2127 case SUMO_ATTR_ROUTE:
2128 if (getParentDemandElements().size() == 2) {
2130 }
2132 updateSpreadStackGeometry = true;
2133 break;
2134 // Specific of from-to edges
2135 case SUMO_ATTR_FROM: {
2136 // change first edge
2138 // compute vehicle
2140 updateSpreadStackGeometry = true;
2141 break;
2142 }
2143 case SUMO_ATTR_TO: {
2144 // change last edge
2145 replaceLastParentEdge(value);
2146 // compute vehicle
2148 updateSpreadStackGeometry = true;
2149 break;
2150 }
2151 case SUMO_ATTR_VIA: {
2152 if (!value.empty()) {
2153 // set new via edges
2154 via = parse< std::vector<std::string> >(value);
2155 // mark parameter as set
2157 } else {
2158 // clear via
2159 via.clear();
2160 // unset parameter
2161 parametersSet &= ~VEHPARS_VIA_SET;
2162 }
2163 // compute vehicle
2165 updateSpreadStackGeometry = true;
2166 break;
2167 }
2168 case SUMO_ATTR_DEPARTEDGE: {
2169 // update depart edge
2170 if (value.empty()) {
2171 // unset parameter
2172 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2173 departEdge = -1;
2175 } else {
2176 // mark parameter as set
2179 }
2180 // compute vehicle
2181 if (getID().size() > 0) {
2183 updateSpreadStackGeometry = true;
2184 }
2185 break;
2186 }
2187 case SUMO_ATTR_ARRIVALEDGE: {
2188 // update arrival edge
2189 if (value.empty()) {
2190 // unset parameter
2191 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2192 arrivalEdge = -1;
2194 } else {
2195 // mark parameter as set
2198 }
2199 if (getID().size() > 0) {
2200 // compute vehicle
2202 updateSpreadStackGeometry = true;
2203 }
2204 break;
2205 }
2206 // Specific of from-to junctions
2208 // change first junction
2210 // compute vehicle
2212 updateSpreadStackGeometry = true;
2213 break;
2214 }
2215 case SUMO_ATTR_TO_JUNCTION: {
2216 // change last junction
2218 // compute vehicle
2220 updateSpreadStackGeometry = true;
2221 break;
2222 }
2223 // Specific of from-to TAZs
2224 case SUMO_ATTR_FROM_TAZ: {
2225 // change first additional
2227 // set taz manually
2228 fromTaz = value;
2229 // compute vehicle
2231 updateSpreadStackGeometry = true;
2232 break;
2233 }
2234 case SUMO_ATTR_TO_TAZ: {
2235 // change last additional
2237 // set taz manually
2238 toTaz = value;
2239 // compute vehicle
2241 updateSpreadStackGeometry = true;
2242 break;
2243 }
2244 default:
2245 setFlowAttribute(this, key, value);
2246 break;
2247 }
2248 // check if stack label has to be updated
2249 if (updateSpreadStackGeometry) {
2250 if (myTagProperty->vehicleEdges()) {
2251 getParentEdges().front()->updateVehicleStackLabels();
2252 getParentEdges().front()->updateVehicleSpreadGeometries();
2253 } else if (myTagProperty->vehicleRoute() && !getRouteParent()->getTagProperty()->isRouteDistribution()) {
2254 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2255 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2256 } else if (myTagProperty->vehicleRouteEmbedded()) {
2257 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2258 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2259 }
2260 }
2261}
2262
2263
2264void
2266 // toggle flow attributes
2267 toggleFlowAttribute(key, value);
2268}
2269
2270/****************************************************************************/
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 drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:773
virtual double getAttributeDouble(SumoXMLAttr key) const =0
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:1519
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
static const double arrivalPositionDiameter
vehicle arrival position radius
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
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)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition RGBColor.h:188
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
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