Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIParameterTableWindow.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2024 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/****************************************************************************/
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>
34
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
39class GUIGlObject;
40class GUIMainWindow;
42class Parameterised;
43
44
45// ===========================================================================
46// class definitions
47// ===========================================================================
61class GUIParameterTableWindow : public FXMainWindow, public GUIPersistentWindowPos {
63public:
69 GUIParameterTableWindow(GUIMainWindow& app, GUIGlObject& o, const std::string& title = "");
70
71
74
75
84 void closeBuilding(const Parameterised* p = 0);
85
86
88 void checkFont(const std::string& text);
89
93 void removeObject(GUIGlObject* const o);
94
95
96
99
106 template<class T>
107 void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
108 myTable->insertRows((int)myItems.size() + 1);
110 myItems.push_back(i);
111 }
112
120 void mkItem(const char* name, bool dynamic, std::string value);
121
122
130 void mkItem(const char* name, bool dynamic, unsigned value);
131
132
140 void mkItem(const char* name, bool dynamic, int value);
141
142
150 void mkItem(const char* name, bool dynamic, long long int value);
151
152
160 void mkItem(const char* name, bool dynamic, double value);
161
162
164
165
166
169
171 long onSimStep(FXObject*, FXSelector, void*);
172
176 long onTableSelected(FXObject*, FXSelector, void*);
177
181 long onTableDeselected(FXObject*, FXSelector, void*);
182
183
193 long onRightButtonPress(FXObject*, FXSelector, void*);
194
196 long onLeftBtnPress(FXObject*, FXSelector, void*);
198
201 static void updateAll() {
202 FXMutexLock locker(myGlobalContainerLock);
203 for (GUIParameterTableWindow* const window : myContainer) {
204 window->updateTable();
205 }
206 }
207
208protected:
215 void updateTable();
216
218 static FXMutex myGlobalContainerLock;
219
221 static std::vector<GUIParameterTableWindow*> myContainer;
222
223private:
226
228 FXTable* myTable;
229
232
234 std::vector<GUIParameterTableItemInterface*> myItems;
235
238
240 unsigned myCurrentPos;
241
243 mutable FXMutex myLock;
244
246 static int numParams(const GUIGlObject* obj);
247
248protected:
249 FOX_CONSTRUCTOR(GUIParameterTableWindow)
250
251};
Instance of a single line in a parameter window.
Interface to a single line in a parameter window.
A window containing a gl-object's parameter.
long onRightButtonPress(FXObject *, FXSelector, void *)
Shows a popup.
GUIMainWindow * myApplication
The main application window.
static FXMutex myGlobalContainerLock
The mutex used to avoid concurrent updates of the instance container.
void removeObject(GUIGlObject *const o)
Lets this window know the object shown is being deleted.
static int numParams(const GUIGlObject *obj)
returns the number of parameters if obj is Parameterised and 0 otherwise
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
int myTrackerY
y-position for opening new tracker window
long onLeftBtnPress(FXObject *, FXSelector, void *)
directly opens tracker when clicking on last column
long onTableSelected(FXObject *, FXSelector, void *)
Does nothing.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
FXMutex myLock
A lock assuring save updates in case of object deletion.
std::vector< GUIParameterTableItemInterface * > myItems
The list of table rows.
unsigned myCurrentPos
The index of the next row to add - used while building.
void checkFont(const std::string &text)
ensure that the font covers the given text
long onTableDeselected(FXObject *, FXSelector, void *)
Does nothing.
FXTable * myTable
The table to display the information in.
static std::vector< GUIParameterTableWindow * > myContainer
The container of items that shall be updated.
long onSimStep(FXObject *, FXSelector, void *)
Updates the table due to a simulation step.
void updateTable()
Updates the table.
static void updateAll()
Updates all instances.
GUIGlObject * myObject
The object to get the information from.
Persists window position in the registry.
An upper class for objects with additional parameters.