57 #ifdef CHECK_MEMORY_LEAKS 59 #endif // CHECK_MEMORY_LEAKS 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");
91 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
92 (*i)->decRef(
"GNEEdge::~GNEEdge");
93 if ((*i)->unreferenced()) {
99 (*i)->decRef(
"GNEEdge::~GNEEdge");
100 if ((*i)->unreferenced()) {
113 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
114 (*i)->updateGeometry();
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) {
296 throw ProcessError(
"Invalid geometry size in edge " +
id);
304 const SUMOReal 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");
414 for (std::vector<GNEEdge*>::iterator i = incomingEdges.begin(); i != incomingEdges.end(); i++) {
415 (*i)->remakeGNEConnections();
425 for (std::vector<NBEdge::Connection>::iterator i = myConnections.begin(); i != myConnections.end(); i++) {
428 newCons.back()->incRef(
"GNEEdge::GNEEdge");
429 newCons.back()->updateLinkState();
442 (*i)->decRef(
"GNEEdge::clearGNEConnections");
444 if ((*i)->unreferenced()) {
454 undoList->
p_begin(
"copy template");
463 for (
int i = 0; i < (int)
myLanes.size(); i++) {
476 std::set<GUIGlID> result;
477 for (
size_t i = 0; i <
myLanes.size(); i++) {
484 const std::vector<GNELane*>&
490 const std::vector<GNEConnection*>&
540 return "lane specific";
546 return "lane specific";
552 return "lane specific";
576 undoList->
p_begin(
"change edge attribute");
579 for (LaneVector::iterator it =
myLanes.begin(); it !=
myLanes.end(); it++) {
580 (*it)->setAttribute(key, value, undoList);
588 undoList->
p_begin(
"change edge attribute");
598 undoList->
p_begin(
"change edge attribute");
655 return isPositive<SUMOReal>(value);
658 return isPositive<int>(value);
661 return canParse<int>(value);
676 value,
"user-supplied position", 0, ok,
true);
687 return canParse<SUMOReal>(value) && (isPositive<SUMOReal>(value) || parse<SUMOReal>(value) ==
NBEdge::UNSPECIFIED_WIDTH);
690 return canParse<SUMOReal>(value);
719 throw InvalidArgument(
"GNEEdge::setAttribute (private) called for attr SUMO_ATTR_NUMLANES. This should never happen");
782 undoList->
p_begin(
"change number of lanes");
786 const int oldNumLanes = (int)
myLanes.size();
787 for (
int i = oldNumLanes; i < numLanes; i++) {
792 for (
int i = oldNumLanes - 1; i > numLanes - 1; i--) {
811 lane =
new GNELane(*
this, index);
814 lane->
incRef(
"GNEEdge::addLane");
822 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
841 throw ProcessError(
"Should not remove the last lane from an edge\n");
848 lane->
decRef(
"GNEEdge::removeLane");
855 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
895 con->
decRef(
"GNEEdge::removeConnection");
905 if ((*i)->getFromLaneIndex() == fromLane
906 && (*i)->getEdgeTo()->getNBEdge() == to
907 && (*i)->getToLaneIndex() == toLane) {
919 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
920 (*i)->setMicrosimID(
getNBEdge()->getLaneID((*i)->getIndex()));
929 if (*i == additional) {
930 throw ProcessError(
"additional element with ID='" + additional->
getID() +
"' was already inserted in edge with ID='" +
getID() +
"'");
947 throw ProcessError(
"additional element with ID='" + additional->
getID() +
"' doesn't exist in edge with ID='" +
getID() +
"'");
954 const std::vector<GNEAdditional*>&
964 if ((*i) == additionalSet) {
978 if ((*i) == additionalSet) {
988 const std::vector<GNEAdditionalSet*>&
996 for (std::vector<GNELane*>::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); i++) {
997 if ((*i)->isRestricted(vclass)) {
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
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
The information about how to spread the lanes from the given position.
void updateGeometry()
update pre-computed geometry information
const std::vector< GNEAdditional * > & getAdditionalChilds() const
return list of additionals associated with this edge
void remakeGNEConnections()
remake connections
void addConnection(NBEdge::Connection nbCon, GNEConnection *con)
adds a connection
SUMOReal endOffset
This lane's offset to the intersection begin.
A structure which describes a connection between edges or lanes.
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.
const std::vector< T > & getSchemes() const
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
GUIVisualizationTextSettings streetName
SUMOReal getEndOffset() const
Returns the offset to the destination node.
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 drawGL(const GUIVisualizationSettings &s) const
Draws the object.
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.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
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
PositionVector myOrigShape
restore point for undo
int indexOfClosest(const Position &p) const
index of the closest position to p
void setMicrosimID(const std::string &newID)
override to also set lane ids
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
SUMOReal length() const
Returns the length.
void setLaneWidth(int lane, SUMOReal width)
set lane specific width (negative lane implies set for all lanes)
std::set< GUIGlID > getLaneGlIDs()
returns GLIDs of all lanes
void setSpeed(int lane, SUMOReal 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)
Stores the information about how to visualize structures.
int getPriority() const
Returns the priority of the edge.
const std::string & getTypeID() const
get ID of type
The representation of a single edge during network building.
void declareConnectionsAsLoaded()
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
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...
bool hasLaneSpecificSpeed() const
whether lanes differ in speed
bool hasRestrictedLane(SUMOVehicleClass vclass) const
check if edge has a restricted lane
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
void setStreetName(const std::string &name)
sets the street name of this edge
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
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
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
std::vector< GNEEdge * > getGNEIncomingEdges() const
Return incoming GNEEdges.
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)
void clearGNEConnections()
clear current connections
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::vector< GNEConnection * > & getGNEConnections()
returns a reference to the GNEConnection vector
static void drawText(const std::string &text, const Position &pos, const SUMOReal layer, const SUMOReal size, const RGBColor &col=RGBColor::BLACK, const SUMOReal angle=0)
draw Text with given parameters
const std::string & getID() const
Returns the id.
Lane & getLaneStruct(int lane)
An Element wich group additionalSet elements.
bool myWasSplit
whether this edge was created from a split
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
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
bool removeAdditionalGeometrySet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this edge
static OptionsCont & getOptions()
Retrieves the options.
SUMOReal scale
information about a lane's width (temporary, used for a single view)
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this edge
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
SUMOReal speed
The speed allowed on this lane.
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
static void drawFilledCircle(SUMOReal width, int steps=8)
Draws a filled circle around (0,0)
An (internal) definition of a single lane of an edge.
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
std::string getAttribute(SumoXMLAttr key) const
int getIndex() const
returns the index of the lane
void addAdditionalChild(GNEAdditional *additional)
add additional child to this edge
bool hasLaneSpecificWidth() const
whether lanes differ in width
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
SUMOReal z() const
Returns the z-position.
SVCPermissions preferred
List of vehicle types that are preferred on this lane.
int getNumLanes() const
Returns the number of lanes.
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
void add(SUMOReal xoff, SUMOReal yoff, SUMOReal zoff)
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
friend class GNEChange_Attribute
declare friend class
AdditionalVector myAdditionals
list with the additonals vinculated with this edge
SUMOReal getFinalLength() const
get length that will be assigned to the lanes in the final network
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
SUMOReal contPos
custom position for internal junction on this connection
int myPriority
The priority of the edge.
SUMOReal x() const
Returns the x-position.
const std::string & getStreetName() const
Returns the street name of this edge.
SUMOReal length2D() const
Returns the length.
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
int insertAtClosest(const Position &p)
inserts p between the two closest positions and returns the insertion index
void setLoadedLength(SUMOReal val)
set loaded lenght
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
GNEJunction * getGNEJunctionSource() const
returns the source-junction
void incRef(const std::string &debugMsg="")
The connection was given by the user.
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false)
Removes the specified connection(s)
std::string getVehicleClassNames(SVCPermissions permissions)
Returns the ids of the given classes, divided using a ' '.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
virtual GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
void decRef(const std::string &debugMsg="")
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.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
A road/street connecting two junctions (netedit-version)
ConnectionVector myGNEConnections
vector with the connections of this edge
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
GNEJunction * getGNEJunctionDest() const
returns the destination-junction
const PositionVector & getShape() const
returns the shape of the lane
const std::vector< GNELane * > & getLanes()
returns a reference to the lane vector
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.
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.
virtual void setMicrosimID(const std::string &newID)
Changes the microsimID of the object.
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
An Element which don't belongs to GNENet but has influency in the simulation.
bool isClosed() const
check if PositionVector is closed
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
set preferred Vehicle Class
void updateJunctionPosition(GNEJunction *junction, const Position &origPos)
update edge geometry after junction move
void updateGeometry()
update pre-computed geometry information
static const SUMOReal SNAP_RADIUS
void mul(SUMOReal val)
Multiplies both positions with the given value.
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
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
bool isValid(SumoXMLAttr key, const std::string &value)
const Position & getPosition() const
Returns the position of this node.
void removeExplicitTurnaround(std::string id)
remove edge id from the list of explicit turnarounds
GUIGlID getGlID() const
Returns the numerical id of the object.
LaneVector myLanes
vectgor with the lanes of this edge
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
void removeConnection(NBEdge::Connection nbCon)
removes a connection
void setEndOffset(int lane, SUMOReal offset)
set lane specific end-offset (negative lane implies set for all lanes)
static const std::string GUESSED
feature has been reguessed (may still be unchanged be we can't tell (yet)
bool addAdditionalSet(GNEAdditionalSet *additionalSet)
add GNEAdditionalSet to this edge
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
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
AdditionalSetVector myAdditionalSets
list with the additonalSets vinculated with this edge
NBEdge & myNBEdge
the underlying NBEdge
NBNode * getFromNode() const
Returns the origin node of the edge.
bool hasString(const std::string &str) const
NBEdge * getNBEdge()
returns the internal NBEdge
const SUMOReal SUMO_const_halfLaneWidth
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
std::vector< GNEConnection * > ConnectionVector
Definition of the connection's vector.
Boundary getBoundary() const
Returns the street's geometry.
SUMOReal y() const
Returns the y-position.
NBNode * getNBNode() const
Return net build node.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
GUISelectedStorage gSelected
A global holder of selected objects.
void resetEndpoint(const Position &pos, GNEUndoList *undoList)
restores the endpoint to the junction position at the appropriate end
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
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
bool wasSplit()
whether this edge was created from a split
bool setConnection(int lane, NBEdge *destEdge, int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS, SUMOReal visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection to a certain lane of a certain edge.
Position getSplitPos(const Position &clickPos)
NBNode * getToNode() const
Returns the destination node of the edge.
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)
SUMOReal width
This lane's width.
static const SUMOReal INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void remakeIncomingGNEConnections()
remake connections of all incoming edges
SUMOReal visibility
custom foe visiblity for connection