⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 123view.cpp

📁 很好的vtk书籍
💻 CPP
字号:
// 123View.cpp : implementation of the CMy123View class
//

#include "stdafx.h"
#include "123.h"

#include "123Doc.h"
#include "123View.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMy123View

IMPLEMENT_DYNCREATE(CMy123View, CView)

BEGIN_MESSAGE_MAP(CMy123View, CView)
	//{{AFX_MSG_MAP(CMy123View)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	ON_WM_ERASEBKGND()
	ON_WM_SIZE()
	ON_WM_LBUTTONDBLCLK()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy123View construction/destruction

CMy123View::CMy123View()
{
	this->pvtkMFCWindow     = NULL;
	
	// Create the the renderer, window and interactor objects.
	this->pvtkRenderer    = vtkRenderer::New();
}

CMy123View::~CMy123View()
{
	// delete generic vtk window
	if (this->pvtkMFCWindow) delete this->pvtkMFCWindow;
}

BOOL CMy123View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMy123View drawing

void CMy123View::OnDraw(CDC* pDC)
{
	CMy123Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	if (this->pvtkMFCWindow)
	{
		if (pDC->IsPrinting())
			this->pvtkMFCWindow->DrawDC(pDC);
	}
}

/////////////////////////////////////////////////////////////////////////////
// CMy123View printing

BOOL CMy123View::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMy123View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMy123View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMy123View diagnostics

#ifdef _DEBUG
void CMy123View::AssertValid() const
{
	CView::AssertValid();
}

void CMy123View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMy123Doc* CMy123View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy123Doc)));
	return (CMy123Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMy123View message handlers

int CMy123View::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	
	return 0;
}

void CMy123View::OnDestroy() 
{
	// Delete the the renderer, window and interactor objects.
	if (this->pvtkRenderer)      this->pvtkRenderer->Delete();
	
	// destroy base
	CView::OnDestroy();	
}

BOOL CMy123View::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	
	return TRUE;
}
void CMy123View::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	if (this->pvtkMFCWindow)
		this->pvtkMFCWindow->MoveWindow(0, 0, cx, cy);
}

void CMy123View::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	AfxMessageBox("You made a double click");

	CView::OnLButtonDblClk(nFlags, point);
}

void CMy123View::OnInitialUpdate() 
{
	CView::OnInitialUpdate();
	
	if (this->pvtkMFCWindow) delete this->pvtkMFCWindow;
	this->pvtkMFCWindow = new vtkMFCWindow(this);
	
	this->pvtkMFCWindow->GetRenderWindow()->AddRenderer(this->pvtkRenderer);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -