Eclipse SUMO - Simulation of Urban MObility
GNEVehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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// ===========================================================================
44FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[] = {
46};
47
48FXDEFMAP(GNEVehicle::GNESelectedVehiclesPopupMenu) GNESelectedVehiclesPopupMenuMap[] = {
50};
51
52// Object implementation
53FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
54FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
55
56// ===========================================================================
57// static defintions
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}, {}),
292SUMOVehicleParameter(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}, {}),
306SUMOVehicleParameter(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, GNEEdge* fromEdge, GNEEdge* toEdge,
319 const std::vector<GNEEdge*>& via) :
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 // set via parameter without updating references
326 // adjust default flow attributes
328}
329
330
331GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via,
332 const SUMOVehicleParameter& vehicleParameters) :
333 GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
334 (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
335 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
336SUMOVehicleParameter(vehicleParameters) {
337 // set via parameter without updating references
339 // adjust default flow attributes
341}
342
343
344GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
345 GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
347 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
348 fromJunction, toJunction
349}, {}, {}, {}, {vehicleType}, {}),
351 // adjust default flow attributes
353}
354
355
356GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
357 GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
359 GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
360 fromJunction, toJunction
361}, {}, {}, {}, {vehicleType}, {}),
362SUMOVehicleParameter(vehicleParameters) {
363 // adjust default flow attributes
365}
366
367
369
370
373 // get first and last lanes
374 const GNELane* firstLane = getFirstPathLane();
375 const GNELane* lastLane = getLastPathLane();
376 // get depart and arrival positions (doubles)
377 const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
378 const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
379 // obtain diameter
381 // return move operation depending if we're editing departPos or arrivalPos
383 return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
387 return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
390 } else {
391 return nullptr;
392 }
393}
394
395
396std::string
398 // obtain depart
399 std::string departStr = depart < 0 ? "0.00" : time2string(depart);
400 // we need to handle depart as a tuple of 20 numbers (format: 000000...00<departTime>)
401 departStr.reserve(20 - departStr.size());
402 // add 0s at the beginning of departStr until we have 20 numbers
403 for (int i = (int)departStr.size(); i < 20; i++) {
404 departStr.insert(departStr.begin(), '0');
405 }
406 return departStr;
407}
408
409
410void
412 // attribute VType must not be written if is DEFAULT_VTYPE_ID
414 // unset VType parameter
415 parametersSet &= ~VEHPARS_VTYPE_SET;
416 // write vehicle attributes (VType will not be written)
418 // set VType parameter again
420 } else {
421 // write vehicle attributes, including VType
423 }
424 // write specific attribute depending of tag property
426 // write route
428 }
429 // write from, to and edge vias
431 // write manually from/to edges (it correspond to front and back parent edges)
432 device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
433 device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
434 // only write via if there isn't empty
435 if (via.size() > 0) {
436 device.writeAttr(SUMO_ATTR_VIA, via);
437 }
438 }
439 // write fromJunction and toJunction
441 // write manually from/to junctions (it correspond to front and back parent junctions)
444 }
445 // write specific routeFlow/flow attributes
446 if (myTagProperty.isFlow()) {
447 // write routeFlow values depending if it was set
450 }
453 }
456 }
459 }
462 }
465 }
466 }
467 // write parameters
468 writeParams(device);
469 // write route elements associated to this vehicle (except for calibrator FLows)
470 if ((getChildDemandElements().size() > 0) && !myTagProperty.isCalibrator()) {
471 if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
472 // write embedded route
473 getChildDemandElements().front()->writeDemandElement(device);
474 // write sorted stops
475 const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
476 for (const auto& stop : sortedStops) {
477 stop->writeDemandElement(device);
478 }
479 } else {
480 for (const auto& route : getChildDemandElements()) {
481 route->writeDemandElement(device);
482 }
483 }
484 }
485 // close vehicle tag
486 device.closeTag();
487}
488
489
492 // only trips or flows can have problems
495 // check path
496 if (myNet->getPathManager()->isPathValid(this)) {
497 return Problem::OK;
498 } else {
500 }
501 } else if (getParentDemandElements().size() == 2) {
502 // check if exist a valid path using route parent edges
504 return Problem::OK;
505 } else {
507 }
508 } else if (getChildDemandElements().size() > 0 && (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED)) {
509 // get sorted stops and check number
510 std::vector<GNEDemandElement*> embeddedRouteStopWaypoints;
511 for (const auto& routeChild : getChildDemandElements()) {
512 if (routeChild->getTagProperty().isStop() || routeChild->getTagProperty().isWaypoint()) {
513 embeddedRouteStopWaypoints.push_back(routeChild);
514 }
515 }
516 const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
517 if (sortedStops.size() != embeddedRouteStopWaypoints.size()) {
519 }
520 // check if exist a valid path using embedded route 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 = getParentDemandElements().at(1)->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(getParentDemandElements().at(0)->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().getTag() == GNE_TAG_ROUTE_EMBEDDED)) {
558 // get sorted stops and check number
559 std::vector<GNEDemandElement*> embeddedRouteStopWaypoints;
560 for (const auto& routeChild : getChildDemandElements()) {
561 if (routeChild->getTagProperty().isStop() || routeChild->getTagProperty().isWaypoint()) {
562 embeddedRouteStopWaypoints.push_back(routeChild);
563 }
564 }
565 const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
566 if (sortedStops.size() != embeddedRouteStopWaypoints.size()) {
567 return toString(embeddedRouteStopWaypoints.size() - embeddedRouteStopWaypoints.size()) + " stops are outside of embedded route (downstream)";
568 }
569 // get embedded route edges
570 const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().front()->getParentEdges();
571 // check if exist at least a connection between every edge
572 for (int i = 1; i < (int)routeEdges.size(); i++) {
573 if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getParentDemandElements().at(0)->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
574 return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
575 }
576 }
577 // if there are connections between all edges, then all is ok
578 return "";
579 } else {
580 return "";
581 }
582}
583
584
585void
587
588}
589
590
593 return getParentDemandElements().front()->getVClass();
594}
595
596
597const RGBColor&
599 return color;
600}
601
602
603void
605 if (getParentJunctions().size() > 0) {
606 // calculate rotation between both junctions
607 const Position posA = getParentJunctions().front()->getPositionInView();
608 const Position posB = getParentJunctions().back()->getPositionInView();
609 const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
610 // update Geometry
611 myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
612 } else {
613 // get first path lane
614 const GNELane* firstPathLane = getFirstPathLane();
615 // check path lane
616 if (firstPathLane) {
617 // declare departPos
618 double posOverLane = 0;
619 if (canParse<double>(getDepartPos())) {
620 posOverLane = parse<double>(getDepartPos());
621 }
622 // update Geometry
624 // compute route embedded associated with this vehicle
625 for (const auto& demandElement : getChildDemandElements()) {
626 if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
627 demandElement->computePathElement();
628 }
629 demandElement->updateGeometry();
630 }
631 }
632 }
633}
634
635
638 return myDemandElementGeometry.getShape().front();
639}
640
641
645 // obtain all selected vehicles
646 const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
647 std::vector<GNEVehicle*> selectedVehicles;
648 selectedVehicles.reserve(selectedDemandElements.size());
649 for (const auto& selectedDemandElement : selectedDemandElements) {
650 if (selectedDemandElement->getTagProperty().isVehicle()) {
651 selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
652 }
653 }
654 // return a GNESelectedVehiclesPopupMenu
655 return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
656 } else {
657 // return a GNESingleVehiclePopupMenu
658 return new GNESingleVehiclePopupMenu(this, app, parent);
659 }
660}
661
662
663std::string
666 return getParentDemandElements().at(1)->getID();
668 return getParentEdges().front()->getID();
669 } else {
670 throw ProcessError("Invalid vehicle tag");
671 }
672}
673
674
675double
677 return s.vehicleSize.getExaggeration(s, this);
678}
679
680
683 Boundary vehicleBoundary;
684 vehicleBoundary.add(myDemandElementGeometry.getShape().front());
685 vehicleBoundary.grow(20);
686 return vehicleBoundary;
687}
688
689
690void
691GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
692 // geometry of this element cannot be splitted
693}
694
695
696void
698 // only drawn in super mode demand
702 // declare common attributes
704 const double exaggeration = getExaggeration(s);
705 const double width = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_WIDTH);
706 const double length = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
707 const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
708 // obtain Position an rotation (depending of draw spread vehicles)
709 if (drawSpreadVehicles && mySpreadGeometry.getShape().size() == 0) {
710 return;
711 }
712 const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
713 const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
714 // check that position is valid
715 if (vehiclePosition != Position::INVALID) {
716 // first push name
718 // first check if if mouse is enough near to this vehicle to draw it
719 if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
720 // push draw matrix
722 // Start with the drawing of the area translating matrix to origin
724 // translate to drawing position
725 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
726 glRotated(vehicleRotation, 0, 0, -1);
727 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
728 glTranslated(0, (-1) * length * exaggeration, 0);
729 GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
730 // Pop last matrix
732 } else {
734 // push draw matrix
736 // Start with the drawing of the area translating matrix to origin
738 // translate to drawing position
739 glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
740 glRotated(vehicleRotation, 0, 0, -1);
741 // extra translation needed to draw vehicle over edge (to avoid selecting problems)
742 glTranslated(0, (-1) * length * exaggeration, 0);
743 // set lane color
744 setColor(s);
745 double upscaleLength = exaggeration;
746 if ((exaggeration > 1) && (length > 5)) {
747 // reduce the length/width ratio because this is not useful at high zoom
748 upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
749 }
750 glScaled(exaggeration, upscaleLength, 1);
751 // check if we're drawing in selecting mode
753 // draw vehicle as a box and don't draw the rest of details
755 } else {
756 // draw the vehicle depending of detail level
757 if (s.drawDetail(s.detailSettings.vehicleShapes, exaggeration)) {
759 } else if (s.drawDetail(s.detailSettings.vehicleBoxes, exaggeration)) {
761 } else if (s.drawDetail(s.detailSettings.vehicleTriangles, exaggeration)) {
763 }
764 // check if min gap has to be drawn
765 if (s.drawMinGap) {
766 const double minGap = -1 * getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_MINGAP);
767 glColor3d(0., 1., 0.);
768 glBegin(GL_LINES);
769 glVertex2d(0., 0);
770 glVertex2d(0., minGap);
771 glVertex2d(-.5, minGap);
772 glVertex2d(.5, minGap);
773 glEnd();
774 }
775 // drawing name at GLO_MAX fails unless translating z
776 glTranslated(0, MIN2(length / 2, double(5)), -getType());
777 glScaled(1 / exaggeration, 1 / upscaleLength, 1);
778 glRotated(vehicleRotation, 0, 0, -1);
780 // draw line
781 if (s.vehicleName.show(this) && line != "") {
782 glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
784 }
785 }
786 // pop draw matrix
788 // draw line between junctions if path isn't valid
789 if ((getParentJunctions().size() > 0) && !myNet->getPathManager()->isPathValid(this)) {
790 drawJunctionLine(this);
791 }
792 // draw stack label
793 if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
794 drawStackLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
795 }
796 // draw flow label
797 if (myTagProperty.isFlow()) {
798 drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
799 }
800 // draw lock icon
801 GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), vehiclePosition, exaggeration);
802 // check if mouse is over element
803 mouseWithinGeometry(vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation);
804 // inspect contour
806 // draw using drawDottedContourClosedShape
807 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::INSPECT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
808 }
809 // front contour
810 if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
811 // draw using drawDottedContourClosedShape
812 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::FRONT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
813 }
814 // delete contour
815 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
816 // draw using drawDottedContourClosedShape
817 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::REMOVE, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
818 }
819 // select contour
820 if (myNet->getViewNet()->drawSelectContour(this, this)) {
821 // draw using drawDottedContourClosedShape
822 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::SELECT, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
823 }
827 // draw using drawDottedContourClosedShape
828 GUIDottedGeometry::drawDottedSquaredShape(s, GUIDottedGeometry::DottedContourType::ORANGE, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
829 }
830 }
831 // pop name
833 }
834 }
835}
836
837
838void
840 // calculate path (only for flows and trips)
841 if (getParentJunctions().size() > 0) {
842 // calculate path
845 // declare lane stops
846 std::vector<GNELane*> laneStopWaypoints;
847 // iterate over child demand elements
848 for (const auto& demandElement : getChildDemandElements()) {
849 // extract lanes
850 if (demandElement->getTagProperty().isStop() || demandElement->getTagProperty().isWaypoint()) {
851 if (demandElement->getParentAdditionals().size() > 0) {
852 laneStopWaypoints.push_back(demandElement->getParentAdditionals().front()->getParentLanes().front());
853 } else {
854 laneStopWaypoints.push_back(demandElement->getParentLanes().front());
855 }
856 }
857 }
858 // declare lane vector
859 std::vector<GNELane*> lanes;
860 // get first and last lanes
861 const auto firstLane = getFirstPathLane();
862 const auto lastLane = getLastPathLane();
863 // check first and last lanes
864 if (firstLane && lastLane) {
865 // add first lane
866 lanes.push_back(getFirstPathLane());
867 // now check if there are lane Stops
868 if (laneStopWaypoints.size() > 0) {
869 // add stop lanes
870 for (const auto& laneStop : laneStopWaypoints) {
871 lanes.push_back(laneStop);
872 }
873 } else {
874 // add via lanes
875 for (int i = 1; i < ((int)getParentEdges().size() - 1); i++) {
876 lanes.push_back(getParentEdges().at(i)->getLaneByAllowedVClass(getVClass()));
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) + getParentDemandElements().at(0)->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)getParentDemandElements().at(1)->getParentEdges().size())) {
1097 // use departEdge
1098 firstEdge = getParentDemandElements().at(1)->getParentEdges().at(departEdge);
1099 } else {
1100 // use first route edge
1101 firstEdge = getParentDemandElements().at(1)->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 = canParse<int>(getAttribute(SUMO_ATTR_DEPARTLANE)) ? parse<int>(getAttribute(SUMO_ATTR_DEPARTLANE)) : -1;
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)getParentDemandElements().at(1)->getParentEdges().size())) {
1143 // use arrival edge
1144 lastEdge = getParentDemandElements().at(1)->getParentEdges().at(arrivalEdge);
1145 } else {
1146 // use last route edge
1147 lastEdge = getParentDemandElements().at(1)->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 = canParse<int>(getAttribute(SUMO_ATTR_ARRIVALLANE)) ? parse<int>(getAttribute(SUMO_ATTR_ARRIVALLANE)) : -1;
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 getParentDemandElements().at(0)->getID();
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";
1278 return "split";
1279 } else if (departProcedure == DepartDefinition::NOW) {
1280 return "now";
1281 } else {
1282 return time2string(depart);
1283 }
1284 case SUMO_ATTR_ROUTE:
1285 if (getParentDemandElements().size() == 2) {
1286 return getParentDemandElements().at(1)->getID();
1287 } else {
1288 return "";
1289 }
1290 // Specific of from-to edge
1291 case SUMO_ATTR_FROM:
1292 return getParentEdges().front()->getID();
1293 case SUMO_ATTR_TO:
1294 return getParentEdges().back()->getID();
1295 case SUMO_ATTR_VIA:
1296 return toString(via);
1298 if (departEdge == -1) {
1299 return "";
1300 } else {
1301 return toString(departEdge);
1302 }
1304 if (arrivalEdge == -1) {
1305 return "";
1306 } else {
1307 return toString(arrivalEdge);
1308 }
1309 // Specific of from-to junctions
1311 return getParentJunctions().front()->getID();
1313 return getParentJunctions().back()->getID();
1314 // Specific of flows
1315 case SUMO_ATTR_END:
1316 return time2string(repetitionEnd);
1318 return toString(3600 / STEPS2TIME(repetitionOffset));
1319 case SUMO_ATTR_PERIOD:
1320 case GNE_ATTR_POISSON:
1322 case SUMO_ATTR_PROB:
1323 return toString(repetitionProbability, 10);
1324 case SUMO_ATTR_NUMBER:
1325 return toString(repetitionNumber);
1326 // other
1327 case GNE_ATTR_SELECTED:
1330 return getParametersStr();
1332 return toString(parametersSet);
1333 default:
1334 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1335 }
1336}
1337
1338
1339double
1341 switch (key) {
1342 case SUMO_ATTR_DEPART:
1343 case SUMO_ATTR_BEGIN:
1344 return STEPS2TIME(depart);
1346 // only return departPos it if is given
1348 return departPos;
1349 } else {
1350 return 0;
1351 }
1353 // only return departPos it if is given
1355 return arrivalPos;
1356 } else {
1357 return -1;
1358 }
1359 case SUMO_ATTR_WIDTH:
1360 case SUMO_ATTR_LENGTH:
1361 case SUMO_ATTR_MINGAP:
1362 return getParentDemandElements().at(0)->getAttributeDouble(key);
1363 default:
1364 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1365 }
1366}
1367
1368
1371 switch (key) {
1372 case SUMO_ATTR_DEPARTPOS: {
1373 // get first path lane shape
1374 const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1375 // check arrivalPosProcedure
1377 if (departPos < 0) {
1378 return laneShape.front();
1379 } else if (departPos > laneShape.length2D()) {
1380 return laneShape.back();
1381 } else {
1382 return laneShape.positionAtOffset2D(departPos);
1383 }
1384 } else {
1385 return laneShape.front();
1386 }
1387 }
1388 case SUMO_ATTR_ARRIVALPOS: {
1389 // get last path lane shape
1390 const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1391 // check arrivalPosProcedure
1393 if (arrivalPos < 0) {
1394 return laneShape.front();
1395 } else if (arrivalPos > laneShape.length2D()) {
1396 return laneShape.back();
1397 } else {
1398 return laneShape.positionAtOffset2D(arrivalPos);
1399 }
1400 } else {
1401 return laneShape.back();
1402 }
1403 }
1404 default:
1405 throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1406 }
1407}
1408
1409
1410void
1411GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1412 if (value == getAttribute(key)) {
1413 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1414 }
1415 switch (key) {
1416 case SUMO_ATTR_ID:
1417 case SUMO_ATTR_TYPE:
1418 case SUMO_ATTR_COLOR:
1425 case SUMO_ATTR_LINE:
1428 case SUMO_ATTR_REROUTE:
1432 // Specific of vehicles
1433 case SUMO_ATTR_DEPART:
1434 case SUMO_ATTR_BEGIN:
1435 case SUMO_ATTR_ROUTE:
1436 // Specific of from-to edges
1437 case SUMO_ATTR_FROM:
1438 case SUMO_ATTR_TO:
1439 case SUMO_ATTR_VIA:
1442 // Specific of from-to junctions
1445 // Specific of flows
1446 case SUMO_ATTR_END:
1447 case SUMO_ATTR_NUMBER:
1449 case SUMO_ATTR_PERIOD:
1450 case GNE_ATTR_POISSON:
1451 case SUMO_ATTR_PROB:
1452 // other
1454 case GNE_ATTR_SELECTED:
1455 undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
1456 break;
1457 default:
1458 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1459 }
1460}
1461
1462
1463bool
1464GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1465 // declare string error
1466 std::string error;
1467 switch (key) {
1468 case SUMO_ATTR_ID:
1469 // Vehicles, Trips and Flows share namespace
1471 (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VEHICLE, value, false) == nullptr) &&
1472 (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_TRIP, value, false) == nullptr) &&
1473 (myNet->getAttributeCarriers()->retrieveDemandElement(GNE_TAG_FLOW_ROUTE, value, false) == nullptr) &&
1474 (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_FLOW, value, false) == nullptr)) {
1475 return true;
1476 } else {
1477 return false;
1478 }
1479 case SUMO_ATTR_TYPE:
1481 case SUMO_ATTR_COLOR:
1482 return canParse<RGBColor>(value);
1483 case SUMO_ATTR_DEPARTLANE: {
1484 int dummyDepartLane;
1485 DepartLaneDefinition dummyDepartLaneProcedure;
1486 parseDepartLane(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1487 // if error is empty, check if depart lane is correct
1488 if (error.empty()) {
1489 if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1490 return true;
1491 } else if (isTemplate()) {
1492 return true;
1493 } else if (getParentJunctions().size() > 0) {
1494 return (dummyDepartLane == 0);
1495 } else {
1496 return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1497 }
1498 } else {
1499 return false;
1500 }
1501 }
1502 case SUMO_ATTR_DEPARTPOS: {
1503 double dummyDepartPos;
1504 DepartPosDefinition dummyDepartPosProcedure;
1505 parseDepartPos(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPos, dummyDepartPosProcedure, error);
1506 // if error is empty, given value is valid
1507 return error.empty();
1508 }
1509 case SUMO_ATTR_DEPARTSPEED: {
1510 double dummyDepartSpeed;
1511 DepartSpeedDefinition dummyDepartSpeedProcedure;
1512 parseDepartSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1513 // if error is empty, check if depart speed is correct
1514 if (error.empty()) {
1515 if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1516 return true;
1517 } else if (isTemplate()) {
1518 return true;
1519 } else {
1520 return (dummyDepartSpeed <= getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1521 }
1522 } else {
1523 return false;
1524 }
1525 }
1526 case SUMO_ATTR_ARRIVALLANE: {
1527 int dummyArrivalLane;
1528 ArrivalLaneDefinition dummyArrivalLaneProcedure;
1529 parseArrivalLane(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1530 // if error is empty, given value is valid
1531 if (error.empty()) {
1532 if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1533 return true;
1534 } else if (isTemplate()) {
1535 return true;
1536 } else if (getParentJunctions().size() > 0) {
1537 return (dummyArrivalLane == 0);
1538 } else {
1539 return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1540 }
1541 } else {
1542 return false;
1543 }
1544 }
1545 case SUMO_ATTR_ARRIVALPOS: {
1546 double dummyArrivalPos;
1547 ArrivalPosDefinition dummyArrivalPosProcedure;
1548 parseArrivalPos(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1549 // if error is empty, given value is valid
1550 return error.empty();
1551 }
1553 double dummyArrivalSpeed;
1554 ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1555 parseArrivalSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1556 // if error is empty, given value is valid
1557 return error.empty();
1558 }
1559 case SUMO_ATTR_LINE:
1560 return true;
1562 return canParse<int>(value) && parse<int>(value) >= 0;
1564 return canParse<int>(value) && parse<int>(value) >= 0;
1565 case SUMO_ATTR_REROUTE:
1566 return true; // check
1568 double dummyDepartPosLat;
1569 DepartPosLatDefinition dummyDepartPosLatProcedure;
1570 parseDepartPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1571 // if error is empty, given value is valid
1572 return error.empty();
1573 }
1575 double dummyArrivalPosLat;
1576 ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1577 parseArrivalPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1578 // if error is empty, given value is valid
1579 return error.empty();
1580 }
1582 return areInsertionChecksValid(value);
1583 // Specific of vehicles
1584 case SUMO_ATTR_DEPART:
1585 case SUMO_ATTR_BEGIN: {
1586 SUMOTime dummyDepart;
1587 DepartDefinition dummyDepartProcedure;
1588 parseDepart(value, toString(SUMO_TAG_VEHICLE), id, dummyDepart, dummyDepartProcedure, error);
1589 // if error is empty, given value is valid
1590 return error.empty();
1591 }
1592 case SUMO_ATTR_ROUTE:
1593 if (getParentDemandElements().size() == 2) {
1595 } else {
1596 return true;
1597 }
1598 // Specific of from-to edges
1599 case SUMO_ATTR_FROM:
1600 case SUMO_ATTR_TO:
1601 return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
1603 case SUMO_ATTR_ARRIVALEDGE: {
1604 if (value.empty()) {
1605 return true;
1606 } else if (canParse<int>(value)) {
1607 // get index
1608 const int index = parse<int>(value);
1609 // check conditions
1610 if (index < 0) {
1611 return false;
1613 // check parent route
1614 return (index < (int)getParentDemandElements().at(1)->getParentEdges().size());
1615 } else {
1616 // check embedded route
1617 return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1618 }
1619 } else {
1620 return false;
1621 }
1622 }
1623 case SUMO_ATTR_VIA:
1624 if (value.empty()) {
1625 return true;
1626 } else {
1627 return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1628 }
1629 // Specific of from-to junctions
1632 return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveJunction(value, false) != nullptr);
1633 // Specific of flows
1634 case SUMO_ATTR_END:
1635 if (canParse<double>(value)) {
1636 return (parse<double>(value) >= 0);
1637 } else {
1638 return false;
1639 }
1641 if (canParse<double>(value)) {
1642 return (parse<double>(value) > 0);
1643 } else {
1644 return false;
1645 }
1646 case SUMO_ATTR_PERIOD:
1647 case GNE_ATTR_POISSON:
1648 if (canParse<double>(value)) {
1649 return (parse<double>(value) > 0);
1650 } else {
1651 return false;
1652 }
1653 case SUMO_ATTR_PROB:
1654 if (canParse<double>(value)) {
1655 const double prob = parse<double>(value);
1656 return ((prob >= 0) && (prob <= 1));
1657 } else {
1658 return false;
1659 }
1660 case SUMO_ATTR_NUMBER:
1661 if (canParse<int>(value)) {
1662 return (parse<int>(value) >= 0);
1663 } else {
1664 return false;
1665 }
1666 // other
1667 case GNE_ATTR_SELECTED:
1668 return canParse<bool>(value);
1671 default:
1672 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1673 }
1674}
1675
1676
1677void
1679 switch (key) {
1680 case SUMO_ATTR_END:
1681 case SUMO_ATTR_NUMBER:
1683 case SUMO_ATTR_PERIOD:
1684 case GNE_ATTR_POISSON:
1685 case SUMO_ATTR_PROB:
1686 undoList->add(new GNEChange_EnableAttribute(this, key, true, parametersSet), true);
1687 return;
1688 default:
1689 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1690 }
1691}
1692
1693
1694void
1696 switch (key) {
1697 case SUMO_ATTR_END:
1698 case SUMO_ATTR_NUMBER:
1700 case SUMO_ATTR_PERIOD:
1701 case GNE_ATTR_POISSON:
1702 case SUMO_ATTR_PROB:
1703 undoList->add(new GNEChange_EnableAttribute(this, key, false, parametersSet), true);
1704 return;
1705 default:
1706 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1707 }
1708}
1709
1710
1711bool
1713 switch (key) {
1714 case SUMO_ATTR_END:
1715 return (parametersSet & VEHPARS_END_SET) != 0;
1716 case SUMO_ATTR_NUMBER:
1717 return (parametersSet & VEHPARS_NUMBER_SET) != 0;
1719 return (parametersSet & VEHPARS_VPH_SET) != 0;
1720 case SUMO_ATTR_PERIOD:
1721 return (parametersSet & VEHPARS_PERIOD_SET) != 0;
1722 case GNE_ATTR_POISSON:
1723 return (parametersSet & VEHPARS_POISSON_SET) != 0;
1724 case SUMO_ATTR_PROB:
1725 return (parametersSet & VEHPARS_PROB_SET) != 0;
1726 default:
1727 return true;
1728 }
1729}
1730
1731
1732std::string
1734 return getTagStr();
1735}
1736
1737
1738std::string
1740 // special case for Trips and flow
1742 // check if we're inspecting a Edge
1743 if (!myNet->getViewNet()->getInspectedAttributeCarriers().empty() &&
1744 myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1745 // check if edge correspond to a "from", "to" or "via" edge
1747 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1748 } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
1749 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1750 } else {
1751 // iterate over via
1752 for (const auto& i : via) {
1753 if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
1754 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1755 }
1756 }
1757 }
1758 }
1759 }
1760 return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1761}
1762
1763
1764const Parameterised::Map&
1766 return getParametersMap();
1767}
1768
1769// ===========================================================================
1770// protected
1771// ===========================================================================
1772
1773void
1775 // change color
1776 if (drawUsingSelectColor()) {
1778 } else {
1779 // obtain vehicle color
1780 const GUIColorer& c = s.vehicleColorer;
1781 // set color depending of vehicle color active
1782 switch (c.getActive()) {
1783 case 0: {
1784 // test for emergency vehicle
1785 if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "emergency") {
1787 break;
1788 }
1789 // test for firebrigade
1790 if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "firebrigade") {
1792 break;
1793 }
1794 // test for police car
1795 if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "police") {
1797 break;
1798 }
1799 if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "scooter") {
1801 break;
1802 }
1803 // check if color was set
1806 break;
1807 } else {
1808 // take their parent's color)
1810 break;
1811 }
1812 }
1813 case 2: {
1816 } else {
1818 }
1819 break;
1820 }
1821 case 3: {
1824 } else {
1826 }
1827 break;
1828 }
1829 case 4: {
1832 } else {
1834 }
1835 break;
1836 }
1837 case 5: {
1838 Position p = getParentDemandElements().at(1)->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1839 const Boundary& b = myNet->getBoundary();
1840 Position center = b.getCenter();
1841 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1842 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1844 break;
1845 }
1846 case 6: {
1847 Position p = getParentDemandElements().at(1)->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1848 const Boundary& b = myNet->getBoundary();
1849 Position center = b.getCenter();
1850 double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1851 double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1853 break;
1854 }
1855 case 7: {
1856 Position pb = getParentDemandElements().at(1)->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1857 Position pe = getParentDemandElements().at(1)->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1858 const Boundary& b = myNet->getBoundary();
1859 double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1860 Position minp(b.xmin(), b.ymin());
1861 Position maxp(b.xmax(), b.ymax());
1862 double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1864 break;
1865 }
1866 case 29: { // color randomly (by pointer hash)
1867 std::hash<const GNEVehicle*> ptr_hash;
1868 const double hue = (double)(ptr_hash(this) % 360); // [0-360]
1869 const double sat = (double)((ptr_hash(this) / 360) % 67) / 100. + 0.33; // [0.33-1]
1871 break;
1872 }
1873 default: {
1875 }
1876 }
1877 }
1878}
1879
1880// ===========================================================================
1881// private
1882// ===========================================================================
1883
1884void
1885GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1886 // declare string error
1887 std::string error;
1888 // flag to upate stack label
1889 bool updateSpreadStackGeometry = false;
1890 switch (key) {
1891 case SUMO_ATTR_ID:
1892 // update microsimID
1893 setMicrosimID(value);
1894 // set manually vehicle ID (needed for saving)
1895 id = value;
1896 // Change IDs of all person plans children (stops, embedded routes...)
1897 for (const auto& childDemandElement : getChildDemandElements()) {
1898 childDemandElement->setMicrosimID(getID());
1899 }
1900 break;
1901 case SUMO_ATTR_TYPE:
1902 if (getID().size() > 0) {
1904 // set manually vtypeID (needed for saving)
1905 vtypeid = value;
1906 }
1907 break;
1908 case SUMO_ATTR_COLOR:
1909 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1910 color = parse<RGBColor>(value);
1911 // mark parameter as set
1913 } else {
1914 // set default value
1915 color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1916 // unset parameter
1917 parametersSet &= ~VEHPARS_COLOR_SET;
1918 }
1919 break;
1921 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1923 // mark parameter as set
1925 } else {
1926 // set default value
1928 // unset parameter
1929 parametersSet &= ~VEHPARS_DEPARTLANE_SET;
1930 }
1931 break;
1933 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1935 // mark parameter as set
1937 } else {
1938 // set default value
1940 // unset parameter
1941 parametersSet &= ~VEHPARS_DEPARTPOS_SET;
1942 }
1943 if (getID().size() > 0) {
1945 updateSpreadStackGeometry = true;
1946 }
1947 break;
1949 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1951 // mark parameter as set
1953 } else {
1954 // set default value
1956 // unset parameter
1957 parametersSet &= ~VEHPARS_DEPARTSPEED_SET;
1958 }
1959 break;
1961 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1963 // mark parameter as set
1965 } else {
1966 // set default value
1968 // unset parameter
1969 parametersSet &= ~VEHPARS_ARRIVALLANE_SET;
1970 }
1971 break;
1973 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1975 // mark parameter as set
1977 } else {
1978 // set default value
1980 // unset parameter
1981 parametersSet &= ~VEHPARS_ARRIVALPOS_SET;
1982 }
1983 if (getID().size() > 0) {
1985 updateSpreadStackGeometry = true;
1986 }
1987 break;
1989 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1991 // mark parameter as set
1993 } else {
1994 // set default value
1996 // unset parameter
1997 parametersSet &= ~VEHPARS_ARRIVALSPEED_SET;
1998 }
1999 break;
2000 case SUMO_ATTR_LINE:
2001 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2002 line = value;
2003 // mark parameter as set
2005 } else {
2006 // set default value
2008 // unset parameter
2009 parametersSet &= ~VEHPARS_LINE_SET;
2010 }
2011 break;
2013 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2014 personNumber = parse<int>(value);
2015 // mark parameter as set
2017 } else {
2018 // set default value
2019 personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2020 // unset parameter
2021 parametersSet &= ~VEHPARS_PERSON_NUMBER_SET;
2022 }
2023 break;
2025 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2026 containerNumber = parse<int>(value);
2027 // mark parameter as set
2029 } else {
2030 // set default value
2032 // unset parameter
2033 parametersSet &= ~VEHPARS_CONTAINER_NUMBER_SET;
2034 }
2035 break;
2036 case SUMO_ATTR_REROUTE:
2037 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2038 // mark parameter as set
2040 } else {
2041 // unset parameter
2042 parametersSet &= ~VEHPARS_ROUTE_SET;
2043 }
2044 break;
2046 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2048 // mark parameter as set
2050 } else {
2051 // set default value
2053 // unset parameter
2054 parametersSet &= ~VEHPARS_DEPARTPOSLAT_SET;
2055 }
2056 break;
2058 if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2060 // mark parameter as set
2062 } else {
2063 // set default value
2065 // unset parameter
2066 parametersSet &= ~VEHPARS_ARRIVALPOSLAT_SET;
2067 }
2069 break;
2071 parseInsertionChecks(value);
2072 break;
2073 // Specific of vehicles
2074 case SUMO_ATTR_DEPART:
2075 case SUMO_ATTR_BEGIN: {
2077 break;
2078 }
2079 case SUMO_ATTR_ROUTE:
2080 if (getParentDemandElements().size() == 2) {
2082 }
2084 updateSpreadStackGeometry = true;
2085 break;
2086 // Specific of from-to edges
2087 case SUMO_ATTR_FROM: {
2088 // change first edge
2090 // compute vehicle
2092 updateSpreadStackGeometry = true;
2093 break;
2094 }
2095 case SUMO_ATTR_TO: {
2096 // change last edge
2097 replaceLastParentEdge(value);
2098 // compute vehicle
2100 updateSpreadStackGeometry = true;
2101 break;
2102 }
2103 case SUMO_ATTR_VIA: {
2104 if (!value.empty()) {
2105 // set new via edges
2106 via = parse< std::vector<std::string> >(value);
2107 // mark parameter as set
2109 } else {
2110 // clear via
2111 via.clear();
2112 // unset parameter
2113 parametersSet &= ~VEHPARS_VIA_SET;
2114 }
2115 // update via
2116 replaceMiddleParentEdges(value, true);
2117 // compute vehicle
2119 updateSpreadStackGeometry = true;
2120 break;
2121 }
2122 case SUMO_ATTR_DEPARTEDGE: {
2123 // update depart edge
2124 if (value.empty()) {
2125 // unset parameter
2126 parametersSet &= ~VEHPARS_DEPARTEDGE_SET;
2127 departEdge = -1;
2129 } else {
2130 // mark parameter as set
2132 departEdge = parse<int>(value);
2134 }
2135 // compute vehicle
2136 if (getID().size() > 0) {
2138 updateSpreadStackGeometry = true;
2139 }
2140 break;
2141 }
2142 case SUMO_ATTR_ARRIVALEDGE: {
2143 // update arrival edge
2144 if (value.empty()) {
2145 // unset parameter
2146 parametersSet &= ~VEHPARS_ARRIVALEDGE_SET;
2147 arrivalEdge = -1;
2149 } else {
2150 // mark parameter as set
2152 arrivalEdge = parse<int>(value);
2154 }
2155 if (getID().size() > 0) {
2156 // compute vehicle
2158 updateSpreadStackGeometry = true;
2159 }
2160 break;
2161 }
2162 // Specific of from-to junctions
2164 // change first junction
2166 // compute vehicle
2168 updateSpreadStackGeometry = true;
2169 break;
2170 }
2171 case SUMO_ATTR_TOJUNCTION: {
2172 // change last junction
2174 // compute vehicle
2176 updateSpreadStackGeometry = true;
2177 break;
2178 }
2179 // Specific of flows
2180 case SUMO_ATTR_END:
2181 repetitionEnd = string2time(value);
2182 break;
2184 repetitionOffset = TIME2STEPS(3600 / parse<double>(value));
2185 break;
2186 case SUMO_ATTR_PERIOD:
2187 case GNE_ATTR_POISSON:
2189 break;
2190 case SUMO_ATTR_PROB:
2191 repetitionProbability = parse<double>(value);
2192 break;
2193 case SUMO_ATTR_NUMBER:
2194 repetitionNumber = parse<int>(value);
2195 break;
2196 // other
2197 case GNE_ATTR_SELECTED:
2198 if (parse<bool>(value)) {
2200 } else {
2202 }
2203 break;
2205 setParametersStr(value);
2206 break;
2207 default:
2208 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
2209 }
2210 // check if stack label has to be updated
2211 if (updateSpreadStackGeometry) {
2213 getParentEdges().front()->updateVehicleStackLabels();
2214 getParentEdges().front()->updateVehicleSpreadGeometries();
2215 } else if (getParentDemandElements().size() == 2) {
2216 getParentDemandElements().at(1)->getParentEdges().front()->updateVehicleStackLabels();
2217 getParentDemandElements().at(1)->getParentEdges().front()->updateVehicleSpreadGeometries();
2218 } else if (getChildDemandElements().size() > 0) {
2219 getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2220 getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2221 }
2222 }
2223}
2224
2225
2226void
2228 // set flow parameters
2229 setFlowParameters(this, key, value);
2230}
2231
2232
2233void
2235 if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2237 // change depart
2239 departPos = moveResult.newFirstPos;
2240 }
2243 // change arrival
2245 arrivalPos = moveResult.newFirstPos;
2246 }
2247 // set lateral offset
2249 // update geometry
2251}
2252
2253
2254void
2256 // reset lateral offset
2258 // check departPos
2259 if (moveResult.newFirstPos != INVALID_DOUBLE) {
2260 // begin change attribute
2261 undoList->begin(myTagProperty.getGUIIcon(), "departPos of " + getTagStr());
2262 // now set departPos
2263 setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2264 // check if depart lane has to be changed
2265 if (moveResult.newFirstLane) {
2266 // set new depart lane
2268 }
2269 }
2270 // check arrivalPos
2271 if (moveResult.newSecondPos != INVALID_DOUBLE) {
2272 // begin change attribute
2273 undoList->begin(myTagProperty.getGUIIcon(), "arrivalPos of " + getTagStr());
2274 // now set arrivalPos
2276 // check if arrival lane has to be changed
2277 if (moveResult.newSecondLane) {
2278 // set new arrival lane
2280 }
2281 }
2282 // end change attribute
2283 undoList->end();
2284}
2285
2286
2287void
2288GNEVehicle::drawStackLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const {
2289 // declare contour width
2290 const double contourWidth = (0.05 * exaggeration);
2291 // Push matrix
2293 // Traslate to vehicle top
2294 glTranslated(vehiclePosition.x(), vehiclePosition.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW);
2295 glRotated(vehicleRotation, 0, 0, -1);
2296 glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration), 0, 0);
2297 // draw external box
2299 GLHelper::drawBoxLine(Position(), 0, (length * exaggeration), 0.3 * exaggeration);
2300 // draw internal box
2301 glTranslated(0, 0, 0.1);
2302 GLHelper::setColor(RGBColor(0, 128, 0));
2303 GLHelper::drawBoxLine(Position(0, -contourWidth), Position(0, -contourWidth), 0, (length * exaggeration) - (contourWidth * 2), (0.3 * exaggeration) - contourWidth);
2304 // draw stack label
2305 GLHelper::drawText("vehicles stacked: " + toString(myStackedLabelNumber), Position(0, length * exaggeration * -0.5), (.1 * exaggeration), (0.6 * exaggeration), RGBColor::WHITE, 90, 0, -1);
2306 // pop draw matrix
2308}
2309
2310
2311void
2312GNEVehicle::drawFlowLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const {
2313 // declare contour width
2314 const double contourWidth = (0.05 * exaggeration);
2315 // Push matrix
2317 // Traslate to vehicle bot
2318 glTranslated(vehiclePosition.x(), vehiclePosition.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW);
2319 glRotated(vehicleRotation, 0, 0, -1);
2320 glTranslated(-1 * ((width * 0.5 * exaggeration) + (0.35 * exaggeration)), 0, 0);
2321 // draw external box
2323 GLHelper::drawBoxLine(Position(), Position(), 0, (length * exaggeration), 0.3 * exaggeration);
2324 // draw internal box
2325 glTranslated(0, 0, 0.1);
2327 GLHelper::drawBoxLine(Position(0, -contourWidth), Position(0, -contourWidth), 0, (length * exaggeration) - (contourWidth * 2), (0.3 * exaggeration) - contourWidth);
2328 // draw stack label
2329 GLHelper::drawText("Flow", Position(0, length * exaggeration * -0.5), (.1 * exaggeration), (0.6 * exaggeration), RGBColor::BLACK, 90, 0, -1);
2330 // pop draw matrix
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)
Definition: GUIAppEnum.h:1283
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:448
@ GLO_TRIP
a trip
@ GLO_ROUTEFLOW
a routeFlow
@ GLO_ROUTE
a route
@ GLO_FLOW
a flow
@ GLO_VEHICLE
a vehicle
@ GLO_PERSONFLOW
a person flow
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
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:54
#define TIME2STEPS(x)
Definition: SUMOTime.h:56
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.
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_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.
@ 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 (used in NETEDIT)
@ 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 (used in NETEDIT)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions (used in NETEDIT)
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ GNE_TAG_ROUTE_EMBEDDED
embedded route (used in NETEDIT)
@ 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_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ 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
Definition: StdDefs.h:60
T MIN2(T a, T b)
Definition: StdDefs.h:71
T MAX2(T a, T b)
Definition: StdDefs.h:77
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 drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:685
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
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
Position getPathElementArrivalPos() const
get path element arrival position
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< const GNEDemandElement * > getSortedStops(const std::vector< GNEEdge * > &edges) const
get sorted stops
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 replaceMiddleParentEdges(const std::string &value, const bool updateChildReferences)
replace middle (via) parent edges
void setFlowParameters(SUMOVehicleParameter *vehicleParameters, const SumoXMLAttr attribute, const bool value)
set flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
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:839
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:1229
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< 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:142
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:917
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:876
const GUIGeometry & getLaneGeometry() const
Definition: GNELane.cpp:136
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:124
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
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
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:144
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
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
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.
Definition: GNEVehicle.cpp:220
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:149
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.
Definition: GNEVehicle.cpp:65
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.
Definition: GNEVehicle.cpp:128
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
void drawFlowLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw flow label
GNELane * getLastPathLane() const
get last path lane
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNEVehicle.cpp:676
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:586
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:682
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:372
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:664
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNEVehicle.cpp:891
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:839
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:368
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:697
bool isAttributeEnabled(SumoXMLAttr key) const
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:598
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...
Definition: GNEVehicle.cpp:491
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:353
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVehicle.cpp:691
std::string getHierarchyName() const
get Hierarchy Name (Used in AC Hierarchy)
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GNEVehicle.cpp:643
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:604
Position getAttributePosition(SumoXMLAttr key) const
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:397
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:533
void drawStackLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw stack label
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:637
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)
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNEVehicle.cpp:411
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:262
SUMOVehicleClass getVClass() const
Definition: GNEVehicle.cpp:592
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:656
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
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
Definition: GNEViewNet.cpp:644
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.
Definition: GNEViewNet.cpp:474
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::DemandViewOptions & getDemandViewOptions() const
get demand view options
Definition: GNEViewNet.cpp:650
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_VEHICLETYPE
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
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)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
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
Definition: GUIGeometry.cpp:58
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
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 mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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.
Definition: GUIGlObject.h:154
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.
Definition: GUIGlObject.h:102
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
const 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.
Definition: OptionsCont.cpp:59
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
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
Definition: Parameterised.h:45
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:257
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:298
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition: Position.h:247
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:262
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 const RGBColor GREY
Definition: RGBColor.h:194
static const RGBColor CYAN
Definition: RGBColor.h:189
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 BLACK
Definition: RGBColor.h:193
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
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
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 isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
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