fix(3d): 双击与单击隔离 + 异常类型下拉误显「暂无数据」
双击结束时"第一下"会先触发单击(点会移/线多一段/面多一条边)。修:每次单击前快照 pts_,双击时 先回滚那一下(pts_=快照)再 finish → 双击纯结束,不再附带加点/移点。 EmptyAwareComboBox::realItemCount 用 itemData(i,UserRole-1) 取 flags 是错的(非 Qt flags 角色), 对正常项恒判不可选 → 计数恒 0 → 有真实项(异常区)也误插「暂无数据」。改用 model()->flags()。 构建:app 链接通过
This commit is contained in:
parent
04af569b7d
commit
d470dc8154
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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_;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue