Eclipse SUMO - Simulation of Urban MObility
GNEJunction.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// A class for visualizing and editing junctions in netedit (adapted from
19// GUIJunctionWrapper)
20/****************************************************************************/
21#include <config.h>
22
26#include <netbuild/NBOwnTLDef.h>
29#include <netedit/GNENet.h>
30#include <netedit/GNEUndoList.h>
31#include <netedit/GNEViewNet.h>
45
46
47#include "GNEConnection.h"
48#include "GNEJunction.h"
49#include "GNECrossing.h"
50#include "GNEWalkingArea.h"
51
52
53// ===========================================================================
54// method definitions
55// ===========================================================================
56
57GNEJunction::GNEJunction(GNENet* net, NBNode* nbn, bool loaded) :
59 GUIIconSubSys::getIcon(GUIIcon::JUNCTION), {}, {}, {}, {}, {}, {}),
60 myNBNode(nbn),
61 myMaxDrawingSize(1),
62 myAmCreateEdgeSource(false),
63 myLogicStatus(loaded ? FEATURE_LOADED : FEATURE_GUESSED),
64 myAmResponsible(false),
65 myHasValidLogic(loaded),
66 myAmTLSSelected(false),
67 myColorForMissingConnections(false),
68 myTesselation(nbn->getID(), "", RGBColor::MAGENTA, nbn->getShape(), false, true, 0),
69myExaggeration(1) {
70 // update centering boundary without updating grid
71 updateCenteringBoundary(false);
72}
73
74
76 // delete all GNECrossing
77 for (const auto& crossing : myGNECrossings) {
78 crossing->decRef();
79 if (crossing->unreferenced()) {
80 // check if remove it from Attribute Carriers
81 if (myNet->getAttributeCarriers()->getCrossings().count(crossing) > 0) {
83 }
84 // show extra information for tests
85 WRITE_DEBUG("Deleting unreferenced " + crossing->getTagStr() + " '" + crossing->getID() + "' in GNEJunction destructor");
86 delete crossing;
87 }
88 }
89 // delete all GNEWalkingArea
90 for (const auto& walkingArea : myGNEWalkingAreas) {
91 walkingArea->decRef();
92 if (walkingArea->unreferenced()) {
93 // check if remove it from Attribute Carriers
94 if (myNet->getAttributeCarriers()->getWalkingAreas().count(walkingArea) > 0) {
96 }
97 // show extra information for tests
98 WRITE_DEBUG("Deleting unreferenced " + walkingArea->getTagStr() + " '" + walkingArea->getID() + "' in GNEJunction destructor");
99 delete walkingArea;
100 }
101 }
102 if (myAmResponsible) {
103 // show extra information for tests
104 WRITE_DEBUG("Deleting NBNode of '" + getID() + "' in GNEJunction destructor");
105 delete myNBNode;
106 }
107}
108
109
110const PositionVector&
112 return myNBNode->getShape();
113}
114
115
116void
119 // trigger rebuilding tesselation
120 myExaggeration = 2;
121}
122
123
124void
125GNEJunction::updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings) {
126 // recalc max drawing size
127 myMaxDrawingSize = MAX2(getCenteringBoundary().getWidth(), getCenteringBoundary().getHeight());
128 // rebuild crossings
129 rebuildGNECrossings(rebuildNBNodeCrossings);
130 // clear walking areas
132 // clear missing connections
134}
135
136
139 return myNBNode->getPosition();
140}
141
142
145 // edit depending if shape is being edited
146 if (isShapeEdited()) {
147 // calculate move shape operation
150 } else {
151 // return move junction position
152 return new GNEMoveOperation(this, myNBNode->getPosition());
153 }
154}
155
156
157void
158GNEJunction::removeGeometryPoint(const Position clickedPosition, GNEUndoList* undoList) {
159 // edit depending if shape is being edited
160 if (isShapeEdited()) {
161 // get original shape
163 // check shape size
164 if (shape.size() > 2) {
165 // obtain index
166 int index = shape.indexOfClosest(clickedPosition);
167 // get snap radius
169 // check if we have to create a new index
170 if ((index != -1) && shape[index].distanceSquaredTo2D(clickedPosition) < (snap_radius * snap_radius)) {
171 // remove geometry point
172 shape.erase(shape.begin() + index);
173 // commit new shape
174 undoList->begin(GUIIcon::JUNCTION, "remove geometry point of " + getTagStr());
175 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_SHAPE, toString(shape)));
176 undoList->end();
177 }
178 }
179 }
180}
181
182
183void
184GNEJunction::rebuildGNECrossings(bool rebuildNBNodeCrossings) {
185 // rebuild GNECrossings only if create crossings and walkingAreas in net is enabled
187 if (rebuildNBNodeCrossings) {
188 // build new NBNode::Crossings and walking areas
192 }
193 // create a vector to keep retrieved and created crossings
194 std::vector<GNECrossing*> retrievedCrossings;
195 // iterate over NBNode::Crossings of GNEJunction
196 for (const auto& crossing : myNBNode->getCrossingsIncludingInvalid()) {
197 // retrieve existent GNECrossing, or create it
198 GNECrossing* retrievedGNECrossing = retrieveGNECrossing(crossing.get());
199 retrievedCrossings.push_back(retrievedGNECrossing);
200 // check if previously this GNECrossings exists, and if true, remove it from myGNECrossings and insert in tree again
201 std::vector<GNECrossing*>::iterator retrievedExists = std::find(myGNECrossings.begin(), myGNECrossings.end(), retrievedGNECrossing);
202 if (retrievedExists != myGNECrossings.end()) {
203 myGNECrossings.erase(retrievedExists);
204 // update geometry of retrieved crossing
205 retrievedGNECrossing->updateGeometry();
206 // update boundary
207 retrievedGNECrossing->updateCenteringBoundary(false);
208 } else {
209 // include reference to created GNECrossing
210 retrievedGNECrossing->incRef();
211 }
212 }
213 // delete non retrieved GNECrossings (we don't need to extract if from Tree two times)
214 for (const auto& crossing : myGNECrossings) {
215 crossing->decRef();
216 // check if crossing is selected
217 if (crossing->isAttributeCarrierSelected()) {
218 crossing->unselectAttributeCarrier();
219 }
220 // remove it from inspected ACS
222 // remove it from net
223 myNet->removeGLObjectFromGrid(crossing);
224 // remove it from attributeCarriers
226 if (crossing->unreferenced()) {
227 // show extra information for tests
228 WRITE_DEBUG("Deleting unreferenced " + crossing->getTagStr() + " in rebuildGNECrossings()");
229 delete crossing;
230 }
231 }
232 // copy retrieved (existent and created) GNECrossings to myGNECrossings
233 myGNECrossings = retrievedCrossings;
234 }
235}
236
237
238void
240 if (OptionsCont::getOptions().getBool("lefthand")) {
241 myNBNode->mirrorX();
242 for (NBEdge* e : myNBNode->getEdges()) {
243 e->mirrorX();
244
245 }
246 }
247}
248
249
250void
251GNEJunction::buildTLSOperations(GUISUMOAbstractView& parent, GUIGLObjectPopupMenu* ret, const int numSelectedJunctions) {
252 // create menu pane for edge operations
253 FXMenuPane* TLSOperations = new FXMenuPane(ret);
254 ret->insertMenuPaneChild(TLSOperations);
255 new FXMenuCascade(ret, "TLS operations", GUIIconSubSys::getIcon(GUIIcon::MODETLS), TLSOperations);
256 // create menu commands for all TLS operations
257 FXMenuCommand* mcAddTLS = GUIDesigns::buildFXMenuCommand(TLSOperations, "Add TLS", nullptr, &parent, MID_GNE_JUNCTION_ADDTLS);
258 FXMenuCommand* mcAddJoinedTLS = GUIDesigns::buildFXMenuCommand(TLSOperations, "Add joined TLS", nullptr, &parent, MID_GNE_JUNCTION_ADDJOINTLS);
259 // check if disable create TLS
260 if (myNBNode->getControllingTLS().size() > 0) {
261 mcAddTLS->disable();
262 mcAddJoinedTLS->disable();
263 } else {
264 mcAddTLS->enable();
265 // check if add joined TLS
266 if (isAttributeCarrierSelected() && (numSelectedJunctions > 1)) {
267 mcAddJoinedTLS->enable();
268 } else {
269 mcAddJoinedTLS->disable();
270 }
271 }
272}
273
274
277 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
278 // build common commands
279 buildPopupHeader(ret, app);
282 // build selection and show parameters menu
285 buildPositionCopyEntry(ret, app);
286 // add separator
287 new FXMenuSeparator(ret);
288 // check if we're in supermode network
290 const int numSelectedJunctions = myNet->getAttributeCarriers()->getNumberOfSelectedJunctions();
291 const int numEndpoints = (int)myNBNode->getEndPoints().size();
292 // check if we're handling a selection
293 bool handlingSelection = isAttributeCarrierSelected() && (numSelectedJunctions > 1);
294 // check if menu commands has to be disabled
298 // build TLS operation
299 if (!invalidMode) {
300 buildTLSOperations(parent, ret, numSelectedJunctions);
301 }
302 // create menu commands
303 GUIDesigns::buildFXMenuCommand(ret, "Reset edge endpoints", nullptr, &parent, MID_GNE_JUNCTION_RESET_EDGE_ENDPOINTS);
304 FXMenuCommand* mcCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Set custom junction shape", nullptr, &parent, MID_GNE_JUNCTION_EDIT_SHAPE);
305 FXMenuCommand* mcResetCustomShape = GUIDesigns::buildFXMenuCommand(ret, "Reset junction shape", nullptr, &parent, MID_GNE_JUNCTION_RESET_SHAPE);
306 FXMenuCommand* mcReplaceByGeometryPoint = GUIDesigns::buildFXMenuCommand(ret, "Replace junction by geometry point", nullptr, &parent, MID_GNE_JUNCTION_REPLACE);
307 FXMenuCommand* mcSplitJunction = GUIDesigns::buildFXMenuCommand(ret, "Split junction (" + toString(numEndpoints) + " end points)", nullptr, &parent, MID_GNE_JUNCTION_SPLIT);
308 FXMenuCommand* mcSplitJunctionAndReconnect = GUIDesigns::buildFXMenuCommand(ret, "Split junction and reconnect", nullptr, &parent, MID_GNE_JUNCTION_SPLIT_RECONNECT);
309 // check if is a roundabout
310 if (myNBNode->isRoundabout()) {
311 GUIDesigns::buildFXMenuCommand(ret, "Select roundabout", nullptr, &parent, MID_GNE_JUNCTION_SELECT_ROUNDABOUT);
312 } else {
313 // get radius
314 const double radius = (myNBNode->getRadius() == NBNode::UNSPECIFIED_RADIUS) ? OptionsCont::getOptions().getFloat("default.junctions.radius") : myNBNode->getRadius();
315 const std::string menuEntryInfo = "Convert to roundabout (using junction attribute radius " + toString(radius) + ")";
316 FXMenuCommand* mcRoundabout = GUIDesigns::buildFXMenuCommand(ret, menuEntryInfo.c_str(), nullptr, &parent, MID_GNE_JUNCTION_CONVERT_ROUNDABOUT);
317 // check if disable depending of number of edges
318 if ((getChildEdges().size() < 2) ||
319 ((myGNEIncomingEdges.size() == 1) && (myGNEOutgoingEdges.size() == 1) && (myGNEIncomingEdges[0]->getFromJunction() == myGNEOutgoingEdges[0]->getToJunction()))) {
320 mcRoundabout->disable();
321 }
322 }
323 // check multijunctions
324 const std::string multi = ((numSelectedJunctions > 1) && isAttributeCarrierSelected()) ? " of " + toString(numSelectedJunctions) + " junctions" : "";
325 FXMenuCommand* mcClearConnections = GUIDesigns::buildFXMenuCommand(ret, "Clear connections" + multi, nullptr, &parent, MID_GNE_JUNCTION_CLEAR_CONNECTIONS);
326 FXMenuCommand* mcResetConnections = GUIDesigns::buildFXMenuCommand(ret, "Reset connections" + multi, nullptr, &parent, MID_GNE_JUNCTION_RESET_CONNECTIONS);
327 // check if current mode is correct
328 if (invalidMode) {
329 mcCustomShape->disable();
330 mcClearConnections->disable();
331 mcResetConnections->disable();
332 }
333 // check if we're handling a selection
334 if (handlingSelection) {
335 mcResetCustomShape->setText(TL("Reset junction shapes"));
336 }
337 // disable mcClearConnections if junction hasn't connections
338 if (getGNEConnections().empty()) {
339 mcClearConnections->disable();
340 }
341 // disable mcResetCustomShape if junction doesn't have a custom shape
342 if (myNBNode->getShape().size() == 0) {
343 mcResetCustomShape->disable();
344 }
345 // checkIsRemovable requires turnarounds to be computed. This is ugly
346 if ((myNBNode->getIncomingEdges().size() == 2) && (myNBNode->getOutgoingEdges().size() == 2)) {
348 }
349 std::string reason = "wrong edit mode";
350 if (invalidMode || !myNBNode->checkIsRemovableReporting(reason)) {
351 mcReplaceByGeometryPoint->setText(mcReplaceByGeometryPoint->getText() + " (" + reason.c_str() + ")");
352 mcReplaceByGeometryPoint->disable();
353 }
354 // check if disable split junctions
355 if (numEndpoints == 1) {
356 mcSplitJunction->disable();
357 mcSplitJunctionAndReconnect->disable();
358 }
359 }
360 return ret;
361}
362
363
364double
366 return s.junctionSize.getExaggeration(s, this, 4);
367}
368
369
370void
372 // Remove object from net
373 if (updateGrid) {
375 }
376 // update boundary
377 if (myNBNode->getShape().size() > 0) {
379 } else {
380 // calculate boundary using EXTENT as size
381 const double EXTENT = 2;
382 Boundary b(myNBNode->getPosition().x() - EXTENT, myNBNode->getPosition().y() - EXTENT,
383 myNBNode->getPosition().x() + EXTENT, myNBNode->getPosition().y() + EXTENT);
384 myBoundary = b;
385 }
386 myBoundary.grow(10);
387 // add object into net
388 if (updateGrid) {
390 }
391 // trigger rebuilding tesselation
392 myExaggeration = 2;
393}
394
395
396void
398 // check if boundary has to be drawn
399 if (s.drawBoundaries) {
401 }
402 // check if draw start und end
403 const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
405 // declare variables
406 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
407 const double junctionExaggeration = getExaggeration(s);
408 const double bubbleRadius = s.neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
409 // declare draw shape flag
410 const bool drawShape = (myNBNode->getShape().size() > 0) && s.drawJunctionShape;
411 // declare draw bubble flag
412 bool drawBubble = true;
413 if (!s.drawJunctionShape) {
414 // don't draw bubble if it was disabled in GUIVisualizationSettings
415 drawBubble = false;
416 }
417 if (myNBNode->getShape().area() > 4) {
418 // don't draw if shape area is greather than 4
419 drawBubble = false;
420 }
422 // only draw bubbles in network mode
423 drawBubble = false;
424 }
426 // force draw bubbles if we enabled option in checkbox of viewNet
427 drawBubble = true;
428 }
431 // force draw if this junction is a candidate
432 drawBubble = true;
433 }
434 // only continue if exaggeration is greather than 0
435 if (junctionExaggeration > 0) {
436 // push junction name
438 // push layer matrix
440 // translate to front
442 // push name
443 if (s.scale * junctionExaggeration * myMaxDrawingSize < 1.) {
444 // draw something simple so that selection still works
446 } else {
447 // check if shape has to be drawn
448 if (drawShape) {
449 // set shape color
450 const RGBColor junctionShapeColor = setColor(s, false);
451 // recognize full transparency and simply don't draw
452 if (junctionShapeColor.alpha() != 0) {
453 // set color
454 GLHelper::setColor(junctionShapeColor);
455 // adjust shape to exaggeration
456 if ((junctionExaggeration > 1 || myExaggeration > 1) && junctionExaggeration != myExaggeration) {
457 myExaggeration = junctionExaggeration;
460 myTesselation.getShapeRef().scaleRelative(junctionExaggeration);
462 }
463 // first check if inner junction polygon can be drawn
465 // only draw a point if mouse is around shape
466 if (myTesselation.getShape().around(mousePosition)) {
467 // push matrix
469 // move to mouse position
470 glTranslated(mousePosition.x(), mousePosition.y(), 0.1);
471 // draw a simple circle
473 // pop matrix
475 }
476 } else if ((s.scale * junctionExaggeration * myMaxDrawingSize) >= 40) {
477 // draw shape with high detail
479 } else {
480 // draw shape
482 }
483 // draw shape points only in Network supemode
485 // set color
486 const RGBColor darkerColor = junctionShapeColor.changedBrightness(-32);
487 // calculate geometry
488 GUIGeometry junctionGeometry;
489 // obtain junction Shape
490 PositionVector junctionOpenShape = myNBNode->getShape();
491 // adjust shape to exaggeration
492 if (junctionExaggeration > 1) {
493 junctionOpenShape.scaleRelative(junctionExaggeration);
494 }
495 // update geometry
496 junctionGeometry.updateGeometry(junctionOpenShape);
497 // set color
498 GLHelper::setColor(darkerColor);
499 // draw shape
501 // draw geometry points
503 s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration,
504 myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
505 // draw moving hint
507 GUIGeometry::drawMovingHint(s, myNet->getViewNet()->getPositionInformation(), junctionOpenShape, darkerColor,
508 s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration);
509 }
510 }
511 }
512 }
513 // check if bubble has to be drawn
514 if (drawBubble) {
515 // set bubble color
516 const RGBColor bubbleColor = setColor(s, true);
517 // recognize full transparency and simply don't draw
518 if (bubbleColor.alpha() != 0) {
519 // check if mouse is in bubble
520 const bool mouseInBubble = (mousePosition.distanceSquaredTo2D(myNBNode->getPosition()) <= (bubbleRadius * bubbleRadius));
521 // only draw filled circle if we aren't in draw for selecting mode, or if distance to center is enough)
522 if (!s.drawForPositionSelection || mouseInBubble) {
523 // push matrix
525 // set color
526 GLHelper::setColor(bubbleColor);
527 // move matrix junction center
528 glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
529 // draw filled circle
531 // pop matrix
533 }
534 }
535 }
536 // draw TLS
537 drawTLSIcon(s);
538 // draw elevation
541 // Translate to center of junction
542 glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
543 // draw Z value
546 }
547 // pop layer Matrix
549 // pop junction name
551 // draw name and ID
554 if (s.junctionName.show(this) && myNBNode->getName() != "") {
556 }
557 }
558 // draw Junction childs
560 // draw path additional elements
562 // draw lock icon
564 // draw dotted contours
565 drawDottedContours(s, drawShape, drawBubble, junctionExaggeration, bubbleRadius);
566 }
567 }
568}
569
570
571void
573 // Check if edge can be deleted
576 }
577}
578
579
580void
583}
584
585
586NBNode*
588 return myNBNode;
589}
590
591
592std::vector<GNEJunction*>
594 // use set to avoid duplicates junctions
595 std::set<GNEJunction*> junctions;
596 for (const auto& incomingEdge : myGNEIncomingEdges) {
597 junctions.insert(incomingEdge->getFromJunction());
598 }
599 for (const auto& outgoingEdge : myGNEOutgoingEdges) {
600 junctions.insert(outgoingEdge->getToJunction());
601 }
602 return std::vector<GNEJunction*>(junctions.begin(), junctions.end());
603}
604
605
606void
608 // Check if incoming edge was already inserted
609 std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
610 if (i != myGNEIncomingEdges.end()) {
611 throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + getTagStr() + " with ID " + getID() + "'");
612 } else {
613 // Add edge into containers
614 myGNEIncomingEdges.push_back(edge);
615 }
616}
617
618
619
620void
622 // Check if outgoing edge was already inserted
623 std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
624 if (i != myGNEOutgoingEdges.end()) {
625 throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + getTagStr() + " with ID " + getID() + "'");
626 } else {
627 // Add edge into containers
628 myGNEOutgoingEdges.push_back(edge);
629 }
630}
631
632
633void
635 // Check if incoming edge was already inserted
636 std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
637 if (i == myGNEIncomingEdges.end()) {
638 throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + getTagStr() + " with ID " + getID() + "'");
639 } else {
640 // remove edge from containers
641 myGNEIncomingEdges.erase(i);
642 }
643}
644
645
646void
648 // Check if outgoing edge was already inserted
649 std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
650 if (i == myGNEOutgoingEdges.end()) {
651 throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + getTagStr() + " with ID " + getID() + "'");
652 } else {
653 // remove edge from containers
654 myGNEOutgoingEdges.erase(i);
655 }
656}
657
658
659const std::vector<GNEEdge*>&
661 return myGNEIncomingEdges;
662}
663
664
665const std::vector<GNEEdge*>&
667 return myGNEOutgoingEdges;
668}
669
670
671const std::vector<GNECrossing*>&
673 return myGNECrossings;
674}
675
676
677const std::vector<GNEWalkingArea*>&
679 return myGNEWalkingAreas;
680}
681
682
683std::vector<GNEConnection*>
685 std::vector<GNEConnection*> connections;
686 for (const auto& incomingEdge : myGNEIncomingEdges) {
687 for (const auto& connection : incomingEdge->getGNEConnections()) {
688 connections.push_back(connection);
689 }
690 }
691 return connections;
692}
693
694
695void
698}
699
700
701void
703 myAmCreateEdgeSource = false;
704}
705
706
707void
709 myAmTLSSelected = selected;
710}
711
712
713void
715 if (!myNBNode->hasCustomShape()) {
716 if (myNBNode->myPoly.size() > 0) {
717 // write GL Debug
718 WRITE_GLDEBUG("<-- Invalidating shape of junction '" + getID() + "' -->");
719 // clear poly
720 myNBNode->myPoly.clear();
721 // update centering boundary
723 }
725 }
726}
727
728
729void
730GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
731 myHasValidLogic = valid;
732 if (!valid) {
733 assert(undoList != 0);
734 assert(undoList->hasCommandGroup());
737 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
738 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge((*it)->getID());
739 removeConnectionsFrom(srcEdge, undoList, false); // false, because the whole tls will be invalidated at the end
740 undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
741 }
742 undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status), true);
743 invalidateTLS(undoList);
744 } else {
745 // logic valed, then rebuild GNECrossings to adapt it to the new logic
746 // (but don't rebuild the crossings in NBNode because they are already finished)
747 rebuildGNECrossings(false);
748 }
749}
750
751
752void
753GNEJunction::removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane) {
754 NBEdge* srcNBE = edge->getNBEdge();
755 NBEdge* turnEdge = srcNBE->getTurnDestination();
756 // Make a copy of connections
757 std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
758 // delete in reverse so that undoing will add connections in the original order
759 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
760 if (lane >= 0 && (*con_it).fromLane != lane) {
761 continue;
762 }
763 bool hasTurn = con_it->toEdge == turnEdge;
764 undoList->add(new GNEChange_Connection(edge, *con_it, false, false), true);
765 // needs to come after GNEChange_Connection
766 // XXX bug: this code path will not be used on a redo!
767 if (hasTurn) {
769 }
770 }
771 if (updateTLS) {
772 std::vector<NBConnection> removeConnections;
773 for (NBEdge::Connection con : connections) {
774 removeConnections.push_back(NBConnection(srcNBE, con.fromLane, con.toEdge, con.toLane));
775 }
776 removeTLSConnections(removeConnections, undoList);
777 }
778}
779
780
781void
782GNEJunction::removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane) {
783 NBEdge* destNBE = edge->getNBEdge();
784 std::vector<NBConnection> removeConnections;
785 for (NBEdge* srcNBE : myNBNode->getIncomingEdges()) {
786 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge(srcNBE->getID());
787 std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
788 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
789 if ((*con_it).toEdge == destNBE) {
790 if (lane >= 0 && (*con_it).toLane != lane) {
791 continue;
792 }
793 bool hasTurn = srcNBE->getTurnDestination() == destNBE;
794 undoList->add(new GNEChange_Connection(srcEdge, *con_it, false, false), true);
795 // needs to come after GNEChange_Connection
796 // XXX bug: this code path will not be used on a redo!
797 if (hasTurn) {
798 myNet->addExplicitTurnaround(srcNBE->getID());
799 }
800 removeConnections.push_back(NBConnection(srcNBE, (*con_it).fromLane, destNBE, (*con_it).toLane));
801 }
802 }
803 }
804 if (updateTLS) {
805 removeTLSConnections(removeConnections, undoList);
806 }
807}
808
809
810void
811GNEJunction::removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList) {
812 if (connections.size() > 0) {
813 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
814 for (const auto& TLS : coypOfTls) {
815 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
816 // guessed TLS (NBOwnTLDef) do not need to be updated
817 if (tlDef != nullptr) {
818 std::string newID = tlDef->getID();
819 // create replacement before deleting the original because deletion will mess up saving original nodes
820 NBLoadedSUMOTLDef* replacementDef = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
821 for (NBConnection& con : connections) {
822 replacementDef->removeConnection(con);
823 }
824 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
825 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
826 // the removed traffic light may have controlled more than one junction. These too have become invalid now
827 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
828 for (const auto& node : copyOfNodes) {
829 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
830 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
831 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
832 }
833 }
834 }
835 }
836}
837
838
839void
841 // remap connections of the edge
842 assert(which->getLanes().size() == by->getLanes().size());
843 std::vector<NBEdge::Connection> connections = which->getNBEdge()->getConnections();
844 for (NBEdge::Connection& c : connections) {
845 undoList->add(new GNEChange_Connection(which, c, false, false), true);
846 undoList->add(new GNEChange_Connection(by, c, false, true), true);
847 }
848 // also remap tls connections
849 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
850 for (const auto& TLS : coypOfTls) {
851 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
852 // guessed TLS (NBOwnTLDef) do not need to be updated
853 if (tlDef != nullptr) {
854 std::string newID = tlDef->getID();
855 // create replacement before deleting the original because deletion will mess up saving original nodes
856 NBLoadedSUMOTLDef* replacementDef = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
857 for (int i = 0; i < (int)which->getLanes().size(); ++i) {
858 replacementDef->replaceRemoved(which->getNBEdge(), i, by->getNBEdge(), i, true);
859 }
860 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
861 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
862 // the removed traffic light may have controlled more than one junction. These too have become invalid now
863 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
864 for (const auto& node : copyOfNodes) {
865 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
866 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
867 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
868 }
869 }
870 }
871}
872
873
874void
877 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
878 NBEdge* srcNBE = *it;
879 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge(srcNBE->getID());
881 }
882}
883
884
885void
886GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection, const NBConnection& addedConnection) {
887 assert(undoList->hasCommandGroup());
888 // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
889 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
890 for (const auto& TLS : coypOfTls) {
891 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
892 if (tlDef != nullptr) {
893 NBTrafficLightDefinition* replacementDef = nullptr;
894 std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
895 if (deletedConnection != NBConnection::InvalidConnection) {
896 // create replacement before deleting the original because deletion will mess up saving original nodes
897 NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
898 repl->removeConnection(deletedConnection);
899 replacementDef = repl;
900 } else if (addedConnection != NBConnection::InvalidConnection) {
901 if (addedConnection.getTLIndex() == NBConnection::InvalidTlIndex) {
902 // custom tl indices of crossings might become invalid upon recomputation so we must save them
903 // however, they could remain valid so we register a change but keep them at their old value
904 for (const auto& crossing : myGNECrossings) {
905 const std::string oldValue = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX);
907 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX, oldValue), true);
908 const std::string oldValue2 = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX2);
910 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX2, oldValue2), true);
911 }
912 }
913 NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
914 repl->addConnection(addedConnection.getFrom(), addedConnection.getTo(),
915 addedConnection.getFromLane(), addedConnection.getToLane(), addedConnection.getTLIndex(), addedConnection.getTLIndex2());
916 replacementDef = repl;
917 } else {
918 // recompute crossing indices along with everything else
919 for (const auto& crossing : myGNECrossings) {
920 const std::string oldValue = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX);
922 const std::string oldValue2 = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX2);
924 }
925 replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
926 replacementDef->setProgramID(tlDef->getProgramID());
927 }
928 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
929 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
930 // the removed traffic light may have controlled more than one junction. These too have become invalid now
931 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
932 for (const auto& node : copyOfNodes) {
933 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
934 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
935 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
936 }
937 }
938 }
939}
940
941void
943 // obtain a copy of GNECrossing of junctions
944 const auto copyOfGNECrossings = myGNECrossings;
945 // iterate over copy of GNECrossings
946 for (const auto& crossing : copyOfGNECrossings) {
947 // obtain the set of edges vinculated with the crossing (due it works as ID)
948 EdgeSet edgeSet(crossing->getCrossingEdges().begin(), crossing->getCrossingEdges().end());
949 // If this edge is part of the set of edges of crossing
950 if (edgeSet.count(edge->getNBEdge()) == 1) {
951 // delete crossing if this is their last edge
952 if ((crossing->getCrossingEdges().size() == 1) && (crossing->getCrossingEdges().front() == edge->getNBEdge())) {
953 myNet->deleteCrossing(crossing, undoList);
954 } else {
955 // remove this edge of the edge's attribute of crossing (note: This can invalidate the crossing)
956 std::vector<std::string> edges = GNEAttributeCarrier::parse<std::vector<std::string>>(crossing->getAttribute(SUMO_ATTR_EDGES));
957 edges.erase(std::find(edges.begin(), edges.end(), edge->getID()));
958 crossing->setAttribute(SUMO_ATTR_EDGES, joinToString(edges, " "), undoList);
959 }
960 }
961 }
962}
963
964
965bool
967 return myHasValidLogic;
968}
969
970
972GNEJunction::retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist) {
973 // iterate over all crossing
974 for (const auto& crossing : myGNECrossings) {
975 // if found, return it
976 if (crossing->getCrossingEdges() == NBNodeCrossing->edges) {
977 return crossing;
978 }
979 }
980 if (createIfNoExist) {
981 // create new GNECrossing
982 GNECrossing* createdGNECrossing = new GNECrossing(this, NBNodeCrossing->edges);
983 // show extra information for tests
984 WRITE_DEBUG("Created " + createdGNECrossing->getTagStr() + " '" + createdGNECrossing->getID() + "' in retrieveGNECrossing()");
985 // update geometry after creating
986 createdGNECrossing->updateGeometry();
987 // add it in Network
988 myNet->addGLObjectIntoGrid(createdGNECrossing);
989 // add it in attributeCarriers
990 myNet->getAttributeCarriers()->insertCrossing(createdGNECrossing);
991 return createdGNECrossing;
992 } else {
993 return nullptr;
994 }
995}
996
997
999GNEJunction::retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist) {
1000 // iterate over all walkingArea
1001 for (const auto& walkingArea : myGNEWalkingAreas) {
1002 // if found, return it
1003 if (walkingArea->getID() == NBNodeWalkingAreaID) {
1004 return walkingArea;
1005 }
1006 }
1007 if (createIfNoExist) {
1008 // create new GNEWalkingArea
1009 GNEWalkingArea* createdGNEWalkingArea = new GNEWalkingArea(this, NBNodeWalkingAreaID);
1010 // show extra information for tests
1011 WRITE_DEBUG("Created " + createdGNEWalkingArea->getTagStr() + " '" + createdGNEWalkingArea->getID() + "' in retrieveGNEWalkingArea()");
1012 // update geometry after creating
1013 createdGNEWalkingArea->updateGeometry();
1014 // add it in Network
1015 myNet->addGLObjectIntoGrid(createdGNEWalkingArea);
1016 // add it in attributeCarriers
1017 myNet->getAttributeCarriers()->insertWalkingArea(createdGNEWalkingArea);
1018 return createdGNEWalkingArea;
1019 } else {
1020 return nullptr;
1021 }
1022}
1023
1024
1025void
1027 // only it's needed to mark the connections of incoming edges
1028 for (const auto& i : myGNEIncomingEdges) {
1029 for (const auto& j : i->getGNEConnections()) {
1030 j->markConnectionGeometryDeprecated();
1031 }
1032 if (includingNeighbours) {
1033 i->getFromJunction()->markConnectionsDeprecated(false);
1034 }
1035 }
1036}
1037
1038
1039void
1040GNEJunction::setJunctionType(const std::string& value, GNEUndoList* undoList) {
1041 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " type");
1043 if (getNBNode()->isTLControlled() &&
1044 // if switching changing from or to traffic_light_right_on_red we need to remove the old plan
1047 ) {
1048 // make a copy because we will modify the original
1049 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1050 for (const auto& TLS : copyOfTls) {
1051 undoList->add(new GNEChange_TLS(this, TLS, false), true);
1052 }
1053 }
1054 if (!getNBNode()->isTLControlled()) {
1055 // create new traffic light
1056 undoList->add(new GNEChange_TLS(this, nullptr, true), true);
1057 }
1058 } else if (getNBNode()->isTLControlled()) {
1059 // delete old traffic light
1060 // make a copy because we will modify the original
1061 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1062 for (const auto& TLS : copyOfTls) {
1063 undoList->add(new GNEChange_TLS(this, TLS, false, false), true);
1064 const std::vector<NBNode*> copyOfNodes = TLS->getNodes(); // make a copy!
1065 for (const auto& node : copyOfNodes) {
1066 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1067 sharing->invalidateTLS(undoList);
1068 }
1069 }
1070 }
1071 // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
1072 undoList->add(new GNEChange_Attribute(this, SUMO_ATTR_TYPE, value), true);
1073 for (const auto& crossing : myGNECrossings) {
1074 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX, "-1"), true);
1075 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX2, "-1"), true);
1076 }
1077 undoList->end();
1078}
1079
1080
1081double
1083 return myMaxDrawingSize;
1084}
1085
1086
1087void
1089 // delete non retrieved GNEWalkingAreas (we don't need to extract if from Tree two times)
1090 for (const auto& walkingArea : myGNEWalkingAreas) {
1091 walkingArea->decRef();
1092 // check if walkingArea is selected
1093 if (walkingArea->isAttributeCarrierSelected()) {
1094 walkingArea->unselectAttributeCarrier();
1095 }
1096 // remove it from inspected ACS
1098 // remove it from net
1099 myNet->removeGLObjectFromGrid(walkingArea);
1100 // remove it from attributeCarriers
1102 if (walkingArea->unreferenced()) {
1103 // show extra information for tests
1104 WRITE_DEBUG("Deleting unreferenced " + walkingArea->getTagStr() + " in rebuildGNEWalkingAreas()");
1105 delete walkingArea;
1106 }
1107 }
1108 myGNEWalkingAreas.clear();
1109}
1110
1111
1112void
1114 // first clear GNEWalkingAreas
1116 // iterate over NBNode::WalkingAreas of GNEJunction
1117 for (const auto& walkingArea : myNBNode->getWalkingAreas()) {
1118 // retrieve existent GNEWalkingArea, or create it
1119 GNEWalkingArea* retrievedGNEWalkingArea = retrieveGNEWalkingArea(walkingArea.id, true);
1120 // include reference to created GNEWalkingArea
1121 retrievedGNEWalkingArea->incRef();
1122 // update geometry of retrieved walkingArea
1123 retrievedGNEWalkingArea->updateGeometry();
1124 // update boundary
1125 retrievedGNEWalkingArea->updateCenteringBoundary(false);
1126 // add in walkingAreas
1127 myGNEWalkingAreas.push_back(retrievedGNEWalkingArea);
1128 }
1129}
1130
1131
1132std::string
1134 switch (key) {
1135 case SUMO_ATTR_ID:
1136 return getMicrosimID();
1137 case SUMO_ATTR_POSITION:
1138 return toString(myNBNode->getPosition());
1139 case SUMO_ATTR_TYPE:
1140 return toString(myNBNode->getType());
1142 return myLogicStatus;
1143 case SUMO_ATTR_SHAPE:
1144 return toString(myNBNode->getShape());
1145 case SUMO_ATTR_RADIUS:
1146 if (myNBNode->getRadius() < 0) {
1147 return "default";
1148 } else {
1149 return toString(myNBNode->getRadius());
1150 }
1151 case SUMO_ATTR_TLTYPE:
1153 // @todo this causes problems if the node were to have multiple programs of different type (plausible)
1154 return toString((*myNBNode->getControllingTLS().begin())->getType());
1155 } else {
1156 return "No TLS";
1157 }
1158 case SUMO_ATTR_TLLAYOUT:
1160 return toString((*myNBNode->getControllingTLS().begin())->getLayout());
1161 } else {
1162 return "No TLS";
1163 }
1164 case SUMO_ATTR_TLID:
1166 return toString((*myNBNode->getControllingTLS().begin())->getID());
1167 } else {
1168 return "No TLS";
1169 }
1171 // keep clear is only used as a convenience feature in plain xml
1172 // input. When saving to .net.xml the status is saved only for the connections
1173 // to show the correct state we must check all connections
1174 for (const auto& i : myGNEIncomingEdges) {
1175 for (const auto& j : i->getGNEConnections()) {
1176 if (j->getNBEdgeConnection().keepClear) {
1177 return True;
1178 }
1179 }
1180 }
1181 return False;
1184 case SUMO_ATTR_FRINGE:
1186 case SUMO_ATTR_NAME:
1187 return myNBNode->getName();
1188 case GNE_ATTR_SELECTED:
1191 return myNBNode->getParametersStr();
1192 default:
1193 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1194 }
1195}
1196
1197
1198void
1199GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1200 if (value == getAttribute(key)) {
1201 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1202 }
1203 switch (key) {
1204 case SUMO_ATTR_ID:
1205 case SUMO_ATTR_POSITION:
1207 case SUMO_ATTR_SHAPE:
1208 case SUMO_ATTR_RADIUS:
1210 case SUMO_ATTR_FRINGE:
1211 case SUMO_ATTR_NAME:
1212 case GNE_ATTR_SELECTED:
1214 undoList->add(new GNEChange_Attribute(this, key, value), true);
1215 break;
1217 // change Keep Clear attribute in all connections
1218 undoList->begin(GUIIcon::JUNCTION, "change keepClear for whole junction");
1219 for (const auto& i : myGNEIncomingEdges) {
1220 for (const auto& j : i->getGNEConnections()) {
1221 undoList->add(new GNEChange_Attribute(j, key, value), true);
1222 }
1223 }
1224 undoList->end();
1225 break;
1226 case SUMO_ATTR_TYPE: {
1227 // set junction type
1228 setJunctionType(value, undoList);
1229 break;
1230 }
1231 case SUMO_ATTR_TLTYPE: {
1232 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " tl-type");
1233 // make a copy because we will modify the original
1234 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1235 for (const auto& TLS : copyOfTls) {
1236 NBLoadedSUMOTLDef* oldLoaded = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
1237 if (oldLoaded != nullptr) {
1238 NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(*oldLoaded, *oldLoaded->getLogic());
1239 newDef->guessMinMaxDuration();
1240 std::vector<NBNode*> nodes = TLS->getNodes();
1241 for (const auto& node : nodes) {
1242 GNEJunction* junction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1243 undoList->add(new GNEChange_TLS(junction, TLS, false), true);
1244 undoList->add(new GNEChange_TLS(junction, newDef, true), true);
1245 }
1246 }
1247 }
1248 undoList->add(new GNEChange_Attribute(this, key, value), true);
1249 undoList->end();
1250 break;
1251 }
1252 case SUMO_ATTR_TLLAYOUT: {
1253 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " tlLayout");
1254 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1255 for (const auto& oldTLS : copyOfTls) {
1256 std::vector<NBNode*> copyOfNodes = oldTLS->getNodes();
1257 NBOwnTLDef* newTLS = new NBOwnTLDef(oldTLS->getID(), oldTLS->getOffset(), oldTLS->getType());
1259 newTLS->setProgramID(oldTLS->getProgramID());
1260 for (const auto& node : copyOfNodes) {
1261 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1262 undoList->add(new GNEChange_TLS(oldJunction, oldTLS, false), true);
1263 }
1264 for (const auto& node : copyOfNodes) {
1265 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1266 undoList->add(new GNEChange_TLS(oldJunction, newTLS, true), true);
1267 }
1268 }
1269 undoList->end();
1270 break;
1271 }
1272 case SUMO_ATTR_TLID: {
1273 undoList->begin(GUIIcon::JUNCTION, "change " + toString(SUMO_TAG_TRAFFIC_LIGHT) + " id");
1274 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1275 assert(copyOfTls.size() > 0);
1276 NBTrafficLightDefinition* currentTLS = *copyOfTls.begin();
1277 NBTrafficLightDefinition* currentTLSCopy = nullptr;
1278 const bool currentIsSingle = currentTLS->getNodes().size() == 1;
1279 const bool currentIsLoaded = dynamic_cast<NBLoadedSUMOTLDef*>(currentTLS) != nullptr;
1280 if (currentIsLoaded) {
1281 currentTLSCopy = new NBLoadedSUMOTLDef(*currentTLS,
1282 *dynamic_cast<NBLoadedSUMOTLDef*>(currentTLS)->getLogic());
1283 }
1284 // remove from previous tls
1285 for (const auto& TLS : copyOfTls) {
1286 undoList->add(new GNEChange_TLS(this, TLS, false), true);
1287 }
1289 // programs to which the current node shall be added
1290 const std::map<std::string, NBTrafficLightDefinition*> programs = tlCont.getPrograms(value);
1291 if (programs.size() > 0) {
1292 for (const auto& TLSProgram : programs) {
1293 NBTrafficLightDefinition* oldTLS = TLSProgram.second;
1294 if (dynamic_cast<NBOwnTLDef*>(oldTLS) != nullptr) {
1295 undoList->add(new GNEChange_TLS(this, oldTLS, true), true);
1296 } else {
1297 // delete and re-create the definition because the loaded phases are now invalid
1298 if (dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS) != nullptr &&
1299 dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS)->usingSignalGroups()) {
1300 // keep the old program and add all-red state for the added links
1301 NBLoadedSUMOTLDef* newTLSJoined = new NBLoadedSUMOTLDef(*oldTLS, *dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS)->getLogic());
1302 newTLSJoined->joinLogic(currentTLSCopy);
1303 undoList->add(new GNEChange_TLS(this, newTLSJoined, true, true), true);
1304 } else {
1305 undoList->add(new GNEChange_TLS(this, nullptr, true, false, value), true);
1306 }
1308 // switch from old to new definition
1309 std::vector<NBNode*> copyOfNodes = oldTLS->getNodes();
1310 for (const auto& node : copyOfNodes) {
1311 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1312 undoList->add(new GNEChange_TLS(oldJunction, oldTLS, false), true);
1313 undoList->add(new GNEChange_TLS(oldJunction, newTLS, true), true);
1314 }
1315 }
1316 }
1317 } else {
1318 if (currentIsSingle && currentIsLoaded) {
1319 // rename the traffic light but keep everything else
1320 NBTrafficLightLogic* renamedLogic = dynamic_cast<NBLoadedSUMOTLDef*>(currentTLSCopy)->getLogic();
1321 renamedLogic->setID(value);
1322 NBLoadedSUMOTLDef* renamedTLS = new NBLoadedSUMOTLDef(*currentTLSCopy, *renamedLogic);
1323 renamedTLS->setID(value);
1324 undoList->add(new GNEChange_TLS(this, renamedTLS, true, true), true);
1325 } else {
1326 // create new traffic light
1327 undoList->add(new GNEChange_TLS(this, nullptr, true, false, value), true);
1328 }
1329 }
1330 delete currentTLSCopy;
1331 undoList->end();
1332 break;
1333 }
1334 default:
1335 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1336 }
1337}
1338
1339
1340bool
1341GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
1342 switch (key) {
1343 case SUMO_ATTR_ID:
1344 return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveJunction(value, false) == nullptr);
1345 case SUMO_ATTR_TYPE:
1347 case SUMO_ATTR_POSITION:
1348 return canParse<Position>(value);
1349 case SUMO_ATTR_SHAPE:
1350 // empty shapes are allowed
1351 return canParse<PositionVector>(value);
1352 case SUMO_ATTR_RADIUS:
1353 if (value.empty() || (value == "default")) {
1354 return true;
1355 } else {
1356 return canParse<double>(value) && ((parse<double>(value) >= 0) || (parse<double>(value) == -1));
1357 }
1358 case SUMO_ATTR_TLTYPE:
1360 case SUMO_ATTR_TLLAYOUT:
1362 case SUMO_ATTR_TLID:
1363 return myNBNode->isTLControlled() && (value != "");
1365 return canParse<bool>(value);
1368 case SUMO_ATTR_FRINGE:
1370 case SUMO_ATTR_NAME:
1371 return true;
1372 case GNE_ATTR_SELECTED:
1373 return canParse<bool>(value);
1376 default:
1377 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1378 }
1379}
1380
1381
1382bool
1384 switch (key) {
1385 case SUMO_ATTR_TLTYPE:
1386 case SUMO_ATTR_TLLAYOUT:
1387 case SUMO_ATTR_TLID:
1388 return myNBNode->isTLControlled();
1389 case SUMO_ATTR_KEEP_CLEAR: {
1390 // check if at least there is an incoming connection
1391 for (const auto& incomingEdge : myGNEIncomingEdges) {
1392 if (incomingEdge->getGNEConnections().size() > 0) {
1393 return true;
1394 }
1395 }
1396 return false;
1397 }
1398 default:
1399 return true;
1400 }
1401}
1402
1403
1404bool
1406 switch (key) {
1407 case SUMO_ATTR_SHAPE:
1408 return !myNBNode->hasCustomShape();
1409 default:
1410 return false;
1411 }
1412}
1413
1414
1415const Parameterised::Map&
1417 return myNBNode->getParametersMap();
1418}
1419
1420
1421void
1423 myAmResponsible = newVal;
1424}
1425
1426// ===========================================================================
1427// private
1428// ===========================================================================
1429
1430void
1432 // draw TLS icon if isn't being drawn for selecting
1436 const Position pos = myNBNode->getPosition();
1437 glTranslated(pos.x(), pos.y(), 2.2);
1438 glColor3d(1, 1, 1);
1439 const double halfWidth = 32 / s.scale;
1440 const double halfHeight = 64 / s.scale;
1441 GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(GUITexture::TLS), -halfWidth, -halfHeight, halfWidth, halfHeight);
1443 }
1444}
1445
1446
1447void
1449 // draw crossings
1450 for (const auto& crossing : myGNECrossings) {
1451 crossing->drawGL(s);
1452 }
1453 // draw walkingAreas
1454 for (const auto& walkingArea : myGNEWalkingAreas) {
1455 walkingArea->drawGL(s);
1456 }
1457 // draw connections and route elements connections (Only for incoming edges)
1458 for (const auto& incomingEdge : myGNEIncomingEdges) {
1459 for (const auto& connection : incomingEdge->getGNEConnections()) {
1460 connection->drawGL(s);
1461 }
1462 }
1463 // draw child demand elements
1464 for (const auto& demandElement : getChildDemandElements()) {
1465 if (!demandElement->getTagProperty().isPlacedInRTree()) {
1466 demandElement->drawGL(s);
1467 }
1468 }
1469}
1470
1471
1472void
1473GNEJunction::drawDottedContours(const GUIVisualizationSettings& s, const bool drawShape, const bool drawBubble, const double junctionExaggeration, const double bubbleRadius) const {
1474 // check if inspected dotted contour has to be drawn
1476 if (drawBubble) {
1478 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1479 }
1480 if (drawShape) {
1482 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1483 }
1484 }
1485 // check if front dotted contour has to be drawn
1486 if ((myNet->getViewNet()->getFrontAttributeCarrier() == this)) {
1487 if (drawBubble) {
1489 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1490 }
1491 if (drawShape) {
1493 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1494 }
1495 }
1496 // check if TLS dotted contour has to be drawn
1500 if (drawBubble) {
1502 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1503 }
1504 if (drawShape) {
1506 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1507 }
1508 }
1509 // check if mouse is over junction
1510 if (drawBubble) {
1511 mouseWithinGeometry(myNBNode->getPosition(), bubbleRadius);
1512 } else {
1514 }
1515 // draw dotted contours regarding create edge mode
1517 if (drawBubble) {
1519 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1520 }
1521 if (drawShape) {
1523 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1524 }
1527 // get dotted contour type
1529 // draw bubble
1530 if (drawBubble) {
1531 // mark this node
1532 gPostDrawing.markedNode = this;
1533 // draw dotted contour
1535 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1536 } else if (drawShape) {
1537 // mark this node
1538 gPostDrawing.markedNode = this;
1539 // draw dotted contour
1541 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1542 }
1543 }
1544 // draw dotted contours regarding inspect vehicles over junctions
1545 const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers();
1546 if ((inspectedACs.size() == 1) &&
1547 ((inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_TRIP_JUNCTIONS) ||
1548 (inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_FLOW_JUNCTIONS))) {
1549 // get vehicle
1550 const auto vehicle = myNet->getAttributeCarriers()->retrieveDemandElement(inspectedACs.front());
1551 // check parent junctions
1552 if (vehicle->getParentJunctions().front() == this) {
1553 if (drawBubble) {
1555 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1556 }
1557 if (drawShape) {
1559 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1560 }
1561 } else if (vehicle->getParentJunctions().back() == this) {
1562 if (drawBubble) {
1564 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1565 }
1566 if (drawShape) {
1568 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1569 }
1570 }
1571 }
1572 // delete contour
1573 if (myNet->getViewNet()->drawDeleteContour(this, this)) {
1574 if (drawBubble) {
1576 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1577 }
1578 if (drawShape) {
1580 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1581 }
1582 }
1583 // select contour
1584 if (myNet->getViewNet()->drawSelectContour(this, this)) {
1585 if (drawBubble) {
1587 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1588 }
1589 if (drawShape) {
1591 (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1592 }
1593 }
1594}
1595
1596
1597void
1598GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
1599 switch (key) {
1600 case SUMO_ATTR_KEEP_CLEAR: {
1601 throw InvalidArgument(toString(key) + " cannot be edited");
1602 }
1603 case SUMO_ATTR_ID: {
1605 break;
1606 }
1607 case SUMO_ATTR_TYPE: {
1612 }
1614 break;
1615 }
1616 case SUMO_ATTR_POSITION: {
1617 // set new position in NBNode updating edge boundaries
1618 moveJunctionGeometry(parse<Position>(value), true);
1619 // mark this connections and all of the junction's Neighbours as deprecated
1621 // update centering boundary and grid
1623 break;
1624 }
1626 if (myLogicStatus == FEATURE_GUESSED && value != FEATURE_GUESSED) {
1627 // clear guessed connections. previous connections will be restored
1629 // Clear GNEConnections of incoming edges
1630 for (const auto& i : myGNEIncomingEdges) {
1631 i->clearGNEConnections();
1632 }
1633 }
1634 myLogicStatus = value;
1635 break;
1636 case SUMO_ATTR_SHAPE: {
1637 // set new shape (without updating grid)
1638 myNBNode->setCustomShape(parse<PositionVector>(value));
1639 // mark this connections and all of the junction's Neighbours as deprecated
1641 // update centering boundary and grid
1643 break;
1644 }
1645 case SUMO_ATTR_RADIUS: {
1646 if (value.empty() || (value == "default")) {
1647 myNBNode->setRadius(-1);
1648 } else {
1649 myNBNode->setRadius(parse<double>(value));
1650 }
1651 break;
1652 }
1653 case SUMO_ATTR_TLTYPE: {
1654 // we need to make a copy of controlling TLS (because original will be updated)
1655 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1656 for (const auto& TLS : copyOfTls) {
1658 // add special parameters values for NEMA
1659 if (TLS->getType() == TrafficLightType::NEMA) {
1660 if (!TLS->knowsParameter("barrierPhases")) {
1661 TLS->setParameter("barrierPhases", "4,8");
1662 }
1663 if (!TLS->knowsParameter("barrier2Phases")) {
1664 TLS->setParameter("barrier2Phases", "2,6");
1665 }
1666 if (!TLS->knowsParameter("ring1")) {
1667 TLS->setParameter("ring1", "0,2,0,4");
1668 }
1669 if (!TLS->knowsParameter("ring2")) {
1670 TLS->setParameter("ring2", "0,6,0,8");
1671 }
1672 }
1673 }
1674 break;
1675 }
1676 case SUMO_ATTR_TLLAYOUT:
1677 // should not be triggered (handled via GNEChange_TLS)
1678 break;
1681 break;
1682 case SUMO_ATTR_FRINGE:
1684 break;
1685 case SUMO_ATTR_NAME:
1686 myNBNode->setName(value);
1687 break;
1688 case GNE_ATTR_SELECTED:
1689 if (parse<bool>(value)) {
1691 } else {
1693 }
1694 break;
1696 myNBNode->setParametersStr(value);
1697 break;
1698 default:
1699 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1700 }
1701 // invalidate path calculator
1703}
1704
1705
1706void
1708 // set new position in NBNode without updating grid
1709 if (isShapeEdited()) {
1710 // set new shape
1712 } else if (moveResult.shapeToUpdate.size() > 0) {
1713 moveJunctionGeometry(moveResult.shapeToUpdate.front(), false);
1714 }
1716}
1717
1718
1719void
1721 // make sure that newShape isn't empty
1722 if (moveResult.shapeToUpdate.size() > 0) {
1723 // check if we're editing a shape
1724 if (isShapeEdited()) {
1725 // commit new shape
1726 undoList->begin(GUIIcon::JUNCTION, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
1728 undoList->end();
1730 undoList->begin(GUIIcon::JUNCTION, "position of " + getTagStr());
1731 undoList->changeAttribute(new GNEChange_Attribute(this, SUMO_ATTR_POSITION, toString(moveResult.shapeToUpdate.front())));
1732 undoList->end();
1733 }
1734 }
1735}
1736
1737
1738double
1739GNEJunction::getColorValue(const GUIVisualizationSettings& /* s */, int activeScheme) const {
1740 switch (activeScheme) {
1741 case 0:
1743 return 3;
1744 } else {
1745 return 0;
1746 }
1747 case 1:
1749 case 2:
1750 switch (myNBNode->getType()) {
1752 return 0;
1754 return 1;
1756 return 2;
1758 return 3;
1760 return 4;
1762 return 5;
1764 return 6;
1766 return 7;
1769 return 8;
1771 return 8; // may happen before first network computation
1773 assert(false);
1774 return 8;
1776 return 9;
1778 return 10;
1780 return 11;
1782 return 12;
1784 return 13;
1785 default:
1786 assert(false);
1787 return 0;
1788 }
1789 case 3:
1790 return myNBNode->getPosition().z();
1791 default:
1792 assert(false);
1793 return 0;
1794 }
1795}
1796
1797void
1799 for (auto edge : myGNEIncomingEdges) {
1800 if (edge->getGNEConnections().size() > 0) {
1802 return;
1803 }
1804 }
1805 // no connections. Use normal color for border edges and cul-de-sac
1806 if (myGNEIncomingEdges.size() == 0 || myGNEOutgoingEdges.size() == 0) {
1808 return;
1809 } else if (myGNEIncomingEdges.size() == 1 && myGNEOutgoingEdges.size() == 1) {
1810 NBEdge* in = myGNEIncomingEdges[0]->getNBEdge();
1811 NBEdge* out = myGNEOutgoingEdges[0]->getNBEdge();
1812 if (in->isTurningDirectionAt(out)) {
1814 return;
1815 }
1816 }
1818}
1819
1820
1821void
1822GNEJunction::moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries) {
1823 // obtain NBNode position
1824 const Position orig = myNBNode->getPosition();
1825 // reinit NBNode
1826 myNBNode->reinit(pos, myNBNode->getType());
1827 // set new position of adjacent edges
1828 for (const auto& edge : getNBNode()->getEdges()) {
1829 myNet->getAttributeCarriers()->retrieveEdge(edge->getID())->updateJunctionPosition(this, orig);
1830 }
1831 // declare three sets with all affected GNEJunctions, GNEEdges and GNEConnections
1832 std::set<GNEJunction*> affectedJunctions;
1833 std::set<GNEEdge*> affectedEdges;
1834 // Iterate over GNEEdges
1835 for (const auto& edge : getChildEdges()) {
1836 // Add source and destiny junctions
1837 affectedJunctions.insert(edge->getFromJunction());
1838 affectedJunctions.insert(edge->getToJunction());
1839 // Obtain neighbors of Junction source
1840 for (const auto& junctionSourceEdge : edge->getFromJunction()->getChildEdges()) {
1841 affectedEdges.insert(junctionSourceEdge);
1842 }
1843 // Obtain neighbors of Junction destiny
1844 for (const auto& junctionDestinyEdge : edge->getToJunction()->getChildEdges()) {
1845 affectedEdges.insert(junctionDestinyEdge);
1846 }
1847 }
1848 // reset walking areas of affected edges
1849 for (const auto& affectedJunction : affectedJunctions) {
1850 affectedJunction->clearWalkingAreas();
1851 }
1852 // Iterate over affected Edges
1853 for (const auto& affectedEdge : affectedEdges) {
1854 // update edge boundaries
1855 if (updateEdgeBoundaries) {
1856 affectedEdge->updateCenteringBoundary(true);
1857 }
1858 // Update edge geometry
1859 affectedEdge->updateGeometry();
1860 }
1861}
1862
1863
1866 // get active scheme
1867 const int scheme = s.junctionColorer.getActive();
1868 // first check if we're editing shape
1869 if (myShapeEdited) {
1871 }
1872 // set default color
1874 // set special bubble color
1875 if (bubble && (scheme == 0) && !myColorForMissingConnections) {
1876 color = s.junctionColorer.getScheme().getColor(1);
1877 }
1878 // override with special colors (unless the color scheme is based on selection)
1879 if (drawUsingSelectColor() && scheme != 1) {
1880 color = s.colorSettings.selectionColor;
1881 }
1882 // overwrite color if we're in data mode
1884 color = s.junctionColorer.getScheme().getColor(6);
1885 }
1886 // special color for source candidate junction
1887 if (mySourceCandidate) {
1889 }
1890 // special color for target candidate junction
1891 if (myTargetCandidate) {
1893 }
1894 // special color for special candidate junction
1895 if (mySpecialCandidate) {
1897 }
1898 // special color for possible candidate junction
1899 if (myPossibleCandidate) {
1901 }
1902 // special color for conflicted candidate junction
1905 }
1906 // return color
1907 return color;
1908}
1909
1910
1911void
1914 tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
1915 tlDef->addNode(myNBNode);
1916}
1917
1918
1919void
1922 if (tlDef->getNodes().size() == 1) {
1923 tlCont.extract(tlDef);
1924 }
1926}
1927
1928
1929/****************************************************************************/
@ NETWORK_MOVE
mode for moving network elements
@ NETWORK_CREATE_EDGE
mode for creating new edges
@ NETWORK_TLS
mode for editing tls
@ NETWORK_CONNECT
mode for connecting lanes
@ MID_GNE_JUNCTION_ADDTLS
Add TLS into junction.
Definition: GUIAppEnum.h:1191
@ MID_GNE_JUNCTION_RESET_EDGE_ENDPOINTS
reset edge endpoints
Definition: GUIAppEnum.h:1185
@ MID_GNE_JUNCTION_CLEAR_CONNECTIONS
clear junction's connections
Definition: GUIAppEnum.h:1171
@ MID_GNE_JUNCTION_SELECT_ROUNDABOUT
select all roundabout nodes and edges of the current roundabout
Definition: GUIAppEnum.h:1187
@ MID_GNE_JUNCTION_RESET_SHAPE
reset junction shape
Definition: GUIAppEnum.h:1183
@ MID_GNE_JUNCTION_RESET_CONNECTIONS
reset junction's connections
Definition: GUIAppEnum.h:1173
@ MID_GNE_JUNCTION_SPLIT
turn junction into multiple junctions
Definition: GUIAppEnum.h:1177
@ MID_GNE_JUNCTION_REPLACE
turn junction into geometry node
Definition: GUIAppEnum.h:1175
@ MID_GNE_JUNCTION_CONVERT_ROUNDABOUT
convert junction to roundabout
Definition: GUIAppEnum.h:1189
@ MID_GNE_JUNCTION_SPLIT_RECONNECT
turn junction into multiple junctions and reconnect them heuristically
Definition: GUIAppEnum.h:1179
@ MID_GNE_JUNCTION_EDIT_SHAPE
edit junction shape
Definition: GUIAppEnum.h:1181
@ MID_GNE_JUNCTION_ADDJOINTLS
Add join TLS into junctions.
Definition: GUIAppEnum.h:1193
@ GLO_MAX
empty max
@ GLO_JUNCTION
a junction
GUIPostDrawing gPostDrawing
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
#define TL(string)
Definition: MsgHandler.h:282
#define WRITE_GLDEBUG(msg)
Definition: MsgHandler.h:277
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:50
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:42
@ GNE_TAG_TRIP_JUNCTIONS
a trip between junctions (used in NETEDIT)
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions (used in NETEDIT)
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_TRAFFIC_LIGHT
a traffic light
@ SUMO_TAG_EDGE
begin/end of the description of an edge
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_RADIUS
The turning radius at an intersection in m.
@ SUMO_ATTR_TLLAYOUT
node: the layout of the traffic light program
@ GNE_ATTR_SELECTED
element is selected
@ SUMO_ATTR_EDGES
the edges of a route
@ GNE_ATTR_PARAMETERS
parameters "key1=value1|key2=value2|...|keyN=valueN"
@ SUMO_ATTR_FRINGE
Fringe type of node.
@ GNE_ATTR_MODIFICATION_STATUS
whether a feature has been loaded,guessed,modified or approved
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_TLTYPE
node: the type of traffic light
@ SUMO_ATTR_NAME
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_ID
@ SUMO_ATTR_RIGHT_OF_WAY
How to compute right of way.
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
@ SUMO_ATTR_POSITION
T MAX2(T a, T b)
Definition: StdDefs.h:77
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:282
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
Definition: GLHelper.cpp:203
static void drawBoundary(const Boundary &b)
Draw a boundary (used for debugging)
Definition: GLHelper.cpp:894
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
static void pushName(unsigned int name)
push Name
Definition: GLHelper.cpp:139
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:277
static void popName()
pop Name
Definition: GLHelper.cpp:148
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:685
static void drawTextSettings(const GUIVisualizationTextSettings &settings, const std::string &text, const Position &pos, const double scale, const double angle=0, const double layer=2048, const int align=0)
Definition: GLHelper.cpp:716
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
friend class GNEChange_Attribute
declare friend class
static const std::string True
true value in string format (used for comparing boolean values in getAttribute(......
const std::string & getTagStr() const
get tag assigned to this object in string format
static const std::string FEATURE_GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
GNENet * myNet
pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
static const std::string FEATURE_MODIFIED
feature has been manually modified (implies approval)
static const std::string False
true value in string format(used for comparing boolean values in getAttribute(...))
bool myPossibleCandidate
flag to mark this element as possible candidate
bool mySpecialCandidate
flag to mark this element as special 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
const GNEJunction * getJunctionSource() const
get junction source for new edge
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
Definition: GNECrossing.h:42
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
Definition: GNECrossing.cpp:86
struct for saving subordinated elements (Junction->Edge->Lane->(Additional | DemandElement)
ProtectElements * getProtectElements() const
get protect elements modul
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:53
NBEdge * getNBEdge() const
returns the internal NBEdge
Definition: GNEEdge.cpp:481
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition: GNEEdge.cpp:839
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
Definition: GNEEdge.cpp:328
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEEdge * > & getChildEdges() const
get child edges
void removeTLSConnections(std::vector< NBConnection > &connections, GNEUndoList *undoList)
remove the given connections from all traffic light definitions of this junction
void drawDottedContours(const GUIVisualizationSettings &s, const bool drawShape, const bool drawBubble, const double junctionExaggeration, const double bubbleRadius) const
draw dotted contours
void updateGLObject()
update GLObject (geometry, ID, etc.)
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
void rebuildGNEWalkingAreas()
rebuilds WalkingAreas objects for this junction
void updateGeometryAfterNetbuild(bool rebuildNBNodeCrossings=false)
update pre-computed geometry information without modifying netbuild structures
bool myAmResponsible
whether we are responsible for deleting myNBNode
Definition: GNEJunction.h:290
void removeGeometryPoint(const Position clickedPosition, GNEUndoList *undoList)
remove geometry point in the clicked position
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
friend class GNEChange_TLS
Declare friend class.
Definition: GNEJunction.h:52
TesselatedPolygon myTesselation
An object that stores the shape and its tesselation.
Definition: GNEJunction.h:302
const std::vector< GNEWalkingArea * > & getGNEWalkingAreas() const
Returns GNEWalkingAreas.
std::string getAttribute(SumoXMLAttr key) const
void setResponsible(bool newVal)
set responsibility for deleting internal structures
void deleteGLObject()
delete element
bool myColorForMissingConnections
whether this junction probably should have some connections but doesn't
Definition: GNEJunction.h:299
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
Definition: GNEJunction.cpp:57
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void moveJunctionGeometry(const Position &pos, const bool updateEdgeBoundaries)
reposition the node at pos without updating GRID and informs the edges
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void invalidateShape()
void updateGeometry()
update pre-computed geometry information (including crossings)
bool isLogicValid()
whether this junction has a valid logic
void drawTLSIcon(const GUIVisualizationSettings &s) const
draw TLS icon
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the (child) outgoings GNEEdges vinculated with this junction
Definition: GNEJunction.h:271
double getColorValue(const GUIVisualizationSettings &s, int activeScheme) const
determines color value
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionChildren(const GUIVisualizationSettings &s) const
draw junction childs
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
void replaceIncomingConnections(GNEEdge *which, GNEEdge *by, GNEUndoList *undoList)
replace one edge by another in all tls connections
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
double getMaxDrawingSize() const
get the maximum size (in either x-, or y-dimension) for determining whether to draw or not
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
Definition: GNEJunction.h:274
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void clearWalkingAreas()
clear walking areas
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
GNEWalkingArea * retrieveGNEWalkingArea(const std::string &NBNodeWalkingAreaID, bool createIfNoExist=true)
get GNEWalkingArea if exist, and if not create it if create is enabled
GNEMoveOperation * getMoveOperation()
get move operation
GNECrossing * retrieveGNECrossing(NBNode::Crossing *NBNodeCrossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the (child) incomings GNEEdges vinculated with this junction
Definition: GNEJunction.h:268
const PositionVector & getJunctionShape() const
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void markConnectionsDeprecated(bool includingNeighbours)
mark connections as deprecated
const Parameterised::Map & getACParametersMap() const
get parameters map
void mirrorXLeftHand()
temporarily mirror coordinates in lefthand network to compute correct crossing geometries
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double myMaxDrawingSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not.
Definition: GNEJunction.h:280
Position getPositionInView() const
Returns position of hierarchical element in view.
bool isAttributeComputed(SumoXMLAttr key) const
bool myAmTLSSelected
whether this junction is selected in tls-mode
Definition: GNEJunction.h:296
void removeConnectionsFrom(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections from the given edge
bool isValid(SumoXMLAttr key, const std::string &value)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
RGBColor setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
bool myHasValidLogic
whether this junctions logic is valid
Definition: GNEJunction.h:293
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
Definition: GNEJunction.h:287
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
NBNode * getNBNode() const
Return net build node.
NBNode * myNBNode
A reference to the represented junction.
Definition: GNEJunction.h:265
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void checkMissingConnections()
compute whether this junction probably should have some connections but doesn't
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
void setJunctionType(const std::string &value, GNEUndoList *undoList)
set junction Type (using undo/redo)
double myExaggeration
exaggeration used in tesselation
Definition: GNEJunction.h:305
~GNEJunction()
Destructor.
Definition: GNEJunction.cpp:75
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
std::vector< GNEWalkingArea * > myGNEWalkingAreas
the built walkingArea objects
Definition: GNEJunction.h:277
void removeConnectionsTo(GNEEdge *edge, GNEUndoList *undoList, bool updateTLS, int lane=-1)
remove all connections to the given edge
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
Definition: GNEJunction.h:284
void buildTLSOperations(GUISUMOAbstractView &parent, GUIGLObjectPopupMenu *ret, const int numSelectedJunctions)
build TLS operations contextual menu
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
bool isAttributeEnabled(SumoXMLAttr key) const
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
GNEMoveOperation * calculateMoveShapeOperation(const PositionVector originalShape, const Position mousePosition, const double snapRadius, const bool onlyContour)
calculate move shape operation
move operation
move result
PositionVector shapeToUpdate
shape to update (edited in moveElement)
void insertWalkingArea(GNEWalkingArea *walkingArea)
insert walkingArea
GNEJunction * retrieveJunction(const std::string &id, bool hardFail=true) const
get junction by id
void updateJunctionID(GNEJunction *junction, const std::string &newID)
update junction ID in container
void insertCrossing(GNECrossing *crossing)
insert crossing
void deleteWalkingArea(GNEWalkingArea *walkingArea)
delete walkingArea
int getNumberOfSelectedJunctions() const
get number of selected junctions
const std::set< GNECrossing * > & getCrossings() const
get crossings
GNEEdge * retrieveEdge(const std::string &id, bool hardFail=true) const
get edge by id
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
void deleteCrossing(GNECrossing *crossing)
delete crossing
const std::set< GNEWalkingArea * > & getWalkingAreas() const
get walkingAreas
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
Definition: GNENet.cpp:611
NBNetBuilder * getNetBuilder() const
get net builder
Definition: GNENet.cpp:1394
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1245
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition: GNENet.cpp:1257
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition: GNENet.cpp:1993
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
GNEPathManager * getPathManager()
get path manager
Definition: GNENet.cpp:138
void requireRecompute()
inform the net about the need for recomputation
Definition: GNENet.cpp:1376
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition: GNENet.cpp:2005
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition: GNENet.cpp:375
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1987
bool myShapeEdited
flag to check if element shape is being edited
bool isShapeEdited() const
check if shape is being edited
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Boundary myBoundary
object boundary
void invalidatePathCalculator()
invalidate pathCalculator
PathCalculator * getPathCalculator()
obtain instance of PathCalculator
void drawJunctionPathElements(const GUIVisualizationSettings &s, const GNEJunction *junction)
draw junction path elements
void incRef(const std::string &debugMsg="")
Increase reference.
bool isJunctionSelected(const GNEJunction *junction) const
check if given junction is selected (used fo joining)
bool isJoiningJunctions() const
is joining junctions
GNETLSEditorFrame::TLSJunction * getTLSJunction() const
get module for TLS Junction
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
bool hasCommandGroup() const
Check if undoList has command group.
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
void changeAttribute(GNEChange_Attribute *change)
special method for change attributes, avoid empty changes, always execute
GNEJunction * getJunctionFront() const
get front junction or a pointer to nullptr
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
Definition: GNEViewNet.cpp:632
bool drawSelectContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw select contour
bool drawDeleteContour(const GUIGlObject *GLObject, const GNEAttributeCarrier *AC) const
check if draw delete contour
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
Definition: GNEViewNet.cpp:802
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
Definition: GNEViewNet.cpp:644
void drawTranslateFrontAttributeCarrier(const GNEAttributeCarrier *AC, double typeOrLayer, const double extraOffset=0)
draw front attributeCarrier
GNEViewParent * getViewParent() const
get the net object
GNEUndoList * getUndoList() const
get the undoList object
void removeFromAttributeCarrierInspected(const GNEAttributeCarrier *AC)
remove given AC of list of inspected Attribute Carriers
const std::vector< GNEAttributeCarrier * > & getInspectedAttributeCarriers() const
get inspected attribute carriers
bool mergeJunctions(GNEJunction *movedJunction, GNEJunction *targetJunction)
try to merge moved junction with another junction in that spot return true if merging did take place
Definition: GNEViewNet.cpp:808
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
Definition: GNEViewNet.cpp:474
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::ObjectsUnderCursor & getObjectsUnderCursor() const
get objects under cursor
Definition: GNEViewNet.cpp:462
GNEDeleteFrame * getDeleteFrame() const
get frame for delete elements
GNETLSEditorFrame * getTLSEditorFrame() const
get frame for NETWORK_TLS
GNECreateEdgeFrame * getCreateEdgeFrame() const
get frame for NETWORK_CREATEEDGE
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
static FXMenuCommand * buildFXMenuCommand(FXComposite *p, const std::string &text, FXIcon *icon, FXObject *tgt, FXSelector sel)
build menu command
Definition: GUIDesigns.cpp:42
static void drawDottedContourClosedShape(const GUIVisualizationSettings &s, const DottedContourType type, const PositionVector &shape, const double exaggeration, const double customWidth=1)
draw dotted contour for the given closed shape (used by Juctions, shapes and TAZs)
static void drawDottedContourCircle(const GUIVisualizationSettings &s, const DottedContourType type, const Position &pos, const double radius, const double exaggeration)
draw dotted contour for the given Position and radius (used by Juctions and POIs)
The popup menu of a globject.
void insertMenuPaneChild(FXMenuPane *child)
Insert a sub-menu pane in this GUIGLObjectPopupMenu.
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
void updateGeometry(const PositionVector &shape)
update entire geometry
Definition: GUIGeometry.cpp:58
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
Definition: GUIGlObject.h:141
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
void 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.
Definition: GUIGlObject.h:154
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
GUIGlID getGlID() const
Returns the numerical id of the object.
Definition: GUIGlObject.h:102
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
const GUIGlObject * markedNode
marked Node (used in create edge mode)
const T getColor(const double value) const
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Stores the information about how to visualize structures.
GUIVisualizationTextSettings junctionName
GUIVisualizationSizeSettings junctionSize
bool drawBoundaries
enable or disable draw boundaries
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
bool drawJunctionShape
whether the shape of the junction should be drawn
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
GUIVisualizationCandidateColorSettings candidateColorSettings
candidate color settings
GUIVisualizationTextSettings junctionID
bool drawMovingGeometryPoint(const double exaggeration, const double radius) const
check if moving geometry point can be draw
GUIVisualizationColorSettings colorSettings
color settings
double scale
information about a lane's width (temporary, used for a single view)
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
GUIColorer junctionColorer
The junction colorer.
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
double angle
The current view rotation angle.
NBEdge * getFrom() const
returns the from-edge (start of the connection)
int getFromLane() const
returns the from-lane
int getTLIndex2() const
Definition: NBConnection.h:94
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled
Definition: NBConnection.h:91
static const int InvalidTlIndex
Definition: NBConnection.h:123
int getToLane() const
returns the to-lane
NBEdge * getTo() const
returns the to-edge (end of the connection)
static const NBConnection InvalidConnection
Definition: NBConnection.h:124
void removeRoundabout(const NBNode *node)
remove roundabout that contains the given node
The representation of a single edge during network building.
Definition: NBEdge.h:92
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:1043
const std::string & getID() const
Definition: NBEdge.h:1526
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Definition: NBEdge.cpp:3430
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition: NBEdge.cpp:3767
A loaded (complete) traffic light logic.
void setID(const std::string &newID)
resets the id
NBTrafficLightLogic * getLogic()
Returns the internal logic.
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
void joinLogic(NBTrafficLightDefinition *def)
join nodes and states from the given logic (append red state)
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, int linkIndex2, bool reconstruct=true)
Adds a connection and immediately informs the edges.
void guessMinMaxDuration()
heuristically add minDur and maxDur when switching from tlType fixed to actuated
void replaceRemoved(NBEdge *removed, int removedLane, NBEdge *by, int byLane, bool incoming)
Replaces a removed edge/lane.
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
Definition: NBNetBuilder.h:183
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:139
A definition of a pedestrian crossing.
Definition: NBNode.h:129
EdgeVector edges
The edges being crossed.
Definition: NBNode.h:136
Represents a single node (junction) during network building.
Definition: NBNode.h:66
RightOfWay getRightOfWay() const
Returns hint on how to compute right of way.
Definition: NBNode.h:290
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition: NBNode.cpp:3634
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node)
Definition: NBNode.h:326
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
Definition: NBNode.cpp:307
static const double UNSPECIFIED_RADIUS
unspecified lane width
Definition: NBNode.h:210
FringeType getFringeType() const
Returns fringe type.
Definition: NBNode.h:295
void buildCrossingsAndWalkingAreas()
build crossings, and walkingareas. Also removes invalid loaded crossings if wished
Definition: NBNode.cpp:2729
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:275
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
Definition: NBNode.h:545
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:2453
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition: NBNode.cpp:3689
void invalidateIncomingConnections(bool reallowSetting=false)
invalidate incoming connections
Definition: NBNode.cpp:1880
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
Definition: NBNode.h:258
void mirrorX()
mirror coordinates along the x-axis
Definition: NBNode.cpp:346
std::vector< std::pair< Position, std::string > > getEndPoints() const
return list of unique endpoint coordinates of all edges at this node
Definition: NBNode.cpp:3792
const std::vector< std::unique_ptr< Crossing > > & getCrossingsIncludingInvalid() const
Definition: NBNode.h:714
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition: NBNode.h:263
bool hasCustomShape() const
return whether the shape was set by the user
Definition: NBNode.h:560
const std::string & getName() const
Returns intersection name.
Definition: NBNode.h:300
void setRadius(double radius)
set the turning radius
Definition: NBNode.h:535
void setName(const std::string &name)
set intersection name
Definition: NBNode.h:555
const Position & getPosition() const
Definition: NBNode.h:250
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition: NBNode.cpp:375
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Definition: NBNode.h:268
const PositionVector & getShape() const
retrieve the junction shape
Definition: NBNode.cpp:2447
double getRadius() const
Returns the turning radius of this node.
Definition: NBNode.h:280
bool isRoundabout() const
return whether this node is part of a roundabout
Definition: NBNode.cpp:3514
bool checkIsRemovableReporting(std::string &reason) const
check if node is removable and return reason if not
Definition: NBNode.cpp:2334
const std::vector< WalkingArea > & getWalkingAreas() const
return this junctions pedestrian walking areas
Definition: NBNode.h:719
PositionVector myPoly
the (outer) shape of the junction
Definition: NBNode.h:896
void setFringeType(FringeType fringeType)
set method for computing right-of-way
Definition: NBNode.h:550
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:321
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:44
void setLayout(TrafficLightLayout layout)
sets the layout for the generated signal plan
Definition: NBOwnTLDef.h:134
The base class for traffic light logic definitions.
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
const std::string & getProgramID() const
Returns the ProgramID.
TrafficLightType getType() const
get the algorithm type (static etc..)
virtual void setProgramID(const std::string &programID)
Sets the programID.
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
SUMOTime getOffset()
Returns the offset.
A container for traffic light definitions and built programs.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
A SUMO-compliant built logic for a traffic light.
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any)
virtual void setID(const std::string &newID)
resets the id
Definition: Named.h:82
const std::string & getID() const
Returns the id.
Definition: Named.h:74
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
static bool areParametersValid(const std::string &value, bool report=false, const std::string kvsep="=", const std::string sep="|")
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
void setParametersStr(const std::string &paramsString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
std::string getParametersStr(const std::string kvsep="=", const std::string sep="|") const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:257
double x() const
Returns the x-position.
Definition: Position.h:55
double z() const
Returns the z-position.
Definition: Position.h:65
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
void closePolygon()
ensures that the last position equals the first
int indexOfClosest(const Position &p, bool twoD=false) const
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
double area() const
Returns the area (0 for non-closed)
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition: RGBColor.cpp:92
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200
static const RGBColor MAGENTA
Definition: RGBColor.h:190
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: SUMOPolygon.cpp:52
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
Definition: SUMOPolygon.cpp:82
static StringBijection< SumoXMLNodeType > NodeTypes
node types
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static StringBijection< TrafficLightLayout > TrafficLightLayouts
traffic light layouts
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
static StringBijection< RightOfWay > RightOfWayValues
righ of way algorithms
static StringBijection< FringeType > FringeTypeValues
fringe types
const std::string & getString(const T key) const
bool hasString(const std::string &str) const
T get(const std::string &str) const
std::vector< GLPrimitive > myTesselation
id of the display list for the cached tesselation
Definition: GUIPolygon.h:74
PositionVector & getShapeRef()
Definition: GUIPolygon.h:76
void drawTesselation(const PositionVector &shape) const
Definition: GUIPolygon.cpp:118
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4451
NetworkEditMode networkEditMode
the current Network edit mode
bool isCurrentSupermodeData() const
@check if current supermode is Data
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position viewPosition, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool editingElevation() const
check if we're editing elevation
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 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 selectionColor
basic selection color
static const RGBColor editShapeColor
color for edited shapes (Junctions, crossings and connections)
static const double junctionGeometryPointRadius
moving junction 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 scaledSize(double scale, double constFactor=0.1) const
get scale size
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:201