mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-03-31 12:15:36 -04:00
Added optional scrollbar to be able to scroll back through waterfall.
When scrolling is enabled:
Can adjust power scale for complete waterfall, not just future spectra.
Waterfall time axis can use local time or UTC.
Waterfall not lost when resizing window.
Can now zoom when device is stopped.
Added Min averaging type.
Added button to load spectrum from .csv file.
Add button to save spectrum/waterfall to .png or jpg.
Changed show all controls button to a combobox with choices of Min/Std/All (Minimum/Standard/All).
Changed some buttons in spectrum GUI from QPushButton to QToolButton so their size matches the others.
Fix spectrum from displaying a mixture of old and new spectrums (m_currentSpectrum was a pointer to SpectrumVis buffer).
Added M1 and M2 memories to allow display of reference spectra.
Added math operations to allow spectrum to be difference of current spectrum and either memory or a moving average.
Fixed measurement counts, so they are performed once per spectrum, not on displayed spectra.
Added spectrum mask measurement, to check when a spectrum exceeds mask held in M1 or M2.
Optionally display power/frequency under cursor in status line.
Optionally display peak power/frequency in status line.
Fix incorrect nyquist sample replication, when zoom used.
Fix cursor not changing from resize to pointer when moving over spectrum measurements window.
Add spectrum colour setting.
167 lines
7.0 KiB
C++
167 lines
7.0 KiB
C++
///////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
// written by Christian Daniel //
|
|
// Copyright (C) 2014 John Greb <hexameron@spam.no> //
|
|
// Copyright (C) 2015-2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
// Copyright (C) 2015 Hoernchen <la@tfc-server.de> //
|
|
// Copyright (C) 2018 beta-tester <alpha-beta-release@gmx.net> //
|
|
// Copyright (C) 2022 Jon Beniston, M7RCE <jon@beniston.com> //
|
|
// Copyright (C) 2022 Jiří Pinkava <jiri.pinkava@rossum.ai> //
|
|
// //
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU General Public License V3 for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <QSplitter>
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
|
|
#include "gui/glspectrum.h"
|
|
#include "gui/glspectrumview.h"
|
|
#include "gui/spectrummeasurements.h"
|
|
|
|
GLSpectrum::GLSpectrum(QWidget *parent) :
|
|
QWidget(parent)
|
|
{
|
|
m_spectrumContainer = new QWidget();
|
|
QHBoxLayout *hLayout = new QHBoxLayout(m_spectrumContainer);
|
|
m_spectrum = new GLSpectrumView();
|
|
m_scrollBar = new QScrollBar(Qt::Vertical);
|
|
m_spectrum->setScrollBar(m_scrollBar);
|
|
hLayout->addWidget(m_spectrum);
|
|
hLayout->addWidget(m_scrollBar);
|
|
hLayout->setContentsMargins(0, 0, 0, 0);
|
|
hLayout->setSpacing(0);
|
|
|
|
m_measurements = new SpectrumMeasurements();
|
|
m_spectrum->setMeasurements(m_measurements);
|
|
|
|
m_splitter = new QSplitter(Qt::Vertical);
|
|
m_splitter->addWidget(m_spectrumContainer);
|
|
m_splitter->addWidget(m_measurements);
|
|
m_position = SpectrumSettings::PositionBelow;
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->addWidget(m_splitter);
|
|
setLayout(layout);
|
|
m_measurements->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
}
|
|
|
|
void GLSpectrum::setMeasurementsVisible(bool visible)
|
|
{
|
|
m_measurements->setVisible(visible);
|
|
}
|
|
|
|
void GLSpectrum::setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position)
|
|
{
|
|
switch (position)
|
|
{
|
|
case SpectrumSettings::PositionAbove:
|
|
m_splitter->setOrientation(Qt::Vertical);
|
|
m_splitter->insertWidget(0, m_measurements);
|
|
break;
|
|
case SpectrumSettings::PositionBelow:
|
|
m_splitter->setOrientation(Qt::Vertical);
|
|
m_splitter->insertWidget(0, m_spectrumContainer);
|
|
break;
|
|
case SpectrumSettings::PositionLeft:
|
|
m_splitter->setOrientation(Qt::Horizontal);
|
|
m_splitter->insertWidget(0, m_measurements);
|
|
break;
|
|
case SpectrumSettings::PositionRight:
|
|
m_splitter->setOrientation(Qt::Horizontal);
|
|
m_splitter->insertWidget(0, m_spectrumContainer);
|
|
break;
|
|
}
|
|
m_position = position;
|
|
}
|
|
|
|
void GLSpectrum::setMeasurementParams(SpectrumSettings::Measurement measurement,
|
|
int centerFrequencyOffset, int bandwidth, int chSpacing, int adjChBandwidth,
|
|
int harmonics, int peaks, bool highlight, int precision, unsigned memoryMask)
|
|
{
|
|
m_spectrum->setMeasurementParams(measurement, centerFrequencyOffset, bandwidth, chSpacing, adjChBandwidth, harmonics, peaks, highlight, precision, memoryMask);
|
|
// Resize splitter so there's just enough space for the measurements table
|
|
// But don't use more than 50%
|
|
QList<int> sizes = m_splitter->sizes();
|
|
if (parentWidget() && (sizes[0] == 0) && (sizes[1] == 0))
|
|
{
|
|
// Initial sizing when first created
|
|
QSize s = parentWidget()->size();
|
|
switch (m_position)
|
|
{
|
|
case SpectrumSettings::PositionAbove:
|
|
sizes[0] = m_measurements->sizeHint().height();
|
|
sizes[1] = s.height() - sizes[0] - m_splitter->handleWidth();
|
|
sizes[1] = std::max(sizes[1], sizes[0]);
|
|
break;
|
|
case SpectrumSettings::PositionLeft:
|
|
sizes[0] = m_measurements->sizeHint().width();
|
|
sizes[1] = s.width() - sizes[0] - m_splitter->handleWidth();
|
|
sizes[1] = std::max(sizes[1], sizes[0]);
|
|
break;
|
|
case SpectrumSettings::PositionBelow:
|
|
sizes[1] = m_measurements->sizeHint().height();
|
|
sizes[0] = s.height() - sizes[1] - m_splitter->handleWidth();
|
|
sizes[0] = std::max(sizes[0], sizes[1]);
|
|
break;
|
|
case SpectrumSettings::PositionRight:
|
|
sizes[1] = m_measurements->sizeHint().width();
|
|
sizes[0] = s.width() - sizes[1] - m_splitter->handleWidth();
|
|
sizes[0] = std::max(sizes[0], sizes[1]);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// When measurement type is changed when already visible
|
|
int diff = 0;
|
|
switch (m_position)
|
|
{
|
|
case SpectrumSettings::PositionAbove:
|
|
diff = m_measurements->sizeHint().height() - sizes[0];
|
|
sizes[0] += diff;
|
|
sizes[1] -= diff;
|
|
sizes[1] = std::max(sizes[1], sizes[0]);
|
|
break;
|
|
case SpectrumSettings::PositionLeft:
|
|
diff = m_measurements->sizeHint().width() - sizes[0];
|
|
sizes[0] += diff;
|
|
sizes[1] -= diff;
|
|
sizes[1] = std::max(sizes[1], sizes[0]);
|
|
break;
|
|
case SpectrumSettings::PositionBelow:
|
|
diff = m_measurements->sizeHint().height() - sizes[1];
|
|
sizes[1] += diff;
|
|
sizes[0] -= diff;
|
|
sizes[0] = std::max(sizes[0], sizes[1]);
|
|
break;
|
|
case SpectrumSettings::PositionRight:
|
|
diff = m_measurements->sizeHint().width() - sizes[1];
|
|
sizes[1] += diff;
|
|
sizes[0] -= diff;
|
|
sizes[0] = std::max(sizes[0], sizes[1]);
|
|
break;
|
|
}
|
|
}
|
|
m_splitter->setSizes(sizes);
|
|
//resize(size().expandedTo(minimumSizeHint()));
|
|
}
|
|
|
|
void GLSpectrum::resetMeasurements()
|
|
{
|
|
m_measurements->reset();
|
|
m_spectrum->resetMeasurements();
|
|
}
|