增加了参数界面控件的使用

Release-dev
chenzenghui 2025-05-08 23:00:13 +08:00
parent 203bb6cfc8
commit e895d7ffb3
13 changed files with 698 additions and 184 deletions

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6386D3E3-B743-419F-8354-DA48D0B08728}</ProjectGuid>
<Keyword>QtVS_v304</Keyword>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0</WindowsTargetPlatformVersion>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')"
>$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>tools_qt5</QtInstall>
<QtModules>core</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>tools_qt5</QtInstall>
<QtModules>core</QtModules>
<QtBuildConfig>release</QtBuildConfig>
</PropertyGroup>
<Target Name="QtMsBuildNotFound"
BeforeTargets="CustomBuild;ClCompile"
Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
<Message Importance="High"
Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
</Target>
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(QtMsBuild)\qt.targets" />
</ImportGroup>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
#include <QtCore/QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}

View File

@ -44,6 +44,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SPG4Tool", "SPG4Tool\SPG4To
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KJ135WBJYAlgInterfaceToolbox", "Toolbox\KJ135WBJYAlgInterfaceToolbox\KJ135WBJYAlgInterfaceToolbox.vcxproj", "{D3E9A2CA-7F05-425A-A4B6-416EC20972E8}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KJ135WBJYAlgInterfaceToolbox", "Toolbox\KJ135WBJYAlgInterfaceToolbox\KJ135WBJYAlgInterfaceToolbox.vcxproj", "{D3E9A2CA-7F05-425A-A4B6-416EC20972E8}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GF3StripPatchProcess", "GF3StripPatchProcess\GF3StripPatchProcess.vcxproj", "{6386D3E3-B743-419F-8354-DA48D0B08728}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM Debug|ARM = Debug|ARM
@ -210,6 +212,18 @@ Global
{D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x64.Build.0 = Release|x64 {D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x64.Build.0 = Release|x64
{D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x86.ActiveCfg = Release|x64 {D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x86.ActiveCfg = Release|x64
{D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x86.Build.0 = Release|x64 {D3E9A2CA-7F05-425A-A4B6-416EC20972E8}.Release|x86.Build.0 = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|ARM.ActiveCfg = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|ARM.Build.0 = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|x64.ActiveCfg = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|x64.Build.0 = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|x86.ActiveCfg = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Debug|x86.Build.0 = Debug|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|ARM.ActiveCfg = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|ARM.Build.0 = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|x64.ActiveCfg = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|x64.Build.0 = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|x86.ActiveCfg = Release|x64
{6386D3E3-B743-419F-8354-DA48D0B08728}.Release|x86.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -112,8 +112,10 @@
<ClCompile Include="KJ135WBJYAlgInterfaceToolbox.cpp" /> <ClCompile Include="KJ135WBJYAlgInterfaceToolbox.cpp" />
<ClCompile Include="KJ135WBJYAlgWidgetComponet.cpp" /> <ClCompile Include="KJ135WBJYAlgWidgetComponet.cpp" />
<ClCompile Include="QWBFZAlgComponetXmlParamsDialog.cpp" /> <ClCompile Include="QWBFZAlgComponetXmlParamsDialog.cpp" />
<ClCompile Include="WBFZAlgComponetXmlParaseOperator.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="WBFZAlgComponetXmlParaseOperator.h" />
<QtMoc Include="QWBFZAlgComponetXmlParamsDialog.h" /> <QtMoc Include="QWBFZAlgComponetXmlParamsDialog.h" />
<QtMoc Include="KJ135WBJYAlgInterfaceToolbox.h" /> <QtMoc Include="KJ135WBJYAlgInterfaceToolbox.h" />
<ClInclude Include="KJ135WBJYAlgInterfacetoolbox_global.h" /> <ClInclude Include="KJ135WBJYAlgInterfacetoolbox_global.h" />

View File

@ -32,22 +32,28 @@
<ClCompile Include="QWBFZAlgComponetXmlParamsDialog.cpp"> <ClCompile Include="QWBFZAlgComponetXmlParamsDialog.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="WBFZAlgComponetXmlParaseOperator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="KJ135WBJYAlgInterfacetoolbox_global.h"> <ClInclude Include="KJ135WBJYAlgInterfacetoolbox_global.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="WBFZAlgComponetXmlParaseOperator.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="KJ135WBJYAlgWidgetComponet.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="KJ135WBJYAlgInterfaceToolbox.h"> <QtMoc Include="KJ135WBJYAlgInterfaceToolbox.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="QWBFZAlgComponetXmlParamsDialog.h"> <QtMoc Include="QWBFZAlgComponetXmlParamsDialog.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="KJ135WBJYAlgWidgetComponet.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtUic Include="QWBFZAlgComponetXmlParamsDialog.ui"> <QtUic Include="QWBFZAlgComponetXmlParamsDialog.ui">

View File

@ -1,149 +1,225 @@
#include "KJ135WBJYAlgWidgetComponet.h" #include "KJ135WBJYAlgWidgetComponet.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QMessageBox>
AbstractComponentWidget::AbstractComponentWidget(QWidget* parent) :QWidget(parent)
FileSelectWidget::FileSelectWidget( ComponentType paramtype, QWidget* parent)
: QWidget(parent),
paramType(paramtype)
{ {
this->m_pFileSelectButton = new QToolButton(this); this->componentType = ComponentType::UNKNOW; // 默认未知类型
this->m_pFileSelectButton->setText("Select File"); this->ParaName = QString(); // 参数名称
QObject::connect(m_pFileSelectButton, SIGNAL(clicked()), this, SLOT(onSelectFile())); this->ParaChsName = QString(); // 参数中文名称
m_pFileNameEdit = new QLineEdit(this); this->Description = QString(); // 参数描述
this->m_pFileNameLabel = new QLabel("Selected File:", this); this->Datatype = QString(); // 数据类型
QHBoxLayout* layout = new QHBoxLayout(this); this->ParaType = QString(); // 参数类型
layout->addWidget(m_pFileNameLabel);
layout->addWidget(m_pFileNameEdit);
layout->addWidget(m_pFileSelectButton);
setLayout(layout);
} }
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;
}
// File 文件选择
FileSelectWidget::FileSelectWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
FileSelectWidget::~FileSelectWidget() FileSelectWidget::~FileSelectWidget()
{ {
// Destructor implementation
} }
void FileSelectWidget::setFileName(const QString& fileName) void FileSelectWidget::initUI()
{ {
this->m_pFileNameEdit->setText(fileName); // 初始化控件
// fileNameLabel
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
//filePathEdit
filePathEdit = new QLineEdit(this);
// fileSelectButton
fileSelectButton = new QToolButton(this);
fileSelectButton->setText(u8"选择文件");
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30);
filePathEdit->setMinimumHeight(30);
fileSelectButton->setMinimumHeight(30);
// 绑定信号-槽
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::getFileName() const QString FileSelectWidget::getValue() const
{ {
return this->m_pFileNameEdit->text(); if (nullptr != filePathEdit)
}
void FileSelectWidget::setLabelText(const QString& text)
{
this->m_pFileNameLabel->setText(text);
}
void FileSelectWidget::setDataTypeStr(const QString& str)
{
this->DataTypeStr = str;
}
void FileSelectWidget::onSelectFile()
{
if (this->paramType == ComponentType::FolderSelect)
{ {
QString folderName = QFileDialog::getExistingDirectory(this, u8"Select Folder", ""); return filePathEdit->text();
if (!folderName.isEmpty())
{
this->m_pFileNameEdit->setText(folderName);
emit fileSelected(folderName);
} }
return; else {
QMessageBox::warning(nullptr, u8"警告", u8"请先选择文件");
return QString();
} }
else if (this->paramType == ComponentType::FileSelect) }
void FileSelectWidget::onFileSelectButtonClicked()
{
if (this->componentType == ComponentType::FileSelect)
{ {
QString fileName = QFileDialog::getOpenFileName(this, u8"Select File", "", QString("All Files (*);;%1(*.%1)").arg(this->DataTypeStr)); QString fileName = QFileDialog::getOpenFileName(this, u8"选择文件", "", u8"所有文件(*.*);;文本文件(*.txt);;图像文件(*.png *.jpg *.bmp)");
if (!fileName.isEmpty()) if (!fileName.isEmpty())
{ {
this->m_pFileNameEdit->setText(fileName); filePathEdit->setText(fileName);
emit fileSelected(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()));
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"警告", u8"请选择文件");
}
}
else {
QString fileName = QFileDialog::getExistingDirectory(this,
QString(u8"选择文件夹:%1").arg(this->getParaChsName()),
"");
if (!fileName.isEmpty())
{
filePathEdit->setText(fileName);
}
else {
QMessageBox::warning(this, u8"警告", u8"请选择文件夹");
} }
return;
} }
else {}
} }
/*************** 复选框 **************************/
ComboxSelectWidget::ComboxSelectWidget(QWidget* parent)
// 整数输入组件
IntInputWidget::IntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{ {
} }
ComboxSelectWidget::~ComboxSelectWidget()
{
}
void ComboxSelectWidget::setLabelText(const QString& text)
{
}
void ComboxSelectWidget::setDataTypeStr(const QString& str)
{
}
void ComboxSelectWidget::addItem(const QString& item)
{
}
void ComboxSelectWidget::setCurrentIndex(int index)
{
}
void ComboxSelectWidget::setCurrentText(const QString& text)
{
}
QString ComboxSelectWidget::getCurrentText() const
{
return QString();
}
/*************** 整数输入 **************************/
IntInputWidget::IntInputWidget(QWidget* parent)
{
}
IntInputWidget::~IntInputWidget() IntInputWidget::~IntInputWidget()
{ {
} }
void IntInputWidget::setLabelText(const QString& text) void IntInputWidget::initUI()
{ {
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
intInput = new QSpinBox(this);
intInput->setRange(-1000000, 1000000);
intInput->setSingleStep(1);
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30);
intInput->setMinimumHeight(30);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(intInput);
this->setLayout(layout);
} }
void IntInputWidget::setDataTypeStr(const QString& str) QString IntInputWidget::getValue() const
{ {
if (nullptr == this->intInput)
{
return QString();
}
else {
return QString::number(this->intInput->value());
}
} }
void IntInputWidget::setValue(int value) // 浮点数输入组件
{
}
int IntInputWidget::getValue() const DoubleInputWidget::DoubleInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
return 0;
}
/*************** 浮点数输入 **************************/
DoubleInputWidget::DoubleInputWidget(QWidget* parent)
{ {
} }
@ -151,19 +227,140 @@ DoubleInputWidget::~DoubleInputWidget()
{ {
} }
void DoubleInputWidget::setLabelText(const QString& text) void DoubleInputWidget::initUI()
{
fileNameLabel = new QLabel(this);
fileNameLabel->setText(this->getParaName());
doubleInput = new QDoubleSpinBox(this);
doubleInput->setRange(-1000000, 1000000);
doubleInput->setSingleStep(1e-6);
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30);
doubleInput->setMinimumHeight(30);
// 水平布局
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(fileNameLabel);
layout->addWidget(doubleInput);
this->setLayout(layout);
}
QString DoubleInputWidget::getValue() const
{
if (nullptr != this->doubleInput)
{
return QString::number(this->doubleInput->value(),'e',14);
}
else {
return QString();
}
}
// 整数输入组件
ScopeIntInputWidget::ScopeIntInputWidget(QWidget* parent) :AbstractComponentWidget(parent)
{
}
ScopeIntInputWidget::~ScopeIntInputWidget()
{ {
} }
void DoubleInputWidget::setDataTypeStr(const QString& str) 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(30);
intInputMin->setMinimumHeight(30);
intInputMax->setMinimumHeight(30);
// 水平布局
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)
{ {
} }
void DoubleInputWidget::setValue(double value) ScopeDoubleInputWidget::~ScopeDoubleInputWidget()
{ {
} }
double DoubleInputWidget::getValue() const void ScopeDoubleInputWidget::initUI()
{ {
return 0.0; 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);
// 设置文件最小控件高度
fileNameLabel->setMinimumHeight(30);
doubleInputMin->setMinimumHeight(30);
doubleInputMax->setMinimumHeight(30);
// 水平布局
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(QString::number(doubleInputMin->value(),'e',14))
.arg(QString::number(doubleInputMax->value(), 'e', 14));
}
else {
QMessageBox::warning(nullptr, u8"警告", u8"请先输入");
}
return QString();
} }

