[IGSTK-Users] Qt and rending View2D

Anna Brounstein abrou at ece.ubc.ca
Fri Apr 13 20:18:52 EDT 2012


Hello,

I am trying to view a slice of a CT volume loaded with the
CTImageReaderClass. I am using Qt. As far as I can tell, the volume is
loaded correctly, but it does not seem to render in the View2D. I
believe the View2D is connected to the widget correctly, as I can
succesfully change the background colour.

I first read the image using CTImageReaderClass, then store it in a
CTImageSpatialObject. I believe the ImageSpatialObject is created
correctly, as it contains the correct information such as origin.

Finally, I store the CTImageSpatialObject in a
CTImageSpatialObjectRepresentation, so I can add it to the View2D.
Again, I believe this is done correctly, because
ImageSpatialObjectRepresentation contains the same data.

One theory I have, is that I am not setting the RequestSetSlice(
SliceType ) correctly. The object representation's
m_SliceNumberToBeSet may be equal to 0, bt m_SliceNumber remains at
3452816845. I have tested multiple datasets from different sources. I
am unsure how to fix this, if this is the case.

My other theory is that I am not rendering the view correctly.

Unfortunately, I haven't been able to find any examples that really
help me. The closest I have found on my computer is
FourViewsTrackingWithCT, but this is using FLTK and does not display
anything (I don't believe it's loading correctly, as the sliders are
greyed out as well; I assume this is a different issue).

Also, please note that I am a View3D working correctly in the same
project; similar to the OneViewTrackingWithQtAndMicronTracker example.

My system is Windows XP, 32bit and I am using VS2010 Express. I am
using ITK 3.20.1, VTK 5.8.0, IGSTK 4.4 and Qt 4.8.0. I appologize that
this is basic, however I have not been able to find a solution or
example online to help.

I am wondering if anyone might have suggestions on where I have gone
wrong, what I should read or examples I should look at. Thank you very
much,

Anna B

Below is a snippet of my code:

    // instantiate a 2D view
    typedef igstk::View2D ViewType;
    ViewType::Pointer view = ViewType::New();

	typedef igstk::CTImageSpatialObject ImageSpatialObjectType;
	ImageSpatialObjectType::Pointer m_ImageSpatialObject =
ImageSpatialObjectType::New();

	typedef igstk::CTImageReader ImageReaderType;
	ImageReaderType::Pointer m_ImageReader = ImageReaderType::New();

	typedef ImageSpatialObjectType::ImageType ITKImageType;

	typedef igstk::CTImageSpatialObjectRepresentation ImageRepresentationType;
	ImageRepresentationType::Pointer imageRepresentation =
ImageRepresentationType::New();

    igstkObserverObjectMacro( ImageSpatialObject,
ImageReaderType::ImageModifiedEvent,ImageSpatialObjectType);
    igstkObserverConstObjectMacro( ITKImage,
ImageSpatialObjectType::ITKImageModifiedEvent, ITKImageType);

	
	m_ImageReader->RequestSetDirectory(
"C:/prototype/bin/DICOM/GE_PhilipsPhantom");
		
	m_ImageReader->RequestReadImage();
	if(!m_ImageReader->FileSuccessfullyRead () )
	{
		std::cout << "Image not read" << std::endl;
	}
	ImageSpatialObjectObserver::Pointer imageSpatialObjectObserver =
ImageSpatialObjectObserver::New();

	m_ImageReader->AddObserver( ImageReaderType::ImageModifiedEvent(),
imageSpatialObjectObserver );

	m_ImageReader->RequestGetImage();
	if(!imageSpatialObjectObserver->GotImageSpatialObject())
      {

	  std::cout << "Cannot Read Image" << std::endl;

      }
    else
      {
		std::cout << "Image Loaded" << std::endl;
        m_ImageSpatialObject =
imageSpatialObjectObserver->GetImageSpatialObject();
		if(m_ImageSpatialObject->IsEmpty() )
		{
			std::cout << "The Object is Empty!!!" << std::endl;
		}
      }
	imageRepresentation->RequestSetImageSpatialObject( m_ImageSpatialObject );
	imageRepresentation->RequestSetSliceNumber( 0 );
	imageRepresentation->RequestSetOrientation(ImageRepresentationType::Axial );

	view->RequestAddObject( imageRepresentation );
	view->RequestSetOrientation( igstk::View2D::Axial );
	view->RequestResetCamera();
	view->SetRefreshRate( 30 );
	view->SetLogger( logger );
	mainWindow.SetDRRView( view );
	
	view->RequestResetCamera();
	mainWindow.show();
	view->RequestStart();
	view->SetRendererBackgroundColor(1,1,1);
	
	
	// In the source file containg GUI information:
void PrototypeGUI::SetDRRView( igstk::View2D * view )
{

	m_GUI.DRRView->RequestSetView (view);
	view->AddObserver( igstk::CoordinateSystemTransformToEvent(),
                                   m_ViewPickerObserver );
}



More information about the IGSTK-Users mailing list