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