From 3ed1ea75acbab73689cb6e722712af3f037eabb5 Mon Sep 17 00:00:00 2001 From: gaozheng Date: Fri, 26 Jun 2026 11:00:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(3d):=20=E5=BC=82=E5=B8=B8=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=8E=A5=E5=B9=B3=E5=8F=B0=20legend(=E4=B8=8E?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E4=B8=80=E8=87=B4,=E4=B8=8D=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=20mock=20=E4=BF=9D=E5=AD=98)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正前一轮误判:异常样式("与平台一致")不依赖真后端保存链——getDetail/{id} 端点存在且返回 legend。 - 新增 getExceptionTypeDetail(typeId) → GET /business/exceptionType/getDetail/{id}(wireObject 取 data) - AnomalySaveDialog 选中类型变化时拉其 legend,按形态(1点 pointColor / 2线·3面 polylineColor+Width+ Shape→dashed)派生样式;首项自动预取 - main accept 后用 dlg.styleColor/Width/Dashed 覆盖默认(#ff3030/2/实线)→异常按平台类型样式渲染 注:真保存(newException)仍卡——实测真后端无任何登记三维体/切片为 dsObject 的端点(voxel/slice generate 无、通用 dsObject create 也无),异常 remarkSourceId 无真实实体可指,是后端缺端点的硬依赖。 测试:通过 --- src/app/AnomalySaveDialog.cpp | 26 +++++++++++++++++++- src/app/AnomalySaveDialog.hpp | 13 ++++++++++ src/app/main.cpp | 6 +++++ src/data/api/ApiDatasetCommandRepository.cpp | 7 ++++++ src/data/api/ApiDatasetCommandRepository.hpp | 3 +++ src/data/repo/IDatasetCommandRepository.hpp | 7 ++++++ 6 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/app/AnomalySaveDialog.cpp b/src/app/AnomalySaveDialog.cpp index db2d4d0..fa85572 100644 --- a/src/app/AnomalySaveDialog.cpp +++ b/src/app/AnomalySaveDialog.cpp @@ -22,7 +22,7 @@ AnomalySaveDialog::AnomalySaveDialog(const QString& screenshotPath, int shotW, i geopro::data::IDatasetCommandRepository* cmdRepo, const QString& projectId, int remarkSourceType, QWidget* parent) - : QDialog(parent) { + : QDialog(parent), cmdRepo_(cmdRepo), remarkSourceType_(remarkSourceType) { setWindowTitle(QStringLiteral("保存异常")); setModal(true); @@ -39,6 +39,9 @@ AnomalySaveDialog::AnomalySaveDialog(const QString& screenshotPath, int shotW, i type_ = new EmptyAwareComboBox(); formkit::capField(type_); form->addRow(formkit::editLabel(QStringLiteral("异常类型")), type_); + // 选中类型变化 → 拉其平台样式(legend),使保存的异常按平台类型样式渲染。 + connect(type_, qOverload(&QComboBox::currentIndexChanged), this, + [this](int) { loadStyleForCurrent(); }); loadTypes(cmdRepo, projectId, remarkSourceType); // 异步拉平台异常类型填充(与平台一致) remark_ = new QPlainTextEdit(); @@ -77,9 +80,30 @@ void AnomalySaveDialog::loadTypes(geopro::data::IDatasetCommandRepository* cmdRe self->type_->addItem(o.value(QStringLiteral("label")).toString(), o.value(QStringLiteral("value")).toString()); } + self->loadStyleForCurrent(); // 首项自动选中 → 预取其样式 }); } +void AnomalySaveDialog::loadStyleForCurrent() { + if (cmdRepo_ == nullptr) return; + const QString typeId = type_->currentData().toString(); + if (typeId.isEmpty()) return; + QPointer self(this); + cmdRepo_->getExceptionTypeDetail(typeId, [self](bool ok, QJsonObject data, const QString&) { + if (!self || !ok) return; + const QJsonObject lg = data.value(QStringLiteral("legend")).toObject(); + // 按形态(1点/2线/3面)从 legend 派生样式:点用 pointColor;线/面用 polyline*。 + if (self->remarkSourceType_ == 1) { + self->styleColor_ = lg.value(QStringLiteral("pointColor")).toString(); + } else { + self->styleColor_ = lg.value(QStringLiteral("polylineColor")).toString(); + self->styleWidth_ = lg.value(QStringLiteral("polylineWidth")).toDouble(); + self->styleDashed_ = + lg.value(QStringLiteral("polylineShape")).toString().contains(QStringLiteral("dash")); + } + }); +} + QString AnomalySaveDialog::anomalyName() const { const QString n = name_->text().trimmed(); return n.isEmpty() ? QStringLiteral("异常") : n; diff --git a/src/app/AnomalySaveDialog.hpp b/src/app/AnomalySaveDialog.hpp index 7220eaa..c32d2ba 100644 --- a/src/app/AnomalySaveDialog.hpp +++ b/src/app/AnomalySaveDialog.hpp @@ -30,10 +30,23 @@ public: QString typeId() const; QString remark() const; + // 选中类型的平台样式(从 legend 按形态派生,与平台一致)。styleColor 空 = 未取到,调用方用默认样式。 + QString styleColor() const { return styleColor_; } + double styleWidth() const { return styleWidth_; } + bool styleDashed() const { return styleDashed_; } + private: // 异步拉平台异常类型(label→显示, value→id)填充下拉;空/失败时下拉留空(EmptyAwareComboBox 提示)。 void loadTypes(geopro::data::IDatasetCommandRepository* cmdRepo, const QString& projectId, int remarkSourceType); + // 拉当前选中类型的详情 legend → 按形态(点/线/面)派生 styleColor/Width/Dashed。 + void loadStyleForCurrent(); + + geopro::data::IDatasetCommandRepository* cmdRepo_ = nullptr; + int remarkSourceType_ = 3; + QString styleColor_; // legend 派生线/点色(空=未取到) + double styleWidth_ = 0.0; // legend.polylineWidth + bool styleDashed_ = false; // legend.polylineShape 含 "dash" QLineEdit* name_ = nullptr; QComboBox* type_ = nullptr; diff --git a/src/app/main.cpp b/src/app/main.cpp index 2f4cd82..7dad451 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -597,6 +597,12 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re a.typeName = dlg.typeName().toStdString(); a.exceptionTypeId = dlg.typeId().toStdString(); a.remark = dlg.remark().toStdString(); + // 平台样式:选中异常类型的 legend 派生(与平台一致);未取到则保留上面的默认样式。 + if (!dlg.styleColor().isEmpty()) { + a.lineColor = dlg.styleColor().toStdString(); + if (dlg.styleWidth() > 0.0) a.lineWidth = dlg.styleWidth(); + a.dashed = dlg.styleDashed(); + } scene3dRepo->saveAnomaly( a, shot.toStdString(), [sceneView, renderWindowPtr, refreshAnomalies, refreshAnalysis, diff --git a/src/data/api/ApiDatasetCommandRepository.cpp b/src/data/api/ApiDatasetCommandRepository.cpp index c48e6e8..d0edbb6 100644 --- a/src/data/api/ApiDatasetCommandRepository.cpp +++ b/src/data/api/ApiDatasetCommandRepository.cpp @@ -387,6 +387,13 @@ void ApiDatasetCommandRepository::listExceptionTypes( std::move(cb)); } +void ApiDatasetCommandRepository::getExceptionTypeDetail( + const QString& exceptionTypeId, std::function cb) { + wireObject(api_.getAsync(QStringLiteral("/business/exceptionType/getDetail/%1") + .arg(enc(exceptionTypeId))), + std::move(cb)); +} + void ApiDatasetCommandRepository::listArrayTypes( std::function cb) { wireArray(api_.getAsync(QStringLiteral("/business/script/arrayTypeList")), std::move(cb)); diff --git a/src/data/api/ApiDatasetCommandRepository.hpp b/src/data/api/ApiDatasetCommandRepository.hpp index f0d093d..fcde77a 100644 --- a/src/data/api/ApiDatasetCommandRepository.hpp +++ b/src/data/api/ApiDatasetCommandRepository.hpp @@ -81,6 +81,9 @@ public: void listExceptionTypes( const QString& projectId, const QString& remarkSourceType, std::function cb) override; + void getExceptionTypeDetail( + const QString& exceptionTypeId, + std::function cb) override; void listArrayTypes(std::function cb) override; void getExceptionName( const QString& exceptionTypeId, const QString& remarkSourceId, diff --git a/src/data/repo/IDatasetCommandRepository.hpp b/src/data/repo/IDatasetCommandRepository.hpp index 8bfc527..f56aa35 100644 --- a/src/data/repo/IDatasetCommandRepository.hpp +++ b/src/data/repo/IDatasetCommandRepository.hpp @@ -167,6 +167,13 @@ public: const QString& projectId, const QString& remarkSourceType, std::function cb) = 0; + // 异常类型详情:GET /business/exceptionType/getDetail/{id} → data{...legend...}。 + // data.legend = {polylineColor/Width/Shape, pointColor/Size/Shape, polygonFillColor,...}, + // 供创建异常时按平台类型样式渲染(与平台一致)。回调 data = 整个 data 对象。 + virtual void getExceptionTypeDetail( + const QString& exceptionTypeId, + std::function cb) = 0; + // 装置类型枚举:GET /business/script/arrayTypeList → [{itemValue,name}](电阻率/视电阻率段装置筛选用)。 virtual void listArrayTypes(std::function cb) = 0;