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 
30 class GUIGeometry {
31 
32 
33 public:
35  GUIGeometry();
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 scaleGeometry(const double scale);
61 
63  const PositionVector& getShape() const;
64 
66  const std::vector<double>& getShapeRotations() const;
67 
69  const std::vector<double>& getShapeLengths() const;
70 
73 
75  static double calculateRotation(const Position& first, const Position& second);
76 
78  static double calculateLength(const Position& first, const Position& second);
79 
81  static void adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape, double& endPos, const PositionVector& endLaneShape);
82 
84 
87 
89  static void drawLaneGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape, const std::vector<double>& rotations,
90  const std::vector<double>& lengths, const std::vector<RGBColor>& colors, double width, const bool onlyContour = false);
91 
93  static void drawGeometry(const GUIVisualizationSettings& s, const Position& mousePos, const GUIGeometry& geometry, const double width, double offset = 0);
94 
96  static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);
97 
99  static void drawGeometryPoints(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
100  const RGBColor& geometryPointColor, const RGBColor& textColor, const double radius,
101  const double exaggeration, const bool editingElevation, const bool drawExtremeSymbols);
102 
104  static void drawMovingHint(const GUIVisualizationSettings& s, const Position& mousePos, const PositionVector& shape,
105  const RGBColor& hintColor, const double radius, const double exaggeration);
106 
108  static void drawParentLine(const GUIVisualizationSettings& s, const Position& parent, const Position& child, const RGBColor& color, const bool drawEntire);
109 
111  static void drawChildLine(const GUIVisualizationSettings& s, const Position& child, const Position& parent, const RGBColor& color, const bool drawEntire);
112 
114  static PositionVector getVertexCircleAroundPosition(const Position& pos, const double width, const int steps = 8);
115 
117  static void rotateOverLane(const double rot);
118 
120 
121 protected:
123  void clearGeometry();
124 
127 
130 
132  std::vector<double> myShapeRotations;
133 
135  std::vector<double> myShapeLengths;
136 
137 private:
140 
142  static int angleLookup(const double angleDeg);
143 };
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.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.