[vtkusers] Help updating a QVTKWidget

Garrett Larson garrett at unc.edu
Mon Nov 23 08:04:23 EST 2009


I've created an application that contains a QVTKWidget linked to a
vtkImageViewer2. Alterations to the vtkImageData before initializing the
vtkImageViewer2 are visible as soon as I call viewer->Render(), but any
changes I make later do not appear until I click inside the widget. In fact,
this happens even if I run the exact same sequence of methods to make a new
vtkImageViewer2 (as below). Is this a result of the QVTKWidget caching the
image data, and if so, how can I make it update? Thanks!

==================

  gridData = vtkImageData::New();

// etc.

  gridData->
SetScalarTypeToFloat();
  gridData->AllocateScalars();
  gridData->GetPointData()->GetScalars()->FillComponent(0,0);


// The vtkImageData *gridData is modified via calls to SetScalarComponent...


gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);

  viewer = vtkImageViewer2::New();
  viewer->SetInput(gridData);
  viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());
  viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());
  viewer->Render();

// ... and the modified image is displayed correctly.

// But if the vtkImageData *gridData is further modified via calls to
SetScalarComponent...


gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);

  viewer = vtkImageViewer2::New();
  viewer->SetInput(gridData);
  viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());
  viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());
  viewer->Render();

// ...the new changes are still not visible until I click the image.

===================

-Garrett Larson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091123/10648a1a/attachment.htm>


More information about the vtkusers mailing list