Path: blob/main/src/netedit/dialogs/tools/GNEPythonToolDialogElements.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 GNEPythonToolDialogElements.h14/// @author Pablo Alvarez Lopez15/// @date Jun 202216///17// Elements used in GNEPythonToolDialog18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <vector>24#include <utils/foxtools/fxheader.h>2526// ===========================================================================27// class declaration28// ===========================================================================2930class GNEApplicationWindow;31class GNEPythonTool;32class GNEPythonToolDialog;33class MFXButtonTooltip;34class MFXLabelTooltip;35class Option;3637// ===========================================================================38// class definitions39// ===========================================================================4041/// @brief elements used in Tool Dialogs42class GNEPythonToolDialogElements {4344public:45/// @brief category46class Category : public FXHorizontalFrame {4748public:49/// @brief constructor50Category(FXVerticalFrame* argumentFrame, const std::string& category);5152/// @brief destructor53~Category();5455private:56/// @brief Invalidated copy constructor.57Category(const Category&) = delete;5859/// @brief Invalidated assignment operator.60Category& operator=(const Category&) = delete;61};6263/// @brief argument64class Argument : public FXHorizontalFrame {65/// @brief FOX-declaration66FXDECLARE_ABSTRACT(GNEPythonToolDialogElements::Argument)6768public:69/// @brief constructor (we need pythonTool and applicationWindow because is called during GNEPythonToolDialog constructor)70Argument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,71GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,72const std::string& parameter, Option* option);7374/// @brief destructor75~Argument();7677/// @brief reset to default value78virtual void reset() = 0;7980/// @brief get parameter label81MFXLabelTooltip* getParameterLabel() const;8283/// @brief get argument84const std::string getArgument() const;8586/// @brief check if required attribute is set87bool requiredAttributeSet() const;8889/// @name FOX-callbacks90/// @{9192/// @brief Called when user changes argument value93virtual long onCmdSetValue(FXObject*, FXSelector, void*) = 0;9495/// @brief Called when user press reset button96long onCmdResetValue(FXObject*, FXSelector, void*);9798/// @brief Called when user press reset button99long onUpdResetValue(FXObject*, FXSelector, void*);100101/// @}102103protected:104/// @brief default constructor105Argument();106107/// @brief get value108virtual const std::string getValue() const = 0;109110/// @brief tool dialog parent111GNEPythonToolDialog* myToolDialogParent;112113/// @brief option114Option* myOption;115116/// @brief default value117const std::string myDefaultValue;118119/// @brief auxiliar elements frame120FXHorizontalFrame* myElementsFrame = nullptr;121122private:123/// @brief parameter label124MFXLabelTooltip* myParameterLabel = nullptr;125126/// @brief reset button127FXButton* myResetButton = nullptr;128129/// @brief Invalidated copy constructor.130Argument(const Argument&) = delete;131132/// @brief Invalidated assignment operator.133Argument& operator=(const Argument&) = delete;134};135136137/// @brief edge vector argument138class EdgeVectorArgument : public Argument {139/// @brief FOX-declaration140FXDECLARE(GNEPythonToolDialogElements::EdgeVectorArgument)141142public:143/// @brief constructor144EdgeVectorArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,145GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,146const std::string name, Option* option);147148/// @brief reset to default value149void reset();150151/// @brief Called when user changes argument value152long onCmdSetValue(FXObject*, FXSelector, void*);153154/// @brief Called when user press use seleted edges button155long onCmdUseCurrent(FXObject*, FXSelector, void*);156157/// @brief enable or disable use selected edges button158long onUpdUseCurrent(FXObject* sender, FXSelector, void*);159160protected:161/// @brief FOX need this162EdgeVectorArgument();163164/// @brief get value165const std::string getValue() const;166167/// @brief edge vectgor textField168FXTextField* myEdgeVectorTextField = nullptr;169170private:171/// @brief current edges button172MFXButtonTooltip* myCurrentEdgesButton = nullptr;173174/// @brief Invalidated copy constructor.175EdgeVectorArgument(const EdgeVectorArgument&) = delete;176177/// @brief Invalidated assignment operator.178EdgeVectorArgument& operator=(const EdgeVectorArgument&) = delete;179};180181182/// @brief filename argument183class FileNameArgument : public Argument {184/// @brief FOX-declaration185FXDECLARE(GNEPythonToolDialogElements::FileNameArgument)186187public:188/// @brief constructor189FileNameArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,190GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,191const std::string name, Option* option);192193/// @brief reset to default value194void reset();195196/// @brief Called when user press open filename button197long onCmdOpenFilename(FXObject*, FXSelector, void*);198199/// @brief Called when user set filename200long onCmdSetValue(FXObject*, FXSelector, void*);201202protected:203/// @brief FOX need this204FileNameArgument();205206/// @brief constructor for current buttons207FileNameArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,208GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,209const std::string name, Option* option, const std::string& useCurrent);210211/// @brief get value212const std::string getValue() const;213214/// @brief filename textField215FXTextField* myFilenameTextField = nullptr;216217private:218/// @brief current button219MFXButtonTooltip* myCurrentButton = nullptr;220221/// @brief filename button222MFXButtonTooltip* myOpenFilenameButton = nullptr;223224/// @brief Invalidated copy constructor.225FileNameArgument(const FileNameArgument&) = delete;226227/// @brief Invalidated assignment operator.228FileNameArgument& operator=(const FileNameArgument&) = delete;229};230231/// @brief network argument232class NetworkArgument : public FileNameArgument {233/// @brief FOX-declaration234FXDECLARE(GNEPythonToolDialogElements::NetworkArgument)235236public:237/// @brief constructor238NetworkArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,239GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,240const std::string name, Option* option);241242/// @brief Called when user press open filename button243long onCmdOpenFilename(FXObject*, FXSelector, void*);244245/// @brief Called when user press use current button246long onCmdUseCurrentNetworkFile(FXObject*, FXSelector, void*);247248/// @brief enable or disable use current button249long onUpdUseCurrentNetworkFile(FXObject* sender, FXSelector, void*);250251protected:252/// @brief FOX need this253NetworkArgument();254255private:256/// @brief Invalidated copy constructor.257NetworkArgument(const NetworkArgument&) = delete;258259/// @brief Invalidated assignment operator.260NetworkArgument& operator=(const NetworkArgument&) = delete;261};262263/// @brief additional argument264class AdditionalArgument : public FileNameArgument {265/// @brief FOX-declaration266FXDECLARE(GNEPythonToolDialogElements::AdditionalArgument)267268public:269/// @brief constructor270AdditionalArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,271GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,272const std::string name, Option* option);273274/// @brief Called when user press open filename button275long onCmdOpenFilename(FXObject*, FXSelector, void*);276277/// @brief Called when user press use current button278long onCmdUseCurrentAdditionalFile(FXObject*, FXSelector, void*);279280/// @brief enable or disable use current button281long onUpdUseCurrentAdditionalFile(FXObject* sender, FXSelector, void*);282283protected:284/// @brief FOX need this285AdditionalArgument();286287private:288/// @brief Invalidated copy constructor.289AdditionalArgument(const AdditionalArgument&) = delete;290291/// @brief Invalidated assignment operator.292AdditionalArgument& operator=(const AdditionalArgument&) = delete;293};294295/// @brief route argument296class RouteArgument : public FileNameArgument {297/// @brief FOX-declaration298FXDECLARE(GNEPythonToolDialogElements::RouteArgument)299300public:301/// @brief constructor302RouteArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,303GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,304const std::string name, Option* option);305306/// @brief Called when user press open filename button307long onCmdOpenFilename(FXObject*, FXSelector, void*);308309/// @brief Called when user press use current button310long onCmdUseCurrentRouteFile(FXObject*, FXSelector, void*);311312/// @brief enable or disable use current button313long onUpdUseCurrentRouteFile(FXObject* sender, FXSelector, void*);314315protected:316/// @brief FOX need this317RouteArgument();318319private:320/// @brief Invalidated copy constructor.321RouteArgument(const RouteArgument&) = delete;322323/// @brief Invalidated assignment operator.324RouteArgument& operator=(const RouteArgument&) = delete;325};326327/// @brief data argument328class DataArgument : public FileNameArgument {329/// @brief FOX-declaration330FXDECLARE(GNEPythonToolDialogElements::DataArgument)331332public:333/// @brief constructor334DataArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,335GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,336const std::string name, Option* option);337338/// @brief Called when user press open filename button339long onCmdOpenFilename(FXObject*, FXSelector, void*);340341/// @brief Called when user press use current button342long onCmdUseCurrentDataFile(FXObject*, FXSelector, void*);343344/// @brief enable or disable use current button345long onUpdUseCurrentDataFile(FXObject* sender, FXSelector, void*);346347protected:348/// @brief FOX need this349DataArgument();350351private:352/// @brief Invalidated copy constructor.353DataArgument(const DataArgument&) = delete;354355/// @brief Invalidated assignment operator.356DataArgument& operator=(const DataArgument&) = delete;357};358359/// @brief sumo config argument360class SumoConfigArgument : public FileNameArgument {361/// @brief FOX-declaration362FXDECLARE(GNEPythonToolDialogElements::SumoConfigArgument)363364public:365/// @brief constructor366SumoConfigArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,367GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,368const std::string name, Option* option);369370/// @brief Called when user press open filename button371long onCmdOpenFilename(FXObject*, FXSelector, void*);372373/// @brief Called when user press use current button374long onCmdUseCurrentSumoConfigFile(FXObject*, FXSelector, void*);375376/// @brief enable or disable use current button377long onUpdUseCurrentSumoConfigFile(FXObject* sender, FXSelector, void*);378379protected:380/// @brief FOX need this381SumoConfigArgument();382383private:384/// @brief Invalidated copy constructor.385SumoConfigArgument(const SumoConfigArgument&) = delete;386387/// @brief Invalidated assignment operator.388SumoConfigArgument& operator=(const SumoConfigArgument&) = delete;389};390391/// @brief int argument392class EdgeArgument : public Argument {393394public:395/// @brief constructor396EdgeArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,397GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,398const std::string name, Option* option);399400/// @brief reset to default value401void reset();402403/// @brief Called when user set int value404long onCmdSetValue(FXObject*, FXSelector, void*);405406protected:407/// @brief get value408const std::string getValue() const;409410/// @brief int textField411FXTextField* myEdgeTextField = nullptr;412413private:414/// @brief invalid int in string format415static const std::string INVALID_INT_STR;416417/// @brief Invalidated copy constructor.418EdgeArgument(const EdgeArgument&) = delete;419420/// @brief Invalidated assignment operator.421EdgeArgument& operator=(const EdgeArgument&) = delete;422};423424/// @brief string argument425class StringArgument : public Argument {426427public:428/// @brief constructor429StringArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,430GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,431const std::string name, Option* option);432433/// @brief reset to default value434void reset();435436/// @brief Called when user set string value437long onCmdSetValue(FXObject*, FXSelector, void*);438439protected:440/// @brief get value441const std::string getValue() const;442443/// @brief string textField444FXTextField* myStringTextField = nullptr;445446private:447/// @brief Invalidated copy constructor.448StringArgument(const StringArgument&) = delete;449450/// @brief Invalidated assignment operator.451StringArgument& operator=(const StringArgument&) = delete;452};453454/// @brief int argument455class IntArgument : public Argument {456457public:458/// @brief constructor459IntArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,460GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,461const std::string name, Option* option);462463/// @brief reset to default value464void reset();465466/// @brief Called when user set int value467long onCmdSetValue(FXObject*, FXSelector, void*);468469protected:470/// @brief get value471const std::string getValue() const;472473/// @brief int textField474FXTextField* myIntTextField = nullptr;475476private:477/// @brief invalid int in string format478static const std::string INVALID_INT_STR;479480/// @brief Invalidated copy constructor.481IntArgument(const IntArgument&) = delete;482483/// @brief Invalidated assignment operator.484IntArgument& operator=(const IntArgument&) = delete;485};486487/// @brief float argument488class FloatArgument : public Argument {489490public:491/// @brief constructor492FloatArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,493GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,494const std::string name, Option* option);495496/// @brief reset to default value497void reset();498499/// @brief Called when user set float value500long onCmdSetValue(FXObject*, FXSelector, void*);501502protected:503/// @brief get value504const std::string getValue() const;505506/// @brief float textField507FXTextField* myFloatTextField = nullptr;508509private:510/// @brief invalid float in string format511static const std::string INVALID_DOUBLE_STR;512513/// @brief Invalidated copy constructor.514FloatArgument(const IntArgument&) = delete;515516/// @brief Invalidated assignment operator.517FloatArgument& operator=(const IntArgument&) = delete;518};519520521/// @brief bool argument522class BoolArgument : public Argument {523524public:525/// @brief constructor526BoolArgument(GNEPythonToolDialog* toolDialogParent, const GNEPythonTool* pythonTool,527GNEApplicationWindow* applicationWindow, FXVerticalFrame* argumentFrame,528const std::string name, Option* option);529530/// @brief reset to default value531void reset();532533/// @brief Called when user set bool value534long onCmdSetValue(FXObject*, FXSelector, void*);535536protected:537/// @brief get value538const std::string getValue() const;539540/// @brief check button541FXCheckButton* myCheckButton = nullptr;542543private:544/// @brief Invalidated copy constructor.545BoolArgument(const IntArgument&) = delete;546547/// @brief Invalidated assignment operator.548BoolArgument& operator=(const IntArgument&) = delete;549};550};551552553