From e1fd88db9b7edc13a90b5c81263d062ebcf2932b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 17 Jan 2011 18:09:38 -0800 Subject: qtgui plots static const fixes: Initialize static data members in the cpp file: http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12 For the WaterfallDisplayPlot, rather than bringing the initialization into the cpp file, the numbers seemed far more fitting as an enum given that they are by nature. This removed the symbol declaration from the cpp file, so its actually simpler. --- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 6 ------ 1 file changed, 6 deletions(-) (limited to 'gr-qtgui/src/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index 680c44756..805af1d8d 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -210,12 +210,6 @@ private: }; -const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; -const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_WHITE_HOT; -const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_BLACK_HOT; -const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_INCANDESCENT; -const int WaterfallDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED; - WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) : QwtPlot(parent) { -- cgit From 7cea46f75e3f4f4b0d42de89d7cedd90a0f091e0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 17 Jan 2011 20:37:09 -0800 Subject: qtgui boost use posix time: Replace calls to gmtime_r with boost::posix_time to make the code portable on systems without gmtime_r. --- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gr-qtgui/src/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index 680c44756..dc8d7b7ac 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -12,6 +12,8 @@ #include +#include + class FreqOffsetAndPrecisionClass { public: @@ -138,8 +140,7 @@ public: QwtText returnLabel(""); timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); - struct tm timeTm; - gmtime_r(&lineTime.tv_sec, &timeTm); + tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec))); 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, @@ -192,8 +193,7 @@ protected: QString yLabel(""); timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); - struct tm timeTm; - gmtime_r(&lineTime.tv_sec, &timeTm); + tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec))); 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, -- cgit From 82c9301797aae0e8355213827b1e6cbfe0648a39 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 22 Jan 2011 20:48:57 -0800 Subject: qtgui: use the posix time to_simple_string to simplify label text --- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'gr-qtgui/src/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index dc8d7b7ac..694dc86d8 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -13,6 +13,7 @@ #include #include +namespace pt = boost::posix_time; class FreqOffsetAndPrecisionClass { @@ -137,15 +138,9 @@ public: virtual QwtText label(double value) const { - QwtText returnLabel(""); - timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); - tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec))); - 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)); + return QwtText(QString("").sprintf("%s.%03ld", time_str.c_str(), lineTime.tv_nsec/1000000)); } virtual void initiateUpdate() @@ -190,14 +185,9 @@ protected: using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - QString yLabel(""); - timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); - tm timeTm(boost::posix_time::to_tm(boost::posix_time::from_time_t(lineTime.tv_sec))); - 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)); + 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()). -- cgit From fc806ce5d72807a47d479aecaddb2239722d5fb0 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Sun, 23 Jan 2011 12:52:07 -0500 Subject: Removing YYYY-mmm-DD from time displayed on Waterfall plot. --- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gr-qtgui/src/lib/WaterfallDisplayPlot.cc') diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index 694dc86d8..d7421f06e 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -140,6 +140,11 @@ public: { timespec lineTime = timespec_add(GetZeroTime(), (-value) * GetSecondsPerLine()); 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)); } @@ -187,6 +192,11 @@ protected: { timespec lineTime = timespec_add(GetZeroTime(), (-p.y()) * GetSecondsPerLine()); 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"). -- cgit