Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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
32
33public:
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 clearGeometry();
63
65 void moveGeometryToSide(const double amount);
66
68 void scaleGeometry(const double scale);
69
71 const PositionVector& getShape() const;
72
74 const std::vector<double>& getShapeRotations() const;
75
77 const std::vector<double>& getShapeLengths() const;
78
81
83 static double calculateRotation(const Position& first, const Position& second);
84
86 static double calculateLength(const Position& first, const Position& second);
87
89 static void adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape, double& endPos,
90 const PositionVector& endLaneShape);
91
93
96
98 static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,
99 const double width, double offset = 0);
100
102 static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,
103 const std::vector<RGBColor>& colors, const double width, double offset = 0);
104
106 static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);
107
110 const RGBColor& color, const double radius, const double exaggeration,
111 const bool editingElevation);
112
114 static void drawParentLine(const GUIVisualizationSettings& s, const Position& parent, const Position& child,
115 const RGBColor& color, const bool drawEntire, const double lineWidth);
116
118 static void drawChildLine(const GUIVisualizationSettings& s, const Position& child, const Position& parent,
119 const RGBColor& color, const bool drawEntire, const double lineWidth);
120
122 static PositionVector getVertexCircleAroundPosition(const Position& pos, const double width, const int steps = 8);
123
125 static void rotateOverLane(const double rot);
126
128
129protected:
132
135
137 std::vector<double> myShapeRotations;
138
140 std::vector<double> myShapeLengths;
141
142private:
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.
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.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.