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.

87 lines
1.7 KiB
C++

#include "stdafx.h"
#include "EntityBend.h"
#define PEN_WIDTH 5
#define PEN_COLOR RGB(0,0,255)
CEntityBend::CEntityBend()
{
selected = false;
m_pen.CreatePen(PS_SOLID, PEN_WIDTH, PEN_COLOR);
}
CEntityBend::~CEntityBend()
{
}
void CEntityBend::SetData(CPointList& pl) {
dfPoint dp;
POSITION p = pl.GetHeadPosition();
while (p)
{
dp = pl.GetNext(p);
points.AddTail(dp);
}
}
void CEntityBend::DrawSelect(CDC* pdc)
{
CPen* pOld = pdc->SelectObject(&m_pen);
dfPoint dp, dpFirst;
POSITION p = points.GetHeadPosition();
dp = points.GetNext(p);
dpFirst = dp;
pdc->MoveTo(dp.x0, dp.y0);
pdc->LineTo(dp.x0, dp.y0);
while (p)
{
dp = points.GetNext(p);
pdc->LineTo(dp.x0, dp.y0);
}
pdc->LineTo(dpFirst.x0, dpFirst.y0);
pdc->SelectObject(pOld);
}
void CEntityBend::Draw(CDC* pDC, COLORREF color)
{
if (points.GetCount() <= 0) return;
CPen* pOld = pDC->SelectObject(&m_pen);
int nCount = points.GetCount();
POINT *pt = new POINT[nCount + 1];
dfPoint dp;
POSITION p = points.GetHeadPosition();
dp = points.GetNext(p);
pt[0].x = dp.x0;
pt[0].y = dp.y0;
pDC->MoveTo(dp.x0, dp.y0);
int i = 1;
while (p)
{
dp = points.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);
if (selected)
{
DrawSelect(pDC);
}
}
void CEntityBend::SetName(LPCTSTR leftWell, LPCTSTR leftStrati, LPCTSTR rightWell, LPCTSTR rightStrati)
{
this->leftWell = leftWell;
this->leftStrati = leftStrati;
this->rightWell = rightWell;
this->rightStrati = rightStrati;
}