完成参数界面渲染

Release-dev
chenzenghui 2025-05-11 02:34:49 +08:00
parent 2fd81a6b62
commit 88421d6a25
9 changed files with 925 additions and 146 deletions

View File

@ -92,7 +92,7 @@
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
</Link> </Link>

View File

@ -1,19 +1,21 @@
#include "KJ135WBJYAlgWidgetComponet.h" #include "KJ135WBJYAlgWidgetComponet.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QMessageBox> #include <QMessageBox>
#include <QGroupBox>
AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent) AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent)
{ {
this->componentType = ComponentType::UNKNOW; // 默认未知类型 this->componentType = ComponentType::UNKNOW; // 默认未知类型
this->ParaName = QString(); // 参数名称 this->ParaName = QString(); // 参数名称
this->ParaChsName = QString(); // 参数中文名称 this->ParaChsName = QString(); // 参数中文名称
this->Description = QString(); // 参数描述 this->Description = QString(); // 参数描述
this->Datatype = QString(); // 数据类型 this->Datatype = QString(); // 数据类型
this->ParaType = QString(); // 参数类型 this->ParaType = QString(); // 参数类型
} }
AbstractComponentWidget::~AbstractComponentWidget() AbstractComponentWidget::~AbstractComponentWidget()
{ {
} }
QString AbstractComponentWidget::getParaName() const QString AbstractComponentWidget::getParaName() const
@ -38,13 +40,13 @@ void AbstractComponentWidget::setParaChsName(const QString& name)
QString AbstractComponentWidget::getDescription() const QString AbstractComponentWidget::getDescription() const
{ {
return this->Description; return this->Description;
} }
void AbstractComponentWidget::setDescription(const QString& description) void AbstractComponentWidget::setDescription(const QString& description)
{ {
this->setToolTip(description);// 绑定提示 this->setToolTip(description);// 绑定提示
this->Description = description; this->Description = description;
} }
@ -78,7 +80,16 @@ ComponentType AbstractComponentWidget::getComponentType() const
return this->componentType; return this->componentType;
} }
// File 文件选择 QString AbstractComponentWidget::getValue() const
{
return QString();
}
void AbstractComponentWidget::initUI()
{
}
// File 文件选择
FileSelectWidget::FileSelectWidget(QWidget* parent) :AbstractComponentWidget(parent) FileSelectWidget::FileSelectWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
@ -90,29 +101,29 @@ FileSelectWidget::~FileSelectWidget()
void FileSelectWidget::initUI() void FileSelectWidget::initUI()
{ {
// 初始化控件 // 初始化控件
// fileNameLabel // fileNameLabel
fileNameLabel = new QLabel(this); fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName()); fileNameLabel->setText(this->getParaName());
//filePathEdit //filePathEdit
filePathEdit = new QLineEdit(this); filePathEdit = new QLineEdit(this);
// fileSelectButton // fileSelectButton
fileSelectButton = new QToolButton(this); fileSelectButton = new QToolButton(this);
fileSelectButton->setText(u8"选择文件"); fileSelectButton->setText(u8"选择文件");
// 设置文件最小控件高度 // 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30); fileNameLabel->setMinimumHeight(40);
filePathEdit->setMinimumHeight(30); filePathEdit->setMinimumHeight(40);
fileSelectButton->setMinimumHeight(30); fileSelectButton->setMinimumHeight(40);
// 绑定信号-槽 // 绑定信号-槽
QObject::connect(fileSelectButton, SIGNAL(clicked()) , this, SLOT(onFileSelectButtonClicked())); QObject::connect(fileSelectButton, SIGNAL(clicked()), this, SLOT(onFileSelectButtonClicked()));
// 水平布局 // 水平布局
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel); layout->addWidget(fileNameLabel);
layout->addWidget(filePathEdit); layout->addWidget(filePathEdit);
@ -129,7 +140,7 @@ QString FileSelectWidget::getValue() const
return filePathEdit->text(); return filePathEdit->text();
} }
else { else {
QMessageBox::warning(nullptr, u8"警告", u8"请先选择文件"); QMessageBox::warning(nullptr, u8"警告", u8"请先选择文件");
return QString(); return QString();
} }
} }
@ -138,46 +149,58 @@ void FileSelectWidget::onFileSelectButtonClicked()
{ {
if (this->componentType == ComponentType::FileSelect) if (this->componentType == ComponentType::FileSelect)
{ {
QString fileName = QFileDialog::getOpenFileName(this, u8"选择文件", "", u8"所有文件(*.*);;文本文件(*.txt);;图像文件(*.png *.jpg *.bmp)"); QString fileName = QFileDialog::getOpenFileName(this,
if (!fileName.isEmpty()) QString(u8"选择%1").arg(this->getParaChsName()),
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"警告", u8"请选择文件");
}
}
else if (this->componentType == ComponentType::FolderSelect)
{
QString fileName = QFileDialog::getOpenFileName(this,
QString(u8"选择%1").arg(this->getParaChsName()),
"", "",
QString(u8"所有文件(*.*);;%1文件(*.%2);;").arg(this->getDatatype()).arg(this->getDatatype())); QString(u8"所有文件(*.*);;%1文件(*.%2);;").arg(this->getDatatype()).arg(this->getDatatype()));
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
filePathEdit->setText(fileName); filePathEdit->setText(fileName);
} }
else { else {
QMessageBox::warning(this, u8"警告", u8"请选择文件"); QMessageBox::warning(this, u8"警告", u8"请选择文件");
} }
} }
else { else if (this->componentType == ComponentType::MulitFileSelect)
{
QStringList fileName = QFileDialog::getOpenFileNames(this,
QString(u8"选择文件夹:%1").arg(this->getParaChsName()),
"");
if (fileName.count() != 0)
{
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);
}
else {
QMessageBox::warning(this, u8"警告", u8"请选择文件夹");
}
}
else if (this->componentType == ComponentType::FolderSelect) {
QString fileName = QFileDialog::getExistingDirectory(this, QString fileName = QFileDialog::getExistingDirectory(this,
QString(u8"选择文件夹:%1").arg(this->getParaChsName()), QString(u8"选择文件夹:%1").arg(this->getParaChsName()),
""); "");
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
fileName = QString(u8"%1%2").arg(fileName).arg(QDir::separator());
filePathEdit->setText(fileName); filePathEdit->setText(fileName);
} }
else { else {
QMessageBox::warning(this, u8"警告", u8"请选择文件夹"); QMessageBox::warning(this, u8"警告", u8"请选择文件夹");
} }
} }
else {
QMessageBox::warning(this, u8"警告", u8"参数控件格式错误");
}
} }
// 整数输入组件 // 整数输入组件
IntInputWidget::IntInputWidget(QWidget* parent) :AbstractComponentWidget(parent) IntInputWidget::IntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
@ -193,13 +216,13 @@ void IntInputWidget::initUI()
intInput = new QSpinBox(this); intInput = new QSpinBox(this);
intInput->setRange(-1000000, 1000000); intInput->setRange(-920240809, 920240809);
intInput->setSingleStep(1); intInput->setSingleStep(1);
// 设置文件最小控件高度 // 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30); fileNameLabel->setMinimumHeight(40);
intInput->setMinimumHeight(30); intInput->setMinimumHeight(40);
// 水平布局 // 水平布局
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel); layout->addWidget(fileNameLabel);
layout->addWidget(intInput); layout->addWidget(intInput);
@ -216,8 +239,8 @@ QString IntInputWidget::getValue() const
return QString::number(this->intInput->value()); return QString::number(this->intInput->value());
} }
} }
// 浮点数输入组件 // 浮点数输入组件
DoubleInputWidget::DoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent) DoubleInputWidget::DoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
@ -233,14 +256,13 @@ void DoubleInputWidget::initUI()
fileNameLabel->setText(this->getParaName()); fileNameLabel->setText(this->getParaName());
doubleInput = new QDoubleSpinBox(this); doubleInput = new QLineEdit(this);
doubleInput->setRange(-1000000, 1000000);
doubleInput->setSingleStep(1e-6);
// 设置文件最小控件高度 // 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30); fileNameLabel->setMinimumHeight(40);
doubleInput->setMinimumHeight(30); doubleInput->setMinimumHeight(40);
// 水平布局 // 水平布局
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel); layout->addWidget(fileNameLabel);
layout->addWidget(doubleInput); layout->addWidget(doubleInput);
@ -251,7 +273,7 @@ QString DoubleInputWidget::getValue() const
{ {
if (nullptr != this->doubleInput) if (nullptr != this->doubleInput)
{ {
return QString::number(this->doubleInput->value(),'e',14); return this->doubleInput->text();
} }
else { else {
return QString(); return QString();
@ -260,10 +282,10 @@ QString DoubleInputWidget::getValue() const
// 整数输入组件 // 整数输入组件
ScopeIntInputWidget::ScopeIntInputWidget(QWidget* parent) :AbstractComponentWidget(parent) ScopeIntInputWidget::ScopeIntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
} }
ScopeIntInputWidget::~ScopeIntInputWidget() ScopeIntInputWidget::~ScopeIntInputWidget()
@ -285,11 +307,11 @@ void ScopeIntInputWidget::initUI()
intInputMax->setRange(-1000000, 1000000); intInputMax->setRange(-1000000, 1000000);
intInputMax->setSingleStep(1); intInputMax->setSingleStep(1);
// 设置文件最小控件高度 // 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30); fileNameLabel->setMinimumHeight(40);
intInputMin->setMinimumHeight(30); intInputMin->setMinimumHeight(40);
intInputMax->setMinimumHeight(30); intInputMax->setMinimumHeight(40);
// 水平布局 // 水平布局
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel); layout->addWidget(fileNameLabel);
layout->addWidget(intInputMin); layout->addWidget(intInputMin);
@ -298,6 +320,7 @@ void ScopeIntInputWidget::initUI()
this->setLayout(layout); this->setLayout(layout);
} }
QString ScopeIntInputWidget::getValue() const QString ScopeIntInputWidget::getValue() const
{ {
if (nullptr != intInputMin && nullptr != intInputMax) if (nullptr != intInputMin && nullptr != intInputMax)
@ -307,14 +330,14 @@ QString ScopeIntInputWidget::getValue() const
.arg(QString::number(intInputMax->value())); .arg(QString::number(intInputMax->value()));
} }
else { else {
QMessageBox::warning(nullptr, u8"警告", u8"请先输入"); QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
} }
return QString(); return QString();
} }
// 浮点数输入组件 // 浮点数输入组件
ScopeDoubleInputWidget::ScopeDoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent) ScopeDoubleInputWidget::ScopeDoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
} }
@ -327,22 +350,19 @@ void ScopeDoubleInputWidget::initUI()
{ {
fileNameLabel = new QLabel(this); fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName()); fileNameLabel->setText(this->getParaName());
doubleInputMin = new QDoubleSpinBox(this); doubleInputMin = new QLineEdit(this);
doubleInputMax->setRange(-1000000, 1000000);
doubleInputMin->setSingleStep(1);
scopeConnectStr = new QLabel(this); scopeConnectStr = new QLabel(this);
scopeConnectStr->setText(u8" - "); scopeConnectStr->setText(u8" - ");
doubleInputMax = new QDoubleSpinBox(this); doubleInputMax = new QLineEdit(this);
doubleInputMax->setRange(-1000000, 1000000);
doubleInputMax->setSingleStep(1);
// 设置文件最小控件高度 // 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30); fileNameLabel->setMinimumHeight(40);
doubleInputMin->setMinimumHeight(30); doubleInputMin->setMinimumHeight(40);
doubleInputMax->setMinimumHeight(30); doubleInputMax->setMinimumHeight(40);
// 水平布局 // 水平布局
QHBoxLayout* layout = new QHBoxLayout(this); QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel); layout->addWidget(fileNameLabel);
layout->addWidget(doubleInputMin); layout->addWidget(doubleInputMin);
@ -356,11 +376,537 @@ QString ScopeDoubleInputWidget::getValue() const
if (nullptr != doubleInputMin && nullptr != doubleInputMax) if (nullptr != doubleInputMin && nullptr != doubleInputMax)
{ {
return QString("%1;%2") return QString("%1;%2")
.arg(QString::number(doubleInputMin->value(),'e',14)) .arg(doubleInputMin->text())
.arg(QString::number(doubleInputMax->value(), 'e', 14)); .arg(doubleInputMax->text());
} }
else { else {
QMessageBox::warning(nullptr, u8"警告", u8"请先输入"); QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
} }
return QString(); return QString();
} }
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();
}

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
/** /**
* *
* @file KJ135WBJYAlgWidgetComponet.h * @file KJ135WBJYAlgWidgetComponet.h
* @brief KJ135WBJYAlgWidgetComponet.h * @brief KJ135WBJYAlgWidgetComponet.h
* @details * @details
* *
*/ */
#ifndef __KJ135WBJYAlgInterfaceToolbox_GLOBAL_H__ #ifndef __KJ135WBJYAlgInterfaceToolbox_GLOBAL_H__
@ -29,18 +29,25 @@
/// <summary> /// <summary>
/// 参数类型枚举 /// 参数类型枚举
/// </summary> /// </summary>
enum ComponentType{ enum ComponentType{
UNKNOW = 0, // 未知类型 UNKNOW = 0, // 未知类型
FileSelect , // 文件选择 WorkSpace, // 工作空间路径
FolderSelect, // 文件夹选择 FileSelect , // 文件选择
ComboxSelect,// 枚举多选 MulitFileSelect , // 文件选择
IntInput,// 整数输入 FolderSelect, // 文件夹选择
DoubleInput,// 浮点数输入 ComboxSelect,// 枚举多选
MultipleSelect,// 多选 IntInput,// 整数输入
ScopeIntInput,// 整数范围输入 stringInput,
ScopeDoubleInput,// 浮点数范围输入 BoxDoubleInput,// 复选框浮点数输入
DoubleInput,// 浮点数输入
MultipleSelect,// 多选
MultiIntInput,// 整数多选输入
MultiDoubleInput,// 浮点数多选输入
ScopeIntInput,// 整数范围输入
ScopeDoubleInput,// 浮点数范围输入
}; };
@ -50,8 +57,8 @@ enum ComponentType{
/** /**
<Parameter> <Parameter>
<ParaName>CoveringIDs</ParaName> <ParaName>CoveringIDs</ParaName>
<ParaChsName>id</ParaChsName> <ParaChsName>id</ParaChsName>
<Description>id,id使;GlobeLand30cover_roi_ids = 10;20;30;40;50;70;71;72;83;74;90</Description> <Description>id,id使;GlobeLand30cover_roi_ids = 10;20;30;40;50;70;71;72;83;74;90</Description>
<ParaType>Value</ParaType> <ParaType>Value</ParaType>
<DataType>string</DataType> <DataType>string</DataType>
<ParaSource>Man</ParaSource> <ParaSource>Man</ParaSource>
@ -79,36 +86,39 @@ public:
~AbstractComponentWidget(); ~AbstractComponentWidget();
protected: protected:
QString ParaName; // 参数名称 QString ParaName; // 参数名称
QString ParaChsName;// 参数中文名称 QString ParaChsName;// 参数中文名称
QString Description;// 参数描述 QString Description;// 参数描述
QString Datatype;// 数据类型 Value // 决定参数的输入类型 QString Datatype;// 数据类型 Value // 决定参数的输入类型
QString ParaType;// 参数类型 string QString ParaType;// 参数类型 string
ComponentType componentType = ComponentType::UNKNOW; // 组件类型 ComponentType componentType = ComponentType::UNKNOW; // 组件类型
public://属性操作 public://属性操作
QString getParaName() const; QString getParaName() const;
void setParaName(const QString& name); void setParaName(const QString& name);
// 设置参数中文名称 // 设置参数中文名称
QString getParaChsName() const; QString getParaChsName() const;
void setParaChsName(const QString& name); void setParaChsName(const QString& name);
// 设置参数描述 // 设置参数描述
QString getDescription() const; QString getDescription() const;
void setDescription(const QString& description); void setDescription(const QString& description);
// 设置数据类型 // 设置数据类型
QString getDatatype() const; QString getDatatype() const;
void setDatatype(const QString& datatype); void setDatatype(const QString& datatype);
// 设置参数类型 // 设置参数类型
QString getParaType() const; QString getParaType() const;
void setParaType(const QString& type); void setParaType(const QString& type);
void setComponentType(ComponentType type); void setComponentType(ComponentType type);
ComponentType getComponentType() const; ComponentType getComponentType() const;
virtual QString getValue() const;
virtual void initUI();
}; };
/// <summary> /// <summary>
/// File 文件选择组件 /// File 文件选择组件
/// </summary> /// </summary>
class FileSelectWidget : public AbstractComponentWidget class FileSelectWidget : public AbstractComponentWidget
{ {
@ -116,19 +126,19 @@ class FileSelectWidget : public AbstractComponentWidget
public: public:
FileSelectWidget(QWidget* parent = nullptr); FileSelectWidget(QWidget* parent = nullptr);
~FileSelectWidget(); ~FileSelectWidget();
void initUI(); virtual void initUI() override;
private: private:
QLabel* fileNameLabel=nullptr; // 文件名称 QLabel* fileNameLabel=nullptr; // 文件名称
QLineEdit* filePathEdit = nullptr; QLineEdit* filePathEdit = nullptr;
QToolButton* fileSelectButton = nullptr; QToolButton* fileSelectButton = nullptr;
public slots: public slots:
void onFileSelectButtonClicked(); void onFileSelectButtonClicked();
public: public:
QString getValue() const; virtual QString getValue() const override;
}; };
/// <summary> /// <summary>
/// int输入组件 /// int输入组件
/// </summary> /// </summary>
class IntInputWidget : public AbstractComponentWidget class IntInputWidget : public AbstractComponentWidget
{ {
@ -136,18 +146,18 @@ class IntInputWidget : public AbstractComponentWidget
public: public:
IntInputWidget(QWidget* parent = nullptr); IntInputWidget(QWidget* parent = nullptr);
~IntInputWidget(); ~IntInputWidget();
void initUI(); virtual void initUI() override;
private: private:
QLabel* fileNameLabel = nullptr; // 文件名称 QLabel* fileNameLabel = nullptr; // 文件名称
QSpinBox* intInput = nullptr; QSpinBox* intInput = nullptr;
public: public:
QString getValue() const; virtual QString getValue() const override;
}; };
/// <summary> /// <summary>
/// double 输入组件 /// double 输入组件
/// </summary> /// </summary>
class DoubleInputWidget : public AbstractComponentWidget class DoubleInputWidget : public AbstractComponentWidget
{ {
@ -155,16 +165,16 @@ class DoubleInputWidget : public AbstractComponentWidget
public: public:
DoubleInputWidget(QWidget* parent = nullptr); DoubleInputWidget(QWidget* parent = nullptr);
~DoubleInputWidget(); ~DoubleInputWidget();
void initUI(); virtual void initUI() override;
private: private:
QLabel* fileNameLabel = nullptr; // 文件名称 QLabel* fileNameLabel = nullptr; // 文件名称
QDoubleSpinBox* doubleInput = nullptr; QLineEdit* doubleInput = nullptr;
public: public:
QString getValue() const; virtual QString getValue() const override;
}; };
/// <summary> /// <summary>
/// 整数值 数据范围输入组件 /// 整数值 数据范围输入组件
/// </summary> /// </summary>
class ScopeIntInputWidget : public AbstractComponentWidget class ScopeIntInputWidget : public AbstractComponentWidget
{ {
@ -172,19 +182,19 @@ class ScopeIntInputWidget : public AbstractComponentWidget
public: public:
ScopeIntInputWidget(QWidget* parent = nullptr); ScopeIntInputWidget(QWidget* parent = nullptr);
~ScopeIntInputWidget(); ~ScopeIntInputWidget();
void initUI(); virtual void initUI() override;
private: private:
QLabel* fileNameLabel = nullptr; // 文件名称 QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* scopeConnectStr = nullptr; // 文件名称 QLabel* scopeConnectStr = nullptr; // 文件名称
QSpinBox* intInputMin = nullptr; QSpinBox* intInputMin = nullptr;
QSpinBox* intInputMax = nullptr; QSpinBox* intInputMax = nullptr;
public: public:
QString getValue() const; virtual QString getValue() const override;
}; };
/// <summary> /// <summary>
/// 浮点数值 数据范围输入组件 /// 浮点数值 数据范围输入组件
/// </summary> /// </summary>
class ScopeDoubleInputWidget : public AbstractComponentWidget class ScopeDoubleInputWidget : public AbstractComponentWidget
{ {
@ -192,24 +202,139 @@ class ScopeDoubleInputWidget : public AbstractComponentWidget
public: public:
ScopeDoubleInputWidget(QWidget* parent = nullptr); ScopeDoubleInputWidget(QWidget* parent = nullptr);
~ScopeDoubleInputWidget(); ~ScopeDoubleInputWidget();
void initUI(); virtual void initUI() override;
private: private:
QLabel* fileNameLabel = nullptr; // 文件名称 QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* scopeConnectStr = nullptr; // 文件名称 QLabel* scopeConnectStr = nullptr; // 文件名称
QDoubleSpinBox* doubleInputMin = nullptr; QLineEdit* doubleInputMin = nullptr;
QDoubleSpinBox* doubleInputMax = nullptr; QLineEdit* doubleInputMax = nullptr;
public: public:
QString getValue() const; virtual QString getValue() const override;
}; };
class BoxDoubleInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
BoxDoubleInputWidget(QWidget* parent = nullptr);
~BoxDoubleInputWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLineEdit* doubleInputMin = nullptr;
public:
virtual QString getValue() const override;
};
class MultiIntInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
MultiIntInputWidget(QWidget* parent = nullptr);
~MultiIntInputWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLineEdit* IntInputMin = nullptr;
public:
virtual QString getValue() const override;
};
class MultiDoubleInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
MultiDoubleInputWidget(QWidget* parent = nullptr);
~MultiDoubleInputWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLineEdit* doubleInputMin = nullptr;
public:
virtual QString getValue() const override;
};
class CorrectMethodcomboxSelectWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
CorrectMethodcomboxSelectWidget(QWidget* parent = nullptr);
~CorrectMethodcomboxSelectWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QComboBox* comboxSelect = nullptr;
public:
virtual QString getValue() const override;
};
class FeatureCombinationMultiIntInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
FeatureCombinationMultiIntInputWidget(QWidget* parent = nullptr);
~FeatureCombinationMultiIntInputWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
/*
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)*/
QCheckBox* checkbox0 = nullptr; // 表面散射
QCheckBox* checkbox1 = nullptr; // 偶次散射p_d
QCheckBox* checkbox2 = nullptr; // 体散射p_v
QCheckBox* checkbox3 = nullptr; // 散射角α_s
QCheckBox* checkbox4 = nullptr; // 散射相位ϕ_α
QCheckBox* checkbox5 = nullptr; // 目标散射对称度τ
QCheckBox* checkbox6 = nullptr; // 相对能量λ_i
QCheckBox* checkbox7 = nullptr; // 表面散射f_s
QCheckBox* checkbox8 = nullptr; // 二次散射f_d
QCheckBox* checkbox9 = nullptr; // 体散射f_v
QCheckBox* checkbox10 = nullptr; // 螺旋体散射f_h
QCheckBox* checkbox11 = nullptr; // 分解散射熵H
QCheckBox* checkbox12 = nullptr; // 反熵A
QCheckBox* checkbox13 = nullptr; // 平均散射角α
public:
virtual QString getValue() const override;
};
class StringInputWidget :public AbstractComponentWidget
{
Q_OBJECT
public:
StringInputWidget(QWidget* parent = nullptr);
~StringInputWidget();
virtual void initUI() override;
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLineEdit* IntInputMin = nullptr;
public:
virtual QString getValue() const override;
};
/// <summary>
/// 参数文件工厂
/// </summary>
/// <param name="ParaName">参数名称</param>
/// <param name="ParaChsName">参数中文别名</param>
/// <param name="Datatype">数据类型</param>
/// <param name="ParaType">参数类型</param>
/// <param name="Description">描述</param>
/// <param name="parent">父控件</param>
/// <returns></returns>
AbstractComponentWidget* createComponentWidgetFactory(QString ParaName, QString ParaChsName, QString Datatype, QString ParaType, QString Description,QWidget* parent = nullptr);
#endif// __KJ135WBJYAlgInterfaceToolbox_GLOBAL_H__ #endif// __KJ135WBJYAlgInterfaceToolbox_GLOBAL_H__

