Path: blob/main/src/netedit/frames/network/GNETAZFrame.h
169685 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 GNETAZFrame.h14/// @author Pablo Alvarez Lopez15/// @date Oct 201816///17// The Widget for add TAZ elements18/****************************************************************************/19#pragma once20#include <config.h>2122#include <netedit/frames/GNEFrame.h>23#include <netedit/GNEViewNetHelper.h>2425// ===========================================================================26// class definitions27// ===========================================================================2829class GNEAttributesEditor;30class GNEDrawingShape;31class GNETAZSourceSink;3233// ===========================================================================34// class definitions35// ===========================================================================3637class GNETAZFrame : public GNEFrame {3839public:40// ===========================================================================41// class CurrentTAZ42// ===========================================================================4344class CurrentTAZ : public MFXGroupBoxModule {4546public:47/// @brief struct for edges and the source/sink colors48class TAZEdgeColor {4950public:51/// @brief constructor52TAZEdgeColor(CurrentTAZ* CurrentTAZParent, GNEEdge* _edge, GNETAZSourceSink* _source, GNETAZSourceSink* _sink);5354/// @brief destructor (needed because RGBColors has to be deleted)55~TAZEdgeColor();5657/// @brief update colors58void updateColors();5960/// @brief TAZ edge61GNEEdge* edge;6263/// @brief source TAZ64GNETAZSourceSink* source;6566/// @brief sink TAZ67GNETAZSourceSink* sink;6869/// @brief color by source [0-9]70int sourceColor;7172/// @brief color by sink [0-9]73int sinkColor;7475/// @brief color by source + sink [0-9]76int sourcePlusSinkColor;7778/// @brief color by source - sink [0-9]79int sourceMinusSinkColor;8081private:82/// @brief pointer to CurrentTAZParent83CurrentTAZ* myCurrentTAZParent;8485/// @brief default color86TAZEdgeColor();87};8889/// @brief constructor90CurrentTAZ(GNETAZFrame* TAZFrameParent);9192/// @brief destructor93~CurrentTAZ();9495/// @brief set current TAZ96void setTAZ(GNETAZ* editedTAZ);9798/// @brief get current TAZ99GNETAZ* getTAZ() const;100101/// @brief check if given edge belongs to current TAZ102bool isTAZEdge(GNEEdge* edge) const;103104/// @brief get current selected edges105const std::vector<GNEEdge*>& getSelectedEdges() const;106107/// @brief get TAZEdges108const std::vector<CurrentTAZ::TAZEdgeColor>& getTAZEdges() const;109110/// @brief refresh TAZEdges111void refreshTAZEdges();112113protected:114/// @brief add source sink115void addSourceSink(GNETAZSourceSink* additional);116117private:118/// @brief pointer to TAZ Frame119GNETAZFrame* myTAZFrameParent;120121/// @brief current edited TAZ122GNETAZ* myEditedTAZ;123124/// @brief vector with pointers to selected edges125std::vector<GNEEdge*> mySelectedEdges;126127/// @brief vector with TAZ's edges128std::vector<TAZEdgeColor> myTAZEdgeColors;129130/// @brief Label for current TAZ131FXLabel* myCurrentTAZLabel;132133/// @brief maximum source plus sink value of current TAZ Edges134double myMaxSourcePlusSinkWeight;135136/// @brief minimum source plus sink value of current TAZ Edges137double myMinSourcePlusSinkWeight;138139/// @brief maximum source minus sink value of current TAZ Edges140double myMaxSourceMinusSinkWeight;141142/// @brief minimum source minus sink value of current TAZ Edges143double myMinSourceMinusSinkWeight;144};145146// ===========================================================================147// class TAZCommonStatistics148// ===========================================================================149150class TAZCommonStatistics : public MFXGroupBoxModule {151152public:153/// @brief constructor154TAZCommonStatistics(GNETAZFrame* TAZFrameParent);155156/// @brief destructor157~TAZCommonStatistics();158159/// @brief show TAZ Common Statistics Module160void showTAZCommonStatisticsModule();161162/// @brief hide TAZ Common Statistics Module163void hideTAZCommonStatisticsModule();164165/// @brief update Statistics label166void updateStatistics();167168private:169/// @brief pointer to TAZFrame parent170GNETAZFrame* myTAZFrameParent;171172/// @brief Statistics labels173FXLabel* myStatisticsLabel;174};175176// ===========================================================================177// class TAZSaveChanges178// ===========================================================================179180class TAZSaveChanges : public MFXGroupBoxModule {181/// @brief FOX-declaration182FXDECLARE(GNETAZFrame::TAZSaveChanges)183184public:185/// @brief constructor186TAZSaveChanges(GNETAZFrame* TAZFrameParent);187188/// @brief destructor189~TAZSaveChanges();190191/// @brief show TAZ Save Changes Module192void showTAZSaveChangesModule();193194/// @brief hide TAZ Save Changes Module195void hideTAZSaveChangesModule();196197/// @brief enable buttons save and cancel changes (And begin Undo List)198void enableButtonsAndBeginUndoList();199200/// @brief return true if there is changes to save201bool isChangesPending() const;202203/// @name FOX-callbacks204/// @{205/// @brief Called when the user press the button save changes206long onCmdSaveChanges(FXObject*, FXSelector, void*);207208/// @brief Called when the user press the button cancel changes209long onCmdCancelChanges(FXObject*, FXSelector, void*);210/// @}211212protected:213FOX_CONSTRUCTOR(TAZSaveChanges)214215private:216/// @brief pointer to TAZFrame parent217GNETAZFrame* myTAZFrameParent;218219/// @field FXButton for save changes in TAZEdges220FXButton* mySaveChangesButton;221222/// @field FXButton for cancel changes in TAZEdges223FXButton* myCancelChangesButton;224};225226// ===========================================================================227// class TAZChildDefaultParameters228// ===========================================================================229230class TAZChildDefaultParameters : public MFXGroupBoxModule {231/// @brief FOX-declaration232FXDECLARE(GNETAZFrame::TAZChildDefaultParameters)233234public:235/// @brief constructor236TAZChildDefaultParameters(GNETAZFrame* TAZFrameParent);237238/// @brief destructor239~TAZChildDefaultParameters();240241/// @brief extend TAZ child default parameters Module (if we have selected a TAZ)242void extendTAZChildDefaultParameters();243244/// @brief collapse TAZ child default parameters Module (if we have selected a TAZ)245void collapseTAZChildDefaultParameters();246247/// @brief update "select edges button"248void updateSelectEdgesButton();249250/// @brief get default source weight251double getDefaultTAZSourceWeight() const;252253/// @brief default sink weight254double getDefaultTAZSinkWeight() const;255256/// @brief check if toggle membership is enabled257bool getToggleMembership() const;258259/// @name FOX-callbacks260/// @{261/// @brief Called when the user changes default values262long onCmdSetDefaultValues(FXObject* obj, FXSelector, void*);263264/// @brief Called when the user press "use selected edges" button265long onCmdUseSelectedEdges(FXObject* obj, FXSelector, void*);266267/// @brief Called when the user press "zero fringe probabilities" button268long onCmdSetZeroFringeProbabilities(FXObject* obj, FXSelector, void*);269/// @}270271protected:272/// @brief FOX need this273FOX_CONSTRUCTOR(TAZChildDefaultParameters)274275private:276/// @brief pointer to TAZFrame parent277GNETAZFrame* myTAZFrameParent;278279/// @brief CheckButton to enable or disable Toggle edge Membership280FXCheckButton* myToggleMembership;281282/// @brief Horizontal Frame toggle membership283FXHorizontalFrame* myToggleMembershipFrame;284285/// @brief Horizontal Frame for default TAZ Source Weight286FXHorizontalFrame* myDefaultTAZSourceFrame;287288/// @brief textField to set a default value for TAZ Sources289FXTextField* myTextFieldDefaultValueTAZSources;290291/// @brief Horizontal Frame for default TAZ Sink Weight292FXHorizontalFrame* myDefaultTAZSinkFrame;293294/// @brief textField to set a default value for TAZ Sinks295FXTextField* myTextFieldDefaultValueTAZSinks;296297/// @brief button for use selected edges298FXButton* myUseSelectedEdges;299300/// @brief button for setting zero fringe probabilities301FXButton* myZeroFringeProbabilities;302303/// @brief information label304FXLabel* myInformationLabel;305306/// @brief default source weight307double myDefaultTAZSourceWeight;308309/// @brief default sink weight310double myDefaultTAZSinkWeight;311};312313// ===========================================================================314// class TAZSelectionStatistics315// ===========================================================================316317class TAZSelectionStatistics : public MFXGroupBoxModule {318/// @brief FOX-declaration319FXDECLARE(GNETAZFrame::TAZSelectionStatistics)320321public:322/// @brief constructor323TAZSelectionStatistics(GNETAZFrame* TAZFrameParent);324325/// @brief destructor326~TAZSelectionStatistics();327328/// @brief show TAZ Selection Statistics Module329void showTAZSelectionStatisticsModule();330331/// @brief hide TAZ Selection Statistics Module332void hideTAZSelectionStatisticsModule();333334/// @brief add an edge and their TAZ Children in the list of selected items335bool selectEdge(const CurrentTAZ::TAZEdgeColor& edge);336337/// @brief un select an edge (and their TAZ Children)338bool unselectEdge(GNEEdge* edge);339340/// @brief check if an edge is selected341bool isEdgeSelected(GNEEdge* edge);342343/// @brief clear current TAZ children344void clearSelectedEdges();345346/// @brief get map with edge and TAZChildren347const std::vector<CurrentTAZ::TAZEdgeColor>& getEdgeAndTAZChildrenSelected() const;348349/// @name FOX-callbacks350/// @{351/// @brief Called when the user set a new value352long onCmdSetNewValues(FXObject* obj, FXSelector, void*);353354/// @brief Called when the user press select edges355long onCmdSelectEdges(FXObject* obj, FXSelector, void*);356/// @}357358protected:359FOX_CONSTRUCTOR(TAZSelectionStatistics)360361/// @brief update TAZSelectionStatistics362void updateStatistics();363364private:365/// @brief pointer to TAZFrame parent366GNETAZFrame* myTAZFrameParent;367368/// @brief Horizontal Frame for default TAZ Source Weight369FXHorizontalFrame* myTAZSourceFrame;370371/// @brief textField for TAZ Source weight372FXTextField* myTextFieldTAZSourceWeight;373374/// @brief Horizontal Frame for default TAZ Sink Weight375FXHorizontalFrame* myTAZSinkFrame;376377/// @brief textField for TAZ Sink weight378FXTextField* myTextFieldTAZSinkWeight;379380/// @brief Statistics labels381FXLabel* myStatisticsLabel;382383/// @brief vector with the current selected edges and their associated children384std::vector<CurrentTAZ::TAZEdgeColor> myEdgeAndTAZChildrenSelected;385};386387// ===========================================================================388// class TAZEdgesGraphic389// ===========================================================================390391class TAZEdgesGraphic : public MFXGroupBoxModule {392/// @brief FOX-declaration393FXDECLARE(GNETAZFrame::TAZEdgesGraphic)394395public:396/// @brief constructor397TAZEdgesGraphic(GNETAZFrame* TAZFrameParent);398399/// @brief destructor400~TAZEdgesGraphic();401402/// @brief show TAZ Edges Graphic Module403void showTAZEdgesGraphicModule();404405/// @brief hide TAZ Edges Graphic Module406void hideTAZEdgesGraphicModule();407408/// @brief update edge colors;409void updateEdgeColors();410411/// @name FOX-callbacks412/// @{413/// @brief Called when the user select one kind of representation414long onCmdChoosenBy(FXObject* obj, FXSelector, void*);415/// @}416417protected:418FOX_CONSTRUCTOR(TAZEdgesGraphic)419420private:421/// @brief pointer to TAZFrame parent422GNETAZFrame* myTAZFrameParent;423424/// @brief add radio button "color by source"425FXRadioButton* myColorBySourceWeight;426427/// @brief add radio button "color by sink"428FXRadioButton* myColorBySinkWeight;429430/// @brief add radio button "color source + sink"431FXRadioButton* myColorBySourcePlusSinkWeight;432433/// @brief add radio button "color source - Sink"434FXRadioButton* myColorBySourceMinusSinkWeight;435436/// @brief default RGBColor for all edges437RGBColor myEdgeDefaultColor;438439/// @brief RGBColor color for selected egdes440RGBColor myEdgeSelectedColor;441};442443/**@brief Constructor444* @brief viewParent GNEViewParent in which this GNEFrame is placed445* @brief viewNet viewNet that uses this GNEFrame446*/447GNETAZFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);448449/// @brief Destructor450~GNETAZFrame();451452/// @brief show TAZ Frame453void show();454455/// @brief hide TAZ frame456void hide();457458/**@brief process click over Viewnet459* @param[in] clickedPosition clicked position over ViewNet460* @param[in] viewObjects objects under cursors461* @return true if something (select TAZ or add edge) was successfully done462*/463bool processClick(const Position& clickedPosition, const GNEViewNetHelper::ViewObjectsSelector& viewObjects);464465/// @brief process selection of edges in view net466void processEdgeSelection(const std::vector<GNEEdge*>& edges);467468/// @brief get drawing mode module469GNEDrawingShape* getDrawingShapeModule() const;470471/// @brief get Current TAZ module472CurrentTAZ* getCurrentTAZModule() const;473474/// @brief get TAZ Selection Statistics module475TAZSelectionStatistics* getTAZSelectionStatisticsModule() const;476477/// @brief get TAZ Save Changes module478TAZSaveChanges* getTAZSaveChangesModule() const;479480protected:481/// @brief SumoBaseObject used for creating TAZ482CommonXMLStructure::SumoBaseObject* myBaseTAZ = nullptr;483484/**@brief build a shaped element using the drawed shape485* return true if was successfully created486* @note called when user stop drawing shape487*/488bool shapeDrawed();489490/// @brief add or remove a source and a sink, or remove it if edge is in the list of TAZ Children491bool addOrRemoveTAZMember(GNEEdge* edge);492493/// @brief drop all TAZSources and TAZ Sinks of current TAZ494void dropTAZMembers();495496private:497/// @brief current TAZ498CurrentTAZ* myCurrentTAZ = nullptr;499500/// @brief TAZ Edges common parameters501TAZCommonStatistics* myTAZCommonStatistics = nullptr;502503/// @brief TAZ parameters504GNEAttributesEditor* myTAZAttributesEditor = nullptr;505506/// @brief Drawing shape507GNEDrawingShape* myDrawingShape = nullptr;508509/// @brief save TAZ Edges510TAZSaveChanges* myTAZSaveChanges = nullptr;511512/// @brief TAZ child defaults parameters513TAZChildDefaultParameters* myTAZChildDefaultParameters = nullptr;514515/// @brief TAZ Edges selection parameters516TAZSelectionStatistics* myTAZSelectionStatistics = nullptr;517518/// @brief TAZ Edges Graphic519TAZEdgesGraphic* myTAZEdgesGraphic = nullptr;520};521522523