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.

86 lines
1.9 KiB
C++

#include "stdafx.h"
#include "DrawBend.h"
#include "DrawOperator/GDFLOGBRUSH.h"
#define PEN_WIDTH 2
#define PEN_COLOR RGB(255,0,0)
CDrawBend::CDrawBend()
{
m_pen.CreatePen(PS_SOLID, PEN_WIDTH, PEN_COLOR);
}
CDrawBend::~CDrawBend()
{
}
//void CDrawBend::OnDraw(CXyDC* pDC)
//{
// if (PointList.GetCount() < 1) return;
// int od = pDC->GetDC()->SetROP2(R2_NOTXORPEN);
// Draw(pDC, PointList, PEN_COLOR);
//
// if (PointList.GetCount() > 0)
// {
// dfPoint p1 = PointList.GetTail();
// DrawLine(PrevPoint.x0, PrevPoint.y0, p1.x0, p1.y0);
// }
// pDC->GetDC()->SetROP2(od);
//}
//void CDrawBend::Select(CDC* pDC)
//{
//
//}
void CDrawBend::Draw(CDC* pDC, CPointList& pl, COLORREF color)
{
if (pl.GetCount() <= 0) return;
CPen* pOld = pDC->SelectObject(&m_pen);
//dfPoint dp;
//POSITION p = pl.GetHeadPosition();
//dp = pl.GetNext(p);
//pDC->MoveTo(dp.x0, dp.y0);
//pDC->LineTo(dp.x0, dp.y0);
//while (p)
//{
// dp = pl.GetNext(p);
// pDC->LineTo(dp.x0, dp.y0);
//}
int nCount = pl.GetCount();
POINT *pt = new POINT[nCount+1];
dfPoint dp;
POSITION p = pl.GetHeadPosition();
dp = pl.GetNext(p);
pt[0].x = dp.x0;
pt[0].y = dp.y0;
pDC->MoveTo(dp.x0, dp.y0);
int i = 1;
while (p)
{
dp = pl.GetNext(p);
pt[i].x = dp.x0;
pt[i].y = dp.y0;
i++;
}
pt[nCount].x = pt[0].x;
pt[nCount].y = pt[0].y;
CBrush* brush = new CBrush(color);
CRgn* pRgn = new CRgn;
if (pRgn->CreatePolygonRgn(pt, nCount, WINDING)) {
pDC->FillRgn(pRgn, brush);
}
delete pRgn; pRgn = NULL;
delete brush; brush = nullptr;
pDC->SelectObject(pOld);
//GDFLOGBRUSH brush;
//brush.m_color = RGB(255, 0, 0);
//CPoint2D pts[3];
//pts[0].x0 = rectSegment.CenterPoint().x0;
//pts[0].y0 = rectSegment.top;
//pts[1].x0 = rectSegment.left + rectSegment.Width() * m_iLeftValue / m_iMaxValue;
//pts[2].x0 = rectSegment.left + rectSegment.Width() * m_iRightValue / m_iMaxValue;
//pts[1].y0 = pts[2].y0 = rectSegment.bottom;
//pDC->DrawFillPolygon()
}