Path: blob/main/src/netedit/frames/demand/GNEDistributionFrame.h
194347 views
/****************************************************************************/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 GNEDistributionFrame.h14/// @author Pablo Alvarez Lopez15/// @date Jun 202316///17// The Widget for edit distribution elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/frames/GNEFrame.h>23#include <netedit/frames/common/GNEGroupBoxModule.h>24#include <utils/gui/images/GUIIcons.h>25#include <utils/xml/SUMOXMLDefinitions.h>2627// ===========================================================================28// class definitions29// ===========================================================================3031class GNEAttributesEditor;32class GNEDemandElement;33class MFXComboBoxIcon;34class MFXTextFieldIcon;3536// ===========================================================================37// class definitions38// ===========================================================================3940class GNEDistributionFrame {4142public:43// ===========================================================================44// class declaration45// ===========================================================================4647class DistributionValuesEditor;48class DistributionSelector;4950// ===========================================================================51// class DistributionEditor52// ===========================================================================5354class DistributionEditor : public GNEGroupBoxModule {55/// @brief FOX-declaration56FXDECLARE(GNEDistributionFrame::DistributionEditor)5758/// @brief declare friend class59friend class DistributionValuesEditor;6061public:62/// @brief constructor63DistributionEditor(GNEFrame* frameParent, SumoXMLTag distributionTag, GUIIcon icon);6465/// @brief destructor66~DistributionEditor();6768/// @brief get distribution tag69SumoXMLTag getDistributionTag() const;7071/// @name FOX-callbacks72/// @{7374/// @brief Called when "create distribution" button is clicked75long onCmdCreateDistribution(FXObject*, FXSelector, void*);7677/// @brief Called when "Delete distribution" button is clicked78long onCmdDeleteDistribution(FXObject*, FXSelector, void*);7980/// @brief Called when "Delete distribution" button is updated81long onUpdDeleteDistribution(FXObject* sender, FXSelector, void*);8283/// @}8485protected:86/// @brief FOX needs this87FOX_CONSTRUCTOR(DistributionEditor)8889private:90/// @brief pointer to frame parent91GNEFrame* myFrameParent;9293/// @briuef distribution tag94SumoXMLTag myDistributionTag;9596/// @brief distribution selector97DistributionSelector* myDistributionSelector = nullptr;9899/// @brief "create Distribution" button100MFXButtonTooltip* myCreateDistributionButton = nullptr;101102/// @brief "delete Distribution" button103MFXButtonTooltip* myDeleteDistributionButton = nullptr;104105/// @brief Invalidated copy constructor.106DistributionEditor(const DistributionEditor&) = delete;107108/// @brief Invalidated assignment operator109DistributionEditor& operator=(const DistributionEditor& src) = delete;110};111112// ===========================================================================113// class DistributionSelector114// ===========================================================================115116class DistributionSelector : public GNEGroupBoxModule {117/// @brief FOX-declaration118FXDECLARE(GNEDistributionFrame::DistributionSelector)119120/// @brief declare friend class121friend class DistributionValuesEditor;122123public:124/// @brief constructor125DistributionSelector(GNEFrame* frameParent);126127/// @brief destructor128~DistributionSelector();129130/// @brief refresh modul131void setDistribution(GNEDemandElement* distribution);132133/// @brief current distribution134GNEDemandElement* getCurrentDistribution() const;135136/// @brief refresh distribution IDs (only call when user change ID in internal attributes)137void refreshDistributionIDs();138139/// @brief refresh modul140void refreshDistributionSelector();141142/// @name FOX-callbacks143/// @{144145/// @brief Called when the user select distribution in ComboBox146long onCmdSelectDistribution(FXObject*, FXSelector, void*);147148/// @brief update distribution comboBox149long onCmdUpdateDistribution(FXObject* sender, FXSelector, void*);150151/// @}152153protected:154/// @brief FOX need this155FOX_CONSTRUCTOR(DistributionSelector)156157/// @brief fill distribution comboBox158std::map<std::string, GNEDemandElement*> fillDistributionComboBox();159160private:161/// @brief pointer to Frame Parent162GNEFrame* myFrameParent;163164/// @brief pointer to distribution editor165DistributionEditor* myDistributionEditor = nullptr;166167/// @brief attributes editor168GNEAttributesEditor* myAttributesEditor = nullptr;169170/// @brief distribution values editor171DistributionValuesEditor* myDistributionValuesEditor = nullptr;172173/// @brief comboBox with the list of distributions174MFXComboBoxIcon* myDistributionsComboBox = nullptr;175176/// @brief current distribution element177GNEDemandElement* myCurrentDistribution = nullptr;178179/// @brief Invalidated copy constructor.180DistributionSelector(const DistributionSelector&) = delete;181182/// @brief Invalidated assignment operator183DistributionSelector& operator=(const DistributionSelector& src) = delete;184};185186// ===========================================================================187// class DistributionRow188// ===========================================================================189190class DistributionRow : protected FXHorizontalFrame {191/// @brief FOX-declaration192FXDECLARE(GNEDistributionFrame::DistributionRow)193194public:195/// @brief constructor for key-probability attributes196DistributionRow(DistributionValuesEditor* attributeEditorParent, GNEDemandElement* distributionReference);197198/// @brief destroy DistributionRow (but don't delete)199void destroy();200201/// @brief get pointer to distributionReference202GNEDemandElement* getDistributionReference() const;203204/// @brief get delete row button205MFXButtonTooltip* getDeleteRowButton() const;206207/// @name FOX-callbacks208/// @{209210/// @brief try to set new probability211long onCmdSetProbability(FXObject*, FXSelector, void*);212213/// @}214215protected:216/// @brief FOX need this217FOX_CONSTRUCTOR(DistributionRow)218219private:220/// @brief pointer to DistributionValuesEditor parent221DistributionValuesEditor* myDistributionValuesEditorParent;222223/// @brief pointer to distributionReference224GNEDemandElement* myDistributionReference = nullptr;225226/// @brief delete row button227MFXButtonTooltip* myDeleteRowButton = nullptr;228229/// @brief label230FXLabel* myIconLabel = nullptr;231232/// @brief comboBox with ID233MFXTextFieldIcon* myIDTextField = nullptr;234235/// @brief textField to modify the probability attribute236MFXTextFieldIcon* myProbabilityTextField = nullptr;237238/// @brief Invalidated copy constructor.239DistributionRow(const DistributionRow&) = delete;240241/// @brief Invalidated assignment operator242DistributionRow& operator=(const DistributionRow& src) = delete;243};244245// ===========================================================================246// class DistributionValuesEditor247// ===========================================================================248249class DistributionValuesEditor : public GNEGroupBoxModule {250/// @brief FOX-declaration251FXDECLARE(GNEDistributionFrame::DistributionValuesEditor)252253/// @brief declare friend class254friend class DistributionRow;255256public:257/// @brief constructor258DistributionValuesEditor(GNEFrame* frameParent, DistributionEditor* distributionEditor,259DistributionSelector* distributionSelector,260GNEAttributesEditor* attributesEditor);261262/// @brief show attributes of multiple ACs263void showDistributionValuesEditor();264265/// @brief hide attribute editor266void hideDistributionValuesEditor();267268/// @brief refresh rows269void refreshRows();270271/// @brief pointer to GNEFrame parent272GNEFrame* getFrameParent() const;273274/// @name FOX-callbacks275/// @{276277/// @brief Called when user press the add button278long onCmdAddRow(FXObject*, FXSelector, void*);279280/// @brief Called when user press the add button281long onCmdRemoveRow(FXObject* obj, FXSelector, void*);282283/// @}284285protected:286/// @brief FOX need this287FOX_CONSTRUCTOR(DistributionValuesEditor)288289/// @brief update sum label290void updateSumLabel();291292private:293/// @brief pointer to frame parent294GNEFrame* myFrameParent;295296/// @brief distribution editor297DistributionEditor* myDistributionEditor;298299/// @brief distribution selector300DistributionSelector* myDistributionSelector;301302/// @brief attributes editor303GNEAttributesEditor* myAttributesEditor;304305/// @brief list of Attribute editor rows306std::vector<DistributionRow*> myDistributionRows;307308/// @brief bot frame309FXHorizontalFrame* myBotFrame = nullptr;310311/// @brief add buton312MFXButtonTooltip* myAddButton = nullptr;313314/// @brief sum label315FXLabel* mySumLabel = nullptr;316317/// @brief Invalidated copy constructor.318DistributionValuesEditor(const DistributionValuesEditor&) = delete;319320/// @brief Invalidated assignment operator321DistributionValuesEditor& operator=(const DistributionValuesEditor& src) = delete;322};323};324325326