View File

@ -26,106 +26,181 @@
#include <QCheckBox> #include <QCheckBox>
/// <summary> /// <summary>
/// 参数类型枚举 /// 参数类型枚举
/// </summary> /// </summary>
enum ComponentType{ enum ComponentType{
FileSelect = 0, // ÎļþÑ¡Ôñ UNKNOW = 0, // 未知类型
FileSelect , // 文件选择
FolderSelect, // 文件夹选择 FolderSelect, // 文件夹选择
ComboxSelect,// 枚举多选 ComboxSelect,// 枚举多选
IntInput,// 整数输入 IntInput,// 整数输入
DoubleInput,// 浮点数输入 DoubleInput,// 浮点数输入
MultipleSelect,// 多选
ScopeIntInput,// 整数范围输入
ScopeDoubleInput,// 浮点数范围输入
}; };
class FileSelectWidget : public QWidget
/**
<Parameter>
<ParaName>CoveringIDs</ParaName>
<ParaChsName>id</ParaChsName>
<Description>id,id使;GlobeLand30cover_roi_ids = 10;20;30;40;50;70;71;72;83;74;90</Description>
<ParaType>Value</ParaType>
<DataType>string</DataType>
<ParaSource>Man</ParaSource>
<ParaValue>1;4;5;6;7;11;10;20;30;50;60;70;71;72;73;74;80;90;255</ParaValue>
<EnModification>True</EnModification>
<EnMultipleChoice>False</EnMultipleChoice>
<Control>UploadInput</Control>
<InputType>Aux</InputType>
<InputNum>0</InputNum>
<DateFrom>Aux</DateFrom>
<OptionValue>DEFAULT</OptionValue>
<MinValue>DEFAULT</MinValue>
<MaxValue>DEFAULT</MaxValue>
<NoDataValue>DEFAULT</NoDataValue>
<filePath>DEFAULT</filePath>
</Parameter>
**/
class AbstractComponentWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
FileSelectWidget(ComponentType paramtype = ComponentType::FileSelect,QWidget* parent = nullptr); AbstractComponentWidget(QWidget* parent = nullptr);
~AbstractComponentWidget();
protected:
QString ParaName; // 参数名称
QString ParaChsName;// 参数中文名称
QString Description;// 参数描述
QString Datatype;// 数据类型 Value // 决定参数的输入类型
QString ParaType;// 参数类型 string
ComponentType componentType = ComponentType::UNKNOW; // 组件类型
public://属性操作
QString getParaName() const;
void setParaName(const QString& name);
// 设置参数中文名称
QString getParaChsName() const;
void setParaChsName(const QString& name);
// 设置参数描述
QString getDescription() const;
void setDescription(const QString& description);
// 设置数据类型
QString getDatatype() const;
void setDatatype(const QString& datatype);
// 设置参数类型
QString getParaType() const;
void setParaType(const QString& type);
void setComponentType(ComponentType type);
ComponentType getComponentType() const;
};
/// <summary>
/// File 文件选择组件
/// </summary>
class FileSelectWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
FileSelectWidget(QWidget* parent = nullptr);
~FileSelectWidget(); ~FileSelectWidget();
void initUI();
void setFileName(const QString& fileName);
QString getFileName() const;
void setLabelText(const QString& text);
void setDataTypeStr(const QString& str);
private slots:
void onSelectFile();
signals:
void fileSelected(const QString& fileName);
private: private:
QToolButton* m_pFileSelectButton; QLabel* fileNameLabel=nullptr; // 文件名称
QLineEdit* m_pFileNameEdit; QLineEdit* filePathEdit = nullptr;
QLabel* m_pFileNameLabel; QToolButton* fileSelectButton = nullptr;
QString DataTypeStr; public slots:
ComponentType paramType; void onFileSelectButtonClicked();
};
class ComboxSelectWidget : public QWidget
{
Q_OBJECT
public: public:
ComboxSelectWidget(QWidget* parent = nullptr); QString getValue() const;
~ComboxSelectWidget(); };
void setLabelText(const QString& text);
void setDataTypeStr(const QString& str);
void addItem(const QString& item);
void setCurrentIndex(int index);
void setCurrentText(const QString& text);
QString getCurrentText() const;
private:
QComboBox* m_pCombox;
QLabel* m_pComboxLabel;
QString DataTypeStr;
};
class IntInputWidget : public QWidget /// <summary>
/// int输入组件
/// </summary>
class IntInputWidget : public AbstractComponentWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
IntInputWidget(QWidget* parent = nullptr); IntInputWidget(QWidget* parent = nullptr);
~IntInputWidget(); ~IntInputWidget();
void setLabelText(const QString& text); void initUI();
void setDataTypeStr(const QString& str);
void setValue(int value);
int getValue() const;
private: private:
QSpinBox* m_pIntInput; QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* m_pIntInputLabel; QSpinBox* intInput = nullptr;
QString DataTypeStr;
public:
QString getValue() const;
}; };
class DoubleInputWidget : public QWidget /// <summary>
/// double 输入组件
/// </summary>
class DoubleInputWidget : public AbstractComponentWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
DoubleInputWidget(QWidget* parent = nullptr); DoubleInputWidget(QWidget* parent = nullptr);
~DoubleInputWidget(); ~DoubleInputWidget();
void setLabelText(const QString& text); void initUI();
void setDataTypeStr(const QString& str);
void setValue(double value);
double getValue() const;
private: private:
QDoubleSpinBox* m_pDoubleInput; QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* m_pDoubleInputLabel; QDoubleSpinBox* doubleInput = nullptr;
QString DataTypeStr; public:
QString getValue() const;
};
/// <summary>
/// 整数值 数据范围输入组件
/// </summary>
class ScopeIntInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
ScopeIntInputWidget(QWidget* parent = nullptr);
~ScopeIntInputWidget();
void initUI();
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* scopeConnectStr = nullptr; // 文件名称
QSpinBox* intInputMin = nullptr;
QSpinBox* intInputMax = nullptr;
public:
QString getValue() const;
}; };
/// <summary>
/// 浮点数值 数据范围输入组件
/// </summary>
class ScopeDoubleInputWidget : public AbstractComponentWidget
{
Q_OBJECT
public:
ScopeDoubleInputWidget(QWidget* parent = nullptr);
~ScopeDoubleInputWidget();
void initUI();
private:
QLabel* fileNameLabel = nullptr; // 文件名称
QLabel* scopeConnectStr = nullptr; // 文件名称
QDoubleSpinBox* doubleInputMin = nullptr;
QDoubleSpinBox* doubleInputMax = nullptr;
public:
QString getValue() const;
};

