当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsPath::AddBeziers方法代码示例

本文整理汇总了C++中GraphicsPath::AddBeziers方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsPath::AddBeziers方法的具体用法?C++ GraphicsPath::AddBeziers怎么用?C++ GraphicsPath::AddBeziers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsPath的用法示例。


在下文中一共展示了GraphicsPath::AddBeziers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RecalcConnectionLayout

void CXTPFlowGraphPaintManager::RecalcConnectionLayout(CXTPFlowGraphDrawContext* /*pDC*/, CXTPFlowGraphConnection* pConnection)
{
	CXTPFlowGraphConnectionPoint* pFrom = pConnection->GetOutputPoint();
	CXTPFlowGraphConnectionPoint* pTo = pConnection->GetInputPoint();

	if (pFrom == NULL)
		return;

	CPoint ptFrom, ptTo;

	ptFrom = pFrom->GetNode()->GetLocation();
	ptFrom.x += pFrom->GetNode()->GetSize().cx;
	ptFrom.y += pFrom->m_rcPoint.CenterPoint().y;

	if (pTo != NULL)
	{
		ptTo = pTo->GetNode()->GetLocation();
		ptTo.y += pTo->m_rcPoint.CenterPoint().y;

		if (pTo->GetType() == xtpFlowGraphPointInputAndOutput)
		{
			if (ptFrom.x > ptTo.x)
				ptTo.x += pTo->GetNode()->GetSize().cx;
		}

		pConnection->m_ptInputPoint = ptTo;
	}
	else
	{
		ptTo = pConnection->m_ptInputPoint;
	}

	if (pFrom->GetType() == xtpFlowGraphPointInputAndOutput)
	{
		if (ptTo.x < ptFrom.x - pFrom->GetNode()->GetSize().cx / 2)
			ptFrom.x -= pFrom->GetNode()->GetSize().cx;
	}


	pConnection->m_ptOutputPoint = ptFrom;

	GraphicsPath* path = new GraphicsPath();

	XTPFlowGraphConnectorType type = pConnection->GetStyle() == -1 ? m_nConnectorType : (XTPFlowGraphConnectorType)pConnection->GetStyle();

	CPoint ptControlPoint = pConnection->GetControlPoint();

	if (type == xtpFlowGraphConnectorStraight)
	{
		if (ptControlPoint != CPoint(-1, -1))
		{
			Point pts[] = {Point(ptFrom.x, ptFrom.y), Point(ptControlPoint.x, ptControlPoint.y), Point(ptTo.x, ptTo.y) };

			path->AddLines(pts, 3);
		}
		else
		{
			path->AddLine(ptFrom.x, ptFrom.y, ptTo.x, ptTo.y);
		}
	}
	else
	{
		if (ptControlPoint != CPoint(-1, -1))
		{
			/*PointF pt[3] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y), PointF((REAL)pConnection->GetControlPoint().x, (REAL)pConnection->GetControlPoint().y),
			PointF((REAL)ptTo.x, (REAL)ptTo.y) };
			path->AddCurve(pt, 3);*/

			PointF pt2[4] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y),
				PointF((REAL)ptControlPoint.x, (REAL)ptFrom.y), PointF((REAL)ptControlPoint.x,  (REAL)ptTo.y),
				PointF((REAL)ptTo.x, (REAL)ptTo.y) };

			path->AddBeziers(pt2, 4);

		}
		else
		{
			PointF pt[4] = {PointF((REAL)ptFrom.x, (REAL)ptFrom.y), PointF((REAL)(ptFrom.x + ptTo.x) / 2, (REAL)ptFrom.y),
				PointF(REAL(ptFrom.x + ptTo.x) / 2, (REAL)ptTo.y), PointF((REAL)ptTo.x, (REAL)ptTo.y) };
			path->AddBeziers(pt, 4);
		}
	}


	SAFE_DELETE(pConnection->m_pPath);
	pConnection->m_pPath = path;

}
开发者ID:lai3d,项目名称:ThisIsASoftRenderer,代码行数:88,代码来源:XTPFlowGraphPaintManager.cpp


注:本文中的GraphicsPath::AddBeziers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。