[vtkusers] Help updating a QVTKWidget
Clinton Stimpson
clinton at elemtech.com
Mon Nov 23 10:11:38 EST 2009
You may ignore the caching stuff in there. Its off by default, and is
only useful to prevent updates when there are no changes.
Whenever you make changes to VTK's data objects it's your job to call
qvtkWidget->update() or viewer->Render() afterward so the new changes
get put onto the screen.
Clint
On 11/23/2009 07:27 AM, 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091123/f741eeae/attachment.htm>
More information about the vtkusers
mailing list