[vtkusers] Help updating a QVTKWidget

bigreddot at ftml.net bigreddot at ftml.net
Mon Nov 23 13:29:00 EST 2009


FWIW I had a similar problem with QVTKWidget not updating, even when I 
explicitly called with methods that supposedly should have caused updates. The 
only thing I finally got to work was:

     render_window_->GetInteractor( )->Render( );

Not sure why that works or why going through the interactor would make the 
difference.

HTH

Garrett Larson wrote:
> 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.
> 
> 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.
> 
> -Garrett Larson
> 
> 
> On Mon, Nov 23, 2009 at 8:53 AM, André Prins <a.h.prins at gmail.com 
> <mailto:a.h.prins at gmail.com>> wrote:
> 
>     You could try calling QVTKWidget::update(), which is Qt's method of
>     repainting the widget.
>     See for example: http://doc.trolltech.com/4.5/qwidget.html#update.
> 
>     Regards,
>     André
> 
>     On Mon, Nov 23, 2009 at 2:04 PM, Garrett Larson <garrett at unc.edu
>     <mailto:garrett at unc.edu>> wrote:
>      > 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
>      > _______________________________________________
>      > Powered by www.kitware.com <http://www.kitware.com>
>      >
>      > Visit other Kitware open-source projects at
>      > http://www.kitware.com/opensource/opensource.html
>      >
>      > Please keep messages on-topic and check the VTK FAQ at:
>      > http://www.vtk.org/Wiki/VTK_FAQ
>      >
>      > Follow this link to subscribe/unsubscribe:
>      > http://www.vtk.org/mailman/listinfo/vtkusers
>      >
>      >
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list