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-2018 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>
35 #include <utils/common/SUMOTime.h>
36 #include "GUIParameterTableItem.h"
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class GUIGlObject;
43 class GUIMainWindow;
45 class Parameterised;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
64 class GUIParameterTableWindow : public FXMainWindow {
65  FXDECLARE(GUIParameterTableWindow)
66 public:
74  GUIGlObject& o, int noRows);
75 
76 
79 
80 
89  void closeBuilding(const Parameterised* p = 0);
90 
91 
92 
96  void removeObject(GUIGlObject* const o);
97 
98 
99 
102 
109  template<class T>
110  void mkItem(const char* name, bool dynamic, ValueSource<T>* src) {
112  myItems.push_back(i);
113  }
114 
122  void mkItem(const char* name, bool dynamic, std::string value);
123 
124 
132  void mkItem(const char* name, bool dynamic, unsigned value);
133 
134 
142  void mkItem(const char* name, bool dynamic, int value);
143 
144 
152  void mkItem(const char* name, bool dynamic, long long int value);
153 
154 
162  void mkItem(const char* name, bool dynamic, double value);
163 
164 
166 
167 
168 
171 
173  long onSimStep(FXObject*, FXSelector, void*);
174 
178  long onTableSelected(FXObject*, FXSelector, void*);
179 
183  long onTableDeselected(FXObject*, FXSelector, void*);
184 
194  long onRightButtonPress(FXObject*, FXSelector, void*);
196 
199  static void updateAll() {
201  std::for_each(myContainer.begin(), myContainer.end(), std::mem_fun(&GUIParameterTableWindow::updateTable));
202  }
203 
204 protected:
211  void updateTable();
212 
215 
217  static std::vector<GUIParameterTableWindow*> myContainer;
218 
219 private:
222 
224  FXTable* myTable;
225 
228 
230  std::vector<GUIParameterTableItemInterface*> myItems;
231 
233  unsigned myCurrentPos;
234 
236  mutable MFXMutex myLock;
237 
239  static int numParams(const GUIGlObject* obj);
240 
241 protected:
244 
245 };
246 
247 
248 #endif
249 
250 /****************************************************************************/
251 
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
void removeObject(GUIGlObject *const o)
Lets this window know the object shown is being deleted.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
unsigned myCurrentPos
The index of the next row to add - used while building.
FXTable * myTable
The table to display the information in.
GUIMainWindow * myApplication
The main application window.
void updateTable()
Updates the table.
static MFXMutex myGlobalContainerLock
The mutex used to avoid concurrent updates of the instance container.
static int numParams(const GUIGlObject *obj)
returns the number of parameters if obj is Parameterised and 0 otherwise
Interface to a single line in a parameter window.
static std::vector< GUIParameterTableWindow * > myContainer
The container of items that shall be updated.
long onRightButtonPress(FXObject *, FXSelector, void *)
Shows a popup.
An upper class for objects with additional parameters.
Definition: Parameterised.h:44
long onSimStep(FXObject *, FXSelector, void *)
Updates the table due to a simulation step.
long onTableDeselected(FXObject *, FXSelector, void *)
Does nothing.
GUIParameterTableWindow()
FOX needs this.
MFXMutex myLock
A lock assuring save updates in case of object deletion.
A mutex encapsulator which locks/unlocks the given mutex on construction/destruction, respectively.
Definition: AbstractMutex.h:59
GUIGlObject * myObject
The object to get the information from.
static void updateAll()
Updates all instances.
Instance of a single line in a parameter window.
long onTableSelected(FXObject *, FXSelector, void *)
Does nothing.
std::vector< GUIParameterTableItemInterface * > myItems
The list of table rows.
A window containing a gl-object&#39;s parameter.