Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Representation of vehicles in netedit
19/****************************************************************************/
20
27#include <netedit/GNENet.h>
28#include <netedit/GNESegment.h>
30#include <netedit/GNEUndoList.h>
37
38#include "GNEVehicle.h"
39#include "GNERoute.h"
40#include "GNERouteHandler.h"
41
42// ===========================================================================
43// FOX callback mapping
44// ===========================================================================
45
49
53
54// Object implementation
55FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
56FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
57
58// ===========================================================================
59// GNEVehicle::GNESingleVehiclePopupMenu
60// ===========================================================================
61
63 GUIGLObjectPopupMenu(app, parent, vehicle),
64 myVehicle(vehicle) {
65 // build common options
66 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
67 // route length
68 vehicle->buildMenuCommandRouteLength(this);
69 // add transform functions only in demand mode
70 if (myVehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
71 // add reverse
72 vehicle->buildMenuAddReverse(this);
73 // continue depending of type
74 if (myVehicle->getTagProperty()->vehicleJunctions()) {
75 // create menu pane for transform operations
76 FXMenuPane* transformOperation = new FXMenuPane(this);
77 this->insertMenuPaneChild(transformOperation);
78 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
79 // Create menu commands for all transform
80 GUIDesigns::buildFXMenuCommand(transformOperation,
81 TL("Trip (over junctions)"),
83 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_JUNCTIONS));
84 GUIDesigns::buildFXMenuCommand(transformOperation,
85 TL("Flow (over junctions)"),
87 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_JUNCTIONS));
88 } else if (myVehicle->getTagProperty()->vehicleTAZs()) {
89 // create menu pane for transform operations
90 FXMenuPane* transformOperation = new FXMenuPane(this);
91 this->insertMenuPaneChild(transformOperation);
92 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
93 // Create menu commands for all transform
94 GUIDesigns::buildFXMenuCommand(transformOperation,
95 TL("Trip (over TAZs)"),
97 (myVehicle->getTagProperty()->getTag() == GNE_TAG_TRIP_TAZS));
98 GUIDesigns::buildFXMenuCommand(transformOperation,
99 TL("Flow (over TAZs)"),
101 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_TAZS));
102 } else {
103 // create menu pane for transform operations
104 FXMenuPane* transformOperation = new FXMenuPane(this);
105 this->insertMenuPaneChild(transformOperation);
106 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
107 // Create menu commands for all transform
108 GUIDesigns::buildFXMenuCommand(transformOperation,
109 TL("Vehicle"),
111 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_VEHICLE));
112 GUIDesigns::buildFXMenuCommand(transformOperation,
113 TL("Vehicle (embedded route)"),
115 (myVehicle->getTagProperty()->getTag() == GNE_TAG_VEHICLE_WITHROUTE));
116 GUIDesigns::buildFXMenuCommand(transformOperation,
117 TL("RouteFlow"),
119 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_ROUTE));
120 GUIDesigns::buildFXMenuCommand(transformOperation,
121 TL("RouteFlow (embedded route)"),
123 (myVehicle->getTagProperty()->getTag() == GNE_TAG_FLOW_WITHROUTE));
124 GUIDesigns::buildFXMenuCommand(transformOperation,
125 TL("Trip"),
127 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_TRIP));
128 GUIDesigns::buildFXMenuCommand(transformOperation,
129 TL("Flow"),
131 (myVehicle->getTagProperty()->getTag() == SUMO_TAG_FLOW));
132 }
133 }
134}
135
136
138
139
140long
142 switch (FXSELID(sel)) {
145 break;
148 break;
150 GNERouteHandler::transformToVehicle(myVehicle, false);
151 break;
154 break;
157 break;
160 break;
163 break;
166 break;
169 break;
172 break;
173 default:
174 break;
175 }
176 return 1;
177}
178
179// ===========================================================================
180// GNEVehicle::GNESelectedVehiclesPopupMenu
181// ===========================================================================
182
183GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
184 GUIGLObjectPopupMenu(app, parent, vehicle),
185 mySelectedVehicles(selectedVehicle),
186 myVehicleTag(vehicle->getTagProperty()->getTag()) {
187 // build common options
188 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
189 // route length
190 vehicle->buildMenuCommandRouteLength(this);
191 // add transform functions only in demand mode
193 // add reverse
194 vehicle->buildMenuAddReverse(this);
195 // continue depending of type
196 if (vehicle->getTagProperty()->vehicleJunctions()) {
197 // create menu pane for transform operations
198 FXMenuPane* transformOperation = new FXMenuPane(this);
199 this->insertMenuPaneChild(transformOperation);
200 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
201 // Create menu commands for restricted transforms
203 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
206 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
208 // create separator
209 new FXMenuSeparator(transformOperation);
210 // Create menu commands for all transform
211 GUIDesigns::buildFXMenuCommand(transformOperation,
212 TL("Trips (over junctions)"),
214 GUIDesigns::buildFXMenuCommand(transformOperation,
215 TL("Flows (over junctions)"),
217 } else if (vehicle->getTagProperty()->vehicleTAZs()) {
218 // create menu pane for transform operations
219 FXMenuPane* transformOperation = new FXMenuPane(this);
220 this->insertMenuPaneChild(transformOperation);
221 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
222 // Create menu commands for all transform
224 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
227 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
229 // create separator
230 new FXMenuSeparator(transformOperation);
231 // Create menu commands for all transform
232 GUIDesigns::buildFXMenuCommand(transformOperation,
233 TL("Trips (over TAZs)"),
235 GUIDesigns::buildFXMenuCommand(transformOperation,
236 TL("Flows (over TAZs)"),
238 } else {
239 // create menu pane for transform operations
240 FXMenuPane* transformOperation = new FXMenuPane(this);
241 this->insertMenuPaneChild(transformOperation);
242 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
243 // Create menu commands for all transform
245 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
248 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
251 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
254 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
257 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
260 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
262 // create separator
263 new FXMenuSeparator(transformOperation);
264 // Create menu commands for all transform
265 GUIDesigns::buildFXMenuCommand(transformOperation,
266 TL("Vehicles"),
268 GUIDesigns::buildFXMenuCommand(transformOperation,
269 TL("Vehicles (embedded route)"),
271 GUIDesigns::buildFXMenuCommand(transformOperation,
272 TL("RouteFlows"),
274 GUIDesigns::buildFXMenuCommand(transformOperation,
275 TL("RouteFlows (embedded route)"),
277 GUIDesigns::buildFXMenuCommand(transformOperation,
278 TL("Trips"),
280 GUIDesigns::buildFXMenuCommand(transformOperation,
281 TL("Flows"),
283 }
284 }
285}
286
287
289
290
291long
292GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
293 // iterate over all selected vehicles
294 for (const auto& vehicle : mySelectedVehicles) {
295 switch (FXSELID(sel)) {
297 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
298 if (myRestrictedMenuCommands.count(obj) > 0) {
299 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
301 }
302 } else {
304 }
305 }
306 break;
308 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
309 if (myRestrictedMenuCommands.count(obj) > 0) {
310 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
312 }
313 } else {
315 }
316 }
317 break;
319 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
320 if (myRestrictedMenuCommands.count(obj) > 0) {
321 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
323 }
324 } else {
326 }
327 }
328 break;
330 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
331 if (myRestrictedMenuCommands.count(obj) > 0) {
332 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
334 }
335 } else {
337 }
338 }
339 break;
341 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
342 if (myRestrictedMenuCommands.count(obj) > 0) {
343 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
345 }
346 } else {
348 }
349 }
350 break;
352 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
353 if (myRestrictedMenuCommands.count(obj) > 0) {
354 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
356 }
357 } else {
359 }
360 }
361 break;
363 if (vehicle->getTagProperty()->vehicleJunctions()) {
364 if (myRestrictedMenuCommands.count(obj) > 0) {
365 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
367 }
368 } else {
370 }
371 }
372 break;
374 if (vehicle->getTagProperty()->vehicleJunctions()) {
375 if (myRestrictedMenuCommands.count(obj) > 0) {
376 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
378 }
379 } else {
381 }
382 }
383 break;
385 if (vehicle->getTagProperty()->vehicleTAZs()) {
386 if (myRestrictedMenuCommands.count(obj) > 0) {
387 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
389 }
390 } else {
392 }
393 }
394 break;
396 if (vehicle->getTagProperty()->vehicleTAZs()) {
397 if (myRestrictedMenuCommands.count(obj) > 0) {
398 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
400 }
401 } else {
403 }
404 }
405 break;
406 default:
407 break;
408 }
409 }
410 return 1;
411}
412
413// ===========================================================================
414// member method definitions
415// ===========================================================================
416#ifdef _MSC_VER
417#pragma warning(push)
418#pragma warning(disable: 4355) // mask warning about "this" in initializers
419#endif
423 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
425 // set end and vehPerHours as default flow values
428}
429
430
431GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename,
432 GNEDemandElement* vehicleType, GNEDemandElement* route) :
433 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
435 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
436 SUMO_ATTR_POSITION, myPosOverView)) {
437 // set parents
438 setParents<GNEDemandElement*>({vehicleType, route});
439 // SUMOVehicleParameter ID has to be set manually
440 id = vehicleID;
441 // set manually vtypeID (needed for saving)
442 vtypeid = vehicleType->getID();
443}
444
445
446GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEDemandElement* route,
447 const SUMOVehicleParameter& vehicleParameters) :
448 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
449 GNEDemandElementFlow(this, vehicleParameters),
450 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
451 SUMO_ATTR_POSITION, myPosOverView)) {
452 // set parents
453 setParents<GNEDemandElement*>({vehicleType, route});
454 // SUMOVehicleParameter ID has to be set manually
455 id = vehicleParameters.id;
456 // set manually vtypeID (needed for saving)
457 vtypeid = vehicleType->getID();
458}
459
460
461GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
462 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
463 GNEDemandElementFlow(this, vehicleParameters),
464 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
465 SUMO_ATTR_POSITION, myPosOverView)) {
466 // set parents
467 setParent<GNEDemandElement*>(vehicleType);
468 // SUMOVehicleParameter ID has to be set manually
469 id = vehicleParameters.id;
470 // reset routeid
471 routeid.clear();
472 // set manually vtypeID (needed for saving)
473 vtypeid = vehicleType->getID();
474}
475
476
477GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType,
478 GNEEdge* fromEdge, GNEEdge* toEdge) :
479 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
481 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
482 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
483 SUMO_ATTR_POSITION, myPosOverView)) {
484 // set parents
485 setParents<GNEEdge*>({fromEdge, toEdge});
486 setParent<GNEDemandElement*>(vehicleType);
487}
488
489
490GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
491 const SUMOVehicleParameter& vehicleParameters) :
492 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
493 GNEDemandElementFlow(this, vehicleParameters),
494 myMoveElementVehicle(new GNEMoveElementVehicle(this, fromEdge, toEdge)),
495 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
496 SUMO_ATTR_POSITION, myPosOverView)) {
497 // set parents
498 setParents<GNEEdge*>({fromEdge, toEdge});
499 setParent<GNEDemandElement*>(vehicleType);
500}
501
502
503GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
504 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
506 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
507 SUMO_ATTR_POSITION, myPosOverView)) {
508 // set parents
509 setParents<GNEJunction*>({fromJunction, toJunction});
510 setParent<GNEDemandElement*>(vehicleType);
511}
512
513
514GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
515 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
516 GNEDemandElementFlow(this, vehicleParameters),
517 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
518 SUMO_ATTR_POSITION, myPosOverView)) {
519 // set parents
520 setParents<GNEJunction*>({fromJunction, toJunction});
521 setParent<GNEDemandElement*>(vehicleType);
522}
523
524
525GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
526 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
527 GNEDemandElementFlow(this, vehicleParameters),
528 myMoveElementView(new GNEMoveElementView(this, GNEMoveElementView::AttributesFormat::POSITION,
529 SUMO_ATTR_POSITION, myPosOverView)) {
530 // set parents
531 setParents<GNEAdditional*>({fromTAZ, toTAZ});
532 setParent<GNEDemandElement*>(vehicleType);
533 // mark taz parameters as set
536 fromTaz = fromTAZ->getID();
537 toTaz = toTAZ->getID();
538}
539#ifdef _MSC_VER
540#pragma warning(pop)
541#endif
542
543
545
546
551
552
555 return this;
556}
557
558
559const Parameterised*
561 return this;
562}
563
564
565void
567 // attribute VType must not be written if is DEFAULT_VTYPE_ID
569 // unset VType parameter
570 parametersSet &= ~VEHPARS_VTYPE_SET;
571 // write vehicle attributes (VType will not be written)
573 // set VType parameter again
575 } else {
576 // write vehicle attributes, including type/distribution
578 }
579 // write route
581 // write route
583 }
584 // write from, to and edge vias
586 // write manually from/to edges (it correspond to front and back parent edges)
587 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
588 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
589 // only write via if there isn't empty
590 if (via.size() > 0) {
591 device.writeAttr(SUMO_ATTR_VIA, via);
592 }
593 }
594 // write from and to junctions
596 // write manually from/to junctions (it correspond to front and back parent junctions)
599 }
600 // write parameters
601 writeParams(device);
602 // write route elements associated to this vehicle (except for calibrator FLows)
603 if ((getChildDemandElements().size() > 0) && !myTagProperty->isCalibrator()) {
604 if (getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
605 // write embedded route
606 getChildDemandElements().front()->writeDemandElement(device);
607 // write stops
608 for (const auto& demandElement : getChildDemandElements()) {
609 if (demandElement->getTagProperty()->isVehicleStop()) {
610 demandElement->writeDemandElement(device);
611 }
612 }
613 } else {
614 for (const auto& route : getChildDemandElements()) {
615 route->writeDemandElement(device);
616 }
617 }
618 }
619 // close vehicle tag
620 device.closeTag();
621}
622
623
626 // check conditions
627 if (myTagProperty->vehicleTAZs()) {
628 // vehicles and flows over tazs are always valid
629 return Problem::OK;
630 } else if (myTagProperty->vehicleEdges()) {
631 // check vehicles and flows paths
632 if (getParentEdges().front() == getParentEdges().back()) {
633 return Problem::OK;
634 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
635 return Problem::OK;
636 } else {
638 }
639 } else if (myTagProperty->vehicleJunctions()) {
640 // check vehicles and flows paths
641 if (getParentJunctions().front() == getParentJunctions().back()) {
642 return Problem::OK;
643 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
644 return Problem::OK;
645 } else {
647 }
648 } else if (myTagProperty->vehicleRoute()) {
649 // check if routeParent is a distribution
650 if (getRouteParent()->getTagProperty()->isRouteDistribution()) {
651 return Problem::OK;
652 } else {
653 // check if exist a valid path using route parent edges
655 return Problem::OK;
656 } else {
658 }
659 }
660 } else if (myTagProperty->vehicleRouteEmbedded()) {
661 // check if exist a valid path using route child edges
663 return Problem::OK;
664 } else {
666 }
667 } else {
669 }
670}
671
672
673std::string
675 // only trips or flows can have problems
677 // check if exist at least a connection between every edge
678 for (int i = 1; i < (int)getParentEdges().size(); i++) {
680 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
681 }
682 }
683 // if there are connections between all edges, then all is ok
684 return "";
685 } else if (myTagProperty->vehicleJunctions()) {
686 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
687 } else if (myTagProperty->vehicleRoute()) {
688 // get route parent edges
689 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
690 // check if exist at least a connection between every edge
691 for (int i = 1; i < (int)routeEdges.size(); i++) {
692 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
693 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
694 }
695 }
696 // if there are connections between all edges, then all is ok
697 return "";
698 } else if (myTagProperty->vehicleRouteEmbedded()) {
699 // get route parent edges
700 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
701 // check if exist at least a connection between every edge
702 for (int i = 1; i < (int)routeEdges.size(); i++) {
703 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
704 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
705 }
706 }
707 // if there are connections between all edges, then all is ok
708 return "";
709 } else {
710 return "";
711 }
712}
713
714
715void
719
720
723 return getParentDemandElements().front()->getVClass();
724}
725
726
727const RGBColor&
729 return color;
730}
731
732
733void
735 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
736 // remove vehicle from grid
738 // reset view position to 0
739 myPosOverView = Position(0, 0);
740 // continue depending if the routeDistribution have references
741 for (auto routeRef : getParentDemandElements().at(1)->getChildDemandElements()) {
742 if (routeRef->getTagProperty()->isDistributionReference()) {
743 myPosOverView = routeRef->getParentDemandElements().at(1)->getParentEdges().front()->getChildLanes().at(0)->getLaneShape().front();
744 break;
745 }
746 }
747 // update vehicle geometry
749 // add object in grid again
751 } else if (getParentJunctions().size() > 0) {
752 // calculate rotation between both junctions
753 const Position posA = getParentJunctions().front()->getPositionInView();
754 const Position posB = getParentJunctions().back()->getPositionInView();
755 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
756 // update Geometry
757 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
758 } else if (getParentAdditionals().size() > 0) {
759 // calculate rotation between both TAZs
760 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
761 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
762 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
763 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
764 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
765 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
766 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
767 // update Geometry
769 } else {
770 // get first path lane
771 const GNELane* firstPathLane = getFirstPathLane();
772 // check path lane
773 if (firstPathLane) {
774 // declare departPos
775 double posOverLane = 0;
777 posOverLane = departPos;
778 }
779 // update Geometry
780 myDemandElementGeometry.updateGeometry(firstPathLane->getLaneShape(), posOverLane, 0 /*myMovingLateralOffset*/);
781 // compute route embedded associated with this vehicle
782 for (const auto& demandElement : getChildDemandElements()) {
783 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
784 demandElement->computePathElement();
785 }
786 demandElement->updateGeometry();
787 }
788 }
789 }
790}
791
792
796 return myPosOverView;
797 } else {
798 return myDemandElementGeometry.getShape().front();
799 }
800}
801
802
803bool
805 // get edit modes
806 const auto& editModes = myNet->getViewNet()->getEditModes();
807 // check if we're editing a type
808 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
810 return true;
811 }
812 // check opened popup
813 if (myNet->getViewNet()->getPopup()) {
814 return myNet->getViewNet()->getPopup()->getGLObject() == this;
815 }
816 return false;
817}
818
819
823 // obtain all selected vehicles
824 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
825 std::vector<GNEVehicle*> selectedVehicles;
826 selectedVehicles.reserve(selectedDemandElements.size());
827 for (const auto& selectedDemandElement : selectedDemandElements) {
828 if (selectedDemandElement->getTagProperty()->isVehicle()) {
829 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
830 }
831 }
832 // return a GNESelectedVehiclesPopupMenu
833 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
834 } else {
835 // return a GNESingleVehiclePopupMenu
836 return new GNESingleVehiclePopupMenu(this, app, parent);
837 }
838}
839
840
841std::string
844 return getRouteParent()->getID();
845 } else if (myTagProperty->vehicleEdges()) {
846 return getParentEdges().front()->getID();
847 } else if (myTagProperty->vehicleJunctions()) {
848 return getParentJunctions().front()->getID();
849 } else if (myTagProperty->vehicleTAZs()) {
850 return getParentAdditionals().front()->getID();
851 } else {
852 throw ProcessError(TL("Invalid vehicle tag"));
853 }
854}
855
856
857double
861
862
865 Boundary vehicleBoundary;
866 if (myTagProperty->vehicleRoute() && getRouteParent()->getTagProperty()->isRouteDistribution()) {
867 vehicleBoundary.add(myPosOverView);
868 } else {
869 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
870 }
871 vehicleBoundary.grow(20);
872 return vehicleBoundary;
873}
874
875
876void
877GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
878 // geometry of this element cannot be splitted
879}
880
881
882void
884 // only drawn in super mode demand
888 // declare common attributes
890 const double exaggeration = getExaggeration(s);
891 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
892 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
893 // obtain Position an rotation (depending of draw spread vehicles)
894 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
895 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
896 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
897 // check that position is valid
898 if (vehiclePosition == Position::INVALID) {
899 return;
900 }
901 // get detail level
902 const auto d = s.getDetailLevel(exaggeration);
903 // draw geometry only if we'rent in drawForObjectUnderCursor mode
906 // push draw matrix
908 // Start with the drawing of the area translating matrix to origin
910 // translate to drawing position
911 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
912 glRotated(vehicleRotation, 0, 0, -1);
913 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
914 glTranslated(0, (-1) * length * exaggeration, 0);
915 // set lane color
917 double upscaleLength = exaggeration;
918 if ((exaggeration > 1) && (length > 5)) {
919 // reduce the length/width ratio because this is not useful at high zoom
920 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
921 }
922 glScaled(exaggeration, upscaleLength, 1);
923 // draw the vehicle depending of detail level
930 }
931 // check if min gap has to be drawn
932 if (s.drawMinGap) {
933 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
934 glColor3d(0., 1., 0.);
935 glBegin(GL_LINES);
936 glVertex2d(0., 0);
937 glVertex2d(0., minGap);
938 glVertex2d(-.5, minGap);
939 glVertex2d(.5, minGap);
940 glEnd();
941 }
942 // drawing name at GLO_MAX fails unless translating z
943 glTranslated(0, MIN2(length / 2, double(5)), -getType());
944 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
945 glRotated(-vehicleRotation, 0, 0, -1);
947 // draw line
948 if (s.vehicleName.show(this) && line != "") {
949 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
951 }
952 // pop draw matrix
954 // draw line between junctions if path isn't valid
955 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
956 drawJunctionLine(this);
957 }
958 // draw lock icon
959 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
960 // draw stack label
961 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
962 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
963 }
964 // draw flow label
965 if (myTagProperty->isFlow()) {
966 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
967 }
968 // draw dotted contour
970 }
971 // draw squared shape
972 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
973 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
974 }
975 }
976}
977
978
979void
981 // calculate path (only for flows and trips)
983 // calculate path
985 } else if (myTagProperty->vehicleEdges()) {
986 // save edges in wich this vehicle has to stop
987 std::vector<GNEEdge*> edgeStops;
988 // iterate over child demand elements
989 for (const auto& demandElement : getChildDemandElements()) {
990 // extract lanes
991 if (demandElement->getTagProperty()->isVehicleStop()) {
992 GNEEdge* edgeStop = nullptr;
993 if (demandElement->getParentAdditionals().size() > 0) {
994 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
995 } else {
996 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
997 }
998 if (edgeStop) {
999 // avoid double edge stops
1000 if (stops.empty()) {
1001 edgeStops.push_back(edgeStop);
1002 } else if (edgeStops.back() != edgeStop) {
1003 edgeStops.push_back(edgeStop);
1004 }
1005 }
1006 }
1007 }
1008 // declare edge vector
1009 std::vector<GNEEdge*> edgePath;
1010 // get first and last lanes
1011 const auto firstLane = getFirstPathLane();
1012 const auto lastLane = getLastPathLane();
1013 // check first and last lanes
1014 if (firstLane && lastLane) {
1015 // add first lane
1016 edgePath.push_back(firstLane->getParentEdge());
1017 // give more priority to stops instead via
1018 if (edgeStops.size() > 0) {
1019 // add stops only if they're accesibles
1020 for (const auto& edgeStop : edgeStops) {
1021 // check if exist a valid path that includes the last edge
1022 auto edgePathStop = edgePath;
1023 edgePathStop.push_back(edgeStop);
1024 edgePathStop.push_back(lastLane->getParentEdge());
1026 if (path.size() > 0) {
1027 edgePath.push_back(edgeStop);
1028 }
1029 }
1030 } else {
1031 // add via lanes
1032 for (const auto& edgeViaID : via) {
1033 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1034 if (edgeVia) {
1035 // check if exist a valid path that includes the last edge
1036 auto edgePathStop = edgePath;
1037 edgePathStop.push_back(edgeVia);
1038 edgePathStop.push_back(lastLane->getParentEdge());
1039 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1040 edgePath.push_back(edgeVia);
1041 }
1042 }
1043 }
1044 }
1045 // add last lane
1046 edgePath.push_back(lastLane->getParentEdge());
1047 // calculate path
1048 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1049 }
1050 }
1051 // update geometry
1053}
1054
1055
1056void
1057GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1058 // conditions for draw always in network mode
1059 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1062 // conditions for draw always in demand mode
1063 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1065 // conditions for draw if is selected
1066 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1068 // conditions for draw if is inspected
1069 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1071 // check drawing conditions
1072 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1074 // get detail level
1075 const auto d = s.getDetailLevel(1);
1076 // calculate width
1077 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1078 // calculate startPos
1079 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1080 // get endPos
1081 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1082 // declare path geometry
1083 GUIGeometry vehicleGeometry;
1084 // update pathGeometry depending of first and last segment
1085 if (segment->isFirstSegment() && segment->isLastSegment()) {
1086 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1087 geometryDepartPos,
1089 geometryEndPos,
1091 } else if (segment->isFirstSegment()) {
1092 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1093 geometryDepartPos,
1095 -1,
1097 } else if (segment->isLastSegment()) {
1098 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1099 -1,
1101 geometryEndPos,
1103 } else {
1104 vehicleGeometry = segment->getLane()->getLaneGeometry();
1105 }
1106 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1108 // obtain color
1110 // Add a draw matrix
1112 // Start with the drawing of the area translating matrix to origin
1113 glTranslated(0, 0, getType() + offsetFront);
1114 // Set color
1115 GLHelper::setColor(pathColor);
1116 // draw geometry
1117 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1118 // show index over every edge
1119 if (isInspected && s.showRouteIndex) {
1120 const double textSize = s.vehicleName.size / s.scale;
1121 std::string label = toString(segment->getLaneIndex());
1122 Position pos = segment->getLane()->getLaneShape().front() - Position(0, textSize * 1);
1123 GLHelper::drawTextSettings(s.vehicleName, label, pos, s.scale, s.angle, 1.0);
1124 }
1125 // Pop last matrix
1127 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1128 if (segment->getNextLane()) {
1129 // push draw matrix
1131 // Start with the drawing of the area translating matrix to origin
1133 // Set red color
1135 // get firstPosition (last position of current lane shape)
1136 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1137 // get lastPosition (first position of next lane shape)
1138 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1139 // draw box line
1140 GLHelper::drawBoxLine(arrivalPosition,
1141 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1142 firstPosition.distanceTo2D(arrivalPosition), .05);
1143 // pop draw matrix
1145 }
1146 // check if this is the last segment
1147 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1148 // get geometryEndPos
1149 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1150 // check if endPos can be drawn
1152 // push draw matrix
1154 // Start with the drawing of the area translating matrix to origin
1156 // translate to geometryEndPos
1157 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1158 // Set person plan color
1159 GLHelper::setColor(pathColor);
1160 // resolution of drawn circle depending of the zoom (To improve smoothness)
1162 // pop draw matrix
1164 }
1165 }
1166 // draw dotted contour
1167 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1168 }
1169 // calculate contour and draw dotted geometry
1170 if (segment->isFirstSegment() || segment->isLastSegment()) {
1171 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1172 0, segment, segment->getLane()->getParentEdge());
1173 } else {
1174 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1175 0, segment, segment->getLane()->getParentEdge());
1176 }
1177 // check if add this path element to redraw buffer
1178 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1180 }
1181 }
1182}
1183
1184
1185void
1186GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1187 // conditions for draw always in network mode
1188 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1191 // conditions for draw always in demand mode
1192 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1194 // conditions for draw if is selected
1195 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1197 // conditions for draw if is inspected
1198 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1200 // check drawing conditions
1201 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1203 // get detail level
1204 const auto d = s.getDetailLevel(1);
1205 // calculate width
1206 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1207 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1209 // Add a draw matrix
1211 // Start with the drawing of the area translating matrix to origin
1212 glTranslated(0, 0, getType() + offsetFront);
1213 // Set color of the base
1214 if (drawUsingSelectColor()) {
1216 } else {
1218 }
1219 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1220 if (segment->getPreviousLane() && segment->getNextLane()) {
1221 // draw lane2lane
1223 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1224 // draw line between center of junction and last lane shape
1225 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1226 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1227 // draw line between center of junction and first lane shape
1228 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1229 }
1230 // Pop last matrix
1232 // draw dotted contour
1233 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1234 }
1235 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1236 if (segment->getPreviousLane() && segment->getNextLane()) {
1237 // calculate contour and draw dotted geometry
1239 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1240 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1241 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1242 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1243 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1244 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1245 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1246 }
1247 // check if add this path element to redraw buffer
1248 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1250 }
1251 }
1252}
1253
1254
1255GNELane*
1257 // declare first edge
1258 GNEEdge* firstEdge = nullptr;
1259 // continue depending of tags
1260 if (myTagProperty->vehicleRoute()) {
1261 // check departEdge
1262 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1263 // use departEdge
1264 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1265 } else {
1266 // use first route edge
1267 firstEdge = getRouteParent()->getParentEdges().front();
1268 }
1269 } else if (myTagProperty->vehicleRouteEmbedded()) {
1270 // check if embedded route exist (due during loading embedded route doesn't exist)
1271 if (getChildDemandElements().empty()) {
1272 return nullptr;
1273 }
1274 // check departEdge
1275 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1276 // use depart edge
1277 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1278 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1279 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1280 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1281 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1282 } else {
1283 return nullptr;
1284 }
1285 } else if (getParentEdges().size() > 0) {
1286 // use first parent edge
1287 firstEdge = getParentEdges().front();
1288 } else {
1289 // defined over junctions
1290 return nullptr;
1291 }
1292 // get departLane index
1293 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1294 // check departLane index
1295 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getChildLanes().size())) {
1296 return firstEdge->getChildLanes().at(departLaneIndex);
1297 } else {
1298 // get first allowed VClass
1299 return firstEdge->getLaneByAllowedVClass(getVClass());
1300 }
1301}
1302
1303
1304GNELane*
1306 // declare last edge
1307 GNEEdge* lastEdge = nullptr;
1308 // continue depending of tags
1309 if (myTagProperty->vehicleRoute()) {
1310 // check arrivalEdge
1311 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1312 // use arrival edge
1313 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1314 } else {
1315 // use last route edge
1316 lastEdge = getRouteParent()->getParentEdges().back();
1317 }
1318 } else if (myTagProperty->vehicleRouteEmbedded()) {
1319 // check if embedded route exist (due during loading embedded route doesn't exist)
1320 if (getChildDemandElements().empty()) {
1321 return nullptr;
1322 }
1323 // check arrivalEdge
1324 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1325 // use arrival edge
1326 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1327 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1328 // use last route edge
1329 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1330 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1331 // use lane
1332 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1333 } else {
1334 return nullptr;
1335 }
1336 } else if (getParentEdges().size() > 0) {
1337 // use last parent edge
1338 lastEdge = getParentEdges().back();
1339 } else {
1340 // defined over junctions
1341 return nullptr;
1342 }
1343 // get arrivalLane index
1344 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1345 // check arrivalLane index
1346 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getChildLanes().size())) {
1347 return lastEdge->getChildLanes().at(arrivalLaneIndex);
1348 } else {
1349 // get last allowed VClass
1350 return lastEdge->getLaneByAllowedVClass(getVClass());
1351 }
1352}
1353
1354
1355std::string
1357 switch (key) {
1358 case SUMO_ATTR_ID:
1359 return getMicrosimID();
1360 case SUMO_ATTR_TYPE:
1361 return vtypeid;
1362 case SUMO_ATTR_COLOR:
1364 return toString(color);
1365 } else {
1367 }
1370 return getDepartLane();
1371 } else {
1373 }
1376 return getDepartPos();
1377 } else {
1379 }
1382 return getDepartSpeed();
1383 } else {
1385 }
1388 return getArrivalLane();
1389 } else {
1391 }
1394 return getArrivalPos();
1395 } else {
1397 }
1400 return getArrivalSpeed();
1401 } else {
1403 }
1404 case SUMO_ATTR_LINE:
1405 if (wasSet(VEHPARS_LINE_SET)) {
1406 return line;
1407 } else {
1409 }
1412 return toString(personNumber);
1413 } else {
1415 }
1418 return toString(containerNumber);
1419 } else {
1421 }
1422 case SUMO_ATTR_REROUTE:
1424 return "true";
1425 } else {
1426 return "false";
1427 }
1430 return getDepartPosLat();
1431 } else {
1433 }
1436 return getArrivalPosLat();
1437 } else {
1439 }
1441 return getInsertionChecks();
1442 // Specific of vehicles over routes
1443 case SUMO_ATTR_ROUTE:
1444 if (getParentDemandElements().size() == 2) {
1445 return getRouteParent()->getID();
1446 } else {
1447 return "";
1448 }
1449 // Specific of from-to edge
1450 case SUMO_ATTR_FROM:
1451 return getParentEdges().front()->getID();
1452 case SUMO_ATTR_TO:
1453 return getParentEdges().back()->getID();
1454 case SUMO_ATTR_VIA:
1455 return toString(via);
1457 if (departEdge == -1) {
1458 return "";
1459 } else {
1460 return toString(departEdge);
1461 }
1463 if (arrivalEdge == -1) {
1464 return "";
1465 } else {
1466 return toString(arrivalEdge);
1467 }
1468 // Specific of from-to junctions
1470 return getParentJunctions().front()->getID();
1472 return getParentJunctions().back()->getID();
1473 // Specific of from-to tazs
1474 case SUMO_ATTR_FROM_TAZ:
1475 return getParentAdditionals().front()->getID();
1476 case SUMO_ATTR_TO_TAZ:
1477 return getParentAdditionals().back()->getID();
1478 // other
1480 return toString(parametersSet);
1481 default:
1482 return getFlowAttribute(this, key);
1483 }
1484}
1485
1486
1487double
1489 switch (key) {
1492 return departLane;
1493 } else {
1494 return -1;
1495 }
1497 // only return departPos it if is given
1499 return departPos;
1500 } else {
1501 return 0;
1502 }
1505 return arrivalLane;
1506 } else {
1507 return -1;
1508 }
1510 // only return departPos it if is given
1512 return arrivalPos;
1513 } else {
1514 return -1;
1515 }
1516 case SUMO_ATTR_WIDTH:
1517 case SUMO_ATTR_LENGTH:
1518 case SUMO_ATTR_MINGAP:
1519 return getTypeParent()->getAttributeDouble(key);
1520 default:
1521 return getFlowAttributeDouble(key);
1522 }
1523}
1524
1525
1528 switch (key) {
1530 // check if this vehicle was defined over junctions
1531 if (getParentJunctions().size() > 0) {
1532 return getParentJunctions().front()->getPositionInView();
1533 } else {
1534 // get first path lane shape
1535 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1536 // check arrivalPosProcedure
1538 if (departPos < 0) {
1539 return laneShape.front();
1540 } else if (departPos > laneShape.length2D()) {
1541 return laneShape.back();
1542 } else {
1543 return laneShape.positionAtOffset2D(departPos);
1544 }
1545 } else {
1546 return laneShape.front();
1547 }
1548 }
1549 }
1551 // check if this vehicle was defined over junctions
1552 if (getParentJunctions().size() > 0) {
1553 return getParentJunctions().back()->getPositionInView();
1554 } else {
1555 // get last path lane shape
1556 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1557 // check arrivalPosProcedure
1559 if (arrivalPos < 0) {
1560 return laneShape.front();
1561 } else if (arrivalPos > laneShape.length2D()) {
1562 return laneShape.back();
1563 } else {
1564 return laneShape.positionAtOffset2D(arrivalPos);
1565 }
1566 } else {
1567 return laneShape.back();
1568 }
1569 }
1570 }
1571 default:
1572 return getCommonAttributePosition(key);
1573 }
1574}
1575
1576
1577void
1578GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1579 if (value == getAttribute(key)) {
1580 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1581 }
1582 switch (key) {
1583 case SUMO_ATTR_ID:
1584 case SUMO_ATTR_TYPE:
1585 case SUMO_ATTR_COLOR:
1592 case SUMO_ATTR_LINE:
1595 case SUMO_ATTR_REROUTE:
1599 // Specific of vehicles over routes
1600 case SUMO_ATTR_ROUTE:
1601 // Specific of from-to edges
1602 case SUMO_ATTR_FROM:
1603 case SUMO_ATTR_TO:
1604 case SUMO_ATTR_VIA:
1607 // Specific of from-to junctions
1610 // Specific of from-to taz
1611 case SUMO_ATTR_FROM_TAZ:
1612 case SUMO_ATTR_TO_TAZ:
1613 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1614 break;
1615 default:
1616 setFlowAttribute(this, key, value, undoList);
1617 break;
1618 }
1619}
1620
1621
1622bool
1623GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1624 // get ACs
1625 const auto ACs = myNet->getAttributeCarriers();
1626 // declare string error
1627 std::string error;
1628 switch (key) {
1629 case SUMO_ATTR_ID:
1631 case SUMO_ATTR_TYPE:
1632 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1633 case SUMO_ATTR_COLOR:
1634 return canParse<RGBColor>(value);
1635 case SUMO_ATTR_DEPARTLANE: {
1636 int dummyDepartLane;
1637 DepartLaneDefinition dummyDepartLaneProcedure;
1638 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1639 // if error is empty, check if depart lane is correct
1640 if (error.empty()) {
1641 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1642 return true;
1643 } else if (isTemplate()) {
1644 return true;
1645 } else if (getParentJunctions().size() > 0) {
1646 return (dummyDepartLane == 0);
1647 } else if (getParentAdditionals().size() > 0) {
1648 return (dummyDepartLane == 0);
1649 } else {
1650 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1651 }
1652 } else {
1653 return false;
1654 }
1655 }
1656 case SUMO_ATTR_DEPARTPOS: {
1657 double dummyDepartPos;
1658 DepartPosDefinition dummyDepartPosProcedure;
1659 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1660 // if error is empty, given value is valid
1661 return error.empty();
1662 }
1663 case SUMO_ATTR_DEPARTSPEED: {
1664 double dummyDepartSpeed;
1665 DepartSpeedDefinition dummyDepartSpeedProcedure;
1666 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1667 // if error is empty, check if depart speed is correct
1668 if (error.empty()) {
1669 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1670 return true;
1671 } else if (isTemplate()) {
1672 return true;
1673 } else {
1674 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1675 }
1676 } else {
1677 return false;
1678 }
1679 }
1680 case SUMO_ATTR_ARRIVALLANE: {
1681 int dummyArrivalLane;
1682 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1683 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1684 // if error is empty, given value is valid
1685 if (error.empty()) {
1686 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1687 return true;
1688 } else if (isTemplate()) {
1689 return true;
1690 } else if (getParentJunctions().size() > 0) {
1691 return (dummyArrivalLane == 0);
1692 } else if (getParentAdditionals().size() > 0) {
1693 return (dummyArrivalLane == 0);
1694 } else {
1695 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1696 }
1697 } else {
1698 return false;
1699 }
1700 }
1701 case SUMO_ATTR_ARRIVALPOS: {
1702 double dummyArrivalPos;
1703 ArrivalPosDefinition dummyArrivalPosProcedure;
1704 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1705 // if error is empty, given value is valid
1706 return error.empty();
1707 }
1709 double dummyArrivalSpeed;
1710 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1711 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1712 // if error is empty, given value is valid
1713 return error.empty();
1714 }
1715 case SUMO_ATTR_LINE:
1716 return true;
1718 return canParse<int>(value) && parse<int>(value) >= 0;
1720 return canParse<int>(value) && parse<int>(value) >= 0;
1721 case SUMO_ATTR_REROUTE:
1722 return true; // check
1724 double dummyDepartPosLat;
1725 DepartPosLatDefinition dummyDepartPosLatProcedure;
1726 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1727 // if error is empty, given value is valid
1728 return error.empty();
1729 }
1731 double dummyArrivalPosLat;
1732 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1733 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1734 // if error is empty, given value is valid
1735 return error.empty();
1736 }
1738 return areInsertionChecksValid(value);
1739 // Specific of vehicles over routes
1740 case SUMO_ATTR_ROUTE:
1741 if (getParentDemandElements().size() == 2) {
1742 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::routes, value, false) != nullptr);
1743 } else {
1744 return true;
1745 }
1746 // Specific of from-to edges
1747 case SUMO_ATTR_FROM:
1748 case SUMO_ATTR_TO:
1749 return (ACs->retrieveEdge(value, false) != nullptr);
1751 case SUMO_ATTR_ARRIVALEDGE: {
1752 if (value.empty()) {
1753 return true;
1754 } else if (canParse<int>(value)) {
1755 // get index
1756 const int index = parse<int>(value);
1757 // check conditions
1758 if (index < 0) {
1759 return false;
1760 } else if (myTagProperty->vehicleRoute()) {
1761 // check parent route
1762 return (index < (int)getRouteParent()->getParentEdges().size());
1763 } else {
1764 // check embedded route
1765 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1766 }
1767 } else {
1768 return false;
1769 }
1770 }
1771 case SUMO_ATTR_VIA:
1772 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1773 // Specific of from-to junctions
1776 return (ACs->retrieveJunction(value, false) != nullptr);
1777 // Specific of from-to taz
1778 case SUMO_ATTR_FROM_TAZ:
1779 case SUMO_ATTR_TO_TAZ:
1780 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1781 default:
1782 return isValidFlowAttribute(this, key, value);
1783 }
1784}
1785
1786
1787void
1789 enableFlowAttribute(this, key, undoList);
1790}
1791
1792
1793void
1795 disableFlowAttribute(this, key, undoList);
1796}
1797
1798
1799bool
1803
1804
1805std::string
1807 return getTagStr();
1808}
1809
1810
1811std::string
1813 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1814 // special case for Trips and flow
1815 if (myTagProperty->vehicleEdges()) {
1816 // check if we're inspecting a Edge
1817 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1818 // check if edge correspond to a "from", "to" or "via" edge
1819 if (inspectedElements.isACInspected(getParentEdges().front())) {
1820 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1821 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1822 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1823 } else {
1824 // iterate over via
1825 for (const auto& viaEdgeID : via) {
1826 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1827 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1828 }
1829 }
1830 }
1831 }
1832 }
1833 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1834}
1835
1836
1838GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1839 // get net and undoList
1840 const auto net = originalVehicle->getNet();
1841 auto undoList = net->getViewNet()->getUndoList();
1842 // declare new route, vehicle and embedded route
1843 GNERoute* newRoute = nullptr;
1844 GNEVehicle* newVehicle = nullptr;
1845 GNERoute* newEmbeddedRoute = nullptr;
1846 // generate new vehicle ID
1847 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1848 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1849 // extract vehicle parameters and update ID
1850 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1851 newVehicleParameters.id = newVehicleID;
1852 // create vehicle using vehicleParameters
1853 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1854 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1855 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1856 originalVehicle->getParentDemandElements().at(0), newRoute,
1857 newVehicleParameters);
1858 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1859 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1860 originalVehicle->getParentDemandElements().at(0),
1861 newVehicleParameters);
1862 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1863 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1864 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1865 originalVehicle->getParentDemandElements().at(0),
1866 originalVehicle->getParentEdges().front(),
1867 originalVehicle->getParentEdges().back(),
1868 newVehicleParameters);
1869 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1870 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1871 originalVehicle->getParentDemandElements().at(0),
1872 originalVehicle->getParentJunctions().front(),
1873 originalVehicle->getParentJunctions().back(),
1874 newVehicleParameters);
1875 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1876 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1877 originalVehicle->getParentDemandElements().at(0),
1878 originalVehicle->getParentAdditionals().front(),
1879 originalVehicle->getParentAdditionals().back(),
1880 newVehicleParameters);
1881 }
1882 // add new vehicle
1883 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1884 if (newRoute) {
1885 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1886 }
1887 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1888 if (newEmbeddedRoute) {
1889 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1890 }
1891 undoList->end();
1892 return newVehicle;
1893}
1894
1895// ===========================================================================
1896// protected
1897// ===========================================================================
1898
1901 // change color
1902 if (drawUsingSelectColor()) {
1904 } else {
1905 return getColorByScheme(s.vehicleColorer, this);
1906 }
1907}
1908
1909
1912 return *this;
1913}
1914
1915// ===========================================================================
1916// private
1917// ===========================================================================
1918
1919void
1920GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1921 // declare string error
1922 std::string error;
1923 // flag to upate stack label
1924 bool updateSpreadStackGeometry = false;
1925 switch (key) {
1926 case SUMO_ATTR_ID:
1927 // update microsimID
1928 setDemandElementID(value);
1929 // set manually vehicle ID (needed for saving)
1930 id = value;
1931 break;
1932 case SUMO_ATTR_TYPE:
1933 if (getID().size() > 0) {
1935 // set manually vtypeID (needed for saving)
1936 vtypeid = value;
1937 }
1938 break;
1939 case SUMO_ATTR_COLOR:
1940 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1941 color = parse<RGBColor>(value);
1942 // mark parameter as set
1944 } else {
1945 // set default value
1947 // unset parameter
1948 parametersSet &= ~VEHPARS_COLOR_SET;
1949 }
1950 break;
1952 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1954 // mark parameter as set
1956 } else {
1957 // set default value
1959 // unset parameter
1960 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1961 }
1962 break;
1964 if (value == toString(INVALID_DOUBLE)) {
1966 // mark parameter as set
1968 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1970 // mark parameter as set
1972 } else {
1973 // set default value
1975 // unset parameter
1976 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1977 }
1978 if (getID().size() > 0) {
1980 updateSpreadStackGeometry = true;
1981 }
1982 break;
1984 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1986 // mark parameter as set
1988 } else {
1989 // set default value
1991 // unset parameter
1992 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1993 }
1994 break;
1996 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1998 // mark parameter as set
2000 } else {
2001 // set default value
2003 // unset parameter
2004 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2005 }
2006 break;
2008 if (value == toString(INVALID_DOUBLE)) {
2010 // mark parameter as set
2012 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2014 // mark parameter as set
2016 } else {
2017 // set default value
2019 // unset parameter
2020 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2021 }
2022 if (getID().size() > 0) {
2024 updateSpreadStackGeometry = true;
2025 }
2026 break;
2028 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2030 // mark parameter as set
2032 } else {
2033 // set default value
2035 // unset parameter
2036 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2037 }
2038 break;
2039 case SUMO_ATTR_LINE:
2040 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2041 line = value;
2042 // mark parameter as set
2044 } else {
2045 // set default value
2047 // unset parameter
2048 parametersSet &= ~VEHPARS_LINE_SET;
2049 }
2050 break;
2052 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2053 personNumber = parse<int>(value);
2054 // mark parameter as set
2056 } else {
2057 // set default value
2059 // unset parameter
2060 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2061 }
2062 break;
2064 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2065 containerNumber = parse<int>(value);
2066 // mark parameter as set
2068 } else {
2069 // set default value
2071 // unset parameter
2072 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2073 }
2074 break;
2075 case SUMO_ATTR_REROUTE:
2076 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2077 // mark parameter as set
2079 } else {
2080 // unset parameter
2081 parametersSet &= ~VEHPARS_ROUTE_SET;
2082 }
2083 break;
2085 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2087 // mark parameter as set
2089 } else {
2090 // set default value
2092 // unset parameter
2093 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2094 }
2095 break;
2097 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2099 // mark parameter as set
2101 } else {
2102 // set default value
2104 // unset parameter
2105 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2106 }
2108 break;
2110 if (value.empty() || (value == "all")) {
2111 // unset parameter
2112 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2113 } else {
2114 // mark parameter as set
2116 }
2118 break;
2119 // Specific of vehicles over routes
2120 case SUMO_ATTR_ROUTE:
2121 if (getParentDemandElements().size() == 2) {
2123 }
2125 updateSpreadStackGeometry = true;
2126 break;
2127 // Specific of from-to edges
2128 case SUMO_ATTR_FROM: {
2129 // change first edge
2131 // compute vehicle
2133 updateSpreadStackGeometry = true;
2134 break;
2135 }
2136 case SUMO_ATTR_TO: {
2137 // change last edge
2138 replaceLastParentEdge(value);
2139 // compute vehicle
2141 updateSpreadStackGeometry = true;
2142 break;
2143 }
2144 case SUMO_ATTR_VIA: {
2145 if (!value.empty()) {
2146 // set new via edges
2147 via = parse< std::vector<std::string> >(value);
2148 // mark parameter as set
2150 } else {
2151 // clear via
2152 via.clear();
2153 // unset parameter
2154 parametersSet &= ~VEHPARS_VIA_SET;
2155 }
2156 // compute vehicle
2158 updateSpreadStackGeometry = true;
2159 break;
2160 }
2161 case SUMO_ATTR_DEPARTEDGE: {
2162 // update depart edge
2163 if (value.empty()) {
2164 // unset parameter
2165 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2166 departEdge = -1;
2168 } else {
2169 // mark parameter as set
2171 departEdge = parse<int>(value);
2173 }
2174 // compute vehicle
2175 if (getID().size() > 0) {
2177 updateSpreadStackGeometry = true;
2178 }
2179 break;
2180 }
2181 case SUMO_ATTR_ARRIVALEDGE: {
2182 // update arrival edge
2183 if (value.empty()) {
2184 // unset parameter
2185 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2186 arrivalEdge = -1;
2188 } else {
2189 // mark parameter as set
2191 arrivalEdge = parse<int>(value);
2193 }
2194 if (getID().size() > 0) {
2195 // compute vehicle
2197 updateSpreadStackGeometry = true;
2198 }
2199 break;
2200 }
2201 // Specific of from-to junctions
2203 // change first junction
2205 // compute vehicle
2207 updateSpreadStackGeometry = true;
2208 break;
2209 }
2210 case SUMO_ATTR_TO_JUNCTION: {
2211 // change last junction
2213 // compute vehicle
2215 updateSpreadStackGeometry = true;
2216 break;
2217 }
2218 // Specific of from-to TAZs
2219 case SUMO_ATTR_FROM_TAZ: {
2220 // change first additional
2222 // set taz manually
2223 fromTaz = value;
2224 // compute vehicle
2226 updateSpreadStackGeometry = true;
2227 break;
2228 }
2229 case SUMO_ATTR_TO_TAZ: {
2230 // change last additional
2232 // set taz manually
2233 toTaz = value;
2234 // compute vehicle
2236 updateSpreadStackGeometry = true;
2237 break;
2238 }
2239 default:
2240 setFlowAttribute(this, key, value);
2241 break;
2242 }
2243 // check if stack label has to be updated
2244 if (updateSpreadStackGeometry) {
2245 if (myTagProperty->vehicleEdges()) {
2246 getParentEdges().front()->updateVehicleStackLabels();
2247 getParentEdges().front()->updateVehicleSpreadGeometries();
2248 } else if (myTagProperty->vehicleRoute() && !getRouteParent()->getTagProperty()->isRouteDistribution()) {
2249 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2250 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2251 } else if (myTagProperty->vehicleRouteEmbedded()) {
2252 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2253 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2254 }
2255 }
2256}
2257
2258
2259void
2261 // toggle flow attributes
2262 toggleFlowAttribute(key, value);
2263}
2264
2265/****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ DEMAND_TYPE
Mode for editing types.
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_EMBEDDED
transform vehicle to flow over junctions
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_TAZS
transform vehicle to flow over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE_EMBEDDED
transform vehicle to vehicle over junctions
@ MID_GNE_VEHICLE_TRANSFORM_ROUTEFLOW
transform vehicle to flow over route
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_JUNCTIONS
transform vehicle to trip over junctions
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_TAZS
transform vehicle to trip over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_TRIP
transform vehicle to trip
@ MID_GNE_VEHICLE_TRANSFORM_FLOW
transform vehicle to flow
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE
transform vehicle to vehicle over route
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_JUNCTIONS
transform vehicle to flow over jucntions
GUIViewObjectsHandler gViewObjectsHandler
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const long long int VEHPARS_ARRIVALSPEED_SET
const long long int VEHPARS_DEPARTPOSLAT_SET
const long long int VEHPARS_ARRIVALPOSLAT_SET
const long long int VEHPARS_PERSON_NUMBER_SET
const long long int VEHPARS_DEPARTSPEED_SET
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const long long int VEHPARS_ROUTE_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
const long long int VEHPARS_COLOR_SET
const long long int VEHPARS_VIA_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_ARRIVALLANE_SET
const long long int VEHPARS_DEPARTLANE_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_ARRIVALPOS_SET
const long long int VEHPARS_ARRIVALEDGE_SET
const long long int VEHPARS_CONTAINER_NUMBER_SET
const long long int VEHPARS_FROM_TAZ_SET
const long long int VEHPARS_VTYPE_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ GIVEN
The arrival position is given.
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const long long int VEHPARS_LINE_SET
const long long int VEHPARS_DEPARTEDGE_SET
const long long int VEHPARS_INSERTION_CHECKS_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_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:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition GLHelper.cpp:348
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:773
virtual double getAttributeDouble(SumoXMLAttr key) const =0
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 std::string & getFilename() const
get filename in which save this AC
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
std::string getFlowAttribute(const GNEDemandElement *flowElement, SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void 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
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
GNELane * getLaneByAllowedVClass(const SUMOVehicleClass vClass) const
return the first lane that allow a vehicle of type vClass (or the first lane, if none was found)
Definition GNEEdge.cpp:1502
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
static const double arrivalPositionDiameter
vehicle arrival position radius
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1440
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1450
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:174
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:144
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2193
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, const SumoXMLTag tag, const bool isPlan)
check if path element geometry must be drawn in the given lane
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void calculatePath(GNEPathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToFlowJunctions(GNEVehicle *originalVehicle)
transform to flow over junctions
static void transformToTripJunctions(GNEVehicle *originalVehicle)
transform to trip over junctions
static void transformToFlowTAZs(GNEVehicle *originalVehicle)
transform to flow over TAZs
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
static void transformToTripTAZs(GNEVehicle *originalVehicle)
transform to trip over TAZs
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
int getLaneIndex() const
get lane index
bool isLastSegment() const
check if segment is the last path's segment
bool isFlow() const
return true if tag correspond to a flow element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
const RGBColor & getDefaultColorValue(SumoXMLAttr attr) const
get default bool value
bool vehicleJunctions() const
return true if tag correspond to a vehicle placed over from-to junctions
bool isCalibrator() const
return true if tag correspond to a calibrator (Only used to group all detectors in the XML)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
SumoXMLTag getXMLTag() const
default values
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
const std::string & getDefaultStringValue(SumoXMLAttr attr) const
default values
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h: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:96
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:316
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:325
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:319
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:322
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
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationWidthSettings widthSettings
width settings
bool checkDrawVehicle(Detail d, const bool selected) const
check if draw vehicle
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
bool showRouteIndex
Information whether the route index should be shown.
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static 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 SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
An upper class for objects with additional parameters.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition RGBColor.h:188
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
bool areInsertionChecksValid(const std::string &value) const
check if given insertion checks are valid
double arrivalPos
(optional) The position the vehicle shall arrive on
static int parseInsertionChecks(const std::string &value)
parses insertion checks
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string getInsertionChecks() const
get insertion checks in string format
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int insertionChecks
bitset of InsertionCheck
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
#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