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.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#pragma once
21#include <config.h>
22
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
29
31
32
33public:
36
38 GUIGeometry(const PositionVector& shape);
39
41 GUIGeometry(const PositionVector& shape, const std::vector<double>& shapeRotations, const std::vector<double>& shapeLengths);
42
44 void updateGeometry(const PositionVector& shape);
45
47 void updateGeometry(const PositionVector& shape, const double posOverShape, const double lateralOffset);
48
50 void updateGeometry(const PositionVector& shape, double starPosOverShape, double endPosOverShape, const double lateralOffset);
51
53 void updateGeometry(const PositionVector& shape, double beginTrimPosition, double endTrimPosition,
54 const Position& extraFirstPosition, const Position& extraLastPosition);
55
57 void updateSinglePosGeometry(const Position& position, const double rotation);
58
60 void moveGeometryToSide(const double amount);
61
63 void scaleGeometry(const double scale);
64
66 const PositionVector& getShape() const;
67
69 const std::vector<double>& getShapeRotations() const;
70
72 const std::vector<double>& getShapeLengths() const;
73
76
78 static double calculateRotation(const Position& first, const Position& second);
79
81 static double calculateLength(const Position& first, const Position& second);
82
84 static void adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape, double& endPos, const PositionVector& endLaneShape);
85
87
90
92 static void drawLaneGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape, const std::vector<double>& rotations,
93 const std::vector<double>& lengths, const std::vector<RGBColor>& colors, double width, const bool onlyContour = false, const double offset = 0);
94
96 static void drawGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const GUIGeometry& geometry, const double width, double offset = 0);
97
99 static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);
100
102 static void drawGeometryPoints(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
103 const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius,
104 const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols);
105
107 static void drawMovingHint(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
108 const RGBColor& hintColor, const double radius, const double exaggeration);
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
126protected:
128 void clearGeometry();
129
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.)
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.