68 myOrigPos(nbn.getPosition()),
69 myAmCreateEdgeSource(false),
70 myLogicStatus(loaded ? LOADED : GUESSED),
71 myAmResponsible(false),
72 myHasValidLogic(loaded),
73 myAmTLSSelected(false) {
90 const double EXTENT = 2;
111 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
131 FXMenuCommand* mcCustomShape =
new FXMenuCommand(ret,
"Set custom shape", 0, &parent,
MID_GNE_NODE_SHAPE);
132 FXMenuCommand* mcReplace =
new FXMenuCommand(ret,
"Replace by geometry node", 0, &parent,
MID_GNE_NODE_REPLACE);
136 mcCustomShape->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
143 mcReplace->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
146 (
dynamic_cast<GNEViewNet&
>(parent)).markPopupPosition();
182 glGetFloatv(GL_CURRENT_COLOR, color);
188 if (exaggeration > 1) {
203 glGetFloatv(GL_CURRENT_COLOR, color);
207 glTranslated(pos.
x(), pos.
y(),
getType() + 0.05);
217 glGetFloatv(GL_CURRENT_COLOR, color);
221 glTranslated(pos.
x(), pos.
y(),
getType() - 0.05);
230 glTranslated(pos.
x(), pos.
y(),
getType() + 0.1);
232 const double halfWidth = 32 / s.
scale;
233 const double halfHeight = 64 / s.
scale;
267 std::vector<GNEJunction*>
270 std::set<GNEJunction*> junctions;
272 junctions.insert((*i)->getGNEJunctionSource());
275 junctions.insert((*i)->getGNEJunctionDestiny());
277 return std::vector<GNEJunction*>(junctions.begin(), junctions.end());
337 const std::vector<GNEEdge*>&
343 const std::vector<GNEEdge*>&
349 const std::vector<GNEEdge*>&
354 const std::vector<GNECrossing*>&
379 std::set<GNEJunction*> neighborsJunctions;
382 neighborsJunctions.insert((*i)->getGNEJunctionSource());
385 neighborsJunctions.insert((*i)->getGNEJunctionDestiny());
399 for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
435 std::set<GNEJunction*> affectedJunctions;
436 std::set<GNEEdge*> affectedEdges;
438 for (std::vector<GNEEdge*>::const_iterator i =
myGNEEdges.begin(); i !=
myGNEEdges.end(); i++) {
440 affectedJunctions.insert((*i)->getGNEJunctionSource());
441 affectedJunctions.insert((*i)->getGNEJunctionDestiny());
443 for (std::vector<GNEEdge*>::const_iterator j = (*i)->getGNEJunctionSource()->getGNEEdges().begin(); j != (*i)->getGNEJunctionSource()->getGNEEdges().end(); j++) {
444 affectedEdges.insert(*j);
447 for (std::vector<GNEEdge*>::const_iterator j = (*i)->getGNEJunctionDestiny()->getGNEEdges().begin(); j != (*i)->getGNEJunctionDestiny()->getGNEEdges().end(); j++) {
448 affectedEdges.insert(*j);
452 for (std::set<GNEJunction*>::iterator i = affectedJunctions.begin(); i != affectedJunctions.end(); i++) {
454 (*i)->updateGeometry();
457 for (std::set<GNEEdge*>::iterator i = affectedEdges.begin(); i != affectedEdges.end(); i++) {
459 (*i)->updateGeometry();
483 assert(undoList != 0);
487 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
492 std::vector<NBEdge::Connection> connections = srcNBE->
getConnections();
494 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
495 bool hasTurn = con_it->toEdge == turnEdge;
516 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
529 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
533 std::string newID = tlDef->
getID();
538 replacementDef = repl;
544 undoList->add(
new GNEChange_TLS(
this, replacementDef,
true,
false, newID),
true);
546 const std::vector<NBNode*> coNodes = tlDef->
getNodes();
547 for (std::vector<NBNode*>::const_iterator it_node = coNodes.begin(); it_node != coNodes.end(); it_node++) {
549 undoList->add(
new GNEChange_TLS(sharing, tlDef,
false),
true);
550 undoList->add(
new GNEChange_TLS(sharing, replacementDef,
true,
false, newID),
true);
562 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
563 EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end());
564 if (edgeSet.count(edge->
getNBEdge()) == 1) {
582 if ((*it)->unreferenced()) {
646 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
654 }
else if (
getNBNode()->isTLControlled()) {
658 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
671 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
675 const std::map<std::string, NBTrafficLightDefinition*>& programs = tlCont.
getPrograms(value);
676 if (programs.size() > 0) {
678 for (std::map<std::string, NBTrafficLightDefinition*>::const_iterator it = programs.begin(); it != programs.end(); it++) {
680 if (dynamic_cast<NBOwnTLDef*>(oldTLS) != 0) {
684 const std::vector<NBNode*> nodes = oldTLS->
getNodes();
685 for (std::vector<NBNode*>::const_iterator it_node = nodes.begin(); it_node != nodes.end(); ++it_node) {
687 undoList->add(
new GNEChange_TLS(oldJunction, oldTLS,
false),
true);
689 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
692 for (std::vector<NBNode*>::const_iterator it_node = nodes.begin(); it_node != nodes.end(); ++it_node) {
694 undoList->add(
new GNEChange_TLS(oldJunction, newTLS,
true),
true);
700 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
731 return canParse<double>(value);
738 return value ==
"true" || value ==
"false";
782 (*i)->clearGNEConnections();
798 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
891 tlCont.
insert(tlDef, forceInsert);
899 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
double myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
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
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.
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
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
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
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)
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
Position getPosition() const
Return current position.
friend class GNEChange_TLS
Declare friend class.
Stores the information about how to visualize structures.
double y() const
Returns the y-position.
GUIVisualizationSettings * getVisualisationSettings() const
get visualitation settings
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..)
void moveby(double x, double y, double z=0)
Moves the boundary by the given amount.
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
double x() const
Returns the x-position.
turn junction into geometry node
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)
const std::string & getID() const
Returns the id.
bool myAmTLSSelected
whether this junction is selected in tls-mode
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...
void registerMove(GNEUndoList *undoList)
registers completed movement with the undoList
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.
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
Position myOrigPos
restore point for undo
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 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
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
bool isTLControlled() const
Returns whether this node is controlled by any tls.
void invalidateIncomingConnections()
invalidate incoming connections
void removeCrossing(const EdgeVector &edges)
remove a pedestrian crossing from this node (identified by its edges)
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...
void buildCrossingsAndWalkingAreas(bool discardInvalid=true)
build crossings, and walkingareas. Also removes invalid loaded crossings if wished ...
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
friend class GNEChange_Attribute
declare friend class
T get(const std::string &str) const
void removeFromCrossings(GNEEdge *edge, GNEUndoList *undoList)
removes the given edge from all pedestrian crossings
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 dropGNECrossings()
drop crossings
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 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.
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
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
const PositionVector & getShape() const
retrieve the junction shape
A road/street connecting two junctions (netedit-version)
double selectionScale
the current selection scaling in NETEDIT (temporary)
virtual ~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 recomputeNeighborsJunctions()
recompute neighbors junctions
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
void rebuildGNECrossings()
rebuilds crossing objects for this junction
const std::vector< NBNode * > & getNodes() const
Returns the list of controlled nodes.
void move(Position pos)
reposition the node at pos and informs the edges
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
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.
const Position & getPosition() const
Represents a single node (junction) during network building.
GUIGlID getGlID() const
Returns the numerical id of the object.
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
double getExaggeration(const GUIVisualizationSettings &s, double factor=20) const
return the drawing size including exaggeration and constantSize values
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
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
color of selection
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
void setPosition(Position pos)
reposition the NBNnode and nothing else
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
bool checkIsRemovable() const
check if node is removable
NBNode * getNBNode() const
Return net build node.
GUISelectedStorage gSelected
A global holder of selected objects.
A window containing a gl-object's parameter.
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.
void requireRecompute()
inform the net about the need for recomputation
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