CXTPChartDeviceCommand* CXTPChartAreaSeriesView::CreateLegendDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcBounds)
{
	UNREFERENCED_PARAMETER(pDC);
	rcBounds.DeflateRect(1, 1);

	CXTPChartDeviceCommand* pCommand = new CXTPChartPolygonAntialiasingDeviceCommand();

	CXTPChartAreaSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartAreaSeriesStyle, m_pSeries->GetStyle());

	CXTPChartPointF ptCenter(rcBounds.CenterPoint().x, rcBounds.top + 4) ;
	int nSize = 8;


	CXTPChartPoints arrPoints;
	arrPoints.Add(CXTPChartPointF(rcBounds.left, rcBounds.bottom + 1));
	arrPoints.Add(CXTPChartPointF(ptCenter.X, float(rcBounds.top + 4)));
	arrPoints.Add(CXTPChartPointF(rcBounds.right, rcBounds.bottom + 1));

	pCommand->AddChildCommand(pStyle->GetFillStyle()->CreateDeviceCommand(arrPoints, GetActualColor(), GetActualColor2()));


	CXTPChartColor clrBorder = GetBorderActualColor();
	pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand(arrPoints[0], arrPoints[1], clrBorder, 1));
	pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand(arrPoints[1], arrPoints[2], clrBorder, 1));

	pCommand->AddChildCommand(pStyle->GetMarker()->CreateDeviceCommand(pDC, ptCenter, nSize, GetColor(), GetColor2(), GetColor().GetDarkColor()));

	return pCommand;
}
CXTPChartDeviceCommand* CXTPChartPyramidSeriesView::CreateLegendDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcBounds,
	CXTPChartColor color1, CXTPChartColor color2, CXTPChartColor clrBorder)
{
	UNREFERENCED_PARAMETER(pDC);
	rcBounds.DeflateRect(1, 1);

	CXTPChartPyramidSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartPyramidSeriesStyle, GetStyle());

	CXTPChartDeviceCommand* pCommand = new CXTPChartPolygonAntialiasingDeviceCommand();

	CXTPChartPoints arrPoints;

	arrPoints.Add(CXTPChartPointF((rcBounds.left + rcBounds.right) / 2, rcBounds.top));

	arrPoints.Add(CXTPChartPointF(rcBounds.right, rcBounds.bottom ));
	arrPoints.Add(CXTPChartPointF(rcBounds.left, rcBounds.bottom));

	pCommand->AddChildCommand(pStyle->GetFillStyle()->CreateDeviceCommand(arrPoints, color1, color2));

	if (pStyle->GetBorder()->IsVisible())
		pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, clrBorder, 1));


	return pCommand;
}
CXTPChartDeviceCommand* CXTPChartPyramidSeriesPointView::CreateDeviceCommand(CXTPChartDeviceContext* pDC)
{
	UNREFERENCED_PARAMETER(pDC);

	CXTPChartColor color1 = GetColor();
	CXTPChartColor color2 = GetColor2();
	CXTPChartColor clrBorder = GetBorderActualColor();

	CXTPChartDeviceCommand* pCommand = new CXTPChartHitTestElementCommand(m_pPoint);

	CXTPChartPyramidSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartPyramidSeriesStyle, GetSeriesView()->GetStyle());

	CXTPChartPoints arrPoints;

	arrPoints.Add(CXTPChartPointF(m_rc.GetLeft() + int((m_rc.Width - m_rc.Width * m_dFrom) / 2), m_rc.GetTop()));
	arrPoints.Add(CXTPChartPointF(m_rc.GetLeft() + int((m_rc.Width + m_rc.Width * m_dFrom) / 2), m_rc.GetTop()));

	arrPoints.Add(CXTPChartPointF(m_rc.GetLeft() + int((m_rc.Width + m_rc.Width * m_dTo) / 2), m_rc.GetBottom()));
	arrPoints.Add(CXTPChartPointF(m_rc.GetLeft() + int((m_rc.Width - m_rc.Width * m_dTo) / 2), m_rc.GetBottom()));

	pCommand->AddChildCommand(pStyle->GetFillStyle()->CreateDeviceCommand(arrPoints, color1, color2));

	if (pStyle->GetBorder()->IsVisible())
		pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, clrBorder, pStyle->GetBorder()->GetThickness()));


	return pCommand;
}
CXTPChartClipRegionDeviceCommand::CXTPChartClipRegionDeviceCommand(const CXTPChartPoints& points)
{
	GpPath* pGpPath = NULL;
	GdipCreatePath(FillModeAlternate, &pGpPath);
	GdipAddPathPolygon(pGpPath, (GpPointF*)points.GetData(), (int)points.GetSize());

	m_pGpClip = NULL;
	GdipCreateRegionPath(pGpPath, &m_pGpClip);

	m_pGpState = NULL;
	GdipCreateRegion(&m_pGpState);

	GdipDeletePath(pGpPath);
}
CXTPChartDeviceCommand* CXTPChartRadarAxisXView::CreateInterlacedDeviceCommand(CXTPChartDeviceContext* pDC)
{
	UNREFERENCED_PARAMETER(pDC);

	if (!m_pAxis->IsInterlaced())
		return NULL;

	if (m_arrTicks.GetSize() < 2)
		return NULL;


	CXTPChartDeviceCommand* pCommands = new CXTPChartDeviceCommand();

	CXTPChartColor color1 = m_pAxis->GetActualInterlacedColor();
	CXTPChartColor color2 = m_pAxis->GetActualInterlacedColor2();

	for (int i = 0; i + 1 < m_arrTicks.GetSize(); i += 2)
	{

		double dFrom = ValueToAngle(m_arrTicks[i].m_dValue);
		double dTo = ValueToAngle(m_arrTicks[i + 1].m_dValue);

		if (dTo > dFrom)
			dTo -= 2 * CXTPChartMathUtils::m_dPI;


		if (IsPolygonDiagramStyle())
		{
			CXTPChartPoints pts;
			pts.Add(m_ptCenter);
			pts.Add(CXTPChartPointF(m_ptCenter.X + cos(dFrom) * m_nRadius, m_ptCenter.Y - sin(dFrom) * m_nRadius));
			pts.Add(CXTPChartPointF(m_ptCenter.X + cos(dTo) * m_nRadius, m_ptCenter.Y - sin(dTo) * m_nRadius));

			pCommands->AddChildCommand(m_pAxis->GetInterlacedFillStyle()->CreateDeviceCommand(pts, color1, color2));

		}
		else
		{
			pCommands->AddChildCommand(new CXTPChartGradientPieDeviceCommand(CXTPPoint3d(m_ptCenter), m_nRadius, m_nRadius,
				-CXTPChartMathUtils::Radian2Degree(dFrom), CXTPChartMathUtils::Radian2Degree(dFrom - dTo), 0, 0, m_rcBounds, color1, color2));
		}
	}


	return pCommands;
}
CXTPChartDeviceCommand* CXTPChartAreaSeriesView::CreateDeviceCommand(CXTPChartDeviceContext* pDC)
{
	CXTPChartDeviceCommand* pSeriesCommand = new CXTPChartHitTestElementCommand(m_pSeries);
	CXTPChartDeviceCommand* pCommand = pSeriesCommand->AddChildCommand(new CXTPChartPolygonAntialiasingDeviceCommand());

	CXTPChartAreaSeriesStyle* pStyle = (CXTPChartAreaSeriesStyle*)GetStyle();

	CXTPChartAxis* pAxisY = GetAxisViewY()->GetAxis();

	CXTPChartColor clrBorder = GetBorderActualColor();

	double dZero = max(0, pAxisY->GetRange()->GetMinValue());

	int nCount = m_pPointsView->GetCount();
	if (nCount > 1)
	{
		CXTPChartPointSeriesPointView* pPointView =  (CXTPChartPointSeriesPointView*)m_pPointsView->GetAt(0);

		CXTPChartPointF pointPrev = GetScreenPoint(pPointView->GetPoint()->GetInternalArgumentValue(), pPointView->m_dInternalValue);

		CXTPChartPoints arrPoints;
		arrPoints.Add(GetScreenPoint(pPointView->GetPoint()->GetInternalArgumentValue(), dZero));

		for (int i = 1; i < nCount; i++)
		{
			pPointView =  (CXTPChartPointSeriesPointView*)m_pPointsView->GetAt(i);
			CXTPChartPointF pointNext = pPointView->GetScreenPoint();

			arrPoints.Add(pointPrev);

			pointPrev = pointNext;
		}

		arrPoints.Add(pointPrev);

		pPointView =  (CXTPChartPointSeriesPointView*)m_pPointsView->GetAt(nCount - 1);

		arrPoints.Add(GetScreenPoint(pPointView->GetPoint()->GetInternalArgumentValue(), dZero));

		pCommand->AddChildCommand(pStyle->GetFillStyle()->CreateDeviceCommand(arrPoints, GetActualColor(), GetActualColor2()));


		arrPoints.RemoveAt(0);
		arrPoints.RemoveAt(arrPoints.GetSize() - 1);

		if (pStyle->GetBorder()->IsVisible())
			pCommand->AddChildCommand(new CXTPChartSolidPolylineDeviceCommand(arrPoints, clrBorder, pStyle->GetBorder()->GetThickness()));
	}

	pCommand->AddChildCommand(CXTPChartSeriesView::CreateDeviceCommand(pDC));

	return pSeriesCommand;
}
CXTPChartSolidSplinePolygonDeviceCommand::CXTPChartSolidSplinePolygonDeviceCommand(const CXTPChartPoints& points, const CXTPChartColor& color, BOOL bTwoSides)
{
	m_color = color;

	if (!bTwoSides)
	{
		GpPath* pGpPath = 0;
		GdipCreatePath(FillModeAlternate, &pGpPath);
		GdipStartPathFigure(pGpPath);

		int nCount = (int)points.GetSize();

		GdipAddPathLine(pGpPath, points[0].X, points[0].Y, points[1].X, points[1].Y);
		GdipAddPathCurve(pGpPath, (PointF*)points.GetData() + 1, nCount - 2);
		GdipAddPathLine(pGpPath, points[nCount - 2].X, points[nCount - 2].Y, points[nCount - 1].X, points[nCount - 1].Y);

		GdipClosePathFigures(pGpPath);

		m_pGpPath = pGpPath;
	}
	else
	{

		GpPath* pGpPath = 0;
		GdipCreatePath(FillModeAlternate, &pGpPath);
		GdipStartPathFigure(pGpPath);

		int nCount = (int)points.GetSize();

		GdipAddPathCurve(pGpPath, (PointF*)points.GetData(), nCount / 2);
		GdipAddPathLine(pGpPath, points[nCount / 2].X, points[nCount / 2].Y, points[nCount / 2 + 1].X, points[nCount / 2 + 1].Y);

		GdipAddPathCurve(pGpPath, (PointF*)points.GetData() + nCount / 2, nCount / 2);

		GdipAddPathLine(pGpPath, points[nCount - 1].X, points[nCount - 1].Y, points[0].X, points[0].Y);

		GdipClosePathFigures(pGpPath);

		m_pGpPath = pGpPath;

	}
}
CXTPChartDeviceCommand* CXTPChartRadarSplineAreaSeriesView::CreateDeviceCommand(CXTPChartDeviceContext* pDC)
{
	CXTPChartDeviceCommand* pSeriesCommand = new CXTPChartHitTestElementCommand(m_pSeries);
	CXTPChartDeviceCommand* pCommand = pSeriesCommand->AddChildCommand(new CXTPChartPolygonAntialiasingDeviceCommand());

	CXTPChartRadarSplineAreaSeriesStyle* pStyle = (CXTPChartRadarSplineAreaSeriesStyle*)GetStyle();

	int nCount = m_pPointsView->GetCount();

	if (nCount > 1)
	{
		CXTPChartPoints arrPoints;

		for (int i = 0; i < nCount; i++)
		{
			CXTPChartRadarPointSeriesPointView* pPointView =  (CXTPChartRadarPointSeriesPointView*)m_pPointsView->GetAt(i);
			CXTPChartPointF pointNext = pPointView->GetScreenPoint();

			arrPoints.Add(pointNext);
		}

		CXTPChartPointF ptFirst = arrPoints[0];
		arrPoints.Add(ptFirst);

		pCommand->AddChildCommand(pStyle->GetFillStyle()->CreateSplineDeviceCommand(arrPoints, GetActualColor(), GetActualColor2(), 2));

		if (pStyle->GetBorder()->IsVisible())
		{
			CXTPChartColor clrBorder = GetBorderActualColor();

			pCommand->AddChildCommand(new CXTPChartSolidSplineDeviceCommand(arrPoints, clrBorder, pStyle->GetBorder()->GetThickness()));
		}
	}

	pCommand->AddChildCommand(CXTPChartSeriesView::CreateDeviceCommand(pDC));

	return pSeriesCommand;
}
CXTPChartPolygonDeviceCommand::CXTPChartPolygonDeviceCommand(const CXTPChartPoints& points)
{
	m_points.Copy(points);

	if (points.GetSize() != 0)
	{
		double xMax = points[0].X, xMin = points[0].X;
		double yMax = points[0].Y, yMin = points[0].Y;

		for (int i = 1; i < points.GetSize(); i++)
		{
			xMax = max(xMax, points[i].X);
			yMax = max(yMax, points[i].Y);
			xMin = min(xMin, points[i].X);
			yMin = min(yMin, points[i].Y);
		}

		m_bounds.X = (REAL)xMin;
		m_bounds.Y = (REAL)yMin;
		m_bounds.Width = (REAL)(xMax - xMin);
		m_bounds.Height = (REAL)(yMax - yMin);
	}
}
Exemplo n.º 10
0
CXTPChartDeviceCommand* CXTPChartMarker::CreateDeviceCommand(CXTPChartDeviceContext* pDC, const CXTPChartPointF& point, int nWidth, CXTPChartColor color, CXTPChartColor color2, CXTPChartColor colorBorder)
{
	if (!m_bVisible)
		return NULL;

	UNREFERENCED_PARAMETER(pDC);

	CXTPChartDeviceCommand* pCommand = new CXTPChartPolygonAntialiasingDeviceCommand();

	if (m_nType == xtpChartMarkerCircle)
	{
		pCommand->AddChildCommand(m_pFillStyle->CreateCircleDeviceCommand(point, nWidth / 2, color, color2));

		if (m_bBorderVisible)
		{
			pCommand->AddChildCommand(new CXTPChartBoundedCircleDeviceCommand(point, nWidth / 2, colorBorder, 1));
		}
	}
	else if (m_nType == xtpChartMarkerSquare)
	{
		CXTPChartPoints arrPoints;

		arrPoints.Add(CXTPChartPointF(point.X - nWidth / 2, point.Y - nWidth / 2));
		arrPoints.Add(CXTPChartPointF(point.X + nWidth / 2, point.Y - nWidth / 2));
		arrPoints.Add(CXTPChartPointF(point.X + nWidth / 2, point.Y + nWidth / 2));
		arrPoints.Add(CXTPChartPointF(point.X - nWidth / 2, point.Y + nWidth / 2));

		pCommand->AddChildCommand(m_pFillStyle->CreateDeviceCommand(arrPoints, color, color2));

		if (m_bBorderVisible)
		{
			pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, colorBorder, 1));
		}
	}
	else if (m_nType == xtpChartMarkerDiamond)
	{
		CXTPChartPoints arrPoints;

		float d = nWidth / (float)sqrt(2.0) - 1;

		arrPoints.Add(CXTPChartPointF(point.X - d, point.Y));
		arrPoints.Add(CXTPChartPointF(point.X, point.Y - d));
		arrPoints.Add(CXTPChartPointF(point.X + d, point.Y));
		arrPoints.Add(CXTPChartPointF(point.X, point.Y + d));

		pCommand->AddChildCommand(m_pFillStyle->CreateDeviceCommand(arrPoints, color, color2));

		if (m_bBorderVisible)
		{
			pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, colorBorder, 1));
		}
	}
	else if (m_nType == xtpChartMarkerTriangle || m_nType == xtpChartMarkerPentagon || m_nType == xtpChartMarkerHexagon)
	{
		int nSide = m_nType == xtpChartMarkerTriangle ? 3 : m_nType == xtpChartMarkerPentagon ? 5 : 6;

		CXTPChartPoints arrPoints;
		double d = nWidth / (float)sqrt(2.0) - 1;
		const double PI = acos(-1.0);

		for (int i = 0; i < nSide; i++)
		{
			arrPoints.Add(CXTPChartPointF(point.X + d * cos(PI / 2 + i * 2 * PI / nSide), point.Y - d * sin(PI / 2 + i * 2 * PI / nSide)));
		}

		pCommand->AddChildCommand(m_pFillStyle->CreateDeviceCommand(arrPoints, color, color2));

		if (m_bBorderVisible)
		{
			pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, colorBorder, 1));
		}

	}
	else if (m_nType == xtpChartMarkerStar)
	{
		int nSide = 5;

		CXTPChartPoints arrPoints;
		double d = nWidth / (float)sqrt(2.0) - 1;
		const double PI = acos(-1.0);

		double angle = 2 * PI / nSide;

		for (int i = 0; i < nSide; i++)
		{
			arrPoints.Add(CXTPChartPointF(point.X + d * cos(PI / 2 + i * angle), point.Y - d * sin(PI / 2 + i * angle)));

			arrPoints.Add(CXTPChartPointF(point.X + d / 2 * cos(PI / 2 + i * angle + angle/ 2), point.Y - d / 2 * sin(PI / 2 + i * angle + angle / 2)));
		}

		pCommand->AddChildCommand(m_pFillStyle->CreateDeviceCommand(arrPoints, color, color2));

		if (m_bBorderVisible)
		{
			pCommand->AddChildCommand(new CXTPChartBoundedPolygonDeviceCommand(arrPoints, colorBorder, 1));
		}

	}
	return pCommand;
}