diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 1b01033ec..53fbae5df 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #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, diff --git a/sdrgui/gui/glspectrumview.cpp b/sdrgui/gui/glspectrumview.cpp index b0946096b..ea37d0a9e 100644 --- a/sdrgui/gui/glspectrumview.cpp +++ b/sdrgui/gui/glspectrumview.cpp @@ -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; } } diff --git a/sdrgui/gui/glspectrumview.h b/sdrgui/gui/glspectrumview.h index 25a5f598b..ddc7180e7 100644 --- a/sdrgui/gui/glspectrumview.h +++ b/sdrgui/gui/glspectrumview.h @@ -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(); diff --git a/sdrgui/gui/spectrummarkersdialog.cpp b/sdrgui/gui/spectrummarkersdialog.cpp index 935621c79..28f6b9e7e 100644 --- a/sdrgui/gui/spectrummarkersdialog.cpp +++ b/sdrgui/gui/spectrummarkersdialog.cpp @@ -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(); +} diff --git a/sdrgui/gui/spectrummarkersdialog.h b/sdrgui/gui/spectrummarkersdialog.h index bfdb53da6..95e5d11ee 100644 --- a/sdrgui/gui/spectrummarkersdialog.h +++ b/sdrgui/gui/spectrummarkersdialog.h @@ -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;