/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GUIGeometry.h14/// @author Pablo Alvarez Lopez15/// @date Oct 202016///17// File for geometry classes and functions18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/geom/PositionVector.h>23#include <utils/gui/globjects/GUIGlObject.h>24#include <utils/gui/settings/GUIVisualizationSettings.h>2526// ===========================================================================27// class definitions28// ===========================================================================2930class GUIGeometry {3132public:33/// @brief default constructor34GUIGeometry();3536/// @brief parameter constructor37GUIGeometry(const PositionVector& shape);3839/// @brief parameter constructor40GUIGeometry(const PositionVector& shape, const std::vector<double>& shapeRotations,41const std::vector<double>& shapeLengths);4243/// @brief update entire geometry44void updateGeometry(const PositionVector& shape);4546/// @brief update geometry (using a shape, a position over shape and a lateral offset)47void updateGeometry(const PositionVector& shape, const double posOverShape, const double lateralOffset);4849/// @brief update geometry (using a shape, a starPos over shape, a endPos and a lateral offset)50void updateGeometry(const PositionVector& shape, double starPosOverShape, double endPosOverShape,51const double lateralOffset);5253/// @brief update geometry (using a shape to be trimmed)54void updateGeometry(const PositionVector& shape, double beginTrimPosition, const Position& extraFirstPosition,55double endTrimPosition, const Position& extraLastPosition);5657/// @brief update position and rotation58void updateSinglePosGeometry(const Position& position, const double rotation);5960/// @brief clear geometry61void clearGeometry();6263/// @brief move current shape to side64void moveGeometryToSide(const double amount);6566/// @brief scale geometry67void scaleGeometry(const double scale);6869/// @brief The shape of the additional element70const PositionVector& getShape() const;7172/// @brief The rotations of the single shape parts73const std::vector<double>& getShapeRotations() const;7475/// @brief The lengths of the single shape parts76const std::vector<double>& getShapeLengths() const;7778/// @name calculation functions79/// @{8081/// @brief return angle between two points (used in geometric calculations)82static double calculateRotation(const Position& first, const Position& second);8384/// @brief return length between two points (used in geometric calculations)85static double calculateLength(const Position& first, const Position& second);8687/// @brief adjust start and end positions in geometric path88static void adjustStartPosGeometricPath(double& startPos, const PositionVector& startLaneShape, double& endPos,89const PositionVector& endLaneShape);9091/// @}9293/// @name draw functions94/// @{9596/// @brief draw geometry97static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,98const double width, double offset = 0);99100/// @brief draw colored geometry101static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry& geometry,102const std::vector<RGBColor>& colors, const double width, double offset = 0);103104/// @brief draw contour geometry105static void drawContourGeometry(const GUIGeometry& geometry, const double width, const bool drawExtremes = false);106107/// @brief draw geometry points108static void drawGeometryPoints(const GUIVisualizationSettings::Detail d, const PositionVector& shape,109const RGBColor& color, const double radius, const double exaggeration,110const bool editingElevation);111112/// @brief draw line between parent and children (used in netedit)113static void drawParentLine(const GUIVisualizationSettings& s, const Position& parent, const Position& child,114const RGBColor& color, const bool drawEntire, const double lineWidth);115116/// @brief draw line between child and parent (used in netedit)117static void drawChildLine(const GUIVisualizationSettings& s, const Position& child, const Position& parent,118const RGBColor& color, const bool drawEntire, const double lineWidth);119120/// @brief get a circle around the given position121static PositionVector getVertexCircleAroundPosition(const Position& pos, const double width, const int steps = 8);122123/// @brief rotate over lane (used by Lock icons, detector logos, etc.)124static void rotateOverLane(const double rot);125126/// @}127128protected:129/// @brief calculate shape rotations and lengths130void calculateShapeRotationsAndLengths();131132/// @brief element shape133PositionVector myShape;134135/// @brief The rotations of the shape (note: Always size = myShape.size()-1)136std::vector<double> myShapeRotations;137138/// @brief The lengths of the shape (note: Always size = myShape.size()-1)139std::vector<double> myShapeLengths;140141private:142/// @brief Storage for precomputed sin/cos-values describing a circle143static PositionVector myCircleCoords;144145/// @brief normalize angle for lookup in myCircleCoords146static int angleLookup(const double angleDeg);147};148149150