标签:class date() window 实例化 ref 处理程序 win 释放 专用
目录
在CXxxView.h中添加以下面代码引用相关头文件:
#include <vtkRenderer.h>
#include <vtkMFCWindow.h>
#include <vtkWin32OpenGLRenderWindow.h>
在类CXxxView中定义两个需要用到的成员变量:
private:
//显示的变量,vtkrender和vtkMFCWindow
vtkRenderer *pvtkRenderer;
vtkMFCWindow *pvtkMFCWindow;
CXxxView::CXxxView()
{
// TODO: 在此处添加构造代码
//实例化视图对象
this->pvtkRenderer = vtkRenderer::New();
}
void CXxxView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: 在此添加专用代码和/或调用基类
//初始化的时候创建vtkMFCwindow对象
if (this->pvtkMFCWindow) delete this->pvtkMFCWindow;
this->pvtkMFCWindow = new vtkMFCWindow(this);
//将render对象添加到实现窗口vtkMFCwindow中
this->pvtkMFCWindow->GetRenderWindow()->AddRenderer(this->pvtkRenderer);
}
void CXxxView::OnDraw(CDC* pDC)
{
CVtkMFCDoc* pDoc = GetDocument();
// TODO: 在此处为本机数据添加绘制代码
if (this->pvtkMFCWindow)
{
if (pDC->IsPrinting())
this->pvtkMFCWindow->DrawDC(pDC);
}
}
void CXxxView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
if (this->pvtkMFCWindow)
this->pvtkMFCWindow->MoveWindow(0, 0, cx, cy);
}
void CXxxView::OnDestroy()
{
CView::OnDestroy();
// TODO: 在此处添加消息处理程序代码
if (this->pvtkRenderer) this->pvtkRenderer->Delete();
}
CXxxView::~CVtkMFCView()
{
if (this->pvtkMFCWindow) delete this->pvtkMFCWindow;
}
标签:class date() window 实例化 ref 处理程序 win 释放 专用
原文地址:https://www.cnblogs.com/dilex/p/9322642.html