[vtkusers] Loading an image in a Renderer (Qt integrated widget)

Tomás Aguado Gómez tomas.aguado at gmail.com
Thu Jul 27 09:40:24 EDT 2006


Hello everyone:

I am a newbie using VTK. I am developing an open source phase  
unwrapping algorythm test benchmarker, y have a renderer inside a  
QVTKwidget and I want to show an image on it. I use the following  
code which works but shows some problems:

vtkImageData *vimg = vtkImageData::New();
   vimg->SetDimensions(257,257 ,1);
   vtkFloatArray *scalars = vtkFloatArray::New();
   scalars->SetArray(u,66049,1);
   vimg->SetScalarTypeToFloat();
   vimg->AllocateScalars();
   vimg->GetPointData()->SetScalars(scalars);
   scalars->Delete();


   vtkImageMapper *isoMapper = vtkImageMapper::New();
   isoMapper->SetInput(vimg);
   isoMapper->SetColorLevel(0.0);
   isoMapper->SetColorWindow(20.0);


   vtkActor2D *isoActor=vtkActor2D::New();
   isoActor->SetMapper( isoMapper );
   isoActor->SetPosition(6,6);
   ren1->AddActor(isoActor);

   double va[] = {0,257,0,257,0,0};
   ren1->ResetCamera(va);
   ren1->GetRenderWindow()->Render();



The problems are the following:

****When a window passes over my application some strange lines  
appear like interference, I think it could be because I only render  
the image once.

****I want the image to be centered within the renderer ¿How can I  
achieve that?I mean not a static centering (I can achieve that with  
SetPosition) but a dynamic method independent from the size of the  
image itself which scalates the image when the renderer is resized too.


Thanks in advance and hoping to become a pro soon so I can help others!!

Tomás Aguado Gómez
Grupo de Sistemas y Comunicaciones
Universidad Rey Juan Carlos
Móstoles Madrid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060727/8e4412c8/attachment.htm>


More information about the vtkusers mailing list