geopro/src/app/ColorScaleIO.hpp

35 lines
1.2 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 <string>
#include <utility>
#include <vector>
#include "model/ColorScale.hpp" // core::Rgba
namespace geopro::app {
// .lvl 文件一行(复刻 colorUtils.js parseLvlFile / generateLvlContent
struct LvlRow {
double level = 0.0;
geopro::core::Rgba color{0, 0, 0, 255}; // FFGColor填充色
bool dashed = false; // LStyle: solid / .1 in. Dash
geopro::core::Rgba lineColor{0, 0, 0, 255}; // LColor线色
};
// 解析 .lvl 文本 → 行列表(头部校验失败/空 → 空)。
std::vector<LvlRow> parseLvl(const std::string& content);
// 生成 .lvl 文本LVL3 头 + 每行 14 列),与原系统互通。
std::string generateLvl(const std::vector<LvlRow>& rows);
// .clr 连续色阶(复刻 colorEditor.vue import/export。pos ∈ [0,1] 升序opacity ∈ [0,1]。
struct ClrData {
std::vector<std::pair<double, geopro::core::Rgba>> stops;
double opacity = 1.0;
};
// 解析 .clr 文本(头 `ColorMap n 0 6 2` + `pos*100 r g b a` 行 + 末两行透明度)。失败 → stops 空。
ClrData parseClr(const std::string& content);
// 生成 .clr 文本。
std::string generateClr(const ClrData& data);
} // namespace geopro::app