📄 point.cpp
字号:
// Point.cpp: implementation of the CPnt class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Cad.h"
#include "Entity.h"
#include "Point.h"
#include "CadDoc.h"
#include "CadView.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
_declspec(dllexport) CPnt::CPnt()
{
m_dX=m_dY=0;
m_nType=ID_DRAW_POINT;
m_nColor=RGB(0,0,0);
m_nLineType=PS_SOLID;
}
_declspec(dllexport) CPnt::CPnt(double dX,double dY)
{
m_dX=dX;
m_dY=dY;
m_nType=ID_DRAW_POINT;
m_nColor=g_nCurColor;
m_nLineType=g_nCurLineType;
}
_declspec(dllexport) CPnt::~CPnt()
{
}
_declspec(dllexport) BOOL CPnt::Create(CDC* pDC,BOOL bSure)
{
BOOL ret=FALSE;
if(bSure==TRUE)
{
CStatusBar* pStatus=(CStatusBar*)
AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR);
ASSERT(pStatus);
switch(g_nStep)
{
case 0:
m_dX=g_dCurX;
m_dY=g_dCurY;
g_nStep=0;
pStatus->SetPaneText(0,"Enter the point");
ret=TRUE;
break;
default:
break;
}
}
return ret;
}
_declspec(dllexport) void CPnt::Draw(CDC* pDC,UINT nColor,UINT nLineType)
{
CPen* pNewPen=new CPen;
if(nColor==0&&nLineType==0)
pNewPen->CreatePen(m_nLineType,1,m_nColor);
else
pNewPen->CreatePen(nLineType,1,nColor);
CPen* pOldPen = pDC->SelectObject( pNewPen );
CPoint point;
g_pCurView->WorldToScreen(point,m_dX,m_dY);
pDC->MoveTo(point.x-2,point.y-2);
pDC->LineTo(point.x+2,point.y+2);
pDC->MoveTo(point.x+2,point.y-2);
pDC->LineTo(point.x-2,point.y+2);
pDC->SelectObject( pOldPen );
}
_declspec(dllexport) BOOL CPnt::OSnap()
{
double d=0;
double sd=g_nOSnapSize*g_pCurView->m_dScreenToWorld;
BOOL ret=FALSE;
switch(g_nOpqTask)
{
case ID_OSNAP_ENDPOINT:
case ID_OSNAP_MIDPOINT:
d=GetTwoPntDis2(g_dCurX,g_dCurY,m_dX,m_dY);
if(d<sd*sd)
{
g_dCurX=m_dX;
g_dCurY=m_dY;
ret=TRUE;
}
break;
default:
if((g_nOSnapType&3)!=0)
{
d=GetTwoPntDis2(g_dCurX,g_dCurY,m_dX,m_dY);
if(d<sd*sd)
{
g_dCurX=m_dX;
g_dCurY=m_dY;
ret=TRUE;
}
}
break;
}
return ret;
}
_declspec(dllexport) BOOL CPnt::Pick()
{
double sd=5.0*5.0*g_pCurView->m_dScreenToWorld;
double d=GetTwoPntDis2(g_dCurX,g_dCurY,m_dX,m_dY);
BOOL ret=FALSE;
if(d<sd)
{
ret=TRUE;
}
return ret;
}
_declspec(dllexport) void operator <<(CArchive& ar,CPnt& it)
{
ar<<it.m_dX;
ar<<it.m_dY;
}
_declspec(dllexport) void operator >>(CArchive& ar,CPnt& it)
{ ar>>it.m_dX;
ar>>it.m_dY;
}
_declspec(dllexport) void CPnt::Serialize(CArchive& ar)
{AFX_MANAGE_STATE(AfxGetStaticModuleState());
CEntity::Serialize(ar);
if(ar.IsStoring())
ar<<*this;
else
ar>>*this;
}
_declspec(dllexport) CPnt& CPnt::operator=(CPnt& in)
{
return in;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -