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; }
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* CXTPChartHighLowSeriesPointView::CreateDeviceCommand(CXTPChartDeviceContext* pDC) { UNREFERENCED_PARAMETER(pDC); CPoint pointOpen = GetScreenPoint(chartOpen).Round(); CPoint pointClose = GetScreenPoint(chartClose).Round(); CPoint pointLow = GetScreenPoint(chartLow).Round(); CPoint pointHight = GetScreenPoint(chartHigh).Round(); BOOL bUpColor = TRUE; CXTPChartSeriesPoint* pPrevPoint = m_pPoint->GetPreviousPoint(); if (pPrevPoint) { if (pPrevPoint->GetValue(chartClose) > m_pPoint->GetValue(chartClose)) { bUpColor = FALSE; } } CXTPChartHighLowSeriesView* pView = (CXTPChartHighLowSeriesView*)GetSeriesView(); CXTPChartAxisView* pAxisView = pView->GetAxisViewX(); CXTPChartHighLowSeriesStyle* pStyle = (CXTPChartHighLowSeriesStyle*)GetSeriesView()->GetStyle(); int nWidth = (int)(pAxisView->DistanceToPoint(1) * 0.5); if (nWidth < 5) nWidth = 5; int nLineThickness = pStyle->GetLineThickness(); nWidth = (nWidth & ~1) + nLineThickness * 3; CXTPChartDeviceCommand* pCommand = new CXTPChartHitTestElementCommand(m_pPoint); CXTPChartColor color = bUpColor ? pStyle->GetUpColor() : pStyle->GetDownColor(); pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointHight), CXTPChartPointF(pointLow), color, nLineThickness)); pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointOpen), CXTPChartPointF((float)(pointOpen.x - nWidth / 2), (float)pointOpen.y), color, nLineThickness)); pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointClose), CXTPChartPointF((float)(pointClose.x + nWidth / 2), (float)pointClose.y), color, nLineThickness)); return pCommand; }
CXTPChartPointF CXTPChartRangeBarSeriesPointView::GetScreenPoint(BOOL bMinValue) const { CXTPChartRangeBarSeriesView* pSeriesView = (CXTPChartRangeBarSeriesView*)GetSeriesView(); CXTPChartRangeBarSeriesStyle* pSeriesStyle = (CXTPChartRangeBarSeriesStyle*)GetSeriesView()->GetStyle(); CXTPChartAxisView* pAxisXView = pSeriesView->GetAxisViewX(); if (pSeriesView->m_nBarIndex != -1) { int nCount = pSeriesView->m_nBarCount; int nIndex = pSeriesView->m_nBarIndex; double dOffset = (1 + pSeriesStyle->GetBarDistanceFixed()) / pAxisXView->GetScale(); double dRangeBarWidth = (pSeriesStyle->GetBarWidth() - dOffset * (nCount - 1)) / nCount; CXTPChartPointF pt(pSeriesView->GetScreenPoint(m_pPoint->GetInternalArgumentValue() - pSeriesStyle->GetBarWidth() / 2 + dRangeBarWidth / 2 + dRangeBarWidth * nIndex + dOffset * nIndex, m_pPoint->GetValue(bMinValue ? 0 : 1))); return pt; } return CXTPChartPointF(0, 0); }
CXTPChartDeviceCommand* CXTPChartHighLowSeriesView::CreateLegendDeviceCommand(CXTPChartDeviceContext* pDC, CRect rcBounds) { UNREFERENCED_PARAMETER(pDC); rcBounds.DeflateRect(1, 1); CXTPChartDeviceCommand* pCommand = new CXTPChartDeviceCommand(); CXTPChartHighLowSeriesStyle* pStyle = STATIC_DOWNCAST(CXTPChartHighLowSeriesStyle, m_pSeries->GetStyle()); CPoint ptCenter(rcBounds.CenterPoint().x, rcBounds.CenterPoint().y) ; for (int i = 0; i < 2; i++) { CXTPChartColor color = i == 0 ? pStyle->GetUpColor() : pStyle->GetDownColor(); int nHeight = rcBounds.Height() - 3; int x = i == 0 ? ptCenter.x - 4 : ptCenter.x + 4; int y = i == 0 ? rcBounds.top : rcBounds.top + 3; CPoint pointHight(x, y); CPoint pointLow(x, pointHight.y + nHeight); CPoint pointOpen(x, pointHight.y + nHeight / 3); CPoint pointClose(x, pointHight.y + nHeight * 2 / 3); int nWidth = 6; pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointHight), CXTPChartPointF(pointLow), color, 2)); pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointOpen), CXTPChartPointF((float)(pointOpen.x - nWidth / 2), (float)pointOpen.y), color, 2)); pCommand->AddChildCommand(new CXTPChartSolidLineDeviceCommand( CXTPChartPointF(pointClose), CXTPChartPointF((float)(pointClose.x + nWidth / 2), (float)pointClose.y), color, 2)); } return pCommand; }
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; }