1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-08-16 04:32:30 -04:00

GLSpectrum: remove markers manually. Fixed UI

This commit is contained in:
f4exb 2020-07-06 03:20:08 +02:00
parent c534766ea2
commit 20e16ebe49
2 changed files with 67 additions and 15 deletions

View File

@ -191,8 +191,6 @@ void GLSpectrum::setCenterFrequency(qint64 frequency)
m_mutex.lock(); m_mutex.lock();
m_centerFrequency = frequency; m_centerFrequency = frequency;
m_changesPending = true; m_changesPending = true;
m_histogramMarkers.clear();
m_waterfallMarkers.clear();
m_mutex.unlock(); m_mutex.unlock();
update(); update();
} }
@ -202,7 +200,6 @@ void GLSpectrum::setReferenceLevel(Real referenceLevel)
m_mutex.lock(); m_mutex.lock();
m_referenceLevel = referenceLevel; m_referenceLevel = referenceLevel;
m_changesPending = true; m_changesPending = true;
m_histogramMarkers.clear();
m_mutex.unlock(); m_mutex.unlock();
update(); update();
} }
@ -212,7 +209,6 @@ void GLSpectrum::setPowerRange(Real powerRange)
m_mutex.lock(); m_mutex.lock();
m_powerRange = powerRange; m_powerRange = powerRange;
m_changesPending = true; m_changesPending = true;
m_histogramMarkers.clear();
m_mutex.unlock(); m_mutex.unlock();
update(); update();
} }
@ -240,8 +236,6 @@ void GLSpectrum::setSampleRate(qint32 sampleRate)
m_messageQueueToGUI->push(new MsgReportSampleRate(m_sampleRate)); m_messageQueueToGUI->push(new MsgReportSampleRate(m_sampleRate));
} }
m_changesPending = true; m_changesPending = true;
m_histogramMarkers.clear();
m_waterfallMarkers.clear();
m_mutex.unlock(); m_mutex.unlock();
update(); update();
} }
@ -259,8 +253,10 @@ void GLSpectrum::setDisplayWaterfall(bool display)
{ {
m_mutex.lock(); m_mutex.lock();
m_displayWaterfall = display; m_displayWaterfall = display;
if (!display) {
m_waterfallMarkers.clear();
}
m_changesPending = true; m_changesPending = true;
m_waterfallMarkers.clear();
stopDrag(); stopDrag();
m_mutex.unlock(); m_mutex.unlock();
update(); update();
@ -282,7 +278,6 @@ void GLSpectrum::setInvertedWaterfall(bool inv)
{ {
m_mutex.lock(); m_mutex.lock();
m_invertedWaterfall = inv; m_invertedWaterfall = inv;
m_waterfallMarkers.clear();
m_changesPending = true; m_changesPending = true;
stopDrag(); stopDrag();
m_mutex.unlock(); m_mutex.unlock();
@ -293,6 +288,9 @@ void GLSpectrum::setDisplayMaxHold(bool display)
{ {
m_mutex.lock(); m_mutex.lock();
m_displayMaxHold = display; m_displayMaxHold = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
m_histogramMarkers.clear();
}
m_changesPending = true; m_changesPending = true;
stopDrag(); stopDrag();
m_mutex.unlock(); m_mutex.unlock();
@ -303,6 +301,9 @@ void GLSpectrum::setDisplayCurrent(bool display)
{ {
m_mutex.lock(); m_mutex.lock();
m_displayCurrent = display; m_displayCurrent = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
m_histogramMarkers.clear();
}
m_changesPending = true; m_changesPending = true;
stopDrag(); stopDrag();
m_mutex.unlock(); m_mutex.unlock();
@ -313,6 +314,9 @@ void GLSpectrum::setDisplayHistogram(bool display)
{ {
m_mutex.lock(); m_mutex.lock();
m_displayHistogram = display; m_displayHistogram = display;
if (!m_displayMaxHold && !m_displayCurrent && !m_displayHistogram) {
m_histogramMarkers.clear();
}
m_changesPending = true; m_changesPending = true;
stopDrag(); stopDrag();
m_mutex.unlock(); m_mutex.unlock();
@ -1974,28 +1978,58 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
if (event->button() == Qt::RightButton) if (event->button() == Qt::RightButton)
{ {
QPointF pHis = ep; QPointF pHis = ep;
bool doUpdate = false;
pHis.rx() = (pHis.x() - m_histogramRect.left()*width()) / (width() - m_leftMargin - m_rightMargin); pHis.rx() = (pHis.x() - m_histogramRect.left()*width()) / (width() - m_leftMargin - m_rightMargin);
pHis.ry() = (pHis.y() - m_histogramRect.top()*height()) / (height() - waterfallShiftY); pHis.ry() = (pHis.y() - m_histogramRect.top()*height()) / (height() - waterfallShiftY);
if ((m_histogramMarkers.size() > 0) && (pHis.x() >= 0) && (pHis.x() <= 1) && (pHis.y() >= 0) && (pHis.y() <= 1)) { if (event->modifiers() & Qt::ShiftModifier)
m_histogramMarkers.pop_back(); {
if ((pHis.x() >= 0) && (pHis.x() <= 1) && (pHis.y() >= 0) && (pHis.y() <= 1))
{
m_histogramMarkers.clear();
doUpdate = true;
}
}
else
{
if ((m_histogramMarkers.size() > 0) && (pHis.x() >= 0) && (pHis.x() <= 1) && (pHis.y() >= 0) && (pHis.y() <= 1))
{
m_histogramMarkers.pop_back();
doUpdate = true;
}
} }
QPointF pWat = ep; QPointF pWat = ep;
pWat.rx() = (pWat.x() - m_waterfallRect.left()*width()) / (width() - m_leftMargin - m_rightMargin); pWat.rx() = (pWat.x() - m_waterfallRect.left()*width()) / (width() - m_leftMargin - m_rightMargin);
pWat.ry() = (pWat.y() - m_waterfallRect.top()*height()) / (height() - histogramShiftY); pWat.ry() = (pWat.y() - m_waterfallRect.top()*height()) / (height() - histogramShiftY);
if ((m_waterfallMarkers.size() > 0) && (pWat.x() >= 0) && (pWat.x() <= 1) && (pWat.y() >= 0) && (pWat.y() <= 1)) { if (event->modifiers() & Qt::ShiftModifier)
m_waterfallMarkers.pop_back(); {
if ((pWat.x() >= 0) && (pWat.x() <= 1) && (pWat.y() >= 0) && (pWat.y() <= 1))
{
m_waterfallMarkers.clear();
doUpdate = true;
}
}
else
{
if ((m_waterfallMarkers.size() > 0) && (pWat.x() >= 0) && (pWat.x() <= 1) && (pWat.y() >= 0) && (pWat.y() <= 1))
{
m_waterfallMarkers.pop_back();
doUpdate = true;
}
} }
update(); if (doUpdate) {
update();
}
} }
else if (event->button() == Qt::LeftButton) else if (event->button() == Qt::LeftButton)
{ {
if (event->modifiers() & Qt::ShiftModifier) if (event->modifiers() & Qt::ShiftModifier)
{ {
QPointF pHis = ep; QPointF pHis = ep;
bool doUpdate = false;
pHis.rx() = (pHis.x() - m_histogramRect.left()*width()) / (width() - m_leftMargin - m_rightMargin); pHis.rx() = (pHis.x() - m_histogramRect.left()*width()) / (width() - m_leftMargin - m_rightMargin);
pHis.ry() = (pHis.y() - m_histogramRect.top()*height()) / (height() - waterfallShiftY); pHis.ry() = (pHis.y() - m_histogramRect.top()*height()) / (height() - waterfallShiftY);
float frequency = (pHis.x()-0.5)*m_sampleRate + m_centerFrequency; float frequency = (pHis.x()-0.5)*m_sampleRate + m_centerFrequency;
@ -2034,6 +2068,8 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
m_linear ? 3 : 1, m_linear ? 3 : 1,
false); false);
} }
doUpdate = true;
} }
} }
@ -2076,17 +2112,20 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
3, 3,
true); true);
} }
doUpdate = true;
} }
} }
update(); if (doUpdate) {
update();
}
} }
if (m_cursorState == CSSplitter) if (m_cursorState == CSSplitter)
{ {
grabMouse(); grabMouse();
m_cursorState = CSSplitterMoving; m_cursorState = CSSplitterMoving;
m_waterfallMarkers.clear();
return; return;
} }
else if (m_cursorState == CSChannel) else if (m_cursorState == CSChannel)

View File

@ -326,6 +326,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="3"> <item row="2" column="0" colspan="3">