Skip to content

Commit

Permalink
ENH: Update ctkVTKRenderView::lookFromAxis API
Browse files Browse the repository at this point in the history
This commit is a follow up of d620ad9 (BUG: Fix unexpected camera
position change in ctkVTKRenderView::lookFromAxis) removing the use
of the "fov" parameter originally introduced in fbb33cd (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 <lasso@queensu.ca>
  • Loading branch information
jcfr and lassoan committed Oct 24, 2022
1 parent aa3cc43 commit 8e2d15d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions Libs/Visualization/VTK/Widgets/ctkVTKRenderView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 6 additions & 2 deletions Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8e2d15d

Please sign in to comment.