• 大小: 4.03MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-15
  • 语言: C/C++
  • 标签: MFC  绘图  

资源简介

一个基于MFC的画图程序,可以画直线,圆,矩形,多边形等。

资源截图

代码片段和文件信息

// Circle.cpp: implementation of the CCircle class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “Testwork.h“
#include “Circle.h“
#include “Math.h“

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCircle::CCircle()
{}

CCircle::CCircle(CPoint m_begain_ptCPoint m_final_pt)
{
this->m_begain_pt=m_begain_pt;
this->m_final_pt=m_final_pt;
this->m_IsSelected=false;
this->m_IsDelete=false;
m_radius=CMathOp::Dist((float)m_begain_pt.x(float)m_begain_pt.y(float)m_final_pt.x(float)m_final_pt.y);
}

CCircle::~CCircle()
{}

void CCircle::DrawGraph(CPoint ACPoint BCPen &dpen)
{
m_dc->SelectStockobject(NULL_BRUSH);
m_dc->Selectobject(dpen);
float radius=CMathOp::Dist((float)A.x(float)A.y(float)B.x(float)B.y);
m_dc->Ellipse(A.x-(int)radiusA.y-(int)radiusA.x+(int)radiusA.y+(int)radius);
}

void CCircle::DrawPoint()
{
m_dc->Ellipse(tmp_lt_pt.x-2tmp_lt_pt.y-2tmp_lt_pt.x+2tmp_lt_pt.y+2);
m_dc->Ellipse(tmp_lb_pt.x-2tmp_lb_pt.y-2tmp_lb_pt.x+2tmp_lb_pt.y+2);
m_dc->Ellipse(tmp_rt_pt.x-2tmp_rt_pt.y-2tmp_rt_pt.x+2tmp_rt_pt.y+2);
m_dc->Ellipse(tmp_rb_pt.x-2tmp_rb_pt.y-2tmp_rb_pt.x+2tmp_rb_pt.y+2);
}

void CCircle::DrawGraph()
{
if(m_IsSelected==true)
CCircle::DrawPoint();
if(m_IsDelete==false)
{
m_dc->Selectobject(m_IsSelected==true?select_pen:draw_pen);
m_dc->SelectStockobject(NULL_BRUSH);
m_dc->Ellipse(m_begain_pt.x-(int)m_radiusm_begain_pt.y-(int)m_radiusm_begain_pt.x+(int)m_radiusm_begain_pt.y+(int)m_radius);
}
}

void CCircle::EraseGraph()
{
m_dc->Selectobject(erase_pen);
m_dc->SelectStockobject(NULL_BRUSH);
CCircle::DrawPoint();
m_dc->Ellipse(m_begain_pt.x-(int)m_radiusm_begain_pt.y-(int)m_radiusm_begain_pt.x+(int)m_radiusm_begain_pt.y+(int)m_radius);
}

void CCircle::Offset(int dxint dy)
{
m_begain_pt.x += dx;
m_begain_pt.y += dy;
m_final_pt.x += dx;
m_final_pt.y += dy;
CCircle::InitBox();
}

void CCircle::DrawPixel(CPoint ACPen &dpen)
{
m_dc->Selectobject(dpen);
m_dc->Ellipse(A.x-2A.y-2A.x+2A.y+2);
}

void CCircle::InitBox()
{
this->m_left=m_begain_pt.x-(int)m_radius;
this->m_right=m_begain_pt.x+(int)m_radius;
this->m_top=m_begain_pt.y-(int)m_radius;
this->m_bottom=m_begain_pt.y+(int)m_radius;
tmp_lt_pt.x=m_left;tmp_lt_pt.y=m_top;
tmp_lb_pt.x=m_left;tmp_lb_pt.y=m_bottom;
tmp_rt_pt.x=m_right;tmp_rt_pt.y=m_top;
tmp_rb_pt.x=m_right;tmp_rb_pt.y=m_bottom;
}

int CCircle::IsInBox(CPoint tmp_pt)
{
int dis=(int)CMathOp::Dist((float)tmp_pt.x(float)tmp_pt.y(float)m_begain_pt.x(float)m_begain_pt.y);
if(dis<=8)
return 2;
else if(dis<=m_radius+10 && dis>=m_radius-10)
return 1;
else 
return 0

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3692  2012-08-15 10:53  Testwork\Circle.cpp

     文件       1040  2012-08-15 10:52  Testwork\Circle.h

     文件       1157  2012-08-11 16:10  Testwork\Command.cpp

     文件        920  2012-08-23 11:02  Testwork\Command.h

     文件       1602  2012-08-23 11:02  Testwork\CommandCircle.cpp

     文件        839  2012-08-10 16:05  Testwork\CommandCircle.h

     文件       1255  2012-08-24 10:02  Testwork\Commandcurve.cpp

     文件        780  2012-08-10 16:05  Testwork\Commandcurve.h

     文件       1621  2012-09-03 12:50  Testwork\CommandLine.cpp

     文件        777  2012-08-10 16:05  Testwork\CommandLine.h

     文件       1613  2012-08-23 11:02  Testwork\CommandRectangle.cpp

     文件        822  2012-08-13 10:30  Testwork\CommandRectangle.h

     文件        603  2012-08-30 10:25  Testwork\Compass.cpp

     文件        544  2012-08-30 10:23  Testwork\Compass.h

     文件        789  2012-08-31 17:39  Testwork\Compass1.cpp

     文件        721  2012-08-31 09:46  Testwork\Compass1.h

     文件        798  2012-08-11 11:07  Testwork\Curve.cpp

     文件        668  2012-08-11 11:05  Testwork\Curve.h

     文件      22314  2012-09-05 09:18  Testwork\Debug\BmpButton.obj

     文件          0  2012-09-05 09:18  Testwork\Debug\BmpButton.sbr

     文件      18191  2012-09-03 11:20  Testwork\Debug\Circle.obj

     文件          0  2012-09-03 11:20  Testwork\Debug\Circle.sbr

     文件      10016  2012-09-03 11:20  Testwork\Debug\Command.obj

     文件          0  2012-09-03 11:20  Testwork\Debug\Command.sbr

     文件       8868  2012-09-03 11:20  Testwork\Debug\CommandCircle.obj

     文件          0  2012-09-03 11:20  Testwork\Debug\CommandCircle.sbr

     文件       8654  2012-09-03 11:20  Testwork\Debug\Commandcurve.obj

     文件          0  2012-09-03 11:20  Testwork\Debug\Commandcurve.sbr

     文件       7908  2012-09-05 09:18  Testwork\Debug\CommandLine.obj

     文件          0  2012-09-05 09:18  Testwork\Debug\CommandLine.sbr

............此处省略101个文件信息

评论

共有 条评论