Thanks for the quick response! I've tried that and unfortunately it isn't working for me. I think the issue has to do with the fact that I'm changing the pixel values manually, and the widgets don't realize the image has changed. <br>
<br>I thought it might have to do with the cachedImageDirty() signal, but I don't understand when to call markCachedImageDirty() (before qvtkWidget->update() ? after?) or how to check if the flag is being set appropriately as the value is a protected member of QVTKWidget.<br>
<br>-Garrett Larson<br><br><br><div class="gmail_quote">On Mon, Nov 23, 2009 at 8:53 AM, André Prins <span dir="ltr"><<a href="mailto:a.h.prins@gmail.com">a.h.prins@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You could try calling QVTKWidget::update(), which is Qt's method of<br>
repainting the widget.<br>
See for example: <a href="http://doc.trolltech.com/4.5/qwidget.html#update" target="_blank">http://doc.trolltech.com/4.5/qwidget.html#update</a>.<br>
<br>
Regards,<br>
André<br>
<div><div></div><div class="h5"><br>
On Mon, Nov 23, 2009 at 2:04 PM, Garrett Larson <<a href="mailto:garrett@unc.edu">garrett@unc.edu</a>> wrote:<br>
> I've created an application that contains a QVTKWidget linked to a<br>
> vtkImageViewer2. Alterations to the vtkImageData before initializing the<br>
> vtkImageViewer2 are visible as soon as I call viewer->Render(), but any<br>
> changes I make later do not appear until I click inside the widget. In fact,<br>
> this happens even if I run the exact same sequence of methods to make a new<br>
> vtkImageViewer2 (as below). Is this a result of the QVTKWidget caching the<br>
> image data, and if so, how can I make it update? Thanks!<br>
><br>
> ==================<br>
><br>
> gridData = vtkImageData::New();<br>
><br>
> // etc.<br>
><br>
> gridData-><br>
> SetScalarTypeToFloat();<br>
> gridData->AllocateScalars();<br>
> gridData->GetPointData()->GetScalars()->FillComponent(0,0);<br>
><br>
><br>
> // The vtkImageData *gridData is modified via calls to SetScalarComponent...<br>
><br>
><br>
> gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);<br>
><br>
> viewer = vtkImageViewer2::New();<br>
> viewer->SetInput(gridData);<br>
> viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());<br>
> viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());<br>
> viewer->Render();<br>
><br>
> // ... and the modified image is displayed correctly.<br>
><br>
> // But if the vtkImageData *gridData is further modified via calls to<br>
> SetScalarComponent...<br>
><br>
><br>
> gridData->SetScalarComponentFromDouble((int)pos[0],(int)pos[1],0,0,intensity);<br>
><br>
> viewer = vtkImageViewer2::New();<br>
> viewer->SetInput(gridData);<br>
> viewer->SetupInteractor(this->ui->qvtkWidget->GetInteractor());<br>
> viewer->SetRenderWindow(this->ui->qvtkWidget->GetRenderWindow());<br>
> viewer->Render();<br>
><br>
> // ...the new changes are still not visible until I click the image.<br>
><br>
> ===================<br>
><br>
> -Garrett Larson<br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
</blockquote></div><br>