View File

@ -22,7 +22,9 @@ void WBFZAlgComponetLoadXmlParamsProcess()
return; return;
} }
else { else {
// TODO: 解析xml文件加载参数
} }
return;
} }

View File

@ -16,6 +16,9 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QScrollArea" name="scrollAreaParamWidget"> <widget class="QScrollArea" name="scrollAreaParamWidget">
<property name="toolTip">
<string/>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -0,0 +1 @@
#include "WBFZAlgComponetXmlParaseOperator.h"

View File

@ -0,0 +1,67 @@
#pragma once
#ifndef __WBFZAlgComponetXmlParaseOperator_H__
#define __WBFZAlgComponetXmlParaseOperator_H__
#include <QObject>
#include <QString>
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
#include <QtXml>
#include <QFile>
#include <QTextStream>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QDomNodeList>
#include <QDomText>
#include <QDomNamedNodeMap>
#include <QDomAttr>
#include <QDomEntity>
#include <QDomEntityReference>
#include "KJ135WBJYAlgWidgetComponet.h" // 算法组件参数界面组件类
// 算法组件参数xml项
class WBFZAlgComponetXmlParamenterItem
{
public:
WBFZAlgComponetXmlParamenterItem(QDomElement* itemparameter);
~WBFZAlgComponetXmlParamenterItem();
void setName(const QString& name);
void setValue(const QString& value);
QString getName() const;
QString getValue() const;
QString WriteXml() const;
private:
QString name; // 参数名称
QString value;// 参数值
QString Datatype;// 参数类型
QString ParaType;// 参数类型
QDomElement* itemparameter;
};
// 算法组件xml参数解析主类
class WBFZAlgComponetXmlParaseOperator
{
public:
WBFZAlgComponetXmlParaseOperator();
~WBFZAlgComponetXmlParaseOperator();
void loadXmlFile(const QString& fileName);
private:
void parseXmlFile();
void displayParsedData();
private:
QString workSpacePath;
private:// 参数文件结构
};
#endif// __WBFZAlgComponetXmlParaseOperator_H__