Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ess-dmsc/daquiri
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenjc committed Mar 21, 2022
2 parents 682a93e + 019896d commit c1417e3
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 25 deletions.
6 changes: 4 additions & 2 deletions source/daqlite/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion source/daqlite/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion source/daqlite/CustomTofPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
47 changes: 33 additions & 14 deletions source/daqlite/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down
5 changes: 3 additions & 2 deletions source/daqlite/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ class MainWindow : public QMainWindow {
void updateGradientLabel();

/// \brief update GUI label text
void updateAutoScaleLabel();
void updateAutoScaleLabels();

public slots:
void handleExitButton();
void handleClearButton();
void handleLogButton();
void handleGradientButton();
void handleInvertButton();
void handleAutoScaleButton();
void handleAutoScaleXButton();
void handleAutoScaleYButton();
void handleKafkaData(uint64_t ElapsedCountNS);

private:
Expand Down
43 changes: 38 additions & 5 deletions source/daqlite/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,46 @@
</widget>
</item>
<item>
<widget class="QLabel" name="lblAutoScale">
<widget class="QLabel" name="lblAutoScaleX">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Auto scale:</string>
<string>Auto scale X:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblAutoScaleText">
<widget class="QLabel" name="lblAutoScaleXText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblAutoScaleY">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Auto scale Y:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblAutoScaleYText">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -262,9 +288,16 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonAutoScale">
<widget class="QPushButton" name="pushButtonAutoScaleX">
<property name="text">
<string>Auto scale X</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonAutoScaleY">
<property name="text">
<string>Auto scale</string>
<string>Auto scale Y</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit c1417e3

Please sign in to comment.