[vtkusers] vtkSeedWidget GetSeedDisplayPosition Question
Ken Urish
ken.urish at gmail.com
Tue Jun 24 23:02:38 EDT 2008
Ive been struggling with vtkSeedWidget and I would apprecaite if
anyone can point me in the right direction. Any example code on how to
get seed position off 2d image would be just as good.
I can easily place seeds on a 2d image using vtkSeedWidget. I am
having difficulty getting their location. I setup a callback that
monitors mouse position and pointPlaceEvents. It correctly tells me
how many seeds I have.
I am trying to then have it give me the seed location by calling:
this->SeedRepresentation->GetSeedDisplayPosition (seedNumber, point);
I get the error message: vtkSeedRepresentation (029B6D28): Trying to
access non-existent handle. I am stuck. I put the call back below for
any help.
Thanks
--Ken--
// This callback is responsible for setting the seed label.
class vtkSeedCallback : public vtkCommand
{
public:
static vtkSeedCallback *New()
{ return new vtkSeedCallback; }
virtual void Execute(vtkObject*, unsigned long eid, void*)
{
if ( eid == vtkCommand::CursorChangedEvent )
cout << "cursor changed\n";
else
{
int seedNumber;
double point[3];
double ptMapped[3];
cout << "point placed\n";
cout << "Total number of seeds: "
<< this->SeedRepresentation->GetNumberOfSeeds () << "\n";
seedNumber = this->SeedRepresentation->GetNumberOfSeeds ();
this->SeedRepresentation->GetSeedDisplayPosition
(seedNumber, point);
}
}
vtkSeedCallback() : SeedRepresentation(0) {}
vtkSeedRepresentation *SeedRepresentation;
};
//Below is the setup in main program for the callback
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renWin->Render();
// Say hello to my big widget
// Create the widget and its representation
vtkPointHandleRepresentation2D *handle =
vtkPointHandleRepresentation2D::New();
handle->GetProperty()->SetColor(1,0,0);
vtkSeedRepresentation *rep = vtkSeedRepresentation::New();
rep->SetHandleRepresentation(handle);
vtkSeedWidget *widget = vtkSeedWidget::New();
widget->SetInteractor(iren);
widget->SetRepresentation(rep);
vtkSeedCallback *mcbk = vtkSeedCallback::New();
mcbk->SeedRepresentation = rep;
widget->AddObserver(vtkCommand::PlacePointEvent,mcbk);
widget->AddObserver(vtkCommand::CursorChangedEvent,mcbk);
// render the image
iren->Initialize();
renWin->Render();
widget->On();
iren->Start();
More information about the vtkusers
mailing list