Path: blob/main/src/netedit/frames/common/GNESelectorFrame.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 GNESelectorFrame.h14/// @author Jakob Erdmann15/// @date Mar 201116///17// The Widget for modifying selections of network-elements18// (some elements adapted from GUIDialog_GLChosenEditor)19/****************************************************************************/20#pragma once21#include <config.h>2223#include <unordered_map>24#include <netedit/frames/GNEFrame.h>25#include <netedit/GNEViewNetHelper.h>26#include <utils/foxtools/MFXComboBoxIcon.h>2728// ===========================================================================29// class declaration30// ===========================================================================3132class GNEAttributeProperties;33class GNEMatchAttribute;34class GNEMatchGenericDataAttribute;35class GNETagProperties;3637// ===========================================================================38// class definitions39// ===========================================================================40/**41* @class GNESelectorFrame42* The Widget for modifying selections of network-elements43*/44class GNESelectorFrame : public GNEFrame {4546public:47// ===========================================================================48// class SelectionInformation49// ===========================================================================5051class SelectionInformation : public MFXGroupBoxModule {5253public:54/// @brief constructor55SelectionInformation(GNESelectorFrame* selectorFrameParent);5657/// @brief destructor58~SelectionInformation();5960/// @brief update information label61void updateInformationLabel();6263protected:64/// @brief update information label65void updateInformationLabel(const std::string& element, int number);6667private:68/// @brief string for keep information69std::string myInformation;7071/// @brief information label72FXLabel* myInformationLabel;7374/// @brief pointer to Selector Frame Parent75GNESelectorFrame* mySelectorFrameParent;7677/// @brief Invalidated copy constructor.78SelectionInformation(const SelectionInformation&) = delete;7980/// @brief Invalidated assignment operator.81SelectionInformation& operator=(const SelectionInformation&) = delete;82};8384// ===========================================================================85// class ModificationMode86// ===========================================================================8788class ModificationMode : public MFXGroupBoxModule {89/// @brief FOX-declaration90FXDECLARE(GNESelectorFrame::ModificationMode)9192public:93/// @brief operations of selector94enum class Operation {95ADD,96SUB,97RESTRICT,98REPLACE,99DEFAULT100};101102/// @brief constructor103ModificationMode(GNESelectorFrame* selectorFrameParent);104105/// @brief destructor106~ModificationMode();107108/// @brief get current modification mode109Operation getModificationMode() const;110111/// @name FOX-callbacks112/// @{113/// @brief called when user change type of selection operation114long onCmdSelectModificationMode(FXObject*, FXSelector, void*);115116/// @}117118protected:119/// @brief FOX need this120FOX_CONSTRUCTOR(ModificationMode)121122private:123/// @brief add radio button124FXRadioButton* myAddRadioButton;125126/// @brief remove radio button127FXRadioButton* myRemoveRadioButton;128129/// @brief keep button130FXRadioButton* myKeepRadioButton;131132/// @brief replace radio button133FXRadioButton* myReplaceRadioButton;134135/// @brief how to modify selection136Operation myModificationModeType;137138/// @brief Invalidated copy constructor.139ModificationMode(const ModificationMode&) = delete;140141/// @brief Invalidated assignment operator.142ModificationMode& operator=(const ModificationMode&) = delete;143};144145// ===========================================================================146// class VisualScaling147// ===========================================================================148149class VisualScaling : public MFXGroupBoxModule {150/// @brief FOX-declaration151FXDECLARE(GNESelectorFrame::VisualScaling)152153public:154/// @brief constructor155VisualScaling(GNESelectorFrame* selectorFrameParent);156157/// @brief destructor158~VisualScaling();159160/// @name FOX-callbacks161/// @{162163/// @brief Called when the user changes visual scaling164long onCmdScaleSelection(FXObject*, FXSelector, void*);165166/// @}167168protected:169/// @brief FOX need this170FOX_CONSTRUCTOR(VisualScaling)171172private:173/// @brief pointer to Selector Frame Parent174GNESelectorFrame* mySelectorFrameParent;175176/// @brief Spinner for selection scaling177FXRealSpinner* mySelectionScaling;178179/// @brief Invalidated copy constructor.180VisualScaling(const VisualScaling&) = delete;181182/// @brief Invalidated assignment operator.183VisualScaling& operator=(const VisualScaling&) = delete;184};185186// ===========================================================================187// class SelectionOperation188// ===========================================================================189190class SelectionOperation : public MFXGroupBoxModule {191/// @brief FOX-declaration192FXDECLARE(GNESelectorFrame::SelectionOperation)193194public:195/// @brief constructor196SelectionOperation(GNESelectorFrame* selectorFrameParent);197198/// @brief destructor199~SelectionOperation();200201/// @brief load from file202void loadFromFile(const std::string& file) const;203204/// @name FOX-callbacks205/// @{206207/**@brief Called when the user presses the Load-button208* @note Opens a file dialog and forces the parent to load the list of selected209* objects when a file was chosen. Rebuilds the list, then, and redraws itself.210*/211long onCmdLoad(FXObject*, FXSelector, void*);212213/** @brief Called when the user presses the Save-button214* @note Opens a file dialog and forces the selection container to save the list215of selected objects when a file was chosen. If the saving failed, a message window is shown.216*/217long onCmdSave(FXObject*, FXSelector, void*);218219/**@brief Called when the user presses the Clear-button220* @note Clear the internal list and calls GUISelectedStorage::clear and repaints itself221*/222long onCmdClear(FXObject*, FXSelector, void*);223224/**@brief Called when the user presses the delete-button225*/226long onCmdDelete(FXObject*, FXSelector, void*);227228/**@brief Called when the user presses the Invert-button229* @note invert the selection and repaints itself230*/231long onCmdInvert(FXObject*, FXSelector, void*);232233/**@brief Called when the user presses the Reduce-button234* @note Reduce network235*/236long onCmdReduce(FXObject*, FXSelector, void*);237238/// @}239240protected:241/// @brief FOX need this242FOX_CONSTRUCTOR(SelectionOperation)243244/// @brief struct used for massive selections245struct MassiveSelection {246247/// @brief constructor with bucket size (normally the max number of elements)248MassiveSelection(const int bucketSize);249250/// @brief destructor251~MassiveSelection();252253/// @brief check if there are element to process254bool isElementToProcess() const;255256/// @brief ACs to select (the bool flag shows if element is locked)257std::unordered_map<GNEAttributeCarrier*, bool> ACsToSelect;258259/// @brief ACs to select (the bool flag shows if element is locked)260std::unordered_map<GNEAttributeCarrier*, bool> ACsToUnselect;261262/// @brief locked types263std::map<GUIGlObjectType, bool> lockedTypes;264265private:266/// @brief constructor (invalidated)267MassiveSelection();268};269270/// @brief process massive network element selection271MassiveSelection processMassiveNetworkElementSelection(const bool filterLanes) const;272273/// @brief process massive demand element selection274MassiveSelection processMassiveDemandElementSelection() const;275276/// @brief process massive dataelement selection277MassiveSelection processMassiveDataElementSelection() const;278279/// @brief ask if continue due locking280bool askContinueIfLock() const;281282private:283/// @brief pointer to Selector Frame Parent284GNESelectorFrame* mySelectorFrameParent;285286/// @brief Invalidated copy constructor.287SelectionOperation(const SelectionOperation&) = delete;288289/// @brief Invalidated assignment operator.290SelectionOperation& operator=(const SelectionOperation&) = delete;291};292293// ===========================================================================294// class SelectionHierarchy295// ===========================================================================296297class SelectionHierarchy : public MFXGroupBoxModule {298/// @brief FOX-declaration299FXDECLARE(GNESelectorFrame::SelectionHierarchy)300301public:302/// @brief constructor303SelectionHierarchy(GNESelectorFrame* selectorFrameParent);304305/// @brief destructor306~SelectionHierarchy();307308/// @name FOX-callbacks309/// @{310311/// @brief called when user select an item in comboBox312long onCmdSelectItem(FXObject* obj, FXSelector, void*);313314/// @brief called when user press select/unselect parents button315long onCmdParents(FXObject* obj, FXSelector, void*);316317/// @brief called when user press select/unselect children button318long onCmdChildren(FXObject* obj, FXSelector, void*);319320/// @}321322protected:323/// @brief FOX need this324FOX_CONSTRUCTOR(SelectionHierarchy)325326private:327/// @brief enum used in comboBox328enum class Selection {329ALL,330JUNCTION,331EDGE,332LANE,333CONNECTION,334CROSSING,335ADDITIONAL,336WIRE,337SHAPE,338DEMAND,339DATA,340NOTHING,341};342343/// @brief pointer to Selector Frame Parent344GNESelectorFrame* mySelectorFrameParent;345346/// @brief comboBox for parents347MFXComboBoxIcon* myParentsComboBox = nullptr;348349/// @brief comboBox for children350MFXComboBoxIcon* myChildrenComboBox = nullptr;351352/// @brief select parents button353FXButton* mySelectParentsButton = nullptr;354355/// @brief unselect parents button356FXButton* myUnselectParentsButton = nullptr;357358/// @brief select children button359FXButton* mySelectChildrenButton = nullptr;360361/// @brief unselect parents button362FXButton* myUnselectChildrenButton = nullptr;363364// @brief items365const std::vector<std::pair<Selection, std::string> > myItems = {366std::make_pair(Selection::ALL, "all"),367std::make_pair(Selection::JUNCTION, "junction"),368std::make_pair(Selection::EDGE, "edge"),369std::make_pair(Selection::LANE, "lane"),370std::make_pair(Selection::CONNECTION, "connection"),371std::make_pair(Selection::CROSSING, "crossing"),372std::make_pair(Selection::ADDITIONAL, "additionalElements"),373std::make_pair(Selection::WIRE, "wireElements"),374std::make_pair(Selection::SHAPE, "shapeElements"),375std::make_pair(Selection::DEMAND, "demandElements"),376std::make_pair(Selection::DATA, "dataElements")377};378379/// @brief current selected parent380Selection myCurrentSelectedParent;381382/// @brief current selected child383Selection myCurrentSelectedChild;384385/// @brief Invalidated copy constructor.386SelectionHierarchy(const SelectionHierarchy&) = delete;387388/// @brief Invalidated assignment operator.389SelectionHierarchy& operator=(const SelectionHierarchy&) = delete;390};391392// ===========================================================================393// class Legend394// ===========================================================================395396class Information : public MFXGroupBoxModule {397398public:399/// @brief constructor400Information(GNESelectorFrame* selectorFrameParent);401402/// @brief destructor403~Information();404};405406/**@brief Constructor407* @brief viewParent GNEViewParent in which this GNEFrame is placed408* @brief viewNet viewNet that uses this GNEFrame409*/410GNESelectorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);411412/// @brief Destructor413~GNESelectorFrame();414415/// @brief show Frame416void show();417418/// @brief hide Frame419void hide();420421/// @brief function called after undo/redo in the current frame422void updateFrameAfterUndoRedo();423424/// @brief clear current selection with possibility of undo/redo425void clearCurrentSelection() const;426427/**@brief select attribute carrier (element)428* @param viewObjects objects under cursors429*/430bool selectAttributeCarrier(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);431432/**@brief apply list of ids to the current selection according to Operation,433* @note if setop==DEFAULT than the currently set mode (myOperation) is used434*/435void handleIDs(const std::vector<GNEAttributeCarrier*>& ACs, const ModificationMode::Operation setop = ModificationMode::Operation::DEFAULT);436437/// @brief get vertical frame that holds all widgets of frame438FXVerticalFrame* getContentFrame() const;439440/// @brief get modification mode modul441ModificationMode* getModificationModeModul() const;442443/// @brief get selection operation modul444GNESelectorFrame::SelectionOperation* getSelectionOperationModul() const;445446/// @brief get modul for selection information447SelectionInformation* getSelectionInformation() const;448449private:450/// @brief modul for selection information451GNESelectorFrame::SelectionInformation* mySelectionInformation = nullptr;452453/// @brief modul for change modification mode454GNESelectorFrame::ModificationMode* myModificationMode = nullptr;455456/// @brief modul for match attribute457GNEMatchAttribute* myMatchAttribute = nullptr;458459/// @brief modul for visual scaling460GNESelectorFrame::VisualScaling* myVisualScaling = nullptr;461462/// @brief modul for selection operations463GNESelectorFrame::SelectionOperation* mySelectionOperation = nullptr;464465/// @brief modul for selection hierarchy466GNESelectorFrame::SelectionHierarchy* mySelectionHierarchy = nullptr;467468/// @brief information modul469GNESelectorFrame::Information* myInformation = nullptr;470471/// @brief Invalidated copy constructor.472GNESelectorFrame(const GNESelectorFrame&) = delete;473474/// @brief Invalidated assignment operator.475GNESelectorFrame& operator=(const GNESelectorFrame&) = delete;476};477478479