COMPASSi/trunk/code/inc/DataManager/DataManagerInterface/include/DataManager.h

466 lines
18 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef DATAMANGER_H
#define DATAMANGER_H
#include "BaseDataManager.h"
#include "Singleton.h"
#include "DataManagerGlobal.h"
#include "SnapCurvePointsState.h"
#include "VersionData.h"
#include "ModelData.h"
#include "WindowLogData.h"
#include "DataContainer/DataBlock.h"
#include "DataContainer/StabCalculationData.h"
#include <QFileInfo>
#include "StrengthSet.hxx"
#include "TonnageModelDS.hxx"
#include "EEDIModelDS.hxx"
#include "XLSXDataManager.h"
#include "StabilityUndoRedoManager.h"
#include "StabCalculation/BasicInf.h"
#ifdef __cplusplus
extern "C"
{
#endif
enum DATAMANAGER_DLL_API_EXPORTS XMLFile_Type
{
XMLFile_Type_null = 0,
XMLFile_Type_xls,
XMLFile_Type_iges,
XMLFile_Type_csx,
XMLFile_Type_dxf,
XMLFile_Type_size
};
enum DATAMANAGER_DLL_API_EXPORTS calculate_section_type
{
SECTION_FLAT_BAR_ROUND, // 球扁钢
SECTION_ANGLE, // 角钢
SECTION_EQUAL_ANGLE, // 等边角钢
SECTION_T_SHAPE, // 丄型钢倒T型钢
SECTION_BENT_PLATE, // 折边板
SECTION_FLAT_BAR, // 扁钢
SECTION_OTHER // 其他
};
enum DATAMANAGER_DLL_API_EXPORTS calculate_diagonal
{
DIAGONAL_SINGLE_ANGLE, // 单角钢
DIAGONAL_DOUBLE_ANGLE // 双角钢
};
enum DATAMANAGER_DLL_API_EXPORTS calculate_strut
{
STRUT_PIPE, // 管型
STRUT_CROSS // 十字型
};
class DATAMANAGER_DLL_API_EXPORTS DataManager : public BaseDataManager
{
public:
static DataManager *getDataManagerModelInstance();
static void destroy();
bool showWindowsLog(QString &log);
void addShowWindowsLog(QString log);
void readFile(XMLFile_Type type, const QString &filePath);
void loadXLSXFile(const QString &filePath);
void saveFile(QString &savefilePath);
// 捕获点的选择
void snap_point(SNAP_POINTS_Type iSelect, int &errorCode, QString &outMsg, QString &data, const QString &message);
ModelData &getModelData()
{
return m_ModelData;
}
const ShipInfo_M& getShipInfo()
{
return m_ModelData.getShipInfo();
}
static int GetGeomObjectIDByName(const std::string &name);
static int GetObjectIDByName(const std::string &name);
static IModel *GetObjectByID(int id);
static IModel *GetObjectByName(const std::string &name);
static std::vector<int> GetAllObject();
static vector<Point3D> GetCurvePointByFSEx(int CurveID, int type);
static vector<int> sortListByDependent(vector<int> lst);
static bool IsDependentByID(int deriveID, int srcID);
// void create_point(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, std::vector<int> &ids);
static int create_point(vector<string> &commandLines, std::vector<Point3D_M> &points, vector<Point3D> &vPoint3d, vector<int> &order);
int create_point(vector<string> &commandLines, QString &strLog);
static int create_line(vector<string> &commandLines, Curve_M &curve, std::vector<Point3D_M> &points, vector<Point3D> &vPoint3d, vector<Curve> &vCur, vector<int> &order);
int create_line(vector<string> &commandLines, QString &strLog);
// void create_line(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
static int create_surface(vector<string> &commandLines, Surface_M &surface, vector<Surface> &vSur, vector<int> &order);
int create_surface(vector<string> &commandLines, QString &strLog);
// void create_surface(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
static int create_solid(vector<string> &commandLines, Solid_M &solid, vector<Solid> &vSol, vector<int> &order);
int create_solid(vector<string> &commandLines, QString &strLog);
// void create_solid(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
int create_Hull(vector<string> &commandLines, Hull_M &hull, vector<Hull> &vHull, vector<int> &order);
int create_Hull(vector<string> &commandLines, QString &strLog);
// void create_mainbody(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
int create_unit_and_space(vector<string> &commandLines, Space_M &space, vector<Space> &vSpace, vector<int> &order);
int create_unit_and_space(vector<string> &commandLines, QString &strLog);
// void create_unit_and_space(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
int create_Appendage(vector<string> &commandLines, Appendage_M &appendage, vector<Appendage> &vappendage, vector<int> &order);
int create_Appendage(vector<string> &commandLines, QString &strLog);
// void create_Appendage(int &errorCode, QString &outMsg, QString &data, const QString &message, OCCStructDataMD *m_pDataMD, int &id);
int setObjVisible(vector<string> &commandLines);
void stab_model_editor_hydro_static(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_tank_cap(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_intact(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_allow_kg(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_damage(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_damage_prob(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_inclining(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_check(int &errorCode, QString &outMsg, QString &data, const QString &message);
void stab_model_editor_save(int &errorCode, QString &outMsg, QString &data, const QString &message);
void analysis_structure_get_2d_data(json &outjson);
void structure_show_tree(int &errorCode, QString &outMsg, QString &data, const QString &message);
void analysis_show_tree(int &errorCode, QString &outMsg, QString &data, const QString &message);
void certify_Tonnage(int &errorCode, QString &outMsg, QString &data, const QString &message);
void structure_model_editor_check(int &errorCode, QString &outMsg, QString &data, const QString &message);
void structure_model_editor_save(int &errorCode, QString &outMsg, QString &data, const QString &message);
void structure_section_editor(json &outjson);
void structure_scantlings_editor(json &outjson);
void structure_strength_editor(json &outjson);
void structure_twbg_editor(json &outjson);
void structure_patp_editor(json &outjson);
void structure_zcmt_editor(json &outjson);
void structure_cprt_editor(json &outjson);
void structure_strength_editor_save(const json &value_j);
void structure_patp_editor_save(const json &value_j);
void structure_twbg_editor_save(const json &value_j);
void structure_zcmt_editor_save(const json &value_j);
void structure_cprt_editor_save(const json &value_j);
void structure_section_editor_save(const json &value_j);
void structure_scantlings_editor_save(const json &value_j);
int cmd_add_obj(IModel *model, QString &strLog);
//复制
int cmd_copy(std::string &singlecmdstring, QString &strLog);
// 剪切
int cmd_trim(std::string &singlecmdstring, QString &strLog);
// 镜像
int cmd_mirror(std::string &singlecmdstring, QString &strLog);
// 求交
int cmd_intersection(std::string &singlecmdstring, QString &strLog);
// 拼接
int cmd_join(std::string &singlecmdstring, QString &strLog);
// 删除
int cmd_delete(std::string &singlecmdstring, QString &strLog, std::vector<string> &vDeleteObjName);
// std::vector<std::string> RemoveSpaces(const std::string &input);
// std::string FirstWord(const std::string &str);
// int ParseCmdType(const std::string &data);
// std::vector<std::string> SplitCommand(std::string data);
// bool OCCModelingDeleteObjs(int executingCmdID,vector<int>& lst);
int cmd_tool_show_obj_command(std::string &singlecmdstring, QString &strLog);
void UpdateModelMaps()
{
m_ModelData.UpdateModelMaps();
}
void UpdateModelMaps(vector<IModel *> *discardData, vector<IModel *> *usingData)
{
m_ModelData.UpdateModelMaps(discardData, usingData);
}
const std::vector<int> getCurrentOperationId()
{
return m_vCurrentOperationId;
}
// 导入型值表
// 横向横剖线 命令集
std::vector<std::string> &getTransverseProfile_commad();
// 梁拱命令
std::vector<std::string> &getCamber_commad();
// 绘制纵剖线
std::vector<std::string> &getLongitudinalProfile_commad();
// 水线
std::vector<std::string> &getWaterLine_commad();
// 空间线
std::vector<std::string> &getSpaceLine_commad();
void setImportOffsetOption(ImportOffsetOption &_option);
void push_undo_redo_data(int icommandid, std::vector<IModel *> &data);
void cmd_undo(std::vector<string> &disCardObjsName, std::vector<int> &changesObjsID, bool &isCanUndo, bool &isCanRedo);
void cmd_redo(std::vector<string> &disCardObjsName, std::vector<int> &changesObjsID, bool &isCanUndo, bool &isCanRedo);
bool isCanUndo();
bool isCanRedo();
///-------------------------------稳性计算-------------------------start----------------//
void addBInfo(BInf& info);
BInf* FindByParamID(string strParamID);
void AddXLabelRow(XLabel& data);
void updateStationLabel();
void updateWaterlinePositions();
void updateButtocklineLabel();
void updateCompartmentData();
string CheckHydostatic();
string ConnectErrorString(string oldErr, string newErr);
std::string CheckTableBasicInf(bool hasIntact = true, bool hasInclining = true);
std::string CheckTableShell();
string CheckTableLimitStaticPoint();
string CheckTankcapacity();
string CheckTableCompartment();
string CheckIntact();
string CheckCrRule(BasicInf& bf);
string CheckTableLWT();
string CheckTableWind();
string CheckTablePartialLoad();
string CheckTablePartialLoadItem();
string CheckTableCase();
string CheckDamage();
string CheckDamageProb();
string CheckInclining();
void saveStabFile(QString savefilePath);
bool ExportHullCalFile(string fileName, string path);
bool ExportSpaceCalFile(string fileName, string path);
static string ErrInfoAddName(vector<int>& spaceIDs, vector<string>& spaceNames, string err);
bool isCalcTank(std::vector<string>& subItems);
///-------------------------------稳性计算-------------------------end----------------//
private:
QString GetOcmFileName(const QString &file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".ocm";
}
QString GetCmdFileName(const QString &file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".lst";
}
QString GetRstFileName(const QString &file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".rst";
}
QString GetStabFileName(const QString& file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".stab";
}
QString GetTankFileName(const QString& file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".tank";
}
QString GetHullFileName(const QString& file)
{
QFileInfo fileInfo(file);
return fileInfo.path() + "/" + fileInfo.baseName() + ".hull";
}
void setCurrentOperationId(std::vector<int> vData)
{
m_vCurrentOperationId.swap(vData);
}
void setCurrentOperationId(int id)
{
std::vector<int> vData;
vData.emplace_back(id);
m_vCurrentOperationId.swap(vData);
}
bool setObjVisible(int id, int value);
public:
static const int ARRAY_SIZE_NORMAL = 256;
static const int ARRAY_SIZE_MEDIUM = 1024;
static const int ARRAY_SIZE_LARGE = 2048;
int getExecutingCmdID()
{
return m_executingCmdID;
}
void autoAddExecutingCmdID()
{
m_executingCmdID++;
}
static string StabCrRuleToString(StabCrRule type); //20180701 added by czb
static QString NavAreaToString(const QString& type);
static string ChildShipTypeToString(ChildShipType type); //20200428 by czb, modified;
static string ShipTypeToString(ShipType type);
VersionData& getVersionData()
{
return m_VersionData;
}
void resetCheck();
void certify_save_Tonnage(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_check_Tonnage(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_create_cal(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_cal(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_delete_cal(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_EEDI(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_EEDI_save(int & errorCode, QString & outMsg, QString & data, const QString & message);
void certify_EEDI_check(int & errorCode, QString & outMsg, QString & data, const QString & message);
std::string CheckBasicInf();
std::string CheckV1Simpson();
std::string CheckV2Simpson();
std::string CheckV2Block();
std::string CheckV2Other();
std::string CheckV3();
std::string CheckV41();
std::string CheckV42();
std::string CheckV43();
std::string CheckV5();
bool isTonnagechecked = false;
void calculate_section(int &errorCode, QString &outMsg, QString &data, const QString &message);
void calculate_strut(int &errorCode, QString &outMsg, QString &data, const QString &message);
void calculate_diagonal(int &errorCode, QString &outMsg, QString &data, const QString &message);
double Gjpmms(double h, double A, double Y, double I, double dbkd, double dbhd,double& ii, double& ww, double& yy);
void calculate_strut_open(int &errorCode, QString &outMsg, QString &data, const QString &message);
void calculate_diagonal_open(int &errorCode, QString &outMsg, QString &data, const QString &message);
void calculate_section_open(int &errorCode, QString &outMsg, QString &data, const QString &message);
std::vector<std::string> extract_ids_from_file(const QString &filePath, const std::string &rootName);
private:
DataManager();
~DataManager();
int m_executingCmdID = 0;
SnapCurvePointsState m_Snap_curve_points; // 5个按钮 捕捉点线
WindowLogData m_windowLogData;
VersionData m_VersionData;
ModelData m_ModelData;
GroupStruct m_GroupStructData;
// pugi::xml_node occIndexData;
pugi::xml_document m_XmlDoc;
//StabilityCalDataBlock *m_StabilityCal = nullptr;
StabCalculationData m_StabCalData;
StructureCalDataBlock *m_StructureCal = nullptr;
CertifyCalDataBlock *m_CertifyCal = nullptr;
std::unique_ptr<::strength_set::StrengthSet> m_StrengthSet;
std::unique_ptr<::tonnagemodel_ds::TonnageModelDS> m_TonnageModelDS;
std::unique_ptr<::eedimodel_ds::EEDIModelDS> m_EEDIModelDS;
std::string m_cmdStr; // CMD命令
std::vector<int> m_vCurrentOperationId;
XLSXDataManager m_xlsmDataManager;
StabilityUndoRedoManager m_undoRedoMg;
std::string m_HullLabelStr = "";
bool m_IsHydostaticChecked = false;
bool m_IsBasicInfChecked = false;
bool m_TableShellIsChecked = false;
bool m_TableLimitStaticPointIsChecked = false;
bool m_IsTankcapacityChecked = false;
bool m_TableCompartmentIsChecked = false;
bool m_IsIntactChecked = false;
bool m_IsCriteriaRuleChecked = false;
bool m_TableLWTIsChecked = false;
bool m_TableWindIsChecked = false;
bool m_TableParialLoadIsChecked = false;
bool m_TablePartialLoadItemIsChecked = false;
bool m_TableCaseIsChecked = false;
bool m_TableDamageIsChecked = false;
bool m_TableDamageProbIsChecked = false;
bool m_IsIncliningChecked = false;
StabCrRule m_CrRule;
static DataManager *m_pDataManagerInstance;
};
#ifdef __cplusplus
}
#endif
#endif