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
22#include <netedit/GNENet.h>
25
27
28// ===========================================================================
29// member method definitions
30// ===========================================================================
31
33 myAdditional(additional),
34 myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,
35 SUMO_ATTR_POSITION, myPosOverView)) {
36}
37
38
40 myAdditional(additional),
41 myPosOverView(pos),
42 myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,
43 SUMO_ATTR_POSITION, myPosOverView)) {
44}
45
46
50
51
52void
54 // update additional geometry
56 // update geometries of all children
57 for (const auto& rerouterElement : myAdditional->getChildAdditionals()) {
58 rerouterElement->updateGeometry();
59 }
60}
61
62
63void
65 // remove additional from grid
66 if (updateGrid) {
68 }
69 // now update geometry
71 // add shape boundary
73 // grow
75 // add positions of all childrens (intervals and symbols)
76 for (const auto& additionalChild : myAdditional->getChildAdditionals()) {
77 myAdditional->myAdditionalBoundary.add(additionalChild->getCenteringBoundary());
78 for (const auto& secondAdditionalChild : additionalChild->getChildAdditionals()) {
79 myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getCenteringBoundary());
80 // special case for parking area rerouter
81 if (secondAdditionalChild->getParentAdditionals().size() > 1) {
82 myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getParentAdditionals().at(1)->getCenteringBoundary());
83 }
84 }
85 }
86 // add additional into RTREE again
87 if (updateGrid) {
89 }
90}
91
92
93void
95 GUITexture texture, GUITexture selectedTexture) const {
96 // draw boundaries
98 // Obtain drawing exaggeration
99 const double exaggeration = myAdditional->getExaggeration(s);
100 // get detail level
101 const auto d = s.getDetailLevel(exaggeration);
102 // draw geometry only if we'rent in drawForObjectUnderCursor mode
104 // Add layer matrix
106 // translate to front
108 // translate to position
109 glTranslated(myPosOverView.x(), myPosOverView.y(), 0);
110 // scale
111 glScaled(exaggeration, exaggeration, 1);
112 // set White color
113 glColor3d(1, 1, 1);
114 // rotate
115 glRotated(180, 0, 0, 1);
116 // draw texture
119 } else {
121 }
122 // Pop layer matrix
124 // draw lock icon
126 // Draw additional ID
128 // draw additional name
130 // draw dotted contour
132 }
133 // calculate contour
135}
136
137
138
139/****************************************************************************/
GUITexture
An enumeration of gifs used by the gui applications.
Definition GUITextures.h:31
@ SUMO_ATTR_POSITION
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition Boundary.cpp:75
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
static void popMatrix()
pop matrix
Definition GLHelper.cpp:131
static void drawBoundary(const GUIVisualizationSettings &s, const Boundary &b)
Draw a boundary (used for debugging)
Definition GLHelper.cpp:952
static void pushMatrix()
push matrix
Definition GLHelper.cpp:118
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
GNEContour myAdditionalContour
variable used for draw additional contours
GUIGeometry myAdditionalGeometry
geometry to be precomputed in updateGeometry(...)
void drawAdditionalID(const GUIVisualizationSettings &s) const
draw additional ID
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
void drawAdditionalName(const GUIVisualizationSettings &s) const
draw additional name
Boundary myAdditionalBoundary
Additional Boundary (used only by additionals placed over grid)
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
bool isAttributeCarrierSelected() const
check if attribute carrier is selected
bool drawUsingSelectColor() const
check if attribute carrier must be drawn using selecting color.
void drawInLayer(const double typeOrLayer, const double extraOffset=0) const
draw element in the given layer, or in front if corresponding flag is enabled
GNENet * getNet() const
get pointer to net
virtual void updateGeometry()=0
update pre-computed geometry information
bool drawDottedContours(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GNEAttributeCarrier *AC, const double lineWidth, const bool addOffset) const
draw dotted contours (basics, select, delete, inspect...)
void calculateContourRectangleShape(const GUIVisualizationSettings &s, const GUIVisualizationSettings::Detail d, const GUIGlObject *glObject, const Position &pos, const double width, const double height, const double layer, const double offsetX, const double offsetY, const double rot, const double scale, const GUIGlObject *boundaryParent) const
calculate contour (for rectangled elements)
const GNEHierarchicalContainerChildren< GNEAdditional * > & getChildAdditionals() const
return child additionals
void addGLObjectIntoGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1440
void removeGLObjectFromGrid(GNEAttributeCarrier *AC)
add GL Object into net
Definition GNENet.cpp:1450
const PositionVector & getShape() const
The shape of the additional element.
void updateGeometry(const PositionVector &shape)
update entire geometry
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
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
double x() const
Returns the x-position.
Definition Position.h:52
double y() const
Returns the y-position.
Definition Position.h:57
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
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