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

📄 lineview.cpp

📁 visual c++数字图像与图形处理中的光盘内容
💻 CPP
字号:
// LineView.cpp : implementation of the CLineView class
//

#include "stdafx.h"
#include "Line.h"

#include "LineDoc.h"
#include "LineView.h"

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

#include "PLine.h"

/////////////////////////////////////////////////////////////////////////////
// CLineView

IMPLEMENT_DYNCREATE(CLineView,  CView)

BEGIN_MESSAGE_MAP(CLineView,  CView)
	//{{AFX_MSG_MAP(CLineView)
		// 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
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLineView construction/destruction

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

}

CLineView::~CLineView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CLineView drawing

void CLineView::OnDraw(CDC* pDC)
{

	//下面将用CPLine绘制直线, 代码十分简单.
	//直线基元
	CPLine pl;

	//采用CPoint对象
	CPoint pt1, pt2;

	//利用Windows函数
	pt1.x = 20;		pt1.y = 20;
	pt2.x = 200;	pt2.y = 20;
	pl.Draw(pDC, pt1, pt2, CPen(PS_DASHDOTDOT, 1, RGB(255, 0, 0)));

	//利用Windows函数
	pt1.y = 30;		pt2.y = 30;
	pl.Draw(pDC, pt1, pt2, CPen(PS_DOT, 1, RGB(255, 0, 0)));
	
	//采用POINT结构
	POINT pt3, pt4;
	pt3.x = 20;		pt3.y = 50;
	pt4.x = 200;	pt4.y = 50;
	FLOATCOLORRGB clr3 = {0.0f, 0.0f, 0.0f};
	FLOATCOLORRGB clr4 = {1.0f, 0.0f, 0.0f};
	pl.Draw(pDC, pt3, pt4, clr3, clr4);

	//采用Brsenham算法(颜色渐变)
	pt3.x = 20;		pt3.y = 70;
	pt4.x = 200;	pt4.y = 140;
	pl.Draw(pDC, pt3, pt4, clr3, clr4);

	//采用Brsenham算法(红色)
	pt3.x = 200;	pt3.y = 70;
	pt4.x = 20;		pt4.y = 140;
	pl.Draw(pDC, pt3, pt4, RGB(255, 0, 0));
	
	//采用Brsenham算法(颜色渐变)
	pt3.x = 210;	pt3.y = 20;
	pt4.x = 210;	pt4.y = 140;
	pl.Draw(pDC, pt3, pt4, clr3, clr4);

	//采用Brsenham算法(颜色渐变)
	pt3.x = 220;	pt3.y = 140;
	pt4.x = 220;	pt4.y = 20;
	pl.Draw(pDC, pt3, pt4, clr3, clr4);

	//采用Brsenham算法(颜色渐变)
	pt1.x = 20;		pt1.y = 150;
	pt2.x = 220;	pt2.y = 150;
	pl.Draw(pDC, pt1, pt2, clr3, clr4);

}

/////////////////////////////////////////////////////////////////////////////
// CLineView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CLineView message handlers

⌨️ 快捷键说明

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