Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAdditionalListed.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 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// A abstract class for representation of additional listed elements
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNENet.h>
26
27#include "GNEAdditionalListed.h"
28
29// ===========================================================================
30// member method definitions
31// ===========================================================================
32
36
37
38void
40 // get end position of parent
41 const Position& parentPosition = myAdditional->getParentAdditionals().front()->getAdditionalGeometry().getShape().back();
42 // get draw position index
44 // calculate x and y position
45 const double yPosition = ((2 * shapeHeight) + ySeparation) * myDrawPositionIndex * -1;
46 // calculate y position
47 const auto startPos = parentPosition + Position(lineLenght, yPosition);
48 const auto endPos = parentPosition + Position(lineLenght + shapeWidth, yPosition);
49 // set geometries
50 myAdditional->myAdditionalGeometry.updateGeometry({startPos, endPos});
51 myInternalRectangle.updateGeometry({startPos + Position(padding, 0), endPos - Position(padding, 0)});
52 // calculate icon size
54 // calculate signPosition
55 myIconPosition = startPos + Position((2 * iconPadding) + myIconSize, 0);
56 // calculate text position
58 // now calculate lines
59 PositionVector linePositions;
60 linePositions.push_back(parentPosition);
61 linePositions.push_back(parentPosition + Position(lineLenght * 0.5, 0));
62 linePositions.push_back(startPos - Position((lineLenght * 0.5), 0));
63 linePositions.push_back(startPos);
64 myLineGeometry.updateGeometry(linePositions);
65 // update centering boundary (needed for centering)
66 myAdditional->updateCenteringBoundary(false);
67 // update geometries of all children
68 for (const auto& rerouterElement : myAdditional->getChildAdditionals()) {
69 rerouterElement->updateGeometry();
70 }
71}
72
73
74void
76 GUITexture texture, const std::string text) const {
77 // check if additional has to be drawn
78 if (myAdditional->getNet()->getViewNet()->getDataViewOptions().showAdditionals()) {
79 // get detail level
80 const auto d = s.getDetailLevel(1);
81 // draw boundaries
82 GLHelper::drawBoundary(s, myAdditional->getCenteringBoundary());
83 // draw geometry only if we'rent in drawForObjectUnderCursor mode
84 if (s.checkDrawAdditional(d, myAdditional->isAttributeCarrierSelected())) {
85 // calculate colors
86 const RGBColor baseColor = myAdditional->isAttributeCarrierSelected() ? s.colorSettings.selectedAdditionalColor : baseCol;
87 const RGBColor secondColor = baseColor.changedBrightness(-30);
88 const RGBColor textColor = myAdditional->isAttributeCarrierSelected() ? s.colorSettings.selectedAdditionalColor.changedBrightness(30) : textCol;
89 // Add layer matrix
91 // translate to front
92 myAdditional->drawInLayer(myAdditional->getType());
93 // draw lines
96 // draw extern rectangle
97 GLHelper::setColor(secondColor);
98 GUIGeometry::drawGeometry(d, myAdditional->getAdditionalGeometry(), shapeHeight);
99 // move to front
100 glTranslated(0, 0, 0.1);
101 // draw intern rectangle
102 GLHelper::setColor(baseColor);
104 // draw interval
106 // check if draw lock icon or rerouter interval icon
108 // pop layer matrix
110 // draw lock icon
112 } else {
113 // translate to front
114 glTranslated(myIconPosition.x(), myIconPosition.y(), 0.1);
115 // set White color
116 glColor3d(1, 1, 1);
117 // rotate
118 glRotated(180, 0, 0, 1);
119 // draw texture
121 // pop layer matrix
123 }
124 // draw dotted contour
125 myAdditional->myAdditionalContour.drawDottedContours(s, d, myAdditional, s.dottedContourSettings.segmentWidthSmall, true);
126 }
127 // calculate contour
128 myAdditional->myAdditionalContour.calculateContourExtrudedShape(s, d, myAdditional, myAdditional->getAdditionalGeometry().getShape(), myAdditional->getType(), shapeHeight, 1, true, true, 0,
129 nullptr, nullptr);
130 }
131}
132
133
138
139
140int
142 // filter symbols
143 std::vector<GNEAdditional*> children;
144 for (const auto& child : myAdditional->getParentAdditionals().front()->getChildAdditionals()) {
145 if (!child->getTagProperty()->isSymbol()) {
146 children.push_back(child);
147 }
148 }
149 // now get index
150 for (int i = 0; i < (int)children.size(); i++) {
151 if (children.at(i) == myAdditional) {
152 return i;
153 }
154 }
155 return 0;
156}
157
158
159std::string
161 // 10 + 3 + 10
162 if (text.size() <= 23) {
163 return text;
164 } else {
165 // get text size
166 const int textPosition = (int)text.size() - 10;
167 // declare strings
168 std::string partA, partB;
169 // resize
170 partA.reserve(10);
171 partB.reserve(10);
172 // fill both
173 for (int i = 0; i < 10; i++) {
174 partA.push_back(text.at(i));
175 partB.push_back(text.at(textPosition + i));
176 }
177 // return composition
178 return (partA + "..." + partB);
179 }
180}
181
182/****************************************************************************/
GUITexture
An enumeration of gifs used by the gui applications.
Definition GUITextures.h:31
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition GLHelper.cpp:653
static void popMatrix()
pop matrix
Definition GLHelper.cpp:135
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging).
Definition GLHelper.cpp:957
static void pushMatrix()
push matrix
Definition GLHelper.cpp:122
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition GLHelper.cpp:747
GNEAdditionalListed(GNEAdditional *additional)
default constructor
void drawListedAdditional(const GUIVisualizationSettings &s, const RGBColor baseCol, const RGBColor textCol, GUITexture texture, const std::string text) const
draw listed additional
Position getListedPositionInView() const
get listed position in view
const double ySeparation
Y separation.
int myDrawPositionIndex
draw position index
GUIGeometry myLineGeometry
vector with line geometry
const double shapeHeight
shapeHeight
Position myTextPosition
text position
const double iconPadding
icon padding
Position myIconPosition
sign position
GNEAdditional * myAdditional
pointer to additional
const double padding
padding between internal and external rectangle
GUIGeometry myInternalRectangle
internal rectangle
const double lineWidth
line width
int getDrawPositionIndex() const
get draw position index
void updateGeometryListedAdditional()
update geometry of listed additional
double myIconSize
icon size
const double shapeWidth
shape width
std::string adjustListedAdditionalText(const std::string &text) const
adjust listed additional text
const double lineLenght
line offset (must be divisible by 2)
static void drawGeometry(const GUIVisualizationSettings::Detail d, const GUIGeometry &geometry, const double width, double offset=0)
draw geometry
static GUIGlID getTexture(GUITexture which)
returns a texture previously defined in the enum GUITexture
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
Stores the information about how to visualize structures.
bool checkDrawAdditional(Detail d, const bool selected) const
check if draw additionals
Detail getDetailLevel(const double exaggeration) const
return the detail level
GUIVisualizationColorSettings colorSettings
color settings
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
GUIVisualizationAdditionalSettings additionalSettings
Additional settings.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition RGBColor.cpp:200
@ FONS_ALIGN_MIDDLE
Definition fontstash.h:47
@ FONS_ALIGN_LEFT
Definition fontstash.h:42
static bool checkDrawing(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const double exaggeration)
check if icon can be drawn
static void drawLockIcon(const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, GUIGlObjectType type, const Position position, const double exaggeration, const double size=0.5, const double offsetx=0, const double offsety=0)
draw lock icon
static const RGBColor connectionColor
connection color
RGBColor selectedAdditionalColor
additional selection color (busStops, Detectors...)
static const double segmentWidthSmall
width of small dotted contour segments