[vtkusers] cannot use vtkCornerAnnotation with vtkImageSlice class
    ankit.master at gmail.com 
    ankit.master at gmail.com
       
    Fri Mar  2 14:11:34 EST 2012
    
    
  
Hello, 
I am trying to read an image and also provide a corner annotation to it, I
am using vtkImageSlice and vtkCornerAnnotation classes to do; but whenever I
bring up an image, I always get blank image. However, when I comment out the
following command my image appears correctly. 
renderer-> AddViewProp(cornerAnnotation) 
So, it appears that the renderer is overwriting the Image that is read
earlier by the actor of type corner annotation, does anyone know what should
I do to not get a blank image and also be able to visualize corner
annotation. 
Following is my code snippet. 
 vtkSmartPointer<vtkImageData> grayImageReal =
vtkSmartPointer<vtkImageData>::New();
   
    CreateGrayScaleImage(grayImageReal, realImage);
  
   
    vtkSmartPointer<vtkImageSliceMapper> imageSliceMapper =       
vtkSmartPointer<vtkImageSliceMapper>::New();
   
//imageSliceMapper->SetInputConnection(grayImageReal->GetProducerPort());
    imageSliceMapper->SetInputConnection( (*it )-> GetProducerPort());
    vtkSmartPointer<vtkImageSlice> imageSlice =
vtkSmartPointer<vtkImageSlice>::New();
    imageSlice->SetMapper(imageSliceMapper);
    // Setup renderers
    vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
    // renderer->AddViewProp(imageSlice);
    renderer->AddActor(imageSlice); 
    renderer->ResetCamera();
    // mouse event picker 
    vtkSmartPointer<vtkPropPicker> propPicker =
vtkSmartPointer<vtkPropPicker>::New();
    propPicker->PickFromListOn();
    propPicker->AddPickList(imageSlice);   //Note vtkImageSlice is the
parent class of vtkImageActor.  
    // Annotate the image with window/level and mouse over pixel
    // information
     vtkSmartPointer<vtkCornerAnnotation> cornerAnnotation = 
      vtkSmartPointer<vtkCornerAnnotation>::New();
  cornerAnnotation->SetLinearFontScaleFactor( 2 );
  cornerAnnotation->SetNonlinearFontScaleFactor( 1 );
  cornerAnnotation->SetMaximumFontSize( 20 );
  cornerAnnotation->SetText( 0, "lower left" );
  cornerAnnotation->SetText( 1, "lower right" );
  cornerAnnotation->SetText( 2, "upper left" );
  cornerAnnotation->SetText( 3, "upper right" );
  cornerAnnotation->GetTextProperty()->SetColor( 1,0,0);
 
  renderer->AddViewProp(cornerAnnotation);        
After the above renderer statement my Image is completely lost and what is
rendered is a blank page, although I do get to see the annotation. 
Thank you in advance. 
Ankit 
--
View this message in context: http://vtk.1045678.n5.nabble.com/cannot-use-vtkCornerAnnotation-with-vtkImageSlice-class-tp5531915p5531915.html
Sent from the VTK - Users mailing list archive at Nabble.com.
    
    
More information about the vtkusers
mailing list