Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNELane.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-2026 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/****************************************************************************/
19// A class for visualizing Lane geometry (adapted from GNELaneWrapper)
20/****************************************************************************/
21
22#include <netbuild/NBEdgeCont.h>
33#include <netedit/GNENet.h>
41
42#include "GNELane.h"
43#include "GNEInternalLane.h"
44#include "GNEConnection.h"
45#include "GNEEdgeTemplate.h"
46
47// ===========================================================================
48// FOX callback mapping
49// ===========================================================================
50
51// Object implementation
52FXIMPLEMENT(GNELane, FXDelegator, 0, 0)
53
54// ===========================================================================
55// method definitions
56// ===========================================================================
57
58// ---------------------------------------------------------------------------
59// GNELane::LaneDrawingConstants - methods
60// ---------------------------------------------------------------------------
61
63 myLane(lane) {
64}
65
66
67void
69 // get NBEdge
70 const auto& NBEdge = myLane->getParentEdge()->getNBEdge();
71 // get lane struct
72 const auto& laneStruct = myLane->getParentEdges().front()->getNBEdge()->getLaneStruct(myLane->getIndex());
73 // get selection scale
74 const double selectionScale = myLane->isAttributeCarrierSelected() || myLane->getParentEdges().front()->isAttributeCarrierSelected() ? s.selectorFrameScale : 1;
75 // get lane width
76 const double laneWidth = (laneStruct.width == -1 ? SUMO_const_laneWidth : laneStruct.width);
77 // calculate exaggeration
78 myExaggeration = selectionScale * s.laneWidthExaggeration;
79 // get detail level
81 // check if draw lane as railway
82 myDrawAsRailway = isRailway(laneStruct.permissions) && ((laneStruct.permissions & SVC_BUS) == 0) && s.showRails;
83 // adjust rest of parameters depending if draw as railway
84 if (myDrawAsRailway) {
85 // draw as railway: assume standard gauge of 1435mm when lane width is not set
86 myDrawingWidth = (laneWidth == SUMO_const_laneWidth ? 1.4350 : laneWidth) * myExaggeration;
87 // calculate internal drawing width
89 } else {
90 // calculate exaggerated drawing width
91 myDrawingWidth = laneWidth * myExaggeration * 0.5;
92 // calculate internal drawing width
94 }
95 // check if draw superposed
97 // adjust parameters depending of superposing
98 if (myDrawSuperposed) {
99 // apply offset
100 myOffset = myDrawingWidth * 0.5;
101 // reduce width
102 myDrawingWidth *= 0.4;
104 } else {
105 // restore offset
106 myOffset = 0;
107 }
108}
109
110
111double
113 return myExaggeration;
114}
115
116
117double
119 return myDrawingWidth;
120}
121
122
123double
125 return myInternalDrawingWidth;
126}
127
128
129double
131 return myOffset;
132}
133
134
137 return myDetail;
138}
139
140
141bool
143 return myDrawAsRailway;
144}
145
146
147bool
149 return myDrawSuperposed;
150}
151
152
153// ---------------------------------------------------------------------------
154// GNELane - methods
155// ---------------------------------------------------------------------------
156#ifdef _MSC_VER
157#pragma warning(push)
158#pragma warning(disable: 4355) // mask warning about "this" in initializers
159#endif
160GNELane::GNELane(GNEEdge* edge, const int index) :
161 GNENetworkElement(edge->getNet(), edge->getNBEdge()->getLaneID(index), SUMO_TAG_LANE),
163 myIndex(index),
165 mySpecialColor(nullptr),
168 // set parents
169 setParent<GNEEdge*>(edge);
170 // update centering boundary without updating grid
172}
173
174
176 GNENetworkElement(nullptr, "dummyConstructorGNELane", SUMO_TAG_LANE),
177 myMoveElementLane(new GNEMoveElementLane(this)),
178 myIndex(-1),
179 myDrawingConstants(nullptr),
180 mySpecialColor(nullptr),
181 mySpecialColorValue(-1),
182 myLane2laneConnections(this) {
183}
184#ifdef _MSC_VER
185#pragma warning(pop)
186#endif
187
189 if (myDrawingConstants) {
190 delete myDrawingConstants;
191 }
192}
193
194
199
200
203 return &(getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex));
204}
205
206
207const Parameterised*
209 return &(getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex));
210}
211
212
213GNEEdge*
215 return getParentEdges().front();
216}
217
218
219bool
221 return (getParentEdges().front()->getNBEdge()->getPermissions(myIndex) & SVC_PEDESTRIAN) > 0;
222}
223
224
225const GUIGeometry&
227 return myLaneGeometry;
228}
229
230
231const PositionVector&
233 if (getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 0) {
234 return getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape;
235 } else {
236 return getParentEdges().front()->getNBEdge()->getLaneShape(myIndex);
237 }
238}
239
240
241const std::vector<double>&
245
246
247const std::vector<double>&
251
252
257
258
259void
261 // Clear texture containers
264 // get lane shape and extend if is too short
265 auto laneShape = getLaneShape();
266 if (laneShape.length2D() < 1) {
267 laneShape.extrapolate2D(1 - laneShape.length2D());
268 }
269 // Obtain lane shape of NBEdge
271 // update connections
273 // update additionals children associated with this lane
274 for (const auto& additional : getParentAdditionals()) {
275 additional->updateGeometry();
276 }
277 // update additionals parents associated with this lane
278 for (const auto& additional : getChildAdditionals()) {
279 additional->updateGeometry();
280 }
281 // update partial demand elements parents associated with this lane
282 for (const auto& demandElement : getParentDemandElements()) {
283 demandElement->updateGeometry();
284 }
285 // update partial demand elements children associated with this lane
286 for (const auto& demandElement : getChildDemandElements()) {
287 demandElement->updateGeometry();
288 }
289 // Update geometry of parent generic datas that have this edge as parent
290 for (const auto& additionalParent : getParentGenericDatas()) {
291 additionalParent->updateGeometry();
292 }
293 // Update geometry of additionals generic datas vinculated to this edge
294 for (const auto& childAdditionals : getChildGenericDatas()) {
295 childAdditionals->updateGeometry();
296 }
297 // compute geometry of path elements elements vinculated with this lane (depending of showDemandElements)
299 for (const auto& childAdditional : getChildAdditionals()) {
300 childAdditional->computePathElement();
301 }
302 for (const auto& childDemandElement : getChildDemandElements()) {
303 childDemandElement->computePathElement();
304 }
305 for (const auto& childGenericData : getChildGenericDatas()) {
306 childGenericData->computePathElement();
307 }
308 }
309 // in Move mode, connections aren't updated
311 // Update incoming connections of this lane
312 const auto incomingConnections = getGNEIncomingConnections();
313 for (const auto& connection : incomingConnections) {
314 connection->updateGeometry();
315 }
316 // Update outgoings connections of this lane
317 const auto outGoingConnections = getGNEOutcomingConnections();
318 for (const auto& connection : outGoingConnections) {
319 connection->updateGeometry();
320 }
321 }
322 // if lane has enought length for show textures of restricted lanes
323 if ((getLaneShapeLength() > 4)) {
324 // if lane is restricted
326 // get values for position and rotation of icons
327 for (int i = 2; i < getLaneShapeLength() - 1; i += 15) {
330 }
331 }
332 }
333}
334
335
338 return getLaneShape().positionAtOffset2D(getLaneShape().length2D() * 0.5);
339}
340
341
342bool
344 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
345 // check if we're inspecting a connection
346 if (inspectedElements.isInspectingSingleElement() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) &&
347 inspectedElements.getFirstAC()->getAttribute(GNE_ATTR_FROM_LANEID) == getID()) {
348 return true;
349 } else {
350 return false;
351 }
352}
353
354
355bool
357 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
358 // check if we're inspecting a connection
359 if (inspectedElements.isInspectingSingleElement() && (inspectedElements.getFirstAC()->getTagProperty()->getTag() == SUMO_TAG_CONNECTION) &&
360 inspectedElements.getFirstAC()->getAttribute(GNE_ATTR_TO_LANEID) == getID()) {
361 return true;
362 } else {
363 return false;
364 }
365}
366
367
368bool
370 // check opened popup
371 if (myNet->getViewNet()->getPopup()) {
372 return myNet->getViewNet()->getPopup()->getGLObject() == this;
373 }
374 return false;
375}
376
377
378bool
380 // get modes and viewParent (for code legibility)
381 const auto& modes = myNet->getViewNet()->getEditModes();
382 const auto& viewParent = myNet->getViewParent();
383 // check if we're selecting edges in additional mode
384 if (modes.isCurrentSupermodeNetwork() && (modes.networkEditMode == NetworkEditMode::NETWORK_ADDITIONAL)) {
385 if (viewParent->getAdditionalFrame()->getViewObjetsSelector()->isNetworkElementSelected(this)) {
386 return true;
387 } else if (viewParent->getAdditionalFrame()->getViewObjetsSelector()->getTag() == myTagProperty->getTag()) {
389 } else {
390 return false;
391 }
392 } else {
393 return false;
394 }
395}
396
397
398bool
400 // first check if we're selecting edges or lanes
402 return false;
403 } else {
404 // get edit modes
405 const auto& editModes = myNet->getViewNet()->getEditModes();
406 // check if we're in delete mode
407 if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_DELETE)) {
409 } else {
410 return false;
411 }
412 }
413}
414
415
416bool
418 return false;
419}
420
421
422bool
424 // first check if we're selecting edges or lanes
426 return false;
427 } else {
428 // get edit modes
429 const auto& editModes = myNet->getViewNet()->getEditModes();
430 // check if we're in select mode
431 if (editModes.isCurrentSupermodeNetwork() && (editModes.networkEditMode == NetworkEditMode::NETWORK_SELECT)) {
433 } else {
434 return false;
435 }
436 }
437}
438
439
440bool
442 // check if we're editing this network element
444 if (editedNetworkElement) {
445 return editedNetworkElement == this;
446 } else {
447 return false;
448 }
449}
450
451
452void
454 // update lane drawing constan
456 // calculate layer
457 double layer = GLO_LANE;
458 if (getParentEdges().front()->isMarkedForDrawingFront()) {
459 layer = GLO_FRONTELEMENT;
461 layer = GLO_JUNCTION + 2;
462 }
463 // check drawing conditions
465 // draw lane
466 drawLane(s, layer);
467 // draw lock icon
469 // draw dotted contour
471 }
472 // calculate contour (always before children)
473 calculateLaneContour(s, layer);
474 // draw children
475 drawChildren(s);
476}
477
478
479void
481 // Check if edge can be deleted
483 myNet->deleteLane(this, myNet->getUndoList(), false);
484 }
485}
486
487
488void
492
493
494
497 // first obtain edit mode (needed because certain Commands depend of current edit mode)
499 // get mouse position
500 const auto mousePosition = myNet->getViewNet()->getPositionInformation();
501 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, this);
502 buildPopupHeader(ret, app);
504 // build copy names entry
505 if (editMode != NetworkEditMode::NETWORK_TLS) {
506 GUIDesigns::buildFXMenuCommand(ret, TL("Copy parent edge name to clipboard"), nullptr, ret, MID_COPY_EDGE_NAME);
508 }
509 // stop if we're in data mode
511 return ret;
512 }
513 // build lane selection
516 } else {
518 }
519 // build edge selection
522 } else {
524 }
525 // stop if we're in data mode
527 return ret;
528 }
529 // add separator
530 new FXMenuSeparator(ret);
531 if (editMode != NetworkEditMode::NETWORK_TLS) {
532 // build show parameters menu
534 // build position copy entry
535 buildPositionCopyEntry(ret, app);
536 }
537 // check if we're in supermode network
539 // create end point
540 FXMenuCommand* resetEndPoints = GUIDesigns::buildFXMenuCommand(ret, TL("Reset edge end points"), nullptr, &parent, MID_GNE_RESET_GEOMETRYPOINT);
541 // enable or disable reset end points
542 if (getParentEdges().front()->hasCustomEndPoints()) {
543 resetEndPoints->enable();
544 } else {
545 resetEndPoints->disable();
546 }
547 // check if we clicked over a geometry point
548 if ((editMode == NetworkEditMode::NETWORK_MOVE) && getParentEdges().front()->clickedOverGeometryPoint(mousePosition)) {
549 GUIDesigns::buildFXMenuCommand(ret, TL("Set custom Geometry Point"), nullptr, &parent, MID_GNE_CUSTOM_GEOMETRYPOINT);
550 }
551 // add separator
552 new FXMenuSeparator(ret);
553 //build operations
554 if ((editMode != NetworkEditMode::NETWORK_CONNECT) && (editMode != NetworkEditMode::NETWORK_TLS)) {
555 // build edge operations
556 buildEdgeOperations(parent, ret);
557 // build lane operations
558 buildLaneOperations(parent, ret);
559 // build template operations
560 buildTemplateOperations(parent, ret);
561 // add separator
562 new FXMenuSeparator(ret);
563 // build rechable operations
564 buildRechableOperations(parent, ret);
565 } else if (editMode == NetworkEditMode::NETWORK_TLS) {
567 GUIDesigns::buildFXMenuCommand(ret, TL("Select state for all links from this edge:"), nullptr, nullptr, 0);
568 const std::vector<std::string> names = GNEInternalLane::LinkStateNames.getStrings();
569 for (auto it : names) {
570 FXuint state = GNEInternalLane::LinkStateNames.get(it);
571 FXMenuRadio* mc = new FXMenuRadio(ret, it.c_str(), this, FXDataTarget::ID_OPTION + state);
574 }
575 }
576 } else {
577 FXMenuCommand* mc = GUIDesigns::buildFXMenuCommand(ret, TL("Additional options available in 'Inspect Mode'"), nullptr, nullptr, 0);
578 mc->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), nullptr);
579 }
580 // build shape positions menu
581 if (editMode != NetworkEditMode::NETWORK_TLS) {
582 new FXMenuSeparator(ret);
583 // get lane shape
584 const auto& laneShape = myLaneGeometry.getShape();
585 // get variables
586 const double pos = laneShape.nearest_offset_to_point2D(mousePosition);
587 const Position firstAnglePos = laneShape.positionAtOffset2D(pos - 0.001);
588 const Position secondAnglePos = laneShape.positionAtOffset2D(pos);
589 const double angle = firstAnglePos.angleTo2D(secondAnglePos);
590
591 // build menu commands
592 GUIDesigns::buildFXMenuCommand(ret, TL("Shape pos: ") + toString(pos), nullptr, nullptr, 0);
593 GUIDesigns::buildFXMenuCommand(ret, TL("Length pos: ") + toString(pos * getLaneParametricLength() / getLaneShapeLength()), nullptr, nullptr, 0);
594 if (getParentEdges().front()->getNBEdge()->getDistance() != 0) {
595 GUIDesigns::buildFXMenuCommand(ret, TL("Distance: ") + toString(getParentEdges().front()->getNBEdge()->getDistancAt(pos)), nullptr, nullptr, 0);
596 }
597 GUIDesigns::buildFXMenuCommand(ret, TL("Height: ") + toString(firstAnglePos.z()), nullptr, nullptr, 0);
598 GUIDesigns::buildFXMenuCommand(ret, TL("Angle: ") + toString((GeomHelper::naviDegree(angle))), nullptr, nullptr, 0);
599 }
600 }
601 return ret;
602}
603
604
605double
607 return s.addSize.getExaggeration(s, this);
608}
609
610
615
616
617void
618GNELane::updateCenteringBoundary(const bool /*updateGrid*/) {
619 // nothing to update
620}
621
622
623int
625 return myIndex;
626}
627
628
629void
631 myIndex = index;
632 setNetworkElementID(getParentEdges().front()->getNBEdge()->getLaneID(index));
633}
634
635
636double
638 return getParentEdges().front()->getNBEdge()->getLaneSpeed(myIndex);
639}
640
641
642double
644 double laneParametricLength = getParentEdges().front()->getNBEdge()->getLoadedLength();
645 if (laneParametricLength > 0) {
646 return laneParametricLength;
647 } else {
648 throw ProcessError(TL("Lane Parametric Length cannot be never 0"));
649 }
650}
651
652
653double
657
658
659bool
661 return getParentEdges().front()->getNBEdge()->getPermissions(myIndex) == vclass;
662}
663
664
669
670
671std::string
673 const NBEdge* edge = getParentEdges().front()->getNBEdge();
674 switch (key) {
675 case SUMO_ATTR_ID:
676 return getMicrosimID();
678 return getParentEdges().front()->getFromJunction()->getID();
680 return getParentEdges().front()->getToJunction()->getID();
681 case SUMO_ATTR_SPEED:
682 return toString(edge->getLaneSpeed(myIndex));
683 case SUMO_ATTR_ALLOW:
691 case SUMO_ATTR_WIDTH:
693 return "default";
694 } else {
695 return toString(edge->getLaneStruct(myIndex).width);
696 }
698 return toString(edge->getLaneStruct(myIndex).friction);
703 case SUMO_ATTR_SHAPE:
708 case SUMO_ATTR_TYPE:
709 return edge->getLaneStruct(myIndex).type;
710 case SUMO_ATTR_INDEX:
711 return toString(myIndex);
717 } else {
718 return "";
719 }
720 case GNE_ATTR_PARENT:
721 return getParentEdges().front()->getID();
722 default:
723 return getCommonAttribute(key);
724 }
725}
726
727
728double
732
733
738
739
742 switch (key) {
743 case SUMO_ATTR_SHAPE:
745 return getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape;
746 default:
748 }
749}
750
751
752std::string
754 std::string result = getAttribute(key);
755 if ((key == SUMO_ATTR_ALLOW || key == SUMO_ATTR_DISALLOW) && result.find("all") != std::string::npos) {
756 result += " " + getVehicleClassNames(SVCAll, true);
757 }
758 return result;
759}
760
761
762void
763GNELane::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
764 switch (key) {
765 case SUMO_ATTR_ID:
766 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
767 case SUMO_ATTR_SPEED:
768 case SUMO_ATTR_ALLOW:
772 case SUMO_ATTR_WIDTH:
776 case SUMO_ATTR_SHAPE:
779 case SUMO_ATTR_TYPE:
780 case SUMO_ATTR_INDEX:
782 // special case for stop offset, because affects to stopOffsetExceptions (#15297)
783 if (canParse<double>(value) && (parse<double>(value) == 0)) {
785 }
786 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
787 break;
789 GNEChange_Attribute::changeAttribute(this, key, value, undoList);
790 break;
791 default:
792 setCommonAttribute(key, value, undoList);
793 break;
794 }
795}
796
797
798bool
799GNELane::isValid(SumoXMLAttr key, const std::string& value) {
800 switch (key) {
801 case SUMO_ATTR_ID:
802 case SUMO_ATTR_INDEX:
803 return false;
804 case SUMO_ATTR_SPEED:
805 return canParse<double>(value);
806 case SUMO_ATTR_ALLOW:
810 return canParseVehicleClasses(value);
811 case SUMO_ATTR_WIDTH:
812 if (value.empty() || (value == "default")) {
813 return true;
814 } else {
815 return canParse<double>(value) && ((parse<double>(value) > 0) || (parse<double>(value) == NBEdge::UNSPECIFIED_WIDTH));
816 }
819 return canParse<double>(value) && (parse<double>(value) >= 0);
821 return canParse<bool>(value);
822 case SUMO_ATTR_SHAPE:
824 // A lane shape can either be empty or have more than 1 element
825 if (value.empty()) {
826 return true;
827 } else if (canParse<PositionVector>(value)) {
828 return parse<PositionVector>(value).size() > 1;
829 }
830 return false;
831 case GNE_ATTR_OPPOSITE: {
832 if (value.empty()) {
833 return true;
834 } else {
835 NBEdge* oppEdge = myNet->getEdgeCont().retrieve(value.substr(0, value.rfind("_")));
836 if (oppEdge == nullptr || oppEdge->getLaneID(oppEdge->getNumLanes() - 1) != value) {
837 return false;
838 }
839 NBEdge* edge = getParentEdges().front()->getNBEdge();
840 if (oppEdge->getFromNode() != edge->getToNode() || oppEdge->getToNode() != edge->getFromNode()) {
841 WRITE_WARNINGF(TL("Opposite lane '%' does not connect the same nodes as edge '%'!"), value, edge->getID());
842 return false;
843 }
844 return true;
845 }
846 }
847 case SUMO_ATTR_TYPE:
848 return true;
850 return canParse<double>(value) && (parse<double>(value) >= 0);
852 return canParseVehicleClasses(value);
853 default:
854 return isCommonAttributeValid(key, value);
855 }
856}
857
858
859bool
861 switch (key) {
862 case SUMO_ATTR_ID:
863 case SUMO_ATTR_INDEX:
864 return false;
866 return getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).laneStopOffset.getOffset() > 0;
867 default:
868 return true;
869 }
870}
871
872
873bool
875 const NBEdge* edge = getParentEdges().front()->getNBEdge();
876 switch (key) {
877 case SUMO_ATTR_WIDTH:
879 default:
880 return false;
881 }
882}
883
884
885void
886GNELane::setSpecialColor(const RGBColor* color, double colorValue) {
887 mySpecialColor = color;
888 mySpecialColorValue = colorValue;
889}
890
891// ===========================================================================
892// private
893// ===========================================================================
894
895void
896GNELane::setAttribute(SumoXMLAttr key, const std::string& value) {
897 // get parent edge
898 NBEdge* edge = getParentEdges().front()->getNBEdge();
899 // get template editor
901 // check if we have to update template
902 const bool updateTemplate = templateEditor->getEdgeTemplate() ? (templateEditor->getEdgeTemplate()->getID() == getParentEdges().front()->getID()) : false;
903 switch (key) {
904 case SUMO_ATTR_ID:
905 case SUMO_ATTR_INDEX:
906 throw InvalidArgument("Modifying attribute '" + toString(key) + "' of " + getTagStr() + " isn't allowed");
907 case SUMO_ATTR_SPEED:
908 edge->setSpeed(myIndex, parse<double>(value));
909 break;
910 case SUMO_ATTR_ALLOW:
912 break;
915 break;
918 break;
921 break;
922 case SUMO_ATTR_WIDTH:
923 if (value.empty() || (value == "default")) {
925 } else {
926 edge->setLaneWidth(myIndex, parse<double>(value));
927 }
928 // update edge parent boundary
929 getParentEdges().front()->updateCenteringBoundary(true);
930 break;
932 edge->setFriction(myIndex, parse<double>(value));
933 break;
935 edge->setEndOffset(myIndex, parse<double>(value));
936 break;
938 edge->setAcceleration(myIndex, parse<bool>(value));
939 break;
940 case SUMO_ATTR_SHAPE:
942 // set new shape
943 edge->setLaneShape(myIndex, parse<PositionVector>(value));
944 // update edge parent boundary
945 getParentEdges().front()->updateCenteringBoundary(true);
946 break;
947 case GNE_ATTR_OPPOSITE: {
948 if (value != "") {
949 NBEdge* oppEdge = myNet->getEdgeCont().retrieve(value.substr(0, value.rfind("_")));
950 oppEdge->getLaneStruct(oppEdge->getNumLanes() - 1).oppositeID = getID();
951 } else {
952 // reset prior oppEdge if existing
953 const std::string oldValue = getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).oppositeID;
954 NBEdge* oppEdge = myNet->getEdgeCont().retrieve(oldValue.substr(0, oldValue.rfind("_")));
955 if (oppEdge != nullptr) {
956 oppEdge->getLaneStruct(oppEdge->getNumLanes() - 1).oppositeID = "";
957 }
958 }
959 getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).oppositeID = value;
960 break;
961 }
962 case SUMO_ATTR_TYPE:
963 edge->getLaneStruct(myIndex).type = value;
964 break;
966 if (value.empty()) {
968 } else {
969 edge->getLaneStruct(myIndex).laneStopOffset.setOffset(parse<double>(value));
970 }
971 break;
974 break;
975 default:
976 setCommonAttribute(key, value);
977 break;
978 }
979 // update template
980 if (updateTemplate) {
981 templateEditor->setEdgeTemplate(getParentEdges().front());
982 }
983 // invalidate demand path calculator
985}
986
987
988void
989GNELane::drawLane(const GUIVisualizationSettings& s, const double layer) const {
990 // Push layer matrix
992 // translate to layer
993 drawInLayer(layer);
994 // set lane colors
995 RGBColor laneColor = setLaneColor(s);
996 // never draw when at full transparency
997 if (laneColor.alpha() != 0) {
998 // Check if lane has to be draw as railway and if isn't being drawn for selecting
1000 // draw as railway
1002 } else if (myShapeColors.size() > 0) {
1003 // draw geometry with own colors
1006 } else {
1007 // draw geometry with current color
1009 double drawingWidth = myDrawingConstants->getDrawingWidth();
1011 drawingWidth = myNet->getViewNet()->m2p(drawingWidth);
1012 }
1015 }
1016 // if lane is selected, draw a second lane over it
1018 // draw start end shape points
1020 // check if draw details
1022 // draw markings
1024 // Draw direction indicators
1026 // draw lane textures
1027 drawTextures(s);
1028 // draw lane arrows
1029 drawArrows(s);
1030 // draw link numbers
1031 drawLinkNo(s);
1032 // draw TLS link numbers
1033 drawTLSLinkNo(s);
1034 // draw stopOffsets
1036 }
1037 // draw shape edited
1038 drawShapeEdited(s);
1039 }
1040 // Pop layer matrix
1042}
1043
1044
1045void
1047 // only draw if lane is selected
1048 if (drawUsingSelectColor()) {
1049 // Push matrix
1051 // move back
1052 glTranslated(0, 0, 0.1);
1053 // set selected edge color
1055 // draw geometry with current color
1058 // Pop matrix
1060 }
1061}
1062
1063
1064void
1066 // if shape is being edited, draw point and green line
1067 if (myShapeEdited) {
1068 // push shape edited matrix
1070 // translate
1072 // set selected edge color
1074 // draw shape around
1077 // move front
1078 glTranslated(0, 0, 1);
1079 // draw geometry points
1084 // Pop shape edited matrix
1086 }
1087}
1088
1089
1090void
1092 // draw additional children
1093 for (const auto& additional : getChildAdditionals()) {
1094 if (!additional->getTagProperty()->isListedElement()) {
1095 additional->drawGL(s);
1096 }
1097 }
1098 // draw demand element children
1099 for (const auto& demandElement : getChildDemandElements()) {
1100 if (!demandElement->getTagProperty()->isPlacedInRTree()) {
1101 demandElement->drawGL(s);
1102 }
1103 }
1104 // draw path additional elements
1108}
1109
1110
1111void
1113 // check conditions
1115 // check if this is the last lane (note: First lane is the lane more far of the edge's center)
1116 const bool firstlane = (myIndex == 0);
1117 const bool lastLane = (myIndex == (getParentEdges().front()->getNBEdge()->getNumLanes() - 1));
1118 // declare separator width
1119 const auto separatorWidth = SUMO_const_laneMarkWidth * 0.5;
1120 // get passengers change left and right for previous, current and next lane
1121 const bool changeRightTop = lastLane ? true : getParentEdges().front()->getNBEdge()->allowsChangingRight(myIndex + 1, SVC_PASSENGER);
1122 const bool changeLeftCurrent = lastLane ? true : getParentEdges().front()->getNBEdge()->allowsChangingLeft(myIndex, SVC_PASSENGER);
1123 const bool changeRightCurrent = firstlane ? true : getParentEdges().front()->getNBEdge()->allowsChangingRight(myIndex, SVC_PASSENGER);
1124 const bool changeLeftBot = firstlane ? true : getParentEdges().front()->getNBEdge()->allowsChangingLeft(myIndex - 1, SVC_PASSENGER);
1125 // save current color
1126 const auto currentColor = GLHelper::getColor();
1127 // separator offsets
1128 const double topSeparatorOffset = myDrawingConstants->getOffset() + (myDrawingConstants->getDrawingWidth() * -1) + separatorWidth;
1129 const double botSeparatorOffset = myDrawingConstants->getOffset() + myDrawingConstants->getDrawingWidth() - separatorWidth;
1130 // push matrix
1132 // translate
1133 glTranslated(0, 0, 0.1);
1134 // continue depending of lanes
1135 if (myDrawingConstants->drawSuperposed() || (firstlane && lastLane)) {
1136 // draw top and bot separator only
1138 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, topSeparatorOffset);
1139 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, botSeparatorOffset);
1140 } else if (firstlane) {
1141 // draw top separator
1142 GLHelper::setColor((changeLeftCurrent && changeRightTop) ? RGBColor::WHITE : RGBColor::ORANGE);
1143 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, topSeparatorOffset);
1144 // check if draw inverse marking
1145 if (changeLeftCurrent) {
1146 GLHelper::setColor(currentColor);
1148 3, 6, topSeparatorOffset, true, true, s.lefthand, 1);
1149 }
1150 // draw bot separator
1152 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, botSeparatorOffset);
1153 } else if (lastLane) {
1154 // draw top separator
1156 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, topSeparatorOffset);
1157 // draw bot separator
1158 GLHelper::setColor((changeRightCurrent && changeLeftBot) ? RGBColor::WHITE : RGBColor::ORANGE);
1159 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, botSeparatorOffset);
1160 // check if draw inverse marking
1161 if (changeRightCurrent) {
1162 GLHelper::setColor(currentColor);
1164 3, 6, botSeparatorOffset, true, true, s.lefthand, 1);
1165 }
1166 } else {
1167 // draw top separator
1168 GLHelper::setColor((changeLeftCurrent && changeRightTop) ? RGBColor::WHITE : RGBColor::ORANGE);
1169 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, topSeparatorOffset);
1170 // check if draw inverse marking
1171 if (changeLeftCurrent) {
1172 GLHelper::setColor(currentColor);
1174 3, 6, topSeparatorOffset, true, true, s.lefthand, 1);
1175 }
1176 // draw bot separator
1177 GLHelper::setColor((changeRightCurrent && changeLeftBot) ? RGBColor::WHITE : RGBColor::ORANGE);
1178 GUIGeometry::drawGeometry(myDrawingConstants->getDetail(), myLaneGeometry, separatorWidth, botSeparatorOffset);
1179 // check if draw inverse marking
1180 if (changeRightCurrent) {
1181 GLHelper::setColor(currentColor);
1183 3, 6, botSeparatorOffset, true, true, s.lefthand, 1);
1184 }
1185 }
1186 // pop matrix
1188 }
1189}
1190
1191
1192void
1194 // check draw conditions
1195 if (s.drawLinkJunctionIndex.show(getParentEdges().front()->getToJunction())) {
1196 // get connections
1197 const auto& connections = getParentEdges().front()->getNBEdge()->getConnectionsFromLane(myIndex);
1198 // get number of links
1199 const int noLinks = (int)connections.size();
1200 // only continue if there is links
1201 if (noLinks > 0) {
1202 // push link matrix
1204 // move front
1205 glTranslated(0, 0, GLO_TEXTNAME);
1206 // calculate width
1207 const double width = getParentEdges().front()->getNBEdge()->getLaneWidth(myIndex) / (double) noLinks;
1208 // get X1
1209 double x1 = getParentEdges().front()->getNBEdge()->getLaneWidth(myIndex) / 2;
1210 // iterate over links
1211 for (int i = noLinks - 1; i >= 0; i--) {
1212 // calculate x2
1213 const double x2 = x1 - (double)(width / 2.);
1214 // get link index
1215 const int linkIndex = getParentEdges().front()->getNBEdge()->getToNode()->getConnectionIndex(getParentEdges().front()->getNBEdge(),
1216 connections[s.lefthand ? noLinks - 1 - i : i]);
1217 // draw link index
1219 // update x1
1220 x1 -= width;
1221 }
1222 // pop link matrix
1224 }
1225 }
1226}
1227
1228
1229void
1231 // check conditions
1233 (getParentEdges().front()->getToJunction()->getNBNode()->getControllingTLS().size() > 0)) {
1234 // get connections
1235 const auto& connections = getParentEdges().front()->getNBEdge()->getConnectionsFromLane(myIndex);
1236 // get numer of links
1237 const int noLinks = (int)connections.size();
1238 // only continue if there are links
1239 if (noLinks > 0) {
1240 // push link matrix
1242 // move t front
1243 glTranslated(0, 0, GLO_TEXTNAME);
1244 // calculate width
1245 const double w = getParentEdges().front()->getNBEdge()->getLaneWidth(myIndex) / (double) noLinks;
1246 // calculate x1
1247 double x1 = getParentEdges().front()->getNBEdge()->getLaneWidth(myIndex) / 2;
1248 // iterate over links
1249 for (int i = noLinks - 1; i >= 0; --i) {
1250 // calculate x2
1251 const double x2 = x1 - (double)(w / 2.);
1252 // get link number
1253 const int linkNo = connections[s.lefthand ? noLinks - 1 - i : i].tlLinkIndex;
1254 // draw link number
1256 // update x1
1257 x1 -= w;
1258 }
1259 // pop link matrix
1261 }
1262 }
1263}
1264
1265
1266void
1268 if (s.showLinkDecals && getParentEdges().front()->getToJunction()->isLogicValid()) {
1269 // calculate begin, end and rotation
1270 const Position& begin = myLaneGeometry.getShape()[-2];
1271 const Position& end = myLaneGeometry.getShape().back();
1272 const double rot = GUIGeometry::calculateRotation(begin, end);
1273 // push arrow matrix
1275 // move front (note: must draw on top of junction shape?
1276 glTranslated(0, 0, 3);
1277 // change color depending of spreadSuperposed
1280 } else {
1282 }
1283 // move to end
1284 glTranslated(end.x(), end.y(), 0);
1285 // rotate
1286 glRotated(rot, 0, 0, 1);
1287 const double width = getParentEdges().front()->getNBEdge()->getLaneWidth(myIndex);
1288 if (width < SUMO_const_laneWidth) {
1290 }
1291 // apply offset
1292 glTranslated(myDrawingConstants->getOffset() * -1, 0, 0);
1293 // get destination node
1294 const NBNode* dest = getParentEdges().front()->getNBEdge()->myTo;
1295 // draw all links iterating over connections
1296 for (const auto& connection : getParentEdges().front()->getNBEdge()->myConnections) {
1297 if (connection.fromLane == myIndex) {
1298 // get link direction
1299 LinkDirection dir = dest->getDirection(getParentEdges().front()->getNBEdge(), connection.toEdge, s.lefthand);
1300 // draw depending of link direction
1301 switch (dir) {
1303 GLHelper::drawBoxLine(Position(0, 4), 0, 2, .05);
1304 GLHelper::drawTriangleAtEnd(Position(0, 4), Position(0, 1), (double) 1, (double) .25);
1305 break;
1307 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1308 GLHelper::drawBoxLine(Position(0, 2.5), 90, 1, .05);
1309 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.5, 2.5), (double) 1, (double) .25);
1310 break;
1312 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1313 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
1314 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.5, 2.5), (double) 1, (double) .25);
1315 break;
1317 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1318 GLHelper::drawBoxLine(Position(0, 2.5), 90, .5, .05);
1319 GLHelper::drawBoxLine(Position(0.5, 2.5), 180, 1, .05);
1320 GLHelper::drawTriangleAtEnd(Position(0.5, 2.5), Position(0.5, 4), (double) 1, (double) .25);
1321 break;
1323 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1324 GLHelper::drawBoxLine(Position(0, 2.5), -90, 1, .05);
1325 GLHelper::drawBoxLine(Position(-0.5, 2.5), -180, 1, .05);
1326 GLHelper::drawTriangleAtEnd(Position(-0.5, 2.5), Position(-0.5, 4), (double) 1, (double) .25);
1327 break;
1329 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1330 GLHelper::drawBoxLine(Position(0, 2.5), 45, .7, .05);
1331 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(1.2, 1.3), (double) 1, (double) .25);
1332 break;
1334 GLHelper::drawBoxLine(Position(0, 4), 0, 1.5, .05);
1335 GLHelper::drawBoxLine(Position(0, 2.5), -45, .7, .05);
1336 GLHelper::drawTriangleAtEnd(Position(0, 2.5), Position(-1.2, 1.3), (double) 1, (double) .25);
1337 break;
1339 GLHelper::drawBoxLine(Position(1, 5.8), 245, 2, .05);
1340 GLHelper::drawBoxLine(Position(-1, 5.8), 115, 2, .05);
1341 glTranslated(0, 5, 0);
1342 GLHelper::drawOutlineCircle(0.9, 0.8, 32);
1343 glTranslated(0, -5, 0);
1344 break;
1345 default:
1346 break;
1347 }
1348 }
1349 }
1350 // pop arrow matrix
1352 }
1353}
1354
1355
1356void
1359 glTranslated(0, 0, 0.1); // must draw on top of junction shape
1360 std::vector<NBEdge::Connection> connections = getParentEdges().front()->getNBEdge()->getConnectionsFromLane(myIndex);
1361 NBNode* node = getParentEdges().front()->getNBEdge()->getToNode();
1362 const Position& startPos = myLaneGeometry.getShape()[-1];
1363 for (auto it : connections) {
1364 const LinkState state = node->getLinkState(getParentEdges().front()->getNBEdge(), it.toEdge, it.fromLane, it.toLane, it.mayDefinitelyPass, it.tlID);
1365 switch (state) {
1367 glColor3d(1, 1, 0);
1368 break;
1370 glColor3d(0, 1, 1);
1371 break;
1372 case LINKSTATE_MAJOR:
1373 glColor3d(1, 1, 1);
1374 break;
1375 case LINKSTATE_MINOR:
1376 glColor3d(.4, .4, .4);
1377 break;
1378 case LINKSTATE_STOP:
1379 glColor3d(.7, .4, .4);
1380 break;
1381 case LINKSTATE_EQUAL:
1382 glColor3d(.7, .7, .7);
1383 break;
1385 glColor3d(.7, .7, 1);
1386 break;
1387 case LINKSTATE_ZIPPER:
1388 glColor3d(.75, .5, 0.25);
1389 break;
1390 default:
1391 throw ProcessError(TLF("Unexpected LinkState '%'", toString(state)));
1392 }
1393 const Position& endPos = it.toEdge->getLaneShape(it.toLane)[0];
1394 glBegin(GL_LINES);
1395 glVertex2d(startPos.x(), startPos.y());
1396 glVertex2d(endPos.x(), endPos.y());
1397 glEnd();
1398 GLHelper::drawTriangleAtEnd(startPos, endPos, (double) 1.5, (double) .2);
1399 }
1401}
1402
1403
1404void
1405GNELane::calculateLaneContour(const GUIVisualizationSettings& s, const double layer) const {
1406 // first check if edge parent was inserted with full boundary
1407 if (!gViewObjectsHandler.checkBoundaryParentObject(this, layer, getParentEdges().front())) {
1408 // calculate contour
1411 true, true, myDrawingConstants->getOffset(), nullptr, getParentEdges().front());
1412 // calculate geometry points contour if we're editing shape
1413 if (myShapeEdited) {
1417 }
1418 }
1419}
1420
1421
1424 const auto& inspectedElements = myNet->getViewNet()->getInspectedElements();
1425 // declare a RGBColor variable
1426 RGBColor color;
1427 // we need to draw lanes with a special color if we're inspecting a Trip or Flow and this lane belongs to a via's edge.
1428 if (inspectedElements.getFirstAC() &&
1429 !inspectedElements.getFirstAC()->isAttributeCarrierSelected() &&
1430 inspectedElements.getFirstAC()->getTagProperty()->vehicleEdges()) {
1431 // obtain attribute "via"
1432 std::vector<std::string> viaEdges = parse<std::vector<std::string> >(inspectedElements.getFirstAC()->getAttribute(SUMO_ATTR_VIA));
1433 // iterate over viaEdges
1434 for (const auto& edge : viaEdges) {
1435 // check if parent edge is in the via edges
1436 if (getParentEdges().front()->getID() == edge) {
1437 // set green color in GLHelper and return it
1438 color = RGBColor::GREEN;
1439 }
1440 }
1441 }
1442 if (mySpecialColor != nullptr) {
1443 // If special color is enabled, set it
1444 color = *mySpecialColor;
1445 } else if (getParentEdges().front()->drawUsingSelectColor() && s.laneColorer.getActive() != 1) {
1446 // override with special colors (unless the color scheme is based on selection)
1448 } else {
1449 // Get normal lane color
1450 const GUIColorer& c = s.laneColorer;
1451 if (!setFunctionalColor(c.getActive(), color) && !setMultiColor(s, c, color)) {
1452 color = c.getScheme().getColor(getColorValue(s, c.getActive()));
1453 }
1454 }
1455 // special color for conflicted candidate edges
1456 if (getParentEdges().front()->isConflictedCandidate()) {
1457 // extra check for route frame
1460 }
1461 }
1462 // special color for special candidate edges
1463 if (getParentEdges().front()->isSpecialCandidate()) {
1464 // extra check for route frame
1467 }
1468 }
1469 // special color for candidate edges
1470 if (getParentEdges().front()->isPossibleCandidate()) {
1471 // extra check for route frame
1474 }
1475 }
1476 // special color for source candidate edges
1477 if (getParentEdges().front()->isSourceCandidate()) {
1479 }
1480 // special color for target candidate edges
1481 if (getParentEdges().front()->isTargetCandidate()) {
1483 }
1484 // special color for invalid candidate edges
1485 if (getParentEdges().front()->isInvalidCandidate()) {
1487 }
1488 // special color for source candidate lanes
1489 if (mySourceCandidate) {
1491 }
1492 // special color for target candidate lanes
1493 if (myTargetCandidate) {
1495 }
1496 // special color for special candidate lanes
1497 if (mySpecialCandidate) {
1499 }
1500 // special color for possible candidate lanes
1501 if (myPossibleCandidate) {
1503 }
1504 // special color for conflicted candidate lanes
1507 }
1508 // special color for invalid candidate lanes
1509 if (myInvalidCandidate) {
1511 }
1512 // set color in GLHelper
1513 GLHelper::setColor(color);
1514 return color;
1515}
1516
1517
1518bool
1519GNELane::setFunctionalColor(int activeScheme, RGBColor& col) const {
1520 switch (activeScheme) {
1521 case 6: {
1522 double hue = GeomHelper::naviDegree(myLaneGeometry.getShape().beginEndAngle()); // [0-360]
1523 col = RGBColor::fromHSV(hue, 1., 1.);
1524 return true;
1525 }
1526 default:
1527 return false;
1528 }
1529}
1530
1531
1532bool
1534 const int activeScheme = c.getActive();
1535 myShapeColors.clear();
1536 switch (activeScheme) {
1537 case 9: // color by height at segment start
1538 for (PositionVector::const_iterator ii = myLaneGeometry.getShape().begin(); ii != myLaneGeometry.getShape().end() - 1; ++ii) {
1539 myShapeColors.push_back(c.getScheme().getColor(ii->z()));
1540 }
1541 col = c.getScheme().getColor(getColorValue(s, 8));
1542 return true;
1543 case 11: // color by inclination at segment start
1544 for (int ii = 1; ii < (int)myLaneGeometry.getShape().size(); ++ii) {
1545 const double inc = (myLaneGeometry.getShape()[ii].z() - myLaneGeometry.getShape()[ii - 1].z()) / MAX2(POSITION_EPS, myLaneGeometry.getShape()[ii].distanceTo2D(myLaneGeometry.getShape()[ii - 1]));
1546 myShapeColors.push_back(c.getScheme().getColor(inc));
1547 }
1548 col = c.getScheme().getColor(getColorValue(s, 10));
1549 return true;
1550 default:
1551 return false;
1552 }
1553}
1554
1555
1556double
1557GNELane::getColorValue(const GUIVisualizationSettings& s, int activeScheme) const {
1558 const SVCPermissions myPermissions = getParentEdges().front()->getNBEdge()->getPermissions(myIndex);
1559 if (mySpecialColor != nullptr && mySpecialColorValue != std::numeric_limits<double>::max()) {
1560 return mySpecialColorValue;
1561 }
1562 switch (activeScheme) {
1563 case 0:
1564 switch (myPermissions) {
1565 case SVC_PEDESTRIAN:
1566 return 1;
1567 case SVC_BICYCLE:
1568 return 2;
1569 case 0:
1570 // forbidden road or green verge
1571 return getParentEdges().front()->getNBEdge()->getPermissions() == 0 ? 10 : 3;
1572 case SVC_SHIP:
1573 return 4;
1574 case SVC_AUTHORITY:
1575 return 8;
1576 case SVC_AIRCRAFT:
1577 case SVC_DRONE:
1578 return 12;
1579 default:
1580 break;
1581 }
1582 if (getParentEdges().front()->getNBEdge()->isMacroscopicConnector()) {
1583 return 9;
1584 } else if (isRailway(myPermissions)) {
1585 return 5;
1586 } else if ((myPermissions & SVC_PASSENGER) != 0) {
1587 if ((myPermissions & (SVC_RAIL_CLASSES & ~SVC_RAIL_FAST)) != 0 && (myPermissions & SVC_SHIP) == 0) {
1588 return 6;
1589 } else {
1590 return 0;
1591 }
1592 } else {
1593 if ((myPermissions & SVC_RAIL_CLASSES) != 0 && (myPermissions & SVC_SHIP) == 0) {
1594 return 6;
1595 } else {
1596 return 7;
1597 }
1598 }
1599 case 1:
1600 return isAttributeCarrierSelected() || getParentEdges().front()->isAttributeCarrierSelected();
1601 case 2:
1602 return (double)myPermissions;
1603 case 3:
1604 return getParentEdges().front()->getNBEdge()->getLaneSpeed(myIndex);
1605 case 4:
1606 return getParentEdges().front()->getNBEdge()->getNumLanes();
1607 case 5: {
1608 return getParentEdges().front()->getNBEdge()->getLoadedLength() / getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).shape.length();
1609 }
1610 // case 6: by angle (functional)
1611 case 7: {
1612 return getParentEdges().front()->getNBEdge()->getPriority();
1613 }
1614 case 8: {
1615 // color by z of first shape point
1616 return myLaneGeometry.getShape()[0].z();
1617 }
1618 // case 9: by segment height
1619 case 10: {
1620 // color by incline
1621 return (myLaneGeometry.getShape()[-1].z() - myLaneGeometry.getShape()[0].z()) / getParentEdges().front()->getNBEdge()->getLength();
1622 }
1623 // case 11: by segment incline
1624
1625 case 12: {
1626 // by numerical edge param value
1627 if (getParentEdges().front()->getNBEdge()->hasParameter(s.edgeParam)) {
1628 try {
1629 return StringUtils::toDouble(getParentEdges().front()->getNBEdge()->getParameter(s.edgeParam, "0"));
1630 } catch (NumberFormatException&) {
1631 try {
1632 return StringUtils::toBool(getParentEdges().front()->getNBEdge()->getParameter(s.edgeParam, "0"));
1633 } catch (BoolFormatException&) {
1634 return -1;
1635 }
1636 }
1637 } else {
1639 }
1640 }
1641 case 13: {
1642 // by numerical lane param value
1643 if (getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).hasParameter(s.laneParam)) {
1644 try {
1645 return StringUtils::toDouble(getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).getParameter(s.laneParam, "0"));
1646 } catch (NumberFormatException&) {
1647 try {
1648 return StringUtils::toBool(getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).getParameter(s.laneParam, "0"));
1649 } catch (BoolFormatException&) {
1650 return -1;
1651 }
1652 }
1653 } else {
1655 }
1656 }
1657 case 14: {
1658 return getParentEdges().front()->getNBEdge()->getDistance();
1659 }
1660 case 15: {
1661 return fabs(getParentEdges().front()->getNBEdge()->getDistance());
1662 }
1663 }
1664 return 0;
1665}
1666
1667
1668void
1669GNELane::drawOverlappedRoutes(const int numRoutes) const {
1670 // get middle point and angle
1673 // Push route matrix
1675 // translate to front
1676 glTranslated(0, 0, GLO_ROUTE + 1);
1677 // get middle
1678 GLHelper::drawText(toString(numRoutes) + " routes", center, 0, 1.8, RGBColor::BLACK, angle + 90);
1679 // pop route matrix
1681
1682}
1683
1684
1685void
1687 const auto& laneStopOffset = getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).laneStopOffset;
1688 // check conditions
1689 if (laneStopOffset.isDefined() && (laneStopOffset.getPermissions() & SVC_PASSENGER) != 0) {
1690 const Position& end = getLaneShape().back();
1691 const Position& f = getLaneShape()[-2];
1692 const double rot = RAD2DEG(atan2((end.x() - f.x()), (f.y() - end.y())));
1695 glTranslated(end.x(), end.y(), 1);
1696 glRotated(rot, 0, 0, 1);
1697 glTranslated(0, laneStopOffset.getOffset(), 0);
1698 glBegin(GL_QUADS);
1699 glVertex2d(-myDrawingConstants->getDrawingWidth(), 0.0);
1700 glVertex2d(-myDrawingConstants->getDrawingWidth(), 0.2);
1701 glVertex2d(myDrawingConstants->getDrawingWidth(), 0.2);
1702 glVertex2d(myDrawingConstants->getDrawingWidth(), 0.0);
1703 glEnd();
1705 }
1706}
1707
1708
1709bool
1711 return isWaterway(getParentEdges().front()->getNBEdge()->getPermissions(myIndex)) && s.showRails; // reusing the showRails setting
1712}
1713
1714
1715void
1717 // Draw direction indicators if the correspondient option is enabled
1718 if (s.showLaneDirection) {
1719 // improve visibility of superposed rail edges
1721 glColor3d(0.3, 0.3, 0.3);
1722 }
1723 // get width and sideOffset
1724 const double width = MAX2(NUMERICAL_EPS, (myDrawingConstants->getDrawingWidth() * 2 * myDrawingConstants->getExaggeration()));
1725 // push direction indicator matrix
1727 // move to front
1728 glTranslated(0, 0, 0.1);
1729 // iterate over shape
1730 for (int i = 0; i < (int) myLaneGeometry.getShape().size() - 1; ++i) {
1731 // push triangle matrix
1733 // move front
1734 glTranslated(myLaneGeometry.getShape()[i].x(), myLaneGeometry.getShape()[i].y(), 0.1);
1735 // rotate
1736 glRotated(myLaneGeometry.getShapeRotations()[i], 0, 0, 1);
1737 // calculate subwidth
1738 for (double subWidth = 0; subWidth < myLaneGeometry.getShapeLengths()[i]; subWidth += width) {
1739 // calculate length
1740 const double length = MIN2(width * 0.5, myLaneGeometry.getShapeLengths()[i] - subWidth);
1741 // draw triangle
1742 glBegin(GL_TRIANGLES);
1743 glVertex2d(-myDrawingConstants->getOffset(), -subWidth - length);
1744 glVertex2d(-myDrawingConstants->getOffset() - width * 0.25, -subWidth);
1745 glVertex2d(-myDrawingConstants->getOffset() + width * 0.25, -subWidth);
1746 glEnd();
1747 }
1748 // pop triangle matrix
1750 }
1751 // pop direction indicator matrix
1753 }
1754}
1755
1756
1757void
1759 // draw foot width 150mm, assume that distance between rail feet inner sides is reduced on both sides by 39mm with regard to the gauge
1760 // assume crosstie length of 181% gauge (2600mm for standard gauge)
1761 // first save current color (obtained from view configuration)
1762 const auto currentLaneColor = GLHelper::getColor();
1763 // Set current color
1764 GLHelper::setColor(currentLaneColor);
1765 // continue depending of detail
1767 // move
1768 glTranslated(0, 0, 0.1);
1769 // draw external crossbar
1770 const double crossbarWidth = 0.2 * myDrawingConstants->getExaggeration();
1771 // draw geometry
1775 // move
1776 glTranslated(0, 0, 0.01);
1777 // Set color gray
1778 glColor3d(0.8, 0.8, 0.8);
1779 // draw geometry
1783 // move
1784 glTranslated(0, 0, 0.01);
1785 // Set current color
1786 GLHelper::setColor(currentLaneColor);
1787 // Draw crossties
1790 myDrawingConstants->getOffset(), false);
1791 } else if (myShapeColors.size() > 0) {
1792 // draw colored box lines
1795 } else {
1796 // draw geometry with current color
1799 }
1800}
1801
1802
1803void
1805 // check all conditions for drawing textures
1806 if (!s.disableLaneIcons && (myLaneRestrictedTexturePositions.size() > 0)) {
1807 // Declare default width of icon (3)
1808 const double iconWidth = myDrawingConstants->getDrawingWidth() * 0.6;
1809 // Draw list of icons
1810 for (int i = 0; i < (int)myLaneRestrictedTexturePositions.size(); i++) {
1811 // Push draw matrix 2
1813 // Set white color
1814 glColor3d(1, 1, 1);
1815 // Translate matrix 2
1816 glTranslated(myLaneRestrictedTexturePositions.at(i).x(), myLaneRestrictedTexturePositions.at(i).y(), 0.1);
1817 // Rotate matrix 2
1818 glRotated(myLaneRestrictedTextureRotations.at(i), 0, 0, -1);
1819 glRotated(90, 0, 0, 1);
1820 // draw texture box depending of type of restriction
1823 } else if (isRestricted(SVC_BICYCLE)) {
1825 } else if (isRestricted(SVC_BUS)) {
1827 }
1828 // Pop draw matrix 2
1830 }
1831 }
1832}
1833
1834
1835void
1837 // draw a Start/endPoints if lane has a custom shape
1838 if ((myDrawingConstants->getDetail() <= GUIVisualizationSettings::Detail::GeometryPoint) && (getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape.size() > 1)) {
1839 // obtain circle width and resolution
1840 const double circleWidth = GNEEdge::SNAP_RADIUS * MIN2((double)1, s.laneWidthExaggeration) / 2;
1841 // obtain custom shape
1842 const PositionVector& customShape = getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape;
1843 // set color (override with special colors unless the color scheme is based on selection)
1844 if (drawUsingSelectColor() && s.laneColorer.getActive() != 1) {
1846 } else {
1847 GLHelper::setColor(s.junctionColorer.getSchemes()[0].getColor(2));
1848 }
1849 // push start matrix
1851 // move to shape start position
1852 glTranslated(customShape.front().x(), customShape.front().y(), 0.1);
1853 // draw circle
1855 // draw s depending of detail
1857 // move top
1858 glTranslated(0, 0, 0.1);
1859 // draw "S"
1860 GLHelper::drawText("S", Position(), 0.1, circleWidth, RGBColor::WHITE);
1861 }
1862 // pop start matrix
1864 // draw line between junction and start position
1866 // move top
1867 glTranslated(0, 0, 0.1);
1868 // set line width
1869 glLineWidth(4);
1870 // draw line
1871 GLHelper::drawLine(customShape.front(), getParentEdges().front()->getFromJunction()->getPositionInView());
1872 // pop line matrix
1874 // push start matrix
1876 // move to end position
1877 glTranslated(customShape.back().x(), customShape.back().y(), 0.1);
1878 // draw filled circle
1880 // draw "e" depending of detail
1882 // move top
1883 glTranslated(0, 0, 0.1);
1884 // draw "E"
1885 GLHelper::drawText("E", Position(), 0, circleWidth, RGBColor::WHITE);
1886 }
1887 // pop start matrix
1889 // draw line between Junction and end position
1891 // move top
1892 glTranslated(0, 0, 0.1);
1893 // set line width
1894 glLineWidth(4);
1895 // draw line
1896 GLHelper::drawLine(customShape.back(), getParentEdges().front()->getToJunction()->getPositionInView());
1897 // pop line matrix
1899 }
1900}
1901
1902
1903std::string
1905 return getParentEdges().front()->getID();
1906}
1907
1908
1909long
1910GNELane::onDefault(FXObject* obj, FXSelector sel, void* data) {
1911 myNet->getViewParent()->getTLSEditorFrame()->handleMultiChange(this, obj, sel, data);
1912 return 1;
1913}
1914
1915
1916std::vector<GNEConnection*>
1918 // Declare a vector to save incoming connections
1919 std::vector<GNEConnection*> incomingConnections;
1920 // Obtain incoming edges if junction source was already created
1921 GNEJunction* junctionSource = getParentEdges().front()->getFromJunction();
1922 if (junctionSource) {
1923 // Iterate over incoming GNEEdges of junction
1924 for (const auto& incomingEdge : junctionSource->getGNEIncomingEdges()) {
1925 // Iterate over connection of incoming edges
1926 for (const auto& connection : incomingEdge->getGNEConnections()) {
1927 if (connection->getLaneTo()->getIndex() == getIndex()) {
1928 incomingConnections.push_back(connection);
1929 }
1930 }
1931 }
1932 }
1933 return incomingConnections;
1934}
1935
1936
1937std::vector<GNEConnection*>
1939 // Obtain GNEConnection of parent edge
1940 const std::vector<GNEConnection*>& edgeConnections = getParentEdges().front()->getGNEConnections();
1941 std::vector<GNEConnection*> outcomingConnections;
1942 // Obtain outgoing connections
1943 for (const auto& connection : edgeConnections) {
1944 if (connection->getLaneFrom()->getIndex() == getIndex()) {
1945 outcomingConnections.push_back(connection);
1946 }
1947 }
1948 return outcomingConnections;
1949}
1950
1951
1952void
1954 // update incoming connections of lane
1955 std::vector<GNEConnection*> incomingConnections = getGNEIncomingConnections();
1956 for (const auto& incomingConnection : incomingConnections) {
1957 incomingConnection->updateConnectionID();
1958 }
1959 // update outcoming connections of lane
1960 std::vector<GNEConnection*> outcomingConnections = getGNEOutcomingConnections();
1961 for (const auto& outcomingConnection : outcomingConnections) {
1962 outcomingConnection->updateConnectionID();
1963 }
1964}
1965
1966
1967double
1969 // factor should not be 0
1970 if (getParentEdges().front()->getNBEdge()->getFinalLength() > 0) {
1971 return MAX2(POSITION_EPS, (getLaneShape().length() / getParentEdges().front()->getNBEdge()->getFinalLength()));
1972 } else {
1973 return POSITION_EPS;
1974 };
1975}
1976
1977
1978void
1980 // Create basic commands
1981 std::string edgeDescPossibleMulti = toString(SUMO_TAG_EDGE);
1982 const int edgeSelSize = getParentEdges().front()->isAttributeCarrierSelected() ? myNet->getAttributeCarriers()->getNumberOfSelectedEdges() : 0;
1983 if (edgeSelSize && getParentEdges().front()->isAttributeCarrierSelected() && (edgeSelSize > 1)) {
1984 edgeDescPossibleMulti = toString(edgeSelSize) + " " + toString(SUMO_TAG_EDGE) + "s";
1985 }
1986 // create menu pane for edge operations
1987 FXMenuPane* edgeOperations = new FXMenuPane(ret);
1988 ret->insertMenuPaneChild(edgeOperations);
1989 if (edgeSelSize > 0) {
1990 new FXMenuCascade(ret, TLF("Edge operations (% selected)", toString(edgeSelSize)).c_str(), nullptr, edgeOperations);
1991 } else {
1992 new FXMenuCascade(ret, TL("Edge operations"), nullptr, edgeOperations);
1993 }
1994 // create menu commands for all edge operations
1995 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Split edge here"), nullptr, &parent, MID_GNE_EDGE_SPLIT);
1996 auto splitBothDirections = GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Split edge in both directions here (no symmetric opposite edge)"), nullptr, &parent, MID_GNE_EDGE_SPLIT_BIDI);
1997 // check if allow split edge in both directions
1998 splitBothDirections->disable();
1999 const auto oppositeEdges = getParentEdges().front()->getOppositeEdges();
2000 if (oppositeEdges.size() == 0) {
2001 splitBothDirections->setText(TL("Split edge in both directions here (no opposite edge)"));
2002 } else {
2003 for (const auto& oppositeEdge : oppositeEdges) {
2004 // get reverse inner geometry
2005 const auto reverseGeometry = oppositeEdge->getNBEdge()->getInnerGeometry().reverse();
2006 if (reverseGeometry == getParentEdges().front()->getNBEdge()->getInnerGeometry()) {
2007 splitBothDirections->enable();
2008 splitBothDirections->setText(TL("Split edge in both directions here"));
2009 }
2010 }
2011 }
2012 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Set geometry endpoint here (shift-click)"), nullptr, &parent, MID_GNE_EDGE_EDIT_ENDPOINT);
2013 // restore geometry points depending of selection status
2014 if (getParentEdges().front()->isAttributeCarrierSelected()) {
2015 if (edgeSelSize == 1) {
2016 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Restore both geometry endpoints"), nullptr, &parent, MID_GNE_EDGE_RESET_ENDPOINT);
2017 } else {
2018 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Restore geometry endpoints of all selected edges"), nullptr, &parent, MID_GNE_EDGE_RESET_ENDPOINT);
2019 }
2020 } else {
2021 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Restore geometry endpoint (shift-click)"), nullptr, &parent, MID_GNE_EDGE_RESET_ENDPOINT);
2022 }
2023 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Reverse %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_REVERSE);
2024 auto reverse = GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Add reverse direction for %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_ADD_REVERSE);
2025 if (getParentEdges().front()->getReverseEdge() != nullptr) {
2026 reverse->disable();
2027 }
2028 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Add reverse disconnected direction for %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_ADD_REVERSE_DISCONNECTED);
2029 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Reset lengths for %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_RESET_LENGTH);
2030 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Straighten %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_STRAIGHTEN);
2031 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Smooth %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_SMOOTH);
2032 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Straighten elevation of %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_STRAIGHTEN_ELEVATION);
2033 GUIDesigns::buildFXMenuCommand(edgeOperations, TLF("Smooth elevation of %", edgeDescPossibleMulti), nullptr, &parent, MID_GNE_EDGE_SMOOTH_ELEVATION);
2034}
2035
2036
2037void
2039 // Get icons
2040 FXIcon* pedestrianIcon = GUIIconSubSys::getIcon(GUIIcon::LANE_PEDESTRIAN);
2041 FXIcon* bikeIcon = GUIIconSubSys::getIcon(GUIIcon::LANE_BIKE);
2042 FXIcon* busIcon = GUIIconSubSys::getIcon(GUIIcon::LANE_BUS);
2043 FXIcon* greenVergeIcon = GUIIconSubSys::getIcon(GUIIcon::LANEGREENVERGE);
2044 // declare number of selected lanes
2045 int numSelectedLanes = 0;
2046 // if lane is selected, calculate number of restricted lanes
2047 bool edgeHasSidewalk = false;
2048 bool edgeHasBikelane = false;
2049 bool edgeHasBuslane = false;
2050 bool differentLaneShapes = false;
2052 const auto selectedLanes = myNet->getAttributeCarriers()->getSelectedLanes();
2053 // update numSelectedLanes
2054 numSelectedLanes = (int)selectedLanes.size();
2055 // iterate over selected lanes
2056 for (const auto& selectedLane : selectedLanes) {
2057 if (selectedLane->getParentEdges().front()->hasRestrictedLane(SVC_PEDESTRIAN)) {
2058 edgeHasSidewalk = true;
2059 }
2060 if (selectedLane->getParentEdges().front()->hasRestrictedLane(SVC_BICYCLE)) {
2061 edgeHasBikelane = true;
2062 }
2063 if (selectedLane->getParentEdges().front()->hasRestrictedLane(SVC_BUS)) {
2064 edgeHasBuslane = true;
2065 }
2066 if (selectedLane->getParentEdges().front()->getNBEdge()->getLaneStruct(selectedLane->getIndex()).customShape.size() != 0) {
2067 differentLaneShapes = true;
2068 }
2069 }
2070 } else {
2071 edgeHasSidewalk = getParentEdges().front()->hasRestrictedLane(SVC_PEDESTRIAN);
2072 edgeHasBikelane = getParentEdges().front()->hasRestrictedLane(SVC_BICYCLE);
2073 edgeHasBuslane = getParentEdges().front()->hasRestrictedLane(SVC_BUS);
2074 differentLaneShapes = getParentEdges().front()->getNBEdge()->getLaneStruct(myIndex).customShape.size() != 0;
2075 }
2076 // create menu pane for lane operations
2077 FXMenuPane* laneOperations = new FXMenuPane(ret);
2078 ret->insertMenuPaneChild(laneOperations);
2079 if (numSelectedLanes > 0) {
2080 new FXMenuCascade(ret, TLF("Lane operations (% selected)", toString(numSelectedLanes)).c_str(), nullptr, laneOperations);
2081 } else {
2082 new FXMenuCascade(ret, TL("Lane operations"), nullptr, laneOperations);
2083 }
2084 GUIDesigns::buildFXMenuCommand(laneOperations, TL("Duplicate lane"), nullptr, &parent, MID_GNE_LANE_DUPLICATE);
2085 GUIDesigns::buildFXMenuCommand(laneOperations, TL("Set custom lane shape"), nullptr, &parent, MID_GNE_LANE_EDIT_SHAPE);
2086 FXMenuCommand* resetCustomShape = GUIDesigns::buildFXMenuCommand(laneOperations, TL("Reset custom shape"), nullptr, &parent, MID_GNE_LANE_RESET_CUSTOMSHAPE);
2087 if (!differentLaneShapes) {
2088 resetCustomShape->disable();
2089 }
2090 FXMenuCommand* resetOppositeLane = GUIDesigns::buildFXMenuCommand(laneOperations, TL("Reset opposite lane"), nullptr, &parent, MID_GNE_LANE_RESET_OPPOSITELANE);
2091 if (getAttribute(GNE_ATTR_OPPOSITE).empty()) {
2092 resetOppositeLane->disable();
2093 }
2094 // Create panel for lane operations and insert it in ret
2095 FXMenuPane* addSpecialLanes = new FXMenuPane(laneOperations);
2096 ret->insertMenuPaneChild(addSpecialLanes);
2097 FXMenuPane* removeSpecialLanes = new FXMenuPane(laneOperations);
2098 ret->insertMenuPaneChild(removeSpecialLanes);
2099 FXMenuPane* transformSlanes = new FXMenuPane(laneOperations);
2100 ret->insertMenuPaneChild(transformSlanes);
2101 // Create menu comands for all add special lanes
2102 FXMenuCommand* addSidewalk = GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Sidewalk"), pedestrianIcon, &parent, MID_GNE_LANE_ADD_SIDEWALK);
2103 FXMenuCommand* addBikelane = GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Bike lane"), bikeIcon, &parent, MID_GNE_LANE_ADD_BIKE);
2104 FXMenuCommand* addBuslane = GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Bus lane"), busIcon, &parent, MID_GNE_LANE_ADD_BUS);
2105 // if parent edge is selected, always add greenverge in front
2106 if (getParentEdges().front()->isAttributeCarrierSelected()) {
2107 GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Green verge"), greenVergeIcon, &parent, MID_GNE_LANE_ADD_GREENVERGE_FRONT);
2108 } else {
2109 GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Green verge (front)"), greenVergeIcon, &parent, MID_GNE_LANE_ADD_GREENVERGE_FRONT);
2110 GUIDesigns::buildFXMenuCommand(addSpecialLanes, TL("Green verge (back)"), greenVergeIcon, &parent, MID_GNE_LANE_ADD_GREENVERGE_BACK);
2111 }
2112 // Create menu comands for all remove special lanes and disable it
2113 FXMenuCommand* removeSidewalk = GUIDesigns::buildFXMenuCommand(removeSpecialLanes, TL("Sidewalk"), pedestrianIcon, &parent, MID_GNE_LANE_REMOVE_SIDEWALK);
2114 removeSidewalk->disable();
2115 FXMenuCommand* removeBikelane = GUIDesigns::buildFXMenuCommand(removeSpecialLanes, TL("Bike lane"), bikeIcon, &parent, MID_GNE_LANE_REMOVE_BIKE);
2116 removeBikelane->disable();
2117 FXMenuCommand* removeBuslane = GUIDesigns::buildFXMenuCommand(removeSpecialLanes, TL("Bus lane"), busIcon, &parent, MID_GNE_LANE_REMOVE_BUS);
2118 removeBuslane->disable();
2119 FXMenuCommand* removeGreenVerge = GUIDesigns::buildFXMenuCommand(removeSpecialLanes, TL("Green verge"), greenVergeIcon, &parent, MID_GNE_LANE_REMOVE_GREENVERGE);
2120 removeGreenVerge->disable();
2121 // Create menu comands for all transform special lanes and disable it
2122 FXMenuCommand* transformLaneToSidewalk = GUIDesigns::buildFXMenuCommand(transformSlanes, TL("Sidewalk"), pedestrianIcon, &parent, MID_GNE_LANE_TRANSFORM_SIDEWALK);
2123 FXMenuCommand* transformLaneToBikelane = GUIDesigns::buildFXMenuCommand(transformSlanes, TL("Bike lane"), bikeIcon, &parent, MID_GNE_LANE_TRANSFORM_BIKE);
2124 FXMenuCommand* transformLaneToBuslane = GUIDesigns::buildFXMenuCommand(transformSlanes, TL("Bus lane"), busIcon, &parent, MID_GNE_LANE_TRANSFORM_BUS);
2125 FXMenuCommand* transformLaneToGreenVerge = GUIDesigns::buildFXMenuCommand(transformSlanes, TL("Green verge"), greenVergeIcon, &parent, MID_GNE_LANE_TRANSFORM_GREENVERGE);
2126 // add menuCascade for lane operations
2127 new FXMenuCascade(laneOperations, TLF("Add restricted %", toString(SUMO_TAG_LANE)).c_str(), nullptr, addSpecialLanes);
2128 FXMenuCascade* cascadeRemoveSpecialLane = new FXMenuCascade(laneOperations, TLF("Remove restricted %", toString(SUMO_TAG_LANE)).c_str(), nullptr, removeSpecialLanes);
2129 new FXMenuCascade(laneOperations, TLF("Transform to restricted %", toString(SUMO_TAG_LANE)).c_str(), nullptr, transformSlanes);
2130 // Enable and disable options depending of current transform of the lane
2131 if (edgeHasSidewalk) {
2132 transformLaneToSidewalk->disable();
2133 addSidewalk->disable();
2134 removeSidewalk->enable();
2135 }
2136 if (edgeHasBikelane) {
2137 transformLaneToBikelane->disable();
2138 addBikelane->disable();
2139 removeBikelane->enable();
2140 }
2141 if (edgeHasBuslane) {
2142 transformLaneToBuslane->disable();
2143 addBuslane->disable();
2144 removeBuslane->enable();
2145 }
2147 transformLaneToGreenVerge->disable();
2148 removeGreenVerge->enable();
2149 }
2150 // Check if cascade menu must be disabled
2151 if (!edgeHasSidewalk && !edgeHasBikelane && !edgeHasBuslane && !isRestricted(SVC_IGNORING)) {
2152 cascadeRemoveSpecialLane->disable();
2153 }
2154 // for whatever reason, sonar complains in the next line that cascadeRemoveSpecialLane may leak, but fox does the cleanup
2155} // NOSONAR
2156
2157
2158void
2160 // Create basic commands
2161 std::string edgeDescPossibleMulti = toString(SUMO_TAG_EDGE);
2162 const int numSelectedEdges = getParentEdges().front()->isAttributeCarrierSelected() ? myNet->getAttributeCarriers()->getNumberOfSelectedEdges() : 0;
2163 if ((numSelectedEdges > 0) && getParentEdges().front()->isAttributeCarrierSelected() && (numSelectedEdges > 1)) {
2164 edgeDescPossibleMulti = toString(numSelectedEdges) + " " + toString(SUMO_TAG_EDGE) + "s";
2165 }
2166 // create menu pane for edge operations
2167 FXMenuPane* edgeOperations = new FXMenuPane(ret);
2168 ret->insertMenuPaneChild(edgeOperations);
2169 if (numSelectedEdges > 0) {
2170 new FXMenuCascade(ret, TLF("Template operations (% selected)", toString(numSelectedEdges)).c_str(), nullptr, edgeOperations);
2171 } else {
2172 new FXMenuCascade(ret, TL("Template operations"), nullptr, edgeOperations);
2173 }
2174 // create menu commands for all edge operations
2175 GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Use edge as template"), nullptr, &parent, MID_GNE_EDGE_USEASTEMPLATE);
2176 auto applyTemplate = GUIDesigns::buildFXMenuCommand(edgeOperations, TL("Apply template"), nullptr, &parent, MID_GNE_EDGE_APPLYTEMPLATE);
2177 // check if disable apply template
2179 applyTemplate->disable();
2180 }
2181}
2182
2183
2184void
2186 // addreachability menu
2187 FXMenuPane* reachableByClass = new FXMenuPane(ret);
2188 ret->insertMenuPaneChild(reachableByClass);
2189 if (myNet->isNetRecomputed()) {
2190 new FXMenuCascade(ret, TL("Select reachable"), GUIIconSubSys::getIcon(GUIIcon::MODEVEHICLE), reachableByClass);
2191 for (const auto& vClass : SumoVehicleClassStrings.getStrings()) {
2192 GUIDesigns::buildFXMenuCommand(reachableByClass, vClass.c_str(), VClassIcons::getVClassIcon(SumoVehicleClassStrings.get(vClass)), &parent, MID_REACHABILITY);
2193 }
2194 } else {
2195 FXMenuCommand* menuCommand = GUIDesigns::buildFXMenuCommand(ret, TL("Select reachable (compute junctions)"), nullptr, nullptr, 0);
2196 menuCommand->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), nullptr);
2197 }
2198}
2199
2200/****************************************************************************/
NetworkEditMode
@brie enum for network edit modes
@ NETWORK_DELETE
mode for deleting network elements
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_ADDITIONAL
Mode for editing additionals.
@ NETWORK_TLS
mode for editing tls
@ NETWORK_SELECT
mode for selecting network elements
@ NETWORK_CONNECT
mode for connecting lanes
@ MID_GNE_ADDSELECT_EDGE
Add edge to selected items - menu entry.
Definition GUIAppEnum.h:859
@ MID_GNE_LANE_EDIT_SHAPE
edit lane shape
@ MID_GNE_LANE_TRANSFORM_BIKE
transform lane to bikelane
@ MID_GNE_EDGE_REVERSE
reverse an edge
@ MID_ADDSELECT
Add to selected items - menu entry.
Definition GUIAppEnum.h:487
@ MID_GNE_LANE_ADD_BUS
add busLane
@ MID_GNE_REMOVESELECT_EDGE
Remove edge from selected items - Menu Entry.
Definition GUIAppEnum.h:861
@ MID_GNE_EDGE_STRAIGHTEN_ELEVATION
interpolate z values linear between junctions
@ MID_GNE_EDGE_SMOOTH
smooth geometry
@ MID_GNE_LANE_RESET_CUSTOMSHAPE
reset custom shape
@ MID_GNE_EDGE_STRAIGHTEN
remove inner geometry
@ MID_GNE_LANE_TRANSFORM_BUS
transform lane to busLane
@ MID_COPY_EDGE_NAME
Copy edge name (for lanes only)
Definition GUIAppEnum.h:461
@ MID_GNE_LANE_DUPLICATE
duplicate a lane
@ MID_GNE_LANE_ADD_GREENVERGE_FRONT
add greenVerge front of current lane
@ MID_GNE_LANE_REMOVE_GREENVERGE
remove greenVerge
@ MID_GNE_EDGE_ADD_REVERSE_DISCONNECTED
add reverse edge disconnected (used for for spreadtype center)
@ MID_GNE_EDGE_SPLIT_BIDI
split an edge
@ MID_GNE_LANE_REMOVE_BIKE
remove bikelane
@ MID_GNE_LANE_RESET_OPPOSITELANE
reset opposite lane
@ MID_REACHABILITY
show reachability from a given lane
Definition GUIAppEnum.h:533
@ MID_GNE_EDGE_RESET_LENGTH
reset custom lengths
@ MID_GNE_LANE_REMOVE_BUS
remove busLane
@ MID_GNE_LANE_REMOVE_SIDEWALK
remove sidewalk
@ MID_GNE_EDGE_RESET_ENDPOINT
reset default geometry endpoints
@ MID_GNE_LANE_ADD_GREENVERGE_BACK
add greenVerge back of current lane
@ MID_GNE_EDGE_SMOOTH_ELEVATION
smooth elevation with regard to adjoining edges
@ MID_GNE_EDGE_ADD_REVERSE
add reverse edge
@ MID_GNE_EDGE_APPLYTEMPLATE
apply template
@ MID_GNE_EDGE_USEASTEMPLATE
use edge as tempalte
@ MID_GNE_LANE_ADD_SIDEWALK
add sidewalk
@ MID_GNE_RESET_GEOMETRYPOINT
reset geometry point
@ MID_GNE_LANE_TRANSFORM_SIDEWALK
transform lane to sidewalk
@ MID_GNE_LANE_ADD_BIKE
add bikelane
@ MID_GNE_EDGE_SPLIT
split an edge
@ MID_GNE_LANE_TRANSFORM_GREENVERGE
transform lane to greenVerge
@ MID_GNE_CUSTOM_GEOMETRYPOINT
set custom geometry point
@ MID_GNE_EDGE_EDIT_ENDPOINT
change default geometry endpoints
@ MID_REMOVESELECT
Remove from selected items - Menu Entry.
Definition GUIAppEnum.h:489
@ GLO_ROUTE
a route
@ GLO_JUNCTION
a junction
@ GLO_FRONTELEMENT
front element (used in netedit)
@ GLO_LANE
a lane
@ GLO_TEXTNAME
text element (used in netedit)
GUIViewObjectsHandler gViewObjectsHandler
@ LANE_PEDESTRIAN
@ LANEGREENVERGE
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
const SVCPermissions SVCAll
all VClasses are allowed
SVCPermissions invertPermissions(SVCPermissions permissions)
negate the given permissions and ensure that only relevant bits are set
bool isRailway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a (exclusive) railway edge.
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permissions is a waterway edge.
const std::string & getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_SHIP
is an arbitrary ship
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_RAIL_CLASSES
classes which drive on tracks
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_RAIL_FAST
vehicle that is allowed to drive on high-speed rail tracks
@ SVC_DRONE
@ SVC_AUTHORITY
authorities vehicles
@ SVC_BUS
vehicle is a bus
@ SVC_AIRCRAFT
@ SVC_PEDESTRIAN
pedestrian
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
@ PARTLEFT
The link is a partial left direction.
@ RIGHT
The link is a (hard) right direction.
@ TURN
The link is a 180 degree turn.
@ LEFT
The link is a (hard) left direction.
@ STRAIGHT
The link is a straight direction.
@ TURN_LEFTHAND
The link is a 180 degree turn (left-hand network)
@ PARTRIGHT
The link is a partial right direction.
@ NODIR
The link has no direction (is a dead end link)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_MAJOR
This is an uncontrolled, major link, may pass.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_ZIPPER
This is an uncontrolled, zipper-merge link.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
@ LINKSTATE_TL_OFF_NOSIGNAL
The link is controlled by a tls which is off, not blinking, may pass.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_SPEED
@ GNE_ATTR_STOPOFFSET
stop offset (virtual, used by edge and lanes)
@ SUMO_ATTR_VIA
@ GNE_ATTR_OPPOSITE
to busStop (used by personPlans)
@ SUMO_ATTR_TO_JUNCTION
@ GNE_ATTR_PARENT
parent of an additional element
@ SUMO_ATTR_CUSTOMSHAPE
whether a given shape is user-defined
@ GNE_ATTR_FROM_LANEID
from lane ID (used in GNEConnection)
@ GNE_ATTR_STOPOEXCEPTION
stop exceptions (virtual, used by edge and lanes)
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ENDOFFSET
@ SUMO_ATTR_ACCELERATION
@ GNE_ATTR_TO_LANEID
to lane ID (used in GNEConnection)
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_FRICTION
const double SUMO_const_laneWidth
Definition StdDefs.h:52
T MIN2(T a, T b)
Definition StdDefs.h:80
const double SUMO_const_laneMarkWidth
Definition StdDefs.h:55
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:49
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition GLHelper.cpp:433
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:649
static void drawOutlineCircle(double radius, double iRadius, int steps=8)
Draws an unfilled circle around (0,0)
Definition GLHelper.cpp:591
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
Definition GLHelper.cpp:624
static void drawTextAtEnd(const std::string &text, const PositionVector &shape, double x, const GUIVisualizationTextSettings &settings, const double scale)
draw text and the end of shape
Definition GLHelper.cpp:824
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static RGBColor getColor()
gets the gl-color
Definition GLHelper.cpp:655
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition GLHelper.cpp:296
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:534
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
static void drawInverseMarkings(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double maxLength, double spacing, double halfWidth, bool cl, bool cr, bool lefthand, double scale)
@bried draw the space between markings (in road color)
Definition GLHelper.cpp:886
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:742
static void drawCrossTies(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double length, double spacing, double halfWidth, double offset, bool lessDetail)
draw crossties for railroads or pedestrian crossings
Definition GLHelper.cpp:843
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
double getCommonAttributeDouble(SumoXMLAttr key) const
bool isMarkedForDrawingFront() const
check if this AC is marked for drawing front
bool mySelected
boolean to check if this AC is selected (more quickly as checking GUIGlObjectStorage)
const std::string getID() const override
get ID (all Attribute Carriers have one)
PositionVector getCommonAttributePositionVector(SumoXMLAttr key) const
void setCommonAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
Position getCommonAttributePosition(SumoXMLAttr key) const
GNENet * myNet
pointer to net
GNENet * getNet() const
get pointer to net
bool isCommonAttributeValid(SumoXMLAttr key, const std::string &value) const
std::string getCommonAttribute(SumoXMLAttr key) const
const GNETagProperties * myTagProperty
reference to tagProperty associated with this attribute carrier
bool myPossibleCandidate
flag to mark this element as possible candidate
bool mySpecialCandidate
flag to mark this element as special candidate
bool myInvalidCandidate
flag to mark this element as invalid candidate
bool myTargetCandidate
flag to mark this element as target candidate
bool myConflictedCandidate
flag to mark this element as conflicted candidate
bool mySourceCandidate
flag to mark this element as source candidate
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
Boundary getContourBoundary() const
get contour boundary
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourAllGeometryPoints(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double radius, const double scale, const bool calculatePosOverShape) const
calculate contour for all geometry points
struct for saving subordinated elements (Junction->Edge->Lane->(Additional | DemandElement)
ProtectElements * getProtectElements() const
get protect elements modul
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition GNEEdge.cpp:755
static const double SNAP_RADIUS
Definition GNEEdge.h:318
const GNEHierarchicalContainerParents< GNEAdditional * > & getParentAdditionals() const
get parent additionals
const GNEHierarchicalContainerParents< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
const GNEHierarchicalContainerParents< GNEEdge * > & getParentEdges() const
get parent edges
const GNEHierarchicalContainerChildren< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
const GNEHierarchicalContainerParents< GNEGenericData * > & getParentGenericDatas() const
get parent demand elements
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
const GNEHierarchicalContainerChildren< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
void setEdgeTemplate(const GNEEdge *edge)
set edge template
GNEEdgeTemplate * getEdgeTemplate() const
get edge template (to copy attributes from)
TemplateEditor * getTemplateEditor() const
get template editor
static RGBColor colorForLinksState(FXuint state)
return the color for each linkstate
static const StringBijection< FXuint > LinkStateNames
long names for link states
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
class lane2lane connection geometry
FOX-declaration.
Definition GNELane.h:52
const GNELane * myLane
lane
Definition GNELane.h:84
double myInternalDrawingWidth
internal lane drawing width (used for drawing selected lanes)
Definition GNELane.h:93
void update(const GUIVisualizationSettings &s)
update lane drawing constants
Definition GNELane.cpp:68
GUIVisualizationSettings::Detail myDetail
detail level
Definition GNELane.h:99
bool drawAsRailway() const
draw as railway
Definition GNELane.cpp:142
bool drawSuperposed() const
draw superposed
Definition GNELane.cpp:148
double getExaggeration() const
get exaggeration
Definition GNELane.cpp:112
double myExaggeration
exaggeration
Definition GNELane.h:87
double getDrawingWidth() const
get lane drawing width
Definition GNELane.cpp:118
double getInternalDrawingWidth() const
get internal lane drawing width
Definition GNELane.cpp:124
double myDrawingWidth
lane drawing width
Definition GNELane.h:90
bool myDrawAsRailway
draw as railway
Definition GNELane.h:102
double myOffset
lane offset
Definition GNELane.h:96
double getOffset() const
get lane offset
Definition GNELane.cpp:130
bool myDrawSuperposed
draw supersposed (reduced width so that the lane markings below are visible)
Definition GNELane.h:105
GUIVisualizationSettings::Detail getDetail() const
get detail
Definition GNELane.cpp:136
GNELane2laneConnection myLane2laneConnections
lane2lane connections
Definition GNELane.h:384
const PositionVector & getLaneShape() const
get elements shape
Definition GNELane.cpp:232
bool isAttributeComputed(SumoXMLAttr key) const override
Definition GNELane.cpp:874
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
Definition GNELane.cpp:666
~GNELane()
Destructor.
Definition GNELane.cpp:188
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const override
return value for lane coloring according to the given scheme
Definition GNELane.cpp:1557
void drawLaneStopOffset(const GUIVisualizationSettings &s) const
draw laneStopOffset
Definition GNELane.cpp:1686
void drawSelectedLane(const GUIVisualizationSettings &s) const
draw selected lane
Definition GNELane.cpp:1046
std::vector< double > myLaneRestrictedTextureRotations
Rotations of textures of restricted lanes.
Definition GNELane.h:371
bool allowPedestrians() const
check if current lane allow pedestrians
Definition GNELane.cpp:220
void drawMarkingsAndBoundings(const GUIVisualizationSettings &s) const
draw lane markings
Definition GNELane.cpp:1112
bool checkDrawSelectContour() const override
check if draw select contour (blue)
Definition GNELane.cpp:423
const RGBColor * mySpecialColor
optional special color
Definition GNELane.h:375
Position getPositionInView() const
Returns position of hierarchical element in view.
Definition GNELane.cpp:337
bool drawAsWaterway(const GUIVisualizationSettings &s) const
whether to draw this lane as a waterways
Definition GNELane.cpp:1710
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition GNELane.cpp:612
double getLengthGeometryFactor() const
get length geometry factor
Definition GNELane.cpp:1968
PositionVector getAttributePositionVector(SumoXMLAttr key) const override
Definition GNELane.cpp:741
void drawDirectionIndicators(const GUIVisualizationSettings &s) const
direction indicators for lanes
Definition GNELane.cpp:1716
bool checkDrawOverContour() const override
check if draw over contour (orange)
Definition GNELane.cpp:379
int getIndex() const
returns the index of the lane
Definition GNELane.cpp:624
GNEMoveElementLane * myMoveElementLane
move element lane
Definition GNELane.h:353
GUIGeometry myLaneGeometry
lane geometry
Definition GNELane.h:359
void drawShapeEdited(const GUIVisualizationSettings &s) const
draw shape edited
Definition GNELane.cpp:1065
void drawOverlappedRoutes(const int numRoutes) const
draw overlapped routes
Definition GNELane.cpp:1669
bool checkDrawRelatedContour() const override
check if draw related contour (cyan)
Definition GNELane.cpp:369
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition GNELane.cpp:496
bool checkDrawToContour() const override
check if draw from contour (magenta)
Definition GNELane.cpp:356
std::string getParentName() const override
Returns the name of the parent object (if any)
Definition GNELane.cpp:1904
void buildLaneOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build lane operations contextual menu
Definition GNELane.cpp:2038
GNEMoveElement * getMoveElement() const override
methods to retrieve the elements linked to this lane
Definition GNELane.cpp:196
GNELane()
FOX needs this.
Definition GNELane.cpp:175
std::vector< GNEConnection * > getGNEOutcomingConnections()
returns a vector with the outgoing GNEConnections of this lane
Definition GNELane.cpp:1938
DrawingConstants * myDrawingConstants
LaneDrawingConstants.
Definition GNELane.h:362
const std::vector< double > & getShapeRotations() const
get rotations of the single shape parts
Definition GNELane.cpp:242
std::string getAttributeForSelection(SumoXMLAttr key) const override
method for getting the attribute in the context of object selection
Definition GNELane.cpp:753
void buildTemplateOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build template oerations contextual menu
Definition GNELane.cpp:2159
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition GNELane.cpp:606
bool setMultiColor(const GUIVisualizationSettings &s, const GUIColorer &c, RGBColor &col) const
sets multiple colors according to the current scheme index and some lane function
Definition GNELane.cpp:1533
void calculateLaneContour(const GUIVisualizationSettings &s, const double layer) const
calculate contour
Definition GNELane.cpp:1405
void drawTLSLinkNo(const GUIVisualizationSettings &s) const
draw TLS link Number
Definition GNELane.cpp:1230
double getLaneParametricLength() const
returns the parameteric length of the lane
Definition GNELane.cpp:643
RGBColor setLaneColor(const GUIVisualizationSettings &s) const
set color according to edit mode and visualisation settings
Definition GNELane.cpp:1423
std::vector< GNEConnection * > getGNEIncomingConnections()
returns a vector with the incoming GNEConnections of this lane
Definition GNELane.cpp:1917
void updateGeometry() override
update pre-computed geometry information
Definition GNELane.cpp:260
bool isRestricted(SUMOVehicleClass vclass) const
check if this lane is restricted
Definition GNELane.cpp:660
bool checkDrawFromContour() const override
check if draw from contour (green)
Definition GNELane.cpp:343
const DrawingConstants * getDrawingConstants() const
get lane drawing constants (previously calculated in drawGL())
Definition GNELane.cpp:254
int myIndex
The index of this lane.
Definition GNELane.h:356
void drawLaneAsRailway() const
draw lane as railway
Definition GNELane.cpp:1758
std::string getAttribute(SumoXMLAttr key) const override
Definition GNELane.cpp:672
void setIndex(int index)
Definition GNELane.cpp:630
void setSpecialColor(const RGBColor *Color2, double colorValue=std::numeric_limits< double >::max())
Definition GNELane.cpp:886
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition GNELane.cpp:453
const GUIGeometry & getLaneGeometry() const
get lane geometry
Definition GNELane.cpp:226
bool checkDrawMoveContour() const override
check if draw move contour (red)
Definition GNELane.cpp:441
Position getAttributePosition(SumoXMLAttr key) const override
Definition GNELane.cpp:735
double getAttributeDouble(SumoXMLAttr key) const override
Definition GNELane.cpp:729
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList) override
Definition GNELane.cpp:763
void drawArrows(const GUIVisualizationSettings &s) const
draw lane arrows
Definition GNELane.cpp:1267
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
Definition GNELane.cpp:618
void drawLane(const GUIVisualizationSettings &s, const double layer) const
draw lane
Definition GNELane.cpp:989
double mySpecialColorValue
optional value that corresponds to which the special color corresponds
Definition GNELane.h:378
void drawChildren(const GUIVisualizationSettings &s) const
draw children
Definition GNELane.cpp:1091
Parameterised * getParameters() override
get parameters associated with this lane
Definition GNELane.cpp:202
std::vector< Position > myLaneRestrictedTexturePositions
Position of textures of restricted lanes.
Definition GNELane.h:368
long onDefault(FXObject *, FXSelector, void *) override
multiplexes message to two targets
Definition GNELane.cpp:1910
bool checkDrawDeleteContour() const override
check if draw delete contour (pink/white)
Definition GNELane.cpp:399
double getLaneShapeLength() const
returns the length of the lane's shape
Definition GNELane.cpp:654
void updateGLObject() override
update GLObject (geometry, ID, etc.)
Definition GNELane.cpp:489
void drawStartEndGeometryPoints(const GUIVisualizationSettings &s) const
draw start and end geometry points
Definition GNELane.cpp:1836
std::vector< RGBColor > myShapeColors
The color of the shape parts (cached)
Definition GNELane.h:381
bool checkDrawDeleteContourSmall() const override
check if draw delete contour small (pink/white)
Definition GNELane.cpp:417
bool setFunctionalColor(int activeScheme, RGBColor &col) const
sets the color according to the current scheme index and some lane function
Definition GNELane.cpp:1519
void updateConnectionIDs()
update IDs of incoming connections of this lane
Definition GNELane.cpp:1953
void buildRechableOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build rechable operations contextual menu
Definition GNELane.cpp:2185
bool isValid(SumoXMLAttr key, const std::string &value) override
Definition GNELane.cpp:799
bool isAttributeEnabled(SumoXMLAttr key) const override
Definition GNELane.cpp:860
void drawLane2LaneConnections() const
draw lane to lane connections
Definition GNELane.cpp:1357
void buildEdgeOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret)
build edge operations contextual menu
Definition GNELane.cpp:1979
const std::vector< double > & getShapeLengths() const
get lengths of the single shape parts
Definition GNELane.cpp:248
void drawLinkNo(const GUIVisualizationSettings &s) const
draw link Number
Definition GNELane.cpp:1193
double getSpeed() const
returns the current speed of lane
Definition GNELane.cpp:637
void drawTextures(const GUIVisualizationSettings &s) const
draw lane textures
Definition GNELane.cpp:1804
void deleteGLObject() override
delete element
Definition GNELane.cpp:480
GNEEdge * getParentEdge() const
get parent edge
Definition GNELane.cpp:214
std::vector< GNELane * > getSelectedLanes() const
get selected lanes
int getNumberOfSelectedEdges() const
get number of selected edges
void deleteLane(GNELane *lane, GNEUndoList *undoList, bool recomputeConnections)
removes lane
Definition GNENet.cpp:664
GNEPathManager * getDataPathManager()
get data path manager
Definition GNENet.cpp:204
GNEPathManager * getDemandPathManager()
get demand path manager
Definition GNENet.cpp:198
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:174
bool isNetRecomputed() const
check if net require recomputing
Definition GNENet.cpp:1623
GNEPathManager * getNetworkPathManager()
get network path manager
Definition GNENet.cpp:192
GNEViewParent * getViewParent() const
get view parent (used for simplify code)
Definition GNENet.cpp:150
NBEdgeCont & getEdgeCont()
returns the NBEdgeCont of the underlying netbuilder
Definition GNENet.cpp:2206
GNEUndoList * getUndoList() const
get undo list(used for simplify code)
Definition GNENet.cpp:156
GNEViewNet * getViewNet() const
get view net (used for simplify code)
Definition GNENet.cpp:144
GNEContour myNetworkElementContour
network element contour
bool myShapeEdited
flag to check if element shape is being edited
void setNetworkElementID(const std::string &newID)
set network element id
bool drawCandidateEdgesWithSpecialColor() const
draw candidate edges with special color (Only for candidates, special and conflicted)
void invalidatePathCalculator()
invalidate pathCalculator
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void drawLanePathElements(const GUIVisualizationSettings &s, const GNELane *lane) const
draw lane path elements
GNEPathCreator * getPathCreator() const
get path creator module
bool controlsEdge(GNEEdge *edge) const
whether the given edge is controlled by the currently edited tlDef
void handleMultiChange(GNELane *lane, FXObject *obj, FXSelector sel, void *data)
update phase definition for the current traffic light and phase
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
GNELane * getLaneFront() const
get front lane or a pointer to nullptr
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::EditNetworkElementShapes & getEditNetworkElementShapes() const
get Edit Shape module
GNEViewNetHelper::InspectedElements & getInspectedElements()
get inspected elements
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
bool checkOverLockedElement(const GUIGlObject *GLObject, const bool isSelected) const
check if given element is locked (used for drawing select and delete contour)
bool checkSelectEdges() const
check if select edges (toggle using button or shift)
const GNEViewNetHelper::ViewObjectsSelector & getViewObjectsSelector() const
get objects under cursor
GNEDeleteFrame * getDeleteFrame() const
get frame for delete elements
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for NETWORK_TLS
GNEInspectorFrame * getInspectorFrame() const
get frame for inspect elements
GNERouteFrame * getRouteFrame() const
get frame for DEMAND_ROUTE
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel, const bool disable=false)
build menu command
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
GUIGlObject * getGLObject() const
The object that belongs to this popup-menu.
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
static double calculateRotation(const Position &first, const Position &second)
return angle between two points (used in geometric calculations)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app, bool addSeparator=true) const
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.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
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.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
T getColor(const double value) const
const std::vector< T > & getSchemes() const
double m2p(double meter) const
meter-to-pixels conversion method
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
GUIGLObjectPopupMenu * getPopup() const
ge the current popup-menu
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 checkBoundaryParentObject(const GUIGlObject *GLObject, const double layer, const GUIGlObject *parent)
Stores the information about how to visualize structures.
GUIVisualizationSizeSettings addSize
bool disableLaneIcons
whether drawing is performed in left-hand networks
GUIVisualizationTextSettings drawLinkJunctionIndex
Detail getDetailLevel(const double exaggeration) const
return the detail level
bool showRails
Information whether rails shall be drawn.
GUIVisualizationCandidateColorSettings candidateColorSettings
candidate color settings
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
bool lefthand
whether drawing is performed in left-hand networks
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
static const RGBColor & getLinkColor(const LinkState &ls, bool realistic=false)
map from LinkState to color constants
double scale
information about a lane's width (temporary, used for a single view)
bool showLaneDirection
Whether to show direction indicators for lanes.
bool drawForViewObjectsHandler
whether drawing is performed for the purpose of selecting objects in view using ViewObjectsHandler
bool showLinkDecals
Information whether link textures (arrows) shall be drawn.
GUIColorer laneColorer
The lane colorer.
bool laneShowBorders
Information whether lane borders shall be drawn.
GUIVisualizationTextSettings drawLinkTLIndex
double selectorFrameScale
the current selection scaling in netedit (set in SelectorFrame)
bool spreadSuperposed
Whether to improve visualisation of superposed (rail) edges.
GUIColorer junctionColorer
The junction colorer.
std::string edgeParam
key for coloring by edge parameter
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
static double naviDegree(const double angle)
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
Definition MFXUtils.cpp:145
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
The representation of a single edge during network building.
Definition NBEdge.h:92
double getLaneSpeed(int lane) const
get lane speed
Definition NBEdge.cpp:2233
void setPermittedChanging(int lane, SVCPermissions changeLeft, SVCPermissions changeRight)
set allowed classes for changing to the left and right from the given lane
Definition NBEdge.cpp:4531
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition NBEdge.cpp:4540
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
Definition NBEdge.cpp:4503
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition NBEdge.cpp:4455
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:552
Lane & getLaneStruct(int lane)
Definition NBEdge.h:1451
bool isBidiRail(bool ignoreSpread=false) const
whether this edge is part of a bidirectional railway
Definition NBEdge.cpp:772
const std::string & getID() const
Definition NBEdge.h:1551
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition NBEdge.cpp:4326
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition NBEdge.cpp:4487
bool isBidiEdge(bool checkPotential=false) const
whether this edge is part of a bidirectional edge pair
Definition NBEdge.cpp:784
int getNumLanes() const
Returns the number of lanes.
Definition NBEdge.h:526
void setFriction(int lane, double friction)
set lane specific friction (negative lane implies set for all lanes)
Definition NBEdge.cpp:4471
std::string getLaneID(int lane) const
get lane ID
Definition NBEdge.cpp:4178
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition NBEdge.cpp:4495
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:545
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:346
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition NBEdge.cpp:4409
Represents a single node (junction) during network building.
Definition NBNode.h:66
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
Definition NBNode.cpp:2499
LinkState getLinkState(const NBEdge *incoming, const NBEdge *outgoing, int fromLane, int toLane, bool mayDefinitelyPass, const std::string &tlID) const
get link state
Definition NBNode.cpp:2584
An upper class for objects with additional parameters.
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:52
double z() const
Returns the z-position.
Definition Position.h:62
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double length2D() const
Returns the length.
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position
double length() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
static const RGBColor WHITE
Definition RGBColor.h:195
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:92
static const RGBColor ORANGE
Definition RGBColor.h:194
static const RGBColor CYAN
Definition RGBColor.h:192
static const RGBColor GREEN
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:403
static const RGBColor BLACK
Definition RGBColor.h:196
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
void setOffset(const double offset)
set offset
bool isDefined() const
check if stopOffset was defined
void setExceptions(const std::string permissions)
set exceptions (used in netedit)
std::string getExceptions() const
get exceptions (used in netedit)
double getOffset() const
get offset
std::vector< std::string > getStrings() const
get all strings
T get(const std::string &str) const
get key
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
static FXIcon * getVClassIcon(const SUMOVehicleClass vc)
returns icon associated to the given vClass
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeDemand() const
@check if current supermode is Demand
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
GNENetworkElement * getEditedNetworkElement() const
pointer to edited network element
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 editingElevation() const
check if we're editing elevation
bool showDemandElements() const
check if show demand elements checkbox is enabled
static const RGBColor special
color for selected special candidate element (Usually selected using shift+click)
static const RGBColor conflict
color for selected conflict candidate element (Usually selected using ctrl+click)
static const RGBColor invalid
color for invalid elements
static const RGBColor target
color for selected candidate target
static const RGBColor possible
color for possible candidate element
static const RGBColor source
color for selected candidate source
RGBColor selectedEdgeColor
edge selection color
RGBColor selectedLaneColor
lane selection color
static const RGBColor editShapeColor
color for edited shapes (Junctions, crossings and connections)
static const double segmentWidth
width of dotted contour segments
static const double laneGeometryPointRadius
moving lane geometry point radius
static const double junctionBubbleRadius
junction bubble radius
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 width
This lane's width.
Definition NBEdge.h:176
StopOffset laneStopOffset
stopOffsets.second - The stop offset for vehicles stopping at the lane's end. Applies if vClass is in...
Definition NBEdge.h:173
PositionVector customShape
A custom shape for this lane set by the user.
Definition NBEdge.h:189
double endOffset
This lane's offset to the intersection begin.
Definition NBEdge.h:169
std::string type
the type of this lane
Definition NBEdge.h:192
std::string oppositeID
An opposite lane ID, if given.
Definition NBEdge.h:179
SVCPermissions changeRight
List of vehicle types that are allowed to change right from this lane.
Definition NBEdge.h:166
double friction
The friction on this lane.
Definition NBEdge.h:154
SVCPermissions changeLeft
List of vehicle types that are allowed to change Left from this lane.
Definition NBEdge.h:163
bool accelRamp
Whether this lane is an acceleration lane.
Definition NBEdge.h:182