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 const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
870 // obtain Position an rotation (depending of draw spread vehicles)
871 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
872 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
873 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
874 // check that position is valid
875 if (vehiclePosition == Position::INVALID) {
876 return;
877 }
878 // get detail level
879 const auto d = s.getDetailLevel(exaggeration);
880 // draw geometry only if we'rent in drawForObjectUnderCursor mode
882 // first check if if mouse is enough near to this vehicle to draw it
883 if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
884 // push draw matrix
886 // Start with the drawing of the area translating matrix to origin
888 // translate to drawing position
889 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
890 glRotated(vehicleRotation, 0, 0, -1);
891 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
892 glTranslated(0, (-1) * length * exaggeration, 0);
893 GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
894 // Pop last matrix
896 } else {
898 // push draw matrix
900 // Start with the drawing of the area translating matrix to origin
902 // translate to drawing position
903 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
904 glRotated(vehicleRotation, 0, 0, -1);
905 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
906 glTranslated(0, (-1) * length * exaggeration, 0);
907 // set lane color
909 double upscaleLength = exaggeration;
910 if ((exaggeration > 1) && (length > 5)) {
911 // reduce the length/width ratio because this is not useful at high zoom
912 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
913 }
914 glScaled(exaggeration, upscaleLength, 1);
915 // check if we're drawing in selecting mode
917 // draw vehicle as a box and don't draw the rest of details
919 } else {
920 // draw the vehicle depending of detail level
927 }
928 // check if min gap has to be drawn
929 if (s.drawMinGap) {
930 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
931 glColor3d(0., 1., 0.);
932 glBegin(GL_LINES);
933 glVertex2d(0., 0);
934 glVertex2d(0., minGap);
935 glVertex2d(-.5, minGap);
936 glVertex2d(.5, minGap);
937 glEnd();
938 }
939 // drawing name at GLO_MAX fails unless translating z
940 glTranslated(0, MIN2(length / 2, double(5)), -getType());
941 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
942 glRotated(vehicleRotation, 0, 0, -1);
944 // draw line
945 if (s.vehicleName.show(this) && line != "") {
946 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
948 }
949 }
950 // pop draw matrix
952 // draw line between junctions if path isn't valid
953 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
954 drawJunctionLine(this);
955 }
956 // draw stack label
957 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
958 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
959 }
960 // draw flow label
961 if (myTagProperty.isFlow()) {
962 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
963 }
964 }
965 // draw lock icon
966 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
967 // draw dotted contour
969 }
970 // draw squared shape
971 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(), length * -0.5, 0, vehicleRotation, exaggeration);
972 }
973 }
974}
975
976
977void
979 // calculate path (only for flows and trips)
981 // calculate path
983 } else if (myTagProperty.vehicleEdges()) {
984 // save edges in wich this vehicle has to stop
985 std::vector<GNEEdge*> edgeStops;
986 // iterate over child demand elements
987 for (const auto& demandElement : getChildDemandElements()) {
988 // extract lanes
989 if (demandElement->getTagProperty().isVehicleStop()) {
990 GNEEdge* edgeStop = nullptr;
991 if (demandElement->getParentAdditionals().size() > 0) {
992 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
993 } else {
994 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
995 }
996 if (edgeStop) {
997 // avoid double edge stops
998 if (stops.empty()) {
999 edgeStops.push_back(edgeStop);
1000 } else if (edgeStops.back() != edgeStop) {
1001 edgeStops.push_back(edgeStop);
1002 }
1003 }
1004 }
1005 }
1006 // declare edge vector
1007 std::vector<GNEEdge*> edgePath;
1008 // get first and last lanes
1009 const auto firstLane = getFirstPathLane();
1010 const auto lastLane = getLastPathLane();
1011 // check first and last lanes
1012 if (firstLane && lastLane) {
1013 // add first lane
1014 edgePath.push_back(firstLane->getParentEdge());
1015 // give more priority to stops instead via
1016 if (edgeStops.size() > 0) {
1017 // add stops only if they're accesibles
1018 for (const auto& edgeStop : edgeStops) {
1019 // check if exist a valid path that includes the last edge
1020 auto edgePathStop = edgePath;
1021 edgePathStop.push_back(edgeStop);
1022 edgePathStop.push_back(lastLane->getParentEdge());
1024 if (path.size() > 0) {
1025 edgePath.push_back(edgeStop);
1026 }
1027 }
1028 } else {
1029 // add via lanes
1030 for (const auto& edgeViaID : via) {
1031 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1032 if (edgeVia) {
1033 // check if exist a valid path that includes the last edge
1034 auto edgePathStop = edgePath;
1035 edgePathStop.push_back(edgeVia);
1036 edgePathStop.push_back(lastLane->getParentEdge());
1037 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1038 edgePath.push_back(edgeVia);
1039 }
1040 }
1041 }
1042 }
1043 // add last lane
1044 edgePath.push_back(lastLane->getParentEdge());
1045 // calculate path
1046 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1047 }
1048 }
1049 // update geometry
1051}
1052
1053
1054void
1055GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1056 // conditions for draw always in network mode
1057 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1060 // conditions for draw always in demand mode
1061 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1063 // conditions for draw if is selected
1064 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1066 // conditions for draw if is inspected
1067 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1069 // check drawing conditions
1070 if (segment->getLane() && !s.drawForRectangleSelection && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1072 // get detail level
1073 const auto d = s.getDetailLevel(1);
1074 // calculate width
1075 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1076 // calculate startPos
1077 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1078 // get endPos
1079 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1080 // declare path geometry
1081 GUIGeometry vehicleGeometry;
1082 // update pathGeometry depending of first and last segment
1083 if (segment->isFirstSegment() && segment->isLastSegment()) {
1084 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1085 geometryDepartPos,
1087 geometryEndPos,
1089 } else if (segment->isFirstSegment()) {
1090 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1091 geometryDepartPos,
1093 -1,
1095 } else if (segment->isLastSegment()) {
1096 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1097 -1,
1099 geometryEndPos,
1101 } else {
1102 vehicleGeometry = segment->getLane()->getLaneGeometry();
1103 }
1104 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1106 // obtain color
1108 // Add a draw matrix
1110 // Start with the drawing of the area translating matrix to origin
1111 glTranslated(0, 0, getType() + offsetFront);
1112 // Set color
1113 GLHelper::setColor(pathColor);
1114 // draw geometry
1115 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1116 // Pop last matrix
1118 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1119 if (segment->getNextLane()) {
1120 // push draw matrix
1122 // Start with the drawing of the area translating matrix to origin
1124 // Set red color
1126 // get firstPosition (last position of current lane shape)
1127 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1128 // get lastPosition (first position of next lane shape)
1129 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1130 // draw box line
1131 GLHelper::drawBoxLine(arrivalPosition,
1132 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1133 firstPosition.distanceTo2D(arrivalPosition), .05);
1134 // pop draw matrix
1136 }
1137 // check if this is the last segment
1138 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1139 // get geometryEndPos
1140 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1141 // check if endPos can be drawn
1143 // push draw matrix
1145 // Start with the drawing of the area translating matrix to origin
1147 // translate to geometryEndPos
1148 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1149 // Set person plan color
1150 GLHelper::setColor(pathColor);
1151 // resolution of drawn circle depending of the zoom (To improve smoothness)
1153 // pop draw matrix
1155 }
1156 }
1157 // Draw name if isn't being drawn for selecting
1158 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
1159 // draw dotted contour
1160 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1161 }
1162 // calculate contour and draw dotted geometry
1163 if (segment->isFirstSegment() || segment->isLastSegment()) {
1164 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0, segment);
1165 } else {
1166 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0, segment);
1167 }
1168 // check if add this path element to redraw buffer
1169 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1171 }
1172 }
1173}
1174
1175
1176void
1177GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1178 // conditions for draw always in network mode
1179 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1182 // conditions for draw always in demand mode
1183 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1185 // conditions for draw if is selected
1186 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1188 // conditions for draw if is inspected
1189 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1191 // check drawing conditions
1192 if (segment->getJunction() && !s.drawForRectangleSelection && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1194 // get detail level
1195 const auto d = s.getDetailLevel(1);
1196 // calculate width
1197 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1198 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1200 // Add a draw matrix
1202 // Start with the drawing of the area translating matrix to origin
1203 glTranslated(0, 0, getType() + offsetFront);
1204 // Set color of the base
1205 if (drawUsingSelectColor()) {
1207 } else {
1209 }
1210 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1211 if (segment->getPreviousLane() && segment->getNextLane()) {
1212 // draw lane2lane
1214 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1215 // draw line between center of junction and last lane shape
1216 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1217 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1218 // draw line between center of junction and first lane shape
1219 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1220 }
1221 // Pop last matrix
1223 // draw dotted contour
1224 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1225 }
1226 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1227 if (segment->getPreviousLane() && segment->getNextLane()) {
1228 // calculate contour and draw dotted geometry
1230 getType(), width, 1, false, false, 0, segment);
1231 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1232 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1233 getType(), width, 1, true, true, 0, segment);
1234 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1235 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1236 getType(), width, 1, true, true, 0, segment);
1237 }
1238 // check if add this path element to redraw buffer
1239 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1241 }
1242 }
1243}
1244
1245
1246GNELane*
1248 // declare first edge
1249 GNEEdge* firstEdge = nullptr;
1250 // continue depending of tags
1252 // check departEdge
1253 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1254 // use departEdge
1255 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1256 } else {
1257 // use first route edge
1258 firstEdge = getRouteParent()->getParentEdges().front();
1259 }
1260 } else if (myTagProperty.vehicleRouteEmbedded()) {
1261 // check if embedded route exist (due during loading embedded route doesn't exist)
1262 if (getChildDemandElements().empty()) {
1263 return nullptr;
1264 }
1265 // check departEdge
1266 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1267 // use depart edge
1268 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1269 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1270 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1271 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1272 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1273 } else {
1274 return nullptr;
1275 }
1276 } else if (getParentEdges().size() > 0) {
1277 // use first parent edge
1278 firstEdge = getParentEdges().front();
1279 } else {
1280 // defined over junctions
1281 return nullptr;
1282 }
1283 // get departLane index
1284 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1285 // check departLane index
1286 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1287 return firstEdge->getLanes().at(departLaneIndex);
1288 } else {
1289 // get first allowed VClass
1290 return firstEdge->getLaneByAllowedVClass(getVClass());
1291 }
1292}
1293
1294
1295GNELane*
1297 // declare last edge
1298 GNEEdge* lastEdge = nullptr;
1299 // continue depending of tags
1301 // check arrivalEdge
1302 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1303 // use arrival edge
1304 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1305 } else {
1306 // use last route edge
1307 lastEdge = getRouteParent()->getParentEdges().back();
1308 }
1309 } else if (myTagProperty.vehicleRouteEmbedded()) {
1310 // check if embedded route exist (due during loading embedded route doesn't exist)
1311 if (getChildDemandElements().empty()) {
1312 return nullptr;
1313 }
1314 // check arrivalEdge
1315 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1316 // use arrival edge
1317 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1318 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1319 // use last route edge
1320 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1321 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1322 // use lane
1323 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1324 } else {
1325 return nullptr;
1326 }
1327 } else if (getParentEdges().size() > 0) {
1328 // use last parent edge
1329 lastEdge = getParentEdges().back();
1330 } else {
1331 // defined over junctions
1332 return nullptr;
1333 }
1334 // get arrivalLane index
1335 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1336 // check arrivalLane index
1337 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1338 return lastEdge->getLanes().at(arrivalLaneIndex);
1339 } else {
1340 // get last allowed VClass
1341 return lastEdge->getLaneByAllowedVClass(getVClass());
1342 }
1343}
1344
1345
1346std::string
1348 switch (key) {
1349 case SUMO_ATTR_ID:
1350 return getMicrosimID();
1351 case SUMO_ATTR_TYPE:
1352 return vtypeid;
1353 case SUMO_ATTR_COLOR:
1355 return toString(color);
1356 } else {
1358 }
1361 return getDepartLane();
1362 } else {
1364 }
1367 return getDepartPos();
1368 } else {
1370 }
1373 return getDepartSpeed();
1374 } else {
1376 }
1379 return getArrivalLane();
1380 } else {
1382 }
1385 return getArrivalPos();
1386 } else {
1388 }
1391 return getArrivalSpeed();
1392 } else {
1394 }
1395 case SUMO_ATTR_LINE:
1396 if (wasSet(VEHPARS_LINE_SET)) {
1397 return line;
1398 } else {
1400 }
1403 return toString(personNumber);
1404 } else {
1406 }
1409 return toString(containerNumber);
1410 } else {
1412 }
1413 case SUMO_ATTR_REROUTE:
1415 return "true";
1416 } else {
1417 return "false";
1418 }
1421 return getDepartPosLat();
1422 } else {
1424 }
1427 return getArrivalPosLat();
1428 } else {
1430 }
1432 return getInsertionChecks();
1433 // Specific of vehicles over routes
1434 case SUMO_ATTR_ROUTE:
1435 if (getParentDemandElements().size() == 2) {
1436 return getRouteParent()->getID();
1437 } else {
1438 return "";
1439 }
1440 // Specific of from-to edge
1441 case SUMO_ATTR_FROM:
1442 return getParentEdges().front()->getID();
1443 case SUMO_ATTR_TO:
1444 return getParentEdges().back()->getID();
1445 case SUMO_ATTR_VIA:
1446 return toString(via);
1448 if (departEdge == -1) {
1449 return "";
1450 } else {
1451 return toString(departEdge);
1452 }
1454 if (arrivalEdge == -1) {
1455 return "";
1456 } else {
1457 return toString(arrivalEdge);
1458 }
1459 // Specific of from-to junctions
1461 return getParentJunctions().front()->getID();
1463 return getParentJunctions().back()->getID();
1464 // Specific of from-to tazs
1465 case SUMO_ATTR_FROM_TAZ:
1466 return getParentAdditionals().front()->getID();
1467 case SUMO_ATTR_TO_TAZ:
1468 return getParentAdditionals().back()->getID();
1469 // other
1470 case GNE_ATTR_SELECTED:
1473 return getParametersStr();
1475 return toString(parametersSet);
1476 default:
1477 return getFlowAttribute(key);
1478 }
1479}
1480
1481
1482double
1484 switch (key) {
1487 return departLane;
1488 } else {
1489 return -1;
1490 }
1492 // only return departPos it if is given
1494 return departPos;
1495 } else {
1496 return 0;
1497 }
1500 return arrivalLane;
1501 } else {
1502 return -1;
1503 }
1505 // only return departPos it if is given
1507 return arrivalPos;
1508 } else {
1509 return -1;
1510 }
1511 case SUMO_ATTR_WIDTH:
1512 case SUMO_ATTR_LENGTH:
1513 case SUMO_ATTR_MINGAP:
1514 return getTypeParent()->getAttributeDouble(key);
1515 default:
1516 return getFlowAttributeDouble(key);
1517 }
1518}
1519
1520
1523 switch (key) {
1525 // check if this vehicle was defined over junctions
1526 if (getParentJunctions().size() > 0) {
1527 return getParentJunctions().front()->getPositionInView();
1528 } else {
1529 // get first path lane shape
1530 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1531 // check arrivalPosProcedure
1533 if (departPos < 0) {
1534 return laneShape.front();
1535 } else if (departPos > laneShape.length2D()) {
1536 return laneShape.back();
1537 } else {
1538 return laneShape.positionAtOffset2D(departPos);
1539 }
1540 } else {
1541 return laneShape.front();
1542 }
1543 }
1544 }
1546 // check if this vehicle was defined over junctions
1547 if (getParentJunctions().size() > 0) {
1548 return getParentJunctions().back()->getPositionInView();
1549 } else {
1550 // get last path lane shape
1551 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1552 // check arrivalPosProcedure
1554 if (arrivalPos < 0) {
1555 return laneShape.front();
1556 } else if (arrivalPos > laneShape.length2D()) {
1557 return laneShape.back();
1558 } else {
1559 return laneShape.positionAtOffset2D(arrivalPos);
1560 }
1561 } else {
1562 return laneShape.back();
1563 }
1564 }
1565 }
1566 default:
1567 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1568 }
1569}
1570
1571
1572void
1573GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1574 if (value == getAttribute(key)) {
1575 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1576 }
1577 switch (key) {
1578 case SUMO_ATTR_ID:
1579 case SUMO_ATTR_TYPE:
1580 case SUMO_ATTR_COLOR:
1587 case SUMO_ATTR_LINE:
1590 case SUMO_ATTR_REROUTE:
1594 // Specific of vehicles over routes
1595 case SUMO_ATTR_ROUTE:
1596 // Specific of from-to edges
1597 case SUMO_ATTR_FROM:
1598 case SUMO_ATTR_TO:
1599 case SUMO_ATTR_VIA:
1602 // Specific of from-to junctions
1605 // Specific of from-to taz
1606 case SUMO_ATTR_FROM_TAZ:
1607 case SUMO_ATTR_TO_TAZ:
1608 // other
1610 case GNE_ATTR_SELECTED:
1611 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1612 break;
1613 default:
1614 setFlowAttribute(this, key, value, undoList);
1615 break;
1616 }
1617}
1618
1619
1620bool
1621GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1622 // get ACs
1623 const auto ACs = myNet->getAttributeCarriers();
1624 // declare string error
1625 std::string error;
1626 switch (key) {
1627 case SUMO_ATTR_ID:
1629 case SUMO_ATTR_TYPE:
1630 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1631 case SUMO_ATTR_COLOR:
1632 return canParse<RGBColor>(value);
1633 case SUMO_ATTR_DEPARTLANE: {
1634 int dummyDepartLane;
1635 DepartLaneDefinition dummyDepartLaneProcedure;
1636 parseDepartLane(value, myTagProperty.getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1637 // if error is empty, check if depart lane is correct
1638 if (error.empty()) {
1639 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1640 return true;
1641 } else if (isTemplate()) {
1642 return true;
1643 } else if (getParentJunctions().size() > 0) {
1644 return (dummyDepartLane == 0);
1645 } else if (getParentAdditionals().size() > 0) {
1646 return (dummyDepartLane == 0);
1647 } else {
1648 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1649 }
1650 } else {
1651 return false;
1652 }
1653 }
1654 case SUMO_ATTR_DEPARTPOS: {
1655 double dummyDepartPos;
1656 DepartPosDefinition dummyDepartPosProcedure;
1657 parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1658 // if error is empty, given value is valid
1659 return error.empty();
1660 }
1661 case SUMO_ATTR_DEPARTSPEED: {
1662 double dummyDepartSpeed;
1663 DepartSpeedDefinition dummyDepartSpeedProcedure;
1664 parseDepartSpeed(value, myTagProperty.getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1665 // if error is empty, check if depart speed is correct
1666 if (error.empty()) {
1667 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1668 return true;
1669 } else if (isTemplate()) {
1670 return true;
1671 } else {
1672 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1673 }
1674 } else {
1675 return false;
1676 }
1677 }
1678 case SUMO_ATTR_ARRIVALLANE: {
1679 int dummyArrivalLane;
1680 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1681 parseArrivalLane(value, myTagProperty.getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1682 // if error is empty, given value is valid
1683 if (error.empty()) {
1684 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1685 return true;
1686 } else if (isTemplate()) {
1687 return true;
1688 } else if (getParentJunctions().size() > 0) {
1689 return (dummyArrivalLane == 0);
1690 } else if (getParentAdditionals().size() > 0) {
1691 return (dummyArrivalLane == 0);
1692 } else {
1693 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1694 }
1695 } else {
1696 return false;
1697 }
1698 }
1699 case SUMO_ATTR_ARRIVALPOS: {
1700 double dummyArrivalPos;
1701 ArrivalPosDefinition dummyArrivalPosProcedure;
1702 parseArrivalPos(value, myTagProperty.getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1703 // if error is empty, given value is valid
1704 return error.empty();
1705 }
1707 double dummyArrivalSpeed;
1708 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1709 parseArrivalSpeed(value, myTagProperty.getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1710 // if error is empty, given value is valid
1711 return error.empty();
1712 }
1713 case SUMO_ATTR_LINE:
1714 return true;
1716 return canParse<int>(value) && parse<int>(value) >= 0;
1718 return canParse<int>(value) && parse<int>(value) >= 0;
1719 case SUMO_ATTR_REROUTE:
1720 return true; // check
1722 double dummyDepartPosLat;
1723 DepartPosLatDefinition dummyDepartPosLatProcedure;
1724 parseDepartPosLat(value, myTagProperty.getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1725 // if error is empty, given value is valid
1726 return error.empty();
1727 }
1729 double dummyArrivalPosLat;
1730 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1731 parseArrivalPosLat(value, myTagProperty.getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1732 // if error is empty, given value is valid
1733 return error.empty();
1734 }
1736 return areInsertionChecksValid(value);
1737 // Specific of vehicles over routes
1738 case SUMO_ATTR_ROUTE:
1739 if (getParentDemandElements().size() == 2) {
1740 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1741 } else {
1742 return true;
1743 }
1744 // Specific of from-to edges
1745 case SUMO_ATTR_FROM:
1746 case SUMO_ATTR_TO:
1747 return (ACs->retrieveEdge(value, false) != nullptr);
1749 case SUMO_ATTR_ARRIVALEDGE: {
1750 if (value.empty()) {
1751 return true;
1752 } else if (canParse<int>(value)) {
1753 // get index
1754 const int index = parse<int>(value);
1755 // check conditions
1756 if (index < 0) {
1757 return false;
1758 } else if (myTagProperty.vehicleRoute()) {
1759 // check parent route
1760 return (index < (int)getRouteParent()->getParentEdges().size());
1761 } else {
1762 // check embedded route
1763 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1764 }
1765 } else {
1766 return false;
1767 }
1768 }
1769 case SUMO_ATTR_VIA:
1770 if (value.empty()) {
1771 return true;
1772 } else {
1773 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1774 }
1775 // Specific of from-to junctions
1778 return (ACs->retrieveJunction(value, false) != nullptr);
1779 // Specific of from-to taz
1780 case SUMO_ATTR_FROM_TAZ:
1781 case SUMO_ATTR_TO_TAZ:
1782 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1783 // other
1784 case GNE_ATTR_SELECTED:
1785 return canParse<bool>(value);
1788 default:
1789 return isValidFlowAttribute(this, key, value);
1790 }
1791}
1792
1793
1794void
1796 enableFlowAttribute(this, key, undoList);
1797}
1798
1799
1800void
1802 disableFlowAttribute(this, key, undoList);
1803}
1804
1805
1806bool
1810
1811
1812std::string
1814 return getTagStr();
1815}
1816
1817
1818std::string
1820 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1821 // special case for Trips and flow
1823 // check if we're inspecting a Edge
1824 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty().getTag() == SUMO_TAG_EDGE)) {
1825 // check if edge correspond to a "from", "to" or "via" edge
1826 if (inspectedElements.isACInspected(getParentEdges().front())) {
1827 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1828 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1829 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1830 } else {
1831 // iterate over via
1832 for (const auto& viaEdgeID : via) {
1833 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1834 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1835 }
1836 }
1837 }
1838 }
1839 }
1840 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1841}
1842
1843
1844const Parameterised::Map&
1848
1849
1851GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1852 // get net and undoList
1853 const auto net = originalVehicle->getNet();
1854 auto undoList = net->getViewNet()->getUndoList();
1855 // declare new route, vehicle and embedded route
1856 GNERoute* newRoute = nullptr;
1857 GNEVehicle* newVehicle = nullptr;
1858 GNERoute* newEmbeddedRoute = nullptr;
1859 // generate new vehicle ID
1860 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1861 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty().getTag());
1862 // extract vehicle parameters and update ID
1863 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1864 newVehicleParameters.id = newVehicleID;
1865 // create vehicle using vehicleParameters
1866 if (originalVehicle->getTagProperty().vehicleRoute()) {
1867 newRoute = new GNERoute(net, newRouteID, originalVehicle->getParentDemandElements().at(1));
1868 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1869 originalVehicle->getParentDemandElements().at(0), newRoute,
1870 newVehicleParameters);
1871 } else if (originalVehicle->getTagProperty().vehicleRouteEmbedded()) {
1872 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1873 originalVehicle->getParentDemandElements().at(0),
1874 newVehicleParameters);
1875 newEmbeddedRoute = new GNERoute(net, newVehicle, originalVehicle->getChildDemandElements().front());
1876 } else if (originalVehicle->getTagProperty().vehicleEdges()) {
1877 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1878 originalVehicle->getParentDemandElements().at(0),
1879 originalVehicle->getParentEdges().front(),
1880 originalVehicle->getParentEdges().back(),
1881 newVehicleParameters);
1882 } else if (originalVehicle->getTagProperty().vehicleJunctions()) {
1883 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1884 originalVehicle->getParentDemandElements().at(0),
1885 originalVehicle->getParentJunctions().front(),
1886 originalVehicle->getParentJunctions().back(),
1887 newVehicleParameters);
1888 } else if (originalVehicle->getTagProperty().vehicleTAZs()) {
1889 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1890 originalVehicle->getParentDemandElements().at(0),
1891 originalVehicle->getParentAdditionals().front(),
1892 originalVehicle->getParentAdditionals().back(),
1893 newVehicleParameters);
1894 }
1895 // add new vehicle
1896 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1897 if (newRoute) {
1898 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1899 }
1900 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1901 if (newEmbeddedRoute) {
1902 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1903 }
1904 undoList->end();
1905 return newVehicle;
1906}
1907
1908// ===========================================================================
1909// protected
1910// ===========================================================================
1911
1914 // change color
1915 if (drawUsingSelectColor()) {
1917 } else {
1918 return getColorByScheme(s.vehicleColorer, this);
1919 }
1920}
1921
1922
1925 return *this;
1926}
1927
1928// ===========================================================================
1929// private
1930// ===========================================================================
1931
1932void
1933GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1934 // declare string error
1935 std::string error;
1936 // flag to upate stack label
1937 bool updateSpreadStackGeometry = false;
1938 switch (key) {
1939 case SUMO_ATTR_ID:
1940 // update microsimID
1941 setDemandElementID(value);
1942 // set manually vehicle ID (needed for saving)
1943 id = value;
1944 break;
1945 case SUMO_ATTR_TYPE:
1946 if (getID().size() > 0) {
1947 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1949 } else {
1951 }
1952 // set manually vtypeID (needed for saving)
1953 vtypeid = value;
1954 }
1955 break;
1956 case SUMO_ATTR_COLOR:
1957 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1958 color = parse<RGBColor>(value);
1959 // mark parameter as set
1961 } else {
1962 // set default value
1963 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1964 // unset parameter
1965 parametersSet &= ~VEHPARS_COLOR_SET;
1966 }
1967 break;
1969 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1971 // mark parameter as set
1973 } else {
1974 // set default value
1976 // unset parameter
1977 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1978 }
1979 break;
1981 if (value == toString(INVALID_DOUBLE)) {
1983 // mark parameter as set
1985 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1987 // mark parameter as set
1989 } else {
1990 // set default value
1992 // unset parameter
1993 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1994 }
1995 if (getID().size() > 0) {
1997 updateSpreadStackGeometry = true;
1998 }
1999 break;
2001 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2003 // mark parameter as set
2005 } else {
2006 // set default value
2008 // unset parameter
2009 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
2010 }
2011 break;
2013 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2015 // mark parameter as set
2017 } else {
2018 // set default value
2020 // unset parameter
2021 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2022 }
2023 break;
2025 if (value == toString(INVALID_DOUBLE)) {
2027 // mark parameter as set
2029 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2031 // mark parameter as set
2033 } else {
2034 // set default value
2036 // unset parameter
2037 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2038 }
2039 if (getID().size() > 0) {
2041 updateSpreadStackGeometry = true;
2042 }
2043 break;
2045 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2047 // mark parameter as set
2049 } else {
2050 // set default value
2052 // unset parameter
2053 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2054 }
2055 break;
2056 case SUMO_ATTR_LINE:
2057 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2058 line = value;
2059 // mark parameter as set
2061 } else {
2062 // set default value
2064 // unset parameter
2065 parametersSet &= ~VEHPARS_LINE_SET;
2066 }
2067 break;
2069 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2070 personNumber = parse<int>(value);
2071 // mark parameter as set
2073 } else {
2074 // set default value
2075 personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2076 // unset parameter
2077 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2078 }
2079 break;
2081 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2082 containerNumber = parse<int>(value);
2083 // mark parameter as set
2085 } else {
2086 // set default value
2088 // unset parameter
2089 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2090 }
2091 break;
2092 case SUMO_ATTR_REROUTE:
2093 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2094 // mark parameter as set
2096 } else {
2097 // unset parameter
2098 parametersSet &= ~VEHPARS_ROUTE_SET;
2099 }
2100 break;
2102 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2104 // mark parameter as set
2106 } else {
2107 // set default value
2109 // unset parameter
2110 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2111 }
2112 break;
2114 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2116 // mark parameter as set
2118 } else {
2119 // set default value
2121 // unset parameter
2122 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2123 }
2125 break;
2128 break;
2129 // Specific of vehicles over routes
2130 case SUMO_ATTR_ROUTE:
2131 if (getParentDemandElements().size() == 2) {
2133 }
2135 updateSpreadStackGeometry = true;
2136 break;
2137 // Specific of from-to edges
2138 case SUMO_ATTR_FROM: {
2139 // change first edge
2141 // compute vehicle
2143 updateSpreadStackGeometry = true;
2144 break;
2145 }
2146 case SUMO_ATTR_TO: {
2147 // change last edge
2148 replaceLastParentEdge(value);
2149 // compute vehicle
2151 updateSpreadStackGeometry = true;
2152 break;
2153 }
2154 case SUMO_ATTR_VIA: {
2155 if (!value.empty()) {
2156 // set new via edges
2157 via = parse< std::vector<std::string> >(value);
2158 // mark parameter as set
2160 } else {
2161 // clear via
2162 via.clear();
2163 // unset parameter
2164 parametersSet &= ~VEHPARS_VIA_SET;
2165 }
2166 // compute vehicle
2168 updateSpreadStackGeometry = true;
2169 break;
2170 }
2171 case SUMO_ATTR_DEPARTEDGE: {
2172 // update depart edge
2173 if (value.empty()) {
2174 // unset parameter
2175 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2176 departEdge = -1;
2178 } else {
2179 // mark parameter as set
2181 departEdge = parse<int>(value);
2183 }
2184 // compute vehicle
2185 if (getID().size() > 0) {
2187 updateSpreadStackGeometry = true;
2188 }
2189 break;
2190 }
2191 case SUMO_ATTR_ARRIVALEDGE: {
2192 // update arrival edge
2193 if (value.empty()) {
2194 // unset parameter
2195 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2196 arrivalEdge = -1;
2198 } else {
2199 // mark parameter as set
2201 arrivalEdge = parse<int>(value);
2203 }
2204 if (getID().size() > 0) {
2205 // compute vehicle
2207 updateSpreadStackGeometry = true;
2208 }
2209 break;
2210 }
2211 // Specific of from-to junctions
2213 // change first junction
2215 // compute vehicle
2217 updateSpreadStackGeometry = true;
2218 break;
2219 }
2220 case SUMO_ATTR_TO_JUNCTION: {
2221 // change last junction
2223 // compute vehicle
2225 updateSpreadStackGeometry = true;
2226 break;
2227 }
2228 // Specific of from-to TAZs
2229 case SUMO_ATTR_FROM_TAZ: {
2230 // change first additional
2232 // set taz manually
2233 fromTaz = value;
2234 // compute vehicle
2236 updateSpreadStackGeometry = true;
2237 break;
2238 }
2239 case SUMO_ATTR_TO_TAZ: {
2240 // change last additional
2242 // set taz manually
2243 toTaz = value;
2244 // compute vehicle
2246 updateSpreadStackGeometry = true;
2247 break;
2248 }
2249 // other
2250 case GNE_ATTR_SELECTED:
2251 if (parse<bool>(value)) {
2253 } else {
2255 }
2256 break;
2258 setParametersStr(value);
2259 break;
2260 default:
2261 setFlowAttribute(this, key, value);
2262 break;
2263 }
2264 // check if stack label has to be updated
2265 if (updateSpreadStackGeometry) {
2267 getParentEdges().front()->updateVehicleStackLabels();
2268 getParentEdges().front()->updateVehicleSpreadGeometries();
2269 } else if (myTagProperty.vehicleRoute()) {
2270 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2271 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2272 } else if (myTagProperty.vehicleRouteEmbedded()) {
2273 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2274 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2275 }
2276 }
2277}
2278
2279
2280void
2282 // toggle flow attributes
2283 toggleFlowAttribute(key, value);
2284}
2285
2286
2287void
2289 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2291 // change depart
2294 departPos = moveResult.newFirstPos;
2295 }
2298 // change arrival
2301 arrivalPos = moveResult.newFirstPos;
2302 }
2303 // set lateral offset
2305 // update geometry
2307}
2308
2309
2310void
2312 // reset lateral offset
2314 // check value
2315 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2316 // continue depending if we're moving first or last position
2318 // begin change attribute
2319 undoList->begin(this, TLF("departPos of %", getTagStr()));
2320 // now set departPos
2321 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2322 // check if depart lane has to be changed
2323 if (moveResult.newFirstLane) {
2324 // set new depart lane
2326 }
2327 } else {
2328 // begin change attribute
2329 undoList->begin(this, TLF("arrivalPos of %", getTagStr()));
2330 // now set arrivalPos
2331 setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newFirstPos), undoList);
2332 // check if arrival lane has to be changed
2333 if (moveResult.newFirstLane) {
2334 // set new arrival lane
2336 }
2337 }
2338 }
2339 // end change attribute
2340 undoList->end();
2341}
2342
2343/****************************************************************************/
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_SELECTED
element is selected
@ 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:654
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
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:347
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:295
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:539
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
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:787
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
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
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 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
calculate contour (for rectangled elements)
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
calculate contour extruded (used in elements formed by a central shape)
void 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...)
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
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)
std::string getFlowAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
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:1538
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:2155
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
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
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.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
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