[vtkusers] threads and refreshing vtkRenderWindow
Giancarlo Amati
ilferraresebono at hotmail.it
Mon May 18 18:16:55 EDT 2009
Many thanks!!!
This morning I've actually found the solution using QT....just emitting timer events builting up a QTimer with QT and connecting my main thread to capture those events. In that case I'll call the Render() function staying in the main one....
Many thanks
GC.
> Date: Mon, 18 May 2009 08:52:20 -0600
> From: clinton at elemtech.com
> To: ilferraresebono at hotmail.it
> CC: david.cole at kitware.com; vtkusers at vtk.org
> Subject: Re: [vtkusers] threads and refreshing vtkRenderWindow
>
>
> Have you look at this?
> http://doc.trolltech.com/qq/qq06-glimpsing.html
> It would need adjustments if using VTK instead, and I'm curious if it'll
> work just fine.
>
> But, first, you could try overloading QVTKWidget::paintEvent() to do
> nothing.
> Then in your QThread::run, you create all your VTK objects and do your
> Render() calls from there.
> You're getting the wglMakeCurrent error because the context is current
> in the main thread, and you're trying to make it current in another
> thread as well. That is not allowed.
> http://msdn.microsoft.com/en-us/library/dd374387(VS.85).aspx
>
> Clint
>
> Giancarlo Amati wrote:
> > Nope I don't,....I was just telling you how I did organize my
> > code...and as you said the Render() function should be called only
> > from the thread that the MAIN one, I was simply asking..if calling a
> > function which belongs to the main thread (which is the Parent from
> > the 2nd one) is the reason that generates the wglMakeCurrent error.
> > Moreover, as the documentation about the vtkMutexLock class on the vtk
> > website is quite poor, I was just wondering if there were any other
> > resource.
> >
> > My project is mainly about a device system which tracks IReds
> > visulalized with VTK, basically what I am doing is a real-time
> > animation with QT and VTK. So, as I need to update the VTK scene
> > without interfering with the QT events, the QT users group told me
> > that the best way is to create a thread which updates the scene. But
> > apparently this generates a wglMakeCurrent error for the reasons you
> > told me.
> >
> >
> > GC.
> >
> > ------------------------------------------------------------------------
> > Date: Fri, 15 May 2009 11:08:20 -0400
> > Subject: Re: [vtkusers] threads and refreshing vtkRenderWindow
> > From: david.cole at kitware.com
> > To: ilferraresebono at hotmail.it
> > CC: vtkusers at vtk.org
> >
> > Are you asking us to tell you how your program is organized with
> > respect to threads? (That's somewhat beyond the scope of the VTK
> > mailing list.)
> >
> > It sounds like your project might be better off single-threaded.
> >
> > It would be better if you call UpdateMy3DObject from the same thread
> > that actually does the rendering.
> >
> >
> > On Fri, May 15, 2009 at 10:59 AM, Giancarlo Amati
> > <ilferraresebono at hotmail.it <mailto:ilferraresebono at hotmail.it>> wrote:
> >
> > Many thanks,
> >
> > what I have is a mainWindow which has functions for rendering and
> > then a thread that calls a kind of "UpdateMy3Dobjects" function
> > which belongs to the mainWindow object. Now,
> > this "UpdateMy3DObjects" function works fine whenever that thread
> > is not running while, I got the wglMakeCurrent error as soon as
> > the thread runs the UpdateMy3Dobjects" function.
> > So,
> > as the UpdateMy3Dobjects function calls the RenderWindow->Render()
> > method (renderwindow buidt in a QVTKWidget object of my GUI)
> > calling that UpdateMy3DObject from the thread does correspond to a
> > call form a thread different from the main one?
> > In that case if I create a global variable, boolean for example
> > which is true when I execute the UpdateMy3DObject function and
> > false otherwise...would it help to synchronize these threads?
> >
> > I checked out on the VTK documentation and I found the
> > vktMutexLock class....and i tried to understand the example in the
> > documetation which is a bit difficult honestly, but,....can that
> > class be useful for my project?
> >
> > many kind regards.
> > Giancarlo
> >
> > ------------------------------------------------------------------------
> > Date: Fri, 15 May 2009 10:19:51 -0400
> > Subject: Re: [vtkusers] threads and refreshing vtkRenderWindow
> > From: david.cole at kitware.com <mailto:david.cole at kitware.com>
> > To: ilferraresebono at hotmail.it <mailto:ilferraresebono at hotmail.it>
> > CC: vtkusers at vtk.org <mailto:vtkusers at vtk.org>
> >
> >
> > I will not claim to be cleverer, but I think I can answer the
> > question:
> >
> > Your mistake is calling vtkObjects from multiple threads without
> > synchonization objects. In general, vtkObjects are only safely
> > accessible by one thread at a time. Multi-thread access means you
> > will have to use some sort of mutexes or locks to guarantee that
> > only one thread at a time will call vtkObject methods.
> > Furthermore, you should only attempt to call Render from the main
> > GUI thread of your application.
> >
> >
> > Hope this helps,
> > David
> >
> >
> > On Fri, May 15, 2009 at 9:25 AM, Giancarlo Amati
> > <ilferraresebono at hotmail.it <mailto:ilferraresebono at hotmail.it>>
> > wrote:
> >
> > Hello vtkUSERS!!! This is an ash question for only the
> > cleverer!! :D
> >
> > I have a thread which modifies some data already in the
> > vtkRenderWindow., now, the problem I have is when I want to
> > refresh the window.
> > I though calling something like renderWindow->Render() or
> > renderer->render(), but I get some error messages related to
> > "Resource already in use" and "wglMakeCurrent()" function error.
> >
> > Where is my mistake and any idea about how to overcome it?
> >
> > Kind regards.
> >
> > GC.
> >
> > ------------------------------------------------------------------------
> > Scrivi, parla e gioca con i tuoi amici! Scarica Messenger
> > 2009! <http://messenger.it/gioca.aspx>
> >
> > _______________________________________________
> > 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
> >
> >
> >
> > ------------------------------------------------------------------------
> > Quali sono le parole più cliccate? Scopri la top!
> > <http://livesearch.it.msn.com/>
> >
> >
> >
> > ------------------------------------------------------------------------
> > Quali sono le parole più cliccate? Scopri la top!
> > <http://livesearch.it.msn.com/>
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
> >
>
>
_________________________________________________________________
Cerca le Parole, gioca su Typectionary!
http://typectionary.it.msn.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090519/e19d089d/attachment.htm>
More information about the vtkusers
mailing list