1530 lines
48 KiB
C++
1530 lines
48 KiB
C++
#ifndef STABCALCULATION_H
|
||
#define STABCALCULATION_H
|
||
|
||
#include <QString>
|
||
#include <string>
|
||
#include <map>
|
||
#include "Serialization.h"
|
||
#include "DataCheck.h"
|
||
//#include "XmlSerialization.h"
|
||
#include "ChangeFSPos.h"
|
||
#include "ModelDS.hxx"
|
||
|
||
// using namespace model_ds;
|
||
|
||
// 该文件中定义所有稳性计算 所需 结构体 和 序列化/反序列化 方法
|
||
|
||
struct XLabel
|
||
{
|
||
std::string id;
|
||
double x;
|
||
};
|
||
|
||
struct StationLabel
|
||
{
|
||
StationLabel()
|
||
{
|
||
id = "";
|
||
pos = 0;
|
||
}
|
||
std::string id;
|
||
double pos;
|
||
};
|
||
|
||
struct WaterlineLabel :public StationLabel
|
||
{
|
||
|
||
};
|
||
struct ButtocklineLabel :public StationLabel
|
||
{
|
||
|
||
};
|
||
|
||
struct Pull {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double tb; // 对应 XML 中的 <xs:element name="Tb">
|
||
double zt; // 对应 XML 中的 <xs:element name="Zt">
|
||
};
|
||
|
||
struct Jet {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double f; // 对应 XML 中的 <xs:element name="F">
|
||
double z; // 对应 XML 中的 <xs:element name="Z">
|
||
|
||
// 默认构造函数
|
||
Jet() : f(0.0), z(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
Jet(const std::string& caseid, const std::string& id, double f, double z)
|
||
: caseid(caseid), id(id), f(f), z(z) {}
|
||
};
|
||
|
||
struct Lift {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double wx; // 对应 XML 中的 <xs:element name="Wx">
|
||
double bx; // 对应 XML 中的 <xs:element name="bx">
|
||
double mi; // 对应 XML 中的 <xs:element name="Mi">
|
||
|
||
// 默认构造函数
|
||
Lift() : wx(0.0), bx(0.0), mi(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
Lift(const std::string& caseid, const std::string& id, double wx, double bx, double mi)
|
||
: caseid(caseid), id(id), wx(wx), bx(bx), mi(mi) {}
|
||
};
|
||
struct Sidesway {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double p; // 对应 XML 中的 <xs:element name="P">
|
||
double zh; // 对应 XML 中的 <xs:element name="Zh">
|
||
|
||
// 默认构造函数
|
||
Sidesway() : p(0.0), zh(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
Sidesway(const std::string& caseid, const std::string& id, double p, double zh)
|
||
: caseid(caseid), id(id), p(p), zh(zh) {}
|
||
};
|
||
|
||
struct Pile {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double wd; // 对应 XML 中的 <xs:element name="Wd">
|
||
double bd; // 对应 XML 中的 <xs:element name="bd">
|
||
|
||
// 默认构造函数
|
||
Pile() : wd(0.0), bd(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
Pile(const std::string& caseid, const std::string& id, double wd, double bd)
|
||
: caseid(caseid), id(id), wd(wd), bd(bd) {}
|
||
};
|
||
|
||
struct Mud {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double wp; // 对应 XML 中的 <xs:element name="Wp">
|
||
double bp; // 对应 XML 中的 <xs:element name="bp">
|
||
|
||
// 默认构造函数
|
||
Mud() : wp(0.0), bp(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
Mud(const std::string& caseid, const std::string& id, double wp, double bp)
|
||
: caseid(caseid), id(id), wp(wp), bp(bp) {}
|
||
};
|
||
|
||
struct MudAsym {
|
||
std::string caseid; // 对应 XML 中的 <xs:element name="CaseID">
|
||
std::string id; // 对应 XML 中的 <xs:element name="ID">
|
||
double w; // 对应 XML 中的 <xs:element name="W">
|
||
double y; // 对应 XML 中的 <xs:element name="Y">
|
||
double unitweight; // 对应 XML 中的 <xs:element name="UnitWeight">
|
||
|
||
// 默认构造函数
|
||
MudAsym() : w(0.0), y(0.0), unitweight(0.0) {}
|
||
|
||
// 构造函数(带参数)
|
||
MudAsym(const std::string& caseid, const std::string& id, double w, double y, double unitweight)
|
||
: caseid(caseid), id(id), w(w), y(y), unitweight(unitweight) {}
|
||
};
|
||
|
||
struct DamCompartmentProb {
|
||
std::string id;
|
||
std::string compartment_ids;
|
||
double x1;
|
||
double x2;
|
||
double b1;
|
||
double b2;
|
||
double h1;
|
||
double h2;
|
||
double hm;
|
||
|
||
// 构造函数初始化
|
||
DamCompartmentProb(
|
||
const std::string& id_ = "",
|
||
const std::string& compartmentids_ = "",
|
||
double x1_ = 0.0,
|
||
double x2_ = 0.0,
|
||
double b1_ = 0.0,
|
||
double b2_ = 0.0,
|
||
double h1_ = 0.0,
|
||
double h2_ = 0.0,
|
||
double hm_ = 0.0
|
||
)
|
||
: id(id_),
|
||
compartment_ids(compartmentids_),
|
||
x1(x1_),
|
||
x2(x2_),
|
||
b1(b1_),
|
||
b2(b2_),
|
||
h1(h1_),
|
||
h2(h2_),
|
||
hm(hm_) {}
|
||
};
|
||
|
||
|
||
struct BInf
|
||
{
|
||
std::string paramid;
|
||
std::string unit;
|
||
std::string caption;
|
||
std::string value_type;
|
||
std::string value;
|
||
std::string remark;
|
||
|
||
// void fromBInf_Row(BInf_Row& row)
|
||
// {
|
||
// paramid = row.ParamID();
|
||
// caption = row.Caption().get();
|
||
// remark = row.Remark().get();
|
||
// unit = row.Unit().get();
|
||
// value = row.Value().get();
|
||
// value_type = row.ValueType().get();
|
||
// }
|
||
};
|
||
|
||
struct Shell
|
||
{
|
||
std::string id;
|
||
std::string shell_id;
|
||
int type;
|
||
int shell_affect;
|
||
double affect_coef;
|
||
std::string remark;
|
||
int sid;
|
||
};
|
||
|
||
struct FloodPoint
|
||
{
|
||
std::string id;
|
||
std::string xsymbol;
|
||
double x;
|
||
double y;
|
||
double z;
|
||
};
|
||
|
||
struct LimitStaticPoint
|
||
{
|
||
std::string id;
|
||
std::string xsymbol;
|
||
double x1;
|
||
double y1;
|
||
double z1;
|
||
double x2;
|
||
double y2;
|
||
double z2;
|
||
};
|
||
|
||
struct ImmersionPoint
|
||
{
|
||
std::string id;
|
||
std::string xsymbol;
|
||
double x;
|
||
double y;
|
||
double z;
|
||
std::string compartment;
|
||
};
|
||
|
||
struct Deckline
|
||
{
|
||
std::string id;
|
||
std::string xsymbol;
|
||
double x;
|
||
double y;
|
||
double z;
|
||
};
|
||
|
||
struct Compartment
|
||
{
|
||
std::string id;
|
||
std::string space_id;
|
||
std::string flood_points;
|
||
int type;
|
||
double coef;
|
||
double permeability;
|
||
double density;
|
||
std::string remark;
|
||
int sid;
|
||
};
|
||
|
||
struct LWT
|
||
{
|
||
std::string id;
|
||
int type;
|
||
double g;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
std::string xa_symbol;
|
||
std::string xf_symbol;
|
||
double xa;
|
||
double xf;
|
||
};
|
||
|
||
struct PartialLoad
|
||
{
|
||
std::string id;
|
||
std::string remark;
|
||
};
|
||
|
||
struct PartialLoadWeight
|
||
{
|
||
PartialLoadWeight()
|
||
{
|
||
partial_load_id = "";
|
||
id = "";
|
||
wt_type = 0;
|
||
compartment = "";
|
||
compartment_type = 0;
|
||
free_surf_type = 0;
|
||
g = 0;
|
||
ratio = 0;
|
||
density = 0;
|
||
xg_symbol = "";
|
||
xg = 0;
|
||
yg = 0;
|
||
zg = 0;
|
||
xa_symbol = "";
|
||
xf_symbol = "";
|
||
xa = 0;
|
||
xf = 0;
|
||
}
|
||
|
||
std::string partial_load_id;
|
||
std::string id;
|
||
int wt_type;
|
||
std::string compartment;
|
||
int compartment_type;
|
||
int free_surf_type;
|
||
double g;
|
||
double ratio;
|
||
double density;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
std::string xa_symbol;
|
||
std::string xf_symbol;
|
||
double xa;
|
||
double xf;
|
||
};
|
||
|
||
struct PartialLoadItem
|
||
{
|
||
std::string partialloadid;
|
||
std::string id;
|
||
std::string type;
|
||
std::string compartment;
|
||
double g;
|
||
double ratio;
|
||
double density = 0;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
std::string xa_symbol;
|
||
std::string xf_symbol;
|
||
double xa;
|
||
double xf;
|
||
int freesurftype;
|
||
double v;
|
||
double l;
|
||
double b;
|
||
double h;
|
||
int persontype;
|
||
double np;
|
||
double bp;
|
||
double lp;
|
||
double mpy;
|
||
double mpz;
|
||
double gbulk;
|
||
};
|
||
|
||
|
||
struct PartialLoadFreeSurf
|
||
{
|
||
std::string partial_load_id;
|
||
std::string id;
|
||
int freesurftype = 3; // 默认值为3
|
||
std::string compartment = "";
|
||
double g = 0.0; // 默认值为0
|
||
double ratio = 0.5; // 默认值为0.5
|
||
double density = 0.0; // 默认值为0
|
||
double v = 0.0; // 默认值为0
|
||
double l = 0.0; // 默认值为0
|
||
double b = 0.0; // 默认值为0
|
||
double h = 0.0; // 默认值为0
|
||
|
||
};
|
||
|
||
struct PartialLoadBulk
|
||
{
|
||
std::string partial_load_id;
|
||
std::string id;
|
||
double gbulk;
|
||
};
|
||
|
||
struct PartialLoadPerson
|
||
{
|
||
std::string partial_load_id;
|
||
std::string id;
|
||
int person_type;
|
||
double np;
|
||
double bp;
|
||
double lp;
|
||
double mpy;
|
||
double mpz;
|
||
};
|
||
|
||
struct PartialLoadIce
|
||
{
|
||
std::string partial_load_id;
|
||
std::string id;
|
||
int type;
|
||
double as;
|
||
double wi;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
};
|
||
|
||
struct WindFixed
|
||
{
|
||
std::string id;
|
||
int type;
|
||
double as;
|
||
double zf;
|
||
double full_coef;
|
||
double stream_line_coef;
|
||
};
|
||
|
||
struct WindNonFixed
|
||
{
|
||
std::string id;
|
||
int type;
|
||
double as;
|
||
double zf;
|
||
double full_coef;
|
||
double stream_line_coef;
|
||
};
|
||
|
||
struct Case
|
||
{
|
||
std::string id;
|
||
int ship_type;
|
||
int child_type;
|
||
std::string criterial_factor;
|
||
int check_state;
|
||
std::string partial_load;
|
||
std::string wind;
|
||
std::string remark;
|
||
};
|
||
|
||
struct AllowNM
|
||
{
|
||
double x;
|
||
double nz;
|
||
double nf;
|
||
double mz;
|
||
double mf;
|
||
};
|
||
|
||
struct DamCase
|
||
{
|
||
std::string id;
|
||
std::string remark;
|
||
};
|
||
|
||
struct DamCompartment
|
||
{
|
||
std::string id;
|
||
std::string compartment_ids;
|
||
};
|
||
|
||
struct DamCaseProb
|
||
{
|
||
std::string id;
|
||
int type;
|
||
double d;
|
||
double at;
|
||
double gm;
|
||
};
|
||
|
||
struct DamRegion
|
||
{
|
||
int id;
|
||
int type;
|
||
std::string xa_symbol;
|
||
double xa;
|
||
std::string xf_symbol;
|
||
double xf;
|
||
std::string yp;
|
||
std::string zp;
|
||
|
||
double ymax; // 对应 XML 中的 Ymax (xs:double),minOccurs="0"
|
||
double hmax; // 对应 XML 中的 Hmax (xs:double),minOccurs="0"
|
||
int myp; // 对应 XML 中的 Myp (xs:int),minOccurs="0"
|
||
int mzp; // 对应 XML 中的 Mzp (xs:int),minOccurs="0"
|
||
bool isnew; // 对应 XML 中的 isNew (xs:boolean),default="true",minOccurs="0"
|
||
};
|
||
|
||
struct CompExtent
|
||
{
|
||
std::string id;
|
||
std::string space_id;
|
||
double xmin;
|
||
double xmax;
|
||
double ymin;
|
||
double ymax;
|
||
double zmin;
|
||
double zmax;
|
||
|
||
int xregionid; // 对应 XML 中的 XRegionID
|
||
int yregionid; // 对应 XML 中的 YRegionID
|
||
int zregionid; // 对应 XML 中的 ZRegionID
|
||
};
|
||
|
||
|
||
struct IncliningDraft
|
||
{
|
||
std::string id;
|
||
double aft;
|
||
double mid;
|
||
double bow;
|
||
std::string remark;
|
||
};
|
||
|
||
struct IncliningStatus
|
||
{
|
||
std::string paramid;
|
||
std::string unit;
|
||
std::string caption;
|
||
std::string value_type;
|
||
std::string value;
|
||
std::string remark;
|
||
};
|
||
|
||
struct IncliningExtraWeight
|
||
{
|
||
std::string id;
|
||
int type;
|
||
double g;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
std::string compartment;
|
||
double density;
|
||
double ratio;
|
||
};
|
||
|
||
struct IncliningRelocateWeight
|
||
{
|
||
std::string id;
|
||
double g;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
std::string xg1_symbol;
|
||
double xg1;
|
||
double yg1;
|
||
double zg1;
|
||
};
|
||
|
||
struct IncliningAbsentWeight
|
||
{
|
||
std::string id;
|
||
double g;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
};
|
||
|
||
struct IncliningTank
|
||
{
|
||
std::string id;
|
||
std::string compartment;
|
||
double g;
|
||
double ratio;
|
||
double density;
|
||
double v;
|
||
double l;
|
||
double b;
|
||
double h;
|
||
};
|
||
|
||
struct IncliningMobileWeight
|
||
{
|
||
std::string id;
|
||
double g;
|
||
std::string xg_symbol;
|
||
double xg;
|
||
double yg;
|
||
double zg;
|
||
double b;
|
||
std::string description;
|
||
};
|
||
|
||
struct IncliningDevice
|
||
{
|
||
int id;
|
||
std::string x;
|
||
std::string param;
|
||
std::string remark;
|
||
};
|
||
|
||
struct IncliningCase
|
||
{
|
||
int id;
|
||
std::string weight_ids;
|
||
std::string port_weight_ids;
|
||
};
|
||
|
||
struct IncliningRecord
|
||
{
|
||
IncliningRecord()
|
||
{
|
||
device_id = 0;
|
||
case_id = 0;
|
||
avg= "";
|
||
no1= ""; // 对应 XML 中的 No1
|
||
no2= ""; // 对应 XML 中的 No2
|
||
no3= ""; // 对应 XML 中的 No3
|
||
no4= ""; // 对应 XML 中的 No4
|
||
no5= ""; // 对应 XML 中的 No5
|
||
no6= ""; // 对应 XML 中的 No6
|
||
no7= ""; // 对应 XML 中的 No7
|
||
no8= ""; // 对应 XML 中的 No8
|
||
no9= ""; // 对应 XML 中的 No9
|
||
}
|
||
int device_id;
|
||
int case_id;
|
||
std::string avg;
|
||
std::string no1; // 对应 XML 中的 No1
|
||
std::string no2; // 对应 XML 中的 No2
|
||
std::string no3; // 对应 XML 中的 No3
|
||
std::string no4; // 对应 XML 中的 No4
|
||
std::string no5; // 对应 XML 中的 No5
|
||
std::string no6; // 对应 XML 中的 No6
|
||
std::string no7; // 对应 XML 中的 No7
|
||
std::string no8; // 对应 XML 中的 No8
|
||
std::string no9; // 对应 XML 中的 No9
|
||
};
|
||
|
||
struct StabCalcBaseData
|
||
{
|
||
public:
|
||
StabCalcBaseData()
|
||
{
|
||
|
||
}
|
||
~StabCalcBaseData()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
|
||
static std::set<std::string> m_lwtsumID;
|
||
|
||
static bool IsInLWTSumID(string id)
|
||
{
|
||
if (m_lwtsumID.find(id) == m_lwtsumID.end())
|
||
{
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
virtual int fromXml();
|
||
virtual int toXml();
|
||
void updateData();
|
||
|
||
static std::vector<BInf> binf_data_grid_view; // 计算参数网格
|
||
static std::vector<Shell> shell_data_grid_view; // 船壳网格
|
||
static std::vector<Compartment> compartment_data_grid_view; // 舱容参数网格
|
||
static std::vector<FloodPoint> flood_point_data_grid_view; // 进水点网格
|
||
static std::vector<ImmersionPoint> immersion_point_data_grid_view; // 浸没点网格
|
||
static std::vector<LimitStaticPoint> limit_static_point_data_grid_view; // 出水入水点网格
|
||
static std::vector<Deckline> deckline_data_grid_view; // 甲板边线网格
|
||
static std::vector<LWT> lwt_data_grid_view; // 计算参数表格
|
||
static std::vector<PartialLoad> partial_load_data_grid_view; // 装载项
|
||
static std::vector<PartialLoadWeight> partial_load_weight_data_grid_view; // 装载重量及关联自由页面
|
||
static std::vector<PartialLoadFreeSurf> partial_load_free_surf_data_grid_view; // 非关联自由页面
|
||
static std::vector<PartialLoadBulk> partial_load_bulk_data_grid_view; // 散货滑移
|
||
static std::vector<PartialLoadPerson> partial_load_person_data_grid_view; // 乘客集舷
|
||
static std::vector<PartialLoadIce> partial_load_ice_data_grid_view; // 结冰重量
|
||
static std::vector<WindFixed> wind_fixed_data_grid_view; // 固定受风项
|
||
static std::vector<WindNonFixed> wind_non_fixed_data_grid_view; // 活动受风项
|
||
static std::vector<Case> case_data_grid_view; // 固定受风项
|
||
static std::vector<AllowNM> allow_nm_data_grid_view; // 计算参数
|
||
static std::vector<DamCase> dam_case_data_grid_view;
|
||
static std::vector<DamCompartment> dam_compartment_data_grid_view;
|
||
static std::vector<DamCaseProb> dam_case_prob_data_grid_view;
|
||
static std::vector<DamRegion> dam_region_data_grid_view;
|
||
static std::vector<CompExtent> comp_extent_data_grid_view;
|
||
static std::vector<DamCompartmentProb> dam_comp_prob_data_grid_view;
|
||
static std::vector<IncliningDraft> inclining_draft_data_grid_view;
|
||
static std::vector<IncliningStatus> inclining_status_data_grid_view;
|
||
static std::vector<IncliningExtraWeight> inclining_extra_weight_data_grid_view;
|
||
static std::vector<IncliningRelocateWeight> inclining_relocate_weight_data_grid_view;
|
||
static std::vector<IncliningAbsentWeight> inclining_absent_weight_data_grid_view;
|
||
static std::vector<IncliningTank> inclining_tank_data_grid_view;
|
||
static std::vector<IncliningMobileWeight> inclining_mobile_weight_data_grid_view;
|
||
static std::vector<IncliningDevice> inclining_device_data_grid_view;
|
||
static std::vector<IncliningCase> inclining_case_data_grid_view;
|
||
static std::vector<IncliningRecord> inclining_record_data_grid_view;
|
||
static std::vector<PartialLoadItem> partial_load_item_data_grid_view;
|
||
static std::vector<XLabel> xlabel_data_grid_view;
|
||
|
||
|
||
static std::vector<Pull> Pull_data_grid_view;
|
||
static std::vector<Jet> Jet_data_grid_view;
|
||
static std::vector<Lift> Lift_data_grid_view;
|
||
static std::vector<Sidesway> Sidesway_data_grid_view;
|
||
static std::vector<Pile> Pile_data_grid_view;
|
||
static std::vector<Mud> Mud_data_grid_view;
|
||
static std::vector<MudAsym> MudAsym_data_grid_view;
|
||
|
||
static std::vector<StationLabel> station_label_data_grid_view;
|
||
|
||
static std::vector<WaterlineLabel> waterline_label_data_grid_view;
|
||
|
||
static std::vector<ButtocklineLabel> buttockline_label_data_grid_view;
|
||
public:
|
||
|
||
static std::string FindByParamID(std::string paramid);
|
||
|
||
static Compartment* compartment_FindByID(std::string id);
|
||
|
||
static Case* Case_FindByID(std::string id);
|
||
|
||
static IncliningCase* IncliningCase_FindByID(int id);
|
||
|
||
static PartialLoad* PartialLoad_FindByID(std::string id);
|
||
static WindNonFixed* WindNonFixed_FindByID(std::string id);
|
||
|
||
|
||
|
||
template <typename T>
|
||
static bool FindByParamID(std::string paramid, T& value)
|
||
{
|
||
std::string strvalue = FindByParamID(paramid);
|
||
try
|
||
{
|
||
value = std::stod(strvalue);
|
||
|
||
}
|
||
catch (const std::exception&)
|
||
{
|
||
|
||
|
||
}
|
||
return true;
|
||
}
|
||
|
||
static bool IsContainSeparators(const std::string& str_sr) {
|
||
|
||
QString str = QString::fromStdString(str_sr);
|
||
QList<QChar> separators = { ';', ':', ',', ';', ':', ',' };
|
||
|
||
// 如果字符串为空,返回 false
|
||
if (str.isEmpty()) return false;
|
||
|
||
// 遍历每个分隔符,检查字符串中是否包含分隔符
|
||
for (const QChar& separator : separators) {
|
||
if (str.contains(separator)) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
static vector<string> getSeparators(const std::string& str_sr) {
|
||
|
||
QString str = QString::fromStdString(str_sr); // 转换为 QString
|
||
QList<QChar> separators = { ';', ':', ',', ';', ':', ',' };
|
||
|
||
std::vector<std::string> result;
|
||
|
||
// 如果字符串为空,返回空 vector
|
||
if (str.isEmpty()) return result;
|
||
|
||
QString currentPart;
|
||
// 遍历字符串中的每个字符
|
||
for (int i = 0; i < str.size(); ++i) {
|
||
QChar currentChar = str[i];
|
||
|
||
// 如果当前字符是分隔符
|
||
if (separators.contains(currentChar)) {
|
||
// 将当前部分添加到结果中
|
||
if (!currentPart.isEmpty()) {
|
||
result.push_back(currentPart.toStdString());
|
||
currentPart.clear(); // 清空当前部分,开始新的部分
|
||
}
|
||
}
|
||
else {
|
||
// 否则,将当前字符添加到当前部分
|
||
currentPart += currentChar;
|
||
}
|
||
}
|
||
|
||
// 添加最后的部分(如果有的话)
|
||
if (!currentPart.isEmpty()) {
|
||
result.push_back(currentPart.toStdString());
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
static bool IsInWindSumID(const std::string& id) {
|
||
// 定义 WindSumID 数组
|
||
std::array<std::string, 4> windSumID = { "主甲板以下", "满实", "非满实", "全船" };
|
||
|
||
// 遍历数组检查是否包含指定 id
|
||
for (const auto& item : windSumID) {
|
||
if (item == id) return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
|
||
static bool IsInSumID(const std::string& id) {
|
||
// 定义 WindSumID 数组
|
||
std::array<std::string, 4> SumID = { "全船" };
|
||
|
||
// 遍历数组检查是否包含指定 id
|
||
for (const auto& item : SumID) {
|
||
if (item == id) return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
template <typename T>
|
||
static void convertToJson(json& outJson, std::string strKey, std::vector<T>& vData)
|
||
{
|
||
// 将每个元素转换为 JSON 并添加到 outJson[strKey] 中
|
||
for (const auto& item : vData) {
|
||
outJson[strKey].push_back(item); // 自动调用 nlohmann 库的序列化函数
|
||
}
|
||
}
|
||
|
||
// 模板函数,将 JSON 数据反向转换为容器中的对象
|
||
template <typename T>
|
||
static void convertFromJson(const json& inJson, std::string strKey, std::vector<T>& vData)
|
||
{
|
||
// 检查键是否存在并且是一个数组
|
||
if (inJson.contains(strKey) && inJson[strKey].is_array()) {
|
||
// 清空容器数据
|
||
vData.clear();
|
||
|
||
// 遍历 JSON 数组,将每个元素反序列化到容器中
|
||
for (const auto& item : inJson[strKey]) {
|
||
T obj = item.get<T>(); // 使用 nlohmann::json 的 get() 方法反序列化
|
||
vData.push_back(obj); // 将对象添加到容器
|
||
}
|
||
}
|
||
}
|
||
};
|
||
|
||
|
||
enum eBinfTabpage_Type
|
||
{
|
||
eBinfTabpage_Type_Hydro = 0,
|
||
eBinfTabpage_Type_TankCap,
|
||
eBinfTabpage_Type_Intact,
|
||
eBinfTabpage_Type_AllowKG,
|
||
eBinfTabpage_Type_Damage,
|
||
eBinfTabpage_Type_DamageProb,
|
||
eBinfTabpage_Type_Inclining,
|
||
eBinfTabpage_Type_Size
|
||
};
|
||
|
||
// 舱容标签页容器
|
||
struct TankCapTabpage
|
||
{
|
||
// 舱容参数网格
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "compartment_data_grid_view", StabCalcBaseData::compartment_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "compartment_data_grid_view", StabCalcBaseData::compartment_data_grid_view);
|
||
}
|
||
|
||
|
||
};
|
||
|
||
// 基础信息标签页容器
|
||
struct BinfTabpage
|
||
{
|
||
void convertToJson(json& j, eBinfTabpage_Type type);
|
||
void getDisPlayData(eBinfTabpage_Type type, std::vector<BInf>& binf_data_grid_view);
|
||
|
||
void convertFromJson(json& j, eBinfTabpage_Type type);
|
||
};
|
||
|
||
// 船型特征点标签页容器
|
||
struct FloodpointTabpage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "flood_point_data_grid_view", StabCalcBaseData::flood_point_data_grid_view); // 进水点网格
|
||
StabCalcBaseData::convertToJson(j, "immersion_point_data_grid_view", StabCalcBaseData::immersion_point_data_grid_view); // 浸没点网格
|
||
StabCalcBaseData::convertToJson(j, "limit_static_point_data_grid_view", StabCalcBaseData::limit_static_point_data_grid_view); // 出水入水点网格
|
||
StabCalcBaseData::convertToJson(j, "deckline_data_grid_view", StabCalcBaseData::deckline_data_grid_view); // 甲板边线网格
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "flood_point_data_grid_view", StabCalcBaseData::flood_point_data_grid_view); // 进水点网格
|
||
StabCalcBaseData::convertFromJson(j, "immersion_point_data_grid_view", StabCalcBaseData::immersion_point_data_grid_view); // 浸没点网格
|
||
StabCalcBaseData::convertFromJson(j, "limit_static_point_data_grid_view", StabCalcBaseData::limit_static_point_data_grid_view); // 出水入水点网格
|
||
StabCalcBaseData::convertFromJson(j, "deckline_data_grid_view", StabCalcBaseData::deckline_data_grid_view); // 甲板边线网格
|
||
}
|
||
};
|
||
|
||
// 空船重量
|
||
struct IntactLwtTabpage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "lwt_data_grid_view", StabCalcBaseData::lwt_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "lwt_data_grid_view", StabCalcBaseData::lwt_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 装载项
|
||
struct IntactPartialLoadTabpage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "partial_load_data_grid_view", StabCalcBaseData::partial_load_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "partial_load_weight_data_grid_view", StabCalcBaseData::partial_load_weight_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "partial_load_free_surf_data_grid_view", StabCalcBaseData::partial_load_free_surf_data_grid_view);
|
||
|
||
StabCalcBaseData::convertToJson(j, "partial_load_bulk_data_grid_view", StabCalcBaseData::partial_load_bulk_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "partial_load_person_data_grid_view", StabCalcBaseData::partial_load_person_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "partial_load_ice_data_grid_view", StabCalcBaseData::partial_load_ice_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_data_grid_view", StabCalcBaseData::partial_load_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_weight_data_grid_view", StabCalcBaseData::partial_load_weight_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_free_surf_data_grid_view", StabCalcBaseData::partial_load_free_surf_data_grid_view);
|
||
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_bulk_data_grid_view", StabCalcBaseData::partial_load_bulk_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_person_data_grid_view", StabCalcBaseData::partial_load_person_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "partial_load_ice_data_grid_view", StabCalcBaseData::partial_load_ice_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 受风项
|
||
struct IntactWindTabpage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "wind_fixed_data_grid_view", StabCalcBaseData::wind_fixed_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "wind_non_fixed_data_grid_view", StabCalcBaseData::wind_non_fixed_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "wind_fixed_data_grid_view", StabCalcBaseData::wind_fixed_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "wind_non_fixed_data_grid_view", StabCalcBaseData::wind_non_fixed_data_grid_view);
|
||
}
|
||
};
|
||
|
||
// 完整工况
|
||
struct IntactCaseTabpage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "case_data_grid_view", StabCalcBaseData::case_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "case_data_grid_view", StabCalcBaseData::case_data_grid_view);
|
||
}
|
||
};
|
||
|
||
// 许用剪力弯矩
|
||
struct AllowNMTabPage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "allow_nm_data_grid_view", StabCalcBaseData::allow_nm_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "case_data_grid_view", StabCalcBaseData::case_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 破损工况
|
||
struct DamageCaseTabPage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "dam_case_data_grid_view", StabCalcBaseData::dam_case_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "dam_compartment_data_grid_view", StabCalcBaseData::dam_compartment_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "dam_case_data_grid_view", StabCalcBaseData::dam_case_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "dam_compartment_data_grid_view", StabCalcBaseData::dam_compartment_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 破损工况
|
||
struct DamageCaseProbTabPage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "dam_case_prob_data_grid_view", StabCalcBaseData::dam_case_prob_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "dam_region_data_grid_view", StabCalcBaseData::dam_region_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "comp_extent_data_grid_view", StabCalcBaseData::comp_extent_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "dam_comp_prob_data_grid_view", StabCalcBaseData::dam_comp_prob_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "dam_case_prob_data_grid_view", StabCalcBaseData::dam_case_prob_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "dam_region_data_grid_view", StabCalcBaseData::dam_region_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "comp_extent_data_grid_view", StabCalcBaseData::comp_extent_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "dam_comp_prob_data_grid_view", StabCalcBaseData::dam_comp_prob_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 试验初始状态
|
||
struct IncliningStatusTabPage
|
||
{
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "inclining_draft_data_grid_view", StabCalcBaseData::inclining_draft_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "inclining_status_data_grid_view", StabCalcBaseData::inclining_status_data_grid_view);
|
||
}
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "inclining_draft_data_grid_view", StabCalcBaseData::inclining_draft_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "inclining_status_data_grid_view", StabCalcBaseData::inclining_status_data_grid_view);
|
||
}
|
||
};
|
||
|
||
// 试验时装载情况
|
||
struct IncliningLoadingTabPage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "inclining_extra_weight_data_grid_view", StabCalcBaseData::inclining_extra_weight_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "inclining_relocate_weight_data_grid_view", StabCalcBaseData::inclining_relocate_weight_data_grid_view);
|
||
|
||
StabCalcBaseData::convertToJson(j, "inclining_absent_weight_data_grid_view", StabCalcBaseData::inclining_absent_weight_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "inclining_tank_data_grid_view", StabCalcBaseData::inclining_tank_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "inclining_extra_weight_data_grid_view", StabCalcBaseData::inclining_extra_weight_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "inclining_relocate_weight_data_grid_view", StabCalcBaseData::inclining_relocate_weight_data_grid_view);
|
||
|
||
StabCalcBaseData::convertFromJson(j, "inclining_absent_weight_data_grid_view", StabCalcBaseData::inclining_absent_weight_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "inclining_tank_data_grid_view", StabCalcBaseData::inclining_tank_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 横倾测量读数
|
||
struct IncliningRecordTabPage
|
||
{
|
||
|
||
void convertToJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertToJson(j, "inclining_mobile_weight_data_grid_view", StabCalcBaseData::inclining_mobile_weight_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "inclining_device_data_grid_view", StabCalcBaseData::inclining_device_data_grid_view);
|
||
|
||
StabCalcBaseData::convertToJson(j, "inclining_case_data_grid_view", StabCalcBaseData::inclining_case_data_grid_view);
|
||
StabCalcBaseData::convertToJson(j, "inclining_record_data_grid_view", StabCalcBaseData::inclining_record_data_grid_view);
|
||
}
|
||
|
||
void convertFromJson(json& j)
|
||
{
|
||
StabCalcBaseData::convertFromJson(j, "inclining_mobile_weight_data_grid_view", StabCalcBaseData::inclining_mobile_weight_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "inclining_device_data_grid_view", StabCalcBaseData::inclining_device_data_grid_view);
|
||
|
||
StabCalcBaseData::convertFromJson(j, "inclining_case_data_grid_view", StabCalcBaseData::inclining_case_data_grid_view);
|
||
StabCalcBaseData::convertFromJson(j, "inclining_record_data_grid_view", StabCalcBaseData::inclining_record_data_grid_view);
|
||
}
|
||
|
||
};
|
||
|
||
// 顶级容器结构体
|
||
struct Hydro : public DataCheck
|
||
{
|
||
public:
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
|
||
void convertFromJson(json& j);
|
||
|
||
|
||
|
||
const std::vector<BInf>& getBInfData()
|
||
{
|
||
return StabCalcBaseData::binf_data_grid_view;
|
||
}
|
||
|
||
void addBInfData(BInf& info)
|
||
{
|
||
StabCalcBaseData::binf_data_grid_view.emplace_back(info);
|
||
}
|
||
|
||
BInf* FindByParamID(std::string strParamID)
|
||
{
|
||
auto it = StabCalcBaseData::binf_data_grid_view.begin();
|
||
for (; it != StabCalcBaseData::binf_data_grid_view.end(); ++it)
|
||
{
|
||
BInf& info = *it;
|
||
if (info.paramid == strParamID)
|
||
{
|
||
return &info;
|
||
}
|
||
}
|
||
return nullptr;
|
||
}
|
||
|
||
|
||
const std::vector<Shell>& getShellData()
|
||
{
|
||
return StabCalcBaseData::shell_data_grid_view;
|
||
}
|
||
|
||
void addShellData(Shell& s)
|
||
{
|
||
StabCalcBaseData::shell_data_grid_view.emplace_back(s);
|
||
}
|
||
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
FloodpointTabpage hydro_floodpoint_tabpage3; // 船型特征标签页
|
||
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 需引用舱容数据
|
||
|
||
};
|
||
|
||
|
||
|
||
struct TankCap : public DataCheck
|
||
{
|
||
public:
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 舱容标签页
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
FloodpointTabpage hydro_floodpoint_tabpage3; // 船型特征标签页
|
||
|
||
};
|
||
|
||
struct Intact : public DataCheck
|
||
{
|
||
public:
|
||
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
BinfTabpage binf_tabpage1; // 基本信息
|
||
IntactLwtTabpage intact_lwt_tabpage2; // 空船重量
|
||
IntactPartialLoadTabpage intact_partial_load_tabpage1; // 装载项
|
||
IntactWindTabpage intact_wind_tabpage5; // 受风项
|
||
IntactCaseTabpage intact_case_tabpage6; // 完整工况
|
||
AllowNMTabPage allow_nm_tabpage1; // 许用剪力弯矩
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 舱室
|
||
FloodpointTabpage hydro_floodpoint_tabpage3; // 船型特征点
|
||
};
|
||
|
||
struct AllowKG : public DataCheck
|
||
{
|
||
public:
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
};
|
||
|
||
struct Damage : public DataCheck
|
||
{
|
||
public:
|
||
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
DamageCaseTabPage damage_case_tabpage19; //
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 舱室
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
FloodpointTabpage hydro_floodpoint_tabpage3; // 船型特征标签页
|
||
|
||
IntactLwtTabpage intact_lwt_tabpage2; // 需引用 空船重量
|
||
IntactPartialLoadTabpage intact_partial_load_tabpage1; // 需引用 装载项
|
||
IntactWindTabpage intact_wind_tabpage5; // 需引用 受风项
|
||
IntactCaseTabpage intact_case_tabpage6; // 需引用 完整工况
|
||
AllowNMTabPage allow_nm_tabpage1; // 需引用 许用剪力弯矩
|
||
};
|
||
|
||
struct DamageProb : public DataCheck
|
||
{
|
||
public:
|
||
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
DamageCaseProbTabPage damage_case_prob_tabpage; //
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 舱室
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
FloodpointTabpage hydro_floodpoint_tabpage3; // 船型特征标签页
|
||
};
|
||
|
||
struct Inclining : public DataCheck
|
||
{
|
||
public:
|
||
|
||
virtual std::string data_check(const nlohmann::json &j) override;
|
||
|
||
void convertToJson(json& j);
|
||
void convertFromJson(json& j);
|
||
|
||
BinfTabpage binf_tabpage1; // 基础信息标签页
|
||
IncliningStatusTabPage inclining_status_tabpage1; //
|
||
IncliningLoadingTabPage inclining_loading_tabpage1; //
|
||
IncliningRecordTabPage inclining_record_tabpage1; //
|
||
TankCapTabpage tank_cap_compartment_tabpage20; // 需引用舱容标签页
|
||
};
|
||
|
||
// 配置各结构体字段与 JSON 键的映射关系
|
||
// 表格
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(BInf, paramid, unit, caption, value_type, value, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Shell, id, shell_id, type, shell_affect, affect_coef, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FloodPoint, id, xsymbol, y, z)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ImmersionPoint, id, xsymbol, y, z, compartment)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(LimitStaticPoint, id, xsymbol, y1, z1, y2, z2)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Deckline, id, xsymbol, y, z)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Compartment, id, space_id, flood_points, type, coef, density, remark, sid, permeability)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(LWT, id, type, g, xg_symbol, yg, zg, xa_symbol, xf_symbol)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoad, id, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoadWeight, partial_load_id, id, wt_type, compartment, compartment_type, free_surf_type, g, ratio, density, xg_symbol, yg, zg, xa_symbol, xf_symbol)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoadFreeSurf, partial_load_id, id, density, v, l, b, h)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoadBulk, partial_load_id, id, gbulk)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoadPerson, partial_load_id, id, person_type, np, bp, lp, mpy, mpz)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PartialLoadIce, partial_load_id, id, type, as, wi, xg_symbol, yg, zg)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(WindFixed, id, type, as, zf, full_coef, stream_line_coef)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(WindNonFixed, id, type, as, zf, full_coef, stream_line_coef)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Case, id, ship_type, child_type, criterial_factor, check_state, partial_load, wind, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AllowNM, x, nz, nf, mz, mf)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamCase, id, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamCompartment, id, compartment_ids)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamCaseProb, id, type, d, at, gm)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamRegion, id, type, xa_symbol, xa, xf_symbol, xf, yp, zp)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CompExtent, id, space_id, xmin, xmax, ymin, ymax, zmin, zmax)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamCompartmentProb, id, compartment_ids,x1, x2, b1, b2, h1, h2, hm)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningDraft, id, aft, mid, bow, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningStatus, paramid, unit, caption, value_type, value, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningExtraWeight, id, type, g, xg_symbol, yg, zg, compartment, density, ratio)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningRelocateWeight, id, g, xg_symbol, yg, zg, xg1_symbol, xg1, yg1, zg1)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningAbsentWeight, id, g, xg_symbol, yg, zg)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningTank, id, compartment, g, ratio, density, v, l, b, h)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningMobileWeight, id, g, xg_symbol, yg, zg, b, description)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningDevice, id, x, param, remark)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningCase, id, weight_ids, port_weight_ids)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningRecord, device_id, case_id, avg)
|
||
|
||
// 配置容器结构体映射
|
||
// tabpage页
|
||
/*
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(BinfTabpage, binf_data_grid_view, shell_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FloodpointTabpage, flood_point_data_grid_view,
|
||
immersion_point_data_grid_view, limit_static_point_data_grid_view, deckline_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TankCapTabpage, compartment_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IntactLwtTabpage, lwt_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IntactPartialLoadTabpage, partial_load_data_grid_view, partial_load_weight_data_grid_view, partial_load_free_surf_data_grid_view,
|
||
partial_load_bulk_data_grid_view, partial_load_person_data_grid_view, partial_load_ice_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IntactWindTabpage, wind_fixed_data_grid_view, wind_non_fixed_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IntactCaseTabpage, case_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AllowNMTabPage, allow_nm_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamageCaseTabPage, dam_case_data_grid_view, dam_compartment_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamageCaseProbTabPage, dam_case_prob_data_grid_view, dam_region_data_grid_view, comp_extent_data_grid_view, dam_comp_prob_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningStatusTabPage, inclining_draft_data_grid_view, inclining_status_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningLoadingTabPage, inclining_extra_weight_data_grid_view, inclining_relocate_weight_data_grid_view,
|
||
inclining_absent_weight_data_grid_view, inclining_tank_data_grid_view)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(IncliningRecordTabPage, inclining_mobile_weight_data_grid_view, inclining_device_data_grid_view,
|
||
inclining_case_data_grid_view, inclining_record_data_grid_view)
|
||
|
||
// 模型页面
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Hydro, binf_tabpage1, hydro_floodpoint_tabpage3, tank_cap_compartment_tabpage20)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TankCap, tank_cap_compartment_tabpage20, binf_tabpage1, hydro_floodpoint_tabpage3)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Intact, binf_tabpage1, intact_lwt_tabpage2, intact_partial_load_tabpage1, intact_wind_tabpage5, intact_case_tabpage6, allow_nm_tabpage1,
|
||
tank_cap_compartment_tabpage20, hydro_floodpoint_tabpage3)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AllowKG, binf_tabpage1)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Damage,
|
||
damage_case_tabpage19,
|
||
tank_cap_compartment_tabpage20,
|
||
binf_tabpage1,
|
||
hydro_floodpoint_tabpage3,
|
||
intact_lwt_tabpage2,
|
||
intact_partial_load_tabpage1,
|
||
intact_wind_tabpage5,
|
||
intact_case_tabpage6,
|
||
allow_nm_tabpage1)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DamageProb, damage_case_prob_tabpage, tank_cap_compartment_tabpage20, binf_tabpage1, hydro_floodpoint_tabpage3)
|
||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Inclining, binf_tabpage1, inclining_status_tabpage1, inclining_loading_tabpage1, inclining_record_tabpage1, tank_cap_compartment_tabpage20)
|
||
*/
|
||
static void set_binf_visible_by_criteria(std::unordered_set<std::string> &visible_set, std::string crRule, std::string calType)
|
||
{
|
||
// 1-内法规2011;2-内法规2015;3-内法规2016;4-内法规2018;5-内法规2019;1001-特定航线江海直达法规2018;2001-远洋渔船法规2019
|
||
bool bVisible = false;
|
||
if (crRule == "2001" && (calType != "DamageProb")) // 概率破损时不显示 cqr-20210817
|
||
{
|
||
visible_set.insert("IsDoubleDeck");
|
||
visible_set.insert("RollingPeriod");
|
||
visible_set.insert("RollingAngle");
|
||
}
|
||
else
|
||
{
|
||
visible_set.erase("IsDoubleDeck");
|
||
visible_set.erase("RollingPeriod");
|
||
visible_set.erase("RollingAngle");
|
||
}
|
||
};
|
||
|
||
static void set_binf_visible_by_ship_type(std::unordered_set<std::string> &visible_set, std::string ship_type)
|
||
{
|
||
std::vector<std::string> items = SplitString(ship_type);
|
||
bool bVisible = false;
|
||
if (std::find(items.begin(), items.end(), "8") != items.end())
|
||
{
|
||
visible_set.insert("HasMudHold");
|
||
visible_set.insert("StaticAngleReq");
|
||
}
|
||
else
|
||
{
|
||
visible_set.erase("HasMudHold");
|
||
visible_set.erase("StaticAngleReq");
|
||
}
|
||
};
|
||
|
||
static void set_binf_visible_by_bilge_type(std::unordered_set<std::string> &visible_set, int bilge_type)
|
||
{
|
||
switch (bilge_type)
|
||
{
|
||
case 3:
|
||
visible_set.insert("BilgeC2");
|
||
visible_set.insert("BilgeC3");
|
||
visible_set.insert("BilgeC4");
|
||
|
||
break;
|
||
|
||
default:
|
||
visible_set.erase("BilgeC2");
|
||
visible_set.erase("BilgeC3");
|
||
visible_set.erase("BilgeC4");
|
||
|
||
break;
|
||
}
|
||
};
|
||
|
||
// 添加,BInf表相关的过滤函数
|
||
// 完整稳性、破损稳性、许用重心高度
|
||
static void set_binf_visible_stab(std::vector<BInf> &binf_array, std::string calType)
|
||
{
|
||
std::unordered_set<std::string> visible_set;
|
||
for (int i = 0; i < binf_array.size(); ++i)
|
||
{
|
||
std::string str = binf_array[i].paramid;
|
||
if (str == "Origin" ||
|
||
str == "L" ||
|
||
str == "Lpp" ||
|
||
str == "B" ||
|
||
str == "D" ||
|
||
str == "d" ||
|
||
str == "IsSelfNav" ||
|
||
str == "NavArea" ||
|
||
str == "NavSeg" ||
|
||
str == "Density")
|
||
{
|
||
// TODO:_IsShipDimensionDisable定义不明确
|
||
// row.Visible = !_IsShipDimensionDisable;
|
||
}
|
||
|
||
if (str == "StabCriteriaRule" ||
|
||
str == "XType" ||
|
||
str == "IsCatamaran" ||
|
||
str == "IsHighspeed" ||
|
||
str == "IsBox" ||
|
||
str == "Vm" ||
|
||
str == "ShipType" ||
|
||
str == "DraftList" ||
|
||
str == "AngleEvalMax" ||
|
||
str == "AngleEvalInterval" ||
|
||
str == "IsFullWindScale" ||
|
||
str == "ProfileYList" ||
|
||
str == "BilgeKeelArea" ||
|
||
str == "BilgeType" ||
|
||
str == "BilgeC2" ||
|
||
str == "BilgeC3" ||
|
||
str == "BilgeC4" ||
|
||
str == "HasMudHold" ||
|
||
str == "StaticAngleReq" ||
|
||
str == "IsStaticAngleReturnTest" || // 20190405 added by czb
|
||
str == "IntactRemark")
|
||
{
|
||
visible_set.insert(str);
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < binf_array.size(); ++i)
|
||
{
|
||
std::string str = binf_array[i].paramid;
|
||
if (str == "StabCriteriaRule")
|
||
{
|
||
set_binf_visible_by_criteria(visible_set, binf_array[i].value, calType);
|
||
}
|
||
if (str == "ShipType")
|
||
{
|
||
set_binf_visible_by_ship_type(visible_set, binf_array[i].value);
|
||
}
|
||
if (str == "BilgeType")
|
||
{
|
||
int bilge_type = std::stoi(binf_array[i].value);
|
||
set_binf_visible_by_bilge_type(visible_set, bilge_type);
|
||
}
|
||
}
|
||
|
||
binf_array.erase(
|
||
std::remove_if(
|
||
binf_array.begin(),
|
||
binf_array.end(),
|
||
[&visible_set](const BInf &item)
|
||
{
|
||
return visible_set.find(item.paramid) == visible_set.end(); // 使用 find() 替代 contains()
|
||
}),
|
||
binf_array.end());
|
||
};
|
||
|
||
// 概率法破损稳性
|
||
static void set_binf_visible_damage_prob(std::vector<BInf> &binf_array, std::string calType)
|
||
{
|
||
std::unordered_set<std::string> visible_set;
|
||
for (int i = 0; i < binf_array.size(); ++i)
|
||
{
|
||
std::string str = binf_array[i].paramid;
|
||
if (str == "Origin" ||
|
||
str == "L" ||
|
||
str == "Lpp" ||
|
||
str == "B" ||
|
||
str == "D" ||
|
||
str == "d" ||
|
||
str == "IsSelfNav" ||
|
||
str == "NavArea" ||
|
||
str == "NavSeg" ||
|
||
str == "Density")
|
||
{
|
||
// TODO:_IsShipDimensionDisable定义不明确
|
||
// row.Visible = !_IsShipDimensionDisable;
|
||
}
|
||
|
||
if (str == "StabCriteriaRule" ||
|
||
str == "Ls_p" ||
|
||
str == "Xa_p" ||
|
||
str == "Bs_p" ||
|
||
str == "ShipType" ||
|
||
str == "AngleEvalMax" ||
|
||
str == "AngleEvalInterval" ||
|
||
str == "IntactRemark")
|
||
{
|
||
visible_set.insert(str);
|
||
}
|
||
}
|
||
|
||
for (int i = 0; i < binf_array.size(); ++i)
|
||
{
|
||
std::string str = binf_array[i].paramid;
|
||
if (str == "StabCriteriaRule")
|
||
{
|
||
set_binf_visible_by_criteria(visible_set, binf_array[i].value, calType);
|
||
}
|
||
if (str == "ShipType")
|
||
{
|
||
set_binf_visible_by_ship_type(visible_set, binf_array[i].value);
|
||
}
|
||
if (str == "BilgeType")
|
||
{
|
||
int bilge_type = std::stoi(binf_array[i].value);
|
||
set_binf_visible_by_bilge_type(visible_set, bilge_type);
|
||
}
|
||
}
|
||
|
||
binf_array.erase(
|
||
std::remove_if(
|
||
binf_array.begin(),
|
||
binf_array.end(),
|
||
[&visible_set](const BInf &item)
|
||
{
|
||
return visible_set.find(item.paramid) == visible_set.end(); // 使用 find() 替代 contains()
|
||
}),
|
||
binf_array.end());
|
||
};
|
||
#endif |