Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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#include <cmath>
22#include <netedit/GNENet.h>
23#include <netedit/GNEUndoList.h>
24#include <netedit/GNEViewNet.h>
37
38#include "GNEVehicle.h"
39#include "GNERouteHandler.h"
40
41// ===========================================================================
42// FOX callback mapping
43// ===========================================================================
47
51
52// Object implementation
53FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
54FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
55
56// ===========================================================================
57// static definitions
58// ===========================================================================
60
61// ===========================================================================
62// GNEVehicle::GNESingleVehiclePopupMenu
63// ===========================================================================
64
66 GUIGLObjectPopupMenu(app, parent, *vehicle),
67 myVehicle(vehicle),
68 myTransformToVehicle(nullptr),
69 myTransformToVehicleWithEmbeddedRoute(nullptr),
70 myTransformToRouteFlow(nullptr),
71 myTransformToRouteFlowWithEmbeddedRoute(nullptr),
72 myTransformToTrip(nullptr),
73 myTransformToFlow(nullptr) {
74 // build header
75 myVehicle->buildPopupHeader(this, app);
76 // build menu command for center button and copy cursor position to clipboard
79 // build menu commands for names
80 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
81 GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
82 new FXMenuSeparator(this);
83 // build selection and show parameters menu
86 // route length
87 vehicle->buildMenuCommandRouteLength(this);
88 // add transform functions only in demand mode
90 // Get icons
91 FXIcon* vehicleIcon = GUIIconSubSys::getIcon(GUIIcon::VEHICLE);
92 FXIcon* tripIcon = GUIIconSubSys::getIcon(GUIIcon::TRIP);
93 FXIcon* routeFlowIcon = GUIIconSubSys::getIcon(GUIIcon::ROUTEFLOW);
94 FXIcon* flowIcon = GUIIconSubSys::getIcon(GUIIcon::FLOW);
95 // create menu pane for transform operations
96 FXMenuPane* transformOperation = new FXMenuPane(this);
97 this->insertMenuPaneChild(transformOperation);
98 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
99 // Create menu commands for all transform
100 myTransformToVehicle = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicle", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
101 myTransformToVehicleWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicle (embedded route)", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
102 myTransformToRouteFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlow", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
103 myTransformToRouteFlowWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlow (embedded route)", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
104 myTransformToTrip = GUIDesigns::buildFXMenuCommand(transformOperation, "Trip", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
105 myTransformToFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "Flow", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
106 // check what menu command has to be disabled
108 myTransformToVehicle->disable();
112 myTransformToRouteFlow->disable();
115 } else if (myVehicle->getTagProperty().getTag() == SUMO_TAG_TRIP) {
116 myTransformToTrip->disable();
117 } else if (myVehicle->getTagProperty().getTag() == SUMO_TAG_FLOW) {
118 myTransformToFlow->disable();
119 }
120 }
121}
122
123
125
126
127long
129 if (obj == myTransformToVehicle) {
130 GNERouteHandler::transformToVehicle(myVehicle, false);
131 } else if (obj == myTransformToVehicleWithEmbeddedRoute) {
133 } else if (obj == myTransformToRouteFlow) {
135 } else if (obj == myTransformToRouteFlowWithEmbeddedRoute) {
137 } else if (obj == myTransformToTrip) {
139 } else if (obj == myTransformToFlow) {
141 }
142 return 1;
143}
144
145// ===========================================================================
146// GNEVehicle::GNESelectedVehiclesPopupMenu
147// ===========================================================================
148
149GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
150 GUIGLObjectPopupMenu(app, parent, *vehicle),
151 mySelectedVehicles(selectedVehicle),
152 myVehicleTag(vehicle->getTagProperty().getTag()),
153 myTransformToVehicle(nullptr),
154 myTransformToVehicleWithEmbeddedRoute(nullptr),
155 myTransformToRouteFlow(nullptr),
156 myTransformToRouteFlowWithEmbeddedRoute(nullptr),
157 myTransformToTrip(nullptr),
158 myTransformToFlow(nullptr),
159 myTransformAllVehiclesToVehicle(nullptr),
160 myTransformAllVehiclesToVehicleWithEmbeddedRoute(nullptr),
161 myTransformAllVehiclesToRouteFlow(nullptr),
162 myTransformAllVehiclesToRouteFlowWithEmbeddedRoute(nullptr),
163 myTransformAllVehiclesToTrip(nullptr),
164 myTransformAllVehiclesToFlow(nullptr) {
165 // build header
166 vehicle->buildPopupHeader(this, app);
167 // build menu command for center button and copy cursor position to clipboard
168 vehicle->buildCenterPopupEntry(this);
169 vehicle->buildPositionCopyEntry(this, app);
170 // build menu commands for names
171 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
172 GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
173 new FXMenuSeparator(this);
174 // build selection and show parameters menu
175 vehicle->getNet()->getViewNet()->buildSelectionACPopupEntry(this, vehicle);
176 vehicle->buildShowParamsPopupEntry(this);
177 // route length
178 vehicle->buildMenuCommandRouteLength(this);
179 // add transform functions only in demand mode
181 // Get icons
182 FXIcon* vehicleIcon = GUIIconSubSys::getIcon(GUIIcon::VEHICLE);
183 FXIcon* tripIcon = GUIIconSubSys::getIcon(GUIIcon::TRIP);
184 FXIcon* routeFlowIcon = GUIIconSubSys::getIcon(GUIIcon::ROUTEFLOW);
185 FXIcon* flowIcon = GUIIconSubSys::getIcon(GUIIcon::FLOW);
186 // create menu pane for transform operations
187 FXMenuPane* transformOperation = new FXMenuPane(this);
188 this->insertMenuPaneChild(transformOperation);
189 new FXMenuCascade(this, "transform to", nullptr, transformOperation);
190 // Create menu commands for all transform
192 "Vehicles (Only " + vehicle->getTagStr() + ")", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
194 "Vehicles (embedded route, only " + vehicle->getTagStr() + ")", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
196 "RouteFlows (Only " + vehicle->getTagStr() + ")", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
198 "RouteFlows (embedded route, only " + vehicle->getTagStr() + ")", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
200 "Trips (Only " + vehicle->getTagStr() + ")", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
202 "Flows (Only " + vehicle->getTagStr() + ")", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
203 // create separator
204 new FXMenuSeparator(transformOperation);
205 // Create menu commands for all transform all vehicles
206 myTransformAllVehiclesToVehicle = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicles", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
207 myTransformAllVehiclesToVehicleWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicles (embedded route)", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
208 myTransformAllVehiclesToRouteFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlows", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
209 myTransformAllVehiclesToRouteFlowWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlows (embedded route)", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
210 myTransformAllVehiclesToTrip = GUIDesigns::buildFXMenuCommand(transformOperation, "Trips", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
211 myTransformAllVehiclesToFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "Flows", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
212 }
213}
214
215
217
218
219long
221 // iterate over all selected vehicles
222 for (const auto& vehicle : mySelectedVehicles) {
223 if ((obj == myTransformToVehicle) &&
224 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
226 } else if ((obj == myTransformToVehicleWithEmbeddedRoute) &&
227 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
229 } else if ((obj == myTransformToRouteFlow) &&
230 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
232 } else if ((obj == myTransformToRouteFlowWithEmbeddedRoute) &&
233 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
235 } else if ((obj == myTransformToTrip) &&
236 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
238 } else if ((obj == myTransformToFlow) &&
239 (vehicle->getTagProperty().getTag() == myVehicleTag)) {
241 } else if (obj == myTransformAllVehiclesToVehicle) {
243 } else if (obj == myTransformAllVehiclesToVehicleWithEmbeddedRoute) {
245 } else if (obj == myTransformAllVehiclesToRouteFlow) {
247 } else if (obj == myTransformAllVehiclesToRouteFlowWithEmbeddedRoute) {
249 } else if (obj == myTransformAllVehiclesToTrip) {
251 } else if (obj == myTransformAllVehiclesToFlow) {
253 }
254 }
255 return 1;
256}
257
258// ===========================================================================
259// member method definitions
260// ===========================================================================
261
264 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
266 // reset default values
268 // set end and vehPerHours
271}
272
273
274GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route) :
275 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
277 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
279 // SUMOVehicleParameter ID has to be set manually
280 id = vehicleID;
281 // set manually vtypeID (needed for saving)
282 vtypeid = vehicleType->getID();
283 // adjust default flow attributes
285}
286
287
288GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
289 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
291 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
292 SUMOVehicleParameter(vehicleParameters) {
293 // SUMOVehicleParameter ID has to be set manually
294 id = vehicleParameters.id;
295 // set manually vtypeID (needed for saving)
296 vtypeid = vehicleType->getID();
297 // adjust default flow attributes
299}
300
301
302GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
303 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_VEHICLE_WITHROUTE) ? GLO_VEHICLE : GLO_ROUTEFLOW, tag,
305 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType}, {}),
306 SUMOVehicleParameter(vehicleParameters) {
307 // SUMOVehicleParameter ID has to be set manually
308 id = vehicleParameters.id;
309 // reset routeid
310 routeid.clear();
311 // set manually vtypeID (needed for saving)
312 vtypeid = vehicleType->getID();
313 // adjust default flow attributes
315}
316
317
318GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType,
319 GNEEdge* fromEdge, GNEEdge* toEdge) :
320 GNEDemandElement(vehicleID, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
321 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
322 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
324 // adjust default flow attributes
326}
327
328
329GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
330 const SUMOVehicleParameter& vehicleParameters) :
331 GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
332 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
333 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
334 SUMOVehicleParameter(vehicleParameters) {
335 // adjust default flow attributes
337}
338
339
340GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
341 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
343 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {fromJunction, toJunction}, {}, {}, {}, {vehicleType}, {}),
345 // adjust default flow attributes
347}
348
349
350GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
351 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
353 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {fromJunction, toJunction}, {}, {}, {}, {vehicleType}, {}),
354 SUMOVehicleParameter(vehicleParameters) {
355 // adjust default flow attributes
357}
358
359
360GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
361 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_TAZS) ? GLO_FLOW : GLO_TRIP, tag,
363 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {vehicleType}, {}),
364 SUMOVehicleParameter(vehicleParameters) {
365 // mark taz parameters as set
368 fromTaz = fromTAZ->getID();
369 toTaz = toTAZ->getID();
370 // adjust default flow attributes
372}
373
374
376
377
380 // get first and last lanes
381 const GNELane* firstLane = getFirstPathLane();
382 const GNELane* lastLane = getLastPathLane();
383 // get depart and arrival positions (doubles)
384 const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
385 const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
386 // obtain diameter
388 // return move operation depending if we're editing departPos or arrivalPos
390 return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
394 return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
397 } else {
398 return nullptr;
399 }
400}
401
402
403std::string
405 // obtain depart
406 std::string departStr = depart < 0 ? "0.00" : time2string(depart);
407 // we need to handle depart as a tuple of 20 numbers (format: 000000...00<departTime>)
408 departStr.reserve(20 - departStr.size());
409 // add 0s at the beginning of departStr until we have 20 numbers
410 for (int i = (int)departStr.size(); i < 20; i++) {
411 departStr.insert(departStr.begin(), '0');
412 }
413 return departStr;
414}
415
416
417void
419 // attribute VType must not be written if is DEFAULT_VTYPE_ID
421 // unset VType parameter
422 parametersSet &= ~VEHPARS_VTYPE_SET;
423 // write vehicle attributes (VType will not be written)
425 // set VType parameter again
427 } else {
428 // write vehicle attributes, including VType
430 }
431 // write specific attribute depending of tag property
433 // write route
435 }
436 // write from, to and edge vias
438 // write manually from/to edges (it correspond to front and back parent edges)
439 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
440 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
441 // only write via if there isn't empty
442 if (via.size() > 0) {
443 device.writeAttr(SUMO_ATTR_VIA, via);
444 }
445 }
446 // write from and to junctions
448 // write manually from/to junctions (it correspond to front and back parent junctions)
451 }
452 // write specific routeFlow/flow attributes
453 if (myTagProperty.isFlow()) {
454 // write routeFlow values depending if it was set
457 }
460 }
463 }
466 }
468 device.writeAttr(SUMO_ATTR_PERIOD, "exp(" + toString(1.0 / STEPS2TIME(repetitionOffset)) + ")");
469 }
472 }
473 }
474 // write parameters
475 writeParams(device);
476 // write route elements associated to this vehicle (except for calibrator FLows)
477 if ((getChildDemandElements().size() > 0) && !myTagProperty.isCalibrator()) {
478 if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
479 // write embedded route
480 getChildDemandElements().front()->writeDemandElement(device);
481 // write stops
482 for (const auto& demandElement : getChildDemandElements()) {
483 if (demandElement->getTagProperty().isStop() || demandElement->getTagProperty().isWaypoint()) {
484 demandElement->writeDemandElement(device);
485 }
486 }
487 } else {
488 for (const auto& route : getChildDemandElements()) {
489 route->writeDemandElement(device);
490 }
491 }
492 }
493 // close vehicle tag
494 device.closeTag();
495}
496
497
500 // check conditions
502 // vehicles and flows over tazs are always valid
503 return Problem::OK;
506 // check vehicles and flows paths
507 if (myNet->getPathManager()->isPathValid(this)) {
508 return Problem::OK;
509 } else {
511 }
512 } else if (getParentDemandElements().size() == 2) {
513 // check if exist a valid path using route parent edges
515 return Problem::OK;
516 } else {
518 }
519 } else if ((getChildDemandElements().size() > 0) && getChildDemandElements().front()->getTagProperty().isRoute()) {
520 // check if exist a valid path using route child edges
522 return Problem::OK;
523 } else {
525 }
526 } else {
528 }
529}
530
531
532std::string
534 // only trips or flows can have problems
536 // check if exist at least a connection between every edge
537 for (int i = 1; i < (int)getParentEdges().size(); i++) {
539 return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
540 }
541 }
542 // if there are connections between all edges, then all is ok
543 return "";
545 return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
546 } else if (getParentDemandElements().size() == 2) {
547 // get route parent edges
548 const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
549 // check if exist at least a connection between every edge
550 for (int i = 1; i < (int)routeEdges.size(); i++) {
551 if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
552 return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
553 }
554 }
555 // if there are connections between all edges, then all is ok
556 return "";
557 } else if ((getChildDemandElements().size() > 0) && getChildDemandElements().front()->getTagProperty().isRoute()) {
558 // get route parent edges
559 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
560 // check if exist at least a connection between every edge
561 for (int i = 1; i < (int)routeEdges.size(); i++) {
562 if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
563 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
564 }
565 }
566 // if there are connections between all edges, then all is ok
567 return "";
568 } else {
569 return "";
570 }
571}
572
573
574void
578
579
582 return getParentDemandElements().front()->getVClass();
583}
584
585
586const RGBColor&
588 return color;
589}
590
591
592void
594 if (getParentJunctions().size() > 0) {
595 // calculate rotation between both junctions
596 const Position posA = getParentJunctions().front()->getPositionInView();
597 const Position posB = getParentJunctions().back()->getPositionInView();
598 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
599 // update Geometry
600 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
601 } else if (getParentAdditionals().size() > 0) {
602 // calculate rotation between both junctions
603 const Position posA = getParentAdditionals().front()->getPositionInView();
604 const Position posB = getParentAdditionals().back()->getPositionInView();
605 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
606 // update Geometry
607 myDemandElementGeometry.updateSinglePosGeometry(getParentAdditionals().front()->getPositionInView(), rot);
608 } else {
609 // get first path lane
610 const GNELane* firstPathLane = getFirstPathLane();
611 // check path lane
612 if (firstPathLane) {
613 // declare departPos
614 double posOverLane = 0;
616 posOverLane = departPos;
617 }
618 // update Geometry
620 // compute route embedded associated with this vehicle
621 for (const auto& demandElement : getChildDemandElements()) {
622 if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
623 demandElement->computePathElement();
624 }
625 demandElement->updateGeometry();
626 }
627 }
628 }
629}
630
631
636
637
641 // obtain all selected vehicles
642 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
643 std::vector<GNEVehicle*> selectedVehicles;
644 selectedVehicles.reserve(selectedDemandElements.size());
645 for (const auto& selectedDemandElement : selectedDemandElements) {
646 if (selectedDemandElement->getTagProperty().isVehicle()) {
647 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
648 }
649 }
650 // return a GNESelectedVehiclesPopupMenu
651 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
652 } else {
653 // return a GNESingleVehiclePopupMenu
654 return new GNESingleVehiclePopupMenu(this, app, parent);
655 }
656}
657
658
659std::string
662 return getRouteParent()->getID();
664 return getParentEdges().front()->getID();
665 } else {
666 throw ProcessError(TL("Invalid vehicle tag"));
667 }
668}
669
670
671double
675
676
679 Boundary vehicleBoundary;
680 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
681 vehicleBoundary.grow(20);
682 return vehicleBoundary;
683}
684
685
686void
687GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
688 // geometry of this element cannot be splitted
689}
690
691
692void
694 // only drawn in super mode demand
698 // declare common attributes
700 const double exaggeration = getExaggeration(s);
701 const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
702 const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
703 const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
704 const auto vehicleColor = setColor(s);
705 // obtain Position an rotation (depending of draw spread vehicles)
706 if (drawSpreadVehicles && mySpreadGeometry.getShape().size() == 0) {
707 return;
708 }
709 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
710 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
711 // check that position is valid
712 if ((vehicleColor.alpha() != 0) && (vehiclePosition != Position::INVALID)) {
713 // first push name
715 // first check if if mouse is enough near to this vehicle to draw it
716 if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
717 // push draw matrix
719 // Start with the drawing of the area translating matrix to origin
721 // translate to drawing position
722 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
723 glRotated(vehicleRotation, 0, 0, -1);
724 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
725 glTranslated(0, (-1) * length * exaggeration, 0);
726 GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
727 // Pop last matrix
729 } else {
731 // push draw matrix
733 // Start with the drawing of the area translating matrix to origin
735 // translate to drawing position
736 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
737 glRotated(vehicleRotation, 0, 0, -1);
738 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
739 glTranslated(0, (-1) * length * exaggeration, 0);
740 // set lane color
741 GLHelper::setColor(vehicleColor);
742 double upscaleLength = exaggeration;
743 if ((exaggeration > 1) && (length > 5)) {
744 // reduce the length/width ratio because this is not useful at high zoom
745 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
746 }
747 glScaled(exaggeration, upscaleLength, 1);
748 // check if we're drawing in selecting mode
750 // draw vehicle as a box and don't draw the rest of details
752 } else {
753 // draw the vehicle depending of detail level
754 if (s.drawDetail(s.detailSettings.vehicleShapes, exaggeration)) {
756 } else if (s.drawDetail(s.detailSettings.vehicleBoxes, exaggeration)) {
758 } else if (s.drawDetail(s.detailSettings.vehicleTriangles, exaggeration)) {
760 }
761 // check if min gap has to be drawn
762 if (s.drawMinGap) {
763 const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
764 glColor3d(0., 1., 0.);
765 glBegin(GL_LINES);
766 glVertex2d(0., 0);
767 glVertex2d(0., minGap);
768 glVertex2d(-.5, minGap);
769 glVertex2d(.5, minGap);
770 glEnd();
771 }
772 // drawing name at GLO_MAX fails unless translating z
773 glTranslated(0, MIN2(length / 2, double(5)), -getType());
774 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
775 glRotated(vehicleRotation, 0, 0, -1);
777 // draw line
778 if (s.vehicleName.show(this) && line != "") {
779 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
781 }
782 }
783 // pop draw matrix
785 // draw line between junctions if path isn't valid
786 if ((getParentJunctions().size() > 0) && !myNet->getPathManager()->isPathValid(this)) {
787 drawJunctionLine(this);
788 }
789 // draw stack label
790 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
791 drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
792 }
793 // draw flow label
794 if (myTagProperty.isFlow()) {
795 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
796 }
797 // draw lock icon
798 GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), vehiclePosition, exaggeration);
799 // check if mouse is over element
800 mouseWithinGeometry(vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation);
801 // inspect contour
803 // draw using drawDottedContourClosedShape
804 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::INSPECT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
805 }
806 // front contour
807 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
808 // draw using drawDottedContourClosedShape
809 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::FRONT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
810 }
811 // delete contour
812 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
813 // draw using drawDottedContourClosedShape
814 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::REMOVE, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
815 }
816 // select contour
817 if (myNet->getViewNet()->drawSelectContour(this, this)) {
818 // draw using drawDottedContourClosedShape
819 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::SELECT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
820 }
824 // draw using drawDottedContourClosedShape
825 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::ORANGE, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
826 }
827 }
828 // pop name
830 }
831 }
832}
833
834
835void
837 // calculate path (only for flows and trips)
838 if (getParentJunctions().size() > 0) {
839 // calculate path
842 // declare lane stops
843 std::vector<GNELane*> laneStopWaypoints;
844 // iterate over child demand elements
845 for (const auto& demandElement : getChildDemandElements()) {
846 // extract lanes
847 if (demandElement->getTagProperty().isStop() || demandElement->getTagProperty().isWaypoint()) {
848 if (demandElement->getParentAdditionals().size() > 0) {
849 laneStopWaypoints.push_back(demandElement->getParentAdditionals().front()->getParentLanes().front());
850 } else {
851 laneStopWaypoints.push_back(demandElement->getParentLanes().front());
852 }
853 }
854 }
855 // declare lane vector
856 std::vector<GNELane*> lanes;
857 // get first and last lanes
858 const auto firstLane = getFirstPathLane();
859 const auto lastLane = getLastPathLane();
860 // check first and last lanes
861 if (firstLane && lastLane) {
862 // add first lane
863 lanes.push_back(getFirstPathLane());
864 // now check if there are lane Stops
865 if (laneStopWaypoints.size() > 0) {
866 // add stop lanes
867 for (const auto& laneStop : laneStopWaypoints) {
868 lanes.push_back(laneStop);
869 }
870 } else {
871 // add via lanes
872 for (const auto& edgeID : via) {
873 const auto edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
874 if (edge) {
875 lanes.push_back(edge->getLaneByAllowedVClass(getVClass()));
876 }
877 }
878 }
879 // add last lane
880 lanes.push_back(getLastPathLane());
881 // calculate path
883 }
884 }
885 // update geometry
887}
888
889
890void
891GNEVehicle::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const {
892 // get flags
893 const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) ||
894 (myNet->getViewNet()->getFrontAttributeCarrier() == this) ||
895 myNet->getViewNet()->drawDeleteContour(this, this) ||
896 myNet->getViewNet()->drawSelectContour(this, this);
897 const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
900 const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
902 // check conditions
904 (drawNetworkMode || drawDemandMode || dottedElement || isAttributeCarrierSelected()) &&
905 myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, lane, myTagProperty.getTag())) {
906 // calculate width
907 const double width = s.vehicleSize.getExaggeration(s, lane) * s.widthSettings.tripWidth;
908 // calculate startPos
909 const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
910 // get endPos
911 const double geometryEndPos = (getParentJunctions().size() > 0) ? lane->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
912 // declare path geometry
913 GUIGeometry vehicleGeometry;
914 // update pathGeometry depending of first and last segment
915 if (segment->isFirstSegment() && segment->isLastSegment()) {
916 vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
917 geometryDepartPos, geometryEndPos, // extreme positions
918 Position::INVALID, Position::INVALID); // extra positions
919 } else if (segment->isFirstSegment()) {
920 vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
921 geometryDepartPos, -1, // extreme positions
922 Position::INVALID, Position::INVALID); // extra positions
923 } else if (segment->isLastSegment()) {
924 vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
925 -1, geometryEndPos, // extreme positions
926 Position::INVALID, Position::INVALID); // extra positions
927 } else {
928 vehicleGeometry = lane->getLaneGeometry();
929 }
930 // obtain color
932 // Start drawing adding an gl identifier
934 // Add a draw matrix
936 // Start with the drawing of the area translating matrix to origin
937 glTranslated(0, 0, getType() + offsetFront);
938 // Set color
939 GLHelper::setColor(pathColor);
940 // draw geometry
941 GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), vehicleGeometry, width);
942 // Pop last matrix
944 // Draw name if isn't being drawn for selecting
946 drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
947 }
948 // check if we have to draw a red line to the next segment
949 if (segment->getNextSegment()) {
950 // push draw matrix
952 // Start with the drawing of the area translating matrix to origin
954 // Set red color
956 // get firstPosition (last position of current lane shape)
957 const Position& firstPosition = lane->getLaneShape().back();
958 // get lastPosition (first position of next lane shape)
959 const Position& arrivalPosition = segment->getNextSegment()->getPathElement()->getPathElementArrivalPos();
960 // draw box line
961 GLHelper::drawBoxLine(arrivalPosition,
962 RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
963 firstPosition.distanceTo2D(arrivalPosition), .05);
964 // pop draw matrix
966 }
967 // check if this is the last segment
968 if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
969 // get geometryEndPos
970 const Position geometryEndPosition = getPathElementArrivalPos();
971 // check if endPos can be drawn
973 // push draw matrix
975 // Start with the drawing of the area translating matrix to origin
977 // translate to geometryEndPos
978 glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
979 // Set person plan color
980 GLHelper::setColor(pathColor);
981 // resolution of drawn circle depending of the zoom (To improve smoothness)
983 // pop draw matrix
985 }
986 }
987 // Pop name
989 // check if shape dotted contour has to be drawn
990 if (dottedElement) {
991 // declare trim geometry to draw
992 const auto shape = (segment->isFirstSegment() || segment->isLastSegment() ? vehicleGeometry.getShape() : lane->getLaneShape());
993 // check if mouse is over element
994 mouseWithinGeometry(shape, width);
995 // inspect contour
998 }
999 // front contour
1000 if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
1002 }
1003 // delete contour
1004 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
1006 }
1007 // select contour
1008 if (myNet->getViewNet()->drawSelectContour(this, this)) {
1010 }
1011 }
1012 }
1013}
1014
1015
1016void
1017GNEVehicle::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* /*segment*/, const double offsetFront) const {
1018 // get flags
1019 const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) ||
1020 (myNet->getViewNet()->getFrontAttributeCarrier() == this) ||
1021 myNet->getViewNet()->drawDeleteContour(this, this) ||
1022 myNet->getViewNet()->drawSelectContour(this, this);
1023 const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1026 const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1028 // check conditions
1030 fromLane->getLane2laneConnections().exist(toLane) &&
1031 (drawNetworkMode || drawDemandMode || dottedElement || isAttributeCarrierSelected()) &&
1032 myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, fromLane, toLane, myTagProperty.getTag())) {
1033 // Start drawing adding an gl identifier
1035 // obtain lane2lane geometry
1036 const GUIGeometry& lane2laneGeometry = fromLane->getLane2laneConnections().getLane2laneGeometry(toLane);
1037 // calculate width
1038 const double width = s.vehicleSize.getExaggeration(s, fromLane) * s.widthSettings.tripWidth;
1039 // Add a draw matrix
1041 // Start with the drawing of the area translating matrix to origin
1042 glTranslated(0, 0, getType() + offsetFront);
1043 // Set color of the base
1044 if (drawUsingSelectColor()) {
1046 } else {
1048 }
1049 // draw lane2lane
1050 GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane2laneGeometry, width);
1051 // Pop last matrix
1053 // check if shape dotted contour has to be drawn
1054 if (dottedElement) {
1055 // check if exist lane2lane connection
1056 if (fromLane->getLane2laneConnections().exist(toLane)) {
1057 // draw inspected dotted contour
1061 width, 1, false, false);
1062 }
1063 // draw front dotted contour
1064 if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
1067 width, 1, false, false);
1068 }
1069 // delete contour
1070 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
1073 width, 1, false, false);
1074 }
1075 // select contour
1076 if (myNet->getViewNet()->drawSelectContour(this, this)) {
1079 width, 1, false, false);
1080 }
1081 }
1082 }
1083 // Pop name
1085 }
1086}
1087
1088
1089GNELane*
1091 // declare first edge
1092 GNEEdge* firstEdge = nullptr;
1093 // continue depending of tags
1095 // check departEdge
1096 if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1097 // use departEdge
1098 firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1099 } else {
1100 // use first route edge
1101 firstEdge = getRouteParent()->getParentEdges().front();
1102 }
1103 } else if (myTagProperty.hasEmbeddedRoute()) {
1104 // check if embedded route exist (due during loading embedded route doesn't exist
1105 if (getChildDemandElements().empty()) {
1106 return nullptr;
1107 }
1108 // check departEdge
1109 if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1110 // use depart edge
1111 firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1112 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1113 firstEdge = getChildDemandElements().front()->getParentEdges().front();
1114 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1115 firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1116 } else {
1117 return nullptr;
1118 }
1119 } else {
1120 // use first parent edge
1121 firstEdge = getParentEdges().front();
1122 }
1123 // get departLane index
1124 const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1125 // check departLane index
1126 if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1127 return firstEdge->getLanes().at(departLaneIndex);
1128 } else {
1129 // get first allowed VClass
1130 return firstEdge->getLaneByAllowedVClass(getVClass());
1131 }
1132}
1133
1134
1135GNELane*
1137 // declare last edge
1138 GNEEdge* lastEdge = nullptr;
1139 // continue depending of tags
1141 // check arrivalEdge
1142 if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1143 // use arrival edge
1144 lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1145 } else {
1146 // use last route edge
1147 lastEdge = getRouteParent()->getParentEdges().back();
1148 }
1149 } else if (myTagProperty.hasEmbeddedRoute()) {
1150 // check if embedded route exist (due during loading embedded route doesn't exist)
1151 if (getChildDemandElements().empty()) {
1152 return nullptr;
1153 }
1154 // check arrivalEdge
1155 if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1156 // use arrival edge
1157 lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1158 } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1159 // use last route edge
1160 lastEdge = getChildDemandElements().front()->getParentEdges().back();
1161 } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1162 // use lane
1163 lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1164 } else {
1165 return nullptr;
1166 }
1167 } else {
1168 // use last parent edge
1169 lastEdge = getParentEdges().back();
1170 }
1171 // get arrivalLane index
1172 const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1173 // check arrivalLane index
1174 if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1175 return lastEdge->getLanes().at(arrivalLaneIndex);
1176 } else {
1177 // get last allowed VClass
1178 return lastEdge->getLaneByAllowedVClass(getVClass());
1179 }
1180}
1181
1182
1183std::string
1185 switch (key) {
1186 case SUMO_ATTR_ID:
1187 return getMicrosimID();
1188 case SUMO_ATTR_TYPE:
1189 return vtypeid;
1190 case SUMO_ATTR_COLOR:
1192 return toString(color);
1193 } else {
1195 }
1198 return getDepartLane();
1199 } else {
1201 }
1204 return getDepartPos();
1205 } else {
1207 }
1210 return getDepartSpeed();
1211 } else {
1213 }
1216 return getArrivalLane();
1217 } else {
1219 }
1222 return getArrivalPos();
1223 } else {
1225 }
1228 return getArrivalSpeed();
1229 } else {
1231 }
1232 case SUMO_ATTR_LINE:
1233 if (wasSet(VEHPARS_LINE_SET)) {
1234 return line;
1235 } else {
1237 }
1240 return toString(personNumber);
1241 } else {
1243 }
1246 return toString(containerNumber);
1247 } else {
1249 }
1250 case SUMO_ATTR_REROUTE:
1252 return "true";
1253 } else {
1254 return "false";
1255 }
1258 return getDepartPosLat();
1259 } else {
1261 }
1264 return getArrivalPosLat();
1265 } else {
1267 }
1269 return getInsertionChecks();
1270 // Specific of vehicles
1271 case SUMO_ATTR_DEPART:
1272 case SUMO_ATTR_BEGIN:
1274 return "triggered";
1276 return "containerTriggered";
1277 } else if (departProcedure == DepartDefinition::NOW) {
1278 return "now";
1280 return "split";
1282 return "begin";
1283 } else {
1284 return time2string(depart);
1285 }
1286 case SUMO_ATTR_ROUTE:
1287 if (getParentDemandElements().size() == 2) {
1288 return getRouteParent()->getID();
1289 } else {
1290 return "";
1291 }
1292 // Specific of from-to edge
1293 case SUMO_ATTR_FROM:
1294 return getParentEdges().front()->getID();
1295 case SUMO_ATTR_TO:
1296 return getParentEdges().back()->getID();
1297 case SUMO_ATTR_VIA:
1298 return toString(via);
1300 if (departEdge == -1) {
1301 return "";
1302 } else {
1303 return toString(departEdge);
1304 }
1306 if (arrivalEdge == -1) {
1307 return "";
1308 } else {
1309 return toString(arrivalEdge);
1310 }
1311 // Specific of from-to junctions
1313 return getParentJunctions().front()->getID();
1315 return getParentJunctions().back()->getID();
1316 // Specific of from-to tazs
1317 case SUMO_ATTR_FROM_TAZ:
1318 return getParentAdditionals().front()->getID();
1319 case SUMO_ATTR_TO_TAZ:
1320 return getParentAdditionals().back()->getID();
1321 // Specific of flows
1322 case SUMO_ATTR_END:
1323 return time2string(repetitionEnd);
1325 return toString(3600 / STEPS2TIME(repetitionOffset));
1326 case SUMO_ATTR_PERIOD:
1328 case GNE_ATTR_POISSON:
1330 case SUMO_ATTR_PROB:
1331 return toString(repetitionProbability, 10);
1332 case SUMO_ATTR_NUMBER:
1333 return toString(repetitionNumber);
1334 // other
1335 case GNE_ATTR_SELECTED:
1338 return getParametersStr();
1340 return toString(parametersSet);
1341 default:
1342 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1343 }
1344}
1345
1346
1347double
1349 switch (key) {
1350 case SUMO_ATTR_DEPART:
1351 case SUMO_ATTR_BEGIN:
1352 return STEPS2TIME(depart);
1355 return departLane;
1356 } else {
1357 return -1;
1358 }
1360 // only return departPos it if is given
1362 return departPos;
1363 } else {
1364 return 0;
1365 }
1368 return arrivalLane;
1369 } else {
1370 return -1;
1371 }
1373 // only return departPos it if is given
1375 return arrivalPos;
1376 } else {
1377 return -1;
1378 }
1379 case SUMO_ATTR_WIDTH:
1380 case SUMO_ATTR_LENGTH:
1381 case SUMO_ATTR_MINGAP:
1382 return getTypeParent()->getAttributeDouble(key);
1383 default:
1384 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1385 }
1386}
1387
1388
1391 switch (key) {
1392 case SUMO_ATTR_DEPARTPOS: {
1393 // get first path lane shape
1394 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1395 // check arrivalPosProcedure
1397 if (departPos < 0) {
1398 return laneShape.front();
1399 } else if (departPos > laneShape.length2D()) {
1400 return laneShape.back();
1401 } else {
1402 return laneShape.positionAtOffset2D(departPos);
1403 }
1404 } else {
1405 return laneShape.front();
1406 }
1407 }
1408 case SUMO_ATTR_ARRIVALPOS: {
1409 // get last path lane shape
1410 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1411 // check arrivalPosProcedure
1413 if (arrivalPos < 0) {
1414 return laneShape.front();
1415 } else if (arrivalPos > laneShape.length2D()) {
1416 return laneShape.back();
1417 } else {
1418 return laneShape.positionAtOffset2D(arrivalPos);
1419 }
1420 } else {
1421 return laneShape.back();
1422 }
1423 }
1424 default:
1425 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1426 }
1427}
1428
1429
1430void
1431GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1432 if (value == getAttribute(key)) {
1433 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1434 }
1435 switch (key) {
1436 case SUMO_ATTR_ID:
1437 case SUMO_ATTR_TYPE:
1438 case SUMO_ATTR_COLOR:
1445 case SUMO_ATTR_LINE:
1448 case SUMO_ATTR_REROUTE:
1452 // Specific of vehicles
1453 case SUMO_ATTR_DEPART:
1454 case SUMO_ATTR_BEGIN:
1455 case SUMO_ATTR_ROUTE:
1456 // Specific of from-to edges
1457 case SUMO_ATTR_FROM:
1458 case SUMO_ATTR_TO:
1459 case SUMO_ATTR_VIA:
1462 // Specific of from-to junctions
1465 // Specific of from-to taz
1466 case SUMO_ATTR_FROM_TAZ:
1467 case SUMO_ATTR_TO_TAZ:
1468 // Specific of flows
1469 case SUMO_ATTR_END:
1470 case SUMO_ATTR_NUMBER:
1472 case SUMO_ATTR_PERIOD:
1473 case GNE_ATTR_POISSON:
1474 case SUMO_ATTR_PROB:
1475 // other
1477 case GNE_ATTR_SELECTED:
1478 undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
1479 break;
1480 default:
1481 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1482 }
1483}
1484
1485
1486bool
1487GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1488 // get ACs
1489 const auto ACs = myNet->getAttributeCarriers();
1490 // declare string error
1491 std::string error;
1492 switch (key) {
1493 case SUMO_ATTR_ID:
1494 if (value == getID()) {
1495 return true;
1496 } else if (SUMOXMLDefinitions::isValidVehicleID(value)) {
1499 } else {
1500 return false;
1501 }
1502 case SUMO_ATTR_TYPE:
1505 } else {
1506 return false;
1507 }
1508 case SUMO_ATTR_COLOR:
1509 return canParse<RGBColor>(value);
1510 case SUMO_ATTR_DEPARTLANE: {
1511 int dummyDepartLane;
1512 DepartLaneDefinition dummyDepartLaneProcedure;
1513 parseDepartLane(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1514 // if error is empty, check if depart lane is correct
1515 if (error.empty()) {
1516 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1517 return true;
1518 } else if (isTemplate()) {
1519 return true;
1520 } else if (getParentJunctions().size() > 0) {
1521 return (dummyDepartLane == 0);
1522 } else if (getParentAdditionals().size() > 0) {
1523 return (dummyDepartLane == 0);
1524 } else {
1525 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1526 }
1527 } else {
1528 return false;
1529 }
1530 }
1531 case SUMO_ATTR_DEPARTPOS: {
1532 double dummyDepartPos;
1533 DepartPosDefinition dummyDepartPosProcedure;
1534 parseDepartPos(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPos, dummyDepartPosProcedure, error);
1535 // if error is empty, given value is valid
1536 return error.empty();
1537 }
1538 case SUMO_ATTR_DEPARTSPEED: {
1539 double dummyDepartSpeed;
1540 DepartSpeedDefinition dummyDepartSpeedProcedure;
1541 parseDepartSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1542 // if error is empty, check if depart speed is correct
1543 if (error.empty()) {
1544 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1545 return true;
1546 } else if (isTemplate()) {
1547 return true;
1548 } else {
1549 return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1550 }
1551 } else {
1552 return false;
1553 }
1554 }
1555 case SUMO_ATTR_ARRIVALLANE: {
1556 int dummyArrivalLane;
1557 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1558 parseArrivalLane(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1559 // if error is empty, given value is valid
1560 if (error.empty()) {
1561 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1562 return true;
1563 } else if (isTemplate()) {
1564 return true;
1565 } else if (getParentJunctions().size() > 0) {
1566 return (dummyArrivalLane == 0);
1567 } else if (getParentAdditionals().size() > 0) {
1568 return (dummyArrivalLane == 0);
1569 } else {
1570 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1571 }
1572 } else {
1573 return false;
1574 }
1575 }
1576 case SUMO_ATTR_ARRIVALPOS: {
1577 double dummyArrivalPos;
1578 ArrivalPosDefinition dummyArrivalPosProcedure;
1579 parseArrivalPos(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1580 // if error is empty, given value is valid
1581 return error.empty();
1582 }
1584 double dummyArrivalSpeed;
1585 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1586 parseArrivalSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1587 // if error is empty, given value is valid
1588 return error.empty();
1589 }
1590 case SUMO_ATTR_LINE:
1591 return true;
1593 return canParse<int>(value) && parse<int>(value) >= 0;
1595 return canParse<int>(value) && parse<int>(value) >= 0;
1596 case SUMO_ATTR_REROUTE:
1597 return true; // check
1599 double dummyDepartPosLat;
1600 DepartPosLatDefinition dummyDepartPosLatProcedure;
1601 parseDepartPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1602 // if error is empty, given value is valid
1603 return error.empty();
1604 }
1606 double dummyArrivalPosLat;
1607 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1608 parseArrivalPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1609 // if error is empty, given value is valid
1610 return error.empty();
1611 }
1613 return areInsertionChecksValid(value);
1614 // Specific of vehicles
1615 case SUMO_ATTR_DEPART:
1616 case SUMO_ATTR_BEGIN: {
1617 SUMOTime dummyDepart;
1618 DepartDefinition dummyDepartProcedure;
1619 parseDepart(value, toString(SUMO_TAG_VEHICLE), id, dummyDepart, dummyDepartProcedure, error);
1620 // if error is empty, given value is valid
1621 return error.empty();
1622 }
1623 case SUMO_ATTR_ROUTE:
1624 if (getParentDemandElements().size() == 2) {
1625 return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1626 } else {
1627 return true;
1628 }
1629 // Specific of from-to edges
1630 case SUMO_ATTR_FROM:
1631 case SUMO_ATTR_TO:
1632 return SUMOXMLDefinitions::isValidNetID(value) && (ACs->retrieveEdge(value, false) != nullptr);
1634 case SUMO_ATTR_ARRIVALEDGE: {
1635 if (value.empty()) {
1636 return true;
1637 } else if (canParse<int>(value)) {
1638 // get index
1639 const int index = parse<int>(value);
1640 // check conditions
1641 if (index < 0) {
1642 return false;
1644 // check parent route
1645 return (index < (int)getRouteParent()->getParentEdges().size());
1646 } else {
1647 // check embedded route
1648 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1649 }
1650 } else {
1651 return false;
1652 }
1653 }
1654 case SUMO_ATTR_VIA:
1655 if (value.empty()) {
1656 return true;
1657 } else {
1658 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1659 }
1660 // Specific of from-to junctions
1663 return SUMOXMLDefinitions::isValidNetID(value) && (ACs->retrieveJunction(value, false) != nullptr);
1664 // Specific of from-to taz
1665 case SUMO_ATTR_FROM_TAZ:
1666 case SUMO_ATTR_TO_TAZ:
1667 return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1668 // Specific of flows
1669 case SUMO_ATTR_END:
1670 if (canParse<double>(value)) {
1671 return (parse<double>(value) >= 0);
1672 } else {
1673 return false;
1674 }
1676 if (canParse<double>(value)) {
1677 return (parse<double>(value) > 0);
1678 } else {
1679 return false;
1680 }
1681 case SUMO_ATTR_PERIOD:
1682 case GNE_ATTR_POISSON:
1683 if (canParse<double>(value)) {
1684 return (parse<double>(value) > 0);
1685 } else {
1686 return false;
1687 }
1688 case SUMO_ATTR_PROB:
1689 if (canParse<double>(value)) {
1690 const double prob = parse<double>(value);
1691 return ((prob >= 0) && (prob <= 1));
1692 } else {
1693 return false;
1694 }
1695 case SUMO_ATTR_NUMBER:
1696 if (canParse<int>(value)) {
1697 return (parse<int>(value) >= 0);
1698 } else {
1699 return false;
1700 }
1701 // other
1702 case GNE_ATTR_SELECTED:
1703 return canParse<bool>(value);
1706 default:
1707 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1708 }
1709}
1710
1711
1712void
1714 switch (key) {
1715 case SUMO_ATTR_END:
1716 case SUMO_ATTR_NUMBER:
1718 case SUMO_ATTR_PERIOD:
1719 case GNE_ATTR_POISSON:
1720 case SUMO_ATTR_PROB:
1721 undoList->add(new GNEChange_EnableAttribute(this, key, true, parametersSet), true);
1722 return;
1723 default:
1724 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1725 }
1726}
1727
1728
1729void
1731 switch (key) {
1732 case SUMO_ATTR_END:
1733 case SUMO_ATTR_NUMBER:
1735 case SUMO_ATTR_PERIOD:
1736 case GNE_ATTR_POISSON:
1737 case SUMO_ATTR_PROB:
1738 undoList->add(new GNEChange_EnableAttribute(this, key, false, parametersSet), true);
1739 return;
1740 default:
1741 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1742 }
1743}
1744
1745
1746bool
1748 switch (key) {
1749 case SUMO_ATTR_END:
1750 return (parametersSet & VEHPARS_END_SET) != 0;
1751 case SUMO_ATTR_NUMBER:
1752 return (parametersSet & VEHPARS_NUMBER_SET) != 0;
1754 return (parametersSet & VEHPARS_VPH_SET) != 0;
1755 case SUMO_ATTR_PERIOD:
1756 return (parametersSet & VEHPARS_PERIOD_SET) != 0;
1757 case GNE_ATTR_POISSON:
1758 return (parametersSet & VEHPARS_POISSON_SET) != 0;
1759 case SUMO_ATTR_PROB:
1760 return (parametersSet & VEHPARS_PROB_SET) != 0;
1761 default:
1762 return true;
1763 }
1764}
1765
1766
1767std::string
1769 return getTagStr();
1770}
1771
1772
1773std::string
1775 // special case for Trips and flow
1777 // check if we're inspecting a Edge
1778 if (!myNet->getViewNet()->getInspectedAttributeCarriers().empty() &&
1779 myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1780 // check if edge correspond to a "from", "to" or "via" edge
1782 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1783 } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
1784 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1785 } else {
1786 // iterate over via
1787 for (const auto& i : via) {
1788 if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
1789 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1790 }
1791 }
1792 }
1793 }
1794 }
1795 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1796}
1797
1798
1799const Parameterised::Map&
1803
1804// ===========================================================================
1805// protected
1806// ===========================================================================
1807
1810 // change color
1811 if (drawUsingSelectColor()) {
1813 } else {
1814 // obtain vehicle color
1815 const GUIColorer& c = s.vehicleColorer;
1816 // set color depending of vehicle color active
1817 switch (c.getActive()) {
1818 case 0: {
1819 // test for emergency vehicle
1820 if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "emergency") {
1821 return RGBColor::WHITE;
1822 }
1823 // test for firebrigade
1824 if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "firebrigade") {
1825 return RGBColor::RED;
1826 }
1827 // test for police car
1828 if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "police") {
1829 return RGBColor::BLUE;
1830 }
1831 if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "scooter") {
1832 return RGBColor::WHITE;
1833 }
1834 // check if color was set
1836 return color;
1837 } else {
1838 // take their parent's color)
1839 return getTypeParent()->getColor();
1840 }
1841 }
1842 case 2: {
1844 return color;
1845 } else {
1846 return c.getScheme().getColor(0);
1847 }
1848 }
1849 case 3: {
1851 return getTypeParent()->getColor();
1852 } else {
1853 return c.getScheme().getColor(0);
1854 }
1855 break;
1856 }
1857 case 4: {
1859 return getRouteParent()->getColor();
1860 } else {
1861 return c.getScheme().getColor(0);
1862 }
1863 }
1864 case 5: {
1865 Position p = getRouteParent()->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1866 const Boundary& b = myNet->getBoundary();
1867 Position center = b.getCenter();
1868 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1869 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1870 return RGBColor::fromHSV(hue, sat, 1.);
1871 }
1872 case 6: {
1873 Position p = getRouteParent()->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1874 const Boundary& b = myNet->getBoundary();
1875 Position center = b.getCenter();
1876 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1877 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1878 return RGBColor::fromHSV(hue, sat, 1.);
1879 }
1880 case 7: {
1881 Position pb = getRouteParent()->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1882 Position pe = getRouteParent()->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1883 const Boundary& b = myNet->getBoundary();
1884 double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1885 Position minp(b.xmin(), b.ymin());
1886 Position maxp(b.xmax(), b.ymax());
1887 double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1888 return RGBColor::fromHSV(hue, sat, 1.);
1889 }
1890 case 29: { // color randomly (by pointer hash)
1891 std::hash<const GNEVehicle*> ptr_hash;
1892 const double hue = (double)(ptr_hash(this) % 360); // [0-360]
1893 const double sat = (double)((ptr_hash(this) / 360) % 67) / 100. + 0.33; // [0.33-1]
1894 return RGBColor::fromHSV(hue, sat, 1.);
1895 }
1896 default: {
1897 return c.getScheme().getColor(0);
1898 }
1899 }
1900 }
1901}
1902
1903// ===========================================================================
1904// private
1905// ===========================================================================
1906
1907void
1908GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1909 // declare string error
1910 std::string error;
1911 // flag to upate stack label
1912 bool updateSpreadStackGeometry = false;
1913 switch (key) {
1914 case SUMO_ATTR_ID:
1915 // update microsimID
1916 setMicrosimID(value);
1917 // set manually vehicle ID (needed for saving)
1918 id = value;
1919 // Change IDs of all person plans children (stops, embedded routes...)
1920 for (const auto& childDemandElement : getChildDemandElements()) {
1921 childDemandElement->setMicrosimID(getID());
1922 }
1923 break;
1924 case SUMO_ATTR_TYPE:
1925 if (getID().size() > 0) {
1926 if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1928 } else {
1930 }
1931 // set manually vtypeID (needed for saving)
1932 vtypeid = value;
1933 }
1934 break;
1935 case SUMO_ATTR_COLOR:
1936 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1937 color = parse<RGBColor>(value);
1938 // mark parameter as set
1940 } else {
1941 // set default value
1942 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1943 // unset parameter
1944 parametersSet &= ~VEHPARS_COLOR_SET;
1945 }
1946 break;
1948 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1950 // mark parameter as set
1952 } else {
1953 // set default value
1955 // unset parameter
1956 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1957 }
1958 break;
1960 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1962 // mark parameter as set
1964 } else {
1965 // set default value
1967 // unset parameter
1968 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1969 }
1970 if (getID().size() > 0) {
1972 updateSpreadStackGeometry = true;
1973 }
1974 break;
1976 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1978 // mark parameter as set
1980 } else {
1981 // set default value
1983 // unset parameter
1984 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1985 }
1986 break;
1988 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1990 // mark parameter as set
1992 } else {
1993 // set default value
1995 // unset parameter
1996 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
1997 }
1998 break;
2000 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2002 // mark parameter as set
2004 } else {
2005 // set default value
2007 // unset parameter
2008 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
2009 }
2010 if (getID().size() > 0) {
2012 updateSpreadStackGeometry = true;
2013 }
2014 break;
2016 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2018 // mark parameter as set
2020 } else {
2021 // set default value
2023 // unset parameter
2024 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
2025 }
2026 break;
2027 case SUMO_ATTR_LINE:
2028 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2029 line = value;
2030 // mark parameter as set
2032 } else {
2033 // set default value
2035 // unset parameter
2036 parametersSet &= ~VEHPARS_LINE_SET;
2037 }
2038 break;
2040 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2041 personNumber = parse<int>(value);
2042 // mark parameter as set
2044 } else {
2045 // set default value
2046 personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2047 // unset parameter
2048 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2049 }
2050 break;
2052 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2053 containerNumber = parse<int>(value);
2054 // mark parameter as set
2056 } else {
2057 // set default value
2059 // unset parameter
2060 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2061 }
2062 break;
2063 case SUMO_ATTR_REROUTE:
2064 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2065 // mark parameter as set
2067 } else {
2068 // unset parameter
2069 parametersSet &= ~VEHPARS_ROUTE_SET;
2070 }
2071 break;
2073 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2075 // mark parameter as set
2077 } else {
2078 // set default value
2080 // unset parameter
2081 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2082 }
2083 break;
2085 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2087 // mark parameter as set
2089 } else {
2090 // set default value
2092 // unset parameter
2093 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2094 }
2096 break;
2098 parseInsertionChecks(value);
2099 break;
2100 // Specific of vehicles
2101 case SUMO_ATTR_DEPART:
2102 case SUMO_ATTR_BEGIN: {
2104 break;
2105 }
2106 case SUMO_ATTR_ROUTE:
2107 if (getParentDemandElements().size() == 2) {
2109 }
2111 updateSpreadStackGeometry = true;
2112 break;
2113 // Specific of from-to edges
2114 case SUMO_ATTR_FROM: {
2115 // change first edge
2117 // compute vehicle
2119 updateSpreadStackGeometry = true;
2120 break;
2121 }
2122 case SUMO_ATTR_TO: {
2123 // change last edge
2124 replaceLastParentEdge(value);
2125 // compute vehicle
2127 updateSpreadStackGeometry = true;
2128 break;
2129 }
2130 case SUMO_ATTR_VIA: {
2131 if (!value.empty()) {
2132 // set new via edges
2133 via = parse< std::vector<std::string> >(value);
2134 // mark parameter as set
2136 } else {
2137 // clear via
2138 via.clear();
2139 // unset parameter
2140 parametersSet &= ~VEHPARS_VIA_SET;
2141 }
2142 // compute vehicle
2144 updateSpreadStackGeometry = true;
2145 break;
2146 }
2147 case SUMO_ATTR_DEPARTEDGE: {
2148 // update depart edge
2149 if (value.empty()) {
2150 // unset parameter
2151 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2152 departEdge = -1;
2154 } else {
2155 // mark parameter as set
2157 departEdge = parse<int>(value);
2159 }
2160 // compute vehicle
2161 if (getID().size() > 0) {
2163 updateSpreadStackGeometry = true;
2164 }
2165 break;
2166 }
2167 case SUMO_ATTR_ARRIVALEDGE: {
2168 // update arrival edge
2169 if (value.empty()) {
2170 // unset parameter
2171 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2172 arrivalEdge = -1;
2174 } else {
2175 // mark parameter as set
2177 arrivalEdge = parse<int>(value);
2179 }
2180 if (getID().size() > 0) {
2181 // compute vehicle
2183 updateSpreadStackGeometry = true;
2184 }
2185 break;
2186 }
2187 // Specific of from-to junctions
2189 // change first junction
2191 // compute vehicle
2193 updateSpreadStackGeometry = true;
2194 break;
2195 }
2196 case SUMO_ATTR_TOJUNCTION: {
2197 // change last junction
2199 // compute vehicle
2201 updateSpreadStackGeometry = true;
2202 break;
2203 }
2204 // Specific of from-to TAZs
2205 case SUMO_ATTR_FROM_TAZ: {
2206 // change first additional
2208 // set taz manually
2209 fromTaz = value;
2210 // compute vehicle
2212 updateSpreadStackGeometry = true;
2213 break;
2214 }
2215 case SUMO_ATTR_TO_TAZ: {
2216 // change last additional
2218 // set taz manually
2219 toTaz = value;
2220 // compute vehicle
2222 updateSpreadStackGeometry = true;
2223 break;
2224 }
2225 // Specific of flows
2226 case SUMO_ATTR_END:
2227 repetitionEnd = string2time(value);
2228 break;
2230 repetitionOffset = TIME2STEPS(3600 / parse<double>(value));
2231 break;
2232 case SUMO_ATTR_PERIOD:
2234 break;
2235 case GNE_ATTR_POISSON:
2236 repetitionOffset = TIME2STEPS(1 / parse<double>(value));
2237 break;
2238 case SUMO_ATTR_PROB:
2239 repetitionProbability = parse<double>(value);
2240 break;
2241 case SUMO_ATTR_NUMBER:
2242 repetitionNumber = parse<int>(value);
2243 break;
2244 // other
2245 case GNE_ATTR_SELECTED:
2246 if (parse<bool>(value)) {
2248 } else {
2250 }
2251 break;
2253 setParametersStr(value);
2254 break;
2255 default:
2256 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
2257 }
2258 // check if stack label has to be updated
2259 if (updateSpreadStackGeometry) {
2261 getParentEdges().front()->updateVehicleStackLabels();
2262 getParentEdges().front()->updateVehicleSpreadGeometries();
2263 } else if (getParentDemandElements().size() == 2) {
2264 getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2265 getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2266 } else if (getChildDemandElements().size() > 0) {
2267 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2268 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2269 }
2270 }
2271}
2272
2273
2274void
2276 // set flow parameters
2277 setFlowParameters(this, key, value);
2278}
2279
2280
2281void
2283 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2285 // change depart
2287 departPos = moveResult.newFirstPos;
2288 }
2291 // change arrival
2293 arrivalPos = moveResult.newFirstPos;
2294 }
2295 // set lateral offset
2297 // update geometry
2299}
2300
2301
2302void
2304 // reset lateral offset
2306 // check departPos
2307 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2308 // begin change attribute
2309 undoList->begin(myTagProperty.getGUIIcon(), "departPos of " + getTagStr());
2310 // now set departPos
2311 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2312 // check if depart lane has to be changed
2313 if (moveResult.newFirstLane) {
2314 // set new depart lane
2316 }
2317 }
2318 // check arrivalPos
2319 if (moveResult.newSecondPos != INVALID_DOUBLE) {
2320 // begin change attribute
2321 undoList->begin(myTagProperty.getGUIIcon(), "arrivalPos of " + getTagStr());
2322 // now set arrivalPos
2324 // check if arrival lane has to be changed
2325 if (moveResult.newSecondLane) {
2326 // set new arrival lane
2328 }
2329 }
2330 // end change attribute
2331 undoList->end();
2332}
2333
2334/****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ DEMAND_TYPE
Mode for editing types.
long long int SUMOTime
Definition GUI.h:36
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition GUIAppEnum.h:450
@ MID_GNE_VEHICLE_TRANSFORM
transform vehicle to another vehicle type (ej: flow to trip)
@ MID_COPY_NAME
Copy object name - popup entry.
Definition GUIAppEnum.h:448
@ GLO_TRIP
a trip
@ GLO_ROUTEFLOW
a routeFlow
@ GLO_FLOW
a flow
@ GLO_VEHICLE
a vehicle
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define TL(string)
Definition MsgHandler.h:287
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define TIME2STEPS(x)
Definition SUMOTime.h:57
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
const std::string DEFAULT_VTYPE_ID
const int VEHPARS_DEPARTEDGE_SET
const int VEHPARS_ARRIVALEDGE_SET
const int VEHPARS_PROB_SET
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_ROUTE_SET
const int VEHPARS_COLOR_SET
const int VEHPARS_POISSON_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
const int VEHPARS_TO_TAZ_SET
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.
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_ARRIVALPOSLAT_SET
const int VEHPARS_FROM_TAZ_SET
const int VEHPARS_NUMBER_SET
const int VEHPARS_ARRIVALSPEED_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ GIVEN
The arrival position is given.
const int VEHPARS_LINE_SET
const int VEHPARS_PERSON_NUMBER_SET
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_PERIOD_SET
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
DepartDefinition
Possible ways to depart.
@ BEGIN
The departure is at simulation start.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ SPLIT
The departure is triggered by a train split.
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
const int VEHPARS_VIA_SET
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ GNE_TAG_FLOW_TAZS
a flow between TAZs
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_FROMJUNCTION
@ SUMO_ATTR_DEPARTPOS_LAT
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_MINGAP
@ GNE_ATTR_POISSON
poisson definition (used in flow)
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_LINE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_PROB
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_INSERTIONCHECKS
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_TOJUNCTION
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
Position getCenter() const
Returns the center of the boundary.
Definition Boundary.cpp:112
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:78
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:300
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition GLHelper.cpp:130
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:277
static void popName()
pop Name
Definition GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition GLHelper.cpp:716
An Element which don't belong to GNENet but has influence in the simulation.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_EnableAttribute
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool isTemplate() const
check if this AC is template
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
An Element which don't belong to GNENet but has influence in the simulation.
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
Position getPathElementArrivalPos() const
get path element arrival position
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual double getAttributeDouble(SumoXMLAttr key) const =0
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
virtual const RGBColor & getColor() const =0
get color
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)
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
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)
bool demandElementExist(const std::string &id, const std::vector< SumoXMLTag > tags) const
check if the given demand element exist
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
Problem
enum class for demandElement problems
void adjustDefaultFlowAttributes(SUMOVehicleParameter *vehicleParameters)
adjust flow default attributes (called in vehicle/person/flow constructors)
void setFlowParameters(SUMOVehicleParameter *vehicleParameters, const SumoXMLAttr attribute, const bool value)
set flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
A road/street connecting two junctions (netedit-version)
Definition GNEEdge.h:53
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:840
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:1233
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
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:136
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:829
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:788
const GUIGeometry & getLaneGeometry() const
Definition GNELane.cpp:130
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:118
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
bool getAllowChangeLane() const
allow change lane
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNELane * newSecondLane
new second Lane
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
double newSecondPos
new second position
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
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
const Boundary & getBoundary() const
returns the bounder of the network
Definition GNENet.cpp:138
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
GNEPathManager * getPathManager()
get path manager
Definition GNENet.cpp:132
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
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
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
bool drawPathGeometry(const bool dottedElement, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
virtual Position getPathElementArrivalPos() const =0
get path element arrival position
bool isRoute() const
check if pathElement is a route
PathElement()=delete
invalidate default constructor
PathElement * getPathElement() const
get path element
Segment * getNextSegment() const
get next segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
PathDraw * getPathDraw()
obtain instance of PathDraw
void calculatePathJunctions(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNEJunction * > junctions)
calculate path junctions (using dijkstra, require path calculator updated)
void calculatePathLanes(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNELane * > lanes)
calculate path lanes (using dijkstra, require path calculator updated)
bool isPathValid(const PathElement *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 transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
bool isFlow() const
return true if tag correspond to a flow element
bool hasEmbeddedRoute() const
return true if tag correspond to an element that owns an embedded route
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
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
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
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...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:81
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition GNEVehicle.h:120
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition GNEVehicle.h:111
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition GNEVehicle.h:114
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route
Definition GNEVehicle.h:132
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition GNEVehicle.h:135
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition GNEVehicle.h:123
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition GNEVehicle.h:141
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition GNEVehicle.h:126
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition GNEVehicle.h:129
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition GNEVehicle.h:144
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route
Definition GNEVehicle.h:138
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition GNEVehicle.h:117
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition GNEVehicle.h:36
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition GNEVehicle.h:62
GNEVehicle * myVehicle
current vehicle
Definition GNEVehicle.h:59
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition GNEVehicle.h:77
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition GNEVehicle.h:68
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition GNEVehicle.h:74
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition GNEVehicle.h:71
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition GNEVehicle.h:65
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 drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
void computePathElement()
compute pathElement
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
double getAttributeDouble(SumoXMLAttr key) const
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 writed into XML (by default true, can be reimplemented...
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition GNEVehicle.h:356
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void updateGeometry()
update pre-computed geometry information
Position getAttributePosition(SumoXMLAttr key) const
std::string getBegin() const
get begin time of demand element
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
SUMOVehicleClass getVClass() const
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
static void drawDottedSquaredShape(const GUIVisualizationSettings &s, const DottedContourType type, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double exaggeration)
draw dotted squared contour (used by additionals and demand elements)
static void drawDottedContourShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
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
T getColor(const double value) const
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationDetailSettings detailSettings
detail settings
GUIVisualizationWidthSettings widthSettings
width settings
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
double angle
The current view rotation angle.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition Position.h:259
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:300
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:254
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition Position.h:244
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition Position.h:249
double x() const
Returns the x-position.
Definition Position.h:55
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition Position.h:264
double y() const
Returns the y-position.
Definition Position.h:60
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
Definition RGBColor.h:192
static const RGBColor BLUE
Definition RGBColor.h:187
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition RGBColor.cpp:371
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition RGBColor.h:199
static const RGBColor RED
named colors
Definition RGBColor.h:185
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
double repetitionProbability
The probability for emitting a vehicle per second.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
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
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
void parseInsertionChecks(const std::string &value)
parses insertion checks
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.
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.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
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 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.
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
bool wasSet(int what) const
Returns whether the given parameter was set.
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)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
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 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
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
#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
DemandEditMode demandEditMode
the current Demand edit mode
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, 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 vehicleTriangles
details for draw person as triangles
static const double vehicleShapes
details for draw person as shapes
static const double vehicleBoxes
details for draw person as boxes
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