Eclipse SUMO - Simulation of Urban MObility
GUIGeometry.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-2024 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 #pragma once
21 #include <config.h>
22 
26 
27 // ===========================================================================
28 // class definitions
29 // ===========================================================================
30 
31 class GUIGeometry {
32 
33 public:
35  GUIGeometry();
36 
38  GUIGeometry(const PositionVector& shape);
39 
41  GUIGeometry(const PositionVector& shape, const std::vector<double>& shapeRotations,
42  const std::vector<double>& shapeLengths);
43 
45  void updateGeometry(const PositionVector& shape);
46 
48  void updateGeometry(const PositionVector& shape, const double posOverShape, const double lateralOffset);
49 
51  void updateGeometry(const PositionVector& shape, double starPosOverShape, double endPosOverShape,
52  const double lateralOffset);
53 
55  void updateGeometry(const PositionVector& shape, double beginTrimPosition, const Position& extraFirstPosition,
56  double endTrimPosition, const Position& extraLastPosition);
57 
59  void updateSinglePosGeometry(const Position& position, const double rotation);
60 
62  void moveGeometryToSide(const double amount);
63 
65  void scaleGeometry(const double scale);
66 
68  const PositionVector& getShape() const;
69 
71  const std::vector<double>& getShapeRotations() const;
72 
74  const std::vector<double>& getShapeLengths() const;
75 
78 
80  static double calculateRotation(const Position& first, const Position& second);
81 
83  static double calculateLength(const Position& first, const Position& second);
84 
86  static void adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape, double& endPos,
87  const PositionVector& endLaneShape);
88 
90 
93 
95  static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,
96  const double width, double offset = 0);
97 
99  static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,
100  const std::vector<RGBColor>& colors, const double width, double offset = 0);
101 
103  static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);
104 
106  static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector& shape,
107  const RGBColor& color, const double radius, const double exaggeration,
108  const bool editingElevation);
109 
111  static void drawParentLine(const GUIVisualizationSettings& s, const Position& parent, const Position& child,
112  const RGBColor& color, const bool drawEntire, const double lineWidth);
113 
115  static void drawChildLine(const GUIVisualizationSettings& s, const Position& child, const Position& parent,
116  const RGBColor& color, const bool drawEntire, const double lineWidth);
117 
119  static PositionVector getVertexCircleAroundPosition(const Position& pos, const double width, const int steps = 8);
120 
122  static void rotateOverLane(const double rot);
123 
125 
126 protected:
128  void clearGeometry();
129 
132 
135 
137  std::vector<double> myShapeRotations;
138 
140  std::vector<double> myShapeLengths;
141 
142 private:
145 
147  static int angleLookup(const double angleDeg);
148 };
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.
Definition: GUIGeometry.h:144
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)
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
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw 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:59
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:137
GUIGeometry()
default constructor
Definition: GUIGeometry.cpp:39
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.