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
22
29#include <netedit/GNENet.h>
30#include <netedit/GNESegment.h>
32#include <netedit/GNEUndoList.h>
39
40#include "GNEVehicle.h"
41#include "GNERoute.h"
42#include "GNERouteHandler.h"
43
44// ===========================================================================
45// FOX callback mapping
46// ===========================================================================
47
51
55
56// Object implementation
57FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
58FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
59
60// ===========================================================================
61// GNEVehicle::GNESingleVehiclePopupMenu
62// ===========================================================================
63
65 GUIGLObjectPopupMenu(app, parent, vehicle),
66 myVehicle(vehicle) {
67 // build common options
68 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected(), vehicle->myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand(), true);
69 // route length
70 vehicle->buildMenuCommandRouteLength(this);
71 // add transform functions only in demand mode
72 if (myVehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
73 // add reverse
74 vehicle->buildMenuAddReverse(this);
75 // continue depending of type
76 if (myVehicle->getTagProperty()->vehicleJunctions()) {
77 // create menu pane for transform operations
78 FXMenuPane* transformOperation = new FXMenuPane(this);
79 this->insertMenuPaneChild(transformOperation);
80 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
81 // Create menu commands for all transform
82 GUIDesigns::buildFXMenuCommand(transformOperation,
83 TL("Trip (over junctions)"),
85 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_JUNCTIONS));
86 GUIDesigns::buildFXMenuCommand(transformOperation,
87 TL("Flow (over junctions)"),
89 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_JUNCTIONS));
90 } else if (myVehicle->getTagProperty()->vehicleTAZs()) {
91 // create menu pane for transform operations
92 FXMenuPane* transformOperation = new FXMenuPane(this);
93 this->insertMenuPaneChild(transformOperation);
94 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
95 // Create menu commands for all transform
96 GUIDesigns::buildFXMenuCommand(transformOperation,
97 TL("Trip (over TAZs)"),
99 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_TAZS));
100 GUIDesigns::buildFXMenuCommand(transformOperation,
101 TL("Flow (over TAZs)"),
103 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_TAZS));
104 } else {
105 // create menu pane for transform operations
106 FXMenuPane* transformOperation = new FXMenuPane(this);
107 this->insertMenuPaneChild(transformOperation);
108 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
109 // Create menu commands for all transform
110 GUIDesigns::buildFXMenuCommand(transformOperation,
111 TL("Vehicle"),
113 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_VEHICLE));
114 GUIDesigns::buildFXMenuCommand(transformOperation,
115 TL("Vehicle (embedded route)"),
117 (myVehicle->getTagProperty()->getTag() == GNE_TAG_VEHICLE_WITHROUTE));
118 GUIDesigns::buildFXMenuCommand(transformOperation,
119 TL("RouteFlow"),
121 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_ROUTE));
122 GUIDesigns::buildFXMenuCommand(transformOperation,
123 TL("RouteFlow (embedded route)"),
125 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_WITHROUTE));
126 GUIDesigns::buildFXMenuCommand(transformOperation,
127 TL("Trip"),
129 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_TRIP));
130 GUIDesigns::buildFXMenuCommand(transformOperation,
131 TL("Flow"),
133 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_FLOW));
134 }
135 }
136}
137
138
140
141
142long
144 switch (FXSELID(sel)) {
147 break;
150 break;
152 GNERouteHandler::transformToVehicle(myVehicle, false);
153 break;
156 break;
159 break;
162 break;
165 break;
168 break;
171 break;
174 break;
175 default:
176 break;
177 }
178 return 1;
179}
180
181// ===========================================================================
182// GNEVehicle::GNESelectedVehiclesPopupMenu
183// ===========================================================================
184
185GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
186 GUIGLObjectPopupMenu(app, parent, vehicle),
187 mySelectedVehicles(selectedVehicle),
188 myVehicleTag(vehicle->getTagProperty()->getTag()) {
189 // build common options
190 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected(), vehicle->myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand(), true);
191 // route length
192 vehicle->buildMenuCommandRouteLength(this);
193 // add transform functions only in demand mode
195 // add reverse
196 vehicle->buildMenuAddReverse(this);
197 // continue depending of type
198 if (vehicle->getTagProperty()->vehicleJunctions()) {
199 // create menu pane for transform operations
200 FXMenuPane* transformOperation = new FXMenuPane(this);
201 this->insertMenuPaneChild(transformOperation);
202 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
203 // Create menu commands for restricted transforms
205 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
208 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
210 // create separator
211 new FXMenuSeparator(transformOperation);
212 // Create menu commands for all transform
213 GUIDesigns::buildFXMenuCommand(transformOperation,
214 TL("Trips (over junctions)"),
216 GUIDesigns::buildFXMenuCommand(transformOperation,
217 TL("Flows (over junctions)"),
219 } else if (vehicle->getTagProperty()->vehicleTAZs()) {
220 // create menu pane for transform operations
221 FXMenuPane* transformOperation = new FXMenuPane(this);
222 this->insertMenuPaneChild(transformOperation);
223 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
224 // Create menu commands for all transform
226 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
229 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
231 // create separator
232 new FXMenuSeparator(transformOperation);
233 // Create menu commands for all transform
234 GUIDesigns::buildFXMenuCommand(transformOperation,
235 TL("Trips (over TAZs)"),
237 GUIDesigns::buildFXMenuCommand(transformOperation,
238 TL("Flows (over TAZs)"),
240 } else {
241 // create menu pane for transform operations
242 FXMenuPane* transformOperation = new FXMenuPane(this);
243 this->insertMenuPaneChild(transformOperation);
244 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
245 // Create menu commands for all transform
247 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
250 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
253 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
256 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
259 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
262 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
264 // create separator
265 new FXMenuSeparator(transformOperation);
266 // Create menu commands for all transform
267 GUIDesigns::buildFXMenuCommand(transformOperation,
268 TL("Vehicles"),
270 GUIDesigns::buildFXMenuCommand(transformOperation,
271 TL("Vehicles (embedded route)"),
273 GUIDesigns::buildFXMenuCommand(transformOperation,
274 TL("RouteFlows"),
276 GUIDesigns::buildFXMenuCommand(transformOperation,
277 TL("RouteFlows (embedded route)"),
279 GUIDesigns::buildFXMenuCommand(transformOperation,
280 TL("Trips"),
282 GUIDesigns::buildFXMenuCommand(transformOperation,
283 TL("Flows"),
285 }
286 }
287}
288
289
291
292
293long
294GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
295 // iterate over all selected vehicles
296 for (const auto& vehicle : mySelectedVehicles) {
297 switch (FXSELID(sel)) {
299 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
300 if (myRestrictedMenuCommands.count(obj) > 0) {
301 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
303 }
304 } else {
306 }
307 }
308 break;
310 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
311 if (myRestrictedMenuCommands.count(obj) > 0) {
312 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
314 }
315 } else {
317 }
318 }
319 break;
321 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
322 if (myRestrictedMenuCommands.count(obj) > 0) {
323 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
325 }
326 } else {
328 }
329 }
330 break;
332 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
333 if (myRestrictedMenuCommands.count(obj) > 0) {
334 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
336 }
337 } else {
339 }
340 }
341 break;
343 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
344 if (myRestrictedMenuCommands.count(obj) > 0) {
345 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
347 }
348 } else {
350 }
351 }
352 break;
354 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
355 if (myRestrictedMenuCommands.count(obj) > 0) {
356 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
358 }
359 } else {
361 }
362 }
363 break;
365 if (vehicle->getTagProperty()->vehicleJunctions()) {
366 if (myRestrictedMenuCommands.count(obj) > 0) {
367 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
369 }
370 } else {
372 }
373 }
374 break;
376 if (vehicle->getTagProperty()->vehicleJunctions()) {
377 if (myRestrictedMenuCommands.count(obj) > 0) {
378 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
380 }
381 } else {
383 }
384 }
385 break;
387 if (vehicle->getTagProperty()->vehicleTAZs()) {
388 if (myRestrictedMenuCommands.count(obj) > 0) {
389 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
391 }
392 } else {
394 }
395 }
396 break;
398 if (vehicle->getTagProperty()->vehicleTAZs()) {
399 if (myRestrictedMenuCommands.count(obj) > 0) {
400 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
402 }
403 } else {
405 }
406 }
407 break;
408 default:
409 break;
410 }
411 }
412 return 1;
413}
414
415// ===========================================================================
416// member method definitions
417// ===========================================================================
418#ifdef _MSC_VER
419#pragma warning(push)
420#pragma warning(disable: 4355) // mask warning about "this" in initializers
421#endif
423 GNEDemandElement(net, tag),
425 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
427 // set end and vehPerHours as default flow values
430}
431
432
433GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
434 GNEDemandElement* vehicleType, GNEDemandElement* route) :
435 GNEDemandElement(vehicleID, net, tag, fileBucket),
437 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
438 SUMO_ATTR_POSITION, myPosOverView)) {
439 // set parents
440 setParents<GNEDemandElement*>({vehicleType, route});
441 // SUMOVehicleParameter ID has to be set manually
442 id = vehicleID;
443 // set manually vtypeID (needed for saving)
444 vtypeid = vehicleType->getID();
445}
446
447
449 GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
450 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
451 GNEDemandElementFlow(this, vehicleParameters),
452 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
453 SUMO_ATTR_POSITION, myPosOverView)) {
454 // set parents
455 setParents<GNEDemandElement*>({vehicleType, route});
456 // SUMOVehicleParameter ID has to be set manually
457 id = vehicleParameters.id;
458 // set manually vtypeID (needed for saving)
459 vtypeid = vehicleType->getID();
460}
461
462
464 const SUMOVehicleParameter& vehicleParameters) :
465 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
466 GNEDemandElementFlow(this, vehicleParameters),
467 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
468 SUMO_ATTR_POSITION, myPosOverView)) {
469 // set parents
470 setParent<GNEDemandElement*>(vehicleType);
471 // SUMOVehicleParameter ID has to be set manually
472 id = vehicleParameters.id;
473 // reset routeid
474 routeid.clear();
475 // set manually vtypeID (needed for saving)
476 vtypeid = vehicleType->getID();
477}
478
479
480GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
481 GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge) :
482 GNEDemandElement(vehicleID, net, tag, fileBucket),
484 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
485 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
486 SUMO_ATTR_POSITION, myPosOverView)) {
487 // set parents
488 setParents<GNEEdge*>({fromEdge, toEdge});
489 setParent<GNEDemandElement*>(vehicleType);
490}
491
492
494 GNEEdge* fromEdge, GNEEdge* toEdge, const SUMOVehicleParameter& vehicleParameters) :
495 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
496 GNEDemandElementFlow(this, vehicleParameters),
497 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
498 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
499 SUMO_ATTR_POSITION, myPosOverView)) {
500 // set parents
501 setParents<GNEEdge*>({fromEdge, toEdge});
502 setParent<GNEDemandElement*>(vehicleType);
503}
504
505
506GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, FileBucket* fileBucket,
507 GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
508 GNEDemandElement(vehicleID, net, tag, fileBucket),
510 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
511 SUMO_ATTR_POSITION, myPosOverView)) {
512 // set parents
513 setParents<GNEJunction*>({fromJunction, toJunction});
514 setParent<GNEDemandElement*>(vehicleType);
515}
516
517
519 GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
520 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
521 GNEDemandElementFlow(this, vehicleParameters),
522 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
523 SUMO_ATTR_POSITION, myPosOverView)) {
524 // set parents
525 setParents<GNEJunction*>({fromJunction, toJunction});
526 setParent<GNEDemandElement*>(vehicleType);
527}
528
529
531 GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
532 GNEDemandElement(vehicleParameters.id, net, tag, fileBucket),
533 GNEDemandElementFlow(this, vehicleParameters),
534 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
535 SUMO_ATTR_POSITION, myPosOverView)) {
536 // set parents
537 setParents<GNEAdditional*>({fromTAZ, toTAZ});
538 setParent<GNEDemandElement*>(vehicleType);
539 // mark taz parameters as set
542 fromTaz = fromTAZ->getID();
543 toTaz = toTAZ->getID();
544}
545#ifdef _MSC_VER
546#pragma warning(pop)
547#endif
548
549
551
552
557
558
561 return this;
562}
563
564
565const Parameterised*
567 return this;
568}
569
570
571void
573 // attribute VType must not be written if is DEFAULT_VTYPE_ID
575 // unset VType parameter
576 parametersSet &= ~VEHPARS_VTYPE_SET;
577 // write vehicle attributes (VType will not be written)
579 // set VType parameter again
581 } else {
582 // write vehicle attributes, including type/distribution
584 }
585 // write route
587 // write route
589 }
590 // write from, to and edge vias
592 // write manually from/to edges (it correspond to front and back parent edges)
593 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
594 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
595 // only write via if there isn't empty
596 if (via.size() > 0) {
597 device.writeAttr(SUMO_ATTR_VIA, via);
598 }
599 }
600 // write from and to junctions
602 // write manually from/to junctions (it correspond to front and back parent junctions)
605 }
606 // write parameters
607 XMLHelpers::writeParams(device, *this);
608 // write route elements associated to this vehicle (except for calibrator FLows)
609 if ((getChildDemandElements().size() > 0) && !myTagProperty->isCalibrator()) {
610 if (getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
611 // write embedded route
612 getChildDemandElements().front()->writeDemandElement(device);
613 // write stops
614 for (const auto& demandElement : getChildDemandElements()) {
615 if (demandElement->getTagProperty()->isVehicleStop()) {
616 demandElement->writeDemandElement(device);
617 }
618 }
619 } else {
620 for (const auto& route : getChildDemandElements()) {
621 route->writeDemandElement(device);
622 }
623 }
624 }
625 // close vehicle tag
626 device.closeTag();
627}
628
629
632 // check conditions
633 if (myTagProperty->vehicleTAZs()) {
634 // vehicles and flows over tazs are always valid
635 return Problem::OK;
636 } else if (myTagProperty->vehicleEdges()) {
637 // check vehicles and flows paths
638 if (getParentEdges().front() == getParentEdges().back()) {
639 return Problem::OK;
640 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
641 return Problem::OK;
642 } else {
644 }
645 } else if (myTagProperty->vehicleJunctions()) {
646 // check vehicles and flows paths
647 if (getParentJunctions().front() == getParentJunctions().back()) {
648 return Problem::OK;
649 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
650 return Problem::OK;
651 } else {
653 }
654 } else if (myTagProperty->vehicleRoute()) {
655 // check if routeParent is a distribution
656 if (getRouteParent()->getTagProperty()->isRouteDistribution()) {
657 return Problem::OK;
658 } else {
659 // check if exist a valid path using route parent edges
661 return Problem::OK;
662 } else {
664 }
665 }
666 } else if (myTagProperty->vehicleRouteEmbedded()) {
667 // check if exist a valid path using route child edges
669 return Problem::OK;
670 } else {
672 }
673 } else {
675 }
676}
677
678
679std::string
681 // only trips or flows can have problems
683 // check if exist at least a connection between every edge
684 for (int i = 1; i < (int)getParentEdges().size(); i++) {
686 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
687 }
688 }
689 // if there are connections between all edges, then all is ok
690 return "";
691 } else if (myTagProperty->vehicleJunctions()) {
692 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
693 } else if (myTagProperty->vehicleRoute()) {
694 // get route parent edges
695 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
696 // check if exist at least a connection between every edge
697 for (int i = 1; i < (int)routeEdges.size(); i++) {
698 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
699 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
700 }
701 }
702 // if there are connections between all edges, then all is ok
703 return "";
704 } else if (myTagProperty->vehicleRouteEmbedded()) {
705 // get route parent edges
706 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
707 // check if exist at least a connection between every edge
708 for (int i = 1; i < (int)routeEdges.size(); i++) {
709 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
710 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
711 }
712 }
713 // if there are connections between all edges, then all is ok
714 return "";
715 } else {
716 return "";
717 }
718}
719
720
721void
725
726
729 return getParentDemandElements().front()->getVClass();
730}
731
732
733const RGBColor&
735 return color;
736}
737
738
739void
741 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
742 // remove vehicle from grid
744 // reset view position to 0
745 myPosOverView = Position(0, 0);
746 // continue depending if the routeDistribution have references
747 for (auto routeRef : getParentDemandElements().at(1)->getChildDemandElements()) {
748 if (routeRef->getTagProperty()->isDistributionReference()) {
749 myPosOverView = routeRef->getParentDemandElements().at(1)->getParentEdges().front()->getChildLanes().at(0)->getLaneShape().front();
750 break;
751 }
752 }
753 // update vehicle geometry
755 // add object in grid again
757 } else if (getParentJunctions().size() > 0) {
758 // calculate rotation between both junctions
759 const Position posA = getParentJunctions().front()->getPositionInView();
760 const Position posB = getParentJunctions().back()->getPositionInView();
761 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
762 // update Geometry
763 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
764 } else if (getParentAdditionals().size() > 0) {
765 // calculate rotation between both TAZs
766 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
767 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
768 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
769 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
770 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
771 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
772 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
773 // update Geometry
775 } else {
776 // get first path lane
777 const GNELane* firstPathLane = getFirstPathLane();
778 // check path lane
779 if (firstPathLane) {
780 // declare departPos
781 double posOverLane = 0;
783 posOverLane = departPos;
784 }
785 // update Geometry
786 myDemandElementGeometry.updateGeometry(firstPathLane->getLaneShape(), posOverLane, 0 /*myMovingLateralOffset*/);
787 // compute route embedded associated with this vehicle
788 for (const auto& demandElement : getChildDemandElements()) {
789 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
790 demandElement->computePathElement();
791 }
792 demandElement->updateGeometry();
793 }
794 }
795 }
796}
797
798
802 return myPosOverView;
803 } else {
804 return myDemandElementGeometry.getShape().front();
805 }
806}
807
808
809bool
811 // get edit modes
812 const auto& editModes = myNet->getViewNet()->getEditModes();
813 // check if we're editing a type
814 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
816 return true;
817 }
818 // check opened popup
819 if (myNet->getViewNet()->getPopup()) {
820 return myNet->getViewNet()->getPopup()->getGLObject() == this;
821 }
822 return false;
823}
824
825
829 // obtain all selected vehicles
830 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
831 std::vector<GNEVehicle*> selectedVehicles;
832 selectedVehicles.reserve(selectedDemandElements.size());
833 for (const auto& selectedDemandElement : selectedDemandElements) {
834 if (selectedDemandElement->getTagProperty()->isVehicle()) {
835 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
836 }
837 }
838 // return a GNESelectedVehiclesPopupMenu
839 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
840 } else {
841 // return a GNESingleVehiclePopupMenu
842 return new GNESingleVehiclePopupMenu(this, app, parent);
843 }
844}
845
846
847std::string
850 return getRouteParent()->getID();
851 } else if (myTagProperty->vehicleEdges()) {
852 return getParentEdges().front()->getID();
853 } else if (myTagProperty->vehicleJunctions()) {
854 return getParentJunctions().front()->getID();
855 } else if (myTagProperty->vehicleTAZs()) {
856 return getParentAdditionals().front()->getID();
857 } else {
858 throw ProcessError(TL("Invalid vehicle tag"));
859 }
860}
861
862
863double
867
868
871 Boundary vehicleBoundary;
872 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
873 vehicleBoundary.add(myPosOverView);
874 } else {
875 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
876 }
877 vehicleBoundary.grow(20);
878 return vehicleBoundary;
879}
880
881
882void
883GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
884 // geometry of this element cannot be splitted
885}
886
887
888void
890 // only drawn in super mode demand
894 // declare common attributes
896 const double exaggeration = getExaggeration(s);
897 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
898 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
899 // obtain Position an rotation (depending of draw spread vehicles)
900 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
901 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
902 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
903 // check that position is valid
904 if (vehiclePosition == Position::INVALID) {
905 return;
906 }
907 // get detail level
908 const auto d = s.getDetailLevel(exaggeration);
909 // draw geometry only if we'rent in drawForObjectUnderCursor mode
912 // push draw matrix
914 // Start with the drawing of the area translating matrix to origin
916 // translate to drawing position
917 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
918 glRotated(vehicleRotation, 0, 0, -1);
919 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
920 glTranslated(0, (-1) * length * exaggeration, 0);
921 // set lane color
923 double upscaleLength = exaggeration;
924 if ((exaggeration > 1) && (length > 5)) {
925 // reduce the length/width ratio because this is not useful at high zoom
926 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
927 }
928 glScaled(exaggeration, upscaleLength, 1);
929 // draw the vehicle depending of detail level
936 }
937 // check if min gap has to be drawn
938 if (s.drawMinGap) {
939 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
940 glColor3d(0., 1., 0.);
941 glBegin(GL_LINES);
942 glVertex2d(0., 0);
943 glVertex2d(0., minGap);
944 glVertex2d(-.5, minGap);
945 glVertex2d(.5, minGap);
946 glEnd();
947 }
948 // drawing name at GLO_MAX fails unless translating z
949 glTranslated(0, MIN2(length / 2, double(5)), -getType());
950 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
951 glRotated(-vehicleRotation, 0, 0, -1);
953 // draw line
954 if (s.vehicleName.show(this) && line != "") {
955 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
957 }
958 // pop draw matrix
960 // draw line between junctions if path isn't valid
961 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
962 drawJunctionLine(this);
963 }
964 // draw lock icon
965 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
966 // draw stack label
967 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
968 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
969 }
970 // draw flow label
971 if (myTagProperty->isFlow()) {
972 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
973 }
974 // draw dotted contour
976 }
977 // draw squared shape
978 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
979 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
980 }
981 }
982}
983
984
985void
987 // calculate path (only for flows and trips)
989 // calculate path
991 } else if (myTagProperty->vehicleEdges()) {
992 // save edges in which this vehicle has to stop
993 std::vector<GNEEdge*> edgeStops;
994 // iterate over child demand elements
995 for (const auto& demandElement : getChildDemandElements()) {
996 // extract lanes
997 if (demandElement->getTagProperty()->isVehicleStop()) {
998 GNEEdge* edgeStop = nullptr;
999 if (demandElement->getParentAdditionals().size() > 0) {
1000 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
1001 } else {
1002 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
1003 }
1004 if (edgeStop) {
1005 // avoid double edge stops
1006 if (stops.empty()) {
1007 edgeStops.push_back(edgeStop);
1008 } else if (edgeStops.back() != edgeStop) {
1009 edgeStops.push_back(edgeStop);
1010 }
1011 }
1012 }
1013 }
1014 // declare edge vector
1015 std::vector<GNEEdge*> edgePath;
1016 // get first and last lanes
1017 const auto firstLane = getFirstPathLane();
1018 const auto lastLane = getLastPathLane();
1019 // check first and last lanes
1020 if (firstLane && lastLane) {
1021 // add first lane
1022 edgePath.push_back(firstLane->getParentEdge());
1023 // give more priority to stops instead via
1024 if (edgeStops.size() > 0) {
1025 // add stops only if they're accesibles
1026 for (const auto& edgeStop : edgeStops) {
1027 // check if exist a valid path that includes the last edge
1028 auto edgePathStop = edgePath;
1029 edgePathStop.push_back(edgeStop);
1030 edgePathStop.push_back(lastLane->getParentEdge());
1032 if (path.size() > 0) {
1033 edgePath.push_back(edgeStop);
1034 }
1035 }
1036 } else {
1037 // add via lanes
1038 for (const auto& edgeViaID : via) {
1039 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1040 if (edgeVia) {
1041 // check if exist a valid path that includes the last edge
1042 auto edgePathStop = edgePath;
1043 edgePathStop.push_back(edgeVia);
1044 edgePathStop.push_back(lastLane->getParentEdge());
1045 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1046 edgePath.push_back(edgeVia);
1047 }
1048 }
1049 }
1050 }
1051 // add last lane
1052 edgePath.push_back(lastLane->getParentEdge());
1053 // calculate path
1054 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1055 }
1056 }
1057 // update geometry
1059}
1060
1061
1062void
1063GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1064 // conditions for draw always in network mode
1065 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1068 // conditions for draw always in demand mode
1069 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1071 // conditions for draw if is selected
1072 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1074 // conditions for draw if is inspected
1075 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1077 // check drawing conditions
1078 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1080 // get detail level
1081 const auto d = s.getDetailLevel(1);
1082 // calculate width
1083 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1084 // calculate startPos
1085 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1086 // get endPos
1087 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1088 // declare path geometry
1089 GUIGeometry vehicleGeometry;
1090 // update pathGeometry depending of first and last segment
1091 if (segment->isFirstSegment() && segment->isLastSegment()) {
1092 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1093 geometryDepartPos,
1095 geometryEndPos,
1097 } else if (segment->isFirstSegment()) {
1098 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1099 geometryDepartPos,
1101 -1,
1103 } else if (segment->isLastSegment()) {
1104 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1105 -1,
1107 geometryEndPos,
1109 } else {
1110 vehicleGeometry = segment->getLane()->getLaneGeometry();
1111 }
1112 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1114 // obtain color
1116 // Add a draw matrix
1118 // Start with the drawing of the area translating matrix to origin
1119 glTranslated(0, 0, getType() + offsetFront);
1120 // Set color
1121 GLHelper::setColor(pathColor);
1122 // draw geometry
1123 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1124 // show index over every edge
1125 if (isInspected && s.showRouteIndex) {
1126 const double textSize = s.vehicleName.size / s.scale;
1127 std::string label = toString(segment->getLaneIndex());
1128 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
1129 GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
1130 }
1131 // Pop last matrix
1133 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1134 if (segment->getNextLane()) {
1135 // push draw matrix
1137 // Start with the drawing of the area translating matrix to origin
1139 // Set red color
1141 // get firstPosition (last position of current lane shape)
1142 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1143 // get lastPosition (first position of next lane shape)
1144 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1145 // draw box line
1146 GLHelper::drawBoxLine(arrivalPosition,
1147 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1148 firstPosition.distanceTo2D(arrivalPosition), .05);
1149 // pop draw matrix
1151 }
1152 // check if this is the last segment
1153 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1154 // get geometryEndPos
1155 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1156 // check if endPos can be drawn
1158 // push draw matrix
1160 // Start with the drawing of the area translating matrix to origin
1162 // translate to geometryEndPos
1163 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1164 // Set person plan color
1165 GLHelper::setColor(pathColor);
1166 // resolution of drawn circle depending of the zoom (To improve smoothness)
1168 // pop draw matrix
1170 }
1171 }
1172 // draw dotted contour
1173 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1174 }
1175 // calculate contour and draw dotted geometry
1176 if (segment->isFirstSegment() || segment->isLastSegment()) {
1177 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1178 0, segment, segment->getLane()->getParentEdge());
1179 } else {
1180 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1181 0, segment, segment->getLane()->getParentEdge());
1182 }
1183 // check if add this path element to redraw buffer
1184 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1186 }
1187 }
1188}
1189
1190
1191void
1192GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1193 // conditions for draw always in network mode
1194 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1197 // conditions for draw always in demand mode
1198 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1200 // conditions for draw if is selected
1201 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1203 // conditions for draw if is inspected
1204 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1206 // check drawing conditions
1207 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1209 // get detail level
1210 const auto d = s.getDetailLevel(1);
1211 // calculate width
1212 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1213 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1215 // Add a draw matrix
1217 // Start with the drawing of the area translating matrix to origin
1218 glTranslated(0, 0, getType() + offsetFront);
1219 // Set color of the base
1220 if (drawUsingSelectColor()) {
1222 } else {
1224 }
1225 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1226 if (segment->getPreviousLane() && segment->getNextLane()) {
1227 // draw lane2lane
1229 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1230 // draw line between center of junction and last lane shape
1231 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1232 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1233 // draw line between center of junction and first lane shape
1234 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1235 }
1236 // Pop last matrix
1238 // draw dotted contour
1239 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1240 }
1241 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1242 if (segment->getPreviousLane() && segment->getNextLane()) {
1243 // calculate contour and draw dotted geometry
1245 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1246 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1247 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1248 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1249 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1250 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1251 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1252 }
1253 // check if add this path element to redraw buffer
1254 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1256 }
1257 }
1258}
1259
1260
1261GNELane*
1263 // declare first edge
1264 GNEEdge* firstEdge = nullptr;
1265 // continue depending of tags
1266 if (myTagProperty->vehicleRoute()) {
1267 // check departEdge
1268 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1269 // use departEdge
1270 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1271 } else {
1272 // use first route edge
1273 firstEdge = getRouteParent()->getParentEdges().front();
1274 }
1275 } else if (myTagProperty->vehicleRouteEmbedded()) {
1276 // check if embedded route exist (due during loading embedded route doesn't exist)
1277 if (getChildDemandElements().empty()) {
1278 return nullptr;
1279 }
1280 // check departEdge
1281 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1282 // use depart edge
1283 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1284 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1285 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1286 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1287 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1288 } else {
1289 return nullptr;
1290 }
1291 } else if (getParentEdges().size() > 0) {
1292 // use first parent edge
1293 firstEdge = getParentEdges().front();
1294 } else {
1295 // defined over junctions
1296 return nullptr;
1297 }
1298 // get departLane index
1299 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1300 // check departLane index
1301 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getChildLanes().size())) {
1302 return firstEdge->getChildLanes().at(departLaneIndex);
1303 } else {
1304 // get first allowed VClass
1305 return firstEdge->getLaneByAllowedVClass(getVClass());
1306 }
1307}
1308
1309
1310GNELane*
1312 // declare last edge
1313 GNEEdge* lastEdge = nullptr;
1314 // continue depending of tags
1315 if (myTagProperty->vehicleRoute()) {
1316 // check arrivalEdge
1317 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1318 // use arrival edge
1319 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1320 } else {
1321 // use last route edge
1322 lastEdge = getRouteParent()->getParentEdges().back();
1323 }
1324 } else if (myTagProperty->vehicleRouteEmbedded()) {
1325 // check if embedded route exist (due during loading embedded route doesn't exist)
1326 if (getChildDemandElements().empty()) {
1327 return nullptr;
1328 }
1329 // check arrivalEdge
1330 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1331 // use arrival edge
1332 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1333 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1334 // use last route edge
1335 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1336 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1337 // use lane
1338 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1339 } else {
1340 return nullptr;
1341 }
1342 } else if (getParentEdges().size() > 0) {
1343 // use last parent edge
1344 lastEdge = getParentEdges().back();
1345 } else {
1346 // defined over junctions
1347 return nullptr;
1348 }
1349 // get arrivalLane index
1350 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1351 // check arrivalLane index
1352 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getChildLanes().size())) {
1353 return lastEdge->getChildLanes().at(arrivalLaneIndex);
1354 } else {
1355 // get last allowed VClass
1356 return lastEdge->getLaneByAllowedVClass(getVClass());
1357 }
1358}
1359
1360
1361std::string
1363 switch (key) {
1364 case SUMO_ATTR_ID:
1365 return getMicrosimID();
1366 case SUMO_ATTR_TYPE:
1367 return vtypeid;
1368 case SUMO_ATTR_COLOR:
1370 if (color.isRandom()) {
1371 return "random";
1372 } else {
1373 return toString(color);
1374 }
1375 } else {
1377 }
1380 return getDepartLane();
1381 } else {
1383 }
1386 return getDepartPos();
1387 } else {
1389 }
1392 return getDepartSpeed();
1393 } else {
1395 }
1398 return getArrivalLane();
1399 } else {
1401 }
1404 return getArrivalPos();
1405 } else {
1407 }
1410 return getArrivalSpeed();
1411 } else {
1413 }
1414 case SUMO_ATTR_LINE:
1415 if (wasSet(VEHPARS_LINE_SET)) {
1416 return line;
1417 } else {
1419 }
1422 return toString(personNumber);
1423 } else {
1425 }
1428 return toString(containerNumber);
1429 } else {
1431 }
1432 case SUMO_ATTR_REROUTE:
1434 return "true";
1435 } else {
1436 return "false";
1437 }
1440 return getDepartPosLat();
1441 } else {
1443 }
1446 return getArrivalPosLat();
1447 } else {
1449 }
1451 return getInsertionChecks();
1452 // Specific of vehicles over routes
1453 case SUMO_ATTR_ROUTE:
1454 if (getParentDemandElements().size() == 2) {
1455 return getRouteParent()->getID();
1456 } else {
1457 return "";
1458 }
1459 // Specific of from-to edge
1460 case SUMO_ATTR_FROM:
1461 return getParentEdges().front()->getID();
1462 case SUMO_ATTR_TO:
1463 return getParentEdges().back()->getID();
1464 case SUMO_ATTR_VIA:
1465 return toString(via);
1467 return getDepartEdge();
1469 return getArrivalEdge();
1470 // Specific of from-to junctions
1472 return getParentJunctions().front()->getID();
1474 return getParentJunctions().back()->getID();
1475 // Specific of from-to tazs
1476 case SUMO_ATTR_FROM_TAZ:
1477 return getParentAdditionals().front()->getID();
1478 case SUMO_ATTR_TO_TAZ:
1479 return getParentAdditionals().back()->getID();
1480 // other
1482 return toString(parametersSet);
1483 default:
1484 return getFlowAttribute(this, key);
1485 }
1486}
1487
1488
1489double
1491 switch (key) {
1494 return departLane;
1495 } else {
1496 return -1;
1497 }
1499 // only return departPos it if is given
1501 return departPos;
1502 } else {
1503 return 0;
1504 }
1507 return arrivalLane;
1508 } else {
1509 return -1;
1510 }
1512 // only return departPos it if is given
1514 return arrivalPos;
1515 } else {
1516 return -1;
1517 }
1518 case SUMO_ATTR_WIDTH:
1519 case SUMO_ATTR_LENGTH:
1520 case SUMO_ATTR_MINGAP:
1521 return getTypeParent()->getAttributeDouble(key);
1522 default:
1523 return getFlowAttributeDouble(key);
1524 }
1525}
1526
1527
1530 switch (key) {
1532 // check if this vehicle was defined over junctions
1533 if (getParentJunctions().size() > 0) {
1534 return getParentJunctions().front()->getPositionInView();
1535 } else {
1536 // get first path lane shape
1537 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1538 // check arrivalPosProcedure
1540 if (departPos < 0) {
1541 return laneShape.front();
1542 } else if (departPos > laneShape.length2D()) {
1543 return laneShape.back();
1544 } else {
1545 return laneShape.positionAtOffset2D(departPos);
1546 }
1547 } else {
1548 return laneShape.front();
1549 }
1550 }
1551 }
1553 // check if this vehicle was defined over junctions
1554 if (getParentJunctions().size() > 0) {
1555 return getParentJunctions().back()->getPositionInView();
1556 } else {
1557 // get last path lane shape
1558 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1559 // check arrivalPosProcedure
1561 if (arrivalPos < 0) {
1562 return laneShape.front();
1563 } else if (arrivalPos > laneShape.length2D()) {
1564 return laneShape.back();
1565 } else {
1566 return laneShape.positionAtOffset2D(arrivalPos);
1567 }
1568 } else {
1569 return laneShape.back();
1570 }
1571 }
1572 }
1573 default:
1574 return getCommonAttributePosition(key);
1575 }
1576}
1577
1578
1579void
1580GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1581 if (value == getAttribute(key)) {
1582 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1583 }
1584 switch (key) {
1585 case SUMO_ATTR_ID:
1586 case SUMO_ATTR_TYPE:
1587 case SUMO_ATTR_COLOR:
1594 case SUMO_ATTR_LINE:
1597 case SUMO_ATTR_REROUTE:
1601 // Specific of vehicles over routes
1602 case SUMO_ATTR_ROUTE:
1603 // Specific of from-to edges
1604 case SUMO_ATTR_FROM:
1605 case SUMO_ATTR_TO:
1606 case SUMO_ATTR_VIA:
1609 // Specific of from-to junctions
1612 // Specific of from-to taz
1613 case SUMO_ATTR_FROM_TAZ:
1614 case SUMO_ATTR_TO_TAZ:
1615 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1616 break;
1617 default:
1618 setFlowAttribute(this, key, value, undoList);
1619 break;
1620 }
1621}
1622
1623
1624bool
1625GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1626 // get ACs
1627 const auto ACs = myNet->getAttributeCarriers();
1628 // declare string error
1629 std::string error;
1630 switch (key) {
1631 case SUMO_ATTR_ID:
1633 case SUMO_ATTR_TYPE:
1634 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1635 case SUMO_ATTR_COLOR:
1636 return canParse<RGBColor>(value);
1637 case SUMO_ATTR_DEPARTLANE: {
1638 int dummyDepartLane;
1639 DepartLaneDefinition dummyDepartLaneProcedure;
1640 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1641 // if error is empty, check if depart lane is correct
1642 if (error.empty()) {
1643 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1644 return true;
1645 } else if (isTemplate()) {
1646 return true;
1647 } else if (getParentJunctions().size() > 0) {
1648 return (dummyDepartLane == 0);
1649 } else if (getParentAdditionals().size() > 0) {
1650 return (dummyDepartLane == 0);
1651 } else {
1652 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1653 }
1654 } else {
1655 return false;
1656 }
1657 }
1658 case SUMO_ATTR_DEPARTPOS: {
1659 double dummyDepartPos;
1660 DepartPosDefinition dummyDepartPosProcedure;
1661 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1662 // if error is empty, given value is valid
1663 return error.empty();
1664 }
1665 case SUMO_ATTR_DEPARTSPEED: {
1666 double dummyDepartSpeed;
1667 DepartSpeedDefinition dummyDepartSpeedProcedure;
1668 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1669 // if error is empty, check if depart speed is correct
1670 if (error.empty()) {
1671 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1672 return true;
1673 } else if (isTemplate()) {
1674 return true;
1675 } else {
1676 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1677 }
1678 } else {
1679 return false;
1680 }
1681 }
1682 case SUMO_ATTR_ARRIVALLANE: {
1683 int dummyArrivalLane;
1684 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1685 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1686 // if error is empty, given value is valid
1687 if (error.empty()) {
1688 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1689 return true;
1690 } else if (isTemplate()) {
1691 return true;
1692 } else if (getParentJunctions().size() > 0) {
1693 return (dummyArrivalLane == 0);
1694 } else if (getParentAdditionals().size() > 0) {
1695 return (dummyArrivalLane == 0);
1696 } else {
1697 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1698 }
1699 } else {
1700 return false;
1701 }
1702 }
1703 case SUMO_ATTR_ARRIVALPOS: {
1704 double dummyArrivalPos;
1705 ArrivalPosDefinition dummyArrivalPosProcedure;
1706 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1707 // if error is empty, given value is valid
1708 return error.empty();
1709 }
1711 double dummyArrivalSpeed;
1712 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1713 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1714 // if error is empty, given value is valid
1715 return error.empty();
1716 }
1717 case SUMO_ATTR_LINE:
1718 return true;
1720 return canParse<int>(value) && parse<int>(value) >= 0;
1722 return canParse<int>(value) && parse<int>(value) >= 0;
1723 case SUMO_ATTR_REROUTE:
1724 return true; // check
1726 double dummyDepartPosLat;
1727 DepartPosLatDefinition dummyDepartPosLatProcedure;
1728 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1729 // if error is empty, given value is valid
1730 return error.empty();
1731 }
1733 double dummyArrivalPosLat;
1734 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1735 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1736 // if error is empty, given value is valid
1737 return error.empty();
1738 }
1740 return areInsertionChecksValid(value);
1741 // Specific of vehicles over routes
1742 case SUMO_ATTR_ROUTE:
1743 if (getParentDemandElements().size() == 2) {
1744 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::routes, value, false) != nullptr);
1745 } else {
1746 return true;
1747 }
1748 // Specific of from-to edges
1749 case SUMO_ATTR_FROM:
1750 case SUMO_ATTR_TO:
1751 return (ACs->retrieveEdge(value, false) != nullptr);
1753 case SUMO_ATTR_ARRIVALEDGE: {
1754 if (value.empty()) {
1755 return true;
1756 } else {
1757 RouteIndexDefinition dummyDef;
1758 int dummyIndex;
1759 SUMOVehicleParameter::parseRouteIndex(value, myTagProperty->getTagStr(), id, key, dummyIndex, dummyDef, error);
1760 if (error.empty()) {
1761 if (dummyDef != RouteIndexDefinition::GIVEN) {
1762 return true;
1763 } else if (isTemplate()) {
1764 return true;
1765 } else if (myTagProperty->vehicleRoute()) {
1766 // check parent route
1767 return (dummyIndex < (int)getRouteParent()->getParentEdges().size());
1768 } else if (getChildDemandElements().size() > 0) {
1769 // check embedded route
1770 return (dummyIndex < (int)getChildDemandElements().front()->getParentEdges().size());
1771 } else {
1772 return true;
1773 }
1774 } else {
1775 return false;
1776 }
1777 }
1778 }
1779 case SUMO_ATTR_VIA:
1780 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1781 // Specific of from-to junctions
1784 return (ACs->retrieveJunction(value, false) != nullptr);
1785 // Specific of from-to taz
1786 case SUMO_ATTR_FROM_TAZ:
1787 case SUMO_ATTR_TO_TAZ:
1788 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1789 default:
1790 return isValidFlowAttribute(this, key, value);
1791 }
1792}
1793
1794
1795void
1797 enableFlowAttribute(this, key, undoList);
1798}
1799
1800
1801void
1803 disableFlowAttribute(this, key, undoList);
1804}
1805
1806
1807bool
1811
1812
1813std::string
1815 return getTagStr();
1816}
1817
1818
1819std::string
1821 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1822 // special case for Trips and flow
1823 if (myTagProperty->vehicleEdges()) {
1824 // check if we're inspecting a Edge
1825 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1826 // check if edge correspond to a "from", "to" or "via" edge
1827 if (inspectedElements.isACInspected(getParentEdges().front())) {
1828 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1829 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1830 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1831 } else {
1832 // iterate over via
1833 for (const auto& viaEdgeID : via) {
1834 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1835 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1836 }
1837 }
1838 }
1839 }
1840 }
1841 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1842}
1843
1844
1846GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1847 // get net and undoList
1848 const auto net = originalVehicle->getNet();
1849 auto undoList = net->getViewNet()->getUndoList();
1850 // declare new route, vehicle and embedded route
1851 GNERoute* newRoute = nullptr;
1852 GNEVehicle* newVehicle = nullptr;
1853 GNERoute* newEmbeddedRoute = nullptr;
1854 // generate new vehicle ID
1855 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1856 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1857 // extract vehicle parameters and update ID
1858 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1859 newVehicleParameters.id = newVehicleID;
1860 // create vehicle using vehicleParameters
1861 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1862 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1863 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1864 originalVehicle->getFileBucket(),
1865 originalVehicle->getParentDemandElements().at(0), newRoute,
1866 newVehicleParameters);
1867 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1868 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1869 originalVehicle->getFileBucket(),
1870 originalVehicle->getParentDemandElements().at(0),
1871 newVehicleParameters);
1872 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1873 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1874 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1875 originalVehicle->getFileBucket(),
1876 originalVehicle->getParentDemandElements().at(0),
1877 originalVehicle->getParentEdges().front(),
1878 originalVehicle->getParentEdges().back(),
1879 newVehicleParameters);
1880 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1881 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1882 originalVehicle->getFileBucket(),
1883 originalVehicle->getParentDemandElements().at(0),
1884 originalVehicle->getParentJunctions().front(),
1885 originalVehicle->getParentJunctions().back(),
1886 newVehicleParameters);
1887 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1888 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net,
1889 originalVehicle->getFileBucket(),
1890 originalVehicle->getParentDemandElements().at(0),
1891 originalVehicle->getParentAdditionals().front(),
1892 originalVehicle->getParentAdditionals().back(),
1893 newVehicleParameters);
1894 }
1895 // add new vehicle
1896 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1897 if (newRoute) {
1898 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1899 }
1900 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1901 if (newEmbeddedRoute) {
1902 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1903 }
1904 undoList->end();
1905 return newVehicle;
1906}
1907
1908// ===========================================================================
1909// protected
1910// ===========================================================================
1911
1914 // change color
1915 if (drawUsingSelectColor()) {
1917 } else {
1918 return getColorByScheme(s.vehicleColorer, this);
1919 }
1920}
1921
1922
1925 return *this;
1926}
1927
1928// ===========================================================================
1929// private
1930// ===========================================================================
1931
1932void
1933GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1934 // declare string error
1935 std::string error;
1936 // flag to upate stack label
1937 bool updateSpreadStackGeometry = false;
1938 switch (key) {
1939 case SUMO_ATTR_ID:
1940 // update microsimID
1941 setDemandElementID(value);
1942 // set manually vehicle ID (needed for saving)
1943 id = value;
1944 break;
1945 case SUMO_ATTR_TYPE:
1946 if (getID().size() > 0) {
1948 // set manually vtypeID (needed for saving)
1949 vtypeid = value;
1950 }
1951 break;
1952 case SUMO_ATTR_COLOR:
1953 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1954 color = parse<RGBColor>(value);
1955 // mark parameter as set
1957 } else {
1958 // set default value
1960 // unset parameter
1961 parametersSet &= ~VEHPARS_COLOR_SET;
1962 }
1963 break;
1965 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1967 // mark parameter as set
1969 } else {
1970 // set default value
1972 // unset parameter
1973 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1974 }
1975 break;
1977 if (value == toString(INVALID_DOUBLE)) {
1979 // mark parameter as set
1981 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1983 // mark parameter as set
1985 } else {
1986 // set default value
1988 // unset parameter
1989 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1990 }
1991 if (getID().size() > 0) {
1993 updateSpreadStackGeometry = true;
1994 }
1995 break;
1997 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1999 // mark parameter as set
2001 } else {
2002 // set default value
2004 // unset parameter
2005 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
2006 }
2007 break;
2009 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2011 // mark parameter as set
2013 } else {
2014 // set default value
2016 // unset parameter
2017 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2018 }
2019 break;
2021 if (value == toString(INVALID_DOUBLE)) {
2023 // mark parameter as set
2025 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2027 // mark parameter as set
2029 } else {
2030 // set default value
2032 // unset parameter
2033 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2034 }
2035 if (getID().size() > 0) {
2037 updateSpreadStackGeometry = true;
2038 }
2039 break;
2041 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2043 // mark parameter as set
2045 } else {
2046 // set default value
2048 // unset parameter
2049 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2050 }
2051 break;
2052 case SUMO_ATTR_LINE:
2053 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2054 line = value;
2055 // mark parameter as set
2057 } else {
2058 // set default value
2060 // unset parameter
2061 parametersSet &= ~VEHPARS_LINE_SET;
2062 }
2063 break;
2065 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2066 personNumber = parse<int>(value);
2067 // mark parameter as set
2069 } else {
2070 // set default value
2072 // unset parameter
2073 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2074 }
2075 break;
2077 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2078 containerNumber = parse<int>(value);
2079 // mark parameter as set
2081 } else {
2082 // set default value
2084 // unset parameter
2085 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2086 }
2087 break;
2088 case SUMO_ATTR_REROUTE:
2089 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2090 // mark parameter as set
2092 } else {
2093 // unset parameter
2094 parametersSet &= ~VEHPARS_ROUTE_SET;
2095 }
2096 break;
2098 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2100 // mark parameter as set
2102 } else {
2103 // set default value
2105 // unset parameter
2106 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2107 }
2108 break;
2110 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2112 // mark parameter as set
2114 } else {
2115 // set default value
2117 // unset parameter
2118 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2119 }
2121 break;
2123 if (value.empty() || (value == "all")) {
2124 // unset parameter
2125 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2126 } else {
2127 // mark parameter as set
2129 }
2131 break;
2132 // Specific of vehicles over routes
2133 case SUMO_ATTR_ROUTE:
2134 if (getParentDemandElements().size() == 2) {
2136 }
2138 updateSpreadStackGeometry = true;
2139 break;
2140 // Specific of from-to edges
2141 case SUMO_ATTR_FROM: {
2142 // change first edge
2144 // compute vehicle
2146 updateSpreadStackGeometry = true;
2147 break;
2148 }
2149 case SUMO_ATTR_TO: {
2150 // change last edge
2151 replaceLastParentEdge(value);
2152 // compute vehicle
2154 updateSpreadStackGeometry = true;
2155 break;
2156 }
2157 case SUMO_ATTR_VIA: {
2158 if (!value.empty()) {
2159 // set new via edges
2160 via = parse< std::vector<std::string> >(value);
2161 // mark parameter as set
2163 } else {
2164 // clear via
2165 via.clear();
2166 // unset parameter
2167 parametersSet &= ~VEHPARS_VIA_SET;
2168 }
2169 // compute vehicle
2171 updateSpreadStackGeometry = true;
2172 break;
2173 }
2174 case SUMO_ATTR_DEPARTEDGE: {
2175 // update depart edge
2176 if (value.empty()) {
2177 // unset parameter
2178 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2179 departEdge = -1;
2181 } else {
2182 // mark parameter as set
2185 }
2186 // compute vehicle
2187 if (getID().size() > 0) {
2189 updateSpreadStackGeometry = true;
2190 }
2191 break;
2192 }
2193 case SUMO_ATTR_ARRIVALEDGE: {
2194 // update arrival edge
2195 if (value.empty()) {
2196 // unset parameter
2197 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2198 arrivalEdge = -1;
2200 } else {
2201 // mark parameter as set
2204 }
2205 if (getID().size() > 0) {
2206 // compute vehicle
2208 updateSpreadStackGeometry = true;
2209 }
2210 break;
2211 }
2212 // Specific of from-to junctions
2214 // change first junction
2216 // compute vehicle
2218 updateSpreadStackGeometry = true;
2219 break;
2220 }
2221 case SUMO_ATTR_TO_JUNCTION: {
2222 // change last junction
2224 // compute vehicle
2226 updateSpreadStackGeometry = true;
2227 break;
2228 }
2229 // Specific of from-to TAZs
2230 case SUMO_ATTR_FROM_TAZ: {
2231 // change first additional
2233 // set taz manually
2234 fromTaz = value;
2235 // compute vehicle
2237 updateSpreadStackGeometry = true;
2238 break;
2239 }
2240 case SUMO_ATTR_TO_TAZ: {
2241 // change last additional
2243 // set taz manually
2244 toTaz = value;
2245 // compute vehicle
2247 updateSpreadStackGeometry = true;
2248 break;
2249 }
2250 default:
2251 setFlowAttribute(this, key, value);
2252 break;
2253 }
2254 // check if stack label has to be updated
2255 if (updateSpreadStackGeometry) {
2256 if (myTagProperty->vehicleEdges()) {
2257 getParentEdges().front()->updateVehicleStackLabels();
2258 getParentEdges().front()->updateVehicleSpreadGeometries();
2259 } else if (myTagProperty->vehicleRoute() && !getRouteParent()->getTagProperty()->isRouteDistribution()) {
2260 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2261 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2262 } else if (myTagProperty->vehicleRouteEmbedded()) {
2263 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2264 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2265 }
2266 }
2267}
2268
2269
2270void
2272 // toggle flow attributes
2273 toggleFlowAttribute(key, value);
2274}
2275
2276/****************************************************************************/
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:316
#define TLF(string,...)
Definition MsgHandler.h:318
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:57
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition GLHelper.cpp:348
static void drawFilledCircleDetailed(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:773
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string getID() const override
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
std::string getFlowAttribute(const GNEDemandElement *flowElement, SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceDemandElementParent(const std::vector< SumoXMLTag > tags, const std::string &value, const int parentIndex)
replace demand element parent
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
FileBucket * getFileBucket() const override
get reference to fileBucket in which save this AC
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
GNELane * getLaneByAllowedVClass(const SUMOVehicleClass vClass) const
return the first lane that allow a vehicle of type vClass (or the first lane, if none was found)
Definition GNEEdge.cpp:1529
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:234
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:683
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:228
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:216
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:1476
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1486
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, const bool allowDelete, const bool addSeparator)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationWidthSettings widthSettings
width settings
bool checkDrawVehicle(Detail d, const bool selected) const
check if draw vehicle
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
bool showRouteIndex
Information whether the route index should be shown.
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static const std::vector< SumoXMLTag > routes
route namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
bool isRandom() const
check if color is random
Definition RGBColor.cpp:130
static const RGBColor RED
named colors
Definition RGBColor.h:204
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.
static OutputDevice & writeParams(OutputDevice &device, const Parameterised &params)
write the parameters of the given object as param tags
#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