150 lines
7.0 KiB
C++
150 lines
7.0 KiB
C++
#pragma once
|
||
#include <vector>
|
||
#include <QJsonObject>
|
||
#include <QMetaType>
|
||
#include <QString>
|
||
#include "model/Field.hpp"
|
||
#include "model/ColorScale.hpp"
|
||
#include "model/Anomaly.hpp"
|
||
|
||
// 详情渲染载荷(纯数据,跨 QVariant 类型擦除传递)。无 Qt-widget 依赖。
|
||
// 命名空间 geopro::core(与同目录 Field.hpp/ColorScale.hpp 一致)。
|
||
namespace geopro::core {
|
||
|
||
// 下拉项:字段码 + 显示名(measurement 工具条 x/y/v/method 下拉驱动;code 可空如 method)。
|
||
struct FieldOption {
|
||
QString code;
|
||
QString name;
|
||
};
|
||
|
||
// measurement 散点工具条配置(来自服务端 scatterGraphConf;反演留空 → 视图渲染反演工具条)。
|
||
// x/y/v/method 为各下拉的可选项(含 fieldCode+name);defaultX/Y/V/Method 为默认选中项的
|
||
// fieldCode(method 的 fieldCode 全为 null,故 defaultMethod 用 name)。empty() 判定走 x 是否为空。
|
||
struct ScatterToolbarConf {
|
||
std::vector<FieldOption> x, y, v, method;
|
||
QString defaultX, defaultY, defaultV, defaultMethod;
|
||
bool empty() const { return x.empty(); }
|
||
};
|
||
|
||
// 散点载荷:反演原数据 / measurement 散点共用(≈ data::ChartParts)。
|
||
// 两者上色一致——按数据 min/max 连续插值(Plotly cauto,含负异常值,RawDataChartView 据 v
|
||
// 有限值 min/max 设 setDataRange)。verticalLegend=true(measurement)时色阶图例画在右侧竖条
|
||
// (离散带,1323→0 自上而下,对齐原版);false(默认,反演原数据)时画在底部横条。
|
||
// toolbar 非空(measurement)时视图渲染 measurement 工具条;altX*/altY* 为 x/y 下拉本地重绘
|
||
// 用的备选列(平距/斜距、伪深度/伪深度+高程),与 scatter.v/.a... 同序、一一对应,避免再发请求。
|
||
struct ScatterPayload {
|
||
geopro::core::ScatterField scatter;
|
||
geopro::core::ColorScale scale;
|
||
bool verticalLegend = false;
|
||
ScatterToolbarConf toolbar;
|
||
std::vector<double> altXHorizontal, altXSlope; // x 下拉:平距 / 斜距
|
||
std::vector<double> altYPseudo, altYElevationPseudo; // y 下拉:伪深度 / 伪深度+高程
|
||
// 色阶模板 id(来自 lvl/colorGradation/getDetail 的 templateId):保存色阶时回带
|
||
// (对照原版 newLvlColorLevel 带读取到的 templateId;可空)。
|
||
QString templateId;
|
||
// type1 原始 properties(lineConfig/labelConfig/层级方案):保存色阶时只覆盖 colorBar+opacity、
|
||
// 其余原样回写,避免清掉网格(共用同一条 businessCode="" 记录)设过的等值线/层级值(对齐原版 load-then-save)。
|
||
QJsonObject properties;
|
||
};
|
||
|
||
// 等值面载荷:grid(rows) + 色阶 + 异常(≈ data::GridParts)。
|
||
// Grid 无默认构造,给占位初始化以满足 QVariant 对默认可构造的要求。
|
||
struct ContourPayload {
|
||
geopro::core::Grid grid{1, 1};
|
||
geopro::core::ColorScale scale;
|
||
std::vector<geopro::core::Anomaly> anomalies;
|
||
// 色阶模板 id(来自 lvl/colorGradation/getDetail type2 的顶层 templateId):保存/覆盖色阶时回带
|
||
// (对照原版 contourPage lvlTemplateId = lvlConfig?.templateId;可空)。
|
||
QString templateId;
|
||
};
|
||
|
||
// 列渲染种类:Text=预格式化文本(默认);Toggle=每行开关(蓝色药丸开关,ON=可见)。
|
||
enum class TableColumnKind { Text, Toggle };
|
||
|
||
// 通用表格列定义。
|
||
struct TableColumn {
|
||
QString code;
|
||
QString title;
|
||
int width = 0;
|
||
int sort = 0;
|
||
TableColumnKind kind = TableColumnKind::Text;
|
||
};
|
||
|
||
// 表格功能按钮(dd_grid:服务端 functionList = DDGridFunctionVO[],驱动列表上方功能按钮行)。
|
||
// 仅 dd_grid 列表携带(其余 Table 复用场景该列表为空 → 不渲染工具条)。enable=false 的按钮不显示
|
||
// (原版 v-show="enable")。点击按 code 路由(原版仅处理 code=="inversion")。
|
||
struct TableFunctionButton {
|
||
QString code; // functionCode(如 inversion)
|
||
QString nameChn; // functionNameChn(按钮中文文案)
|
||
bool enable = true;
|
||
};
|
||
|
||
// 通用表格载荷:列定义 + 预格式化的行(每格 QString)+ 总数(分页用)。
|
||
// 分页(dd_grid 列表,服务端分页 vxe-pager):pageSize>0 时视图渲染分页器,pageNo 为当前页(1 基);
|
||
// pageSize=0(默认)= 不分页(measurement/trajectory 全量列表,一次性返回所有行)。
|
||
// functionButtons:仅 dd_grid 列表非空(来自服务端 functionList),驱动列表上方功能按钮行。
|
||
struct TablePayload {
|
||
std::vector<TableColumn> columns;
|
||
std::vector<std::vector<QString>> rows;
|
||
int total = 0;
|
||
int pageNo = 1; // 当前页(1 基);分页用
|
||
int pageSize = 0; // 每页条数;>0 才渲染分页器(vxe-pager),0=不分页
|
||
std::vector<TableFunctionButton> functionButtons; // dd_grid 功能按钮(其余场景空)
|
||
// M2 行级显隐:仅 measurement 列表置 true(载荷驱动门控,其余视图复用 DataTableView 保持只读)。
|
||
// 为 true 时 Toggle 列可点击 → popconfirm → saveDisplayStatus(rowIds[i], 取反)。
|
||
bool toggleInteractive = false;
|
||
// 每行点 id(与 rows 同序、一一对应,saveDisplayStatus ids[] 用);仅 measurement 填充。
|
||
std::vector<QString> rowIds;
|
||
};
|
||
|
||
// 柱状图系列:名称(图例/legend)+ 各类目的 y 值 + 填充色(hex,如 #5470c6;数据色,两主题一致)。
|
||
struct BarSeries {
|
||
QString name;
|
||
std::vector<double> values;
|
||
QString color;
|
||
};
|
||
|
||
// 柱状图载荷(dd_ert_measurement_gr_data 接地电阻):类目(x 轴标签,如 "#1".."#40")+
|
||
// 一个或多个系列(P1/P2,每系列一组按类目对齐的 y 值)+ 轴标题。
|
||
struct BarPayload {
|
||
std::vector<QString> categories;
|
||
std::vector<BarSeries> series;
|
||
QString xTitle;
|
||
QString yTitle;
|
||
};
|
||
|
||
// 折线图载荷(dd_trajectory_data 高程页签):单条平滑折线。
|
||
// 类目(x 轴标签,如 "#1".."#40",来自 electrodeNo)+ 对齐的 y 值(高程)+ 系列名 + 线色(hex,
|
||
// 如 #5470c6,ECharts 默认蓝,两主题一致)+ 轴标题(x「电极号」/ y「高程」)+ 是否平滑。
|
||
struct LinePayload {
|
||
std::vector<QString> categories;
|
||
std::vector<double> y;
|
||
QString seriesName;
|
||
QString color;
|
||
QString xTitle;
|
||
QString yTitle;
|
||
bool smooth = true;
|
||
};
|
||
|
||
// 轨迹地图点(dd_trajectory_data 地图页签):电极号 + WGS84 经纬度。
|
||
// 服务端 dd/ert/trajectory/line 直接返回 EPSG:4326 经纬(x=经度 lon、y=纬度 lat)。
|
||
struct MapPoint {
|
||
int electrodeNo = 0;
|
||
double lon = 0;
|
||
double lat = 0;
|
||
};
|
||
|
||
// 轨迹地图载荷:一组电极经纬点(按电极号顺序)。视图据此在 Leaflet 上画橙色空心圈标记。
|
||
struct MapPayload {
|
||
std::vector<MapPoint> points;
|
||
};
|
||
|
||
} // namespace geopro::core
|
||
|
||
Q_DECLARE_METATYPE(geopro::core::ScatterPayload)
|
||
Q_DECLARE_METATYPE(geopro::core::ContourPayload)
|
||
Q_DECLARE_METATYPE(geopro::core::TablePayload)
|
||
Q_DECLARE_METATYPE(geopro::core::BarPayload)
|
||
Q_DECLARE_METATYPE(geopro::core::LinePayload)
|
||
Q_DECLARE_METATYPE(geopro::core::MapPayload)
|