geopro/src/app/panels/ObjectTreeSelection.hpp

35 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>
#include "repo/RepoTypes.hpp"
namespace geopro::app {
enum class GsCheck { Unchecked, Partial, Checked };
// GS 复选框三态spec §6
// Unchecked = 自身 ds 关 且 无子 TM 勾选;
// Checked = 自身 ds 开 且 全部子 TM 勾选(注意是 AND不是"父子都打钩即满"
// Partial = 其余(只 ds 开 / 只部分 TM / ds 开但 TM 未满 等)。
// 无子 TMtotalTmCount==0时退化为仅看 dsOnds 开=Checked关=Unchecked
inline GsCheck aggregateGsState(bool dsOn, int checkedTmCount, int totalTmCount) {
const bool anyOn = dsOn || checkedTmCount > 0;
if (!anyOn) return GsCheck::Unchecked;
const bool tmAll = (totalTmCount == 0) || (checkedTmCount == totalTmCount);
if (dsOn && tmAll) return GsCheck::Checked;
return GsCheck::Partial;
}
// 对象树勾选产出的数据源并集按 {id,confType} 去重保序spec §6
inline std::vector<geopro::data::DataSource> dedupeSources(std::vector<geopro::data::DataSource> in) {
std::vector<geopro::data::DataSource> out;
for (const auto& s : in) {
bool dup = false;
for (const auto& o : out)
if (o.id == s.id && o.confType == s.confType) { dup = true; break; }
if (!dup) out.push_back(s);
}
return out;
}
} // namespace geopro::app