Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Representation of vehicles in netedit
19/****************************************************************************/
20
22#include <netedit/GNENet.h>
23#include <netedit/GNESegment.h>
25#include <netedit/GNEUndoList.h>
26#include <netedit/GNEViewNet.h>
37
38#include "GNEVehicle.h"
39#include "GNERoute.h"
40#include "GNERouteHandler.h"
41
42// ===========================================================================
43// FOX callback mapping
44// ===========================================================================
45
49
53
54// Object implementation
55FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
56FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
57
58// ===========================================================================
59// static definitions
60// ===========================================================================
61
63
64// ===========================================================================
65// GNEVehicle::GNESingleVehiclePopupMenu
66// ===========================================================================
67
69 GUIGLObjectPopupMenu(app, parent, vehicle),
70 myVehicle(vehicle) {
71 // build common options
72 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
73 // route length
74 vehicle->buildMenuCommandRouteLength(this);
75 // add transform functions only in demand mode
77 // add reverse
78 vehicle->buildMenuAddReverse(this);
79 // continue depending of type
81 // create menu pane for transform operations
82 FXMenuPane* transformOperation = new FXMenuPane(this);
83 this->insertMenuPaneChild(transformOperation);
84 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
85 // Create menu commands for all transform
86 GUIDesigns::buildFXMenuCommand(transformOperation,
87 TL("Trip (over junctions)"),
90 GUIDesigns::buildFXMenuCommand(transformOperation,
91 TL("Flow (over junctions)"),
94 } else if (myVehicle->getTagProperty()->vehicleTAZs()) {
95 // create menu pane for transform operations
96 FXMenuPane* transformOperation = new FXMenuPane(this);
97 this->insertMenuPaneChild(transformOperation);
98 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
99 // Create menu commands for all transform
100 GUIDesigns::buildFXMenuCommand(transformOperation,
101 TL("Trip (over TAZs)"),
104 GUIDesigns::buildFXMenuCommand(transformOperation,
105 TL("Flow (over TAZs)"),
108 } else {
109 // create menu pane for transform operations
110 FXMenuPane* transformOperation = new FXMenuPane(this);
111 this->insertMenuPaneChild(transformOperation);
112 new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
113 // Create menu commands for all transform
114 GUIDesigns::buildFXMenuCommand(transformOperation,
115 TL("Vehicle"),
118 GUIDesigns::buildFXMenuCommand(transformOperation,
119 TL("Vehicle (embedded route)"),
122 GUIDesigns::buildFXMenuCommand(transformOperation,
123 TL("RouteFlow"),
126 GUIDesigns::buildFXMenuCommand(transformOperation,
127 TL("RouteFlow (embedded route)"),
130 GUIDesigns::buildFXMenuCommand(transformOperation,
131 TL("Trip"),
134 GUIDesigns::buildFXMenuCommand(transformOperation,
135 TL("Flow"),
138 }
139 }
140}
141
142
144
145
146long
148 switch (FXSELID(sel)) {
151 break;
154 break;
156 GNERouteHandler::transformToVehicle(myVehicle, false);
157 break;
160 break;
163 break;
166 break;
169 break;
172 break;
175 break;
178 break;
179 default:
180 break;
181 }
182 return 1;
183}
184
185// ===========================================================================
186// GNEVehicle::GNESelectedVehiclesPopupMenu
187// ===========================================================================
188
189GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
190 GUIGLObjectPopupMenu(app, parent, vehicle),
191 mySelectedVehicles(selectedVehicle),
192 myVehicleTag(vehicle->getTagProperty()->getTag()) {
193 // build common options
194 vehicle->buildPopUpMenuCommonOptions(this, app, vehicle->myNet->getViewNet(), vehicle->getTagProperty()->getTag(), vehicle->isAttributeCarrierSelected());
195 // route length
196 vehicle->buildMenuCommandRouteLength(this);
197 // add transform functions only in demand mode
199 // add reverse
200 vehicle->buildMenuAddReverse(this);
201 // continue depending of type
202 if (vehicle->getTagProperty()->vehicleJunctions()) {
203 // create menu pane for transform operations
204 FXMenuPane* transformOperation = new FXMenuPane(this);
205 this->insertMenuPaneChild(transformOperation);
206 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
207 // Create menu commands for restricted transforms
209 TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
212 TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
214 // create separator
215 new FXMenuSeparator(transformOperation);
216 // Create menu commands for all transform
217 GUIDesigns::buildFXMenuCommand(transformOperation,
218 TL("Trips (over junctions)"),
220 GUIDesigns::buildFXMenuCommand(transformOperation,
221 TL("Flows (over junctions)"),
223 } else if (vehicle->getTagProperty()->vehicleTAZs()) {
224 // create menu pane for transform operations
225 FXMenuPane* transformOperation = new FXMenuPane(this);
226 this->insertMenuPaneChild(transformOperation);
227 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
228 // Create menu commands for all transform
230 TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
233 TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
235 // create separator
236 new FXMenuSeparator(transformOperation);
237 // Create menu commands for all transform
238 GUIDesigns::buildFXMenuCommand(transformOperation,
239 TL("Trips (over TAZs)"),
241 GUIDesigns::buildFXMenuCommand(transformOperation,
242 TL("Flows (over TAZs)"),
244 } else {
245 // create menu pane for transform operations
246 FXMenuPane* transformOperation = new FXMenuPane(this);
247 this->insertMenuPaneChild(transformOperation);
248 new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
249 // Create menu commands for all transform
251 TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
254 TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
257 TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
260 TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
263 TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
266 TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
268 // create separator
269 new FXMenuSeparator(transformOperation);
270 // Create menu commands for all transform
271 GUIDesigns::buildFXMenuCommand(transformOperation,
272 TL("Vehicles"),
274 GUIDesigns::buildFXMenuCommand(transformOperation,
275 TL("Vehicles (embedded route)"),
277 GUIDesigns::buildFXMenuCommand(transformOperation,
278 TL("RouteFlows"),
280 GUIDesigns::buildFXMenuCommand(transformOperation,
281 TL("RouteFlows (embedded route)"),
283 GUIDesigns::buildFXMenuCommand(transformOperation,
284 TL("Trips"),
286 GUIDesigns::buildFXMenuCommand(transformOperation,
287 TL("Flows"),
289 }
290 }
291}
292
293
295
296
297long
298GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
299 // iterate over all selected vehicles
300 for (const auto& vehicle : mySelectedVehicles) {
301 switch (FXSELID(sel)) {
303 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
304 if (myRestrictedMenuCommands.count(obj) > 0) {
305 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
307 }
308 } else {
310 }
311 }
312 break;
314 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
315 if (myRestrictedMenuCommands.count(obj) > 0) {
316 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
318 }
319 } else {
321 }
322 }
323 break;
325 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
326 if (myRestrictedMenuCommands.count(obj) > 0) {
327 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
329 }
330 } else {
332 }
333 }
334 break;
336 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
337 if (myRestrictedMenuCommands.count(obj) > 0) {
338 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
340 }
341 } else {
343 }
344 }
345 break;
347 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
348 if (myRestrictedMenuCommands.count(obj) > 0) {
349 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
351 }
352 } else {
354 }
355 }
356 break;
358 if (!vehicle->getTagProperty()->vehicleJunctions() && !vehicle->getTagProperty()->vehicleTAZs()) {
359 if (myRestrictedMenuCommands.count(obj) > 0) {
360 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
362 }
363 } else {
365 }
366 }
367 break;
369 if (vehicle->getTagProperty()->vehicleJunctions()) {
370 if (myRestrictedMenuCommands.count(obj) > 0) {
371 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
373 }
374 } else {
376 }
377 }
378 break;
380 if (vehicle->getTagProperty()->vehicleJunctions()) {
381 if (myRestrictedMenuCommands.count(obj) > 0) {
382 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
384 }
385 } else {
387 }
388 }
389 break;
391 if (vehicle->getTagProperty()->vehicleTAZs()) {
392 if (myRestrictedMenuCommands.count(obj) > 0) {
393 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
395 }
396 } else {
398 }
399 }
400 break;
402 if (vehicle->getTagProperty()->vehicleTAZs()) {
403 if (myRestrictedMenuCommands.count(obj) > 0) {
404 if (vehicle->getTagProperty()->getTag() == myRestrictedMenuCommands.at(obj)) {
406 }
407 } else {
409 }
410 }
411 break;
412 default:
413 break;
414 }
415 }
416 return 1;
417}
418
419// ===========================================================================
420// member method definitions
421// ===========================================================================
422#ifdef _MSC_VER
423#pragma warning(push)
424#pragma warning(disable: 4355) // mask warning about "this" in initializers
425#endif
429 // set end and vehPerHours as default flow values
432}
433
434
435GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename,
436 GNEDemandElement* vehicleType, GNEDemandElement* route) :
437 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
439 // set parents
440 setParents<GNEDemandElement*>({vehicleType, route});
441 // SUMOVehicleParameter ID has to be set manually
442 id = vehicleID;
443 // set manually vtypeID (needed for saving)
444 vtypeid = vehicleType->getID();
445}
446
447
448GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
449 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
450 GNEDemandElementFlow(this, vehicleParameters) {
451 // set parents
452 setParents<GNEDemandElement*>({vehicleType, route});
453 // SUMOVehicleParameter ID has to be set manually
454 id = vehicleParameters.id;
455 // set manually vtypeID (needed for saving)
456 vtypeid = vehicleType->getID();
457}
458
459
460GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
461 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
462 GNEDemandElementFlow(this, vehicleParameters) {
463 // set parents
464 setParent<GNEDemandElement*>(vehicleType);
465 // SUMOVehicleParameter ID has to be set manually
466 id = vehicleParameters.id;
467 // reset routeid
468 routeid.clear();
469 // set manually vtypeID (needed for saving)
470 vtypeid = vehicleType->getID();
471}
472
473
474GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType,
475 GNEEdge* fromEdge, GNEEdge* toEdge) :
476 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
478 // set parents
479 setParents<GNEEdge*>({fromEdge, toEdge});
480 setParent<GNEDemandElement*>(vehicleType);
481}
482
483
484GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
485 const SUMOVehicleParameter& vehicleParameters) :
486 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
487 GNEDemandElementFlow(this, vehicleParameters) {
488 // set parents
489 setParents<GNEEdge*>({fromEdge, toEdge});
490 setParent<GNEDemandElement*>(vehicleType);
491}
492
493
494GNEVehicle::GNEVehicle(SumoXMLTag tag, const std::string& vehicleID, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
495 GNEDemandElement(vehicleID, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
497 // set parents
498 setParents<GNEJunction*>({fromJunction, toJunction});
499 setParent<GNEDemandElement*>(vehicleType);
500}
501
502
503GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
504 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
505 GNEDemandElementFlow(this, vehicleParameters) {
506 // set parents
507 setParents<GNEJunction*>({fromJunction, toJunction});
508 setParent<GNEDemandElement*>(vehicleType);
509}
510
511
512GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& filename, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
513 GNEDemandElement(vehicleParameters.id, net, filename, tag, GNEPathElement::Options::DEMAND_ELEMENT),
514 GNEDemandElementFlow(this, vehicleParameters) {
515 // set parents
516 setParents<GNEAdditional*>({fromTAZ, toTAZ});
517 setParent<GNEDemandElement*>(vehicleType);
518 // mark taz parameters as set
521 fromTaz = fromTAZ->getID();
522 toTaz = toTAZ->getID();
523}
524#ifdef _MSC_VER
525#pragma warning(pop)
526#endif
527
528
530
531
534 // get first and last lanes
535 const GNELane* firstLane = getFirstPathLane();
536 const GNELane* lastLane = getLastPathLane();
537 // check both lanes
538 if (firstLane && lastLane) {
539 // get depart and arrival positions (doubles)
540 const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
541 const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
542 // obtain diameter
544 // return move operation depending if we're editing departPos or arrivalPos
546 return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
550 return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
553 }
554 }
555 // nothing to move
556 return nullptr;
557}
558
559
560void
562 // attribute VType must not be written if is DEFAULT_VTYPE_ID
564 // unset VType parameter
565 parametersSet &= ~VEHPARS_VTYPE_SET;
566 // write vehicle attributes (VType will not be written)
568 // set VType parameter again
570 } else {
571 // write vehicle attributes, including type/distribution
573 }
574 // write specific attribute depending of tag property
576 // write route
578 }
579 // write from, to and edge vias
581 // write manually from/to edges (it correspond to front and back parent edges)
582 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
583 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
584 // only write via if there isn't empty
585 if (via.size() > 0) {
586 device.writeAttr(SUMO_ATTR_VIA, via);
587 }
588 }
589 // write from and to junctions
591 // write manually from/to junctions (it correspond to front and back parent junctions)
594 }
595 // write flow attributes
596 writeFlowAttributes(this, device);
597 // write parameters
598 writeParams(device);
599 // write route elements associated to this vehicle (except for calibrator FLows)
600 if ((getChildDemandElements().size() > 0) && !myTagProperty->isCalibrator()) {
601 if (getChildDemandElements().front()->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
602 // write embedded route
603 getChildDemandElements().front()->writeDemandElement(device);
604 // write stops
605 for (const auto& demandElement : getChildDemandElements()) {
606 if (demandElement->getTagProperty()->isVehicleStop()) {
607 demandElement->writeDemandElement(device);
608 }
609 }
610 } else {
611 for (const auto& route : getChildDemandElements()) {
612 route->writeDemandElement(device);
613 }
614 }
615 }
616 // close vehicle tag
617 device.closeTag();
618}
619
620
623 // check conditions
624 if (myTagProperty->vehicleTAZs()) {
625 // vehicles and flows over tazs are always valid
626 return Problem::OK;
627 } else if (myTagProperty->vehicleEdges()) {
628 // check vehicles and flows paths
629 if (getParentEdges().front() == getParentEdges().back()) {
630 return Problem::OK;
631 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
632 return Problem::OK;
633 } else {
635 }
636 } else if (myTagProperty->vehicleJunctions()) {
637 // check vehicles and flows paths
638 if (getParentJunctions().front() == getParentJunctions().back()) {
639 return Problem::OK;
640 } else if (myNet->getDemandPathManager()->isPathValid(this)) {
641 return Problem::OK;
642 } else {
644 }
645 } else if (myTagProperty->vehicleRoute()) {
646 // check if exist a valid path using route parent edges
648 return Problem::OK;
649 } else {
651 }
652 } else if (myTagProperty->vehicleRouteEmbedded()) {
653 // check if exist a valid path using route child edges
655 return Problem::OK;
656 } else {
658 }
659 } else {
661 }
662}
663
664
665std::string
667 // only trips or flows can have problems
669 // check if exist at least a connection between every edge
670 for (int i = 1; i < (int)getParentEdges().size(); i++) {
672 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
673 }
674 }
675 // if there are connections between all edges, then all is ok
676 return "";
677 } else if (myTagProperty->vehicleJunctions()) {
678 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
679 } else if (myTagProperty->vehicleRoute()) {
680 // get route parent edges
681 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
682 // check if exist at least a connection between every edge
683 for (int i = 1; i < (int)routeEdges.size(); i++) {
684 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
685 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
686 }
687 }
688 // if there are connections between all edges, then all is ok
689 return "";
690 } else if (myTagProperty->vehicleRouteEmbedded()) {
691 // get route parent edges
692 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
693 // check if exist at least a connection between every edge
694 for (int i = 1; i < (int)routeEdges.size(); i++) {
695 if (myNet->getDemandPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
696 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
697 }
698 }
699 // if there are connections between all edges, then all is ok
700 return "";
701 } else {
702 return "";
703 }
704}
705
706
707void
711
712
715 return getParentDemandElements().front()->getVClass();
716}
717
718
719const RGBColor&
721 return color;
722}
723
724
725void
727 if (getParentJunctions().size() > 0) {
728 // calculate rotation between both junctions
729 const Position posA = getParentJunctions().front()->getPositionInView();
730 const Position posB = getParentJunctions().back()->getPositionInView();
731 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
732 // update Geometry
733 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
734 } else if (getParentAdditionals().size() > 0) {
735 // calculate rotation between both TAZs
736 const Position posA = getParentAdditionals().front()->getAttribute(SUMO_ATTR_CENTER).empty() ?
737 getParentAdditionals().front()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
738 getParentAdditionals().front()->getAttributePosition(SUMO_ATTR_CENTER);
739 const Position posB = getParentAdditionals().back()->getAttribute(SUMO_ATTR_CENTER).empty() ?
740 getParentAdditionals().back()->getAttributePosition(GNE_ATTR_TAZ_CENTROID) :
741 getParentAdditionals().back()->getAttributePosition(SUMO_ATTR_CENTER);
742 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
743 // update Geometry
745 } else {
746 // get first path lane
747 const GNELane* firstPathLane = getFirstPathLane();
748 // check path lane
749 if (firstPathLane) {
750 // declare departPos
751 double posOverLane = 0;
753 posOverLane = departPos;
754 }
755 // update Geometry
757 // compute route embedded associated with this vehicle
758 for (const auto& demandElement : getChildDemandElements()) {
759 if (demandElement->getTagProperty()->getTag() == GNE_TAG_ROUTE_EMBEDDED) {
760 demandElement->computePathElement();
761 }
762 demandElement->updateGeometry();
763 }
764 }
765 }
766}
767
768
773
774
775bool
777 // get edit modes
778 const auto& editModes = myNet->getViewNet()->getEditModes();
779 // check if we're editing a type
780 if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
782 return true;
783 }
784 // check opened popup
785 if (myNet->getViewNet()->getPopup()) {
786 return myNet->getViewNet()->getPopup()->getGLObject() == this;
787 }
788 return false;
789}
790
791
795 // obtain all selected vehicles
796 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
797 std::vector<GNEVehicle*> selectedVehicles;
798 selectedVehicles.reserve(selectedDemandElements.size());
799 for (const auto& selectedDemandElement : selectedDemandElements) {
800 if (selectedDemandElement->getTagProperty()->isVehicle()) {
801 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
802 }
803 }
804 // return a GNESelectedVehiclesPopupMenu
805 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
806 } else {
807 // return a GNESingleVehiclePopupMenu
808 return new GNESingleVehiclePopupMenu(this, app, parent);
809 }
810}
811
812
813std::string
816 return getRouteParent()->getID();
817 } else if (myTagProperty->vehicleEdges()) {
818 return getParentEdges().front()->getID();
819 } else if (myTagProperty->vehicleJunctions()) {
820 return getParentJunctions().front()->getID();
821 } else if (myTagProperty->vehicleTAZs()) {
822 return getParentAdditionals().front()->getID();
823 } else {
824 throw ProcessError(TL("Invalid vehicle tag"));
825 }
826}
827
828
829double
833
834
837 Boundary vehicleBoundary;
838 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
839 vehicleBoundary.grow(20);
840 return vehicleBoundary;
841}
842
843
844void
845GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
846 // geometry of this element cannot be splitted
847}
848
849
850void
852 // only drawn in super mode demand
856 // declare common attributes
858 const double exaggeration = getExaggeration(s);
859 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
860 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
861 // obtain Position an rotation (depending of draw spread vehicles)
862 if ((!drawSpreadVehicles || (mySpreadGeometry.getShape().size() > 0)) && (myDemandElementGeometry.getShape().size() > 0)) {
863 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
864 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
865 // check that position is valid
866 if (vehiclePosition == Position::INVALID) {
867 return;
868 }
869 // get detail level
870 const auto d = s.getDetailLevel(exaggeration);
871 // draw geometry only if we'rent in drawForObjectUnderCursor mode
874 // push draw matrix
876 // Start with the drawing of the area translating matrix to origin
878 // translate to drawing position
879 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
880 glRotated(vehicleRotation, 0, 0, -1);
881 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
882 glTranslated(0, (-1) * length * exaggeration, 0);
883 // set lane color
885 double upscaleLength = exaggeration;
886 if ((exaggeration > 1) && (length > 5)) {
887 // reduce the length/width ratio because this is not useful at high zoom
888 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
889 }
890 glScaled(exaggeration, upscaleLength, 1);
891 // draw the vehicle depending of detail level
898 }
899 // check if min gap has to be drawn
900 if (s.drawMinGap) {
901 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
902 glColor3d(0., 1., 0.);
903 glBegin(GL_LINES);
904 glVertex2d(0., 0);
905 glVertex2d(0., minGap);
906 glVertex2d(-.5, minGap);
907 glVertex2d(.5, minGap);
908 glEnd();
909 }
910 // drawing name at GLO_MAX fails unless translating z
911 glTranslated(0, MIN2(length / 2, double(5)), -getType());
912 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
913 glRotated(vehicleRotation, 0, 0, -1);
915 // draw line
916 if (s.vehicleName.show(this) && line != "") {
917 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
919 }
920 // pop draw matrix
922 // draw line between junctions if path isn't valid
923 if ((getParentJunctions().size() > 0) && !myNet->getDemandPathManager()->isPathValid(this)) {
924 drawJunctionLine(this);
925 }
926 // draw lock icon
927 GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
928 // draw stack label
929 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
930 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
931 }
932 // draw flow label
933 if (myTagProperty->isFlow()) {
934 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
935 }
936 // draw dotted contour
938 }
939 // draw squared shape
940 myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, getType(),
941 length * -0.5, 0, vehicleRotation, exaggeration, nullptr);
942 }
943 }
944}
945
946
947void
949 // calculate path (only for flows and trips)
951 // calculate path
953 } else if (myTagProperty->vehicleEdges()) {
954 // save edges in wich this vehicle has to stop
955 std::vector<GNEEdge*> edgeStops;
956 // iterate over child demand elements
957 for (const auto& demandElement : getChildDemandElements()) {
958 // extract lanes
959 if (demandElement->getTagProperty()->isVehicleStop()) {
960 GNEEdge* edgeStop = nullptr;
961 if (demandElement->getParentAdditionals().size() > 0) {
962 edgeStop = demandElement->getParentAdditionals().front()->getParentLanes().front()->getParentEdge();
963 } else {
964 edgeStop = demandElement->getParentLanes().front()->getParentEdge();
965 }
966 if (edgeStop) {
967 // avoid double edge stops
968 if (stops.empty()) {
969 edgeStops.push_back(edgeStop);
970 } else if (edgeStops.back() != edgeStop) {
971 edgeStops.push_back(edgeStop);
972 }
973 }
974 }
975 }
976 // declare edge vector
977 std::vector<GNEEdge*> edgePath;
978 // get first and last lanes
979 const auto firstLane = getFirstPathLane();
980 const auto lastLane = getLastPathLane();
981 // check first and last lanes
982 if (firstLane && lastLane) {
983 // add first lane
984 edgePath.push_back(firstLane->getParentEdge());
985 // give more priority to stops instead via
986 if (edgeStops.size() > 0) {
987 // add stops only if they're accesibles
988 for (const auto& edgeStop : edgeStops) {
989 // check if exist a valid path that includes the last edge
990 auto edgePathStop = edgePath;
991 edgePathStop.push_back(edgeStop);
992 edgePathStop.push_back(lastLane->getParentEdge());
994 if (path.size() > 0) {
995 edgePath.push_back(edgeStop);
996 }
997 }
998 } else {
999 // add via lanes
1000 for (const auto& edgeViaID : via) {
1001 const auto edgeVia = myNet->getAttributeCarriers()->retrieveEdge(edgeViaID, false);
1002 if (edgeVia) {
1003 // check if exist a valid path that includes the last edge
1004 auto edgePathStop = edgePath;
1005 edgePathStop.push_back(edgeVia);
1006 edgePathStop.push_back(lastLane->getParentEdge());
1007 if (myNet->getDemandPathManager()->getPathCalculator()->calculateDijkstraPath(getVClass(), edgePathStop).size() > 0) {
1008 edgePath.push_back(edgeVia);
1009 }
1010 }
1011 }
1012 }
1013 // add last lane
1014 edgePath.push_back(lastLane->getParentEdge());
1015 // calculate path
1016 myNet->getDemandPathManager()->calculatePath(this, getVClass(), edgePath);
1017 }
1018 }
1019 // update geometry
1021}
1022
1023
1024void
1025GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1026 // conditions for draw always in network mode
1027 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1030 // conditions for draw always in demand mode
1031 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1033 // conditions for draw if is selected
1034 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1036 // conditions for draw if is inspected
1037 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1039 // check drawing conditions
1040 if (segment->getLane() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1042 // get detail level
1043 const auto d = s.getDetailLevel(1);
1044 // calculate width
1045 const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1046 // calculate startPos
1047 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1048 // get endPos
1049 const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1050 // declare path geometry
1051 GUIGeometry vehicleGeometry;
1052 // update pathGeometry depending of first and last segment
1053 if (segment->isFirstSegment() && segment->isLastSegment()) {
1054 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1055 geometryDepartPos,
1057 geometryEndPos,
1059 } else if (segment->isFirstSegment()) {
1060 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1061 geometryDepartPos,
1063 -1,
1065 } else if (segment->isLastSegment()) {
1066 vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1067 -1,
1069 geometryEndPos,
1071 } else {
1072 vehicleGeometry = segment->getLane()->getLaneGeometry();
1073 }
1074 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1076 // obtain color
1078 // Add a draw matrix
1080 // Start with the drawing of the area translating matrix to origin
1081 glTranslated(0, 0, getType() + offsetFront);
1082 // Set color
1083 GLHelper::setColor(pathColor);
1084 // draw geometry
1085 GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1086 // Pop last matrix
1088 // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1089 if (segment->getNextLane()) {
1090 // push draw matrix
1092 // Start with the drawing of the area translating matrix to origin
1094 // Set red color
1096 // get firstPosition (last position of current lane shape)
1097 const Position& firstPosition = segment->getLane()->getLaneShape().back();
1098 // get lastPosition (first position of next lane shape)
1099 const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1100 // draw box line
1101 GLHelper::drawBoxLine(arrivalPosition,
1102 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1103 firstPosition.distanceTo2D(arrivalPosition), .05);
1104 // pop draw matrix
1106 }
1107 // check if this is the last segment
1108 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1109 // get geometryEndPos
1110 const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1111 // check if endPos can be drawn
1113 // push draw matrix
1115 // Start with the drawing of the area translating matrix to origin
1117 // translate to geometryEndPos
1118 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1119 // Set person plan color
1120 GLHelper::setColor(pathColor);
1121 // resolution of drawn circle depending of the zoom (To improve smoothness)
1123 // pop draw matrix
1125 }
1126 }
1127 // Draw name if isn't being drawn for selecting
1128 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
1129 // draw dotted contour
1130 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1131 }
1132 // calculate contour and draw dotted geometry
1133 if (segment->isFirstSegment() || segment->isLastSegment()) {
1134 segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), getType(), width, 1, false, segment->isLastSegment(),
1135 0, segment, segment->getLane()->getParentEdge());
1136 } else {
1137 segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), getType(), width, 1, false, segment->isLastSegment(),
1138 0, segment, segment->getLane()->getParentEdge());
1139 }
1140 // check if add this path element to redraw buffer
1141 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1143 }
1144 }
1145}
1146
1147
1148void
1149GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNESegment* segment, const double offsetFront) const {
1150 // conditions for draw always in network mode
1151 const bool drawInNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1154 // conditions for draw always in demand mode
1155 const bool drawInDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1157 // conditions for draw if is selected
1158 const bool isSelected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1160 // conditions for draw if is inspected
1161 const bool isInspected = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1163 // check drawing conditions
1164 if (segment->getJunction() && (drawInNetworkMode || drawInDemandMode || isSelected || isInspected) &&
1166 // get detail level
1167 const auto d = s.getDetailLevel(1);
1168 // calculate width
1169 const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1170 // draw geometry only if we'rent in drawForObjectUnderCursor mode
1172 // Add a draw matrix
1174 // Start with the drawing of the area translating matrix to origin
1175 glTranslated(0, 0, getType() + offsetFront);
1176 // Set color of the base
1177 if (drawUsingSelectColor()) {
1179 } else {
1181 }
1182 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1183 if (segment->getPreviousLane() && segment->getNextLane()) {
1184 // draw lane2lane
1186 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1187 // draw line between center of junction and last lane shape
1188 GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1189 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1190 // draw line between center of junction and first lane shape
1191 GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1192 }
1193 // Pop last matrix
1195 // draw dotted contour
1196 segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1197 }
1198 // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1199 if (segment->getPreviousLane() && segment->getNextLane()) {
1200 // calculate contour and draw dotted geometry
1202 getType(), width, 1, false, false, 0, segment, segment->getJunction());
1203 } else if (segment->getPreviousLane() && myTagProperty->vehicleJunctions()) {
1204 segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()},
1205 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1206 } else if (segment->getNextLane() && myTagProperty->vehicleJunctions()) {
1207 segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()},
1208 getType(), width, 1, true, true, 0, segment, segment->getJunction());
1209 }
1210 // check if add this path element to redraw buffer
1211 if (!gViewObjectsHandler.isPathElementMarkForRedraw(this) && segment->getContour()->checkDrawPathContour(s, d, this)) {
1213 }
1214 }
1215}
1216
1217
1218GNELane*
1220 // declare first edge
1221 GNEEdge* firstEdge = nullptr;
1222 // continue depending of tags
1223 if (myTagProperty->vehicleRoute()) {
1224 // check departEdge
1225 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1226 // use departEdge
1227 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1228 } else {
1229 // use first route edge
1230 firstEdge = getRouteParent()->getParentEdges().front();
1231 }
1232 } else if (myTagProperty->vehicleRouteEmbedded()) {
1233 // check if embedded route exist (due during loading embedded route doesn't exist)
1234 if (getChildDemandElements().empty()) {
1235 return nullptr;
1236 }
1237 // check departEdge
1238 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1239 // use depart edge
1240 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1241 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1242 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1243 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1244 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1245 } else {
1246 return nullptr;
1247 }
1248 } else if (getParentEdges().size() > 0) {
1249 // use first parent edge
1250 firstEdge = getParentEdges().front();
1251 } else {
1252 // defined over junctions
1253 return nullptr;
1254 }
1255 // get departLane index
1256 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1257 // check departLane index
1258 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getChildLanes().size())) {
1259 return firstEdge->getChildLanes().at(departLaneIndex);
1260 } else {
1261 // get first allowed VClass
1262 return firstEdge->getLaneByAllowedVClass(getVClass());
1263 }
1264}
1265
1266
1267GNELane*
1269 // declare last edge
1270 GNEEdge* lastEdge = nullptr;
1271 // continue depending of tags
1272 if (myTagProperty->vehicleRoute()) {
1273 // check arrivalEdge
1274 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1275 // use arrival edge
1276 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1277 } else {
1278 // use last route edge
1279 lastEdge = getRouteParent()->getParentEdges().back();
1280 }
1281 } else if (myTagProperty->vehicleRouteEmbedded()) {
1282 // check if embedded route exist (due during loading embedded route doesn't exist)
1283 if (getChildDemandElements().empty()) {
1284 return nullptr;
1285 }
1286 // check arrivalEdge
1287 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1288 // use arrival edge
1289 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1290 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1291 // use last route edge
1292 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1293 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1294 // use lane
1295 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1296 } else {
1297 return nullptr;
1298 }
1299 } else if (getParentEdges().size() > 0) {
1300 // use last parent edge
1301 lastEdge = getParentEdges().back();
1302 } else {
1303 // defined over junctions
1304 return nullptr;
1305 }
1306 // get arrivalLane index
1307 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1308 // check arrivalLane index
1309 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getChildLanes().size())) {
1310 return lastEdge->getChildLanes().at(arrivalLaneIndex);
1311 } else {
1312 // get last allowed VClass
1313 return lastEdge->getLaneByAllowedVClass(getVClass());
1314 }
1315}
1316
1317
1318std::string
1320 switch (key) {
1321 case SUMO_ATTR_ID:
1322 return getMicrosimID();
1323 case SUMO_ATTR_TYPE:
1324 return vtypeid;
1325 case SUMO_ATTR_COLOR:
1327 return toString(color);
1328 } else {
1330 }
1333 return getDepartLane();
1334 } else {
1336 }
1339 return getDepartPos();
1340 } else {
1342 }
1345 return getDepartSpeed();
1346 } else {
1348 }
1351 return getArrivalLane();
1352 } else {
1354 }
1357 return getArrivalPos();
1358 } else {
1360 }
1363 return getArrivalSpeed();
1364 } else {
1366 }
1367 case SUMO_ATTR_LINE:
1368 if (wasSet(VEHPARS_LINE_SET)) {
1369 return line;
1370 } else {
1372 }
1375 return toString(personNumber);
1376 } else {
1378 }
1381 return toString(containerNumber);
1382 } else {
1384 }
1385 case SUMO_ATTR_REROUTE:
1387 return "true";
1388 } else {
1389 return "false";
1390 }
1393 return getDepartPosLat();
1394 } else {
1396 }
1399 return getArrivalPosLat();
1400 } else {
1402 }
1404 return getInsertionChecks();
1405 // Specific of vehicles over routes
1406 case SUMO_ATTR_ROUTE:
1407 if (getParentDemandElements().size() == 2) {
1408 return getRouteParent()->getID();
1409 } else {
1410 return "";
1411 }
1412 // Specific of from-to edge
1413 case SUMO_ATTR_FROM:
1414 return getParentEdges().front()->getID();
1415 case SUMO_ATTR_TO:
1416 return getParentEdges().back()->getID();
1417 case SUMO_ATTR_VIA:
1418 return toString(via);
1420 if (departEdge == -1) {
1421 return "";
1422 } else {
1423 return toString(departEdge);
1424 }
1426 if (arrivalEdge == -1) {
1427 return "";
1428 } else {
1429 return toString(arrivalEdge);
1430 }
1431 // Specific of from-to junctions
1433 return getParentJunctions().front()->getID();
1435 return getParentJunctions().back()->getID();
1436 // Specific of from-to tazs
1437 case SUMO_ATTR_FROM_TAZ:
1438 return getParentAdditionals().front()->getID();
1439 case SUMO_ATTR_TO_TAZ:
1440 return getParentAdditionals().back()->getID();
1441 // other
1443 return toString(parametersSet);
1444 default:
1445 return getFlowAttribute(this, key);
1446 }
1447}
1448
1449
1450double
1452 switch (key) {
1455 return departLane;
1456 } else {
1457 return -1;
1458 }
1460 // only return departPos it if is given
1462 return departPos;
1463 } else {
1464 return 0;
1465 }
1468 return arrivalLane;
1469 } else {
1470 return -1;
1471 }
1473 // only return departPos it if is given
1475 return arrivalPos;
1476 } else {
1477 return -1;
1478 }
1479 case SUMO_ATTR_WIDTH:
1480 case SUMO_ATTR_LENGTH:
1481 case SUMO_ATTR_MINGAP:
1482 return getTypeParent()->getAttributeDouble(key);
1483 default:
1484 return getFlowAttributeDouble(key);
1485 }
1486}
1487
1488
1491 switch (key) {
1493 // check if this vehicle was defined over junctions
1494 if (getParentJunctions().size() > 0) {
1495 return getParentJunctions().front()->getPositionInView();
1496 } else {
1497 // get first path lane shape
1498 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1499 // check arrivalPosProcedure
1501 if (departPos < 0) {
1502 return laneShape.front();
1503 } else if (departPos > laneShape.length2D()) {
1504 return laneShape.back();
1505 } else {
1506 return laneShape.positionAtOffset2D(departPos);
1507 }
1508 } else {
1509 return laneShape.front();
1510 }
1511 }
1512 }
1514 // check if this vehicle was defined over junctions
1515 if (getParentJunctions().size() > 0) {
1516 return getParentJunctions().back()->getPositionInView();
1517 } else {
1518 // get last path lane shape
1519 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1520 // check arrivalPosProcedure
1522 if (arrivalPos < 0) {
1523 return laneShape.front();
1524 } else if (arrivalPos > laneShape.length2D()) {
1525 return laneShape.back();
1526 } else {
1527 return laneShape.positionAtOffset2D(arrivalPos);
1528 }
1529 } else {
1530 return laneShape.back();
1531 }
1532 }
1533 }
1534 default:
1535 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1536 }
1537}
1538
1539
1540void
1541GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1542 if (value == getAttribute(key)) {
1543 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1544 }
1545 switch (key) {
1546 case SUMO_ATTR_ID:
1547 case SUMO_ATTR_TYPE:
1548 case SUMO_ATTR_COLOR:
1555 case SUMO_ATTR_LINE:
1558 case SUMO_ATTR_REROUTE:
1562 // Specific of vehicles over routes
1563 case SUMO_ATTR_ROUTE:
1564 // Specific of from-to edges
1565 case SUMO_ATTR_FROM:
1566 case SUMO_ATTR_TO:
1567 case SUMO_ATTR_VIA:
1570 // Specific of from-to junctions
1573 // Specific of from-to taz
1574 case SUMO_ATTR_FROM_TAZ:
1575 case SUMO_ATTR_TO_TAZ:
1576 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1577 break;
1578 default:
1579 setFlowAttribute(this, key, value, undoList);
1580 break;
1581 }
1582}
1583
1584
1585bool
1586GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1587 // get ACs
1588 const auto ACs = myNet->getAttributeCarriers();
1589 // declare string error
1590 std::string error;
1591 switch (key) {
1592 case SUMO_ATTR_ID:
1594 case SUMO_ATTR_TYPE:
1595 return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1596 case SUMO_ATTR_COLOR:
1597 return canParse<RGBColor>(value);
1598 case SUMO_ATTR_DEPARTLANE: {
1599 int dummyDepartLane;
1600 DepartLaneDefinition dummyDepartLaneProcedure;
1601 parseDepartLane(value, myTagProperty->getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1602 // if error is empty, check if depart lane is correct
1603 if (error.empty()) {
1604 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1605 return true;
1606 } else if (isTemplate()) {
1607 return true;
1608 } else if (getParentJunctions().size() > 0) {
1609 return (dummyDepartLane == 0);
1610 } else if (getParentAdditionals().size() > 0) {
1611 return (dummyDepartLane == 0);
1612 } else {
1613 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getChildLanes().size();
1614 }
1615 } else {
1616 return false;
1617 }
1618 }
1619 case SUMO_ATTR_DEPARTPOS: {
1620 double dummyDepartPos;
1621 DepartPosDefinition dummyDepartPosProcedure;
1622 parseDepartPos(value, myTagProperty->getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1623 // if error is empty, given value is valid
1624 return error.empty();
1625 }
1626 case SUMO_ATTR_DEPARTSPEED: {
1627 double dummyDepartSpeed;
1628 DepartSpeedDefinition dummyDepartSpeedProcedure;
1629 parseDepartSpeed(value, myTagProperty->getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1630 // if error is empty, check if depart speed is correct
1631 if (error.empty()) {
1632 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1633 return true;
1634 } else if (isTemplate()) {
1635 return true;
1636 } else {
1637 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1638 }
1639 } else {
1640 return false;
1641 }
1642 }
1643 case SUMO_ATTR_ARRIVALLANE: {
1644 int dummyArrivalLane;
1645 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1646 parseArrivalLane(value, myTagProperty->getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1647 // if error is empty, given value is valid
1648 if (error.empty()) {
1649 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1650 return true;
1651 } else if (isTemplate()) {
1652 return true;
1653 } else if (getParentJunctions().size() > 0) {
1654 return (dummyArrivalLane == 0);
1655 } else if (getParentAdditionals().size() > 0) {
1656 return (dummyArrivalLane == 0);
1657 } else {
1658 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getChildLanes().size();
1659 }
1660 } else {
1661 return false;
1662 }
1663 }
1664 case SUMO_ATTR_ARRIVALPOS: {
1665 double dummyArrivalPos;
1666 ArrivalPosDefinition dummyArrivalPosProcedure;
1667 parseArrivalPos(value, myTagProperty->getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1668 // if error is empty, given value is valid
1669 return error.empty();
1670 }
1672 double dummyArrivalSpeed;
1673 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1674 parseArrivalSpeed(value, myTagProperty->getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1675 // if error is empty, given value is valid
1676 return error.empty();
1677 }
1678 case SUMO_ATTR_LINE:
1679 return true;
1681 return canParse<int>(value) && parse<int>(value) >= 0;
1683 return canParse<int>(value) && parse<int>(value) >= 0;
1684 case SUMO_ATTR_REROUTE:
1685 return true; // check
1687 double dummyDepartPosLat;
1688 DepartPosLatDefinition dummyDepartPosLatProcedure;
1689 parseDepartPosLat(value, myTagProperty->getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1690 // if error is empty, given value is valid
1691 return error.empty();
1692 }
1694 double dummyArrivalPosLat;
1695 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1696 parseArrivalPosLat(value, myTagProperty->getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1697 // if error is empty, given value is valid
1698 return error.empty();
1699 }
1701 return areInsertionChecksValid(value);
1702 // Specific of vehicles over routes
1703 case SUMO_ATTR_ROUTE:
1704 if (getParentDemandElements().size() == 2) {
1705 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1706 } else {
1707 return true;
1708 }
1709 // Specific of from-to edges
1710 case SUMO_ATTR_FROM:
1711 case SUMO_ATTR_TO:
1712 return (ACs->retrieveEdge(value, false) != nullptr);
1714 case SUMO_ATTR_ARRIVALEDGE: {
1715 if (value.empty()) {
1716 return true;
1717 } else if (canParse<int>(value)) {
1718 // get index
1719 const int index = parse<int>(value);
1720 // check conditions
1721 if (index < 0) {
1722 return false;
1723 } else if (myTagProperty->vehicleRoute()) {
1724 // check parent route
1725 return (index < (int)getRouteParent()->getParentEdges().size());
1726 } else {
1727 // check embedded route
1728 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1729 }
1730 } else {
1731 return false;
1732 }
1733 }
1734 case SUMO_ATTR_VIA:
1735 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1736 // Specific of from-to junctions
1739 return (ACs->retrieveJunction(value, false) != nullptr);
1740 // Specific of from-to taz
1741 case SUMO_ATTR_FROM_TAZ:
1742 case SUMO_ATTR_TO_TAZ:
1743 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1744 default:
1745 return isValidFlowAttribute(this, key, value);
1746 }
1747}
1748
1749
1750void
1752 enableFlowAttribute(this, key, undoList);
1753}
1754
1755
1756void
1758 disableFlowAttribute(this, key, undoList);
1759}
1760
1761
1762bool
1766
1767
1768std::string
1770 return getTagStr();
1771}
1772
1773
1774std::string
1776 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1777 // special case for Trips and flow
1778 if (myTagProperty->vehicleEdges()) {
1779 // check if we're inspecting a Edge
1780 if (inspectedElements.getFirstAC() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_EDGE)) {
1781 // check if edge correspond to a "from", "to" or "via" edge
1782 if (inspectedElements.isACInspected(getParentEdges().front())) {
1783 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1784 } else if (inspectedElements.isACInspected(getParentEdges().front())) {
1785 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1786 } else {
1787 // iterate over via
1788 for (const auto& viaEdgeID : via) {
1789 if (viaEdgeID == inspectedElements.getFirstAC()->getID()) {
1790 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1791 }
1792 }
1793 }
1794 }
1795 }
1796 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1797}
1798
1799
1800const Parameterised::Map&
1804
1805
1807GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1808 // get net and undoList
1809 const auto net = originalVehicle->getNet();
1810 auto undoList = net->getViewNet()->getUndoList();
1811 // declare new route, vehicle and embedded route
1812 GNERoute* newRoute = nullptr;
1813 GNEVehicle* newVehicle = nullptr;
1814 GNERoute* newEmbeddedRoute = nullptr;
1815 // generate new vehicle ID
1816 const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1817 const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty()->getTag());
1818 // extract vehicle parameters and update ID
1819 auto newVehicleParameters = originalVehicle->getSUMOVehicleParameter();
1820 newVehicleParameters.id = newVehicleID;
1821 // create vehicle using vehicleParameters
1822 if (originalVehicle->getTagProperty()->vehicleRoute()) {
1823 newRoute = new GNERoute(newRouteID, originalVehicle->getParentDemandElements().at(1));
1824 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1825 originalVehicle->getParentDemandElements().at(0), newRoute,
1826 newVehicleParameters);
1827 } else if (originalVehicle->getTagProperty()->vehicleRouteEmbedded()) {
1828 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1829 originalVehicle->getParentDemandElements().at(0),
1830 newVehicleParameters);
1831 newEmbeddedRoute = new GNERoute(newVehicle, originalVehicle->getChildDemandElements().front());
1832 } else if (originalVehicle->getTagProperty()->vehicleEdges()) {
1833 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1834 originalVehicle->getParentDemandElements().at(0),
1835 originalVehicle->getParentEdges().front(),
1836 originalVehicle->getParentEdges().back(),
1837 newVehicleParameters);
1838 } else if (originalVehicle->getTagProperty()->vehicleJunctions()) {
1839 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1840 originalVehicle->getParentDemandElements().at(0),
1841 originalVehicle->getParentJunctions().front(),
1842 originalVehicle->getParentJunctions().back(),
1843 newVehicleParameters);
1844 } else if (originalVehicle->getTagProperty()->vehicleTAZs()) {
1845 newVehicle = new GNEVehicle(originalVehicle->getTagProperty()->getTag(), net, originalVehicle->getFilename(),
1846 originalVehicle->getParentDemandElements().at(0),
1847 originalVehicle->getParentAdditionals().front(),
1848 originalVehicle->getParentAdditionals().back(),
1849 newVehicleParameters);
1850 }
1851 // add new vehicle
1852 undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1853 if (newRoute) {
1854 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1855 }
1856 undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1857 if (newEmbeddedRoute) {
1858 net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1859 }
1860 undoList->end();
1861 return newVehicle;
1862}
1863
1864// ===========================================================================
1865// protected
1866// ===========================================================================
1867
1870 // change color
1871 if (drawUsingSelectColor()) {
1873 } else {
1874 return getColorByScheme(s.vehicleColorer, this);
1875 }
1876}
1877
1878
1881 return *this;
1882}
1883
1884// ===========================================================================
1885// private
1886// ===========================================================================
1887
1888void
1889GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1890 // declare string error
1891 std::string error;
1892 // flag to upate stack label
1893 bool updateSpreadStackGeometry = false;
1894 switch (key) {
1895 case SUMO_ATTR_ID:
1896 // update microsimID
1897 setDemandElementID(value);
1898 // set manually vehicle ID (needed for saving)
1899 id = value;
1900 break;
1901 case SUMO_ATTR_TYPE:
1902 if (getID().size() > 0) {
1903 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1905 } else {
1907 }
1908 // set manually vtypeID (needed for saving)
1909 vtypeid = value;
1910 }
1911 break;
1912 case SUMO_ATTR_COLOR:
1913 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1914 color = parse<RGBColor>(value);
1915 // mark parameter as set
1917 } else {
1918 // set default value
1920 // unset parameter
1921 parametersSet &= ~VEHPARS_COLOR_SET;
1922 }
1923 break;
1925 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1927 // mark parameter as set
1929 } else {
1930 // set default value
1932 // unset parameter
1933 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1934 }
1935 break;
1937 if (value == toString(INVALID_DOUBLE)) {
1939 // mark parameter as set
1941 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1943 // mark parameter as set
1945 } else {
1946 // set default value
1948 // unset parameter
1949 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1950 }
1951 if (getID().size() > 0) {
1953 updateSpreadStackGeometry = true;
1954 }
1955 break;
1957 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1959 // mark parameter as set
1961 } else {
1962 // set default value
1964 // unset parameter
1965 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1966 }
1967 break;
1969 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1971 // mark parameter as set
1973 } else {
1974 // set default value
1976 // unset parameter
1977 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
1978 }
1979 break;
1981 if (value == toString(INVALID_DOUBLE)) {
1983 // mark parameter as set
1985 } else if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
1987 // mark parameter as set
1989 } else {
1990 // set default value
1992 // unset parameter
1993 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
1994 }
1995 if (getID().size() > 0) {
1997 updateSpreadStackGeometry = true;
1998 }
1999 break;
2001 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2003 // mark parameter as set
2005 } else {
2006 // set default value
2008 // unset parameter
2009 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2010 }
2011 break;
2012 case SUMO_ATTR_LINE:
2013 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2014 line = value;
2015 // mark parameter as set
2017 } else {
2018 // set default value
2020 // unset parameter
2021 parametersSet &= ~VEHPARS_LINE_SET;
2022 }
2023 break;
2025 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2026 personNumber = parse<int>(value);
2027 // mark parameter as set
2029 } else {
2030 // set default value
2032 // unset parameter
2033 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2034 }
2035 break;
2037 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2038 containerNumber = parse<int>(value);
2039 // mark parameter as set
2041 } else {
2042 // set default value
2044 // unset parameter
2045 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2046 }
2047 break;
2048 case SUMO_ATTR_REROUTE:
2049 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2050 // mark parameter as set
2052 } else {
2053 // unset parameter
2054 parametersSet &= ~VEHPARS_ROUTE_SET;
2055 }
2056 break;
2058 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2060 // mark parameter as set
2062 } else {
2063 // set default value
2065 // unset parameter
2066 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2067 }
2068 break;
2070 if (!value.empty() && (value != myTagProperty->getDefaultStringValue(key))) {
2072 // mark parameter as set
2074 } else {
2075 // set default value
2077 // unset parameter
2078 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2079 }
2081 break;
2083 if (value.empty() || (value == "all")) {
2084 // unset parameter
2085 parametersSet &= ~VEHPARS_INSERTION_CHECKS_SET;
2086 } else {
2087 // mark parameter as set
2089 }
2091 break;
2092 // Specific of vehicles over routes
2093 case SUMO_ATTR_ROUTE:
2094 if (getParentDemandElements().size() == 2) {
2096 }
2098 updateSpreadStackGeometry = true;
2099 break;
2100 // Specific of from-to edges
2101 case SUMO_ATTR_FROM: {
2102 // change first edge
2104 // compute vehicle
2106 updateSpreadStackGeometry = true;
2107 break;
2108 }
2109 case SUMO_ATTR_TO: {
2110 // change last edge
2111 replaceLastParentEdge(value);
2112 // compute vehicle
2114 updateSpreadStackGeometry = true;
2115 break;
2116 }
2117 case SUMO_ATTR_VIA: {
2118 if (!value.empty()) {
2119 // set new via edges
2120 via = parse< std::vector<std::string> >(value);
2121 // mark parameter as set
2123 } else {
2124 // clear via
2125 via.clear();
2126 // unset parameter
2127 parametersSet &= ~VEHPARS_VIA_SET;
2128 }
2129 // compute vehicle
2131 updateSpreadStackGeometry = true;
2132 break;
2133 }
2134 case SUMO_ATTR_DEPARTEDGE: {
2135 // update depart edge
2136 if (value.empty()) {
2137 // unset parameter
2138 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2139 departEdge = -1;
2141 } else {
2142 // mark parameter as set
2144 departEdge = parse<int>(value);
2146 }
2147 // compute vehicle
2148 if (getID().size() > 0) {
2150 updateSpreadStackGeometry = true;
2151 }
2152 break;
2153 }
2154 case SUMO_ATTR_ARRIVALEDGE: {
2155 // update arrival edge
2156 if (value.empty()) {
2157 // unset parameter
2158 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2159 arrivalEdge = -1;
2161 } else {
2162 // mark parameter as set
2164 arrivalEdge = parse<int>(value);
2166 }
2167 if (getID().size() > 0) {
2168 // compute vehicle
2170 updateSpreadStackGeometry = true;
2171 }
2172 break;
2173 }
2174 // Specific of from-to junctions
2176 // change first junction
2178 // compute vehicle
2180 updateSpreadStackGeometry = true;
2181 break;
2182 }
2183 case SUMO_ATTR_TO_JUNCTION: {
2184 // change last junction
2186 // compute vehicle
2188 updateSpreadStackGeometry = true;
2189 break;
2190 }
2191 // Specific of from-to TAZs
2192 case SUMO_ATTR_FROM_TAZ: {
2193 // change first additional
2195 // set taz manually
2196 fromTaz = value;
2197 // compute vehicle
2199 updateSpreadStackGeometry = true;
2200 break;
2201 }
2202 case SUMO_ATTR_TO_TAZ: {
2203 // change last additional
2205 // set taz manually
2206 toTaz = value;
2207 // compute vehicle
2209 updateSpreadStackGeometry = true;
2210 break;
2211 }
2212 default:
2213 setFlowAttribute(this, key, value);
2214 break;
2215 }
2216 // check if stack label has to be updated
2217 if (updateSpreadStackGeometry) {
2218 if (myTagProperty->vehicleEdges()) {
2219 getParentEdges().front()->updateVehicleStackLabels();
2220 getParentEdges().front()->updateVehicleSpreadGeometries();
2221 } else if (myTagProperty->vehicleRoute()) {
2222 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2223 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2224 } else if (myTagProperty->vehicleRouteEmbedded()) {
2225 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2226 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2227 }
2228 }
2229}
2230
2231
2232void
2234 // toggle flow attributes
2235 toggleFlowAttribute(key, value);
2236}
2237
2238
2239void
2241 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2243 // change depart
2246 departPos = moveResult.newFirstPos;
2247 }
2250 // change arrival
2253 arrivalPos = moveResult.newFirstPos;
2254 }
2255 // set lateral offset
2257 // update geometry
2259}
2260
2261
2262void
2264 // reset lateral offset
2266 // check value
2267 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2268 // continue depending if we're moving first or last position
2270 // begin change attribute
2271 undoList->begin(this, TLF("departPos of %", getTagStr()));
2272 // now set departPos
2273 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2274 // check if depart lane has to be changed
2275 if (moveResult.newFirstLane) {
2276 // set new depart lane
2278 }
2279 } else {
2280 // begin change attribute
2281 undoList->begin(this, TLF("arrivalPos of %", getTagStr()));
2282 // now set arrivalPos
2283 setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newFirstPos), undoList);
2284 // check if arrival lane has to be changed
2285 if (moveResult.newFirstLane) {
2286 // set new arrival lane
2288 }
2289 }
2290 }
2291 // end change attribute
2292 undoList->end();
2293}
2294
2295/****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ DEMAND_TYPE
Mode for editing types.
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_EMBEDDED
transform vehicle to flow over junctions
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_TAZS
transform vehicle to flow over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE_EMBEDDED
transform vehicle to vehicle over junctions
@ MID_GNE_VEHICLE_TRANSFORM_ROUTEFLOW
transform vehicle to flow over route
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_JUNCTIONS
transform vehicle to trip over junctions
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_TAZS
transform vehicle to trip over TAZs
@ MID_GNE_VEHICLE_TRANSFORM_TRIP
transform vehicle to trip
@ MID_GNE_VEHICLE_TRANSFORM_FLOW
transform vehicle to flow
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE
transform vehicle to vehicle over route
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_JUNCTIONS
transform vehicle to flow over jucntions
GUIViewObjectsHandler gViewObjectsHandler
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const long long int VEHPARS_ARRIVALSPEED_SET
const long long int VEHPARS_DEPARTPOSLAT_SET
const long long int VEHPARS_ARRIVALPOSLAT_SET
const long long int VEHPARS_PERSON_NUMBER_SET
const long long int VEHPARS_DEPARTSPEED_SET
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
const long long int VEHPARS_ROUTE_SET
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
const long long int VEHPARS_COLOR_SET
const long long int VEHPARS_VIA_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_ARRIVALLANE_SET
const long long int VEHPARS_DEPARTLANE_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_ARRIVALPOS_SET
const long long int VEHPARS_ARRIVALEDGE_SET
const long long int VEHPARS_CONTAINER_NUMBER_SET
const long long int VEHPARS_FROM_TAZ_SET
const long long int VEHPARS_VTYPE_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ GIVEN
The arrival position is given.
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const long long int VEHPARS_LINE_SET
const long long int VEHPARS_DEPARTEDGE_SET
const long long int VEHPARS_INSERTION_CHECKS_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_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
description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_TO_JUNCTION
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_TAZ_CENTROID
TAZ Center (uses to return the TAZ centroid if center is not defined)
@ SUMO_ATTR_MINGAP
@ 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:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition GLHelper.cpp:348
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition GLHelper.cpp:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:779
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
bool isTemplate() const
check if this AC is template
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
const std::string & getFilename() const
get filename in which save this AC
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
std::string getFlowAttribute(const GNEDemandElement *flowElement, SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
RGBColor getColorByScheme(const GUIColorer &c, const SUMOVehicleParameter *parameters) const
get color by scheme (used by vehicles, persons and containers)
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
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:1572
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNELane * > & getChildLanes() const
get child lanes
const GNEHierarchicalContainerParents< GNEJunction * > & getParentJunctions() const
get parent junctions
const GNEHierarchicalContainerParents< GNELane * > & getParentLanes() const
get parent lanes
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
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:220
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:692
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:650
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:214
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:202
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
bool getAllowChangeLane() const
allow change lane
CommonMoveOptions * getCommonMoveOptions() 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:176
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, const SumoXMLTag tag, const bool isPlan)
check if path element geometry must be drawn in the given lane
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void calculatePath(GNEPathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const GNEPathElement *pathElement) const
check if path element is valid
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToFlowJunctions(GNEVehicle *originalVehicle)
transform to flow over junctions
static void transformToTripJunctions(GNEVehicle *originalVehicle)
transform to trip over junctions
static void transformToFlowTAZs(GNEVehicle *originalVehicle)
transform to flow over TAZs
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
static void transformToTripTAZs(GNEVehicle *originalVehicle)
transform to trip over TAZs
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
bool isLastSegment() const
check if segment is the last path's segment
bool isFlow() const
return true if tag correspond to a flow element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
const RGBColor & getDefaultColorValue(SumoXMLAttr attr) const
get default bool value
bool vehicleJunctions() const
return true if tag correspond to a vehicle placed over from-to junctions
bool isCalibrator() const
return true if tag correspond to a calibrator (Only used to group all detectors in the XML)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
int getDefaultIntValue(SumoXMLAttr attr) const
get default int value
SumoXMLTag getXMLTag() const
default values
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
const std::string & getDefaultStringValue(SumoXMLAttr attr) const
default values
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:62
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
long onCmdTransform(FXObject *obj, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
std::map< FXObject *, SumoXMLTag > myRestrictedMenuCommands
selected menu commands
Definition GNEVehicle.h:89
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:35
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
GNEVehicle * myVehicle
current vehicle
Definition GNEVehicle.h:58
const Parameterised::Map & getACParametersMap() const
get parameters map
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
GNEMoveOperation * getMoveOperation()
get move operation
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
void computePathElement()
compute pathElement
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition GNEVehicle.h:302
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
double getAttributeDouble(SumoXMLAttr key) const
RGBColor getDrawingColor(const GUIVisualizationSettings &s) const
get drawing color
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool isAttributeEnabled(SumoXMLAttr key) const
const RGBColor & getColor() const
get color
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition GNEVehicle.h:312
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
void updateGeometry()
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
bool isACInspected(GNEAttributeCarrier *AC) const
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
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.
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void buildPopUpMenuCommonOptions(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, GUISUMOAbstractView *parent, const SumoXMLTag tag, const bool selected, bool addSeparator=true)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
GUIVisualizationWidthSettings widthSettings
width settings
bool checkDrawVehicle(Detail d, const bool selected) const
check if draw vehicle
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:278
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:319
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor RED
named colors
Definition RGBColor.h:188
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
static bool parseArrivalPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosLatDefinition &apd, std::string &error)
Validates a given arrivalPosLat value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
std::string getArrivalLane() const
obtain arrival lane parameter in string format
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
RouteIndexDefinition arrivalEdgeProcedure
Information how the vehicle's final edge shall be chosen.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
bool areInsertionChecksValid(const std::string &value) const
check if given insertion checks are valid
double arrivalPos
(optional) The position the vehicle shall arrive on
static int parseInsertionChecks(const std::string &value)
parses insertion checks
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string getInsertionChecks() const
get insertion checks in string format
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int departEdge
(optional) The initial edge within the route of the vehicle
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int insertionChecks
bitset of InsertionCheck
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
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