 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
41 const std::string& name,
SUMOTime timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
bool blockMovement) :
42 GNEDetector(id, viewNet,
GLO_E2DETECTOR,
SUMO_TAG_E2DETECTOR, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, {
46 myEndPositionOverLane(0.),
47 myTimeThreshold(timeThreshold),
48 mySpeedThreshold(speedThreshold),
49 myJamThreshold(jamThreshold),
55 const std::string& name,
SUMOTime timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
bool blockMovement) :
56 GNEDetector(id, viewNet,
GLO_E2DETECTOR,
SUMO_TAG_E2DETECTOR_MULTILANE, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement, lanes),
58 myEndPositionOverLane(endPos),
59 myTimeThreshold(timeThreshold),
60 mySpeedThreshold(speedThreshold),
61 myJamThreshold(jamThreshold),
99 std::string errorFirstLanePosition, separator, errorLastLanePosition;
128 errorFirstLanePosition =
"lanes aren't consecutives";
132 if ((errorFirstLanePosition.size() > 0) && (errorLastLanePosition.size() > 0)) {
136 return errorFirstLanePosition + separator + errorLastLanePosition;
154 bool foundConnection =
true;
159 foundConnection =
false;
161 for (
auto j :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
163 foundConnection =
true;
167 if (!foundConnection) {
198 newPosition.
add(offset);
208 if (newPositionOverLane < 0) {
210 }
else if (newPositionOverLane +
myLength > laneLength) {
220 if ((newStartPosition >= 0) && (newStartPosition <=
getParentLanes().front()->getLaneShapeLength()) &&
221 (newEndPosition >= 0) && (newEndPosition <=
getParentLanes().back()->getLaneShapeLength())) {
251 double startPosFixed, endPosFixed;
260 startPosFixed =
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
269 endPosFixed =
getParentLanes().back()->getParentEdge()->getNBEdge()->getFinalLength();
315 for (
auto j :
getParentLanes().at(i)->getParentEdge()->getGNEConnections()) {
377 glTranslated(-0.75, 0, 0);
379 glScaled(exaggeration, exaggeration, 1);
394 glTranslated(-1.5, 0, 0);
396 glScaled(exaggeration, exaggeration, 1);
404 glTranslated(1.2, 0, 0);
406 glRotated(90, 0, 0, 1);
520 return canParse<std::vector<GNELane*> >(
myViewNet->
getNet(), value,
false);
532 return canParse<double>(value);
534 return canParse<double>(value);
536 return (canParse<double>(value) && (parse<double>(value) >= 0));
538 return (canParse<double>(value) && (parse<double>(value) >= 0));
550 return canParse<SUMOTime>(value);
552 return (canParse<double>(value) && (parse<double>(value) >= 0));
554 return (canParse<double>(value) && (parse<double>(value) >= 0));
556 return canParse<bool>(value);
558 return canParse<bool>(value);
560 return canParse<bool>(value);
596 myFreq = parse<SUMOTime>(value);
626 if (parse<bool>(value)) {
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name)
static bool fixE2DetectorPosition(double &pos, double &length, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
Position position
position of the block icon
void checkE2MultilaneIntegrity()
check if E2 is valid (all of their lanes are connected, it must called after every operation which in...
std::string getParametersStr() const
Returns the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN".
const std::string & getAdditionalID() const
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
double myLength
E2 detector length.
void updateGeometryShape(const PositionVector &shape, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
update geometry shape
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name)
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry() function)
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
std::string getAttribute(SumoXMLAttr key) const
static const RGBColor BLACK
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise,...
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
static const RGBColor E2
color for E2 detectors
Position getPositionInView() const
Returns position of additional in view.
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
void fixAdditionalProblem()
fix additional problem
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(....
void changeAdditionalID(const std::string &newID)
change ID of additional
double myPositionOverLane
position of detector over Lane
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
std::string secondOriginalPosition
value for saving second original position over lane before moving
BlockIcon myBlockIcon
variable BlockIcon
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
bool myFriendlyPosition
Flag for friendly position.
Position snapToActiveGrid(const Position &pos, bool snapXY=true) const
Returns a position that is mapped to the closest grid point if the grid is active.
static const double detectorDetails
details for detectors
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
AdditionalMove myMove
variable AdditionalMove
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
friend class GNEChange_Attribute
declare friend class
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
GNENet * getNet() const
get the net object
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
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, int align=0, double width=-1)
GUIVisualizationTextSettings addName
double getLength() const
get length of E2 Detector
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
GUIVisualizationDetailSettings detailSettings
detail settings
std::string myVehicleTypes
attribute vehicle types
static bool lanesConsecutives(const std::vector< GNELane * > &lanes)
check if lanes are consecutives
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry()
update pre-computed geometry information
bool myE2valid
flag to check if E2 multilane is valid or invalid
void selectAttributeCarrier(bool changeFlag=true)
double getLengthGeometryFactor() const
get length geometry factor
GUIGlID getGlID() const
Returns the numerical id of the object.
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
void replaceParentLanes(GNEShape *elementChild, const std::string &newLaneIDs)
replace the parent edges of a shape
parameters "key1=value1|key2=value2|...|keyN=valueN"
static void drawGeometry(const GNEViewNet *viewNet, const Geometry &geometry, const double width)
draw geometry
bool isAttributeEnabled(SumoXMLAttr key) const
double scale
information about a lane's width (temporary, used for a single view)
GNELane * getLane() const
get lane
A point in 2D or 3D with translation and scaling methods.
double x() const
Returns the x-position.
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
std::string time2string(SUMOTime t)
GNEUndoList * getUndoList() const
get the undoList object
GNEGeometry::Geometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
std::string myAdditionalName
name of additional
static const RGBColor RED
named colors
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse)
double rotation
The rotation of the block icon.
static void drawShapeDottedContourAroundShape(const GUIVisualizationSettings &s, const int type, const PositionVector &shape, const double width)
draw a dotted contour around the given Non closed shape with certain width
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
an e2 detector over multiple lanes (used by Netedit)
GUIVisualizationColorSettings colorSettings
color settings
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc....
RGBColor selectionColor
basic selection color
void setParametersStr(const std::string ¶msString)
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void drawIcon(const GUIVisualizationSettings &s, const double exaggeration, const double size=0.5) const
draw lock icon
double y() const
Returns the y-position.
static bool areParametersValid(const std::string &value, bool report=false)
check if given string can be parsed to a parameters map "key1=value1|key2=value2|....
block movement of a graphic element
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
std::string myFilename
The path to the output file.
bool drawAdditionals(const double exaggeration) const
check if additionals must be drawn
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
std::string getAdditionalProblem() const
return a string with the current additional problem
static void calculateLaneGeometricPath(const GNEAttributeCarrier *AC, GNEGeometry::SegmentGeometry &segmentGeometry, const std::vector< GNELane * > &lanes, double startPos=-1, double endPos=-1, const Position &extraFirstPosition=Position::INVALID, const Position &extraLastPosition=Position::INVALID)
calculate route between lanes
SUMOTime myFreq
The aggregation period the values the detector collects shall be summed up.
GUIVisualizationSizeSettings addSize
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
void add(const Position &pos)
Adds the given position to this one.
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
const std::string & getTagStr() const
get tag assigned to this object in string format
static bool isValidListOfTypeID(const std::string &value)
whether the given string is a valid list of ids for an edge or vehicle type (empty aren't allowed)
Stores the information about how to visualize structures.
Position getLineCenter() const
get line center
~GNEDetectorE2()
Destructor.
GNEGeometry::SegmentGeometry mySegmentGeometry
segment geometry to be precomputed in updateGeometry(...) (used by E2Multilane)
A structure which describes a connection between edges or lanes.
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.
Position originalViewPosition
value for saving first original position over lane before moving
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
Position offset
The offSet of the block icon.
GNEDetectorE2(const std::string &id, GNELane *lane, GNEViewNet *viewNet, double pos, double length, SUMOTime freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement)
Constructor for Single-Lane E2 detectors.