/****************************************************************************/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 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// defines33// ===========================================================================3435#define PADDINGFRAME 10 // (5+5)36#define VERTICALSCROLLBARWIDTH 153738// ===========================================================================39// static members40// ===========================================================================4142FXFont* GNEFrame::myFrameHeaderFont = nullptr;4344// ===========================================================================45// method definitions46// ===========================================================================4748GNEFrame::GNEFrame(GNEViewParent* viewParent, GNEViewNet* viewNet, const std::string& frameLabel) :49FXVerticalFrame(viewParent->getFramesArea(), GUIDesignAuxiliarFrame),50myViewNet(viewNet) {5152// fill myPredefinedTagsMML (to avoid repeating this fill during every element creation)53int i = 0;54while (SUMOXMLDefinitions::attrs[i].key != SUMO_ATTR_NOTHING) {55int key = SUMOXMLDefinitions::attrs[i].key;56assert(key >= 0);57while (key >= (int)myPredefinedTagsMML.size()) {58myPredefinedTagsMML.push_back("");59}60myPredefinedTagsMML[key] = SUMOXMLDefinitions::attrs[i].str;61i++;62}6364// Create font only one time65if (myFrameHeaderFont == nullptr) {66myFrameHeaderFont = new FXFont(getApp(), "Arial", 14, FXFont::Bold);67}6869// Create frame for header70myHeaderFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);7172// Create frame for left elements of header (By default unused)73myHeaderLeftFrame = new FXHorizontalFrame(myHeaderFrame, GUIDesignAuxiliarHorizontalFrameCenteredVertically);74myHeaderLeftFrame->hide();7576// Create title frame77myFrameHeaderLabel = new FXLabel(myHeaderFrame, frameLabel.c_str(), nullptr, GUIDesignLabelFrameInformation);7879// Create frame for right elements of header (By default unused)80myHeaderRightFrame = new FXHorizontalFrame(myHeaderFrame, GUIDesignAuxiliarHorizontalFrameCenteredVertically);81myHeaderRightFrame->hide();8283// Add separator84new FXHorizontalSeparator(this, GUIDesignHorizontalSeparator);8586// Create scroll windows with fixed width for contents87myScrollWindowsContents = new FXScrollWindow(this, GUIDesignScrollWindowFixedWidth(10));8889// Create frame for contents (in which GroupBox will be placed)90myContentFrame = new FXVerticalFrame(myScrollWindowsContents, GUIDesignAuxiliarFrameFixedWidth(0));9192// Set font of header93myFrameHeaderLabel->setFont(myFrameHeaderFont);9495// Hide Frame96FXVerticalFrame::hide();97}9899100GNEFrame::~GNEFrame() {101// delete frame header only one time102if (myFrameHeaderFont) {103delete myFrameHeaderFont;104myFrameHeaderFont = nullptr;105}106}107108109void110GNEFrame::focusUpperElement() {111myFrameHeaderLabel->setFocus();112}113114115void116GNEFrame::show() {117// show scroll window118FXVerticalFrame::show();119// Show and update Frame Area in which this GNEFrame is placed120myViewNet->getViewParent()->showFramesArea();121}122123124void125GNEFrame::hide() {126// hide scroll window127FXVerticalFrame::hide();128// Hide Frame Area in which this GNEFrame is placed129myViewNet->getViewParent()->hideFramesArea();130}131132133void134GNEFrame::setFrameWidth(const int newWidth) {135// set scroll windows size (minus MARGIN)136myScrollWindowsContents->setWidth(newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1);137// calculate new contentWidth138int contentWidth = (newWidth - GUIDesignFrameAreaMargin - DEFAULT_SPACING - 1 - 15);139// adjust contents frame140myContentFrame->setWidth(contentWidth);141// set size of all contents frame children142for (auto child = myContentFrame->getFirst(); child != nullptr; child = child->getNext()) {143child->setWidth(contentWidth);144}145// call frame width updated146frameWidthUpdated();147}148149150GNEViewNet*151GNEFrame::getViewNet() const {152return myViewNet;153}154155156FXVerticalFrame*157GNEFrame::getContentFrame() const {158return myContentFrame;159}160161162FXLabel*163GNEFrame::getFrameHeaderLabel() const {164return myFrameHeaderLabel;165}166167168FXFont*169GNEFrame::getFrameHeaderFont() const {170return myFrameHeaderFont;171}172173174int175GNEFrame::getScrollBarWidth() const {176if (myScrollWindowsContents->verticalScrollBar()->shown()) {177return myScrollWindowsContents->verticalScrollBar()->getWidth();178} else {179return 0;180}181}182183184void185GNEFrame::openHelpAttributesDialog(const GNEAttributeCarrier* AC) const {186// open help dialog with attributes of the given attribute carrier187GNEHelpAttributesDialog(myViewNet->getViewParent()->getGNEAppWindows(), AC);188}189190191void192GNEFrame::updateFrameAfterUndoRedo() {193// this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)194}195196197void198GNEFrame::frameWidthUpdated() {199// this function can be reimplemented in all child frames200}201202// ---------------------------------------------------------------------------203// GNEFrame - protected methods204// ---------------------------------------------------------------------------205206void207GNEFrame::tagSelected() {208// this function has to be reimplemented in all child frames that uses a GNETagSelector module209}210211212void213GNEFrame::demandElementSelected() {214// this function has to be reimplemented in all child frames that uses a DemandElementSelector215}216217218bool219GNEFrame::shapeDrawed() {220// this function has to be reimplemented in all child frames that needs to draw a polygon (for example, GNEFrame or GNETAZFrame)221return false;222}223224225void226GNEFrame::attributeUpdated(SumoXMLAttr /*attribute*/) {227// this function has to be reimplemented in all child frames that uses a AttributeEditor module228}229230231void232GNEFrame::selectedOverlappedElement(GNEAttributeCarrier* /* AC */) {233// this function has to be reimplemented in all child frames that uses a GNEOverlappedInspection234}235236237bool238GNEFrame::createPath(const bool /*useLastRoute*/) {239// this function has to be reimplemented in all child frames that uses a path or consecutiveLanePath240return false;241}242243244const std::vector<std::string>&245GNEFrame::getPredefinedTagsMML() const {246return myPredefinedTagsMML;247}248249250FXLabel*251GNEFrame::buildRainbow(FXComposite* parent) {252// create label for color information253FXLabel* label = new FXLabel(parent, TL("Scale: Min -> Max"), nullptr, GUIDesignLabelThick(JUSTIFY_NORMAL));254// create frame for color scale255FXHorizontalFrame* horizontalFrameColors = new FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame);256for (const auto& color : GNEViewNetHelper::getRainbowScaledColors()) {257FXLabel* colorLabel = new FXLabel(horizontalFrameColors, "", nullptr, GUIDesignLabel(JUSTIFY_LEFT));258colorLabel->setBackColor(MFXUtils::getFXColor(color));259}260return label;261// for whatever reason, sonar complains in the next line that horizontalFrameColors may leak, but fox does the cleanup262} // NOSONAR263264/****************************************************************************/265266267