[vtkusers] Updating a windows form component with its handle outside of main UI thread
chasank
chasank at gmail.com
Tue May 17 15:25:53 EDT 2011
I'm sending the Handle of a PictureBox component to my VolumeRender method,
VolumeRender method binds the PictureBox component with
vtkWin32OpenGLRenderWindow , processes the pipeline and update the
renderWindow. Okay, this process is done outside of UI thread as I wanted,
but the problem is, as soon as volume rendering thread is out of scope, UI
thread I don't know why but it frees the pictureBox component. Here are the
codes;
private: System::Void volumeRenderButton_Click(System::Object^ sender,
System::EventArgs^ e)
{
volumeRenderThread = gcnew System::Threading::Thread(
gcnew System::Threading::ThreadStart(this, &Form1::volumeRender));
volumeRenderThread->Start(threeDPictureBox->Handle);
}
private: void volumeRender( System::Object ^obj )
{
IntPtr ^ptr = (IntPtr ^) obj;
dicom->VolumeRender((HWND)(ptr->ToPointer()), vrSettings);
}
void Dicom::VolumeRender(HWND pictureBoxHandle, VRsettings *settings )
{
renderer = vtkSmartPointer < vtkRenderer > :: New();
renderWindow = vtkSmartPointer < vtkWin32OpenGLRenderWindow > :: New();
renderWindow->AddRenderer(renderer);
renderWindow->SetParentId(pictureBoxHandle);
renderWindow->SetSize(settings->width, settings->height);
renderWindow->Initialize();
iren = vtkSmartPointer < vtkWin32RenderWindowInteractor > :: New();
iren->SetRenderWindow(renderWindow);
/* Volume Render Pipeline
...
...
*/
renderWindow->Render();
iren->Initialize();
}
When debugging the code, after the execution renderWindow->Render()
statement, in the main form, rendered image is seen on pictureBox Component,
but after the volumeRender thread is out of scope, threeDPictureBox is
somehow freed. I've asked same question on
http://stackoverflow.com/questions/6035141/updating-a-windows-form-component-with-its-handle-outside-of-main-ui-thread
stackoverflow I'm not sure if it is VTK related or .NET related. Anyone can
help me? Thanks
--
View this message in context: http://vtk.1045678.n5.nabble.com/Updating-a-windows-form-component-with-its-handle-outside-of-main-UI-thread-tp4404517p4404517.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list