Display cursor frequency on Wide graph (upper and lower) as a ToolTip.

This commit is contained in:
Joe Taylor 2021-05-14 14:14:39 -04:00
parent 56e8f0ceee
commit 7a57a399e0
2 changed files with 20 additions and 0 deletions

View File

@ -16,6 +16,7 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
setAutoFillBackground(false); setAutoFillBackground(false);
setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_OpaquePaintEvent, false);
setAttribute(Qt::WA_NoSystemBackground, true); setAttribute(Qt::WA_NoSystemBackground, true);
setMouseTracking(true);
m_StartFreq = 100; m_StartFreq = 100;
m_nSpan=65; //Units: kHz m_nSpan=65; //Units: kHz
@ -763,6 +764,23 @@ void CPlotter::setLockTxRx(bool b)
} }
} }
void CPlotter::mouseMoveEvent (QMouseEvent * event)
{
int h = m_WaterfallPixmap.height();
int x=event->x();
int y=event->y();
bool lower=(y > 30+h);
float freq=FreqfromX(x);
float df=m_fSample/32768.0;
int ndf=x*df + m_ZoomStartFreq;
if(lower) {
QToolTip::showText(event->globalPos(),QString::number(ndf));
} else {
QToolTip::showText(event->globalPos(),QString::number(freq));
}
QWidget::mouseMoveEvent(event);
}
double CPlotter::rxFreq() double CPlotter::rxFreq()
{ {
return floor(datcom_.fcenter) + 0.001*m_fQSO + 0.000001*m_DF; return floor(datcom_.fcenter) + 0.001*m_fQSO + 0.000001*m_DF;

View File

@ -10,6 +10,7 @@
#include <QtGui> #include <QtGui>
#include <QFrame> #include <QFrame>
#include <QImage> #include <QImage>
#include <QToolTip>
#include <cstring> #include <cstring>
#include "commons.h" #include "commons.h"
@ -82,6 +83,7 @@ protected:
//re-implemented widget event handlers //re-implemented widget event handlers
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
void mouseMoveEvent(QMouseEvent * event) override;
private: private: