42 const std::string& name,
const double timeThreshold,
double speedThreshold,
double jamThreshold,
bool friendlyPos,
bool blockMovement) :
43 GNEDetector(id, viewNet,
GLO_E2DETECTOR,
SUMO_TAG_E2DETECTOR, pos, freq, filename, vehicleTypes, name, friendlyPos, blockMovement),
54 GNEDetectorE2::GNEDetectorE2(
const std::string&
id, std::vector<GNELane*> lanes,
GNEViewNet* viewNet,
double pos,
double endPos,
double freq,
const std::string& filename,
const std::string& vehicleTypes,
55 const std::string& name,
const double 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),
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;
157 while (i < ((
int)
myLanes.size()-1)) {
159 foundConnection =
false;
161 for (
auto j :
myLanes.at(i)->getParentEdge().getGNEConnections()) {
162 if(j->getLaneFrom() ==
myLanes.at(i) && j->getLaneTo() ==
myLanes.at(i+1)) {
163 foundConnection =
true;
167 if(!foundConnection) {
198 newPosition.
add(offset);
210 if((newStartPosition >= 0) && (newStartPosition <=
myLanes.front()->getLaneShapeLength()) &&
211 (newEndPosition >= 0) && (newEndPosition <=
myLanes.back()->getLaneShapeLength())) {
249 double startPosFixed, endPosFixed;
260 startPosFixed =
myLanes.back()->getParentEdge().getNBEdge()->getFinalLength();
269 endPosFixed =
myLanes.back()->getParentEdge().getNBEdge()->getFinalLength();
283 }
else if (
myLanes.size() > 1) {
291 startPosFixed =
myLanes.front()->getParentEdge().getNBEdge()->getFinalLength();
305 endPosFixed =
myLanes.back()->getParentEdge().getNBEdge()->getFinalLength();
311 lastShape = lastShape.
getSubpart(0, endPosFixed *
myLanes.back()->getLengthGeometryFactor());
315 for (
auto j :
myLanes.at(0)->getParentEdge().getGNEConnections()) {
316 if (j->getLaneTo() ==
myLanes.at(1)) {
322 for (
int i = 1; i < ((int)
myLanes.size() - 1); i++) {
328 for (
auto j :
myLanes.at(i)->getParentEdge().getGNEConnections()) {
329 if (j->getLaneTo() ==
myLanes.at(i+1)) {
380 for (
auto j :
myLanes.at(i)->getParentEdge().getGNEConnections()) {
381 if(j->getLaneFrom() ==
myLanes.at(i) && j->getLaneTo() ==
myLanes.at(i+1)) {
451 glTranslated(-0.75, 0, 0);
466 glTranslated(-1.5, 0, 0);
474 glTranslated(1.2, 0, 0);
476 glRotated(90, 0, 0, 1);
589 return canParse<std::vector<GNELane*> >(
myViewNet->
getNet(), value,
false);
601 return canParse<double>(value);
603 return canParse<double>(value);
605 return (canParse<double>(value) && (parse<double>(value) >= 0));
607 return (canParse<double>(value) && (parse<double>(value) >= 0));
619 return (canParse<double>(value) && (parse<double>(value) >= 0));
621 return (canParse<double>(value) && (parse<double>(value) >= 0));
623 return (canParse<double>(value) && (parse<double>(value) >= 0));
625 return canParse<bool>(value);
627 return canParse<bool>(value);
629 return canParse<bool>(value);
659 myFreq = parse<double>(value);
689 if (parse<bool>(value)) {
const TagProperties & myTagProperty
the xml tag to which this attribute carrier corresponds
A structure which describes a connection between edges or lanes.
double scale
information about a lane's width (temporary, used for a single view)
PositionVector multiShapeUnified
multi shape unified
void calculateMultiShapeRotationsAndLengths()
calculate multi shape rotations and lenghts
static bool checkAndFixDetectorPosition(double &pos, const double laneLength, const bool friendlyPos)
check if the position of a detector over a lane is valid
static bool isValidAttribute(const std::string &value)
whether the given string is a valid attribute for a certain key (for example, a name) ...
static void drawBoxLines(const PositionVector &geom, const std::vector< double > &rots, const std::vector< double > &lengths, double width, int cornerDetail=0, double offset=0)
Draws thick lines.
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) ...
GUIVisualizationTextSettings addName
std::vector< double > shapeRotations
The rotations of the single shape parts.
GNELane * getLane() const
get lane
void add(const Position &pos)
Adds the given position to this one.
void setGenericParametersStr(const std::string &value)
set generic parameters in string format
void commitGeometryMoving(GNEUndoList *undoList)
commit geometry changes in the attributes of an element after use of moveGeometry(...)
const std::string & getAdditionalID() const
returns Additional ID
std::string secondOriginalPosition
value for saving second original position over lane before moving
an e2 detector over multiple lanes (used by Netedit)
Stores the information about how to visualize structures.
Position offset
The offSet of the block icon.
double y() const
Returns the y-position.
Position snapToActiveGrid(const Position &pos) const
Returns a position that is mapped to the closest grid point if the grid is active.
std::vector< GNELane * > myLanes
E2 lanes (Single lanes uses only the first lane)
static std::string parseIDs(const std::vector< T > &ACs)
parses a list of specific Attribute Carriers into a string of IDs
double x() const
Returns the x-position.
double myFreq
The aggregation period the values the detector collects shall be summed up.
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)
void unselectAttributeCarrier(bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
Position position
position of the block icon
BlockIcon myBlockIcon
variable BlockIcon
void clearGeometry()
reset geometry
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes ...
Position originalViewPosition
value for saving first original position over lane before moving
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...
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
static const RGBColor BLACK
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
void changeAdditionalID(const std::string &newID)
change ID of additional
Position getLineCenter() const
get line center
double rotation
The rotation of the block icon.
bool isValidDetectorID(const std::string &newID) const
check if a new detector ID is valid
static const RGBColor SUMO_color_E2
color for E2 detectors
~GNEDetectorE2()
Destructor.
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
std::vector< std::vector< double > > multiShapeRotations
The rotations of the multi-shape parts.
GNEViewNet * myViewNet
The GNEViewNet this additional element belongs.
AdditionalMove myMove
variable AdditionalMove
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting...
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
GUIVisualizationSizeSettings addSize
GNEUndoList * getUndoList() const
get the undoList object
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
SumoXMLTag getTag() const
get Tag vinculated with this attribute Property
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
void moveGeometry(const Position &offset)
change the position of the element geometry without saving in undoList
void updateGeometry(bool updateGrid)
update pre-computed geometry information
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.
PositionVector shape
The shape of the additional element.
static bool lanesConsecutives(const std::vector< GNELane *> &lanes)
check if lanes are consecutives
std::string myAdditionalName
name of additional
static bool isGenericParametersValid(const std::string &value)
check if given string can be parsed to a map/list of generic parameters
void removeGLObjectFromGrid(GUIGlObject *o)
add GL Object into net
bool isAdditionalValid() const
check if current additional is valid to be writed into XML (by default true, can be reimplemented in ...
void checkE2MultilaneIntegrity()
check if E2 is valid (all of their lanes are connected, it must called after every operation which in...
friend class GNEChange_Attribute
declare friend class
void selectAttributeCarrier(bool changeFlag=true)
block movement of a graphic element
RGBColor selectionColor
NETEDIT special colors.
std::string myVehicleTypes
attribute vehicle types
std::vector< std::vector< double > > multiShapeLengths
The lengths of the multi-shape shape parts.
bool myE2valid
flag to check if E2 multilane is valid or invalid
void drawName(const Position &pos, const double scale, const GUIVisualizationTextSettings &settings, const double angle=0) const
draw name of item
double myLength
E2 detector length.
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
std::vector< PositionVector > multiShape
The multi-shape of the additional element (used by certain additionals)
GNEDetectorE2(const std::string &id, GNELane *lane, GNEViewNet *viewNet, double pos, double length, double freq, const std::string &filename, const std::string &vehicleTypes, const std::string &name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement)
Constructor for Single-Lane E2 detectors.
void fixAdditionalProblem()
fix additional problem
bool myFriendlyPosition
Flag for friendly position.
RGBColor selectedAdditionalColor
std::string myFilename
The path to the output file.
bool myBlockMovement
boolean to check if additional element is blocked (i.e. cannot be moved with mouse) ...
void calculateShapeRotationsAndLengths()
calculate shape rotations and lenghts
std::string getAttribute(SumoXMLAttr key) const
std::vector< double > shapeLengths
The lengths of the single shape parts.
double getLength() const
get length of E2 Detector
static bool canParse(const std::string &string)
true if a value of type T can be parsed from string
static const RGBColor RED
named colors
static void drawShapeDottedContour(const int type, const PositionVector &shape, const double width)
draw a dotted contour around the given Non closed shape with certain width
const GNEAttributeCarrier * getDottedAC() const
get AttributeCarrier under cursor
AdditionalGeometry myGeometry
geometry to be precomputed in updateGeometry(...)
bool showConnections()
show connections over junctions
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
const std::string & getTagStr() const
get tag assigned to this object in string format
std::string getGenericParametersStr() const
return generic parameters in string format
GNENet * getNet() const
get the net object
GUIGlID getGlID() const
Returns the numerical id of the object.
double myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
std::string firstOriginalLanePosition
value for saving first original position over lane before moving
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
std::string getAdditionalProblem() const
return a string with the current additional problem
bool drawForSelecting
whether drawing is performed for the purpose of selecting objects
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values
void addGLObjectIntoGrid(GUIGlObject *o)
add GL Object into net
static bool isValidFilename(const std::string &value)
whether the given string is a valid attribute for a filename (for example, a name) ...
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
static T parse(const std::string &string)
parses a value of type T from string (used for basic types: int, double, bool, etc.)
void setRotation(GNELane *additionalLane=nullptr)
set Rotation of block Icon (must be called in updateGeometry(bool updateGrid) function) ...
double myPositionOverLane
position of detector over Lane
void draw(double size=0.5) const
draw lock icon
void calculateMultiShapeUnified()
calculate multi shape unified