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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Representation of vehicles in netedit
19 /****************************************************************************/
21 #include <netedit/GNENet.h>
22 #include <netedit/GNEUndoList.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
29 #include <utils/gui/div/GLHelper.h>
33 #include <utils/xml/NamespaceIDs.h>
34 
35 #include "GNEVehicle.h"
36 #include "GNERoute.h"
37 
38 // ===========================================================================
39 // FOX callback mapping
40 // ===========================================================================
41 FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[] = {
43 };
44 
45 FXDEFMAP(GNEVehicle::GNESelectedVehiclesPopupMenu) GNESelectedVehiclesPopupMenuMap[] = {
47 };
48 
49 // Object implementation
50 FXIMPLEMENT(GNEVehicle::GNESingleVehiclePopupMenu, GUIGLObjectPopupMenu, GNESingleVehiclePopupMenuMap, ARRAYNUMBER(GNESingleVehiclePopupMenuMap))
51 FXIMPLEMENT(GNEVehicle::GNESelectedVehiclesPopupMenu, GUIGLObjectPopupMenu, GNESelectedVehiclesPopupMenuMap, ARRAYNUMBER(GNESelectedVehiclesPopupMenuMap))
52 
53 // ===========================================================================
54 // static definitions
55 // ===========================================================================
57 
58 // ===========================================================================
59 // GNEVehicle::GNESingleVehiclePopupMenu
60 // ===========================================================================
61 
63  GUIGLObjectPopupMenu(app, parent, *vehicle),
64  myVehicle(vehicle) {
65  // build header
66  myVehicle->buildPopupHeader(this, app);
67  // build menu command for center button and copy cursor position to clipboard
70  // build menu commands for names
71  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
72  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
73  new FXMenuSeparator(this);
74  // build selection and show parameters menu
77  // route length
78  vehicle->buildMenuCommandRouteLength(this);
79  // add transform functions only in demand mode
81  // add reverse
82  vehicle->buildMenuAddReverse(this);
83  // continue depending of type
85  // create menu pane for transform operations
86  FXMenuPane* transformOperation = new FXMenuPane(this);
87  this->insertMenuPaneChild(transformOperation);
88  new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
89  // Create menu commands for all transform
90  GUIDesigns::buildFXMenuCommand(transformOperation,
91  TL("Trip (over junctions)"),
94  GUIDesigns::buildFXMenuCommand(transformOperation,
95  TL("Flow (over junctions)"),
98  } else if (myVehicle->getTagProperty().vehicleTAZs()) {
99  // create menu pane for transform operations
100  FXMenuPane* transformOperation = new FXMenuPane(this);
101  this->insertMenuPaneChild(transformOperation);
102  new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
103  // Create menu commands for all transform
104  GUIDesigns::buildFXMenuCommand(transformOperation,
105  TL("Trip (over TAZs)"),
108  GUIDesigns::buildFXMenuCommand(transformOperation,
109  TL("Flow (over TAZs)"),
112  } else {
113  // create menu pane for transform operations
114  FXMenuPane* transformOperation = new FXMenuPane(this);
115  this->insertMenuPaneChild(transformOperation);
116  new FXMenuCascade(this, TL("transform to"), nullptr, transformOperation);
117  // Create menu commands for all transform
118  GUIDesigns::buildFXMenuCommand(transformOperation,
119  TL("Vehicle"),
122  GUIDesigns::buildFXMenuCommand(transformOperation,
123  TL("Vehicle (embedded route)"),
126  GUIDesigns::buildFXMenuCommand(transformOperation,
127  TL("RouteFlow"),
130  GUIDesigns::buildFXMenuCommand(transformOperation,
131  TL("RouteFlow (embedded route)"),
134  GUIDesigns::buildFXMenuCommand(transformOperation,
135  TL("Trip"),
138  GUIDesigns::buildFXMenuCommand(transformOperation,
139  TL("Flow"),
142  }
143  }
144 }
145 
146 
148 
149 
150 long
151 GNEVehicle::GNESingleVehiclePopupMenu::onCmdTransform(FXObject*, FXSelector sel, void*) {
152  switch (FXSELID(sel)) {
155  break;
158  break;
160  GNERouteHandler::transformToVehicle(myVehicle, false);
161  break;
163  GNERouteHandler::transformToRouteFlow(myVehicle, false);
164  break;
166  GNERouteHandler::transformToVehicle(myVehicle, true);
167  break;
169  GNERouteHandler::transformToRouteFlow(myVehicle, true);
170  break;
173  break;
176  break;
179  break;
182  break;
183  default:
184  break;
185  }
186  return 1;
187 }
188 
189 // ===========================================================================
190 // GNEVehicle::GNESelectedVehiclesPopupMenu
191 // ===========================================================================
192 
193 GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
194  GUIGLObjectPopupMenu(app, parent, *vehicle),
195  mySelectedVehicles(selectedVehicle),
196  myVehicleTag(vehicle->getTagProperty().getTag()) {
197  // build header
198  vehicle->buildPopupHeader(this, app);
199  // build menu command for center button and copy cursor position to clipboard
200  vehicle->buildCenterPopupEntry(this);
201  vehicle->buildPositionCopyEntry(this, app);
202  // build menu commands for names
203  GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
204  GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
205  new FXMenuSeparator(this);
206  // build selection and show parameters menu
207  vehicle->getNet()->getViewNet()->buildSelectionACPopupEntry(this, vehicle);
208  vehicle->buildShowParamsPopupEntry(this);
209  // route length
210  vehicle->buildMenuCommandRouteLength(this);
211  // add transform functions only in demand mode
212  if (vehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
213  // add reverse
214  vehicle->buildMenuAddReverse(this);
215  // continue depending of type
216  if (vehicle->getTagProperty().vehicleJunctions()) {
217  // create menu pane for transform operations
218  FXMenuPane* transformOperation = new FXMenuPane(this);
219  this->insertMenuPaneChild(transformOperation);
220  new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
221  // Create menu commands for restricted transforms
223  TLF("Trips (over junctions) (only %)", toString(GNE_TAG_TRIP_JUNCTIONS)),
226  TLF("Flows (over junctions) (only %)", toString(GNE_TAG_FLOW_JUNCTIONS)),
228  // create separator
229  new FXMenuSeparator(transformOperation);
230  // Create menu commands for all transform
231  GUIDesigns::buildFXMenuCommand(transformOperation,
232  TL("Trips (over junctions)"),
234  GUIDesigns::buildFXMenuCommand(transformOperation,
235  TL("Flows (over junctions)"),
237  } else if (vehicle->getTagProperty().vehicleTAZs()) {
238  // create menu pane for transform operations
239  FXMenuPane* transformOperation = new FXMenuPane(this);
240  this->insertMenuPaneChild(transformOperation);
241  new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
242  // Create menu commands for all transform
244  TLF("Trips (over TAZs) (only %)", toString(GNE_TAG_TRIP_TAZS)),
247  TLF("Flows (over TAZs) (only %)", toString(GNE_TAG_FLOW_TAZS)),
249  // create separator
250  new FXMenuSeparator(transformOperation);
251  // Create menu commands for all transform
252  GUIDesigns::buildFXMenuCommand(transformOperation,
253  TL("Trips (over TAZs)"),
255  GUIDesigns::buildFXMenuCommand(transformOperation,
256  TL("Flows (over TAZs)"),
258  } else {
259  // create menu pane for transform operations
260  FXMenuPane* transformOperation = new FXMenuPane(this);
261  this->insertMenuPaneChild(transformOperation);
262  new FXMenuCascade(this, TL("transform selected to"), nullptr, transformOperation);
263  // Create menu commands for all transform
265  TLF("Vehicles (only %)", toString(SUMO_TAG_VEHICLE)),
268  TLF("Vehicles (embedded route) (only %)", toString(GNE_TAG_VEHICLE_WITHROUTE)),
271  TLF("RouteFlows (only %)", toString(GNE_TAG_FLOW_ROUTE)),
274  TLF("RouteFlows (embedded route) (only %)", toString(GNE_TAG_FLOW_WITHROUTE)),
277  TLF("Trips (only %)", toString(SUMO_TAG_TRIP)),
280  TLF("Flows (only %)", toString(SUMO_TAG_FLOW)),
282  // create separator
283  new FXMenuSeparator(transformOperation);
284  // Create menu commands for all transform
285  GUIDesigns::buildFXMenuCommand(transformOperation,
286  TL("Vehicles"),
288  GUIDesigns::buildFXMenuCommand(transformOperation,
289  TL("Vehicles (embedded route)"),
291  GUIDesigns::buildFXMenuCommand(transformOperation,
292  TL("RouteFlows"),
294  GUIDesigns::buildFXMenuCommand(transformOperation,
295  TL("RouteFlows (embedded route)"),
297  GUIDesigns::buildFXMenuCommand(transformOperation,
298  TL("Trips"),
300  GUIDesigns::buildFXMenuCommand(transformOperation,
301  TL("Flows"),
303  }
304  }
305 }
306 
307 
309 
310 
311 long
312 GNEVehicle::GNESelectedVehiclesPopupMenu::onCmdTransform(FXObject* obj, FXSelector sel, void*) {
313  // iterate over all selected vehicles
314  for (const auto& vehicle : mySelectedVehicles) {
315  switch (FXSELID(sel)) {
317  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
318  if (myRestrictedMenuCommands.count(obj) > 0) {
319  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
321  }
322  } else {
324  }
325  }
326  break;
328  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
329  if (myRestrictedMenuCommands.count(obj) > 0) {
330  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
332  }
333  } else {
335  }
336  }
337  break;
339  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
340  if (myRestrictedMenuCommands.count(obj) > 0) {
341  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
342  GNERouteHandler::transformToVehicle(vehicle, false);
343  }
344  } else {
345  GNERouteHandler::transformToVehicle(vehicle, false);
346  }
347  }
348  break;
350  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
351  if (myRestrictedMenuCommands.count(obj) > 0) {
352  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
354  }
355  } else {
357  }
358  }
359  break;
361  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
362  if (myRestrictedMenuCommands.count(obj) > 0) {
363  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
365  }
366  } else {
368  }
369  }
370  break;
372  if (!vehicle->getTagProperty().vehicleJunctions() && !vehicle->getTagProperty().vehicleTAZs()) {
373  if (myRestrictedMenuCommands.count(obj) > 0) {
374  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
376  }
377  } else {
379  }
380  }
381  break;
383  if (vehicle->getTagProperty().vehicleJunctions()) {
384  if (myRestrictedMenuCommands.count(obj) > 0) {
385  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
387  }
388  } else {
390  }
391  }
392  break;
394  if (vehicle->getTagProperty().vehicleJunctions()) {
395  if (myRestrictedMenuCommands.count(obj) > 0) {
396  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
398  }
399  } else {
401  }
402  }
403  break;
405  if (vehicle->getTagProperty().vehicleTAZs()) {
406  if (myRestrictedMenuCommands.count(obj) > 0) {
407  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
409  }
410  } else {
412  }
413  }
414  break;
416  if (vehicle->getTagProperty().vehicleTAZs()) {
417  if (myRestrictedMenuCommands.count(obj) > 0) {
418  if (vehicle->getTagProperty().getTag() == myRestrictedMenuCommands.at(obj)) {
420  }
421  } else {
423  }
424  }
425  break;
426  default:
427  break;
428  }
429  }
430  return 1;
431 }
432 
433 // ===========================================================================
434 // member method definitions
435 // ===========================================================================
436 
439  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {}, {}),
440 GNEDemandElementFlow(this) {
441  // reset default values
443  // set end and vehPerHours as default flow values
446 }
447 
448 
449 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route) :
450  GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
452  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
453 GNEDemandElementFlow(this) {
454  // SUMOVehicleParameter ID has to be set manually
455  id = vehicleID;
456  // set manually vtypeID (needed for saving)
457  vtypeid = vehicleType->getID();
458 }
459 
460 
461 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
462  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag,
464  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType, route}, {}),
465 GNEDemandElementFlow(this, vehicleParameters) {
466  // SUMOVehicleParameter ID has to be set manually
467  id = vehicleParameters.id;
468  // set manually vtypeID (needed for saving)
469  vtypeid = vehicleType->getID();
470 }
471 
472 
473 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
474  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_VEHICLE_WITHROUTE) ? GLO_VEHICLE : GLO_ROUTEFLOW, tag,
476  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {}, {vehicleType}, {}),
477 GNEDemandElementFlow(this, vehicleParameters) {
478  // SUMOVehicleParameter ID has to be set manually
479  id = vehicleParameters.id;
480  // reset routeid
481  routeid.clear();
482  // set manually vtypeID (needed for saving)
483  vtypeid = vehicleType->getID();
484 }
485 
486 
487 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType,
488  GNEEdge* fromEdge, GNEEdge* toEdge) :
489  GNEDemandElement(vehicleID, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
490  (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
491  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
492 GNEDemandElementFlow(this) {
493 }
494 
495 
496 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
497  const SUMOVehicleParameter& vehicleParameters) :
498  GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag,
499  (tag == SUMO_TAG_FLOW) ? GUIIconSubSys::getIcon(GUIIcon::FLOW) : GUIIconSubSys::getIcon(GUIIcon::TRIP),
500  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {fromEdge, toEdge}, {}, {}, {vehicleType}, {}),
501 GNEDemandElementFlow(this, vehicleParameters) {
502 }
503 
504 
505 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
506  GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
508  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
509  fromJunction, toJunction
510 }, {}, {}, {}, {vehicleType}, {}),
511 GNEDemandElementFlow(this) {
512 }
513 
514 
515 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
516  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag,
518  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
519  fromJunction, toJunction
520 }, {}, {}, {}, {vehicleType}, {}),
521 GNEDemandElementFlow(this, vehicleParameters) {
522 }
523 
524 
525 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEAdditional* fromTAZ, GNEAdditional* toTAZ, const SUMOVehicleParameter& vehicleParameters) :
526  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_TAZS) ? GLO_FLOW : GLO_TRIP, tag,
528  GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {}, {}, {}, {fromTAZ, toTAZ}, {vehicleType}, {}),
529 GNEDemandElementFlow(this, vehicleParameters) {
530  // mark taz parameters as set
533  fromTaz = fromTAZ->getID();
534  toTaz = toTAZ->getID();
535 }
536 
537 
539 
540 
543  // get first and last lanes
544  const GNELane* firstLane = getFirstPathLane();
545  const GNELane* lastLane = getLastPathLane();
546  // check both lanes
547  if (firstLane && lastLane) {
548  // get depart and arrival positions (doubles)
549  const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
550  const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
551  // obtain diameter
553  // return move operation depending if we're editing departPos or arrivalPos
555  return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
559  return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
562  }
563  }
564  // nothing to move
565  return nullptr;
566 }
567 
568 
569 void
571  // attribute VType must not be written if is DEFAULT_VTYPE_ID
572  if (getTypeParent()->getID() == DEFAULT_VTYPE_ID) {
573  // unset VType parameter
575  // write vehicle attributes (VType will not be written)
577  // set VType parameter again
579  } else {
580  // write vehicle attributes, including type/distribution
582  }
583  // write specific attribute depending of tag property
584  if (myTagProperty.vehicleRoute()) {
585  // write route
587  }
588  // write from, to and edge vias
589  if (myTagProperty.vehicleEdges()) {
590  // write manually from/to edges (it correspond to front and back parent edges)
591  device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
592  device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
593  // only write via if there isn't empty
594  if (via.size() > 0) {
595  device.writeAttr(SUMO_ATTR_VIA, via);
596  }
597  }
598  // write from and to junctions
600  // write manually from/to junctions (it correspond to front and back parent junctions)
603  }
604  // write flow attributes
605  writeFlowAttributes(this, device);
606  // write parameters
607  writeParams(device);
608  // write route elements associated to this vehicle (except for calibrator FLows)
609  if ((getChildDemandElements().size() > 0) && !myTagProperty.isCalibrator()) {
610  if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
611  // write embedded route
612  getChildDemandElements().front()->writeDemandElement(device);
613  // write stops
614  for (const auto& demandElement : getChildDemandElements()) {
615  if (demandElement->getTagProperty().isVehicleStop()) {
616  demandElement->writeDemandElement(device);
617  }
618  }
619  } else {
620  for (const auto& route : getChildDemandElements()) {
621  route->writeDemandElement(device);
622  }
623  }
624  }
625  // close vehicle tag
626  device.closeTag();
627 }
628 
629 
632  // check conditions
633  if (myTagProperty.vehicleTAZs()) {
634  // vehicles and flows over tazs are always valid
635  return Problem::OK;
636  } else if (myTagProperty.vehicleEdges()) {
637  // check vehicles and flows paths
638  if (getParentEdges().front() == getParentEdges().back()) {
639  return Problem::OK;
640  } else if (myNet->getPathManager()->isPathValid(this)) {
641  return Problem::OK;
642  } else {
643  return Problem::INVALID_PATH;
644  }
645  } else if (myTagProperty.vehicleJunctions()) {
646  // check vehicles and flows paths
647  if (getParentJunctions().front() == getParentJunctions().back()) {
648  return Problem::OK;
649  } else if (myNet->getPathManager()->isPathValid(this)) {
650  return Problem::OK;
651  } else {
652  return Problem::INVALID_PATH;
653  }
654  } else if (myTagProperty.vehicleRoute()) {
655  // check if exist a valid path using route parent edges
657  return Problem::OK;
658  } else {
659  return Problem::INVALID_PATH;
660  }
661  } else if (myTagProperty.vehicleRouteEmbedded()) {
662  // check if exist a valid path using route child edges
664  return Problem::OK;
665  } else {
666  return Problem::INVALID_PATH;
667  }
668  } else {
670  }
671 }
672 
673 
674 std::string
676  // only trips or flows can have problems
677  if (myTagProperty.vehicleEdges()) {
678  // check if exist at least a connection between every edge
679  for (int i = 1; i < (int)getParentEdges().size(); i++) {
681  return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
682  }
683  }
684  // if there are connections between all edges, then all is ok
685  return "";
686  } else if (myTagProperty.vehicleJunctions()) {
687  return ("No path between junction '" + getParentJunctions().front()->getID() + "' and '" + getParentJunctions().back()->getID() + "'");
688  } else if (myTagProperty.vehicleRoute()) {
689  // get route parent edges
690  const std::vector<GNEEdge*>& routeEdges = getRouteParent()->getParentEdges();
691  // check if exist at least a connection between every edge
692  for (int i = 1; i < (int)routeEdges.size(); i++) {
693  if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
694  return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
695  }
696  }
697  // if there are connections between all edges, then all is ok
698  return "";
699  } else if (myTagProperty.vehicleRouteEmbedded()) {
700  // get route parent edges
701  const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().at(0)->getParentEdges();
702  // check if exist at least a connection between every edge
703  for (int i = 1; i < (int)routeEdges.size(); i++) {
704  if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getTypeParent()->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
705  return ("There is no valid path between embedded route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
706  }
707  }
708  // if there are connections between all edges, then all is ok
709  return "";
710  } else {
711  return "";
712  }
713 }
714 
715 
716 void
718  //
719 }
720 
721 
724  return getParentDemandElements().front()->getVClass();
725 }
726 
727 
728 const RGBColor&
730  return color;
731 }
732 
733 
734 void
736  if (getParentJunctions().size() > 0) {
737  // calculate rotation between both junctions
738  const Position posA = getParentJunctions().front()->getPositionInView();
739  const Position posB = getParentJunctions().back()->getPositionInView();
740  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
741  // update Geometry
742  myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
743  } else if (getParentAdditionals().size() > 0) {
744  // calculate rotation between both junctions
745  const Position posA = getParentAdditionals().front()->getPositionInView();
746  const Position posB = getParentAdditionals().back()->getPositionInView();
747  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
748  // update Geometry
749  myDemandElementGeometry.updateSinglePosGeometry(getParentAdditionals().front()->getPositionInView(), rot);
750  } else {
751  // get first path lane
752  const GNELane* firstPathLane = getFirstPathLane();
753  // check path lane
754  if (firstPathLane) {
755  // declare departPos
756  double posOverLane = 0;
758  posOverLane = departPos;
759  }
760  // update Geometry
762  // compute route embedded associated with this vehicle
763  for (const auto& demandElement : getChildDemandElements()) {
764  if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
765  demandElement->computePathElement();
766  }
767  demandElement->updateGeometry();
768  }
769  }
770  }
771 }
772 
773 
774 Position
776  return myDemandElementGeometry.getShape().front();
777 }
778 
779 
780 bool
782  // get edit modes
783  const auto& editModes = myNet->getViewNet()->getEditModes();
784  // check if we're editing a type
785  if (editModes.isCurrentSupermodeDemand() && (editModes.demandEditMode == DemandEditMode::DEMAND_TYPE) &&
787  return true;
788  } else {
789  return false;
790  }
791 }
792 
793 
797  // obtain all selected vehicles
798  const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
799  std::vector<GNEVehicle*> selectedVehicles;
800  selectedVehicles.reserve(selectedDemandElements.size());
801  for (const auto& selectedDemandElement : selectedDemandElements) {
802  if (selectedDemandElement->getTagProperty().isVehicle()) {
803  selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
804  }
805  }
806  // return a GNESelectedVehiclesPopupMenu
807  return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
808  } else {
809  // return a GNESingleVehiclePopupMenu
810  return new GNESingleVehiclePopupMenu(this, app, parent);
811  }
812 }
813 
814 
815 std::string
817  if (myTagProperty.vehicleRoute()) {
818  return getRouteParent()->getID();
819  } else if (myTagProperty.vehicleEdges()) {
820  return getParentEdges().front()->getID();
821  } else if (myTagProperty.vehicleJunctions()) {
822  return getParentJunctions().front()->getID();
823  } else if (myTagProperty.vehicleTAZs()) {
824  return getParentAdditionals().front()->getID();
825  } else {
826  throw ProcessError(TL("Invalid vehicle tag"));
827  }
828 }
829 
830 
831 double
833  return s.vehicleSize.getExaggeration(s, this);
834 }
835 
836 
837 Boundary
839  Boundary vehicleBoundary;
840  vehicleBoundary.add(myDemandElementGeometry.getShape().front());
841  vehicleBoundary.grow(20);
842  return vehicleBoundary;
843 }
844 
845 
846 void
847 GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
848  // geometry of this element cannot be splitted
849 }
850 
851 
852 void
854  // only drawn in super mode demand
858  // declare common attributes
860  const double exaggeration = getExaggeration(s);
861  const double width = getTypeParent()->getAttributeDouble(SUMO_ATTR_WIDTH);
862  const double length = getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
863  const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
864  const auto vehicleColor = setColor(s);
865  // obtain Position an rotation (depending of draw spread vehicles)
866  if (drawSpreadVehicles && mySpreadGeometry.getShape().size() == 0) {
867  return;
868  }
869  const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
870  const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
871  // check that position is valid
872  if (vehiclePosition == Position::INVALID) {
873  return;
874  }
875  // get detail level
876  const auto d = s.getDetailLevel(exaggeration);
877  // draw geometry only if we'rent in drawForObjectUnderCursor mode
878  if (!s.drawForViewObjectsHandler) {
879  // first check if if mouse is enough near to this vehicle to draw it
880  if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
881  // push draw matrix
883  // Start with the drawing of the area translating matrix to origin
885  // translate to drawing position
886  glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
887  glRotated(vehicleRotation, 0, 0, -1);
888  // extra translation needed to draw vehicle over edge (to avoid selecting problems)
889  glTranslated(0, (-1) * length * exaggeration, 0);
890  GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
891  // Pop last matrix
893  } else {
895  // push draw matrix
897  // Start with the drawing of the area translating matrix to origin
899  // translate to drawing position
900  glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
901  glRotated(vehicleRotation, 0, 0, -1);
902  // extra translation needed to draw vehicle over edge (to avoid selecting problems)
903  glTranslated(0, (-1) * length * exaggeration, 0);
904  // set lane color
905  GLHelper::setColor(vehicleColor);
906  double upscaleLength = exaggeration;
907  if ((exaggeration > 1) && (length > 5)) {
908  // reduce the length/width ratio because this is not useful at high zoom
909  upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
910  }
911  glScaled(exaggeration, upscaleLength, 1);
912  // check if we're drawing in selecting mode
914  // draw vehicle as a box and don't draw the rest of details
916  } else {
917  // draw the vehicle depending of detail level
924  }
925  // check if min gap has to be drawn
926  if (s.drawMinGap) {
927  const double minGap = -1 * getTypeParent()->getAttributeDouble(SUMO_ATTR_MINGAP);
928  glColor3d(0., 1., 0.);
929  glBegin(GL_LINES);
930  glVertex2d(0., 0);
931  glVertex2d(0., minGap);
932  glVertex2d(-.5, minGap);
933  glVertex2d(.5, minGap);
934  glEnd();
935  }
936  // drawing name at GLO_MAX fails unless translating z
937  glTranslated(0, MIN2(length / 2, double(5)), -getType());
938  glScaled(1 / exaggeration, 1 / upscaleLength, 1);
939  glRotated(vehicleRotation, 0, 0, -1);
941  // draw line
942  if (s.vehicleName.show(this) && line != "") {
943  glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
944  GLHelper::drawTextSettings(s.vehicleName, "line:" + line, Position(0, 0), s.scale, s.angle);
945  }
946  }
947  // pop draw matrix
949  // draw line between junctions if path isn't valid
950  if ((getParentJunctions().size() > 0) && !myNet->getPathManager()->isPathValid(this)) {
951  drawJunctionLine(this);
952  }
953  // draw stack label
954  if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
955  drawStackLabel(myStackedLabelNumber, "Vehicle", vehiclePosition, vehicleRotation, width, length, exaggeration);
956  }
957  // draw flow label
958  if (myTagProperty.isFlow()) {
959  drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
960  }
961  }
962  // draw lock icon
963  GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), vehiclePosition, exaggeration);
964  // draw dotted contour
966  }
967  // draw squared shape
968  myVehicleContour.calculateContourRectangleShape(s, d, this, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
969  }
970 }
971 
972 
973 void
975  // calculate path (only for flows and trips)
977  // calculate path
979  } else if (myTagProperty.vehicleEdges()) {
980  // declare lane stops
981  std::vector<GNELane*> laneStopWaypoints;
982  // iterate over child demand elements
983  for (const auto& demandElement : getChildDemandElements()) {
984  // extract lanes
985  if (demandElement->getTagProperty().isVehicleStop()) {
986  if (demandElement->getParentAdditionals().size() > 0) {
987  laneStopWaypoints.push_back(demandElement->getParentAdditionals().front()->getParentLanes().front());
988  } else {
989  laneStopWaypoints.push_back(demandElement->getParentLanes().front());
990  }
991  }
992  }
993  // declare lane vector
994  std::vector<GNELane*> lanes;
995  // get first and last lanes
996  const auto firstLane = getFirstPathLane();
997  const auto lastLane = getLastPathLane();
998  // check first and last lanes
999  if (firstLane && lastLane) {
1000  // add first lane
1001  lanes.push_back(getFirstPathLane());
1002  // now check if there are lane Stops
1003  if (laneStopWaypoints.size() > 0) {
1004  // add stop lanes
1005  for (const auto& laneStop : laneStopWaypoints) {
1006  lanes.push_back(laneStop);
1007  }
1008  } else {
1009  // add via lanes
1010  for (const auto& edgeID : via) {
1011  const auto edge = myNet->getAttributeCarriers()->retrieveEdge(edgeID, false);
1012  if (edge) {
1013  lanes.push_back(edge->getLaneByAllowedVClass(getVClass()));
1014  }
1015  }
1016  }
1017  // add last lane
1018  lanes.push_back(lastLane);
1019  // calculate path
1020  myNet->getPathManager()->calculatePath(this, getVClass(), lanes);
1021  }
1022  }
1023  // update geometry
1024  updateGeometry();
1025 }
1026 
1027 
1028 void
1029 GNEVehicle::drawLanePartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
1030  const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1033  const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1035  // check conditions
1036  if (segment->getLane() && !s.drawForRectangleSelection && (drawNetworkMode || drawDemandMode || isAttributeCarrierSelected()) &&
1038  // get detail level
1039  const auto d = s.getDetailLevel(1);
1040  // calculate width
1041  const double width = s.vehicleSize.getExaggeration(s, segment->getLane()) * s.widthSettings.tripWidth;
1042  // calculate startPos
1043  const double geometryDepartPos = (getParentJunctions().size() > 0) ? 0 : getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getTypeParent()->getAttributeDouble(SUMO_ATTR_LENGTH);
1044  // get endPos
1045  const double geometryEndPos = (getParentJunctions().size() > 0) ? segment->getLane()->getLaneGeometry().getShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
1046  // declare path geometry
1047  GUIGeometry vehicleGeometry;
1048  // update pathGeometry depending of first and last segment
1049  if (segment->isFirstSegment() && segment->isLastSegment()) {
1050  vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1051  geometryDepartPos,
1053  geometryEndPos,
1055  } else if (segment->isFirstSegment()) {
1056  vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1057  geometryDepartPos,
1059  -1,
1061  } else if (segment->isLastSegment()) {
1062  vehicleGeometry.updateGeometry(segment->getLane()->getLaneGeometry().getShape(),
1063  -1,
1065  geometryEndPos,
1067  } else {
1068  vehicleGeometry = segment->getLane()->getLaneGeometry();
1069  }
1070  // draw geometry only if we'rent in drawForObjectUnderCursor mode
1071  if (!s.drawForViewObjectsHandler) {
1072  // obtain color
1074  // Add a draw matrix
1076  // Start with the drawing of the area translating matrix to origin
1077  glTranslated(0, 0, getType() + offsetFront);
1078  // Set color
1079  GLHelper::setColor(pathColor);
1080  // draw geometry
1081  GUIGeometry::drawGeometry(d, vehicleGeometry, width);
1082  // Pop last matrix
1084  // check if we have to draw a red line to the next segment (if next segment isnt' a junction
1085  if (segment->getNextLane()) {
1086  // push draw matrix
1088  // Start with the drawing of the area translating matrix to origin
1090  // Set red color
1092  // get firstPosition (last position of current lane shape)
1093  const Position& firstPosition = segment->getLane()->getLaneShape().back();
1094  // get lastPosition (first position of next lane shape)
1095  const Position& arrivalPosition = segment->getNextLane()->getLaneShape().front();
1096  // draw box line
1097  GLHelper::drawBoxLine(arrivalPosition,
1098  RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
1099  firstPosition.distanceTo2D(arrivalPosition), .05);
1100  // pop draw matrix
1102  }
1103  // check if this is the last segment
1104  if (segment->isLastSegment() && (getParentJunctions().size() == 0)) {
1105  // get geometryEndPos
1106  const Position geometryEndPosition = getAttributePosition(GNE_ATTR_PLAN_GEOMETRY_ENDPOS);
1107  // check if endPos can be drawn
1109  // push draw matrix
1111  // Start with the drawing of the area translating matrix to origin
1113  // translate to geometryEndPos
1114  glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
1115  // Set person plan color
1116  GLHelper::setColor(pathColor);
1117  // resolution of drawn circle depending of the zoom (To improve smoothness)
1119  // pop draw matrix
1121  }
1122  }
1123  // Draw name if isn't being drawn for selecting
1124  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
1125  // draw dotted contour
1126  segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1127  }
1128  // calculate contour and draw dotted geometry
1129  if (segment->isFirstSegment() || segment->isLastSegment()) {
1130  segment->getContour()->calculateContourExtrudedShape(s, d, this, vehicleGeometry.getShape(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0);
1131  } else {
1132  segment->getContour()->calculateContourExtrudedShape(s, d, this, segment->getLane()->getLaneShape(), width, 1, segment->isFirstSegment(), segment->isLastSegment(), 0);
1133  }
1134  }
1135 }
1136 
1137 
1138 void
1139 GNEVehicle::drawJunctionPartialGL(const GUIVisualizationSettings& s, const GNEPathManager::Segment* segment, const double offsetFront) const {
1140  // get flags
1141  const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1144  const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
1146  // check conditions
1147  if (!s.drawForRectangleSelection && (drawNetworkMode || drawDemandMode || isAttributeCarrierSelected()) &&
1149  // get detail level
1150  const auto d = s.getDetailLevel(1);
1151  // calculate width
1152  const double width = s.vehicleSize.getExaggeration(s, segment->getPreviousLane()) * s.widthSettings.tripWidth;
1153  // draw geometry only if we'rent in drawForObjectUnderCursor mode
1154  if (!s.drawForViewObjectsHandler) {
1155  // Add a draw matrix
1157  // Start with the drawing of the area translating matrix to origin
1158  glTranslated(0, 0, getType() + offsetFront);
1159  // Set color of the base
1160  if (drawUsingSelectColor()) {
1162  } else {
1164  }
1165  // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1166  if (segment->getPreviousLane() && segment->getNextLane()) {
1167  // draw lane2lane
1169  } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1170  // draw line between center of junction and last lane shape
1171  GLHelper::drawBoxLines({segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, width);
1172  } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1173  // draw line between center of junction and first lane shape
1174  GLHelper::drawBoxLines({getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, width);
1175  }
1176  // Pop last matrix
1178  // draw dotted contour
1179  segment->getContour()->drawDottedContours(s, d, this, s.dottedContourSettings.segmentWidth, true);
1180  }
1181  // continue depending if we're in the middle of two lanes or in the begin/end of a junction route
1182  if (segment->getPreviousLane() && segment->getNextLane()) {
1183  // calculate contour and draw dotted geometry
1185  width, 1, false, false);
1186  } else if (segment->getPreviousLane() && myTagProperty.vehicleJunctions()) {
1187  segment->getContour()->calculateContourExtrudedShape(s, d, this, {segment->getPreviousLane()->getLaneShape().back(), getParentJunctions().back()->getPositionInView()}, 0,
1188  width, 1, true, true);
1189  } else if (segment->getNextLane() && myTagProperty.vehicleJunctions()) {
1190  segment->getContour()->calculateContourExtrudedShape(s, d, this, {getParentJunctions().front()->getPositionInView(), segment->getNextLane()->getLaneShape().front()}, 0,
1191  width, 1, true, true);
1192  }
1193  }
1194 }
1195 
1196 
1197 GNELane*
1199  // declare first edge
1200  GNEEdge* firstEdge = nullptr;
1201  // continue depending of tags
1202  if (myTagProperty.vehicleRoute()) {
1203  // check departEdge
1204  if ((departEdge > 0) && (departEdge < (int)getRouteParent()->getParentEdges().size())) {
1205  // use departEdge
1206  firstEdge = getRouteParent()->getParentEdges().at(departEdge);
1207  } else {
1208  // use first route edge
1209  firstEdge = getRouteParent()->getParentEdges().front();
1210  }
1211  } else if (myTagProperty.vehicleRouteEmbedded()) {
1212  // check if embedded route exist (due during loading embedded route doesn't exist)
1213  if (getChildDemandElements().empty()) {
1214  return nullptr;
1215  }
1216  // check departEdge
1217  if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1218  // use depart edge
1219  firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1220  } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1221  firstEdge = getChildDemandElements().front()->getParentEdges().front();
1222  } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1223  firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1224  } else {
1225  return nullptr;
1226  }
1227  } else if (getParentEdges().size() > 0) {
1228  // use first parent edge
1229  firstEdge = getParentEdges().front();
1230  } else {
1231  // defined over junctions
1232  return nullptr;
1233  }
1234  // get departLane index
1235  const int departLaneIndex = (int)getAttributeDouble(SUMO_ATTR_DEPARTLANE);
1236  // check departLane index
1237  if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1238  return firstEdge->getLanes().at(departLaneIndex);
1239  } else {
1240  // get first allowed VClass
1241  return firstEdge->getLaneByAllowedVClass(getVClass());
1242  }
1243 }
1244 
1245 
1246 GNELane*
1248  // declare last edge
1249  GNEEdge* lastEdge = nullptr;
1250  // continue depending of tags
1251  if (myTagProperty.vehicleRoute()) {
1252  // check arrivalEdge
1253  if ((arrivalEdge > 0) && (arrivalEdge < (int)getRouteParent()->getParentEdges().size())) {
1254  // use arrival edge
1255  lastEdge = getRouteParent()->getParentEdges().at(arrivalEdge);
1256  } else {
1257  // use last route edge
1258  lastEdge = getRouteParent()->getParentEdges().back();
1259  }
1260  } else if (myTagProperty.vehicleRouteEmbedded()) {
1261  // check if embedded route exist (due during loading embedded route doesn't exist)
1262  if (getChildDemandElements().empty()) {
1263  return nullptr;
1264  }
1265  // check arrivalEdge
1266  if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1267  // use arrival edge
1268  lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1269  } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1270  // use last route edge
1271  lastEdge = getChildDemandElements().front()->getParentEdges().back();
1272  } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1273  // use lane
1274  lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1275  } else {
1276  return nullptr;
1277  }
1278  } else if (getParentEdges().size() > 0) {
1279  // use last parent edge
1280  lastEdge = getParentEdges().back();
1281  } else {
1282  // defined over junctions
1283  return nullptr;
1284  }
1285  // get arrivalLane index
1286  const int arrivalLaneIndex = (int)getAttributeDouble(SUMO_ATTR_ARRIVALLANE);
1287  // check arrivalLane index
1288  if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1289  return lastEdge->getLanes().at(arrivalLaneIndex);
1290  } else {
1291  // get last allowed VClass
1292  return lastEdge->getLaneByAllowedVClass(getVClass());
1293  }
1294 }
1295 
1296 
1297 std::string
1299  switch (key) {
1300  case SUMO_ATTR_ID:
1301  return getMicrosimID();
1302  case SUMO_ATTR_TYPE:
1303  return vtypeid;
1304  case SUMO_ATTR_COLOR:
1305  if (wasSet(VEHPARS_COLOR_SET)) {
1306  return toString(color);
1307  } else {
1309  }
1310  case SUMO_ATTR_DEPARTLANE:
1312  return getDepartLane();
1313  } else {
1315  }
1316  case SUMO_ATTR_DEPARTPOS:
1318  return getDepartPos();
1319  } else {
1321  }
1322  case SUMO_ATTR_DEPARTSPEED:
1324  return getDepartSpeed();
1325  } else {
1327  }
1328  case SUMO_ATTR_ARRIVALLANE:
1330  return getArrivalLane();
1331  } else {
1333  }
1334  case SUMO_ATTR_ARRIVALPOS:
1336  return getArrivalPos();
1337  } else {
1339  }
1342  return getArrivalSpeed();
1343  } else {
1345  }
1346  case SUMO_ATTR_LINE:
1347  if (wasSet(VEHPARS_LINE_SET)) {
1348  return line;
1349  } else {
1351  }
1354  return toString(personNumber);
1355  } else {
1357  }
1360  return toString(containerNumber);
1361  } else {
1363  }
1364  case SUMO_ATTR_REROUTE:
1366  return "true";
1367  } else {
1368  return "false";
1369  }
1372  return getDepartPosLat();
1373  } else {
1375  }
1378  return getArrivalPosLat();
1379  } else {
1381  }
1383  return getInsertionChecks();
1384  // Specific of vehicles over routes
1385  case SUMO_ATTR_ROUTE:
1386  if (getParentDemandElements().size() == 2) {
1387  return getRouteParent()->getID();
1388  } else {
1389  return "";
1390  }
1391  // Specific of from-to edge
1392  case SUMO_ATTR_FROM:
1393  return getParentEdges().front()->getID();
1394  case SUMO_ATTR_TO:
1395  return getParentEdges().back()->getID();
1396  case SUMO_ATTR_VIA:
1397  return toString(via);
1398  case SUMO_ATTR_DEPARTEDGE:
1399  if (departEdge == -1) {
1400  return "";
1401  } else {
1402  return toString(departEdge);
1403  }
1404  case SUMO_ATTR_ARRIVALEDGE:
1405  if (arrivalEdge == -1) {
1406  return "";
1407  } else {
1408  return toString(arrivalEdge);
1409  }
1410  // Specific of from-to junctions
1412  return getParentJunctions().front()->getID();
1413  case SUMO_ATTR_TO_JUNCTION:
1414  return getParentJunctions().back()->getID();
1415  // Specific of from-to tazs
1416  case SUMO_ATTR_FROM_TAZ:
1417  return getParentAdditionals().front()->getID();
1418  case SUMO_ATTR_TO_TAZ:
1419  return getParentAdditionals().back()->getID();
1420  // other
1421  case GNE_ATTR_SELECTED:
1423  case GNE_ATTR_PARAMETERS:
1424  return getParametersStr();
1426  return toString(parametersSet);
1427  default:
1428  return getFlowAttribute(key);
1429  }
1430 }
1431 
1432 
1433 double
1435  switch (key) {
1436  case SUMO_ATTR_DEPARTLANE:
1438  return departLane;
1439  } else {
1440  return -1;
1441  }
1442  case SUMO_ATTR_DEPARTPOS:
1443  // only return departPos it if is given
1445  return departPos;
1446  } else {
1447  return 0;
1448  }
1449  case SUMO_ATTR_ARRIVALLANE:
1451  return arrivalLane;
1452  } else {
1453  return -1;
1454  }
1455  case SUMO_ATTR_ARRIVALPOS:
1456  // only return departPos it if is given
1458  return arrivalPos;
1459  } else {
1460  return -1;
1461  }
1462  case SUMO_ATTR_WIDTH:
1463  case SUMO_ATTR_LENGTH:
1464  case SUMO_ATTR_MINGAP:
1465  return getTypeParent()->getAttributeDouble(key);
1466  default:
1467  return getFlowAttributeDouble(key);
1468  }
1469 }
1470 
1471 
1472 Position
1474  switch (key) {
1476  // check if this vehicle was defined over junctions
1477  if (getParentJunctions().size() > 0) {
1478  return getParentJunctions().front()->getPositionInView();
1479  } else {
1480  // get first path lane shape
1481  const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1482  // check arrivalPosProcedure
1484  if (departPos < 0) {
1485  return laneShape.front();
1486  } else if (departPos > laneShape.length2D()) {
1487  return laneShape.back();
1488  } else {
1489  return laneShape.positionAtOffset2D(departPos);
1490  }
1491  } else {
1492  return laneShape.front();
1493  }
1494  }
1495  }
1497  // check if this vehicle was defined over junctions
1498  if (getParentJunctions().size() > 0) {
1499  return getParentJunctions().back()->getPositionInView();
1500  } else {
1501  // get last path lane shape
1502  const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1503  // check arrivalPosProcedure
1505  if (arrivalPos < 0) {
1506  return laneShape.front();
1507  } else if (arrivalPos > laneShape.length2D()) {
1508  return laneShape.back();
1509  } else {
1510  return laneShape.positionAtOffset2D(arrivalPos);
1511  }
1512  } else {
1513  return laneShape.back();
1514  }
1515  }
1516  }
1517  default:
1518  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1519  }
1520 }
1521 
1522 
1523 void
1524 GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1525  if (value == getAttribute(key)) {
1526  return; //avoid needless changes, later logic relies on the fact that attributes have changed
1527  }
1528  switch (key) {
1529  case SUMO_ATTR_ID:
1530  case SUMO_ATTR_TYPE:
1531  case SUMO_ATTR_COLOR:
1532  case SUMO_ATTR_DEPARTLANE:
1533  case SUMO_ATTR_DEPARTPOS:
1534  case SUMO_ATTR_DEPARTSPEED:
1535  case SUMO_ATTR_ARRIVALLANE:
1536  case SUMO_ATTR_ARRIVALPOS:
1538  case SUMO_ATTR_LINE:
1541  case SUMO_ATTR_REROUTE:
1545  // Specific of vehicles over routes
1546  case SUMO_ATTR_ROUTE:
1547  // Specific of from-to edges
1548  case SUMO_ATTR_FROM:
1549  case SUMO_ATTR_TO:
1550  case SUMO_ATTR_VIA:
1551  case SUMO_ATTR_DEPARTEDGE:
1552  case SUMO_ATTR_ARRIVALEDGE:
1553  // Specific of from-to junctions
1555  case SUMO_ATTR_TO_JUNCTION:
1556  // Specific of from-to taz
1557  case SUMO_ATTR_FROM_TAZ:
1558  case SUMO_ATTR_TO_TAZ:
1559  // other
1560  case GNE_ATTR_PARAMETERS:
1561  case GNE_ATTR_SELECTED:
1562  GNEChange_Attribute::changeAttribute(this, key, value, undoList);
1563  break;
1564  default:
1565  setFlowAttribute(this, key, value, undoList);
1566  break;
1567  }
1568 }
1569 
1570 
1571 bool
1572 GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1573  // get ACs
1574  const auto ACs = myNet->getAttributeCarriers();
1575  // declare string error
1576  std::string error;
1577  switch (key) {
1578  case SUMO_ATTR_ID:
1580  case SUMO_ATTR_TYPE:
1581  return (myNet->getAttributeCarriers()->retrieveDemandElements(NamespaceIDs::types, value, false) != nullptr);
1582  case SUMO_ATTR_COLOR:
1583  return canParse<RGBColor>(value);
1584  case SUMO_ATTR_DEPARTLANE: {
1585  int dummyDepartLane;
1586  DepartLaneDefinition dummyDepartLaneProcedure;
1587  parseDepartLane(value, myTagProperty.getTagStr(), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1588  // if error is empty, check if depart lane is correct
1589  if (error.empty()) {
1590  if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1591  return true;
1592  } else if (isTemplate()) {
1593  return true;
1594  } else if (getParentJunctions().size() > 0) {
1595  return (dummyDepartLane == 0);
1596  } else if (getParentAdditionals().size() > 0) {
1597  return (dummyDepartLane == 0);
1598  } else {
1599  return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1600  }
1601  } else {
1602  return false;
1603  }
1604  }
1605  case SUMO_ATTR_DEPARTPOS: {
1606  double dummyDepartPos;
1607  DepartPosDefinition dummyDepartPosProcedure;
1608  parseDepartPos(value, myTagProperty.getTagStr(), id, dummyDepartPos, dummyDepartPosProcedure, error);
1609  // if error is empty, given value is valid
1610  return error.empty();
1611  }
1612  case SUMO_ATTR_DEPARTSPEED: {
1613  double dummyDepartSpeed;
1614  DepartSpeedDefinition dummyDepartSpeedProcedure;
1615  parseDepartSpeed(value, myTagProperty.getTagStr(), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1616  // if error is empty, check if depart speed is correct
1617  if (error.empty()) {
1618  if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1619  return true;
1620  } else if (isTemplate()) {
1621  return true;
1622  } else {
1623  return (dummyDepartSpeed <= getTypeParent()->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1624  }
1625  } else {
1626  return false;
1627  }
1628  }
1629  case SUMO_ATTR_ARRIVALLANE: {
1630  int dummyArrivalLane;
1631  ArrivalLaneDefinition dummyArrivalLaneProcedure;
1632  parseArrivalLane(value, myTagProperty.getTagStr(), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1633  // if error is empty, given value is valid
1634  if (error.empty()) {
1635  if (dummyArrivalLaneProcedure != ArrivalLaneDefinition::GIVEN) {
1636  return true;
1637  } else if (isTemplate()) {
1638  return true;
1639  } else if (getParentJunctions().size() > 0) {
1640  return (dummyArrivalLane == 0);
1641  } else if (getParentAdditionals().size() > 0) {
1642  return (dummyArrivalLane == 0);
1643  } else {
1644  return dummyArrivalLane < (int)getLastPathLane()->getParentEdge()->getLanes().size();
1645  }
1646  } else {
1647  return false;
1648  }
1649  }
1650  case SUMO_ATTR_ARRIVALPOS: {
1651  double dummyArrivalPos;
1652  ArrivalPosDefinition dummyArrivalPosProcedure;
1653  parseArrivalPos(value, myTagProperty.getTagStr(), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1654  // if error is empty, given value is valid
1655  return error.empty();
1656  }
1657  case SUMO_ATTR_ARRIVALSPEED: {
1658  double dummyArrivalSpeed;
1659  ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1660  parseArrivalSpeed(value, myTagProperty.getTagStr(), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1661  // if error is empty, given value is valid
1662  return error.empty();
1663  }
1664  case SUMO_ATTR_LINE:
1665  return true;
1667  return canParse<int>(value) && parse<int>(value) >= 0;
1669  return canParse<int>(value) && parse<int>(value) >= 0;
1670  case SUMO_ATTR_REROUTE:
1671  return true; // check
1672  case SUMO_ATTR_DEPARTPOS_LAT: {
1673  double dummyDepartPosLat;
1674  DepartPosLatDefinition dummyDepartPosLatProcedure;
1675  parseDepartPosLat(value, myTagProperty.getTagStr(), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1676  // if error is empty, given value is valid
1677  return error.empty();
1678  }
1679  case SUMO_ATTR_ARRIVALPOS_LAT: {
1680  double dummyArrivalPosLat;
1681  ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1682  parseArrivalPosLat(value, myTagProperty.getTagStr(), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1683  // if error is empty, given value is valid
1684  return error.empty();
1685  }
1687  return areInsertionChecksValid(value);
1688  // Specific of vehicles over routes
1689  case SUMO_ATTR_ROUTE:
1690  if (getParentDemandElements().size() == 2) {
1691  return SUMOXMLDefinitions::isValidVehicleID(value) && (ACs->retrieveDemandElement(SUMO_TAG_ROUTE, value, false) != nullptr);
1692  } else {
1693  return true;
1694  }
1695  // Specific of from-to edges
1696  case SUMO_ATTR_FROM:
1697  case SUMO_ATTR_TO:
1698  return (ACs->retrieveEdge(value, false) != nullptr);
1699  case SUMO_ATTR_DEPARTEDGE:
1700  case SUMO_ATTR_ARRIVALEDGE: {
1701  if (value.empty()) {
1702  return true;
1703  } else if (canParse<int>(value)) {
1704  // get index
1705  const int index = parse<int>(value);
1706  // check conditions
1707  if (index < 0) {
1708  return false;
1709  } else if (myTagProperty.vehicleRoute()) {
1710  // check parent route
1711  return (index < (int)getRouteParent()->getParentEdges().size());
1712  } else {
1713  // check embedded route
1714  return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1715  }
1716  } else {
1717  return false;
1718  }
1719  }
1720  case SUMO_ATTR_VIA:
1721  if (value.empty()) {
1722  return true;
1723  } else {
1724  return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1725  }
1726  // Specific of from-to junctions
1728  case SUMO_ATTR_TO_JUNCTION:
1729  return (ACs->retrieveJunction(value, false) != nullptr);
1730  // Specific of from-to taz
1731  case SUMO_ATTR_FROM_TAZ:
1732  case SUMO_ATTR_TO_TAZ:
1733  return (ACs->retrieveAdditional(SUMO_TAG_TAZ, value, false) != nullptr);
1734  // other
1735  case GNE_ATTR_SELECTED:
1736  return canParse<bool>(value);
1737  case GNE_ATTR_PARAMETERS:
1738  return Parameterised::areParametersValid(value);
1739  default:
1740  return isValidFlowAttribute(this, key, value);
1741  }
1742 }
1743 
1744 
1745 void
1747  enableFlowAttribute(this, key, undoList);
1748 }
1749 
1750 
1751 void
1753  disableFlowAttribute(this, key, undoList);
1754 }
1755 
1756 
1757 bool
1759  return isFlowAttributeEnabled(key);
1760 }
1761 
1762 
1763 std::string
1765  return getTagStr();
1766 }
1767 
1768 
1769 std::string
1771  // special case for Trips and flow
1772  if (myTagProperty.vehicleEdges()) {
1773  // check if we're inspecting a Edge
1774  if (!myNet->getViewNet()->getInspectedAttributeCarriers().empty() &&
1775  myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1776  // check if edge correspond to a "from", "to" or "via" edge
1778  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1779  } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
1780  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1781  } else {
1782  // iterate over via
1783  for (const auto& i : via) {
1784  if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
1785  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1786  }
1787  }
1788  }
1789  }
1790  }
1791  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1792 }
1793 
1794 
1795 const Parameterised::Map&
1797  return getParametersMap();
1798 }
1799 
1800 
1802 GNEVehicle::copyVehicle(const GNEVehicle* originalVehicle) {
1803  // get net and undoList
1804  const auto net = originalVehicle->getNet();
1805  auto undoList = net->getViewNet()->getUndoList();
1806  // declare new route, vehicle and embedded route
1807  GNERoute* newRoute = nullptr;
1808  GNEVehicle* newVehicle = nullptr;
1809  GNERoute* newEmbeddedRoute = nullptr;
1810  // generate new vehicle ID
1811  const std::string newRouteID = net->getAttributeCarriers()->generateDemandElementID(SUMO_TAG_ROUTE);
1812  const std::string newVehicleID = net->getAttributeCarriers()->generateDemandElementID(originalVehicle->getTagProperty().getTag());
1813  // create vehicle using vehicleParameters
1814  if (originalVehicle->getTagProperty().vehicleRoute()) {
1815  newRoute = new GNERoute(net, newRouteID, originalVehicle->getParentDemandElements().at(1));
1816  newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1817  originalVehicle->getParentDemandElements().at(0), newRoute,
1818  originalVehicle->getSUMOVehicleParameter());
1819  } else if (originalVehicle->getTagProperty().vehicleRouteEmbedded()) {
1820  newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1821  originalVehicle->getParentDemandElements().at(0),
1822  originalVehicle->getSUMOVehicleParameter());
1823  newEmbeddedRoute = new GNERoute(net, newVehicle, originalVehicle->getChildDemandElements().front());
1824  } else if (originalVehicle->getTagProperty().vehicleEdges()) {
1825  newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1826  originalVehicle->getParentDemandElements().at(0),
1827  originalVehicle->getParentEdges().front(),
1828  originalVehicle->getParentEdges().back(),
1829  originalVehicle->getSUMOVehicleParameter());
1830  } else if (originalVehicle->getTagProperty().vehicleJunctions()) {
1831  newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1832  originalVehicle->getParentDemandElements().at(0),
1833  originalVehicle->getParentJunctions().front(),
1834  originalVehicle->getParentJunctions().back(),
1835  originalVehicle->getSUMOVehicleParameter());
1836  } else if (originalVehicle->getTagProperty().vehicleTAZs()) {
1837  newVehicle = new GNEVehicle(originalVehicle->getTagProperty().getTag(), net,
1838  originalVehicle->getParentDemandElements().at(0),
1839  originalVehicle->getParentAdditionals().front(),
1840  originalVehicle->getParentAdditionals().back(),
1841  originalVehicle->getSUMOVehicleParameter());
1842  }
1843  // set new ID
1844  newVehicle->setAttribute(SUMO_ATTR_ID, newVehicleID);
1845  // add new vehicle
1846  undoList->begin(originalVehicle, TLF("copy % '%'", newVehicle->getTagStr(), newVehicleID));
1847  if (newRoute) {
1848  net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newRoute, true), true);
1849  }
1850  undoList->add(new GNEChange_DemandElement(newVehicle, true), true);
1851  if (newEmbeddedRoute) {
1852  net->getViewNet()->getUndoList()->add(new GNEChange_DemandElement(newEmbeddedRoute, true), true);
1853  }
1854  undoList->end();
1855  return newVehicle;
1856 }
1857 
1858 // ===========================================================================
1859 // protected
1860 // ===========================================================================
1861 
1862 RGBColor
1864  // change color
1865  if (drawUsingSelectColor()) {
1867  } else {
1868  // obtain vehicle color
1869  const GUIColorer& c = s.vehicleColorer;
1870  // set color depending of vehicle color active
1871  switch (c.getActive()) {
1872  case 0: {
1873  // test for emergency vehicle
1874  if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "emergency") {
1875  return RGBColor::WHITE;
1876  }
1877  // test for firebrigade
1878  if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "firebrigade") {
1879  return RGBColor::RED;
1880  }
1881  // test for police car
1882  if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "police") {
1883  return RGBColor::BLUE;
1884  }
1885  if (getTypeParent()->getAttribute(SUMO_ATTR_GUISHAPE) == "scooter") {
1886  return RGBColor::WHITE;
1887  }
1888  // check if color was set
1889  if (wasSet(VEHPARS_COLOR_SET)) {
1890  return color;
1891  } else {
1892  // take their parent's color)
1893  return getTypeParent()->getColor();
1894  }
1895  }
1896  case 2: {
1897  if (wasSet(VEHPARS_COLOR_SET)) {
1898  return color;
1899  } else {
1900  return c.getScheme().getColor(0);
1901  }
1902  }
1903  case 3: {
1905  return getTypeParent()->getColor();
1906  } else {
1907  return c.getScheme().getColor(0);
1908  }
1909  break;
1910  }
1911  case 4: {
1913  return getRouteParent()->getColor();
1914  } else {
1915  return c.getScheme().getColor(0);
1916  }
1917  }
1918  case 5: {
1919  Position p = getRouteParent()->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1920  const Boundary& b = myNet->getBoundary();
1921  Position center = b.getCenter();
1922  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1923  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1924  return RGBColor::fromHSV(hue, sat, 1.);
1925  }
1926  case 6: {
1927  Position p = getRouteParent()->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1928  const Boundary& b = myNet->getBoundary();
1929  Position center = b.getCenter();
1930  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1931  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1932  return RGBColor::fromHSV(hue, sat, 1.);
1933  }
1934  case 7: {
1935  Position pb = getRouteParent()->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1936  Position pe = getRouteParent()->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1937  const Boundary& b = myNet->getBoundary();
1938  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1939  Position minp(b.xmin(), b.ymin());
1940  Position maxp(b.xmax(), b.ymax());
1941  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1942  return RGBColor::fromHSV(hue, sat, 1.);
1943  }
1944  case 35: { // color randomly (by pointer hash)
1945  std::hash<const GNEVehicle*> ptr_hash;
1946  const double hue = (double)(ptr_hash(this) % 360); // [0-360]
1947  const double sat = (double)((ptr_hash(this) / 360) % 67) / 100. + 0.33; // [0.33-1]
1948  return RGBColor::fromHSV(hue, sat, 1.);
1949  }
1950  default: {
1951  return c.getScheme().getColor(0);
1952  }
1953  }
1954  }
1955 }
1956 
1957 
1958 const SUMOVehicleParameter&
1960  return *this;
1961 }
1962 
1963 // ===========================================================================
1964 // private
1965 // ===========================================================================
1966 
1967 void
1968 GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1969  // declare string error
1970  std::string error;
1971  // flag to upate stack label
1972  bool updateSpreadStackGeometry = false;
1973  switch (key) {
1974  case SUMO_ATTR_ID:
1975  // update microsimID
1976  setDemandElementID(value);
1977  // set manually vehicle ID (needed for saving)
1978  id = value;
1979  break;
1980  case SUMO_ATTR_TYPE:
1981  if (getID().size() > 0) {
1982  if (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr) {
1984  } else {
1986  }
1987  // set manually vtypeID (needed for saving)
1988  vtypeid = value;
1989  }
1990  break;
1991  case SUMO_ATTR_COLOR:
1992  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1993  color = parse<RGBColor>(value);
1994  // mark parameter as set
1996  } else {
1997  // set default value
1998  color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1999  // unset parameter
2001  }
2002  break;
2003  case SUMO_ATTR_DEPARTLANE:
2004  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2006  // mark parameter as set
2008  } else {
2009  // set default value
2011  // unset parameter
2013  }
2014  break;
2015  case SUMO_ATTR_DEPARTPOS:
2016  if (value == toString(INVALID_DOUBLE)) {
2018  // mark parameter as set
2020  } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2022  // mark parameter as set
2024  } else {
2025  // set default value
2027  // unset parameter
2029  }
2030  if (getID().size() > 0) {
2031  updateGeometry();
2032  updateSpreadStackGeometry = true;
2033  }
2034  break;
2035  case SUMO_ATTR_DEPARTSPEED:
2036  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2038  // mark parameter as set
2040  } else {
2041  // set default value
2043  // unset parameter
2045  }
2046  break;
2047  case SUMO_ATTR_ARRIVALLANE:
2048  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2050  // mark parameter as set
2052  } else {
2053  // set default value
2055  // unset parameter
2057  }
2058  break;
2059  case SUMO_ATTR_ARRIVALPOS:
2060  if (value == toString(INVALID_DOUBLE)) {
2062  // mark parameter as set
2064  } else if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2066  // mark parameter as set
2068  } else {
2069  // set default value
2071  // unset parameter
2073  }
2074  if (getID().size() > 0) {
2075  updateGeometry();
2076  updateSpreadStackGeometry = true;
2077  }
2078  break;
2080  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2082  // mark parameter as set
2084  } else {
2085  // set default value
2087  // unset parameter
2089  }
2090  break;
2091  case SUMO_ATTR_LINE:
2092  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2093  line = value;
2094  // mark parameter as set
2096  } else {
2097  // set default value
2099  // unset parameter
2101  }
2102  break;
2104  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2105  personNumber = parse<int>(value);
2106  // mark parameter as set
2108  } else {
2109  // set default value
2110  personNumber = parse<int>(myTagProperty.getDefaultValue(key));
2111  // unset parameter
2113  }
2114  break;
2116  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2117  containerNumber = parse<int>(value);
2118  // mark parameter as set
2120  } else {
2121  // set default value
2122  containerNumber = parse<int>(myTagProperty.getDefaultValue(key));
2123  // unset parameter
2125  }
2126  break;
2127  case SUMO_ATTR_REROUTE:
2128  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2129  // mark parameter as set
2131  } else {
2132  // unset parameter
2134  }
2135  break;
2137  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2139  // mark parameter as set
2141  } else {
2142  // set default value
2144  // unset parameter
2146  }
2147  break;
2149  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
2151  // mark parameter as set
2153  } else {
2154  // set default value
2156  // unset parameter
2158  }
2160  break;
2162  parseInsertionChecks(value);
2163  break;
2164  // Specific of vehicles over routes
2165  case SUMO_ATTR_ROUTE:
2166  if (getParentDemandElements().size() == 2) {
2168  }
2169  updateGeometry();
2170  updateSpreadStackGeometry = true;
2171  break;
2172  // Specific of from-to edges
2173  case SUMO_ATTR_FROM: {
2174  // change first edge
2175  replaceFirstParentEdge(value);
2176  // compute vehicle
2178  updateSpreadStackGeometry = true;
2179  break;
2180  }
2181  case SUMO_ATTR_TO: {
2182  // change last edge
2183  replaceLastParentEdge(value);
2184  // compute vehicle
2186  updateSpreadStackGeometry = true;
2187  break;
2188  }
2189  case SUMO_ATTR_VIA: {
2190  if (!value.empty()) {
2191  // set new via edges
2192  via = parse< std::vector<std::string> >(value);
2193  // mark parameter as set
2195  } else {
2196  // clear via
2197  via.clear();
2198  // unset parameter
2200  }
2201  // compute vehicle
2203  updateSpreadStackGeometry = true;
2204  break;
2205  }
2206  case SUMO_ATTR_DEPARTEDGE: {
2207  // update depart edge
2208  if (value.empty()) {
2209  // unset parameter
2211  departEdge = -1;
2213  } else {
2214  // mark parameter as set
2216  departEdge = parse<int>(value);
2218  }
2219  // compute vehicle
2220  if (getID().size() > 0) {
2222  updateSpreadStackGeometry = true;
2223  }
2224  break;
2225  }
2226  case SUMO_ATTR_ARRIVALEDGE: {
2227  // update arrival edge
2228  if (value.empty()) {
2229  // unset parameter
2231  arrivalEdge = -1;
2233  } else {
2234  // mark parameter as set
2236  arrivalEdge = parse<int>(value);
2238  }
2239  if (getID().size() > 0) {
2240  // compute vehicle
2242  updateSpreadStackGeometry = true;
2243  }
2244  break;
2245  }
2246  // Specific of from-to junctions
2247  case SUMO_ATTR_FROM_JUNCTION: {
2248  // change first junction
2250  // compute vehicle
2252  updateSpreadStackGeometry = true;
2253  break;
2254  }
2255  case SUMO_ATTR_TO_JUNCTION: {
2256  // change last junction
2258  // compute vehicle
2260  updateSpreadStackGeometry = true;
2261  break;
2262  }
2263  // Specific of from-to TAZs
2264  case SUMO_ATTR_FROM_TAZ: {
2265  // change first additional
2267  // set taz manually
2268  fromTaz = value;
2269  // compute vehicle
2271  updateSpreadStackGeometry = true;
2272  break;
2273  }
2274  case SUMO_ATTR_TO_TAZ: {
2275  // change last additional
2277  // set taz manually
2278  toTaz = value;
2279  // compute vehicle
2281  updateSpreadStackGeometry = true;
2282  break;
2283  }
2284  // other
2285  case GNE_ATTR_SELECTED:
2286  if (parse<bool>(value)) {
2288  } else {
2290  }
2291  break;
2292  case GNE_ATTR_PARAMETERS:
2293  setParametersStr(value);
2294  break;
2295  default:
2296  setFlowAttribute(this, key, value);
2297  break;
2298  }
2299  // check if stack label has to be updated
2300  if (updateSpreadStackGeometry) {
2301  if (myTagProperty.vehicleEdges()) {
2302  getParentEdges().front()->updateVehicleStackLabels();
2303  getParentEdges().front()->updateVehicleSpreadGeometries();
2304  } else if (myTagProperty.vehicleRoute()) {
2305  getRouteParent()->getParentEdges().front()->updateVehicleStackLabels();
2306  getRouteParent()->getParentEdges().front()->updateVehicleSpreadGeometries();
2307  } else if (myTagProperty.vehicleRouteEmbedded()) {
2308  getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2309  getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2310  }
2311  }
2312 }
2313 
2314 
2315 void
2317  // toggle flow attributes
2318  toggleFlowAttribute(key, value);
2319 }
2320 
2321 
2322 void
2324  if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2326  // change depart
2329  departPos = moveResult.newFirstPos;
2330  }
2333  // change arrival
2336  arrivalPos = moveResult.newFirstPos;
2337  }
2338  // set lateral offset
2340  // update geometry
2341  updateGeometry();
2342 }
2343 
2344 
2345 void
2347  // reset lateral offset
2349  // check value
2350  if (moveResult.newFirstPos != INVALID_DOUBLE) {
2351  // continue depending if we're moving first or last position
2353  // begin change attribute
2354  undoList->begin(this, TLF("departPos of %", getTagStr()));
2355  // now set departPos
2356  setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2357  // check if depart lane has to be changed
2358  if (moveResult.newFirstLane) {
2359  // set new depart lane
2360  setAttribute(SUMO_ATTR_DEPARTLANE, toString(moveResult.newFirstLane->getIndex()), undoList);
2361  }
2362  } else {
2363  // begin change attribute
2364  undoList->begin(this, TLF("arrivalPos of %", getTagStr()));
2365  // now set arrivalPos
2366  setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newFirstPos), undoList);
2367  // check if arrival lane has to be changed
2368  if (moveResult.newFirstLane) {
2369  // set new arrival lane
2371  }
2372  }
2373  }
2374  // end change attribute
2375  undoList->end();
2376 }
2377 
2378 /****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ DEMAND_TYPE
Mode for editing types.
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_EMBEDDED
transform vehicle to flow over junctions
Definition: GUIAppEnum.h:1369
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_TAZS
transform vehicle to flow over TAZs
Definition: GUIAppEnum.h:1377
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE_EMBEDDED
transform vehicle to vehicle over junctions
Definition: GUIAppEnum.h:1367
@ MID_GNE_VEHICLE_TRANSFORM_ROUTEFLOW
transform vehicle to flow over route
Definition: GUIAppEnum.h:1365
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_JUNCTIONS
transform vehicle to trip over junctions
Definition: GUIAppEnum.h:1371
@ MID_GNE_VEHICLE_TRANSFORM_TRIP_TAZS
transform vehicle to trip over TAZs
Definition: GUIAppEnum.h:1375
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:453
@ MID_GNE_VEHICLE_TRANSFORM_TRIP
transform vehicle to trip
Definition: GUIAppEnum.h:1359
@ MID_GNE_VEHICLE_TRANSFORM_FLOW
transform vehicle to flow
Definition: GUIAppEnum.h:1361
@ MID_GNE_VEHICLE_TRANSFORM_VEHICLE
transform vehicle to vehicle over route
Definition: GUIAppEnum.h:1363
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:451
@ MID_GNE_VEHICLE_TRANSFORM_FLOW_JUNCTIONS
transform vehicle to flow over jucntions
Definition: GUIAppEnum.h:1373
@ GLO_TRIP
a trip
@ GLO_ROUTEFLOW
a routeFlow
@ GLO_FLOW
a flow
@ GLO_VEHICLE
a vehicle
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
@ TRIP_JUNCTIONS
@ FLOW_JUNCTIONS
#define RAD2DEG(x)
Definition: GeomHelper.h:36
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const int VEHPARS_DEPARTEDGE_SET
const int VEHPARS_ARRIVALEDGE_SET
@ GIVEN
The edge index is given.
@ DEFAULT
No information given; use default.
const int VEHPARS_ROUTE_SET
const int VEHPARS_COLOR_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
const int VEHPARS_TO_TAZ_SET
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
@ GIVEN
The arrival lane is given.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_ARRIVALPOSLAT_SET
const int VEHPARS_FROM_TAZ_SET
const int VEHPARS_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
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
const int VEHPARS_VIA_SET
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions
@ GNE_TAG_TRIP_TAZS
a single trip definition that uses TAZs
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ GNE_TAG_FLOW_TAZS
a flow between TAZs
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route
@ GNE_TAG_ROUTE_EMBEDDED
embedded route
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ GNE_ATTR_PLAN_GEOMETRY_STARTPOS
person/container geometry start position
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_DEPARTPOS_LAT
@ SUMO_ATTR_TO_JUNCTION
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_MINGAP
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_LINE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_FROM_TAZ
@ SUMO_ATTR_DEPARTLANE
@ GNE_ATTR_PLAN_GEOMETRY_ENDPOS
person/container geometry end position
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_INSERTIONCHECKS
@ SUMO_ATTR_WIDTH
const double INVALID_DOUBLE
invalid double
Definition: StdDefs.h:64
T MIN2(T a, T b)
Definition: StdDefs.h:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:49
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
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:319
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:655
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
Definition: GLHelper.cpp:347
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:295
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition: GLHelper.cpp:540
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:788
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
bool isTemplate() const
check if this AC is template
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const
calculate contour extruded (used in elements formed by a central shape)
Definition: GNEContour.cpp:88
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double scale) const
calculate contour (for rectangled elements)
Definition: GNEContour.cpp:103
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:263
void toggleFlowAttribute(const SumoXMLAttr attribute, const bool value)
toggle flow parameters (used in toggleAttribute(...) function of vehicles, persons and containers
void drawFlowLabel(const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw flow label
void disableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
bool isFlowAttributeEnabled(SumoXMLAttr key) const
double getFlowAttributeDouble(SumoXMLAttr key) const
bool isValidFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value)
void writeFlowAttributes(const GNEDemandElement *flowElement, OutputDevice &device) const
write flow attributes
void enableFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, GNEUndoList *undoList)
std::string getFlowAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier and adapted to GNEDemandElementFlow
void setFlowAttribute(GNEDemandElement *flowElement, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void buildMenuCommandRouteLength(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
void drawStackLabel(const int number, const std::string &element, const Position &position, const double rotation, const double width, const double length, const double exaggeration) const
draw stack label
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
virtual double getAttributeDouble(SumoXMLAttr key) const =0
bool isValidDemandElementID(const std::string &value) const
check if a new demand element ID is valid
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
void drawJunctionLine(const GNEDemandElement *element) const
draw line between junctions
void replaceFirstParentAdditional(SumoXMLTag tag, const std::string &value)
replace the first parent additional
GNEDemandElement * getRouteParent() const
get route parent (always the second parent demand element)
void setDemandElementID(const std::string &newID)
set demand element id
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void buildMenuAddReverse(GUIGLObjectPopupMenu *ret) const
build menu command route length
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
GNEDemandElement * getTypeParent() const
get type parent (needed because first parent can be either type or typeDistribution)
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
virtual const RGBColor & getColor() const =0
get color
Problem
enum class for demandElement problems
void replaceLastParentAdditional(SumoXMLTag tag, const std::string &value)
replace the last parent additional
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:1047
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:1442
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:214
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:684
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:642
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition: GNELane.cpp:208
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:196
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
bool getAllowChangeLane() const
allow change lane
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEDemandElement * retrieveDemandElements(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:139
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:133
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2022
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &edges) const
calculate Dijkstra path between a list of edges (for example, from-via-to edges)
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutive edges for the given VClass
bool checkDrawPathGeometry(const GUIVisualizationSettings &s, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
PathElement()=delete
invalidate default constructor
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getContour() const
getcontour associated with segment
const GNELane * getNextLane() const
get next lane
const GNELane * getLane() const
get lane associated with this segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
PathDraw * getPathDraw()
obtain instance of PathDraw
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
void calculatePath(PathElement *pathElement, SUMOVehicleClass vClass, GNELane *fromLane, GNELane *toLane)
calculate path between from-to edges (using dijkstra, require path calculator updated)
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToFlowJunctions(GNEVehicle *originalVehicle)
transform to flow over junctions
static void transformToTripJunctions(GNEVehicle *originalVehicle)
transform to trip over junctions
static void transformToFlowTAZs(GNEVehicle *originalVehicle)
transform to flow over TAZs
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
static void transformToTripTAZs(GNEVehicle *originalVehicle)
transform to trip over TAZs
bool isFlow() const
return true if tag correspond to a flow element
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool vehicleJunctions() const
return true if tag correspond to a vehicle placed over from-to junctions
bool isCalibrator() const
return true if tag correspond to a calibrator (Only used to group all detectors in the XML)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool vehicleRouteEmbedded() const
return true if tag correspond to a vehicle placed over an embedded route
bool vehicleEdges() const
return true if tag correspond to a vehicle placed over from-to edges
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
bool vehicleTAZs() const
return true if tag correspond to a vehicle placed over from-to TAZs
bool vehicleRoute() const
plan parents
GNEDemandElement * getCurrentType() const
get current Vehicle Type
TypeSelector * getTypeSelector() const
get vehicle type selector
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:62
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:193
long onCmdTransform(FXObject *obj, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:312
std::map< FXObject *, SumoXMLTag > myRestrictedMenuCommands
selected menu commands
Definition: GNEVehicle.h:89
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:35
long onCmdTransform(FXObject *, FXSelector sel, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:151
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:62
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:58
const Parameterised::Map & getACParametersMap() const
get parameters map
GNELane * getLastPathLane() const
get last path lane
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
Definition: GNEVehicle.cpp:832
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:717
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:838
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:542
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:816
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:974
GNEContour myVehicleContour
variable used for draw vehicle contours
Definition: GNEVehicle.h:302
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:538
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:853
bool isAttributeEnabled(SumoXMLAttr key) const
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:729
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be written into XML (by default true, can be reimplemente...
Definition: GNEVehicle.cpp:631
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:312
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void splitEdgeGeometry(const double splitPosition, const GNENetworkElement *originalElement, const GNENetworkElement *newElement, GNEUndoList *undoList)
split geometry
Definition: GNEVehicle.cpp:847
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
Definition: GNEVehicle.cpp:781
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:795
const SUMOVehicleParameter & getSUMOVehicleParameter() const
@brier get sumo vehicle parameter
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:735
Position getAttributePosition(SumoXMLAttr key) const
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:675
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:775
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform demand element changes
void toggleAttribute(SumoXMLAttr key, const bool value)
method for enable or disable the attribute and nothing else (used in GNEChange_ToggleAttribute)
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
RGBColor setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void writeDemandElement(OutputDevice &device) const
write demand element element into a xml file
Definition: GNEVehicle.cpp:570
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:437
SUMOVehicleClass getVClass() const
obtain VClass related with this demand element
Definition: GNEVehicle.cpp:723
static GNEDemandElement * copyVehicle(const GNEVehicle *originalVehicle)
create a copy of the given vehicle
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:715
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:538
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:721
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNETypeFrame * getTypeFrame() const
get frame for DEMAND_TYPE
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
Definition: GUIDesigns.cpp:42
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
Definition: GUIGlObject.h:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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
GUIVisualizationWidthSettings widthSettings
width settings
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawMinGap
Information whether the minimum gap shall be drawn.
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationTextSettings personName
double angle
The current view rotation angle.
static const std::vector< SumoXMLTag > types
type namespace
Definition: NamespaceIDs.h:53
static const std::vector< SumoXMLTag > vehicles
vehicles namespace
Definition: NamespaceIDs.h:59
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
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:254
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:276
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:317
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:271
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:261
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition: Position.h:266
double x() const
Returns the x-position.
Definition: Position.h:55
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition: Position.h:281
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
Definition: RGBColor.h:192
static const RGBColor BLUE
Definition: RGBColor.h:187
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:371
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:199
static const RGBColor RED
named colors
Definition: RGBColor.h:185
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
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
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.
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
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int arrivalEdge
(optional) The final edge within the route of the vehicle
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
RouteIndexDefinition departEdgeProcedure
Information how the vehicle's initial edge shall be chosen.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
#define M_PI
Definition: odrSpiral.cpp:45
bool showDemandElements() const
check if show demand elements checkbox is enabled
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showNonInspectedDemandElements(const GNEDemandElement *demandElement) const
check if non inspected element has to be hidden
bool showAllTrips() const
check if trips has to be drawn
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor vehicleTripColor
color for vehicle trips
RGBColor selectedVehicleColor
vehicle selection color
static const double segmentWidth
width of dotted contour segments
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size