27#define CIRCLE_RESOLUTION (double)10
50 const std::vector<double>& shapeLengths) :
52 myShapeRotations(shapeRotations),
53 myShapeLengths(shapeLengths) {
70 const double lateralOffset) {
74 const double shapeLength = shape.
length();
76 if (posOverShape < 0) {
79 }
else if (posOverShape > shapeLength) {
91 double endPosOverShape,
const double lateralOffset) {
101 if (starPosOverShape < 0) {
105 if (starPosOverShape < 0) {
106 endPosOverShape = shapeLength;
109 if (starPosOverShape > (shapeLength - POSITION_EPS)) {
110 endPosOverShape = (shapeLength - POSITION_EPS);
113 if ((endPosOverShape > shapeLength)) {
114 endPosOverShape = shapeLength;
117 if (endPosOverShape <= starPosOverShape) {
118 endPosOverShape = endPosOverShape + POSITION_EPS;
135 if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
139 if (beginTrimPosition < 0) {
140 beginTrimPosition = 0;
143 if (endTrimPosition < 0) {
144 endTrimPosition = shapeLength;
147 if (beginTrimPosition > (shapeLength - POSITION_EPS)) {
148 beginTrimPosition = (shapeLength - POSITION_EPS);
151 if ((endTrimPosition > shapeLength)) {
152 endTrimPosition = shapeLength;
155 if (endTrimPosition <= beginTrimPosition) {
156 endTrimPosition = endTrimPosition + POSITION_EPS;
196 shapeLength *= scale;
207const std::vector<double>&
213const std::vector<double>&
222 return ((
double)atan2((second.
x() - first.
x()), (first.
y() - second.
y())) * (
double) 180.0 / (
double)
M_PI);
237 if ((startLaneShape.size() > 0) &&
238 (endLaneShape.size() > 0) &&
239 (startLaneShape == endLaneShape) &&
242 if (startPos >= endPos) {
243 endPos = (startPos + POSITION_EPS);
247 if ((startPos != -1) && (startLaneShape.size() > 0)) {
248 if (startPos < POSITION_EPS) {
249 startPos = POSITION_EPS;
251 if (startPos > (startLaneShape.
length() - POSITION_EPS)) {
252 startPos = (startLaneShape.
length() - POSITION_EPS);
256 if ((endPos != -1) && (endLaneShape.size() > 0)) {
257 if (endPos < POSITION_EPS) {
258 endPos = POSITION_EPS;
260 if (endPos > (endLaneShape.
length() - POSITION_EPS)) {
261 endPos = (endLaneShape.
length() - POSITION_EPS);
269 const GUIGeometry& geometry,
const double width,
double offset) {
279 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
285 }
else if (s.
scale * width < 1) {
323 const RGBColor& geometryPointColor,
const RGBColor& textColor,
const double radius,
const double exaggeration,
324 const bool editingElevation,
const bool drawExtremeSymbols) {
326 const double exaggeratedRadio = (radius * exaggeration);
328 const double exaggeratedRadioSquared = (exaggeratedRadio * exaggeratedRadio);
330 for (
const auto& vertex : shape) {
336 glTranslated(vertex.x(), vertex.y(), 0.2);
348 if (editingElevation) {
355 }
else if ((vertex == shape.front()) && drawDetail && drawExtremeSymbols) {
362 }
else if ((vertex == shape.back()) && (shape.
isClosed() ==
false) && drawDetail && drawExtremeSymbols) {
378 const RGBColor& hintColor,
const double radius,
const double exaggeration) {
380 const double exaggeratedRadio = (radius * exaggeration);
382 const double distanceToShape = shape.
distance2D(mousePos);
384 const double squaredRadius = (radius * radius * exaggeration);
388 for (
int i = 0; i < (int)shape.size(); i++) {
390 if (shape[i].distanceSquaredTo2D(mousePos) <= squaredRadius) {
395 if ((distanceToShape < exaggeratedRadio) && (index == -1)) {
399 const Position hintPos = shape.size() > 1 ? positionOverLane : shape[0];
403 glTranslated(hintPos.
x(), hintPos.
y(), 0.2);
416 const std::vector<double>& rotations,
const std::vector<double>& lengths,
const std::vector<RGBColor>& colors,
417 double width,
const bool onlyContour,
const double offset) {
442 glTranslated(posOverLane.
x(), posOverLane.
y(), 0);
448 }
else if (colors.size() > 0) {
460 const RGBColor& color,
const bool drawEntire,
const double lineWidth) {
469 glTranslated(0, 0, -1);
476 glTranslated(0, 0, 0.1);
480 }
else if (distanceSquared > 25) {
484 glTranslated(0, 0, 0.1);
489 if (distanceSquared > 100) {
500 glTranslated(0, 0, 0.1);
518 const RGBColor& color,
const bool drawEntire,
const double lineWidth) {
523 const double sublineWidth = (lineWidth * 0.8);
529 glTranslated(0, 0, -1);
533 if (drawEntire || (distanceSquared < 25)) {
540 glTranslated(0, 0, 0.1);
548 glTranslated(0, 0, 0.1);
553 if (distanceSquared > 100) {
564 glTranslated(0, 0, 0.1);
591 const double inc = 360 / (double)steps;
593 for (
int i = 0; i <= steps; ++i) {
595 vertexCircle.push_back(
Position(vertex.
x() * width, vertex.
y() * width));
598 vertexCircle.
add(pos);
606 glRotated((rot * -1) + 90, 0, 0, 1);
636 int numberOfSegments = (int)
myShape.size() - 1;
638 if (numberOfSegments >= 0) {
643 for (
int i = 0; i < numberOfSegments; i++) {
#define CIRCLE_RESOLUTION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
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 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 void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
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 rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
static void drawGeometryPoints(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &geometryPointColor, const RGBColor &textColor, const double radius, const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols)
draw geometry points
void moveGeometryToSide(const double amount)
move current shape to side
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static PositionVector myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
void scaleGeometry(const double scale)
scale geometry
static void drawGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
static PositionVector getVertexCircleAroundPosition(const Position &pos, const double width, const int steps=8)
get a circle around the given position
void calculateShapeRotationsAndLengths()
calculate shape rotations and lengths
std::vector< double > myShapeLengths
The lengths of the shape (note: Always size = myShape.size()-1)
static void adjustStartPosGeometricPath(double &startPos, const PositionVector &startLaneShape, double &endPos, const PositionVector &endLaneShape)
adjust start and end positions in geometric path
void clearGeometry()
clear geometry
static int angleLookup(const double angleDeg)
normalize angle for lookup in myCircleCoords
static void drawContourGeometry(const GUIGeometry &geometry, const double width, const bool drawExtremes=false)
draw contour geometry
PositionVector myShape
element shape
void updateSinglePosGeometry(const Position &position, const double rotation)
update position and rotation
static double calculateRotation(const Position &first, const Position &second)
return angle between two points (used in geometric calculations)
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between child and parent (used in NETEDIT)
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
static void drawMovingHint(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const RGBColor &hintColor, const double radius, const double exaggeration)
draw moving hint
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
static void drawLaneGeometry(const GUIVisualizationSettings &s, const Position &mousePos, const PositionVector &shape, const std::vector< double > &rotations, const std::vector< double > &lengths, const std::vector< RGBColor > &colors, double width, const bool onlyContour=false, const double offset=0)
draw lane geometry (use their own function due colors)
std::vector< double > myShapeRotations
The rotations of the shape (note: Always size = myShape.size()-1)
GUIGeometry()
default constructor
static void drawParentLine(const GUIVisualizationSettings &s, const Position &parent, const Position &child, const RGBColor &color, const bool drawEntire, const double lineWidth)
draw line between parent and children (used in NETEDIT)
static double calculateLength(const Position &first, const Position &second)
return length between two points (used in geometric calculations)
Stores the information about how to visualize structures.
bool drawForRectangleSelection
whether drawing is performed for the purpose of selecting objects using a rectangle
GUIVisualizationDetailSettings detailSettings
detail settings
bool drawForPositionSelection
whether drawing is performed for the purpose of selecting objects with a single click
double scale
information about a lane's width (temporary, used for a single view)
bool drawDetail(const double detail, const double exaggeration) const
check if details can be drawn for the given GUIVisualizationDetailSettings and current scale and exxa...
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
int getCircleResolution() const
function to calculate circle resolution for all circles drawn in drawGL(...) functions
A point in 2D or 3D with translation and scaling methods.
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
double x() const
Returns the x-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
double y() const
Returns the y-position.
double length2D() const
Returns the length.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
void push_front_noDoublePos(const Position &p)
insert in front a non double position
double rotationDegreeAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void add(double xoff, double yoff, double zoff)
void closePolygon()
ensures that the last position equals the first
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
PositionVector getSubpart2D(double beginOffset, double endOffset) const
get subpart of a position vector in two dimensions (Z is ignored)
void scaleRelative(double factor)
enlarges/shrinks the polygon by a factor based at the centroid
void push_back_noDoublePos(const Position &p)
insert in back a non double position
bool isClosed() const
check if PositionVector is closed
PositionVector reverse() const
reverse position vector
Position positionAtOffset2D(double pos, double lateralOffset=0) const
Returns the position at the given length.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
static const double arrowLength
arrow length
static const double arrowWidth
arrow width
static const double arrowOffset
arrow offset
static const double geometryPointsText
details for Geometry Points Texts