View File

@ -2,7 +2,8 @@
#include "ui_QWBFZAlgComponetXmlParamsDialog.h" #include "ui_QWBFZAlgComponetXmlParamsDialog.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include "WBFZAlgComponetXmlParaseOperator.h"
#include "FileOperator.h"
QWBFZAlgComponetXmlParamsDialog::QWBFZAlgComponetXmlParamsDialog(QWidget *parent) QWBFZAlgComponetXmlParamsDialog::QWBFZAlgComponetXmlParamsDialog(QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::QWBFZAlgComponetXmlParamsDialogClass) ui(new Ui::QWBFZAlgComponetXmlParamsDialogClass)
@ -11,7 +12,57 @@ QWBFZAlgComponetXmlParamsDialog::QWBFZAlgComponetXmlParamsDialog(QWidget *parent
} }
QWBFZAlgComponetXmlParamsDialog::~QWBFZAlgComponetXmlParamsDialog() QWBFZAlgComponetXmlParamsDialog::~QWBFZAlgComponetXmlParamsDialog()
{} {
delete ui;
delete xmlParseOperator;
}
void QWBFZAlgComponetXmlParamsDialog::loadXmlFile(const QString& fileName)
{
if (nullptr != xmlParseOperator)
{
delete xmlParseOperator;
xmlParseOperator = nullptr;
}
else {}
// 创建xml解析类
xmlParseOperator = new WBFZAlgComponetXmlParaseOperator(this);
xmlParseOperator->loadXmlFile(fileName);
// 根据解析结果创建界面ui
// 1. workspace路径
workspacePathWidget = new FileSelectWidget(this);
workspacePathWidget->setParaName("WorkSpace");
workspacePathWidget->setParaChsName(u8"工作空间路径");
workspacePathWidget->setDescription(u8"工作空间路径");
workspacePathWidget->setDatatype(u8"string");
workspacePathWidget->initUI();
ui->verticalLayout_param->addWidget(workspacePathWidget);
// 2. 参数列表
QList < WBFZAlgComponetXmlParamenterItem*> parameterList = xmlParseOperator->getParameterList();
for (long i = 0; i < parameterList.size(); i++)
{
WBFZAlgComponetXmlParamenterItem* item = parameterList.at(i);
qDebug() << "item->getParaName():" << item->getParaName();
// 创建参数组件
AbstractComponentWidget* parameterWidget = createComponentWidgetFactory(
item->getParaName(),
item->getParaChsName(),
item->getDatatype(),
item->getParaType(),
item->getDescription(),
this);
//parameterWidget->initUI();
ui->verticalLayout_param->addWidget(parameterWidget);
this->parameterWidgetList.append(parameterWidget);
}
}
void WBFZAlgComponetLoadXmlParamsProcess() void WBFZAlgComponetLoadXmlParamsProcess()
{ {
@ -23,8 +74,13 @@ void WBFZAlgComponetLoadXmlParamsProcess()
} }
else { else {
// TODO: 解析xml文件加载参数 // TODO: 解析xml文件加载参数
qDebug() << "xmlFileName:" << xmlFileName;
QWBFZAlgComponetXmlParamsDialog* dialog = new QWBFZAlgComponetXmlParamsDialog();
dialog->setWindowTitle(QString(u8"算法组件xml参数文件-%1").arg(getFileNameFromPath(xmlFileName)));
dialog->loadXmlFile(xmlFileName);
dialog->show();
return;
} }
return; return;
} }

