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
1 changed files with 6 additions and 21 deletions
Showing only changes of commit 43f8228e49 - Show all commits

View File

@ -131,28 +131,13 @@ int InteractionManager::nearestSlice(const Vec3& worldPoint) const {
} }
void InteractionManager::onPicked(const Vec3& worldPoint) { void InteractionManager::onPicked(const Vec3& worldPoint) {
// 单击 = 仅选中命中切片 + 高亮,**不动相机** → 切换切片永不跳。
// 拖动旋转交给默认 TrackballCamera绕场景/体中心,稳定)。曾试"按切片中心移焦点"以实现
// spec C38'以切片为中心',但切片中心≈体中心→与默认视觉等价、却引入切换跳动,得不偿失,故去除。
const int idx = nearestSlice(worldPoint); const int idx = nearestSlice(worldPoint);
if (idx < 0) { if (idx >= 0) {
safeRender(); // 未命中切片:不动相机(拖动绕当前中心旋转,不甩) selected_ = idx;
return; updateSelectionVisual();
}
selected_ = idx;
updateSelectionVisual();
// 旋转中心 = 切片中心spec C38 "以切片为中心旋转"**不是点击点**
// 实测点击点常远离体中心,绕它拖动旋转会大幅摆动(=用户看到的"跳");切片中心≈体中心 → 居中、不甩。
// 焦点与相机位置同步平移同一 delta → 视向/距离不变、点击瞬间画面不动;之后 TrackballCamera 绕切片中心旋转。
if (renderer_) {
if (auto* cam = renderer_->GetActiveCamera()) {
const Vec3 c = slices_[static_cast<std::size_t>(idx)]->center();
double f[3], p[3];
cam->GetFocalPoint(f);
cam->GetPosition(p);
const double d[3] = {c[0] - f[0], c[1] - f[1], c[2] - f[2]};
cam->SetFocalPoint(c[0], c[1], c[2]);
cam->SetPosition(p[0] + d[0], p[1] + d[1], p[2] + d[2]);
renderer_->ResetCameraClippingRange();
}
} }
safeRender(); safeRender();
} }