Eclipse SUMO - Simulation of Urban MObility
GUIParameterTableWindow.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2022 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>
31 #include <utils/common/SUMOTime.h>
32 #include "GUIParameterTableItem.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class GUIGlObject;
39 class GUIMainWindow;
41 class Parameterised;
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
60 class GUIParameterTableWindow : public FXMainWindow {
61  FXDECLARE(GUIParameterTableWindow)
62 public:
69 
70 
73 
74 
83  void closeBuilding(const Parameterised* p = 0);
84 
85 
87  void checkFont(const std::string& text);
88 
92  void removeObject(GUIGlObject* const o);
93 
94 
95 
98 
105  template<class T>
106  void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
107  myTable->insertRows((int)myItems.size() + 1);
109  myItems.push_back(i);
110  }
111 
119  void mkItem(const char* name, bool dynamic, std::string value);
120 
121 
129  void mkItem(const char* name, bool dynamic, unsigned value);
130 
131 
139  void mkItem(const char* name, bool dynamic, int value);
140 
141 
149  void mkItem(const char* name, bool dynamic, long long int value);
150 
151 
159  void mkItem(const char* name, bool dynamic, double value);
160 
161 
163 
164 
165 
168 
170  long onSimStep(FXObject*, FXSelector, void*);
171 
175  long onTableSelected(FXObject*, FXSelector, void*);
176 
180  long onTableDeselected(FXObject*, FXSelector, void*);
181 
182 
192  long onRightButtonPress(FXObject*, FXSelector, void*);
193 
195  long onLeftBtnPress(FXObject*, FXSelector, void*);
197 
200  static void updateAll() {
201  FXMutexLock locker(myGlobalContainerLock);
202  for (GUIParameterTableWindow* const window : myContainer) {
203  window->updateTable();
204  }
205  }
206 
207 protected:
214  void updateTable();
215 
217  static FXMutex myGlobalContainerLock;
218 
220  static std::vector<GUIParameterTableWindow*> myContainer;
221 
222 private:
225 
227  FXTable* myTable;
228 
231 
233  std::vector<GUIParameterTableItemInterface*> myItems;
234 
237 
239  unsigned myCurrentPos;
240 
242  mutable FXMutex myLock;
243 
245  static int numParams(const GUIGlObject* obj);
246 
247 protected:
248  FOX_CONSTRUCTOR(GUIParameterTableWindow)
249 
250 };
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.
GUIParameterTableWindow(GUIMainWindow &app, GUIGlObject &o)
Constructor.
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.
An upper class for objects with additional parameters.
Definition: Parameterised.h:41