[vtkusers] Playing a sequence of images

Beau Sapach beau.sapach at ualberta.ca
Fri Oct 29 12:05:27 EDT 2004


I've done the exact same thing, and even tried multithreading as you have.
In the end I used a timer, so that my "Play" function is:

void MyAppDlg::OnbtnPlay() 
{
	UINT t = this->SetTimer(1,40,NULL);
}

1 being the timer's ID and 40 milliseconds being the interval, setting the
timer function to NULL means it will run the function pointed to by your
WM_TIMER message.  So in class wizard you want to select your MyAppDlg
objectid, then choose it's WM_TIMER message and Add or Edit the function
associated with it, this function should move to the next image "frame" and
re-render every time it is called, mine looks like this:

void MyAppDlg::OnTimer(UINT nIDEvent) 
{
	// Imagedata uses vtkFloatArray ifloat as it's scalar values, change
the 
	// actual float array that ifloat points to by grabbing and casting
the
	// next pointer from the CPtrArray frames
	this->ifloat->SetArray((float*)frames->GetAt(frame),40960,1);
	RenWindow->Render();
	frame++;
	// Loop indefinitely through 35 frames
	if(frame==35){frame = 0;}
	CDialog::OnTimer(nIDEvent);
}

 The KillTimer(timerid) function should be used in your "Stop" button.

Everything still runs on the main thread but the UI should remain
responsive....

Beau

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf
Of Markus Erbacher
Sent: Friday, October 29, 2004 4:27 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Playing a sequence of images

Hi,
I am trying to play an sequence of images. I have all those images as slices
in an vtkImageData. If I play the sequence from the mainthread, the whole
application is frozen till the sequence ends. So I tried to play it in a
different thread. If I do so, I always recieve that Error:

ERROR: In \Programme\Vtk\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 228
vtkWin32OpenGLRenderWindow (06A6D028): wglMakeCurrent failed in
MakeCurrent(), error: Die angeforderte Ressource wird bereits verwendet.

Although that error occurs, the changes in the scene are made. But they are
not rendered.

How can I get the Renderer to rerender the scene? Is there a way without
using Render() (because of the error)?
Or even better: Is their in VTK a possibility to play sequences a other way?

Thanks in advance

Regards
Markus

-- 
NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
GMX DSL-Netzanschluss + Tarif zum superg|nstigen Komplett-Preis!

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list