[vtkusers] Re: VTk and MFC application
Nigel Nunn
nNunn at ausport.gov.au
Mon Oct 23 11:42:47 EDT 2000
Vineet Gupta [vineetseema at hotmail.com] wrote:
> I am creating VTK application using MFC in Visual C++.
> I have created the application that generates the volume
> in VTK window using classes written in MFC application.
> I have a picture window in the MFC application that I want
> the vtk volume to be displayed in. Can someone tell me
> how get the VTK window to display on the Picture Window
> of the MFC Application.
Hi Vineet Gupta,
Many of us MFC users begin with the Vtk/MFC example called
"Sample" that you can get with the current nightlies, or
by downloading vtkNightlyCpp.EXE.
This approach is to fill a vtkPropCollection with actors,
then add them to your "picture view" during OnUpdate():
Notice that the vtkPropCollection is held as a member
in the CDocument-derived class:
propc = this->GetDocument()->GetProps();
See: /vtkNightly/Sample/SampleView.cpp
// CPictureView message handlers
// ...
// ...
void CPictureView::OnUpdate(CView*, LPARAM, CObject*)
{
vtkPropCollection *propc;
vtkProp *prop;
// first remove any old actors
this->Renderer->GetProps()->RemoveAllItems();
propc = this->GetDocument()->GetProps();
propc->InitTraversal();
while (prop = propc->GetNextProp())
{
this->Renderer->AddProp(prop);
this->Renderer->ResetCamera();
}
this->vtkMFCRenderView::OnUpdate(pSender, lHint, pHint);
}
If this is confusing, you can familiarise yourself with
the implied Document/View architecture by working through
the Scribble tutorial that comes with Visual C++.
Good luck,
Nigel
More information about the vtkusers
mailing list