From 8e2d15d94360a197d7d20b7479e9f20ca2783743 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 5 May 2022 01:56:00 -0400 Subject: [PATCH] ENH: Update ctkVTKRenderView::lookFromAxis API This commit is a follow up of d620ad966 (BUG: Fix unexpected camera position change in ctkVTKRenderView::lookFromAxis) removing the use of the "fov" parameter originally introduced in fbb33cdfa (Add ctkVTKRenderView::lookFromAxis(axis, fov)) It was not a good idea to force changing the camera distance from the focal point when the user only requested a view direction change. Co-authored-by: Andras Lasso --- .../Widgets/Testing/Cpp/ctkVTKRenderViewTest1.cpp | 12 ++++++------ .../Widgets/Testing/Cpp/ctkVTKRenderViewTest2.cpp | 12 ++++++------ Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp | 10 ++++++++++ Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h | 8 ++++++-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest1.cpp b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest1.cpp index 7cb553bedc..cfc7bae5f5 100644 --- a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest1.cpp +++ b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest1.cpp @@ -73,12 +73,12 @@ int ctkVTKRenderViewTest1(int argc, char * argv [] ) renderView.renderer()->AddActor(sphereActor.GetPointer()); renderView.lookFromAxis(ctkAxesWidget::Right); - renderView.lookFromAxis(ctkAxesWidget::Left, 10); - renderView.lookFromAxis(ctkAxesWidget::Anterior, 1.); - renderView.lookFromAxis(ctkAxesWidget::Posterior, 1.); - renderView.lookFromAxis(ctkAxesWidget::Superior, 0.333333); - renderView.lookFromAxis(ctkAxesWidget::Inferior, 0.333333); - renderView.lookFromAxis(ctkAxesWidget::None, 100.); + renderView.lookFromAxis(ctkAxesWidget::Left); + renderView.lookFromAxis(ctkAxesWidget::Anterior); + renderView.lookFromAxis(ctkAxesWidget::Posterior); + renderView.lookFromAxis(ctkAxesWidget::Superior); + renderView.lookFromAxis(ctkAxesWidget::Inferior); + renderView.lookFromAxis(ctkAxesWidget::None); if (!interactive) { diff --git a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest2.cpp b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest2.cpp index da555bdee2..f65a1babb5 100644 --- a/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest2.cpp +++ b/Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkVTKRenderViewTest2.cpp @@ -82,12 +82,12 @@ int ctkVTKRenderViewTest2(int argc, char * argv [] ) renderView.renderer()->AddActor(sphereActor.GetPointer()); renderView.lookFromAxis(ctkAxesWidget::Right); - renderView.lookFromAxis(ctkAxesWidget::Left, 10); - renderView.lookFromAxis(ctkAxesWidget::Anterior, 1.); - renderView.lookFromAxis(ctkAxesWidget::Posterior, 1.); - renderView.lookFromAxis(ctkAxesWidget::Superior, 0.333333); - renderView.lookFromAxis(ctkAxesWidget::Inferior, 0.333333); - renderView.lookFromAxis(ctkAxesWidget::None, 100.); + renderView.lookFromAxis(ctkAxesWidget::Left); + renderView.lookFromAxis(ctkAxesWidget::Anterior); + renderView.lookFromAxis(ctkAxesWidget::Posterior); + renderView.lookFromAxis(ctkAxesWidget::Superior); + renderView.lookFromAxis(ctkAxesWidget::Inferior); + renderView.lookFromAxis(ctkAxesWidget::None); if (!interactive) { diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp b/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp index aaaf01fb37..620bccc95c 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp +++ b/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp @@ -492,6 +492,16 @@ void ctkVTKRenderView::resetFocalPoint() void ctkVTKRenderView::lookFromAxis(const ctkAxesWidget::Axis& axis, double fov) { Q_UNUSED(fov); + // The FOV parameter is not used anymore. It was not a good idea to force changing + // the camera distance from the focal point when the user only requested a view direction + // change. + qWarning() << "This function is deprecated. Use lookFromAxis(const ctkAxesWidget::Axis& axis) instead"; + this->lookFromAxis(axis); +} + +//---------------------------------------------------------------------------- +void ctkVTKRenderView::lookFromAxis(const ctkAxesWidget::Axis& axis) +{ Q_D(ctkVTKRenderView); Q_ASSERT(d->Renderer); if (!d->Renderer->IsActiveCameraCreated()) diff --git a/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h b/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h index b0d1e8a311..4a718e6f37 100644 --- a/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h +++ b/Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h @@ -120,8 +120,12 @@ public Q_SLOTS: /// \brief Change camera to look from a given axis to the focal point /// Translate/Rotate the camera to look from a given axis - /// The Field of View (fov) controls how far from the focal point the - /// camera must be (final_pos = focal_point + 3*fov). + void lookFromAxis(const ctkAxesWidget::Axis& axis); + + /// \deprecated + /// \brief Change camera to look from a given axis to the focal point + /// Translate/Rotate the camera to look from a given axis + /// \sa lookFromAxis(const ctkAxesWidget::Axis&) void lookFromAxis(const ctkAxesWidget::Axis& axis, double fov = 10.); public: