52 const std::string& trafficLight,
const std::string& filename,
const std::vector<std::string>& vehicleTypes,
53 const std::vector<std::string>& nextEdges,
const std::string& detectPersons,
const std::string& name,
const SUMOTime timeThreshold,
54 double speedThreshold,
const double jamThreshold,
const bool friendlyPos,
const bool show,
const Parameterised::Map& parameters) :
58}, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
59myEndPositionOverLane(pos + length),
60myTimeThreshold(timeThreshold),
61mySpeedThreshold(speedThreshold),
62myJamThreshold(jamThreshold),
63myTrafficLight(trafficLight),
69 const std::string& trafficLight,
const std::string& filename,
const std::vector<std::string>& vehicleTypes,
70 const std::vector<std::string>& nextEdges,
const std::string& detectPersons,
const std::string& name,
const SUMOTime timeThreshold,
71 double speedThreshold,
const double jamThreshold,
const bool friendlyPos,
const bool show,
const Parameterised::Map& parameters) :
73 pos, freq, lanes, filename, vehicleTypes, nextEdges, detectPersons, name, friendlyPos, parameters),
74 myEndPositionOverLane(endPos),
75 myTimeThreshold(timeThreshold),
76 mySpeedThreshold(speedThreshold),
77 myJamThreshold(jamThreshold),
78 myTrafficLight(trafficLight),
156 std::string errorFirstLanePosition, separator, errorLastLanePosition;
168 return TL(
"lanes aren't consecutives");
172 return TL(
"lanes aren't connected");
190 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
191 separator =
TL(
" and ");
194 return errorFirstLanePosition + separator + errorLastLanePosition;
212 bool foundConnection =
true;
217 foundConnection =
false;
219 for (
const auto& connection :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
221 foundConnection =
true;
225 if (!foundConnection) {
240 newPositionOverLane,
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength(),
241 newEndPositionOverLane,
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength());
276 drawE2(s, d, E2Exaggeration);
288 E2Exaggeration,
true,
true, 0,
nullptr,
getParentLanes().front()->getParentEdge());
341 drawE2PartialLane(s, d, segment, offsetFront, E2Geometry, E2Exaggeration, movingGeometryPoints);
345 if (movingGeometryPoints) {
350 if (segment->
getFromContour() && E2Geometry.
getShape().front().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
352 }
else if (segment->
getToContour() && E2Geometry.
getShape().back().distanceSquaredTo2D(mousePosition) <= (snap_radius * snap_radius)) {
480 }
else if (
canParse<std::vector<GNELane*> >(
myNet, value,
false)) {
487 return canParse<double>(value);
492 return (canParse<double>(value) && (parse<double>(value) >= 0));
494 return canParse<SUMOTime>(value);
496 return (canParse<double>(value) && (parse<double>(value) >= 0));
498 return (canParse<double>(value) && (parse<double>(value) >= 0));
500 return canParse<bool>(value);
512 const double exaggeration)
const {
535 glTranslated(0, 0, 0.1);
550 const GNESegment* segment,
const double offsetFront,
551 const GUIGeometry& geometry,
const double exaggeration,
const bool movingGeometryPoints)
const {
557 glTranslated(0, 0,
getType() + offsetFront);
563 if (movingGeometryPoints) {
572 if (geometry.
getShape().size() > 1) {
573 glTranslated(0, 0, 0.1);
591 glTranslated(pos.
x(), pos.
y(),
getType() + offsetFront + 0.1);
593 glRotated(rot, 0, 0, 1);
595 glTranslated(-1, 0, 0);
597 glScaled(exaggeration, exaggeration, 1);
609 const bool onlyContour,
const double offsetFront,
const GUIGeometry& geometry,
610 const double exaggeration)
const {
616 glTranslated(0, 0,
getType() + offsetFront);
620 }
else if (invalid) {
669 myShow = parse<bool>(value);
739 endPos += difference;
743 startPos += difference;
749 }
else if (startPos >
getParentLanes().front()->getLaneShapeLength()) {
755 }
else if (endPos >
getParentLanes().back()->getLaneShapeLength()) {
770 const double laneLength =
getParentLanes().front()->getParentEdge()->getNBEdge()->getFinalLength();
775 fixedPos += laneLength;
781 }
else if (fixedPos > (
getParentLanes().front()->getLaneShapeLength() - POSITION_EPS)) {
782 return (
getParentLanes().front()->getLaneShapeLength() - POSITION_EPS);
792 const double laneLength =
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
797 fixedPos += laneLength;
801 if (fixedPos < POSITION_EPS) {
803 }
else if (fixedPos >
getParentLanes().back()->getLaneShapeLength()) {
@ GLO_E2DETECTOR
a E2 detector
GUIViewObjectsHandler gViewObjectsHandler
GUIIcon
An enumeration of icons used by the gui applications.
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ GNE_TAG_MULTI_LANE_AREA_DETECTOR
an e2 detector over multiple lanes (placed here due create Additional Frame)
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_SHOW_DETECTOR
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void drawTriangleAtEnd(const Position &p1, const Position &p2, double tLength, double tWidth, const double extraOffset=0)
Draws a triangle at the end of the given line.
static void popMatrix()
pop matrix
static void pushMatrix()
push matrix
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, const int align=0, double width=-1)
static void fixMultiLanePosition(double fromPos, const double fromLaneLength, double toPos, const double tolaneLength)
fix the given positions over two lanes
static void fixLanePosition(double &pos, double &length, const double laneLength)
fix given position over lane
static bool areLaneConnected(const std::vector< GNELane * > &lanes)
check if the given lanes are connected
void drawRightGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw right geometry point
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
void replaceAdditionalParentLanes(const std::string &value)
replace additional parent lanes
double getExaggeration(const GUIVisualizationSettings &s) const
return exaggeration associated with this GLObject
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
bool drawMovingGeometryPoints(const bool ignoreShift) const
check if draw additional extrem geometry points
static bool areLaneConsecutives(const std::vector< GNELane * > &lanes)
check if the given lanes are consecutive
void drawLeftGeometryPoint(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const Position &pos, const double rot, const RGBColor &baseColor, const bool ignoreShift=false) const
draw left geometry point
void drawParentChildLines(const GUIVisualizationSettings &s, const RGBColor &color, const bool onlySymbols=false) const
draw parent and child lines
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
const std::string getID() const
get ID (all Attribute Carriers have one)
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
const std::string & getTagStr() const
get tag assigned to this object in string format
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
GNENet * myNet
pointer to net
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
const GNETagProperties & myTagProperty
reference to tagProperty associated with this attribute carrier
static void changeAttribute(GNEAttributeCarrier *AC, SumoXMLAttr key, const std::string &value, GNEUndoList *undoList, const bool force=false)
change attribute
void calculateContourExtrudedShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const PositionVector &shape, const double layer, const double extrusionWidth, const double scale, const bool closeFirstExtrem, const bool closeLastExtrem, const double offset, const GNESegment *segment, const GUIGlObject *boundaryParent, const bool addToSelectedObjects=true) const
calculate contour extruded (used in elements formed by a central shape)
void calculateContourCircleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, double radius, const double layer, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (circle elements)
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
bool checkDrawPathContour(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC) const
drawing contour functions
void drawE2DetectorLogo(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration, const std::string &logo, const RGBColor &textColor) const
draw E2 detector Logo
double myPositionOverLane
position of detector over Lane
bool isDetectorValid(SumoXMLAttr key, const std::string &value)
void setDetectorAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
double getDetectorAttributeDouble(SumoXMLAttr key) const
void writeDetectorValues(OutputDevice &device) const
write additional element into a xml file
bool myFriendlyPosition
Flag for friendly position.
std::string getDetectorAttribute(SumoXMLAttr key) const
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
bool exist(const GNELane *toLane) const
check if exist a lane2lane geometry for the given toLane
const GUIGeometry & getLane2laneGeometry(const GNELane *toLane) const
get lane2lane geometry
void writeAdditional(OutputDevice &device) const
write additional element into a xml file
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
void updateGeometry()
update pre-computed geometry information
double getAttributeDouble(SumoXMLAttr key) const
void fixAdditionalProblem()
fix additional problem
std::string getAttribute(SumoXMLAttr key) const
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
~GNELaneAreaDetector()
Destructor.
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool myShow
show or hidde detector in sumo-gui
bool isAdditionalValid() const
check if current additional is valid to be written into XML
void drawE2PartialLane(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNESegment *segment, const double offsetFront, const GUIGeometry &geometry, const double exaggeration, const bool movingGeometryPoints) const
draw E2 partial lane
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
void drawJunctionPartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over junction.
void drawLanePartialGL(const GUIVisualizationSettings &s, const GNESegment *segment, const double offsetFront) const
Draws partial object over lane.
void drawE2(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const double exaggeration) const
draw E2 detector
GNELaneAreaDetector(SumoXMLTag tag, GNENet *net)
default Constructor
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
std::string getAdditionalProblem() const
return a string with the current additional problem
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their correspondent attribute are valids
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
void computePathElement()
compute pathElement
void drawE2PartialJunction(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const bool onlyContour, const double offsetFront, const GUIGeometry &geometry, const double exaggeration) const
draw E2 partial junction
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
const PositionVector & getLaneShape() const
get elements shape
const GNELane2laneConnection & getLane2laneConnections() const
get Lane2laneConnection struct
const GUIGeometry & getLaneGeometry() const
get lane geometry
GNEEdge * getParentEdge() const
get parent edge
double myMoveElementLateralOffset
move element lateral offset (used by elements placed over lanes
@ MULTIPLE_LANES_MOVE_BOTH_LAST
@ MULTIPLE_LANES_MOVE_FIRST
@ MULTIPLE_LANES_MOVE_BOTH_FIRST
@ MULTIPLE_LANES_MOVE_LAST
double newFirstPos
new first position
const GNEMoveOperation::OperationType operationType
move operation
A NBNetBuilder extended by visualisation and editing capabilities.
GNEPathManager * getNetworkPathManager()
get network path manager
GNEViewNet * getViewNet() const
get view net
void calculateConsecutivePathLanes(GNEPathElement *pathElement, const std::vector< GNELane * > &lanes)
calculate consecutive path lanes
const GNELane * getLane() const
get lane associated with this segment
const GNEJunction * getJunction() const
get junction associated with this segment
const GNELane * getNextLane() const
get next lane
const GNELane * getPreviousLane() const
get previous lane
GNEContour * getFromContour() const
get from contour associated with segment (only if this is the first path segment)
bool isFirstSegment() const
check if segment is the first path's segment
GNEContour * getContour() const
bool isLastSegment() const
check if segment is the last path's segment
bool isLabelSegment() const
check if segment is label segment
GNEContour * getToContour() const
get to contour associated with segment (only if this is the last path segment)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
const std::string & getDefaultValue(SumoXMLAttr attr) const
return the default value of the attribute of an element
void end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
void begin(GUIIcon icon, const std::string &description)
Begin undo command sub-group with current supermode. This begins a new group of commands that are tre...
void add(GNEChange *command, bool doit=false, bool merge=true)
Add new command, executing it if desired. The new command will be merged with the previous command if...
const GNEViewNetHelper::DataViewOptions & getDataViewOptions() const
get data view options
const GNEViewNetHelper::EditModes & getEditModes() const
get edit modes
const GNEViewNetHelper::NetworkViewOptions & getNetworkViewOptions() const
get network view options
GNEUndoList * getUndoList() const
get the undoList object
bool selectingDetectorsTLSMode() const
check if we're selecting detectors in TLS mode
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0, bool forceShow=false) const
draw name of item
const GUIVisualizationSettings & getVisualisationSettings() const
get visualization settings (read only)
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
void addToRedrawPathElements(const GNEPathElement *pathElement)
add path element to redrawing set
bool isPathElementMarkForRedraw(const GNEPathElement *pathElement) const
check if the given path element has to be redraw again
Stores the information about how to visualize structures.
GUIVisualizationTextSettings addName
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
double scale
information about a lane's width (temporary, used for a single view)
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
GUIVisualizationDetectorSettings detectorSettings
Detector settings.
double getTextAngle(double objectAngle) const
return an angle that is suitable for reading text aligned with the given angle (degrees)
GUIVisualizationNeteditSizeSettings neteditSizeSettings
netedit size settings
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::map< std::string, std::string > Map
parameters map
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
A point in 2D or 3D with translation and scaling methods.
static const Position INVALID
used to indicate that a position is valid
double x() const
Returns the x-position.
double y() const
Returns the y-position.
double length2D() const
Returns the length.
double length() const
Returns the length.
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position getCentroid() const
Returns the centroid (closes the polygon if unclosed)
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
static const RGBColor BLACK
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
static const RGBColor RED
named colors
static bool isValidNetID(const std::string &value)
whether the given string is a valid id for a network element
bool showAdditionals() const
check if additionals has to be drawn
bool isCurrentSupermodeNetwork() const
@check if current supermode is Network
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
bool showConnections() const
check if select show connections checkbox is enabled
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const RGBColor E2Color
color for E2 detectors
static const double E2Width
E2 detector widths.
static const double segmentWidthSmall
width of small dotted contour segments
static const double segmentWidth
width of dotted contour segments
static const double additionalGeometryPointRadius
moving additional geometry point radius
A structure which describes a connection between edges or lanes.