Path: blob/main/src/netedit/frames/demand/GNEDistributionFrame.h
169684 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 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 <utils/xml/SUMOXMLDefinitions.h>2425// ===========================================================================26// class definitions27// ===========================================================================2829class GNEAttributesEditor;30class GNEDemandElement;31class MFXComboBoxIcon;32class MFXTextFieldIcon;3334// ===========================================================================35// class definitions36// ===========================================================================3738class GNEDistributionFrame {3940public:41// ===========================================================================42// class declaration43// ===========================================================================4445class DistributionValuesEditor;46class DistributionSelector;4748// ===========================================================================49// class DistributionEditor50// ===========================================================================5152class DistributionEditor : public MFXGroupBoxModule {53/// @brief FOX-declaration54FXDECLARE(GNEDistributionFrame::DistributionEditor)5556/// @brief declare friend class57friend class DistributionValuesEditor;5859public:60/// @brief constructor61DistributionEditor(GNEFrame* frameParent, SumoXMLTag distributionTag, GUIIcon icon);6263/// @brief destructor64~DistributionEditor();6566/// @brief get distribution tag67SumoXMLTag getDistributionTag() const;6869/// @name FOX-callbacks70/// @{7172/// @brief Called when "create distribution" button is clicked73long onCmdCreateDistribution(FXObject*, FXSelector, void*);7475/// @brief Called when "Delete distribution" button is clicked76long onCmdDeleteDistribution(FXObject*, FXSelector, void*);7778/// @brief Called when "Delete distribution" button is updated79long onUpdDeleteDistribution(FXObject* sender, FXSelector, void*);8081/// @}8283protected:84/// @brief FOX needs this85FOX_CONSTRUCTOR(DistributionEditor)8687private:88/// @brief pointer to frame parent89GNEFrame* myFrameParent;9091/// @briuef distribution tag92SumoXMLTag myDistributionTag;9394/// @brief distribution selector95DistributionSelector* myDistributionSelector = nullptr;9697/// @brief "create Distribution" button98MFXButtonTooltip* myCreateDistributionButton = nullptr;99100/// @brief "delete Distribution" button101MFXButtonTooltip* myDeleteDistributionButton = nullptr;102};103104// ===========================================================================105// class DistributionSelector106// ===========================================================================107108class DistributionSelector : public MFXGroupBoxModule {109/// @brief FOX-declaration110FXDECLARE(GNEDistributionFrame::DistributionSelector)111112/// @brief declare friend class113friend class DistributionValuesEditor;114115public:116/// @brief constructor117DistributionSelector(GNEFrame* frameParent);118119/// @brief destructor120~DistributionSelector();121122/// @brief refresh modul123void setDistribution(GNEDemandElement* distribution);124125/// @brief current distribution126GNEDemandElement* getCurrentDistribution() const;127128/// @brief refresh distribution IDs (only call when user change ID in internal attributes)129void refreshDistributionIDs();130131/// @brief refresh modul132void refreshDistributionSelector();133134/// @name FOX-callbacks135/// @{136137/// @brief Called when the user select distribution in ComboBox138long onCmdSelectDistribution(FXObject*, FXSelector, void*);139140/// @brief update distribution comboBox141long onCmdUpdateDistribution(FXObject* sender, FXSelector, void*);142143/// @}144145protected:146/// @brief FOX need this147FOX_CONSTRUCTOR(DistributionSelector)148149/// @brief fill distribution comboBox150std::map<std::string, GNEDemandElement*> fillDistributionComboBox();151152private:153/// @brief pointer to Frame Parent154GNEFrame* myFrameParent;155156/// @brief pointer to distribution editor157DistributionEditor* myDistributionEditor = nullptr;158159/// @brief attributes editor160GNEAttributesEditor* myAttributesEditor = nullptr;161162/// @brief distribution values editor163DistributionValuesEditor* myDistributionValuesEditor = nullptr;164165/// @brief comboBox with the list of distributions166MFXComboBoxIcon* myDistributionsComboBox = nullptr;167168/// @brief current distribution element169GNEDemandElement* myCurrentDistribution = nullptr;170};171172// ===========================================================================173// class DistributionRow174// ===========================================================================175176class DistributionRow : protected FXHorizontalFrame {177/// @brief FOX-declaration178FXDECLARE(GNEDistributionFrame::DistributionRow)179180public:181/// @brief constructor for key-probability attributes182DistributionRow(DistributionValuesEditor* attributeEditorParent,183const GNEDemandElement* key, const double probability);184185/// @brief destroy DistributionRow (but don't delete)186void destroy();187188/// @brief refresh comboBox189void refreshRow();190191/// @brief get current probability192double getProbability() const;193194/// @name FOX-callbacks195/// @{196197/// @brief try to set new key198long onCmdSetKey(FXObject*, FXSelector, void*);199200/// @brief try to set new probability201long onCmdSetProbability(FXObject*, FXSelector, void*);202203/// @brief remove row204long onCmdRemoveRow(FXObject*, FXSelector, void*);205206/// @}207208protected:209/// @brief FOX need this210FOX_CONSTRUCTOR(DistributionRow)211212/// @brief check if the given ID is valid213bool isValidNewKey() const;214215private:216/// @brief pointer to DistributionValuesEditor parent217DistributionValuesEditor* myDistributionValuesEditorParent;218219/// @brief delete row button220MFXButtonTooltip* myDeleteRowButton = nullptr;221222/// @brief label223FXLabel* myIconLabel = nullptr;224225/// @brief comboBox with keys226MFXComboBoxIcon* myComboBoxKeys = nullptr;227228/// @brief textField to modify the probability attribute229MFXTextFieldIcon* myProbabilityTextField = nullptr;230231/// @brief current Key232const GNEDemandElement* myKey = nullptr;233234/// @brief current probability235double myProbability = 0;236};237238// ===========================================================================239// class DistributionValuesEditor240// ===========================================================================241242class DistributionValuesEditor : public MFXGroupBoxModule {243/// @brief FOX-declaration244FXDECLARE(GNEDistributionFrame::DistributionValuesEditor)245246/// @brief declare friend class247friend class DistributionRow;248249public:250/// @brief constructor251DistributionValuesEditor(GNEFrame* frameParent, DistributionEditor* distributionEditor,252DistributionSelector* distributionSelector,253GNEAttributesEditor* attributesEditor,254SumoXMLTag distributionValueTag);255256/// @brief show attributes of multiple ACs257void showDistributionValuesEditor();258259/// @brief hide attribute editor260void hideDistributionValuesEditor();261262/// @brief destroy and remake rows263void remakeRows();264265/// @brief refresh rows266void refreshRows();267268/// @brief pointer to GNEFrame parent269GNEFrame* getFrameParent() const;270271/// @brief update sum label272void updateSumLabel();273274/// @name FOX-callbacks275/// @{276277/// @brief Called when user press the add button278long onCmdAddRow(FXObject*, FXSelector, void*);279280/// @brief Called when sum button button is updated281long onUpdAddRow(FXObject* sender, FXSelector, void*);282283/// @}284285protected:286/// @brief FOX need this287FOX_CONSTRUCTOR(DistributionValuesEditor)288289private:290/// @brief pointer to frame parent291GNEFrame* myFrameParent;292293/// @brief distribution editor294DistributionEditor* myDistributionEditor;295296/// @brief distribution selector297DistributionSelector* myDistributionSelector;298299/// @brief attributes editor300GNEAttributesEditor* myAttributesEditor;301302/// @brief distribution value tag303SumoXMLTag myDistributionValueTag;304305/// @brief list of Attribute editor rows306std::vector<DistributionRow*> myDistributionRows;307308/// @brief bot frame309FXHorizontalFrame* myBotFrame = nullptr;310311/// @brief sum label312FXLabel* mySumLabel = nullptr;313};314};315316317