text.cpp
来自「故障诊断工作涉及的领域相当广泛」· C++ 代码 · 共 168 行
CPP
168 行
// Text.cpp: implementation of the CText class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Cad.h"
#include "Entity.h"
#include "Text.h"
#include "CadDoc.h"
#include "CadView.h"
#include "EnterText.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
_declspec(dllexport) CText::CText()
{
m_dX=m_dY=0;
m_strText="";
m_nType=ID_DRAW_TEXT;
m_nColor=RGB(0,0,0);
m_nLineType=PS_SOLID;
}
_declspec(dllexport) CText::CText(double dX,double dY,CString strText)
{
m_dX=dX;
m_dY=dY;
m_strText=strText;
m_nType=ID_DRAW_TEXT;
m_nColor=g_nCurColor;
m_nLineType=g_nCurLineType;
}
_declspec(dllexport) CText::~CText()
{
}
_declspec(dllexport) BOOL CText::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;
CEnterTextDlg dlg;
if(dlg.DoModal()==IDOK)
{
m_strText=dlg.m_strText;
ret=TRUE;
}
g_nStep=0;
pStatus->SetPaneText(0,"Enter the point");
break;
}
default:
break;
}
}
return ret;
}
_declspec(dllexport) void CText::Draw(CDC* pDC,UINT nColor,UINT nLineType)
{
CPoint point;
g_pCurView->WorldToScreen(point,m_dX,m_dY);
if(nColor==0)
pDC->SetTextColor(m_nColor);
else
pDC->SetTextColor(nColor);
pDC->TextOut(point.x,point.y,m_strText);
}
_declspec(dllexport) BOOL CText::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 CText::Pick()
{
double sd=5.0*g_pCurView->m_dScreenToWorld;
double d=GetTwoPntDis2(g_dCurX,g_dCurY,m_dX,m_dY);
BOOL ret=FALSE;
if(d<sd*sd)
{
ret=TRUE;
}
return ret;
}
_declspec(dllexport) void operator <<(CArchive& ar,CText& it)
{
ar<<it.m_dX;
ar<<it.m_dY;
ar<<it.m_strText;
}
_declspec(dllexport) void operator >>(CArchive& ar,CText& it)
{ ar>>it.m_dX;
ar>>it.m_dY;
ar>>it.m_strText;
}
_declspec(dllexport) void CText::Serialize(CArchive& ar)
{AFX_MANAGE_STATE(AfxGetStaticModuleState());
CEntity::Serialize(ar);
if(ar.IsStoring())
ar<<*this;
else
ar>>*this;
}
_declspec(dllexport) CText& CText::operator=(CText& in)
{
return in;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?