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/****************************************************************************/
21#include <netedit/GNENet.h>
22#include <netedit/GNEUndoList.h>
23#include <netedit/GNEViewNet.h>
34
35#include "GNEVehicle.h"
36#include "GNERoute.h"
37
38// ===========================================================================
39// FOX callback mapping
40// ===========================================================================
44
48
49// Object implementation
50FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
51FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
52
53// ===========================================================================
54// static definitions
55// ===========================================================================
57
58// ===========================================================================
59// GNEVehicle::GNESingleVehiclePopupMenu
60// ===========================================================================
61
63 GUIGLObjectPopupMenu(app, parent, *vehicle),
64 myVehicle(vehicle) {
65 // build header
66 myVehicle->buildPopupHeader(this, app);
67 // build menu command for center button and copy cursor position to clipboard
70 // build menu commands for names
71 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
72 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
73 new FXMenuSeparator(this);
74 // build selection and show parameters menu
77 // route length
78 vehicle->buildMenuCommandRouteLength(this);
79 // add transform functions only in demand mode
81 // add reverse
82 vehicle->buildMenuAddReverse(this);
83 // continue depending of type
85 // create menu pane for transform operations
86 FXMenuPane* transformOperation = new FXMenuPane(this);
87 this->insertMenuPaneChild(transformOperation);
88 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
89 // Create menu commands for all transform
90 GUIDesigns::buildFXMenuCommand(transformOperation,
91 TL("Trip (over junctions)"),
94 GUIDesigns::buildFXMenuCommand(transformOperation,
95 TL("Flow (over junctions)"),
98 } else if (myVehicle->getTagProperty().vehicleTAZs()) {
99 // create menu pane for transform operations
100 FXMenuPane* transformOperation = new FXMenuPane(this);
101 this->insertMenuPaneChild(transformOperation);
102 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
103 // Create menu commands for all transform
104 GUIDesigns::buildFXMenuCommand(transformOperation,
105 TL("Trip (over TAZs)"),
108 GUIDesigns::buildFXMenuCommand(transformOperation,
109 TL("Flow (over TAZs)"),
112 } else {
113 // create menu pane for transform operations
114 FXMenuPane* transformOperation = new FXMenuPane(this);
115 this->insertMenuPaneChild(transformOperation);
116 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
117 // Create menu commands for all transform
118 GUIDesigns::buildFXMenuCommand(transformOperation,
119 TL("Vehicle"),
122 GUIDesigns::buildFXMenuCommand(transformOperation,
123 TL("Vehicle (embedded route)"),
126 GUIDesigns::buildFXMenuCommand(transformOperation,
127 TL("RouteFlow"),
130 GUIDesigns::buildFXMenuCommand(transformOperation,
131 TL("RouteFlow (embedded route)"),
134 GUIDesigns::buildFXMenuCommand(transformOperation,
135 TL("Trip"),
138 GUIDesigns::buildFXMenuCommand(transformOperation,
139 TL("Flow"),
142 }
143 }
144}
145
146
148
149
150long
152 switch (FXSELID(sel)) {
155 break;
158 break;
160 GNERouteHandler::transformToVehicle(myVehicle, false);
161 break;
164 break;
167 break;
170 break;
173 break;
176 break;
179 break;
182 break;
183 default:
184 break;
185 }
186 return 1;
187}
188
189// ===========================================================================
190// GNEVehicle::GNESelectedVehiclesPopupMenu
191// ===========================================================================
192
193GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
194 GUIGLObjectPopupMenu(app, parent, *vehicle),
195 mySelectedVehicles(selectedVehicle),
196 myVehicleTag(vehicle->getTagProperty().getTag()) {
197 // build header
198 vehicle->buildPopupHeader(this, app);
199 // build menu command for center button and copy cursor position to clipboard
200 vehicle->buildCenterPopupEntry(this);
201 vehicle->buildPositionCopyEntry(this, app);
202 // build menu commands for names
203 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
204 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
205 new FXMenuSeparator(this);
206 // build selection and show parameters menu
207 vehicle->getNet()->getViewNet()->buildSelectionACPopupEntry(this, vehicle);
208 vehicle->buildShowParamsPopupEntry(this);
209 // route length
210 vehicle->buildMenuCommandRouteLength(this);
211 // add transform functions only in demand mode
213 // add reverse
214 vehicle->buildMenuAddReverse(this);
215 // continue depending of type
216 if (vehicle->getTagProperty().vehicleJunctions()) {
217 // create menu pane for transform operations
218 FXMenuPane* transformOperation = new FXMenuPane(this);
219 this->insertMenuPaneChild(transformOperation);
220 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
221 // Create menu commands for restricted transforms
223 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
226 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
228 // create separator
229 new FXMenuSeparator(transformOperation);
230 // Create menu commands for all transform
231 GUIDesigns::buildFXMenuCommand(transformOperation,
232 TL("Trips (over junctions)"),
234 GUIDesigns::buildFXMenuCommand(transformOperation,
235 TL("Flows (over junctions)"),
237 } else if (vehicle->getTagProperty().vehicleTAZs()) {
238 // create menu pane for transform operations
239 FXMenuPane* transformOperation = new FXMenuPane(this);
240 this->insertMenuPaneChild(transformOperation);
241 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
242 // Create menu commands for all transform
244 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
247 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
249 // create separator
250 new FXMenuSeparator(transformOperation);
251 // Create menu commands for all transform
252 GUIDesigns::buildFXMenuCommand(transformOperation,
253 TL("Trips (over TAZs)"),
255 GUIDesigns::buildFXMenuCommand(transformOperation,
256 TL("Flows (over TAZs)"),
258 } else {
259 // create menu pane for transform operations
260 FXMenuPane* transformOperation = new FXMenuPane(this);
261 this->insertMenuPaneChild(transformOperation);
262 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
263 // Create menu commands for all transform
265 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
268 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
271 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
274 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
277 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
280 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
282 // create separator
283 new FXMenuSeparator(transformOperation);
284 // Create menu commands for all transform
285 GUIDesigns::buildFXMenuCommand(transformOperation,
286 TL("Vehicles"),
288 GUIDesigns::buildFXMenuCommand(transformOperation,
289 TL("Vehicles (embedded route)"),
291 GUIDesigns::buildFXMenuCommand(transformOperation,
292 TL("RouteFlows"),
294 GUIDesigns::buildFXMenuCommand(transformOperation,
295 TL("RouteFlows (embedded route)"),
297 GUIDesigns::buildFXMenuCommand(transformOperation,
298 TL("Trips"),
300 GUIDesigns::buildFXMenuCommand(transformOperation,
301 TL("Flows"),
303 }
304 }
305}
306
307
309
310
311long
312GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
313 // iterate over all selected vehicles
314 for (const auto& vehicle : mySelectedVehicles) {
315 switch (FXSELID(sel)) {
317 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
318 if (myRestrictedMenuCommands.count(obj) > 0) {
319 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
321 }
322 } else {
324 }
325 }
326 break;
328 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
329 if (myRestrictedMenuCommands.count(obj) > 0) {
330 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
332 }
333 } else {
335 }
336 }
337 break;
339 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
340 if (myRestrictedMenuCommands.count(obj) > 0) {
341 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
343 }
344 } else {
346 }
347 }
348 break;
350 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
351 if (myRestrictedMenuCommands.count(obj) > 0) {
352 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
354 }
355 } else {
357 }
358 }
359 break;
361 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
362 if (myRestrictedMenuCommands.count(obj) > 0) {
363 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
365 }
366 } else {
368 }
369 }
370 break;
372 if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
373 if (myRestrictedMenuCommands.count(obj) > 0) {
374 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
376 }
377 } else {
379 }
380 }
381 break;
383 if (vehicle->getTagProperty().vehicleJunctions()) {
384 if (myRestrictedMenuCommands.count(obj) > 0) {
385 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
387 }
388 } else {
390 }
391 }
392 break;
394 if (vehicle->getTagProperty().vehicleJunctions()) {
395 if (myRestrictedMenuCommands.count(obj) > 0) {
396 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
398 }
399 } else {
401 }
402 }
403 break;
405 if (vehicle->getTagProperty().vehicleTAZs()) {
406 if (myRestrictedMenuCommands.count(obj) > 0) {
407 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
409 }
410 } else {
412 }
413 }
414 break;
416 if (vehicle->getTagProperty().vehicleTAZs()) {
417 if (myRestrictedMenuCommands.count(obj) > 0) {
418 if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
420 }
421 } else {
423 }
424 }
425 break;
426 default:
427 break;
428 }
429 }
430 return 1;
431}
432
433// ===========================================================================
434// member method definitions
435// ===========================================================================
436
439 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
441 // reset default values
443 // set end and vehPerHours as default flow values
446}
447
448
449GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route) :
450 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
452 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
454 // SUMOVehicleParameter ID has to be set manually
455 id = vehicleID;
456 // set manually vtypeID (needed for saving)
457 vtypeid = vehicleType->getID();
458}
459
460
461GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
462 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
464 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
465GNEDemandElementFlow(this, vehicleParameters) {
466 // SUMOVehicleParameter ID has to be set manually
467 id = vehicleParameters.id;
468 // set manually vtypeID (needed for saving)
469 vtypeid = vehicleType->getID();
470}
471
472
473GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
474 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_VEHICLE_WITHROUTE) ? GLO_VEHICLE : GLO_ROUTEFLOW, tag,
476 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType}, {}),
477GNEDemandElementFlow(this, vehicleParameters) {
478 // SUMOVehicleParameter ID has to be set manually
479 id = vehicleParameters.id;
480 // reset routeid
481 routeid.clear();
482 // set manually vtypeID (needed for saving)
483 vtypeid = vehicleType->getID();
484}
485
486
487GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType,
488 GNEEdge* fromEdge, GNEEdge* toEdge) :
489 GNEDemandElement(vehicleID, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
490 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
491 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
493}
494
495
496GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
497 const SUMOVehicleParameter& vehicleParameters) :
498 GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
499 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
500 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
501GNEDemandElementFlow(this, vehicleParameters) {
502}
503
504
505GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
506 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
508 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
509 fromJunction, toJunction
510}, {}, {}, {}, {vehicleType}, {}),
512}
513
514
515GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
516 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
518 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
519 fromJunction, toJunction
520}, {}, {}, {}, {vehicleType}, {}),
521GNEDemandElementFlow(this, vehicleParameters) {
522}
523
524
525GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
526 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_TAZS) ? GLO_FLOW : GLO_TRIP, tag,
528 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {vehicleType}, {}),
529GNEDemandElementFlow(this, vehicleParameters) {
530 // mark taz parameters as set
533 fromTaz = fromTAZ->getID();
534 toTaz = toTAZ->getID();
535}
536
537
539
540
543 // get first and last lanes
544 const GNELane* firstLane = getFirstPathLane();
545 const GNELane* lastLane = getLastPathLane();
546 // check both lanes
547 if (firstLane && lastLane) {
548 // get depart and arrival positions (doubles)
549 const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
550 const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
551 // obtain diameter
553 // return move operation depending if we're editing departPos or arrivalPos
555 return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
559 return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
562 }
563 }
564 // nothing to move
565 return nullptr;
566}
567
568
569void
571 // attribute VType must not be written if is DEFAULT_VTYPE_ID
573 // unset VType parameter
574 parametersSet &= ~VEHPARS_VTYPE_SET;
575 // write vehicle attributes (VType will not be written)
577 // set VType parameter again
579 } else {
580 // write vehicle attributes, including type/distribution
582 }
583 // write specific attribute depending of tag property
585 // write route
587 }
588 // write from, to and edge vias
590 // write manually from/to edges (it correspond to front and back parent edges)
591 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
592 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
593 // only write via if there isn't empty
594 if (via.size() > 0) {
595 device.writeAttr(SUMO_ATTR_VIA, via);
596 }
597 }
598 // write from and to junctions
600 // write manually from/to junctions (it correspond to front and back parent junctions)
603 }
604 // write flow attributes
605 writeFlowAttributes(this, device);
606 // write parameters
607 writeParams(device);
608 // write route elements associated to this vehicle (except for calibrator FLows)
609 if ((getChildDemandElements().size() > 0) && !myTagProperty.isCalibrator()) {
610 if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
611 // write embedded route
612 getChildDemandElements().front()->writeDemandElement(device);
613 // write stops
614 for (const auto& demandElement : getChildDemandElements()) {
615 if (demandElement->getTagProperty().isVehicleStop()) {
616 demandElement->writeDemandElement(device);
617 }
618 }
619 } else {
620 for (const auto& route : getChildDemandElements()) {
621 route->writeDemandElement(device);
622 }
623 }
624 }
625 // close vehicle tag
626 device.closeTag();
627}
628
629
632 // check conditions
634 // vehicles and flows over tazs are always valid
635 return Problem::OK;
636 } else if (myTagProperty.vehicleEdges()) {
637 // check vehicles and flows paths
638 if (getParentEdges().front() == getParentEdges().back()) {
639 return Problem::OK;
640 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
641 return Problem::OK;
642 } else {
644 }
645 } else if (myTagProperty.vehicleJunctions()) {
646 // check vehicles and flows paths
647 if (getParentJunctions().front() == getParentJunctions().back()) {
648 return Problem::OK;
649 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
650 return Problem::OK;
651 } else {
653 }
654 } else if (myTagProperty.vehicleRoute()) {
655 // check if exist a valid path using route parent edges
657 return Problem::OK;
658 } else {
660 }
661 } else if (myTagProperty.vehicleRouteEmbedded()) {
662 // check if exist a valid path using route child edges
664 return Problem::OK;
665 } else {
667 }
668 } else {
670 }
671}
672
673
674std::string
676 // only trips or flows can have problems
678 // check if exist at least a connection between every edge
679 for (int i = 1; i < (int)getParentEdges().size(); i++) {
681 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
682 }
683 }
684 // if there are connections between all edges, then all is ok
685 return "";
686 } else if (myTagProperty.vehicleJunctions()) {
687 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
688 } else if (myTagProperty.vehicleRoute()) {
689 // get route parent edges
690 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
691 // check if exist at least a connection between every edge
692 for (int i = 1; i < (int)routeEdges.size(); i++) {
693 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
694 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
695 }
696 }
697 // if there are connections between all edges, then all is ok
698 return "";
699 } else if (myTagProperty.vehicleRouteEmbedded()) {
700 // get route parent edges
701 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
702 // check if exist at least a connection between every edge
703 for (int i = 1; i < (int)routeEdges.size(); i++) {
704 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
705 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
706 }
707 }
708 // if there are connections between all edges, then all is ok
709 return "";
710 } else {
711 return "";
712 }
713}
714
715
716void
720
721
724 return getParentDemandElements().front()->getVClass();
725}
726
727
728const RGBColor&
730 return color;
731}
732
733
734void
736 if (getParentJunctions().size() > 0) {
737 // calculate rotation between both junctions
738 const Position posA = getParentJunctions().front()->getPositionInView();
739 const Position posB = getParentJunctions().back()->getPositionInView();
740 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
741 // update Geometry
742 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
743 } else if (getParentAdditionals().size() > 0) {
744 // calculate rotation between both TAZs
745 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
746 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
747 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
748 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
749 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
750 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
751 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
752 // update Geometry
754 } else {
755 // get first path lane
756 const GNELane* firstPathLane = getFirstPathLane();
757 // check path lane
758 if (firstPathLane) {
759 // declare departPos
760 double posOverLane = 0;
762 posOverLane = departPos;
763 }
764 // update Geometry
766 // compute route embedded associated with this vehicle
767 for (const auto& demandElement : getChildDemandElements()) {
768 if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
769 demandElement->computePathElement();
770 }
771 demandElement->updateGeometry();
772 }
773 }
774 }
775}
776
777
782
783
784bool
786 // get edit modes
787 const auto& editModes = myNet->getViewNet()->getEditModes();
788 // check if we're editing a type
789 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
791 return true;
792 } else {
793 return false;
794 }
795}
796
797
801 // obtain all selected vehicles
802 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
803 std::vector<GNEVehicle*> selectedVehicles;
804 selectedVehicles.reserve(selectedDemandElements.size());
805 for (const auto& selectedDemandElement : selectedDemandElements) {
806 if (selectedDemandElement->getTagProperty().isVehicle()) {
807 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
808 }
809 }
810 // return a GNESelectedVehiclesPopupMenu
811 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
812 } else {
813 // return a GNESingleVehiclePopupMenu
814 return new GNESingleVehiclePopupMenu(this, app, parent);
815 }
816}
817
818
819std::string
822 return getRouteParent()->getID();
823 } else if (myTagProperty.vehicleEdges()) {
824 return getParentEdges().front()->getID();
825 } else if (myTagProperty.vehicleJunctions()) {
826 return getParentJunctions().front()->getID();
827 } else if (myTagProperty.vehicleTAZs()) {
828 return getParentAdditionals().front()->getID();
829 } else {
830 throw ProcessError(TL("Invalid vehicle tag"));
831 }
832}
833
834
835double
839
840
843 Boundary vehicleBoundary;
844 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
845 vehicleBoundary.grow(20);
846 return vehicleBoundary;
847}
848
849
850void
851GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
852 // geometry of this element cannot be splitted
853}
854
855
856void
858 // only drawn in super mode demand
862 // declare common attributes
864 const double exaggeration = getExaggeration(s);
865 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
866 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
867 const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
868 // obtain Position an rotation (depending of draw spread vehicles)
869 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
870 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
871 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
872 // check that position is valid
873 if (vehiclePosition == Position::INVALID) {
874 return;
875 }
876 // get detail level
877 const auto d = s.getDetailLevel(exaggeration);
878 // draw geometry only if we'rent in drawForObjectUnderCursor mode
880 // first check if if mouse is enough near to this vehicle to draw it
881 if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
882 // push draw matrix
884 // Start with the drawing of the area translating matrix to origin
886 // translate to drawing position
887 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
888 glRotated(vehicleRotation, 0, 0, -1);
889 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
890 glTranslated(0, (-1) * length * exaggeration, 0);
891 GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
892 // Pop last matrix
894 } else {
896 // push draw matrix
898 // Start with the drawing of the area translating matrix to origin
900 // translate to drawing position
901 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
902 glRotated(vehicleRotation, 0, 0, -1);
903 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
904 glTranslated(0, (-1) * length * exaggeration, 0);
905 // set lane color
907 double upscaleLength = exaggeration;
908 if ((exaggeration > 1) && (length > 5)) {
909 // reduce the length/width ratio because this is not useful at high zoom
910 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
911 }
912 glScaled(exaggeration, upscaleLength, 1);
913 // check if we're drawing in selecting mode
915 // draw vehicle as a box and don't draw the rest of details
917 } else {
918 // draw the vehicle depending of detail level
925 }
926 // check if min gap has to be drawn
927 if (s.drawMinGap) {
928 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
929 glColor3d(0., 1., 0.);
930 glBegin(GL_LINES);
931 glVertex2d(0., 0);
932 glVertex2d(0., minGap);
933 glVertex2d(-.5, minGap);
934 glVertex2d(.5, minGap);
935 glEnd();
936 }
937 // drawing name at GLO_MAX fails unless translating z
938 glTranslated(0, MIN2(length / 2, double(5)), -getType());
939 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
940 glRotated(vehicleRotation, 0, 0, -1);
942 // draw line
943 if (s.vehicleName.show(this) && line != "") {
944 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
946 }
947 }
948 // pop draw matrix
950 // draw line between junctions if path isn't valid
951 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
952 drawJunctionLine(this);
953 }
954 // draw stack label
955 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
956 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
957 }
958 // draw flow label
959 if (myTagProperty.isFlow()) {
960 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
961 }
962 }
963 // draw lock icon
964 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
965 // draw dotted contour
967 }
968 // draw squared shape
969 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(), length * -0.5, 0, vehicleRotation, exaggeration);
970 }
971 }
972}
973
974
975void
977 // calculate path (only for flows and trips)
979 // calculate path
981 } else if (myTagProperty.vehicleEdges()) {
982 // save edges in wich this vehicle has to stop
983 std::vector<GNEEdge*> edgeStops;
984 // iterate over child demand elements
985 for (const auto& demandElement : getChildDemandElements()) {
986 // extract lanes
987 if (demandElement->getTagProperty().isVehicleStop()) {
988 GNEEdge* edgeStop = nullptr;
989 if (demandElement->getParentAdditionals().size() > 0) {
990 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
991 } else {
992 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
993 }
994 if (edgeStop) {
995 // avoid double edge stops
996 if (stops.empty()) {
997 edgeStops.push_back(edgeStop);
998 } else if (edgeStops.back() != edgeStop) {
999 edgeStops.push_back(edgeStop);
1000 }
1001 }
1002 }
1003 }
1004 // declare edge vector
1005 std::vector<GNEEdge*> edgePath;
1006 // get first and last lanes
1007 const auto firstLane = getFirstPathLane();
1008 const auto lastLane = getLastPathLane();
1009 // check first and last lanes
1010 if (firstLane && lastLane) {
1011 // add first lane
1012 edgePath.push_back(firstLane->getParentEdge());
1013 // give more priority to stops instead via
1014 if (edgeStops.size() > 0) {
1015 // add stops only if they're accesibles
1016 for (const auto& edgeStop : edgeStops) {
1017 // check if exist a valid path that includes the last edge
1018 auto edgePathStop = edgePath;
1019 edgePathStop.push_back(edgeStop);
1020 edgePathStop.push_back(lastLane->getParentEdge());
1022 if (path.size() > 0) {
1023 edgePath.push_back(edgeStop);
1024 }
1025 }
1026 } else {
1027 // add via lanes
1028 for (const auto& edgeViaID : via) {
1029 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1030 if (edgeVia) {
1031 // check if exist a valid path that includes the last edge
1032 auto edgePathStop = edgePath;
1033 edgePathStop.push_back(edgeVia);
1034 edgePathStop.push_back(lastLane->getParentEdge());
1035 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1036 edgePath.push_back(edgeVia);
1037 }
1038 }
1039 }
1040 }
1041 // add last lane
1042 edgePath.push_back(lastLane->getParentEdge());
1043 // calculate path
1044 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1045 }
1046 }
1047 // update geometry
1049}
1050
1051
1052void
1053GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
1054 // conditions for draw always in network mode
1055 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1058 // conditions for draw always in demand mode
1059 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1061 // conditions for draw if is selected
1062 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1064 // conditions for draw if is inspected
1065 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1067 // check drawing conditions
1068 if (segment->getLane() && !s.drawForRectangleSelection && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1070 // get detail level
1071 const auto d = s.getDetailLevel(1);
1072 // calculate width
1073 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1074 // calculate startPos
1075 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1076 // get endPos
1077 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1078 // declare path geometry
1079 GUIGeometry vehicleGeometry;
1080 // update pathGeometry depending of first and last segment
1081 if (segment->isFirstSegment() && segment->isLastSegment()) {
1082 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1083 geometryDepartPos,
1085 geometryEndPos,
1087 } else if (segment->isFirstSegment()) {
1088 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1089 geometryDepartPos,
1091 -1,
1093 } else if (segment->isLastSegment()) {
1094 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1095 -1,
1097 geometryEndPos,
1099 } else {
1100 vehicleGeometry = segment->getLane()->getLaneGeometry();
1101 }
1102 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1104 // obtain color
1106 // Add a draw matrix
1108 // Start with the drawing of the area translating matrix to origin
1109 glTranslated(0, 0, getType() + offsetFront);
1110 // Set color
1111 GLHelper::setColor(pathColor);
1112 // draw geometry
1113 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1114 // Pop last matrix
1116 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1117 if (segment->getNextLane()) {
1118 // push draw matrix
1120 // Start with the drawing of the area translating matrix to origin
1122 // Set red color
1124 // get firstPosition (last position of current lane shape)
1125 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1126 // get lastPosition (first position of next lane shape)
1127 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1128 // draw box line
1129 GLHelper::drawBoxLine(arrivalPosition,
1130 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1131 firstPosition.distanceTo2D(arrivalPosition), .05);
1132 // pop draw matrix
1134 }
1135 // check if this is the last segment
1136 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1137 // get geometryEndPos
1138 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1139 // check if endPos can be drawn
1141 // push draw matrix
1143 // Start with the drawing of the area translating matrix to origin
1145 // translate to geometryEndPos
1146 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1147 // Set person plan color
1148 GLHelper::setColor(pathColor);
1149 // resolution of drawn circle depending of the zoom (To improve smoothness)
1151 // pop draw matrix
1153 }
1154 }
1155 // Draw name if isn't being drawn for selecting
1156 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
1157 // draw dotted contour
1158 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1159 }
1160 // calculate contour and draw dotted geometry
1161 if (segment->isFirstSegment() || segment->isLastSegment()) {
1162 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0);
1163 } else {
1164 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0);
1165 }
1166 // check if add this path element to redraw buffer
1167 if (segment->getContour()->checkDrawPathContour(s, d, this)) {
1169 }
1170 }
1171}
1172
1173
1174void
1175GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
1176 // conditions for draw always in network mode
1177 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1180 // conditions for draw always in demand mode
1181 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1183 // conditions for draw if is selected
1184 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1186 // conditions for draw if is inspected
1187 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1189 // check drawing conditions
1190 if (segment->getJunction() && !s.drawForRectangleSelection && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1192 // get detail level
1193 const auto d = s.getDetailLevel(1);
1194 // calculate width
1195 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1196 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1198 // Add a draw matrix
1200 // Start with the drawing of the area translating matrix to origin
1201 glTranslated(0, 0, getType() + offsetFront);
1202 // Set color of the base
1203 if (drawUsingSelectColor()) {
1205 } else {
1207 }
1208 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1209 if (segment->getPreviousLane() && segment->getNextLane()) {
1210 // draw lane2lane
1212 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1213 // draw line between center of junction and last lane shape
1214 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1215 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1216 // draw line between center of junction and first lane shape
1217 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1218 }
1219 // Pop last matrix
1221 // draw dotted contour
1222 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1223 }
1224 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1225 if (segment->getPreviousLane() && segment->getNextLane()) {
1226 // calculate contour and draw dotted geometry
1228 getType(), 0, width, 1, false, false);
1229 } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1230 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1231 getType(), 0, width, 1, true, true);
1232 } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1233 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1234 getType(), 0, width, 1, true, true);
1235 }
1236 }
1237}
1238
1239
1240GNELane*
1242 // declare first edge
1243 GNEEdge* firstEdge = nullptr;
1244 // continue depending of tags
1246 // check departEdge
1247 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1248 // use departEdge
1249 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1250 } else {
1251 // use first route edge
1252 firstEdge = getRouteParent()->getParentEdges().front();
1253 }
1254 } else if (myTagProperty.vehicleRouteEmbedded()) {
1255 // check if embedded route exist (due during loading embedded route doesn't exist)
1256 if (getChildDemandElements().empty()) {
1257 return nullptr;
1258 }
1259 // check departEdge
1260 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1261 // use depart edge
1262 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1263 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1264 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1265 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1266 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1267 } else {
1268 return nullptr;
1269 }
1270 } else if (getParentEdges().size() > 0) {
1271 // use first parent edge
1272 firstEdge = getParentEdges().front();
1273 } else {
1274 // defined over junctions
1275 return nullptr;
1276 }
1277 // get departLane index
1278 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1279 // check departLane index
1280 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1281 return firstEdge->getLanes().at(departLaneIndex);
1282 } else {
1283 // get first allowed VClass
1284 return firstEdge->getLaneByAllowedVClass(getVClass());
1285 }
1286}
1287
1288
1289GNELane*
1291 // declare last edge
1292 GNEEdge* lastEdge = nullptr;
1293 // continue depending of tags
1295 // check arrivalEdge
1296 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1297 // use arrival edge
1298 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1299 } else {
1300 // use last route edge
1301 lastEdge = getRouteParent()->getParentEdges().back();
1302 }
1303 } else if (myTagProperty.vehicleRouteEmbedded()) {
1304 // check if embedded route exist (due during loading embedded route doesn't exist)
1305 if (getChildDemandElements().empty()) {
1306 return nullptr;
1307 }
1308 // check arrivalEdge
1309 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1310 // use arrival edge
1311 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1312 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1313 // use last route edge
1314 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1315 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1316 // use lane
1317 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1318 } else {
1319 return nullptr;
1320 }
1321 } else if (getParentEdges().size() > 0) {
1322 // use last parent edge
1323 lastEdge = getParentEdges().back();
1324 } else {
1325 // defined over junctions
1326 return nullptr;
1327 }
1328 // get arrivalLane index
1329 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1330 // check arrivalLane index
1331 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1332 return lastEdge->getLanes().at(arrivalLaneIndex);
1333 } else {
1334 // get last allowed VClass
1335 return lastEdge->getLaneByAllowedVClass(getVClass());
1336 }
1337}
1338
1339
1340std::string
1342 switch (key) {
1343 case SUMO_ATTR_ID:
1344 return getMicrosimID();
1345 case SUMO_ATTR_TYPE:
1346 return vtypeid;
1347 case SUMO_ATTR_COLOR:
1349 return toString(color);
1350 } else {
1352 }
1355 return getDepartLane();
1356 } else {
1358 }
1361 return getDepartPos();
1362 } else {
1364 }
1367 return getDepartSpeed();
1368 } else {
1370 }
1373 return getArrivalLane();
1374 } else {
1376 }
1379 return getArrivalPos();
1380 } else {
1382 }
1385 return getArrivalSpeed();
1386 } else {
1388 }
1389 case SUMO_ATTR_LINE:
1390 if (wasSet(VEHPARS_LINE_SET)) {
1391 return line;
1392 } else {
1394 }
1397 return toString(personNumber);
1398 } else {
1400 }
1403 return toString(containerNumber);
1404 } else {
1406 }
1407 case SUMO_ATTR_REROUTE:
1409 return "true";
1410 } else {
1411 return "false";
1412 }
1415 return getDepartPosLat();
1416 } else {
1418 }
1421 return getArrivalPosLat();
1422 } else {
1424 }
1426 return getInsertionChecks();
1427 // Specific of vehicles over routes
1428 case SUMO_ATTR_ROUTE:
1429 if (getParentDemandElements().size() == 2) {
1430 return getRouteParent()->getID();
1431 } else {
1432 return "";
1433 }
1434 // Specific of from-to edge
1435 case SUMO_ATTR_FROM:
1436 return getParentEdges().front()->getID();
1437 case SUMO_ATTR_TO:
1438 return getParentEdges().back()->getID();
1439 case SUMO_ATTR_VIA:
1440 return toString(via);
1442 if (departEdge == -1) {
1443 return "";
1444 } else {
1445 return toString(departEdge);
1446 }
1448 if (arrivalEdge == -1) {
1449 return "";
1450 } else {
1451 return toString(arrivalEdge);
1452 }
1453 // Specific of from-to junctions
1455 return getParentJunctions().front()->getID();
1457 return getParentJunctions().back()->getID();
1458 // Specific of from-to tazs
1459 case SUMO_ATTR_FROM_TAZ:
1460 return getParentAdditionals().front()->getID();
1461 case SUMO_ATTR_TO_TAZ:
1462 return getParentAdditionals().back()->getID();
1463 // other
1464 case GNE_ATTR_SELECTED:
1467 return getParametersStr();
1469 return toString(parametersSet);
1470 default:
1471 return getFlowAttribute(key);
1472 }
1473}
1474
1475
1476double
1478 switch (key) {
1481 return departLane;
1482 } else {
1483 return -1;
1484 }
1486 // only return departPos it if is given
1488 return departPos;
1489 } else {
1490 return 0;
1491 }
1494 return arrivalLane;
1495 } else {
1496 return -1;
1497 }
1499 // only return departPos it if is given
1501 return arrivalPos;
1502 } else {
1503 return -1;
1504 }
1505 case SUMO_ATTR_WIDTH:
1506 case SUMO_ATTR_LENGTH:
1507 case SUMO_ATTR_MINGAP:
1508 return getTypeParent()->getAttributeDouble(key);
1509 default:
1510 return getFlowAttributeDouble(key);
1511 }
1512}
1513
1514
1517 switch (key) {
1519 // check if this vehicle was defined over junctions
1520 if (getParentJunctions().size() > 0) {
1521 return getParentJunctions().front()->getPositionInView();
1522 } else {
1523 // get first path lane shape
1524 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1525 // check arrivalPosProcedure
1527 if (departPos < 0) {
1528 return laneShape.front();
1529 } else if (departPos > laneShape.length2D()) {
1530 return laneShape.back();
1531 } else {
1532 return laneShape.positionAtOffset2D(departPos);
1533 }
1534 } else {
1535 return laneShape.front();
1536 }
1537 }
1538 }
1540 // check if this vehicle was defined over junctions
1541 if (getParentJunctions().size() > 0) {
1542 return getParentJunctions().back()->getPositionInView();
1543 } else {
1544 // get last path lane shape
1545 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1546 // check arrivalPosProcedure
1548 if (arrivalPos < 0) {
1549 return laneShape.front();
1550 } else if (arrivalPos > laneShape.length2D()) {
1551 return laneShape.back();
1552 } else {
1553 return laneShape.positionAtOffset2D(arrivalPos);
1554 }
1555 } else {
1556 return laneShape.back();
1557 }
1558 }
1559 }
1560 default:
1561 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1562 }
1563}
1564
1565
1566void
1567GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1568 if (value == getAttribute(key)) {
1569 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1570 }
1571 switch (key) {
1572 case SUMO_ATTR_ID:
1573 case SUMO_ATTR_TYPE:
1574 case SUMO_ATTR_COLOR:
1581 case SUMO_ATTR_LINE:
1584 case SUMO_ATTR_REROUTE:
1588 // Specific of vehicles over routes
1589 case SUMO_ATTR_ROUTE:
1590 // Specific of from-to edges
1591 case SUMO_ATTR_FROM:
1592 case SUMO_ATTR_TO:
1593 case SUMO_ATTR_VIA:
1596 // Specific of from-to junctions
1599 // Specific of from-to taz
1600 case SUMO_ATTR_FROM_TAZ:
1601 case SUMO_ATTR_TO_TAZ:
1602 // other
1604 case GNE_ATTR_SELECTED:
1605 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1606 break;
1607 default:
1608 setFlowAttribute(this, key, value, undoList);
1609 break;
1610 }
1611}
1612
1613
1614bool
1615GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1616 // get ACs
1617 const auto ACs = myNet->getAttributeCarriers();
1618 // declare string error
1619 std::string error;
1620 switch (key) {
1621 case SUMO_ATTR_ID:
1623 case SUMO_ATTR_TYPE:
1624 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1625 case SUMO_ATTR_COLOR:
1626 return canParse<RGBColor>(value);
1627 case SUMO_ATTR_DEPARTLANE: {
1628 int dummyDepartLane;
1629 DepartLaneDefinition dummyDepartLaneProcedure;
1630 parseDepartLane(value, myTagProperty.getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1631 // if error is empty, check if depart lane is correct
1632 if (error.empty()) {
1633 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1634 return true;
1635 } else if (isTemplate()) {
1636 return true;
1637 } else if (getParentJunctions().size() > 0) {
1638 return (dummyDepartLane == 0);
1639 } else if (getParentAdditionals().size() > 0) {
1640 return (dummyDepartLane == 0);
1641 } else {
1642 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1643 }
1644 } else {
1645 return false;
1646 }
1647 }
1648 case SUMO_ATTR_DEPARTPOS: {
1649 double dummyDepartPos;
1650 DepartPosDefinition dummyDepartPosProcedure;
1651 parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1652 // if error is empty, given value is valid
1653 return error.empty();
1654 }
1655 case SUMO_ATTR_DEPARTSPEED: {
1656 double dummyDepartSpeed;
1657 DepartSpeedDefinition dummyDepartSpeedProcedure;
1658 parseDepartSpeed(value, myTagProperty.getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1659 // if error is empty, check if depart speed is correct
1660 if (error.empty()) {
1661 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1662 return true;
1663 } else if (isTemplate()) {
1664 return true;
1665 } else {
1666 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1667 }
1668 } else {
1669 return false;
1670 }
1671 }
1672 case SUMO_ATTR_ARRIVALLANE: {
1673 int dummyArrivalLane;
1674 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1675 parseArrivalLane(value, myTagProperty.getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1676 // if error is empty, given value is valid
1677 if (error.empty()) {
1678 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1679 return true;
1680 } else if (isTemplate()) {
1681 return true;
1682 } else if (getParentJunctions().size() > 0) {
1683 return (dummyArrivalLane == 0);
1684 } else if (getParentAdditionals().size() > 0) {
1685 return (dummyArrivalLane == 0);
1686 } else {
1687 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1688 }
1689 } else {
1690 return false;
1691 }
1692 }
1693 case SUMO_ATTR_ARRIVALPOS: {
1694 double dummyArrivalPos;
1695 ArrivalPosDefinition dummyArrivalPosProcedure;
1696 parseArrivalPos(value, myTagProperty.getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1697 // if error is empty, given value is valid
1698 return error.empty();
1699 }
1701 double dummyArrivalSpeed;
1702 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1703 parseArrivalSpeed(value, myTagProperty.getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1704 // if error is empty, given value is valid
1705 return error.empty();
1706 }
1707 case SUMO_ATTR_LINE:
1708 return true;
1710 return canParse<int>(value) && parse<int>(value) >= 0;
1712 return canParse<int>(value) && parse<int>(value) >= 0;
1713 case SUMO_ATTR_REROUTE:
1714 return true; // check
1716 double dummyDepartPosLat;
1717 DepartPosLatDefinition dummyDepartPosLatProcedure;
1718 parseDepartPosLat(value, myTagProperty.getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1719 // if error is empty, given value is valid
1720 return error.empty();
1721 }
1723 double dummyArrivalPosLat;
1724 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1725 parseArrivalPosLat(value, myTagProperty.getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1726 // if error is empty, given value is valid
1727 return error.empty();
1728 }
1730 return areInsertionChecksValid(value);
1731 // Specific of vehicles over routes
1732 case SUMO_ATTR_ROUTE:
1733 if (getParentDemandElements().size() == 2) {
1734 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1735 } else {
1736 return true;
1737 }
1738 // Specific of from-to edges
1739 case SUMO_ATTR_FROM:
1740 case SUMO_ATTR_TO:
1741 return (ACs->retrieveEdge(value, false) != nullptr);
1743 case SUMO_ATTR_ARRIVALEDGE: {
1744 if (value.empty()) {
1745 return true;
1746 } else if (canParse<int>(value)) {
1747 // get index
1748 const int index = parse<int>(value);
1749 // check conditions
1750 if (index < 0) {
1751 return false;
1752 } else if (myTagProperty.vehicleRoute()) {
1753 // check parent route
1754 return (index < (int)getRouteParent()->getParentEdges().size());
1755 } else {
1756 // check embedded route
1757 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1758 }
1759 } else {
1760 return false;
1761 }
1762 }
1763 case SUMO_ATTR_VIA:
1764 if (value.empty()) {
1765 return true;
1766 } else {
1767 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1768 }
1769 // Specific of from-to junctions
1772 return (ACs->retrieveJunction(value, false) != nullptr);
1773 // Specific of from-to taz
1774 case SUMO_ATTR_FROM_TAZ:
1775 case SUMO_ATTR_TO_TAZ:
1776 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1777 // other
1778 case GNE_ATTR_SELECTED:
1779 return canParse<bool>(value);
1782 default:
1783 return isValidFlowAttribute(this, key, value);
1784 }
1785}
1786
1787
1788void
1790 enableFlowAttribute(this, key, undoList);
1791}
1792
1793
1794void
1796 disableFlowAttribute(this, key, undoList);
1797}
1798
1799
1800bool
1804
1805
1806std::string
1808 return getTagStr();
1809}
1810
1811
1812std::string
1814 // special case for Trips and flow
1816 // check if we're inspecting a Edge
1817 if (!myNet->getViewNet()->getInspectedAttributeCarriers().empty() &&
1818 myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1819 // check if edge correspond to a "from", "to" or "via" edge
1821 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1822 } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
1823 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1824 } else {
1825 // iterate over via
1826 for (const auto& i : via) {
1827 if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
1828 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1829 }
1830 }
1831 }
1832 }
1833 }
1834 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1835}
1836
1837
1838const Parameterised::Map&
1842
1843
1845GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1846 // get net and undoList
1847 const auto net = originalVehicle->getNet();
1848 auto undoList = net->getViewNet()->getUndoList();
1849 // declare new route, vehicle and embedded route
1850 GNERoute* newRoute = nullptr;
1851 GNEVehicle* newVehicle = nullptr;
1852 GNERoute* newEmbeddedRoute = nullptr;
1853 // generate new vehicle ID
1854 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1855 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty().getTag());
1856 // extract vehicle parameters and update ID
1857 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1858 newVehicleParameters.id = newVehicleID;
1859 // create vehicle using vehicleParameters
1860 if (originalVehicle->getTagProperty().vehicleRoute()) {
1861 newRoute = new GNERoute(net, newRouteID, originalVehicle->getParentDemandElements().at(1));
1862 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1863 originalVehicle->getParentDemandElements().at(0), newRoute,
1864 newVehicleParameters);
1865 } else if (originalVehicle->getTagProperty().vehicleRouteEmbedded()) {
1866 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1867 originalVehicle->getParentDemandElements().at(0),
1868 newVehicleParameters);
1869 newEmbeddedRoute = new GNERoute(net, newVehicle, originalVehicle->getChildDemandElements().front());
1870 } else if (originalVehicle->getTagProperty().vehicleEdges()) {
1871 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1872 originalVehicle->getParentDemandElements().at(0),
1873 originalVehicle->getParentEdges().front(),
1874 originalVehicle->getParentEdges().back(),
1875 newVehicleParameters);
1876 } else if (originalVehicle->getTagProperty().vehicleJunctions()) {
1877 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1878 originalVehicle->getParentDemandElements().at(0),
1879 originalVehicle->getParentJunctions().front(),
1880 originalVehicle->getParentJunctions().back(),
1881 newVehicleParameters);
1882 } else if (originalVehicle->getTagProperty().vehicleTAZs()) {
1883 newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1884 originalVehicle->getParentDemandElements().at(0),
1885 originalVehicle->getParentAdditionals().front(),
1886 originalVehicle->getParentAdditionals().back(),
1887 newVehicleParameters);
1888 }
1889 // add new vehicle
1890 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1891 if (newRoute) {
1892 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1893 }
1894 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1895 if (newEmbeddedRoute) {
1896 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1897 }
1898 undoList->end();
1899 return newVehicle;
1900}
1901
1902// ===========================================================================
1903// protected
1904// ===========================================================================
1905
1908 // change color
1909 if (drawUsingSelectColor()) {
1911 } else {
1912 return getColorByScheme(s.vehicleColorer, this);
1913 }
1914}
1915
1916
1919 return *this;
1920}
1921
1922// ===========================================================================
1923// private
1924// ===========================================================================
1925
1926void
1927GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1928 // declare string error
1929 std::string error;
1930 // flag to upate stack label
1931 bool updateSpreadStackGeometry = false;
1932 switch (key) {
1933 case SUMO_ATTR_ID:
1934 // update microsimID
1935 setDemandElementID(value);
1936 // set manually vehicle ID (needed for saving)
1937 id = value;
1938 break;
1939 case SUMO_ATTR_TYPE:
1940 if (getID().size() > 0) {
1941 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1943 } else {
1945 }
1946 // set manually vtypeID (needed for saving)
1947 vtypeid = value;
1948 }
1949 break;
1950 case SUMO_ATTR_COLOR:
1951 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1952 color = parse<RGBColor>(value);
1953 // mark parameter as set
1955 } else {
1956 // set default value
1957 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1958 // unset parameter
1959 parametersSet &= ~VEHPARS_COLOR_SET;
1960 }
1961 break;
1963 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1965 // mark parameter as set
1967 } else {
1968 // set default value
1970 // unset parameter
1971 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1972 }
1973 break;
1975 if (value == toString(INVALID_DOUBLE)) {
1977 // mark parameter as set
1979 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1981 // mark parameter as set
1983 } else {
1984 // set default value
1986 // unset parameter
1987 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1988 }
1989 if (getID().size() > 0) {
1991 updateSpreadStackGeometry = true;
1992 }
1993 break;
1995 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1997 // mark parameter as set
1999 } else {
2000 // set default value
2002 // unset parameter
2003 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
2004 }
2005 break;
2007 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2009 // mark parameter as set
2011 } else {
2012 // set default value
2014 // unset parameter
2015 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
2016 }
2017 break;
2019 if (value == toString(INVALID_DOUBLE)) {
2021 // mark parameter as set
2023 } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2025 // mark parameter as set
2027 } else {
2028 // set default value
2030 // unset parameter
2031 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2032 }
2033 if (getID().size() > 0) {
2035 updateSpreadStackGeometry = true;
2036 }
2037 break;
2039 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2041 // mark parameter as set
2043 } else {
2044 // set default value
2046 // unset parameter
2047 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2048 }
2049 break;
2050 case SUMO_ATTR_LINE:
2051 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2052 line = value;
2053 // mark parameter as set
2055 } else {
2056 // set default value
2058 // unset parameter
2059 parametersSet &= ~VEHPARS_LINE_SET;
2060 }
2061 break;
2063 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2064 personNumber = parse<int>(value);
2065 // mark parameter as set
2067 } else {
2068 // set default value
2069 personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2070 // unset parameter
2071 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2072 }
2073 break;
2075 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2076 containerNumber = parse<int>(value);
2077 // mark parameter as set
2079 } else {
2080 // set default value
2082 // unset parameter
2083 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2084 }
2085 break;
2086 case SUMO_ATTR_REROUTE:
2087 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2088 // mark parameter as set
2090 } else {
2091 // unset parameter
2092 parametersSet &= ~VEHPARS_ROUTE_SET;
2093 }
2094 break;
2096 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2098 // mark parameter as set
2100 } else {
2101 // set default value
2103 // unset parameter
2104 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2105 }
2106 break;
2108 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2110 // mark parameter as set
2112 } else {
2113 // set default value
2115 // unset parameter
2116 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2117 }
2119 break;
2122 break;
2123 // Specific of vehicles over routes
2124 case SUMO_ATTR_ROUTE:
2125 if (getParentDemandElements().size() == 2) {
2127 }
2129 updateSpreadStackGeometry = true;
2130 break;
2131 // Specific of from-to edges
2132 case SUMO_ATTR_FROM: {
2133 // change first edge
2135 // compute vehicle
2137 updateSpreadStackGeometry = true;
2138 break;
2139 }
2140 case SUMO_ATTR_TO: {
2141 // change last edge
2142 replaceLastParentEdge(value);
2143 // compute vehicle
2145 updateSpreadStackGeometry = true;
2146 break;
2147 }
2148 case SUMO_ATTR_VIA: {
2149 if (!value.empty()) {
2150 // set new via edges
2151 via = parse< std::vector<std::string> >(value);
2152 // mark parameter as set
2154 } else {
2155 // clear via
2156 via.clear();
2157 // unset parameter
2158 parametersSet &= ~VEHPARS_VIA_SET;
2159 }
2160 // compute vehicle
2162 updateSpreadStackGeometry = true;
2163 break;
2164 }
2165 case SUMO_ATTR_DEPARTEDGE: {
2166 // update depart edge
2167 if (value.empty()) {
2168 // unset parameter
2169 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2170 departEdge = -1;
2172 } else {
2173 // mark parameter as set
2175 departEdge = parse<int>(value);
2177 }
2178 // compute vehicle
2179 if (getID().size() > 0) {
2181 updateSpreadStackGeometry = true;
2182 }
2183 break;
2184 }
2185 case SUMO_ATTR_ARRIVALEDGE: {
2186 // update arrival edge
2187 if (value.empty()) {
2188 // unset parameter
2189 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2190 arrivalEdge = -1;
2192 } else {
2193 // mark parameter as set
2195 arrivalEdge = parse<int>(value);
2197 }
2198 if (getID().size() > 0) {
2199 // compute vehicle
2201 updateSpreadStackGeometry = true;
2202 }
2203 break;
2204 }
2205 // Specific of from-to junctions
2207 // change first junction
2209 // compute vehicle
2211 updateSpreadStackGeometry = true;
2212 break;
2213 }
2214 case SUMO_ATTR_TO_JUNCTION: {
2215 // change last junction
2217 // compute vehicle
2219 updateSpreadStackGeometry = true;
2220 break;
2221 }
2222 // Specific of from-to TAZs
2223 case SUMO_ATTR_FROM_TAZ: {
2224 // change first additional
2226 // set taz manually
2227 fromTaz = value;
2228 // compute vehicle
2230 updateSpreadStackGeometry = true;
2231 break;
2232 }
2233 case SUMO_ATTR_TO_TAZ: {
2234 // change last additional
2236 // set taz manually
2237 toTaz = value;
2238 // compute vehicle
2240 updateSpreadStackGeometry = true;
2241 break;
2242 }
2243 // other
2244 case GNE_ATTR_SELECTED:
2245 if (parse<bool>(value)) {
2247 } else {
2249 }
2250 break;
2252 setParametersStr(value);
2253 break;
2254 default:
2255 setFlowAttribute(this, key, value);
2256 break;
2257 }
2258 // check if stack label has to be updated
2259 if (updateSpreadStackGeometry) {
2261 getParentEdges().front()->updateVehicleStackLabels();
2262 getParentEdges().front()->updateVehicleSpreadGeometries();
2263 } else if (myTagProperty.vehicleRoute()) {
2264 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2265 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2266 } else if (myTagProperty.vehicleRouteEmbedded()) {
2267 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2268 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2269 }
2270 }
2271}
2272
2273
2274void
2276 // toggle flow attributes
2277 toggleFlowAttribute(key, value);
2278}
2279
2280
2281void
2283 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2285 // change depart
2288 departPos = moveResult.newFirstPos;
2289 }
2292 // change arrival
2295 arrivalPos = moveResult.newFirstPos;
2296 }
2297 // set lateral offset
2299 // update geometry
2301}
2302
2303
2304void
2306 // reset lateral offset
2308 // check value
2309 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2310 // continue depending if we're moving first or last position
2312 // begin change attribute
2313 undoList->begin(this, TLF("departPos of %", getTagStr()));
2314 // now set departPos
2315 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2316 // check if depart lane has to be changed
2317 if (moveResult.newFirstLane) {
2318 // set new depart lane
2320 }
2321 } else {
2322 // begin change attribute
2323 undoList->begin(this, TLF("arrivalPos of %", getTagStr()));
2324 // now set arrivalPos
2325 setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newFirstPos), undoList);
2326 // check if arrival lane has to be changed
2327 if (moveResult.newFirstLane) {
2328 // set new arrival lane
2330 }
2331 }
2332 }
2333 // end change attribute
2334 undoList->end();
2335}
2336
2337/****************************************************************************/
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
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 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
calculate contour extruded (used in elements formed by a central shape)
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 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:1116
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:1536
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:664
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:622
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:142
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:125
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2147
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
PathElement()=delete
invalidate default constructor
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getContour() const
getcontour associated with segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getLane() const
get lane associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
PathDraw * getPathDraw()
obtain instance of PathDraw
void addPathElementToRedrawBuffer(const GNEPathManager::PathElement *pathElement) const
add path elements to redraw buffer
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
void calculatePath(PathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
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
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
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
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 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 drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
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
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
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
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
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.
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