[vtkusers] Using vtkImageTracerWidget together with vtkImagePlaneWidget

Ralph Brecheisen ralph.brecheisen at gmail.com
Wed Oct 28 11:22:35 EDT 2009


Hi,

I saw this question has been posted before on vtkusers however nobody
replied. I'd like
to try again :) It seems that the image tracer widget doesn't work in
combination with the
image plane widget.

I start of by creating the plane widgets (one for each axis) in the
constructor of my viewer class.

for( int i = 0; i < 3; i++ )
{
m_pPlaneWidget[i] = vtkImagePlaneWidget::New();
m_pPlaneWidget[i]->SetInteractor( GetRenderWindow()->GetInteractor() );
m_pPlaneWidget[i]->TextureInterpolateOn();
m_pPlaneWidget[i]->SetResliceInterpolateToLinear();
m_pPlaneWidget[i]->Off();
}

Then I create the tracer widgets. As you can see I'm also creating a dummy
actor to satisfy the SetViewProp
method of the image tracer, however it has no effect whatsoever. The
callback doesn't do anything at the moment.

for( int i = 0; i < 3; i++ )
{
m_pPlane[i] = vtkActor::New();

m_pTracerWidget[i] = vtkImageTracerWidget::New();
m_pTracerCallback[i] = vtkImageTracerWidgetCallback::New();
m_pTracerCallback[i]->SetWidget( m_pTracerWidget[i] );

m_pTracerWidget[i]->SetCaptureRadius( 3 );
m_pTracerWidget[i]->GetGlyphSource()->SetGlyphTypeToNone();
m_pTracerWidget[i]->GetGlyphSource()->SetColor( 1, 0, 0 );
m_pTracerWidget[i]->GetGlyphSource()->SetScale(3 );
m_pTracerWidget[i]->GetGlyphSource()->SetRotationAngle( 45 );
m_pTracerWidget[i]->SetViewProp( m_pPlane[i] );
m_pTracerWidget[i]->SetInteractor( GetRenderWindow()->GetInteractor() );
m_pTracerWidget[i]->AddObserver( vtkCommand::EndInteractionEvent,
m_pTracerCallback[i] );
m_pTracerWidget[i]->Off();
}

Once the vtkImageData (called 'pData') has been loaded, I update the plane
and tracer widgets as follows. The
'sliceNr[i]' is the center slice for that particular plane.

for( int i = 0; i < 3; i++ )
{
m_pPlaneWidget[i]->SetInput( pData );
m_pPlaneWidget[i]->SetPlaneOrientation( i );
m_pPlaneWidget[i]->SetSliceIndex( sliceNr[i] );
m_pPlaneWidget[i]->On();
m_pPlaneWidget[i]->InteractionOff();

m_pTracerWidget[i]->SetInput( pData );
m_pTracerWidget[i]->ProjectToPlaneOn();
m_pTracerWidget[i]->SetProjectionNormal( i );
m_pTracerWidget[i]->SetProjectionPosition(
m_pPlaneWidget[i]->GetSlicePosition() );
m_pTracerWidget[i]->SnapToImageOn();
m_pTracerWidget[i]->AutoCloseOn();
m_pTracerWidget[i]->PlaceWidget();
m_pTracerWidget[i]->On();
m_pTracerWidget[i]->InteractionOn();
}

In principle, I would expect this to enable interaction of all 3 tracer
widgets. However, all that happens when
I click either plane is that the whole collection of planes is rotating
around.

Any ideas on what I'm missing or doing wrong?

Thanks a lot,

Ralph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091028/1176b9eb/attachment.htm>


More information about the vtkusers mailing list