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 /****************************************************************************/
17 // The window that holds the table of an object's parameter
18 /****************************************************************************/
19 #ifndef GUIParameterTableWindow_h
20 #define GUIParameterTableWindow_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <vector>
29 #include <string>
30 #include <algorithm>
31 #include <functional>
32 #include <fx.h>
34 #include <utils/common/SUMOTime.h>
35 #include "GUIParameterTableItem.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class GUIGlObject;
42 class GUIMainWindow;
44 class Parameterised;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
63 class GUIParameterTableWindow : public FXMainWindow {
64  FXDECLARE(GUIParameterTableWindow)
65 public:
73  GUIGlObject& o, int noRows);
74 
75 
78 
79 
88  void closeBuilding(const Parameterised* p = 0);
89 
90 
91 
95  void removeObject(GUIGlObject* const o);
96 
97 
98 
101 
108  template<class T>
109  void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
111  myItems.push_back(i);
112  }
113 
121  void mkItem(const char* name, bool dynamic, std::string value);
122 
123 
131  void mkItem(const char* name, bool dynamic, unsigned value);
132 
133 
141  void mkItem(const char* name, bool dynamic, int value);
142 
143 
151  void mkItem(const char* name, bool dynamic, long long int value);
152 
153 
161  void mkItem(const char* name, bool dynamic, double value);
162 
163 
165 
166 
167 
170 
172  long onSimStep(FXObject*, FXSelector, void*);
173 
177  long onTableSelected(FXObject*, FXSelector, void*);
178 
182  long onTableDeselected(FXObject*, FXSelector, void*);
183 
193  long onRightButtonPress(FXObject*, FXSelector, void*);
195 
198  static void updateAll() {
199  FXMutexLock locker(myGlobalContainerLock);
200  std::for_each(myContainer.begin(), myContainer.end(), std::mem_fun(&GUIParameterTableWindow::updateTable));
201  }
202 
203 protected:
210  void updateTable();
211 
213  static FXMutex myGlobalContainerLock;
214 
216  static std::vector<GUIParameterTableWindow*> myContainer;
217 
218 private:
221 
223  FXTable* myTable;
224 
227 
229  std::vector<GUIParameterTableItemInterface*> myItems;
230 
232  unsigned myCurrentPos;
233 
235  mutable FXMutex myLock;
236 
238  static int numParams(const GUIGlObject* obj);
239 
240 protected:
243 
244 };
245 
246 
247 #endif
248 
249 /****************************************************************************/
250 
GUIParameterTableItemInterface
Interface to a single line in a parameter window.
Definition: GUIParameterTableItem.h:57
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
Parameterised
An upper class for objects with additional parameters.
Definition: Parameterised.h:43
SUMOTime.h
GUIParameterTableWindow::myTable
FXTable * myTable
The table to display the information in.
Definition: GUIParameterTableWindow.h:223
GUIParameterTableWindow::myApplication
GUIMainWindow * myApplication
The main application window.
Definition: GUIParameterTableWindow.h:226
GUIParameterTableItem.h
GUIParameterTableWindow::myContainer
static std::vector< GUIParameterTableWindow * > myContainer
The container of items that shall be updated.
Definition: GUIParameterTableWindow.h:216
GUIParameterTableWindow::numParams
static int numParams(const GUIGlObject *obj)
returns the number of parameters if obj is Parameterised and 0 otherwise
Definition: GUIParameterTableWindow.cpp:238
GUIParameterTableWindow::closeBuilding
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
Definition: GUIParameterTableWindow.cpp:220
GUIParameterTableWindow::onRightButtonPress
long onRightButtonPress(FXObject *, FXSelector, void *)
Shows a popup.
Definition: GUIParameterTableWindow.cpp:142
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:109
GUIParameterTableWindow::onTableDeselected
long onTableDeselected(FXObject *, FXSelector, void *)
Does nothing.
Definition: GUIParameterTableWindow.cpp:136
GUIGlObject
Definition: GUIGlObject.h:66
GUIParameterTableItem
Instance of a single line in a parameter window.
Definition: GUIParameterTableItem.h:99
GUIParameterTableWindow::updateTable
void updateTable()
Updates the table.
Definition: GUIParameterTableWindow.cpp:208
GUIParameterTableWindow::onTableSelected
long onTableSelected(FXObject *, FXSelector, void *)
Does nothing.
Definition: GUIParameterTableWindow.cpp:130
GUIParameterTableWindow::myItems
std::vector< GUIParameterTableItemInterface * > myItems
The list of table rows.
Definition: GUIParameterTableWindow.h:229
GUIParameterTableWindow::myObject
GUIGlObject * myObject
The object to get the information from.
Definition: GUIParameterTableWindow.h:220
ValueSource.h
GUIMainWindow
Definition: GUIMainWindow.h:47
GUIParameterTableWindow::myLock
FXMutex myLock
A lock assuring save updates in case of object deletion.
Definition: GUIParameterTableWindow.h:235
config.h
GUIParameterTableWindow::myGlobalContainerLock
static FXMutex myGlobalContainerLock
The mutex used to avoid concurrent updates of the instance container.
Definition: GUIParameterTableWindow.h:213
ValueSource
Definition: ValueSource.h:33
GUIParameterTableWindow::onSimStep
long onSimStep(FXObject *, FXSelector, void *)
Updates the table due to a simulation step.
Definition: GUIParameterTableWindow.cpp:121
GUIParameterTableWindow::removeObject
void removeObject(GUIGlObject *const o)
Lets this window know the object shown is being deleted.
Definition: GUIParameterTableWindow.cpp:114
GUIParameterTableWindow::myCurrentPos
unsigned myCurrentPos
The index of the next row to add - used while building.
Definition: GUIParameterTableWindow.h:232
GUIParameterTableWindow::updateAll
static void updateAll()
Updates all instances.
Definition: GUIParameterTableWindow.h:198
GUIParameterTableWindow::~GUIParameterTableWindow
~GUIParameterTableWindow()
Destructor.
Definition: GUIParameterTableWindow.cpp:95
GUIParameterTableWindow::GUIParameterTableWindow
GUIParameterTableWindow()
FOX needs this.
Definition: GUIParameterTableWindow.h:242