28#define CIRCLE_RESOLUTION (double)10
51 const std::vector<double>& shapeLengths) :
53 myShapeRotations(shapeRotations),
54 myShapeLengths(shapeLengths) {
71 const double lateralOffset) {
75 const double shapeLength = shape.
length2D();
77 if (posOverShape < 0) {
80 }
else if (posOverShape > shapeLength) {
92 double endPosOverShape,
const double lateralOffset) {
102 if (starPosOverShape < 0) {
106 if (starPosOverShape < 0) {
107 endPosOverShape = shapeLength;
110 if (starPosOverShape > (shapeLength - POSITION_EPS)) {
111 endPosOverShape = (shapeLength - POSITION_EPS);
114 if ((endPosOverShape > shapeLength)) {
115 endPosOverShape = shapeLength;
118 if (endPosOverShape <= starPosOverShape) {
119 endPosOverShape = endPosOverShape + POSITION_EPS;
130 double endTrimPosition,
const Position& extraLastPosition) {
136 if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
140 if (beginTrimPosition < 0) {
141 beginTrimPosition = 0;
144 if (endTrimPosition < 0) {
145 endTrimPosition = shapeLength;
148 if (beginTrimPosition > (shapeLength - POSITION_EPS)) {
149 beginTrimPosition = (shapeLength - POSITION_EPS);
152 if ((endTrimPosition > shapeLength)) {
153 endTrimPosition = shapeLength;
156 if (endTrimPosition <= beginTrimPosition) {
157 endTrimPosition = endTrimPosition + POSITION_EPS;
205 shapeLength *= scale;
216const std::vector<double>&
222const std::vector<double>&
231 return ((
double)atan2((second.
x() - first.
x()), (first.
y() - second.
y())) * (
double) 180.0 / (
double)
M_PI);
246 if ((startLaneShape.size() > 0) &&
247 (endLaneShape.size() > 0) &&
248 (startLaneShape == endLaneShape) &&
251 if (startPos >= endPos) {
252 endPos = (startPos + POSITION_EPS);
256 if ((startPos != -1) && (startLaneShape.size() > 0)) {
257 if (startPos < POSITION_EPS) {
258 startPos = POSITION_EPS;
260 if (startPos > (startLaneShape.
length() - POSITION_EPS)) {
261 startPos = (startLaneShape.
length() - POSITION_EPS);
265 if ((endPos != -1) && (endLaneShape.size() > 0)) {
266 if (endPos < POSITION_EPS) {
267 endPos = POSITION_EPS;
269 if (endPos > (endLaneShape.
length() - POSITION_EPS)) {
270 endPos = (endLaneShape.
length() - POSITION_EPS);
278 const double width,
double offset) {
284 glLineWidth(
static_cast<float>(width));
298 const std::vector<RGBColor>& colors,
const double width,
double offset) {
308 glLineWidth(
static_cast<float>(width));
350 const RGBColor& color,
const double radius,
const double exaggeration,
351 const bool editingElevation) {
355 const double exaggeratedRadio = (radius * exaggeration);
357 for (
const auto& geometryPos : shape) {
361 glTranslated(geometryPos.x(), geometryPos.y(), 0.2);
370 if (editingElevation) {
377 }
else if (geometryPos == shape.front()) {
384 }
else if (geometryPos == shape.back()) {
400 const RGBColor& color,
const bool drawEntire,
const double lineWidth) {
409 glTranslated(0, 0, -1);
416 glTranslated(0, 0, 0.1);
420 }
else if (distanceSquared > 25) {
424 glTranslated(0, 0, 0.1);
429 if (distanceSquared > 100) {
440 glTranslated(0, 0, 0.1);
458 const RGBColor& color,
const bool drawEntire,
const double lineWidth) {
463 const double sublineWidth = (lineWidth * 0.8);
469 glTranslated(0, 0, -1);
473 if (drawEntire || (distanceSquared < 25)) {
480 glTranslated(0, 0, 0.1);
488 glTranslated(0, 0, 0.1);
493 if (distanceSquared > 100) {
504 glTranslated(0, 0, 0.1);
531 const double inc = 360 / (double)steps;
533 for (
int i = 0; i <= steps; ++i) {
535 vertexCircle.push_back(
Position(vertex.
x() * width, vertex.
y() * width));
538 vertexCircle.
add(pos);
546 glRotated((rot * -1) + 90, 0, 0, 1);
568 int numberOfSegments = (int)
myShape.size() - 1;
570 if (numberOfSegments >= 0) {
575 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 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 drawFilledCircleDetailled(const GUIVisualizationSettings::Detail d, const double radius)
Draws a filled circle around (0,0) depending of level of detail.
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.)
void moveGeometryToSide(const double amount)
move current shape to side
const std::vector< double > & getShapeRotations() const
The rotations of the single shape parts.
static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector &shape, const RGBColor &color, const double radius, const double exaggeration, const bool editingElevation)
draw geometry points
static PositionVector myCircleCoords
Storage for precomputed sin/cos-values describing a circle.
void scaleGeometry(const double scale)
scale 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
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw 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
const std::vector< double > & getShapeLengths() const
The lengths of the single shape parts.
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
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
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 (in radians bet...
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.
void add(double xoff, double yoff, double zoff)
void closePolygon()
ensures that the last position equals the first
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector getSubpart2D(double beginOffset, double endOffset) const
get subpart of a position vector in two dimensions (Z is ignored)
Position positionAtOffset2D(double pos, double lateralOffset=0, bool extrapolateBeyond=false) const
Returns the position at the given length.
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
PositionVector reverse() const
reverse position vector
RGBColor invertedColor() const
obtain inverted of current RGBColor
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