[vtkusers] Which fanction shoud I use to clean out the display?

laohubinbin at sohu.com laohubinbin at sohu.com
Sun Jun 19 04:55:53 EDT 2005


Hello all,<p><p>I have a trouble in the display of a model now.<p>The environment is MS Visual C++ 6.0.<p>And it is a MFC project(Doc-View).<p>The key codes are:<p><p>In the Doc:<p><p>	vtkRenderer *ren;<p>	vtkWin32OpenGLRenderWindow *renWin;<p>	vtkWin32RenderWindowInteractor *renWinInter;<p>	vtkCubeSource *cube;<p>	vtkPolyDataMapper *cubeMapper, *AxesMapper;<p>	vtkActor *cubeActor,*myAxesActor;<p>	vtkCubeAxesActor2D *axesActor;<p>	vtkAxes *myAxes;<p>	vtkCamera *myCamera;<p>	vtkLight *myLight1, *myLight2;<p>	BOOL m_bIsThreeDimension;<p><p>  then:<p><p>	m_bIsThreeDimension=TRUE;<p><p>	this->ren=vtkRenderer::New();<p>	this->renWin=vtkWin32OpenGLRenderWindow::New();<p>	this->renWinInter=vtkWin32RenderWindowInteractor::New();<p>	this->cube=vtkCubeSource::New();<p>	this->cubeActor=vtkActor::New();<p>	this->cubeMapper=vtkPolyDataMapper::New();<p>	this->axesActor=vtkCubeAxesActor2D::New();<p>	<p>	this->myAxes=vtkAxes::New();<p>	this->AxesMapper=vtkPolyDataMapper::New();<p>	this->myAxesActor=vtkActor::New();<p>	<p>	this->myCamera=vtkCamera::New();<p>	<p>	this->myLight1=vtkLight::New();<p>	this->myLight2=vtkLight::New();<p>	this->renWin->AddRenderer(this->ren);<p>	this->renWinInter->SetRenderWindow(this->renWin);<p>	this->cubeMapper->SetInput(this->cube->GetOutput());<p>	this->cubeActor->SetMapper(this->cubeMapper);<p>	this->cubeActor->GetProperty()->SetColor(0.9804,0.5020,0.4471);<p>	this->cubeActor->SetPosition(/*0.475,0.475,0.475*//*1,1,1*/0,0,0);<p>	this->ren->AddActor(this->cubeActor);<p>	this->AxesMapper->SetInput(this->myAxes->GetOutput());<p>	this->myAxesActor->SetMapper(this->AxesMapper);<p>	this->myAxesActor->GetProperty()->SetColor(1,0,0);<p>	this->myAxesActor->SetPosition(0,0,0);<p>	this->ren->AddActor(this->myAxesActor);<p>	<p>	this->myLight1->SetColor(1,1,1);<p>	this->myLight1->SetFocalPoint(0,0,0);<p>	this->myLight1->SetPosition(10,15,20);<p>	this->ren->AddLight(this->myLight1);<p>	this->myLight2->SetColor(1,1,1);<p>	this->myLight2->SetFocalPoint(0,0,0);<p>	this->myLight2->SetPosition(-10,-15,-20);<p>	this->ren->AddLight(this->myLight2);<p>	<p>	this->myCamera->SetViewUp(0,0,1);<p>	this->myCamera->SetFocalPoint(0,0,0);<p>	this->myCamera->SetPosition(10,15,10);<p>	this->ren->SetActiveCamera(this->myCamera);<p><p>View::OnCreate(LPCREATESTRUCT lpCreateStruct)<p>{<p>	this->GetDocument()->renWin->SetParentId(this->m_hWnd);<p>	this->GetDocument()->myCamera->SetViewUp(0,0,1);<p>	this->GetDocument()->myCamera->SetFocalPoint(0,0,0);<p>	this->GetDocument()->myCamera->SetPosition(10,15,10);<p>	this->GetDocument()->ren->SetActiveCamera(this->GetDocument()->myCamera);<p><p>	return 0;<p>}<p><p>View::OnDraw(CDC* pDC)<p>{<p>	if (this->GetDocument()->m_bIsThreeDimension)<p>	{	<p>		CRect rect;<p>		this->GetClientRect(&rect);<p>		this->GetDocument()->renWinInter->Initialize();<p>		this->GetDocument()->renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);<p>		this->GetDocument()->ren->ResetCamera();<p>		this->GetDocument()->renWin->Render();<p>	}<p>}<p><p>But after calling a function in the Doc to make  "m_bIsThreeDimension=FALSE" and "UpdateAllViews(NULL)", the model is still displaying and inter-actable.<p>My question is why the model is still displaying after leaping over the codes:<p>"<p>		CRect rect;<p>		this->GetClientRect(&rect);<p>		this->GetDocument()->renWinInter->Initialize();//绘制的重要函数<p>		this->GetDocument()->renWin->SetSize(rect.right-rect.left,rect.bottom-rect.top);<p>		this->GetDocument()->ren->ResetCamera();<p>		this->GetDocument()->renWin->Render();<p>"?<p>How can I make the model not display in the view under the condition of not deleting any object defined.<p><p><p>Thanks and regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050619/9e2bb7f7/attachment.htm>


More information about the vtkusers mailing list