示例#1
0
void CAngleLabel::DecideModiFyType(UINT nMouseState,CPoint point)
{
	if(nMouseState != MS_LBTNDOWN)
		return;

	PointF pt((float)point.x, (float)point.y);

	if(CalcGapOfpoints(pt, m_ptary[0]) <= m_nWidth)
	{
		m_ModifyType = MT_LT;
	}
	else if(CalcGapOfpoints(pt, m_ptary[1]) <= m_nWidth)
	{
		m_ModifyType = MT_RB;
	}
	else if(CalcGapOfpoints(pt, m_ptary[2]) <= m_nWidth)
	{
		m_ModifyType = MT_RC;
	}
	else if(m_Region.IsVisible(pt))
	{
		m_ModifyType = MT_MOVE;
		m_ptModifyOrg.X = (float)point.x;
		m_ptModifyOrg.Y = (float)point.y;
	}
	else
	{
		m_ModifyType = MT_NONE;
	}
}
示例#2
0
ModifyType CAngleLabel::AroundHotPts(CPoint point)
{
	if(!m_bFinish)
	{
		return MT_NONE;
	}

	PointF pt((float)point.x,(float)point.y);

	if(CalcGapOfpoints(pt,m_ptary[0]) <= m_nWidth)
	{
		return MT_TC;
	}
	else if(CalcGapOfpoints(pt,m_ptary[1]) <= m_nWidth)
	{
		return MT_TC;
	}
	else if(CalcGapOfpoints(pt,m_ptary[2]) <= m_nWidth)
	{
		return MT_TC;
	}
	else if(m_Region.IsVisible(pt))
	{
		return MT_MOVE;
	}
	else
	{
		return MT_NONE;
	}
}
void CToolRegularRuler::DecideModiFyType(UINT nMouseState,CPoint point)
{
	if(nMouseState != MS_LBTNDOWN)
	{
		return;
	}

	//Translate the point for the point has been considered rotated so rotated back
	PointF pt((float)point.x,(float)point.y);
	Matrix mat;
	mat.RotateAt(- m_fAngle,m_ptCenter);
	mat.TransformPoints(&pt,1);

	if(m_rcGrip.PtInRect(CPoint((int)pt.X,(int)pt.Y)))
	{
		m_ModifyType = MT_RC;
		m_ptModifyOrg = pt;
	}
	else if(CalcGapOfpoints(pt,m_HotPts.ptRotate) <= 2 * MININTERVAL)
	{
		m_ModifyType = MT_ROTATE;
	}
	else if(m_rcHot.PtInRect(CPoint((int)pt.X,(int)pt.Y)))
	{
		m_ModifyType = MT_MOVE;
		m_ptModifyOrg.X = (float)point.x;
		m_ptModifyOrg.Y = (float)point.y;
	}
	else
	{
		m_ModifyType = MT_NONE;
	}

	AdjustGraph(m_fAngle);
}
void CToolRegularRuler::FormGraphData(UINT nMouseState, CPoint point, CRect& rcUpdate)
{
	PointF pt((float)point.x, (float)point.y);
	if(MS_LBTNDOWN	== nMouseState)
	{
		m_ptary[0] = pt;
		m_nPtCount = 1;
	}
	else
	{
		m_ptary[1] = pt;
		m_nPtCount = 2;
	}

	if(MS_LBTNUP == nMouseState)
	{
		if(CalcGapOfpoints(m_ptary[0], m_ptary[1]) <= 3)
		{
			m_bDataInvalid = TRUE;
		}
		else
		{
			m_bFinish = TRUE;
			InitHotData();
			rcUpdate = m_rcHot;
		}
	}
}
示例#5
0
void CFlatBrushPen::FormGraphData(UINT nMouseState, CPoint point, CRect& rcUpdate)
{
	PointF pt((float)point.x, (float)point.y);

	if(m_nPtCount == 0)
	{
		m_ptary.Add(pt);
		m_nPtCount++;
	}
	else
	{
		PointF ptf = m_ptary[m_nPtCount - 1];
		if(CalcGapOfpoints(pt, ptf) >= 3)
		{
			m_ptary.Add(pt);
			m_nPtCount++;
		}
	}

	if(m_nPtCount >= 2 && !m_bFinish)
	{
		CPoint ptLT((int)m_ptary[m_nPtCount - 1].X, (int)m_ptary[m_nPtCount - 1].Y);
		CPoint ptRB((int)m_ptary[m_nPtCount - 2].X, (int)m_ptary[m_nPtCount - 2].Y);

		rcUpdate.SetRect(ptLT, ptRB);
		rcUpdate.NormalizeRect();

		rcUpdate.InflateRect(3 * m_nWidth, 3 * m_nWidth);
	}

	if(MS_LBTNUP == nMouseState)
	{
		if(( m_nPtCount <= 1) ||
			( m_nPtCount <= 2 && 
			CalcGapOfpoints(m_ptary[0],m_ptary[1]) <= 3))
		{
			m_bDataInvalid = TRUE;
		}
		else
		{
			m_bFinish = TRUE;
			InitHotData();
			rcUpdate = m_rcHot;
		}
	}
}
示例#6
0
void CAngleLabel::InitHotData()
{
	int nleft = (int)min(min(m_ptary[0].X, m_ptary[1].X), m_ptary[2].X);
	int ntop = (int)min(min(m_ptary[0].Y, m_ptary[1].Y), m_ptary[2].Y);
	int nright = (int)max(max(m_ptary[0].X, m_ptary[1].X), m_ptary[2].X);
	int nbottom = (int)max(max(m_ptary[0].Y, m_ptary[1].Y), m_ptary[2].Y);
	m_rcHot.SetRect(nleft, ntop, nright, nbottom);

	float fside1 = CalcGapOfpoints(m_ptary[0], m_ptary[1]);
	float fside2 = CalcGapOfpoints(m_ptary[0], m_ptary[2]);

	if(fside1 >= 100 && fside2 >= 100)
	{
		m_rcHot.InflateRect(HOTINTERVAL, HOTINTERVAL);
	}
	else if(fside1 >= 50 && fside2 >= 50)
	{
		m_rcHot.InflateRect(5 * HOTINTERVAL, 5 * HOTINTERVAL);
	}
	else if(fside1 >= 30 && fside2 >= 30)
	{
		m_rcHot.InflateRect(8 * HOTINTERVAL, 8 * HOTINTERVAL);
	}
	else if(fside1 >= 20 && fside2 >= 20)
	{
		m_rcHot.InflateRect(10 * HOTINTERVAL, 10 * HOTINTERVAL);
	}
	else
	{
		m_rcHot.InflateRect(15 * HOTINTERVAL, 15 * HOTINTERVAL);
	}

	if(m_rcHot.Width() <= 200)
	{
		m_rcHot.InflateRect(8 * HOTINTERVAL, 0);
	}
	else if(m_rcHot.Height() <= 200)
	{
		m_rcHot.InflateRect(0, 8 * HOTINTERVAL);
	}

	m_ptCenter.X = (float)m_rcHot.CenterPoint().x;
	m_ptCenter.Y = (float)m_rcHot.CenterPoint().y;

	SetRegion();
}
示例#7
0
int CAngleLabel::CalLinesAngle()
{
	ASSERT(m_bhas3temppts || m_bFinish);

	float a = CalcGapOfpoints(m_ptary[0], m_ptary[1]);
	float b = CalcGapOfpoints(m_ptary[1], m_ptary[2]);
	float c = CalcGapOfpoints(m_ptary[2], m_ptary[0]);

	if(a <= 1 || c <= 1)
	{
		return 0;
	}
	else
	{
		float fvalue = (a * a + c * c - b * b) / (2 * a * c);
		float PI = 3.1415926f;
		float fangle = (float)(acos(fvalue) * 180 / PI);

		if(fabs(fangle - 180) < 0.1f)
		{
			fangle = 180.0f;
		}
		else if(fabs(fangle) < 0.1f)
		{
			fangle = 0.0f;
		}

		if(fangle < 0 || fangle > 180)
		{
			return 0;
		}
		else
		{
			return (int)(fangle + 0.5f);
		}
	}
}
示例#8
0
BOOL CAngleLabel::IsPtInModifyZone(CPoint point)
{
	BOOL bret = TRUE;
	PointF pt((float)point.x,(float)point.y);

	if(CalcGapOfpoints(pt,m_ptary[0]) <= m_nWidth)
	{
	}
	else if(CalcGapOfpoints(pt,m_ptary[1]) <= m_nWidth)
	{
	}
	else if(CalcGapOfpoints(pt,m_ptary[2]) <= m_nWidth)
	{
	}
	else if(m_Region.IsVisible(pt))
	{
	}
	else
	{
		bret = FALSE;
	}

	return bret;
}
ModifyType CToolRegularRuler::AroundHotPts(CPoint point)
{
	PointF pt((float)point.x, (float)point.y);
	Matrix mat;
	mat.RotateAt(- m_fAngle, m_ptCenter);
	mat.TransformPoints(&pt, 1);

	if(m_rcGrip.PtInRect(CPoint((int)pt.X, (int)pt.Y))/*CalcGapOfpoints(pt,m_HotPts.ptRC) <= HOTINTERVAL*/)
	{
		return MT_RC;
	}
	else if(CalcGapOfpoints(pt, m_HotPts.ptRotate) <= 2 * MININTERVAL)
	{
		return MT_ROTATE;
	}
	else if(m_rcHot.PtInRect(CPoint((int)pt.X, (int)pt.Y)))
	{
		return MT_MOVE;
	}
	else
	{
		return MT_NONE;
	}
}