72 myGNEJunctionSource(myNet->retrieveJunction(myNBEdge.getFromNode()->getID())),
73 myGNEJunctionDestiny(myNet->retrieveJunction(myNBEdge.getToNode()->getID())),
74 myOrigShape(nbe.getInnerGeometry()),
76 myAmResponsible(false),
78 myConnectionStatus(loaded ? LOADED : GUESSED) {
82 for (
int i = 0; i < numLanes; i++) {
84 myLanes.back()->incRef(
"GNEEdge::GNEEdge");
87 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); i++) {
88 (*i)->updateGeometry();
95 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
96 (*i)->decRef(
"GNEEdge::~GNEEdge");
97 if ((*i)->unreferenced()) {
103 (*i)->decRef(
"GNEEdge::~GNEEdge");
104 if ((*i)->unreferenced()) {
117 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
118 (*i)->updateGeometry();
122 (*i)->updateGeometry();
130 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
131 ret.
add((*i)->getBoundary());
177 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
197 glGetFloatv(GL_CURRENT_COLOR, color);
201 for (
int i = 1; i < (int)geom.size() - 1; i++) {
223 if (angle > 90 && angle < 270) {
229 if (drawStreetName) {
270 if (geom[index].distanceTo(clickPos) <
SNAP_RADIUS) {
295 if (geom.size() < 2) {
304 const double distance = geom[index].distanceTo2D(nearest);
306 if (moveEndPoints || (index != 0 && index != (
int)geom.size() - 1)) {
307 const bool closed = geom.
isClosed();
309 geom[index] = geom[index] + newPos;
311 geom[index] = newPos;
313 if (closed && moveEndPoints && (index == 0 || index == (
int)geom.size() - 1)) {
314 const int otherIndex = (int)geom.size() - 1 - index;
315 geom[otherIndex] = geom[index];
322 geom[index] = geom[index] + newPos;
338 if (geom.size() == 0) {
341 geom.
add(delta.
x(), delta.
y(), delta.
z());
349 if (geom.size() == 0) {
354 geom.erase(geom.begin() + index);
365 undoList->
p_begin(
"set endpoint");
412 (*i)->remakeGNEConnections();
425 lane->
incRef(
"GNEEdge::addLane");
433 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
448 for (std::vector<NBEdge::Connection>::iterator i = myConnections.begin(); i != myConnections.end(); i++) {
451 newCons.back()->incRef(
"GNEEdge::GNEEdge");
452 newCons.back()->updateLinkState();
464 (*i)->decRef(
"GNEEdge::clearGNEConnections");
466 if ((*i)->unreferenced()) {
478 if ((*i)->getTag() == routeProbe->
getTag()) {
479 routeProbes.push_back(*i);
483 AdditionalVector::const_iterator it = std::find(routeProbes.begin(), routeProbes.end(), routeProbe);
484 if (it == routeProbes.end()) {
487 return (
int)(it - routeProbes.begin());
496 if ((*i)->getTag() == vaporizer->
getTag()) {
497 vaporizers.push_back(*i);
501 AdditionalVector::const_iterator it = std::find(vaporizers.begin(), vaporizers.end(), vaporizer);
502 if (it == vaporizers.end()) {
505 return (
int)(it - vaporizers.begin());
512 undoList->
p_begin(
"copy template");
521 for (
int i = 0; i < (int)
myLanes.size(); i++) {
534 std::set<GUIGlID> result;
535 for (
size_t i = 0; i <
myLanes.size(); i++) {
542 const std::vector<GNELane*>&
548 const std::vector<GNEConnection*>&
596 return "lane specific";
602 return "lane specific";
610 return "lane specific";
643 const std::string origValue =
myLanes.at(0)->getAttribute(key);
645 for (LaneVector::iterator it =
myLanes.begin(); it !=
myLanes.end(); it++) {
646 (*it)->setAttribute(key, value, undoList);
721 return isPositive<double>(value);
724 return isPositive<int>(value);
727 return canParse<int>(value);
752 if (value ==
"default") {
759 return canParse<double>(value);
811 throw InvalidArgument(
"GNEEdge::setAttribute (private) called for attr SUMO_ATTR_NUMLANES. This should never happen");
837 if (value ==
"default") {
862 geom.erase(geom.begin());
895 const int oldNumLanes = (int)
myLanes.size();
896 for (
int i = oldNumLanes; i < numLanes; i++) {
901 for (
int i = oldNumLanes - 1; i > numLanes - 1; i--) {
920 lane =
new GNELane(*
this, index);
923 lane->
incRef(
"GNEEdge::addLane");
931 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
957 lane->
decRef(
"GNEEdge::removeLane");
964 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
1004 con->
decRef(
"GNEEdge::removeConnection");
1014 if ((*i)->getFromLaneIndex() == fromLane
1015 && (*i)->getEdgeTo()->getNBEdge() == to
1016 && (*i)->getToLaneIndex() == toLane) {
1028 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
1029 (*i)->setMicrosimID(
getNBEdge()->getLaneID((*i)->getIndex()));
1061 const std::vector<GNEAdditional*>&
1079 std::vector<GNERerouter*>::iterator it = std::find(
myReroutes.begin(),
myReroutes.end(), rerouter);
1088 const std::vector<GNERerouter*>&
1102 for (std::vector<GNELane*>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); i++) {
1103 if ((*i)->isRestricted(vclass)) {
void addLane(GNELane *lane, const NBEdge::Lane &laneAttrs)
increase number of lanes by one use the given attributes and restore the GNELane
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
void invalidateConnections(bool reallowSetting=false)
invalidate current connections of edge
GNEJunction * myGNEJunctionSource
pointer to GNEJunction source
The information about how to spread the lanes from the given position.
void updateGeometry()
update pre-computed geometry information
std::string getVehicleClassNames(SVCPermissions permissions, bool expand)
Returns the ids of the given classes, divided using a ' '.
void remakeGNEConnections()
remake connections
double z() const
Returns the z-position.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
const std::string & getTypeID() const
get ID of type
A structure which describes a connection between edges or lanes.
void addIncomingGNEEdge(GNEEdge *edge)
add incoming GNEEdge
void setNumLanes(int numLanes, GNEUndoList *undoList)
changes the number of lanes. When reducing the number of lanes, higher-numbered lanes are removed fir...
int toLane
The lane the connections yields in.
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)
GUIVisualizationTextSettings streetName
double laneWidthExaggeration
The lane exaggeration (upscale thickness)
GNEJunction * getGNEJunctionSource() const
returns the source-junction
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
void resetWritable()
Resets all options to be writeable.
GNENet * myNet
the net to inform about updates
bool myAmResponsible
whether we are responsible for deleting myNBNode
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.
NBEdge * toEdge
The edge the connections yields in.
begin/end of the description of a single lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
std::string myConnectionStatus
modification status of the connections
void add(const Position &pos)
Adds the given position to this one.
void refreshElement(GUIGlObject *o)
refreshes boundary information for o and update
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
GNEJunction * myGNEJunctionDestiny
pointer to GNEJunction destiny
bool hasString(const std::string &str) const
PositionVector myOrigShape
restore point for undo
void setMicrosimID(const std::string &newID)
override to also set lane ids
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
GUIColorer laneColorer
The lane colorer.
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
double x() const
Returns the x-position.
Stores the information about how to visualize structures.
static const double SNAP_RADIUS
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
Position moveGeometry(const Position &oldPos, const Position &newPos, bool relative=false)
change the edge geometry It is up to the Edge to decide whether an new geometry node should be genera...
const std::vector< T > & getSchemes() const
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
NBNode * getNBNode() const
Return net build node.
void setStreetName(const std::string &name)
sets the street name of this edge
Position getPosition() const
Return current position.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false)
Removes the specified connection(s)
std::string getAttribute(SumoXMLAttr key) const
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.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
double getEndOffset() const
Returns the offset to the destination node.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
double getSpeed() const
Returns the speed allowed on this edge.
void setLoadedLength(double val)
set loaded lenght
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...
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
double endOffset
This lane's offset to the intersection begin.
void clearGNEConnections()
clear current connections
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double visibility
custom foe visiblity for connection
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
Lane & getLaneStruct(int lane)
bool isClosed() const
check if PositionVector is closed
int getRouteProbeRelativePosition(GNERouteProbe *routeProbe) const
obtain relative positions of RouteProbes
bool myWasSplit
whether this edge was created from a split
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
first coordinate of edge shape
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.
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
int getIndex() const
returns the index of the lane
GUIGlID getGlID() const
Returns the numerical id of the object.
#define UNUSED_PARAMETER(x)
static const double UNSPECIFIED_WIDTH
unspecified lane width
A class that stores a 2D geometrical boundary.
static OptionsCont & getOptions()
Retrieves the options.
bool setConnection(int lane, NBEdge *destEdge, int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection to a certain lane of a certain edge.
whether a feature has been loaded,guessed,modified or approved
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void removeOutgoingGNEEdge(GNEEdge *edge)
remove outgoing GNEEdge
bool keepClear
whether the junction must be kept clear when using this connection
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
GUIVisualizationTextSettings edgeName
An (internal) definition of a single lane of an edge.
const std::string & getID() const
Returns the id.
static bool isValidID(const std::string &value)
true if value is a valid sumo ID
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
void addLane(int index, bool recompute=true)
add lane
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
const std::vector< GNERerouter * > & getGNERerouters() const
get rerouters vinculated with this edge
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
void push_front_noDoublePos(const Position &p)
insert in front a non double position
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
const Position & getPosition() const
double getLaneWidth() const
Returns the default width of lanes of this edge.
bool hasLaneSpecificSpeed() const
whether lanes differ in speed
int getPriority() const
Returns the priority of the edge.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void addGNERerouter(GNERerouter *rerouter)
add a reference to a rerouter that has this edge as parameter
int getNumberOfGNERerouters() const
get number of rerouters that has this edge as parameters
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
const double SUMO_const_halfLaneWidth
SVCPermissions preferred
List of vehicle types that are preferred on this lane.
int fromLane
The lane the connections starts at.
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.
void deleteLane(int index, bool recompute=true)
delete lane
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
int indexOfClosest(const Position &p) const
index of the closest position to p
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
std::vector< GNERerouter * > myReroutes
list of reroutes that has this edge as parameter
void removeGNERerouter(GNERerouter *rerouter)
remove a reference to a rerouter that has this edge as parameter
friend class GNEChange_Attribute
declare friend class
AdditionalVector myAdditionals
list with the additionals vinculated with this edge
Boundary getBoundary() const
Returns the street's geometry.
double y() const
Returns the y-position.
int getNumLanes() const
Returns the number of lanes.
int getVaporizerRelativePosition(GNEVaporizer *vaporizer) const
obtain relative positions of Vaporizer
double length() const
Returns the length.
int myPriority
The priority of the edge.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
edge: the shape in xml-definition
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
Boundary & grow(double by)
extends the boundary by the given amount
GUIColorer junctionColorer
The junction colorer.
void addOutgoingGNEEdge(GNEEdge *edge)
add outgoing GNEEdge
int insertAtClosest(const Position &p)
inserts p between the two closest positions and returns the insertion index
const std::string getID() const
function to support debugging
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
void incRef(const std::string &debugMsg="")
The connection was given by the user.
double speed
The speed allowed on this lane.
double width
This lane's width.
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
void updateGeometry()
update pre-computed geometry information
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void decRef(const std::string &debugMsg="")
begin/end of the description of an edge
void setGeometry(PositionVector geom, bool inner)
update edge geometry and inform the lanes
GNEEdge(NBEdge &nbe, GNENet *net, bool wasSplit=false, bool loaded=false)
Constructor.
bool canParseVehicleClasses(const std::string &classes)
Checks whether the given string contains only known vehicle classes.
A road/street connecting two junctions (netedit-version)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
ConnectionVector myGNEConnections
vector with the connections of this edge
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getShape() const
returns the shape of the lane
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
double length2D() const
Returns the length.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool deleteGeometry(const Position &pos, GNEUndoList *undoList)
deletes the closest geometry node within SNAP_RADIUS.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
An Element which don't belongs to GNENet but has influency in the simulation.
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
const PositionVector & getGeometry() const
Returns the geometry of the edge.
double getFinalLength() const
get length that will be assigned to the lanes in the final network
double contPos
custom position for internal junction on this connection
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
void updateGeometry()
update pre-computed geometry information
std::vector< GNEAdditional * > AdditionalVector
Definition of the additionals vector.
void buildSelectionPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to (de)select the object.
std::string myType
The type of the edge.
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
bool isValid(SumoXMLAttr key, const std::string &value)
void declareConnectionsAsLoaded(EdgeBuildingStep step=LANES2LANES_USER)
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
LaneVector myLanes
vectgor with the lanes of this edge
SumoXMLTag getTag() const
get XML Tag assigned to this object
void removeConnection(NBEdge::Connection nbCon)
removes a connection
bool hasLaneSpecificWidth() const
whether lanes differ in width
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
last coordinate of edge shape
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
void push_back_noDoublePos(const Position &p)
insert in back a non double position
const std::vector< GNEEdge * > & getGNEIncomingEdges() const
Returns incoming GNEEdges.
static const RGBColor selectionColor
color of selection
void removeAdditionalChild(GNEAdditional *additional)
remove additional child from this edge
GNEConnection * retrieveConnection(int fromLane, NBEdge *to, int toLane)
get connection
NBEdge & myNBEdge
the underlying NBEdge
void mul(double val)
Multiplies both positions with the given value.
NBEdge * getNBEdge()
returns the internal NBEdge
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)
draw Text with given parameters
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
void add(double xoff, double yoff, double zoff)
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
std::vector< GNEConnection * > ConnectionVector
Definition of the connection's vector.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getStreetName() const
Returns the street name of this edge.
GUISelectedStorage gSelected
A global holder of selected objects.
const std::vector< Connection > & getConnections() const
Returns the connections.
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
A window containing a gl-object's parameter.
void changeEdgeEndpoints(GNEEdge *edge, const std::string &newSourceID, const std::string &newDestID)
modifies endpoins of the given edge
NBEdge * getTurnDestination(bool possibleDestination=false) const
bool wasSplit()
whether this edge was created from a split
Position getSplitPos(const Position &clickPos)
friend class GNEChange_Lane
Friend class.
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.
static bool changeGeometry(PositionVector &geom, const std::string &id, const Position &oldPos, const Position &newPos, bool relative=false, bool moveEndPoints=false)
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void remakeIncomingGNEConnections()
remake connections of all incoming edges
GNEJunction * getGNEJunctionDestiny() const
returns the destination-junction
NBNode * getFromNode() const
Returns the origin node of the edge.