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 /****************************************************************************/
20 #include <utils/geom/GeomHelper.h>
21 #include <utils/gui/div/GLHelper.h>
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 lenghts
46 }
47 
48 
49 GUIGeometry::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 
57 void
59  // clear geometry
60  clearGeometry();
61  // update shape
62  myShape = shape;
63  // calculate shape rotation and lenghts
65 }
66 
67 
68 void
69 GUIGeometry::updateGeometry(const PositionVector& shape, const double posOverShape,
70  const double lateralOffset) {
71  // first clear geometry
72  clearGeometry();
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 
89 void
90 GUIGeometry::updateGeometry(const PositionVector& shape, double starPosOverShape,
91  double endPosOverShape, const double lateralOffset) {
92  // first clear geometry
93  clearGeometry();
94  // set new shape
95  myShape = shape;
96  // set lateral offset
97  myShape.move2side(lateralOffset);
98  // get shape lenght
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 lenghts
124 }
125 
126 
127 void
128 GUIGeometry::updateGeometry(const PositionVector& shape, double beginTrimPosition, double endTrimPosition,
129  const Position& extraFirstPosition, const Position& extraLastPosition) {
130  // first clear geometry
131  clearGeometry();
132  // set new shape
133  myShape = shape;
134  // check trim values
135  if ((beginTrimPosition != -1) || (endTrimPosition != -1)) {
136  // get shape lenght
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 lenghts
170 }
171 
172 
173 void
174 GUIGeometry::updateSinglePosGeometry(const Position& position, const double rotation) {
175  // first clear geometry
176  clearGeometry();
177  // set position and rotation
178  myShape.push_back(position);
179  myShapeRotations.push_back(rotation);
180 }
181 
182 
183 void
184 GUIGeometry::scaleGeometry(const double scale) {
185  // scale shape and lenghts
186  myShape.scaleRelative(scale);
187  // scale lenghts
188  for (auto& shapeLength : myShapeLengths) {
189  shapeLength *= scale;
190  }
191 }
192 
193 
194 const PositionVector&
196  return myShape;
197 }
198 
199 
200 const std::vector<double>&
202  return myShapeRotations;
203 }
204 
205 
206 const std::vector<double>&
208  return myShapeLengths;
209 }
210 
211 
212 double
213 GUIGeometry::calculateRotation(const Position& first, const Position& second) {
214  // return rotation (angle) of the vector constructed by points first and second
215  return ((double)atan2((second.x() - first.x()), (first.y() - second.y())) * (double) 180.0 / (double)M_PI);
216 }
217 
218 
219 double
220 GUIGeometry::calculateLength(const Position& first, const Position& second) {
221  // return 2D distance between two points
222  return first.distanceTo2D(second);
223 }
224 
225 
226 void
227 GUIGeometry::adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape,
228  double& endPos, const PositionVector& endLaneShape) {
229  // adjust both, if start and end lane are the same
230  if ((startLaneShape.size() > 0) &&
231  (endLaneShape.size() > 0) &&
232  (startLaneShape == endLaneShape) &&
233  (startPos != -1) &&
234  (endPos != -1)) {
235  if (startPos >= endPos) {
236  endPos = (startPos + POSITION_EPS);
237  }
238  }
239  // adjust startPos
240  if ((startPos != -1) && (startLaneShape.size() > 0)) {
241  if (startPos < POSITION_EPS) {
242  startPos = POSITION_EPS;
243  }
244  if (startPos > (startLaneShape.length() - POSITION_EPS)) {
245  startPos = (startLaneShape.length() - POSITION_EPS);
246  }
247  }
248  // adjust endPos
249  if ((endPos != -1) && (endLaneShape.size() > 0)) {
250  if (endPos < POSITION_EPS) {
251  endPos = POSITION_EPS;
252  }
253  if (endPos > (endLaneShape.length() - POSITION_EPS)) {
254  endPos = (endLaneShape.length() - POSITION_EPS);
255  }
256  }
257 }
258 
259 
260 void
262  const GUIGeometry& geometry, const double width, double offset) {
263  // continue depending of draw for position selection
264  if (s.drawForPositionSelection) {
265  // obtain position over lane relative to mouse position
266  const Position posOverLane = geometry.getShape().positionAtOffset2D(geometry.getShape().nearest_offset_to_point2D(mousePos));
267  // if mouse is over segment
268  if (posOverLane.distanceSquaredTo2D(mousePos) <= (width * width)) {
269  // push matrix
271  // translate to position over lane
272  glTranslated(posOverLane.x(), posOverLane.y(), 0);
273  // Draw circle
275  // pop draw matrix
277  }
278  } else if (s.scale * width < 1) {
279  // draw line (needed for zoom out)
280  GLHelper::drawLine(geometry.getShape());
281  } else {
282  GLHelper::drawBoxLines(geometry.getShape(), geometry.getShapeRotations(), geometry.getShapeLengths(), width, 0, offset);
283  }
284 }
285 
286 
287 void
288 GUIGeometry::drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes) {
289  // get shapes
290  PositionVector shapeA = geometry.getShape();
291  PositionVector shapeB = geometry.getShape();
292  // move both shapes
293  shapeA.move2side((width - 0.1));
294  shapeB.move2side((width - 0.1) * -1);
295  // check if we have to drawn extremes
296  if (drawExtremes) {
297  // reverse shape B
298  shapeB = shapeB.reverse();
299  // append shape B to shape A
300  shapeA.append(shapeB, 0);
301  // close shape A
302  shapeA.closePolygon();
303  // draw box lines using shapeA
304  GLHelper::drawBoxLines(shapeA, 0.1);
305  } else {
306  // draw box lines using shapeA
307  GLHelper::drawBoxLines(shapeA, 0.1);
308  // draw box lines using shapeA
309  GLHelper::drawBoxLines(shapeB, 0.1);
310  }
311 }
312 
313 
314 void
316  const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius, const double exaggeration,
317  const bool editingElevation, const bool drawExtremeSymbols) {
318  // get exaggeratedRadio
319  const double exaggeratedRadio = (radius * exaggeration);
320  // get radius squared
321  const double exaggeratedRadioSquared = (exaggeratedRadio * exaggeratedRadio);
322  // iterate over shape
323  for (const auto& vertex : shape) {
324  // if drawForPositionSelection is enabled, check distance between mouse and vertex
325  if (!s.drawForPositionSelection || (mousePos.distanceSquaredTo2D(vertex) <= exaggeratedRadioSquared)) {
326  // push geometry point matrix
328  // move to vertex
329  glTranslated(vertex.x(), vertex.y(), 0.2);
330  // set color
331  GLHelper::setColor(geometryPointColor);
332  // draw circle
333  GLHelper::drawFilledCircle(exaggeratedRadio, s.getCircleResolution());
334  // pop geometry point matrix
336  // draw elevation or special symbols (Start, End and Block)
338  // get draw detail
339  const bool drawDetail = s.drawDetail(s.detailSettings.geometryPointsText, exaggeration);
340  // draw text
341  if (editingElevation) {
342  // Push Z matrix
344  // draw Z (elevation)
345  GLHelper::drawText(toString(vertex.z()), vertex, 0.3, 0.7, textColor);
346  // pop Z matrix
348  } else if ((vertex == shape.front()) && drawDetail && drawExtremeSymbols) {
349  // push "S" matrix
351  // draw a "s" over first point
352  GLHelper::drawText("S", vertex, 0.3, 2 * exaggeratedRadio, textColor);
353  // pop "S" matrix
355  } else if ((vertex == shape.back()) && (shape.isClosed() == false) && drawDetail && drawExtremeSymbols) {
356  // push "E" matrix
358  // draw a "e" over last point if polygon isn't closed
359  GLHelper::drawText("E", vertex, 0.3, 2 * exaggeratedRadio, textColor);
360  // pop "E" matrix
362  }
363  }
364  }
365  }
366 }
367 
368 
369 void
371  const RGBColor& hintColor, const double radius, const double exaggeration) {
372  // get exaggeratedRadio
373  const double exaggeratedRadio = (radius * exaggeration);
374  // obtain distance to shape
375  const double distanceToShape = shape.distance2D(mousePos);
376  // obtain squared radius
377  const double squaredRadius = (radius * radius * exaggeration);
378  // declare index
379  int index = -1;
380  // iterate over shape
381  for (int i = 0; i < (int)shape.size(); i++) {
382  // check distance
383  if (shape[i].distanceSquaredTo2D(mousePos) <= squaredRadius) {
384  index = i;
385  }
386  }
387  // continue depending of distance to shape
388  if ((distanceToShape < exaggeratedRadio) && (index == -1)) {
389  // obtain position over lane
390  const Position positionOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePos));
391  // calculate hintPos
392  const Position hintPos = shape.size() > 1 ? positionOverLane : shape[0];
393  // push hintPos matrix
395  // translate to hintPos
396  glTranslated(hintPos.x(), hintPos.y(), 0.2);
397  // set color
398  GLHelper::setColor(hintColor);
399  // draw filled circle
400  GLHelper:: drawFilledCircle(exaggeratedRadio, s.getCircleResolution());
401  // pop hintPos matrix
403  }
404 }
405 
406 
407 void
409  const std::vector<double>& rotations, const std::vector<double>& lengths, const std::vector<RGBColor>& colors,
410  double width, const bool onlyContour) {
411  // first check if we're in draw a contour or for selecting cliking mode
412  if (onlyContour) {
413  // get shapes
414  PositionVector shapeA = shape;
415  PositionVector shapeB = shape;
416  // move both shapes
417  shapeA.move2side((width - 0.1));
418  shapeB.move2side((width - 0.1) * -1);
419  // reverse shape B
420  shapeB = shapeB.reverse();
421  // append shape B to shape A
422  shapeA.append(shapeB, 0);
423  // close shape A
424  shapeA.closePolygon();
425  // draw box lines using shapeA
426  GLHelper::drawBoxLines(shapeA, 0.1);
427  } else if (s.drawForPositionSelection) {
428  // obtain position over lane relative to mouse position
429  const Position posOverLane = shape.positionAtOffset2D(shape.nearest_offset_to_point2D(mousePos));
430  // if mouse is over segment
431  if (posOverLane.distanceSquaredTo2D(mousePos) <= (width * width)) {
432  // push matrix
434  // translate to position over lane
435  glTranslated(posOverLane.x(), posOverLane.y(), 0);
436  // Draw circle
438  // pop draw matrix
440  }
441  } else if (colors.size() > 0) {
442  // draw box lines with own colors
443  GLHelper::drawBoxLines(shape, rotations, lengths, colors, width);
444  } else {
445  // draw box lines with current color
446  GLHelper::drawBoxLines(shape, rotations, lengths, width);
447  }
448 }
449 
450 
451 void
453  const RGBColor& color, const bool drawEntire) {
455  // calculate rotation
456  const double rot = RAD2DEG(parent.angleTo2D(child)) + 90;
457  // calculate distance between origin and destiny
458  const double distanceSquared = parent.distanceSquaredTo2D(child);
459  // Add a draw matrix for details
461  // move back
462  glTranslated(0, 0, -1);
463  // draw box line
464  if (drawEntire) {
465  // draw first box line
467  GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), .05);
468  // move front
469  glTranslated(0, 0, 0.1);
470  // draw second box line
471  GLHelper::setColor(color);
472  GLHelper::drawBoxLine(parent, rot, sqrt(distanceSquared), .04);
473  } else if (distanceSquared > 25) {
474  // draw first box line with lenght 4.9
476  GLHelper::drawBoxLine(parent, rot, 4.9, .05);
477  glTranslated(0, 0, 0.1);
478  // draw second box line with lenght 4.9
479  GLHelper::setColor(color);
480  GLHelper::drawBoxLine(parent, rot, 4.9, .04);
481  // draw arrow depending of distanceSquared (10*10)
482  if (distanceSquared > 100) {
483  // calculate positionVector between both points
484  const PositionVector vector = {parent, child};
485  // draw first arrow at end
488  vector.positionAtOffset2D(5),
492  // move front
493  glTranslated(0, 0, 0.1);
494  // draw second arrow at end
495  GLHelper::setColor(color);
497  vector.positionAtOffset2D(5),
501  }
502  }
503  // pop draw matrix
505  }
506 }
507 
508 
509 void
511  const RGBColor& color, const bool drawEntire) {
513  // calculate distance between origin and destiny
514  const double distanceSquared = child.distanceSquaredTo2D(parent);
515  // calculate rotation
516  const double rot = RAD2DEG(child.angleTo2D(parent)) + 90;
517  // Add a draw matrix for details
519  // move back
520  glTranslated(0, 0, -1);
521  // set color
522  GLHelper::setColor(color);
523  // draw box line
524  if (drawEntire || (distanceSquared < 25)) {
525  // set color
526  GLHelper::setColor(color);
527  // draw first box line
529  GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), .05);
530  // move front
531  glTranslated(0, 0, 0.1);
532  // draw second box line
533  GLHelper::setColor(color);
534  GLHelper::drawBoxLine(child, rot, sqrt(distanceSquared), .04);
535  } else {
536  // draw first box line with lenght 4.9
538  GLHelper::drawBoxLine(child, rot, 4.9, .05);
539  glTranslated(0, 0, 0.1);
540  // draw second box line with lenght
541  GLHelper::setColor(color);
542  GLHelper::drawBoxLine(child, rot, 4.9, .04);
543  // draw arrow depending of distanceSquared (10*10)
544  if (distanceSquared > 100) {
545  // calculate positionVector between both points
546  const PositionVector vector = {child, parent};
547  // draw first arrow at end
550  vector.positionAtOffset2D(5),
554  // move front
555  glTranslated(0, 0, 0.1);
556  // draw second arrow at end
557  GLHelper::setColor(color);
559  vector.positionAtOffset2D(5),
563  }
564  }
565  // pop draw matrix
567  }
568 }
569 
570 
572 GUIGeometry::getVertexCircleAroundPosition(const Position& pos, const double width, const int steps) {
573  // first check if we have to fill myCircleCoords (only once)
574  if (myCircleCoords.size() == 0) {
575  for (int i = 0; i <= (int)(360 * CIRCLE_RESOLUTION); ++i) {
576  const double x = (double) sin(DEG2RAD(i / CIRCLE_RESOLUTION));
577  const double y = (double) cos(DEG2RAD(i / CIRCLE_RESOLUTION));
578  myCircleCoords.push_back(Position(x, y));
579  }
580  }
581  PositionVector vertexCircle;
582  const double inc = 360 / (double)steps;
583  // obtain all vertices
584  for (int i = 0; i <= steps; ++i) {
585  const Position& vertex = myCircleCoords[GUIGeometry::angleLookup(i * inc)];
586  vertexCircle.push_back(Position(vertex.x() * width, vertex.y() * width));
587  }
588  // move result using position
589  vertexCircle.add(pos);
590  return vertexCircle;
591 }
592 
593 
594 void
595 GUIGeometry::rotateOverLane(const double rot) {
596  // rotate using rotation calculated in PositionVector
597  glRotated((rot * -1) + 90, 0, 0, 1);
598 }
599 
600 
601 int
602 GUIGeometry::angleLookup(const double angleDeg) {
603  const int numCoords = (int)myCircleCoords.size() - 1;
604  int index = ((int)(floor(angleDeg * CIRCLE_RESOLUTION + 0.5))) % numCoords;
605  if (index < 0) {
606  index += numCoords;
607  }
608  assert(index >= 0);
609  return (int)index;
610 }
611 
612 
614  // clear geometry containers
615  myShape.clear();
616  myShapeRotations.clear();
617  myShapeLengths.clear();
618 }
619 
620 
621 void
623  // clear rotations and lengths
624  myShapeRotations.clear();
625  myShapeLengths.clear();
626  // Get number of parts of the shape
627  int numberOfSegments = (int)myShape.size() - 1;
628  // If number of segments is more than 0
629  if (numberOfSegments >= 0) {
630  // Reserve memory (To improve efficiency)
631  myShapeRotations.reserve(numberOfSegments);
632  myShapeLengths.reserve(numberOfSegments);
633  // Calculate lengths and rotations for every shape
634  for (int i = 0; i < numberOfSegments; i++) {
635  myShapeRotations.push_back(calculateRotation(myShape[i], myShape[i + 1]));
636  myShapeLengths.push_back(calculateLength(myShape[i], myShape[i + 1]));
637  }
638  }
639 }
640 
641 /****************************************************************************/
#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:369
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:507
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:431
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:485
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:123
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:277
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:231
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:114
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:609
static void rotateOverLane(const double rot)
rotate over lane (used by Lock icons, detector logos, etc.)
static void drawChildLine(const GUIVisualizationSettings &s, const Position &child, const Position &parent, const RGBColor &color, const bool drawEntire)
draw line between child and parent (used in NETEDIT)
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
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)
draw lane geometry (use their own function due colors)
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:139
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:135
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:129
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)
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.
std::vector< double > myShapeRotations
The rotations of the shape (note: Always size = myShape.size()-1)
Definition: GUIGeometry.h:132
static void drawParentLine(const GUIVisualizationSettings &s, const Position &parent, const Position &child, const RGBColor &color, const bool drawEntire)
draw line between parent and children (used in NETEDIT)
GUIGeometry()
default constructor
Definition: GUIGeometry.cpp:38
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:293
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:197
#define M_PI
Definition: odrSpiral.cpp:40
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