465 lines
15 KiB
C
465 lines
15 KiB
C
|
#ifndef DATAMODEL_H
|
||
|
#define DATAMODEL_H
|
||
|
|
||
|
#include "Serialization.h"
|
||
|
#include "ShipInfo.h"
|
||
|
#include <unordered_map>
|
||
|
#include "../../Infrastructure.Data/Model/Geometry_M.h" // 更新路径
|
||
|
#include "../../Infrastructure.Data/Model/Hull_M.h"
|
||
|
|
||
|
#define REGISTER_MODE(name) {#name, DisplayMode3D_M::name}
|
||
|
#define UNREGISTER_MODE(name) {DisplayMode3D_M::name, #name}
|
||
|
|
||
|
enum DisplayMode3D_M
|
||
|
{
|
||
|
None_enum = 0,
|
||
|
|
||
|
Point_enum = 0x1,
|
||
|
Curve_enum = 0x2,
|
||
|
Surface_enum = 0x4,
|
||
|
Solid_enum = 0x8,
|
||
|
|
||
|
MainDeck_enum = 0x10,
|
||
|
Shell_enum = 0x20,
|
||
|
Deck_enum = 0x40,
|
||
|
Bound_enum = 0x80,
|
||
|
Subdiv_enum = 0x100,
|
||
|
OpenCargoRegion_enum = 0x200,
|
||
|
Space_enum = 0x400,
|
||
|
Appendage_enum = 0x800,
|
||
|
|
||
|
FrameRuler_enum = 0x1000,
|
||
|
Hull_enum = 0x2000,
|
||
|
MainHull_enum = 0x4000,
|
||
|
SpaceUnit_enum = 0x8000,
|
||
|
DisplayMode3D_M_ALL,
|
||
|
};
|
||
|
|
||
|
// 文本域变量
|
||
|
class DocumentVar
|
||
|
{
|
||
|
public:
|
||
|
bool m_IsUpdateLinkage = false;
|
||
|
};
|
||
|
|
||
|
class DATAMANAGER_DLL_API_EXPORTS ModelData : public Serialization
|
||
|
{
|
||
|
public:
|
||
|
ModelData();
|
||
|
~ModelData();
|
||
|
|
||
|
virtual int fromXml(const pugi::xml_node node);
|
||
|
|
||
|
virtual int toXml(pugi::xml_node node);
|
||
|
|
||
|
static const int ARRAY_SIZE_NORMAL = 256;
|
||
|
|
||
|
void setPrjName(QString name);
|
||
|
void setWorkNO(QString no);
|
||
|
void setDesigner(QString _t);
|
||
|
void setOwner(QString own);
|
||
|
void setSignature(QString _t);
|
||
|
void setCalDate(QString _t);
|
||
|
|
||
|
QString getPrjName();
|
||
|
QString getWorkNO();
|
||
|
QString getDesigner();
|
||
|
QString getOwner();
|
||
|
QString getSignature();
|
||
|
QString getCalDate();
|
||
|
|
||
|
const ShipInfo_M& getShipInfo();
|
||
|
int getShipType();
|
||
|
std::string getShipTypeString();
|
||
|
void setShipType(int t);
|
||
|
void setShipType(std::string t);
|
||
|
void setNavArea(vector<int> &vData);
|
||
|
vector<int> getNavArea();
|
||
|
QStringList getNavAreaEX();
|
||
|
|
||
|
int getSelfPropelled();
|
||
|
void setSelfPropelled(int t);
|
||
|
|
||
|
void setX0Pos(int _t);
|
||
|
int getX0Pos();
|
||
|
|
||
|
double getF0X();
|
||
|
void setF0X(double _t);
|
||
|
|
||
|
double getSt0X();
|
||
|
void setSt0X(double t);
|
||
|
|
||
|
int getStationSize();
|
||
|
int getShipFrame();
|
||
|
int getiFrame();
|
||
|
|
||
|
double getLpp(); // 垂线间长
|
||
|
double getLoa(); // 总长
|
||
|
double getL(); // 规范船长
|
||
|
double getLw(); // 设计水线长
|
||
|
double getB(); // 型宽
|
||
|
double getD(); // 型深
|
||
|
double getT(); // 设计吃水
|
||
|
double getTMax(); // 结构吃水
|
||
|
int getNOe(); // 主机台数
|
||
|
double getNe(); // 单机功率
|
||
|
double getDisp(); // 排水量
|
||
|
double getCb(); // 方形系数
|
||
|
double getV(); // 设计航速
|
||
|
double getDensity(); // 水的密度
|
||
|
double getLe(); // 最大船长Le
|
||
|
|
||
|
void setLpp(double t); // 垂线间长
|
||
|
void setLoa(double t); // 总长
|
||
|
void setL(double t); // 规范船长
|
||
|
void setLw(double t); // 设计水线长
|
||
|
void setB(double t); // 型宽
|
||
|
void setD(double t); // 型深
|
||
|
void setT(double t); // 设计吃水
|
||
|
void setTMax(double t); // 结构吃水
|
||
|
void setNOe(int t); // 主机台数
|
||
|
void setNe(double t); // 单机功率
|
||
|
void setDisp(double t); // 排水量
|
||
|
void setCb(double t); // 方形系数
|
||
|
void setV(double t); // 设计航速
|
||
|
void setDensity(double t); // 水的密度
|
||
|
void setLe(double t);
|
||
|
|
||
|
void setNavSection(vector<int> &vData);
|
||
|
vector<int> getNavSection();
|
||
|
QStringList getNavSectionEx();
|
||
|
|
||
|
// 将字符串转换为枚举值(带异常抛出)
|
||
|
static DisplayMode3D_M parseDisplayModel3D_M(const QString &value)
|
||
|
{
|
||
|
static const QMap<QString, DisplayMode3D_M> mapping = {
|
||
|
REGISTER_MODE(Point_enum),
|
||
|
REGISTER_MODE(Curve_enum),
|
||
|
REGISTER_MODE(Surface_enum),
|
||
|
REGISTER_MODE(Solid_enum),
|
||
|
REGISTER_MODE(MainDeck_enum),
|
||
|
REGISTER_MODE(Shell_enum),
|
||
|
REGISTER_MODE(Deck_enum),
|
||
|
REGISTER_MODE(Bound_enum),
|
||
|
REGISTER_MODE(Subdiv_enum),
|
||
|
REGISTER_MODE(OpenCargoRegion_enum),
|
||
|
REGISTER_MODE(Space_enum),
|
||
|
REGISTER_MODE(Appendage_enum),
|
||
|
REGISTER_MODE(FrameRuler_enum),
|
||
|
REGISTER_MODE(Hull_enum),
|
||
|
REGISTER_MODE(MainHull_enum),
|
||
|
REGISTER_MODE(SpaceUnit_enum)};
|
||
|
|
||
|
auto it = mapping.find(value);
|
||
|
if (it != mapping.end())
|
||
|
{
|
||
|
return it.value();
|
||
|
}
|
||
|
throw std::invalid_argument("Invalid display mode string: " + value.toStdString());
|
||
|
}
|
||
|
|
||
|
// 将枚举值转成字符串(带异常抛出)
|
||
|
static QString deParseDisplayModel3D_M(const DisplayMode3D_M &value)
|
||
|
{
|
||
|
static const QMap<DisplayMode3D_M, QString> deMapping = {
|
||
|
UNREGISTER_MODE(Point_enum),
|
||
|
UNREGISTER_MODE(Curve_enum),
|
||
|
UNREGISTER_MODE(Surface_enum),
|
||
|
UNREGISTER_MODE(Solid_enum),
|
||
|
UNREGISTER_MODE(MainDeck_enum),
|
||
|
UNREGISTER_MODE(Shell_enum),
|
||
|
UNREGISTER_MODE(Deck_enum),
|
||
|
UNREGISTER_MODE(Bound_enum),
|
||
|
UNREGISTER_MODE(Subdiv_enum),
|
||
|
UNREGISTER_MODE(OpenCargoRegion_enum),
|
||
|
UNREGISTER_MODE(Space_enum),
|
||
|
UNREGISTER_MODE(Appendage_enum),
|
||
|
UNREGISTER_MODE(FrameRuler_enum),
|
||
|
UNREGISTER_MODE(Hull_enum),
|
||
|
UNREGISTER_MODE(MainHull_enum),
|
||
|
UNREGISTER_MODE(SpaceUnit_enum)};
|
||
|
|
||
|
auto it = deMapping.find(value);
|
||
|
if (it != deMapping.end())
|
||
|
{
|
||
|
return it.value();
|
||
|
}
|
||
|
return "";
|
||
|
// throw std::invalid_argument("Invalid display mode string: " + value.toStdString());
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Point3D_M>> &getPoint3DModel()
|
||
|
{
|
||
|
return m_Points;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Curve_M>> &getCurveModle()
|
||
|
{
|
||
|
return m_Curves;
|
||
|
}
|
||
|
std::vector<std::pair<int, Surface_M>> &getSurfaces()
|
||
|
{
|
||
|
return m_Surfaces;
|
||
|
}
|
||
|
std::vector<std::pair<int, Solid_M>> &getSolids()
|
||
|
{
|
||
|
return m_Solids;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Frame_M>> &getFrames()
|
||
|
{
|
||
|
return m_Frames;
|
||
|
}
|
||
|
std::vector<std::pair<int, Station_M>> &getStation()
|
||
|
{
|
||
|
return m_Station;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, WaterlinePos_M>> &getWaterlinePos()
|
||
|
{
|
||
|
return m_WaterlinePos;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, ButtocklinePos_M>> &getButtocklinePos()
|
||
|
{
|
||
|
return m_ButtocklinePos;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Hull_M>> &getHulls()
|
||
|
{
|
||
|
return m_Hulls;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Space_M>> &getSpaces()
|
||
|
{
|
||
|
return m_Spaces;
|
||
|
}
|
||
|
|
||
|
std::vector<std::pair<int, Appendage_M>> &getAppendages()
|
||
|
{
|
||
|
return m_Appendages;
|
||
|
}
|
||
|
|
||
|
void insertPoint3D(Point3D_M& data);
|
||
|
void insertCurve(Curve_M& data);
|
||
|
void insertSurface(Surface_M& data);
|
||
|
void insertSolid(Solid_M& data);
|
||
|
void insertHulls(Hull_M& data);
|
||
|
void insertSpace(Space_M& data);
|
||
|
void insertAppendages(Appendage_M& data);
|
||
|
|
||
|
std::vector<string> deleteObjByID(std::vector<int> ids);
|
||
|
|
||
|
|
||
|
void clearData();
|
||
|
|
||
|
private:
|
||
|
int ovmFromXml(const pugi::xml_node node);
|
||
|
int docFromXml(const pugi::xml_node node);
|
||
|
int shipFromXml(const pugi::xml_node node);
|
||
|
int frameFromXml(const pugi::xml_node node);
|
||
|
int stationFromXml(const pugi::xml_node node);
|
||
|
int waterlinePosFromXml(const pugi::xml_node node);
|
||
|
int buttocklinePosFromXml(const pugi::xml_node node);
|
||
|
int calWaterPosFromXml(const pugi::xml_node node);
|
||
|
int calSecPosFromXml(const pugi::xml_node node);
|
||
|
int calHeelPosFromXml(const pugi::xml_node node);
|
||
|
int calTrimPosFromXml(const pugi::xml_node node);
|
||
|
int maxIDFromXml(const pugi::xml_node node);
|
||
|
int maxNameFromXml(const pugi::xml_node node);
|
||
|
int elementFromXml(const pugi::xml_node node);
|
||
|
|
||
|
int point3DFromXml(const pugi::xml_node node);
|
||
|
int curveFromXml(const pugi::xml_node node);
|
||
|
int surfaceFromXml(const pugi::xml_node node);
|
||
|
int solidFromXml(const pugi::xml_node node);
|
||
|
int mdsFromXml(const pugi::xml_node node);
|
||
|
int shellSurfFromXml(const pugi::xml_node node);
|
||
|
int hullFromXml(const pugi::xml_node node);
|
||
|
int deckSurfFromXml(const pugi::xml_node node);
|
||
|
int boundSurfFromXml(const pugi::xml_node node);
|
||
|
int subdivSurfFromXml(const pugi::xml_node node);
|
||
|
int ocrFromXml(const pugi::xml_node node);
|
||
|
int spaceFromXml(const pugi::xml_node node);
|
||
|
int appendAgeFromXml(const pugi::xml_node node);
|
||
|
int materialFromXml(const pugi::xml_node node);
|
||
|
int plateTypeFromXml(const pugi::xml_node node);
|
||
|
int beamTypeFromXml(const pugi::xml_node node);
|
||
|
int sectionFromXml(const pugi::xml_node node);
|
||
|
int scNodeFromXml(const pugi::xml_node node);
|
||
|
int scBeamFromXml(const pugi::xml_node node);
|
||
|
int scPlateFromXml(const pugi::xml_node node);
|
||
|
int scLoopFromXml(const pugi::xml_node node);
|
||
|
int scpFromXml(const pugi::xml_node node);
|
||
|
int sslFromXml(const pugi::xml_node node);
|
||
|
|
||
|
int ovmToXml(pugi::xml_node node);
|
||
|
int docToXml(pugi::xml_node node);
|
||
|
int shipToXml(pugi::xml_node node);
|
||
|
int frameToXml(pugi::xml_node node);
|
||
|
int stationToXml(pugi::xml_node node);
|
||
|
int waterlinePosToXml(pugi::xml_node node);
|
||
|
int buttocklinePosToXml(pugi::xml_node node);
|
||
|
int calWaterPosToXml(pugi::xml_node node);
|
||
|
int calSecPosToXml(pugi::xml_node node);
|
||
|
int calHeelPosToXml(pugi::xml_node node);
|
||
|
int calTrimPosToXml(pugi::xml_node node);
|
||
|
int maxIDToXml(pugi::xml_node node);
|
||
|
int maxNameToXml(pugi::xml_node node);
|
||
|
int elementToXml(pugi::xml_node node);
|
||
|
|
||
|
int point3DToXml(pugi::xml_node node);
|
||
|
int curveToXml(pugi::xml_node node);
|
||
|
int surfaceToXml(pugi::xml_node node);
|
||
|
int solidToXml(pugi::xml_node node);
|
||
|
int mdsToXml(pugi::xml_node node);
|
||
|
int shellSurfToXml(pugi::xml_node node);
|
||
|
int hullToXml(pugi::xml_node node);
|
||
|
int deckSurfToXml(pugi::xml_node node);
|
||
|
int boundSurfToXml(pugi::xml_node node);
|
||
|
int subdivSurfToXml(pugi::xml_node node);
|
||
|
int ocrToXml(pugi::xml_node node);
|
||
|
int spaceToXml(pugi::xml_node node);
|
||
|
int appendAgeToXml(pugi::xml_node node);
|
||
|
int materialToXml(pugi::xml_node node);
|
||
|
int plateTypeToXml(pugi::xml_node node);
|
||
|
int beamTypeToXml(pugi::xml_node node);
|
||
|
int sectionToXml(pugi::xml_node node);
|
||
|
int scNodeToXml(pugi::xml_node node);
|
||
|
int scBeamToXml(pugi::xml_node node);
|
||
|
int scPlateToXml(pugi::xml_node node);
|
||
|
int scLoopToXml(pugi::xml_node node);
|
||
|
int scpToXml(pugi::xml_node node);
|
||
|
int sslToXml(pugi::xml_node node);
|
||
|
|
||
|
|
||
|
public:
|
||
|
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 std::vector<int> GetAllObject(DisplayMode3D_M type);
|
||
|
|
||
|
void deleteObj(IModel* Obj);
|
||
|
void deleteObjs(std::vector<IModel*>* pObjs);
|
||
|
void insertObjs(std::vector<IModel*>* pObjs);
|
||
|
void insertObj(IModel* pObj);
|
||
|
|
||
|
//删除不需要的 //增加需要 并做更新到map
|
||
|
void UpdateModelMaps(vector<IModel*>* discardData, vector<IModel*>* usingData);
|
||
|
void UpdateModelMaps();
|
||
|
void UpdateModelMaps(E_GEO_3D_OBJ_TYPE type);
|
||
|
DisplayMode3D_M getDisplayMode3DType(E_GEO_3D_OBJ_TYPE type);
|
||
|
void UpdateModelMaps(DisplayMode3D_M type);
|
||
|
void UpdateMaxID();
|
||
|
void CheckMaxID();
|
||
|
|
||
|
private:
|
||
|
// 图形对象是否可见
|
||
|
// 点、线、面、体、主体等显示与隐藏
|
||
|
std::vector<std::pair<DisplayMode3D_M, bool>> m_ObjectVisibleMode; // 保留插入顺序
|
||
|
|
||
|
// 文档域变量
|
||
|
DocumentVar m_DocumentVar;
|
||
|
|
||
|
// 船舶基本数据
|
||
|
ShipInfo_M m_ShipInfo;
|
||
|
std::vector<std::pair<int, Frame_M>> m_Frames;
|
||
|
std::vector<std::pair<int, Station_M>> m_Station;
|
||
|
std::vector<std::pair<int, WaterlinePos_M>> m_WaterlinePos;
|
||
|
std::vector<std::pair<int, ButtocklinePos_M>> m_ButtocklinePos;
|
||
|
std::vector<std::pair<int, CalWaterPos_M>> m_CalWaterPos;
|
||
|
std::vector<std::pair<int, CalSecPos_M>> m_CalSecPos;
|
||
|
std::vector<std::pair<int, CalHeelPos_M>> m_CalHeelPos;
|
||
|
std::vector<std::pair<int, CalTrimPos_M>> m_CalTrimPos;
|
||
|
|
||
|
// 模型数据
|
||
|
std::vector<std::pair<std::string, int>> m_MaxIDs;
|
||
|
std::vector<std::pair<std::string, int>> m_MaxNames;
|
||
|
|
||
|
std::vector<std::pair<int, Point3D_M>> m_Points;
|
||
|
std::vector<std::pair<int, Curve_M>> m_Curves;
|
||
|
std::vector<std::pair<int, Surface_M>> m_Surfaces;
|
||
|
std::vector<std::pair<int, Solid_M>> m_Solids;
|
||
|
|
||
|
std::vector<std::pair<int, MainDeckSurf_M>> m_MainDeckSurfs;
|
||
|
std::vector<std::pair<int, ShellSurf_M>> m_ShellSurfs;
|
||
|
std::vector<std::pair<int, Hull_M>> m_Hulls;
|
||
|
std::vector<std::pair<int, DeckSurf_M>> m_DeckSurfs;
|
||
|
std::vector<std::pair<int, BoundSurf_M>> m_BoundSurfs;
|
||
|
std::vector<std::pair<int, SubdivSurf_M>> m_SubdivSurfs;
|
||
|
std::vector<std::pair<int, OpenCargoRegion_M>> m_OpenCargoRegions;
|
||
|
std::vector<std::pair<int, Space_M>> m_Spaces;
|
||
|
std::vector<std::pair<int, Appendage_M>> m_Appendages;
|
||
|
|
||
|
//static int GetObjectByName(const std::string &name);
|
||
|
|
||
|
// static QMap<QString, QMap<int, IModel *>> modelMaps;
|
||
|
|
||
|
// QMap<int, struct Material_M> m_Materials;
|
||
|
// QMap<int, struct PlateType_M> m_PlateTypes;
|
||
|
// QMap<int, struct BeamType_M> m_BeamTypes;
|
||
|
// QMap<int, struct Section_M> m_Sections;
|
||
|
// QMap<int, struct ScNode_M> m_ScNodes;
|
||
|
// QMap<int, struct ScBeam_M> m_ScBeams;
|
||
|
// QMap<int, struct ScPlate_M> m_ScPlates;
|
||
|
// QMap<int, struct ScLoop_M> m_ScLoops;
|
||
|
// QMap<int, struct ScCharactPlate_M> m_ScCharactPlates;
|
||
|
// QMap<int, struct ScShapeLine_M> m_ScShapeLines;
|
||
|
};
|
||
|
|
||
|
|
||
|
struct GroupStruct_Data
|
||
|
{
|
||
|
GroupStruct_Data()
|
||
|
{
|
||
|
m_strName = "";
|
||
|
m_strId = "";
|
||
|
m_type = E_GEO_3D_OBJ_TYPE_SIZE;
|
||
|
|
||
|
}
|
||
|
~GroupStruct_Data()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
std::string getName() const { return m_strName; }
|
||
|
std::string getId() const { return m_strId; }
|
||
|
E_GEO_3D_OBJ_TYPE getType() const { return m_type; }
|
||
|
|
||
|
// Setter functions
|
||
|
void setName(const std::string& str) { m_strName = str; }
|
||
|
void setId(const std::string& id) { m_strId = id; }
|
||
|
void setType(E_GEO_3D_OBJ_TYPE type) { m_type = type; }
|
||
|
|
||
|
private:
|
||
|
std::string m_strName;
|
||
|
std::string m_strId;
|
||
|
E_GEO_3D_OBJ_TYPE m_type;
|
||
|
};
|
||
|
class DATAMANAGER_DLL_API_EXPORTS GroupStruct : public Serialization
|
||
|
{
|
||
|
public:
|
||
|
GroupStruct();
|
||
|
~GroupStruct();
|
||
|
virtual int fromXml(const pugi::xml_node node);
|
||
|
|
||
|
virtual int toXml(pugi::xml_node node);
|
||
|
|
||
|
int dataFromXml(const pugi::xml_node node, std::unordered_map<std::string, std::vector<GroupStruct_Data>>& _Point3DGroup_tmp, E_GEO_3D_OBJ_TYPE type);
|
||
|
|
||
|
|
||
|
|
||
|
private:
|
||
|
|
||
|
std::unordered_map<std::string, std::vector<GroupStruct_Data>> m_Point3DGroup;
|
||
|
|
||
|
std::unordered_map<std::string, std::vector<GroupStruct_Data>> m_CurveGroup;
|
||
|
|
||
|
std::unordered_map<std::string, std::vector<GroupStruct_Data>> m_SurfaceGroup;
|
||
|
|
||
|
std::unordered_map<std::string, std::vector<GroupStruct_Data>> m_SolidGroup;
|
||
|
|
||
|
};
|
||
|
#endif
|