[vtkusers] Reset Window Level / Pressing 'r' key

David Doria daviddoria at gmail.com
Fri Apr 20 08:07:17 EDT 2012


On Fri, Apr 20, 2012 at 5:42 AM, FrankWhite <frankwhite at live.nl> wrote:

> Hi
>
> Does anyone know the code behind pressing the 'r' key or how to duplicate
> its functionality?
>
> I want the camera to reset such that all actors are in the center of the
> window.
>
> I tried:
> - renderer->ResetCamera();
> - renderer->Render();
> - Invoking the ResetWindowLevel event
> - ..
>
> None seem to do the job right. Only when I press 'r' it is centered
> correctly.
>
> I hope someone can shed some light over this.
>
> Thanks in advance.
>
> Frank W.
>

In vtkInteractorStyle.cxx this is the relevant code in the OnChar()
function:

    case 'r' :
    case 'R' :
      this->FindPokedRenderer(rwi->GetEventPosition()[0],
                              rwi->GetEventPosition()[1]);
      if(this->CurrentRenderer!=0)
        {
        this->CurrentRenderer->ResetCamera();
        }
      else
        {
        vtkWarningMacro(<<"no current renderer on the interactor style.");
        }
      rwi->Render();
      break;

As you can see all it does is call ResetCamera(). The centering is exactly
the job of the ResetCamera() function - why do you think it is not working
correctly? Can you make the shortest possible example to show us a case
where it doesn't work?

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120420/79ceb010/attachment.htm>


More information about the vtkusers mailing list