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

📄 cantorview.cpp

📁 给定一条初始直线
💻 CPP
字号:
// cantorView.cpp : CcantorView 类的实现
//date:2009.2.20
//copyright:Tan Chao
//name:Cantor三分集

#include "stdafx.h"
#include "cantor.h"

#include "cantorDoc.h"
#include "cantorView.h"
#include ".\cantorview.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CcantorView

IMPLEMENT_DYNCREATE(CcantorView, CView)

BEGIN_MESSAGE_MAP(CcantorView, CView)
	// 标准打印命令
	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()

// CcantorView 构造/析构

CcantorView::CcantorView()
{
	// TODO: 在此处添加构造代码

}

CcantorView::~CcantorView()
{
}

BOOL CcantorView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
	// 样式

	return CView::PreCreateWindow(cs);
}

// CcantorView 绘制

void CcantorView::OnDraw(CDC* /*pDC*/)
{
	CcantorDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 在此处为本机数据添加绘制代码
	AfxGetMainWnd()->SetWindowText("cantor三分集");//设置窗口名称
	cantor(50,100,1050,100);
}


// CcantorView 打印

BOOL CcantorView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CcantorView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印前添加额外的初始化
}

void CcantorView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 打印后添加清除过程
}


// CcantorView 诊断

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

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

CcantorDoc* CcantorView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CcantorDoc)));
	return (CcantorDoc*)m_pDocument;
}
#endif //_DEBUG


// Cantor三分集

void CcantorView::cantor(int ax, int ay, int bx, int by)
{
	CClientDC pDC(this);
	int c = 5;
	if((bx-ax)<c) 
	{
		pDC.MoveTo (ax,ay);
		pDC.LineTo (bx,by);
	}
	else
	{
		int cx,cy,dx,dy;
		pDC.MoveTo (ax,ay);
		pDC.LineTo (bx,by);
		cx = ax + (bx - ax) / 3;
        cy = ay + 50;
        dx = bx - (bx - ax) / 3;
        dy = by + 50;
        ay = ay + 50;
        by = by + 50;

		cantor(ax, ay, cx, cy);
        cantor(dx, dy, bx, by);
	}
}

⌨️ 快捷键说明

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