Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/additional/GNEAdditionalSquared.cpp
185790 views
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
/****************************************************************************/
14
/// @file GNEAdditionalSquared.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2025
17
///
18
// A abstract class for representation of additional squared elements
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <netedit/elements/moving/GNEMoveElementView.h>
23
#include <netedit/GNENet.h>
24
#include <netedit/GNEViewParent.h>
25
#include <utils/gui/div/GLHelper.h>
26
27
#include "GNEAdditionalSquared.h"
28
29
// ===========================================================================
30
// member method definitions
31
// ===========================================================================
32
33
GNEAdditionalSquared::GNEAdditionalSquared(GNEAdditional* additional) :
34
myAdditional(additional),
35
myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,
36
SUMO_ATTR_POSITION, myPosOverView)) {
37
}
38
39
40
GNEAdditionalSquared::GNEAdditionalSquared(GNEAdditional* additional, const Position pos) :
41
myAdditional(additional),
42
myPosOverView(pos),
43
myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,
44
SUMO_ATTR_POSITION, myPosOverView)) {
45
}
46
47
48
GNEAdditionalSquared::~GNEAdditionalSquared() {
49
delete myMoveElementView;
50
}
51
52
53
void
54
GNEAdditionalSquared::updatedSquaredGeometry() {
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
64
void
65
GNEAdditionalSquared::updatedSquaredCenteringBoundary(const bool updateGrid) {
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
94
void
95
GNEAdditionalSquared::drawSquaredAdditional(const GUIVisualizationSettings& s, const double size,
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
106
GLHelper::pushMatrix();
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()) {
119
GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(selectedTexture), size);
120
} else {
121
GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(texture), size);
122
}
123
// Pop layer matrix
124
GLHelper::popMatrix();
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
/****************************************************************************/
141
142