51 #ifdef CHECK_MEMORY_LEAKS 53 #endif // CHECK_MEMORY_LEAKS 69 myOrigShape(nbe.getInnerGeometry()),
72 myAmResponsible(false),
74 myConnectionStatus(loaded ? LOADED : GUESSED) {
77 for (
int i = 0; i < numLanes; i++) {
79 myLanes.back()->incRef(
"GNEEdge::GNEEdge");
85 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
86 (*i)->decRef(
"GNEEdge::~GNEEdge");
87 if ((*i)->unreferenced()) {
100 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
101 ret.
add((*i)->getBoundary());
148 for (LaneVector::const_iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
157 for (
int i = 1; i < (int)geom.size() - 1; i++) {
178 if (angle > 90 && angle < 270) {
184 if (drawStreetName) {
220 if (geom[index].distanceTo(clickPos) <
SNAP_RADIUS) {
245 if (geom.size() < 2) {
246 throw ProcessError(
"Invalid geometry size in edge " +
id);
254 const SUMOReal distance = geom[index].distanceTo2D(nearest);
256 if (moveEndPoints || (index != 0 && index != (
int)geom.size() - 1)) {
257 const bool closed = geom.
isClosed();
259 geom[index] = geom[index] + newPos;
261 geom[index] = newPos;
263 if (closed && moveEndPoints && (index == 0 || index == (
int)geom.size() - 1)) {
264 const int otherIndex = (int)geom.size() - 1 - index;
265 geom[otherIndex] = geom[index];
272 geom[index] = geom[index] + newPos;
288 if (geom.size() == 0) {
291 geom.
add(delta.
x(), delta.
y(), delta.
z());
299 if (geom.size() == 0) {
304 geom.erase(geom.begin() + index);
315 undoList->
p_begin(
"set endpoint");
362 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
363 (*i)->updateGeometry();
370 undoList->
p_begin(
"copy template");
379 for (
unsigned int i = 0; i <
myLanes.size(); i++) {
392 std::set<GUIGlID> result;
393 for (
size_t i = 0; i <
myLanes.size(); i++) {
438 return "lane specific";
444 return "lane specific";
450 return "lane specific";
474 undoList->
p_begin(
"change edge attribute");
477 for (LaneVector::iterator it =
myLanes.begin(); it !=
myLanes.end(); it++) {
478 (*it)->setAttribute(key, value, undoList);
486 undoList->
p_begin(
"change edge attribute");
496 undoList->
p_begin(
"change edge attribute");
553 return isPositive<SUMOReal>(value);
556 return isPositive<int>(value);
559 return canParse<int>(value);
574 value,
"user-supplied position", 0, ok,
true);
588 return canParse<SUMOReal>(value);
612 throw InvalidArgument(
"GNEEdge::setAttribute (private) called for attr SUMO_ATTR_NUMLANES. This should never happen");
675 undoList->
p_begin(
"change number of lanes");
679 const unsigned int oldNumLanes = (
unsigned int)
myLanes.size();
680 for (
unsigned int i = oldNumLanes; i < numLanes; i++) {
685 for (
unsigned int i = oldNumLanes - 1; i > numLanes - 1; i--) {
704 lane =
new GNELane(*
this, index);
707 lane->
incRef(
"GNEEdge::addLane");
715 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
732 lane->
decRef(
"GNEEdge::removeLane");
734 if (
myLanes.back()->unreferenced()) {
738 for (
int i = 0; i < (int)
myLanes.size(); ++i) {
772 for (LaneVector::iterator i =
myLanes.begin(); i !=
myLanes.end(); ++i) {
773 (*i)->setMicrosimID(
getNBEdge()->getLaneID((*i)->getIndex()));
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.
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.
bool myAmResponsible
whether we are responsible for deleting myNBNode
SUMOReal nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
void buildNameCopyPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds entries which allow to copy the name / typed name into the clipboard.
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 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()
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 without registering undo/redo It is up to the Edge to decide whether an new ...
const std::vector< T > & getSchemes() const
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.
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
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)
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
unsigned int getIndex() const
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 addConnection(unsigned int fromLane, const std::string &toEdgeID, unsigned int toLane, bool mayPass)
adds a connection
void setGeometry(const PositionVector &g, bool inner=false)
(Re)sets the edge's geometry
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)
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.
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)
SUMOReal getLoadedLength() const
Returns the length was set explicitly or the computed length if it wasn't set.
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.
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.
A point in 2D or 3D with translation and scaling methods.
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
bool hasLaneSpecificPermissions() const
whether lanes differ in allowed vehicle classes
friend class GNEChange_Attribute
Boundary getBoundary() const
Returns the street's geometry.
unsigned int getNumLanes() const
Returns the number of lanes.
SUMOReal z() const
Returns the z-position.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
int myPriority
The priority of the edge.
NBNode * getNBNode()
returns the internal NBNode
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)
void drawName(const Position &pos, const SUMOReal scale, const GUIVisualizationTextSettings &settings, const SUMOReal angle=0) const
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)
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.
NBEdge * getNBEdge()
returns the internal NBEdge
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.
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
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 (happens in NETEDIT)
static const SUMOReal UNSPECIFIED_LOADED_LENGTH
no length override given
void deleteLane(unsigned int index, bool recompute=true)
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
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.
Lane & getLaneStruct(unsigned int lane)
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
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)
void setEndpoint(Position pos, GNEUndoList *undoList)
makes pos the new geometry endpoint at the appropriate end
NBEdge & myNBEdge
the underlying NBEdge
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
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 setConnection(unsigned int lane, NBEdge *destEdge, unsigned 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.
void addLane(unsigned int index, bool recompute=true)
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
GNEJunction * getSource() const
returns the source-junction
Position getSplitPos(const Position &clickPos)
friend class GNEChange_Lane
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 setNumLanes(unsigned int numLanes, GNEUndoList *undoList)
changes the number of lanes. When reducing the number of lanes, higher-numbered lanes are removed fir...
void removeConnection(unsigned int fromLane, const std::string &toEdgeID, unsigned int toLane)
removes a connection
NBNode * getFromNode() const
Returns the origin node of the edge.