62 #ifdef CHECK_MEMORY_LEAKS 64 #endif // CHECK_MEMORY_LEAKS 72 myOrigPos(nbn.getPosition()),
73 myAmCreateEdgeSource(false),
74 myLogicStatus(loaded ? LOADED : GUESSED),
75 myAmResponsible(false),
76 myHasValidLogic(loaded),
77 myAmTLSSelected(false) {
93 const double EXTENT = 2;
108 if ((*it)->unreferenced()) {
115 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
135 FXMenuCommand* mcCustomShape =
new FXMenuCommand(ret,
"Set custom shape", 0, &parent,
MID_GNE_NODE_SHAPE);
136 FXMenuCommand* mcReplace =
new FXMenuCommand(ret,
"Replace by geometry node", 0, &parent,
MID_GNE_NODE_REPLACE);
140 mcCustomShape->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
147 mcReplace->handle(&parent, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
150 (
dynamic_cast<GNEViewNet&
>(parent)).markPopupPosition();
186 glGetFloatv(GL_CURRENT_COLOR, color);
192 if (exaggeration > 1) {
207 glGetFloatv(GL_CURRENT_COLOR, color);
211 glTranslated(pos.
x(), pos.
y(),
getType() - 0.05);
220 glTranslated(pos.
x(), pos.
y(),
getType() + 0.1);
251 std::vector<GNEEdge*>
253 std::vector<GNEEdge*> edges;
266 std::vector<GNEEdge*>
268 std::vector<GNEEdge*> incomingEdges;
273 return incomingEdges;
277 std::vector<GNEEdge*>
279 std::vector<GNEEdge*> outgoingEdges;
284 return outgoingEdges;
311 for (EdgeVector::const_iterator it = incident.begin(); it != incident.end(); it++) {
338 std::set<GNEJunction*> affectedJunctions;
339 std::set<GNEEdge*> affectedEdges;
342 std::vector<GNEEdge*> edgesNeighbor;
344 for (std::vector<GNEEdge*>::const_iterator i = GNEEdges.begin(); i != GNEEdges.end(); i++) {
346 affectedJunctions.insert((*i)->getGNEJunctionSource());
347 affectedJunctions.insert((*i)->getGNEJunctionDest());
349 edgesNeighbor = (*i)->getGNEJunctionSource()->getGNEEdges();
350 for (std::vector<GNEEdge*>::const_iterator j = edgesNeighbor.begin(); j != edgesNeighbor.end(); j++) {
351 affectedEdges.insert(*j);
354 edgesNeighbor = (*i)->getGNEJunctionDest()->getGNEEdges();
355 for (std::vector<GNEEdge*>::const_iterator j = edgesNeighbor.begin(); j != edgesNeighbor.end(); j++) {
356 affectedEdges.insert(*j);
360 for (std::set<GNEJunction*>::iterator i = affectedJunctions.begin(); i != affectedJunctions.end(); i++) {
362 if ((*i)->getNBNode()->hasCustomShape() ==
false) {
366 (*i)->getNBNode()->myPoly.clear();
367 (*i)->getNBNode()->myPoly.push_back((*i)->getNBNode()->getPosition());
370 (*i)->getNBNode()->computeNodeShape(-1);
373 (*i)->updateGeometry();
377 for (std::set<GNEEdge*>::iterator i = affectedEdges.begin(); i != affectedEdges.end(); i++) {
380 (*i)->getNBEdge()->computeLaneShapes();
383 (*i)->getNBEdge()->computeEdgeShape();
386 (*i)->updateGeometry();
406 assert(undoList != 0);
410 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
415 std::vector<NBEdge::Connection> connections = srcNBE->
getConnections();
417 for (std::vector<NBEdge::Connection>::reverse_iterator con_it = connections.rbegin(); con_it != connections.rend(); con_it++) {
418 bool hasTurn = con_it->toEdge == turnEdge;
439 for (EdgeVector::iterator it = incoming.begin(); it != incoming.end(); it++) {
452 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
456 std::string newID = tlDef->
getID();
461 replacementDef = repl;
467 undoList->add(
new GNEChange_TLS(
this, replacementDef,
true,
false, newID),
true);
469 const std::vector<NBNode*> coNodes = tlDef->
getNodes();
470 for (std::vector<NBNode*>::const_iterator it_node = coNodes.begin(); it_node != coNodes.end(); it_node++) {
472 undoList->add(
new GNEChange_TLS(sharing, tlDef,
false),
true);
473 undoList->add(
new GNEChange_TLS(sharing, replacementDef,
true,
false, newID),
true);
485 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
486 EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end());
487 if (edgeSet.count(edge->
getNBEdge()) == 1) {
548 undoList->
p_begin(
"change junction type");
554 }
else if (
getNBNode()->isTLControlled()) {
558 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
568 undoList->
p_begin(
"change tls id");
571 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
575 const std::map<std::string, NBTrafficLightDefinition*>& programs = tlCont.
getPrograms(value);
576 if (programs.size() > 0) {
578 for (std::map<std::string, NBTrafficLightDefinition*>::const_iterator it = programs.begin(); it != programs.end(); it++) {
580 if (dynamic_cast<NBOwnTLDef*>(oldTLS) != 0) {
584 const std::vector<NBNode*> nodes = oldTLS->
getNodes();
585 for (std::vector<NBNode*>::const_iterator it_node = nodes.begin(); it_node != nodes.end(); ++it_node) {
587 undoList->add(
new GNEChange_TLS(oldJunction, oldTLS,
false),
true);
589 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
592 for (std::vector<NBNode*>::const_iterator it_node = nodes.begin(); it_node != nodes.end(); ++it_node) {
594 undoList->add(
new GNEChange_TLS(oldJunction, newTLS,
true),
true);
600 undoList->add(
new GNEChange_TLS(
this, 0,
true,
false, value),
true);
627 value,
"user-supplied position", 0, ok,
true);
632 return canParse<SUMOReal>(value);
639 return value ==
"true" || value ==
"false";
678 for (std::vector<GNEEdge*>::iterator i = incomingEdges.begin(); i != incomingEdges.end(); i++) {
679 (*i)->clearGNEConnections();
695 for (std::set<NBTrafficLightDefinition*>::iterator it = tls.begin(); it != tls.end(); it++) {
788 tlCont.
insert(tlDef, forceInsert);
796 if (tlDef->
getNodes().size() == 1) {
806 EdgeSet edgeSet2((*it).edges.begin(), (*it).edges.end());
807 if (edgeSet == edgeSet2) {
808 (*it).width = crossing.
width;
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
GUIVisualizationSizeSettings junctionSize
bool getKeepClear() const
Returns the keepClear flag.
bool myAmResponsible
whether we are responsible for deleting myNBNode
void rebuildCrossings(bool deleteOnly)
rebuilds crossing objects for this junction
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::string myLogicStatus
modification status of the junction logic (all connections across this junction)
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
static StringBijection< SumoXMLNodeType > NodeTypes
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
std::vector< Crossing > myCrossings
Vector of crossings.
SUMOReal width
This lane's width.
Whether vehicles must keep the junction clear.
SUMOReal getRadius() const
Returns the turning radius of this node.
GNENet * myNet
the net to inform about updates
virtual void addNode(NBNode *node)
Adds a node to the traffic light logic.
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
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
std::vector< GNEEdge * > getGNEEdges() const
Return all GNEEdges vinculated with this Junction.
SUMOReal getHeight() const
Returns the height of the boundary (y-axis)
A loaded (complete) traffic light logic.
bool myAmCreateEdgeSource
whether this junction is the first junction for a newly creatededge
static const NBConnection InvalidConnection
A container for traffic light definitions and built programs.
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)
friend class GNEChange_TLS
Declare friend class.
Stores the information about how to visualize structures.
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..)
const std::vector< Crossing > & getCrossings() const
return this junctions pedestrian crossings
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.
void scaleRelative(SUMOReal factor)
enlarges/shrinks the polygon by a factor based at the centroid
static void drawBoxLine(const Position &beg, SUMOReal rot, SUMOReal visLength, SUMOReal width, SUMOReal offset=0)
Draws a thick line.
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.
std::vector< GNEEdge * > getGNEIncomingEdges() const
Return incoming GNEEdges.
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)
SUMOReal getWidth() const
Returns the width of the boudary (x-axis)
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
void updateShapesAndGeometries()
update shapes of all elements associated to the 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
SUMOReal scale
information about a lane's width (temporary, used for a single view)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
bool priority
whether the pedestrians have priority
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.
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
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)
std::string getAttribute(SumoXMLAttr key) const
bool isTLControlled() const
Returns whether this node is controlled by any tls.
void invalidateIncomingConnections()
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
SUMOReal selectionScale
the current selection scaling in NETEDIT (temporary)
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.
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 updateCrossingAttributes(NBNode::Crossing crossing)
modify the specified crossing (using friend privileges)
void setRadius(SUMOReal radius)
set the turning radius
static StringBijection< TrafficLightType > TrafficLightTypes
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.
bool showJunctionAsBubbles() const
return true if junction must be showed as bubbles
SUMOReal myMaxSize
The maximum size (in either x-, or y-dimension) for determining whether to draw or not...
SUMOReal x() const
Returns the x-position.
NBTrafficLightLogic * getLogic()
Returns the internal logic.
GUIColorer junctionColorer
The junction colorer.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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 SUMOReal value) const
const std::string & getProgramID() const
Returns the ProgramID.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
NBNode & myNBNode
A reference to the represented junction.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
std::vector< GNEEdge * > getGNEOutgoingEdges() const
Return incoming GNEEdges.
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) ...
const PositionVector & getShape() const
retrieve the junction shape
A road/street connecting two junctions (netedit-version)
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
virtual ~GNEJunction()
Destructor.
void updateGeometry()
Update the boundary of the junction.
SUMOReal area() const
Returns the area (0 for non-closed)
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
const std::vector< Connection > & getConnections() const
Returns the connections.
void add(SUMOReal x, SUMOReal y, SUMOReal z=0)
Makes the boundary include the given coordinate.
Boundary myBoundary
The represented junction's boundary.
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
void setColor(const GUIVisualizationSettings &s, bool bubble) const
sets junction color depending on circumstances
std::vector< NBEdge * > EdgeVector
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.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
const Position & getPosition() const
Returns the position of this node.
EdgeVector edges
The edges being crossed.
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.
A definition of a pedestrian crossing.
GNEJunction(NBNode &nbn, GNENet *net, bool loaded=false)
Constructor.
SUMOReal getColorValue(const GUIVisualizationSettings &s, bool bubble) const
determines color value
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
std::vector< GNECrossing * > myCrossings
the built crossing objects
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
SUMOReal getExaggeration(const GUIVisualizationSettings &s, SUMOReal factor=20) const
return the drawing size including exaggeration and constantSize values
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
bool hasString(const std::string &str) const
void setPosition(Position pos)
reposition the NBNnode and nothing else
NBEdge * getNBEdge()
returns the internal NBEdge
A traffic light logics which must be computed (only nodes/edges are given)
static GUIGlID getGif(GUITexture which)
returns a texture Gif previously defined in the enum GUITexture
SUMOReal y() const
Returns the y-position.
void closePolygon()
ensures that the last position equals the first
bool checkIsRemovable() const
NBNode * getNBNode() const
Return net build node.
GUISelectedStorage gSelected
A global holder of selected objects.
void moveby(SUMOReal x, SUMOReal y, SUMOReal z=0)
Moves the boundary by the given amount.
A window containing a gl-object's parameter.
NBTrafficLightLogicCont & getTLLogicCont()
returns the tllcont of the underlying netbuilder
static void drawTexturedBox(int which, SUMOReal size)
Draws a named texture as a box with the given size.
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