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.
116 lines
2.6 KiB
C++
116 lines
2.6 KiB
C++
#include "StdAfx.h"
|
|
#include ".\itemequilateral.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
#include "DCHelp.h"
|
|
|
|
CItemEquilateral::CItemEquilateral(CSigmaDoc* ppDoc)
|
|
: CItem(ppDoc)
|
|
, m_PolygonNumber(5)
|
|
, loop(0)
|
|
{
|
|
this->SetType(ITEM_EQUILATERAL);
|
|
//m_nPropertyView=this->ShowPropertyPane(1);
|
|
EnableRButtonCancel(TRUE);
|
|
m_nPropertyView = 0;
|
|
}
|
|
|
|
CItemEquilateral::~CItemEquilateral(void)
|
|
{
|
|
//ShowPropertyPane(m_nPropertyView);
|
|
}
|
|
|
|
void CItemEquilateral::OnLButtonDown(CDC* pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
SetScreenDC(pDC);
|
|
GetDC()->Create(pDC);
|
|
switch(loop)
|
|
{
|
|
case 0:
|
|
PointStart=GetReal(point);
|
|
PointEnd=PointStart;
|
|
DrawLineReal(PointStart.x0,PointStart.y0,PointEnd.x0,PointEnd.y0);
|
|
Draw(GetDC(),PointStart,PointEnd,FALSE);
|
|
break;
|
|
case 1:
|
|
DrawLineReal(PointStart.x0,PointStart.y0,PointEnd.x0,PointEnd.y0);
|
|
DoSelectEnd();
|
|
loop=-1;
|
|
break;
|
|
}
|
|
loop++;
|
|
}
|
|
|
|
BOOL CItemEquilateral::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
{
|
|
if (m_pScreenDC == 0 || m_pBackGroundDC == 0)
|
|
return FALSE;
|
|
|
|
CRect rect = m_client;
|
|
CDC* pDC = m_pScreenDC;
|
|
DCHelp::ClearDC(pDC, m_BackColor);
|
|
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), m_pBackGroundDC, 0, 0, SRCCOPY); //画背景图 清空屏幕上临时绘制的图形
|
|
return TRUE;
|
|
}
|
|
|
|
int CItemEquilateral::OnMouseMove(CDC* pDC, UINT nFlags, CPoint point)
|
|
{
|
|
SetScreenDC(pDC);
|
|
GetDC()->Create(pDC);
|
|
switch(loop)
|
|
{
|
|
case 1:
|
|
DrawLineReal(PointStart.x0,PointStart.y0,PointEnd.x0,PointEnd.y0);
|
|
Draw(GetDC(),PointStart,PointEnd,FALSE);
|
|
PointEnd=GetReal(point);
|
|
DrawLineReal(PointStart.x0,PointStart.y0,PointEnd.x0,PointEnd.y0);
|
|
Draw(GetDC(),PointStart,PointEnd,FALSE);
|
|
|
|
//设置状态条信息
|
|
//SetStatusBarLengthInfo(PointStart.x0,PointStart.y0,PointEnd.x0,PointEnd.y0);
|
|
break;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void CItemEquilateral::OnDraw(CXyDC* pDC)
|
|
{
|
|
}
|
|
|
|
BOOL CItemEquilateral::DoSelectEnd(void)
|
|
{
|
|
Draw(GetDC(),PointStart,PointEnd,TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
void CItemEquilateral::Draw(CXyDC *pDC, dfPoint &pd, dfPoint &pu, BOOL bAdd)
|
|
{
|
|
CList<dfPoint,dfPoint> PointList;
|
|
dfPoint point;
|
|
|
|
AfxGetPublicFunction()->GetEquilateralPolyPoints(PointList, pd, pu, m_PolygonNumber);
|
|
if(pDC)
|
|
{
|
|
int old = pDC->GetDC()->SetROP2(R2_NOTXORPEN);
|
|
|
|
POSITION pos=PointList.GetHeadPosition();
|
|
point = PointList.GetNext(pos);
|
|
pDC->MoveTo(point.x0,point.y0);
|
|
while(pos)
|
|
{
|
|
point = PointList.GetNext(pos);
|
|
pDC->LineTo(point.x0,point.y0);
|
|
}
|
|
|
|
pDC->GetDC()->SetROP2(old);
|
|
}
|
|
|
|
if(bAdd)
|
|
{
|
|
CCurveEx* pCurve=new CCurveEx;
|
|
pCurve->SetPoints(PointList,2);
|
|
pCurve->GetLocation();
|
|
POSITION pos=this->AddElement(pCurve,DOUBLEFOX_CURVE);
|
|
//GetDoc()->Select(pos);
|
|
}
|
|
} |