Files
GUI/src/forms/settings/SystemCorrectionForm.cpp

100 lines
5.2 KiB
C++
Raw Normal View History

2024-04-25 14:37:38 +08:00
#include "SystemCorrectionForm.h"
#include "db/SQLHelper.h"
#include "event/EventCenter.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QDate>
#include <QSpacerItem>
#include <QPushButton>
SystemCorrectionForm::SystemCorrectionForm(QWidget* aParent)
: QWidget(aParent)
{
setObjectName("SystemCorrectionForm");
init();
}
SystemCorrectionForm::~SystemCorrectionForm()
{
}
void SystemCorrectionForm::init()
{
QVBoxLayout* vboxLayout = new QVBoxLayout(this);
QLabel* title = new QLabel(this);
title->setObjectName("SystemCorrectionTitle");
title->setAlignment(Qt::AlignLeft);
title->setText(tr("Scan Preparation"));
vboxLayout->addWidget(title);
QLabel* endline = new QLabel(this);
endline->setObjectName("endline");
endline->setFixedHeight(3);
vboxLayout->addWidget(endline);
QLabel* emptyScanTitle = new QLabel(this);
emptyScanTitle->setObjectName("EmptyScanTitle");
emptyScanTitle->setText(tr("Empty Scan"));
emptyScanTitle->setAlignment(Qt::AlignCenter);
vboxLayout->addWidget(emptyScanTitle);
QLabel* emptyScanDescribe = new QLabel(this);
emptyScanDescribe->setWordWrap(true);
emptyScanDescribe->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
emptyScanDescribe->setText(tr("Empty water scanning involves collecting ultrasound data while the tank is filled with water and free of any objects. It is essential to ensure that the tank is fully filled with water and devoid of any objects before conducting the scan. The purpose of collecting empty water data is to obtain baseline information on the time and energy variations of ultrasound propagation inside the inspection tank. This information is utilized for reconstructing reference data for transmission ultrasound imaging. Additionally, empty water data can be utilized for system status assessment and spatial calibration of the system. Therefore, empty water scanning should be performed regularly, with a frequency of once every month."));
vboxLayout->addWidget(emptyScanDescribe);
endline = new QLabel(this);
endline->setObjectName("endline");
endline->setFixedHeight(3);
vboxLayout->addWidget(endline);
QLabel* currentEmptyScanDate = new QLabel(this);
QDate lastScanDate = SQLHelper::queryValue("SELECT ScanDateTime FROM EScan ORDER BY ScanDateTime DESC LIMIT 1").toDate();
currentEmptyScanDate->setText(tr("Current date for Empty Scanning %1-%2-%3").arg(lastScanDate.year()).arg(lastScanDate.month()).arg(lastScanDate.day()));
vboxLayout->addWidget(currentEmptyScanDate);
QLabel* expirationEmptyScanDate = new QLabel(this);
QDate expirationScanDate = lastScanDate.addMonths(1);
QDate currentDate = QDate::currentDate();
QString dateText = tr("%1-%2-%3").arg(expirationScanDate.year()).arg(expirationScanDate.month()).arg(expirationScanDate.day());;
QString dateFormat = currentDate.daysTo(expirationScanDate) < 3 ? QString("<font color='red'>&nbsp;&nbsp;&nbsp;%1</font>").arg(dateText) : QString(" %1").arg(dateText);
expirationEmptyScanDate->setText(tr("Expiration date for Empty Scanning %1").arg(dateFormat));
vboxLayout->addWidget(expirationEmptyScanDate);
QWidget* emptyScanButtonArea = new QWidget(this);
QHBoxLayout* emptyScanButtonLayout = new QHBoxLayout(emptyScanButtonArea);
QPushButton* emptyScanButton = new QPushButton(this);
emptyScanButton->setText(tr("Excute empty scan"));
emptyScanButton->setFixedWidth(250);
emptyScanButtonLayout->addWidget(emptyScanButton);
emptyScanButtonLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
vboxLayout->addWidget(emptyScanButtonArea);
endline = new QLabel(this);
endline->setObjectName("endline");
endline->setFixedHeight(3);
vboxLayout->addWidget(endline);
vboxLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding));
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]()
{
title->setText(tr("Scan Preparation"));
emptyScanTitle->setText(tr("Empty Scan"));
emptyScanDescribe->setText(tr("Empty water scanning involves collecting ultrasound data while the tank is filled with water and free of any objects. It is essential to ensure that the tank is fully filled with water and devoid of any objects before conducting the scan. The purpose of collecting empty water data is to obtain baseline information on the time and energy variations of ultrasound propagation inside the inspection tank. This information is utilized for reconstructing reference data for transmission ultrasound imaging. Additionally, empty water data can be utilized for system status assessment and spatial calibration of the system. Therefore, empty water scanning should be performed regularly, with a frequency of once every month."));
currentEmptyScanDate->setText(tr("Current date for Empty Scanning %1-%2-%3").arg(lastScanDate.year()).arg(lastScanDate.month()).arg(lastScanDate.day()));
expirationEmptyScanDate->setText(tr("Expiration date for Empty Scanning %1").arg(dateFormat));
});
connect(emptyScanButton, &QPushButton::clicked, []()
{
QString null;
EventCenter::Default()->triggerEvent(RequestEmptyScan, nullptr, (QObject*)&null);
});
}