#pragma once #include #include #include namespace geopro::controller { // 纯逻辑:按 2D 类型管理「平面 z + 成员集」。首勾定 z(之后固定); 全消则平面消失。见 spec §8.2。 // 无 Qt/VTK 依赖,便于纯逻辑单测。被 Plane2DRenderStrategy 持有以摆放足迹。 class PlaneZRegistry { public: // 某类型某 ds 勾选:首勾(成员集空)记录平面 z=dsZ;返回该类型当前平面 z(后续勾选投影到此)。 double onChecked(const std::string& typeId, const std::string& dsId, double dsZ) { auto& p = planes_[typeId]; if (p.members.empty()) p.z = dsZ; // 首勾定 z p.members.insert(dsId); return p.z; } // 取消勾选:移出成员;该类型成员集空时清除条目(平面消失,z 遗忘)。 void onUnchecked(const std::string& typeId, const std::string& dsId) { auto it = planes_.find(typeId); if (it == planes_.end()) return; it->second.members.erase(dsId); if (it->second.members.empty()) planes_.erase(it); // 全消 → 平面消失 } bool hasPlane(const std::string& typeId) const { return planes_.count(typeId) > 0; } double planeZ(const std::string& typeId) const { auto it = planes_.find(typeId); return it == planes_.end() ? 0.0 : it->second.z; } // 滑块整体调:移动该类型既有平面 z(类型不存在则无操作)。 void setPlaneZ(const std::string& typeId, double z) { auto it = planes_.find(typeId); if (it != planes_.end()) it->second.z = z; } private: struct Plane { double z = 0.0; std::set members; }; std::map planes_; }; } // namespace geopro::controller