2025-05-08 15:00:13 +00:00
|
|
|
|
#include "WBFZAlgComponetXmlParaseOperator.h"
|
2025-05-09 07:25:29 +00:00
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem::WBFZAlgComponetXmlParamenterItem(QDomElement* itemparameter, QObject* parent) :QObject(parent)
|
|
|
|
|
{
|
|
|
|
|
if (nullptr == itemparameter) {
|
|
|
|
|
qDebug() << "itemparameter is nullptr.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-05-10 18:34:49 +00:00
|
|
|
|
|
|
|
|
|
this->ParaName = itemparameter->firstChildElement("ParaName").isNull() ? QString() : itemparameter->firstChildElement("ParaName").text();
|
|
|
|
|
this->ParaChsName = itemparameter->firstChildElement("ParaChsName").isNull() ? QString() : itemparameter->firstChildElement("ParaChsName").text();
|
|
|
|
|
this->Description = itemparameter->firstChildElement("Description").isNull() ? QString() : itemparameter->firstChildElement("Description").text();
|
|
|
|
|
this->Datatype = itemparameter->firstChildElement("DataType").isNull() ? QString() : itemparameter->firstChildElement("DataType").text();
|
|
|
|
|
this->ParaType = itemparameter->firstChildElement("ParaType").isNull() ? QString() : itemparameter->firstChildElement("ParaType").text();
|
|
|
|
|
this->ValueStr = itemparameter->firstChildElement("ParaValue").isNull() ? QString() : itemparameter->firstChildElement("ParaValue").text();
|
2025-05-09 07:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem::~WBFZAlgComponetXmlParamenterItem()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParaseOperator::WBFZAlgComponetXmlParaseOperator(QObject* parent) :QObject(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WBFZAlgComponetXmlParaseOperator::~WBFZAlgComponetXmlParaseOperator()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::loadXmlFile(const QString& fileName)
|
|
|
|
|
{
|
|
|
|
|
this->xmlFilePath = fileName;
|
|
|
|
|
this->parseXmlFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::parseXmlFile()
|
|
|
|
|
{
|
|
|
|
|
// 1. Load the XML file
|
|
|
|
|
QFile file(xmlFilePath);
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
|
|
|
qDebug() << "Failed to open XML file.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 2. Create a QDomDocument object
|
|
|
|
|
QDomDocument doc;
|
|
|
|
|
if (!doc.setContent(&file)) {
|
|
|
|
|
qDebug() << "Failed to parse XML file.";
|
|
|
|
|
file.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 3. Close the file
|
|
|
|
|
file.close();
|
|
|
|
|
// 4. Get the root element
|
|
|
|
|
QDomElement root = doc.documentElement();
|
|
|
|
|
// 5. Get the child elements of the root
|
|
|
|
|
QDomNodeList childNodes = root.childNodes();
|
|
|
|
|
// 6. get the workspace path node
|
2025-05-10 18:34:49 +00:00
|
|
|
|
QDomNodeList workspacePathNodes = root.elementsByTagName("WorkSpace");
|
2025-05-09 07:25:29 +00:00
|
|
|
|
if (workspacePathNodes.count() > 0) {
|
|
|
|
|
QDomElement workspacePathElement = workspacePathNodes.at(0).toElement();
|
|
|
|
|
this->workSpacePath = workspacePathElement.text();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
qDebug() << "WorkspacePath not found.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 7. get Root/AlgCompt/Inputs <20>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>Parameter<65>ӽڵ<D3BD>
|
2025-05-10 18:34:49 +00:00
|
|
|
|
QDomNodeList InputsNodes = root.elementsByTagName("Inputs");
|
|
|
|
|
QDomNodeList parameterNodes = InputsNodes.at(0).toElement().elementsByTagName("Parameter");
|
2025-05-09 07:25:29 +00:00
|
|
|
|
if (parameterNodes.count() > 0) {
|
|
|
|
|
for (int i = 0; i < parameterNodes.count(); ++i) {
|
|
|
|
|
QDomElement parameterElement = parameterNodes.at(i).toElement();
|
|
|
|
|
WBFZAlgComponetXmlParamenterItem* item = new WBFZAlgComponetXmlParamenterItem(¶meterElement,this);
|
|
|
|
|
this->ParameterList.append(item);
|
2025-05-10 18:34:49 +00:00
|
|
|
|
qDebug() << "read Parameter Name:" << item->getParaName();
|
|
|
|
|
if (item->getParaName().isEmpty()) {
|
|
|
|
|
QMessageBox::warning(nullptr, u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", u8"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>xml<6D>ļ<EFBFBD><C4BC><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
|
|
|
|
|
qDebug() << "read Parameter Name Error:" << item->getParaName();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-05-09 07:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
qDebug() << "Parameter not found.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParaseOperator::displayParsedData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-10 18:34:49 +00:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-09 07:25:29 +00:00
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaName() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaName(const QString& name)
|
|
|
|
|
{
|
|
|
|
|
this->ParaName = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaChsName() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaChsName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaChsName(const QString& name)
|
|
|
|
|
{
|
|
|
|
|
this->ParaChsName = name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getDescription() const
|
|
|
|
|
{
|
2025-05-10 18:34:49 +00:00
|
|
|
|
return this->Description;
|
2025-05-09 07:25:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setDescription(const QString& description)
|
|
|
|
|
{
|
|
|
|
|
this->Description = description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getDatatype() const
|
|
|
|
|
{
|
|
|
|
|
return this->Datatype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setDatatype(const QString& datatype)
|
|
|
|
|
{
|
|
|
|
|
this->Datatype = datatype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getParaType() const
|
|
|
|
|
{
|
|
|
|
|
return this->ParaType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setParaType(const QString& type)
|
|
|
|
|
{
|
|
|
|
|
this->ParaType = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString WBFZAlgComponetXmlParamenterItem::getValueStr() const
|
|
|
|
|
{
|
|
|
|
|
return this->ValueStr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WBFZAlgComponetXmlParamenterItem::setValueStr(const QString& value)
|
|
|
|
|
{
|
|
|
|
|
this->ValueStr = value;
|
|
|
|
|
}
|