Path: blob/main/src/netedit/frames/common/GNESelectorFrame.h
193874 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 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>2425#include <netedit/frames/GNEFrame.h>26#include <netedit/GNEViewNetHelper.h>27#include "GNEGroupBoxModule.h"2829// ===========================================================================30// class declaration31// ===========================================================================3233class GNEMatchAttribute;34class MFXComboBoxIcon;3536// ===========================================================================37// class definitions38// ===========================================================================3940class GNESelectorFrame : public GNEFrame {4142public:43// ===========================================================================44// class SelectionInformation45// ===========================================================================4647class SelectionInformation : public GNEGroupBoxModule {4849public:50/// @brief constructor51SelectionInformation(GNESelectorFrame* selectorFrameParent);5253/// @brief destructor54~SelectionInformation();5556/// @brief update information label57void updateInformationLabel();5859protected:60/// @brief update information label61void updateInformationLabel(const std::string& element, int number);6263private:64/// @brief string for keep information65std::string myInformation;6667/// @brief information label68FXLabel* myInformationLabel;6970/// @brief pointer to Selector Frame Parent71GNESelectorFrame* mySelectorFrameParent;7273/// @brief Invalidated copy constructor.74SelectionInformation(const SelectionInformation&) = delete;7576/// @brief Invalidated assignment operator.77SelectionInformation& operator=(const SelectionInformation&) = delete;78};7980// ===========================================================================81// class ModificationMode82// ===========================================================================8384class ModificationMode : public GNEGroupBoxModule {85/// @brief FOX-declaration86FXDECLARE(GNESelectorFrame::ModificationMode)8788public:89/// @brief operations of selector90enum class Operation {91ADD,92SUB,93RESTRICT,94REPLACE,95DEFAULT96};9798/// @brief constructor99ModificationMode(GNESelectorFrame* selectorFrameParent);100101/// @brief destructor102~ModificationMode();103104/// @brief get current modification mode105Operation getModificationMode() const;106107/// @name FOX-callbacks108/// @{109/// @brief called when user change type of selection operation110long onCmdSelectModificationMode(FXObject*, FXSelector, void*);111112/// @}113114protected:115/// @brief FOX need this116FOX_CONSTRUCTOR(ModificationMode)117118private:119/// @brief add radio button120FXRadioButton* myAddRadioButton;121122/// @brief remove radio button123FXRadioButton* myRemoveRadioButton;124125/// @brief keep button126FXRadioButton* myKeepRadioButton;127128/// @brief replace radio button129FXRadioButton* myReplaceRadioButton;130131/// @brief how to modify selection132Operation myModificationModeType;133134/// @brief Invalidated copy constructor.135ModificationMode(const ModificationMode&) = delete;136137/// @brief Invalidated assignment operator.138ModificationMode& operator=(const ModificationMode&) = delete;139};140141// ===========================================================================142// class VisualScaling143// ===========================================================================144145class VisualScaling : public GNEGroupBoxModule {146/// @brief FOX-declaration147FXDECLARE(GNESelectorFrame::VisualScaling)148149public:150/// @brief constructor151VisualScaling(GNESelectorFrame* selectorFrameParent);152153/// @brief destructor154~VisualScaling();155156/// @name FOX-callbacks157/// @{158159/// @brief Called when the user changes visual scaling160long onCmdScaleSelection(FXObject*, FXSelector, void*);161162/// @}163164protected:165/// @brief FOX need this166FOX_CONSTRUCTOR(VisualScaling)167168private:169/// @brief pointer to Selector Frame Parent170GNESelectorFrame* mySelectorFrameParent;171172/// @brief Spinner for selection scaling173FXRealSpinner* mySelectionScaling;174175/// @brief Invalidated copy constructor.176VisualScaling(const VisualScaling&) = delete;177178/// @brief Invalidated assignment operator.179VisualScaling& operator=(const VisualScaling&) = delete;180};181182// ===========================================================================183// class SelectionOperation184// ===========================================================================185186class SelectionOperation : public GNEGroupBoxModule {187/// @brief FOX-declaration188FXDECLARE(GNESelectorFrame::SelectionOperation)189190public:191/// @brief constructor192SelectionOperation(GNESelectorFrame* selectorFrameParent);193194/// @brief destructor195~SelectionOperation();196197/// @brief load from file198void loadFromFile(const std::string& file) const;199200/// @name FOX-callbacks201/// @{202203/**@brief Called when the user presses the Load-button204* @note Opens a file dialog and forces the parent to load the list of selected205* objects when a file was chosen. Rebuilds the list, then, and redraws itself.206*/207long onCmdLoad(FXObject*, FXSelector, void*);208209/** @brief Called when the user presses the Save-button210* @note Opens a file dialog and forces the selection container to save the list211of selected objects when a file was chosen. If the saving failed, a message window is shown.212*/213long onCmdSave(FXObject*, FXSelector, void*);214215/**@brief Called when the user presses the Clear-button216* @note Clear the internal list and calls GUISelectedStorage::clear and repaints itself217*/218long onCmdClear(FXObject*, FXSelector, void*);219220/**@brief Called when the user presses the delete-button221*/222long onCmdDelete(FXObject*, FXSelector, void*);223224/**@brief Called when the user presses the Invert-button225* @note invert the selection and repaints itself226*/227long onCmdInvert(FXObject*, FXSelector, void*);228229/**@brief Called when the user presses the Reduce-button230* @note Reduce network231*/232long onCmdReduce(FXObject*, FXSelector, void*);233234/// @}235236protected:237/// @brief FOX need this238FOX_CONSTRUCTOR(SelectionOperation)239240/// @brief struct used for massive selections241struct MassiveSelection {242243/// @brief constructor with bucket size (normally the max number of elements)244MassiveSelection(const int bucketSize);245246/// @brief destructor247~MassiveSelection();248249/// @brief check if there are element to process250bool isElementToProcess() const;251252/// @brief ACs to select (the bool flag shows if element is locked)253std::unordered_map<GNEAttributeCarrier*, bool> ACsToSelect;254255/// @brief ACs to select (the bool flag shows if element is locked)256std::unordered_map<GNEAttributeCarrier*, bool> ACsToUnselect;257258/// @brief locked types259std::map<GUIGlObjectType, bool> lockedTypes;260261private:262/// @brief constructor (invalidated)263MassiveSelection();264};265266/// @brief process massive network element selection267MassiveSelection processMassiveNetworkElementSelection(const bool filterLanes) const;268269/// @brief process massive demand element selection270MassiveSelection processMassiveDemandElementSelection() const;271272/// @brief process massive dataelement selection273MassiveSelection processMassiveDataElementSelection() const;274275/// @brief ask if continue due locking276bool askContinueIfLock() const;277278private:279/// @brief pointer to Selector Frame Parent280GNESelectorFrame* mySelectorFrameParent;281282/// @brief Invalidated copy constructor.283SelectionOperation(const SelectionOperation&) = delete;284285/// @brief Invalidated assignment operator.286SelectionOperation& operator=(const SelectionOperation&) = delete;287};288289// ===========================================================================290// class SelectionHierarchy291// ===========================================================================292293class SelectionHierarchy : public GNEGroupBoxModule {294/// @brief FOX-declaration295FXDECLARE(GNESelectorFrame::SelectionHierarchy)296297public:298/// @brief constructor299SelectionHierarchy(GNESelectorFrame* selectorFrameParent);300301/// @brief destructor302~SelectionHierarchy();303304/// @name FOX-callbacks305/// @{306307/// @brief called when user select an item in comboBox308long onCmdSelectItem(FXObject* obj, FXSelector, void*);309310/// @brief called when user press select/unselect parents button311long onCmdParents(FXObject* obj, FXSelector, void*);312313/// @brief called when user press select/unselect children button314long onCmdChildren(FXObject* obj, FXSelector, void*);315316/// @}317318protected:319/// @brief FOX need this320FOX_CONSTRUCTOR(SelectionHierarchy)321322private:323/// @brief enum used in comboBox324enum class Selection {325ALL,326JUNCTION,327EDGE,328LANE,329CONNECTION,330CROSSING,331ADDITIONAL,332WIRE,333SHAPE,334DEMAND,335DATA,336NOTHING,337};338339/// @brief pointer to Selector Frame Parent340GNESelectorFrame* mySelectorFrameParent;341342/// @brief comboBox for parents343MFXComboBoxIcon* myParentsComboBox = nullptr;344345/// @brief comboBox for children346MFXComboBoxIcon* myChildrenComboBox = nullptr;347348/// @brief select parents button349FXButton* mySelectParentsButton = nullptr;350351/// @brief unselect parents button352FXButton* myUnselectParentsButton = nullptr;353354/// @brief select children button355FXButton* mySelectChildrenButton = nullptr;356357/// @brief unselect parents button358FXButton* myUnselectChildrenButton = nullptr;359360// @brief items361const std::vector<std::pair<Selection, std::string> > myItems = {362std::make_pair(Selection::ALL, "all"),363std::make_pair(Selection::JUNCTION, "junction"),364std::make_pair(Selection::EDGE, "edge"),365std::make_pair(Selection::LANE, "lane"),366std::make_pair(Selection::CONNECTION, "connection"),367std::make_pair(Selection::CROSSING, "crossing"),368std::make_pair(Selection::ADDITIONAL, "additionalElements"),369std::make_pair(Selection::WIRE, "wireElements"),370std::make_pair(Selection::SHAPE, "shapeElements"),371std::make_pair(Selection::DEMAND, "demandElements"),372std::make_pair(Selection::DATA, "dataElements")373};374375/// @brief current selected parent376Selection myCurrentSelectedParent;377378/// @brief current selected child379Selection myCurrentSelectedChild;380381/// @brief Invalidated copy constructor.382SelectionHierarchy(const SelectionHierarchy&) = delete;383384/// @brief Invalidated assignment operator.385SelectionHierarchy& operator=(const SelectionHierarchy&) = delete;386};387388// ===========================================================================389// class Legend390// ===========================================================================391392class Information : public GNEGroupBoxModule {393394public:395/// @brief constructor396Information(GNESelectorFrame* selectorFrameParent);397398/// @brief destructor399~Information();400};401402/**@brief Constructor403* @brief viewParent GNEViewParent in which this GNEFrame is placed404* @brief viewNet viewNet that uses this GNEFrame405*/406GNESelectorFrame(GNEViewParent* viewParent, GNEViewNet* viewNet);407408/// @brief Destructor409~GNESelectorFrame();410411/// @brief show Frame412void show();413414/// @brief hide Frame415void hide();416417/// @brief function called after undo/redo in the current frame418void updateFrameAfterUndoRedo();419420/// @brief clear current selection with possibility of undo/redo421void clearCurrentSelection() const;422423/**@brief select attribute carrier (element)424* @param viewObjects objects under cursors425*/426bool selectAttributeCarrier(const GNEViewNetHelper::ViewObjectsSelector& viewObjects);427428/**@brief apply list of ids to the current selection according to Operation,429* @note if setop==DEFAULT than the currently set mode (myOperation) is used430*/431void handleIDs(const std::vector<GNEAttributeCarrier*>& ACs, const ModificationMode::Operation setop = ModificationMode::Operation::DEFAULT);432433/// @brief get vertical frame that holds all widgets of frame434FXVerticalFrame* getContentFrame() const;435436/// @brief get modification mode modul437ModificationMode* getModificationModeModul() const;438439/// @brief get selection operation modul440GNESelectorFrame::SelectionOperation* getSelectionOperationModul() const;441442/// @brief get modul for selection information443SelectionInformation* getSelectionInformation() const;444445private:446/// @brief modul for selection information447GNESelectorFrame::SelectionInformation* mySelectionInformation = nullptr;448449/// @brief modul for change modification mode450GNESelectorFrame::ModificationMode* myModificationMode = nullptr;451452/// @brief modul for match attribute453GNEMatchAttribute* myMatchAttribute = nullptr;454455/// @brief modul for visual scaling456GNESelectorFrame::VisualScaling* myVisualScaling = nullptr;457458/// @brief modul for selection operations459GNESelectorFrame::SelectionOperation* mySelectionOperation = nullptr;460461/// @brief modul for selection hierarchy462GNESelectorFrame::SelectionHierarchy* mySelectionHierarchy = nullptr;463464/// @brief information modul465GNESelectorFrame::Information* myInformation = nullptr;466467/// @brief Invalidated copy constructor.468GNESelectorFrame(const GNESelectorFrame&) = delete;469470/// @brief Invalidated assignment operator.471GNESelectorFrame& operator=(const GNESelectorFrame&) = delete;472};473474475