You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
843 B
C++
48 lines
843 B
C++
#include "stdafx.h"
|
|
#include "RubberLine.h"
|
|
|
|
RubberLine::RubberLine()
|
|
:m_firstDraw(false)
|
|
{
|
|
}
|
|
|
|
void RubberLine::SetOriginPoint(const CPoint & originPt)
|
|
{
|
|
m_originPt = originPt;
|
|
m_firstDraw = true;
|
|
}
|
|
|
|
void RubberLine::Draw(CDC * pDC, CPoint & motionPt)
|
|
{
|
|
int nOldRop = pDC->SetROP2(R2_NOTXORPEN);
|
|
if (m_firstDraw)
|
|
{
|
|
pDC->MoveTo(m_originPt);
|
|
pDC->LineTo(motionPt);
|
|
|
|
m_oldMotionPt = motionPt;
|
|
m_firstDraw = false;
|
|
pDC->SetROP2(nOldRop);
|
|
return;
|
|
}
|
|
|
|
//擦除原来的橡皮线
|
|
pDC->MoveTo(m_originPt);
|
|
pDC->LineTo(m_oldMotionPt);
|
|
m_oldMotionPt = motionPt;
|
|
|
|
//绘制新的橡皮线
|
|
pDC->MoveTo(m_originPt);
|
|
pDC->LineTo(motionPt);
|
|
|
|
pDC->SetROP2(nOldRop);
|
|
}
|
|
|
|
void RubberLine::Erease(CDC * pDC)
|
|
{
|
|
//擦除原来的橡皮线
|
|
int nOldRop = pDC->SetROP2(R2_NOTXORPEN);
|
|
pDC->MoveTo(m_originPt);
|
|
pDC->LineTo(m_oldMotionPt);
|
|
pDC->SetROP2(nOldRop);
|
|
} |