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-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Representation of vehicles in netedit
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNESegment.h>
24#include <netedit/GNEUndoList.h>
25#include <netedit/GNEViewNet.h>
36
37#include "GNEVehicle.h"
38#include "GNERoute.h"
39
40// ===========================================================================
41// FOX callback mapping
42// ===========================================================================
46
50
51// Object implementation
52FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
53FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
54
55// ===========================================================================
56// static definitions
57// ===========================================================================
59
60// ===========================================================================
61// GNEVehicle::GNESingleVehiclePopupMenu
62// ===========================================================================
63
65 GUIGLObjectPopupMenu(app, parent, *vehicle),
66 myVehicle(vehicle) {
67 // build header
68 myVehicle->buildPopupHeader(this, app);
69 // build menu command for center button and copy cursor position to clipboard
72 // build menu commands for names
73 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
74 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
75 new FXMenuSeparator(this);
76 // build selection and show parameters menu
79 // route length
80 vehicle->buildMenuCommandRouteLength(this);
81 // add transform functions only in demand mode
83 // add reverse
84 vehicle->buildMenuAddReverse(this);
85 // continue depending of type
87 // create menu pane for transform operations
88 FXMenuPane* transformOperation = new FXMenuPane(this);
89 this->insertMenuPaneChild(transformOperation);
90 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
91 // Create menu commands for all transform
92 GUIDesigns::buildFXMenuCommand(transformOperation,
93 TL("Trip (over junctions)"),
96 GUIDesigns::buildFXMenuCommand(transformOperation,
97 TL("Flow (over junctions)"),
100 } else if (myVehicle->getTagProperty().vehicleTAZs()) {
101 // create menu pane for transform operations
102 FXMenuPane* transformOperation = new FXMenuPane(this);
103 this->insertMenuPaneChild(transformOperation);
104 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
105 // Create menu commands for all transform
106 GUIDesigns::buildFXMenuCommand(transformOperation,
107 TL("Trip (over TAZs)"),
110 GUIDesigns::buildFXMenuCommand(transformOperation,
111 TL("Flow (over TAZs)"),
114 } else {
115 // create menu pane for transform operations
116 FXMenuPane* transformOperation = new FXMenuPane(this);
117 this->insertMenuPaneChild(transformOperation);
118 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
119 // Create menu commands for all transform
120 GUIDesigns::buildFXMenuCommand(transformOperation,
121 TL("Vehicle"),
124 GUIDesigns::buildFXMenuCommand(transformOperation,
125 TL("Vehicle (embedded route)"),
128 GUIDesigns::buildFXMenuCommand(transformOperation,
129 TL("RouteFlow"),
132 GUIDesigns::buildFXMenuCommand(transformOperation,
133 TL("RouteFlow (embedded route)"),
136 GUIDesigns::buildFXMenuCommand(transformOperation,
137 TL("Trip"),
140 GUIDesigns::buildFXMenuCommand(transformOperation,
141 TL("Flow"),
144 }
145 }
146}
147
148
150
151
152long
154 switch (FXSELID(sel)) {
157 break;
160 break;
162 GNERouteHandler::transformToVehicle(myVehicle, false);
163 break;
166 break;
169 break;
172 break;
175 break;
178 break;
181 break;
184 break;
185 default:
186 break;
187 }
188 return 1;
189}
190
191// ===========================================================================
192// GNEVehicle::GNESelectedVehiclesPopupMenu
193// ===========================================================================
194
195GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
196 GUIGLObjectPopupMenu(app, parent, *vehicle),
197 mySelectedVehicles(selectedVehicle),
198 myVehicleTag(vehicle->getTagProperty().getTag()) {
199 // build header
200 vehicle->buildPopupHeader(this, app);
201 // build menu command for center button and copy cursor position to clipboard
202 vehicle->buildCenterPopupEntry(this);
203 vehicle->buildPositionCopyEntry(this, app);
204 // build menu commands for names
205 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
206 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
207 new FXMenuSeparator(this);
208 // build selection and show parameters menu
209 vehicle->getNet()->getViewNet()->buildSelectionACPopupEntry(this, vehicle);
210 vehicle->buildShowParamsPopupEntry(this);
211 // route length
212 vehicle->buildMenuCommandRouteLength(this);
213 // add transform functions only in demand mode
215 // add reverse
216 vehicle->buildMenuAddReverse(this);
217 // continue depending of type
218 if (vehicle->getTagProperty().vehicleJunctions()) {
219 // create menu pane for transform operations
220 FXMenuPane* transformOperation = new FXMenuPane(this);
221 this->insertMenuPaneChild(transformOperation);
222 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
223 // Create menu commands for restricted transforms
225 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
228 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
230 // create separator
231 new FXMenuSeparator(transformOperation);
232 // Create menu commands for all transform
233 GUIDesigns::buildFXMenuCommand(transformOperation,
234 TL("Trips (over junctions)"),
236 GUIDesigns::buildFXMenuCommand(transformOperation,
237 TL("Flows (over junctions)"),
239 } else if (vehicle->getTagProperty().vehicleTAZs()) {
240 // create menu pane for transform operations
241 FXMenuPane* transformOperation = new FXMenuPane(this);
242 this->insertMenuPaneChild(transformOperation);
243 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
244 // Create menu commands for all transform
246 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
249 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
251 // create separator
252 new FXMenuSeparator(transformOperation);
253 // Create menu commands for all transform
254 GUIDesigns::buildFXMenuCommand(transformOperation,
255 TL("Trips (over TAZs)"),
257 GUIDesigns::buildFXMenuCommand(transformOperation,
258 TL("Flows (over TAZs)"),
260 } else {
261 // create menu pane for transform operations
262 FXMenuPane* transformOperation = new FXMenuPane(this);
263 this->insertMenuPaneChild(transformOperation);
264 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
265 // Create menu commands for all transform
267 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
270 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
273 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
276 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
279 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
282 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
284 // create separator
285 new FXMenuSeparator(transformOperation);
286 // Create menu commands for all transform
287 GUIDesigns::buildFXMenuCommand(transformOperation,
288 TL("Vehicles"),
290 GUIDesigns::buildFXMenuCommand(transformOperation,
291 TL("Vehicles (embedded route)"),
293 GUIDesigns::buildFXMenuCommand(transformOperation,
294 TL("RouteFlows"),
296 GUIDesigns::buildFXMenuCommand(transformOperation,
297 TL("RouteFlows (embedded route)"),
299 GUIDesigns::buildFXMenuCommand(transformOperation,
300 TL("Trips"),
302 GUIDesigns::buildFXMenuCommand(transformOperation,
303 TL("Flows"),
305 }
306 }
307}
308
309
311
312
313long
314GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
315 // iterate over all selected vehicles
316 for (const auto& vehicle : mySelectedVehicles) {
317 switch (FXSELID(sel)) {
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() && !vehicle->getTagProperty().vehicleTAZs()) {
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() && !vehicle->getTagProperty().vehicleTAZs()) {
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().vehicleJunctions()) {
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().vehicleJunctions()) {
397 if (myRestrictedMenuCommands.count(obj) > 0) {
398 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
400 }
401 } else {
403 }
404 }
405 break;
407 if (vehicle->getTagProperty().vehicleTAZs()) {
408 if (myRestrictedMenuCommands.count(obj) > 0) {
409 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
411 }
412 } else {
414 }
415 }
416 break;
418 if (vehicle->getTagProperty().vehicleTAZs()) {
419 if (myRestrictedMenuCommands.count(obj) > 0) {
420 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
422 }
423 } else {
425 }
426 }
427 break;
428 default:
429 break;
430 }
431 }
432 return 1;
433}
434
435// ===========================================================================
436// member method definitions
437// ===========================================================================
438
441 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
443 // reset default values
445 // set end and vehPerHours as default flow values
448}
449
450
451GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route) :
452 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
454 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
456 // SUMOVehicleParameter ID has to be set manually
457 id = vehicleID;
458 // set manually vtypeID (needed for saving)
459 vtypeid = vehicleType->getID();
460}
461
462
463GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
464 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
466 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
467GNEDemandElementFlow(this, vehicleParameters) {
468 // SUMOVehicleParameter ID has to be set manually
469 id = vehicleParameters.id;
470 // set manually vtypeID (needed for saving)
471 vtypeid = vehicleType->getID();
472}
473
474
475GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
476 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_VEHICLE_WITHROUTE) ? GLO_VEHICLE : GLO_ROUTEFLOW, tag,
478 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType}, {}),
479GNEDemandElementFlow(this, vehicleParameters) {
480 // SUMOVehicleParameter ID has to be set manually
481 id = vehicleParameters.id;
482 // reset routeid
483 routeid.clear();
484 // set manually vtypeID (needed for saving)
485 vtypeid = vehicleType->getID();
486}
487
488
489GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType,
490 GNEEdge* fromEdge, GNEEdge* toEdge) :
491 GNEDemandElement(vehicleID, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
492 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
493 GNEPathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
495}
496
497
498GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
499 const SUMOVehicleParameter& vehicleParameters) :
500 GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
501 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
502 GNEPathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
503GNEDemandElementFlow(this, vehicleParameters) {
504}
505
506
507GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
508 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
510 GNEPathElement::Options::DEMAND_ELEMENT, {
511 fromJunction, toJunction
512}, {}, {}, {}, {vehicleType}, {}),
514}
515
516
517GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
518 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
520 GNEPathElement::Options::DEMAND_ELEMENT, {
521 fromJunction, toJunction
522}, {}, {}, {}, {vehicleType}, {}),
523GNEDemandElementFlow(this, vehicleParameters) {
524}
525
526
527GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
528 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_TAZS) ? GLO_FLOW : GLO_TRIP, tag,
530 GNEPathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {vehicleType}, {}),
531GNEDemandElementFlow(this, vehicleParameters) {
532 // mark taz parameters as set
535 fromTaz = fromTAZ->getID();
536 toTaz = toTAZ->getID();
537}
538
539
541
542
545 // get first and last lanes
546 const GNELane* firstLane = getFirstPathLane();
547 const GNELane* lastLane = getLastPathLane();
548 // check both lanes
549 if (firstLane && lastLane) {
550 // get depart and arrival positions (doubles)
551 const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
552 const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
553 // obtain diameter
555 // return move operation depending if we're editing departPos or arrivalPos
557 return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
561 return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
564 }
565 }
566 // nothing to move
567 return nullptr;
568}
569
570
571void
573 // attribute VType must not be written if is DEFAULT_VTYPE_ID
575 // unset VType parameter
576 parametersSet &= ~VEHPARS_VTYPE_SET;
577 // write vehicle attributes (VType will not be written)
579 // set VType parameter again
581 } else {
582 // write vehicle attributes, including type/distribution
584 }
585 // write specific attribute depending of tag property
587 // write route
589 }
590 // write from, to and edge vias
592 // write manually from/to edges (it correspond to front and back parent edges)
593 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
594 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
595 // only write via if there isn't empty
596 if (via.size() > 0) {
597 device.writeAttr(SUMO_ATTR_VIA, via);
598 }
599 }
600 // write from and to junctions
602 // write manually from/to junctions (it correspond to front and back parent junctions)
605 }
606 // write flow attributes
607 writeFlowAttributes(this, device);
608 // write parameters
609 writeParams(device);
610 // write route elements associated to this vehicle (except for calibrator FLows)
611 if ((getChildDemandElements().size() > 0) && !myTagProperty.isCalibrator()) {
612 if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
613 // write embedded route
614 getChildDemandElements().front()->writeDemandElement(device);
615 // write stops
616 for (const auto& demandElement : getChildDemandElements()) {
617 if (demandElement->getTagProperty().isVehicleStop()) {
618 demandElement->writeDemandElement(device);
619 }
620 }
621 } else {
622 for (const auto& route : getChildDemandElements()) {
623 route->writeDemandElement(device);
624 }
625 }
626 }
627 // close vehicle tag
628 device.closeTag();
629}
630
631
634 // check conditions
636 // vehicles and flows over tazs are always valid
637 return Problem::OK;
638 } else if (myTagProperty.vehicleEdges()) {
639 // check vehicles and flows paths
640 if (getParentEdges().front() == getParentEdges().back()) {
641 return Problem::OK;
642 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
643 return Problem::OK;
644 } else {
646 }
647 } else if (myTagProperty.vehicleJunctions()) {
648 // check vehicles and flows paths
649 if (getParentJunctions().front() == getParentJunctions().back()) {
650 return Problem::OK;
651 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
652 return Problem::OK;
653 } else {
655 }
656 } else if (myTagProperty.vehicleRoute()) {
657 // check if exist a valid path using route parent edges
659 return Problem::OK;
660 } else {
662 }
663 } else if (myTagProperty.vehicleRouteEmbedded()) {
664 // check if exist a valid path using route child edges
666 return Problem::OK;
667 } else {
669 }
670 } else {
672 }
673}
674
675
676std::string
678 // only trips or flows can have problems
680 // check if exist at least a connection between every edge
681 for (int i = 1; i < (int)getParentEdges().size(); i++) {
683 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
684 }
685 }
686 // if there are connections between all edges, then all is ok
687 return "";
688 } else if (myTagProperty.vehicleJunctions()) {
689 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
690 } else if (myTagProperty.vehicleRoute()) {
691 // get route parent edges
692 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
693 // check if exist at least a connection between every edge
694 for (int i = 1; i < (int)routeEdges.size(); i++) {
695 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
696 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
697 }
698 }
699 // if there are connections between all edges, then all is ok
700 return "";
701 } else if (myTagProperty.vehicleRouteEmbedded()) {
702 // get route parent edges
703 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
704 // check if exist at least a connection between every edge
705 for (int i = 1; i < (int)routeEdges.size(); i++) {
706 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
707 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
708 }
709 }
710 // if there are connections between all edges, then all is ok
711 return "";
712 } else {
713 return "";
714 }
715}
716
717
718void
722
723
726 return getParentDemandElements().front()->getVClass();
727}
728
729
730const RGBColor&
732 return color;
733}
734
735
736void
738 if (getParentJunctions().size() > 0) {
739 // calculate rotation between both junctions
740 const Position posA = getParentJunctions().front()->getPositionInView();
741 const Position posB = getParentJunctions().back()->getPositionInView();
742 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
743 // update Geometry
744 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
745 } else if (getParentAdditionals().size() > 0) {
746 // calculate rotation between both TAZs
747 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
748 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
749 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
750 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
751 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
752 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
753 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
754 // update Geometry
756 } else {
757 // get first path lane
758 const GNELane* firstPathLane = getFirstPathLane();
759 // check path lane
760 if (firstPathLane) {
761 // declare departPos
762 double posOverLane = 0;
764 posOverLane = departPos;
765 }
766 // update Geometry
768 // compute route embedded associated with this vehicle
769 for (const auto& demandElement : getChildDemandElements()) {
770 if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
771 demandElement->computePathElement();
772 }
773 demandElement->updateGeometry();
774 }
775 }
776 }
777}
778
779
784
785
786bool
788 // get edit modes
789 const auto& editModes = myNet->getViewNet()->getEditModes();
790 // check if we're editing a type
791 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
793 return true;
794 } else {
795 return false;
796 }
797}
798
799
803 // obtain all selected vehicles
804 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
805 std::vector<GNEVehicle*> selectedVehicles;
806 selectedVehicles.reserve(selectedDemandElements.size());
807 for (const auto& selectedDemandElement : selectedDemandElements) {
808 if (selectedDemandElement->getTagProperty().isVehicle()) {
809 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
810 }
811 }
812 // return a GNESelectedVehiclesPopupMenu
813 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
814 } else {
815 // return a GNESingleVehiclePopupMenu
816 return new GNESingleVehiclePopupMenu(this, app, parent);
817 }
818}
819
820
821std::string
824 return getRouteParent()->getID();
825 } else if (myTagProperty.vehicleEdges()) {
826 return getParentEdges().front()->getID();
827 } else if (myTagProperty.vehicleJunctions()) {
828 return getParentJunctions().front()->getID();
829 } else if (myTagProperty.vehicleTAZs()) {
830 return getParentAdditionals().front()->getID();
831 } else {
832 throw ProcessError(TL("Invalid vehicle tag"));
833 }
834}
835
836
837double
841
842
845 Boundary vehicleBoundary;
846 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
847 vehicleBoundary.grow(20);
848 return vehicleBoundary;
849}
850
851
852void
853GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
854 // geometry of this element cannot be splitted
855}
856
857
858void
860 // only drawn in super mode demand
864 // declare common attributes
866 const double exaggeration = getExaggeration(s);
867 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
868 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
869 // obtain Position an rotation (depending of draw spread vehicles)
870 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
871 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
872 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
873 // check that position is valid
874 if (vehiclePosition == Position::INVALID) {
875 return;
876 }
877 // get detail level
878 const auto d = s.getDetailLevel(exaggeration);
879 // draw geometry only if we'rent in drawForObjectUnderCursor mode
882 // push draw matrix
884 // Start with the drawing of the area translating matrix to origin
886 // translate to drawing position
887 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
888 glRotated(vehicleRotation, 0, 0, -1);
889 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
890 glTranslated(0, (-1) * length * exaggeration, 0);
891 // set lane color
893 double upscaleLength = exaggeration;
894 if ((exaggeration > 1) && (length > 5)) {
895 // reduce the length/width ratio because this is not useful at high zoom
896 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
897 }
898 glScaled(exaggeration, upscaleLength, 1);
899 // draw the vehicle depending of detail level
906 }
907 // check if min gap has to be drawn
908 if (s.drawMinGap) {
909 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
910 glColor3d(0., 1., 0.);
911 glBegin(GL_LINES);
912 glVertex2d(0., 0);
913 glVertex2d(0., minGap);
914 glVertex2d(-.5, minGap);
915 glVertex2d(.5, minGap);
916 glEnd();
917 }
918 // drawing name at GLO_MAX fails unless translating z
919 glTranslated(0, MIN2(length / 2, double(5)), -getType());
920 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
921 glRotated(vehicleRotation, 0, 0, -1);
923 // draw line
924 if (s.vehicleName.show(this) && line != "") {
925 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
927 }
928 // pop draw matrix
930 // draw line between junctions if path isn't valid
931 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
932 drawJunctionLine(this);
933 }
934 // draw lock icon
935 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
936 // draw stack label
937 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
938 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
939 }
940 // draw flow label
941 if (myTagProperty.isFlow()) {
942 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
943 }
944 // draw dotted contour
946 }
947 // draw squared shape
948 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
949 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
950 }
951 }
952}
953
954
955void
957 // calculate path (only for flows and trips)
959 // calculate path
961 } else if (myTagProperty.vehicleEdges()) {
962 // save edges in wich this vehicle has to stop
963 std::vector<GNEEdge*> edgeStops;
964 // iterate over child demand elements
965 for (const auto& demandElement : getChildDemandElements()) {
966 // extract lanes
967 if (demandElement->getTagProperty().isVehicleStop()) {
968 GNEEdge* edgeStop = nullptr;
969 if (demandElement->getParentAdditionals().size() > 0) {
970 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
971 } else {
972 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
973 }
974 if (edgeStop) {
975 // avoid double edge stops
976 if (stops.empty()) {
977 edgeStops.push_back(edgeStop);
978 } else if (edgeStops.back() != edgeStop) {
979 edgeStops.push_back(edgeStop);
980 }
981 }
982 }
983 }
984 // declare edge vector
985 std::vector<GNEEdge*> edgePath;
986 // get first and last lanes
987 const auto firstLane = getFirstPathLane();
988 const auto lastLane = getLastPathLane();
989 // check first and last lanes
990 if (firstLane && lastLane) {
991 // add first lane
992 edgePath.push_back(firstLane->getParentEdge());
993 // give more priority to stops instead via
994 if (edgeStops.size() > 0) {
995 // add stops only if they're accesibles
996 for (const auto& edgeStop : edgeStops) {
997 // check if exist a valid path that includes the last edge
998 auto edgePathStop = edgePath;
999 edgePathStop.push_back(edgeStop);
1000 edgePathStop.push_back(lastLane->getParentEdge());
1002 if (path.size() > 0) {
1003 edgePath.push_back(edgeStop);
1004 }
1005 }
1006 } else {
1007 // add via lanes
1008 for (const auto& edgeViaID : via) {
1009 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1010 if (edgeVia) {
1011 // check if exist a valid path that includes the last edge
1012 auto edgePathStop = edgePath;
1013 edgePathStop.push_back(edgeVia);
1014 edgePathStop.push_back(lastLane->getParentEdge());
1015 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1016 edgePath.push_back(edgeVia);
1017 }
1018 }
1019 }
1020 }
1021 // add last lane
1022 edgePath.push_back(lastLane->getParentEdge());
1023 // calculate path
1024 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1025 }
1026 }
1027 // update geometry
1029}
1030
1031
1032void
1033GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1034 // conditions for draw always in network mode
1035 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1038 // conditions for draw always in demand mode
1039 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1041 // conditions for draw if is selected
1042 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1044 // conditions for draw if is inspected
1045 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1047 // check drawing conditions
1048 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1050 // get detail level
1051 const auto d = s.getDetailLevel(1);
1052 // calculate width
1053 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1054 // calculate startPos
1055 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1056 // get endPos
1057 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1058 // declare path geometry
1059 GUIGeometry vehicleGeometry;
1060 // update pathGeometry depending of first and last segment
1061 if (segment->isFirstSegment() && segment->isLastSegment()) {
1062 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1063 geometryDepartPos,
1065 geometryEndPos,
1067 } else if (segment->isFirstSegment()) {
1068 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1069 geometryDepartPos,
1071 -1,
1073 } else if (segment->isLastSegment()) {
1074 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1075 -1,
1077 geometryEndPos,
1079 } else {
1080 vehicleGeometry = segment->getLane()->getLaneGeometry();
1081 }
1082 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1084 // obtain color
1086 // Add a draw matrix
1088 // Start with the drawing of the area translating matrix to origin
1089 glTranslated(0, 0, getType() + offsetFront);
1090 // Set color
1091 GLHelper::setColor(pathColor);
1092 // draw geometry
1093 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1094 // Pop last matrix
1096 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1097 if (segment->getNextLane()) {
1098 // push draw matrix
1100 // Start with the drawing of the area translating matrix to origin
1102 // Set red color
1104 // get firstPosition (last position of current lane shape)
1105 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1106 // get lastPosition (first position of next lane shape)
1107 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1108 // draw box line
1109 GLHelper::drawBoxLine(arrivalPosition,
1110 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1111 firstPosition.distanceTo2D(arrivalPosition), .05);
1112 // pop draw matrix
1114 }
1115 // check if this is the last segment
1116 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1117 // get geometryEndPos
1118 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1119 // check if endPos can be drawn
1121 // push draw matrix
1123 // Start with the drawing of the area translating matrix to origin
1125 // translate to geometryEndPos
1126 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1127 // Set person plan color
1128 GLHelper::setColor(pathColor);
1129 // resolution of drawn circle depending of the zoom (To improve smoothness)
1131 // pop draw matrix
1133 }
1134 }
1135 // Draw name if isn't being drawn for selecting
1136 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
1137 // draw dotted contour
1138 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1139 }
1140 // calculate contour and draw dotted geometry
1141 if (segment->isFirstSegment() || segment->isLastSegment()) {
1142 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1143 0, segment, segment->getLane()->getParentEdge());
1144 } else {
1145 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1146 0, segment, segment->getLane()->getParentEdge());
1147 }
1148 // check if add this path element to redraw buffer
1149 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1151 }
1152 }
1153}
1154
1155
1156void
1157GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1158 // conditions for draw always in network mode
1159 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1162 // conditions for draw always in demand mode
1163 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1165 // conditions for draw if is selected
1166 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1168 // conditions for draw if is inspected
1169 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1171 // check drawing conditions
1172 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1174 // get detail level
1175 const auto d = s.getDetailLevel(1);
1176 // calculate width
1177 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1178 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1180 // Add a draw matrix
1182 // Start with the drawing of the area translating matrix to origin
1183 glTranslated(0, 0, getType() + offsetFront);
1184 // Set color of the base
1185 if (drawUsingSelectColor()) {
1187 } else {
1189 }
1190 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1191 if (segment->getPreviousLane() && segment->getNextLane()) {
1192 // draw lane2lane
1194 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1195 // draw line between center of junction and last lane shape
1196 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1197 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1198 // draw line between center of junction and first lane shape
1199 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1200 }
1201 // Pop last matrix
1203 // draw dotted contour
1204 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1205 }
1206 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1207 if (segment->getPreviousLane() && segment->getNextLane()) {
1208 // calculate contour and draw dotted geometry
1210 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1211 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1212 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1213 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1214 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1215 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1216 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1217 }
1218 // check if add this path element to redraw buffer
1219 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1221 }
1222 }
1223}
1224
1225
1226GNELane*
1228 // declare first edge
1229 GNEEdge* firstEdge = nullptr;
1230 // continue depending of tags
1232 // check departEdge
1233 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1234 // use departEdge
1235 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1236 } else {
1237 // use first route edge
1238 firstEdge = getRouteParent()->getParentEdges().front();
1239 }
1240 } else if (myTagProperty.vehicleRouteEmbedded()) {
1241 // check if embedded route exist (due during loading embedded route doesn't exist)
1242 if (getChildDemandElements().empty()) {
1243 return nullptr;
1244 }
1245 // check departEdge
1246 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1247 // use depart edge
1248 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1249 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1250 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1251 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1252 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1253 } else {
1254 return nullptr;
1255 }
1256 } else if (getParentEdges().size() > 0) {
1257 // use first parent edge
1258 firstEdge = getParentEdges().front();
1259 } else {
1260 // defined over junctions
1261 return nullptr;
1262 }
1263 // get departLane index
1264 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1265 // check departLane index
1266 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1267 return firstEdge->getLanes().at(departLaneIndex);
1268 } else {
1269 // get first allowed VClass
1270 return firstEdge->getLaneByAllowedVClass(getVClass());
1271 }
1272}
1273
1274
1275GNELane*
1277 // declare last edge
1278 GNEEdge* lastEdge = nullptr;
1279 // continue depending of tags
1281 // check arrivalEdge
1282 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1283 // use arrival edge
1284 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1285 } else {
1286 // use last route edge
1287 lastEdge = getRouteParent()->getParentEdges().back();
1288 }
1289 } else if (myTagProperty.vehicleRouteEmbedded()) {
1290 // check if embedded route exist (due during loading embedded route doesn't exist)
1291 if (getChildDemandElements().empty()) {
1292 return nullptr;
1293 }
1294 // check arrivalEdge
1295 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1296 // use arrival edge
1297 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1298 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1299 // use last route edge
1300 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1301 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1302 // use lane
1303 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1304 } else {
1305 return nullptr;
1306 }
1307 } else if (getParentEdges().size() > 0) {
1308 // use last parent edge
1309 lastEdge = getParentEdges().back();
1310 } else {
1311 // defined over junctions
1312 return nullptr;
1313 }
1314 // get arrivalLane index
1315 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1316 // check arrivalLane index
1317 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1318 return lastEdge->getLanes().at(arrivalLaneIndex);
1319 } else {
1320 // get last allowed VClass
1321 return lastEdge->getLaneByAllowedVClass(getVClass());
1322 }
1323}
1324
1325
1326std::string
1328 switch (key) {
1329 case SUMO_ATTR_ID:
1330 return getMicrosimID();
1331 case SUMO_ATTR_TYPE:
1332 return vtypeid;
1333 case SUMO_ATTR_COLOR:
1335 return toString(color);
1336 } else {
1338 }
1341 return getDepartLane();
1342 } else {
1344 }
1347 return getDepartPos();
1348 } else {
1350 }
1353 return getDepartSpeed();
1354 } else {
1356 }
1359 return getArrivalLane();
1360 } else {
1362 }
1365 return getArrivalPos();
1366 } else {
1368 }
1371 return getArrivalSpeed();
1372 } else {
1374 }
1375 case SUMO_ATTR_LINE:
1376 if (wasSet(VEHPARS_LINE_SET)) {
1377 return line;
1378 } else {
1380 }
1383 return toString(personNumber);
1384 } else {
1386 }
1389 return toString(containerNumber);
1390 } else {
1392 }
1393 case SUMO_ATTR_REROUTE:
1395 return "true";
1396 } else {
1397 return "false";
1398 }
1401 return getDepartPosLat();
1402 } else {
1404 }
1407 return getArrivalPosLat();
1408 } else {
1410 }
1412 return getInsertionChecks();
1413 // Specific of vehicles over routes
1414 case SUMO_ATTR_ROUTE:
1415 if (getParentDemandElements().size() == 2) {
1416 return getRouteParent()->getID();
1417 } else {
1418 return "";
1419 }
1420 // Specific of from-to edge
1421 case SUMO_ATTR_FROM:
1422 return getParentEdges().front()->getID();
1423 case SUMO_ATTR_TO:
1424 return getParentEdges().back()->getID();
1425 case SUMO_ATTR_VIA:
1426 return toString(via);
1428 if (departEdge == -1) {
1429 return "";
1430 } else {
1431 return toString(departEdge);
1432 }
1434 if (arrivalEdge == -1) {
1435 return "";
1436 } else {
1437 return toString(arrivalEdge);
1438 }
1439 // Specific of from-to junctions
1441 return getParentJunctions().front()->getID();
1443 return getParentJunctions().back()->getID();
1444 // Specific of from-to tazs
1445 case SUMO_ATTR_FROM_TAZ:
1446 return getParentAdditionals().front()->getID();
1447 case SUMO_ATTR_TO_TAZ:
1448 return getParentAdditionals().back()->getID();
1449 // other
1451 return getParametersStr();
1453 return toString(parametersSet);
1454 default:
1455 return getFlowAttribute(this, key);
1456 }
1457}
1458
1459
1460double
1462 switch (key) {
1465 return departLane;
1466 } else {
1467 return -1;
1468 }
1470 // only return departPos it if is given
1472 return departPos;
1473 } else {
1474 return 0;
1475 }
1478 return arrivalLane;
1479 } else {
1480 return -1;
1481 }
1483 // only return departPos it if is given
1485 return arrivalPos;
1486 } else {
1487 return -1;
1488 }
1489 case SUMO_ATTR_WIDTH:
1490 case SUMO_ATTR_LENGTH:
1491 case SUMO_ATTR_MINGAP:
1492 return getTypeParent()->getAttributeDouble(key);
1493 default:
1494 return getFlowAttributeDouble(key);
1495 }
1496}
1497
1498
1501 switch (key) {
1503 // check if this vehicle was defined over junctions
1504 if (getParentJunctions().size() > 0) {
1505 return getParentJunctions().front()->getPositionInView();
1506 } else {
1507 // get first path lane shape
1508 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1509 // check arrivalPosProcedure
1511 if (departPos < 0) {
1512 return laneShape.front();
1513 } else if (departPos > laneShape.length2D()) {
1514 return laneShape.back();
1515 } else {
1516 return laneShape.positionAtOffset2D(departPos);
1517 }
1518 } else {
1519 return laneShape.front();
1520 }
1521 }
1522 }
1524 // check if this vehicle was defined over junctions
1525 if (getParentJunctions().size() > 0) {
1526 return getParentJunctions().back()->getPositionInView();
1527 } else {
1528 // get last path lane shape
1529 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1530 // check arrivalPosProcedure
1532 if (arrivalPos < 0) {
1533 return laneShape.front();
1534 } else if (arrivalPos > laneShape.length2D()) {
1535 return laneShape.back();
1536 } else {
1537 return laneShape.positionAtOffset2D(arrivalPos);
1538 }
1539 } else {
1540 return laneShape.back();
1541 }
1542 }
1543 }
1544 default:
1545 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1546 }
1547}
1548
1549
1550void
1551GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1552 if (value == getAttribute(key)) {
1553 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1554 }
1555 switch (key) {
1556 case SUMO_ATTR_ID:
1557 case SUMO_ATTR_TYPE:
1558 case SUMO_ATTR_COLOR:
1565 case SUMO_ATTR_LINE:
1568 case SUMO_ATTR_REROUTE:
1572 // Specific of vehicles over routes
1573 case SUMO_ATTR_ROUTE:
1574 // Specific of from-to edges
1575 case SUMO_ATTR_FROM:
1576 case SUMO_ATTR_TO:
1577 case SUMO_ATTR_VIA:
1580 // Specific of from-to junctions
1583 // Specific of from-to taz
1584 case SUMO_ATTR_FROM_TAZ:
1585 case SUMO_ATTR_TO_TAZ:
1586 // other
1588 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1589 break;
1590 default:
1591 setFlowAttribute(this, key, value, undoList);
1592 break;
1593 }
1594}
1595
1596
1597bool
1598GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1599 // get ACs
1600 const auto ACs = myNet->getAttributeCarriers();
1601 // declare string error
1602 std::string error;
1603 switch (key) {
1604 case SUMO_ATTR_ID:
1606 case SUMO_ATTR_TYPE:
1607 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1608 case SUMO_ATTR_COLOR:
1609 return canParse<RGBColor>(value);
1610 case SUMO_ATTR_DEPARTLANE: {
1611 int dummyDepartLane;
1612 DepartLaneDefinition dummyDepartLaneProcedure;
1613 parseDepartLane(value, myTagProperty.getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1614 // if error is empty, check if depart lane is correct
1615 if (error.empty()) {
1616 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1617 return true;
1618 } else if (isTemplate()) {
1619 return true;
1620 } else if (getParentJunctions().size() > 0) {
1621 return (dummyDepartLane == 0);
1622 } else if (getParentAdditionals().size() > 0) {
1623 return (dummyDepartLane == 0);
1624 } else {
1625 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1626 }
1627 } else {
1628 return false;
1629 }
1630 }
1631 case SUMO_ATTR_DEPARTPOS: {
1632 double dummyDepartPos;
1633 DepartPosDefinition dummyDepartPosProcedure;
1634 parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1635 // if error is empty, given value is valid
1636 return error.empty();
1637 }
1638 case SUMO_ATTR_DEPARTSPEED: {
1639 double dummyDepartSpeed;
1640 DepartSpeedDefinition dummyDepartSpeedProcedure;
1641 parseDepartSpeed(value, myTagProperty.getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1642 // if error is empty, check if depart speed is correct
1643 if (error.empty()) {
1644 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1645 return true;
1646 } else if (isTemplate()) {
1647 return true;
1648 } else {
1649 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1650 }
1651 } else {
1652 return false;
1653 }
1654 }
1655 case SUMO_ATTR_ARRIVALLANE: {
1656 int dummyArrivalLane;
1657 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1658 parseArrivalLane(value, myTagProperty.getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1659 // if error is empty, given value is valid
1660 if (error.empty()) {
1661 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1662 return true;
1663 } else if (isTemplate()) {
1664 return true;
1665 } else if (getParentJunctions().size() > 0) {
1666 return (dummyArrivalLane == 0);
1667 } else if (getParentAdditionals().size() > 0) {
1668 return (dummyArrivalLane == 0);
1669 } else {
1670 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1671 }
1672 } else {
1673 return false;
1674 }
1675 }
1676 case SUMO_ATTR_ARRIVALPOS: {
1677 double dummyArrivalPos;
1678 ArrivalPosDefinition dummyArrivalPosProcedure;
1679 parseArrivalPos(value, myTagProperty.getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1680 // if error is empty, given value is valid
1681 return error.empty();
1682 }
1684 double dummyArrivalSpeed;
1685 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1686 parseArrivalSpeed(value, myTagProperty.getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1687 // if error is empty, given value is valid
1688 return error.empty();
1689 }
1690 case SUMO_ATTR_LINE:
1691 return true;
1693 return canParse<int>(value) && parse<int>(value) >= 0;
1695 return canParse<int>(value) && parse<int>(value) >= 0;
1696 case SUMO_ATTR_REROUTE:
1697 return true; // check
1699 double dummyDepartPosLat;
1700 DepartPosLatDefinition dummyDepartPosLatProcedure;
1701 parseDepartPosLat(value, myTagProperty.getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1702 // if error is empty, given value is valid
1703 return error.empty();
1704 }
1706 double dummyArrivalPosLat;
1707 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1708 parseArrivalPosLat(value, myTagProperty.getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1709 // if error is empty, given value is valid
1710 return error.empty();
1711 }
1713 return areInsertionChecksValid(value);
1714 // Specific of vehicles over routes
1715 case SUMO_ATTR_ROUTE:
1716 if (getParentDemandElements().size() == 2) {
1717 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1718 } else {
1719 return true;
1720 }
1721 // Specific of from-to edges
1722 case SUMO_ATTR_FROM:
1723 case SUMO_ATTR_TO:
1724 return (ACs->retrieveEdge(value, false) != nullptr);
1726 case SUMO_ATTR_ARRIVALEDGE: {
1727 if (value.empty()) {
1728 return true;
1729 } else if (canParse<int>(value)) {
1730 // get index
1731 const int index = parse<int>(value);
1732 // check conditions
1733 if (index < 0) {
1734 return false;
1735 } else if (myTagProperty.vehicleRoute()) {
1736 // check parent route
1737 return (index < (int)getRouteParent()->getParentEdges().size());
1738 } else {
1739 // check embedded route
1740 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1741 }
1742 } else {
1743 return false;
1744 }
1745 }
1746 case SUMO_ATTR_VIA:
1747 if (value.empty()) {
1748 return true;
1749 } else {
1750 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1751 }
1752 // Specific of from-to junctions
1755 return (ACs->retrieveJunction(value, false) != nullptr);
1756 // Specific of from-to taz
1757 case SUMO_ATTR_FROM_TAZ:
1758 case SUMO_ATTR_TO_TAZ:
1759 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1760 // other
1763 default:
1764 return isValidFlowAttribute(this, key, value);
1765 }
1766}
1767
1768
1769void
1771 enableFlowAttribute(this, key, undoList);
1772}
1773
1774
1775void
1777 disableFlowAttribute(this, key, undoList);
1778}
1779
1780
1781bool
1785
1786
1787std::string
1789 return getTagStr();
1790}
1791
1792
1793std::string
1795 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1796 // special case for Trips and flow
1798 // check if we're inspecting a Edge
1799 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty().getTag() == SUMO_TAG_EDGE)) {
1800 // check if edge correspond to a "from", "to" or "via" edge
1801 if (inspectedElements.isACInspected(getParentEdges().front())) {
1802 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1803 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1804 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1805 } else {
1806 // iterate over via
1807 for (const auto& viaEdgeID : via) {
1808 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1809 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1810 }
1811 }
1812 }
1813 }
1814 }
1815 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1816}
1817
1818
1819const Parameterised::Map&
1823
1824
1826GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1827 // get net and undoList
1828 const auto net = originalVehicle->getNet();
1829 auto undoList = net->getViewNet()->getUndoList();
1830 // declare new route, vehicle and embedded route
1831 GNERoute* newRoute = nullptr;
1832 GNEVehicle* newVehicle = nullptr;
1833 GNERoute* newEmbeddedRoute = nullptr;
1834 // generate new vehicle ID
1835 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1836 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty().getTag());
1837 // extract vehicle parameters and update ID
1838 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1839 newVehicleParameters.id = newVehicleID;
1840 // create vehicle using vehicleParameters
1841 if (originalVehicle->getTagProperty().vehicleRoute()) {
1842 newRoute = new GNERoute(net, newRouteID, originalVehicle->getParentDemandElements().at(1));
1843 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1844 originalVehicle->getParentDemandElements().at(0), newRoute,
1845 newVehicleParameters);
1846 } else if (originalVehicle->getTagProperty().vehicleRouteEmbedded()) {
1847 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1848 originalVehicle->getParentDemandElements().at(0),
1849 newVehicleParameters);
1850 newEmbeddedRoute = new GNERoute(net, newVehicle, originalVehicle->getChildDemandElements().front());
1851 } else if (originalVehicle->getTagProperty().vehicleEdges()) {
1852 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1853 originalVehicle->getParentDemandElements().at(0),
1854 originalVehicle->getParentEdges().front(),
1855 originalVehicle->getParentEdges().back(),
1856 newVehicleParameters);
1857 } else if (originalVehicle->getTagProperty().vehicleJunctions()) {
1858 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1859 originalVehicle->getParentDemandElements().at(0),
1860 originalVehicle->getParentJunctions().front(),
1861 originalVehicle->getParentJunctions().back(),
1862 newVehicleParameters);
1863 } else if (originalVehicle->getTagProperty().vehicleTAZs()) {
1864 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1865 originalVehicle->getParentDemandElements().at(0),
1866 originalVehicle->getParentAdditionals().front(),
1867 originalVehicle->getParentAdditionals().back(),
1868 newVehicleParameters);
1869 }
1870 // add new vehicle
1871 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1872 if (newRoute) {
1873 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1874 }
1875 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1876 if (newEmbeddedRoute) {
1877 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1878 }
1879 undoList->end();
1880 return newVehicle;
1881}
1882
1883// ===========================================================================
1884// protected
1885// ===========================================================================
1886
1889 // change color
1890 if (drawUsingSelectColor()) {
1892 } else {
1893 return getColorByScheme(s.vehicleColorer, this);
1894 }
1895}
1896
1897
1900 return *this;
1901}
1902
1903// ===========================================================================
1904// private
1905// ===========================================================================
1906
1907void
1908GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1909 // declare string error
1910 std::string error;
1911 // flag to upate stack label
1912 bool updateSpreadStackGeometry = false;
1913 switch (key) {
1914 case SUMO_ATTR_ID:
1915 // update microsimID
1916 setDemandElementID(value);
1917 // set manually vehicle ID (needed for saving)
1918 id = value;
1919 break;
1920 case SUMO_ATTR_TYPE:
1921 if (getID().size() > 0) {
1922 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1924 } else {
1926 }
1927 // set manually vtypeID (needed for saving)
1928 vtypeid = value;
1929 }
1930 break;
1931 case SUMO_ATTR_COLOR:
1932 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1933 color = parse<RGBColor>(value);
1934 // mark parameter as set
1936 } else {
1937 // set default value
1938 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1939 // unset parameter
1940 parametersSet &= ~VEHPARS_COLOR_SET;
1941 }
1942 break;
1944 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1946 // mark parameter as set
1948 } else {
1949 // set default value
1951 // unset parameter
1952 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1953 }
1954 break;
1956 if (value == toString(INVALID_DOUBLE)) {
1958 // mark parameter as set
1960 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1962 // mark parameter as set
1964 } else {
1965 // set default value
1967 // unset parameter
1968 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1969 }
1970 if (getID().size() > 0) {
1972 updateSpreadStackGeometry = true;
1973 }
1974 break;
1976 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1978 // mark parameter as set
1980 } else {
1981 // set default value
1983 // unset parameter
1984 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1985 }
1986 break;
1988 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1990 // mark parameter as set
1992 } else {
1993 // set default value
1995 // unset parameter
1996 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
1997 }
1998 break;
2000 if (value == toString(INVALID_DOUBLE)) {
2002 // mark parameter as set
2004 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2006 // mark parameter as set
2008 } else {
2009 // set default value
2011 // unset parameter
2012 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2013 }
2014 if (getID().size() > 0) {
2016 updateSpreadStackGeometry = true;
2017 }
2018 break;
2020 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2022 // mark parameter as set
2024 } else {
2025 // set default value
2027 // unset parameter
2028 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2029 }
2030 break;
2031 case SUMO_ATTR_LINE:
2032 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2033 line = value;
2034 // mark parameter as set
2036 } else {
2037 // set default value
2039 // unset parameter
2040 parametersSet &= ~VEHPARS_LINE_SET;
2041 }
2042 break;
2044 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2045 personNumber = parse<int>(value);
2046 // mark parameter as set
2048 } else {
2049 // set default value
2050 personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2051 // unset parameter
2052 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2053 }
2054 break;
2056 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2057 containerNumber = parse<int>(value);
2058 // mark parameter as set
2060 } else {
2061 // set default value
2063 // unset parameter
2064 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2065 }
2066 break;
2067 case SUMO_ATTR_REROUTE:
2068 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2069 // mark parameter as set
2071 } else {
2072 // unset parameter
2073 parametersSet &= ~VEHPARS_ROUTE_SET;
2074 }
2075 break;
2077 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2079 // mark parameter as set
2081 } else {
2082 // set default value
2084 // unset parameter
2085 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2086 }
2087 break;
2089 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2091 // mark parameter as set
2093 } else {
2094 // set default value
2096 // unset parameter
2097 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2098 }
2100 break;
2103 break;
2104 // Specific of vehicles over routes
2105 case SUMO_ATTR_ROUTE:
2106 if (getParentDemandElements().size() == 2) {
2108 }
2110 updateSpreadStackGeometry = true;
2111 break;
2112 // Specific of from-to edges
2113 case SUMO_ATTR_FROM: {
2114 // change first edge
2116 // compute vehicle
2118 updateSpreadStackGeometry = true;
2119 break;
2120 }
2121 case SUMO_ATTR_TO: {
2122 // change last edge
2123 replaceLastParentEdge(value);
2124 // compute vehicle
2126 updateSpreadStackGeometry = true;
2127 break;
2128 }
2129 case SUMO_ATTR_VIA: {
2130 if (!value.empty()) {
2131 // set new via edges
2132 via = parse< std::vector<std::string> >(value);
2133 // mark parameter as set
2135 } else {
2136 // clear via
2137 via.clear();
2138 // unset parameter
2139 parametersSet &= ~VEHPARS_VIA_SET;
2140 }
2141 // compute vehicle
2143 updateSpreadStackGeometry = true;
2144 break;
2145 }
2146 case SUMO_ATTR_DEPARTEDGE: {
2147 // update depart edge
2148 if (value.empty()) {
2149 // unset parameter
2150 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2151 departEdge = -1;
2153 } else {
2154 // mark parameter as set
2156 departEdge = parse<int>(value);
2158 }
2159 // compute vehicle
2160 if (getID().size() > 0) {
2162 updateSpreadStackGeometry = true;
2163 }
2164 break;
2165 }
2166 case SUMO_ATTR_ARRIVALEDGE: {
2167 // update arrival edge
2168 if (value.empty()) {
2169 // unset parameter
2170 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2171 arrivalEdge = -1;
2173 } else {
2174 // mark parameter as set
2176 arrivalEdge = parse<int>(value);
2178 }
2179 if (getID().size() > 0) {
2180 // compute vehicle
2182 updateSpreadStackGeometry = true;
2183 }
2184 break;
2185 }
2186 // Specific of from-to junctions
2188 // change first junction
2190 // compute vehicle
2192 updateSpreadStackGeometry = true;
2193 break;
2194 }
2195 case SUMO_ATTR_TO_JUNCTION: {
2196 // change last junction
2198 // compute vehicle
2200 updateSpreadStackGeometry = true;
2201 break;
2202 }
2203 // Specific of from-to TAZs
2204 case SUMO_ATTR_FROM_TAZ: {
2205 // change first additional
2207 // set taz manually
2208 fromTaz = value;
2209 // compute vehicle
2211 updateSpreadStackGeometry = true;
2212 break;
2213 }
2214 case SUMO_ATTR_TO_TAZ: {
2215 // change last additional
2217 // set taz manually
2218 toTaz = value;
2219 // compute vehicle
2221 updateSpreadStackGeometry = true;
2222 break;
2223 }
2224 // other
2226 setParametersStr(value);
2227 break;
2228 default:
2229 setFlowAttribute(this, key, value);
2230 break;
2231 }
2232 // check if stack label has to be updated
2233 if (updateSpreadStackGeometry) {
2235 getParentEdges().front()->updateVehicleStackLabels();
2236 getParentEdges().front()->updateVehicleSpreadGeometries();
2237 } else if (myTagProperty.vehicleRoute()) {
2238 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2239 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2240 } else if (myTagProperty.vehicleRouteEmbedded()) {
2241 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2242 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2243 }
2244 }
2245}
2246
2247
2248void
2250 // toggle flow attributes
2251 toggleFlowAttribute(key, value);
2252}
2253
2254
2255void
2257 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2259 // change depart
2262 departPos = moveResult.newFirstPos;
2263 }
2266 // change arrival
2269 arrivalPos = moveResult.newFirstPos;
2270 }
2271 // set lateral offset
2273 // update geometry
2275}
2276
2277
2278void
2280 // reset lateral offset
2282 // check value
2283 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2284 // continue depending if we're moving first or last position
2286 // begin change attribute
2287 undoList->begin(this, TLF("departPos of %", getTagStr()));
2288 // now set departPos
2289 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2290 // check if depart lane has to be changed
2291 if (moveResult.newFirstLane) {
2292 // set new depart lane
2294 }
2295 } else {
2296 // begin change attribute
2297 undoList->begin(this, TLF("arrivalPos of %", getTagStr()));
2298 // now set arrivalPos
2299 setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newFirstPos), undoList);
2300 // check if arrival lane has to be changed
2301 if (moveResult.newFirstLane) {
2302 // set new arrival lane
2304 }
2305 }
2306 }
2307 // end change attribute
2308 undoList->end();
2309}
2310
2311/****************************************************************************/
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_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition GUIAppEnum.h:455
@ 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_COPY_NAME
Copy object name - popup entry.
Definition GUIAppEnum.h:453
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_JUNCTIONS
transform vehicle to flow over jucntions
@ GLO_TRIP
a trip
@ GLO_ROUTEFLOW
a routeFlow
@ GLO_FLOW
a flow
@ GLO_VEHICLE
a vehicle
GUIViewObjectsHandler gViewObjectsHandler
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
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
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ GNE_TAG_FLOW_TAZS
a flow between TAZs
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_TO_JUNCTION
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ SUMO_ATTR_MINGAP
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_LINE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_CENTER
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_DEPARTLANE
@ GNE_ATTR_PLAN_GEOMETRY_ENDPOS
person/container geometry end position
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_INSERTIONCHECKS
@ SUMO_ATTR_WIDTH
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
const double SUMO_const_halfLaneWidth
Definition StdDefs.h:49
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:78
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:343
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:782
An Element which don't belong to GNENet but has influence in the simulation.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
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
void resetDefaultValues()
reset attribute carrier to their default values
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 writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:1118
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:1534
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:662
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:620
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:208
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:196
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
bool getAllowChangeLane() const
allow change lane
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition GNENet.h:42
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:145
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2163
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, SumoXMLTag tag)
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
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...
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
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:62
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:89
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:35
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
GNEVehicle * myVehicle
current vehicle
Definition GNEVehicle.h:58
const Parameterised::Map & getACParametersMap() const
get parameters map
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNEMoveOperation * getMoveOperation()
get move operation
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
void computePathElement()
compute pathElement
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition GNEVehicle.h:302
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
double getAttributeDouble(SumoXMLAttr key) const
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAttributeEnabled(SumoXMLAttr key) const
const RGBColor & getColor() const
get color
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition GNEVehicle.h:312
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
void updateGeometry()
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
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
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEMoveFrame * getMoveFrame() const
get frame for move elements
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.
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.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
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.
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 addName
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
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
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:281
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:322
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:276
double x() const
Returns the x-position.
Definition Position.h:55
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:286
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition RGBColor.h:185
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
bool areInsertionChecksValid(const std::string &value) const
check if given insertion checks are valid
double arrivalPos
(optional) The position the vehicle shall arrive on
static int parseInsertionChecks(const std::string &value)
parses insertion checks
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string getInsertionChecks() const
get insertion checks in string format
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int insertionChecks
bitset of InsertionCheck
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
#define M_PI
Definition odrSpiral.cpp:45
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
bool showAllTrips() const
check if trips has to be drawn
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor vehicleTripColor
color for vehicle trips
RGBColor selectedVehicleColor
vehicle selection color
static const double segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size