Path: blob/main/src/utils/gui/windows/GUIDialog_ChooserAbstract.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 GUIDialog_ChooserAbstract.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Sept 200218///19// Class for the window that allows to choose a street, junction or vehicle20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include <vector>26#include <set>27#include <utils/foxtools/fxheader.h>28#include <utils/gui/globjects/GUIGlObject.h>29#include <utils/gui/div/GUIPersistentWindowPos.h>30#include "GUIAppEnum.h"313233// ===========================================================================34// class declarations35// ===========================================================================36class GUIGlChildWindow;37class GUIGlObjectStorage;38class GUIGlObject;394041// ===========================================================================42// class definition43// ===========================================================================44/**45* @class GUIDialog_ChooserAbstract46* Instances of this class are windows that display the list of instances47* from a given artifact like vehicles, edges or junctions and allow48* one of their items49*/50class GUIDialog_ChooserAbstract : public FXMainWindow, public GUIPersistentWindowPos {51// FOX-declarations52FXDECLARE(GUIDialog_ChooserAbstract)5354public:55/** @brief Constructor56* @param[in] windowsParent The calling view57* @param[in] viewParent The calling view (netedit)58* @param[in] icon The icon to use59* @param[in] title The title to use60* @param[in] glStorage The storage to retrieve ids from61*/62GUIDialog_ChooserAbstract(GUIGlChildWindow* windowsParent, int messageId,63FXIcon* icon, const FXString& title, const std::vector<GUIGlID>& ids,64GUIGlObjectStorage& glStorage);6566/// @brief Destructor67virtual ~GUIDialog_ChooserAbstract();6869/** @brief Returns the chosen (selected) object70* @return The selected object71*/72GUIGlObject* getObject() const;7374/// @name FOX-callbacks75/// @{7677/// @brief keyboard functions78//@{79long onKeyPress(FXObject* o, FXSelector sel, void* data);80//@}8182/// @brief Callback: The selected item shall be centered within the calling view83long onCmdCenter(FXObject*, FXSelector, void*);8485/// @brief Callback: The selected vehicle shall be tracked within the calling view86long onCmdTrack(FXObject*, FXSelector, void*);8788/// @brief Callback: The dialog shall be closed89long onCmdClose(FXObject*, FXSelector, void*);9091/// @brief Callback: Something has been typed into the field92long onChgText(FXObject*, FXSelector, void*);9394/// @brief Callback: Selects to current item if enter is pressed95long onCmdText(FXObject*, FXSelector, void*);9697/// @brief Callback: Current list item has changed98long onChgList(FXObject*, FXSelector, void*);99100/// @brief Callback: Current list item selection has changed101long onChgListSel(FXObject*, FXSelector, void*);102103/// @brief Callback: Hides unselected items if pressed104long onCmdFilter(FXObject*, FXSelector, void*);105106/// @brief Callback: Hides unmatched items if pressed107long onCmdFilterSubstr(FXObject*, FXSelector, void*);108109/// @brief Callback: Toggle selection status of current object / list110long onCmdToggleSelection(FXObject*, FXSelector, void*);111long onCmdAddListSelection(FXObject*, FXSelector, void*);112long onCmdClearListSelection(FXObject*, FXSelector, void*);113114/// @brief Callback: Toggle locator by name115long onCmdLocateByName(FXObject*, FXSelector, void*);116117/// @brief Callback: Update list118long onCmdUpdate(FXObject*, FXSelector, void*);119/// @}120121/// @brief sets the focus after the window is created to work-around bug in libfox122void show();123using FXMainWindow::show; // to silence the warning C4266 about a hidden function124125int getMessageId() const {126return myMessageId;127}128129protected:130/// @brief fox need this131FOX_CONSTRUCTOR(GUIDialog_ChooserAbstract)132133/// @brief toggle selection (handled differently in netedit)134virtual void toggleSelection(int listIndex);135136/// @brief set selection (handled differently in netedit)137virtual void select(int listIndex);138139/// @brief unset selection (handled differently in netedit)140virtual void deselect(int listIndex);141142/// @brief filter ACs (needed in netedit)143virtual void filterACs(const std::vector<GUIGlID>& GLIDs);144145/// update the list with the given ids146void refreshList(const std::vector<GUIGlID>& ids);147148/// @brief retrieve name for the given object149virtual std::string getObjectName(GUIGlObject* o) const;150151private:152/// @brief window parent153GUIGlChildWindow* myWindowsParent;154155/// @brief the object type being chosen156int myMessageId;157158/// @brief The list that holds the ids159FXList* myList;160161/// @brief The button that triggers centering on the select object162FXButton* myCenterButton;163164/// @brief The button that triggers tracking on the select vehicle165FXButton* myTrackButton;166167/// @brief The chosen id168GUIGlObject* mySelected;169170/// @brief The text field171FXTextField* myTextEntry;172173/// @brief myList contains (void) pointers to elements of myIDs instead of the more volatile pointers to GUIGlObject174std::set<GUIGlID> myIDs;175176/// @brief whether to locate by object name instead of id177bool myLocateByName;178179/// @brief whether the list was filter by substring180bool myHaveFilteredSubstring;181182/// @brief label for declaring list size183FXLabel* myCountLabel;184185/// @brief Whether search is case sensitive186FXCheckButton* myCaseSensitive;187188/// @brief Whether each change in the list should re-center the view189FXCheckButton* myInstantCenter;190191};192193194