• 大小: 130KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C/C++
  • 标签: MFC  CAD  源代码  

资源简介

画图软件源代码,MFC实现,有图形移动、旋转、选取、删除等功能。

资源截图

代码片段和文件信息

// Context.cpp: implementation of the CContext class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “Context.h“

// 根据绘图模式设置绘图环境:设置设备环境的模式并创建画笔
void SetDrawEnvir(CDC* pDC int drawMode CPen* pPen)
{
int linestyle lineWidth;
COLORREF color;
switch(drawMode) 
{
case dmSelect: // 选中状态
{
pDC->SetROP2(R2_COPYPEN);
linestyle = PS_SOLID;
lineWidth = 1;
color = RGB(25500);
break;
}
case dmPrompt: // 提示状态
{
pDC->SetROP2(R2_COPYPEN);
linestyle = PS_DASH;
lineWidth = 1;
color = RGB(0255255);
break;
}
case dmDrag: // 拖动状态
{
pDC->SetROP2(R2_XORPEN);
linestyle = PS_SOLID;
lineWidth = 1;
color = RGB(1921920);
break;
}
case dmInvalid: // 擦除状态
{
pDC->SetROP2(R2_COPYPEN);
linestyle = PS_SOLID;
lineWidth = 1;
color = ::GetBkColor(*pDC); // 用背景色画
break;
}
case dmNormal:   
default:
{
pDC->SetROP2(R2_COPYPEN);
linestyle = PS_SOLID;
lineWidth = 1;
color = RGB(000);
break;
}
}
pPen->CreatePen(linestylelineWidthcolor) ;
}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*
CContext::CContext()
{

}
*/
CContext::~CContext()
{
g_pView->ReleaseDC(pDC);
}

void CContext::MoveTo(const Position &pt)
{
g_pView->WorldtoScreen(pt ptCurrent); // 将世界坐标转化为屏幕坐标

pDC->SetMapMode(MM_LOENGLISH); 
pDC->MoveTo(ptCurrent); // 移动到ptCurrent
}

void CContext::LineTo(const Position &pt)
{
g_pView->WorldtoScreen(pt ptCurrent); // 将世界坐标转化为屏幕坐标

pDC->SetMapMode(MM_LOENGLISH); 

int n = GetROP2(pDC->GetSafeHdc()); // 得到原来的绘图模式
CPen pen; 
if( drawMode == dmNormal )  // 如果为正常状态的绘制,根据成员变量创建画笔
pen.CreatePen(m_linestylem_lineWidthm_color) ;
else // 非正常状态调用SetDrawEnvir函数设置绘图环境
::SetDrawEnvir(pDC drawMode &pen);

CPen* pOldPen = pDC->Selectobject(&pen); // 得到原来的画笔

pDC->LineTo(ptCurrent);
pDC->Selectobject(pOldPen); // 恢复原来的画笔 
pDC->SetROP2(n); // 恢复原来的绘图模式
}

void CContext::Circle(const Position ¢er double radius)
{
Position ltpos(center.x - radius center.y + radius ) ;
Position rbpos(center.x + radius center.y - radius ) ;
CPoint ssp sep scenp;

g_pView->WorldtoScreen(ltposssp) ;
g_pView->WorldtoScreen(rbpossep) ;
// g_pView->WorldtoScreen(center scenp) ;

int n = GetROP2(pDC->GetSafeHdc());
// create a pen by following rules:
// if in normal draw mode create a pen by its member variables 
// if else create a pen using global funtion “SetDrawEnvir“
CPen pen; 
if( drawMode == dmNormal ) 
pen.CreatePen(m_linestylem_lineWidthm_color) ;
else
::SetDrawEnvir(pDC drawMode &pen);

CPen* pOldPen = pDC->Selectobject(&pen) ;
pDC->SetMapMode(MM_LOENGLISH); 
pDC->SelectStockobject(NULL_BRUSH) ;
pDC->Ellipse(ssp.x ssp.y se

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

     文件       2962  2000-10-16 23:40  VCADVIEW.H

     文件        326  2006-04-16 22:59  RES\cur00001.cur

     文件        326  2000-10-16 23:29  RES\CURSOR1.CUR

     文件        326  2000-10-16 20:03  RES\DRAW_ARC.CUR

     文件        326  2000-10-16 20:04  RES\DRAW_CIR.CUR

     文件        326  2000-10-16 20:02  RES\DRAW_LIN.CUR

     文件        326  2000-10-16 20:04  RES\DRAW_REC.CUR

     文件        838  2000-10-16 18:58  RES\MODIFY.BMP

     文件        326  2000-10-16 23:31  RES\PROMPT_C.CUR

     文件        326  2000-10-16 23:31  RES\PROMPT_L.CUR

     文件        326  2000-10-16 23:31  RES\PROMPT_R.CUR

     文件        326  2006-04-16 22:59  RES\prompt_t.cur

     文件        238  2000-10-17 18:44  RES\PROPERTY.BMP

     文件       1078  2000-08-20 05:03  RES\TOOLBAR.BMP

     文件        718  2010-05-02 15:32  RES\toolbar1.bmp

     文件       1078  2000-08-20 05:03  RES\VCAD.ICO

     文件        396  2000-08-20 05:03  RES\VCAD.RC2

     文件       1078  2000-08-20 05:03  RES\VCADDOC.ICO

     文件        718  2000-10-16 19:03  RES\VIEW.BMP

     文件       5775  2007-03-15 13:33  ARC.CPP

     文件       4735  2007-04-29 22:57  base.CPP

     文件        269  2007-03-01 08:11  base.H

     文件       4027  2007-03-01 16:24  CIRCLE.CPP

     文件        896  2007-03-01 17:45  COMMAND.H

     文件       4281  2007-03-01 10:56  Context.cpp

     文件       2900  2007-03-01 10:54  Context.h

     文件       4660  2007-03-02 13:38  CREATEARC.CPP

     文件       3441  2007-03-02 13:40  CREATECIRCLE.CPP

     文件       2629  2010-05-02 22:39  CREATECMD.H

     文件       3993  2007-03-02 13:47  CREATELINE.CPP

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

评论

共有 条评论