54 #ifdef CHECK_MEMORY_LEAKS 56 #endif // CHECK_MEMORY_LEAKS 71 myOrigShape(nbe.getInnerGeometry()),
73 myAmResponsible(false),
75 myConnectionStatus(loaded ? LOADED : GUESSED) {
79 for (
int i = 0; i < numLanes; i++) {
81 myLanes.back()->incRef(
"GNEEdge::GNEEdge");
87 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
88 (*i)->decRef(
"GNEEdge::~GNEEdge");
89 if ((*i)->unreferenced()) {
98 (*i)->removeEdgeReference();
110 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
111 ret.
add((*i)->getBoundary());
157 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
166 for (
int i = 1; i < (int)geom.size() - 1; i++) {
187 if (angle > 90 && angle < 270) {
193 if (drawStreetName) {
234 if (geom[index].distanceTo(clickPos) <
SNAP_RADIUS) {
259 if (geom.size() < 2) {
260 throw ProcessError(
"Invalid geometry size in edge " +
id);
268 const SUMOReal distance = geom[index].distanceTo2D(nearest);
270 if (moveEndPoints || (index != 0 && index != (
int)geom.size() - 1)) {
271 const bool closed = geom.
isClosed();
273 geom[index] = geom[index] + newPos;
275 geom[index] = newPos;
277 if (closed && moveEndPoints && (index == 0 || index == (
int)geom.size() - 1)) {
278 const int otherIndex = (int)geom.size() - 1 - index;
279 geom[otherIndex] = geom[index];
286 geom[index] = geom[index] + newPos;
302 if (geom.size() == 0) {
305 geom.
add(delta.
x(), delta.
y(), delta.
z());
313 if (geom.size() == 0) {
318 geom.erase(geom.begin() + index);
329 undoList->
p_begin(
"set endpoint");
377 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
378 (*i)->updateGeometry();
382 (*i)->updateGeometry();
386 (*i)->updateGeometry();
393 undoList->
p_begin(
"copy template");
402 for (
int i = 0; i < (int)
myLanes.size(); i++) {
415 std::set<GUIGlID> result;
416 for (
size_t i = 0; i <
myLanes.size(); i++) {
423 const std::vector<GNELane*>&
473 return "lane specific";
479 return "lane specific";
485 return "lane specific";
509 undoList->
p_begin(
"change edge attribute");
512 for (LaneVector::iterator it =
myLanes.begin(); it !=
myLanes.end(); it++) {
513 (*it)->setAttribute(key, value, undoList);
521 undoList->
p_begin(
"change edge attribute");
531 undoList->
p_begin(
"change edge attribute");
588 return isPositive<SUMOReal>(value);
591 return isPositive<int>(value);
594 return canParse<int>(value);
609 value,
"user-supplied position", 0, ok,
true);
620 return canParse<SUMOReal>(value) && (isPositive<SUMOReal>(value) || parse<SUMOReal>(value) ==
NBEdge::UNSPECIFIED_WIDTH);
623 return canParse<SUMOReal>(value);
652 throw InvalidArgument(
"GNEEdge::setAttribute (private) called for attr SUMO_ATTR_NUMLANES. This should never happen");
715 undoList->
p_begin(
"change number of lanes");
719 const int oldNumLanes = (int)
myLanes.size();
720 for (
int i = oldNumLanes; i < numLanes; i++) {
725 for (
int i = oldNumLanes - 1; i > numLanes - 1; i--) {
744 lane =
new GNELane(*
this, index);
747 lane->
incRef(
"GNEEdge::addLane");
755 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
769 throw ProcessError(
"Should not remove the last lane from an edge\n");
775 lane->
decRef(
"GNEEdge::removeLane");
781 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
814 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
815 (*i)->setMicrosimID(
getNBEdge()->getLaneID((*i)->getIndex()));
824 if ((*i) == additional) {
838 if ((*i) == additional) {
848 const std::vector<GNEAdditional*>&
858 if ((*i) == additionalSet) {
872 if ((*i) == additionalSet) {
882 const std::vector<GNEAdditionalSet*>&
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)
The information about how to spread the lanes from the given position.
const std::string & getTypeID() const
SUMOReal endOffset
This lane's offset to the intersection begin.
void setNumLanes(int numLanes, GNEUndoList *undoList)
changes the number of lanes. When reducing the number of lanes, higher-numbered lanes are removed fir...
GNEEdge * retrieveEdge(const std::string &id, bool failHard=true)
get edge by id
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
GUIVisualizationTextSettings streetName
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
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
void addConnection(int fromLane, const std::string &toEdgeID, int toLane, bool mayPass)
adds a connection
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
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
bool setConnection(int lane, NBEdge *destEdge, int destLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS)
Adds a connection to a certain lane of a certain edge.
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
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)
void setLogicValid(bool valid, GNEUndoList *undoList=0, const std::string &status=GUESSED)
Stores the information about how to visualize structures.
The representation of a single edge during network building.
void declareConnectionsAsLoaded()
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
NBNode * getNBNode() const
Return net build node.
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.
std::string getAttribute(SumoXMLAttr key) const
SUMOReal getLaneWidth() const
Returns the default width of lanes of this edge.
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 ...
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
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...
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
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
bool addAdditional(GNEAdditional *additional)
add additional to this edge
const std::vector< GNEAdditional * > & getAdditionals() const
return list of additionals associated with this edge
Lane & getLaneStruct(int lane)
An Element wich group additionalSet elements.
bool isClosed() const
check if PositionVector is closed
bool myWasSplit
whether this edge was created from a split
SUMOReal x() const
Returns the x-position.
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.
Position positionAtOffset2D(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
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)
A class that stores a 2D geometrical boundary.
static OptionsCont & getOptions()
Retrieves the options.
SUMOReal scale
information about a lane's width (temporary, used for a single view)
bool removeAdditional(GNEAdditional *additional)
remove additional from this edge
const std::vector< GNEAdditionalSet * > & getAdditionalSets()
return list of additionalSets associated with this edge
virtual GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
SUMOReal speed
The speed allowed on this lane.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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.
const std::string & getID() const
Returns the id.
SUMOReal length2D() const
Returns the length.
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)
static const std::string MODIFIED
feature has been manually modified (implies approval)
const PositionVector getInnerGeometry() const
Returns the geometry of the edge without the endpoints.
const Position & getPosition() const
Returns the position of this node.
bool hasLaneSpecificSpeed() const
whether lanes differ in speed
int getPriority() const
Returns the priority of the edge.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
SVCPermissions preferred
List of vehicle types that are preferred on this lane.
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)
GNEJunction * retrieveJunction(const std::string &id, bool failHard=true)
get junction by id
void add(SUMOReal xoff, SUMOReal yoff, SUMOReal zoff)
int indexOfClosest(const Position &p) const
index of the closest position to p
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
friend class GNEChange_Attribute
declare friend class
AdditionalVector myAdditionals
vector with the additonals vinculated with this edge
Boundary getBoundary() const
Returns the street's geometry.
SUMOReal z() const
Returns the z-position.
int getNumLanes() const
Returns the number of lanes.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given 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.
GUIColorer junctionColorer
The junction colorer.
int insertAtClosest(const Position &p)
inserts p between the two closest positions and returns the insertion index
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
draw name of item
void setLoadedLength(SUMOReal val)
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
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 ' '.
void removeLane(GNELane *lane)
the number of lanes by one. argument is only used to increase robustness (assertions) ...
SUMOReal getEndOffset() const
Returns the offset to the destination node.
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.
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
SUMOReal length() const
Returns the length.
SUMOReal rotationDegreeAtOffset(SUMOReal pos) const
Returns the rotation at the given length.
void add(SUMOReal x, SUMOReal y)
Makes the boundary include the given coordinate.
void setResponsible(bool newVal)
set responsibility for deleting internal strctures
Boundary & grow(SUMOReal by)
extends the boundary by the given amount
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
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.
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.
void setPreferredVehicleClass(SVCPermissions permissions, int lane=-1)
const PositionVector & getGeometry() const
Returns the geometry of the edge.
SUMOReal y() const
Returns the y-position.
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.
GNEJunction * getDest() const
returns the destination-junction
void renameEdge(GNEEdge *edge, const std::string &newID)
updates the map and reserves new id
bool isValid(SumoXMLAttr key, const std::string &value)
void updateLaneGeometries()
update edge geometry and inform the lanes let the lanes recompute their precomputed geometry informat...
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
List of this edges lanes.
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
bool removeAdditionalSet(GNEAdditionalSet *additionalSet)
remove GNEAdditionalSet from this edge
bool hasLaneSpecificWidth() const
whether lanes differ in width
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
void removeConnection(int fromLane, const std::string &toEdgeID, int toLane)
removes a connection
AdditionalSetVector myAdditionalSets
vector with the additonalSets vinculated with this edge
NBEdge & myNBEdge
the underlying NBEdge
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
SUMOReal getFinalLength() const
length that will be assigned to the lanes in the final network
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
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
const std::string & getStreetName() const
Returns the street name of this edge.
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
GNEJunction * getSource() const
returns the source-junction
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)
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.
NBNode * getFromNode() const
Returns the origin node of the edge.