mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-12 07:06:17 -05:00
Add a contextual pop up menu to the wide graph
Initial button added is to set both Tx and Rx offset. Tidied up encapsulation issue in CPlotter class. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8186 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
0fa78a26c8
commit
f63f46e779
72
plotter.cpp
72
plotter.cpp
@ -10,6 +10,7 @@
|
||||
|
||||
CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
|
||||
QFrame {parent},
|
||||
m_set_freq_action {new QAction {tr ("&Set Rx && Tx Offset"), this}},
|
||||
m_bScaleOK {false},
|
||||
m_bReference {false},
|
||||
m_bReference0 {false},
|
||||
@ -42,6 +43,19 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor
|
||||
setAutoFillBackground(false);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
|
||||
// contextual pop up menu
|
||||
setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
connect (this, &QWidget::customContextMenuRequested, [this] (QPoint const& pos) {
|
||||
QMenu menu {this};
|
||||
menu.addAction (m_set_freq_action);
|
||||
auto const& connection = connect (m_set_freq_action, &QAction::triggered, [this, pos] () {
|
||||
int newFreq = FreqfromX (pos.x ()) + .5;
|
||||
emit setFreq1 (newFreq, newFreq);
|
||||
});
|
||||
menu.exec (mapToGlobal (pos));
|
||||
disconnect (connection);
|
||||
});
|
||||
}
|
||||
|
||||
CPlotter::~CPlotter() { } // Destructor
|
||||
@ -629,35 +643,45 @@ void CPlotter::setRxFreq (int x) //setRxFreq
|
||||
|
||||
int CPlotter::rxFreq() {return m_rxFreq;} //rxFreq
|
||||
|
||||
void CPlotter::mousePressEvent(QMouseEvent *event) //mousePressEvent
|
||||
void CPlotter::mouseReleaseEvent (QMouseEvent * event)
|
||||
{
|
||||
int x=event->x();
|
||||
if(x<0) x=0;
|
||||
if(x>m_Size.width()) x=m_Size.width();
|
||||
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
||||
bool shift = (event->modifiers() & Qt::ShiftModifier);
|
||||
int newFreq = int(FreqfromX(x)+0.5);
|
||||
int oldTxFreq = m_txFreq;
|
||||
int oldRxFreq = m_rxFreq;
|
||||
if (ctrl) {
|
||||
emit setFreq1 (newFreq, newFreq);
|
||||
} else if (shift) {
|
||||
emit setFreq1 (oldRxFreq, newFreq);
|
||||
} else {
|
||||
emit setFreq1(newFreq,oldTxFreq);
|
||||
}
|
||||
if (Qt::LeftButton == event->button ()) {
|
||||
int x=event->x();
|
||||
if(x<0) x=0;
|
||||
if(x>m_Size.width()) x=m_Size.width();
|
||||
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
||||
bool shift = (event->modifiers() & Qt::ShiftModifier);
|
||||
int newFreq = int(FreqfromX(x)+0.5);
|
||||
int oldTxFreq = m_txFreq;
|
||||
int oldRxFreq = m_rxFreq;
|
||||
if (ctrl) {
|
||||
emit setFreq1 (newFreq, newFreq);
|
||||
} else if (shift) {
|
||||
emit setFreq1 (oldRxFreq, newFreq);
|
||||
} else {
|
||||
emit setFreq1(newFreq,oldTxFreq);
|
||||
}
|
||||
|
||||
int n=1;
|
||||
if(ctrl) n+=100;
|
||||
emit freezeDecode1(n);
|
||||
int n=1;
|
||||
if(ctrl) n+=100;
|
||||
emit freezeDecode1(n);
|
||||
}
|
||||
else {
|
||||
event->ignore (); // let parent handle
|
||||
}
|
||||
}
|
||||
|
||||
void CPlotter::mouseDoubleClickEvent(QMouseEvent *event) //mouse2click
|
||||
void CPlotter::mouseDoubleClickEvent (QMouseEvent * event)
|
||||
{
|
||||
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
||||
int n=2;
|
||||
if(ctrl) n+=100;
|
||||
emit freezeDecode1(n);
|
||||
if (Qt::LeftButton == event->button ()) {
|
||||
bool ctrl = (event->modifiers() & Qt::ControlModifier);
|
||||
int n=2;
|
||||
if(ctrl) n+=100;
|
||||
emit freezeDecode1(n);
|
||||
}
|
||||
else {
|
||||
event->ignore (); // let parent handle
|
||||
}
|
||||
}
|
||||
|
||||
void CPlotter::setNsps(int ntrperiod, int nsps) //setNsps
|
||||
|
20
plotter.h
20
plotter.h
@ -23,9 +23,11 @@
|
||||
|
||||
extern bool g_single_decode;
|
||||
|
||||
class QAction;
|
||||
|
||||
class CPlotter : public QFrame
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CPlotter(QWidget *parent = 0);
|
||||
@ -33,7 +35,6 @@ public:
|
||||
|
||||
QSize minimumSizeHint() const;
|
||||
QSize sizeHint() const;
|
||||
bool m_bScaleOK;
|
||||
|
||||
void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall
|
||||
void SetRunningState(bool running);
|
||||
@ -84,15 +85,17 @@ public:
|
||||
void drawRed(int ia, int ib, float swide[]);
|
||||
void setVHF(bool bVHF);
|
||||
void setRedFile(QString fRed);
|
||||
|
||||
bool scaleOK () const {return m_bScaleOK;}
|
||||
signals:
|
||||
void freezeDecode1(int n);
|
||||
void setFreq1(int rxFreq, int txFreq);
|
||||
|
||||
protected:
|
||||
//re-implemented widget event handlers
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void mouseReleaseEvent (QMouseEvent * event) override;
|
||||
void mouseDoubleClickEvent (QMouseEvent * event) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -100,6 +103,9 @@ private:
|
||||
int XfromFreq(float f);
|
||||
float FreqfromX(int x);
|
||||
|
||||
QAction * m_set_freq_action;
|
||||
|
||||
bool m_bScaleOK;
|
||||
bool m_bCurrent;
|
||||
bool m_bCumulative;
|
||||
bool m_bLinearAvg;
|
||||
@ -166,10 +172,6 @@ private:
|
||||
qint32 m_tol;
|
||||
|
||||
char m_sutc[6];
|
||||
|
||||
private slots:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
extern QVector<QColor> g_ColorTbl;
|
||||
|
@ -322,7 +322,7 @@ void WideGraph::on_spec2dComboBox_currentIndexChanged(const QString &arg1)
|
||||
if(arg1=="Reference") {
|
||||
ui->widePlot->setReference(true);
|
||||
}
|
||||
if(ui->widePlot->m_bScaleOK) ui->widePlot->draw(swide,false,false);
|
||||
if(ui->widePlot->scaleOK ()) ui->widePlot->draw(swide,false,false);
|
||||
}
|
||||
|
||||
void WideGraph::on_fSplitSpinBox_valueChanged(int n) //fSplit
|
||||
@ -454,7 +454,7 @@ void WideGraph::on_zeroSlider_valueChanged(int value) //Zero
|
||||
void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
|
||||
{
|
||||
ui->widePlot->setPlot2dGain(value);
|
||||
if(ui->widePlot->m_bScaleOK) {
|
||||
if(ui->widePlot->scaleOK ()) {
|
||||
ui->widePlot->draw(swide,false,false);
|
||||
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
||||
}
|
||||
@ -463,7 +463,7 @@ void WideGraph::on_gain2dSlider_valueChanged(int value) //Gain2
|
||||
void WideGraph::on_zero2dSlider_valueChanged(int value) //Zero2
|
||||
{
|
||||
ui->widePlot->setPlot2dZero(value);
|
||||
if(ui->widePlot->m_bScaleOK) {
|
||||
if(ui->widePlot->scaleOK ()) {
|
||||
ui->widePlot->draw(swide,false,false);
|
||||
if(m_mode=="QRA64") ui->widePlot->draw(swide,false,true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user