diff options
Diffstat (limited to 'gr-qtgui/lib/FrequencyDisplayPlot.cc')
-rw-r--r-- | gr-qtgui/lib/FrequencyDisplayPlot.cc | 255 |
1 files changed, 178 insertions, 77 deletions
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.cc b/gr-qtgui/lib/FrequencyDisplayPlot.cc index f090039f96..0fdba579c8 100644 --- a/gr-qtgui/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/lib/FrequencyDisplayPlot.cc @@ -96,8 +96,8 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent) setAxisScale(QwtPlot::yLeft, _minYAxis, _maxYAxis); setAxisTitle(QwtPlot::yLeft, "Power (dB)"); - QList<QColor> colors; - colors << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green) + 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); @@ -109,51 +109,46 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent) _plot_curve.push_back(new QwtPlotCurve(QString("Data %1").arg(i))); _plot_curve[i]->attach(this); - _plot_curve[i]->setPen(QPen(colors[i])); - - const QwtSymbol *symbol = new QwtSymbol(QwtSymbol::NoSymbol, QBrush(colors[i]), QPen(colors[i]), QSize(7,7)); - #if QWT_VERSION < 0x060000 _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _numPoints); - _plot_curve[i]->setSymbol(*symbol); #else _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _numPoints); - _plot_curve[i]->setSymbol(symbol); #endif + setColor(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(_xAxisPoints, 0x0, _numPoints*sizeof(double)); @@ -163,33 +158,22 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, 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(); @@ -212,9 +196,8 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(int nplots, QWidget* parent) Qt::RightButton); - 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(); @@ -232,7 +215,6 @@ FrequencyDisplayPlot::~FrequencyDisplayPlot() { for(int i = 0; i < _nplots; i++) delete [] _dataPoints[i]; - delete[] _maxFFTPoints; delete[] _minFFTPoints; delete[] _xAxisPoints; @@ -332,54 +314,56 @@ FrequencyDisplayPlot::PlotNewData(const std::vector<double*> dataPoints, 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]; - + _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 - _plot_curve[i]->setRawData(_xAxisPoints, _dataPoints[i], _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 - _plot_curve[i]->setRawSamples(_xAxisPoints, _dataPoints[i], _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(); + } +#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)); + memcpy(_dataPoints[i], dataPoints[i], numDataPoints*sizeof(double)); } - + for(int64_t point = 0; point < numDataPoints; point++){ - if(dataPoints[0][point] < _minFFTPoints[point]) { - _minFFTPoints[point] = dataPoints[0][point]; - } - if(dataPoints[0][point] > _maxFFTPoints[point]) { - _maxFFTPoints[point] = dataPoints[0][point]; - } + if(dataPoints[0][point] < _minFFTPoints[point]) { + _minFFTPoints[point] = dataPoints[0][point]; + } + if(dataPoints[0][point] > _maxFFTPoints[point]) { + _maxFFTPoints[point] = dataPoints[0][point]; + } } - + _noiseFloorAmplitude = noiseFloorAmplitude; _peakFrequency = peakFrequency; _peakAmplitude = peakAmplitude; - + SetUpperIntensityLevel(_peakAmplitude); - + replot(); } } @@ -416,14 +400,24 @@ FrequencyDisplayPlot::ClearMinData() 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) { + _min_fft_visible = visibleFlag; _min_fft_plot_curve->setVisible(visibleFlag); } +const bool FrequencyDisplayPlot::GetMinFFTVisible() const +{ + return _min_fft_visible; +} void FrequencyDisplayPlot::_resetXAxisPoints() @@ -502,4 +496,111 @@ FrequencyDisplayPlot::OnPickerPointSelected6(const QPointF & p) 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 */ |