Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/windows/GUIDialog_ChooserAbstract.h
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file GUIDialog_ChooserAbstract.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @date Sept 2002
19
///
20
// Class for the window that allows to choose a street, junction or vehicle
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <vector>
27
#include <set>
28
#include <utils/foxtools/fxheader.h>
29
#include <utils/gui/globjects/GUIGlObject.h>
30
#include <utils/gui/div/GUIPersistentWindowPos.h>
31
#include "GUIAppEnum.h"
32
33
34
// ===========================================================================
35
// class declarations
36
// ===========================================================================
37
class GUIGlChildWindow;
38
class GUIGlObjectStorage;
39
class GUIGlObject;
40
41
42
// ===========================================================================
43
// class definition
44
// ===========================================================================
45
/**
46
* @class GUIDialog_ChooserAbstract
47
* Instances of this class are windows that display the list of instances
48
* from a given artifact like vehicles, edges or junctions and allow
49
* one of their items
50
*/
51
class GUIDialog_ChooserAbstract : public FXMainWindow, public GUIPersistentWindowPos {
52
// FOX-declarations
53
FXDECLARE(GUIDialog_ChooserAbstract)
54
55
public:
56
/** @brief Constructor
57
* @param[in] windowsParent The calling view
58
* @param[in] viewParent The calling view (netedit)
59
* @param[in] icon The icon to use
60
* @param[in] title The title to use
61
* @param[in] glStorage The storage to retrieve ids from
62
*/
63
GUIDialog_ChooserAbstract(GUIGlChildWindow* windowsParent, int messageId,
64
FXIcon* icon, const FXString& title, const std::vector<GUIGlID>& ids,
65
GUIGlObjectStorage& glStorage);
66
67
/// @brief Destructor
68
virtual ~GUIDialog_ChooserAbstract();
69
70
/** @brief Returns the chosen (selected) object
71
* @return The selected object
72
*/
73
GUIGlObject* getObject() const;
74
75
/// @name FOX-callbacks
76
/// @{
77
78
/// @brief keyboard functions
79
//@{
80
long onKeyPress(FXObject* o, FXSelector sel, void* data);
81
//@}
82
83
/// @brief Callback: The selected item shall be centered within the calling view
84
long onCmdCenter(FXObject*, FXSelector, void*);
85
86
/// @brief Callback: The selected vehicle shall be tracked within the calling view
87
long onCmdTrack(FXObject*, FXSelector, void*);
88
89
/// @brief Callback: The dialog shall be closed
90
long onCmdClose(FXObject*, FXSelector, void*);
91
92
/// @brief Callback: Something has been typed into the field
93
long onChgText(FXObject*, FXSelector, void*);
94
95
/// @brief Callback: Selects to current item if enter is pressed
96
long onCmdText(FXObject*, FXSelector, void*);
97
98
/// @brief Callback: Current list item has changed
99
long onChgList(FXObject*, FXSelector, void*);
100
101
/// @brief Callback: Current list item selection has changed
102
long onChgListSel(FXObject*, FXSelector, void*);
103
104
/// @brief Callback: Hides unselected items if pressed
105
long onCmdFilter(FXObject*, FXSelector, void*);
106
107
/// @brief Callback: Hides unmatched items if pressed
108
long onCmdFilterSubstr(FXObject*, FXSelector, void*);
109
110
/// @brief Callback: Toggle selection status of current object / list
111
long onCmdToggleSelection(FXObject*, FXSelector, void*);
112
long onCmdAddListSelection(FXObject*, FXSelector, void*);
113
long onCmdClearListSelection(FXObject*, FXSelector, void*);
114
115
/// @brief Callback: Toggle locator by name
116
long onCmdLocateByName(FXObject*, FXSelector, void*);
117
118
/// @brief Callback: Update list
119
long onCmdUpdate(FXObject*, FXSelector, void*);
120
/// @}
121
122
/// @brief sets the focus after the window is created to work-around bug in libfox
123
void show();
124
using FXMainWindow::show; // to silence the warning C4266 about a hidden function
125
126
int getMessageId() const {
127
return myMessageId;
128
}
129
130
protected:
131
/// @brief fox need this
132
FOX_CONSTRUCTOR(GUIDialog_ChooserAbstract)
133
134
/// @brief toggle selection (handled differently in netedit)
135
virtual void toggleSelection(int listIndex);
136
137
/// @brief set selection (handled differently in netedit)
138
virtual void select(int listIndex);
139
140
/// @brief unset selection (handled differently in netedit)
141
virtual void deselect(int listIndex);
142
143
/// @brief filter ACs (needed in netedit)
144
virtual void filterACs(const std::vector<GUIGlID>& GLIDs);
145
146
/// update the list with the given ids
147
void refreshList(const std::vector<GUIGlID>& ids);
148
149
/// @brief retrieve name for the given object
150
virtual std::string getObjectName(GUIGlObject* o) const;
151
152
private:
153
/// @brief window parent
154
GUIGlChildWindow* myWindowsParent;
155
156
/// @brief the object type being chosen
157
int myMessageId;
158
159
/// @brief The list that holds the ids
160
FXList* myList;
161
162
/// @brief The button that triggers centering on the select object
163
FXButton* myCenterButton;
164
165
/// @brief The button that triggers tracking on the select vehicle
166
FXButton* myTrackButton;
167
168
/// @brief The chosen id
169
GUIGlObject* mySelected;
170
171
/// @brief The text field
172
FXTextField* myTextEntry;
173
174
/// @brief myList contains (void) pointers to elements of myIDs instead of the more volatile pointers to GUIGlObject
175
std::set<GUIGlID> myIDs;
176
177
/// @brief whether to locate by object name instead of id
178
bool myLocateByName;
179
180
/// @brief whether the list was filter by substring
181
bool myHaveFilteredSubstring;
182
183
/// @brief label for declaring list size
184
FXLabel* myCountLabel;
185
186
/// @brief Whether search is case sensitive
187
FXCheckButton* myCaseSensitive;
188
189
/// @brief Whether each change in the list should re-center the view
190
FXCheckButton* myInstantCenter;
191
192
};
193
194