fix(ui): 右键菜单限三维体段+容器节点去复选框+容器树剪枝(只展示有体路径)

This commit is contained in:
gaozheng 2026-06-25 12:17:50 +08:00
parent 72e82be63c
commit eb50a87694
2 changed files with 22 additions and 5 deletions

View File

@ -486,7 +486,19 @@ void buildWorkbench(QMainWindow& window, geopro::data::LocalSampleRepository& re
// 三维体段=从项目根的完整层级树:项目根/GS/TM 容器节点 → 体(挂生成位置) → 切片(挂体) → 异常(挂体/切片)。 // 三维体段=从项目根的完整层级树:项目根/GS/TM 容器节点 → 体(挂生成位置) → 切片(挂体) → 异常(挂体/切片)。
// populateDatasetList 按 parentId 自动建树spec §7/§8 // populateDatasetList 按 parentId 自动建树spec §7/§8
std::vector<geopro::data::DsRow> voxelTree; std::vector<geopro::data::DsRow> voxelTree;
for (const auto& n : *lastStructNodes) { // 项目根/GS/TM 容器节点ddCode="container",不可勾选) // 剪枝:只展示有三维体挂载的容器路径(从体的生成位置向上追溯到根),不带出无关 GS/TM。
std::map<std::string, const geopro::data::StructNode*> byId;
for (const auto& n : *lastStructNodes) byId[n.id] = &n;
std::set<std::string> keep;
for (const auto& v : vols) {
std::string p = v.parentId; // 体的生成位置(structParentId)
while (!p.empty() && byId.count(p) && !keep.count(p)) {
keep.insert(p);
p = byId[p]->parentId; // 向上到祖先GS/项目根)
}
}
for (const auto& n : *lastStructNodes) { // 仅保留有体路径的容器节点ddCode="container",无复选框)
if (!keep.count(n.id)) continue;
geopro::data::DsRow c; geopro::data::DsRow c;
c.id = n.id; c.id = n.id;
c.dsName = n.name; c.dsName = n.name;

View File

@ -87,8 +87,10 @@ CategorySection::CategorySection(const CategorySpec& spec, geopro::data::Dataset
if (id.isEmpty()) return; if (id.isEmpty()) return;
emit detailRequested(id, it->data(0, kDsDdCodeRole).toString(), it->data(0, kDsNameRole).toString()); emit detailRequested(id, it->data(0, kDsDdCodeRole).toString(), it->data(0, kDsNameRole).toString());
}); });
list_->setContextMenuPolicy(Qt::CustomContextMenu); if (spec_.id == "voxel") { // 仅三维体段提供右键操作菜单(体/切片/异常)
connect(list_, &QTreeWidget::customContextMenuRequested, this, &CategorySection::showContextMenu); list_->setContextMenuPolicy(Qt::CustomContextMenu);
connect(list_, &QTreeWidget::customContextMenuRequested, this, &CategorySection::showContextMenu);
}
body->addWidget(list_, 1); body->addWidget(list_, 1);
root->addWidget(body_, 1); root->addWidget(body_, 1);
@ -170,8 +172,11 @@ void CategorySection::rebuildList() {
const QSignalBlocker block(list_); const QSignalBlocker block(list_);
populateDatasetList(list_, filtered, /*append=*/false); populateDatasetList(list_, filtered, /*append=*/false);
for (QTreeWidgetItemIterator it(list_); *it; ++it) { for (QTreeWidgetItemIterator it(list_); *it; ++it) {
// 容器节点(项目根/GS/TM只作层级骨架不可勾选。 // 容器节点(项目根/GS/TM只作层级骨架——明确去掉复选框、不可勾选。
if ((*it)->data(0, kDsDdCodeRole).toString() == QStringLiteral("container")) continue; if ((*it)->data(0, kDsDdCodeRole).toString() == QStringLiteral("container")) {
(*it)->setFlags((*it)->flags() & ~Qt::ItemIsUserCheckable);
continue;
}
(*it)->setFlags((*it)->flags() | Qt::ItemIsUserCheckable); (*it)->setFlags((*it)->flags() | Qt::ItemIsUserCheckable);
(*it)->setCheckState(0, Qt::Unchecked); (*it)->setCheckState(0, Qt::Unchecked);
} }