1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

communicate from spectrum GUI to markers dialog and fixed some warning issues

This commit is contained in:
f4exb 2022-10-01 20:58:21 +02:00
parent 7e35eeb69c
commit 3011e066a1
5 changed files with 93 additions and 6 deletions

View File

@ -24,6 +24,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QDesktopWidget>
#include <QScreen>
#include "gui/glspectrumgui.h"
#include "dsp/fftwindow.h"
@ -477,8 +478,8 @@ void GLSpectrumGUI::on_markers_clicked(bool checked)
connect(m_markersDialog, SIGNAL(finished(int)), this, SLOT(closeMarkersDialog()));
QPoint globalCursorPos = QCursor::pos();
int mouseScreen = qApp->desktop()->screenNumber(globalCursorPos);
QRect mouseScreenGeometry = qApp->desktop()->screen(mouseScreen)->geometry();
QScreen *screen = QGuiApplication::screenAt(globalCursorPos);
QRect mouseScreenGeometry = screen->geometry();
QPoint localCursorPos = globalCursorPos - mouseScreenGeometry.topLeft();
m_markersDialog->move(localCursorPos);
@ -929,6 +930,20 @@ bool GLSpectrumGUI::handleMessage(const Message& message)
ui->refLevel->blockSignals(false);
return true;
}
else if (GLSpectrumView::MsgReportHistogramMarkersChange::match(message))
{
if (m_markersDialog) {
m_markersDialog->updateHistogramMarkersDisplay();
}
return true;
}
else if (GLSpectrumView::MsgReportWaterfallMarkersChange::match(message))
{
if (m_markersDialog) {
m_markersDialog->updateWaterfallMarkersDisplay();
}
return true;
}
else if (SpectrumVis::MsgStartStop::match(message))
{
const SpectrumVis::MsgStartStop& msg = (SpectrumVis::MsgStartStop&) message;
@ -1035,6 +1050,8 @@ void GLSpectrumGUI::updateCalibrationPoints()
void GLSpectrumGUI::on_measure_clicked(bool checked)
{
(void) checked;
SpectrumMeasurementsDialog measurementsDialog(
m_glSpectrum,
&m_settings,

View File

@ -39,6 +39,8 @@ MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportWaterfallShare, Message)
MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportFFTOverlap, Message)
MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportPowerScale, Message)
MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportCalibrationShift, Message)
MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportHistogramMarkersChange, Message)
MESSAGE_CLASS_DEFINITION(GLSpectrumView::MsgReportWaterfallMarkersChange, Message)
const float GLSpectrumView::m_maxFrequencyZoom = 10.0f;
const float GLSpectrumView::m_annotationMarkerHeight = 20.0f;
@ -340,8 +342,12 @@ void GLSpectrumView::setDisplayWaterfall(bool display)
{
m_mutex.lock();
m_displayWaterfall = display;
if (!display) {
if (!display)
{
m_waterfallMarkers.clear();
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportWaterfallMarkersChange());
}
}
m_changesPending = true;
stopDrag();
@ -406,8 +412,12 @@ void GLSpectrumView::setDisplayMaxHold(bool display)
{
m_mutex.lock();
m_displayMaxHold = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram)
{
m_histogramMarkers.clear();
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
}
m_changesPending = true;
stopDrag();
@ -419,8 +429,12 @@ void GLSpectrumView::setDisplayCurrent(bool display)
{
m_mutex.lock();
m_displayCurrent = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram)
{
m_histogramMarkers.clear();
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
}
m_changesPending = true;
stopDrag();
@ -432,8 +446,12 @@ void GLSpectrumView::setDisplayHistogram(bool display)
{
m_mutex.lock();
m_displayHistogram = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram)
{
m_histogramMarkers.clear();
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
}
m_changesPending = true;
stopDrag();
@ -3663,6 +3681,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
{
m_histogramMarkers.clear();
doUpdate = true;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
}
}
else
@ -3671,6 +3692,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
{
m_histogramMarkers.pop_back();
doUpdate = true;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
}
}
@ -3684,6 +3708,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
{
m_waterfallMarkers.clear();
doUpdate = true;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportWaterfallMarkersChange());
}
}
}
else
@ -3692,6 +3719,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
{
m_waterfallMarkers.pop_back();
doUpdate = true;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportWaterfallMarkersChange());
}
}
}
@ -3748,6 +3778,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
m_linear ? 3 : 1);
}
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportHistogramMarkersChange());
}
doUpdate = true;
}
}
@ -3792,6 +3825,9 @@ void GLSpectrumView::mousePressEvent(QMouseEvent* event)
true);
}
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(new MsgReportWaterfallMarkersChange());
}
doUpdate = true;
}
}

View File

@ -131,6 +131,24 @@ public:
Real m_calibrationShiftdB;
};
class MsgReportHistogramMarkersChange : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportHistogramMarkersChange() :
Message()
{}
};
class MsgReportWaterfallMarkersChange : public Message {
MESSAGE_CLASS_DECLARATION
public:
MsgReportWaterfallMarkersChange() :
Message()
{}
};
GLSpectrumView(QWidget* parent = nullptr);
virtual ~GLSpectrumView();

View File

@ -825,3 +825,17 @@ void SpectrumMarkersDialog::on_showSelect_currentIndexChanged(int index)
m_markersDisplay = (SpectrumSettings::MarkersDisplay) index;
emit updateMarkersDisplay();
}
void SpectrumMarkersDialog::updateHistogramMarkersDisplay()
{
m_histogramMarkerIndex = std::max(m_histogramMarkerIndex, m_histogramMarkers.size() - 1);
ui->marker->setMaximum(m_histogramMarkers.size() - 1);
displayHistogramMarker();
}
void SpectrumMarkersDialog::updateWaterfallMarkersDisplay()
{
m_waterfallMarkerIndex = std::max(m_waterfallMarkerIndex, m_waterfallMarkers.size() - 1);
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
displayWaterfallMarker();
}

View File

@ -46,6 +46,8 @@ public:
void setCenterFrequency(qint64 centerFrequency) { m_centerFrequency = centerFrequency; }
void setPower(float power) { m_power = power; }
void setTime(float time) { m_time = time; }
void updateHistogramMarkersDisplay(); //!< called from spectrum view
void updateWaterfallMarkersDisplay(); //!< called from spectrum view
private:
Ui::SpectrumMarkersDialog* ui;