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

78 lines
3.4 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 <QDialog>
#include <QJsonArray>
#include <QString>
#include <vector>
class QButtonGroup;
class QComboBox;
class QLineEdit;
class QSpinBox;
class QTableWidget;
class QPushButton;
class QToolButton;
class QLabel;
class QVBoxLayout;
class QWidget;
namespace geopro::data {
class IDatasetCommandRepository;
}
namespace geopro::app {
// 自动标注对话框I13复刻原版 AutoAnnotationDialog1400×600
// 左规则卡片列表标题「规则N」+ 折叠 + 删除;阈值模式 radio-button 数值/百分位、min/max、
// 最小点数、异常类型)+「添加规则」。
// 右上:数据统计(最大/最小/均值/中位数,从网格标量算)+ 预览图(后置标注)。
// 右下:预览表(序号/异常名称/异常类型/阈值范围/阈值模式/操作删除)。
// 执行 → executeExceptionMark(预演) → 预览表;确认保存 → batchCreateException → reloadGrid。
// 异常类型仅支持面/polygon原版同listExceptionTypes 取 remarkSourceType="3"。
class AutoAnnotationDialog : public QDialog {
Q_OBJECT
public:
// gridValues网格标量用于右上数据统计 max/min/mean/median可空统计显示 '-')。
AutoAnnotationDialog(geopro::data::IDatasetCommandRepository* repo, QString dsObjectId,
QString projectId, std::vector<double> gridValues,
QWidget* parent = nullptr);
private:
// 一条规则卡片的控件集合(卡片标题/折叠/删除 + 模式 radio + min/max + 最小点数 + 类型)。
struct RuleCard {
QWidget* frame = nullptr; // 整张卡片(删除时移除)
QWidget* body = nullptr; // 折叠隐藏的主体
QLabel* title = nullptr; // 「规则N」
QButtonGroup* modeGroup = nullptr; // 1 数值 / 2 百分位radio-button
QLineEdit* min = nullptr;
QLineEdit* max = nullptr;
QSpinBox* minPoints = nullptr;
QComboBox* type = nullptr; // userData = 异常类型 id
};
void buildStatsBar(QVBoxLayout* into); // 右上统计条max/min/mean/median
void loadExceptionTypes(); // 拉面异常类型(填充所有规则卡片下拉)
void addRule(); // 加一条规则卡片
void removeRule(QWidget* frame); // 删除指定卡片(至少保留一条)
void renumberRules(); // 重排卡片标题「规则N」
int currentMode(const RuleCard& c) const; // 取当前 radio 模式1/2
QJsonArray buildRuleList() const; // 组装 exceptionMarkRuleList
void onExecute(); // executeExceptionMark → 预览
void onSave(); // batchCreateException
void deletePreviewRow(int row); // 删除一条预览异常
geopro::data::IDatasetCommandRepository* repo_ = nullptr;
QString dsObjectId_;
QString projectId_;
std::vector<double> gridValues_;
QVBoxLayout* ruleHost_ = nullptr;
std::vector<RuleCard> rules_;
QJsonArray exceptionTypeOptions_; // 缓存的类型列表({id,name}),新增规则卡片复用
QTableWidget* previewTable_ = nullptr;
QJsonArray previewExceptions_; // execute 返回的预览异常confirm 时批量存)
QLabel* detectedLabel_ = nullptr; // 「共识别到 N 个异常」
QPushButton* saveBtn_ = nullptr;
};
} // namespace geopro::app