[vtkusers] Using vtkImageTracerWidget together with vtkImagePlaneWidget
Dean Inglis
dean.inglis at sympatico.ca
Fri Oct 30 07:53:49 EDT 2009
Hi Ralph,
the problem is that both widgets are intercepting mouse events
at the same time, and since your image plane widgets are spinning
around when you click on one of them, the image plane widgets
have a higher priority than the image tracer widget if they were
added last to the renderer, even though all widgets start with a default
priority of 0. You would have to set the priority
of the tracer widgets to 1 to fix this. The tracer widget
also needs some type of vtkProp to fire picks at, but the image
plane widget does not expose the actor you need, its TexturePlaneActor,
through its public API. A dummy actor will not work unless it is
rendered in the same location in the renderer. vtkImageTracerWidget was
really meant only
for picking on vtkImageActors. You could try to set up a set of
renderers, each with a vtkImageActor whose input image is the
GetResliceOutput
of a corresponding image plane widget and then add tracer widgets to pick
on those actors. Another work around is to use vtkContourWidget and set up
an appropriate point placer for its representation.
Another work around is to access the image plane widgets' picker and
find the TextPlaneActor that the picker keeps in its PickList:
vtkCellPicker* picker = vtkCellPicker::New();
for( int i = 0; i < 3; i++ )
{
m_pPlaneWidget[i]->SetPicker(picker);
vtkPropCollection* pc = picker->GetPickList();
m_pTracerWidget[i]->SetPriority(1);
m_pTracerWidget[i]->SetViewProp(pc->GetLastProp());
}
Dean
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?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dean Inglis, PhD
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~ Centre for Appendicular ~~~~~
Magnetic Resonance Imaging Studies
www.camris.ca
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
612 - 25 Charlton Ave. E.
Hamilton, Ontario, L8N 1Y2
fax: (905) 521-1297
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assistant Professor (Adjunct)
Department of Civil Engineering
McMaster University
Hamilton, Ontario
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Software Demos:
http://www.youtube.com/watch?v=iVmMdUc1gM8
http://www.youtube.com/watch?v=_zYNtHC9-0s
More information about the vtkusers
mailing list