feat/vtk-3d-view #7

Merged
gaozheng merged 301 commits from feat/vtk-3d-view into main 2026-06-27 18:43:52 +08:00
3 changed files with 14 additions and 5 deletions
Showing only changes of commit d470dc8154 - Show all commits

View File

@ -23,12 +23,14 @@ EmptyAwareComboBox::EmptyAwareComboBox(QWidget* parent) : QComboBox(parent) {
int EmptyAwareComboBox::realItemCount() const { int EmptyAwareComboBox::realItemCount() const {
int n = 0; int n = 0;
auto* m = model();
for (int i = 0; i < count(); ++i) { for (int i = 0; i < count(); ++i) {
// 排除临时「暂无数据」占位项。 // 排除临时「暂无数据」占位项。
if (itemData(i, kEmptyHintRole).toBool()) continue; if (itemData(i, kEmptyHintRole).toBool()) continue;
// 排除不可选项(禁用 / NoItemFlags它们不构成「真实可选数据」。 // 排除不可选项(禁用 / NoItemFlags。用 model()->flags() 正确取项标志——
if (!(itemData(i, Qt::UserRole - 1).value<Qt::ItemFlags>() & Qt::ItemIsSelectable)) // 原 itemData(i, UserRole-1) 不是 Qt 的 flags 角色,对正常项恒返回不可选 →
continue; // realItemCount 恒 0 → 有真实项也误插「暂无数据」(用户实测:异常区下方多一条暂无数据)。
if (m && !(m->flags(m->index(i, modelColumn())) & Qt::ItemIsSelectable)) continue;
++n; ++n;
} }
return n; return n;

View File

@ -50,6 +50,7 @@ void AnomalyDrawTool::start(DrawMode mode, const Vec3& planeOrigin, const Vec3&
onFinish_ = std::move(onFinish); onFinish_ = std::move(onFinish);
onCancel_ = std::move(onCancel); onCancel_ = std::move(onCancel);
pts_.clear(); pts_.clear();
ptsBeforeClick_.clear();
lastClickMs_ = -1.0; lastClickMs_ = -1.0;
hasCursor_ = false; hasCursor_ = false;
active_ = true; active_ = true;
@ -254,10 +255,15 @@ void AnomalyDrawTool::installObservers() {
self->lastClickMs_ = now; self->lastClickMs_ = now;
self->lastClickX_ = p[0]; self->lastClickX_ = p[0];
self->lastClickY_ = p[1]; self->lastClickY_ = p[1];
if (dbl) if (dbl) {
// 隔离单/双击:回滚"双击第一下"那次加点/移点(否则点会移、线多一段、面多一条边),再完成。
self->pts_ = self->ptsBeforeClick_;
self->updatePreview();
self->finish(); self->finish();
else } else {
self->ptsBeforeClick_ = self->pts_; // 快照本次点击前状态,供随后可能的双击回滚
self->addVertex(); self->addVertex();
}
break; break;
} }
case vtkCommand::RightButtonPressEvent: case vtkCommand::RightButtonPressEvent:

View File

@ -55,6 +55,7 @@ private:
DrawMode mode_ = DrawMode::Face; DrawMode mode_ = DrawMode::Face;
Vec3 origin_{{0, 0, 0}}, normal_{{0, 0, 1}}; Vec3 origin_{{0, 0, 0}}, normal_{{0, 0, 1}};
std::vector<Vec3> pts_; std::vector<Vec3> pts_;
std::vector<Vec3> ptsBeforeClick_; // 上一次单击前快照:双击时回滚"第一下"加点/移点,隔离单/双击
std::function<void(const std::vector<Vec3>&)> onFinish_; std::function<void(const std::vector<Vec3>&)> onFinish_;
std::function<void()> onCancel_; std::function<void()> onCancel_;