Eclipse SUMO - Simulation of Urban MObility
GNEAdditional.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // A abstract class for representation of additional elements
19 /****************************************************************************/
20 #include <config.h>
22 #include <netedit/GNENet.h>
23 #include <netedit/GNEViewNet.h>
24 #include <netedit/GNEViewParent.h>
33 #include <utils/gui/div/GLHelper.h>
38 
39 #include "GNEAdditional.h"
40 #include "GNETAZ.h"
41 
42 
43 // ===========================================================================
44 // member method definitions
45 // ===========================================================================
46 
47 GNEAdditional::GNEAdditional(const std::string& id, GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
48  const std::vector<GNEJunction*>& junctionParents,
49  const std::vector<GNEEdge*>& edgeParents,
50  const std::vector<GNELane*>& laneParents,
51  const std::vector<GNEAdditional*>& additionalParents,
52  const std::vector<GNEDemandElement*>& demandElementParents,
53  const std::vector<GNEGenericData*>& genericDataParents) :
54  GNEPathManager::PathElement(type, id, icon, GNEPathManager::PathElement::Options::ADDITIONAL_ELEMENT),
55  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
56  myAdditionalName(additionalName) {
57  // check if is template
58  myIsTemplate = (id == "");
59 }
60 
61 
62 GNEAdditional::GNEAdditional(GNENet* net, GUIGlObjectType type, SumoXMLTag tag, FXIcon* icon, std::string additionalName,
63  const std::vector<GNEJunction*>& junctionParents,
64  const std::vector<GNEEdge*>& edgeParents,
65  const std::vector<GNELane*>& laneParents,
66  const std::vector<GNEAdditional*>& additionalParents,
67  const std::vector<GNEDemandElement*>& demandElementParents,
68  const std::vector<GNEGenericData*>& genericDataParents) :
69  GNEPathManager::PathElement(type, additionalParents.front()->getID(), icon, GNEPathManager::PathElement::Options::ADDITIONAL_ELEMENT),
70  GNEHierarchicalElement(net, tag, junctionParents, edgeParents, laneParents, additionalParents, demandElementParents, genericDataParents),
71  myAdditionalName(additionalName) {
72 }
73 
74 
76 
77 
78 void
79 GNEAdditional::removeGeometryPoint(const Position /*clickedPosition*/, GNEUndoList* /*undoList*/) {
80  // currently there isn't additionals with removable geometry points
81 }
82 
83 
86  return this;
87 }
88 
89 
90 const GUIGlObject*
92  return this;
93 }
94 
95 
96 const std::string
98  try {
100  } catch (InvalidArgument&) {
101  return "";
102  }
103 }
104 
105 
106 const GUIGeometry&
108  return myAdditionalGeometry;
109 }
110 
111 
112 void
114  mySpecialColor = color;
115 }
116 
117 
118 bool
120  return true;
121 }
122 
123 
124 std::string
126  return "";
127 }
128 
129 
130 void
132  throw InvalidArgument(getTagStr() + " cannot fix any problem");
133 }
134 
135 
136 void
138  throw InvalidArgument(getTagStr() + " doesn't have an additional dialog");
139 }
140 
141 
142 double
144  return s.addSize.getExaggeration(s, this);
145 }
146 
147 
148 Boundary
151  return myAdditionalBoundary;
152  } else {
154  }
155 }
156 
157 
158 bool
160  // get modes
161  const auto& modes = myNet->getViewNet()->getEditModes();
162  if (myTagProperty.getTag() == SUMO_TAG_TAZ) {
163  // get TAZRelDataFrame
164  const auto& TAZRelDataFrame = myNet->getViewNet()->getViewParent()->getTAZRelDataFrame();
165  const auto& vehicleFrame = myNet->getViewNet()->getViewParent()->getVehicleFrame();
166  // check conditions
167  if (myNet->getViewNet()->getInspectedAttributeCarriers().size() == 1) {
168  // get inspected element
169  const auto inspectedAC = myNet->getViewNet()->getInspectedAttributeCarriers().front();
170  // check if starts in TAZ
171  if (inspectedAC->hasAttribute(SUMO_ATTR_FROM_TAZ) && (inspectedAC->getAttribute(SUMO_ATTR_FROM_TAZ) == getID())) {
172  return true;
173  } else if ((inspectedAC->getTagProperty().getTag() == SUMO_TAG_TAZREL) && (inspectedAC->getAttribute(SUMO_ATTR_FROM) == getID())) {
174  return true;
175  }
176  } else if (TAZRelDataFrame->shown()) {
177  // check first TAZ
178  if (TAZRelDataFrame->getFirstTAZ() == nullptr) {
180  } else if (TAZRelDataFrame->getFirstTAZ() == this) {
181  return true;
182  }
183  } else if (vehicleFrame->shown()) {
184  // get selected TAZs
185  const auto& selectedTAZs = vehicleFrame->getPathCreator()->getSelectedTAZs();
186  // check if this is the second selected TAZ
187  if ((selectedTAZs.size() > 0) && (selectedTAZs.front() == this)) {
188  return true;
189  }
190  }
191  }
192  // get current GNEPlanCreator
193  GNEPlanCreator* planCreator = nullptr;
194  if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_PERSON)) {
195  planCreator = myNet->getViewNet()->getViewParent()->getPersonFrame()->getPlanCreator();
196  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN)) {
198  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER)) {
200  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN)) {
202  }
203  // continue depending of planCreator
204  if (planCreator) {
205  // check if this is the from additional
206  if ((planCreator->getFromBusStop() == this) || (planCreator->getFromTrainStop() == this) ||
207  (planCreator->getFromContainerStop() == this) || (planCreator->getFromTAZ() == this)) {
208  return true;
209  }
210  }
211  // nothing to draw
212  return false;
213 }
214 
215 
216 bool
218  // get modes
219  const auto& modes = myNet->getViewNet()->getEditModes();
220  // special case for TAZs
221  if (myTagProperty.getTag() == SUMO_TAG_TAZ) {
222  // get frames
223  const auto& TAZRelDataFrame = myNet->getViewNet()->getViewParent()->getTAZRelDataFrame();
224  const auto& vehicleFrame = myNet->getViewNet()->getViewParent()->getVehicleFrame();
225  // check conditions
226  if (myNet->getViewNet()->getInspectedAttributeCarriers().size() == 1) {
227  // get inspected element
228  const auto inspectedAC = myNet->getViewNet()->getInspectedAttributeCarriers().front();
229  // check if ends in TAZ
230  if (inspectedAC->hasAttribute(SUMO_ATTR_TO_TAZ) && (inspectedAC->getAttribute(SUMO_ATTR_TO_TAZ) == getID())) {
231  return true;
232  } else if ((inspectedAC->getTagProperty().getTag() == SUMO_TAG_TAZREL) && (inspectedAC->getAttribute(SUMO_ATTR_TO) == getID())) {
233  return true;
234  }
235  } else if (TAZRelDataFrame->shown() && (TAZRelDataFrame->getFirstTAZ() != nullptr)) {
236  // check first TAZ
237  if (TAZRelDataFrame->getSecondTAZ() == nullptr) {
239  } else if (TAZRelDataFrame->getSecondTAZ() == this) {
240  return true;
241  }
242  } else if (vehicleFrame->shown()) {
243  // get selected TAZs
244  const auto& selectedTAZs = vehicleFrame->getPathCreator()->getSelectedTAZs();
245  // check if this is the second selected TAZ
246  if ((selectedTAZs.size() > 1) && (selectedTAZs.back() == this)) {
247  return true;
248  }
249  }
250  }
251  // get current GNEPlanCreator
252  GNEPlanCreator* planCreator = nullptr;
253  if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_PERSON)) {
254  planCreator = myNet->getViewNet()->getViewParent()->getPersonFrame()->getPlanCreator();
255  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN)) {
257  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER)) {
259  } else if (modes.isCurrentSupermodeDemand() && (modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN)) {
261  }
262  // continue depending of planCreator
263  if (planCreator) {
264  // check if this is the from additional
265  if ((planCreator->getToBusStop() == this) || (planCreator->getToTrainStop() == this) ||
266  (planCreator->getToContainerStop() == this) || (planCreator->getToTAZ() == this)) {
267  return true;
268  }
269  }
270  // nothing to draw
271  return false;
272 }
273 
274 
275 bool
277  return false;
278 }
279 
280 
281 bool
283  // get modes
284  const auto& modes = myNet->getViewNet()->getEditModes();
285  // get frames
286  const auto& personFramePlanSelector = myNet->getViewNet()->getViewParent()->getPersonFrame()->getPlanSelector();
287  const auto& personPlanFramePlanSelector = myNet->getViewNet()->getViewParent()->getPersonPlanFrame()->getPlanSelector();
288  const auto& containerFramePlanSelector = myNet->getViewNet()->getViewParent()->getContainerFrame()->getPlanSelector();
289  const auto& containerPlanFramePlanSelector = myNet->getViewNet()->getViewParent()->getContainerPlanFrame()->getPlanSelector();
290  // special case for TAZs
291  if (myTagProperty.getTag() == SUMO_TAG_TAZ) {
292  // get vehicle frame
293  const auto& vehicleFrame = myNet->getViewNet()->getViewParent()->getVehicleFrame();
294  // check if we're in vehicle mode
295  if (vehicleFrame->shown()) {
296  // get current vehicle template
297  const auto& vehicleTemplate = vehicleFrame->getVehicleTagSelector()->getCurrentTemplateAC();
298  // check if vehicle can be placed over from-to TAZs
299  if (vehicleTemplate && vehicleTemplate->getTagProperty().vehicleTAZs()) {
301  }
302  } else if (modes.isCurrentSupermodeDemand()) {
303  // check if we're in person or personPlan modes
304  if (((modes.demandEditMode == DemandEditMode::DEMAND_PERSON) && personFramePlanSelector->markTAZs()) ||
305  ((modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) && personPlanFramePlanSelector->markTAZs())) {
307  }
308  }
309  } else if ((myTagProperty.getTag() == SUMO_TAG_BUS_STOP) && modes.isCurrentSupermodeDemand()) {
310  // check if we're in person or personPlan modes
311  if (((modes.demandEditMode == DemandEditMode::DEMAND_PERSON) && personFramePlanSelector->markBusStops()) ||
312  ((modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) && personPlanFramePlanSelector->markBusStops())) {
314  }
315  } else if ((myTagProperty.getTag() == SUMO_TAG_TRAIN_STOP) && modes.isCurrentSupermodeDemand()) {
316  // check if we're in person or personPlan modes
317  if (((modes.demandEditMode == DemandEditMode::DEMAND_PERSON) && personFramePlanSelector->markTrainStops()) ||
318  ((modes.demandEditMode == DemandEditMode::DEMAND_PERSONPLAN) && personPlanFramePlanSelector->markTrainStops())) {
320  }
321  } else if ((myTagProperty.getTag() == SUMO_TAG_CONTAINER_STOP) && modes.isCurrentSupermodeDemand()) {
322  // check if we're in container or containerPlan modes
323  if (((modes.demandEditMode == DemandEditMode::DEMAND_CONTAINER) && containerFramePlanSelector->markContainerStops()) ||
324  ((modes.demandEditMode == DemandEditMode::DEMAND_CONTAINERPLAN) && containerPlanFramePlanSelector->markContainerStops())) {
326  }
327  }
328  return false;
329 }
330 
331 
332 bool
334  // get edit modes
335  const auto& editModes = myNet->getViewNet()->getEditModes();
336  // check if we're in delete mode
337  if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_DELETE)) {
339  } else {
340  return false;
341  }
342 }
343 
344 
345 bool
347  // get edit modes
348  const auto& editModes = myNet->getViewNet()->getEditModes();
349  // check if we're in select mode
350  if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_SELECT)) {
352  } else {
353  return false;
354  }
355 }
356 
357 
360  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
361  // build header
362  buildPopupHeader(ret, app);
363  // build menu command for center button and copy cursor position to clipboard
365  // build menu commands for names
366  GUIDesigns::buildFXMenuCommand(ret, TLF("Copy % name to clipboard", getTagStr()), nullptr, ret, MID_COPY_NAME);
367  GUIDesigns::buildFXMenuCommand(ret, TLF("Copy % typed name to clipboard", getTagStr()), nullptr, ret, MID_COPY_TYPED_NAME);
368  new FXMenuSeparator(ret);
369  // build selection and show parameters menu
372  buildPositionCopyEntry(ret, app);
373  // show option to open additional dialog
374  if (myTagProperty.hasDialog()) {
375  GUIDesigns::buildFXMenuCommand(ret, TL("Open ") + getTagStr() + TL(" Dialog"), getACIcon(), &parent, MID_OPEN_ADDITIONAL_DIALOG);
376  new FXMenuSeparator(ret);
377  }
378  // Show position parameters
381  // Show menu command inner position
383  GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over additional shape: ") + toString(innerPos), nullptr, nullptr, 0);
384  // If shape isn't empty, show menu command lane position
385  if (myAdditionalGeometry.getShape().size() > 0) {
386  const double lanePos = lane->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
387  GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over lane: ") + toString(innerPos + lanePos), nullptr, nullptr, 0);
388  }
391  // Show menu command inner position
393  GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position over additional shape: ") + toString(innerPos), nullptr, nullptr, 0);
394  // If shape isn't empty, show menu command edge position
395  if (myAdditionalGeometry.getShape().size() > 0) {
396  const double edgePos = edge->getLanes().at(0)->getLaneShape().nearest_offset_to_point2D(myAdditionalGeometry.getShape().front());
397  GUIDesigns::buildFXMenuCommand(ret, TL("Mouse position over edge: ") + toString(innerPos + edgePos), nullptr, nullptr, 0);
398  }
399  } else {
400  GUIDesigns::buildFXMenuCommand(ret, TL("Cursor position in view: ") + toString(getPositionInView().x()) + "," + toString(getPositionInView().y()), nullptr, nullptr, 0);
401  }
402  return ret;
403 }
404 
405 
408  // Create table
409  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
410  // Iterate over attributes
411  for (const auto& attributeProperty : myTagProperty) {
412  // Add attribute and set it dynamic if aren't unique
413  if (attributeProperty.isUnique()) {
414  ret->mkItem(attributeProperty.getAttrStr().c_str(), false, getAttribute(attributeProperty.getAttr()));
415  } else {
416  ret->mkItem(attributeProperty.getAttrStr().c_str(), true, getAttribute(attributeProperty.getAttr()));
417  }
418  }
419  // close building
420  ret->closeBuilding();
421  return ret;
422 }
423 
424 
425 const std::string&
427  return myAdditionalName;
428 }
429 
430 
431 bool
435  } else {
436  return true;
437  }
438 }
439 
440 
441 void
444 }
445 
446 
447 void
450 }
451 
452 
453 void
457  } else {
459  }
460  // update information label
462 }
463 
464 
466  updateGeometry();
467 }
468 
469 
470 void
472  // Nothing to compute
473 }
474 
475 
476 bool
478  return mySelected;
479 }
480 
481 
482 void
483 GNEAdditional::drawLanePartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
484  // Nothing to draw
485 }
486 
487 
488 void
489 GNEAdditional::drawJunctionPartialGL(const GUIVisualizationSettings& /*s*/, const GNEPathManager::Segment* /*segment*/, const double /*offsetFront*/) const {
490  // Nothing to draw
491 }
492 
493 // ---------------------------------------------------------------------------
494 // GNEAdditional - protected methods
495 // ---------------------------------------------------------------------------
496 
497 bool
498 GNEAdditional::isValidAdditionalID(const std::string& value) const {
499  if (value == getID()) {
500  return true;
501  } else if (SUMOXMLDefinitions::isValidAdditionalID(value)) {
502  return (myNet->getAttributeCarriers()->retrieveAdditional(myTagProperty.getTag(), value, false) == nullptr);
503  } else {
504  return false;
505  }
506 }
507 
508 
509 bool
510 GNEAdditional::isValidAdditionalID(const std::vector<SumoXMLTag>& tags, const std::string& value) const {
511  if (value == getID()) {
512  return true;
513  } else if (SUMOXMLDefinitions::isValidAdditionalID(value)) {
514  return (myNet->getAttributeCarriers()->retrieveAdditionals(tags, value, false) == nullptr);
515  } else {
516  return false;
517  }
518 }
519 
520 
521 bool
522 GNEAdditional::isValidDetectorID(const std::string& value) const {
523  if (value == getID()) {
524  return true;
525  } else if (SUMOXMLDefinitions::isValidDetectorID(value)) {
526  return (myNet->getAttributeCarriers()->retrieveAdditional(myTagProperty.getTag(), value, false) == nullptr);
527  } else {
528  return false;
529  }
530 }
531 
532 
533 bool
534 GNEAdditional::isValidDetectorID(const std::vector<SumoXMLTag>& tags, const std::string& value) const {
535  if (value == getID()) {
536  return true;
537  } else if (SUMOXMLDefinitions::isValidDetectorID(value)) {
538  return (myNet->getAttributeCarriers()->retrieveAdditionals(tags, value, false) == nullptr);
539  } else {
540  return false;
541  }
542 }
543 
544 
545 void
546 GNEAdditional::setAdditionalID(const std::string& newID) {
547  // set microsim ID
548  setMicrosimID(newID);
549  // change IDs of certain children
550  for (const auto& additionalChild : getChildAdditionals()) {
551  // get tag
552  const auto tag = additionalChild->getTagProperty().getTag();
553  if ((tag == SUMO_TAG_ACCESS) || (tag == SUMO_TAG_PARKING_SPACE) ||
554  (tag == SUMO_TAG_DET_ENTRY) || (tag == SUMO_TAG_DET_EXIT)) {
555  additionalChild->setAdditionalID(getID());
556  }
557  }
558  // enable save demand elements if this additional has children
559  if (getChildDemandElements().size() > 0) {
561  }
562  // enable save data elements if this additional has children
563  if (getChildGenericDatas().size() > 0) {
565  }
566 }
567 
568 
569 void
571  if (s.addName.show(this) && (myAdditionalGeometry.getShape().size() > 0) && !s.drawForRectangleSelection) {
572  // calculate middle point
573  const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
574  // calculate position
576  // calculate rotation
577  const double rot = (myAdditionalGeometry.getShape().size() == 1) ? myAdditionalGeometry.getShapeRotations().front() : myAdditionalGeometry.getShape().rotationDegreeAtOffset(middlePoint);
578  // draw additional ID
581  } else {
583  }
584  }
585 }
586 
587 
588 void
590  if (s.addFullName.show(this) && (myAdditionalGeometry.getShape().size() > 0) && (myAdditionalName != "") && !s.drawForRectangleSelection) {
591  // calculate middle point
592  const double middlePoint = (myAdditionalGeometry.getShape().length2D() * 0.5);
593  // calculate position
595  // calculate rotation
596  const double rot = (myAdditionalGeometry.getShape().size() == 1) ? myAdditionalGeometry.getShapeRotations().front() : myAdditionalGeometry.getShape().rotationDegreeAtOffset(middlePoint);
597  // draw additional name
600  } else {
602  }
603  }
604 }
605 
606 
607 void
609  replaceParentElements(this, parse<std::vector<GNEEdge*> >(getNet(), value));
610 }
611 
612 
613 void
615  replaceParentElements(this, parse<std::vector<GNELane*> >(getNet(), value));
616 }
617 
618 
619 void
621  replaceChildElements(this, parse<std::vector<GNEEdge*> >(getNet(), value));
622 }
623 
624 
625 void
627  replaceChildElements(this, parse<std::vector<GNELane*> >(getNet(), value));
628 }
629 
630 
631 void
632 GNEAdditional::replaceAdditionalParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
633  std::vector<GNEAdditional*> parentAdditionals;
634  // special case for calibrators and routeprobes
635  if (value.size() > 0) {
636  parentAdditionals = getParentAdditionals();
637  if ((parentAdditionals.size() == 0) && (parentIndex == 0)) {
638  parentAdditionals.push_back(myNet->getAttributeCarriers()->retrieveAdditional(tag, value));
639  } else {
640  parentAdditionals[parentIndex] = myNet->getAttributeCarriers()->retrieveAdditional(tag, value);
641  }
642  }
643  // replace parent additionals
644  replaceParentElements(this, parentAdditionals);
645 }
646 
647 
648 void
649 GNEAdditional::replaceDemandElementParent(SumoXMLTag tag, const std::string& value, const int parentIndex) {
650  std::vector<GNEDemandElement*> parentDemandElements = getParentDemandElements();
651  parentDemandElements[parentIndex] = myNet->getAttributeCarriers()->retrieveDemandElement(tag, value);
652  // replace parent demand elements
653  replaceParentElements(this, parentDemandElements);
654 }
655 
656 
657 void
659  // get new lane parent vector
660  std::vector<GNELane*> newLane = {getParentLanes().front()->getParentEdge()->getLanes().at(getParentLanes().front()->getIndex() + 1)};
661  // replace parent elements
662  replaceParentElements(this, newLane);
663 }
664 
665 
666 void
667 GNEAdditional::calculatePerpendicularLine(const double endLaneposition) {
668  if (getParentEdges().empty()) {
669  throw ProcessError(TL("Invalid number of edges"));
670  } else {
671  // get lanes
672  const GNELane* firstLane = getParentEdges().front()->getLanes().front();
673  const GNELane* lastLane = getParentEdges().front()->getLanes().back();
674  // get first and back lane shapes
675  PositionVector firstLaneShape = firstLane->getLaneShape();
676  PositionVector lastLaneShape = lastLane->getLaneShape();
677  // move shapes
678  firstLaneShape.move2side((firstLane->getParentEdge()->getNBEdge()->getLaneWidth(firstLane->getIndex()) * 0.5) + 1);
679  lastLaneShape.move2side(lastLane->getParentEdge()->getNBEdge()->getLaneWidth(lastLane->getIndex()) * -0.5);
680  // calculate lane postion
681  const double lanePosition = firstLaneShape.length2D() >= endLaneposition ? endLaneposition : firstLaneShape.length2D();
682  // update geometry
683  myAdditionalGeometry.updateGeometry({firstLaneShape.positionAtOffset2D(lanePosition), lastLaneShape.positionAtOffset2D(lanePosition)});
684  }
685 }
686 
687 
688 void
689 GNEAdditional::drawSquaredAdditional(const GUIVisualizationSettings& s, const Position& pos, const double size, GUITexture texture, GUITexture selectedTexture) const {
690  // first check if additional has to be drawn
692  // draw boundaries
694  // Obtain drawing exaggeration
695  const double exaggeration = getExaggeration(s);
696  // get detail level
697  const auto d = s.getDetailLevel(exaggeration);
698  // draw geometry only if we'rent in drawForObjectUnderCursor mode
699  if (!s.drawForViewObjectsHandler) {
700  // Add layer matrix
702  // translate to front
704  // translate to position
705  glTranslated(pos.x(), pos.y(), 0);
706  // scale
707  glScaled(exaggeration, exaggeration, 1);
708  // set White color
709  glColor3d(1, 1, 1);
710  // rotate
711  glRotated(180, 0, 0, 1);
712  // draw texture
713  if (drawUsingSelectColor()) {
715  } else {
717  }
718  // Pop layer matrix
720  // draw lock icon
721  GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), pos, exaggeration, 0.4, 0.5, 0.5);
722  // Draw additional ID
723  drawAdditionalID(s);
724  // draw additional name
726  // draw dotted contour
728  }
729  // calculate contour
730  myAdditionalContour.calculateContourRectangleShape(s, d, this, pos, size, size, 0, 0, 0, exaggeration);
731  }
732 }
733 
734 
735 void
736 GNEAdditional::drawListedAdditional(const GUIVisualizationSettings& s, const Position& parentPosition, const double offsetX, const double extraOffsetY,
737  const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const {
738  // draw boundaries
740  // first check if additional has to be drawn
742  // get detail level
743  const auto d = s.getDetailLevel(1);
744  // declare offsets
745  const double lineOffset = 0.1875;
746  const double baseOffsetX = 6.25;
747  const double baseOffsetY = 0.6;
748  // get draw position index
749  const int drawPositionIndex = getDrawPositionIndex();
750  // calculate lineA position (from parent to middle)
751  Position positionLineA = parentPosition;
752  const double positionLineA_Y = (0 - extraOffsetY + baseOffsetY);
753  // set position depending of indexes
754  positionLineA.add(1 + lineOffset + (baseOffsetX * offsetX), positionLineA_Y, 0);
755  // calculate lineC position (From middle until current listenAdditional
756  Position positionLineB = parentPosition;
757  const double positionLineB_Y = ((drawPositionIndex * -1) - extraOffsetY + baseOffsetY);
758  // set position depending of indexes
759  positionLineB.add(1 + lineOffset + (baseOffsetX * offsetX) + (2 * lineOffset), positionLineB_Y, 0);
760  // calculate signPosition position
761  Position signPosition = parentPosition;
762  // draw geometry only if we'rent in drawForObjectUnderCursor mode
763  if (!s.drawForViewObjectsHandler) {
764  // set position depending of indexes
765  signPosition.add(4.5 + (baseOffsetX * offsetX), (drawPositionIndex * -1) - extraOffsetY + 1, 0);
766  // calculate colors
768  const RGBColor secondColor = baseColor.changedBrightness(-30);
770  // Add layer matrix
772  // translate to front
774  // set line color
776  // draw both lines
777  GLHelper::drawBoxLine(positionLineA, 0, 0.1, lineOffset);
778  GLHelper::drawBoxLine(positionLineB, 0, 0.1, lineOffset);
779  // check if draw middle lane
780  if (drawPositionIndex != 0) {
781  // calculate length
782  const double length = std::abs(positionLineA_Y - positionLineB_Y);
783  // push middle lane matrix
785  //move and rotate
786  glTranslated(positionLineA.x() + lineOffset, positionLineA.y(), 0);
787  glRotated(90, 0, 0, 1);
788  glTranslated((length * -0.5), 0, 0);
789  // draw line
790  GLHelper::drawBoxLine(Position(0, 0), 0, 0.1, length * 0.5);
791  // pop middle lane matrix
793  }
794  // draw extern rectangle
795  GLHelper::setColor(secondColor);
796  GLHelper::drawBoxLine(signPosition, 0, 0.96, 2.75);
797  // move to front
798  glTranslated(0, -0.06, 0.1);
799  // draw intern rectangle
800  GLHelper::setColor(baseColor);
801  GLHelper::drawBoxLine(signPosition, 0, 0.84, 2.69);
802  // move position down
803  signPosition.add(-2, -0.43, 0);
804  // draw interval
805  GLHelper::drawText(adjustListedAdditionalText(text), signPosition, .1, 0.5, textColor, 0, (FONS_ALIGN_LEFT | FONS_ALIGN_MIDDLE));
806  // move to icon position
807  signPosition.add(-0.3, 0);
808  // check if draw lock icon or rerouter interval icon
810  // pop layer matrix
812  // draw lock icon
813  GNEViewNetHelper::LockIcon::drawLockIcon(d, this, getType(), signPosition, 1, 0.4, 0.0, -0.05);
814  } else {
815  // translate to front
816  glTranslated(signPosition.x(), signPosition.y(), 0.1);
817  // set White color
818  glColor3d(1, 1, 1);
819  // rotate
820  glRotated(180, 0, 0, 1);
821  // draw texture
823  // pop layer matrix
825  }
826  // draw dotted contour
828  }
829  // calculate contour
830  myAdditionalContour.calculateContourRectangleShape(s, d, this, signPosition, 0.56, 2.75, 0, -2.3, 0, 1);
831  }
832 }
833 
834 
835 bool
836 GNEAdditional::drawMovingGeometryPoints(const bool ignoreShift) const {
837  // get modes
838  const auto& modes = myNet->getViewNet()->getEditModes();
839  // check conditions
840  if (modes.isCurrentSupermodeNetwork() && (modes.networkEditMode == NetworkEditMode::NETWORK_MOVE) &&
841  (ignoreShift || myNet->getViewNet()->getMouseButtonKeyPressed().shiftKeyPressed())) {
842  return true;
843  } else {
844  return false;
845  }
846 }
847 
848 
849 void
851  // draw child demand elements
852  for (const auto& demandElement : getChildDemandElements()) {
853  if (!demandElement->getTagProperty().isPlacedInRTree()) {
854  demandElement->drawGL(s);
855  }
856  }
857 }
858 
859 
861 GNEAdditional::getMoveOperationSingleLane(const double startPos, const double endPos) {
862  // get allow change lane
863  const bool allowChangeLane = myNet->getViewNet()->getViewParent()->getMoveFrame()->getCommonModeOptions()->getAllowChangeLane();
864  // fist check if we're moving only extremes
866  // get snap radius
868  // get mouse position
869  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
870  // check if we clicked over start or end position
871  if (myAdditionalGeometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
872  // move only start position
873  return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
875  } else if (myAdditionalGeometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
876  // move only end position
877  return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
879  } else {
880  return nullptr;
881  }
882  } else {
883  // move both start and end positions
884  return new GNEMoveOperation(this, getParentLanes().front(), startPos, endPos,
886  }
887 }
888 
889 
891 GNEAdditional::getMoveOperationMultiLane(const double startPos, const double endPos) {
892  // check if shift is pressed
893  const bool shift = myNet->getViewNet()->getMouseButtonKeyPressed().shiftKeyPressed();
894  // get snap radius
896  // get mouse position
897  const Position mousePosition = myNet->getViewNet()->getPositionInformation();
898  // calculate both geometries
899  GUIGeometry fromGeometry, toGeometry;
900  fromGeometry.updateGeometry(getParentLanes().front()->getLaneGeometry().getShape(), startPos, 0);
901  toGeometry.updateGeometry(getParentLanes().back()->getLaneGeometry().getShape(), endPos, 0);
902  // check if we clicked over start or end position
903  if (fromGeometry.getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
904  // move using start position
905  return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
907  } else if (toGeometry.getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
908  // move using end position
909  return new GNEMoveOperation(this, getParentLanes().front(), startPos, getParentLanes().back(), endPos,
911  } else {
912  return nullptr;
913  }
914 }
915 
916 
917 std::string
919  // continue depending of tag
920  switch (tag) {
922  return "jupedsim.walkable_area";
924  return "jupedsim.obstacle";
925  default:
926  throw InvalidArgument("Invalid JuPedSim tag");
927  }
928 }
929 
930 
931 RGBColor
933  // continue depending of tag
934  switch (tag) {
936  return RGBColor(179, 217, 255);
938  return RGBColor(255, 204, 204);
939  default:
940  throw InvalidArgument("Invalid JuPedSim tag");
941  }
942 }
943 
944 
945 bool
947  // continue depending of tag
948  switch (tag) {
951  return true;
952  default:
953  throw InvalidArgument("Invalid JuPedSim tag");
954  }
955 }
956 
957 
958 double
960  // continue depending of tag
961  switch (tag) {
963  return 1;
965  return 2;
966  default:
967  throw InvalidArgument("Invalid JuPedSim tag");
968  }
969 }
970 
971 
974  // continue depending of tag
975  switch (tag) {
977  return GLO_JPS_WALKABLEAREA;
979  return GLO_JPS_OBSTACLE;
980  default:
981  throw InvalidArgument("Invalid JuPedSim tag");
982  }
983 }
984 
985 
986 FXIcon*
988  // continue depending of tag
989  switch (tag) {
994  default:
995  throw InvalidArgument("Invalid JuPedSim tag");
996  }
997 }
998 
999 
1000 void
1002  const double exaggeration, const bool contouredShape) const {
1003  // calculate contour depenidng of contoured shape
1004  if (contouredShape) {
1006  } else {
1008  exaggeration, true, true, 0);
1009  }
1010  // get edit modes
1011  const auto& editModes = myNet->getViewNet()->getEditModes();
1012  // check if draw geometry points
1013  if (editModes.isCurrentSupermodeNetwork() && !myNet->getViewNet()->getViewParent()->getMoveFrame()->getNetworkModeOptions()->getMoveWholePolygons()) {
1014  // check if we're in move mode
1015  const bool moveMode = (editModes.networkEditMode == NetworkEditMode::NETWORK_MOVE);
1016  // get geometry point radius (size depends if we're in move mode)
1017  const double geometryPointRaidus = s.neteditSizeSettings.polygonGeometryPointRadius * (moveMode ? 1 : 0.5);
1018  // calculate contour geometry points
1019  myAdditionalContour.calculateContourAllGeometryPoints(s, d, this, myAdditionalGeometry.getShape(), geometryPointRaidus, exaggeration, moveMode);
1020  }
1021 }
1022 
1023 
1024 GNELane*
1026  return getParentLanes().front();
1027 }
1028 
1029 
1030 GNELane*
1032  return getParentLanes().back();
1033 }
1034 
1035 
1036 Position
1038  throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1039 }
1040 
1041 
1042 void
1043 GNEAdditional::drawParentChildLines(const GUIVisualizationSettings& s, const RGBColor& color, const bool onlySymbols) const {
1044  // check if current additional is inspected, front or selected
1045  const bool currentDrawEntire = myNet->getViewNet()->isAttributeCarrierInspected(this) ||
1047  // push layer matrix
1049  // translate to parentChildLine layer
1050  glTranslated(0, 0, GLO_PARENTCHILDLINE);
1051  // iterate over parent additionals
1052  for (const auto& parent : getParentAdditionals()) {
1053  // get inspected flag
1054  const bool inspected = myNet->getViewNet()->isAttributeCarrierInspected(parent);
1055  // draw parent lines
1056  GUIGeometry::drawParentLine(s, getPositionInView(), parent->getPositionInView(),
1057  (isAttributeCarrierSelected() || parent->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1058  currentDrawEntire || inspected || parent->isAttributeCarrierSelected(), .05);
1059  }
1060  // special case for Parking area reroutes
1061  if (getTagProperty().getTag() == SUMO_TAG_REROUTER) {
1062  // iterate over rerouter elements
1063  for (const auto& rerouterInterval : getChildAdditionals()) {
1064  for (const auto& rerouterElement : rerouterInterval->getChildAdditionals()) {
1065  if (rerouterElement->getTagProperty().getTag() == SUMO_TAG_PARKING_AREA_REROUTE) {
1066  // get parking area
1067  const auto parkingArea = rerouterElement->getParentAdditionals().at(1);
1068  // get inspected flag
1069  const bool inspected = myNet->getViewNet()->isAttributeCarrierInspected(parkingArea);
1070  // draw parent lines
1071  GUIGeometry::drawParentLine(s, getPositionInView(), parkingArea->getPositionInView(),
1072  (isAttributeCarrierSelected() || parkingArea->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1073  currentDrawEntire || inspected || parkingArea->isAttributeCarrierSelected(), .05);
1074  }
1075  }
1076  }
1077  }
1078  // iterate over child additionals
1079  for (const auto& child : getChildAdditionals()) {
1080  // get inspected flag
1081  const bool inspected = myNet->getViewNet()->isAttributeCarrierInspected(child);
1082  // special case for parking zone reroute
1083  if (child->getTagProperty().getTag() == SUMO_TAG_PARKING_AREA_REROUTE) {
1084  // draw child line between parking area and rerouter
1085  GUIGeometry::drawChildLine(s, getPositionInView(), child->getParentAdditionals().front()->getParentAdditionals().front()->getPositionInView(),
1086  (isAttributeCarrierSelected() || child->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1087  currentDrawEntire || inspected || child->isAttributeCarrierSelected(), .05);
1088  } else if (!onlySymbols || child->getTagProperty().isSymbol()) {
1089  // draw child line
1090  GUIGeometry::drawChildLine(s, getPositionInView(), child->getPositionInView(),
1091  (isAttributeCarrierSelected() || child->isAttributeCarrierSelected()) ? s.additionalSettings.connectionColorSelected : color,
1092  currentDrawEntire || inspected || child->isAttributeCarrierSelected(), .05);
1093  }
1094  }
1095  // pop layer matrix
1097 }
1098 
1099 
1100 void
1102  const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1103  drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, -90, 90, ignoreShift);
1104 }
1105 
1106 void
1108  const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1109  drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, 90, 270, ignoreShift);
1110 }
1111 
1112 void
1114  const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1115  drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, -90, 90, ignoreShift);
1116 }
1117 
1118 
1119 void
1121  const double rot, const RGBColor& baseColor, const bool ignoreShift) const {
1122  drawSemiCircleGeometryPoint(s, d, pos, rot, baseColor, 270, 90, ignoreShift);
1123 }
1124 
1125 
1126 int
1128  // filter symbols
1129  std::vector<GNEAdditional*> children;
1130  for (const auto& child : getParentAdditionals().front()->getChildAdditionals()) {
1131  if (!child->getTagProperty().isSymbol()) {
1132  children.push_back(child);
1133  }
1134  }
1135  // now get index
1136  for (int i = 0; i < (int)children.size(); i++) {
1137  if (children.at(i) == this) {
1138  return i;
1139  }
1140  }
1141  return 0;
1142 }
1143 
1144 
1145 bool
1146 GNEAdditional::areLaneConsecutives(const std::vector<GNELane*>& lanes) {
1147  // declare lane iterator
1148  int laneIt = 0;
1149  // iterate over all lanes
1150  while (laneIt < ((int)lanes.size() - 1)) {
1151  // we assume that lanes aren't consecutive
1152  bool consecutiveFound = false;
1153  // get lanes
1154  const auto lane = lanes.at(laneIt);
1155  const auto nextLane = lanes.at(laneIt + 1);
1156  // if there is a connection between "from" lane and "to" lane of connection, change connectionFound to true
1157  for (const auto& outgoingEdge : lane->getParentEdge()->getToJunction()->getGNEOutgoingEdges()) {
1158  for (const auto& outgoingLane : outgoingEdge->getLanes()) {
1159  if (outgoingLane == nextLane) {
1160  consecutiveFound = true;
1161  }
1162  }
1163  }
1164  // abort if consecutiveFound is false
1165  if (!consecutiveFound) {
1166  return false;
1167  }
1168  // update iterator
1169  laneIt++;
1170  }
1171  // lanes are consecutive, then return true
1172  return true;
1173 }
1174 
1175 
1176 bool
1177 GNEAdditional::areLaneConnected(const std::vector<GNELane*>& lanes) {
1178  // declare lane iterator
1179  int laneIt = 0;
1180  // iterate over all lanes, and stop if myE2valid is false
1181  while (laneIt < ((int)lanes.size() - 1)) {
1182  // we assume that E2 is invalid
1183  bool connectionFound = false;
1184  // get lanes
1185  const auto lane = lanes.at(laneIt);
1186  const auto nextLane = lanes.at(laneIt + 1);
1187  // check if both lanes are sidewalks
1188  if ((lane->getAttribute(SUMO_ATTR_ALLOW) == "pedestrian") && (nextLane->getAttribute(SUMO_ATTR_ALLOW) == "pedestrian")) {
1189  connectionFound = true;
1190  }
1191  // if there is a connection between "from" lane and "to" lane of connection, change connectionFound to true
1192  for (const auto& connection : lane->getParentEdge()->getNBEdge()->getConnections()) {
1193  if ((connection.toEdge == nextLane->getParentEdge()->getNBEdge()) &&
1194  (connection.fromLane == lane->getIndex()) &&
1195  (connection.toLane == nextLane->getIndex())) {
1196  connectionFound = true;
1197  }
1198  }
1199  // abort if connectionFound is false
1200  if (!connectionFound) {
1201  return false;
1202  }
1203  // update iterator
1204  laneIt++;
1205  }
1206  // there are connections between all lanes, then return true
1207  return true;
1208 }
1209 
1210 
1211 bool
1213  // throw exception because this function mus be implemented in child (see GNEE3Detector)
1214  throw ProcessError(StringUtils::format("Calling non-implemented function checkChildAdditionalRestriction during saving of %. It muss be reimplemented in child class", getTagStr()));
1215 }
1216 
1217 
1218 void
1220  const Position& pos, const double rot, const RGBColor& baseColor, const double fromAngle, const double toAngle,
1221  const bool /* ignoreShift */) const {
1222  // check if draw geometry point
1224  // push matrix
1226  // translated to front
1227  glTranslated(0, 0, 0.1);
1228  // set color depending if check if mouse is over element
1229  GLHelper::setColor(baseColor.changedBrightness(-50));
1230  // translate and rotate
1231  glTranslated(pos.x(), pos.y(), 0.1);
1232  glRotated(rot, 0, 0, 1);
1233  // draw geometry point
1235  // pop geometry point matrix
1237  }
1238 }
1239 
1240 
1241 std::string
1242 GNEAdditional::adjustListedAdditionalText(const std::string& text) const {
1243  // 10 + 3 + 10
1244  if (text.size() <= 23) {
1245  return text;
1246  } else {
1247  // get text size
1248  const int textPosition = (int)text.size() - 10;
1249  // declare strings
1250  std::string partA, partB;
1251  // resize
1252  partA.reserve(10);
1253  partB.reserve(10);
1254  // fill both
1255  for (int i = 0; i < 10; i++) {
1256  partA.push_back(text.at(i));
1257  partB.push_back(text.at(textPosition + i));
1258  }
1259  // return composition
1260  return (partA + "..." + partB);
1261  }
1262 }
1263 
1264 /****************************************************************************/
@ NETWORK_DELETE
mode for deleting network elements
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_SELECT
mode for selecting network elements
@ DEMAND_PERSONPLAN
Mode for editing person plan.
@ DEMAND_CONTAINER
Mode for editing container.
@ DEMAND_PERSON
Mode for editing person.
@ DEMAND_CONTAINERPLAN
Mode for editing container plan.
@ MID_COPY_TYPED_NAME
Copy typed object name - popup entry.
Definition: GUIAppEnum.h:453
@ MID_OPEN_ADDITIONAL_DIALOG
open additional dialog (used in netedit)
Definition: GUIAppEnum.h:465
@ MID_COPY_NAME
Copy object name - popup entry.
Definition: GUIAppEnum.h:451
GUIGlObjectType
@ GLO_JPS_WALKABLEAREA
walkable area
@ GLO_MAX
empty max
@ GLO_PARENTCHILDLINE
line between parent and childrens
@ GLO_JPS_OBSTACLE
obstacles
GUIViewObjectsHandler gViewObjectsHandler
@ JPS_WALKABLEAREA
@ JPS_OBSTACLE
GUITexture
An enumeration of gifs used by the gui applications.
Definition: GUITextures.h:31
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_PARKING_AREA_REROUTE
entry for an alternative parking zone
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ GNE_TAG_JPS_OBSTACLE
polygon used for draw juPedSim obstacles
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_TAZREL
a relation between two TAZs
@ GNE_TAG_JPS_WALKABLEAREA
polygon used for draw juPedSim walkable areas
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_NAME
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_FROM_TAZ
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
bool isInitialised() const
check if Boundary is Initialised
Definition: Boundary.cpp:235
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:655
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:968
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:295
static void drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
Definition: GLHelper.cpp:540
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void 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:757
bool checkDrawDeleteContour() const
check if draw delete contour (pink/white)
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
virtual std::string getAttribute(SumoXMLAttr key) const =0
GNELane * getLastPathLane() const
get last path lane
bool isValidAdditionalID(const std::string &value) const
check if a new additional ID is valid
virtual void updateGeometry()=0
update pre-computed geometry information
void deleteGLObject()
delete element
GUIGlObject * getGUIGlObject()
get GUIGlObject associated with this AttributeCarrier
void replaceAdditionalParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace additional parent
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
virtual bool isAdditionalValid() const =0
check if current additional is valid to be written into XML (by default true, can be reimplemented in...
virtual std::string getAdditionalProblem() const =0
return a string with the current additional problem (by default empty, can be reimplemented in childr...
std::string adjustListedAdditionalText(const std::string &text) const
adjust listed additional text
virtual void openAdditionalDialog()
open Additional Dialog
static std::string getJuPedSimType(SumoXMLTag tag)
get JuPedSim type
bool checkDrawSelectContour() const
check if draw select contour (blue)
void replaceAdditionalChildLanes(const std::string &value)
replace additional child lanes
void drawListedAdditional(const GUIVisualizationSettings &s, const Position &parentPosition, const double offsetX, const double extraOffsetY, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
void setAdditionalID(const std::string &newID)
set additional ID
GNEContour myAdditionalContour
variable used for draw additional contours
bool isPathElementSelected() const
check if path element is selected
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
bool checkDrawFromContour() const
check if draw from contour (green)
void replaceAdditionalParentEdges(const std::string &value)
replace additional parent edges
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
GNELane * getFirstPathLane() const
get first path lane
static FXIcon * getJuPedSimIcon(SumoXMLTag tag)
get JuPedSim icon
bool isValidDetectorID(const std::string &value) const
check if a new detector ID is valid
void drawUpGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw up geometry point
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
void shiftLaneIndex()
shift lane index
virtual Position getAttributePosition(SumoXMLAttr key) const
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
GNEAdditional(const std::string &id, GNENet *net, GUIGlObjectType type, SumoXMLTag tag, FXIcon *icon, std::string additionalName, const std::vector< GNEJunction * > &junctionParents, const std::vector< GNEEdge * > &edgeParents, const std::vector< GNELane * > &laneParents, const std::vector< GNEAdditional * > &additionalParents, const std::vector< GNEDemandElement * > &demandElementParents, const std::vector< GNEGenericData * > &genericDataParents)
Constructor.
void calculatePerpendicularLine(const double endLaneposition)
calculate perpendicular line between lane parents
GNEMoveOperation * getMoveOperationMultiLane(const double startPos, const double endPos)
get moveOperation for an element over multi lane
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
std::string myAdditionalName
name of additional
void selectGLObject()
select element
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
virtual void drawLanePartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over lane.
void drawDemandElementChildren(const GUIVisualizationSettings &s) const
draw demand element children
static double getJuPedSimLayer(SumoXMLTag tag)
get JuPedSim color
void updateGLObject()
update GLObject (geometry, ID, etc.)
void setSpecialColor(const RGBColor *color)
set special color
const RGBColor * mySpecialColor
pointer to special color (used for drawing Additional with a certain color, mainly used for selection...
bool checkDrawToContour() const
check if draw from contour (magenta)
void drawSquaredAdditional(const GUIVisualizationSettings &s, const Position &pos, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
virtual bool checkChildAdditionalRestriction() const
check restriction with the number of children
void drawSemiCircleGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const double fromAngle, const double toAngle, const bool ignoreShift) const
draw geometry point
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
bool isGLObjectLocked() const
check if element is locked
void replaceAdditionalChildEdges(const std::string &value)
replace additional child edges
virtual void computePathElement()
compute pathElement
virtual void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNEPathManager::Segment *segment, const double offsetFront) const
Draws partial object over junction.
void drawDownGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw down geometry point
void calculateContourPolygons(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const bool contouredShape) const
calculate contour for polygons
static RGBColor getJuPedSimColor(SumoXMLTag tag)
get JuPedSim color
int getDrawPositionIndex() const
get draw position index (used in rerouters and VSS)
const GUIGeometry & getAdditionalGeometry() const
obtain additional geometry
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void replaceDemandElementParent(SumoXMLTag tag, const std::string &value, const int parentIndex)
replace demand element parent
static bool getJuPedSimFill(SumoXMLTag tag)
get JuPedSim fill
~GNEAdditional()
Destructor.
const std::string & getOptionalAdditionalName() const
Returns the additional name.
GNEMoveOperation * getMoveOperationSingleLane(const double startPos, const double endPos)
get moveOperation for an element over single lane
virtual Position getPositionInView() const =0
Returns position of additional in view.
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position (Currently unused in shapes)
bool checkDrawRelatedContour() const
check if draw related contour (cyan)
static GUIGlObjectType getJuPedSimGLO(SumoXMLTag tag)
get GLO color
virtual void fixAdditionalProblem()=0
fix additional problem (by default throw an exception, has to be reimplemented in children)
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
void markAsFrontElement()
mark element as front element
bool checkDrawOverContour() const
check if draw over contour (orange)
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
FXIcon * getACIcon() const
get FXIcon associated to this AC
bool mySelected
boolean to check if this AC is selected (instead of GUIGlObjectStorage)
bool myIsTemplate
whether the current object is a template object (not drawn in the view)
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
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.
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
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanSelector * getPlanSelector() const
get containerPlan selector
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset) const
calculate contour extruded (used in elements formed by a central shape)
Definition: GNEContour.cpp:88
void calculateContourAllGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double radius, const double scale, const bool calculatePosOverShape) const
calculate contour for all geometry points
Definition: GNEContour.cpp:190
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double offsetX, const double offsetY, const double rot, const double scale) const
calculate contour (for rectangled elements)
Definition: GNEContour.cpp:103
void drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
drawing contour functions
Definition: GNEContour.cpp:263
Boundary getContourBoundary() const
get contour boundary
Definition: GNEContour.cpp:59
void calculateContourClosedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double scale) const
calculate contours
Definition: GNEContour.cpp:75
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:683
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:1047
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
void replaceChildElements(T *elementChild, const U &newChildren)
replace child elements
const std::vector< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
const PositionVector & getLaneShape() const
get elements shape
Definition: GNELane.cpp:214
int getIndex() const
returns the index of the lane
Definition: GNELane.cpp:642
GNEEdge * getParentEdge() const
get parent edge
Definition: GNELane.cpp:196
bool getAllowChangeLane() const
allow change lane
bool getMoveWholePolygons() const
move whole polygons
NetworkModeOptions * getNetworkModeOptions() const
get network mode options
CommonModeOptions * getCommonModeOptions() const
get common mode options
move operation
GNELane * retrieveLane(const std::string &id, bool hardFail=true, bool checkVolatileChange=false) const
get lane by id
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
GNEAdditional * retrieveAdditionals(const std::vector< SumoXMLTag > types, const std::string &id, bool hardFail=true) const
Returns the named additional.
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.
void requireSaveDataElements()
inform that data elements has to be saved
void requireSaveDemandElements()
inform that demand elements has to be saved
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void deleteAdditional(GNEAdditional *additional, GNEUndoList *undoList)
remove additional
Definition: GNENet.cpp:650
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:127
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:2056
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanSelector * getPlanSelector() const
get personPlan selector
GNEPlanCreator * getPlanCreator() const
get plan creator module
GNEPlanSelector * getPlanSelector() const
get personPlan selector
GNEAdditional * getFromContainerStop() const
get from container stop
GNEAdditional * getFromTAZ() const
get from TAZ
GNEAdditional * getFromTrainStop() const
get from train stop
GNEAdditional * getToContainerStop() const
get to container stop
GNEAdditional * getFromBusStop() const
get from bus stop
GNEAdditional * getToTAZ() const
get to TAZ
GNEAdditional * getToTrainStop() const
get to train stop
GNEAdditional * getToBusStop() const
get to bus stop
void updateInformationLabel()
update information label
SelectionInformation * getSelectionInformation() const
get modul for selection information
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
bool hasDialog() const
return true if tag correspond to an element that can be edited using a dialog
bool hasAttribute(SumoXMLAttr attr) const
check if current TagProperties owns the attribute "attr"
GNEAttributeCarrier * getCurrentTemplateAC() const
get current templateAC
GNETagSelector * getVehicleTagSelector() const
get vehicle tag selector (needed for transform vehicles)
bool isObjectLocked(GUIGlObjectType objectType, const bool selected) const
check if given GLObject is locked for inspect, select, delete and move
const GUIGlObject * getGUIGlObjectFront() const
get front attribute carrier or a pointer to nullptr
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
Definition: GNEViewNet.cpp:727
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:703
void setFrontAttributeCarrier(GNEAttributeCarrier *AC)
set front attributeCarrier
const GNEViewNetHelper::MouseButtonKeyPressed & getMouseButtonKeyPressed() const
get Key Pressed module
Definition: GNEViewNet.cpp:733
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
GNEUndoList * getUndoList() const
get the undoList object
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
Definition: GNEViewNet.cpp:468
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
GNEViewNetHelper::LockManager & getLockManager()
get lock manager
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:538
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
GNEPersonPlanFrame * getPersonPlanFrame() const
get frame for DEMAND_PERSONFRAME
GNETAZRelDataFrame * getTAZRelDataFrame() const
get frame for DATA_TAZRELDATA
GNEMoveFrame * getMoveFrame() const
get frame for move elements
GNESelectorFrame * getSelectorFrame() const
get frame for select elements
GNEContainerPlanFrame * getContainerPlanFrame() const
get frame for DEMAND_CONTAINERFRAME
GNEVehicleFrame * getVehicleFrame() const
get frame for DEMAND_VEHICLE
GNEContainerFrame * getContainerFrame() const
get frame for DEMAND_CONTAINER
GNEPersonFrame * getPersonFrame() const
get frame for DEMAND_PERSON
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
Definition: GUIDesigns.cpp:42
The popup menu of a globject.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between child and parent (used in netedit)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:59
static void drawParentLine(const GUIVisualizationSettings &s, const Position &parent, const Position &child, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between parent and children (used in netedit)
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.
Definition: GUIGlObject.h:156
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:143
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
bool isElementSelected(const GUIGlObject *GLObject) const
check if element was already selected
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationSizeSettings addSize
GUIVisualizationTextSettings addFullName
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:638
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double x() const
Returns the x-position.
Definition: Position.h:55
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:132
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
double length2D() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
static bool isValidAdditionalID(const std::string &value)
whether the given string is a valid id for an additional object
static bool isValidDetectorID(const std::string &value)
whether the given string is a valid id for an detector
static const std::string format(const std::string &format, T value, Targs... Fargs)
adds a new formatted message
Definition: StringUtils.h:176
@ FONS_ALIGN_MIDDLE
Definition: fontstash.h:47
@ FONS_ALIGN_LEFT
Definition: fontstash.h:42
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static bool checkDrawing(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const double exaggeration)
check if icon can be drawn
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool shiftKeyPressed() const
check if SHIFT is pressed during current event
static const RGBColor connectionColor
connection color
static const RGBColor connectionColorSelected
connection color selected
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double segmentWidth
width of dotted contour segments
static const double polygonGeometryPointRadius
moving geometry point radius
static const double additionalGeometryPointRadius
moving additional geometry point radius
static const double polylineWidth
poly line width
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