/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 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 GNEFrame.cpp14/// @author Pablo Alvarez Lopez15/// @date Jun 201616///17// The Widget for add additional elements18/****************************************************************************/1920#include <netedit/dialogs/GNEHelpAttributesDialog.h>21#include <netedit/GNEApplicationWindow.h>22#include <netedit/GNETagProperties.h>23#include <netedit/GNEViewNet.h>24#include <netedit/GNEViewParent.h>25#include <netedit/elements/GNEAttributeCarrier.h>26#include <utils/gui/div/GUIDesigns.h>27#include <utils/gui/windows/GUIAppEnum.h>2829#include "GNEFrame.h"3031// ===========================================================================32// static members33// ===========================================================================3435FXFont* GNEFrame::myFrameHeaderFont = nullptr;3637// ===========================================================================38// method definitions39// ===========================================================================4041GNEFrame::GNEFrame(GNEViewParent* viewParent, GNEViewNet* viewNet, const std::string& frameLabel) :42FXVerticalFrame(viewParent->getFramesArea(), GUIDesignAuxiliarFrame),43myViewNet(viewNet) {4445// fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)46int i = 0;47while (SUMOXMLDefinitions::attrs[i].key != SUMO_ATTR_NOTHING) {48int key = SUMOXMLDefinitions::attrs[i].key;49assert(key >= 0);50while (key >= (int)myPredefinedTagsMML.size()) {51myPredefinedTagsMML.push_back("");52}53myPredefinedTagsMML[key] = SUMOXMLDefinitions::attrs[i].str;54i++;55}5657// Create font only one time58if (myFrameHeaderFont == nullptr) {59myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);60}6162// Create frame for header63myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);6465// Create frame for left elements of header (By default unused)66myHeaderLeftFrame = new FXHorizontalFrame(myHeaderFrame, GUIDesignAuxiliarHorizontalFrameCenteredVertically);67myHeaderLeftFrame->hide();6869// Create title frame70myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);7172// Create frame for right elements of header (By default unused)73myHeaderRightFrame = new FXHorizontalFrame(myHeaderFrame, GUIDesignAuxiliarHorizontalFrameCenteredVertically);74myHeaderRightFrame->hide();7576// Add separator77new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);7879// Create scroll windows with fixed width for contents80myScrollWindowsContents = new FXScrollWindow(this, GUIDesignScrollWindowFixedWidth(10));8182// Create frame for contents (in which GroupBox will be placed)83myContentFrame = new FXVerticalFrame(myScrollWindowsContents, GUIDesignAuxiliarFrameFixedWidth(0));8485// Set font of header86myFrameHeaderLabel->setFont(myFrameHeaderFont);8788// Hide Frame89FXVerticalFrame::hide();90}919293GNEFrame::~GNEFrame() {94// delete frame header only one time95if (myFrameHeaderFont) {96delete myFrameHeaderFont;97myFrameHeaderFont = nullptr;98}99}100101102void103GNEFrame::focusUpperElement() {104myFrameHeaderLabel->setFocus();105}106107108void109GNEFrame::show() {110// show scroll window111FXVerticalFrame::show();112// Show and update Frame Area in which this GNEFrame is placed113myViewNet->getViewParent()->showFramesArea();114}115116117void118GNEFrame::hide() {119// hide scroll window120FXVerticalFrame::hide();121// Hide Frame Area in which this GNEFrame is placed122myViewNet->getViewParent()->hideFramesArea();123}124125126void127GNEFrame::setFrameWidth(const int newWidth) {128// set scroll windows size (minus MARGIN)129myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);130// calculate new contentWidth131int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);132// adjust contents frame133myContentFrame->setWidth(contentWidth);134// set size of all contents frame children135for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {136child->setWidth(contentWidth);137}138// call frame width updated139frameWidthUpdated();140}141142143GNEViewNet*144GNEFrame::getViewNet() const {145return myViewNet;146}147148149FXVerticalFrame*150GNEFrame::getContentFrame() const {151return myContentFrame;152}153154155FXLabel*156GNEFrame::getFrameHeaderLabel() const {157return myFrameHeaderLabel;158}159160161FXFont*162GNEFrame::getFrameHeaderFont() const {163return myFrameHeaderFont;164}165166167int168GNEFrame::getScrollBarWidth() const {169if (myScrollWindowsContents->verticalScrollBar()->shown()) {170return myScrollWindowsContents->verticalScrollBar()->getWidth();171} else {172return 0;173}174}175176177void178GNEFrame::openHelpAttributesDialog(const GNEAttributeCarrier* AC) const {179auto GNEApp = myViewNet->getViewParent()->getGNEAppWindows();180// open help dialog with attributes of the given attribute carrier181GNEHelpAttributesDialog(GNEApp, AC);182}183184185void186GNEFrame::updateFrameAfterUndoRedo() {187// this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)188}189190191void192GNEFrame::frameWidthUpdated() {193// this function can be reimplemented in all child frames194}195196// ---------------------------------------------------------------------------197// GNEFrame - protected methods198// ---------------------------------------------------------------------------199200void201GNEFrame::tagSelected() {202// this function has to be reimplemented in all child frames that uses a GNETagSelector module203}204205206void207GNEFrame::demandElementSelected() {208// this function has to be reimplemented in all child frames that uses a DemandElementSelector209}210211212bool213GNEFrame::shapeDrawed() {214// this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)215return false;216}217218219void220GNEFrame::attributeUpdated(SumoXMLAttr /*attribute*/) {221// this function has to be reimplemented in all child frames that uses a AttributeEditor module222}223224225void226GNEFrame::selectedOverlappedElement(GNEAttributeCarrier* /* AC */) {227// this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection228}229230231bool232GNEFrame::createPath(const bool /*useLastRoute*/) {233// this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath234return false;235}236237238const std::vector<std::string>&239GNEFrame::getPredefinedTagsMML() const {240return myPredefinedTagsMML;241}242243244FXLabel*245GNEFrame::buildRainbow(FXComposite* parent) {246// create label for color information247FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));248// create frame for color scale249FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);250for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {251FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));252colorLabel->setBackColor(MFXUtils::getFXColor(color));253}254return label;255// for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup256} // NOSONAR257258/****************************************************************************/259260261