RasterProcessTool/Toolbox/KJ135WBJYAlgInterfaceToolbox/KJ135WBJYAlgWidgetComponet.cpp

367 lines
7.9 KiB
C++
Raw Normal View History

#include "KJ135WBJYAlgWidgetComponet.h"
#include <QHBoxLayout>
2025-05-08 15:00:13 +00:00
#include <QMessageBox>
2025-05-08 15:00:13 +00:00
AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent)
{
2025-05-08 15:00:13 +00:00
this->componentType = ComponentType::UNKNOW; // Ĭ<><C4AC>δ֪<CEB4><D6AA><EFBFBD><EFBFBD>
this->ParaName = QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this->ParaChsName = QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this->Description = QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this->Datatype = QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
this->ParaType = QString(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
2025-05-08 15:00:13 +00:00
AbstractComponentWidget::~AbstractComponentWidget()
{
}
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-08 15:00:13 +00:00
return this->Description;
}
2025-05-08 15:00:13 +00:00
void AbstractComponentWidget::setDescription(const QString& description)
{
this->setToolTip(description);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
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-08 15:00:13 +00:00
// File <20>ļ<EFBFBD>ѡ<EFBFBD><D1A1>
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()
{
// <20><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD>
// fileNameLabel
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
2025-05-08 15:00:13 +00:00
//filePathEdit
filePathEdit = new QLineEdit(this);
// fileSelectButton
fileSelectButton = new QToolButton(this);
fileSelectButton->setText(u8"ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>");
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD>ؼ<EFBFBD><D8BC>߶<EFBFBD>
fileNameLabel->setMinimumHeight(30);
filePathEdit->setMinimumHeight(30);
fileSelectButton->setMinimumHeight(30);
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>-<2D><>
QObject::connect(fileSelectButton, SIGNAL(clicked()) , this, SLOT(onFileSelectButtonClicked()));
2025-05-08 15:00:13 +00:00
// ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(filePathEdit);
layout->addWidget(fileSelectButton);
this->setLayout(layout);
2025-05-08 15:00:13 +00:00
}
QString FileSelectWidget::getValue() const
{
2025-05-08 15:00:13 +00:00
if (nullptr != filePathEdit)
{
return filePathEdit->text();
}
else {
QMessageBox::warning(nullptr, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>");
return QString();
}
}
void FileSelectWidget::onFileSelectButtonClicked()
{
if (this->componentType == ComponentType::FileSelect)
{
QString fileName = QFileDialog::getOpenFileName(this, u8"ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>", "", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>(*.*);;<3B>ı<EFBFBD><C4B1>ļ<EFBFBD>(*.txt);;ͼ<><CDBC><EFBFBD>ļ<EFBFBD>(*.png *.jpg *.bmp)");
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>");
}
}
else if (this->componentType == ComponentType::FolderSelect)
{
QString fileName = QFileDialog::getOpenFileName(this,
QString(u8"ѡ<EFBFBD><EFBFBD>%1").arg(this->getParaChsName()),
"",
QString(u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>(*.*);;%1<>ļ<EFBFBD>(*.%2);;").arg(this->getDatatype()).arg(this->getDatatype()));
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>");
}
}
else {
QString fileName = QFileDialog::getExistingDirectory(this,
QString(u8"ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>У<EFBFBD>%1").arg(this->getParaChsName()),
"");
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>");
}
}
}
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);
intInput->setRange(-1000000, 1000000);
intInput->setSingleStep(1);
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD>ؼ<EFBFBD><D8BC>߶<EFBFBD>
fileNameLabel->setMinimumHeight(30);
intInput->setMinimumHeight(30);
// ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
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-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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-08 15:00:13 +00:00
doubleInput = new QDoubleSpinBox(this);
doubleInput->setRange(-1000000, 1000000);
doubleInput->setSingleStep(1e-6);
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD>ؼ<EFBFBD><D8BC>߶<EFBFBD>
fileNameLabel->setMinimumHeight(30);
doubleInput->setMinimumHeight(30);
// ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
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)
{
return QString::number(this->doubleInput->value(),'e',14);
}
else {
return QString();
}
}
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD>ؼ<EFBFBD><D8BC>߶<EFBFBD>
fileNameLabel->setMinimumHeight(30);
intInputMin->setMinimumHeight(30);
intInputMax->setMinimumHeight(30);
// ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(intInputMin);
layout->addWidget(scopeConnectStr);
layout->addWidget(intInputMax);
this->setLayout(layout);
}
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 {
QMessageBox::warning(nullptr, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
return QString();
}
2025-05-08 15:00:13 +00:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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());
doubleInputMin = new QDoubleSpinBox(this);
doubleInputMax->setRange(-1000000, 1000000);
doubleInputMin->setSingleStep(1);
scopeConnectStr = new QLabel(this);
scopeConnectStr->setText(u8" - ");
doubleInputMax = new QDoubleSpinBox(this);
doubleInputMax->setRange(-1000000, 1000000);
doubleInputMax->setSingleStep(1);
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD>ؼ<EFBFBD><D8BC>߶<EFBFBD>
fileNameLabel->setMinimumHeight(30);
doubleInputMin->setMinimumHeight(30);
doubleInputMax->setMinimumHeight(30);
// ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD>
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")
.arg(QString::number(doubleInputMin->value(),'e',14))
.arg(QString::number(doubleInputMax->value(), 'e', 14));
}
else {
QMessageBox::warning(nullptr, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
return QString();
}