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/Makefile.am | 6 ++++-- gr-qtgui/src/lib/WaterfallDisplayPlot.cc | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am index b45b25c9d..446a07fd0 100644 --- a/gr-qtgui/src/lib/Makefile.am +++ b/gr-qtgui/src/lib/Makefile.am @@ -25,7 +25,7 @@ include $(top_srcdir)/Makefile.swig EXTRA_DIST += spectrumdisplayform.ui AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(QT_INCLUDES) $(WITH_INCLUDES) + $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) # Only include these files in the build if qtgui passes configure checks # This is mostly to help make distcheck pass @@ -82,10 +82,12 @@ QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LI $(QT_UIC_EXEC) $< -o $@ # magic flags -libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) +libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) $(LTVERSIONFLAGS) libgnuradio_qtgui_la_LIBADD = \ $(GNURADIO_CORE_LA) \ + $(BOOST_THREAD_LIB) \ + $(BOOST_DATE_TIME_LIB) \ -lstdc++ \ $(QT_LIBS) 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(-) 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(+) 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