From 6e7894bd6465b4ac4a2a1298dbdf6cf44d758a43 Mon Sep 17 00:00:00 2001 From: zyuan Date: Fri, 27 Jun 2025 17:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E6=9E=84=E6=95=B0=E6=8D=AE=E6=95=B4?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/DataManager.h | 9 +- .../DataContainer/DataBlock.h | 84 +- .../DataContainer/StructureCalculationData.h | 62 ++ .../DataManagerInterface/src/DataManager.cpp | 880 +++++++++--------- .../DataContainer/DataBlock.cpp | 12 + .../StructureCalculationData.cpp | 187 ++++ 6 files changed, 755 insertions(+), 479 deletions(-) create mode 100644 trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.h create mode 100644 trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.cpp diff --git a/trunk/code/inc/DataManager/DataManagerInterface/include/DataManager.h b/trunk/code/inc/DataManager/DataManagerInterface/include/DataManager.h index 6ea7bdd..aa5cd2e 100644 --- a/trunk/code/inc/DataManager/DataManagerInterface/include/DataManager.h +++ b/trunk/code/inc/DataManager/DataManagerInterface/include/DataManager.h @@ -10,8 +10,9 @@ #include "WindowLogData.h" #include "DataContainer/DataBlock.h" #include "DataContainer/StabCalculationData.h" +#include "DataContainer/StructureCalculationData.h" #include -#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; diff --git a/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/DataBlock.h b/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/DataBlock.h index d47096e..e0bdbf5 100644 --- a/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/DataBlock.h +++ b/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/DataBlock.h @@ -1,4 +1,4 @@ -//解析各模块计算数据 到内存中 +// 解析各模块计算数据 到内存中 #ifndef DATABLOCK_H #define DATABLOCK_H @@ -11,7 +11,6 @@ #include #include - struct DataRowInf : public QObject { Q_OBJECT @@ -67,39 +66,30 @@ private: class DataBlock { public: - DataBlock(/* args */) + DataBlock(/* args */) { } - virtual ~DataBlock() + virtual ~DataBlock() { clear(); } 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 &dic, pugi::xml_node xDic) @@ -162,7 +152,7 @@ public: { QString name = xe.attribute("Name").value(); QString value = xe.attribute("Value").value(); - + bool ret = o->setProperty(name.toUtf8().constData(), value); } return o; @@ -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& _DataRows, QMap& _childModules, std::vector& _childModuleNames) + void toXml(pugi::xml_node xRoot, QMap &_DataRows, QMap &_childModules, std::vector &_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& _childModules, std::vector& _childModuleNames, QMap& _DataRows, std::vector& _DataRowsNames) ; - - - - + void fromXmlEx(const pugi::xml_node xml, QMap &_childModules, std::vector &_childModuleNames, QMap &_DataRows, std::vector &_DataRowsNames); private: - //QMap m_childModules; - //std::vector m_childModuleNames; + // QMap m_childModules; + // std::vector 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 &_DataRows, QMap &_childModules, std::vector &_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 &_childModules, std::vector &_childModuleNames, QMap &_DataRows, std::vector &_DataRowsNames); }; -class CertifyCalDataBlock: public DataBlock +class CertifyCalDataBlock : public DataBlock { }; #endif \ No newline at end of file diff --git a/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.h b/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.h new file mode 100644 index 0000000..b29ccc4 --- /dev/null +++ b/trunk/code/inc/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.h @@ -0,0 +1,62 @@ +#ifndef STRUCTURECALCULATIONDATA_H +#define STRUCTURECALCULATIONDATA_H + +#include "../StructureCalculation/ScantlingCalculation.h" +#include "../StructureCalculation/StrengthCalculation.h" +#include +#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 &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 m_DataRows; // CSX中DataRows节点下的所有数据 + std::vector m_ModuleNames; + + QMap m_childModules; // CSX中ChildModules节点下的所有子模块数据 + std::vector m_childModuleNames; + + std::unique_ptr<::strength_set::StrengthSet> m_StrengthSet; // XSD表内存映射,也是总纵强度的计算输入 +}; + +#endif \ No newline at end of file diff --git a/trunk/code/projects/DataManager/DataManagerInterface/src/DataManager.cpp b/trunk/code/projects/DataManager/DataManagerInterface/src/DataManager.cpp index 8e860e8..bb9c84b 100644 --- a/trunk/code/projects/DataManager/DataManagerInterface/src/DataManager.cpp +++ b/trunk/code/projects/DataManager/DataManagerInterface/src/DataManager.cpp @@ -68,7 +68,6 @@ DataManager::DataManager() auto log_t = get_shared_logger(); spdlog::set_default_logger(log_t); // 设置为默认 logger - m_StructureCal = new StructureCalDataBlock(); m_CertifyCal = new CertifyCalDataBlock(); XmlSerialization::getXmlSerializationInstance(); @@ -77,7 +76,6 @@ DataManager::DataManager() DataManager::~DataManager() { - DELETE_PTR(m_StructureCal); DELETE_PTR(m_CertifyCal); LOG_DEBUG("DataManager Destroyed"); } @@ -146,7 +144,7 @@ void DataManager::readFile(XMLFile_Type type, const QString &filePath) // 结构计算 { - m_StructureCal->fromXml(root.child("StructureCal")); + // m_StructureCal->fromXml(root.child("StructureCal")); } ///CertifyCal @@ -1535,307 +1533,307 @@ void DataManager::structure_model_editor_check(int &errorCode, QString &outMsg, void DataManager::structure_model_editor_save(int &errorCode, QString &outMsg, QString &data, const QString &message) { - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); - // 总纵强度 or 规范校核? 默认:总纵强度 - QString cal_option = "Strength"; + // // 总纵强度 or 规范校核? 默认:总纵强度 + // QString cal_option = "Strength"; - nlohmann::json j = json::parse(message.toStdString()); + // nlohmann::json j = json::parse(message.toStdString()); - std::string key_str; // 计算模型名称 - nlohmann::json value_j; - for (const auto &[key, value] : j.items()) - { - key_str = key; - value_j = value; - break; - } + // std::string key_str; // 计算模型名称 + // nlohmann::json value_j; + // for (const auto &[key, value] : j.items()) + // { + // key_str = key; + // value_j = value; + // break; + // } - try - { - if (key_str == "patp") - { - structure_patp_editor_save(value_j); - // for (const auto &j_item : value_j["close_room"]) - // { + // try + // { + // if (key_str == "patp") + // { + // structure_patp_editor_save(value_j); + // // for (const auto &j_item : value_j["close_room"]) + // // { - // bool isFound = false; - // strength_set::SecCloseroom obj_web = strength_set::JsonSecCloseroom::from_json(j_item); + // // bool isFound = false; + // // strength_set::SecCloseroom obj_web = strength_set::JsonSecCloseroom::from_json(j_item); - // // 查询 - // for (auto &obj : m_StrengthSet->SecCloseroom()) - // { - // if (j_item["LinkList"].get() == obj.LinkList()) - // { - // // 赋值 - // // - // obj = obj_web; - // isFound = true; - // break; - // } - // } + // // // 查询 + // // for (auto &obj : m_StrengthSet->SecCloseroom()) + // // { + // // if (j_item["LinkList"].get() == obj.LinkList()) + // // { + // // // 赋值 + // // // + // // obj = obj_web; + // // isFound = true; + // // break; + // // } + // // } - // // 未查询到,插入 - // if (!isFound) - // { - // m_StrengthSet->SecCloseroom().push_back(obj_web); - // } - // } - } - if (key_str == "strength") - { - structure_strength_editor_save(value_j); - } - if (key_str == "twbg") - { - structure_twbg_editor_save(value_j); - } - if (key_str == "zcmt") - { - structure_zcmt_editor_save(value_j); - } - if (key_str == "cprt") - { - structure_cprt_editor_save(value_j); - } - if (key_str == "section") - { - structure_section_editor_save(value_j); - } - if (key_str == "scantlings") - { - structure_scantlings_editor_save(value_j); - cal_option = "Scantlings"; - } - } - catch (const std::exception &e) - { - std::cerr << e.what() << '\n'; - } + // // // 未查询到,插入 + // // if (!isFound) + // // { + // // m_StrengthSet->SecCloseroom().push_back(obj_web); + // // } + // // } + // } + // if (key_str == "strength") + // { + // structure_strength_editor_save(value_j); + // } + // if (key_str == "twbg") + // { + // structure_twbg_editor_save(value_j); + // } + // if (key_str == "zcmt") + // { + // structure_zcmt_editor_save(value_j); + // } + // if (key_str == "cprt") + // { + // structure_cprt_editor_save(value_j); + // } + // if (key_str == "section") + // { + // structure_section_editor_save(value_j); + // } + // if (key_str == "scantlings") + // { + // structure_scantlings_editor_save(value_j); + // cal_option = "Scantlings"; + // } + // } + // catch (const std::exception &e) + // { + // std::cerr << e.what() << '\n'; + // } - //保存文件 - xercesc::XMLPlatformUtils::Initialize(); - std::ostringstream ofs("testStructureModel.xml"); - ::xml_schema::namespace_infomap ns_map; - ns_map[""].name = "http://tempuri.org/StrengthSet.xsd"; + // //保存文件 + // xercesc::XMLPlatformUtils::Initialize(); + // std::ostringstream ofs("testStructureModel.xml"); + // ::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); + // // 使用全局命名空间下的 flags + // strength_set::StrengthSet_(ofs, *m_StrengthSet, ns_map, "UTF-8", ::xml_schema::flags::no_xml_declaration); // format_pretty); - xercesc::XMLPlatformUtils::Terminate(); + // xercesc::XMLPlatformUtils::Terminate(); - // m_StructureCal->addOrUpdateDataRow(cal_option, QString::fromStdString(ofs.str())); + // // m_StructureCal->addOrUpdateDataRow(cal_option, QString::fromStdString(ofs.str())); } void DataManager::structure_strength_editor_save(const json &value_j) { - m_StrengthSet->Pub().clear(); - for (const auto &j_item : value_j["pub"]) - { - strength_set::Pub new_obj = strength_set::JsonPub::from_json(j_item); - m_StrengthSet->Pub().push_back(new_obj); - } + // m_StrengthSet->Pub().clear(); + // for (const auto &j_item : value_j["pub"]) + // { + // strength_set::Pub new_obj = strength_set::JsonPub::from_json(j_item); + // m_StrengthSet->Pub().push_back(new_obj); + // } } void DataManager::structure_patp_editor_save(const json &value_j) { - m_StrengthSet->Attach().clear(); - for (const auto &j_item : value_j["attach"]) - { - strength_set::Attach new_obj = strength_set::JsonAttach::from_json(j_item); - m_StrengthSet->Attach().push_back(new_obj); - } + // m_StrengthSet->Attach().clear(); + // for (const auto &j_item : value_j["attach"]) + // { + // strength_set::Attach new_obj = strength_set::JsonAttach::from_json(j_item); + // m_StrengthSet->Attach().push_back(new_obj); + // } - m_StrengthSet->Subgirder().clear(); - for (const auto &j_item : value_j["elem"]) - { - strength_set::Subgirder new_obj = strength_set::JsonSubgirder::from_json(j_item); - m_StrengthSet->Subgirder().push_back(new_obj); - } + // m_StrengthSet->Subgirder().clear(); + // for (const auto &j_item : value_j["elem"]) + // { + // strength_set::Subgirder new_obj = strength_set::JsonSubgirder::from_json(j_item); + // m_StrengthSet->Subgirder().push_back(new_obj); + // } - m_StrengthSet->Girder().clear(); - for (const auto &j_item : value_j["girder"]) - { - strength_set::Girder new_obj = strength_set::JsonGirder::from_json(j_item); - m_StrengthSet->Girder().push_back(new_obj); - } + // m_StrengthSet->Girder().clear(); + // for (const auto &j_item : value_j["girder"]) + // { + // strength_set::Girder new_obj = strength_set::JsonGirder::from_json(j_item); + // m_StrengthSet->Girder().push_back(new_obj); + // } - m_StrengthSet->Mat().clear(); - for (const auto &j_item : value_j["mat"]) - { - strength_set::Mat new_obj = strength_set::JsonMat::from_json(j_item); - m_StrengthSet->Mat().push_back(new_obj); - } + // m_StrengthSet->Mat().clear(); + // for (const auto &j_item : value_j["mat"]) + // { + // strength_set::Mat new_obj = strength_set::JsonMat::from_json(j_item); + // m_StrengthSet->Mat().push_back(new_obj); + // } - m_StrengthSet->Subnode().clear(); - for (const auto &j_item : value_j["node"]) - { - strength_set::Subnode new_obj = strength_set::JsonSubnode::from_json(j_item); - m_StrengthSet->Subnode().push_back(new_obj); - } + // m_StrengthSet->Subnode().clear(); + // for (const auto &j_item : value_j["node"]) + // { + // strength_set::Subnode new_obj = strength_set::JsonSubnode::from_json(j_item); + // m_StrengthSet->Subnode().push_back(new_obj); + // } } void DataManager::structure_twbg_editor_save(const json &value_j) { - m_StrengthSet->SecCloseroom().clear(); - for (const auto &j_item : value_j["close_room"]) - { - strength_set::SecCloseroom new_obj = strength_set::JsonSecCloseroom::from_json(j_item); - m_StrengthSet->SecCloseroom().push_back(new_obj); - } + // m_StrengthSet->SecCloseroom().clear(); + // for (const auto &j_item : value_j["close_room"]) + // { + // strength_set::SecCloseroom new_obj = strength_set::JsonSecCloseroom::from_json(j_item); + // m_StrengthSet->SecCloseroom().push_back(new_obj); + // } - m_StrengthSet->SecPlate().clear(); - for (const auto &j_item : value_j["elem"]) - { - strength_set::SecPlate new_obj = strength_set::JsonSecPlate::from_json(j_item); - m_StrengthSet->SecPlate().push_back(new_obj); - } + // m_StrengthSet->SecPlate().clear(); + // for (const auto &j_item : value_j["elem"]) + // { + // strength_set::SecPlate new_obj = strength_set::JsonSecPlate::from_json(j_item); + // m_StrengthSet->SecPlate().push_back(new_obj); + // } - m_StrengthSet->SecShell().clear(); - for (const auto &j_item : value_j["mutual_elem"]) - { - strength_set::SecShell new_obj = strength_set::JsonSecShell::from_json(j_item); - m_StrengthSet->SecShell().push_back(new_obj); - } + // m_StrengthSet->SecShell().clear(); + // for (const auto &j_item : value_j["mutual_elem"]) + // { + // strength_set::SecShell new_obj = strength_set::JsonSecShell::from_json(j_item); + // m_StrengthSet->SecShell().push_back(new_obj); + // } - m_StrengthSet->SecNode().clear(); - for (const auto &j_item : value_j["node"]) - { - strength_set::SecNode new_obj = strength_set::JsonSecNode::from_json(j_item); - m_StrengthSet->SecNode().push_back(new_obj); - } + // m_StrengthSet->SecNode().clear(); + // for (const auto &j_item : value_j["node"]) + // { + // strength_set::SecNode new_obj = strength_set::JsonSecNode::from_json(j_item); + // m_StrengthSet->SecNode().push_back(new_obj); + // } - m_StrengthSet->Section().clear(); - for (const auto &j_item : value_j["section"]) - { - strength_set::Section new_obj = strength_set::JsonSection::from_json(j_item); - m_StrengthSet->Section().push_back(new_obj); - } + // m_StrengthSet->Section().clear(); + // for (const auto &j_item : value_j["section"]) + // { + // strength_set::Section new_obj = strength_set::JsonSection::from_json(j_item); + // m_StrengthSet->Section().push_back(new_obj); + // } } void DataManager::structure_zcmt_editor_save(const json &value_j) { - m_StrengthSet->Bonjean().clear(); - for (const auto &j_item : value_j["bonjean"]) - { - strength_set::Bonjean new_obj = strength_set::JsonBonjean::from_json(j_item); - m_StrengthSet->Bonjean().push_back(new_obj); - } + // m_StrengthSet->Bonjean().clear(); + // for (const auto &j_item : value_j["bonjean"]) + // { + // strength_set::Bonjean new_obj = strength_set::JsonBonjean::from_json(j_item); + // m_StrengthSet->Bonjean().push_back(new_obj); + // } - m_StrengthSet->Pub().clear(); - for (const auto &j_item : value_j["pub"]) - { - strength_set::Pub new_obj = strength_set::JsonPub::from_json(j_item); - m_StrengthSet->Pub().push_back(new_obj); - } + // m_StrengthSet->Pub().clear(); + // for (const auto &j_item : value_j["pub"]) + // { + // strength_set::Pub new_obj = strength_set::JsonPub::from_json(j_item); + // m_StrengthSet->Pub().push_back(new_obj); + // } - m_StrengthSet->WL().clear(); - for (const auto &j_item : value_j["wl"]) - { - strength_set::WL new_obj = strength_set::JsonWL::from_json(j_item); - m_StrengthSet->WL().push_back(new_obj); - } + // m_StrengthSet->WL().clear(); + // for (const auto &j_item : value_j["wl"]) + // { + // strength_set::WL new_obj = strength_set::JsonWL::from_json(j_item); + // m_StrengthSet->WL().push_back(new_obj); + // } - m_StrengthSet->KL().clear(); - for (const auto &j_item : value_j["kl"]) - { - strength_set::KL new_obj = strength_set::JsonKL::from_json(j_item); - m_StrengthSet->KL().push_back(new_obj); - } + // m_StrengthSet->KL().clear(); + // for (const auto &j_item : value_j["kl"]) + // { + // strength_set::KL new_obj = strength_set::JsonKL::from_json(j_item); + // m_StrengthSet->KL().push_back(new_obj); + // } - m_StrengthSet->LoadCase().clear(); - for (const auto &j_item : value_j["load_case"]) - { - strength_set::LoadCase new_obj = strength_set::JsonLoadCase::from_json(j_item); - m_StrengthSet->LoadCase().push_back(new_obj); - } + // m_StrengthSet->LoadCase().clear(); + // for (const auto &j_item : value_j["load_case"]) + // { + // strength_set::LoadCase new_obj = strength_set::JsonLoadCase::from_json(j_item); + // m_StrengthSet->LoadCase().push_back(new_obj); + // } - m_StrengthSet->Offset().clear(); - for (const auto &j_item : value_j["offset"]) - { - strength_set::Offset new_obj = strength_set::JsonOffset::from_json(j_item); - m_StrengthSet->Offset().push_back(new_obj); - } + // m_StrengthSet->Offset().clear(); + // for (const auto &j_item : value_j["offset"]) + // { + // strength_set::Offset new_obj = strength_set::JsonOffset::from_json(j_item); + // m_StrengthSet->Offset().push_back(new_obj); + // } - m_StrengthSet->StWeight().clear(); - for (const auto &j_item : value_j["st_weight"]) - { - strength_set::StWeight new_obj = strength_set::JsonStWeight::from_json(j_item); - m_StrengthSet->StWeight().push_back(new_obj); - } + // m_StrengthSet->StWeight().clear(); + // for (const auto &j_item : value_j["st_weight"]) + // { + // strength_set::StWeight new_obj = strength_set::JsonStWeight::from_json(j_item); + // m_StrengthSet->StWeight().push_back(new_obj); + // } - m_StrengthSet->ItemWeight().clear(); - for (const auto &j_item : value_j["case_item_weight"]) - { - strength_set::ItemWeight new_obj = strength_set::JsonItemWeight::from_json(j_item); - m_StrengthSet->ItemWeight().push_back(new_obj); - } + // m_StrengthSet->ItemWeight().clear(); + // for (const auto &j_item : value_j["case_item_weight"]) + // { + // strength_set::ItemWeight new_obj = strength_set::JsonItemWeight::from_json(j_item); + // m_StrengthSet->ItemWeight().push_back(new_obj); + // } - m_StrengthSet->MTC().clear(); - for (const auto &j_item : value_j["mtc"]) - { - strength_set::MTC new_obj = strength_set::JsonMTC::from_json(j_item); - m_StrengthSet->MTC().push_back(new_obj); - } + // m_StrengthSet->MTC().clear(); + // for (const auto &j_item : value_j["mtc"]) + // { + // strength_set::MTC new_obj = strength_set::JsonMTC::from_json(j_item); + // m_StrengthSet->MTC().push_back(new_obj); + // } - m_StrengthSet->LiftedCargo().clear(); - for (const auto &j_item : value_j["lifted_cargo"]) - { - strength_set::LiftedCargo new_obj = strength_set::JsonLiftedCargo::from_json(j_item); - m_StrengthSet->LiftedCargo().push_back(new_obj); - } + // m_StrengthSet->LiftedCargo().clear(); + // for (const auto &j_item : value_j["lifted_cargo"]) + // { + // strength_set::LiftedCargo new_obj = strength_set::JsonLiftedCargo::from_json(j_item); + // m_StrengthSet->LiftedCargo().push_back(new_obj); + // } - m_StrengthSet->StaticLoad().clear(); - for (const auto &j_item : value_j["static_load"]) - { - strength_set::StaticLoad new_obj = strength_set::JsonStaticLoad::from_json(j_item); - m_StrengthSet->StaticLoad().push_back(new_obj); - } + // m_StrengthSet->StaticLoad().clear(); + // for (const auto &j_item : value_j["static_load"]) + // { + // strength_set::StaticLoad new_obj = strength_set::JsonStaticLoad::from_json(j_item); + // m_StrengthSet->StaticLoad().push_back(new_obj); + // } - m_StrengthSet->AddtionalLoad().clear(); - for (const auto &j_item : value_j["addtional_load"]) - { - strength_set::AddtionalLoad new_obj = strength_set::JsonAddtionalLoad::from_json(j_item); - m_StrengthSet->AddtionalLoad().push_back(new_obj); - } + // m_StrengthSet->AddtionalLoad().clear(); + // for (const auto &j_item : value_j["addtional_load"]) + // { + // strength_set::AddtionalLoad new_obj = strength_set::JsonAddtionalLoad::from_json(j_item); + // m_StrengthSet->AddtionalLoad().push_back(new_obj); + // } - m_StrengthSet->AllowLoad().clear(); - for (const auto &j_item : value_j["allow_load"]) - { - strength_set::AllowLoad new_obj = strength_set::JsonAllowLoad::from_json(j_item); - m_StrengthSet->AllowLoad().push_back(new_obj); - } + // m_StrengthSet->AllowLoad().clear(); + // for (const auto &j_item : value_j["allow_load"]) + // { + // strength_set::AllowLoad new_obj = strength_set::JsonAllowLoad::from_json(j_item); + // m_StrengthSet->AllowLoad().push_back(new_obj); + // } } void DataManager::structure_cprt_editor_save(const json &value_j) { - m_StrengthSet->ChkPlate().clear(); - for (const auto &j_item : value_j["j_chk_plate"]) - { - strength_set::ChkPlate new_obj = strength_set::JsonChkPlate::from_json(j_item); - m_StrengthSet->ChkPlate().push_back(new_obj); - } + // m_StrengthSet->ChkPlate().clear(); + // for (const auto &j_item : value_j["j_chk_plate"]) + // { + // strength_set::ChkPlate new_obj = strength_set::JsonChkPlate::from_json(j_item); + // m_StrengthSet->ChkPlate().push_back(new_obj); + // } - m_StrengthSet->ChkLongitudinal().clear(); - for (const auto &j_item : value_j["j_chk_longitudinal"]) - { - strength_set::ChkLongitudinal new_obj = strength_set::JsonChkLongitudinal::from_json(j_item); - m_StrengthSet->ChkLongitudinal().push_back(new_obj); - } + // m_StrengthSet->ChkLongitudinal().clear(); + // for (const auto &j_item : value_j["j_chk_longitudinal"]) + // { + // strength_set::ChkLongitudinal new_obj = strength_set::JsonChkLongitudinal::from_json(j_item); + // m_StrengthSet->ChkLongitudinal().push_back(new_obj); + // } - m_StrengthSet->ChkSubgirder().clear(); - for (const auto &j_item : value_j["j_chk_subgirder"]) - { - strength_set::ChkSubgirder new_obj = strength_set::JsonChkSubgirder::from_json(j_item); - m_StrengthSet->ChkSubgirder().push_back(new_obj); - } + // m_StrengthSet->ChkSubgirder().clear(); + // for (const auto &j_item : value_j["j_chk_subgirder"]) + // { + // strength_set::ChkSubgirder new_obj = strength_set::JsonChkSubgirder::from_json(j_item); + // m_StrengthSet->ChkSubgirder().push_back(new_obj); + // } - m_StrengthSet->AllowLoad().clear(); - for (const auto &j_item : value_j["j_allow_load"]) - { - strength_set::AllowLoad new_obj = strength_set::JsonAllowLoad::from_json(j_item); - m_StrengthSet->AllowLoad().push_back(new_obj); - } + // m_StrengthSet->AllowLoad().clear(); + // for (const auto &j_item : value_j["j_allow_load"]) + // { + // strength_set::AllowLoad new_obj = strength_set::JsonAllowLoad::from_json(j_item); + // m_StrengthSet->AllowLoad().push_back(new_obj); + // } } void DataManager::structure_section_editor_save(const json &value_j) @@ -2268,262 +2266,262 @@ void DataManager::certify_Tonnage(int &errorCode, QString &outMsg, QString &data void DataManager::structure_section_editor(json &outjson) { - nlohmann::json j_sections = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->Section()) - { - j_sections.push_back(strength_set::JsonSection::to_json(obj)); - } + // nlohmann::json j_sections = nlohmann::json::array(); + // for (const auto &obj : m_StrengthSet->Section()) + // { + // j_sections.push_back(strength_set::JsonSection::to_json(obj)); + // } - // outjson = QString::fromStdString(j_sections.dump()); + // // outjson = QString::fromStdString(j_sections.dump()); - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_scantlings_editor(json &outjson) { - nlohmann::json j_sections = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->Section()) - { - j_sections.push_back(strength_set::JsonSection::to_json(obj)); - } + // nlohmann::json j_sections = nlohmann::json::array(); + // for (const auto &obj : m_StrengthSet->Section()) + // { + // j_sections.push_back(strength_set::JsonSection::to_json(obj)); + // } - // outjson = QString::fromStdString(j_sections.dump()); + // // outjson = QString::fromStdString(j_sections.dump()); - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_strength_editor(json &outjson) { - nlohmann::json j_pub = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->Pub()) - { - j_pub.push_back(strength_set::JsonPub::to_json(obj)); - break; - } + // nlohmann::json j_pub = nlohmann::json::array(); + // for (const auto &obj : m_StrengthSet->Pub()) + // { + // j_pub.push_back(strength_set::JsonPub::to_json(obj)); + // break; + // } - outjson = {{"pub", j_pub}}; + // outjson = {{"pub", j_pub}}; - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_twbg_editor(json &outjson) { - nlohmann::json j_close_room = nlohmann::json::array(); - nlohmann::json j_elem = nlohmann::json::array(); - nlohmann::json j_mutual_elem = nlohmann::json::array(); - nlohmann::json j_node = nlohmann::json::array(); - nlohmann::json j_section = nlohmann::json::array(); + // nlohmann::json j_close_room = nlohmann::json::array(); + // nlohmann::json j_elem = nlohmann::json::array(); + // nlohmann::json j_mutual_elem = nlohmann::json::array(); + // nlohmann::json j_node = nlohmann::json::array(); + // nlohmann::json j_section = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->SecCloseroom()) - { - j_close_room.push_back(strength_set::JsonSecCloseroom::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->SecCloseroom()) + // { + // j_close_room.push_back(strength_set::JsonSecCloseroom::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->SecPlate()) - { - j_elem.push_back(strength_set::JsonSecPlate::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->SecPlate()) + // { + // j_elem.push_back(strength_set::JsonSecPlate::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->SecShell()) - { - j_mutual_elem.push_back(strength_set::JsonSecShell::to_json(obj)); - break; - } + // for (const auto &obj : m_StrengthSet->SecShell()) + // { + // j_mutual_elem.push_back(strength_set::JsonSecShell::to_json(obj)); + // break; + // } - for (const auto &obj : m_StrengthSet->SecNode()) - { - j_node.push_back(strength_set::JsonSecNode::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->SecNode()) + // { + // j_node.push_back(strength_set::JsonSecNode::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Section()) - { - j_section.push_back(strength_set::JsonSection::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Section()) + // { + // j_section.push_back(strength_set::JsonSection::to_json(obj)); + // } - outjson = {{"close_room", j_close_room}, - {"elem", j_elem}, - {"mutual_elem", j_mutual_elem}, - {"node", j_node}, - {"section", j_section}}; + // outjson = {{"close_room", j_close_room}, + // {"elem", j_elem}, + // {"mutual_elem", j_mutual_elem}, + // {"node", j_node}, + // {"section", j_section}}; - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_patp_editor(json &outjson) { - nlohmann::json j_attach = nlohmann::json::array(); - nlohmann::json j_elem = nlohmann::json::array(); - nlohmann::json j_girder = nlohmann::json::array(); - nlohmann::json j_mat = nlohmann::json::array(); - nlohmann::json j_node = nlohmann::json::array(); + // nlohmann::json j_attach = nlohmann::json::array(); + // nlohmann::json j_elem = nlohmann::json::array(); + // nlohmann::json j_girder = nlohmann::json::array(); + // nlohmann::json j_mat = nlohmann::json::array(); + // nlohmann::json j_node = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->Attach()) - { - j_attach.push_back(strength_set::JsonAttach::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Attach()) + // { + // j_attach.push_back(strength_set::JsonAttach::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Subgirder()) - { - j_elem.push_back(strength_set::JsonSubgirder::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Subgirder()) + // { + // j_elem.push_back(strength_set::JsonSubgirder::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Girder()) - { - j_girder.push_back(strength_set::JsonGirder::to_json(obj)); - break; - } + // for (const auto &obj : m_StrengthSet->Girder()) + // { + // j_girder.push_back(strength_set::JsonGirder::to_json(obj)); + // break; + // } - for (const auto &obj : m_StrengthSet->Mat()) - { - j_mat.push_back(strength_set::JsonMat::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Mat()) + // { + // j_mat.push_back(strength_set::JsonMat::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Subnode()) - { - j_node.push_back(strength_set::JsonSubnode::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Subnode()) + // { + // j_node.push_back(strength_set::JsonSubnode::to_json(obj)); + // } - outjson = {{"attach", j_attach}, - {"elem", j_elem}, - {"girder", j_girder}, - {"mat", j_mat}, - {"node", j_node}}; + // outjson = {{"attach", j_attach}, + // {"elem", j_elem}, + // {"girder", j_girder}, + // {"mat", j_mat}, + // {"node", j_node}}; - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_zcmt_editor(json &outjson) { - nlohmann::json j_bonjean = nlohmann::json::array(); - nlohmann::json j_pub = nlohmann::json::array(); - nlohmann::json j_wl = nlohmann::json::array(); - nlohmann::json j_kl = nlohmann::json::array(); - nlohmann::json j_load_case = nlohmann::json::array(); - nlohmann::json j_offset = nlohmann::json::array(); - nlohmann::json j_st_weight = nlohmann::json::array(); - nlohmann::json j_case_item_weight = nlohmann::json::array(); - nlohmann::json j_mtc = nlohmann::json::array(); - nlohmann::json j_lifted_cargo = nlohmann::json::array(); - nlohmann::json j_static_load = nlohmann::json::array(); - nlohmann::json j_addtional_load = nlohmann::json::array(); - nlohmann::json j_allow_load = nlohmann::json::array(); + // nlohmann::json j_bonjean = nlohmann::json::array(); + // nlohmann::json j_pub = nlohmann::json::array(); + // nlohmann::json j_wl = nlohmann::json::array(); + // nlohmann::json j_kl = nlohmann::json::array(); + // nlohmann::json j_load_case = nlohmann::json::array(); + // nlohmann::json j_offset = nlohmann::json::array(); + // nlohmann::json j_st_weight = nlohmann::json::array(); + // nlohmann::json j_case_item_weight = nlohmann::json::array(); + // nlohmann::json j_mtc = nlohmann::json::array(); + // nlohmann::json j_lifted_cargo = nlohmann::json::array(); + // nlohmann::json j_static_load = nlohmann::json::array(); + // nlohmann::json j_addtional_load = nlohmann::json::array(); + // nlohmann::json j_allow_load = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->Bonjean()) - { - j_bonjean.push_back(strength_set::JsonBonjean::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Bonjean()) + // { + // j_bonjean.push_back(strength_set::JsonBonjean::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Pub()) - { - j_pub.push_back(strength_set::JsonPub::to_json(obj)); - break; - } + // for (const auto &obj : m_StrengthSet->Pub()) + // { + // j_pub.push_back(strength_set::JsonPub::to_json(obj)); + // break; + // } - for (const auto &obj : m_StrengthSet->WL()) - { - j_wl.push_back(strength_set::JsonWL::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->WL()) + // { + // j_wl.push_back(strength_set::JsonWL::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->KL()) - { - j_kl.push_back(strength_set::JsonKL::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->KL()) + // { + // j_kl.push_back(strength_set::JsonKL::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->LoadCase()) - { - j_load_case.push_back(strength_set::JsonLoadCase::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->LoadCase()) + // { + // j_load_case.push_back(strength_set::JsonLoadCase::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->Offset()) - { - j_offset.push_back(strength_set::JsonOffset::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->Offset()) + // { + // j_offset.push_back(strength_set::JsonOffset::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->StWeight()) - { - j_st_weight.push_back(strength_set::JsonStWeight::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->StWeight()) + // { + // j_st_weight.push_back(strength_set::JsonStWeight::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->ItemWeight()) - { - j_case_item_weight.push_back(strength_set::JsonItemWeight::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->ItemWeight()) + // { + // j_case_item_weight.push_back(strength_set::JsonItemWeight::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->MTC()) - { - j_mtc.push_back(strength_set::JsonMTC::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->MTC()) + // { + // j_mtc.push_back(strength_set::JsonMTC::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->LiftedCargo()) - { - j_lifted_cargo.push_back(strength_set::JsonLiftedCargo::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->LiftedCargo()) + // { + // j_lifted_cargo.push_back(strength_set::JsonLiftedCargo::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->StaticLoad()) - { - j_static_load.push_back(strength_set::JsonStaticLoad::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->StaticLoad()) + // { + // j_static_load.push_back(strength_set::JsonStaticLoad::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->AddtionalLoad()) - { - j_addtional_load.push_back(strength_set::JsonAddtionalLoad::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->AddtionalLoad()) + // { + // j_addtional_load.push_back(strength_set::JsonAddtionalLoad::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->AllowLoad()) - { - j_allow_load.push_back(strength_set::JsonAllowLoad::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->AllowLoad()) + // { + // j_allow_load.push_back(strength_set::JsonAllowLoad::to_json(obj)); + // } - outjson = {{"bonjean", j_bonjean}, - {"pub", j_pub}, - {"wl", j_wl}, - {"kl", j_kl}, - {"load_case", j_load_case}, - {"offset", j_offset}, - {"st_weight", j_st_weight}, - {"case_item_weight", j_case_item_weight}, - {"mtc", j_mtc}, - {"lifted_cargo", j_lifted_cargo}, - {"static_load", j_static_load}, - {"addtional_load", j_addtional_load}, - {"allow_load", j_allow_load}}; + // outjson = {{"bonjean", j_bonjean}, + // {"pub", j_pub}, + // {"wl", j_wl}, + // {"kl", j_kl}, + // {"load_case", j_load_case}, + // {"offset", j_offset}, + // {"st_weight", j_st_weight}, + // {"case_item_weight", j_case_item_weight}, + // {"mtc", j_mtc}, + // {"lifted_cargo", j_lifted_cargo}, + // {"static_load", j_static_load}, + // {"addtional_load", j_addtional_load}, + // {"allow_load", j_allow_load}}; - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } void DataManager::structure_cprt_editor(json &outjson) { - nlohmann::json j_chk_plate = nlohmann::json::array(); - nlohmann::json j_chk_longitudinal = nlohmann::json::array(); - nlohmann::json j_chk_subgirder = nlohmann::json::array(); - nlohmann::json j_allow_load = nlohmann::json::array(); + // nlohmann::json j_chk_plate = nlohmann::json::array(); + // nlohmann::json j_chk_longitudinal = nlohmann::json::array(); + // nlohmann::json j_chk_subgirder = nlohmann::json::array(); + // nlohmann::json j_allow_load = nlohmann::json::array(); - for (const auto &obj : m_StrengthSet->ChkPlate()) - { - j_chk_plate.push_back(strength_set::JsonChkPlate::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->ChkPlate()) + // { + // j_chk_plate.push_back(strength_set::JsonChkPlate::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->ChkLongitudinal()) - { - j_chk_longitudinal.push_back(strength_set::JsonChkLongitudinal::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->ChkLongitudinal()) + // { + // j_chk_longitudinal.push_back(strength_set::JsonChkLongitudinal::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->ChkSubgirder()) - { - j_chk_subgirder.push_back(strength_set::JsonChkSubgirder::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->ChkSubgirder()) + // { + // j_chk_subgirder.push_back(strength_set::JsonChkSubgirder::to_json(obj)); + // } - for (const auto &obj : m_StrengthSet->AllowLoad()) - { - j_allow_load.push_back(strength_set::JsonAllowLoad::to_json(obj)); - } + // for (const auto &obj : m_StrengthSet->AllowLoad()) + // { + // j_allow_load.push_back(strength_set::JsonAllowLoad::to_json(obj)); + // } - outjson = {{"j_chk_plate", j_chk_plate}, - {"j_chk_longitudinal", j_chk_longitudinal}, - {"j_chk_subgirder", j_chk_subgirder}, - {"j_allow_load", j_allow_load}}; + // outjson = {{"j_chk_plate", j_chk_plate}, + // {"j_chk_longitudinal", j_chk_longitudinal}, + // {"j_chk_subgirder", j_chk_subgirder}, + // {"j_allow_load", j_allow_load}}; - LOG_DEBUG("trace"); + // LOG_DEBUG("trace"); } int DataManager::cmd_add_obj(IModel *model, QString &strLog) diff --git a/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/DataBlock.cpp b/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/DataBlock.cpp index 145d1fc..337dcaa 100644 --- a/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/DataBlock.cpp +++ b/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/DataBlock.cpp @@ -10,6 +10,18 @@ void StabilityCalDataBlock::fromXmlEx(const pugi::xml_node xml, QMap& _childModules, std::vector& _childModuleNames, QMap& _DataRows, std::vector& _DataRowsNames) +{ + if (!xml.empty()) + { + deserializeObjDics(_childModules, xml.child("ChildModulus"), _childModuleNames); + deserializeObjDics(_DataRows, xml.child("DataRows"), _DataRowsNames); + + int a = 0; } } \ No newline at end of file diff --git a/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.cpp b/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.cpp new file mode 100644 index 0000000..c975e5d --- /dev/null +++ b/trunk/code/projects/DataManager/Infrastructure.Data/DataContainer/StructureCalculationData.cpp @@ -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 &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 &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 &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; +}