diff options
author | Tom Rondeau | 2011-01-23 12:56:28 -0500 |
---|---|---|
committer | Tom Rondeau | 2011-01-23 12:56:28 -0500 |
commit | 499bb149412e9b01419f82c755e6845338ba3b58 (patch) | |
tree | f051810dcc851185cbff9cfd932f0a4ba219c399 /gr-qtgui/src/lib/WaterfallDisplayPlot.cc | |
parent | 0bc402f938a4aa2504b606811a3c80d2c5ea75af (diff) | |
parent | fc806ce5d72807a47d479aecaddb2239722d5fb0 (diff) | |
download | gnuradio-499bb149412e9b01419f82c755e6845338ba3b58.tar.gz gnuradio-499bb149412e9b01419f82c755e6845338ba3b58.tar.bz2 gnuradio-499bb149412e9b01419f82c755e6845338ba3b58.zip |
Merge branch 'mergeme/qtgui/use_boost_posix_time' into next
Diffstat (limited to 'gr-qtgui/src/lib/WaterfallDisplayPlot.cc')
-rw-r--r-- | gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index 805af1d8d..a8e5361e7 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -12,6 +12,9 @@ #include <qapplication.h> +#include <boost/date_time/posix_time/posix_time.hpp> +namespace pt = boost::posix_time; + class FreqOffsetAndPrecisionClass { public: @@ -135,16 +138,14 @@ public: virtual QwtText label(double value) const { - QwtText returnLabel(""); - timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); - struct tm timeTm; - gmtime_r(&lineTime.tv_sec, &timeTm); - returnLabel = (QString("").sprintf("%04d/%02d/%02d\n%02d:%02d:%02d.%03ld", - timeTm.tm_year+1900, timeTm.tm_mon+1, - timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, - timeTm.tm_sec, lineTime.tv_nsec/1000000)); - return returnLabel; + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); } virtual void initiateUpdate() @@ -189,15 +190,14 @@ protected: using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - QString yLabel(""); - timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); - struct tm timeTm; - gmtime_r(&lineTime.tv_sec, &timeTm); - yLabel = (QString("").sprintf("%04d/%02d/%02d %02d:%02d:%02d.%03ld", - timeTm.tm_year+1900, timeTm.tm_mon+1, - timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, - timeTm.tm_sec, lineTime.tv_nsec/1000000)); + std::string time_str = pt::to_simple_string(pt::from_time_t(lineTime.tv_sec)); + + // lops off the YYYY-mmm-DD part of the string + int ind = time_str.find(" "); + if(ind != std::string::npos) + time_str = time_str.substr(ind); + QString yLabel(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); QwtText t(QString("%1 %2, %3"). arg(p.x(), 0, 'f', GetFrequencyPrecision()). |