Hi,
I'm trying to set up label map drawing on dicom slices very similar to the
paintbrush examples, except I'm using Qt for my widgets. Everything works,
I have a WidgetGroup for three PaintBrushWidgets that show my axial,
coronal, and sagittal views. And I can successfully draw on the Axial view,
however, the drawings are not visible on the other two views. I can
actually draw on the other two views, and what I draw shows up in the Axial
view correctly oriented to reflect what I drew in the other views, but it is
still not visible in the other two views. The reason the axial works is
because I set the drawing from that representation up first (it is the 0th
widget in the Group), and set that drawing to the representation of the
other views, just like in the examples. Some of the code is pasted below.
Is there a flag or setting that may not be set, or something else I'm
missing?
Thanks,
Stephen
//get the group of slice images
vtkSmartPointer<vtkKWEWidgetGroup> set = /*widget group*/;
//loop through slice viewers
for(int i = 0; i < 3; i++)
{
vtkSmartPointer<vtkImageViewer2> imageViewer = /*a vtk image viewer*/;
//finish connecting the filters
imageViewer->SetInput(/*image output*/)
//create paintbrush widget
CfimPaintbrushWidget* w = CfimPaintbrushWidget::New();
w->SetInteractor( imageViewer->GetRenderWindow()->GetInteractor());
vtkSmartPointer<vtkKWEPaintbrushRepresentation2D> rep =
vtkKWEPaintbrushRepresentation2D::SafeDownCast(w->GetRepresentation());
if (rep)
{
rep->SetImageActor(imageViewer->GetImageActor());
rep->SetImageData(/*image output*/);
rep->GetPaintbrushOperation()->GetPaintbrushShape()->SetSpacing(
(/*image output*/)->GetSpacing() );
rep->GetPaintbrushOperation()->GetPaintbrushShape()->SetOrigin(
(/*image output*/)->GetOrigin() );
}
set->AddWidget(w);
w->Delete();
}
set->SetEnabled(1);
//get the drawing from the first widget, which is probably axial
vtkKWEPaintbrushRepresentation2D * rep =
vtkKWEPaintbrushRepresentation2D::SafeDownCast(
set->GetNthWidget(0)->GetRepresentation());
vtkKWEPaintbrushDrawing * drawing = rep->GetPaintbrushDrawing();
// Our internal representation will be to manage a label map.
drawing->SetRepresentationToLabel();
// This will allocate our canvas based on the size of the overlay image
// that was set on the WidgetRepresentation.
drawing->InitializeData();
drawing->RemoveAllItems();
//create label map
vtkKWEPaintbrushLabelData *paintbrushLabelMap =
vtkKWEPaintbrushLabelData::New();
paintbrushLabelMap->Initialize();
//set label map boundaries
int extent[6];
double spacing[3], origin[3];
/*image output*/->GetExtent(extent);
/*image output*/->GetSpacing(spacing);
/*image output*/->GetOrigin(origin);
paintbrushLabelMap->SetExtent(extent);
paintbrushLabelMap->SetOrigin(origin);
paintbrushLabelMap->SetSpacing(spacing);
// Set the label map as the initial canvas data of the drawing.
drawing->SetPaintbrushData( paintbrushLabelMap );
//hook the same drawing to the other views
for (unsigned int i = 1; i < set->GetNumberOfWidgets(); i++)
{
vtkKWEPaintbrushRepresentation2D * repr =
vtkKWEPaintbrushRepresentation2D::SafeDownCast(
set->GetNthWidget(i)->GetRepresentation());
repr->SetPaintbrushDrawing( drawing );
}
_______________________________________________
VtkEdge mailing list
[email protected]
http://public.kitware.com/cgi-bin/mailman/listinfo/vtkedge