[vtkusers] Re: problem with fitting image into viewport
Thomas Lambertz
thomas at hexerei-software.de
Tue May 30 15:25:52 EDT 2006
Goodwin Lawlor wrote:
> Thomas Lambertz wrote:
>> Hi Goodwin,
>>
>> thx for your answer. The link is unfortuantly one of the ones i based
>> my code on. They used a vtkActor which seemes to work fine.
>>
>> I am still not sure wether it has to do with vtkActor2D or the
>> vtkImageMapper i used - or better the way i used them. The bug is
>> certanly in my code.
>> Any suggestions ?
>>
>> Kind regards,
>> Tom
>>
>
> Hi Tom,
>
> You need to set the renWin to the same size as the image...
>
> int dims[3];
> connector->GetOutput()->GetDimensions(dims);
> renWin->SetSize(dims[0],dims[1]);
>
> the parallel scale should be set to half the y image dimension:
>
> ren2->GetActiveCamera()->SetParallelScale(dims[1]/2);
>
> hth
>
> Goodwin
>
Hi Goodwin,
i thought renWin->SetSize(x,y); sets the dimension of the renderWindow
in display-coordinates. This is exactly what i wanted to avoid. I have a
userdefinded Windowsize and i want to fit my image into that.
After reading more and more in the mailinglistarchive i found out that
my problem seemes to be the use of vtkActor2D as this simply doesnt take
account of camera settings. Someone may correct me if i am wrong.
Your Code:
>/ here's the bit you need: (app is an image; numCol and numRow are
/>/ the image
/>/ dims)
/>/
/>/ vtkImageActor ia
/>/ ia SetInput [app GetOutput]
/>/ ia InterpolateOff
/>/ vtkRenderer ren1
/>/ ren1 AddActor ia
/>/ ren1 SetBackground 1 1 1
/>/ vtkRenderWindow renWin
/>/ renWin AddRenderer ren1
/>/ renWin SetSize [expr $numCol / 4] [expr $numRow / 4]
/>/ vtkInteractorStyleImage istyle
/>/ vtkRenderWindowInteractor iren
/>/ iren SetRenderWindow renWin
/>/ iren SetInteractorStyle istyle
/>/ [ren1 GetActiveCamera] ParallelProjectionOn
/>/ #fit the image to the render window
/>/ [ren1 GetActiveCamera] SetParallelScale [expr $numRow / 2]
/>/ renWin Render
/>/
/>/
/>/ hth
/>/
/>/ Goodwin
found in http://public.kitware.com/pipermail/vtkusers/2005-May/079949.html seemes to bring me right back on track as it gives me the missing link vtkImageActor.
Thank you very much for your help !
King regards,
Tom
/
More information about the vtkusers
mailing list