|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "HTrackerHandleCalculator.h"
|
|
|
|
|
|
|
|
|
|
|
|
HTrackerHandleCalculator::HTrackerHandleCalculator()
|
|
|
|
|
|
:m_HandleSize(12)
|
|
|
|
|
|
{
|
|
|
|
|
|
memset(m_Points, 0, sizeof(m_Points));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Tracker<65><72><EFBFBD>ε<EFBFBD><CEB5>ĸ<EFBFBD><C4B8>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
|
void HTrackerHandleCalculator::Calculate(const CRect & boundRect)
|
|
|
|
|
|
{
|
|
|
|
|
|
//CRect rc(boundRect);
|
|
|
|
|
|
//rc.InflateRect(m_OuterMargin, m_OuterMargin);
|
|
|
|
|
|
|
|
|
|
|
|
m_Points[0].x = m_Points[3].x = boundRect.left;
|
|
|
|
|
|
m_Points[1].x = m_Points[2].x = boundRect.right;
|
|
|
|
|
|
m_Points[0].y = m_Points[1].y = boundRect.top;
|
|
|
|
|
|
m_Points[2].y = m_Points[3].y = boundRect.bottom;
|
|
|
|
|
|
|
|
|
|
|
|
m_Points[4] = boundRect.CenterPoint();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CRect HTrackerHandleCalculator::GetHandleRect(int iHandle)
|
|
|
|
|
|
{
|
|
|
|
|
|
//if (iHandle == HandleBody)
|
|
|
|
|
|
//return m_StartRect;
|
|
|
|
|
|
|
|
|
|
|
|
CRect rc;
|
|
|
|
|
|
rc.SetRectEmpty();
|
|
|
|
|
|
rc.OffsetRect(GetHandlePoint(m_Points, iHandle));
|
|
|
|
|
|
int d = m_HandleSize / 2;
|
|
|
|
|
|
rc.InflateRect(d, d);
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CPoint HTrackerHandleCalculator::GetHandlePoint(int iHandle)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetHandlePoint(m_Points, iHandle);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
POINT HTrackerHandleCalculator::GetCenterPoint()
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Points[4];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HTrackerHandleCalculator::Reset()
|
|
|
|
|
|
{
|
|
|
|
|
|
memset(m_Points, 0, sizeof(m_Points));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
POINT HTrackerHandleCalculator::Test(int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_Points[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
//pPointsΪm_PointSrc
|
|
|
|
|
|
CPoint HTrackerHandleCalculator::GetHandlePoint(LPPOINT pPoints, int iHandle)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Handles are numbered clockwise, like this:
|
|
|
|
|
|
//
|
|
|
|
|
|
// HandleTopLeft HandleTop HandleTopRight
|
|
|
|
|
|
// 0 1 2
|
|
|
|
|
|
// *-----------*-----------*
|
|
|
|
|
|
// | |
|
|
|
|
|
|
// | |
|
|
|
|
|
|
// HandleLeft 7 * * 8 * 3 HandleRight
|
|
|
|
|
|
// | HandleCenter |
|
|
|
|
|
|
// | |
|
|
|
|
|
|
// *-----------*-----------*
|
|
|
|
|
|
// 6 5 4
|
|
|
|
|
|
// HandleBottomLeft HandleBottom HandleBottomRight
|
|
|
|
|
|
//
|
|
|
|
|
|
// The center point is handle 8, the HandleBody is handle 9.
|
|
|
|
|
|
|
|
|
|
|
|
if (iHandle >= 8)
|
|
|
|
|
|
return pPoints[4]; // center
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ϊż<CEAA><C5BC><EFBFBD>㣬<EFBFBD><E3A3AC>Ϊ<EFBFBD>ǵ㡣
|
|
|
|
|
|
//m_PointSrcǰ<63>ĸ<EFBFBD><C4B8><EFBFBD>Ϊ<EFBFBD>ǵ㡣iHandle<6C><65><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ǽǵ㡣
|
|
|
|
|
|
//<2F><><EFBFBD>Գ<EFBFBD><D4B3><EFBFBD>2<EFBFBD><32><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>iHandle<6C><65>Ӧ<EFBFBD>Ľǵ<C4BD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int i = iHandle / 2;
|
|
|
|
|
|
if ((iHandle & 1) == 0)
|
|
|
|
|
|
return pPoints[i]; // corner
|
|
|
|
|
|
|
|
|
|
|
|
int j = i + 1;
|
|
|
|
|
|
if (j > 3) j = 0;
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>е<EFBFBD>
|
|
|
|
|
|
CPoint pnt;
|
|
|
|
|
|
pnt.x = (pPoints[i].x + pPoints[j].x) / 2;
|
|
|
|
|
|
pnt.y = (pPoints[i].y + pPoints[j].y) / 2;
|
|
|
|
|
|
return pnt; // edge
|
|
|
|
|
|
}
|