Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEJunction.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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
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
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 // get junction exaggeration
403 const double junctionExaggeration = getExaggeration(s);
404 // check if draw junction as shape
405 const bool junctionShape = ((myNBNode->getShape().size() > 0) && s.drawJunctionShape);
406 const bool junctionBubble = drawAsBubble(s);
407 // only continue if exaggeration is greather than 0
408 if (junctionExaggeration > 0) {
409 // get mouse position
410 const Position mousePosition = myNet->getViewNet()->getPositionInformation();
411 // push junction name
413 // push layer matrix
415 // translate to front
417 // push name
418 if (s.scale * junctionExaggeration * myMaxDrawingSize < 1.) {
419 // draw something simple so that selection still works
421 } else {
422 // draw junction as shape
423 if (junctionShape) {
424 drawJunctionAsShape(s, junctionExaggeration, mousePosition);
425 }
426 // draw junction as bubble
427 if (junctionBubble) {
428 drawJunctionAsBubble(s, junctionExaggeration, mousePosition);
429 }
430 // draw TLS
431 drawTLSIcon(s);
432 // draw elevation
435 // Translate to center of junction
436 glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
437 // draw Z value
440 }
441 }
442 // pop layer Matrix
444 // pop junction name
446 // draw lock icon
448 // draw name and ID
451 if (s.junctionName.show(this) && myNBNode->getName() != "") {
453 }
454 }
455 // draw Junction childs
457 // draw path additional elements
459 // draw dotted contours
460 if (junctionShape) {
461 drawDottedContoursShape(s, junctionExaggeration);
462 }
463 if (junctionBubble) {
464 drawDottedContoursBubble(s, junctionExaggeration);
465 }
466 }
467}
468
469
470void
472 // Check if edge can be deleted
475 }
476}
477
478
479void
483
484
485NBNode*
487 return myNBNode;
488}
489
490
491std::vector<GNEJunction*>
493 // use set to avoid duplicates junctions
494 std::set<GNEJunction*> junctions;
495 for (const auto& incomingEdge : myGNEIncomingEdges) {
496 junctions.insert(incomingEdge->getFromJunction());
497 }
498 for (const auto& outgoingEdge : myGNEOutgoingEdges) {
499 junctions.insert(outgoingEdge->getToJunction());
500 }
501 return std::vector<GNEJunction*>(junctions.begin(), junctions.end());
502}
503
504
505void
507 // Check if incoming edge was already inserted
508 std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
509 if (i != myGNEIncomingEdges.end()) {
510 throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + getTagStr() + " with ID " + getID() + "'");
511 } else {
512 // Add edge into containers
513 myGNEIncomingEdges.push_back(edge);
514 }
515}
516
517
518
519void
521 // Check if outgoing edge was already inserted
522 std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
523 if (i != myGNEOutgoingEdges.end()) {
524 throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' was already inserted into " + getTagStr() + " with ID " + getID() + "'");
525 } else {
526 // Add edge into containers
527 myGNEOutgoingEdges.push_back(edge);
528 }
529}
530
531
532void
534 // Check if incoming edge was already inserted
535 std::vector<GNEEdge*>::iterator i = std::find(myGNEIncomingEdges.begin(), myGNEIncomingEdges.end(), edge);
536 if (i == myGNEIncomingEdges.end()) {
537 throw InvalidArgument("Incoming " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + getTagStr() + " with ID " + getID() + "'");
538 } else {
539 // remove edge from containers
540 myGNEIncomingEdges.erase(i);
541 }
542}
543
544
545void
547 // Check if outgoing edge was already inserted
548 std::vector<GNEEdge*>::iterator i = std::find(myGNEOutgoingEdges.begin(), myGNEOutgoingEdges.end(), edge);
549 if (i == myGNEOutgoingEdges.end()) {
550 throw InvalidArgument("Outgoing " + toString(SUMO_TAG_EDGE) + " with ID '" + edge->getID() + "' doesn't found into " + getTagStr() + " with ID " + getID() + "'");
551 } else {
552 // remove edge from containers
553 myGNEOutgoingEdges.erase(i);
554 }
555}
556
557
558const std::vector<GNEEdge*>&
562
563
564const std::vector<GNEEdge*>&
568
569
570const std::vector<GNECrossing*>&
574
575
576const std::vector<GNEWalkingArea*>&
580
581
582std::vector<GNEConnection*>
584 std::vector<GNEConnection*> connections;
585 for (const auto& incomingEdge : myGNEIncomingEdges) {
586 for (const auto& connection : incomingEdge->getGNEConnections()) {
587 connections.push_back(connection);
588 }
589 }
590 return connections;
591}
592
593
594void
598
599
600void
604
605
606void
608 myAmTLSSelected = selected;
609}
610
611
612void
614 if (!myNBNode->hasCustomShape()) {
615 if (myNBNode->myPoly.size() > 0) {
616 // write GL Debug
617 WRITE_GLDEBUG("<-- Invalidating shape of junction '" + getID() + "' -->");
618 // clear poly
619 myNBNode->myPoly.clear();
620 // update centering boundary
622 }
624 }
625}
626
627
628void
629GNEJunction::setLogicValid(bool valid, GNEUndoList* undoList, const std::string& status) {
630 myHasValidLogic = valid;
631 if (!valid) {
632 assert(undoList != 0);
633 assert(undoList->hasCommandGroup());
636 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
637 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge((*it)->getID());
638 removeConnectionsFrom(srcEdge, undoList, false); // false, because the whole tls will be invalidated at the end
639 undoList->add(new GNEChange_Attribute(srcEdge, GNE_ATTR_MODIFICATION_STATUS, status), true);
640 }
641 undoList->add(new GNEChange_Attribute(this, GNE_ATTR_MODIFICATION_STATUS, status), true);
642 invalidateTLS(undoList);
643 } else {
644 // logic valed, then rebuild GNECrossings to adapt it to the new logic
645 // (but don't rebuild the crossings in NBNode because they are already finished)
646 rebuildGNECrossings(false);
647 }
648}
649
650
651void
652GNEJunction::removeConnectionsFrom(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane) {
653 NBEdge* srcNBE = edge->getNBEdge();
654 NBEdge* turnEdge = srcNBE->getTurnDestination();
655 // Make a copy of connections
656 std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
657 // delete in reverse so that undoing will add connections in the original order
658 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
659 if (lane >= 0 && (*con_it).fromLane != lane) {
660 continue;
661 }
662 bool hasTurn = con_it->toEdge == turnEdge;
663 undoList->add(new GNEChange_Connection(edge, *con_it, false, false), true);
664 // needs to come after GNEChange_Connection
665 // XXX bug: this code path will not be used on a redo!
666 if (hasTurn) {
668 }
669 }
670 if (updateTLS) {
671 std::vector<NBConnection> removeConnections;
672 for (NBEdge::Connection con : connections) {
673 removeConnections.push_back(NBConnection(srcNBE, con.fromLane, con.toEdge, con.toLane));
674 }
675 removeTLSConnections(removeConnections, undoList);
676 }
677}
678
679
680void
681GNEJunction::removeConnectionsTo(GNEEdge* edge, GNEUndoList* undoList, bool updateTLS, int lane) {
682 NBEdge* destNBE = edge->getNBEdge();
683 std::vector<NBConnection> removeConnections;
684 for (NBEdge* srcNBE : myNBNode->getIncomingEdges()) {
685 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge(srcNBE->getID());
686 std::vector<NBEdge::Connection> connections = srcNBE->getConnections();
687 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
688 if ((*con_it).toEdge == destNBE) {
689 if (lane >= 0 && (*con_it).toLane != lane) {
690 continue;
691 }
692 bool hasTurn = srcNBE->getTurnDestination() == destNBE;
693 undoList->add(new GNEChange_Connection(srcEdge, *con_it, false, false), true);
694 // needs to come after GNEChange_Connection
695 // XXX bug: this code path will not be used on a redo!
696 if (hasTurn) {
697 myNet->addExplicitTurnaround(srcNBE->getID());
698 }
699 removeConnections.push_back(NBConnection(srcNBE, (*con_it).fromLane, destNBE, (*con_it).toLane));
700 }
701 }
702 }
703 if (updateTLS) {
704 removeTLSConnections(removeConnections, undoList);
705 }
706}
707
708
709void
710GNEJunction::removeTLSConnections(std::vector<NBConnection>& connections, GNEUndoList* undoList) {
711 if (connections.size() > 0) {
712 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
713 for (const auto& TLS : coypOfTls) {
714 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
715 // guessed TLS (NBOwnTLDef) do not need to be updated
716 if (tlDef != nullptr) {
717 std::string newID = tlDef->getID();
718 // create replacement before deleting the original because deletion will mess up saving original nodes
719 NBLoadedSUMOTLDef* replacementDef = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
720 for (NBConnection& con : connections) {
721 replacementDef->removeConnection(con);
722 }
723 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
724 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
725 // the removed traffic light may have controlled more than one junction. These too have become invalid now
726 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
727 for (const auto& node : copyOfNodes) {
728 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
729 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
730 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
731 }
732 }
733 }
734 }
735}
736
737
738void
740 // remap connections of the edge
741 assert(which->getLanes().size() == by->getLanes().size());
742 std::vector<NBEdge::Connection> connections = which->getNBEdge()->getConnections();
743 for (NBEdge::Connection& c : connections) {
744 undoList->add(new GNEChange_Connection(which, c, false, false), true);
745 undoList->add(new GNEChange_Connection(by, c, false, true), true);
746 }
747 // also remap tls connections
748 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
749 for (const auto& TLS : coypOfTls) {
750 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
751 // guessed TLS (NBOwnTLDef) do not need to be updated
752 if (tlDef != nullptr) {
753 std::string newID = tlDef->getID();
754 // create replacement before deleting the original because deletion will mess up saving original nodes
755 NBLoadedSUMOTLDef* replacementDef = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
756 for (int i = 0; i < (int)which->getLanes().size(); ++i) {
757 replacementDef->replaceRemoved(which->getNBEdge(), i, by->getNBEdge(), i, true);
758 }
759 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
760 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
761 // the removed traffic light may have controlled more than one junction. These too have become invalid now
762 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
763 for (const auto& node : copyOfNodes) {
764 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
765 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
766 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
767 }
768 }
769 }
770}
771
772
773void
776 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
777 NBEdge* srcNBE = *it;
778 GNEEdge* srcEdge = myNet->getAttributeCarriers()->retrieveEdge(srcNBE->getID());
780 }
781}
782
783
784void
785GNEJunction::invalidateTLS(GNEUndoList* undoList, const NBConnection& deletedConnection, const NBConnection& addedConnection) {
786 assert(undoList->hasCommandGroup());
787 // NBLoadedSUMOTLDef becomes invalid, replace with NBOwnTLDef which will be dynamically recomputed
788 const std::set<NBTrafficLightDefinition*> coypOfTls = myNBNode->getControllingTLS(); // make a copy!
789 for (const auto& TLS : coypOfTls) {
790 NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
791 if (tlDef != nullptr) {
792 NBTrafficLightDefinition* replacementDef = nullptr;
793 std::string newID = tlDef->getID(); // + "_reguessed"; // changes due to reguessing will be visible in diff
794 if (deletedConnection != NBConnection::InvalidConnection) {
795 // create replacement before deleting the original because deletion will mess up saving original nodes
796 NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
797 repl->removeConnection(deletedConnection);
798 replacementDef = repl;
799 } else if (addedConnection != NBConnection::InvalidConnection) {
800 if (addedConnection.getTLIndex() == NBConnection::InvalidTlIndex) {
801 // custom tl indices of crossings might become invalid upon recomputation so we must save them
802 // however, they could remain valid so we register a change but keep them at their old value
803 for (const auto& crossing : myGNECrossings) {
804 const std::string oldValue = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX);
806 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX, oldValue), true);
807 const std::string oldValue2 = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX2);
809 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX2, oldValue2), true);
810 }
811 }
812 NBLoadedSUMOTLDef* repl = new NBLoadedSUMOTLDef(*tlDef, *tlDef->getLogic());
813 repl->addConnection(addedConnection.getFrom(), addedConnection.getTo(),
814 addedConnection.getFromLane(), addedConnection.getToLane(), addedConnection.getTLIndex(), addedConnection.getTLIndex2());
815 replacementDef = repl;
816 } else {
817 // recompute crossing indices along with everything else
818 for (const auto& crossing : myGNECrossings) {
819 const std::string oldValue = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX);
821 const std::string oldValue2 = crossing->getAttribute(SUMO_ATTR_TLLINKINDEX2);
823 }
824 replacementDef = new NBOwnTLDef(newID, tlDef->getOffset(), tlDef->getType());
825 replacementDef->setProgramID(tlDef->getProgramID());
826 }
827 undoList->add(new GNEChange_TLS(this, tlDef, false), true);
828 undoList->add(new GNEChange_TLS(this, replacementDef, true, false, newID), true);
829 // the removed traffic light may have controlled more than one junction. These too have become invalid now
830 const std::vector<NBNode*> copyOfNodes = tlDef->getNodes(); // make a copy!
831 for (const auto& node : copyOfNodes) {
832 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
833 undoList->add(new GNEChange_TLS(sharing, tlDef, false), true);
834 undoList->add(new GNEChange_TLS(sharing, replacementDef, true, false, newID), true);
835 }
836 }
837 }
838}
839
840void
842 // obtain a copy of GNECrossing of junctions
843 const auto copyOfGNECrossings = myGNECrossings;
844 // iterate over copy of GNECrossings
845 for (const auto& crossing : copyOfGNECrossings) {
846 // obtain the set of edges vinculated with the crossing (due it works as ID)
847 EdgeSet edgeSet(crossing->getCrossingEdges().begin(), crossing->getCrossingEdges().end());
848 // If this edge is part of the set of edges of crossing
849 if (edgeSet.count(edge->getNBEdge()) == 1) {
850 // delete crossing if this is their last edge
851 if ((crossing->getCrossingEdges().size() == 1) && (crossing->getCrossingEdges().front() == edge->getNBEdge())) {
852 myNet->deleteCrossing(crossing, undoList);
853 } else {
854 // remove this edge of the edge's attribute of crossing (note: This can invalidate the crossing)
855 std::vector<std::string> edges = GNEAttributeCarrier::parse<std::vector<std::string>>(crossing->getAttribute(SUMO_ATTR_EDGES));
856 edges.erase(std::find(edges.begin(), edges.end(), edge->getID()));
857 crossing->setAttribute(SUMO_ATTR_EDGES, joinToString(edges, " "), undoList);
858 }
859 }
860 }
861}
862
863
864bool
868
869
871GNEJunction::retrieveGNECrossing(NBNode::Crossing* NBNodeCrossing, bool createIfNoExist) {
872 // iterate over all crossing
873 for (const auto& crossing : myGNECrossings) {
874 // if found, return it
875 if (crossing->getCrossingEdges() == NBNodeCrossing->edges) {
876 return crossing;
877 }
878 }
879 if (createIfNoExist) {
880 // create new GNECrossing
881 GNECrossing* createdGNECrossing = new GNECrossing(this, NBNodeCrossing->edges);
882 // show extra information for tests
883 WRITE_DEBUG("Created " + createdGNECrossing->getTagStr() + " '" + createdGNECrossing->getID() + "' in retrieveGNECrossing()");
884 // update geometry after creating
885 createdGNECrossing->updateGeometry();
886 // add it in Network
887 myNet->addGLObjectIntoGrid(createdGNECrossing);
888 // add it in attributeCarriers
889 myNet->getAttributeCarriers()->insertCrossing(createdGNECrossing);
890 return createdGNECrossing;
891 } else {
892 return nullptr;
893 }
894}
895
896
898GNEJunction::retrieveGNEWalkingArea(const std::string& NBNodeWalkingAreaID, bool createIfNoExist) {
899 // iterate over all walkingArea
900 for (const auto& walkingArea : myGNEWalkingAreas) {
901 // if found, return it
902 if (walkingArea->getID() == NBNodeWalkingAreaID) {
903 return walkingArea;
904 }
905 }
906 if (createIfNoExist) {
907 // create new GNEWalkingArea
908 GNEWalkingArea* createdGNEWalkingArea = new GNEWalkingArea(this, NBNodeWalkingAreaID);
909 // show extra information for tests
910 WRITE_DEBUG("Created " + createdGNEWalkingArea->getTagStr() + " '" + createdGNEWalkingArea->getID() + "' in retrieveGNEWalkingArea()");
911 // update geometry after creating
912 createdGNEWalkingArea->updateGeometry();
913 // add it in Network
914 myNet->addGLObjectIntoGrid(createdGNEWalkingArea);
915 // add it in attributeCarriers
916 myNet->getAttributeCarriers()->insertWalkingArea(createdGNEWalkingArea);
917 return createdGNEWalkingArea;
918 } else {
919 return nullptr;
920 }
921}
922
923
924void
925GNEJunction::markConnectionsDeprecated(bool includingNeighbours) {
926 // only it's needed to mark the connections of incoming edges
927 for (const auto& i : myGNEIncomingEdges) {
928 for (const auto& j : i->getGNEConnections()) {
929 j->markConnectionGeometryDeprecated();
930 }
931 if (includingNeighbours) {
932 i->getFromJunction()->markConnectionsDeprecated(false);
933 }
934 }
935}
936
937
938void
939GNEJunction::setJunctionType(const std::string& value, GNEUndoList* undoList) {
940 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " type");
942 if (getNBNode()->isTLControlled() &&
943 // if switching changing from or to traffic_light_right_on_red we need to remove the old plan
946 ) {
947 // make a copy because we will modify the original
948 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
949 for (const auto& TLS : copyOfTls) {
950 undoList->add(new GNEChange_TLS(this, TLS, false), true);
951 }
952 }
953 if (!getNBNode()->isTLControlled()) {
954 // create new traffic light
955 undoList->add(new GNEChange_TLS(this, nullptr, true), true);
956 }
957 } else if (getNBNode()->isTLControlled()) {
958 // delete old traffic light
959 // make a copy because we will modify the original
960 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
961 for (const auto& TLS : copyOfTls) {
962 undoList->add(new GNEChange_TLS(this, TLS, false, false), true);
963 const std::vector<NBNode*> copyOfNodes = TLS->getNodes(); // make a copy!
964 for (const auto& node : copyOfNodes) {
965 GNEJunction* sharing = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
966 sharing->invalidateTLS(undoList);
967 }
968 }
969 }
970 // must be the final step, otherwise we do not know which traffic lights to remove via GNEChange_TLS
971 undoList->add(new GNEChange_Attribute(this, SUMO_ATTR_TYPE, value), true);
972 for (const auto& crossing : myGNECrossings) {
973 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX, "-1"), true);
974 undoList->add(new GNEChange_Attribute(crossing, SUMO_ATTR_TLLINKINDEX2, "-1"), true);
975 }
976 undoList->end();
977}
978
979
980double
984
985
986void
988 // delete non retrieved GNEWalkingAreas (we don't need to extract if from Tree two times)
989 for (const auto& walkingArea : myGNEWalkingAreas) {
990 walkingArea->decRef();
991 // check if walkingArea is selected
992 if (walkingArea->isAttributeCarrierSelected()) {
993 walkingArea->unselectAttributeCarrier();
994 }
995 // remove it from inspected ACS
997 // remove it from net
998 myNet->removeGLObjectFromGrid(walkingArea);
999 // remove it from attributeCarriers
1001 if (walkingArea->unreferenced()) {
1002 // show extra information for tests
1003 WRITE_DEBUG("Deleting unreferenced " + walkingArea->getTagStr() + " in rebuildGNEWalkingAreas()");
1004 delete walkingArea;
1005 }
1006 }
1007 myGNEWalkingAreas.clear();
1008}
1009
1010
1011void
1013 // first clear GNEWalkingAreas
1015 // iterate over NBNode::WalkingAreas of GNEJunction
1016 for (const auto& walkingArea : myNBNode->getWalkingAreas()) {
1017 // retrieve existent GNEWalkingArea, or create it
1018 GNEWalkingArea* retrievedGNEWalkingArea = retrieveGNEWalkingArea(walkingArea.id, true);
1019 // include reference to created GNEWalkingArea
1020 retrievedGNEWalkingArea->incRef();
1021 // update geometry of retrieved walkingArea
1022 retrievedGNEWalkingArea->updateGeometry();
1023 // update boundary
1024 retrievedGNEWalkingArea->updateCenteringBoundary(false);
1025 // add in walkingAreas
1026 myGNEWalkingAreas.push_back(retrievedGNEWalkingArea);
1027 }
1028}
1029
1030
1031std::string
1033 switch (key) {
1034 case SUMO_ATTR_ID:
1035 return getMicrosimID();
1036 case SUMO_ATTR_POSITION:
1037 return toString(myNBNode->getPosition());
1038 case SUMO_ATTR_TYPE:
1039 return toString(myNBNode->getType());
1041 return myLogicStatus;
1042 case SUMO_ATTR_SHAPE:
1043 return toString(myNBNode->getShape());
1044 case SUMO_ATTR_RADIUS:
1045 if (myNBNode->getRadius() < 0) {
1046 return "default";
1047 } else {
1048 return toString(myNBNode->getRadius());
1049 }
1050 case SUMO_ATTR_TLTYPE:
1052 // @todo this causes problems if the node were to have multiple programs of different type (plausible)
1053 return toString((*myNBNode->getControllingTLS().begin())->getType());
1054 } else {
1055 return "No TLS";
1056 }
1057 case SUMO_ATTR_TLLAYOUT:
1059 return toString((*myNBNode->getControllingTLS().begin())->getLayout());
1060 } else {
1061 return "No TLS";
1062 }
1063 case SUMO_ATTR_TLID:
1065 return toString((*myNBNode->getControllingTLS().begin())->getID());
1066 } else {
1067 return "No TLS";
1068 }
1070 // keep clear is only used as a convenience feature in plain xml
1071 // input. When saving to .net.xml the status is saved only for the connections
1072 // to show the correct state we must check all connections
1073 for (const auto& i : myGNEIncomingEdges) {
1074 for (const auto& j : i->getGNEConnections()) {
1075 if (j->getNBEdgeConnection().keepClear) {
1076 return True;
1077 }
1078 }
1079 }
1080 return False;
1083 case SUMO_ATTR_FRINGE:
1085 case SUMO_ATTR_NAME:
1086 return myNBNode->getName();
1087 case GNE_ATTR_SELECTED:
1090 return myNBNode->getParametersStr();
1091 default:
1092 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1093 }
1094}
1095
1096
1097void
1098GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList) {
1099 if (value == getAttribute(key)) {
1100 return; //avoid needless changes, later logic relies on the fact that attributes have changed
1101 }
1102 switch (key) {
1103 case SUMO_ATTR_ID:
1105 case SUMO_ATTR_SHAPE:
1106 case SUMO_ATTR_RADIUS:
1108 case SUMO_ATTR_FRINGE:
1109 case SUMO_ATTR_NAME:
1110 case GNE_ATTR_SELECTED:
1112 undoList->add(new GNEChange_Attribute(this, key, value), true);
1113 break;
1114 case SUMO_ATTR_POSITION: {
1115 // change Keep Clear attribute in all connections
1116 undoList->begin(GUIIcon::JUNCTION, TL("change junction position"));
1117 // obtain NBNode position
1118 const Position orig = myNBNode->getPosition();
1119 // change junction position
1120 undoList->add(new GNEChange_Attribute(this, key, value), true);
1121 // calculate delta using new position
1122 const Position delta = myNBNode->getPosition() - orig;
1123 // set new position of adjacent edges
1124 for (const auto& edge : myGNEIncomingEdges) {
1125 const Position newEnd = edge->getNBEdge()->getGeometry().back() + delta;
1126 undoList->add(new GNEChange_Attribute(edge, GNE_ATTR_SHAPE_END, toString(newEnd)), true);
1127 }
1128 for (const auto& edge : myGNEOutgoingEdges) {
1129 const Position newStart = edge->getNBEdge()->getGeometry().front() + delta;
1130 undoList->add(new GNEChange_Attribute(edge, GNE_ATTR_SHAPE_START, toString(newStart)), true);
1131 }
1132 undoList->end();
1133 break;
1134 }
1136 // change Keep Clear attribute in all connections
1137 undoList->begin(GUIIcon::JUNCTION, TL("change keepClear for whole junction"));
1138 for (const auto& i : myGNEIncomingEdges) {
1139 for (const auto& j : i->getGNEConnections()) {
1140 undoList->add(new GNEChange_Attribute(j, key, value), true);
1141 }
1142 }
1143 undoList->end();
1144 break;
1145 case SUMO_ATTR_TYPE: {
1146 // set junction type
1147 setJunctionType(value, undoList);
1148 break;
1149 }
1150 case SUMO_ATTR_TLTYPE: {
1151 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " tl-type");
1152 // make a copy because we will modify the original
1153 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1154 for (const auto& TLS : copyOfTls) {
1155 NBLoadedSUMOTLDef* oldLoaded = dynamic_cast<NBLoadedSUMOTLDef*>(TLS);
1156 if (oldLoaded != nullptr) {
1157 NBLoadedSUMOTLDef* newDef = new NBLoadedSUMOTLDef(*oldLoaded, *oldLoaded->getLogic());
1158 newDef->guessMinMaxDuration();
1159 std::vector<NBNode*> nodes = TLS->getNodes();
1160 for (const auto& node : nodes) {
1161 GNEJunction* junction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1162 undoList->add(new GNEChange_TLS(junction, TLS, false), true);
1163 undoList->add(new GNEChange_TLS(junction, newDef, true), true);
1164 }
1165 }
1166 }
1167 undoList->add(new GNEChange_Attribute(this, key, value), true);
1168 undoList->end();
1169 break;
1170 }
1171 case SUMO_ATTR_TLLAYOUT: {
1172 undoList->begin(GUIIcon::JUNCTION, "change " + getTagStr() + " tlLayout");
1173 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1174 for (const auto& oldTLS : copyOfTls) {
1175 std::vector<NBNode*> copyOfNodes = oldTLS->getNodes();
1176 NBOwnTLDef* newTLS = new NBOwnTLDef(oldTLS->getID(), oldTLS->getOffset(), oldTLS->getType());
1178 newTLS->setProgramID(oldTLS->getProgramID());
1179 for (const auto& node : copyOfNodes) {
1180 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1181 undoList->add(new GNEChange_TLS(oldJunction, oldTLS, false), true);
1182 }
1183 for (const auto& node : copyOfNodes) {
1184 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1185 undoList->add(new GNEChange_TLS(oldJunction, newTLS, true), true);
1186 }
1187 }
1188 undoList->end();
1189 break;
1190 }
1191 case SUMO_ATTR_TLID: {
1192 undoList->begin(GUIIcon::JUNCTION, "change " + toString(SUMO_TAG_TRAFFIC_LIGHT) + " id");
1193 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1194 assert(copyOfTls.size() > 0);
1195 NBTrafficLightDefinition* currentTLS = *copyOfTls.begin();
1196 NBTrafficLightDefinition* currentTLSCopy = nullptr;
1197 const bool currentIsSingle = currentTLS->getNodes().size() == 1;
1198 const bool currentIsLoaded = dynamic_cast<NBLoadedSUMOTLDef*>(currentTLS) != nullptr;
1199 if (currentIsLoaded) {
1200 currentTLSCopy = new NBLoadedSUMOTLDef(*currentTLS,
1201 *dynamic_cast<NBLoadedSUMOTLDef*>(currentTLS)->getLogic());
1202 }
1203 // remove from previous tls
1204 for (const auto& TLS : copyOfTls) {
1205 undoList->add(new GNEChange_TLS(this, TLS, false), true);
1206 }
1208 // programs to which the current node shall be added
1209 const std::map<std::string, NBTrafficLightDefinition*> programs = tlCont.getPrograms(value);
1210 if (programs.size() > 0) {
1211 for (const auto& TLSProgram : programs) {
1212 NBTrafficLightDefinition* oldTLS = TLSProgram.second;
1213 if (dynamic_cast<NBOwnTLDef*>(oldTLS) != nullptr) {
1214 undoList->add(new GNEChange_TLS(this, oldTLS, true), true);
1215 } else {
1216 // delete and re-create the definition because the loaded phases are now invalid
1217 if (dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS) != nullptr &&
1218 dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS)->usingSignalGroups()) {
1219 // keep the old program and add all-red state for the added links
1220 NBLoadedSUMOTLDef* newTLSJoined = new NBLoadedSUMOTLDef(*oldTLS, *dynamic_cast<NBLoadedSUMOTLDef*>(oldTLS)->getLogic());
1221 newTLSJoined->joinLogic(currentTLSCopy);
1222 undoList->add(new GNEChange_TLS(this, newTLSJoined, true, true), true);
1223 } else {
1224 undoList->add(new GNEChange_TLS(this, nullptr, true, false, value), true);
1225 }
1227 // switch from old to new definition
1228 std::vector<NBNode*> copyOfNodes = oldTLS->getNodes();
1229 for (const auto& node : copyOfNodes) {
1230 GNEJunction* oldJunction = myNet->getAttributeCarriers()->retrieveJunction(node->getID());
1231 undoList->add(new GNEChange_TLS(oldJunction, oldTLS, false), true);
1232 undoList->add(new GNEChange_TLS(oldJunction, newTLS, true), true);
1233 }
1234 }
1235 }
1236 } else {
1237 if (currentIsSingle && currentIsLoaded) {
1238 // rename the traffic light but keep everything else
1239 NBTrafficLightLogic* renamedLogic = dynamic_cast<NBLoadedSUMOTLDef*>(currentTLSCopy)->getLogic();
1240 renamedLogic->setID(value);
1241 NBLoadedSUMOTLDef* renamedTLS = new NBLoadedSUMOTLDef(*currentTLSCopy, *renamedLogic);
1242 renamedTLS->setID(value);
1243 undoList->add(new GNEChange_TLS(this, renamedTLS, true, true), true);
1244 } else {
1245 // create new traffic light
1246 undoList->add(new GNEChange_TLS(this, nullptr, true, false, value), true);
1247 }
1248 }
1249 delete currentTLSCopy;
1250 undoList->end();
1251 break;
1252 }
1253 default:
1254 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1255 }
1256}
1257
1258
1259bool
1260GNEJunction::isValid(SumoXMLAttr key, const std::string& value) {
1261 switch (key) {
1262 case SUMO_ATTR_ID:
1263 return SUMOXMLDefinitions::isValidNetID(value) && (myNet->getAttributeCarriers()->retrieveJunction(value, false) == nullptr);
1264 case SUMO_ATTR_TYPE:
1266 case SUMO_ATTR_POSITION:
1267 return canParse<Position>(value);
1268 case SUMO_ATTR_SHAPE:
1269 // empty shapes are allowed
1270 return canParse<PositionVector>(value);
1271 case SUMO_ATTR_RADIUS:
1272 if (value.empty() || (value == "default")) {
1273 return true;
1274 } else {
1275 return canParse<double>(value) && ((parse<double>(value) >= 0) || (parse<double>(value) == -1));
1276 }
1277 case SUMO_ATTR_TLTYPE:
1279 case SUMO_ATTR_TLLAYOUT:
1281 case SUMO_ATTR_TLID:
1282 return myNBNode->isTLControlled() && (value != "");
1284 return canParse<bool>(value);
1287 case SUMO_ATTR_FRINGE:
1289 case SUMO_ATTR_NAME:
1290 return true;
1291 case GNE_ATTR_SELECTED:
1292 return canParse<bool>(value);
1295 default:
1296 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1297 }
1298}
1299
1300
1301bool
1303 switch (key) {
1304 case SUMO_ATTR_TLTYPE:
1305 case SUMO_ATTR_TLLAYOUT:
1306 case SUMO_ATTR_TLID:
1307 return myNBNode->isTLControlled();
1308 case SUMO_ATTR_KEEP_CLEAR: {
1309 // check if at least there is an incoming connection
1310 for (const auto& incomingEdge : myGNEIncomingEdges) {
1311 if (incomingEdge->getGNEConnections().size() > 0) {
1312 return true;
1313 }
1314 }
1315 return false;
1316 }
1317 default:
1318 return true;
1319 }
1320}
1321
1322
1323bool
1325 switch (key) {
1326 case SUMO_ATTR_SHAPE:
1327 return !myNBNode->hasCustomShape();
1328 default:
1329 return false;
1330 }
1331}
1332
1333
1334const Parameterised::Map&
1338
1339
1340void
1342 myAmResponsible = newVal;
1343}
1344
1345// ===========================================================================
1346// private
1347// ===========================================================================
1348
1349bool
1351 // check conditions
1354 // force draw if this junction is a candidate
1355 return true;
1356 }
1357 if (!s.drawJunctionShape) {
1358 // don't draw bubble if it was disabled in GUIVisualizationSettings
1359 return false;
1360 }
1362 // force draw bubbles if we enabled option in checkbox of viewNet
1363 return true;
1364 }
1365 if (myNBNode->getShape().area() > 4) {
1366 // don't draw if shape area is greather than 4
1367 return false;
1368 }
1370 // only draw bubbles in network mode
1371 return false;
1372 }
1373 return true;
1374}
1375
1376
1377void
1379 const double junctionExaggeration, const Position mousePosition) const {
1380 // calculate bubble radius
1381 const double bubbleRadius = s.neteditSizeSettings.junctionBubbleRadius * junctionExaggeration;
1382 // set bubble color
1383 const RGBColor bubbleColor = setColor(s, true);
1384 // recognize full transparency and simply don't draw
1385 if (bubbleColor.alpha() != 0) {
1386 // check if mouse is in bubble
1387 const bool mouseInBubble = (mousePosition.distanceSquaredTo2D(myNBNode->getPosition()) <= (bubbleRadius * bubbleRadius));
1388 // only draw filled circle if we aren't in draw for selecting mode, or if distance to center is enough)
1389 if (!s.drawForPositionSelection || mouseInBubble) {
1390 // push matrix
1392 // set color
1393 GLHelper::setColor(bubbleColor);
1394 // move matrix junction center
1395 glTranslated(myNBNode->getPosition().x(), myNBNode->getPosition().y(), 0.1);
1396 // draw filled circle
1398 // pop matrix
1400 }
1401 }
1402}
1403
1404
1405void
1407 const double junctionExaggeration, const Position mousePosition) const {
1408 // check if draw start und end
1409 const bool drawExtremeSymbols = myNet->getViewNet()->getEditModes().isCurrentSupermodeNetwork() &&
1411 // set shape color
1412 const RGBColor junctionShapeColor = setColor(s, false);
1413 // recognize full transparency and simply don't draw
1414 if (junctionShapeColor.alpha() != 0) {
1415 // set color
1416 GLHelper::setColor(junctionShapeColor);
1417 // adjust shape to exaggeration
1418 if ((junctionExaggeration > 1 || myExaggeration > 1) && junctionExaggeration != myExaggeration) {
1419 myExaggeration = junctionExaggeration;
1422 myTesselation.getShapeRef().scaleRelative(junctionExaggeration);
1424 }
1425 // first check if inner junction polygon can be drawn
1427 // only draw a point if mouse is around shape
1428 if (myTesselation.getShape().around(mousePosition)) {
1429 // push matrix
1431 // move to mouse position
1432 glTranslated(mousePosition.x(), mousePosition.y(), 0.1);
1433 // draw a simple circle
1435 // pop matrix
1437 }
1438 } else if ((s.scale * junctionExaggeration * myMaxDrawingSize) >= 40) {
1439 // draw shape with high detail
1441 } else {
1442 // draw shape
1444 }
1445 // draw shape points only in Network supemode
1447 // set color
1448 const RGBColor darkerColor = junctionShapeColor.changedBrightness(-32);
1449 // calculate geometry
1450 GUIGeometry junctionGeometry;
1451 // obtain junction Shape
1452 PositionVector junctionOpenShape = myNBNode->getShape();
1453 // adjust shape to exaggeration
1454 if (junctionExaggeration > 1) {
1455 junctionOpenShape.scaleRelative(junctionExaggeration);
1456 }
1457 // update geometry
1458 junctionGeometry.updateGeometry(junctionOpenShape);
1459 // set color
1460 GLHelper::setColor(darkerColor);
1461 // draw shape
1463 // draw geometry points
1465 s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration,
1466 myNet->getViewNet()->getNetworkViewOptions().editingElevation(), drawExtremeSymbols);
1467 // draw moving hint
1469 GUIGeometry::drawMovingHint(s, myNet->getViewNet()->getPositionInformation(), junctionOpenShape, darkerColor,
1470 s.neteditSizeSettings.junctionGeometryPointRadius, junctionExaggeration);
1471 }
1472 }
1473 }
1474}
1475
1476
1477void
1479 // draw TLS icon if isn't being drawn for selecting
1483 const Position pos = myNBNode->getPosition();
1484 glTranslated(pos.x(), pos.y(), 2.2);
1485 glColor3d(1, 1, 1);
1486 const double halfWidth = 32 / s.scale;
1487 const double halfHeight = 64 / s.scale;
1488 GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(GUITexture::TLS), -halfWidth, -halfHeight, halfWidth, halfHeight);
1490 }
1491}
1492
1493
1494void
1496 // draw crossings
1497 for (const auto& crossing : myGNECrossings) {
1498 crossing->drawGL(s);
1499 }
1500 // draw walkingAreas
1501 for (const auto& walkingArea : myGNEWalkingAreas) {
1502 walkingArea->drawGL(s);
1503 }
1504 // draw connections and route elements connections (Only for incoming edges)
1505 for (const auto& incomingEdge : myGNEIncomingEdges) {
1506 for (const auto& connection : incomingEdge->getGNEConnections()) {
1507 connection->drawGL(s);
1508 }
1509 }
1510 // draw child demand elements
1511 for (const auto& demandElement : getChildDemandElements()) {
1512 if (!demandElement->getTagProperty().isPlacedInRTree()) {
1513 demandElement->drawGL(s);
1514 }
1515 }
1516}
1517
1518
1519void
1520GNEJunction::drawDottedContoursBubble(const GUIVisualizationSettings& s, const double junctionExaggeration) const {
1521 // get inspected ACs
1522 const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers();
1523 // check if mouse is over junction
1524 const bool mouseWithin = mouseWithinGeometry(myNBNode->getPosition(), s.neteditSizeSettings.junctionBubbleRadius * junctionExaggeration);
1525 // declare dotted contour type
1526 auto dottedContourType = GUIDottedGeometry::DottedContourType::NOTHING;
1527 // check conditions
1530 } else if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
1532 } else if (myAmCreateEdgeSource) {
1534 } else if ((inspectedACs.size() == 1) && ((inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_TRIP_JUNCTIONS) ||
1535 (inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_FLOW_JUNCTIONS))) {
1536 // get vehicle
1537 const auto vehicleOverJunctions = myNet->getAttributeCarriers()->retrieveDemandElement(inspectedACs.front());
1538 // check parent junctions
1539 if (vehicleOverJunctions->getParentJunctions().front() == this) {
1541 } else if (vehicleOverJunctions->getParentJunctions().back() == this) {
1543 }
1544 } else if (myNet->getViewNet()->drawDeleteContour(this, this)) {
1546 } else if (myNet->getViewNet()->drawSelectContour(this, this)) {
1549 // get TLS junction
1550 const auto TLSJunction = myNet->getViewNet()->getViewParent()->getTLSEditorFrame()->getTLSJunction();
1552 TLSJunction->isJoiningJunctions() && TLSJunction->isJunctionSelected(this)) {
1555 (gPostDrawing.markedNode == nullptr) && mouseWithin) {
1556 // get dotted contour type
1559 } else {
1561 }
1562 // mark this node (to avoid mark another junctions)
1563 gPostDrawing.markedNode = this;
1564 }
1565 }
1566 // check if draw dotted contour
1567 if (dottedContourType != GUIDottedGeometry::DottedContourType::NOTHING) {
1569 s.neteditSizeSettings.junctionBubbleRadius, (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1570 }
1571}
1572
1573
1574
1575void
1576GNEJunction::drawDottedContoursShape(const GUIVisualizationSettings& s, const double junctionExaggeration) const {
1577 // get inspected ACs
1578 const auto& inspectedACs = myNet->getViewNet()->getInspectedAttributeCarriers();
1579 // check if mouse is over junction
1580 const bool mouseWithin = mouseWithinGeometry(myNBNode->getShape());
1581 // declare dotted contour type
1582 auto dottedContourType = GUIDottedGeometry::DottedContourType::NOTHING;
1583 // check conditions
1586 } else if (myNet->getViewNet()->getFrontAttributeCarrier() == this) {
1588 } else if (myAmCreateEdgeSource) {
1590 } else if ((inspectedACs.size() == 1) && ((inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_TRIP_JUNCTIONS) ||
1591 (inspectedACs.front()->getTagProperty().getTag() == GNE_TAG_FLOW_JUNCTIONS))) {
1592 // get vehicle
1593 const auto vehicleOverJunctions = myNet->getAttributeCarriers()->retrieveDemandElement(inspectedACs.front());
1594 // check parent junctions
1595 if (vehicleOverJunctions->getParentJunctions().front() == this) {
1597 } else if (vehicleOverJunctions->getParentJunctions().back() == this) {
1599 }
1600 } else if (myNet->getViewNet()->drawDeleteContour(this, this)) {
1602 } else if (myNet->getViewNet()->drawSelectContour(this, this)) {
1605 // get TLS junction
1606 const auto TLSJunction = myNet->getViewNet()->getViewParent()->getTLSEditorFrame()->getTLSJunction();
1608 TLSJunction->isJoiningJunctions() && TLSJunction->isJunctionSelected(this)) {
1611 (gPostDrawing.markedNode == nullptr) && mouseWithin) {
1612 // get dotted contour type
1615 } else {
1617 }
1618 // mark this node (to avoid mark another junctions)
1619 gPostDrawing.markedNode = this;
1620 }
1621 }
1622 // check if draw dotted contour
1623 if (dottedContourType != GUIDottedGeometry::DottedContourType::NOTHING) {
1625 myNBNode->getShape(), (junctionExaggeration >= 1) ? junctionExaggeration : 1);
1626 }
1627}
1628
1629
1630void
1631GNEJunction::setAttribute(SumoXMLAttr key, const std::string& value) {
1632 switch (key) {
1633 case SUMO_ATTR_KEEP_CLEAR: {
1634 throw InvalidArgument(toString(key) + " cannot be edited");
1635 }
1636 case SUMO_ATTR_ID: {
1638 break;
1639 }
1640 case SUMO_ATTR_TYPE: {
1645 }
1647 break;
1648 }
1649 case SUMO_ATTR_POSITION: {
1650 // set new position in NBNode updating edge boundaries
1651 moveJunctionGeometry(parse<Position>(value), true);
1652 // mark this connections and all of the junction's Neighbours as deprecated
1654 // update centering boundary and grid
1656 break;
1657 }
1659 if (myLogicStatus == FEATURE_GUESSED && value != FEATURE_GUESSED) {
1660 // clear guessed connections. previous connections will be restored
1662 // Clear GNEConnections of incoming edges
1663 for (const auto& i : myGNEIncomingEdges) {
1664 i->clearGNEConnections();
1665 }
1666 }
1667 myLogicStatus = value;
1668 break;
1669 case SUMO_ATTR_SHAPE: {
1670 // set new shape (without updating grid)
1671 myNBNode->setCustomShape(parse<PositionVector>(value));
1672 // mark this connections and all of the junction's Neighbours as deprecated
1674 // update centering boundary and grid
1676 break;
1677 }
1678 case SUMO_ATTR_RADIUS: {
1679 if (value.empty() || (value == "default")) {
1680 myNBNode->setRadius(-1);
1681 } else {
1682 myNBNode->setRadius(parse<double>(value));
1683 }
1684 break;
1685 }
1686 case SUMO_ATTR_TLTYPE: {
1687 // we need to make a copy of controlling TLS (because original will be updated)
1688 const std::set<NBTrafficLightDefinition*> copyOfTls = myNBNode->getControllingTLS();
1689 for (const auto& TLS : copyOfTls) {
1690 TLS->setType(SUMOXMLDefinitions::TrafficLightTypes.get(value));
1691 // add special parameters values for NEMA
1692 if (TLS->getType() == TrafficLightType::NEMA) {
1693 if (!TLS->knowsParameter("barrierPhases")) {
1694 TLS->setParameter("barrierPhases", "4,8");
1695 }
1696 if (!TLS->knowsParameter("barrier2Phases")) {
1697 TLS->setParameter("barrier2Phases", "2,6");
1698 }
1699 if (!TLS->knowsParameter("ring1")) {
1700 TLS->setParameter("ring1", "0,2,0,4");
1701 }
1702 if (!TLS->knowsParameter("ring2")) {
1703 TLS->setParameter("ring2", "0,6,0,8");
1704 }
1705 }
1706 }
1707 break;
1708 }
1709 case SUMO_ATTR_TLLAYOUT:
1710 // should not be triggered (handled via GNEChange_TLS)
1711 break;
1714 break;
1715 case SUMO_ATTR_FRINGE:
1717 break;
1718 case SUMO_ATTR_NAME:
1719 myNBNode->setName(value);
1720 break;
1721 case GNE_ATTR_SELECTED:
1722 if (parse<bool>(value)) {
1724 } else {
1726 }
1727 break;
1729 myNBNode->setParametersStr(value);
1730 break;
1731 default:
1732 throw InvalidArgument(getTagStr() + " doesn't have an attribute of type '" + toString(key) + "'");
1733 }
1734 // invalidate path calculator
1736}
1737
1738
1739void
1741 // set new position in NBNode without updating grid
1742 if (isShapeEdited()) {
1743 // set new shape
1745 } else if (moveResult.shapeToUpdate.size() > 0) {
1746 // obtain NBNode position
1747 const Position orig = myNBNode->getPosition();
1748 // move geometry
1749 moveJunctionGeometry(moveResult.shapeToUpdate.front(), false);
1750 // set new position of adjacent edges depending if we're moving a selection
1751 for (const auto& NBEdge : getNBNode()->getEdges()) {
1752 myNet->getAttributeCarriers()->retrieveEdge(NBEdge->getID())->updateJunctionPosition(this, orig);
1753 }
1754 }
1756}
1757
1758
1759void
1761 // update objects in the current junction position
1763 // check if there is another junction in the same position
1764 GNEJunction* secondJunction = nullptr;
1765 const auto& clickedJunctions = myNet->getViewNet()->getObjectsUnderCursor().getClickedJunctions();
1766 for (auto it = clickedJunctions.begin(); (it != clickedJunctions.end()) && (secondJunction == nullptr); it++) {
1767 if (*it != this) {
1768 secondJunction = *it;
1769 }
1770 }
1771 // make sure that newShape isn't empty
1772 if (moveResult.shapeToUpdate.size() > 0) {
1773 // check if we're editing a shape
1774 if (isShapeEdited()) {
1775 // commit new shape
1776 undoList->begin(GUIIcon::JUNCTION, "moving " + toString(SUMO_ATTR_SHAPE) + " of " + getTagStr());
1777 setAttribute(SUMO_ATTR_SHAPE, toString(moveResult.shapeToUpdate), undoList);
1778 undoList->end();
1779 } else if (!myNet->getViewNet()->mergeJunctions(this, secondJunction)) {
1780 setAttribute(SUMO_ATTR_POSITION, toString(moveResult.shapeToUpdate.front()), undoList);
1781 }
1782 }
1783}
1784
1785
1786double
1787GNEJunction::getColorValue(const GUIVisualizationSettings& /* s */, int activeScheme) const {
1788 switch (activeScheme) {
1789 case 0:
1791 return 3;
1792 } else {
1793 return 0;
1794 }
1795 case 1:
1797 case 2:
1798 switch (myNBNode->getType()) {
1800 return 0;
1802 return 1;
1804 return 2;
1806 return 3;
1808 return 4;
1810 return 5;
1812 return 6;
1814 return 7;
1817 return 8;
1819 return 8; // may happen before first network computation
1821 assert(false);
1822 return 8;
1824 return 9;
1826 return 10;
1828 return 11;
1830 return 12;
1832 return 13;
1833 default:
1834 assert(false);
1835 return 0;
1836 }
1837 case 3:
1838 return myNBNode->getPosition().z();
1839 default:
1840 assert(false);
1841 return 0;
1842 }
1843}
1844
1845void
1847 for (auto edge : myGNEIncomingEdges) {
1848 if (edge->getGNEConnections().size() > 0) {
1850 return;
1851 }
1852 }
1853 // no connections. Use normal color for border edges and cul-de-sac
1854 if (myGNEIncomingEdges.size() == 0 || myGNEOutgoingEdges.size() == 0) {
1856 return;
1857 } else if (myGNEIncomingEdges.size() == 1 && myGNEOutgoingEdges.size() == 1) {
1858 NBEdge* in = myGNEIncomingEdges[0]->getNBEdge();
1859 NBEdge* out = myGNEOutgoingEdges[0]->getNBEdge();
1860 if (in->isTurningDirectionAt(out)) {
1862 return;
1863 }
1864 }
1866}
1867
1868
1869void
1870GNEJunction::moveJunctionGeometry(const Position& pos, const bool updateEdgeBoundaries) {
1871 // reinit NBNode
1872 myNBNode->reinit(pos, myNBNode->getType());
1873 // declare three sets with all affected GNEJunctions, GNEEdges and GNEConnections
1874 std::set<GNEJunction*> affectedJunctions;
1875 std::set<GNEEdge*> affectedEdges;
1876 // Iterate over GNEEdges
1877 for (const auto& edge : getChildEdges()) {
1878 // Add source and destiny junctions
1879 affectedJunctions.insert(edge->getFromJunction());
1880 affectedJunctions.insert(edge->getToJunction());
1881 // Obtain neighbors of Junction source
1882 for (const auto& junctionSourceEdge : edge->getFromJunction()->getChildEdges()) {
1883 affectedEdges.insert(junctionSourceEdge);
1884 }
1885 // Obtain neighbors of Junction destiny
1886 for (const auto& junctionDestinyEdge : edge->getToJunction()->getChildEdges()) {
1887 affectedEdges.insert(junctionDestinyEdge);
1888 }
1889 }
1890 // reset walking areas of affected edges
1891 for (const auto& affectedJunction : affectedJunctions) {
1892 affectedJunction->clearWalkingAreas();
1893 }
1894 // Iterate over affected Edges
1895 for (const auto& affectedEdge : affectedEdges) {
1896 // update edge boundaries
1897 if (updateEdgeBoundaries) {
1898 affectedEdge->updateCenteringBoundary(true);
1899 }
1900 // Update edge geometry
1901 affectedEdge->updateGeometry();
1902 }
1903}
1904
1905
1908 // get active scheme
1909 const int scheme = s.junctionColorer.getActive();
1910 // first check if we're editing shape
1911 if (myShapeEdited) {
1913 }
1914 // set default color
1916 // set special bubble color
1917 if (bubble && (scheme == 0) && !myColorForMissingConnections) {
1918 color = s.junctionColorer.getScheme().getColor(1);
1919 }
1920 // override with special colors (unless the color scheme is based on selection)
1921 if (drawUsingSelectColor() && scheme != 1) {
1922 color = s.colorSettings.selectionColor;
1923 }
1924 // overwrite color if we're in data mode
1926 color = s.junctionColorer.getScheme().getColor(6);
1927 }
1928 // special color for source candidate junction
1929 if (mySourceCandidate) {
1931 }
1932 // special color for target candidate junction
1933 if (myTargetCandidate) {
1935 }
1936 // special color for special candidate junction
1937 if (mySpecialCandidate) {
1939 }
1940 // special color for possible candidate junction
1941 if (myPossibleCandidate) {
1943 }
1944 // special color for conflicted candidate junction
1947 }
1948 // return color
1949 return color;
1950}
1951
1952
1953void
1956 tlCont.insert(tlDef, forceInsert); // may return false for tlDef which controls multiple junctions
1957 tlDef->addNode(myNBNode);
1958}
1959
1960
1961void
1964 if (tlDef->getNodes().size() == 1) {
1965 tlCont.extract(tlDef);
1966 }
1968}
1969
1970
1971/****************************************************************************/
@ 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.
@ MID_GNE_JUNCTION_RESET_EDGE_ENDPOINTS
reset edge endpoints
@ MID_GNE_JUNCTION_CLEAR_CONNECTIONS
clear junction's connections
@ MID_GNE_JUNCTION_SELECT_ROUNDABOUT
select all roundabout nodes and edges of the current roundabout
@ MID_GNE_JUNCTION_RESET_SHAPE
reset junction shape
@ MID_GNE_JUNCTION_RESET_CONNECTIONS
reset junction's connections
@ MID_GNE_JUNCTION_SPLIT
turn junction into multiple junctions
@ MID_GNE_JUNCTION_REPLACE
turn junction into geometry node
@ MID_GNE_JUNCTION_CONVERT_ROUNDABOUT
convert junction to roundabout
@ MID_GNE_JUNCTION_SPLIT_RECONNECT
turn junction into multiple junctions and reconnect them heuristically
@ MID_GNE_JUNCTION_EDIT_SHAPE
edit junction shape
@ MID_GNE_JUNCTION_ADDJOINTLS
Add join TLS into junctions.
@ 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:281
#define TL(string)
Definition MsgHandler.h:287
#define WRITE_GLDEBUG(msg)
Definition MsgHandler.h:282
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
@ GNE_TAG_FLOW_JUNCTIONS
a flow between junctions
@ 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
@ GNE_ATTR_SHAPE_END
last coordinate of edge shape
@ 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.
@ GNE_ATTR_SHAPE_START
first coordinate of edge shape
@ 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:82
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:283
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:897
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:44
void updateCenteringBoundary(const bool updateGrid)
update centering boundary (implies change in RTREE)
void updateGeometry()
update pre-computed geometry information
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:480
const std::vector< GNELane * > & getLanes() const
returns a reference to the lane vector
Definition GNEEdge.cpp:840
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 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
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.
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
GNEJunction(GNENet *net, NBNode *nbn, bool loaded=false)
Constructor.
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
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
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection, const NBConnection &addedConnection=NBConnection::InvalidConnection)
void clearWalkingAreas()
clear walking areas
void drawDottedContoursShape(const GUIVisualizationSettings &s, const double junctionExaggeration) const
draw dotted contours (shape)
bool drawAsBubble(const GUIVisualizationSettings &s) const
check if draw junction as bubble
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
void drawDottedContoursBubble(const GUIVisualizationSettings &s, const double junctionExaggeration) const
draw dotted contours (bubble)
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
void drawJunctionAsShape(const GUIVisualizationSettings &s, const double junctionExaggeration, const Position mousePosition) const
draw junction as bubble
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.
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
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
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
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.
void drawJunctionAsBubble(const GUIVisualizationSettings &s, const double junctionExaggeration, const Position mousePosition) const
draw junction as bubble
NBNode * myNBNode
A reference to the represented junction.
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
~GNEJunction()
Destructor.
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=FEATURE_GUESSED)
std::vector< GNEWalkingArea * > myGNEWalkingAreas
the built walkingArea objects
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
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:602
NBNetBuilder * getNetBuilder() const
get net builder
Definition GNENet.cpp:1424
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1248
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1260
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
Definition GNENet.cpp:2036
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:120
GNEPathManager * getPathManager()
get path manager
Definition GNENet.cpp:132
void requireRecompute()
inform the net about the need for recomputation
Definition GNENet.cpp:1406
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
Definition GNENet.cpp:2048
void deleteJunction(GNEJunction *junction, GNEUndoList *undoList)
removes junction and all incident edges
Definition GNENet.cpp:366
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2030
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.
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
const std::vector< GNEJunction * > & getClickedJunctions() const
get vector with clicked junctions
void updateObjectsUnderCursor(const Position &pos)
Update objects under cursor in the given position.
const GNEAttributeCarrier * getFrontAttributeCarrier() const
get front attributeCarrier
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
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
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
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
void buildSelectionACPopupEntry(GUIGLObjectPopupMenu *ret, GNEAttributeCarrier *AC)
Builds an entry which allows to (de)select the object.
bool isAttributeCarrierInspected(const GNEAttributeCarrier *AC) const
check if attribute carrier is being inspected
const GNEViewNetHelper::ObjectsUnderCursor & getObjectsUnderCursor() const
get objects under cursor
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
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
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.
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool mouseWithinGeometry(const Position center, const double radius) const
check if mouse is within elements geometry (for circles)
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.
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)
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
int getTLIndex() const
returns the index within the controlling tls or InvalidTLIndex if this link is unontrolled
static const int InvalidTlIndex
int getToLane() const
returns the to-lane
NBEdge * getTo() const
returns the to-edge (end of the connection)
static const NBConnection InvalidConnection
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:1027
const std::string & getID() const
Definition NBEdge.h:1515
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Definition NBEdge.cpp:3516
NBEdge * getTurnDestination(bool possibleDestination=false) const
Definition NBEdge.cpp:3861
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)
NBEdgeCont & getEdgeCont()
A definition of a pedestrian crossing.
Definition NBNode.h:135
EdgeVector edges
The edges being crossed.
Definition NBNode.h:142
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:298
Position getCenter() const
Returns a position that is guaranteed to lie within the node shape.
Definition NBNode.cpp:3770
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:334
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
Definition NBNode.cpp:332
static const double UNSPECIFIED_RADIUS
unspecified lane width
Definition NBNode.h:218
FringeType getFringeType() const
Returns fringe type.
Definition NBNode.h:303
void buildCrossingsAndWalkingAreas()
build crossings, and walkingareas. Also removes invalid loaded crossings if wished
Definition NBNode.cpp:2857
SumoXMLNodeType getType() const
Returns the type of this node.
Definition NBNode.h:283
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
Definition NBNode.h:567
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition NBNode.cpp:2577
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
Definition NBNode.cpp:3825
void invalidateIncomingConnections(bool reallowSetting=false)
invalidate incoming connections
Definition NBNode.cpp:1947
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
Definition NBNode.h:266
void mirrorX()
mirror coordinates along the x-axis
Definition NBNode.cpp:371
std::vector< std::pair< Position, std::string > > getEndPoints() const
return list of unique endpoint coordinates of all edges at this node
Definition NBNode.cpp:3928
const std::vector< std::unique_ptr< Crossing > > & getCrossingsIncludingInvalid() const
Definition NBNode.h:737
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
Definition NBNode.h:271
bool hasCustomShape() const
return whether the shape was set by the user
Definition NBNode.h:582
const std::string & getName() const
Returns intersection name.
Definition NBNode.h:308
void setRadius(double radius)
set the turning radius
Definition NBNode.h:557
void setName(const std::string &name)
set intersection name
Definition NBNode.h:577
const Position & getPosition() const
Definition NBNode.h:258
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
Definition NBNode.cpp:400
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
Definition NBNode.h:276
const PositionVector & getShape() const
retrieve the junction shape
Definition NBNode.cpp:2571
double getRadius() const
Returns the turning radius of this node.
Definition NBNode.h:288
bool isRoundabout() const
return whether this node is part of a roundabout
Definition NBNode.cpp:3650
bool checkIsRemovableReporting(std::string &reason) const
check if node is removable and return reason if not
Definition NBNode.cpp:2458
const std::vector< WalkingArea > & getWalkingAreas() const
return this junctions pedestrian walking areas
Definition NBNode.h:742
PositionVector myPoly
the (outer) shape of the junction
Definition NBNode.h:925
void setFringeType(FringeType fringeType)
set method for computing right-of-way
Definition NBNode.h:572
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition NBNode.h:329
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:137
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.
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
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:259
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
const PositionVector & getShape() const
Returns the shape of the polygon.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
PositionVector & getShapeRef()
Return the exterior shape of the polygon.
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
void drawTesselation(const PositionVector &shape) const
perform the tesselation / drawing
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