[vtkusers] How to update the renderer when the data is modified?

Ali - saveez at hotmail.com
Fri Nov 3 09:08:47 EST 2006


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