mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-07-01 08:25:27 -04:00
Spectrum frequency zoom: implemented panning. Implements #773
This commit is contained in:
parent
8f09cdd80e
commit
d22bdb3e5e
@ -2211,6 +2211,10 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event->modifiers() & Qt::AltModifier)
|
||||||
|
{
|
||||||
|
frequencyPan(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_cursorState == CSSplitter)
|
if (m_cursorState == CSSplitter)
|
||||||
{
|
{
|
||||||
@ -2303,6 +2307,24 @@ void GLSpectrum::frequencyZoom(QWheelEvent *event)
|
|||||||
qDebug("GLSpectrum::spectrumZoom: pw: %f p: %f z: %f", pw, m_frequencyZoomPos, m_frequencyZoomFactor);
|
qDebug("GLSpectrum::spectrumZoom: pw: %f p: %f z: %f", pw, m_frequencyZoomPos, m_frequencyZoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLSpectrum::frequencyPan(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (m_frequencyZoomFactor == 1.0f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPointF& p = event->pos();
|
||||||
|
float pw = (p.x() - m_leftMargin) / (width() - m_leftMargin - m_rightMargin); // position in window
|
||||||
|
pw = pw < 0.0f ? 0.0f : pw > 1.0f ? 1.0 : pw;
|
||||||
|
float dw = pw - 0.5f;
|
||||||
|
m_frequencyZoomPos += dw * (1.0f / m_frequencyZoomFactor);
|
||||||
|
float lim = 0.5f / m_frequencyZoomFactor;
|
||||||
|
m_frequencyZoomPos = m_frequencyZoomPos < lim ? lim : m_frequencyZoomPos > 1 - lim ? 1 - lim : m_frequencyZoomPos;
|
||||||
|
|
||||||
|
updateFFTLimits();
|
||||||
|
qDebug("GLSpectrum::frequencyPan: pw: %f p: %f", pw, m_frequencyZoomPos);
|
||||||
|
}
|
||||||
|
|
||||||
void GLSpectrum::resetFrequencyZoom()
|
void GLSpectrum::resetFrequencyZoom()
|
||||||
{
|
{
|
||||||
m_frequencyZoomFactor = 1.0f;
|
m_frequencyZoomFactor = 1.0f;
|
||||||
|
@ -350,6 +350,7 @@ private:
|
|||||||
void wheelEvent(QWheelEvent*);
|
void wheelEvent(QWheelEvent*);
|
||||||
void channelMarkerMove(QWheelEvent*, int mul);
|
void channelMarkerMove(QWheelEvent*, int mul);
|
||||||
void frequencyZoom(QWheelEvent*);
|
void frequencyZoom(QWheelEvent*);
|
||||||
|
void frequencyPan(QMouseEvent*);
|
||||||
void resetFrequencyZoom();
|
void resetFrequencyZoom();
|
||||||
void updateFFTLimits();
|
void updateFFTLimits();
|
||||||
void setFrequencyScale();
|
void setFrequencyScale();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user