Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/gui/div/GUIParameterTableWindow.h
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2002-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 GUIParameterTableWindow.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @author Jakob Erdmann
18
/// @date Sept 2002
19
///
20
// The window that holds the table of an object's parameter
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <vector>
26
#include <string>
27
#include <algorithm>
28
#include <functional>
29
#include <utils/foxtools/fxheader.h>
30
#include <utils/common/ValueSource.h>
31
#include <utils/common/SUMOTime.h>
32
#include <utils/gui/div/GUIPersistentWindowPos.h>
33
#include "GUIParameterTableItem.h"
34
35
36
// ===========================================================================
37
// class declarations
38
// ===========================================================================
39
class GUIGlObject;
40
class GUIMainWindow;
41
class GUIParameterTableItemInterface;
42
class Parameterised;
43
44
45
// ===========================================================================
46
// class definitions
47
// ===========================================================================
48
/**
49
* @class GUIParameterTableWindow
50
* @brief A window containing a gl-object's parameter
51
*
52
* This class realises a view on some parameter of a gl-object. The gl-object
53
* itself is responsible for filling this table.
54
*
55
* After allocating such a table, the object should fill the rows by calling
56
* one of the mkItem-methods for each. The building is closed using closeBuilding
57
* what forces the table to be displayed.
58
*
59
* Each row is represented using an instance of GUIParameterTableItemInterface.
60
*/
61
class GUIParameterTableWindow : public FXMainWindow, public GUIPersistentWindowPos {
62
FXDECLARE(GUIParameterTableWindow)
63
public:
64
/** @brief Constructor
65
*
66
* @param[in] app The application this window belongs to
67
* @param[in] o The gl-object this table describes
68
*/
69
GUIParameterTableWindow(GUIMainWindow& app, GUIGlObject& o, const std::string& title = "");
70
71
72
/// @brief Destructor
73
~GUIParameterTableWindow();
74
75
76
/** @brief Closes the building of the table
77
*
78
* Adds the table to the list of child windows of the applications also
79
* telling the application that the window should be updated in each
80
* simulation step. Shows the table.
81
*
82
* @see GUIMainWindow::addChild
83
*/
84
void closeBuilding(const Parameterised* p = 0);
85
86
87
/// @brief ensure that the font covers the given text
88
void checkFont(const std::string& text);
89
90
/** @brief Lets this window know the object shown is being deleted
91
* @param[in] o The deleted (shown) object
92
*/
93
void removeObject(GUIGlObject* const o);
94
95
96
97
/// @name Row adding functions
98
/// @{
99
100
/** @brief Adds a row which obtains its value from a ValueSource
101
*
102
* @param[in] name The name of the row entry
103
* @param[in] dynamic Information whether the entry is dynamic
104
* @param[in] src The value source to use
105
*/
106
template<class T>
107
void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
108
myTable->insertRows((int)myItems.size() + 1);
109
GUIParameterTableItemInterface* i = new GUIParameterTableItem<T>(myTable, myCurrentPos++, name, dynamic, src);
110
myItems.push_back(i);
111
}
112
113
/** @brief Adds a row which shows a string-value
114
*
115
* @param[in] name The name of the row entry
116
* @param[in] dynamic Information whether the entry is dynamic
117
* @param[in] value The value to show
118
* @todo the dynamic-parameter is obsolete(?)
119
*/
120
void mkItem(const char* name, bool dynamic, std::string value);
121
122
123
/** @brief Adds a row which shows a unsigned-value
124
*
125
* @param[in] name The name of the row entry
126
* @param[in] dynamic Information whether the entry is dynamic
127
* @param[in] value The value to show
128
* @todo the dynamic-parameter is obsolete
129
*/
130
void mkItem(const char* name, bool dynamic, unsigned value);
131
132
133
/** @brief Adds a row which shows a integer-value
134
*
135
* @param[in] name The name of the row entry
136
* @param[in] dynamic Information whether the entry is dynamic
137
* @param[in] value The value to show
138
* @todo the dynamic-parameter is obsolete
139
*/
140
void mkItem(const char* name, bool dynamic, int value);
141
142
143
/** @brief Adds a row which shows a 64 bit integer-value
144
*
145
* @param[in] name The name of the row entry
146
* @param[in] dynamic Information whether the entry is dynamic
147
* @param[in] value The value to show
148
* @todo the dynamic-parameter is obsolete
149
*/
150
void mkItem(const char* name, bool dynamic, long long int value);
151
152
153
/** @brief Adds a row which shows a double-value
154
*
155
* @param[in] name The name of the row entry
156
* @param[in] dynamic Information whether the entry is dynamic
157
* @param[in] value The value to show
158
* @todo the dynamic-parameter is obsolete
159
*/
160
void mkItem(const char* name, bool dynamic, double value);
161
162
163
/// @}
164
165
166
167
/// @name FOX-callbacks
168
/// @{
169
170
/** @brief Updates the table due to a simulation step */
171
long onSimStep(FXObject*, FXSelector, void*);
172
173
/** @brief Does nothing
174
* @todo Recheck whether this is needed (to override FXTable-behaviour?)
175
*/
176
long onTableSelected(FXObject*, FXSelector, void*);
177
178
/** @brief Does nothing
179
* @todo Recheck whether this is needed (to override FXTable-behaviour?)
180
*/
181
long onTableDeselected(FXObject*, FXSelector, void*);
182
183
184
/** @brief Shows a popup
185
*
186
* Callback for right-mouse-button pressing event. Obtains the selected row
187
* and determines whether it is dynamic. If so, a popup-menu which allows
188
* to open a tracker for this value is built and shown.
189
*
190
* @see GUIParameterTableItemInterface
191
* @see GUIParam_PopupMenuInterface
192
*/
193
long onRightButtonPress(FXObject*, FXSelector, void*);
194
195
/// @brief directly opens tracker when clicking on last column
196
long onLeftBtnPress(FXObject*, FXSelector, void*);
197
/// @}
198
199
/** @brief Updates all instances
200
*/
201
static void updateAll() {
202
FXMutexLock locker(myGlobalContainerLock);
203
for (GUIParameterTableWindow* const window : myContainer) {
204
window->updateTable();
205
}
206
}
207
208
protected:
209
/** @brief Updates the table
210
*
211
* Goes through all entries and updates them using GUIParameterTableItemInterface::update.
212
*
213
* @see GUIParameterTableItemInterface::update
214
*/
215
void updateTable();
216
217
/// @brief The mutex used to avoid concurrent updates of the instance container
218
static FXMutex myGlobalContainerLock;
219
220
/// @brief The container of items that shall be updated
221
static std::vector<GUIParameterTableWindow*> myContainer;
222
223
private:
224
/// @brief The object to get the information from
225
GUIGlObject* myObject;
226
227
/// @brief The table to display the information in
228
FXTable* myTable;
229
230
/// @brief The main application window
231
GUIMainWindow* myApplication;
232
233
/// @brief The list of table rows
234
std::vector<GUIParameterTableItemInterface*> myItems;
235
236
/// @brief y-position for opening new tracker window
237
int myTrackerY;
238
239
/// @brief The index of the next row to add - used while building
240
unsigned myCurrentPos;
241
242
/// @brief A lock assuring save updates in case of object deletion
243
mutable FXMutex myLock;
244
245
/// @brief returns the number of parameters if obj is Parameterised and 0 otherwise
246
static int numParams(const GUIGlObject* obj);
247
248
protected:
249
FOX_CONSTRUCTOR(GUIParameterTableWindow)
250
251
};
252
253