RasterProcessTool/Toolbox/KJ135WBJYAlgInterfaceToolbox/KJ135WBJYAlgWidgetComponet.cpp

924 lines
26 KiB
C++
Raw Normal View History

2025-05-10 18:34:49 +00:00
#include "KJ135WBJYAlgWidgetComponet.h"
#include <QHBoxLayout>
2025-05-08 15:00:13 +00:00
#include <QMessageBox>
2025-05-10 18:34:49 +00:00
#include <QGroupBox>
2025-05-08 15:00:13 +00:00
AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent)
{
2025-05-10 18:34:49 +00:00
this->componentType = ComponentType::UNKNOW; // 默认未知类型
this->ParaName = QString(); // 参数名称
this->ParaChsName = QString(); // 参数中文名称
this->Description = QString(); // 参数描述
this->Datatype = QString(); // 数据类型
this->ParaType = QString(); // 参数类型
}
2025-05-08 15:00:13 +00:00
AbstractComponentWidget::~AbstractComponentWidget()
{
2025-05-10 18:34:49 +00:00
}
2025-05-08 15:00:13 +00:00
QString AbstractComponentWidget::getParaName() const
{
2025-05-08 15:00:13 +00:00
return this->ParaName;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setParaName(const QString& name)
{
2025-05-08 15:00:13 +00:00
this->ParaName = name;
}
2025-05-08 15:00:13 +00:00
QString AbstractComponentWidget::getParaChsName() const
{
2025-05-08 15:00:13 +00:00
return this->ParaChsName;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setParaChsName(const QString& name)
{
2025-05-08 15:00:13 +00:00
this->ParaChsName = name;
}
2025-05-08 15:00:13 +00:00
QString AbstractComponentWidget::getDescription() const
{
2025-05-10 18:34:49 +00:00
2025-05-08 15:00:13 +00:00
return this->Description;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setDescription(const QString& description)
{
2025-05-10 18:34:49 +00:00
this->setToolTip(description);// 绑定提示
2025-05-08 15:00:13 +00:00
this->Description = description;
}
2025-05-08 15:00:13 +00:00
QString AbstractComponentWidget::getDatatype() const
{
2025-05-08 15:00:13 +00:00
return this->Datatype;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setDatatype(const QString& datatype)
{
2025-05-08 15:00:13 +00:00
this->Datatype = datatype;
}
2025-05-08 15:00:13 +00:00
QString AbstractComponentWidget::getParaType() const
{
2025-05-08 15:00:13 +00:00
return this->ParaType;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setParaType(const QString& type)
{
2025-05-08 15:00:13 +00:00
this->ParaType = type;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setComponentType(ComponentType type)
{
2025-05-08 15:00:13 +00:00
this->componentType = type;
}
2025-05-08 15:00:13 +00:00
ComponentType AbstractComponentWidget::getComponentType() const
{
2025-05-08 15:00:13 +00:00
return this->componentType;
}
2025-05-10 18:34:49 +00:00
QString AbstractComponentWidget::getValue() const
{
return QString();
}
void AbstractComponentWidget::initUI()
{
}
// File 文件选择
2025-05-08 15:00:13 +00:00
FileSelectWidget::FileSelectWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
2025-05-08 15:00:13 +00:00
FileSelectWidget::~FileSelectWidget()
{
}
2025-05-08 15:00:13 +00:00
void FileSelectWidget::initUI()
{
2025-05-10 18:34:49 +00:00
// 初始化控件
2025-05-08 15:00:13 +00:00
// fileNameLabel
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
2025-05-08 15:00:13 +00:00
//filePathEdit
filePathEdit = new QLineEdit(this);
2025-05-10 18:34:49 +00:00
2025-05-08 15:00:13 +00:00
// fileSelectButton
fileSelectButton = new QToolButton(this);
2025-05-10 18:34:49 +00:00
fileSelectButton->setText(u8"选择文件");
2025-05-10 18:34:49 +00:00
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
filePathEdit->setMinimumHeight(40);
fileSelectButton->setMinimumHeight(40);
2025-05-10 18:34:49 +00:00
// 绑定信号-槽
QObject::connect(fileSelectButton, SIGNAL(clicked()), this, SLOT(onFileSelectButtonClicked()));
2025-05-10 18:34:49 +00:00
// 水平布局
2025-05-08 15:00:13 +00:00
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(filePathEdit);
layout->addWidget(fileSelectButton);
this->setLayout(layout);
}
QString FileSelectWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr != filePathEdit)
{
2025-05-10 19:04:56 +00:00
if (this->componentType == ComponentType::FolderSelect) {
//检测最后一个字符是否为分隔符
QString filePath = filePathEdit->text();
if (filePath.endsWith(QDir::separator())) {
return filePath;
}
else {
return QString(u8"%1%2").arg(filePath).arg(QDir::separator());
}
}
else{
return filePathEdit->text();
}
2025-05-08 15:00:13 +00:00
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(nullptr, u8"警告", u8"请先选择文件");
2025-05-08 15:00:13 +00:00
return QString();
}
}
void FileSelectWidget::onFileSelectButtonClicked()
{
if (this->componentType == ComponentType::FileSelect)
{
2025-05-10 18:34:49 +00:00
QString fileName = QFileDialog::getOpenFileName(this,
QString(u8"选择%1").arg(this->getParaChsName()),
"",
QString(u8"所有文件(*.*);;%1文件(*.%2);;").arg(this->getDatatype()).arg(this->getDatatype()));
2025-05-08 15:00:13 +00:00
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(this, u8"警告", u8"请选择文件");
2025-05-08 15:00:13 +00:00
}
}
2025-05-10 18:34:49 +00:00
else if (this->componentType == ComponentType::MulitFileSelect)
2025-05-08 15:00:13 +00:00
{
2025-05-10 18:34:49 +00:00
QStringList fileName = QFileDialog::getOpenFileNames(this,
QString(u8"选择文件夹:%1").arg(this->getParaChsName()),
"");
if (fileName.count() != 0)
2025-05-08 15:00:13 +00:00
{
2025-05-10 18:34:49 +00:00
QString filePathlist = fileName.at(0);
for (long i = 1; i < fileName.count(); i++)
{
filePathlist = QString(u8"%1;%2").arg(filePathlist).arg(fileName.at(i));
}
filePathlist = QString(u8"%1;").arg(filePathlist);
filePathEdit->setText(filePathlist);
2025-05-08 15:00:13 +00:00
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(this, u8"警告", u8"请选择文件夹");
2025-05-08 15:00:13 +00:00
}
}
2025-05-10 18:34:49 +00:00
else if (this->componentType == ComponentType::FolderSelect) {
2025-05-08 15:00:13 +00:00
QString fileName = QFileDialog::getExistingDirectory(this,
2025-05-10 18:34:49 +00:00
QString(u8"选择文件夹:%1").arg(this->getParaChsName()),
2025-05-08 15:00:13 +00:00
"");
if (!fileName.isEmpty())
{
2025-05-10 18:34:49 +00:00
fileName = QString(u8"%1%2").arg(fileName).arg(QDir::separator());
2025-05-08 15:00:13 +00:00
filePathEdit->setText(fileName);
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(this, u8"警告", u8"请选择文件夹");
2025-05-08 15:00:13 +00:00
}
2025-05-10 18:34:49 +00:00
}
else {
QMessageBox::warning(this, u8"警告", u8"参数控件格式错误");
}
}
2025-05-08 15:00:13 +00:00
2025-05-10 18:34:49 +00:00
// 整数输入组件
2025-05-08 15:00:13 +00:00
IntInputWidget::IntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
IntInputWidget::~IntInputWidget()
{
}
2025-05-08 15:00:13 +00:00
void IntInputWidget::initUI()
{
2025-05-08 15:00:13 +00:00
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
intInput = new QSpinBox(this);
2025-05-10 18:34:49 +00:00
intInput->setRange(-920240809, 920240809);
2025-05-08 15:00:13 +00:00
intInput->setSingleStep(1);
2025-05-10 18:34:49 +00:00
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
intInput->setMinimumHeight(40);
// 水平布局
2025-05-08 15:00:13 +00:00
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(intInput);
this->setLayout(layout);
}
2025-05-08 15:00:13 +00:00
QString IntInputWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr == this->intInput)
{
return QString();
}
else {
return QString::number(this->intInput->value());
}
}
2025-05-10 18:34:49 +00:00
// 浮点数输入组件
2025-05-08 15:00:13 +00:00
DoubleInputWidget::DoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
2025-05-08 15:00:13 +00:00
DoubleInputWidget::~DoubleInputWidget()
{
}
2025-05-08 15:00:13 +00:00
void DoubleInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
2025-05-10 18:34:49 +00:00
doubleInput = new QLineEdit(this);
2025-05-10 18:34:49 +00:00
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
doubleInput->setMinimumHeight(40);
// 水平布局
2025-05-08 15:00:13 +00:00
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(doubleInput);
this->setLayout(layout);
}
2025-05-08 15:00:13 +00:00
QString DoubleInputWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr != this->doubleInput)
{
2025-05-10 18:34:49 +00:00
return this->doubleInput->text();
2025-05-08 15:00:13 +00:00
}
else {
return QString();
}
}
2025-05-08 15:00:13 +00:00
2025-05-10 18:34:49 +00:00
// 整数输入组件
2025-05-08 15:00:13 +00:00
ScopeIntInputWidget::ScopeIntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
2025-05-10 18:34:49 +00:00
2025-05-08 15:00:13 +00:00
}
ScopeIntInputWidget::~ScopeIntInputWidget()
{
}
void ScopeIntInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
intInputMin = new QSpinBox(this);
intInputMin->setRange(-1000000, 1000000);
intInputMin->setSingleStep(1);
scopeConnectStr = new QLabel(this);
scopeConnectStr->setText(u8" - ");
intInputMax = new QSpinBox(this);
intInputMax->setRange(-1000000, 1000000);
intInputMax->setSingleStep(1);
2025-05-10 18:34:49 +00:00
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
intInputMin->setMinimumHeight(40);
intInputMax->setMinimumHeight(40);
// 水平布局
2025-05-08 15:00:13 +00:00
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(intInputMin);
layout->addWidget(scopeConnectStr);
layout->addWidget(intInputMax);
this->setLayout(layout);
}
2025-05-10 18:34:49 +00:00
2025-05-08 15:00:13 +00:00
QString ScopeIntInputWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr != intInputMin && nullptr != intInputMax)
{
return QString("%1;%2")
.arg(QString::number(intInputMin->value()))
.arg(QString::number(intInputMax->value()));
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
2025-05-08 15:00:13 +00:00
}
return QString();
}
2025-05-08 15:00:13 +00:00
2025-05-10 18:34:49 +00:00
// 浮点数输入组件
2025-05-08 15:00:13 +00:00
ScopeDoubleInputWidget::ScopeDoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
2025-05-08 15:00:13 +00:00
ScopeDoubleInputWidget::~ScopeDoubleInputWidget()
{
}
2025-05-08 15:00:13 +00:00
void ScopeDoubleInputWidget::initUI()
{
2025-05-08 15:00:13 +00:00
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
2025-05-10 18:34:49 +00:00
doubleInputMin = new QLineEdit(this);
2025-05-08 15:00:13 +00:00
scopeConnectStr = new QLabel(this);
scopeConnectStr->setText(u8" - ");
2025-05-10 18:34:49 +00:00
doubleInputMax = new QLineEdit(this);
2025-05-08 15:00:13 +00:00
2025-05-10 18:34:49 +00:00
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
doubleInputMin->setMinimumHeight(40);
doubleInputMax->setMinimumHeight(40);
// 水平布局
2025-05-08 15:00:13 +00:00
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(doubleInputMin);
layout->addWidget(scopeConnectStr);
layout->addWidget(doubleInputMax);
this->setLayout(layout);
}
2025-05-08 15:00:13 +00:00
QString ScopeDoubleInputWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr != doubleInputMin && nullptr != doubleInputMax)
{
return QString("%1;%2")
2025-05-10 18:34:49 +00:00
.arg(doubleInputMin->text())
.arg(doubleInputMax->text());
2025-05-08 15:00:13 +00:00
}
else {
2025-05-10 18:34:49 +00:00
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
2025-05-08 15:00:13 +00:00
}
return QString();
}
2025-05-10 18:34:49 +00:00
AbstractComponentWidget* createComponentWidgetFactory(QString ParaName, QString ParaChsName, QString Datatype, QString ParaType, QString Description, QWidget* parent)
{
qDebug() << "createComponentWidgetFactory: " << ParaName << ParaChsName << Datatype << ParaType << Description;
if (QString::compare(ParaName, u8"WorkSpace", Qt::CaseInsensitive) == 0) { // 判断是否相等
AbstractComponentWidget* workspacePathWidget = new FileSelectWidget(parent);
workspacePathWidget->setParaName(ParaName);
workspacePathWidget->setParaChsName(ParaChsName);
workspacePathWidget->setDescription(Description);
workspacePathWidget->setDatatype(Datatype);
workspacePathWidget->setComponentType(ComponentType::FolderSelect);
workspacePathWidget->initUI();
return workspacePathWidget;
}
else if(QString::compare(ParaName, u8"box", Qt::CaseInsensitive) == 0 ){ // 包围盒
AbstractComponentWidget* boxInpputWidget = new BoxDoubleInputWidget(parent);
boxInpputWidget->setParaName(ParaName);
boxInpputWidget->setParaChsName(ParaChsName);
boxInpputWidget->setDescription(Description);
boxInpputWidget->setDatatype(Datatype);
boxInpputWidget->setComponentType(ComponentType::BoxDoubleInput);
boxInpputWidget->initUI();
return boxInpputWidget;
}
else if (QString::compare(ParaName, u8"CoveringIDs", Qt::CaseInsensitive) == 0 ) { // 地表覆盖类型
AbstractComponentWidget* intInpputWidget = new MultiIntInputWidget(parent);
intInpputWidget->setParaName(ParaName);
intInpputWidget->setParaChsName(ParaChsName);
intInpputWidget->setDescription(Description);
intInpputWidget->setDatatype(Datatype);
intInpputWidget->setComponentType(ComponentType::MultiIntInput);
intInpputWidget->initUI();
return intInpputWidget;
}
else if (QString::compare(ParaName, u8"NDVIScope", Qt::CaseInsensitive) == 0) { //NDVI 范围
AbstractComponentWidget* scopeDoubleInputWidget = new ScopeDoubleInputWidget(parent);
scopeDoubleInputWidget->setParaName(ParaName);
scopeDoubleInputWidget->setParaChsName(ParaChsName);
scopeDoubleInputWidget->setDescription(Description);
scopeDoubleInputWidget->setDatatype(Datatype);
scopeDoubleInputWidget->setComponentType(ComponentType::ScopeDoubleInput);
scopeDoubleInputWidget->initUI();
return scopeDoubleInputWidget;
}
else if (QString::compare(ParaName, u8"MainImg", Qt::CaseInsensitive) == 0 ) { // 浮点数输入
AbstractComponentWidget* InputWidget = new IntInputWidget(parent);
InputWidget->setParaName(ParaName);
InputWidget->setParaChsName(ParaChsName);
InputWidget->setDescription(Description);
InputWidget->setDatatype(Datatype);
InputWidget->setComponentType(ComponentType::IntInput);
InputWidget->initUI();
return InputWidget;
}
else if (QString::compare(ParaName, u8"SARS", Qt::CaseInsensitive) == 0 ) { // 浮点数输入
AbstractComponentWidget* InputWidget = new FileSelectWidget(parent);
InputWidget->setParaName(ParaName);
InputWidget->setParaChsName(ParaChsName);
InputWidget->setDescription(Description);
InputWidget->setDatatype(Datatype);
InputWidget->setComponentType(ComponentType::MulitFileSelect);
InputWidget->initUI();
return InputWidget;
}
else if (QString::compare(ParaName, u8"CorrectMethod", Qt::CaseInsensitive) == 0 ) { // 浮点数输入
AbstractComponentWidget* scopeDoubleInputWidget = new CorrectMethodcomboxSelectWidget(parent);
scopeDoubleInputWidget->setParaName(ParaName);
scopeDoubleInputWidget->setParaChsName(ParaChsName);
scopeDoubleInputWidget->setDescription(Description);
scopeDoubleInputWidget->setDatatype(Datatype);
scopeDoubleInputWidget->setComponentType(ComponentType::IntInput);
scopeDoubleInputWidget->initUI();
return scopeDoubleInputWidget;
}
else if (QString::compare(ParaName, u8"FeatureCombination", Qt::CaseInsensitive) == 0) { // 浮点数输入
AbstractComponentWidget* InputWidget = new FeatureCombinationMultiIntInputWidget(parent);
InputWidget->setParaName(ParaName);
InputWidget->setParaChsName(ParaChsName);
InputWidget->setDescription(Description);
InputWidget->setDatatype(Datatype);
InputWidget->setComponentType(ComponentType::IntInput);
InputWidget->initUI();
return InputWidget;
}
else if (QString::compare(ParaType, u8"Value", Qt::CaseInsensitive) == 0 && QString::compare(Datatype, u8"string", Qt::CaseInsensitive) == 0) {
AbstractComponentWidget* InputWidget = new StringInputWidget(parent);
InputWidget->setParaName(ParaName);
InputWidget->setParaChsName(ParaChsName);
InputWidget->setDescription(Description);
InputWidget->setDatatype(Datatype);
InputWidget->setComponentType(ComponentType::IntInput);
InputWidget->initUI();
return InputWidget;
}
else if (QString::compare(ParaType, u8"Value", Qt::CaseInsensitive) == 0 && QString::compare(Datatype, u8"float", Qt::CaseInsensitive) == 0) { // 浮点数输入
AbstractComponentWidget* InputWidget = new DoubleInputWidget(parent);
InputWidget->setParaName(ParaName);
InputWidget->setParaChsName(ParaChsName);
InputWidget->setDescription(Description);
InputWidget->setDatatype(Datatype);
InputWidget->setComponentType(ComponentType::DoubleInput);
InputWidget->initUI();
return InputWidget;
}
else if (QString::compare(ParaType, u8"File", Qt::CaseInsensitive) == 0 && QString::compare(Datatype, u8"File", Qt::CaseInsensitive) == 0) { // 强制选择文件夹
AbstractComponentWidget* fileSelectWidget = new FileSelectWidget(parent);
fileSelectWidget->setParaName(ParaName);
fileSelectWidget->setParaChsName(ParaChsName);
fileSelectWidget->setDescription(Description);
fileSelectWidget->setDatatype(Datatype);
fileSelectWidget->setComponentType(ComponentType::FolderSelect);
fileSelectWidget->initUI();
return fileSelectWidget;
}
else if (QString::compare(ParaType, u8"File", Qt::CaseInsensitive) == 0 && QString::compare(Datatype, u8"tar.gz", Qt::CaseInsensitive) == 0) {// 选择文件
AbstractComponentWidget* fileSelectWidget = new FileSelectWidget(parent);
fileSelectWidget->setParaName(ParaName);
fileSelectWidget->setParaChsName(ParaChsName);
fileSelectWidget->setDescription(Description);
fileSelectWidget->setDatatype(Datatype);
fileSelectWidget->setComponentType(ComponentType::FileSelect);
fileSelectWidget->initUI();
return fileSelectWidget;
}
else if (QString::compare(ParaType, u8"File", Qt::CaseInsensitive) == 0) {// 选择文件
AbstractComponentWidget* fileSelectWidget = new FileSelectWidget(parent);
fileSelectWidget->setParaName(ParaName);
fileSelectWidget->setParaChsName(ParaChsName);
fileSelectWidget->setDescription(Description);
fileSelectWidget->setDatatype(Datatype);
fileSelectWidget->setComponentType(ComponentType::MulitFileSelect);
fileSelectWidget->initUI();
return fileSelectWidget;
}
return nullptr;
}
BoxDoubleInputWidget::BoxDoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
BoxDoubleInputWidget::~BoxDoubleInputWidget()
{
}
void BoxDoubleInputWidget::initUI()
{
// 修改提示
this->Description = QString(u8"%1;不填参数请填写empty作为不填写指令").arg(this->Description);
this->setToolTip(this->Description);
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
doubleInputMin = new QLineEdit(this);
doubleInputMin->setPlaceholderText(u8"请输入包围盒参数");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
doubleInputMin->setMinimumHeight(40);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(doubleInputMin);
this->setLayout(layout);
}
QString BoxDoubleInputWidget::getValue() const
{
QString valuestr = this->doubleInputMin->text();
// 非法性检查
if (valuestr.isEmpty())
{
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
return QString();
}
else if (valuestr.compare("empty", Qt::CaseSensitive) == 0)
{
return QString("empty");
}
else {
// 经纬度包围盒SNWE。例子30.0;30.2;117.3;117.5 37;38.2;108.87;109.1 , 请根据例子给出规则检查代码
QStringList list = valuestr.split(";");
if (list.size() != 4)
{
QMessageBox::warning(nullptr, u8"警告", QString(u8"包围盒参数格式错误\n%1").arg(this->Description));
return QString("empty");
}
for (int i = 0; i < list.size(); i++)
{
bool ok;
double value = list.at(i).toDouble(&ok);
if (!ok)
{
QMessageBox::warning(nullptr, u8"警告", QString(u8"包围盒参数格式错误\n%1").arg(this->Description));
return QString("empty");
}
}
return valuestr;
}
return QString("empty");
}
MultiIntInputWidget::MultiIntInputWidget(QWidget* parent)
{
}
MultiIntInputWidget::~MultiIntInputWidget()
{
}
void MultiIntInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
IntInputMin = new QLineEdit(this);
IntInputMin->setPlaceholderText(u8"请输入整数");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
IntInputMin->setMinimumHeight(40);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(IntInputMin);
this->setLayout(layout);
}
QString MultiIntInputWidget::getValue() const
{
QString valuestr = this->IntInputMin->text();
// 非法性检查
if (valuestr.isEmpty())
{
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
return QString();
}
else if (valuestr.compare("empty", Qt::CaseSensitive) == 0)
{
return QString("empty");
}
else {
QStringList list = valuestr.split(";");
for (int i = 0; i < list.size(); i++)
{
bool ok;
int value = list.at(i).toInt(&ok);
if (!ok)
{
QMessageBox::warning(nullptr, u8"警告", QString(u8"整数参数格式错误\n%1").arg(this->Description));
return QString("empty");
}
}
return valuestr;
}
return QString("empty");
}
MultiDoubleInputWidget::MultiDoubleInputWidget(QWidget* parent)
{
}
MultiDoubleInputWidget::~MultiDoubleInputWidget()
{
}
void MultiDoubleInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
doubleInputMin = new QLineEdit(this);
doubleInputMin->setPlaceholderText(u8"请输入浮点数");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
doubleInputMin->setMinimumHeight(40);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(doubleInputMin);
this->setLayout(layout);
}
QString MultiDoubleInputWidget::getValue() const
{
QString valuestr = this->doubleInputMin->text();
// 非法性检查
if (valuestr.isEmpty())
{
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
return QString();
}
else if (valuestr.compare("empty", Qt::CaseSensitive) == 0)
{
return QString("empty");
}
else {
QStringList list = valuestr.split(";");
for (int i = 0; i < list.size(); i++)
{
bool ok;
double value = list.at(i).toDouble(&ok);
if (!ok)
{
QMessageBox::warning(nullptr, u8"警告", QString(u8"浮点数参数格式错误\n%1").arg(this->Description));
return QString("empty");
}
}
return valuestr;
}
return QString("empty");
}
CorrectMethodcomboxSelectWidget::CorrectMethodcomboxSelectWidget(QWidget* parent)
{
}
CorrectMethodcomboxSelectWidget::~CorrectMethodcomboxSelectWidget()
{
}
void CorrectMethodcomboxSelectWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
comboxSelect = new QComboBox(this);
comboxSelect->addItem(u8"2:RD");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
comboxSelect->setMinimumHeight(40);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(comboxSelect);
this->setLayout(layout);
comboxSelect->setEnabled(false);
}
QString CorrectMethodcomboxSelectWidget::getValue() const
{
return u8"2";
}
FeatureCombinationMultiIntInputWidget::FeatureCombinationMultiIntInputWidget(QWidget* parent)
{
}
FeatureCombinationMultiIntInputWidget::~FeatureCombinationMultiIntInputWidget()
{
}
void FeatureCombinationMultiIntInputWidget::initUI()
{
/*
checkbox
Freemanp_s(0)p_d(1)p_v(2);
Touziα_s(3)ϕ_α(4)τ(5)λ_i(6);
Yamaguchif_s(7)f_d(8)f_v(9)f_h(10);
Cloude-PottierH(11)A(12)α(13)*/
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
// 不同控件checkbox 初始化
checkbox0 = new QCheckBox(u8"表面散射p_s(0)", this);
checkbox1 = new QCheckBox(u8"偶次散射p_d(1)", this);
checkbox2 = new QCheckBox(u8"体散射p_v(2)", this);
checkbox3 = new QCheckBox(u8"散射角α_s(3)", this);
checkbox4 = new QCheckBox(u8"散射相位ϕ_α(4)", this);
checkbox5 = new QCheckBox(u8"目标散射对称度τ(5)", this);
checkbox6 = new QCheckBox(u8"相对能量λ_i(6)", this);
checkbox7 = new QCheckBox(u8"表面散射f_s(7)", this);
checkbox8 = new QCheckBox(u8"二次散射f_d(8)", this);
checkbox9 = new QCheckBox(u8"体散射f_v(9)", this);
checkbox10 = new QCheckBox(u8"螺旋体散射f_h(10)", this);
checkbox11 = new QCheckBox(u8"分解散射熵H(11)", this);
checkbox12 = new QCheckBox(u8"反熵A(12)", this);
checkbox13 = new QCheckBox(u8"平均散射角α(13)", this);
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
checkbox0->setMinimumHeight(40);
checkbox1->setMinimumHeight(40);
checkbox2->setMinimumHeight(40);
checkbox3->setMinimumHeight(40);
checkbox4->setMinimumHeight(40);
checkbox5->setMinimumHeight(40);
checkbox6->setMinimumHeight(40);
checkbox7->setMinimumHeight(40);
checkbox8->setMinimumHeight(40);
checkbox9->setMinimumHeight(40);
checkbox10->setMinimumHeight(40);
checkbox11->setMinimumHeight(40);
checkbox12->setMinimumHeight(40);
checkbox13->setMinimumHeight(40);
// 垂直布局并按照Freeman、Touzi、Yamaguchi、Cloude-Pottier的分组每一个分组使用一个QGroupBox,水平
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(fileNameLabel);
QGroupBox* FreemanGroup = new QGroupBox(u8"Freeman", this);
QHBoxLayout* FreemanLayout = new QHBoxLayout(FreemanGroup);
FreemanLayout->addWidget(checkbox0);
FreemanLayout->addWidget(checkbox1);
FreemanLayout->addWidget(checkbox2);
QGroupBox* TouziGroup = new QGroupBox(u8"Touzi", this);
QHBoxLayout* TouziLayout = new QHBoxLayout(TouziGroup);
TouziLayout->addWidget(checkbox3);
TouziLayout->addWidget(checkbox4);
TouziLayout->addWidget(checkbox5);
TouziLayout->addWidget(checkbox6);
QGroupBox* YamaguchiGroup = new QGroupBox(u8"Yamaguchi", this);
QHBoxLayout* YamaguchiLayout = new QHBoxLayout(YamaguchiGroup);
YamaguchiLayout->addWidget(checkbox7);
YamaguchiLayout->addWidget(checkbox8);
YamaguchiLayout->addWidget(checkbox9);
YamaguchiLayout->addWidget(checkbox10);
QGroupBox* CloudePottierGroup = new QGroupBox(u8"Cloude-Pottier", this);
QHBoxLayout* CloudePottierLayout = new QHBoxLayout(CloudePottierGroup);
CloudePottierLayout->addWidget(checkbox11);
CloudePottierLayout->addWidget(checkbox12);
CloudePottierLayout->addWidget(checkbox13);
layout->addWidget(FreemanGroup);
layout->addWidget(TouziGroup);
layout->addWidget(YamaguchiGroup);
layout->addWidget(CloudePottierGroup);
this->setLayout(layout);
}
QString FeatureCombinationMultiIntInputWidget::getValue() const
{
// 检查所有的checkbox是否被选中,然后给出形如0,1,2,7,8,9,10的字符串
QString valuestr = QString();
if (checkbox0->isChecked())
{
valuestr += "0,";
}
if (checkbox1->isChecked())
{
valuestr += "1,";
}
if (checkbox2->isChecked())
{
valuestr += "2,";
}
if (checkbox3->isChecked())
{
valuestr += "3,";
}
if (checkbox4->isChecked())
{
valuestr += "4,";
}
if (checkbox5->isChecked())
{
valuestr += "5,";
}
if (checkbox6->isChecked())
{
valuestr += "6,";
}
if (checkbox7->isChecked())
{
valuestr += "7,";
}
if (checkbox8->isChecked())
{
valuestr += "8,";
}
if (checkbox9->isChecked())
{
valuestr += "9,";
}
if (checkbox10->isChecked())
{
valuestr += "10,";
}
if (checkbox11->isChecked())
{
valuestr += "11,";
}
if (checkbox12->isChecked())
{
valuestr += "12,";
}
if (checkbox13->isChecked())
{
valuestr += "13,";
}
// 去掉最后一个逗号
if (valuestr.length() > 0)
{
valuestr = valuestr.left(valuestr.length() - 1);
}
else {
QMessageBox::warning(nullptr, u8"警告", u8"请至少选择一个参数");
return QString();
}
return valuestr;
}
StringInputWidget::StringInputWidget(QWidget* parent)
{
}
StringInputWidget::~StringInputWidget()
{
}
void StringInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
IntInputMin = new QLineEdit(this);
IntInputMin->setPlaceholderText(u8"请输入");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(40);
IntInputMin->setMinimumHeight(40);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(IntInputMin);
this->setLayout(layout);
}
QString StringInputWidget::getValue() const
{
return IntInputMin->text();
}