feat(vtk): I3dSceneRepository 补齐切片/异常/任务接口设计(spec §6.3-6.5)+LocalSample内存态stub
This commit is contained in:
parent
624cdcbb2e
commit
77f1b5543e
|
|
@ -1,8 +1,11 @@
|
|||
#pragma once
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "model/Anomaly.hpp"
|
||||
#include "model/Field.hpp"
|
||||
#include "repo/RepoTypes.hpp"
|
||||
|
||||
|
|
@ -31,7 +34,7 @@ struct TerrainPaths {
|
|||
// **契约:onOk/onErr 必须在主(GUI)线程调用**——上层(VtkSceneController)回调内直接操作
|
||||
// 场景/发 Qt 信号,依赖主线程亲和;Api 实现若在工作线程完成须 post 回主线程再回调。
|
||||
// dimensionOf 是同步纯函数(无 I/O,只做类型→维度映射)。
|
||||
// 切片/异常/任务等签名本期不在接口内(留 P3/P4)。
|
||||
// 切片/异常/任务接口已按 spec §6.3–6.5 完整设计(见下方),LocalSample 内存态 stub,将来 Api3dRepository 换实现。
|
||||
class I3dSceneRepository {
|
||||
public:
|
||||
using OnError = std::function<void(const std::string& message)>;
|
||||
|
|
@ -47,6 +50,81 @@ public:
|
|||
|
||||
// 异步:加载地形 DEM/影像路径。
|
||||
virtual void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) = 0;
|
||||
|
||||
// ── 切片数据集 CRUD(spec §6.3)──────────────────────────────────────────
|
||||
// 切面位姿(原点 + 法向,用 std::array 去裸 double[])。
|
||||
struct SliceSpec {
|
||||
std::string volumeDsId; // 所属三维体 dsId
|
||||
std::array<double, 3> origin{{0, 0, 0}}; // 切面上一点(世界米)
|
||||
std::array<double, 3> normal{{0, 0, 1}}; // 切面法向(单位向量)
|
||||
std::string colorScaleId;
|
||||
};
|
||||
// 切片数据集(持久化态):dsId/名字 + 位姿 + 采样网格。
|
||||
struct SliceDataset {
|
||||
std::string dsId, name;
|
||||
SliceSpec spec;
|
||||
geopro::core::Grid section{0, 0}; // 切面着色网格(保存后才填)
|
||||
};
|
||||
|
||||
// 保存为新切片数据集 → onOk(newDsId)。
|
||||
virtual void createSlice(const SliceSpec& spec, const std::string& name,
|
||||
std::function<void(std::string /*newDsId*/)> onOk,
|
||||
OnError onErr) = 0;
|
||||
// 覆盖已有切片位姿。
|
||||
virtual void saveSlice(const std::string& dsId, const SliceSpec& spec,
|
||||
std::function<void()> onOk, OnError onErr) = 0;
|
||||
// 删除切片数据集。
|
||||
virtual void deleteSlice(const std::string& dsId,
|
||||
std::function<void()> onOk, OnError onErr) = 0;
|
||||
|
||||
// ── 异常 / 异常体(spec §6.4)────────────────────────────────────────────
|
||||
// 异常体(树中间层):含该体下的多个 Anomaly。
|
||||
struct AnomalyBody {
|
||||
std::string id, name, typeName;
|
||||
std::vector<geopro::core::Anomaly> members;
|
||||
};
|
||||
// 异常树:对象 → 异常体分组 → 异常,以及未分组异常。
|
||||
struct AnomalyTree {
|
||||
std::vector<AnomalyBody> bodies;
|
||||
std::vector<geopro::core::Anomaly> loose; // 未分组异常
|
||||
};
|
||||
|
||||
// 加载对象的完整异常树。
|
||||
virtual void loadAnomalyTree(const std::string& objectId,
|
||||
std::function<void(AnomalyTree)> onOk, OnError onErr) = 0;
|
||||
// 保存/新建异常(含截图属性)→ onOk(anomalyId)。
|
||||
virtual void saveAnomaly(const geopro::core::Anomaly& a,
|
||||
const std::string& screenshotPngPath,
|
||||
std::function<void(std::string /*anomalyId*/)> onOk,
|
||||
OnError onErr) = 0;
|
||||
// 删除单个异常。
|
||||
virtual void deleteAnomaly(const std::string& anomalyId,
|
||||
std::function<void()> onOk, OnError onErr) = 0;
|
||||
// 删除异常体分组(及其下异常)。
|
||||
virtual void deleteAnomalyGroup(const std::string& bodyId,
|
||||
std::function<void()> onOk, OnError onErr) = 0;
|
||||
|
||||
// ── 任务管理(spec §6.5)─────────────────────────────────────────────────
|
||||
// 任务调用记录(当前数据集历史)。
|
||||
struct TaskRecord {
|
||||
std::string id, taskName, status, createTime;
|
||||
};
|
||||
// 可使用任务(与 ds 类型 ddCode 相符的任务插件;复用 model/list 语义)。
|
||||
struct UsableTask {
|
||||
std::string scriptId, scriptCode, name;
|
||||
int opType = 0;
|
||||
};
|
||||
|
||||
// 加载当前数据集的任务调用记录。
|
||||
virtual void loadTaskRecords(const std::string& dsId,
|
||||
std::function<void(std::vector<TaskRecord>)> onOk,
|
||||
OnError onErr) = 0;
|
||||
// 加载与 ddCode 匹配的可用任务插件列表。
|
||||
virtual void loadUsableTasks(const std::string& ddCode,
|
||||
std::function<void(std::vector<UsableTask>)> onOk,
|
||||
OnError onErr) = 0;
|
||||
};
|
||||
// 注:以上切片/异常/任务接口已按 spec §6.3–6.5 完整设计;
|
||||
// LocalSample3dRepository 提供内存态 stub;真实后端 = 将来 Api3dRepository(上层不变)。
|
||||
|
||||
} // namespace geopro::data
|
||||
|
|
|
|||
|
|
@ -156,4 +156,69 @@ void LocalSample3dRepository::loadTerrainPaths(std::function<void(TerrainPaths)>
|
|||
}
|
||||
}
|
||||
|
||||
// ── 切片 CRUD(spec §6.3 内存态 stub)───────────────────────────────────────
|
||||
|
||||
void LocalSample3dRepository::createSlice(const SliceSpec& spec, const std::string& /*name*/,
|
||||
std::function<void(std::string)> onOk,
|
||||
OnError /*onErr*/) {
|
||||
std::string newId = "slice-" + std::to_string(++sliceCounter_);
|
||||
slices_[newId] = spec;
|
||||
onOk(std::move(newId));
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::saveSlice(const std::string& dsId, const SliceSpec& spec,
|
||||
std::function<void()> onOk, OnError /*onErr*/) {
|
||||
slices_[dsId] = spec;
|
||||
onOk();
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::deleteSlice(const std::string& dsId,
|
||||
std::function<void()> onOk, OnError /*onErr*/) {
|
||||
slices_.erase(dsId);
|
||||
onOk();
|
||||
}
|
||||
|
||||
// ── 异常 / 异常体(spec §6.4 内存态 stub)──────────────────────────────────
|
||||
|
||||
void LocalSample3dRepository::loadAnomalyTree(const std::string& /*objectId*/,
|
||||
std::function<void(AnomalyTree)> onOk,
|
||||
OnError /*onErr*/) {
|
||||
onOk(AnomalyTree{}); // stub: 空树(无样本异常)
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::saveAnomaly(const geopro::core::Anomaly& a,
|
||||
const std::string& /*screenshotPngPath*/,
|
||||
std::function<void(std::string)> onOk,
|
||||
OnError /*onErr*/) {
|
||||
std::string newId = "anomaly-" + std::to_string(++anomalyCounter_);
|
||||
anomalies_[newId] = a;
|
||||
onOk(std::move(newId));
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::deleteAnomaly(const std::string& anomalyId,
|
||||
std::function<void()> onOk, OnError /*onErr*/) {
|
||||
anomalies_.erase(anomalyId);
|
||||
onOk();
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::deleteAnomalyGroup(const std::string& /*bodyId*/,
|
||||
std::function<void()> onOk, OnError /*onErr*/) {
|
||||
// stub: 内存态无 AnomalyBody 存储(bodyId 仅逻辑分组,真实 backend 实现时才有)
|
||||
onOk();
|
||||
}
|
||||
|
||||
// ── 任务管理(spec §6.5 内存态 stub)────────────────────────────────────────
|
||||
|
||||
void LocalSample3dRepository::loadTaskRecords(const std::string& /*dsId*/,
|
||||
std::function<void(std::vector<TaskRecord>)> onOk,
|
||||
OnError /*onErr*/) {
|
||||
onOk({}); // stub: 无样本任务记录
|
||||
}
|
||||
|
||||
void LocalSample3dRepository::loadUsableTasks(const std::string& /*ddCode*/,
|
||||
std::function<void(std::vector<UsableTask>)> onOk,
|
||||
OnError /*onErr*/) {
|
||||
onOk({}); // stub: 空列表(真实实现按 ddCode 过滤 model/list 返回)
|
||||
}
|
||||
|
||||
} // namespace geopro::data
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "repo/I3dSceneRepository.hpp"
|
||||
|
||||
|
|
@ -25,10 +27,43 @@ public:
|
|||
OnError onErr) override;
|
||||
void loadTerrainPaths(std::function<void(TerrainPaths)> onOk, OnError onErr) override;
|
||||
|
||||
// 切片 CRUD(spec §6.3 内存态 stub)
|
||||
void createSlice(const SliceSpec& spec, const std::string& name,
|
||||
std::function<void(std::string)> onOk, OnError onErr) override;
|
||||
void saveSlice(const std::string& dsId, const SliceSpec& spec,
|
||||
std::function<void()> onOk, OnError onErr) override;
|
||||
void deleteSlice(const std::string& dsId,
|
||||
std::function<void()> onOk, OnError onErr) override;
|
||||
|
||||
// 异常 / 异常体(spec §6.4 内存态 stub)
|
||||
void loadAnomalyTree(const std::string& objectId,
|
||||
std::function<void(AnomalyTree)> onOk, OnError onErr) override;
|
||||
void saveAnomaly(const geopro::core::Anomaly& a, const std::string& screenshotPngPath,
|
||||
std::function<void(std::string)> onOk, OnError onErr) override;
|
||||
void deleteAnomaly(const std::string& anomalyId,
|
||||
std::function<void()> onOk, OnError onErr) override;
|
||||
void deleteAnomalyGroup(const std::string& bodyId,
|
||||
std::function<void()> onOk, OnError onErr) override;
|
||||
|
||||
// 任务管理(spec §6.5 内存态 stub)
|
||||
void loadTaskRecords(const std::string& dsId,
|
||||
std::function<void(std::vector<TaskRecord>)> onOk,
|
||||
OnError onErr) override;
|
||||
void loadUsableTasks(const std::string& ddCode,
|
||||
std::function<void(std::vector<UsableTask>)> onOk,
|
||||
OnError onErr) override;
|
||||
|
||||
private:
|
||||
LocalSampleRepository& base_;
|
||||
std::string projectCrs_;
|
||||
double baseLat_, baseLon_;
|
||||
|
||||
// 内存态存储(stub,无持久化;重启清空)
|
||||
int sliceCounter_ = 0;
|
||||
std::map<std::string, SliceSpec> slices_; // dsId → spec
|
||||
|
||||
int anomalyCounter_ = 0;
|
||||
std::map<std::string, geopro::core::Anomaly> anomalies_; // anomalyId → Anomaly
|
||||
};
|
||||
|
||||
} // namespace geopro::data
|
||||
|
|
|
|||
|
|
@ -96,6 +96,26 @@ struct FakeSceneRepo : data::I3dSceneRepository {
|
|||
void loadTerrainPaths(std::function<void(data::TerrainPaths)> onOk, OnError) override {
|
||||
onOk(data::TerrainPaths{"dem.tif", "image.tif"});
|
||||
}
|
||||
|
||||
// 切片/异常/任务 stub(满足纯虚,行为同 LocalSample3dRepository)
|
||||
void createSlice(const SliceSpec&, const std::string&,
|
||||
std::function<void(std::string)> onOk, OnError) override { onOk("slice-0"); }
|
||||
void saveSlice(const std::string&, const SliceSpec&,
|
||||
std::function<void()> onOk, OnError) override { onOk(); }
|
||||
void deleteSlice(const std::string&,
|
||||
std::function<void()> onOk, OnError) override { onOk(); }
|
||||
void loadAnomalyTree(const std::string&,
|
||||
std::function<void(AnomalyTree)> onOk, OnError) override { onOk({}); }
|
||||
void saveAnomaly(const core::Anomaly&, const std::string&,
|
||||
std::function<void(std::string)> onOk, OnError) override { onOk("anomaly-0"); }
|
||||
void deleteAnomaly(const std::string&,
|
||||
std::function<void()> onOk, OnError) override { onOk(); }
|
||||
void deleteAnomalyGroup(const std::string&,
|
||||
std::function<void()> onOk, OnError) override { onOk(); }
|
||||
void loadTaskRecords(const std::string&,
|
||||
std::function<void(std::vector<TaskRecord>)> onOk, OnError) override { onOk({}); }
|
||||
void loadUsableTasks(const std::string&,
|
||||
std::function<void(std::vector<UsableTask>)> onOk, OnError) override { onOk({}); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
Loading…
Reference in New Issue