Exemplo n.º 1
0
CElementImpl* CElementImpl::FindPointUnderPoint(ILSVGPoint* mousept, ILSVGMatrix* addmatrix, int& segindex, int& ctl)
{
	SVGLib::ISVGLocatablePtr locatable = m_domElement;
	if (locatable)
	{
		UPOSITION pos = m_childList.GetTailPosition();
		while (pos)
		{
			CElement* pElement = (CElement*)m_childList.GetPrev(pos);

			CElement* pFElement = pElement->FindPointUnderPoint(mousept, segindex, ctl);
			if (pFElement)
				return pFElement;
		}

		if (!wcscmp(m_domElement->tagName, L"path"))
		{
			CPathElement* pathElement = (CPathElement*)this;

			SVGLib::ISVGMatrixPtr matrix = locatable->getScreenCTM();
		/*
			SVGLib::ISVGMatrixPtr imatrix = matrix->inverse();

			SVGLib::ISVGPointPtr xpt = mousept->matrixTransform(imatrix);
*/


			SVGLib::ISVGAnimatedPathDataPtr pathData = m_domElement;
			SVGLib::ISVGPathSegListPtr seglist = pathData->normalizedPathSegList;

			ctl = 0;
			segindex = pathElement->FindPoint(seglist, matrix, mousept->x, mousept->y, ctl);
			if ((segindex >= 0) && (ctl == 0))
				return this;

			SVGLib::_tagSVGRect bbox = locatable->getBBox();

			if (mousept->x >= bbox.x && mousept->x <= bbox.x+bbox.width &&
				mousept->y >=  bbox.y && mousept->y <= bbox.y+bbox.height)
			{
				segindex = -1;
				return this;
			}
		}
	}
	return NULL;
}