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

📄 midpointlineview.cpp

📁 The mid-point algorithm中点算法
💻 CPP
字号:
// MidPointLineView.cpp : implementation of the CMidPointLineView class
//

#include "stdafx.h"
#include "MidPointLine.h"

#include "MidPointLineDoc.h"
#include "MidPointLineView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView

IMPLEMENT_DYNCREATE(CMidPointLineView, CView)

BEGIN_MESSAGE_MAP(CMidPointLineView, CView)
	//{{AFX_MSG_MAP(CMidPointLineView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView construction/destruction

CMidPointLineView::CMidPointLineView()
{
	// TODO: add construction code here

}

CMidPointLineView::~CMidPointLineView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView drawing

void CMidPointLineView::OnDraw(CDC* pDC)
{
	CMidPointLineDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	int x0=100,y0=100,x1=400,y1=200;
	int dx,dy,incrE,incrNE,d,x,y;
	dx=x1-x0;
	dy=y1-y0;
	d=dx-2*dy;
	incrE=-2*dy;
	incrNE=2*(dx-dy);
	x=x0,y=y0;
	pDC->SetPixel(x,y,RGB(255,0,0));
	while (x<x1)
	{
		if (d>0)
		{
			d+=incrE;
		} 
		else
		{
			d+=incrNE;
				y++;
		}
		x++;
	pDC->SetPixel(x,y,RGB(255,0,0));
	}
}

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMidPointLineView message handlers

⌨️ 快捷键说明

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