Path: blob/main/src/netedit/elements/additional/GNEAdditionalSquared.cpp
185790 views
/****************************************************************************/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 GNEAdditionalSquared.cpp14/// @author Pablo Alvarez Lopez15/// @date Oct 202516///17// A abstract class for representation of additional squared elements18/****************************************************************************/19#include <config.h>2021#include <netedit/elements/moving/GNEMoveElementView.h>22#include <netedit/GNENet.h>23#include <netedit/GNEViewParent.h>24#include <utils/gui/div/GLHelper.h>2526#include "GNEAdditionalSquared.h"2728// ===========================================================================29// member method definitions30// ===========================================================================3132GNEAdditionalSquared::GNEAdditionalSquared(GNEAdditional* additional) :33myAdditional(additional),34myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,35SUMO_ATTR_POSITION, myPosOverView)) {36}373839GNEAdditionalSquared::GNEAdditionalSquared(GNEAdditional* additional, const Position pos) :40myAdditional(additional),41myPosOverView(pos),42myMoveElementView(new GNEMoveElementView(additional, GNEMoveElementView::AttributesFormat::POSITION,43SUMO_ATTR_POSITION, myPosOverView)) {44}454647GNEAdditionalSquared::~GNEAdditionalSquared() {48delete myMoveElementView;49}505152void53GNEAdditionalSquared::updatedSquaredGeometry() {54// update additional geometry55myAdditional->myAdditionalGeometry.updateGeometry({myPosOverView - Position(1, 0), myPosOverView + Position(1, 0)});56// update geometries of all children57for (const auto& rerouterElement : myAdditional->getChildAdditionals()) {58rerouterElement->updateGeometry();59}60}616263void64GNEAdditionalSquared::updatedSquaredCenteringBoundary(const bool updateGrid) {65// remove additional from grid66if (updateGrid) {67myAdditional->getNet()->removeGLObjectFromGrid(myAdditional);68}69// now update geometry70myAdditional->updateGeometry();71// add shape boundary72myAdditional->myAdditionalBoundary = myAdditional->myAdditionalGeometry.getShape().getBoxBoundary();73// grow74myAdditional->myAdditionalBoundary.grow(5);75// add positions of all childrens (intervals and symbols)76for (const auto& additionalChild : myAdditional->getChildAdditionals()) {77myAdditional->myAdditionalBoundary.add(additionalChild->getCenteringBoundary());78for (const auto& secondAdditionalChild : additionalChild->getChildAdditionals()) {79myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getCenteringBoundary());80// special case for parking area rerouter81if (secondAdditionalChild->getParentAdditionals().size() > 1) {82myAdditional->myAdditionalBoundary.add(secondAdditionalChild->getParentAdditionals().at(1)->getCenteringBoundary());83}84}85}86// add additional into RTREE again87if (updateGrid) {88myAdditional->getNet()->addGLObjectIntoGrid(myAdditional);89}90}919293void94GNEAdditionalSquared::drawSquaredAdditional(const GUIVisualizationSettings& s, const double size,95GUITexture texture, GUITexture selectedTexture) const {96// draw boundaries97GLHelper::drawBoundary(s, myAdditional->getCenteringBoundary());98// Obtain drawing exaggeration99const double exaggeration = myAdditional->getExaggeration(s);100// get detail level101const auto d = s.getDetailLevel(exaggeration);102// draw geometry only if we'rent in drawForObjectUnderCursor mode103if (s.checkDrawAdditional(d, myAdditional->isAttributeCarrierSelected())) {104// Add layer matrix105GLHelper::pushMatrix();106// translate to front107myAdditional->drawInLayer(myAdditional->getType());108// translate to position109glTranslated(myPosOverView.x(), myPosOverView.y(), 0);110// scale111glScaled(exaggeration, exaggeration, 1);112// set White color113glColor3d(1, 1, 1);114// rotate115glRotated(180, 0, 0, 1);116// draw texture117if (myAdditional->drawUsingSelectColor()) {118GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(selectedTexture), size);119} else {120GUITexturesHelper::drawTexturedBox(GUITextureSubSys::getTexture(texture), size);121}122// Pop layer matrix123GLHelper::popMatrix();124// draw lock icon125GNEViewNetHelper::LockIcon::drawLockIcon(d, myAdditional, myAdditional->getType(), myPosOverView, exaggeration, 0.4, 0.5, 0.5);126// Draw additional ID127myAdditional->drawAdditionalID(s);128// draw additional name129myAdditional->drawAdditionalName(s);130// draw dotted contour131myAdditional->myAdditionalContour.drawDottedContours(s, d, myAdditional, s.dottedContourSettings.segmentWidth, true);132}133// calculate contour134myAdditional->myAdditionalContour.calculateContourRectangleShape(s, d, myAdditional, myPosOverView, size, size, myAdditional->getType(), 0, 0, 0, exaggeration, nullptr);135}136137138139/****************************************************************************/140141142