Eclipse SUMO - Simulation of Urban MObility
GUIGeometry.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// File for geometry classes and functions
19/****************************************************************************/
24
25#include "GUIGeometry.h"
26
27#define CIRCLE_RESOLUTION (double)10 // inverse in degrees
28
29// ===========================================================================
30// static member definitions
31// ===========================================================================
33
34// ===========================================================================
35// method definitions
36// ===========================================================================
37
39}
40
41
43 myShape(shape) {
44 // calculate shape rotation and lengths
46}
47
48
49GUIGeometry::GUIGeometry(const PositionVector& shape, const std::vector<double>& shapeRotations,
50 const std::vector<double>& shapeLengths) :
51 myShape(shape),
52 myShapeRotations(shapeRotations),
53 myShapeLengths(shapeLengths) {
54}
55
56
57void
59 // clear geometry
61 // update shape
62 myShape = shape;
63 // calculate shape rotation and lengths
65}
66
67
68void
69GUIGeometry::updateGeometry(const PositionVector& shape, const double posOverShape,
70 const double lateralOffset) {
71 // first clear geometry
73 // get shape length
74 const double shapeLength = shape.length();
75 // calculate position and rotation
76 if (posOverShape < 0) {
77 myShape.push_back(shape.positionAtOffset(0, lateralOffset));
78 myShapeRotations.push_back(shape.rotationDegreeAtOffset(0));
79 } else if (posOverShape > shapeLength) {
80 myShape.push_back(shape.positionAtOffset(shapeLength, lateralOffset));
81 myShapeRotations.push_back(shape.rotationDegreeAtOffset(shapeLength));
82 } else {
83 myShape.push_back(shape.positionAtOffset(posOverShape, lateralOffset));
84 myShapeRotations.push_back(shape.rotationDegreeAtOffset(posOverShape));
85 }
86}
87
88
89void
90GUIGeometry::updateGeometry(const PositionVector& shape, double starPosOverShape,
91 double endPosOverShape, const double lateralOffset) {
92 // first clear geometry
94 // set new shape
95 myShape = shape;
96 // set lateral offset
97 myShape.move2side(lateralOffset);
98 // get shape length
99 const double shapeLength = myShape.length2D();
100 // set initial beginTrim value
101 if (starPosOverShape < 0) {
102 endPosOverShape = 0;
103 }
104 // set initial endtrim value
105 if (starPosOverShape < 0) {
106 endPosOverShape = shapeLength;
107 }
108 // check maximum beginTrim
109 if (starPosOverShape > (shapeLength - POSITION_EPS)) {
110 endPosOverShape = (shapeLength - POSITION_EPS);
111 }
112 // check maximum endTrim
113 if ((endPosOverShape > shapeLength)) {
114 endPosOverShape = shapeLength;
115 }
116 // check sub-vector
117 if (endPosOverShape <= starPosOverShape) {
118 endPosOverShape = endPosOverShape + POSITION_EPS;
119 }
120 // trim shape
121 myShape = myShape.getSubpart2D(starPosOverShape, endPosOverShape);
122 // calculate shape rotation and lengths
124}
125
126
127void
128GUIGeometry::updateGeometry(const PositionVector& shape, double beginTrimPosition, double endTrimPosition,
129 const Position& extraFirstPosition, const Position& extraLastPosition) {
130 // first clear geometry
132 // set new shape
133 myShape = shape;
134 // check trim values
135 if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
136 // get shape length
137 const double shapeLength = myShape.length2D();
138 // set initial beginTrim value
139 if (beginTrimPosition < 0) {
140 beginTrimPosition = 0;
141 }
142 // set initial endtrim value
143 if (endTrimPosition < 0) {
144 endTrimPosition = shapeLength;
145 }
146 // check maximum beginTrim
147 if (beginTrimPosition > (shapeLength - POSITION_EPS)) {
148 beginTrimPosition = (shapeLength - POSITION_EPS);
149 }
150 // check maximum endTrim
151 if ((endTrimPosition > shapeLength)) {
152 endTrimPosition = shapeLength;
153 }
154 // check sub-vector
155 if (endTrimPosition <= beginTrimPosition) {
156 endTrimPosition = endTrimPosition + POSITION_EPS;
157 }
158 // trim shape
159 myShape = myShape.getSubpart2D(beginTrimPosition, endTrimPosition);
160 // add extra positions
161 if (extraFirstPosition != Position::INVALID) {
162 myShape.push_front_noDoublePos(extraFirstPosition);
163 }
164 if (extraLastPosition != Position::INVALID) {
165 myShape.push_back_noDoublePos(extraLastPosition);
166 }
167 }
168 // calculate shape rotation and lengths
170}
171
172
173void
174GUIGeometry::updateSinglePosGeometry(const Position& position, const double rotation) {
175 // first clear geometry
177 // set position and rotation
178 myShape.push_back(position);
179 myShapeRotations.push_back(rotation);
180}
181
182
183void
185 // move shape
186 myShape.move2side(amount);
187}
188
189
190void
191GUIGeometry::scaleGeometry(const double scale) {
192 // scale shape and lengths
193 myShape.scaleRelative(scale);
194 // scale lengths
195 for (auto& shapeLength : myShapeLengths) {
196 shapeLength *= scale;
197 }
198}
199
200
201const PositionVector&
203 return myShape;
204}
205
206
207const std::vector<double>&
209 return myShapeRotations;
210}
211
212
213const std::vector<double>&
215 return myShapeLengths;
216}
217
218
219double
221 // return rotation (angle) of the vector constructed by points first and second
222 return ((double)atan2((second.x() - first.x()), (first.y() - second.y())) * (double) 180.0 / (double)M_PI);
223}
224
225
226double
227GUIGeometry::calculateLength(const Position& first, const Position& second) {
228 // return 2D distance between two points
229 return first.distanceTo2D(second);
230}
231
232
233void
234GUIGeometry::adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape,
235 double& endPos, const PositionVector& endLaneShape) {
236 // adjust both, if start and end lane are the same
237 if ((startLaneShape.size() > 0) &&
238 (endLaneShape.size() > 0) &&
239 (startLaneShape == endLaneShape) &&
240 (startPos != -1) &&
241 (endPos != -1)) {
242 if (startPos >= endPos) {
243 endPos = (startPos + POSITION_EPS);
244 }
245 }
246 // adjust startPos
247 if ((startPos != -1) && (startLaneShape.size() > 0)) {
248 if (startPos < POSITION_EPS) {
249 startPos = POSITION_EPS;
250 }
251 if (startPos > (startLaneShape.length() - POSITION_EPS)) {
252 startPos = (startLaneShape.length() - POSITION_EPS);
253 }
254 }
255 // adjust endPos
256 if ((endPos != -1) && (endLaneShape.size() > 0)) {
257 if (endPos < POSITION_EPS) {
258 endPos = POSITION_EPS;
259 }
260 if (endPos > (endLaneShape.length() - POSITION_EPS)) {
261 endPos = (endLaneShape.length() - POSITION_EPS);
262 }
263 }
264}
265
266
267void
269 const GUIGeometry& geometry, const double width, double offset) {
270 // continue depending of draw for position selection
272 // obtain position over lane relative to mouse position
273 const Position posOverLane = geometry.getShape().positionAtOffset2D(geometry.getShape().nearest_offset_to_point2D(mousePos));
274 // if mouse is over segment
275 if (posOverLane.distanceSquaredTo2D(mousePos) <= (width * width)) {
276 // push matrix
278 // translate to position over lane
279 glTranslated(posOverLane.x(), posOverLane.y(), 0);
280 // Draw circle
282 // pop draw matrix
284 }
285 } else if (s.scale * width < 1) {
286 // draw line (needed for zoom out)
287 GLHelper::drawLine(geometry.getShape());
288 } else {
289 GLHelper::drawBoxLines(geometry.getShape(), geometry.getShapeRotations(), geometry.getShapeLengths(), width, 0, offset);
290 }
291}
292
293
294void
295GUIGeometry::drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes) {
296 // get shapes
297 PositionVector shapeA = geometry.getShape();
298 PositionVector shapeB = geometry.getShape();
299 // move both shapes
300 shapeA.move2side((width - 0.1));
301 shapeB.move2side((width - 0.1) * -1);
302 // check if we have to drawn extremes
303 if (drawExtremes) {
304 // reverse shape B
305 shapeB = shapeB.reverse();
306 // append shape B to shape A
307 shapeA.append(shapeB, 0);
308 // close shape A
309 shapeA.closePolygon();
310 // draw box lines using shapeA
311 GLHelper::drawBoxLines(shapeA, 0.1);
312 } else {
313 // draw box lines using shapeA
314 GLHelper::drawBoxLines(shapeA, 0.1);
315 // draw box lines using shapeA
316 GLHelper::drawBoxLines(shapeB, 0.1);
317 }
318}
319
320
321void
323 const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius, const double exaggeration,
324 const bool editingElevation, const bool drawExtremeSymbols) {
325 // get exaggeratedRadio
326 const double exaggeratedRadio = (radius * exaggeration);
327 // get radius squared
328 const double exaggeratedRadioSquared = (exaggeratedRadio * exaggeratedRadio);
329 // iterate over shape
330 for (const auto& vertex : shape) {
331 // if drawForPositionSelection is enabled, check distance between mouse and vertex
332 if (!s.drawForPositionSelection || (mousePos.distanceSquaredTo2D(vertex) <= exaggeratedRadioSquared)) {
333 // push geometry point matrix
335 // move to vertex
336 glTranslated(vertex.x(), vertex.y(), 0.2);
337 // set color
338 GLHelper::setColor(geometryPointColor);
339 // draw circle
340 GLHelper::drawFilledCircle(exaggeratedRadio, s.getCircleResolution());
341 // pop geometry point matrix
343 // draw elevation or special symbols (Start, End and Block)
345 // get draw detail
346 const bool drawDetail = s.drawDetail(s.detailSettings.geometryPointsText, exaggeration);
347 // draw text
348 if (editingElevation) {
349 // Push Z matrix
351 // draw Z (elevation)
352 GLHelper::drawText(toString(vertex.z()), vertex, 0.3, 0.7, textColor);
353 // pop Z matrix
355 } else if ((vertex == shape.front()) && drawDetail && drawExtremeSymbols) {
356 // push "S" matrix
358 // draw a "s" over first point
359 GLHelper::drawText("S", vertex, 0.3, 2 * exaggeratedRadio, textColor);
360 // pop "S" matrix
362 } else if ((vertex == shape.back()) && (shape.isClosed() == false) && drawDetail && drawExtremeSymbols) {
363 // push "E" matrix
365 // draw a "e" over last point if polygon isn't closed
366 GLHelper::drawText("E", vertex, 0.3, 2 * exaggeratedRadio, textColor);
367 // pop "E" matrix
369 }
370 }
371 }
372 }
373}
374
375
376void
378 const RGBColor& hintColor, const double radius, const double exaggeration) {
379 // get exaggeratedRadio
380 const double exaggeratedRadio = (radius * exaggeration);
381 // obtain distance to shape
382 const double distanceToShape = shape.distance2D(mousePos);
383 // obtain squared radius
384 const double squaredRadius = (radius * radius * exaggeration);
385 // declare index
386 int index = -1;
387 // iterate over shape
388 for (int i = 0; i < (int)shape.size(); i++) {
389 // check distance
390 if (shape[i].distanceSquaredTo2D(mousePos) <= squaredRadius) {
391 index = i;
392 }
393 }
394 // continue depending of distance to shape
395 if ((distanceToShape < exaggeratedRadio) && (index == -1)) {
396 // obtain position over lane
397 const Position positionOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePos));
398 // calculate hintPos
399 const Position hintPos = shape.size() > 1 ? positionOverLane : shape[0];
400 // push hintPos matrix
402 // translate to hintPos
403 glTranslated(hintPos.x(), hintPos.y(), 0.2);
404 // set color
405 GLHelper::setColor(hintColor);
406 // draw filled circle
408 // pop hintPos matrix
410 }
411}
412
413
414void
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) {
418 // first check if we're in draw a contour or for selecting cliking mode
419 if (onlyContour) {
420 // get shapes
421 PositionVector shapeA = shape;
422 PositionVector shapeB = shape;
423 // move both shapes
424 shapeA.move2side((width - 0.1));
425 shapeB.move2side((width - 0.1) * -1);
426 // reverse shape B
427 shapeB = shapeB.reverse();
428 // append shape B to shape A
429 shapeA.append(shapeB, 0);
430 // close shape A
431 shapeA.closePolygon();
432 // draw box lines using shapeA
433 GLHelper::drawBoxLines(shapeA, 0.1);
434 } else if (s.drawForPositionSelection) {
435 // obtain position over lane relative to mouse position
436 const Position posOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePos), offset);
437 // if mouse is over segment
438 if (posOverLane.distanceSquaredTo2D(mousePos) <= (width * width)) {
439 // push matrix
441 // translate to position over lane
442 glTranslated(posOverLane.x(), posOverLane.y(), 0);
443 // Draw circle
445 // pop draw matrix
447 }
448 } else if (colors.size() > 0) {
449 // draw box lines with own colors
450 GLHelper::drawBoxLines(shape, rotations, lengths, colors, width, 0, offset);
451 } else {
452 // draw box lines with current color
453 GLHelper::drawBoxLines(shape, rotations, lengths, width, 0, offset);
454 }
455}
456
457
458void
460 const RGBColor& color, const bool drawEntire, const double lineWidth) {
462 // calculate rotation
463 const double rot = RAD2DEG(parent.angleTo2D(child)) + 90;
464 // calculate distance between origin and destiny
465 const double distanceSquared = parent.distanceSquaredTo2D(child);
466 // Add a draw matrix for details
468 // move back
469 glTranslated(0, 0, -1);
470 // draw box line
471 if (drawEntire) {
472 // draw first box line
474 GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), lineWidth);
475 // move front
476 glTranslated(0, 0, 0.1);
477 // draw second box line
478 GLHelper::setColor(color);
479 GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), .04);
480 } else if (distanceSquared > 25) {
481 // draw first box line with length 4.9
483 GLHelper::drawBoxLine(parent, rot, 4.9, lineWidth);
484 glTranslated(0, 0, 0.1);
485 // draw second box line with length 4.9
486 GLHelper::setColor(color);
487 GLHelper::drawBoxLine(parent, rot, 4.9, .04);
488 // draw arrow depending of distanceSquared (10*10)
489 if (distanceSquared > 100) {
490 // calculate positionVector between both points
491 const PositionVector vector = {parent, child};
492 // draw first arrow at end
495 vector.positionAtOffset2D(5),
499 // move front
500 glTranslated(0, 0, 0.1);
501 // draw second arrow at end
502 GLHelper::setColor(color);
504 vector.positionAtOffset2D(5),
508 }
509 }
510 // pop draw matrix
512 }
513}
514
515
516void
518 const RGBColor& color, const bool drawEntire, const double lineWidth) {
520 // calculate distance between origin and destiny
521 const double distanceSquared = child.distanceSquaredTo2D(parent);
522 // calculate subline width
523 const double sublineWidth = (lineWidth * 0.8);
524 // calculate rotation
525 const double rot = RAD2DEG(child.angleTo2D(parent)) + 90;
526 // Add a draw matrix for details
528 // move back
529 glTranslated(0, 0, -1);
530 // set color
531 GLHelper::setColor(color);
532 // draw box line
533 if (drawEntire || (distanceSquared < 25)) {
534 // set color
535 GLHelper::setColor(color);
536 // draw first box line
538 GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), lineWidth);
539 // move front
540 glTranslated(0, 0, 0.1);
541 // draw second box line
542 GLHelper::setColor(color);
543 GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), sublineWidth);
544 } else {
545 // draw first box line with length 4.9
547 GLHelper::drawBoxLine(child, rot, 4.9, lineWidth);
548 glTranslated(0, 0, 0.1);
549 // draw second box line with length
550 GLHelper::setColor(color);
551 GLHelper::drawBoxLine(child, rot, 4.9, sublineWidth);
552 // draw arrow depending of distanceSquared (10*10)
553 if (distanceSquared > 100) {
554 // calculate positionVector between both points
555 const PositionVector vector = {child, parent};
556 // draw first arrow at end
559 vector.positionAtOffset2D(5),
563 // move front
564 glTranslated(0, 0, 0.1);
565 // draw second arrow at end
566 GLHelper::setColor(color);
568 vector.positionAtOffset2D(5),
572 }
573 }
574 // pop draw matrix
576 }
577}
578
579
581GUIGeometry::getVertexCircleAroundPosition(const Position& pos, const double width, const int steps) {
582 // first check if we have to fill myCircleCoords (only once)
583 if (myCircleCoords.size() == 0) {
584 for (int i = 0; i <= (int)(360 * CIRCLE_RESOLUTION); ++i) {
585 const double x = (double) sin(DEG2RAD(i / CIRCLE_RESOLUTION));
586 const double y = (double) cos(DEG2RAD(i / CIRCLE_RESOLUTION));
587 myCircleCoords.push_back(Position(x, y));
588 }
589 }
590 PositionVector vertexCircle;
591 const double inc = 360 / (double)steps;
592 // obtain all vertices
593 for (int i = 0; i <= steps; ++i) {
594 const Position& vertex = myCircleCoords[GUIGeometry::angleLookup(i * inc)];
595 vertexCircle.push_back(Position(vertex.x() * width, vertex.y() * width));
596 }
597 // move result using position
598 vertexCircle.add(pos);
599 return vertexCircle;
600}
601
602
603void
605 // rotate using rotation calculated in PositionVector
606 glRotated((rot * -1) + 90, 0, 0, 1);
607}
608
609
610int
611GUIGeometry::angleLookup(const double angleDeg) {
612 const int numCoords = (int)myCircleCoords.size() - 1;
613 int index = ((int)(floor(angleDeg * CIRCLE_RESOLUTION + 0.5))) % numCoords;
614 if (index < 0) {
615 index += numCoords;
616 }
617 assert(index >= 0);
618 return (int)index;
619}
620
621
623 // clear geometry containers
624 myShape.clear();
625 myShapeRotations.clear();
626 myShapeLengths.clear();
627}
628
629
630void
632 // clear rotations and lengths
633 myShapeRotations.clear();
634 myShapeLengths.clear();
635 // Get number of parts of the shape
636 int numberOfSegments = (int)myShape.size() - 1;
637 // If number of segments is more than 0
638 if (numberOfSegments >= 0) {
639 // Reserve memory (To improve efficiency)
640 myShapeRotations.reserve(numberOfSegments);
641 myShapeLengths.reserve(numberOfSegments);
642 // Calculate lengths and rotations for every shape
643 for (int i = 0; i < numberOfSegments; i++) {
644 myShapeRotations.push_back(calculateRotation(myShape[i], myShape[i + 1]));
645 myShapeLengths.push_back(calculateLength(myShape[i], myShape[i + 1]));
646 }
647 }
648}
649
650/****************************************************************************/
#define CIRCLE_RESOLUTION
Definition: GUIGeometry.cpp:27
#define DEG2RAD(x)
Definition: GeomHelper.h:35
#define RAD2DEG(x)
Definition: GeomHelper.h:36
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
static void drawLine(const Position &beg, double rot, double visLength)
Draws a thin line.
Definition: GLHelper.cpp:421
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
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.
Definition: GLHelper.cpp:558
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
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.
Definition: GLHelper.cpp:329
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:277
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
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)
Definition: GLHelper.cpp:685
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.
Definition: GUIGeometry.h:144
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)
Definition: GUIGeometry.h:140
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
Definition: GUIGeometry.h:134
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
Definition: GUIGeometry.cpp:58
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)
Definition: GUIGeometry.h:137
GUIGeometry()
default constructor
Definition: GUIGeometry.cpp:38
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.
Definition: Position.h:37
double distanceSquaredTo2D(const Position &p2) const
returns the square of the distance to another position (Only using x and y positions)
Definition: Position.h:257
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:298
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition: Position.h:252
double x() const
Returns the x-position.
Definition: Position.h:55
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position
Definition: Position.h:262
double y() const
Returns the y-position.
Definition: Position.h:60
A list of positions.
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.
Definition: RGBColor.cpp:200
#define M_PI
Definition: odrSpiral.cpp:45
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