[vtkusers] vtkWin32RenderWindowInteractor does not interacts inside a .NET component pictureBox
Chasan KIOUTSOUKMOUSTAFA
chasank at gmail.com
Tue Apr 19 18:05:07 EDT 2011
I have a Microsoft Visual C++ project, trying to relate with my native C++
code with .NET components.
I'm binding a vtkWin32OpenGLRenderWindow object with PictureBox object, it
works. However there is no interaction with
rendered image inside PictureBox. It stands still. What's the point I'm
missing ? Thanks for replies.
Code is below;
Form.h
--------------------------------------------------------------------------------------------------------------------------------------------
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
std::string path = "C:\\Dicom\\skull";
Dicom *dicom = new Dicom();
dicom->VolumeRender(this->pictureBox1, path.c_str());
}
---------------------------------------------------------------------------------------------------------------------------------------------
Dicom.cpp
---------------------------------------------------------------------------------------------------------------------------------------------
void Dicom::VolumeRender( Windows::Forms::PictureBox ^pictureBox,
std::string FolderPath )
{
vtkSmartPointer < vtkRenderer> renderer = vtkSmartPointer < vtkRenderer
> :: New();
vtkSmartPointer < vtkWin32OpenGLRenderWindow > renderWindow =
vtkSmartPointer < vtkWin32OpenGLRenderWindow > :: New();
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowId((HWND)((pictureBox->Handle).ToPointer()));
renderWindow->Initialize();
vtkSmartPointer < vtkWin32RenderWindowInteractor > iren =
vtkSmartPointer < vtkWin32RenderWindowInteractor > :: New();
iren->SetRenderWindow(renderWindow);
vtkSmartPointer < vtkDICOMImageReader> reader = vtkSmartPointer <
vtkDICOMImageReader >::New();
reader->SetDirectoryName(FolderPath.c_str());
reader->Update();
volumeMapper = vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
volumeMapper->SetInputConnection(reader->GetOutputPort());
volumeMapper->SetBlendModeToComposite();
volumeColor = vtkSmartPointer<vtkColorTransferFunction>::New();
volumeColor->AddRGBPoint(0, 0.0, 0.0, 0.0);
volumeColor->AddRGBPoint(500, 1.0, 0.5, 0.3);
volumeColor->AddRGBPoint(1000, 1.0, 0.5, 0.3);
volumeColor->AddRGBPoint(1150, 1.0, 1.0, 0.9);
volumeScalarOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
volumeScalarOpacity->AddPoint(0, 0.00);
volumeScalarOpacity->AddPoint(500, 0.15);
volumeScalarOpacity->AddPoint(1000, 0.15);
volumeScalarOpacity->AddPoint(1150, 0.90);
volumeGradientOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
volumeGradientOpacity->AddPoint(0, 0.0);
volumeGradientOpacity->AddPoint(90, 0.5);
volumeGradientOpacity->AddPoint(100, 1.0);
volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
volumeProperty->SetColor(volumeColor);
volumeProperty->SetScalarOpacity(volumeScalarOpacity);
volumeProperty->SetGradientOpacity(volumeGradientOpacity);
volumeProperty->SetInterpolationTypeToLinear();
volumeProperty->ShadeOff();
volumeProperty->SetAmbient(0.4);
volumeProperty->SetDiffuse(0.6);
volumeProperty->SetSpecular(0.2);
LODProperty = vtkSmartPointer <vtkLODProp3D>::New();
int id = LODProperty->AddLOD(volumeMapper, volumeProperty, 0.0);
LODProperty->SetLODLevel(id, 0.0);
renderer->AddViewProp(LODProperty);
renderer->ResetCamera();
renderer->Render();
renderWindow->Render();
iren->Initialize();
iren->Start();
}
-------------------------------------------------------------------------------------------------------------------------------------------
--
Chasan KIOUTSOUKMOUSTAFA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110420/51614107/attachment.htm>
More information about the vtkusers
mailing list