69 myAmCreateEdgeSource(false),
70 myLogicStatus(loaded ? LOADED : GUESSED),
71 myAmResponsible(false),
72 myHasValidLogic(loaded),
73 myAmTLSSelected(false) {
82 if (it->unreferenced()) {
85 WRITE_WARNING(
"Deleting unreferenced " +
toString(it->getTag()) +
" '" + it->getID() +
"' in GNEJunction destructor");
104 const double EXTENT = 2;
122 if (rebuildNBNodeCrossings) {
127 std::vector<GNECrossing*> retrievedCrossings;
132 retrievedCrossings.push_back(retrievedGNECrossing);
141 retrievedGNECrossing->
incRef();
147 if (it->unreferenced()) {
150 WRITE_WARNING(
"Deleting unreferenced " +
toString(it->getTag()) +
" '" + it->getID() +
"' in rebuildGNECrossings()");
156 myGNECrossings = retrievedCrossings;
177 FXMenuCommand* mcReplace =
new FXMenuCommand(ret,
"Replace junction by geometry point", 0, &parent,
MID_GNE_JUNCTION_REPLACE);
184 mcCustomShape->disable();
185 mcClearConnections->disable();
186 mcResetConnections->disable();
190 mcClearConnections->disable();
196 std::string reason =
"wrong edit mode";
198 mcReplace->setText(mcReplace->getText() +
" (" + reason.c_str() +
")");
199 mcReplace->disable();
232 glGetFloatv(GL_CURRENT_COLOR, color);
238 if (exaggeration > 1) {
252 glGetFloatv(GL_CURRENT_COLOR, color);
256 glTranslated(pos.
x(), pos.
y(),
getType() + 0.05);
265 glGetFloatv(GL_CURRENT_COLOR, color);
269 glTranslated(pos.
x(), pos.
y(),
getType() - 0.05);
273 }
else if (s.
scale >= 2) {
275 }
else if (s.
scale >= 1) {
287 glTranslated(pos.
x(), pos.
y(),
getType() + 0.1);
289 const double halfWidth = 32 / s.
scale;
290 const double halfHeight = 64 / s.
scale;
324 std::vector<GNEJunction*>
327 std::set<GNEJunction*> junctions;
329 junctions.insert(i->getGNEJunctionSource());
332 junctions.insert(i->getGNEJunctionDestiny());
334 return std::vector<GNEJunction*>(junctions.begin(), junctions.end());
395 const std::vector<GNEEdge*>&
401 const std::vector<GNEEdge*>&
407 const std::vector<GNEEdge*>&
413 const std::vector<GNECrossing*>&
419 std::vector<GNEConnection*>
421 std::vector<GNEConnection*> connections;
423 for (
auto j : i->getGNEConnections()) {
424 connections.push_back(j);
454 for (
auto i : junctionNeighbours) {
461 newPosition.
add(offset);
483 std::set<GNEJunction*> affectedJunctions;
484 std::set<GNEEdge*> affectedEdges;
488 affectedJunctions.insert(i->getGNEJunctionSource());
489 affectedJunctions.insert(i->getGNEJunctionDestiny());
491 for (
auto j : i->getGNEJunctionSource()->getGNEEdges()) {
492 affectedEdges.insert(j);
495 for (
auto j : i->getGNEJunctionDestiny()->getGNEEdges()) {
496 affectedEdges.insert(j);
500 for (
auto i : affectedJunctions) {
505 for (
auto i : affectedEdges) {
531 assert(undoList != 0);
535 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
540 std::vector<NBEdge::Connection> connections = srcNBE->
getConnections();
542 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
543 bool hasTurn = con_it->toEdge == turnEdge;
566 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
579 for (
auto it : coypOfTls) {
583 std::string newID = tlDef->
getID();
588 replacementDef = repl;
594 undoList->add(
new GNEChange_TLS(
this, replacementDef,
true,
false, newID),
true);
596 const std::vector<NBNode*> copyOfNodes = tlDef->
getNodes();
597 for (
auto it_node : copyOfNodes) {
599 undoList->add(
new GNEChange_TLS(sharing, tlDef,
false),
true);
600 undoList->add(
new GNEChange_TLS(sharing, replacementDef,
true,
false, newID),
true);
611 for (
auto c : copyOfGNECrossings) {
613 EdgeSet edgeSet(c->getNBCrossing()->edges.begin(), c->getNBCrossing()->edges.end());
615 if (edgeSet.count(edge->
getNBEdge()) == 1) {
617 if ((c->getNBCrossing()->edges.size() == 1) && (c->getNBCrossing()->edges.front() == edge->
getNBEdge())) {
621 std::vector<std::string> edges = GNEAttributeCarrier::parse<std::vector<std::string>>(c->getAttribute(
SUMO_ATTR_EDGES));
622 edges.erase(std::find(edges.begin(), edges.end(), edge->
getID()));
639 if (i->getNBCrossing() == crossing) {
643 if (createIfNoExist) {
650 return createdGNECrossing;
710 for (
auto it : copyOfTls) {
718 }
else if (
getNBNode()->isTLControlled()) {
722 for (
auto it : copyOfTls) {
735 for (
auto it : copyOfTls) {
739 const std::map<std::string, NBTrafficLightDefinition*> programs = tlCont.
getPrograms(value);
740 if (programs.size() > 0) {
742 for (
auto it : programs) {
744 if (dynamic_cast<NBOwnTLDef*>(oldTLS) != 0) {
748 const std::vector<NBNode*> copyOfNodes = oldTLS->
getNodes();
749 for (
auto it_node : copyOfNodes) {
751 undoList->add(
new GNEChange_TLS(oldJunction, oldTLS,
false),
true);
753 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
756 for (
auto it_node : copyOfNodes) {
758 undoList->add(
new GNEChange_TLS(oldJunction, newTLS,
true),
true);
764 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
792 return canParse<double>(value);
798 return canParse<bool>(value);
839 i->clearGNEConnections();
858 for (
auto it : copyOfTls) {
955 tlCont.
insert(tlDef, forceInsert);
963 if (tlDef->
getNodes().size() == 1) {
GUIVisualizationSizeSettings junctionSize
bool getKeepClear() const
Returns the keepClear flag.
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
bool myAmResponsible
whether we are responsible for deleting myNBNode
GUIVisualizationTextSettings junctionName
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
void removeConnection(const NBConnection &conn, bool reconstruct=true)
removes the given connection from the traffic light if recontruct=true, reconstructs the logic and in...
bool myHasValidLogic
whether this junctions logic is valid
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
std::vector< GNEConnection * > getGNEConnections() const
Returns all GNEConnections vinculated with this junction.
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
Position getPositionInView() const
Return current position.
std::string myLogicStatus
modification status of the junction logic (all connections across this junction)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
static StringBijection< SumoXMLNodeType > NodeTypes
node types
void setLogicValid(bool valid, GNEUndoList *undoList, const std::string &status=GUESSED)
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
double scale
information about a lane's width (temporary, used for a single view)
Whether vehicles must keep the junction clear.
const std::vector< GNEEdge * > & getGNEOutgoingEdges() const
Returns incoming GNEEdges.
reset junction's connections
GNENet * myNet
the net to inform about updates
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void removeIncomingGNEEdge(GNEEdge *edge)
remove incoming GNEEdge
double z() const
Returns the z-position.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
begin/end of the description of a junction
void add(const Position &pos)
Adds the given position to this one.
PositionVector myPoly
the (outer) shape of the junction
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
void markAsCreateEdgeSource()
marks as first junction in createEdge-mode
void removeEdgeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
NBNetBuilder * getNetBuilder() const
get net builder
A loaded (complete) traffic light logic.
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static const NBConnection InvalidConnection
A container for traffic light definitions and built programs.
std::vector< GNEEdge * > myGNEIncomingEdges
vector with the incomings GNEEdges vinculated with this junction
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
bool isValid(SumoXMLAttr key, const std::string &value)
turn junction into geometry node
friend class GNEChange_TLS
Declare friend class.
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
bool hasCustomShape() const
return whether the shape was set by the user
The representation of a single edge during network building.
TrafficLightType getType() const
get the algorithm type (static etc..)
double x() const
Returns the x-position.
The base class for traffic light logic definitions.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
link,node: the traffic light id responsible for this link
double getWidth() const
Returns the width of the boudary (x-axis)
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
A NBNetBuilder extended by visualisation and editing capabilities.
NBEdge * getTurnDestination(bool possibleDestination=false) const
static void drawFilledPoly(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
int editMode
the current NETEDIT mode (temporary)
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
void addExplicitTurnaround(std::string id)
add edge id to the list of explicit turnarounds
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void selectTLS(bool selected)
notify the junction of being selected in tls-mode. (used to control drawing)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
bool myAmTLSSelected
whether this junction is selected in tls-mode
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
void setCustomShape(const PositionVector &shape)
set the junction shape
void extract(NBTrafficLightDefinition *definition)
Extracts a traffic light definition from myDefinitions but keeps it in myExtracted for eventual * del...
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
void updateShapesAndGeometries()
update shapes of all elements associated to the junction
const std::vector< GNEEdge * > & getGNEEdges() const
Returns all GNEEdges vinculated with this Junction.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used, also builds an entry for copying the geo-position.
Boundary getBoundary() const
Returns the boundary of the junction.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
whether a feature has been loaded,guessed,modified or approved
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
double area() const
Returns the area (0 for non-closed)
SUMOTime getOffset()
Returns the offset.
void updateGeometry()
update pre-computed geometry information
void renameJunction(GNEJunction *junction, const std::string &newID)
updates the map and reserves new id
static void drawFilledPolyTesselated(const PositionVector &v, bool close)
Draws a filled polygon described by the list of points.
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
const std::vector< GNECrossing * > & getGNECrossings() const
Returns GNECrossings.
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
static const std::string MODIFIED
feature has been manually modified (implies approval)
void setRadius(double radius)
set the turning radius
std::string getAttribute(SumoXMLAttr key) const
This functions has to be implemented in all GNEAttributeCarriers.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
void invalidateIncomingConnections()
invalidate incoming connections
The turning radius at an intersection in m.
std::set< NBEdge * > EdgeSet
container for unique edges
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
bool hasCommandGroup() const
Check if undoList has command group.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
This object is responsible for drawing a shape and for supplying a a popup menu. Messages are routete...
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
A point in 2D or 3D with translation and scaling methods.
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
bool isLogicValid()
whether this junction has a valid logic
void buildCrossingsAndWalkingAreas()
build crossings, and walkingareas. Also removes invalid loaded crossings if wished ...
friend class GNEChange_Attribute
declare friend class
T get(const std::string &str) const
void commitGeometryMoving(const Position &oldPos, GNEUndoList *undoList)
registers completed movement with the undoList
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node) ...
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
NBTrafficLightLogic * getLogic()
Returns the internal logic.
node: the type of traffic light
edge: the shape in xml-definition
Boundary & grow(double by)
extends the boundary by the given amount
GUIColorer junctionColorer
The junction colorer.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void deleteCrossing(GNECrossing *crossing, GNEUndoList *undoList)
remove crossing
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
std::vector< GNEEdge * > myGNEEdges
vector with the GNEEdges vinculated with this junction
const std::string getID() const
function to support debugging
void unMarkAsCreateEdgeSource()
removes mark as first junction in createEdge-mode
void setProgramID(const std::string &programID)
Sets the programID.
const T getColor(const double value) const
const std::string & getProgramID() const
Returns the ProgramID.
void incRef(const std::string &debugMsg="")
Increarse reference.
double getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
NBNode & myNBNode
A reference to the represented junction.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void setKeepClear(bool keepClear)
set the keepClear flag
bool checkIsRemovableReporting(std::string &reason) const
check if node is removable and return reason if not
void invalidateTLS(GNEUndoList *undoList, const NBConnection &deletedConnection=NBConnection::InvalidConnection)
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any) ...
begin/end of the description of an edge
EditMode getCurrentEditMode() const
get the current edit mode
const PositionVector & getShape() const
retrieve the junction shape
A road/street connecting two junctions (netedit-version)
static const double BUBBLE_RADIUS
double selectionScale
the current selection scaling in NETEDIT (temporary)
~GNEJunction()
Destructor.
double getRadius() const
Returns the turning radius of this node.
bool haveNetworkCrossings()
notify about style of loaded network (Without Crossings)
void updateGeometry()
Update the boundary of the junction.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
const std::vector< Connection > & getConnections() const
Returns the connections.
double getHeight() const
Returns the height of the boundary (y-axis)
Boundary myBoundary
The represented junction's boundary.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node (The set of tls that control this node) ...
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
std::vector< GNECrossing * > myGNECrossings
the built crossing objects
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
void moveGeometry(const Position &oldPos, const Position &offset)
change the position of the element geometry without saving in undoList
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
SumoXMLNodeType getType() const
Returns the type of this node.
std::vector< GNEEdge * > myGNEOutgoingEdges
vector with the outgoings GNEEdges vinculated with this junction
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
clear junction's connections
const Position & getPosition() const
Represents a single node (junction) during network building.
GUIGlID getGlID() const
Returns the numerical id of the object.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
A definition of a pedestrian crossing.
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
void rebuildGNECrossings(bool rebuildNBNodeCrossings=true)
rebuilds crossing objects for this junction
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
const std::vector< Crossing * > & getCrossingsIncludingInvalid() const
bool drawJunctionShape
whether the shape of the junction should be drawn
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
static const RGBColor selectionColor
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
mode for connecting lanes
mode for creating new edges
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
bool hasString(const std::string &str) const
GNECrossing * retrieveGNECrossing(NBNode::Crossing *crossing, bool createIfNoExist=true)
get GNECrossing if exist, and if not create it if create is enabled
NBEdge * getNBEdge()
returns the internal NBEdge
std::vector< GNEJunction * > getJunctionNeighbours() const
return GNEJunction neighbours
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
A traffic light logics which must be computed (only nodes/edges are given)
void closePolygon()
ensures that the last position equals the first
NBNode * getNBNode() const
Return net build node.
GUISelectedStorage gSelected
A global holder of selected objects.
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
static bool isTrafficLight(SumoXMLNodeType type)
return whether the given type is a traffic light
static PositionVector parseShapeReporting(const std::string &shpdef, const std::string &objecttype, const char *objectid, bool &ok, bool allowEmpty, bool report=true)
Builds a PositionVector from a string representation, reporting occured errors.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void requireRecompute()
inform the net about the need for recomputation
void moveJunctionGeometry(const Position &pos)
reposition the node at pos and informs the edges
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void markAsModified(GNEUndoList *undoList)
prevent re-guessing connections at this junction
GNEViewNet * getViewNet() const
get view net
SumoXMLTag getTag() const
get XML Tag assigned to this object