summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib/FrequencyDisplayPlot.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/lib/FrequencyDisplayPlot.cc')
-rw-r--r--gr-qtgui/lib/FrequencyDisplayPlot.cc591
1 files changed, 332 insertions, 259 deletions
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc
index b74d460150..e279155544 100644
--- a/gr-qtgui/lib/FrequencyDisplayPlot.cc
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2008,2009,2010,2011 Free Software Foundation, Inc.
+ * Copyright 2008-2011 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,88 +25,44 @@
#include <FrequencyDisplayPlot.h>
+#include "qtgui_types.h"
#include <qwt_scale_draw.h>
-
-class FreqPrecisionClass
-{
-public:
- FreqPrecisionClass(const int freqPrecision)
- {
- _frequencyPrecision = freqPrecision;
- }
-
- virtual ~FreqPrecisionClass()
- {
- }
-
- virtual unsigned int GetFrequencyPrecision() const
- {
- return _frequencyPrecision;
- }
-
- virtual void SetFrequencyPrecision(const unsigned int newPrecision)
- {
- _frequencyPrecision = newPrecision;
- }
-protected:
- unsigned int _frequencyPrecision;
-
-private:
-
-};
-
-class FreqDisplayScaleDraw: public QwtScaleDraw, public FreqPrecisionClass
-{
-public:
- FreqDisplayScaleDraw(const unsigned int precision)
- : QwtScaleDraw(), FreqPrecisionClass(precision)
- {
- }
-
- virtual ~FreqDisplayScaleDraw()
- {
- }
-
- virtual QwtText label(double value) const
- {
- return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision());
- }
-
-protected:
-
-private:
-
-};
-
-class FreqDisplayZoomer: public QwtPlotZoomer, public FreqPrecisionClass
+#include <qwt_legend.h>
+#include <qwt_legend_item.h>
+#include <QColor>
+#include <iostream>
+
+/***********************************************************************
+ * Widget to provide mouse pointer coordinate text
+ **********************************************************************/
+class FreqDisplayZoomer: public QwtPlotZoomer, public FreqOffsetAndPrecisionClass
{
public:
FreqDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision)
- : QwtPlotZoomer(canvas),FreqPrecisionClass(freqPrecision)
+ : QwtPlotZoomer(canvas),
+ FreqOffsetAndPrecisionClass(freqPrecision)
{
setTrackerMode(QwtPicker::AlwaysOn);
}
-
- virtual ~FreqDisplayZoomer(){
-
- }
-
- virtual void updateTrackerText(){
+
+ virtual void updateTrackerText()
+ {
updateDisplay();
}
- void SetUnitType(const std::string &type)
+ void setUnitType(const std::string &type)
{
_unitType = type;
}
protected:
using QwtPlotZoomer::trackerText;
- virtual QwtText trackerText( const QwtDoublePoint& p ) const
+ virtual QwtText trackerText(QPoint const &p) const
{
- QwtText t(QString("%1 %2, %3 dB").
- arg(p.x(), 0, 'f', GetFrequencyPrecision()).
- arg(_unitType.c_str()).arg(p.y(), 0, 'f', 2));
+ QwtDoublePoint dp = QwtPlotZoomer::invTransform(p);
+ QwtText t(QString("%1 %2, %3 dB")
+ .arg(dp.x(), 0, 'f', getFrequencyPrecision())
+ .arg(_unitType.c_str()).arg(dp.y(), 0, 'f', 2));
return t;
}
@@ -114,41 +70,21 @@ private:
std::string _unitType;
};
-FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
- : QwtPlot(parent)
-{
- _startFrequency = 0;
- _stopFrequency = 4000;
-
- _lastReplot = 0;
-
- resize(parent->width(), parent->height());
- _useCenterFrequencyFlag = false;
+/***********************************************************************
+ * Main frequency display plotter widget
+ **********************************************************************/
+FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent)
+ : DisplayPlot(nplots, parent)
+{
+ _startFrequency = -1;
+ _stopFrequency = 1;
_numPoints = 1024;
- _dataPoints = new double[_numPoints];
_minFFTPoints = new double[_numPoints];
_maxFFTPoints = new double[_numPoints];
_xAxisPoints = new double[_numPoints];
- // Disable polygon clipping
-#if QWT_VERSION < 0x060000
- QwtPainter::setDeviceClipping(false);
-#else
- QwtPainter::setPolylineSplitting(false);
-#endif
-
-#if QWT_VERSION < 0x060000
- // We don't need the cache here
- canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
- canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
-#endif
-
- QPalette palette;
- palette.setColor(canvas()->backgroundRole(), QColor("white"));
- canvas()->setPalette(palette);
-
setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)");
setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0));
@@ -158,52 +94,67 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis);
setAxisTitle(QwtPlot::yLeft, "Power (dB)");
+ QList<QColor> default_colors;
+ default_colors << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green)
+ << QColor(Qt::black) << QColor(Qt::cyan) << QColor(Qt::magenta)
+ << QColor(Qt::yellow) << QColor(Qt::gray) << QColor(Qt::darkRed)
+ << QColor(Qt::darkGreen) << QColor(Qt::darkBlue) << QColor(Qt::darkGray);
+
// Automatically deleted when parent is deleted
- _fft_plot_curve = new QwtPlotCurve("Power Spectrum");
- _fft_plot_curve->attach(this);
- _fft_plot_curve->setPen(QPen(Qt::blue));
+ for(int i = 0; i < _nplots; i++) {
+ _dataPoints.push_back(new double[_numPoints]);
+ memset(_dataPoints[i], 0x0, _numPoints*sizeof(double));
+
+ _plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i)));
+ _plot_curve[i]->attach(this);
+
+ QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(default_colors[i]),
+ QPen(default_colors[i]), QSize(7,7));
#if QWT_VERSION < 0x060000
- _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints);
+ _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints);
+ _plot_curve[i]->setSymbol(*symbol);
#else
- _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints);
+ _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints);
+ _plot_curve[i]->setSymbol(symbol);
#endif
-
+ setLineColor(i, default_colors[i]);
+ }
+
_min_fft_plot_curve = new QwtPlotCurve("Minimum Power");
_min_fft_plot_curve->attach(this);
- _min_fft_plot_curve->setPen(QPen(Qt::magenta));
-
+ const QColor _default_min_fft_color = Qt::magenta;
+ setMinFFTColor(_default_min_fft_color);
#if QWT_VERSION < 0x060000
_min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints);
#else
_min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints);
#endif
-
_min_fft_plot_curve->setVisible(false);
-
+
_max_fft_plot_curve = new QwtPlotCurve("Maximum Power");
_max_fft_plot_curve->attach(this);
- _max_fft_plot_curve->setPen(QPen(Qt::darkYellow));
-
+ QColor _default_max_fft_color = Qt::darkYellow;
+ setMaxFFTColor(_default_max_fft_color);
#if QWT_VERSION < 0x060000
_max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints);
#else
_max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints);
#endif
-
_max_fft_plot_curve->setVisible(false);
-
+
_lower_intensity_marker= new QwtPlotMarker();
_lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- _lower_intensity_marker->setLinePen(QPen(Qt::cyan));
+ QColor _default_marker_lower_intensity_color = Qt::cyan;
+ setMarkerLowerIntensityColor(_default_marker_lower_intensity_color);
_lower_intensity_marker->attach(this);
-
+
_upper_intensity_marker = new QwtPlotMarker();
_upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
- _upper_intensity_marker->setLinePen(QPen(Qt::green, 0, Qt::DotLine));
+ QColor _default_marker_upper_intensity_color = Qt::green;
+ setMarkerUpperIntensityColor(_default_marker_upper_intensity_color);
_upper_intensity_marker->attach(this);
- memset(_dataPoints, 0x0, _numPoints*sizeof(double));
memset(_xAxisPoints, 0x0, _numPoints*sizeof(double));
for(int64_t number = 0; number < _numPoints; number++){
@@ -211,33 +162,22 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
_maxFFTPoints[number] = -280.0;
}
- // set up peak marker
- QwtSymbol symbol;
-
_markerPeakAmplitude = new QwtPlotMarker();
- _markerPeakAmplitude->setLinePen(QPen(Qt::yellow));
- symbol.setStyle(QwtSymbol::Diamond);
- symbol.setSize(8);
- symbol.setPen(QPen(Qt::yellow));
- symbol.setBrush(QBrush(Qt::yellow));
-
-#if QWT_VERSION < 0x060000
- _markerPeakAmplitude->setSymbol(symbol);
-#else
- _markerPeakAmplitude->setSymbol(&symbol);
-#endif
-
+ QColor _default_marker_peak_amplitude_color = Qt::yellow;
+ setMarkerPeakAmplitudeColor(_default_marker_peak_amplitude_color);
/// THIS CAUSES A PROBLEM!
//_markerPeakAmplitude->attach(this);
_markerNoiseFloorAmplitude = new QwtPlotMarker();
_markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine);
- _markerNoiseFloorAmplitude->setLinePen(QPen(Qt::darkRed, 0, Qt::DotLine));
+ QColor _default_marker_noise_floor_amplitude_color = Qt::darkRed;
+ setMarkerNoiseFloorAmplitudeColor(_default_marker_noise_floor_amplitude_color);
_markerNoiseFloorAmplitude->attach(this);
_markerCF= new QwtPlotMarker();
_markerCF->setLineStyle(QwtPlotMarker::VLine);
- _markerCF->setLinePen(QPen(Qt::lightGray, 0, Qt::DotLine));
+ QColor _default_marker_CF_color = Qt::lightGray;
+ setMarkerCFColor(_default_marker_CF_color);
_markerCF->attach(this);
_markerCF->hide();
@@ -248,21 +188,6 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
replot();
- // emit the position of clicks on widget
- _picker = new QwtDblClickPlotPicker(canvas());
-
-#if QWT_VERSION < 0x060000
- connect(_picker, SIGNAL(selected(const QwtDoublePoint &)),
- this, SLOT(OnPickerPointSelected(const QwtDoublePoint &)));
-#else
- connect(_picker, SIGNAL(selected(const QPointF &)),
- this, SLOT(OnPickerPointSelected6(const QPointF &)));
-#endif
-
- // Configure magnify on mouse wheel
- _magnifier = new QwtPlotMagnifier(canvas());
- _magnifier->setAxisEnabled(QwtPlot::xBottom, false);
-
_zoomer = new FreqDisplayZoomer(canvas(), 0);
#if QWT_VERSION < 0x060000
@@ -274,38 +199,33 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent)
_zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
- _panner = new QwtPlotPanner(canvas());
- _panner->setAxisEnabled(QwtPlot::yRight, false);
- _panner->setMouseButton(Qt::MidButton);
- // Avoid jumping when labels with more/less digits
- // appear/disappear when scrolling vertically
-
- const QFontMetrics fm(axisWidget(QwtPlot::yLeft)->font());
- QwtScaleDraw *sd = axisScaleDraw(QwtPlot::yLeft);
- sd->setMinimumExtent( fm.width("100.00") );
-
- const QColor c(Qt::darkRed);
- _zoomer->setRubberBandPen(c);
- _zoomer->setTrackerPen(c);
+ const QColor default_zoomer_color(Qt::darkRed);
+ setZoomerColor(default_zoomer_color);
// Do this after the zoomer has been built
_resetXAxisPoints();
+
+ // Turn off min/max hold plots in legend
+ QWidget *w;
+ QwtLegend* legendDisplay = legend();
+ w = legendDisplay->find(_min_fft_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
+ w = legendDisplay->find(_max_fft_plot_curve);
+ ((QwtLegendItem*)w)->setChecked(true);
}
FrequencyDisplayPlot::~FrequencyDisplayPlot()
{
- delete[] _dataPoints;
+ for(int i = 0; i < _nplots; i++)
+ delete [] _dataPoints[i];
delete[] _maxFFTPoints;
delete[] _minFFTPoints;
delete[] _xAxisPoints;
-
- // _fft_plot_curves deleted when parent deleted
- // _zoomer and _panner deleted when parent deleted
}
void
-FrequencyDisplayPlot::set_yaxis(double min, double max)
+FrequencyDisplayPlot::setYaxis(double min, double max)
{
// Get the new max/min values for the plot
_minYAxis = min;
@@ -314,28 +234,21 @@ FrequencyDisplayPlot::set_yaxis(double min, double max)
// Set the axis max/min to the new values
setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis);
- // Reset the base zoom level to the new axis scale set here
- _zoomer->setZoomBase();
+ // Reset the base zoom level to the new axis scale set here.
+ // But don't do it if we set the axis due to auto scaling.
+ if(!_autoscale_state)
+ _zoomer->setZoomBase();
}
void
-FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
- const double constStopFreq,
- const double constCenterFreq,
- const bool useCenterFrequencyFlag,
+FrequencyDisplayPlot::setFrequencyRange(const double centerfreq,
+ const double bandwidth,
const double units, const std::string &strunits)
{
- double startFreq = constStartFreq / units;
- double stopFreq = constStopFreq / units;
- double centerFreq = constCenterFreq / units;
+ double startFreq = (centerfreq - bandwidth/2.0f) / units;
+ double stopFreq = (centerfreq + bandwidth/2.0f) / units;
_xAxisMultiplier = units;
- _useCenterFrequencyFlag = useCenterFrequencyFlag;
-
- if(_useCenterFrequencyFlag){
- startFreq = (startFreq + centerFreq);
- stopFreq = (stopFreq + centerFreq);
- }
bool reset = false;
if((startFreq != _startFrequency) || (stopFreq != _stopFrequency))
@@ -345,7 +258,7 @@ FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
_startFrequency = startFreq;
_stopFrequency = stopFreq;
- if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){
+ if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)) {
double display_units = ceil(log10(units)/2.0);
setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units));
setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str()));
@@ -353,21 +266,21 @@ FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq,
if(reset)
_resetXAxisPoints();
- ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units);
- ((FreqDisplayZoomer*)_zoomer)->SetUnitType(strunits);
+ ((FreqDisplayZoomer*)_zoomer)->setFrequencyPrecision(display_units);
+ ((FreqDisplayZoomer*)_zoomer)->setUnitType(strunits);
}
}
}
double
-FrequencyDisplayPlot::GetStartFrequency() const
+FrequencyDisplayPlot::getStartFrequency() const
{
return _startFrequency;
}
double
-FrequencyDisplayPlot::GetStopFrequency() const
+FrequencyDisplayPlot::getStopFrequency() const
{
return _stopFrequency;
}
@@ -376,117 +289,169 @@ void
FrequencyDisplayPlot::replot()
{
_markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude);
+ _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency);
// Make sure to take into account the start frequency
- if(_useCenterFrequencyFlag){
- _markerPeakAmplitude->setXValue((_peakFrequency/1000.0) + _startFrequency);
- }
- else{
- _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency);
- }
+// if(_useCenterFrequencyFlag){
+// _markerPeakAmplitude->setXValue((_peakFrequency/1000.0) + _startFrequency);
+// }
+// else{
+// _markerPeakAmplitude->setXValue(_peakFrequency + _startFrequency);
+// }
_markerPeakAmplitude->setYValue(_peakAmplitude);
QwtPlot::replot();
}
void
-FrequencyDisplayPlot::resizeSlot( QSize *s )
-{
- resize(s->width(), s->height());
-}
-
-void
-FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints,
+FrequencyDisplayPlot::plotNewData(const std::vector<double*> dataPoints,
+ const int64_t numDataPoints,
const double noiseFloorAmplitude, const double peakFrequency,
const double peakAmplitude, const double timeInterval)
{
- // Only update plot if there is data and if the time interval has elapsed
- if((numDataPoints > 0) &&
- (gruel::high_res_timer_now() - _lastReplot > timeInterval*gruel::high_res_timer_tps())) {
-
- if(numDataPoints != _numPoints) {
- _numPoints = numDataPoints;
-
- delete[] _dataPoints;
- delete[] _minFFTPoints;
- delete[] _maxFFTPoints;
- delete[] _xAxisPoints;
- _dataPoints = new double[_numPoints];
- _xAxisPoints = new double[_numPoints];
- _minFFTPoints = new double[_numPoints];
- _maxFFTPoints = new double[_numPoints];
-
+ if(!_stop) {
+ if(numDataPoints > 0) {
+ if(numDataPoints != _numPoints) {
+ _numPoints = numDataPoints;
+
+ delete[] _minFFTPoints;
+ delete[] _maxFFTPoints;
+ delete[] _xAxisPoints;
+ _xAxisPoints = new double[_numPoints];
+ _minFFTPoints = new double[_numPoints];
+ _maxFFTPoints = new double[_numPoints];
+
+ for(int i = 0; i < _nplots; i++) {
+ delete[] _dataPoints[i];
+ _dataPoints[i] = new double[_numPoints];
+
#if QWT_VERSION < 0x060000
- _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints);
- _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints);
- _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints);
+ _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints);
#else
- _fft_plot_curve->setRawSamples(_xAxisPoints, _dataPoints, _numPoints);
- _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints);
- _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints);
+ _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints);
#endif
-
- _resetXAxisPoints();
- ClearMaxData();
- ClearMinData();
- }
-
- memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double));
- for(int64_t point = 0; point < numDataPoints; point++){
- if(dataPoints[point] < _minFFTPoints[point]){
- _minFFTPoints[point] = dataPoints[point];
+ }
+#if QWT_VERSION < 0x060000
+ _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints);
+ _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints);
+#else
+ _min_fft_plot_curve->setRawSamples(_xAxisPoints, _minFFTPoints, _numPoints);
+ _max_fft_plot_curve->setRawSamples(_xAxisPoints, _maxFFTPoints, _numPoints);
+#endif
+ _resetXAxisPoints();
+ clearMaxData();
+ clearMinData();
+ }
+
+ for(int i = 0; i < _nplots; i++) {
+ memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double));
}
- if(dataPoints[point] > _maxFFTPoints[point]){
- _maxFFTPoints[point] = dataPoints[point];
+
+ double bottom=1e20, top=-1e20;
+ for(int n = 0; n < _nplots; n++) {
+ for(int64_t point = 0; point < numDataPoints; point++) {
+ if(dataPoints[n][point] < _minFFTPoints[point]) {
+ _minFFTPoints[point] = dataPoints[n][point];
+ }
+ if(dataPoints[n][point] > _maxFFTPoints[point]) {
+ _maxFFTPoints[point] = dataPoints[n][point];
+ }
+
+ // Find overall top and bottom values in plot.
+ // Used for autoscaling y-axis.
+ if(dataPoints[n][point] < bottom) {
+ bottom = dataPoints[n][point];
+ }
+ if(dataPoints[n][point] > top) {
+ top = dataPoints[n][point];
+ }
+ }
}
+
+ if(_autoscale_state)
+ _autoScale(bottom, top);
+
+ _noiseFloorAmplitude = noiseFloorAmplitude;
+ _peakFrequency = peakFrequency;
+ _peakAmplitude = peakAmplitude;
+
+ setUpperIntensityLevel(_peakAmplitude);
+
+ replot();
}
-
- _noiseFloorAmplitude = noiseFloorAmplitude;
- _peakFrequency = peakFrequency;
- _peakAmplitude = peakAmplitude;
-
- SetUpperIntensityLevel(_peakAmplitude);
-
- replot();
-
- _lastReplot = gruel::high_res_timer_now();
}
}
void
-FrequencyDisplayPlot::ClearMaxData()
+FrequencyDisplayPlot::plotNewData(const double* dataPoints,
+ const int64_t numDataPoints,
+ const double noiseFloorAmplitude, const double peakFrequency,
+ const double peakAmplitude, const double timeInterval)
{
- for(int64_t number = 0; number < _numPoints; number++){
+ std::vector<double*> vecDataPoints;
+ vecDataPoints.push_back((double*)dataPoints);
+ plotNewData(vecDataPoints, numDataPoints, noiseFloorAmplitude,
+ peakFrequency, peakAmplitude, timeInterval);
+}
+
+void
+FrequencyDisplayPlot::clearMaxData()
+{
+ for(int64_t number = 0; number < _numPoints; number++) {
_maxFFTPoints[number] = _minYAxis;
}
}
void
-FrequencyDisplayPlot::ClearMinData()
+FrequencyDisplayPlot::clearMinData()
{
- for(int64_t number = 0; number < _numPoints; number++){
+ for(int64_t number = 0; number < _numPoints; number++) {
_minFFTPoints[number] = _maxYAxis;
}
}
void
-FrequencyDisplayPlot::SetMaxFFTVisible(const bool visibleFlag)
+FrequencyDisplayPlot::_autoScale(double bottom, double top)
+{
+ // Auto scale the y-axis with a margin of 10 dB on either side.
+ setYaxis(bottom - 10, top + 10);
+}
+
+void
+FrequencyDisplayPlot::setAutoScale(bool state)
+{
+ _autoscale_state = state;
+}
+
+void
+FrequencyDisplayPlot::setMaxFFTVisible(const bool visibleFlag)
{
+ _max_fft_visible = visibleFlag;
_max_fft_plot_curve->setVisible(visibleFlag);
}
+const bool FrequencyDisplayPlot::getMaxFFTVisible() const
+{
+ return _max_fft_visible;
+}
void
-FrequencyDisplayPlot::SetMinFFTVisible(const bool visibleFlag)
+FrequencyDisplayPlot::setMinFFTVisible(const bool visibleFlag)
{
+ _min_fft_visible = visibleFlag;
_min_fft_plot_curve->setVisible(visibleFlag);
}
+const bool FrequencyDisplayPlot::getMinFFTVisible() const
+{
+ return _min_fft_visible;
+}
void
FrequencyDisplayPlot::_resetXAxisPoints()
{
- double fft_bin_size = (_stopFrequency-_startFrequency) / static_cast<double>(_numPoints);
+ double fft_bin_size = (_stopFrequency-_startFrequency)
+ / static_cast<double>(_numPoints);
double freqValue = _startFrequency;
- for(int64_t loc = 0; loc < _numPoints; loc++){
+ for(int64_t loc = 0; loc < _numPoints; loc++) {
_xAxisPoints[loc] = freqValue;
freqValue += fft_bin_size;
}
@@ -500,29 +465,30 @@ FrequencyDisplayPlot::_resetXAxisPoints()
zbase.setRight(_stopFrequency);
_zoomer->zoom(zbase);
_zoomer->setZoomBase(zbase);
+ _zoomer->setZoomBase(true);
_zoomer->zoom(0);
}
void
-FrequencyDisplayPlot::SetLowerIntensityLevel(const double lowerIntensityLevel)
+FrequencyDisplayPlot::setLowerIntensityLevel(const double lowerIntensityLevel)
{
- _lower_intensity_marker->setYValue( lowerIntensityLevel );
+ _lower_intensity_marker->setYValue(lowerIntensityLevel);
}
void
-FrequencyDisplayPlot::SetUpperIntensityLevel(const double upperIntensityLevel)
+FrequencyDisplayPlot::setUpperIntensityLevel(const double upperIntensityLevel)
{
- _upper_intensity_marker->setYValue( upperIntensityLevel );
+ _upper_intensity_marker->setYValue(upperIntensityLevel);
}
void
-FrequencyDisplayPlot::SetTraceColour (QColor c)
+FrequencyDisplayPlot::setTraceColour(QColor c)
{
- _fft_plot_curve->setPen(QPen(c));
+ _plot_curve[0]->setPen(QPen(c));
}
void
-FrequencyDisplayPlot::SetBGColour (QColor c)
+FrequencyDisplayPlot::setBGColour(QColor c)
{
QPalette palette;
palette.setColor(canvas()->backgroundRole(), c);
@@ -530,7 +496,7 @@ FrequencyDisplayPlot::SetBGColour (QColor c)
}
void
-FrequencyDisplayPlot::ShowCFMarker (const bool show)
+FrequencyDisplayPlot::showCFMarker(const bool show)
{
if (show)
_markerCF->show();
@@ -540,21 +506,128 @@ FrequencyDisplayPlot::ShowCFMarker (const bool show)
void
-FrequencyDisplayPlot::OnPickerPointSelected(const QwtDoublePoint & p)
+FrequencyDisplayPlot::onPickerPointSelected(const QwtDoublePoint & p)
{
QPointF point = p;
- //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
+ //fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
point.setX(point.x() * _xAxisMultiplier);
emit plotPointSelected(point);
}
void
-FrequencyDisplayPlot::OnPickerPointSelected6(const QPointF & p)
+FrequencyDisplayPlot::onPickerPointSelected6(const QPointF & p)
{
QPointF point = p;
- //fprintf(stderr,"OnPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
+ //fprintf(stderr,"onPickerPointSelected %f %f %d\n", point.x(), point.y(), _xAxisMultiplier);
point.setX(point.x() * _xAxisMultiplier);
emit plotPointSelected(point);
}
+void
+FrequencyDisplayPlot::setMinFFTColor (QColor c)
+{
+ _min_fft_color = c;
+ _min_fft_plot_curve->setPen(QPen(c));
+}
+const QColor
+FrequencyDisplayPlot::getMinFFTColor() const {return _min_fft_color;}
+
+void
+FrequencyDisplayPlot::setMaxFFTColor (QColor c)
+{
+ _max_fft_color = c;
+ _max_fft_plot_curve->setPen(QPen(c));
+}
+const QColor
+FrequencyDisplayPlot::getMaxFFTColor() const {return _max_fft_color;}
+
+void
+FrequencyDisplayPlot::setMarkerLowerIntensityColor (QColor c)
+{
+ _marker_lower_intensity_color = c;
+ _lower_intensity_marker->setLinePen(QPen(c));
+}
+const QColor
+FrequencyDisplayPlot::getMarkerLowerIntensityColor () const {return _marker_lower_intensity_color;}
+void
+FrequencyDisplayPlot::setMarkerLowerIntensityVisible (bool visible)
+{
+ _marker_lower_intensity_visible = visible;
+ if (visible)
+ _lower_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ _lower_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+}
+const bool
+FrequencyDisplayPlot::getMarkerLowerIntensityVisible () const {return _marker_lower_intensity_visible;}
+
+void
+FrequencyDisplayPlot::setMarkerUpperIntensityColor (QColor c)
+{
+ _marker_upper_intensity_color = c;
+ _upper_intensity_marker->setLinePen(QPen(c, 0, Qt::DotLine));
+}
+const QColor
+FrequencyDisplayPlot::getMarkerUpperIntensityColor () const {return _marker_upper_intensity_color;}
+void
+FrequencyDisplayPlot::setMarkerUpperIntensityVisible (bool visible)
+{
+ _marker_upper_intensity_visible = visible;
+ if (visible)
+ _upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine);
+ else
+ _upper_intensity_marker->setLineStyle(QwtPlotMarker::NoLine);
+}
+const bool
+FrequencyDisplayPlot::getMarkerUpperIntensityVisible () const {return _marker_upper_intensity_visible;}
+
+void
+FrequencyDisplayPlot::setMarkerPeakAmplitudeColor (QColor c)
+{
+ _marker_peak_amplitude_color = c;
+ _markerPeakAmplitude->setLinePen(QPen(c));
+ QwtSymbol symbol;
+ symbol.setStyle(QwtSymbol::Diamond);
+ symbol.setSize(8);
+ symbol.setPen(QPen(c));
+ symbol.setBrush(QBrush(c));
+#if QWT_VERSION < 0x060000
+ _markerPeakAmplitude->setSymbol(symbol);
+#else
+ _markerPeakAmplitude->setSymbol(&symbol);
+#endif
+}
+const QColor
+FrequencyDisplayPlot::getMarkerPeakAmplitudeColor () const {return _marker_peak_amplitude_color;}
+
+void
+FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeColor (QColor c)
+{
+ _marker_noise_floor_amplitude_color = c;
+ _markerNoiseFloorAmplitude->setLinePen(QPen(c, 0, Qt::DotLine));
+}
+const QColor
+FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeColor () const {return _marker_noise_floor_amplitude_color;}
+
+void
+FrequencyDisplayPlot::setMarkerNoiseFloorAmplitudeVisible (bool visible)
+{
+ _marker_noise_floor_amplitude_visible = visible;
+ if (visible)
+ _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::HLine);
+ else
+ _markerNoiseFloorAmplitude->setLineStyle(QwtPlotMarker::NoLine);
+}
+const bool
+FrequencyDisplayPlot::getMarkerNoiseFloorAmplitudeVisible () const {return _marker_noise_floor_amplitude_visible;}
+
+void
+FrequencyDisplayPlot::setMarkerCFColor (QColor c)
+{
+ _marker_CF_color = c;
+ _markerCF->setLinePen(QPen(c, 0, Qt::DotLine));
+}
+const QColor
+FrequencyDisplayPlot::getMarkerCFColor () const {return _marker_CF_color;}
+
#endif /* FREQUENCY_DISPLAY_PLOT_C */