diff --git a/source/daqlite/Configuration.cpp b/source/daqlite/Configuration.cpp index 18877799..5e4b08a5 100644 --- a/source/daqlite/Configuration.cpp +++ b/source/daqlite/Configuration.cpp @@ -76,7 +76,8 @@ void Configuration::getTOFConfig() { TOF.Scale = getVal("tof", "scale", TOF.Scale); TOF.MaxValue = getVal("tof", "max_value", TOF.MaxValue); TOF.BinSize = getVal("tof", "bin_size", TOF.BinSize); - TOF.AutoScale = getVal("tof", "auto_scale", TOF.AutoScale); + TOF.AutoScaleX = getVal("tof", "auto_scale_x", TOF.AutoScaleX); + TOF.AutoScaleY = getVal("tof", "auto_scale_y", TOF.AutoScaleY); } void Configuration::print() { @@ -102,7 +103,8 @@ void Configuration::print() { fmt::print(" Scale {}\n", TOF.Scale); fmt::print(" Max value {}\n", TOF.MaxValue); fmt::print(" Bin size {}\n", TOF.BinSize); - fmt::print(" Auto scale {}\n", TOF.AutoScale); + fmt::print(" Auto scale x {}\n", TOF.AutoScaleX); + fmt::print(" Auto scale y {}\n", TOF.AutoScaleY); } //\brief getVal() template is used to effectively achieve diff --git a/source/daqlite/Configuration.h b/source/daqlite/Configuration.h index 2b969c44..03daaab1 100644 --- a/source/daqlite/Configuration.h +++ b/source/daqlite/Configuration.h @@ -50,7 +50,8 @@ class Configuration { unsigned int Scale{1000}; // ns -> us unsigned int MaxValue{25000}; // us unsigned int BinSize{512}; // bins - bool AutoScale{true}; + bool AutoScaleX{true}; + bool AutoScaleY{true}; }; struct Geometry { diff --git a/source/daqlite/CustomTofPlot.cpp b/source/daqlite/CustomTofPlot.cpp index e0f23227..da6976d0 100644 --- a/source/daqlite/CustomTofPlot.cpp +++ b/source/daqlite/CustomTofPlot.cpp @@ -77,8 +77,10 @@ void CustomTofPlot::plotDetectorImage(bool Force) { } // yAxis->rescale(); - if (mConfig.TOF.AutoScale) { + if (mConfig.TOF.AutoScaleX) { xAxis->setRange(0, mConfig.TOF.MaxValue * 1.05); + } + if (mConfig.TOF.AutoScaleY){ yAxis->setRange(0, MaxY * 1.05); } replot(); diff --git a/source/daqlite/MainWindow.cpp b/source/daqlite/MainWindow.cpp index c7dab2c5..3123f7e6 100644 --- a/source/daqlite/MainWindow.cpp +++ b/source/daqlite/MainWindow.cpp @@ -46,11 +46,13 @@ MainWindow::MainWindow(Configuration &Config, QWidget *parent) SLOT(handleGradientButton())); connect(ui->pushButtonInvert, SIGNAL(clicked()), this, SLOT(handleInvertButton())); - connect(ui->pushButtonAutoScale, SIGNAL(clicked()), this, - SLOT(handleAutoScaleButton())); + connect(ui->pushButtonAutoScaleX, SIGNAL(clicked()), this, + SLOT(handleAutoScaleXButton())); + connect(ui->pushButtonAutoScaleY, SIGNAL(clicked()), this, + SLOT(handleAutoScaleYButton())); updateGradientLabel(); - updateAutoScaleLabel(); + updateAutoScaleLabels(); show(); startKafkaConsumerThread(); } @@ -126,19 +128,27 @@ void MainWindow::updateGradientLabel() { QString::fromStdString(mConfig.Plot.ColorGradient)); } -void MainWindow::updateAutoScaleLabel() { +void MainWindow::updateAutoScaleLabels() { // AutoScale button and lables are not relevant for TOF so we hide them if (not TOF) { - ui->pushButtonAutoScale->setVisible(false); - ui->lblAutoScaleText->setVisible(false); - ui->lblAutoScale->setVisible(false); + ui->pushButtonAutoScaleX->setVisible(false); + ui->lblAutoScaleXText->setVisible(false); + ui->lblAutoScaleX->setVisible(false); + ui->pushButtonAutoScaleY->setVisible(false); + ui->lblAutoScaleYText->setVisible(false); + ui->lblAutoScaleY->setVisible(false); return; } - if (mConfig.TOF.AutoScale) - ui->lblAutoScaleText->setText(QString::fromStdString("on")); + if (mConfig.TOF.AutoScaleX) + ui->lblAutoScaleXText->setText(QString::fromStdString("on")); else - ui->lblAutoScaleText->setText(QString::fromStdString("off")); + ui->lblAutoScaleXText->setText(QString::fromStdString("off")); + + if (mConfig.TOF.AutoScaleY) + ui->lblAutoScaleYText->setText(QString::fromStdString("on")); + else + ui->lblAutoScaleYText->setText(QString::fromStdString("off")); } // toggle the log scale flag @@ -155,13 +165,22 @@ void MainWindow::handleInvertButton() { updateGradientLabel(); } -// toggle the auto scale button -void MainWindow::handleAutoScaleButton() { +// toggle the auto scale x button +void MainWindow::handleAutoScaleXButton() { + if (not TOF) + return; + + mConfig.TOF.AutoScaleX = not mConfig.TOF.AutoScaleX; + updateAutoScaleLabels(); +} + +// toggle the auto scale y button +void MainWindow::handleAutoScaleYButton() { if (not TOF) return; - mConfig.TOF.AutoScale = not mConfig.TOF.AutoScale; - updateAutoScaleLabel(); + mConfig.TOF.AutoScaleY = not mConfig.TOF.AutoScaleY; + updateAutoScaleLabels(); } void MainWindow::handleGradientButton() { diff --git a/source/daqlite/MainWindow.h b/source/daqlite/MainWindow.h index 8945827b..a3257589 100644 --- a/source/daqlite/MainWindow.h +++ b/source/daqlite/MainWindow.h @@ -34,7 +34,7 @@ class MainWindow : public QMainWindow { void updateGradientLabel(); /// \brief update GUI label text - void updateAutoScaleLabel(); + void updateAutoScaleLabels(); public slots: void handleExitButton(); @@ -42,7 +42,8 @@ public slots: void handleLogButton(); void handleGradientButton(); void handleInvertButton(); - void handleAutoScaleButton(); + void handleAutoScaleXButton(); + void handleAutoScaleYButton(); void handleKafkaData(uint64_t ElapsedCountNS); private: diff --git a/source/daqlite/MainWindow.ui b/source/daqlite/MainWindow.ui index a07cda81..43dfa7c4 100644 --- a/source/daqlite/MainWindow.ui +++ b/source/daqlite/MainWindow.ui @@ -181,7 +181,7 @@ - + 0 @@ -189,12 +189,38 @@ - Auto scale: + Auto scale X: - + + + + 0 + 0 + + + + + + + + + + + + 0 + 0 + + + + Auto scale Y: + + + + + 0 @@ -262,9 +288,16 @@ - + + + Auto scale X + + + + + - Auto scale + Auto scale Y