Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEAdditionalSquared.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 squared elements
19/****************************************************************************/
20#include <config.h>
21
23#include <netedit/GNENet.h>
26
28
29// ===========================================================================
30// member method definitions
31// ===========================================================================
32
38
39
41 myAdditional(additional),
42 myPosOverView(pos),
43 myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,
45}
46
47
51
52
53void
55 // update additional geometry
56 myAdditional->myAdditionalGeometry.updateGeometry({myPosOverView - Position(1, 0), myPosOverView + Position(1, 0)});
57 // update geometries of all children
58 for (const auto& rerouterElement : myAdditional->getChildAdditionals()) {
59 rerouterElement->updateGeometry();
60 }
61}
62
63
64void
66 // remove additional from grid
67 if (updateGrid) {
68 myAdditional->getNet()->removeGLObjectFromGrid(myAdditional);
69 }
70 // now update geometry
71 myAdditional->updateGeometry();
72 // add shape boundary
73 myAdditional->myAdditionalBoundary = myAdditional->myAdditionalGeometry.getShape().getBoxBoundary();
74 // grow
75 myAdditional->myAdditionalBoundary.grow(5);
76 // add positions of all childrens (intervals and symbols)
77 for (const auto& additionalChild : myAdditional->getChildAdditionals()) {
78 myAdditional->myAdditionalBoundary.add(additionalChild->getCenteringBoundary());
79 for (const auto& secondAdditionalChild : additionalChild->getChildAdditionals()) {
80 myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getCenteringBoundary());
81 // special case for parking area rerouter
82 if (secondAdditionalChild->getParentAdditionals().size() > 1) {
83 myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getParentAdditionals().at(1)->getCenteringBoundary());
84 }
85 }
86 }
87 // add additional into RTREE again
88 if (updateGrid) {
89 myAdditional->getNet()->addGLObjectIntoGrid(myAdditional);
90 }
91}
92
93
94void
96 GUITexture texture, GUITexture selectedTexture) const {
97 // draw boundaries
98 GLHelper::drawBoundary(s, myAdditional->getCenteringBoundary());
99 // Obtain drawing exaggeration
100 const double exaggeration = myAdditional->getExaggeration(s);
101 // get detail level
102 const auto d = s.getDetailLevel(exaggeration);
103 // draw geometry only if we'rent in drawForObjectUnderCursor mode
104 if (s.checkDrawAdditional(d, myAdditional->isAttributeCarrierSelected())) {
105 // Add layer matrix
107 // translate to front
108 myAdditional->drawInLayer(myAdditional->getType());
109 // translate to position
110 glTranslated(myPosOverView.x(), myPosOverView.y(), 0);
111 // scale
112 glScaled(exaggeration, exaggeration, 1);
113 // set White color
114 glColor3d(1, 1, 1);
115 // rotate
116 glRotated(180, 0, 0, 1);
117 // draw texture
118 if (myAdditional->drawUsingSelectColor()) {
120 } else {
122 }
123 // Pop layer matrix
125 // draw lock icon
126 GNEViewNetHelper::LockIcon::drawLockIcon(d, myAdditional, myAdditional->getType(), myPosOverView, exaggeration, 0.4, 0.5, 0.5);
127 // Draw additional ID
128 myAdditional->drawAdditionalID(s);
129 // draw additional name
130 myAdditional->drawAdditionalName(s);
131 // draw dotted contour
132 myAdditional->myAdditionalContour.drawDottedContours(s, d, myAdditional, s.dottedContourSettings.segmentWidth, true);
133 }
134 // calculate contour
135 myAdditional->myAdditionalContour.calculateContourRectangleShape(s, d, myAdditional, myPosOverView, size, size, myAdditional->getType(), 0, 0, 0, exaggeration, nullptr);
136}
137
138
139
140/****************************************************************************/
GUITexture
An enumeration of gifs used by the gui applications.
Definition GUITextures.h:31
@ SUMO_ATTR_POSITION
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
void updatedSquaredGeometry()
updated squared geometry
Position myPosOverView
position over view
GNEAdditional * myAdditional
pointer to additional
void updatedSquaredCenteringBoundary(const bool updateGrid)
updated squared centering boundary
GNEMoveElementView * myMoveElementView
move element over view
void drawSquaredAdditional(const GUIVisualizationSettings &s, const double size, GUITexture texture, GUITexture selectedTexture) const
draw squared additional
GNEAdditionalSquared(GNEAdditional *additional)
default constructor
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
GUIVisualizationDottedContourSettings dottedContourSettings
dotted contour settings
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
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 double segmentWidth
width of dotted contour segments