geopro/src/app/panels/chart/GridDataChartView.hpp

117 lines
5.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <functional>
#include <vector>
#include <QString>
#include <QWidget>
#include "model/Anomaly.hpp"
#include "model/ColorScale.hpp"
#include "model/Field.hpp"
#include "model/detail/DetailPayloads.hpp"
#include "panels/chart/IDetailView.hpp"
#include "ContourLineDialog.hpp" // ContourLineConfig线形/标注状态)
class QSlider;
class QLabel;
class QCheckBox;
class QTimer;
class QwtPlot;
class QwtPlotRescaler;
namespace geopro::data {
class IColorTemplateRepository;
class IDatasetCommandRepository;
}
namespace geopro::app {
class AnomalyTablePanel;
class DescriptionPanel;
class ColorBarWidget;
class ColorMapService;
class ContourPlotItem;
class ContourHoverTip;
// 网格数据图表视图:工具条 + QwtPlot白底 + 真实比尺 + 实时平移/滚轮缩放x 轴在底部)
// + 独立色阶条 + 底部双页签(异常列表/描述)。
// 填充走 ContourPlotItem 栅格热力图 + 矢量等值线 + 标注 + 异常叠加。
class GridDataChartView : public QWidget, public IDetailView {
Q_OBJECT
public:
explicit GridDataChartView(QWidget* parent = nullptr);
~GridDataChartView() override;
// 网格数据到达(懒加载结果):建色彩服务 + ContourPlotItem挂到 QwtPlot更新色阶条/异常表。
void setGridData(const geopro::core::Grid& grid, const geopro::core::ColorScale& gridScale,
const std::vector<geopro::core::Anomaly>& anoms);
// IDetailView解包 ContourPayloadgrid + 色阶 + 异常)→ setGridData。坏/空 variant 保持空态。
QWidget* widget() override { return this; }
void setPayload(const QVariant& payload) override;
// 注入色阶模板仓储 + 当前 projectId 取值回调(打开编辑器时取一次,随项目切换生效)。
// 可传空仓储 → 编辑器内「另存为/打开」「新建色阶」禁用。
void setColorTemplateRepo(geopro::data::IColorTemplateRepository* repo,
std::function<QString()> projectIdGetter);
// 注入反演命令仓储 + dsId/projectId 取值回调(网格化/白化/滤波/另存为按钮)。
// 可传空仓储 → 这些按钮退化为「暂未实现」占位提示。
void setCommandRepo(geopro::data::IDatasetCommandRepository* repo,
std::function<QString()> dsIdGetter,
std::function<QString()> projectIdGetter);
private:
void rebuildContour(); // 按当前显隐开关重建并重绘 ContourPlotItem
void openColorScaleEditor(); // 「色阶配置」→ 共享色阶编辑器(色阶 + 层级⚙ + 线形⚙)
void openGridWizard(); // I1「网格」→ 网格化向导
void openWhitening(); // I3「白化」→ 白化弹窗
void openFilter(); // I4「滤波处理」→ 滤波弹窗
void openSaveAs(); // I15「另存为」→ 复用 SaveAsDialog(Inversion)
void reloadGrid(); // 处理类成功后loadInversionGrid → setGridData 重绘
void applySimplify(); // I8把当前滑块容差透传给 ContourPlotItem 并重绘
void showNotImplemented(QWidget* anchor); // 占位提示(无仓储/无 dsId
void openExceptionDialog(); // I9 异常创建
void openAutoAnnotation(); // I13 自动标注
void deleteAnomaly(int index); // I10 异常删除
void showAnomalyDetail(int index); // I11 异常详情/编辑
void locateAnomaly(int index); // I12 异常定位(高亮 + 缩放)
void loadDescription(); // I14 进入时回填描述
void saveDescription(const QString& text); // I14 保存描述
QwtPlot* plot_ = nullptr;
QwtPlotRescaler* rescaler_ = nullptr;
ColorBarWidget* colorBar_ = nullptr;
AnomalyTablePanel* anomalyTable_ = nullptr;
DescriptionPanel* descriptionPanel_ = nullptr;
QSlider* simplifySlider_ = nullptr;
QLabel* simplifyValueLabel_ = nullptr;
QCheckBox* chkShowLabels_ = nullptr; // 工具条「显示等值线标注」(线形⚙ 改标注显隐后同步)
QTimer* simplifyDebounce_ = nullptr; // I8 简化容差防抖(~300ms
ContourHoverTip* contourTip_ = nullptr; // I7 等值线提示hover
// 渲染状态
ColorMapService* colorSvc_ = nullptr; // heapsetGridData 重建
ContourPlotItem* contourItem_ = nullptr;
geopro::core::Grid grid_{1, 1};
geopro::core::ColorScale gridScale_;
std::vector<geopro::core::Anomaly> anoms_;
bool hasGrid_ = false;
// 工具条显隐开关
bool showAnomalies_ = true;
bool showLabels_ = true;
ContourLineConfig lineCfg_; // 线形/标注配置(色阶编辑器 线形⚙ 下发)
// 色阶模板仓储 + projectId 取值回调(注入;空则编辑器后端按钮禁用)。
geopro::data::IColorTemplateRepository* tplRepo_ = nullptr;
std::function<QString()> projectIdGetter_;
// 反演命令仓储 + dsId 取值回调(注入;空则处理类按钮占位提示)。
geopro::data::IDatasetCommandRepository* cmdRepo_ = nullptr;
std::function<QString()> dsIdGetter_;
};
} // namespace geopro::app