mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-26 02:20:26 -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(); | ||||
|             } | ||||
|         } | ||||
| 		else if (event->modifiers() & Qt::AltModifier) | ||||
| 		{ | ||||
| 			frequencyPan(event); | ||||
| 		} | ||||
| 
 | ||||
|         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); | ||||
| } | ||||
| 
 | ||||
| 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() | ||||
| { | ||||
| 	m_frequencyZoomFactor = 1.0f; | ||||
|  | ||||
| @ -350,6 +350,7 @@ private: | ||||
|     void wheelEvent(QWheelEvent*); | ||||
|     void channelMarkerMove(QWheelEvent*, int mul); | ||||
|     void frequencyZoom(QWheelEvent*); | ||||
|     void frequencyPan(QMouseEvent*); | ||||
|     void resetFrequencyZoom(); | ||||
|     void updateFFTLimits(); | ||||
|     void setFrequencyScale(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user