Eclipse SUMO - Simulation of Urban MObility
GNEVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // Representation of vehicles in NETEDIT
19 /****************************************************************************/
20 #include <cmath>
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEUndoList.h>
24 #include <netedit/GNEViewNet.h>
25 #include <netedit/GNEViewParent.h>
29 #include <utils/gui/div/GLHelper.h>
34 
35 #include "GNEVehicle.h"
36 #include "GNERouteHandler.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 defintions
55 // ===========================================================================
57 
58 // ===========================================================================
59 // GNEVehicle::GNESingleVehiclePopupMenu
60 // ===========================================================================
61 
63  GUIGLObjectPopupMenu(app, parent, *vehicle),
64  myVehicle(vehicle),
65  myTransformToVehicle(nullptr),
66  myTransformToVehicleWithEmbeddedRoute(nullptr),
67  myTransformToRouteFlow(nullptr),
68  myTransformToRouteFlowWithEmbeddedRoute(nullptr),
69  myTransformToTrip(nullptr),
70  myTransformToFlow(nullptr) {
71  // build header
72  myVehicle->buildPopupHeader(this, app);
73  // build menu command for center button and copy cursor position to clipboard
75  myVehicle->buildPositionCopyEntry(this, false);
76  // buld menu commands for names
77  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
78  GUIDesigns::buildFXMenuCommand(this, ("Copy " + myVehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
79  new FXMenuSeparator(this);
80  // build selection and show parameters menu
83  // add transform functions only in demand mode
85  // Get icons
86  FXIcon* vehicleIcon = GUIIconSubSys::getIcon(GUIIcon::VEHICLE);
87  FXIcon* tripIcon = GUIIconSubSys::getIcon(GUIIcon::TRIP);
88  FXIcon* routeFlowIcon = GUIIconSubSys::getIcon(GUIIcon::ROUTEFLOW);
89  FXIcon* flowIcon = GUIIconSubSys::getIcon(GUIIcon::FLOW);
90  // create menu pane for transform operations
91  FXMenuPane* transformOperation = new FXMenuPane(this);
92  this->insertMenuPaneChild(transformOperation);
93  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
94  // Create menu comands for all transform
95  myTransformToVehicle = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicle", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
96  myTransformToVehicleWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicle (embedded route)", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
97  myTransformToRouteFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlow", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
98  myTransformToRouteFlowWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlow (embedded route)", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
99  myTransformToTrip = GUIDesigns::buildFXMenuCommand(transformOperation, "Trip", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
100  myTransformToFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "Flow", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
101  // check what menu command has to be disabled
103  myTransformToVehicle->disable();
106  } else if (myVehicle->getTagProperty().getTag() == GNE_TAG_FLOW_ROUTE) {
107  myTransformToRouteFlow->disable();
110  } else if (myVehicle->getTagProperty().getTag() == SUMO_TAG_TRIP) {
111  myTransformToTrip->disable();
112  } else if (myVehicle->getTagProperty().getTag() == SUMO_TAG_FLOW) {
113  myTransformToFlow->disable();
114  }
115  }
116 }
117 
118 
120 
121 
122 long
123 GNEVehicle::GNESingleVehiclePopupMenu::onCmdTransform(FXObject* obj, FXSelector, void*) {
124  if (obj == myTransformToVehicle) {
125  GNERouteHandler::transformToVehicle(myVehicle, false);
126  } else if (obj == myTransformToVehicleWithEmbeddedRoute) {
127  GNERouteHandler::transformToVehicle(myVehicle, true);
128  } else if (obj == myTransformToRouteFlow) {
129  GNERouteHandler::transformToRouteFlow(myVehicle, false);
130  } else if (obj == myTransformToRouteFlowWithEmbeddedRoute) {
131  GNERouteHandler::transformToRouteFlow(myVehicle, true);
132  } else if (obj == myTransformToTrip) {
134  } else if (obj == myTransformToFlow) {
136  }
137  return 1;
138 }
139 
140 // ===========================================================================
141 // GNEVehicle::GNESelectedVehiclesPopupMenu
142 // ===========================================================================
143 
144 GNEVehicle::GNESelectedVehiclesPopupMenu::GNESelectedVehiclesPopupMenu(GNEVehicle* vehicle, const std::vector<GNEVehicle*>& selectedVehicle, GUIMainWindow& app, GUISUMOAbstractView& parent) :
145  GUIGLObjectPopupMenu(app, parent, *vehicle),
146  mySelectedVehicles(selectedVehicle),
147  myVehicleTag(vehicle->getTagProperty().getTag()),
148  myTransformToVehicle(nullptr),
149  myTransformToVehicleWithEmbeddedRoute(nullptr),
150  myTransformToRouteFlow(nullptr),
151  myTransformToRouteFlowWithEmbeddedRoute(nullptr),
152  myTransformToTrip(nullptr),
153  myTransformToFlow(nullptr),
154  myTransformAllVehiclesToVehicle(nullptr),
155  myTransformAllVehiclesToVehicleWithEmbeddedRoute(nullptr),
156  myTransformAllVehiclesToRouteFlow(nullptr),
157  myTransformAllVehiclesToRouteFlowWithEmbeddedRoute(nullptr),
158  myTransformAllVehiclesToTrip(nullptr),
159  myTransformAllVehiclesToFlow(nullptr) {
160  // build header
161  vehicle->buildPopupHeader(this, app);
162  // build menu command for center button and copy cursor position to clipboard
163  vehicle->buildCenterPopupEntry(this);
164  vehicle->buildPositionCopyEntry(this, false);
165  // buld menu commands for names
166  GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " name to clipboard").c_str(), nullptr, this, MID_COPY_NAME);
167  GUIDesigns::buildFXMenuCommand(this, ("Copy " + vehicle->getTagStr() + " typed name to clipboard").c_str(), nullptr, this, MID_COPY_TYPED_NAME);
168  new FXMenuSeparator(this);
169  // build selection and show parameters menu
170  vehicle->getNet()->getViewNet()->buildSelectionACPopupEntry(this, vehicle);
171  vehicle->buildShowParamsPopupEntry(this);
172  // add transform functions only in demand mode
173  if (vehicle->getNet()->getViewNet()->getEditModes().isCurrentSupermodeDemand()) {
174  // Get icons
175  FXIcon* vehicleIcon = GUIIconSubSys::getIcon(GUIIcon::VEHICLE);
176  FXIcon* tripIcon = GUIIconSubSys::getIcon(GUIIcon::TRIP);
177  FXIcon* routeFlowIcon = GUIIconSubSys::getIcon(GUIIcon::ROUTEFLOW);
178  FXIcon* flowIcon = GUIIconSubSys::getIcon(GUIIcon::FLOW);
179  // create menu pane for transform operations
180  FXMenuPane* transformOperation = new FXMenuPane(this);
181  this->insertMenuPaneChild(transformOperation);
182  new FXMenuCascade(this, "transform to", nullptr, transformOperation);
183  // Create menu comands for all transform
185  "Vehicles (Only " + vehicle->getTagStr() + ")", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
187  "Vehicles (embedded route, only " + vehicle->getTagStr() + ")", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
189  "RouteFlows (Only " + vehicle->getTagStr() + ")", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
191  "RouteFlows (embedded route, only " + vehicle->getTagStr() + ")", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
193  "Trips (Only " + vehicle->getTagStr() + ")", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
195  "Flows (Only " + vehicle->getTagStr() + ")", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
196  // create separator
197  new FXMenuSeparator(transformOperation);
198  // Create menu comands for all transform all vehicles
199  myTransformAllVehiclesToVehicle = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicles", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
200  myTransformAllVehiclesToVehicleWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "Vehicles (embedded route)", vehicleIcon, this, MID_GNE_VEHICLE_TRANSFORM);
201  myTransformAllVehiclesToRouteFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlows", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
202  myTransformAllVehiclesToRouteFlowWithEmbeddedRoute = GUIDesigns::buildFXMenuCommand(transformOperation, "RouteFlows (embedded route)", routeFlowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
203  myTransformAllVehiclesToTrip = GUIDesigns::buildFXMenuCommand(transformOperation, "Trips", tripIcon, this, MID_GNE_VEHICLE_TRANSFORM);
204  myTransformAllVehiclesToFlow = GUIDesigns::buildFXMenuCommand(transformOperation, "Flows", flowIcon, this, MID_GNE_VEHICLE_TRANSFORM);
205  }
206 }
207 
208 
210 
211 
212 long
214  // iterate over all selected vehicles
215  for (const auto& vehicle : mySelectedVehicles) {
216  if ((obj == myTransformToVehicle) &&
217  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
218  GNERouteHandler::transformToVehicle(vehicle, false);
219  } else if ((obj == myTransformToVehicleWithEmbeddedRoute) &&
220  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
222  } else if ((obj == myTransformToRouteFlow) &&
223  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
225  } else if ((obj == myTransformToRouteFlowWithEmbeddedRoute) &&
226  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
228  } else if ((obj == myTransformToTrip) &&
229  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
231  } else if ((obj == myTransformToFlow) &&
232  (vehicle->getTagProperty().getTag() == myVehicleTag)) {
234  } else if (obj == myTransformAllVehiclesToVehicle) {
235  GNERouteHandler::transformToVehicle(vehicle, false);
236  } else if (obj == myTransformAllVehiclesToVehicleWithEmbeddedRoute) {
238  } else if (obj == myTransformAllVehiclesToRouteFlow) {
240  } else if (obj == myTransformAllVehiclesToRouteFlowWithEmbeddedRoute) {
242  } else if (obj == myTransformAllVehiclesToTrip) {
244  } else if (obj == myTransformAllVehiclesToFlow) {
246  }
247  }
248  return 1;
249 }
250 
251 // ===========================================================================
252 // member method definitions
253 // ===========================================================================
254 
257 {}, {}, {}, {}, {}, {}, {}, {}),
259  // reset default values
261  // set end and vehPerHours
264 }
265 
266 
267 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEDemandElement* route) :
268  GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT,
269 {}, {}, {}, {}, {}, {}, {vehicleType, route}, {}),
271  // SUMOVehicleParameter ID has to be set manually
272  id = vehicleID;
273  // set manually vtypeID (needed for saving)
274  vtypeid = vehicleType->getID();
275 }
276 
277 
278 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEDemandElement* route, const SUMOVehicleParameter& vehicleParameters) :
279  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_ROUTE) ? GLO_ROUTEFLOW : GLO_VEHICLE, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT,
280 {}, {}, {}, {}, {}, {}, {vehicleType, route}, {}),
281 SUMOVehicleParameter(vehicleParameters) {
282  // SUMOVehicleParameter ID has to be set manually
283  id = vehicleParameters.id;
284  // set manually vtypeID (needed for saving)
285  vtypeid = vehicleType->getID();
286 }
287 
288 
289 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, const SUMOVehicleParameter& vehicleParameters) :
290  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_VEHICLE_WITHROUTE) ? GLO_VEHICLE : GLO_ROUTEFLOW, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT,
291 {}, {}, {}, {}, {}, {}, {vehicleType}, {}),
292 SUMOVehicleParameter(vehicleParameters) {
293  // SUMOVehicleParameter ID has to be set manually
294  id = vehicleParameters.id;
295  // reset routeid
296  routeid.clear();
297  // set manually vtypeID (needed for saving)
298  vtypeid = vehicleType->getID();
299 }
300 
301 
302 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge,
303  const std::vector<GNEEdge*>& via) :
304  GNEDemandElement(vehicleID, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT,
305 {}, {fromEdge, toEdge}, {}, {}, {}, {}, {vehicleType}, {}),
307  // set via parameter without updating references
309 }
310 
311 
312 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEEdge* fromEdge, GNEEdge* toEdge, const std::vector<GNEEdge*>& via,
313  const SUMOVehicleParameter& vehicleParameters) :
314  GNEDemandElement(vehicleParameters.id, net, (tag == SUMO_TAG_FLOW) ? GLO_FLOW : GLO_TRIP, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT,
315 {}, {fromEdge, toEdge}, {}, {}, {}, {}, {vehicleType}, {}),
316 SUMOVehicleParameter(vehicleParameters) {
317  // set via parameter without updating references
319 }
320 
321 
322 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, const std::string& vehicleID, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction) :
323  GNEDemandElement(vehicleID, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
324  fromJunction, toJunction
325 }, {}, {}, {}, {}, {}, {vehicleType}, {}),
327 }
328 
329 
330 GNEVehicle::GNEVehicle(SumoXMLTag tag, GNENet* net, GNEDemandElement* vehicleType, GNEJunction* fromJunction, GNEJunction* toJunction, const SUMOVehicleParameter& vehicleParameters) :
331  GNEDemandElement(vehicleParameters.id, net, (tag == GNE_TAG_FLOW_JUNCTIONS) ? GLO_FLOW : GLO_TRIP, tag, GNEPathManager::PathElement::Options::DEMAND_ELEMENT, {
332  fromJunction, toJunction
333 }, {}, {}, {}, {}, {}, {vehicleType}, {}),
334 SUMOVehicleParameter(vehicleParameters) {
335 }
336 
337 
339 
340 
343  // get first and last lanes
344  const GNELane* firstLane = getFirstPathLane();
345  const GNELane* lastLane = getLastPathLane();
346  // get depart and arrival positions (doubles)
347  const double departPosDouble = getAttributeDouble(SUMO_ATTR_DEPARTPOS);
348  const double arrivalPosDouble = (getAttributeDouble(SUMO_ATTR_ARRIVALPOS) < 0) ? lastLane->getLaneShape().length2D() : getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
349  // obtain diameter
351  // return move operation depending if we're editing departPos or arrivalPos
353  return new GNEMoveOperation(this, firstLane, departPosDouble, lastLane, INVALID_DOUBLE,
357  return new GNEMoveOperation(this, firstLane, INVALID_DOUBLE, lastLane, arrivalPosDouble,
360  } else {
361  return nullptr;
362  }
363 }
364 
365 
366 std::string
368  // obtain depart
369  std::string departStr = depart < 0 ? "0.00" : time2string(depart);
370  // we need to handle depart as a tuple of 20 numbers (format: 000000...00<departTime>)
371  departStr.reserve(20 - departStr.size());
372  // add 0s at the beginning of departStr until we have 20 numbers
373  for (int i = (int)departStr.size(); i < 20; i++) {
374  departStr.insert(departStr.begin(), '0');
375  }
376  return departStr;
377 }
378 
379 
380 void
382  // attribute VType musn't be written if is DEFAULT_VTYPE_ID
383  if (getParentDemandElements().at(0)->getID() == DEFAULT_VTYPE_ID) {
384  // unset VType parameter
386  // write vehicle attributes (VType will not be written)
388  // set VType parameter again
390  } else {
391  // write vehicle attributes, including VType
393  }
394  // write specific attribute depeding of tag property
396  // write route
398  }
399  // write from, to and edge vias
401  // write manually from/to edges (it correspond to fron and back parent edges)
402  device.writeAttr(SUMO_ATTR_FROM, getParentEdges().front()->getID());
403  device.writeAttr(SUMO_ATTR_TO, getParentEdges().back()->getID());
404  // only write via if there isn't empty
405  if (via.size() > 0) {
406  device.writeAttr(SUMO_ATTR_VIA, via);
407  }
408  }
409  // write fronJunction and toJunction
411  // write manually from/to junctions (it correspond to fron and back parent junctions)
414  }
415  // write specific routeFlow/flow attributes
416  if (myTagProperty.isFlow()) {
417  // write routeFlow values depending if it was set
420  }
423  }
426  }
429  }
432  }
433  }
434  // write parameters
435  writeParams(device);
436  // write route elements associated to this vehicle
437  if (getChildDemandElements().size() > 0) {
438  if (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
439  // write embedded route
440  getChildDemandElements().front()->writeDemandElement(device);
441  // write sorted stops
442  const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
443  for (const auto& stop : sortedStops) {
444  stop->writeDemandElement(device);
445  }
446  } else {
447  for (const auto& route : getChildDemandElements()) {
448  route->writeDemandElement(device);
449  }
450  }
451  }
452  // close vehicle tag
453  device.closeTag();
454 }
455 
456 
459  // only trips or flows can have problems
461  // check path
462  if (myNet->getPathManager()->isPathValid(this)) {
463  return Problem::OK;
464  } else {
465  return Problem::INVALID_PATH;
466  }
468  return Problem::OK;
469  } else if (getParentDemandElements().size() == 2) {
470  // check if exist a valid path using route parent edges
472  return Problem::OK;
473  } else {
474  return Problem::INVALID_PATH;
475  }
476  } else if (getChildDemandElements().size() > 0 && (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED)) {
477  // get sorted stops and check number
478  std::vector<GNEDemandElement*> embeddedRouteStops;
479  for (const auto& routeChild : getChildDemandElements()) {
480  if (routeChild->getTagProperty().isStop()) {
481  embeddedRouteStops.push_back(routeChild);
482  }
483  }
484  const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
485  if (sortedStops.size() != embeddedRouteStops.size()) {
487  }
488  // check if exist a valid path using embebbed route edges
490  return Problem::OK;
491  } else {
492  return Problem::INVALID_PATH;
493  }
494  } else {
496  }
497 }
498 
499 
500 std::string
502  // only trips or flows can have problems
504  // check if exist at least a connection between every edge
505  for (int i = 1; i < (int)getParentEdges().size(); i++) {
507  return ("There is no valid path between edges '" + getParentEdges().at((int)i - 1)->getID() + "' and '" + getParentEdges().at(i)->getID() + "'");
508  }
509  }
510  // there is connections bewteen all edges, then all ok
511  return "";
512  } else if (getParentDemandElements().size() == 2) {
513  // get route parent edges
514  const std::vector<GNEEdge*>& routeEdges = getParentDemandElements().at(1)->getParentEdges();
515  // check if exist at least a connection between every edge
516  for (int i = 1; i < (int)routeEdges.size(); i++) {
517  if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getParentDemandElements().at(0)->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
518  return ("There is no valid path between route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
519  }
520  }
521  // there is connections bewteen all edges, then all ok
522  return "";
523  } else if (getChildDemandElements().size() > 0 && (getChildDemandElements().front()->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED)) {
524  // get sorted stops and check number
525  std::vector<GNEDemandElement*> embeddedRouteStops;
526  for (const auto& routeChild : getChildDemandElements()) {
527  if (routeChild->getTagProperty().isStop()) {
528  embeddedRouteStops.push_back(routeChild);
529  }
530  }
531  const auto sortedStops = getSortedStops(getChildDemandElements().front()->getParentEdges());
532  if (sortedStops.size() != embeddedRouteStops.size()) {
533  return toString(embeddedRouteStops.size() - sortedStops.size()) + " stops are outside of embedded route (downstream)";
534  }
535  // get embebbed route edges
536  const std::vector<GNEEdge*>& routeEdges = getChildDemandElements().front()->getParentEdges();
537  // check if exist at least a connection between every edge
538  for (int i = 1; i < (int)routeEdges.size(); i++) {
539  if (myNet->getPathManager()->getPathCalculator()->consecutiveEdgesConnected(getParentDemandElements().at(0)->getVClass(), routeEdges.at((int)i - 1), routeEdges.at(i)) == false) {
540  return ("There is no valid path between embebbed route edges '" + routeEdges.at((int)i - 1)->getID() + "' and '" + routeEdges.at(i)->getID() + "'");
541  }
542  }
543  // there is connections bewteen all edges, then all ok
544  return "";
545  } else {
546  return "";
547  }
548 }
549 
550 
551 void
553 
554 }
555 
556 
559  return getParentDemandElements().front()->getVClass();
560 }
561 
562 
563 const RGBColor&
565  return color;
566 }
567 
568 
569 void
571  if (getParentJunctions().size() > 0) {
572  // calculate rotation between both junctions
573  const Position posA = getParentJunctions().front()->getPositionInView();
574  const Position posB = getParentJunctions().back()->getPositionInView();
575  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) -180.0 / (double)M_PI);
576  // update Geometry
577  myDemandElementGeometry.updateSinglePosGeometry(getParentJunctions().front()->getPositionInView(), rot);
578  } else {
579  // get first path lane
580  const GNELane* firstPathLane = getFirstPathLane();
581  // check path lane
582  if (firstPathLane) {
583  // declare departPos
584  double posOverLane = 0;
585  if (canParse<double>(getDepartPos())) {
586  posOverLane = parse<double>(getDepartPos());
587  }
588  // update Geometry
590  // compute route embedded vinculated with this vehicle
591  for (const auto& demandElement : getChildDemandElements()) {
592  if (demandElement->getTagProperty().getTag() == GNE_TAG_ROUTE_EMBEDDED) {
593  demandElement->computePathElement();
594  }
595  demandElement->updateGeometry();
596  }
597  }
598  }
599 }
600 
601 
602 Position
604  return myDemandElementGeometry.getShape().front();
605 }
606 
607 
611  // obtain all selected vehicles
612  const auto selectedDemandElements = myNet->getAttributeCarriers()->getSelectedDemandElements();
613  std::vector<GNEVehicle*> selectedVehicles;
614  selectedVehicles.reserve(selectedDemandElements.size());
615  for (const auto& selectedDemandElement : selectedDemandElements) {
616  if (selectedDemandElement->getTagProperty().isVehicle()) {
617  selectedVehicles.push_back(dynamic_cast<GNEVehicle*>(selectedDemandElement));
618  }
619  }
620  // return a GNESelectedVehiclesPopupMenu
621  return new GNESelectedVehiclesPopupMenu(this, selectedVehicles, app, parent);
622  } else {
623  // return a GNESingleVehiclePopupMenu
624  return new GNESingleVehiclePopupMenu(this, app, parent);
625  }
626 }
627 
628 
629 std::string
632  return getParentDemandElements().at(1)->getID();
633  } else if ((myTagProperty.getTag() == SUMO_TAG_TRIP) || (myTagProperty.getTag() == SUMO_TAG_FLOW)) {
634  return getParentEdges().front()->getID();
635  } else {
636  throw ProcessError("Invalid vehicle tag");
637  }
638 }
639 
640 
641 double
643  return s.vehicleSize.getExaggeration(s, this);
644 }
645 
646 
647 Boundary
649  Boundary vehicleBoundary;
650  vehicleBoundary.add(myDemandElementGeometry.getShape().front());
651  vehicleBoundary.grow(20);
652  return vehicleBoundary;
653 }
654 
655 
656 void
657 GNEVehicle::splitEdgeGeometry(const double /*splitPosition*/, const GNENetworkElement* /*originalElement*/, const GNENetworkElement* /*newElement*/, GNEUndoList* /*undoList*/) {
658  // geometry of this element cannot be splitted
659 }
660 
661 
662 void
664  // only drawn in super mode demand
668  // declare common attributes
670  const double exaggeration = getExaggeration(s);
671  const double width = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_WIDTH);
672  const double length = getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
673  const double vehicleSizeSquared = (width * width) * (length * length) * (exaggeration * exaggeration);
674  // obtain Position an rotation (depending of draw spread vehicles)
675  if (drawSpreadVehicles && mySpreadGeometry.getShape().size() == 0) {
676  return;
677  }
678  const Position vehiclePosition = drawSpreadVehicles ? mySpreadGeometry.getShape().front() : myDemandElementGeometry.getShape().front();
679  const double vehicleRotation = drawSpreadVehicles ? mySpreadGeometry.getShapeRotations().front() : myDemandElementGeometry.getShapeRotations().front();
680  // check that position is valid
681  if (vehiclePosition != Position::INVALID) {
682  // first push name
684  // first check if if mouse is enought near to this vehicle to draw it
685  if (s.drawForRectangleSelection && (myNet->getViewNet()->getPositionInformation().distanceSquaredTo2D(vehiclePosition) >= (vehicleSizeSquared + 2))) {
686  // push draw matrix
688  // Start with the drawing of the area traslating matrix to origin
690  // translate to drawing position
691  glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
692  glRotated(vehicleRotation, 0, 0, -1);
693  // extra translation needed to draw vehicle over edge (to avoid selecting problems)
694  glTranslated(0, (-1) * length * exaggeration, 0);
695  GLHelper::drawBoxLine(Position(0, 1), 0, 2, 1);
696  // Pop last matrix
698  } else {
700  // push draw matrix
702  // Start with the drawing of the area traslating matrix to origin
704  // translate to drawing position
705  glTranslated(vehiclePosition.x(), vehiclePosition.y(), 0);
706  glRotated(vehicleRotation, 0, 0, -1);
707  // extra translation needed to draw vehicle over edge (to avoid selecting problems)
708  glTranslated(0, (-1) * length * exaggeration, 0);
709  // set lane color
710  setColor(s);
711  double upscaleLength = exaggeration;
712  if ((exaggeration > 1) && (length > 5)) {
713  // reduce the length/width ratio because this is not usefull at high zoom
714  upscaleLength = MAX2(1.0, upscaleLength * (5 + sqrt(length - 5)) / length);
715  }
716  glScaled(exaggeration, upscaleLength, 1);
717  // check if we're drawing in selecting mode
719  // draw vehicle as a box and don't draw the rest of details
721  } else {
722  // draw the vehicle depending of detail level
723  if (s.drawDetail(s.detailSettings.vehicleShapes, exaggeration)) {
725  } else if (s.drawDetail(s.detailSettings.vehicleBoxes, exaggeration)) {
727  } else if (s.drawDetail(s.detailSettings.vehicleTriangles, exaggeration)) {
729  }
730  // check if min gap has to be drawn
731  if (s.drawMinGap) {
732  const double minGap = -1 * getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_MINGAP);
733  glColor3d(0., 1., 0.);
734  glBegin(GL_LINES);
735  glVertex2d(0., 0);
736  glVertex2d(0., minGap);
737  glVertex2d(-.5, minGap);
738  glVertex2d(.5, minGap);
739  glEnd();
740  }
741  // drawing name at GLO_MAX fails unless translating z
742  glTranslated(0, MIN2(length / 2, double(5)), -getType());
743  glScaled(1 / exaggeration, 1 / upscaleLength, 1);
744  glRotated(vehicleRotation, 0, 0, -1);
746  // draw line
747  if (s.vehicleName.show(this) && line != "") {
748  glTranslated(0, 0.6 * s.vehicleName.scaledSize(s.scale), 0);
749  GLHelper::drawTextSettings(s.vehicleName, "line:" + line, Position(0, 0), s.scale, s.angle);
750  }
751  }
752  // pop draw matrix
754  // draw stack label
755  if ((myStackedLabelNumber > 0) && !drawSpreadVehicles) {
756  drawStackLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
757  }
758  // draw flow label
759  if (myTagProperty.isFlow()) {
760  drawFlowLabel(vehiclePosition, vehicleRotation, width, length, exaggeration);
761  }
762  // draw lock icon
763  GNEViewNetHelper::LockIcon::drawLockIcon(this, getType(), vehiclePosition, exaggeration);
764  // check if dotted contours has to be drawn
766  // draw using drawDottedContourClosedShape
767  GUIDottedGeometry::drawDottedSquaredShape(GUIDottedGeometry::DottedContourType::INSPECT, s, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
768  // draw junction line
770  }
771  if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
772  // draw using drawDottedContourClosedShape
773  GUIDottedGeometry::drawDottedSquaredShape(GUIDottedGeometry::DottedContourType::FRONT, s, vehiclePosition, length * 0.5, width * 0.5, length * -0.5, 0, vehicleRotation, exaggeration);
774  // draw junction line
776  }
777  }
778  // pop name
780  }
781  }
782 }
783 
784 
785 void
787  // calculate path (only for flows and trips)
788  if (getParentJunctions().size() > 0) {
789  // currently disabled
790  } else if ((myTagProperty.getTag() == SUMO_TAG_FLOW) || (myTagProperty.getTag() == SUMO_TAG_TRIP)) {
791  // declare lane stops
792  std::vector<GNELane*> laneStops;
793  // iterate over child demand elements
794  for (const auto& demandElement : getChildDemandElements()) {
795  // extract lanes
796  if (demandElement->getTagProperty().getTag() == SUMO_TAG_STOP_LANE) {
797  laneStops.push_back(demandElement->getParentLanes().front());
798  } else if (demandElement->getTagProperty().getTag() == SUMO_TAG_STOP_BUSSTOP) {
799  laneStops.push_back(demandElement->getParentAdditionals().front()->getParentLanes().front());
800  }
801  }
802  // declare lane vector
803  std::vector<GNELane*> lanes;
804  // get first and last lanes
805  GNELane* firstLane = getFirstPathLane();
806  GNELane* lastLane = getLastPathLane();
807  // check first and last lanes
808  if (firstLane && lastLane) {
809  // add first lane
810  lanes.push_back(getFirstPathLane());
811  // noch check if there are lane Stops
812  if (laneStops.size() > 0) {
813  // add stop lanes
814  for (const auto& laneStop : laneStops) {
815  lanes.push_back(laneStop);
816  }
817  } else {
818  // add via lanes
819  for (int i = 1; i < ((int)getParentEdges().size() - 1); i++) {
820  lanes.push_back(getParentEdges().at(i)->getLaneByAllowedVClass(getVClass()));
821  }
822  }
823  // add last lane
824  lanes.push_back(getLastPathLane());
825  // calculate path
826  myNet->getPathManager()->calculatePathLanes(this, getVClass(), lanes);
827  }
828  }
829  // update geometry
830  updateGeometry();
831 }
832 
833 
834 void
835 GNEVehicle::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* lane, const GNEPathManager::Segment* segment, const double offsetFront) const {
836  // get flags
837  const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this);
838  const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
841  const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
843  // check conditions
844  if (!s.drawForRectangleSelection &&
845  (drawNetworkMode || drawDemandMode || dottedElement || isAttributeCarrierSelected()) &&
846  myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, lane, myTagProperty.getTag())) {
847  // calculate width
848  const double width = s.vehicleSize.getExaggeration(s, lane) * s.widthSettings.tripWidth;
849  // calculate startPos
850  const double geometryDepartPos = getAttributeDouble(SUMO_ATTR_DEPARTPOS) + getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_LENGTH);
851  // get endPos
852  const double geometryEndPos = getAttributeDouble(SUMO_ATTR_ARRIVALPOS);
853  // declare path geometry
854  GUIGeometry vehicleGeometry;
855  // update pathGeometry depending of first and last segment
856  if (segment->isFirstSegment() && segment->isLastSegment()) {
857  vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
858  geometryDepartPos, geometryEndPos, // extrem positions
859  Position::INVALID, Position::INVALID); // extra positions
860  } else if (segment->isFirstSegment()) {
861  vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
862  geometryDepartPos, -1, // extrem positions
863  Position::INVALID, Position::INVALID); // extra positions
864  } else if (segment->isLastSegment()) {
865  vehicleGeometry.updateGeometry(lane->getLaneGeometry().getShape(),
866  -1, geometryEndPos, // extrem positions
867  Position::INVALID, Position::INVALID); // extra positions
868  } else {
869  vehicleGeometry = lane->getLaneGeometry();
870  }
871  // obtain color
873  // Start drawing adding an gl identificator
875  // Add a draw matrix
877  // Start with the drawing of the area traslating matrix to origin
878  glTranslated(0, 0, getType() + offsetFront);
879  // Set color
880  GLHelper::setColor(pathColor);
881  // draw geometry
882  GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), vehicleGeometry, width);
883  // Pop last matrix
885  // Draw name if isn't being drawn for selecting
886  if (!s.drawForRectangleSelection) {
887  drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
888  }
889  // check if we have to draw a red line to the next segment
890  if (segment->getNextSegment()) {
891  // push draw matrix
893  // Start with the drawing of the area traslating matrix to origin
895  // Set red color
897  // get firstPosition (last position of current lane shape)
898  const Position& firstPosition = lane->getLaneShape().back();
899  // get lastPosition (first position of next lane shape)
900  const Position& arrivalPosition = segment->getNextSegment()->getPathElement()->getPathElementArrivalPos();
901  // draw box line
902  GLHelper::drawBoxLine(arrivalPosition,
903  RAD2DEG(firstPosition.angleTo2D(arrivalPosition)) - 90,
904  firstPosition.distanceTo2D(arrivalPosition), .05);
905  // pop draw matrix
907  }
908  // check if this is the last segment
909  if (segment->isLastSegment()) {
910  // get geometryEndPos
911  const Position geometryEndPosition = getPathElementArrivalPos();
912  // check if endPos can be drawn
914  // push draw matrix
916  // Start with the drawing of the area traslating matrix to origin
918  // translate to geometryEndPos
919  glTranslated(geometryEndPosition.x(), geometryEndPosition.y(), 0);
920  // Set person plan color
921  GLHelper::setColor(pathColor);
922  // resolution of drawn circle depending of the zoom (To improve smothness)
924  // pop draw matrix
926  }
927  }
928  // Pop name
930  // check if shape dotted contour has to be drawn
931  if (dottedElement) {
932  // declare trim geometry to draw
933  const auto shape = (segment->isFirstSegment() || segment->isLastSegment() ? vehicleGeometry.getShape() : lane->getLaneShape());
934  // draw inspected dotted contour
937  }
938  // draw front dotted contour
939  if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
941  }
942  }
943  }
944 }
945 
946 
947 void
948 GNEVehicle::drawPartialGL(const GUIVisualizationSettings& s, const GNELane* fromLane, const GNELane* toLane, const GNEPathManager::Segment* /*segment*/, const double offsetFront) const {
949  // get flags
950  const bool dottedElement = myNet->getViewNet()->isAttributeCarrierInspected(this) || (myNet->getViewNet()->getFrontAttributeCarrier() == this);
951  const bool drawNetworkMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
954  const bool drawDemandMode = myNet->getViewNet()->getEditModes().isCurrentSupermodeDemand() &&
956  // check conditions
957  if (!s.drawForRectangleSelection &&
958  fromLane->getLane2laneConnections().exist(toLane) &&
959  (drawNetworkMode || drawDemandMode || dottedElement || isAttributeCarrierSelected()) &&
960  myNet->getPathManager()->getPathDraw()->drawPathGeometry(dottedElement, fromLane, toLane, myTagProperty.getTag())) {
961  // Start drawing adding an gl identificator
963  // obtain lane2lane geometry
964  const GUIGeometry& lane2laneGeometry = fromLane->getLane2laneConnections().getLane2laneGeometry(toLane);
965  // calculate width
966  const double width = s.vehicleSize.getExaggeration(s, fromLane) * s.widthSettings.tripWidth;
967  // Add a draw matrix
969  // Start with the drawing of the area traslating matrix to origin
970  glTranslated(0, 0, getType() + offsetFront);
971  // Set color of the base
972  if (drawUsingSelectColor()) {
974  } else {
976  }
977  // draw lane2lane
978  GUIGeometry::drawGeometry(s, myNet->getViewNet()->getPositionInformation(), lane2laneGeometry, width);
979  // Pop last matrix
981  // check if shape dotted contour has to be drawn
982  if (dottedElement) {
983  // check if exist lane2lane connection
984  if (fromLane->getLane2laneConnections().exist(toLane)) {
985  // draw inspected dotted contour
988  width, 1, false, false, 0.1);
989  }
990  // draw front dotted contour
991  if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
993  width, 1, false, false, 0.1);
994  }
995  }
996  }
997  // Pop name
999  }
1000 }
1001 
1002 
1003 GNELane*
1005  // declare first edge
1006  GNEEdge* firstEdge = nullptr;
1007  // continue depending of tags
1009  // check departEdge
1010  if ((departEdge > 0) && (departEdge < (int)getParentDemandElements().at(1)->getParentEdges().size())) {
1011  // use departEdge
1012  firstEdge = getParentDemandElements().at(1)->getParentEdges().at(departEdge);
1013  } else {
1014  // use first route edge
1015  firstEdge = getParentDemandElements().at(1)->getParentEdges().front();
1016  }
1018  // check if embebbed route exist (due during loading embedded route doesn't exist
1019  if (getChildDemandElements().empty()) {
1020  return nullptr;
1021  }
1022  // check departEdge
1023  if ((departEdge > 0) && (departEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1024  // use depart edge
1025  firstEdge = getChildDemandElements().front()->getParentEdges().at(departEdge);
1026  } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1027  firstEdge = getChildDemandElements().front()->getParentEdges().front();
1028  } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1029  firstEdge = getChildDemandElements().front()->getParentLanes().front()->getParentEdge();
1030  } else {
1031  return nullptr;
1032  }
1033  } else {
1034  // use first parent edge
1035  firstEdge = getParentEdges().front();
1036  }
1037  // get departLane index
1038  const int departLaneIndex = canParse<int>(getAttribute(SUMO_ATTR_DEPARTLANE)) ? parse<int>(getAttribute(SUMO_ATTR_DEPARTLANE)) : -1;
1039  // check departLane index
1040  if ((departLaneIndex >= 0) && (departLaneIndex < (int)firstEdge->getLanes().size())) {
1041  return firstEdge->getLanes().at(departLaneIndex);
1042  } else {
1043  // get first allowed VClass
1044  return firstEdge->getLaneByAllowedVClass(getVClass());
1045  }
1046 }
1047 
1048 
1049 GNELane*
1051  // declare last edge
1052  GNEEdge* lastEdge = nullptr;
1053  // continue depending of tags
1055  // check arrivalEdge
1056  if ((arrivalEdge > 0) && (arrivalEdge < (int)getParentDemandElements().at(1)->getParentEdges().size())) {
1057  // use arrival edge
1058  lastEdge = getParentDemandElements().at(1)->getParentEdges().at(arrivalEdge);
1059  } else {
1060  // use last route edge
1061  lastEdge = getParentDemandElements().at(1)->getParentEdges().back();
1062  }
1064  // check if embebbed route exist (due during loading embedded route doesn't exist)
1065  if (getChildDemandElements().empty()) {
1066  return nullptr;
1067  }
1068  // check arrivalEdge
1069  if ((arrivalEdge > 0) && (arrivalEdge < (int)getChildDemandElements().front()->getParentEdges().size())) {
1070  // use arrival edge
1071  lastEdge = getChildDemandElements().front()->getParentEdges().at(arrivalEdge);
1072  } else if (getChildDemandElements().front()->getParentEdges().size() > 0) {
1073  // use last route edge
1074  lastEdge = getChildDemandElements().front()->getParentEdges().back();
1075  } else if (getChildDemandElements().front()->getParentLanes().size() > 0) {
1076  // use lane
1077  lastEdge = getChildDemandElements().front()->getParentLanes().back()->getParentEdge();
1078  } else {
1079  return nullptr;
1080  }
1081  } else {
1082  // use last parent edge
1083  lastEdge = getParentEdges().back();
1084  }
1085  // get arrivalLane index
1086  const int arrivalLaneIndex = canParse<int>(getAttribute(SUMO_ATTR_ARRIVALLANE)) ? parse<int>(getAttribute(SUMO_ATTR_ARRIVALLANE)) : -1;
1087  // check arrivalLane index
1088  if ((arrivalLaneIndex >= 0) && (arrivalLaneIndex < (int)lastEdge->getLanes().size())) {
1089  return lastEdge->getLanes().at(arrivalLaneIndex);
1090  } else {
1091  // get last allowed VClass
1092  return lastEdge->getLaneByAllowedVClass(getVClass());
1093  }
1094 }
1095 
1096 
1097 std::string
1099  switch (key) {
1100  case SUMO_ATTR_ID:
1101  return getID();
1102  case SUMO_ATTR_TYPE:
1103  return getParentDemandElements().at(0)->getID();
1104  case SUMO_ATTR_COLOR:
1105  if (wasSet(VEHPARS_COLOR_SET)) {
1106  return toString(color);
1107  } else {
1109  }
1110  case SUMO_ATTR_DEPARTLANE:
1112  return getDepartLane();
1113  } else {
1115  }
1116  case SUMO_ATTR_DEPARTPOS:
1118  return getDepartPos();
1119  } else {
1121  }
1122  case SUMO_ATTR_DEPARTSPEED:
1124  return getDepartSpeed();
1125  } else {
1127  }
1128  case SUMO_ATTR_ARRIVALLANE:
1130  return getArrivalLane();
1131  } else {
1133  }
1134  case SUMO_ATTR_ARRIVALPOS:
1136  return getArrivalPos();
1137  } else {
1139  }
1142  return getArrivalSpeed();
1143  } else {
1145  }
1146  case SUMO_ATTR_LINE:
1147  if (wasSet(VEHPARS_LINE_SET)) {
1148  return line;
1149  } else {
1151  }
1154  return toString(personNumber);
1155  } else {
1157  }
1160  return toString(containerNumber);
1161  } else {
1163  }
1164  case SUMO_ATTR_REROUTE:
1166  return "true";
1167  } else {
1168  return "false";
1169  }
1172  return getDepartPosLat();
1173  } else {
1175  }
1178  return getArrivalPosLat();
1179  } else {
1181  }
1182  // Specific of vehicles
1183  case SUMO_ATTR_DEPART:
1184  return time2string(depart);
1185  case SUMO_ATTR_ROUTE:
1186  if (getParentDemandElements().size() == 2) {
1187  return getParentDemandElements().at(1)->getID();
1188  } else {
1189  return "";
1190  }
1191  // Specific of from-to edge
1192  case SUMO_ATTR_FROM:
1193  return getParentEdges().front()->getID();
1194  case SUMO_ATTR_TO:
1195  return getParentEdges().back()->getID();
1196  case SUMO_ATTR_VIA:
1197  return toString(via);
1198  case SUMO_ATTR_DEPARTEDGE:
1199  if (departEdge == -1) {
1200  return "";
1201  } else {
1202  return toString(departEdge);
1203  }
1204  case SUMO_ATTR_ARRIVALEDGE:
1205  if (arrivalEdge == -1) {
1206  return "";
1207  } else {
1208  return toString(arrivalEdge);
1209  }
1210  // Specific of from-to junctions
1212  return getParentJunctions().front()->getID();
1213  case SUMO_ATTR_TOJUNCTION:
1214  return getParentJunctions().back()->getID();
1215  // Specific of flows
1216  case SUMO_ATTR_BEGIN:
1217  return time2string(depart);
1218  case SUMO_ATTR_END:
1219  return time2string(repetitionEnd);
1220  case SUMO_ATTR_VEHSPERHOUR:
1221  return toString(3600 / STEPS2TIME(repetitionOffset));
1222  case SUMO_ATTR_PERIOD:
1223  return time2string(repetitionOffset);
1224  case SUMO_ATTR_PROB:
1226  case SUMO_ATTR_NUMBER:
1227  return toString(repetitionNumber);
1228  // other
1229  case GNE_ATTR_SELECTED:
1231  case GNE_ATTR_PARAMETERS:
1232  return getParametersStr();
1234  return toString(parametersSet);
1235  default:
1236  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1237  }
1238 }
1239 
1240 
1241 double
1243  switch (key) {
1244  case SUMO_ATTR_DEPART:
1245  case SUMO_ATTR_BEGIN:
1246  return STEPS2TIME(depart);
1247  case SUMO_ATTR_DEPARTPOS:
1248  // only return departPos it if is given
1250  return departPos;
1251  } else {
1252  return 0;
1253  }
1254  case SUMO_ATTR_ARRIVALPOS:
1255  // only return departPos it if is given
1257  return arrivalPos;
1258  } else {
1259  return -1;
1260  }
1261  case SUMO_ATTR_WIDTH:
1262  case SUMO_ATTR_LENGTH:
1263  case SUMO_ATTR_MINGAP:
1264  return getParentDemandElements().at(0)->getAttributeDouble(key);
1265  default:
1266  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1267  }
1268 }
1269 
1270 
1271 Position
1273  switch (key) {
1274  case SUMO_ATTR_DEPARTPOS: {
1275  // get first path lane shape
1276  const PositionVector& laneShape = getFirstPathLane()->getLaneShape();
1277  // check arrivalPosProcedure
1279  if (departPos < 0) {
1280  return laneShape.front();
1281  } else if (departPos > laneShape.length2D()) {
1282  return laneShape.back();
1283  } else {
1284  return laneShape.positionAtOffset2D(departPos);
1285  }
1286  } else {
1287  return laneShape.front();
1288  }
1289  }
1290  case SUMO_ATTR_ARRIVALPOS: {
1291  // get last path lane shape
1292  const PositionVector& laneShape = getLastPathLane()->getLaneShape();
1293  // check arrivalPosProcedure
1295  if (arrivalPos < 0) {
1296  return laneShape.front();
1297  } else if (arrivalPos > laneShape.length2D()) {
1298  return laneShape.back();
1299  } else {
1300  return laneShape.positionAtOffset2D(arrivalPos);
1301  }
1302  } else {
1303  return laneShape.back();
1304  }
1305  }
1306  default:
1307  throw InvalidArgument(getTagStr() + " doesn't have a double attribute of type '" + toString(key) + "'");
1308  }
1309 }
1310 
1311 
1312 void
1313 GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1314  if (value == getAttribute(key)) {
1315  return; //avoid needless changes, later logic relies on the fact that attributes have changed
1316  }
1317  switch (key) {
1318  case SUMO_ATTR_ID:
1319  case SUMO_ATTR_TYPE:
1320  case SUMO_ATTR_COLOR:
1321  case SUMO_ATTR_DEPARTLANE:
1322  case SUMO_ATTR_DEPARTPOS:
1323  case SUMO_ATTR_DEPARTSPEED:
1324  case SUMO_ATTR_ARRIVALLANE:
1325  case SUMO_ATTR_ARRIVALPOS:
1327  case SUMO_ATTR_LINE:
1330  case SUMO_ATTR_REROUTE:
1333  // Specific of vehicles
1334  case SUMO_ATTR_DEPART:
1335  case SUMO_ATTR_ROUTE:
1336  // Specific of from-to edges
1337  case SUMO_ATTR_FROM:
1338  case SUMO_ATTR_TO:
1339  case SUMO_ATTR_VIA:
1340  case SUMO_ATTR_DEPARTEDGE:
1341  case SUMO_ATTR_ARRIVALEDGE:
1342  // Specific of from-to junctions
1344  case SUMO_ATTR_TOJUNCTION:
1345  // Specific of flows
1346  case SUMO_ATTR_BEGIN:
1347  case SUMO_ATTR_END:
1348  case SUMO_ATTR_NUMBER:
1349  case SUMO_ATTR_VEHSPERHOUR:
1350  case SUMO_ATTR_PERIOD:
1351  case SUMO_ATTR_PROB:
1352  // other
1353  case GNE_ATTR_PARAMETERS:
1354  case GNE_ATTR_SELECTED:
1355  undoList->changeAttribute(new GNEChange_Attribute(this, key, value));
1356  break;
1357  default:
1358  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1359  }
1360 }
1361 
1362 
1363 bool
1364 GNEVehicle::isValid(SumoXMLAttr key, const std::string& value) {
1365  // declare string error
1366  std::string error;
1367  switch (key) {
1368  case SUMO_ATTR_ID:
1369  // Vehicles, Trips and Flows share namespace
1371  (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VEHICLE, value, false) == nullptr) &&
1372  (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_TRIP, value, false) == nullptr) &&
1373  (myNet->getAttributeCarriers()->retrieveDemandElement(GNE_TAG_FLOW_ROUTE, value, false) == nullptr) &&
1374  (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_FLOW, value, false) == nullptr)) {
1375  return true;
1376  } else {
1377  return false;
1378  }
1379  case SUMO_ATTR_TYPE:
1380  return SUMOXMLDefinitions::isValidTypeID(value) && (myNet->getAttributeCarriers()->retrieveDemandElement(SUMO_TAG_VTYPE, value, false) != nullptr);
1381  case SUMO_ATTR_COLOR:
1382  return canParse<RGBColor>(value);
1383  case SUMO_ATTR_DEPARTLANE: {
1384  int dummyDepartLane;
1385  DepartLaneDefinition dummyDepartLaneProcedure;
1386  parseDepartLane(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartLane, dummyDepartLaneProcedure, error);
1387  // if error is empty, check if depart lane is correct
1388  if (error.empty()) {
1389  if (dummyDepartLaneProcedure != DepartLaneDefinition::GIVEN) {
1390  return true;
1391  } else {
1392  return dummyDepartLane < (int)getFirstPathLane()->getParentEdge()->getLanes().size();
1393  }
1394  } else {
1395  return false;
1396  }
1397  }
1398  case SUMO_ATTR_DEPARTPOS: {
1399  double dummyDepartPos;
1400  DepartPosDefinition dummyDepartPosProcedure;
1401  parseDepartPos(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPos, dummyDepartPosProcedure, error);
1402  // if error is empty, given value is valid
1403  return error.empty();
1404  }
1405  case SUMO_ATTR_DEPARTSPEED: {
1406  double dummyDepartSpeed;
1407  DepartSpeedDefinition dummyDepartSpeedProcedure;
1408  parseDepartSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartSpeed, dummyDepartSpeedProcedure, error);
1409  // if error is empty, check if depart speed is correct
1410  if (error.empty()) {
1411  if (dummyDepartSpeedProcedure != DepartSpeedDefinition::GIVEN) {
1412  return true;
1413  } else {
1414  return (dummyDepartSpeed <= getParentDemandElements().at(0)->getAttributeDouble(SUMO_ATTR_MAXSPEED));
1415  }
1416  } else {
1417  return false;
1418  }
1419  }
1420  case SUMO_ATTR_ARRIVALLANE: {
1421  int dummyArrivalLane;
1422  ArrivalLaneDefinition dummyArrivalLaneProcedure;
1423  parseArrivalLane(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalLane, dummyArrivalLaneProcedure, error);
1424  // if error is empty, given value is valid
1425  return error.empty();
1426  }
1427  case SUMO_ATTR_ARRIVALPOS: {
1428  double dummyArrivalPos;
1429  ArrivalPosDefinition dummyArrivalPosProcedure;
1430  parseArrivalPos(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPos, dummyArrivalPosProcedure, error);
1431  // if error is empty, given value is valid
1432  return error.empty();
1433  }
1434  case SUMO_ATTR_ARRIVALSPEED: {
1435  double dummyArrivalSpeed;
1436  ArrivalSpeedDefinition dummyArrivalSpeedProcedure;
1437  parseArrivalSpeed(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalSpeed, dummyArrivalSpeedProcedure, error);
1438  // if error is empty, given value is valid
1439  return error.empty();
1440  }
1441  case SUMO_ATTR_LINE:
1442  return true;
1444  return canParse<int>(value) && parse<int>(value) >= 0;
1446  return canParse<int>(value) && parse<int>(value) >= 0;
1447  case SUMO_ATTR_REROUTE:
1448  return true; // check
1449  case SUMO_ATTR_DEPARTPOS_LAT: {
1450  double dummyDepartPosLat;
1451  DepartPosLatDefinition dummyDepartPosLatProcedure;
1452  parseDepartPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyDepartPosLat, dummyDepartPosLatProcedure, error);
1453  // if error is empty, given value is valid
1454  return error.empty();
1455  }
1456  case SUMO_ATTR_ARRIVALPOS_LAT: {
1457  double dummyArrivalPosLat;
1458  ArrivalPosLatDefinition dummyArrivalPosLatProcedure;
1459  parseArrivalPosLat(value, toString(SUMO_TAG_VEHICLE), id, dummyArrivalPosLat, dummyArrivalPosLatProcedure, error);
1460  // if error is empty, given value is valid
1461  return error.empty();
1462  }
1463  // Specific of vehicles
1464  case SUMO_ATTR_DEPART: {
1465  SUMOTime dummyDepart;
1466  DepartDefinition dummyDepartProcedure;
1467  parseDepart(value, toString(SUMO_TAG_VEHICLE), id, dummyDepart, dummyDepartProcedure, error);
1468  // if error is empty, given value is valid
1469  return error.empty();
1470  }
1471  case SUMO_ATTR_ROUTE:
1472  if (getParentDemandElements().size() == 2) {
1474  } else {
1475  return true;
1476  }
1477  // Specific of from-to edges
1478  case SUMO_ATTR_FROM:
1479  case SUMO_ATTR_TO:
1480  return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveEdge(value, false) != nullptr);
1481  case SUMO_ATTR_DEPARTEDGE:
1482  case SUMO_ATTR_ARRIVALEDGE: {
1483  if (value.empty()) {
1484  return true;
1485  } else if (canParse<int>(value)) {
1486  // get index
1487  const int index = parse<int>(value);
1488  // check conditions
1489  if (index < 0) {
1490  return false;
1492  // check parent route
1493  return (index < (int)getParentDemandElements().at(1)->getParentEdges().size());
1494  } else {
1495  // check embedded route
1496  return (index < (int)getChildDemandElements().front()->getParentEdges().size());
1497  }
1498  } else {
1499  return false;
1500  }
1501  }
1502  case SUMO_ATTR_VIA:
1503  if (value.empty()) {
1504  return true;
1505  } else {
1506  return canParse<std::vector<GNEEdge*> >(myNet, value, false);
1507  }
1508  // Specific of from-to junctions
1510  case SUMO_ATTR_TOJUNCTION:
1511  return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveJunction(value, false) != nullptr);
1512  // Specific of flows
1513  case SUMO_ATTR_BEGIN:
1514  if (canParse<double>(value)) {
1515  return (parse<double>(value) >= 0);
1516  } else {
1517  return false;
1518  }
1519  case SUMO_ATTR_END:
1520  if (value.empty()) {
1521  return true;
1522  } else if (canParse<double>(value)) {
1523  return (parse<double>(value) >= 0);
1524  } else {
1525  return false;
1526  }
1527  case SUMO_ATTR_VEHSPERHOUR:
1528  if (value.empty()) {
1529  return true;
1530  } else if (canParse<double>(value)) {
1531  return (parse<double>(value) > 0);
1532  } else {
1533  return false;
1534  }
1535  case SUMO_ATTR_PERIOD:
1536  if (value.empty()) {
1537  return true;
1538  } else if (canParse<double>(value)) {
1539  return (parse<double>(value) > 0);
1540  } else {
1541  return false;
1542  }
1543  case SUMO_ATTR_PROB:
1544  if (value.empty()) {
1545  return true;
1546  } else if (canParse<double>(value)) {
1547  return (parse<double>(value) >= 0);
1548  } else {
1549  return false;
1550  }
1551  case SUMO_ATTR_NUMBER:
1552  if (canParse<int>(value)) {
1553  return (parse<int>(value) >= 0);
1554  } else {
1555  return false;
1556  }
1557  // other
1558  case GNE_ATTR_SELECTED:
1559  return canParse<bool>(value);
1560  case GNE_ATTR_PARAMETERS:
1561  return Parameterised::areParametersValid(value);
1562  default:
1563  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1564  }
1565 }
1566 
1567 
1568 void
1570  switch (key) {
1571  case SUMO_ATTR_END:
1572  case SUMO_ATTR_NUMBER:
1573  case SUMO_ATTR_VEHSPERHOUR:
1574  case SUMO_ATTR_PERIOD:
1575  case SUMO_ATTR_PROB:
1576  undoList->add(new GNEChange_EnableAttribute(this, key, true, parametersSet), true);
1577  return;
1578  default:
1579  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1580  }
1581 }
1582 
1583 
1584 void
1586  // nothing to disable
1587 }
1588 
1589 
1590 bool
1592  switch (key) {
1593  case SUMO_ATTR_END:
1594  return (parametersSet & VEHPARS_END_SET) != 0;
1595  case SUMO_ATTR_NUMBER:
1596  return (parametersSet & VEHPARS_NUMBER_SET) != 0;
1597  case SUMO_ATTR_VEHSPERHOUR:
1598  return (parametersSet & VEHPARS_VPH_SET) != 0;
1599  case SUMO_ATTR_PERIOD:
1600  return (parametersSet & VEHPARS_PERIOD_SET) != 0;
1601  case SUMO_ATTR_PROB:
1602  return (parametersSet & VEHPARS_PROB_SET) != 0;
1603  default:
1604  return true;
1605  }
1606 }
1607 
1608 
1609 std::string
1611  return getTagStr();
1612 }
1613 
1614 
1615 std::string
1617  // special case for Trips and flow
1619  // check if we're inspecting a Edge
1620  if (!myNet->getViewNet()->getInspectedAttributeCarriers().empty() &&
1621  myNet->getViewNet()->getInspectedAttributeCarriers().front()->getTagProperty().getTag() == SUMO_TAG_EDGE) {
1622  // check if edge correspond to a "from", "to" or "via" edge
1624  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (from)";
1625  } else if (myNet->getViewNet()->isAttributeCarrierInspected(getParentEdges().front())) {
1626  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (to)";
1627  } else {
1628  // iterate over via
1629  for (const auto& i : via) {
1630  if (i == myNet->getViewNet()->getInspectedAttributeCarriers().front()->getID()) {
1631  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID) + " (via)";
1632  }
1633  }
1634  }
1635  }
1636  }
1637  return getTagStr() + ": " + getAttribute(SUMO_ATTR_ID);
1638 }
1639 
1640 
1641 const std::map<std::string, std::string>&
1643  return getParametersMap();
1644 }
1645 
1646 // ===========================================================================
1647 // protected
1648 // ===========================================================================
1649 
1650 void
1652  // change color
1653  if (drawUsingSelectColor()) {
1655  } else {
1656  // obtain vehicle color
1657  const GUIColorer& c = s.vehicleColorer;
1658  // set color depending of vehicle color active
1659  switch (c.getActive()) {
1660  case 0: {
1661  // test for emergency vehicle
1662  if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "emergency") {
1664  break;
1665  }
1666  // test for firebrigade
1667  if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "firebrigade") {
1669  break;
1670  }
1671  // test for police car
1672  if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "police") {
1674  break;
1675  }
1676  if (getParentDemandElements().at(0)->getAttribute(SUMO_ATTR_GUISHAPE) == "scooter") {
1678  break;
1679  }
1680  // check if color was set
1681  if (wasSet(VEHPARS_COLOR_SET)) {
1683  break;
1684  } else {
1685  // take their parent's color)
1687  break;
1688  }
1689  }
1690  case 2: {
1691  if (wasSet(VEHPARS_COLOR_SET)) {
1693  } else {
1695  }
1696  break;
1697  }
1698  case 3: {
1701  } else {
1703  }
1704  break;
1705  }
1706  case 4: {
1709  } else {
1711  }
1712  break;
1713  }
1714  case 5: {
1715  Position p = getParentDemandElements().at(1)->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1716  const Boundary& b = myNet->getBoundary();
1717  Position center = b.getCenter();
1718  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1719  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1720  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1721  break;
1722  }
1723  case 6: {
1724  Position p = getParentDemandElements().at(1)->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1725  const Boundary& b = myNet->getBoundary();
1726  Position center = b.getCenter();
1727  double hue = 180. + atan2(center.x() - p.x(), center.y() - p.y()) * 180. / M_PI;
1728  double sat = p.distanceTo(center) / center.distanceTo(Position(b.xmin(), b.ymin()));
1729  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1730  break;
1731  }
1732  case 7: {
1733  Position pb = getParentDemandElements().at(1)->getParentEdges().at(0)->getLanes().at(0)->getLaneShape()[0];
1734  Position pe = getParentDemandElements().at(1)->getParentEdges().back()->getLanes().at(0)->getLaneShape()[-1];
1735  const Boundary& b = myNet->getBoundary();
1736  double hue = 180. + atan2(pb.x() - pe.x(), pb.y() - pe.y()) * 180. / M_PI;
1737  Position minp(b.xmin(), b.ymin());
1738  Position maxp(b.xmax(), b.ymax());
1739  double sat = pb.distanceTo(pe) / minp.distanceTo(maxp);
1740  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1741  break;
1742  }
1743  case 29: { // color randomly (by pointer hash)
1744  std::hash<const GNEVehicle*> ptr_hash;
1745  const double hue = (double)(ptr_hash(this) % 360); // [0-360]
1746  const double sat = ((ptr_hash(this) / 360) % 67) / 100.0 + 0.33; // [0.33-1]
1747  GLHelper::setColor(RGBColor::fromHSV(hue, sat, 1.));
1748  break;
1749  }
1750  default: {
1752  }
1753  }
1754  }
1755 }
1756 
1757 // ===========================================================================
1758 // private
1759 // ===========================================================================
1760 
1761 void
1762 GNEVehicle::setAttribute(SumoXMLAttr key, const std::string& value) {
1763  // declare string error
1764  std::string error;
1765  // flag to upate stack label
1766  bool updateSpreadStackGeometry = false;
1767  switch (key) {
1768  case SUMO_ATTR_ID:
1769  // update microsimID
1770  setMicrosimID(value);
1771  // set manually vehicle ID (needed for saving)
1772  id = value;
1773  // Change IDs of all person plans children (stops, embedded routes...)
1774  for (const auto& childDemandElement : getChildDemandElements()) {
1775  childDemandElement->setMicrosimID(getID());
1776  }
1777  break;
1778  case SUMO_ATTR_TYPE:
1779  if (getID().size() > 0) {
1781  // set manually vtypeID (needed for saving)
1782  vtypeid = value;
1783  }
1784  break;
1785  case SUMO_ATTR_COLOR:
1786  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1787  color = parse<RGBColor>(value);
1788  // mark parameter as set
1790  } else {
1791  // set default value
1792  color = parse<RGBColor>(myTagProperty.getDefaultValue(key));
1793  // unset parameter
1795  }
1796  break;
1797  case SUMO_ATTR_DEPARTLANE:
1798  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1800  // mark parameter as set
1802  } else {
1803  // set default value
1805  // unset parameter
1807  }
1808  break;
1809  case SUMO_ATTR_DEPARTPOS:
1810  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1812  // mark parameter as set
1814  } else {
1815  // set default value
1817  // unset parameter
1819  }
1820  if (getID().size() > 0) {
1821  updateGeometry();
1822  updateSpreadStackGeometry = true;
1823  }
1824  break;
1825  case SUMO_ATTR_DEPARTSPEED:
1826  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1828  // mark parameter as set
1830  } else {
1831  // set default value
1833  // unset parameter
1835  }
1836  break;
1837  case SUMO_ATTR_ARRIVALLANE:
1838  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1840  // mark parameter as set
1842  } else {
1843  // set default value
1845  // unset parameter
1847  }
1848  break;
1849  case SUMO_ATTR_ARRIVALPOS:
1850  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1852  // mark parameter as set
1854  } else {
1855  // set default value
1857  // unset parameter
1859  }
1860  if (getID().size() > 0) {
1861  updateGeometry();
1862  updateSpreadStackGeometry = true;
1863  }
1864  break;
1866  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1868  // mark parameter as set
1870  } else {
1871  // set default value
1873  // unset parameter
1875  }
1876  break;
1877  case SUMO_ATTR_LINE:
1878  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1879  line = value;
1880  // mark parameter as set
1882  } else {
1883  // set default value
1885  // unset parameter
1887  }
1888  break;
1890  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1891  personNumber = parse<int>(value);
1892  // mark parameter as set
1894  } else {
1895  // set default value
1896  personNumber = parse<int>(myTagProperty.getDefaultValue(key));
1897  // unset parameter
1899  }
1900  break;
1902  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1903  containerNumber = parse<int>(value);
1904  // mark parameter as set
1906  } else {
1907  // set default value
1908  containerNumber = parse<int>(myTagProperty.getDefaultValue(key));
1909  // unset parameter
1911  }
1912  break;
1913  case SUMO_ATTR_REROUTE:
1914  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1915  // mark parameter as set
1917  } else {
1918  // unset parameter
1920  }
1921  break;
1923  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1925  // mark parameter as set
1927  } else {
1928  // set default value
1930  // unset parameter
1932  }
1933  break;
1935  if (!value.empty() && (value != myTagProperty.getDefaultValue(key))) {
1937  // mark parameter as set
1939  } else {
1940  // set default value
1942  // unset parameter
1944  }
1946  break;
1947  // Specific of vehicles
1948  case SUMO_ATTR_DEPART: {
1950  break;
1951  }
1952  case SUMO_ATTR_ROUTE:
1953  if (getParentDemandElements().size() == 2) {
1955  }
1956  updateGeometry();
1957  updateSpreadStackGeometry = true;
1958  break;
1959  // Specific of from-to edges
1960  case SUMO_ATTR_FROM: {
1961  // change first edge
1962  replaceFirstParentEdge(value);
1963  // compute vehicle
1965  updateSpreadStackGeometry = true;
1966  break;
1967  }
1968  case SUMO_ATTR_TO: {
1969  // change last edge
1970  replaceLastParentEdge(value);
1971  // compute vehicle
1973  updateSpreadStackGeometry = true;
1974  break;
1975  }
1976  case SUMO_ATTR_VIA: {
1977  if (!value.empty()) {
1978  // set new via edges
1979  via = parse< std::vector<std::string> >(value);
1980  // mark parameter as set
1982  } else {
1983  // clear via
1984  via.clear();
1985  // unset parameter
1987  }
1988  // update via
1989  replaceMiddleParentEdges(value, true);
1990  // compute vehicle
1992  updateSpreadStackGeometry = true;
1993  break;
1994  }
1995  case SUMO_ATTR_DEPARTEDGE: {
1996  // update depart edge
1997  if (value.empty()) {
1998  departEdge = -1;
1999  } else {
2000  departEdge = parse<int>(value);
2001  }
2002  // compute vehicle
2003  if (getID().size() > 0) {
2005  updateSpreadStackGeometry = true;
2006  }
2007  break;
2008  }
2009  case SUMO_ATTR_ARRIVALEDGE: {
2010  // update arrival edge
2011  if (value.empty()) {
2012  arrivalEdge = 0;
2013  } else {
2014  arrivalEdge = parse<int>(value);
2015  }
2016  if (getID().size() > 0) {
2017  // compute vehicle
2019  updateSpreadStackGeometry = true;
2020  }
2021  break;
2022  }
2023  // Specific of from-to junctions
2024  case SUMO_ATTR_FROMJUNCTION: {
2025  // change first junction
2027  // compute vehicle
2029  updateSpreadStackGeometry = true;
2030  break;
2031  }
2032  case SUMO_ATTR_TOJUNCTION: {
2033  // change last junction
2035  // compute vehicle
2037  updateSpreadStackGeometry = true;
2038  break;
2039  }
2040  // Specific of flows
2041  case SUMO_ATTR_BEGIN: {
2042  depart = string2time(value);
2043  break;
2044  }
2045  case SUMO_ATTR_END:
2046  repetitionEnd = string2time(value);
2047  break;
2048  case SUMO_ATTR_VEHSPERHOUR:
2049  repetitionOffset = TIME2STEPS(3600 / parse<double>(value));
2050  break;
2051  case SUMO_ATTR_PERIOD:
2052  repetitionOffset = string2time(value);
2053  break;
2054  case SUMO_ATTR_PROB:
2055  repetitionProbability = parse<double>(value);
2056  break;
2057  case SUMO_ATTR_NUMBER:
2058  repetitionNumber = parse<int>(value);
2059  break;
2060  // other
2061  case GNE_ATTR_SELECTED:
2062  if (parse<bool>(value)) {
2064  } else {
2066  }
2067  break;
2068  case GNE_ATTR_PARAMETERS:
2069  setParametersStr(value);
2070  break;
2071  default:
2072  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
2073  }
2074  // check if stack label has to be updated
2075  if (updateSpreadStackGeometry) {
2077  getParentEdges().front()->updateVehicleStackLabels();
2078  getParentEdges().front()->updateVehicleSpreadGeometries();
2079  } else if (getParentDemandElements().size() == 2) {
2080  getParentDemandElements().at(1)->getParentEdges().front()->updateVehicleStackLabels();
2081  getParentDemandElements().at(1)->getParentEdges().front()->updateVehicleSpreadGeometries();
2082  } else if (getChildDemandElements().size() > 0) {
2083  getChildDemandElements().front()->getParentEdges().front()->updateVehicleStackLabels();
2084  getChildDemandElements().front()->getParentEdges().front()->updateVehicleSpreadGeometries();
2085  }
2086  }
2087 }
2088 
2089 
2090 void
2091 GNEVehicle::toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters) {
2092  if (value) {
2094  } else {
2095  parametersSet = previousParameters;
2096  }
2097 }
2098 
2099 
2100 void
2102  if ((moveResult.newFirstPos != INVALID_DOUBLE) &&
2104  // change depart
2106  departPos = moveResult.newFirstPos;
2107  }
2110  // change arrival
2112  arrivalPos = moveResult.newFirstPos;
2113  }
2114  // set lateral offset
2116  // update geometry
2117  updateGeometry();
2118 }
2119 
2120 
2121 void
2123  // reset lateral offset
2125  // check departPos
2126  if (moveResult.newFirstPos != INVALID_DOUBLE) {
2127  // begin change attribute
2128  undoList->begin(myTagProperty.getGUIIcon(), "departPos of " + getTagStr());
2129  // now set departPos
2130  setAttribute(SUMO_ATTR_DEPARTPOS, toString(moveResult.newFirstPos), undoList);
2131  // check if depart lane has to be changed
2132  if (moveResult.newFirstLane) {
2133  // set new depart lane
2134  setAttribute(SUMO_ATTR_DEPARTLANE, toString(moveResult.newFirstLane->getIndex()), undoList);
2135  }
2136  }
2137  // check arrivalPos
2138  if (moveResult.newSecondPos != INVALID_DOUBLE) {
2139  // begin change attribute
2140  undoList->begin(myTagProperty.getGUIIcon(), "arrivalPos of " + getTagStr());
2141  // now set arrivalPos
2142  setAttribute(SUMO_ATTR_ARRIVALPOS, toString(moveResult.newSecondPos), undoList);
2143  // check if arrival lane has to be changed
2144  if (moveResult.newSecondLane) {
2145  // set new arrival lane
2147  }
2148  }
2149  // end change attribute
2150  undoList->end();
2151 }
2152 
2153 
2154 void
2155 GNEVehicle::drawStackLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const {
2156  // declare contour width
2157  const double contourWidth = (0.05 * exaggeration);
2158  // Push matrix
2160  // Traslate to vehicle top
2161  glTranslated(vehiclePosition.x(), vehiclePosition.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW);
2162  glRotated(vehicleRotation, 0, 0, -1);
2163  glTranslated((width * exaggeration * 0.5) + (0.35 * exaggeration), 0, 0);
2164  // draw external box
2166  GLHelper::drawBoxLine(Position(), 0, (length * exaggeration), 0.3 * exaggeration);
2167  // draw internal box
2168  glTranslated(0, 0, 0.1);
2169  GLHelper::setColor(RGBColor(0, 128, 0));
2170  GLHelper::drawBoxLine(Position(0, -contourWidth), Position(0, -contourWidth), 0, (length * exaggeration) - (contourWidth * 2), (0.3 * exaggeration) - contourWidth);
2171  // draw stack label
2172  GLHelper::drawText("vehicles stacked: " + toString(myStackedLabelNumber), Position(0, length * exaggeration * -0.5), (.1 * exaggeration), (0.6 * exaggeration), RGBColor::WHITE, 90, 0, -1);
2173  // pop draw matrix
2175 }
2176 
2177 
2178 void
2179 GNEVehicle::drawFlowLabel(const Position& vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const {
2180  // declare contour width
2181  const double contourWidth = (0.05 * exaggeration);
2182  // Push matrix
2184  // Traslate to vehicle bot
2185  glTranslated(vehiclePosition.x(), vehiclePosition.y(), GLO_ROUTE + getType() + 0.1 + GLO_PERSONFLOW);
2186  glRotated(vehicleRotation, 0, 0, -1);
2187  glTranslated(-1 * ((width * 0.5 * exaggeration) + (0.35 * exaggeration)), 0, 0);
2188  // draw external box
2190  GLHelper::drawBoxLine(Position(), Position(), 0, (length * exaggeration), 0.3 * exaggeration);
2191  // draw internal box
2192  glTranslated(0, 0, 0.1);
2194  GLHelper::drawBoxLine(Position(0, -contourWidth), Position(0, -contourWidth), 0, (length * exaggeration) - (contourWidth * 2), (0.3 * exaggeration) - contourWidth);
2195  // draw stack label
2196  GLHelper::drawText("Flow", Position(0, length * exaggeration * -0.5), (.1 * exaggeration), (0.6 * exaggeration), RGBColor::BLACK, 90, 0, -1);
2197  // pop draw matrix
2199 }
2200 
2201 
2202 void
2204  // draw line for trip/flows junctions
2206  // get two points
2207  const Position posA = getParentJunctions().front()->getPositionInView();
2208  const Position posB = getParentJunctions().back()->getPositionInView();
2209  const double rot = ((double)atan2((posB.x() - posA.x()), (posA.y() - posB.y())) * (double) 180.0 / (double)M_PI);
2210  const double len = posA.distanceTo2D(posB);
2211  // push draw matrix
2213  // Start with the drawing of the area traslating matrix to origin
2215  // set trip color
2217  // draw line
2218  GLHelper::drawBoxLine(posA, rot, len, 0.25);
2219  // pop draw matrix
2221  }
2222 }
2223 
2224 /****************************************************************************/
FXDEFMAP(GNEVehicle::GNESingleVehiclePopupMenu) GNESingleVehiclePopupMenuMap[]
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:413
@ MID_GNE_VEHICLE_TRANSFORM
transform vehicle to another vehicle type (ej: flow to trip)
Definition: GUIAppEnum.h:1180
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:411
@ GLO_TRIP
a trip
@ GLO_ROUTEFLOW
a routeFlow
@ GLO_ROUTE
a route
@ GLO_FLOW
a flow
@ GLO_VEHICLE
a vehicle
@ GLO_PERSONFLOW
a person flow
#define RAD2DEG(x)
Definition: GeomHelper.h:36
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
const std::string DEFAULT_VTYPE_ID
const int VEHPARS_PROB_SET
const int VEHPARS_VPH_SET
const int VEHPARS_END_SET
const int VEHPARS_ROUTE_SET
const int VEHPARS_COLOR_SET
DepartLaneDefinition
Possible ways to choose a lane on depart.
@ GIVEN
The lane is given.
ArrivalSpeedDefinition
Possible ways to choose the arrival speed.
DepartPosLatDefinition
Possible ways to choose the lateral departure position.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
ArrivalLaneDefinition
Possible ways to choose the arrival lane.
const int VEHPARS_DEPARTPOS_SET
const int VEHPARS_CONTAINER_NUMBER_SET
const int VEHPARS_ARRIVALLANE_SET
DepartSpeedDefinition
Possible ways to choose the departure speed.
@ GIVEN
The speed is given.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_ARRIVALPOSLAT_SET
const int VEHPARS_NUMBER_SET
const int VEHPARS_ARRIVALSPEED_SET
ArrivalPosDefinition
Possible ways to choose the arrival position.
@ GIVEN
The arrival position is given.
const int VEHPARS_LINE_SET
const int VEHPARS_PERSON_NUMBER_SET
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_PERIOD_SET
ArrivalPosLatDefinition
Possible ways to choose the lateral arrival position.
const int VEHPARS_VTYPE_SET
const int VEHPARS_ARRIVALPOS_SET
DepartDefinition
Possible ways to depart.
const int VEHPARS_VIA_SET
const int VEHPARS_DEPARTPOSLAT_SET
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions (used in NETEDIT)
@ SUMO_TAG_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_STOP_LANE
stop placed over a lane (used in netedit)
@ SUMO_TAG_VEHICLE
description of a vehicle
@ GNE_TAG_FLOW_ROUTE
a flow definition using a route instead of a from-to edges route (used in NETEDIT)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions (used in NETEDIT)
@ GNE_TAG_FLOW_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_TAG_STOP_BUSSTOP
stop placed over a busStop (used in netedit)
@ GNE_TAG_VEHICLE_WITHROUTE
description of a vehicle with an embedded route (used in NETEDIT)
@ GNE_TAG_ROUTE_EMBEDDED
embedded route (used in NETEDIT)
@ SUMO_TAG_TRIP
a single trip definition (used by router)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_NUMBER
@ SUMO_ATTR_ARRIVALSPEED
@ SUMO_ATTR_ARRIVALLANE
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_DEPARTEDGE
@ SUMO_ATTR_VEHSPERHOUR
@ SUMO_ATTR_ARRIVALEDGE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_FROMJUNCTION
@ SUMO_ATTR_DEPARTPOS_LAT
@ GNE_ATTR_FLOWPARAMETERS
flow parameters (integer for mask end, number, etc...)
@ SUMO_ATTR_ARRIVALPOS
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_MINGAP
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_CONTAINER_NUMBER
@ SUMO_ATTR_LINE
@ SUMO_ATTR_DEPARTPOS
@ SUMO_ATTR_GUISHAPE
@ SUMO_ATTR_REROUTE
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_DEPARTSPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_DEPARTLANE
@ SUMO_ATTR_PROB
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_PERSON_NUMBER
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_MAXSPEED
@ SUMO_ATTR_ID
@ SUMO_ATTR_ARRIVALPOS_LAT
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_TOJUNCTION
const double INVALID_DOUBLE
Definition: StdDefs.h:63
T MIN2(T a, T b)
Definition: StdDefs.h:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
const double SUMO_const_halfLaneWidth
Definition: StdDefs.h:50
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:111
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:132
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:231
static void popName()
pop Name
Definition: GLHelper.cpp:141
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:609
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:640
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_EnableAttribute
friend class GNEChange_Attribute
declare friend class
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get tagProperty associated with this Attribute Carrier
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void resetDefaultValues()
reset attribute carrier to their default values
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
An Element which don't belongs to GNENet but has influency in the simulation.
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
Position getPathElementArrivalPos() const
get path element arrival position
GUIGeometry myDemandElementGeometry
demand element geometry (also called "stacked geometry")
void replaceLastParentEdge(const std::string &value)
replace the last parent edge
GUIGeometry mySpreadGeometry
demand element spread geometry (Only used by vehicles and pedestrians)
void replaceFirstParentJunction(const std::string &value)
replace the first parent junction
std::vector< const GNEDemandElement * > getSortedStops(const std::vector< GNEEdge * > &edges) const
get sorted stops
void replaceFirstParentEdge(const std::string &value)
replace the first parent edge
int myStackedLabelNumber
stacked label number
Problem
enum class for demandElement problems
void replaceMiddleParentEdges(const std::string &value, const bool updateChildReferences)
replace middle (via) parent edges
void replaceLastParentJunction(const std::string &value)
replace the last parent junction
const std::string & getID() const
get ID
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:782
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:1144
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given tolane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:131
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition: GNELane.cpp:838
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:797
const GUIGeometry & getLaneGeometry() const
Definition: GNELane.cpp:125
GNEEdge * getParentEdge() const
get arent edge
Definition: GNELane.cpp:113
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
bool getAllowChangeLane() const
allow change lane
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
move result
const GNELane * newFirstLane
new first Lane
double newFirstPos
new first position
const GNELane * newSecondLane
new second Lane
const GNEMoveOperation::OperationType operationType
move operation
double firstLaneOffset
lane offset
double newSecondPos
new second position
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
std::vector< GNEDemandElement * > getSelectedDemandElements() const
get selected demand elements
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GNENet.cpp:137
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:131
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1964
bool consecutiveEdgesConnected(const SUMOVehicleClass vClass, const GNEEdge *from, const GNEEdge *to) const
check if exist a path between the two given consecutives edges for the given VClass
std::vector< GNEEdge * > calculateDijkstraPath(const SUMOVehicleClass vClass, const std::vector< GNEEdge * > &partialEdges) const
calculate Dijkstra path between a list of partial edges
bool drawPathGeometry(const bool dottedElement, const GNELane *lane, SumoXMLTag tag)
check if path element geometry must be drawn in the given lane
PathElement()
default constructor
virtual Position getPathElementArrivalPos() const =0
get path element arrival position
PathElement * getPathElement() const
get path element
Segment * getNextSegment() const
get next segment
bool isLastSegment() const
check if segment is the last path's segment
bool isFirstSegment() const
check if segment is the first path's segment
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
PathDraw * getPathDraw()
obtain instance of PathDraw
void calculatePathLanes(PathElement *pathElement, SUMOVehicleClass vClass, const std::vector< GNELane * > lanes)
calculate path lanes (using dijkstra, require path calculator updated)
bool isPathValid(const PathElement *pathElement) const
check if path element is valid
static void transformToRouteFlow(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform routeFlow over an existent route
static void transformToFlow(GNEVehicle *originalVehicle)
transform to flow
static void setFlowParameters(const SumoXMLAttr attribute, int &parameters)
set flow parameters
static void transformToTrip(GNEVehicle *originalVehicle)
transform to trip
static void transformToVehicle(GNEVehicle *originalVehicle, bool createEmbeddedRoute)
transform vehicle functions
bool isFlow() const
return true if tag correspond to a flow element
GUIIcon getGUIIcon() const
get GUI icon associated to this Tag
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
SumoXMLTag getXMLTag() const
get XML tag
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:82
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:213
GNESelectedVehiclesPopupMenu(GNEVehicle *vehicle, const std::vector< GNEVehicle * > &selectedVehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:144
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:121
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:112
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:115
FXMenuCommand * myTransformAllVehiclesToVehicleWithEmbeddedRoute
menu command for transform all selected vehicles to vehicle with an embedded route
Definition: GNEVehicle.h:133
FXMenuCommand * myTransformAllVehiclesToRouteFlow
menu command for transform all selected vehicles to route flow
Definition: GNEVehicle.h:136
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:124
FXMenuCommand * myTransformAllVehiclesToTrip
menu command for transform all selected vehicles to trip
Definition: GNEVehicle.h:142
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:127
FXMenuCommand * myTransformAllVehiclesToVehicle
menu command for transform all selected vehicles to vehicle
Definition: GNEVehicle.h:130
FXMenuCommand * myTransformAllVehiclesToFlow
menu command for transform all selected vehicles to flow
Definition: GNEVehicle.h:145
FXMenuCommand * myTransformAllVehiclesToRouteFlowWithEmbeddedRoute
menu command for transform all selected vehicles to route flow with an embedded route
Definition: GNEVehicle.h:139
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:118
class used in GUIGLObjectPopupMenu for single vehicle transformations
Definition: GNEVehicle.h:37
GNESingleVehiclePopupMenu(GNEVehicle *vehicle, GUIMainWindow &app, GUISUMOAbstractView &parent)
Constructor.
Definition: GNEVehicle.cpp:62
FXMenuCommand * myTransformToVehicle
menu command for transform to vehicle
Definition: GNEVehicle.h:63
GNEVehicle * myVehicle
current vehicle
Definition: GNEVehicle.h:60
long onCmdTransform(FXObject *obj, FXSelector, void *)
Called to transform the current vehicle to another vehicle type.
Definition: GNEVehicle.cpp:123
FXMenuCommand * myTransformToFlow
menu command for transform to flow
Definition: GNEVehicle.h:78
FXMenuCommand * myTransformToRouteFlow
menu command for transform to route flow
Definition: GNEVehicle.h:69
FXMenuCommand * myTransformToTrip
menu command for transform to trip
Definition: GNEVehicle.h:75
FXMenuCommand * myTransformToRouteFlowWithEmbeddedRoute
menu command for transform to route flow with an embedded route
Definition: GNEVehicle.h:72
FXMenuCommand * myTransformToVehicleWithEmbeddedRoute
menu command for transform to vehicle with an embedded route
Definition: GNEVehicle.h:66
void drawFlowLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw flow label
GNELane * getLastPathLane() const
get last path lane
void setColor(const GUIVisualizationSettings &s) const
sets the color according to the currente settings
void disableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration asociated with this GLObject
Definition: GNEVehicle.cpp:642
void fixDemandElementProblem()
fix demand element problem (by default throw an exception, has to be reimplemented in children)
Definition: GNEVehicle.cpp:552
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GNEVehicle.cpp:648
GNEMoveOperation * getMoveOperation()
get move operation
Definition: GNEVehicle.cpp:342
std::string getAttribute(SumoXMLAttr key) const
inherited from GNEAttributeCarrier
std::string getParentName() const
Returns the name of the parent object.
Definition: GNEVehicle.cpp:630
void drawPartialGL(const GUIVisualizationSettings &s, const GNELane *lane, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object.
Definition: GNEVehicle.cpp:835
void computePathElement()
compute pathElement
Definition: GNEVehicle.cpp:786
std::string getPopUpID() const
get PopPup ID (Used in AC Hierarchy)
~GNEVehicle()
destructor
Definition: GNEVehicle.cpp:338
double getAttributeDouble(SumoXMLAttr key) const
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GNEVehicle.cpp:663
bool isAttributeEnabled(SumoXMLAttr key) const
const RGBColor & getColor() const
get color
Definition: GNEVehicle.cpp:564
const std::map< std::string, std::string > & getACParametersMap() const
get parameters map
void enableAttribute(SumoXMLAttr key, GNEUndoList *undoList)
GNELane * getFirstPathLane() const
get first path lane
Problem isDemandElementValid() const
check if current demand element is valid to be writed into XML (by default true, can be reimplemented...
Definition: GNEVehicle.cpp:458
static const double myArrivalPositionDiameter
vehicle arrival position radius
Definition: GNEVehicle.h:354
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:657
void drawJunctionLine() const
draw junction line
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:609
void toogleAttribute(SumoXMLAttr key, const bool value, const int previousParameters)
method for enable or disable the attribute and nothing else (used in GNEChange_EnableAttribute)
void updateGeometry()
update pre-computed geometry information
Definition: GNEVehicle.cpp:570
Position getAttributePosition(SumoXMLAttr key) const
std::string getBegin() const
get begin time of demand element
Definition: GNEVehicle.cpp:367
std::string getDemandElementProblem() const
return a string with the current demand element problem (by default empty, can be reimplemented in ch...
Definition: GNEVehicle.cpp:501
void drawStackLabel(const Position &vehiclePosition, const double vehicleRotation, const double width, const double length, const double exaggeration) const
draw stack label
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
Position getPositionInView() const
Returns position of demand element in view.
Definition: GNEVehicle.cpp:603
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 writeDemandElement(OutputDevice &device) const
writte demand element element into a xml file
Definition: GNEVehicle.cpp:381
GNEVehicle(SumoXMLTag tag, GNENet *net)
default constructor
Definition: GNEVehicle.cpp:255
SUMOVehicleClass getVClass() const
Definition: GNEVehicle.cpp:558
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:537
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:513
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:525
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:432
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:531
GNEMoveFrame * getMoveFrame() const
get frame for move elements
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
draw vehicle as a triangle
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedSquaredShape(const DottedContourType type, const GUIVisualizationSettings &s, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double exaggeration)
draw dotted squared contour (used by additionals and demand elements)
static void drawDottedContourShape(const DottedContourType type, const GUIVisualizationSettings &s, const PositionVector &shape, const double width, const double exaggeration, const bool drawFirstExtrem, const bool drawLastExtrem, const double lineWidth=-1)
draw dotted contour for the given shape (used by additionals)
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:58
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
const T getColor(const double value) const
Position getPositionInformation() const
Returns the cursor's x/y position within the network.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
GUIVisualizationTextSettings vehicleName
GUIVisualizationSizeSettings vehicleSize
GUIColorer vehicleColorer
The vehicle colorer.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationDetailSettings detailSettings
detail settings
GUIVisualizationWidthSettings widthSettings
width settings
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
bool drawMinGap
Information whether the minimum gap shall be drawn.
GUIVisualizationTextSettings personName
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
double angle
The current view rotation angle.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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:248
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|....
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"
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".
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:257
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:242
double distanceSquaredTo(const Position &p2) const
returns the square of the distance to another position
Definition: Position.h:247
double x() const
Returns the x-position.
Definition: Position.h:55
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition: Position.h:262
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
double length2D() const
Returns the length.
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor WHITE
Definition: RGBColor.h:192
static const RGBColor BLUE
Definition: RGBColor.h:187
static const RGBColor GREY
Definition: RGBColor.h:194
static const RGBColor ORANGE
Definition: RGBColor.h:191
static const RGBColor CYAN
Definition: RGBColor.h:189
static RGBColor fromHSV(double h, double s, double v)
Converts the given hsv-triplet to rgb, inspired by http://alvyray.com/Papers/CG/hsv2rgb....
Definition: RGBColor.cpp:368
static const RGBColor BLACK
Definition: RGBColor.h:193
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:199
static const RGBColor RED
named colors
Definition: RGBColor.h:185
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
double arrivalPosLat
(optional) The lateral position the vehicle shall arrive on
std::string getArrivalSpeed() const
obtain arrival speed parameter in string format
double repetitionProbability
The probability for emitting a vehicle per second.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
SumoXMLTag tag
The vehicle tag.
std::string vtypeid
The vehicle's type id.
std::string getDepartLane() const
obtain depart lane parameter in string format
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
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.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
std::string getDepartSpeed() const
obtain depart speed parameter in string format
std::string getArrivalPos() const
obtain arrival pos parameter in string format
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
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 routeid
The vehicle's route id.
std::string id
The vehicle's id.
int departEdge
(optional) The initial edge within the route of the vehicle
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
bool wasSet(int what) const
Returns whether the given parameter was set.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static bool parseDepartPosLat(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosLatDefinition &dpd, std::string &error)
Validates a given departPosLat value.
std::string getDepartPosLat() const
obtain depart pos lat parameter in string format
std::string getArrivalPosLat() const
obtain arrival pos lat parameter in string format
std::string getDepartPos() const
obtain depart pos parameter in string format
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
int arrivalEdge
(optional) The final edge within the route of the vehicle
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
int containerNumber
The static number of containers in the vehicle when it departs.
ArrivalPosLatDefinition arrivalPosLatProcedure
Information how the vehicle shall choose the lateral arrival position.
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static bool isValidVehicleID(const std::string &value)
whether the given string is a valid id for a vehicle or flow
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
#define M_PI
Definition: odrSpiral.cpp:40
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 GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool drawSpreadVehicles() const
check if vehicles must be drawn spread
bool showDemandElements() const
check if show demand elements checkbox is enabled
RGBColor vehicleTripColor
color for vehicle trips
RGBColor selectedVehicleColor
vehicle selection color
static const double vehicleTriangles
details for draw person as triangles
static const double vehicleShapes
details for draw person as shapes
static const double vehicleBoxes
details for draw person as boxes
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
bool show(const GUIGlObject *o) const
whether to show the text
double scaledSize(double scale, double constFactor=0.1) const
get scale size