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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The window that holds the table of an object's parameter
17 /****************************************************************************/
18 #ifndef GUIParameterTableWindow_h
19 #define GUIParameterTableWindow_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <vector>
28 #include <string>
29 #include <algorithm>
30 #include <functional>
31 #include <fx.h>
33 #include <utils/common/SUMOTime.h>
34 #include "GUIParameterTableItem.h"
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class GUIGlObject;
41 class GUIMainWindow;
43 class Parameterised;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
62 class GUIParameterTableWindow : public FXMainWindow {
63  FXDECLARE(GUIParameterTableWindow)
64 public:
72  GUIGlObject& o, int noRows);
73 
74 
77 
78 
87  void closeBuilding(const Parameterised* p = 0);
88 
89 
90 
94  void removeObject(GUIGlObject* const o);
95 
96 
97 
100 
107  template<class T>
108  void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
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 
192  long onRightButtonPress(FXObject*, FXSelector, void*);
194 
197  static void updateAll() {
198  FXMutexLock locker(myGlobalContainerLock);
199  std::for_each(myContainer.begin(), myContainer.end(), std::mem_fun(&GUIParameterTableWindow::updateTable));
200  }
201 
202 protected:
209  void updateTable();
210 
212  static FXMutex myGlobalContainerLock;
213 
215  static std::vector<GUIParameterTableWindow*> myContainer;
216 
217 private:
220 
222  FXTable* myTable;
223 
226 
228  std::vector<GUIParameterTableItemInterface*> myItems;
229 
231  unsigned myCurrentPos;
232 
234  mutable FXMutex myLock;
235 
237  static int numParams(const GUIGlObject* obj);
238 
239 protected:
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248 
GUIParameterTableItemInterface
Interface to a single line in a parameter window.
Definition: GUIParameterTableItem.h:56
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:42
SUMOTime.h
GUIParameterTableWindow::myTable
FXTable * myTable
The table to display the information in.
Definition: GUIParameterTableWindow.h:222
GUIParameterTableWindow::myApplication
GUIMainWindow * myApplication
The main application window.
Definition: GUIParameterTableWindow.h:225
GUIParameterTableItem.h
GUIParameterTableWindow::myContainer
static std::vector< GUIParameterTableWindow * > myContainer
The container of items that shall be updated.
Definition: GUIParameterTableWindow.h:215
GUIParameterTableWindow::numParams
static int numParams(const GUIGlObject *obj)
returns the number of parameters if obj is Parameterised and 0 otherwise
Definition: GUIParameterTableWindow.cpp:237
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:219
GUIParameterTableWindow::onRightButtonPress
long onRightButtonPress(FXObject *, FXSelector, void *)
Shows a popup.
Definition: GUIParameterTableWindow.cpp:141
GUIParameterTableWindow::mkItem
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
Definition: GUIParameterTableWindow.h:108
FOX_CONSTRUCTOR
#define FOX_CONSTRUCTOR(classname)
Definition: config.h:13
GUIParameterTableWindow::onTableDeselected
long onTableDeselected(FXObject *, FXSelector, void *)
Does nothing.
Definition: GUIParameterTableWindow.cpp:135
GUIGlObject
Definition: GUIGlObject.h:65
GUIParameterTableWindow::GUIParameterTableWindow
GUIParameterTableWindow(GUIMainWindow &app, GUIGlObject &o, int noRows)
Constructor.
Definition: GUIParameterTableWindow.cpp:61
GUIParameterTableItem
Instance of a single line in a parameter window.
Definition: GUIParameterTableItem.h:98
GUIParameterTableWindow::updateTable
void updateTable()
Updates the table.
Definition: GUIParameterTableWindow.cpp:207
GUIParameterTableWindow::onTableSelected
long onTableSelected(FXObject *, FXSelector, void *)
Does nothing.
Definition: GUIParameterTableWindow.cpp:129
GUIParameterTableWindow::myItems
std::vector< GUIParameterTableItemInterface * > myItems
The list of table rows.
Definition: GUIParameterTableWindow.h:228
GUIParameterTableWindow::myObject
GUIGlObject * myObject
The object to get the information from.
Definition: GUIParameterTableWindow.h:219
ValueSource.h
GUIMainWindow
Definition: GUIMainWindow.h:46
GUIParameterTableWindow::myLock
FXMutex myLock
A lock assuring save updates in case of object deletion.
Definition: GUIParameterTableWindow.h:234
config.h
GUIParameterTableWindow::myGlobalContainerLock
static FXMutex myGlobalContainerLock
The mutex used to avoid concurrent updates of the instance container.
Definition: GUIParameterTableWindow.h:212
ValueSource
Definition: ValueSource.h:32
GUIParameterTableWindow::onSimStep
long onSimStep(FXObject *, FXSelector, void *)
Updates the table due to a simulation step.
Definition: GUIParameterTableWindow.cpp:120
GUIParameterTableWindow::removeObject
void removeObject(GUIGlObject *const o)
Lets this window know the object shown is being deleted.
Definition: GUIParameterTableWindow.cpp:113
GUIParameterTableWindow::myCurrentPos
unsigned myCurrentPos
The index of the next row to add - used while building.
Definition: GUIParameterTableWindow.h:231
GUIParameterTableWindow::updateAll
static void updateAll()
Updates all instances.
Definition: GUIParameterTableWindow.h:197
GUIParameterTableWindow::~GUIParameterTableWindow
~GUIParameterTableWindow()
Destructor.
Definition: GUIParameterTableWindow.cpp:94