#include <TrackerValueDesc.h>
This class contains the information needed to display a time line of float values.
Definition at line 54 of file TrackerValueDesc.h.
Public Member Functions | |
| void | addValue (SUMOReal value) |
| Adds a new value to the list. | |
| const std::vector< SUMOReal > & | getAggregatedValues () |
| returns the vector of aggregated values The values will be locked - no further addition will be perfomed until the method "unlockValues" will be called | |
| size_t | getAggregationSpan () const |
| get the aggregation amount | |
| const RGBColor & | getColor () const |
| Returns the color to use to display the value. | |
| SUMOReal | getMax () const |
| Returns the values maximum. | |
| SUMOReal | getMin () const |
| Returns the values minimum. | |
| const std::string & | getName () const |
| Returns the name of the value. | |
| SUMOReal | getRange () const |
| returns the maximum value range | |
| size_t | getRecordingBegin () const |
| Returns the timestep the recording started. | |
| const std::vector< SUMOReal > & | getValues () |
| returns the vector of collected values The values will be locked - no further addition will be perfomed until the method "unlockValues" will be called | |
| SUMOReal | getYCenter () const |
| Returns the center of the value. | |
| void | setAggregationSpan (size_t as) |
| set the aggregation amount | |
| TrackerValueDesc (const std::string &name, const RGBColor &col, GUIGlObject *o, size_t recordBegin) | |
| Constructor. | |
| void | unlockValues () |
| Releases the locking after the values have been drawn. | |
| ~TrackerValueDesc () | |
| Destructor. | |
Private Attributes | |
| RGBColor | myActiveCol |
| The color to use when the value is set as "active". | |
| std::vector< SUMOReal > | myAggregatedValues |
| Collected values in their aggregated form. | |
| size_t | myAggregationInterval |
| The aggregation interval. | |
| RGBColor | myInactiveCol |
| The color to use when the value is set as "inactive". | |
| SUMOReal | myInvalidValue |
| Values like this shall not be counted on aggregation. | |
| MFXMutex | myLock |
| SUMOReal | myMax |
| SUMOReal | myMin |
| The minimum and the maximum of the value. | |
| std::string | myName |
| The name of the value. | |
| GUIGlObject * | myObject |
| The object to retrieve the information from. | |
| size_t | myRecordingBegin |
| The time step the values are added from. | |
| SUMOReal | myTmpLastAggValue |
| Temporary storage for the last aggregation interval. | |
| size_t | myValidNo |
| Counter for valid numbers within the current aggregation interval. | |
| std::vector< SUMOReal > | myValues |
| Values collected. | |
| TrackerValueDesc::TrackerValueDesc | ( | const std::string & | name, | |
| const RGBColor & | col, | |||
| GUIGlObject * | o, | |||
| size_t | recordBegin | |||
| ) |
Constructor.
Definition at line 43 of file TrackerValueDesc.cpp.
00047 : myName(name), myObject(o), 00048 myActiveCol(col), myInactiveCol(col), 00049 myMin(0), myMax(0), 00050 myAggregationInterval(1), myInvalidValue(-1), myValidNo(0), 00051 myRecordingBegin(recordBegin), myTmpLastAggValue(0) {}
| TrackerValueDesc::~TrackerValueDesc | ( | ) |
Destructor.
Definition at line 54 of file TrackerValueDesc.cpp.
References MFXMutex::locked(), myLock, and MFXMutex::unlock().
00054 { 00055 // just to quit cleanly on a failure 00056 if (myLock.locked()) { 00057 myLock.unlock(); 00058 } 00059 }
| void TrackerValueDesc::addValue | ( | SUMOReal | value | ) | [virtual] |
Adds a new value to the list.
Implements ValueRetriever< SUMOReal >.
Definition at line 63 of file TrackerValueDesc.cpp.
References MFXMutex::lock(), myAggregatedValues, myAggregationInterval, myInvalidValue, myLock, myMax, myMin, myTmpLastAggValue, myValidNo, myValues, SUMOReal, and MFXMutex::unlock().
00063 { 00064 if (myValues.size()==0) { 00065 myMin = (SUMOReal) value; 00066 myMax = (SUMOReal) value; 00067 } else { 00068 myMin = (SUMOReal) value < myMin ? (SUMOReal) value : myMin; 00069 myMax = (SUMOReal) value > myMax ? (SUMOReal) value : myMax; 00070 } 00071 myLock.lock(); 00072 myValues.push_back((SUMOReal) value); 00073 if (value!=myInvalidValue) { 00074 myTmpLastAggValue += (SUMOReal) value; 00075 myValidNo++; 00076 } 00077 // check what to do with aggregated values 00078 if (myValues.size()!=0&&myValues.size()%myAggregationInterval==0) { 00079 // ok, a new aggregation is filled completely. Set. 00080 if (myValidNo!=0) { 00081 myAggregatedValues.push_back( 00082 myTmpLastAggValue / (SUMOReal) myValidNo); 00083 } else { 00084 myAggregatedValues.push_back(0); 00085 } 00086 myTmpLastAggValue = 0; 00087 myValidNo = 0; 00088 } else { 00089 // remove the one previously set 00090 if (myAggregatedValues.size()!=0) { 00091 myAggregatedValues.erase(myAggregatedValues.end()-1); 00092 } 00093 // append newly computed 00094 if (myValidNo!=0) { 00095 myAggregatedValues.push_back( 00096 myTmpLastAggValue / (SUMOReal) myValidNo); 00097 } else { 00098 myAggregatedValues.push_back(0); 00099 } 00100 } 00101 myLock.unlock(); 00102 }
| const std::vector< SUMOReal > & TrackerValueDesc::getAggregatedValues | ( | ) |
returns the vector of aggregated values The values will be locked - no further addition will be perfomed until the method "unlockValues" will be called
Definition at line 147 of file TrackerValueDesc.cpp.
References MFXMutex::lock(), myAggregatedValues, and myLock.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), and GUIParameterTracker::onCmdSave().
00147 { 00148 myLock.lock(); 00149 return myAggregatedValues; 00150 }
| size_t TrackerValueDesc::getAggregationSpan | ( | ) | const |
get the aggregation amount
Definition at line 196 of file TrackerValueDesc.cpp.
References myAggregationInterval.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue().
00196 { 00197 return myAggregationInterval; 00198 }
| const RGBColor & TrackerValueDesc::getColor | ( | ) | const |
Returns the color to use to display the value.
Definition at line 134 of file TrackerValueDesc.cpp.
References myActiveCol.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue().
00134 { 00135 return myActiveCol; 00136 }
| SUMOReal TrackerValueDesc::getMax | ( | ) | const |
Returns the values maximum.
Definition at line 120 of file TrackerValueDesc.cpp.
References myMax.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), getRange(), and getYCenter().
00120 { 00121 return myMax; 00122 }
| SUMOReal TrackerValueDesc::getMin | ( | ) | const |
Returns the values minimum.
Definition at line 114 of file TrackerValueDesc.cpp.
References myMin.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), getRange(), and getYCenter().
00114 { 00115 return myMin; 00116 }
| const std::string & TrackerValueDesc::getName | ( | ) | const |
Returns the name of the value.
Definition at line 154 of file TrackerValueDesc.cpp.
References myName.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), and GUIParameterTracker::onCmdSave().
00154 { 00155 return myName; 00156 }
| SUMOReal TrackerValueDesc::getRange | ( | ) | const |
returns the maximum value range
Definition at line 106 of file TrackerValueDesc.cpp.
References getMax(), getMin(), myMax, and myMin.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), and GUIParameterTracker::GUIParameterTrackerPanel::patchHeightVal().
| size_t TrackerValueDesc::getRecordingBegin | ( | ) | const |
Returns the timestep the recording started.
Definition at line 202 of file TrackerValueDesc.cpp.
References myRecordingBegin.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue().
00202 { 00203 return myRecordingBegin; 00204 }
| const std::vector< SUMOReal > & TrackerValueDesc::getValues | ( | ) |
returns the vector of collected values The values will be locked - no further addition will be perfomed until the method "unlockValues" will be called
Definition at line 140 of file TrackerValueDesc.cpp.
References MFXMutex::lock(), myLock, and myValues.
| SUMOReal TrackerValueDesc::getYCenter | ( | ) | const |
Returns the center of the value.
Definition at line 126 of file TrackerValueDesc.cpp.
References getMax(), getMin(), myMax, and myMin.
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), and GUIParameterTracker::GUIParameterTrackerPanel::patchHeightVal().
| void TrackerValueDesc::setAggregationSpan | ( | size_t | as | ) |
set the aggregation amount
Definition at line 165 of file TrackerValueDesc.cpp.
References MFXMutex::lock(), myAggregatedValues, myAggregationInterval, myInvalidValue, myLock, myTmpLastAggValue, myValidNo, myValues, SUMOReal, and MFXMutex::unlock().
00165 { 00166 myLock.lock(); 00167 if (myAggregationInterval!=as) { 00168 // ok, the aggregation has changed, 00169 // let's recompute the list of aggregated values 00170 myAggregatedValues.clear(); 00171 std::vector<SUMOReal>::iterator i; 00172 for (i=myValues.begin(); i!=myValues.end();) { 00173 SUMOReal value = 0; 00174 myValidNo = 0; 00175 for (size_t j=0; j<as&&i!=myValues.end(); j++, ++i) { 00176 if ((*i)!=myInvalidValue) { 00177 value += (*i); 00178 myValidNo++; 00179 } 00180 } 00181 if (myValidNo==0) { 00182 myAggregatedValues.push_back(0); 00183 myTmpLastAggValue = 0; 00184 } else { 00185 myAggregatedValues.push_back(value / (SUMOReal) myValidNo); 00186 myTmpLastAggValue = value / (SUMOReal) myValidNo; 00187 } 00188 } 00189 } 00190 myAggregationInterval = as; 00191 myLock.unlock(); 00192 }
| void TrackerValueDesc::unlockValues | ( | ) |
Releases the locking after the values have been drawn.
Definition at line 159 of file TrackerValueDesc.cpp.
References myLock, and MFXMutex::unlock().
Referenced by GUIParameterTracker::GUIParameterTrackerPanel::drawValue(), and GUIParameterTracker::onCmdSave().
RGBColor TrackerValueDesc::myActiveCol [private] |
The color to use when the value is set as "active".
Definition at line 115 of file TrackerValueDesc.h.
Referenced by getColor().
std::vector<SUMOReal> TrackerValueDesc::myAggregatedValues [private] |
Collected values in their aggregated form.
Definition at line 124 of file TrackerValueDesc.h.
Referenced by addValue(), getAggregatedValues(), and setAggregationSpan().
The aggregation interval.
Definition at line 133 of file TrackerValueDesc.h.
Referenced by addValue(), getAggregationSpan(), and setAggregationSpan().
RGBColor TrackerValueDesc::myInactiveCol [private] |
The color to use when the value is set as "inactive".
Definition at line 118 of file TrackerValueDesc.h.
SUMOReal TrackerValueDesc::myInvalidValue [private] |
Values like this shall not be counted on aggregation.
Definition at line 136 of file TrackerValueDesc.h.
Referenced by addValue(), and setAggregationSpan().
MFXMutex TrackerValueDesc::myLock [private] |
Definition at line 130 of file TrackerValueDesc.h.
Referenced by addValue(), getAggregatedValues(), getValues(), setAggregationSpan(), unlockValues(), and ~TrackerValueDesc().
SUMOReal TrackerValueDesc::myMax [private] |
Definition at line 127 of file TrackerValueDesc.h.
Referenced by addValue(), getMax(), getRange(), and getYCenter().
SUMOReal TrackerValueDesc::myMin [private] |
The minimum and the maximum of the value.
Definition at line 127 of file TrackerValueDesc.h.
Referenced by addValue(), getMin(), getRange(), and getYCenter().
std::string TrackerValueDesc::myName [private] |
GUIGlObject* TrackerValueDesc::myObject [private] |
size_t TrackerValueDesc::myRecordingBegin [private] |
The time step the values are added from.
Definition at line 142 of file TrackerValueDesc.h.
Referenced by getRecordingBegin().
SUMOReal TrackerValueDesc::myTmpLastAggValue [private] |
Temporary storage for the last aggregation interval.
Definition at line 145 of file TrackerValueDesc.h.
Referenced by addValue(), and setAggregationSpan().
size_t TrackerValueDesc::myValidNo [private] |
Counter for valid numbers within the current aggregation interval.
Definition at line 139 of file TrackerValueDesc.h.
Referenced by addValue(), and setAggregationSpan().
std::vector<SUMOReal> TrackerValueDesc::myValues [private] |
Values collected.
Definition at line 121 of file TrackerValueDesc.h.
Referenced by addValue(), getValues(), and setAggregationSpan().
1.5.6