结构数据整合
This commit is contained in:
parent
ef35bc62d6
commit
6e7894bd64
|
@ -10,8 +10,9 @@
|
|||
#include "WindowLogData.h"
|
||||
#include "DataContainer/DataBlock.h"
|
||||
#include "DataContainer/StabCalculationData.h"
|
||||
#include "DataContainer/StructureCalculationData.h"
|
||||
#include <QFileInfo>
|
||||
#include "StrengthSet.hxx"
|
||||
// #include "StrengthSet.hxx"
|
||||
#include "TonnageModelDS.hxx"
|
||||
#include "EEDIModelDS.hxx"
|
||||
#include "XLSXDataManager.h"
|
||||
|
@ -423,11 +424,13 @@ extern "C"
|
|||
|
||||
StabCalculationData m_StabCalData;
|
||||
|
||||
StructureCalDataBlock *m_StructureCal = nullptr;
|
||||
StructureCalculationData m_StructureCalData;
|
||||
|
||||
// StructureCalDataBlock *m_StructureCal = 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;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//解析各模块计算数据 到内存中
|
||||
// 解析各模块计算数据 到内存中
|
||||
|
||||
#ifndef DATABLOCK_H
|
||||
#define DATABLOCK_H
|
||||
|
@ -11,7 +11,6 @@
|
|||
#include <QDebug>
|
||||
#include <string>
|
||||
|
||||
|
||||
struct DataRowInf : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -77,29 +76,20 @@ public:
|
|||
|
||||
virtual QString DataBlockName() { return "DataBlockName"; };
|
||||
|
||||
|
||||
|
||||
virtual void clear()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void toXml(pugi::xml_node xRoot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void fromXml(const pugi::xml_node xml)
|
||||
{
|
||||
if (xml.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void serializeObjDic(const QMap<QString, DataRowInf *> &dic, pugi::xml_node xDic)
|
||||
|
@ -177,40 +167,31 @@ public:
|
|||
class StabilityCalDataBlock : public DataBlock
|
||||
{
|
||||
public:
|
||||
|
||||
StabilityCalDataBlock()
|
||||
{
|
||||
|
||||
}
|
||||
~StabilityCalDataBlock()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
QString DataBlockName() override { return "StabilityCal"; }
|
||||
|
||||
|
||||
|
||||
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");
|
||||
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));
|
||||
DataRowInf *o = _childModules.value(QString::fromStdString(key));
|
||||
if (!o)
|
||||
{
|
||||
continue;
|
||||
|
@ -219,25 +200,58 @@ public:
|
|||
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) ;
|
||||
|
||||
|
||||
|
||||
|
||||
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:
|
||||
//QMap<QString, DataRowInf*> m_childModules;
|
||||
//std::vector<std::string> m_childModuleNames;
|
||||
// QMap<QString, DataRowInf*> m_childModules;
|
||||
// std::vector<std::string> m_childModuleNames;
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
};
|
||||
#endif
|
|
@ -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);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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