结构数据整合
This commit is contained in:
parent
ef35bc62d6
commit
6e7894bd64
|
@ -10,8 +10,9 @@
|
||||||
#include "WindowLogData.h"
|
#include "WindowLogData.h"
|
||||||
#include "DataContainer/DataBlock.h"
|
#include "DataContainer/DataBlock.h"
|
||||||
#include "DataContainer/StabCalculationData.h"
|
#include "DataContainer/StabCalculationData.h"
|
||||||
|
#include "DataContainer/StructureCalculationData.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "StrengthSet.hxx"
|
// #include "StrengthSet.hxx"
|
||||||
#include "TonnageModelDS.hxx"
|
#include "TonnageModelDS.hxx"
|
||||||
#include "EEDIModelDS.hxx"
|
#include "EEDIModelDS.hxx"
|
||||||
#include "XLSXDataManager.h"
|
#include "XLSXDataManager.h"
|
||||||
|
@ -423,11 +424,13 @@ extern "C"
|
||||||
|
|
||||||
StabCalculationData m_StabCalData;
|
StabCalculationData m_StabCalData;
|
||||||
|
|
||||||
StructureCalDataBlock *m_StructureCal = nullptr;
|
StructureCalculationData m_StructureCalData;
|
||||||
|
|
||||||
|
// StructureCalDataBlock *m_StructureCal = nullptr;
|
||||||
|
|
||||||
CertifyCalDataBlock *m_CertifyCal = nullptr;
|
CertifyCalDataBlock *m_CertifyCal = nullptr;
|
||||||
|
|
||||||
std::unique_ptr<::strength_set::StrengthSet> m_StrengthSet;
|
// std::unique_ptr<::strength_set::StrengthSet> m_StrengthSet;
|
||||||
|
|
||||||
std::unique_ptr<::tonnagemodel_ds::TonnageModelDS> m_TonnageModelDS;
|
std::unique_ptr<::tonnagemodel_ds::TonnageModelDS> m_TonnageModelDS;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
struct DataRowInf : public QObject
|
struct DataRowInf : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -77,29 +76,20 @@ public:
|
||||||
|
|
||||||
virtual QString DataBlockName() { return "DataBlockName"; };
|
virtual QString DataBlockName() { return "DataBlockName"; };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void clear()
|
virtual void clear()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void toXml(pugi::xml_node xRoot)
|
virtual void toXml(pugi::xml_node xRoot)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void fromXml(const pugi::xml_node xml)
|
virtual void fromXml(const pugi::xml_node xml)
|
||||||
{
|
{
|
||||||
if (xml.empty())
|
if (xml.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void serializeObjDic(const QMap<QString, DataRowInf *> &dic, pugi::xml_node xDic)
|
void serializeObjDic(const QMap<QString, DataRowInf *> &dic, pugi::xml_node xDic)
|
||||||
|
@ -177,34 +167,25 @@ public:
|
||||||
class StabilityCalDataBlock : public DataBlock
|
class StabilityCalDataBlock : public DataBlock
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
StabilityCalDataBlock()
|
StabilityCalDataBlock()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
~StabilityCalDataBlock()
|
~StabilityCalDataBlock()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString DataBlockName() override { return "StabilityCal"; }
|
QString DataBlockName() override { return "StabilityCal"; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void toXml(pugi::xml_node xRoot, QMap<QString, DataRowInf *> &_DataRows, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames)
|
void toXml(pugi::xml_node xRoot, QMap<QString, DataRowInf *> &_DataRows, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames)
|
||||||
{
|
{
|
||||||
pugi::xml_node xDicDataRows = xRoot.append_child("DataRows");
|
pugi::xml_node xDicDataRows = xRoot.append_child("DataRows");
|
||||||
serializeObjDic(_DataRows, xDicDataRows);
|
serializeObjDic(_DataRows, xDicDataRows);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pugi::xml_node xDic = xRoot.append_child("ChildModulus");
|
pugi::xml_node xDic = xRoot.append_child("ChildModulus");
|
||||||
for (auto it = _childModuleNames.begin(); it != _childModuleNames.end(); ++it)
|
for (auto it = _childModuleNames.begin(); it != _childModuleNames.end(); ++it)
|
||||||
{
|
{
|
||||||
|
@ -219,15 +200,10 @@ public:
|
||||||
pugi::xml_node xo = xDic.append_child(o->ID().toStdString().c_str());
|
pugi::xml_node xo = xDic.append_child(o->ID().toStdString().c_str());
|
||||||
serializeToXml(xo, o);
|
serializeToXml(xo, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fromXmlEx(const pugi::xml_node xml, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames, QMap<QString, DataRowInf *> &_DataRows, std::vector<std::string> &_DataRowsNames);
|
void fromXmlEx(const pugi::xml_node xml, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames, QMap<QString, DataRowInf *> &_DataRows, std::vector<std::string> &_DataRowsNames);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// QMap<QString, DataRowInf*> m_childModules;
|
// QMap<QString, DataRowInf*> m_childModules;
|
||||||
// std::vector<std::string> m_childModuleNames;
|
// std::vector<std::string> m_childModuleNames;
|
||||||
|
@ -235,6 +211,44 @@ private:
|
||||||
|
|
||||||
class StructureCalDataBlock : public DataBlock
|
class StructureCalDataBlock : public DataBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
StructureCalDataBlock()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~StructureCalDataBlock()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DataBlockName() override { return "StructureCal"; }
|
||||||
|
|
||||||
|
void clear()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void toXml(pugi::xml_node xRoot, QMap<QString, DataRowInf *> &_DataRows, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames)
|
||||||
|
{
|
||||||
|
pugi::xml_node xDicDataRows = xRoot.append_child("DataRows");
|
||||||
|
serializeObjDic(_DataRows, xDicDataRows);
|
||||||
|
|
||||||
|
pugi::xml_node xDic = xRoot.append_child("ChildModulus");
|
||||||
|
for (auto it = _childModuleNames.begin(); it != _childModuleNames.end(); ++it)
|
||||||
|
{
|
||||||
|
std::string key = *it;
|
||||||
|
|
||||||
|
DataRowInf *o = _childModules.value(QString::fromStdString(key));
|
||||||
|
if (!o)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pugi::xml_node xo = xDic.append_child(o->ID().toStdString().c_str());
|
||||||
|
serializeToXml(xo, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void fromXmlEx(const pugi::xml_node xml, QMap<QString, DataRowInf *> &_childModules, std::vector<std::string> &_childModuleNames, QMap<QString, DataRowInf *> &_DataRows, std::vector<std::string> &_DataRowsNames);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CertifyCalDataBlock : public DataBlock
|
class CertifyCalDataBlock : public DataBlock
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
#ifndef STRUCTURECALCULATIONDATA_H
|
||||||
|
#define STRUCTURECALCULATIONDATA_H
|
||||||
|
|
||||||
|
#include "../StructureCalculation/ScantlingCalculation.h"
|
||||||
|
#include "../StructureCalculation/StrengthCalculation.h"
|
||||||
|
#include <QMap>
|
||||||
|
#include "Serialization.h"
|
||||||
|
#include "DataBlock.h"
|
||||||
|
|
||||||
|
// 该类是结构计算的数据容器类,继承自Serialization
|
||||||
|
// 用于存储结构计算相关的数据,包括CXS中结构计算数据块,以及XSD表的内存映射
|
||||||
|
class StructureCalculationData : public Serialization
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StructureCalculationData()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~StructureCalculationData()
|
||||||
|
{
|
||||||
|
for (auto it = m_DataRows.begin(); it != m_DataRows.end(); ++it)
|
||||||
|
{
|
||||||
|
delete it.value();
|
||||||
|
}
|
||||||
|
m_DataRows.clear();
|
||||||
|
|
||||||
|
for (auto it = m_childModules.begin(); it != m_childModules.end(); ++it)
|
||||||
|
{
|
||||||
|
delete it.value();
|
||||||
|
}
|
||||||
|
m_childModules.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int fromXml(const pugi::xml_node node);
|
||||||
|
int toXml(pugi::xml_node node);
|
||||||
|
void saveStructureCalcData(QString path);
|
||||||
|
// void updateData()
|
||||||
|
// {
|
||||||
|
// m_CalcBaseData.updateData();
|
||||||
|
// }
|
||||||
|
|
||||||
|
std::vector<std::string> &getAnalyseNameList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString getDataRowValue(const QString &key);
|
||||||
|
void addOrUpdateDataRow(const QString &key, QString value = "", QString caption = "", QString remark = "");
|
||||||
|
bool createDataRow(const QString &key, QString value = "", QString caption = "", QString remark = "");
|
||||||
|
bool isEmpty();
|
||||||
|
bool CreateChildModulus(const QString &key, QString caption = "", QString remark = "");
|
||||||
|
|
||||||
|
private:
|
||||||
|
StructureCalDataBlock m_StructureCal; // 存储结构计算csx中xml节点值,和相关子模块
|
||||||
|
|
||||||
|
QMap<QString, DataRowInf *> m_DataRows; // CSX中DataRows节点下的所有数据
|
||||||
|
std::vector<std::string> m_ModuleNames;
|
||||||
|
|
||||||
|
QMap<QString, DataRowInf *> m_childModules; // CSX中ChildModules节点下的所有子模块数据
|
||||||
|
std::vector<std::string> m_childModuleNames;
|
||||||
|
|
||||||
|
std::unique_ptr<::strength_set::StrengthSet> m_StrengthSet; // XSD表内存映射,也是总纵强度的计算输入
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,18 @@ void StabilityCalDataBlock::fromXmlEx(const pugi::xml_node xml, QMap<QString, Da
|
||||||
deserializeObjDics(_DataRows, xml.child("DataRows"), _DataRowsNames);
|
deserializeObjDics(_DataRows, xml.child("DataRows"), _DataRowsNames);
|
||||||
|
|
||||||
|
|
||||||
|
int a = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StructureCalDataBlock::fromXmlEx(const pugi::xml_node xml, QMap<QString, DataRowInf*>& _childModules, std::vector<std::string>& _childModuleNames, QMap<QString, DataRowInf*>& _DataRows, std::vector<std::string>& _DataRowsNames)
|
||||||
|
{
|
||||||
|
if (!xml.empty())
|
||||||
|
{
|
||||||
|
deserializeObjDics(_childModules, xml.child("ChildModulus"), _childModuleNames);
|
||||||
|
deserializeObjDics(_DataRows, xml.child("DataRows"), _DataRowsNames);
|
||||||
|
|
||||||
|
|
||||||
int a = 0;
|
int a = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,187 @@
|
||||||
|
#include "DataContainer/StructureCalculationData.h"
|
||||||
|
|
||||||
|
int StructureCalculationData::fromXml(const pugi::xml_node node)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (node.empty())
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_StructureCal.fromXmlEx(node, m_childModules, m_childModuleNames, m_DataRows, m_ModuleNames);
|
||||||
|
|
||||||
|
xercesc::XMLPlatformUtils::Initialize();
|
||||||
|
::xml_schema::properties props;
|
||||||
|
|
||||||
|
std::string xml_string = "";
|
||||||
|
// 总纵强度
|
||||||
|
if (getDataRowValue("Strength") != "")
|
||||||
|
{
|
||||||
|
xml_string = getDataRowValue("Strength").toStdString();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::istringstream iss(xml_string);
|
||||||
|
m_StrengthSet = strength_set::StrengthSet_(iss, ::xml_schema::flags::dont_validate, props);
|
||||||
|
}
|
||||||
|
catch (const xsd::cxx::tree::error<char> &e)
|
||||||
|
{
|
||||||
|
std::cerr << "错误行号: " << e.line() << std::endl; // 注意是 line() 不是 line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 规范校核--TODO
|
||||||
|
if (getDataRowValue("Scantlings") != "")
|
||||||
|
{
|
||||||
|
xml_string = getDataRowValue("Scantlings").toStdString();
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// std::istringstream iss(xml_string);
|
||||||
|
// m_StrengthSet = strength_set::StrengthSet_(iss, ::xml_schema::flags::dont_validate, props);
|
||||||
|
// }
|
||||||
|
// catch (const xsd::cxx::tree::error<char> &e)
|
||||||
|
// {
|
||||||
|
// std::cerr << "错误行号: " << e.line() << std::endl; // 注意是 line() 不是 line
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
xercesc::XMLPlatformUtils::Terminate();
|
||||||
|
|
||||||
|
return EXECUTE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StructureCalculationData::saveStructureCalcData(QString path)
|
||||||
|
{
|
||||||
|
xercesc::XMLPlatformUtils::Initialize();
|
||||||
|
std::ostringstream ofs(path.toStdString());
|
||||||
|
::xml_schema::namespace_infomap ns_map;
|
||||||
|
|
||||||
|
// 总纵强度
|
||||||
|
{
|
||||||
|
ns_map[""].name = "http://tempuri.org/StrengthSet.xsd";
|
||||||
|
|
||||||
|
// 使用全局命名空间下的 flags
|
||||||
|
strength_set::StrengthSet_(ofs, *m_StrengthSet, ns_map, "UTF-8", ::xml_schema::flags::no_xml_declaration); // format_pretty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 规范校核
|
||||||
|
{
|
||||||
|
ns_map[""].name = "http://tempuri.org/ScantlingSet.xsd";
|
||||||
|
|
||||||
|
// 使用全局命名空间下的 flags
|
||||||
|
// scantling_set::ScantlingSet_(ofs, *m_ScantlingsSet, ns_map, "UTF-8", ::xml_schema::flags::no_xml_declaration); // format_pretty);
|
||||||
|
|
||||||
|
// xercesc::XMLPlatformUtils::Terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
xercesc::XMLPlatformUtils::Terminate();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> &StructureCalculationData::getAnalyseNameList()
|
||||||
|
{
|
||||||
|
return m_childModuleNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
int StructureCalculationData::toXml(pugi::xml_node node)
|
||||||
|
{
|
||||||
|
xercesc::XMLPlatformUtils::Initialize();
|
||||||
|
std::ostringstream ofs("temp.xml");
|
||||||
|
::xml_schema::namespace_infomap ns_map;
|
||||||
|
|
||||||
|
// 总纵强度
|
||||||
|
{
|
||||||
|
ns_map[""].name = "http://tempuri.org/StrengthSet.xsd";
|
||||||
|
|
||||||
|
// 使用全局命名空间下的 flags
|
||||||
|
std::string strValue = strength_set::StrengthSet_(ofs, *m_StrengthSet, ns_map, "UTF-8", ::xml_schema::flags::no_xml_declaration); // format_pretty);
|
||||||
|
|
||||||
|
addOrUpdateDataRow("Structure", QString::fromStdString(strValue));
|
||||||
|
m_StructureCal.toXml(node, m_DataRows, m_childModules, m_childModuleNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 规范校核
|
||||||
|
{
|
||||||
|
ns_map[""].name = "http://tempuri.org/ScantlingSet.xsd";
|
||||||
|
|
||||||
|
// 使用全局命名空间下的 flags
|
||||||
|
// std::string strValue = scantling_set::ScantlingSet_(ofs, *m_ScantlingsSet, ns_map, "UTF-8", ::xml_schema::flags::no_xml_declaration); // format_pretty);
|
||||||
|
|
||||||
|
// addOrUpdateDataRow("Scantlings", QString::fromStdString(strValue));
|
||||||
|
// m_StructureCal.toXml(node, m_DataRows, m_childModules, m_childModuleNames);
|
||||||
|
}
|
||||||
|
xercesc::XMLPlatformUtils::Terminate();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StructureCalculationData::isEmpty()
|
||||||
|
{
|
||||||
|
if (m_DataRows.size() > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StructureCalculationData::getDataRowValue(const QString &key)
|
||||||
|
{
|
||||||
|
if (!m_DataRows.contains(key))
|
||||||
|
return "";
|
||||||
|
QString dd = m_DataRows[key]->Value();
|
||||||
|
return dd;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StructureCalculationData::addOrUpdateDataRow(const QString &key, QString value, QString caption, QString remark)
|
||||||
|
{
|
||||||
|
if (key.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_DataRows.contains(key))
|
||||||
|
{
|
||||||
|
DataRowInf *o = new DataRowInf();
|
||||||
|
o->setID(key);
|
||||||
|
o->setCaption(caption);
|
||||||
|
o->setRemark(remark);
|
||||||
|
o->setValue(value);
|
||||||
|
m_DataRows.insert(key, o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DataRowInf *o = m_DataRows.value(key);
|
||||||
|
o->setCaption(caption);
|
||||||
|
o->setRemark(remark);
|
||||||
|
o->setValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StructureCalculationData::createDataRow(const QString &key, QString value, QString caption, QString remark)
|
||||||
|
{
|
||||||
|
if (!m_DataRows.contains(key))
|
||||||
|
{
|
||||||
|
DataRowInf *o = new DataRowInf();
|
||||||
|
o->setID(key);
|
||||||
|
o->setCaption(caption);
|
||||||
|
o->setRemark(remark);
|
||||||
|
o->setValue(value);
|
||||||
|
m_DataRows.insert(key, o);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StructureCalculationData::CreateChildModulus(const QString &key, QString caption, QString remark)
|
||||||
|
{
|
||||||
|
if (!m_childModules.contains(key))
|
||||||
|
{
|
||||||
|
DataRowInf *o = new DataRowInf();
|
||||||
|
o->setID(key);
|
||||||
|
o->setCaption(caption);
|
||||||
|
o->setRemark(remark);
|
||||||
|
o->setValue("");
|
||||||
|
m_childModules.insert(key, o);
|
||||||
|
m_childModuleNames.push_back(key.toStdString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
Loading…
Reference in New Issue