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.
77 lines
1.5 KiB
C++
77 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "SigmaDoc.h"
|
|
#include "DrawOperator/Xy.h"
|
|
#include <cassert>
|
|
|
|
/**
|
|
* 曲线路径点绘制类
|
|
*/
|
|
class CurveNodeDrawer
|
|
{
|
|
public:
|
|
CurveNodeDrawer(CSigmaDoc* pDoc)
|
|
: m_pDoc(pDoc)
|
|
{
|
|
assert(m_pDoc != nullptr);
|
|
}
|
|
|
|
void Draw(CDC* pDC, CPositionList& positions) const
|
|
{
|
|
if (pDC == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CSize size = m_pDoc->GetHandleSize();
|
|
|
|
POSITION pos = positions.GetHeadPosition();
|
|
while (pos != nullptr)
|
|
{
|
|
POSITION pt = positions.GetNext(pos);
|
|
COne* pOne = m_pDoc->m_pXy->GetAt(pt);
|
|
if (pOne == nullptr)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (pOne->GetType() != DOUBLEFOX_CURVE)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
CCurveEx* pCurve = pOne->GetValueSafe<CCurveEx>();
|
|
|
|
DrawSingleNode(pDC, pCurve, size);
|
|
}
|
|
}
|
|
|
|
private:
|
|
// 仅绘制单个曲线节点(核心绘制逻辑)
|
|
void DrawSingleNode(CDC* pDC, CCurveEx* pCurve, const CSize& handleSize) const
|
|
{
|
|
CSize sz = m_pDoc->GetHandleSize();
|
|
|
|
int lastDrawIndex = 0;
|
|
for (int i = 0; i < pCurve->num; i++)
|
|
{
|
|
CPoint pt1 = m_pDoc->GetDC().GetScreen(pCurve->x[i], pCurve->y[i]);
|
|
if (i == 0 || i == pCurve->num - 1)
|
|
{
|
|
m_pDoc->DrawHandle(pCurve->x[i], pCurve->y[i], TRACKER_NO_EDIT, pDC);
|
|
}
|
|
else
|
|
{
|
|
CPoint pt2 = m_pDoc->GetDC().GetScreen(pCurve->x[lastDrawIndex], pCurve->y[lastDrawIndex]);
|
|
if (abs(pt1.x - pt2.x) > sz.cx || abs(pt1.y - pt2.y) > sz.cy)
|
|
{
|
|
m_pDoc->DrawHandle(pCurve->x[i], pCurve->y[i], TRACKER_NO_EDIT, pDC);
|
|
lastDrawIndex = i;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CSigmaDoc* m_pDoc = nullptr;
|
|
};
|