#include "KJ135WBJYAlgWidgetComponet.h" #include #include #include AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent) { this->componentType = ComponentType::UNKNOW; // 默认未知类型 this->ParaName = QString(); // 参数名称 this->ParaChsName = QString(); // 参数中文名称 this->Description = QString(); // 参数描述 this->Datatype = QString(); // 数据类型 this->ParaType = QString(); // 参数类型 } AbstractComponentWidget::~AbstractComponentWidget() { } QString AbstractComponentWidget::getParaName() const { return this->ParaName; } void AbstractComponentWidget::setParaName(const QString& name) { this->ParaName = name; } QString AbstractComponentWidget::getParaChsName() const { return this->ParaChsName; } void AbstractComponentWidget::setParaChsName(const QString& name) { this->ParaChsName = name; } QString AbstractComponentWidget::getDescription() const { return this->Description; } void AbstractComponentWidget::setDescription(const QString& description) { this->setToolTip(description);// 绑定提示 this->Description = description; } QString AbstractComponentWidget::getDatatype() const { return this->Datatype; } void AbstractComponentWidget::setDatatype(const QString& datatype) { this->Datatype = datatype; } QString AbstractComponentWidget::getParaType() const { return this->ParaType; } void AbstractComponentWidget::setParaType(const QString& type) { this->ParaType = type; } void AbstractComponentWidget::setComponentType(ComponentType type) { this->componentType = type; } ComponentType AbstractComponentWidget::getComponentType() const { return this->componentType; } QString AbstractComponentWidget::getValue() const { return QString(); } void AbstractComponentWidget::initUI() { } // File 文件选择 FileSelectWidget::FileSelectWidget(QWidget* parent) :AbstractComponentWidget(parent) { } FileSelectWidget::~FileSelectWidget() { } void FileSelectWidget::initUI() { // 初始化控件 // fileNameLabel fileNameLabel = new QLabel(this); fileNameLabel->setText(this->getParaName()); //filePathEdit filePathEdit = new QLineEdit(this); // fileSelectButton fileSelectButton = new QToolButton(this); fileSelectButton->setText(u8"选择文件"); // 设置文件最小控件高度 fileNameLabel->setMinimumHeight(40); filePathEdit->setMinimumHeight(40); fileSelectButton->setMinimumHeight(40); // 绑定信号-槽 QObject::connect(fileSelectButton, SIGNAL(clicked()), this, SLOT(onFileSelectButtonClicked())); // 水平布局 QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(fileNameLabel); layout->addWidget(filePathEdit); layout->addWidget(fileSelectButton); this->setLayout(layout); } QString FileSelectWidget::getValue() const { if (nullptr != filePathEdit) { 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(); } } else { QMessageBox::warning(nullptr, u8"警告", u8"请先选择文件"); return QString(); } } void FileSelectWidget::onFileSelectButtonClicked() { if (this->componentType == ComponentType::FileSelect) { QString fileName = QFileDialog::getOpenFileName(this, QString(u8"选择%1").arg(this->getParaChsName()), "", QString(u8"所有文件(*.*);;%1文件(*.%2);;").arg(this->getDatatype()).arg(this->getDatatype())); if (!fileName.isEmpty()) { filePathEdit->setText(fileName); } else { QMessageBox::warning(this, u8"警告", u8"请选择文件"); } } 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(u8"选择文件夹:%1").arg(this->getParaChsName()), ""); if (!fileName.isEmpty()) { fileName = QString(u8"%1%2").arg(fileName).arg(QDir::separator()); filePathEdit->setText(fileName); } else { QMessageBox::warning(this, u8"警告", u8"请选择文件夹"); } } else { QMessageBox::warning(this, u8"警告", u8"参数控件格式错误"); } } // 整数输入组件 IntInputWidget::IntInputWidget(QWidget* parent) :AbstractComponentWidget(parent) { } IntInputWidget::~IntInputWidget() { } void IntInputWidget::initUI() { fileNameLabel = new QLabel(this); fileNameLabel->setText(this->getParaName()); intInput = new QSpinBox(this); intInput->setRange(-920240809, 920240809); intInput->setSingleStep(1); // 设置文件最小控件高度 fileNameLabel->setMinimumHeight(40); intInput->setMinimumHeight(40); // 水平布局 QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(fileNameLabel); layout->addWidget(intInput); this->setLayout(layout); } QString IntInputWidget::getValue() const { if (nullptr == this->intInput) { return QString(); } else { return QString::number(this->intInput->value()); } } // 浮点数输入组件 DoubleInputWidget::DoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent) { } DoubleInputWidget::~DoubleInputWidget() { } void DoubleInputWidget::initUI() { fileNameLabel = new QLabel(this); fileNameLabel->setText(this->getParaName()); doubleInput = new QLineEdit(this); // 设置文件最小控件高度 fileNameLabel->setMinimumHeight(40); doubleInput->setMinimumHeight(40); // 水平布局 QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(fileNameLabel); layout->addWidget(doubleInput); this->setLayout(layout); } QString DoubleInputWidget::getValue() const { if (nullptr != this->doubleInput) { return this->doubleInput->text(); } else { return QString(); } } // 整数输入组件 ScopeIntInputWidget::ScopeIntInputWidget(QWidget* parent) :AbstractComponentWidget(parent) { } 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); // 设置文件最小控件高度 fileNameLabel->setMinimumHeight(40); intInputMin->setMinimumHeight(40); intInputMax->setMinimumHeight(40); // 水平布局 QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(fileNameLabel); layout->addWidget(intInputMin); layout->addWidget(scopeConnectStr); layout->addWidget(intInputMax); this->setLayout(layout); } QString ScopeIntInputWidget::getValue() const { if (nullptr != intInputMin && nullptr != intInputMax) { return QString("%1;%2") .arg(QString::number(intInputMin->value())) .arg(QString::number(intInputMax->value())); } else { QMessageBox::warning(nullptr, u8"警告", u8"请先输入"); } return QString(); } // 浮点数输入组件 ScopeDoubleInputWidget::ScopeDoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent) { } ScopeDoubleInputWidget::~ScopeDoubleInputWidget() { } void ScopeDoubleInputWidget::initUI() { fileNameLabel = new QLabel(this); fileNameLabel->setText(this->getParaName()); doubleInputMin = new QLineEdit(this); scopeConnectStr = new QLabel(this); scopeConnectStr->setText(u8" - "); doubleInputMax = new QLineEdit(this); // 设置文件最小控件高度 fileNameLabel->setMinimumHeight(40); doubleInputMin->setMinimumHeight(40); doubleInputMax->setMinimumHeight(40); // 水平布局 QHBoxLayout* layout = new QHBoxLayout(this); layout->addWidget(fileNameLabel); layout->addWidget(doubleInputMin); layout->addWidget(scopeConnectStr); layout->addWidget(doubleInputMax); this->setLayout(layout); } QString ScopeDoubleInputWidget::getValue() const { if (nullptr != doubleInputMin && nullptr != doubleInputMax) { return QString("%1;%2") .arg(doubleInputMin->text()) .arg(doubleInputMax->text()); } else { QMessageBox::warning(nullptr, u8"警告", u8"请先输入"); } 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 阵列 Freeman:表面散射p_s(0)、偶次散射p_d(1)、体散射p_v(2); Touzi:散射角α_s(3)、散射相位ϕ_α(4)、目标散射对称度τ(5)、相对能量λ_i(6); Yamaguchi:表面散射f_s(7)、二次散射f_d(8)、体散射f_v(9)、螺旋体散射f_h(10); Cloude-Pottier:分解散射熵H(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(); }