[vtkusers] How to update the renderer when the data is modified?
Glen Lehmann
glehmann at atamai.com
Fri Nov 3 09:34:56 EST 2006
Hi Ali,
Yes, I had a brief look at the code ...
The vtkImageData is modified but not updated. Modified() will change
vtkImageImport's MTime and Update will execute code inside the filter
that does the work. MTime is used to keep track of whether or not the
filter needs to be updated. So, regardless of VTK version, the
following is true:
// Nothing happens
vtkImageData->Modified();
vtkRenderer->Render();
// Something happens
vtkImageData->Modified();
vtkImageData->Update();
vtkRenderer->Render();
If you're using VTK 5, you should read over the new pipeline
mechanism; however, the above code will also work in VTK 4.
HTH,
Glen
On 03/11/06, Ali - <saveez at hotmail.com> wrote:
> Glen,
>
> Have you had a look at the code? When vtkImageData is modified, it calls
> Render() to update the view and that generates the opengl error. Where does
> vtkImageData.Update() fit in this design? By 'automatically updated' I mean
> event-based.
>
>
>
> >
> >Hi Ali,
> >
> >Yes, in 10 years VTK has done a great job of figuring this one out.
> >Do some browsing through the Wiki or grab one of the VTK books to
> >learn a bit more about the VTK pipeline.
> >
> >In short, VTK is demand-driven. You need to call Update() on your
> >vtkImageData after it is modified, this will update the pipeline.
> >
> >HTH,
> >
> >Glen
> >
> >On 02/11/06, Ali - <saveez at hotmail.com> wrote:
> >>Hi,
> >>
> >>First of all, I think this should have been already implemented in VTK,
> >>the
> >>library is 10 years old! When some data is modified in the pipeline, the
> >>renderer does not get updated automatically.
> >>
> >>Trying the following ends up with the error: wglMakeCurrent failed in
> >>MakeCurrent(). What would the right way of implementing this? All I am
> >>doing
> >>is displaying an image with vtkImageViewer2, and all I want is the
> >>renderer
> >>to get updated automatically when the image data is modified.
> >>
> >>static void UpdateRenderer(vtkObject *vtkNotUsed( caller ),
> >> unsigned long vtkNotUsed(eventId),
> >> void *obj, void *)
> >>{
> >> vtkImageViewer2* vw = reinterpret_cast<vtkImageViewer2*>(obj);
> >> vw->Render();
> >>}
> >>
> >>main()
> >>{
> >> vtkImageImport im = vtkImageImport::New();
> >> // ...
> >> vtkImageViewer2 *viewer = vtkImageViewer2::New();
> >> // ...
> >> vtkCallbackCommand *cbc = vtkCallbackCommand::New();
> >> cbc->SetCallback(UpdateRenderer);
> >> cbc->SetClientData((void *)viewer);
> >> im->AddObserver(vtkCommand::RenderEvent, cbc);
> >> cbc->Delete();
> >> // ...
> >>}
> >>
>
> _________________________________________________________________
> Be the first to hear what's new at MSN - sign up to our free newsletters!
> http://www.msn.co.uk/newsletters
>
>
More information about the vtkusers
mailing list