Skip to content
Snippets Groups Projects
Verified Commit df5bfe0f authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

Method to Save ROOT Files

This simply writes the histogram to a .root file.

It has still to be verified that this works within the Flatpak sandbox.
parent bc7a6f9e
No related branches found
No related tags found
No related merge requests found
Pipeline #3249 passed with stage
in 1 minute and 9 seconds
......@@ -25,10 +25,12 @@
**/
#include <QApplication>
#include <QFileDialog>
#include <QFontMetrics>
#include <QMessageBox>
#include <QVBoxLayout>
#include <TFile.h>
#include <TSystem.h>
#include "clientgui.h"
......@@ -62,11 +64,12 @@ ClientGui::ClientGui(const QString& name, const QString& token, std::unique_ptr<
//connect(_ui.cmdTargetGold, &QPushButton::clicked, std::bind(&ClientGui::setBeamholeState, this, ExperimentState::BeamHoleState::GoldFoil));
connect(_ui.cmdStartAdc, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::startAdc));
connect(_ui.cmdStopAdc, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::stopAdc));
connect(_ui.cmdSaveData, &QPushButton::clicked, this, &ClientGui::saveRootFile);
connect(_ui.cmdClearHisto, &QPushButton::clicked, this, &ClientGui::clearHistogram);
connect(_ui.cmdAdcThresholdUp, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdUp));
connect(_ui.cmdAdcThresholdDown, &QPushButton::clicked, std::bind(&ClientGui::sendSimpleActiontoServer, this, Protocol::Action::adcThresholdDown));
connect(_ui.cmdTargetGold, &QPushButton::clicked, [this] () -> void {QMessageBox::information(this, tr("Experiment Part not available"), tr("This part of the experiment is currently left out, because it has also been left out in the real experiment in the recent years.\nThis measurement only confirms the calibraton of the setup and takes a long time due to the low activity of the real-world ²⁴¹Am source."), QMessageBox::Ok);});
connect(_ui.cmdTargetGold, &QPushButton::clicked, [this]() -> void {QMessageBox::information(this, tr("Experiment Part not available"), tr("This part of the experiment is currently left out, because it has also been left out in the real experiment in the recent years.\nThis measurement only confirms the calibraton of the setup and takes a long time due to the low activity of the real-world ²⁴¹Am source."), QMessageBox::Ok);});
gStyle->SetCanvasPreferGL(true);
......@@ -268,6 +271,23 @@ void ClientGui::clearHistogram(const bool fromServer)
sendSimpleActiontoServer(Protocol::Action::clearHistogram);
}
void Fp311Online::ClientGui::saveRootFile()
{
const QString filename = QFileDialog::getSaveFileName(
this,
tr("Save Content of Histogram to ROOT File"),
QString(),
tr("ROOT files (*.root)")
);
if (filename.isEmpty())
return;
TFile savefile(filename.toUtf8().constData(), "RECREATE");
savefile.cd();
_histo->Write("ADC");
savefile.Close("R");
}
void ClientGui::showEvent(QShowEvent* event)
{
QMainWindow::showEvent(event);
......
......@@ -87,6 +87,8 @@ private:
void fillEventsIntoHistogram(const QString& adcchannels);
void clearHistogram(const bool fromServer = false);
void saveRootFile();
void showEvent(QShowEvent* event) override;
const CliLogger::ComponentLogger logError = CliLogger::createComponentLogger(QStringLiteral("ClientGui"), LogLevel::Error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment