From 0b007c4b37c8fc8dbf723086f6d5f3cddfb19e66 Mon Sep 17 00:00:00 2001 From: Chris Esposito Date: Sun, 30 Jun 2019 13:02:55 +1000 Subject: [PATCH] XY Mode fixed --- Desktop_Interface/isodriver.cpp | 30 ++++++++++++++++--- Desktop_Interface/isodriver.h | 1 + Desktop_Interface/mainwindow.cpp | 27 ++++++++++++++++- Desktop_Interface/mainwindow.h | 2 ++ .../ui_elements/cursorenabler.cpp | 14 +++++---- Desktop_Interface/ui_elements/cursorenabler.h | 3 +- 6 files changed, 65 insertions(+), 12 deletions(-) diff --git a/Desktop_Interface/isodriver.cpp b/Desktop_Interface/isodriver.cpp index 05ee63c9..3f2b46bb 100644 --- a/Desktop_Interface/isodriver.cpp +++ b/Desktop_Interface/isodriver.cpp @@ -733,7 +733,8 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) udateCursors(); if(XYmode){ - axes->graph(0)->setData(CH1,CH2); + QCPCurve* curve = reinterpret_cast(axes->plottable(0)); + curve->setData(CH1, CH2); axes->xAxis->setRange(xmin, xmax); axes->yAxis->setRange(ymin, ymax); }else{ @@ -1090,14 +1091,35 @@ void isoDriver::setSerialDecodeEnabled_CH2(bool enabled){ } void isoDriver::setXYmode(bool enabled){ - XYmode = enabled; - if(!enabled){ + int graphCount = axes->graphCount(); + static QVector graphState; + graphState.resize(graphCount); + + if(enabled) // Hide graphs - we only want the X-Y plot to appear + { xmin = 20; xmax = -20; ymin = 20; ymax = -20; + + for (int i=0; i < graphCount; i++) + { + qDebug() << "isVisible" << axes->graph(i)->visible(); + graphState[i] = axes->graph(i)->visible(); + axes->graph(i)->setVisible(false); + } } - axes->graph(1)->setVisible(!enabled); + else // Restore State + { + for (int i=0; i < graphCount; i++) + { + qDebug() << "graphState" << graphState[i]; + axes->graph(i)->setVisible(graphState[i]); + } + } + + emit enableCursorGroup(!enabled); + XYmode = enabled; } void isoDriver::triggerGroupStateChange(bool enabled){ diff --git a/Desktop_Interface/isodriver.h b/Desktop_Interface/isodriver.h index c62159dc..cabb288e 100644 --- a/Desktop_Interface/isodriver.h +++ b/Desktop_Interface/isodriver.h @@ -216,6 +216,7 @@ signals: void botRangeUpdated(double); void timeWindowUpdated(double); void delayUpdated(double); + void enableCursorGroup(bool); public slots: void setVoltageRange(QWheelEvent *event); void timerTick(void); diff --git a/Desktop_Interface/mainwindow.cpp b/Desktop_Interface/mainwindow.cpp index f9eec6de..b5a3d328 100644 --- a/Desktop_Interface/mainwindow.cpp +++ b/Desktop_Interface/mainwindow.cpp @@ -236,6 +236,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->offsetSpinBox_CH2, SIGNAL(valueChanged(double)), ui->controller_iso, SLOT(offsetChanged_CH2(double))); connect(ui->attenuationComboBox_CH1, SIGNAL(currentIndexChanged(int)), ui->controller_iso, SLOT(attenuationChanged_CH1(int))); connect(ui->attenuationComboBox_CH2, SIGNAL(currentIndexChanged(int)), ui->controller_iso, SLOT(attenuationChanged_CH2(int))); + connect(ui->controller_iso, &isoDriver::enableCursorGroup, this, &MainWindow::cursorGroupEnabled); } MainWindow::~MainWindow() @@ -245,6 +246,9 @@ MainWindow::~MainWindow() void MainWindow::initialisePlot() { + QCPCurve *xyCurve = new QCPCurve(ui->scopeAxes->xAxis, ui->scopeAxes->yAxis); + xyCurve->setPen(QPen(Qt::yellow, 1)); + ui->scopeAxes->addPlottable(xyCurve); ui->scopeAxes->addGraph(); ui->scopeAxes->addGraph(); ui->scopeAxes->addGraph(); @@ -308,7 +312,6 @@ void MainWindow::initialisePlot() ui->scopeAxes->setBackground(Qt::black); - ui->scopeAxes->replot(); } @@ -2377,3 +2380,25 @@ void MainWindow::on_actionPinout_triggered() { QDesktopServices::openUrl(QUrl(kPinoutUrl, QUrl::TolerantMode)); } + +void MainWindow::cursorGroupEnabled(bool enabled) +{ + static bool cursorStatsEnabledState; + static bool makeCursorsNicerState; + + if (enabled) + { + ui->controller_iso->cursorStatsEnabled = cursorStatsEnabledState; + ui->makeCursorsNicer->setTurnedOn(makeCursorsNicerState); + ui->cursorGroup->setEnabled(true); + } + else + { + cursorStatsEnabledState = ui->controller_iso->cursorStatsEnabled; + makeCursorsNicerState = ui->makeCursorsNicer->turnedOn(); + ui->controller_iso->cursorStatsEnabled = false; + ui->makeCursorsNicer->setTurnedOn(false); + ui->cursorGroup->setEnabled(false); + } + +} diff --git a/Desktop_Interface/mainwindow.h b/Desktop_Interface/mainwindow.h index 1dad9a98..c4d51bdc 100644 --- a/Desktop_Interface/mainwindow.h +++ b/Desktop_Interface/mainwindow.h @@ -213,6 +213,8 @@ private slots: void on_actionPinout_triggered(); + void cursorGroupEnabled(bool enabled); + private: //Generic Vars Ui::MainWindow *ui; diff --git a/Desktop_Interface/ui_elements/cursorenabler.cpp b/Desktop_Interface/ui_elements/cursorenabler.cpp index e2a2fa48..77a5391b 100644 --- a/Desktop_Interface/ui_elements/cursorenabler.cpp +++ b/Desktop_Interface/ui_elements/cursorenabler.cpp @@ -5,23 +5,25 @@ cursorEnabler::cursorEnabler(QWidget *parent) : QLabel(parent) { this->setVisible(0); #ifdef PLATFORM_ANDROID - this->turnedOn = false; + this->m_turnedOn = false; #endif } void cursorEnabler::setTurnedOn(bool enabled){ - turnedOn = enabled; + m_turnedOn = enabled; #ifdef PLATFORM_ANDROID - this->turnedOn = false; + this->m_turnedOn = false; #endif } void cursorEnabler::clickDetected(QMouseEvent* event){ - if(turnedOn){ - if (event->button() == Qt::LeftButton){ + if(m_turnedOn){ + if (event->button() == Qt::LeftButton) + { tickHori(1); } - if (event->button() == Qt::RightButton){ + else if (event->button() == Qt::RightButton) + { tickVert(1); } } diff --git a/Desktop_Interface/ui_elements/cursorenabler.h b/Desktop_Interface/ui_elements/cursorenabler.h index a7f6deac..6674deb0 100644 --- a/Desktop_Interface/ui_elements/cursorenabler.h +++ b/Desktop_Interface/ui_elements/cursorenabler.h @@ -12,8 +12,9 @@ class cursorEnabler : public QLabel Q_OBJECT public: explicit cursorEnabler(QWidget *parent = 0); + bool turnedOn() {return m_turnedOn;} private: - bool turnedOn = true; + bool m_turnedOn = true; signals: void tickHori(bool); void tickVert(bool);