geopro/src/app/ContourLevels.hpp

27 lines
1.3 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 <vector>
namespace geopro::app {
// 层级(分层方式)参数,复刻原版 contourLevel.vue 的 emit。纯数据无 Qt 依赖。
struct ContourLevelParams {
enum class Method { Normal, Logarithmic, EqualArea };
Method method = Method::Normal;
double minValue = 0.0; // 最小等值线normal/log
double maxValue = 1.0; // 最大等值线normal/log
double interval = 0.1; // 间隔数normal
int layerCount = 10; // 层数normal
int logLinesCount = 8; // 每数量级次要等值线数log
int equalAreaLayerCount = 10; // 等积分层层数equalArea
};
// 按分层方式生成升序层级值(复刻 colorLevel.vue case 'level' 的层级重算):
// normal —— len=ceil((max-min)/间隔)levels = min + 间隔*i
// logarithmic —— 10 的幂区间细分(每数量级 logLinesCount 条次要线)
// equalArea —— 原始样本分位;样本不足 cnt 个时退化为等距 cnt 段(复刻原版失败兜底)
// samples 仅 equalArea 用(其余忽略)。返回的颜色由调用方在旧色阶上插值。
std::vector<double> generateContourLevels(const ContourLevelParams& p,
const std::vector<double>& samples);
} // namespace geopro::app