Fixes a lot of warnings by cleaning up namespace issues.
[debian/gnuradio] / gr-qtgui / src / lib / ConstellationDisplayPlot.cc
index c422c8f525d72d057d38fc1fbff955ae6f34c151..9ad5bdd3c44215b94d90e84a447c00e8a0b6a3be 100644 (file)
@@ -24,22 +24,24 @@ public:
   }
 
 protected:
+  using QwtPlotZoomer::trackerText;
   virtual QwtText trackerText( const QwtDoublePoint& p ) const 
   {
-    QwtText t(QString("Sample %1, %2 V").arg(p.x(), 0, 'f', 0).arg(p.y(), 0, 'f', 4));
-
+    QwtText t(QString("(%1, %2)").arg(p.x(), 0, 'f', 4).
+             arg(p.y(), 0, 'f', 4));
     return t;
   }
 };
 
-ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent):QwtPlot(parent){
+ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent)
+  : QwtPlot(parent)
+{
   timespec_reset(&_lastReplot);
 
   resize(parent->width(), parent->height());
 
-  _displayIntervalTime = (1.0/10.0); // 1/10 of a second between updates
-
   _numPoints = 1024;
+  _penSize = 5;
   _realDataPoints = new double[_numPoints];
   _imagDataPoints = new double[_numPoints];
 
@@ -55,17 +57,17 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent):QwtPlot(pare
   canvas()->setPalette(palette);  
 
   setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine);
-  setAxisScale(QwtPlot::xBottom, -1.0, 1.0);
+  set_xaxis(-2.0, 2.0);
   setAxisTitle(QwtPlot::xBottom, "In-phase");
 
   setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine);
-  setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
+  set_yaxis(-2.0, 2.0);
   setAxisTitle(QwtPlot::yLeft, "Quadrature");
 
   // Automatically deleted when parent is deleted
   _plot_curve = new QwtPlotCurve("Constellation Points");
   _plot_curve->attach(this);
-  _plot_curve->setPen(QPen(Qt::blue, 5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+  _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
   _plot_curve->setStyle(QwtPlotCurve::Dots);
   _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints);
 
@@ -100,14 +102,12 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent):QwtPlot(pare
   _zoomer->setRubberBandPen(c);
   _zoomer->setTrackerPen(c);
 
-  QwtLegend* legendDisplay = new QwtLegend(this);
-  legendDisplay->setItemMode(QwtLegend::CheckableItem);
-  insertLegend(legendDisplay);
-
-  connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) ));
+  connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), 
+         this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) ));
 }
 
-ConstellationDisplayPlot::~ConstellationDisplayPlot(){
+ConstellationDisplayPlot::~ConstellationDisplayPlot()
+{
   delete[] _realDataPoints;
   delete[] _imagDataPoints;
 
@@ -115,26 +115,55 @@ ConstellationDisplayPlot::~ConstellationDisplayPlot(){
   // _zoomer and _panner deleted when parent deleted
 }
 
+void 
+ConstellationDisplayPlot::set_pen_size(int size)
+{
+  if(size > 0 && size < 30){
+    _penSize = size;
+    _plot_curve->setPen(QPen(Qt::blue, _penSize, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
+  }
+}
 
 
-void ConstellationDisplayPlot::replot(){
+void
+ConstellationDisplayPlot::set_xaxis(double min, double max)
+{
+  setAxisScale(QwtPlot::xBottom, min, max);
+}
 
-  const timespec startTime = get_highres_clock();
-  
-  QwtPlot::replot();
+void
+ConstellationDisplayPlot::set_yaxis(double min, double max)
+{
+  setAxisScale(QwtPlot::yLeft, min, max);
+}
 
-  double differenceTime = (diff_timespec(get_highres_clock(), startTime));
+void
+ConstellationDisplayPlot::set_axis(double xmin, double xmax,
+                                  double ymin, double ymax)
+{
+  set_xaxis(xmin, xmax);
+  set_yaxis(ymin, ymax);
+}
 
-  differenceTime *= 99.0;
-  // Require at least a 10% duty cycle
-  if(differenceTime > (1.0/10.0)){
-    _displayIntervalTime = differenceTime;
-  }
+void ConstellationDisplayPlot::replot()
+{
+  QwtPlot::replot();
 }
 
-void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, const double* imagDataPoints, const int64_t numDataPoints){
-  if(numDataPoints > 0){
+void
+ConstellationDisplayPlot::resizeSlot( QSize *s )
+{
+  resize(s->width(), s->height());
+}
 
+void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints,
+                                          const double* imagDataPoints,
+                                          const int64_t numDataPoints,
+                                          const double timeInterval)
+{
+  if((numDataPoints > 0) && 
+     (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) {
+    
     if(numDataPoints != _numPoints){
       _numPoints = numDataPoints;
 
@@ -145,22 +174,19 @@ void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, const d
       
       _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints);
     }
+
     memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double));
     memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double));
 
-  }
-
-  // Allow at least a 50% duty cycle
-  if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){
-    // Only replot the screen if it is visible
-    if(isVisible()){
-      replot();
-    }
+    replot();
+    
     _lastReplot = get_highres_clock();
   }
 }
 
-void ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on){
+void
+ConstellationDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on)
+{
   plotItem->setVisible(!on);
 }