#include <GUIParameterTableItem.h>

This class represents a single item of a parameter table and is an implementation of the GUIParameterTableItemInterface that allows different value-types.
As some values may change over the simulation, this class holds the information whether they change and how to ask for new values if they do.
Definition at line 118 of file GUIParameterTableItem.h.
Public Member Functions | |
| bool | dynamic () const throw () |
| Returns the information whether this item may change. | |
| const std::string & | getName () const throw () |
| Returns the name of this value. | |
| ValueSource< T > * | getSourceCopy () const throw () |
| Returns a copy of the source if the value is dynamic. | |
| ValueSource< SUMOReal > * | getSUMORealSourceCopy () const throw () |
| Returns a SUMOReal-typed copy of the source if the value is dynamic. | |
| GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, std::string value) throw () | |
| Constructor for string-typed, non-changing (static) values. | |
| GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, T value) throw () | |
| Constructor for non-changing (static) values. | |
| GUIParameterTableItem (FXTable *table, unsigned pos, const std::string &name, bool dynamic, ValueSource< T > *src) throw () | |
| Constructor for changing (dynamic) values. | |
| void | init (bool dynamic, std::string value) throw () |
| Initialises the line. | |
| void | update () throw () |
| Resets the value if it's dynamic. | |
| ~GUIParameterTableItem () throw () | |
| Destructor. | |
Private Attributes | |
| bool | myAmDynamic |
| Information whether the value may change. | |
| std::string | myName |
| The name of this value. | |
| ValueSource< T > * | mySource |
| The source to gain new values from; this source is==0 if the values are not dynamic. | |
| FXTable * | myTable |
| The table this entry belongs to. | |
| FXint | myTablePosition |
| The position within the table. | |
| T | myValue |
| A backup of the value to avoid the redrawing when nothing has changed. | |
| GUIParameterTableItem< T >::GUIParameterTableItem | ( | FXTable * | table, | |
| unsigned | pos, | |||
| const std::string & | name, | |||
| bool | dynamic, | |||
| ValueSource< T > * | src | |||
| ) | throw () [inline] |
Constructor for changing (dynamic) values.
| [in] | table | The table this item belongs to |
| [in] | pos | The row of the table this item fills |
| [in] | name | The name of the represented value |
| [in] | dynamic | Information whether this value changes over time |
| [in] | src | The value source |
Definition at line 130 of file GUIParameterTableItem.h.
References GUIParameterTableItemInterface::dynamic().
00133 : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(src), 00134 myValue(src->getValue()), myTable(table) { 00135 init(dynamic, toString<T>(src->getValue())); 00136 }
| GUIParameterTableItem< T >::GUIParameterTableItem | ( | FXTable * | table, | |
| unsigned | pos, | |||
| const std::string & | name, | |||
| bool | dynamic, | |||
| T | value | |||
| ) | throw () [inline] |
Constructor for non-changing (static) values.
| [in] | table | The table this item belongs to |
| [in] | pos | The row of the table this item fills |
| [in] | name | The name of the represented value |
| [in] | dynamic | Information whether this value changes over time |
| [in] | value | The value |
Definition at line 150 of file GUIParameterTableItem.h.
References GUIParameterTableItemInterface::dynamic().
00153 : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(0), 00154 myValue(value), myTable(table) { 00155 init(dynamic, toString<T>(value)); 00156 }
| GUIParameterTableItem< T >::GUIParameterTableItem | ( | FXTable * | table, | |
| unsigned | pos, | |||
| const std::string & | name, | |||
| bool | dynamic, | |||
| std::string | value | |||
| ) | throw () [inline] |
Constructor for string-typed, non-changing (static) values.
| [in] | table | The table this item belongs to |
| [in] | pos | The row of the table this item fills |
| [in] | name | The name of the represented value |
| [in] | dynamic | Information whether this value changes over time |
| [in] | value | The value |
Definition at line 170 of file GUIParameterTableItem.h.
References GUIParameterTableItemInterface::dynamic().
00173 : myAmDynamic(dynamic), myName(name), myTablePosition((FXint) pos), mySource(0), 00174 myValue(0), myTable(table) { 00175 init(dynamic, value); 00176 }
| GUIParameterTableItem< T >::~GUIParameterTableItem | ( | ) | throw () [inline] |
Destructor.
Definition at line 180 of file GUIParameterTableItem.h.
00180 { 00181 delete mySource; 00182 }
| bool GUIParameterTableItem< T >::dynamic | ( | ) | const throw () [inline, virtual] |
Returns the information whether this item may change.
Implements GUIParameterTableItemInterface.
Definition at line 213 of file GUIParameterTableItem.h.
00213 { 00214 return myAmDynamic; 00215 }
| const std::string& GUIParameterTableItem< T >::getName | ( | ) | const throw () [inline, virtual] |
Returns the name of this value.
Implements GUIParameterTableItemInterface.
Definition at line 222 of file GUIParameterTableItem.h.
00222 { 00223 return myName; 00224 }
| ValueSource<T>* GUIParameterTableItem< T >::getSourceCopy | ( | ) | const throw () [inline] |
Returns a copy of the source if the value is dynamic.
Definition at line 250 of file GUIParameterTableItem.h.
| ValueSource<SUMOReal>* GUIParameterTableItem< T >::getSUMORealSourceCopy | ( | ) | const throw () [inline, virtual] |
Returns a SUMOReal-typed copy of the source if the value is dynamic.
Implements GUIParameterTableItemInterface.
Definition at line 262 of file GUIParameterTableItem.h.
References ValueSource< T >::makeSUMORealReturningCopy().
00262 { 00263 if (mySource==0) { 00264 return 0; 00265 } 00266 return mySource->makeSUMORealReturningCopy(); 00267 }
| void GUIParameterTableItem< T >::init | ( | bool | dynamic, | |
| std::string | value | |||
| ) | throw () [inline] |
Initialises the line.
Fills the line using the name, the current value, and the information whether the value changes over time.
| [in] | dynamic | Information whether this value changes over time |
| [in] | value | The current (initial) value |
Definition at line 193 of file GUIParameterTableItem.h.
References GUIParameterTableItemInterface::dynamic(), GUIIconSubSys::getIcon(), ICON_NO, and ICON_YES.
00193 { 00194 myTable->setItemText(myTablePosition, 0, myName.c_str()); 00195 myTable->setItemText(myTablePosition, 1, value.c_str()); 00196 if (dynamic) { 00197 myTable->setItemIcon(myTablePosition, 2, 00198 GUIIconSubSys::getIcon(ICON_YES)); 00199 } else { 00200 myTable->setItemIcon(myTablePosition, 2, 00201 GUIIconSubSys::getIcon(ICON_NO)); 00202 } 00203 myTable->setItemJustify(myTablePosition, 2, 00204 FXTableItem::CENTER_X|FXTableItem::CENTER_Y); 00205 }
| void GUIParameterTableItem< T >::update | ( | ) | throw () [inline, virtual] |
Resets the value if it's dynamic.
If the value is dynamic, the current value is retrieved from the value source. If it is different from the previous one (stored in myValue), it is stored in myValue and set as the current value text within the according table cell.
Implements GUIParameterTableItemInterface.
Definition at line 234 of file GUIParameterTableItem.h.
References GUIParameterTableItemInterface::dynamic().
00234 { 00235 if (!dynamic()||mySource==0) { 00236 return; 00237 } 00238 T value = mySource->getValue(); 00239 if (value!=myValue) { 00240 myValue = value; 00241 myTable->setItemText(myTablePosition, 1, toString<T>(myValue).c_str()); 00242 } 00243 }
bool GUIParameterTableItem< T >::myAmDynamic [private] |
std::string GUIParameterTableItem< T >::myName [private] |
ValueSource<T>* GUIParameterTableItem< T >::mySource [private] |
The source to gain new values from; this source is==0 if the values are not dynamic.
Definition at line 281 of file GUIParameterTableItem.h.
FXTable* GUIParameterTableItem< T >::myTable [private] |
FXint GUIParameterTableItem< T >::myTablePosition [private] |
T GUIParameterTableItem< T >::myValue [private] |
A backup of the value to avoid the redrawing when nothing has changed.
Definition at line 284 of file GUIParameterTableItem.h.
1.5.6