View File

@ -8,6 +8,9 @@ namespace Ui
class QWBFZAlgComponetXmlParamsDialogClass; class QWBFZAlgComponetXmlParamsDialogClass;
} }
class WBFZAlgComponetXmlParaseOperator;
class AbstractComponentWidget; // 算法组件参数界面组件类
class QWBFZAlgComponetXmlParamsDialog : public QDialog class QWBFZAlgComponetXmlParamsDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -18,6 +21,17 @@ public:
private: private:
Ui::QWBFZAlgComponetXmlParamsDialogClass* ui; Ui::QWBFZAlgComponetXmlParamsDialogClass* ui;
private:
WBFZAlgComponetXmlParaseOperator* xmlParseOperator = nullptr; // 算法组件xml参数解析类
public:
void loadXmlFile(const QString& fileName); // 加载xml文件
private: // 界面控件
AbstractComponentWidget* workspacePathWidget = nullptr; // 工作空间路径组件
QList<AbstractComponentWidget*> parameterWidgetList; // 参数组件列表
}; };

View File

@ -31,6 +31,11 @@
<height>351</height> <height>351</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_param"/>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>

View File

@ -6,12 +6,13 @@ WBFZAlgComponetXmlParamenterItem::WBFZAlgComponetXmlParamenterItem(QDomElement*
qDebug() << "itemparameter is nullptr."; qDebug() << "itemparameter is nullptr.";
return; return;
} }
this->ParaName = itemparameter->attribute("Name");
this->ParaChsName = itemparameter->attribute("ChsName"); this->ParaName = itemparameter->firstChildElement("ParaName").isNull() ? QString() : itemparameter->firstChildElement("ParaName").text();
this->Description = itemparameter->attribute("Description"); this->ParaChsName = itemparameter->firstChildElement("ParaChsName").isNull() ? QString() : itemparameter->firstChildElement("ParaChsName").text();
this->Datatype = itemparameter->attribute("Datatype"); this->Description = itemparameter->firstChildElement("Description").isNull() ? QString() : itemparameter->firstChildElement("Description").text();
this->ParaType = itemparameter->attribute("Type"); this->Datatype = itemparameter->firstChildElement("DataType").isNull() ? QString() : itemparameter->firstChildElement("DataType").text();
this->ValueStr = itemparameter->text(); this->ParaType = itemparameter->firstChildElement("ParaType").isNull() ? QString() : itemparameter->firstChildElement("ParaType").text();
this->ValueStr = itemparameter->firstChildElement("ParaValue").isNull() ? QString() : itemparameter->firstChildElement("ParaValue").text();
} }
WBFZAlgComponetXmlParamenterItem::~WBFZAlgComponetXmlParamenterItem() WBFZAlgComponetXmlParamenterItem::~WBFZAlgComponetXmlParamenterItem()
@ -20,7 +21,6 @@ WBFZAlgComponetXmlParamenterItem::~WBFZAlgComponetXmlParamenterItem()
WBFZAlgComponetXmlParaseOperator::WBFZAlgComponetXmlParaseOperator(QObject* parent) :QObject(parent) WBFZAlgComponetXmlParaseOperator::WBFZAlgComponetXmlParaseOperator(QObject* parent) :QObject(parent)
{ {
} }
WBFZAlgComponetXmlParaseOperator::~WBFZAlgComponetXmlParaseOperator() WBFZAlgComponetXmlParaseOperator::~WBFZAlgComponetXmlParaseOperator()
@ -55,7 +55,7 @@ void WBFZAlgComponetXmlParaseOperator::parseXmlFile()
// 5. Get the child elements of the root // 5. Get the child elements of the root
QDomNodeList childNodes = root.childNodes(); QDomNodeList childNodes = root.childNodes();
// 6. get the workspace path node // 6. get the workspace path node
QDomNodeList workspacePathNodes = root.elementsByTagName("WorkspacePath"); QDomNodeList workspacePathNodes = root.elementsByTagName("WorkSpace");
if (workspacePathNodes.count() > 0) { if (workspacePathNodes.count() > 0) {
QDomElement workspacePathElement = workspacePathNodes.at(0).toElement(); QDomElement workspacePathElement = workspacePathNodes.at(0).toElement();
this->workSpacePath = workspacePathElement.text(); this->workSpacePath = workspacePathElement.text();
@ -65,26 +65,51 @@ void WBFZAlgComponetXmlParaseOperator::parseXmlFile()
return; return;
} }
// 7. get Root/AlgCompt/Inputs ϵÄËùÓÐParameter×Ó½Úµã // 7. get Root/AlgCompt/Inputs ϵÄËùÓÐParameter×Ó½Úµã
QDomNodeList parameterNodes = root.elementsByTagName("Parameter"); QDomNodeList InputsNodes = root.elementsByTagName("Inputs");
QDomNodeList parameterNodes = InputsNodes.at(0).toElement().elementsByTagName("Parameter");
if (parameterNodes.count() > 0) { if (parameterNodes.count() > 0) {
for (int i = 0; i < parameterNodes.count(); ++i) { for (int i = 0; i < parameterNodes.count(); ++i) {
QDomElement parameterElement = parameterNodes.at(i).toElement(); QDomElement parameterElement = parameterNodes.at(i).toElement();
WBFZAlgComponetXmlParamenterItem* item = new WBFZAlgComponetXmlParamenterItem(&parameterElement,this); WBFZAlgComponetXmlParamenterItem* item = new WBFZAlgComponetXmlParamenterItem(&parameterElement,this);
this->ParameterList.append(item); this->ParameterList.append(item);
qDebug() << "read Parameter Name:" << item->getParaName();
if (item->getParaName().isEmpty()) {
QMessageBox::warning(nullptr, u8"警告", u8"参数名称为空,可能是xml文件格式错误");
qDebug() << "read Parameter Name Error:" << item->getParaName();
return;
}
} }
} }
else { else {
qDebug() << "Parameter not found."; qDebug() << "Parameter not found.";
return; return;
} }
// 8. Display the parsed data
} }
void WBFZAlgComponetXmlParaseOperator::displayParsedData() void WBFZAlgComponetXmlParaseOperator::displayParsedData()
{ {
} }
QString WBFZAlgComponetXmlParaseOperator::getWorkSpacePath() const
{
return this->workSpacePath;
}
void WBFZAlgComponetXmlParaseOperator::setWorkSpacePath(const QString& path)
{
this->workSpacePath = path;
}
QList<WBFZAlgComponetXmlParamenterItem*> WBFZAlgComponetXmlParaseOperator::getParameterList() const
{
return ParameterList;
}
void WBFZAlgComponetXmlParaseOperator::setParameterList(const QList<WBFZAlgComponetXmlParamenterItem*>& list)
{
this->ParameterList = list;
}
QString WBFZAlgComponetXmlParamenterItem::getParaName() const QString WBFZAlgComponetXmlParamenterItem::getParaName() const
{ {
return this->ParaName; return this->ParaName;
@ -107,7 +132,7 @@ void WBFZAlgComponetXmlParamenterItem::setParaChsName(const QString& name)
QString WBFZAlgComponetXmlParamenterItem::getDescription() const QString WBFZAlgComponetXmlParamenterItem::getDescription() const
{ {
return QString(); return this->Description;
} }
void WBFZAlgComponetXmlParamenterItem::setDescription(const QString& description) void WBFZAlgComponetXmlParamenterItem::setDescription(const QString& description)

View File

@ -76,6 +76,14 @@ private://
QDomElement rootElement; // 根节点 QDomElement rootElement; // 根节点
QDomElement workSpaceElement; // 工作空间节点 QDomElement workSpaceElement; // 工作空间节点
QList<WBFZAlgComponetXmlParamenterItem*> ParameterList; // 参数列表 QList<WBFZAlgComponetXmlParamenterItem*> ParameterList; // 参数列表
public:
QString getWorkSpacePath() const;// { return this->workSpacePath; } // 获取工作空间路径
void setWorkSpacePath(const QString& path);// { this->workSpacePath = path; } // 设置工作空间路径
QList<WBFZAlgComponetXmlParamenterItem*> getParameterList() const; // { return this->ParameterList; } // 获取参数列表
void setParameterList(const QList<WBFZAlgComponetXmlParamenterItem*>& list); //{ this->ParameterList = list; } // 设置参数列表
}; };