Esempio n. 1
0
void CChartPointsSerie::Draw(CDC *pDC)
{
	if (!m_bIsVisible)
		return;
	if (!pDC->GetSafeHdc())
		return;

	CBrush NewBrush(m_SerieColor);
	CPen BorderPen(PS_SOLID, 1, m_colBorder);
	CBrush ShadowBrush(m_ShadowColor);
	CPen ShadowPen(PS_SOLID, 1, m_ShadowColor);
	CPen* pOldPen = pDC->SelectObject(&BorderPen);
	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	pDC->SetBkMode(TRANSPARENT);
	//To have lines limited in the drawing rectangle :
	pDC->IntersectClipRect(m_PlottingRect);

	//Draw all points that haven't been drawn yet
	for (m_uLastDrawnPoint;m_uLastDrawnPoint<(int)GetPointsCount();m_uLastDrawnPoint++)
	{
		SChartXYPoint Point = GetPoint(m_uLastDrawnPoint);
		CPoint ScreenPoint;
		ValueToScreen(Point.X, Point.Y, ScreenPoint);

		CRect PointRect;
		PointRect.SetRect(ScreenPoint.x-m_iXPointSize/2,ScreenPoint.y-m_iYPointSize/2,ScreenPoint.x+m_iXPointSize/2,ScreenPoint.y+m_iYPointSize/2);
		CRect ShadowRect = PointRect + CSize(m_iShadowDepth,m_iShadowDepth);

		switch(m_iPointType)
		{
		case ptEllipse:
			if (m_bShadow)
			{
				pOldPen = pDC->SelectObject(&ShadowPen);
				pDC->SelectObject(&ShadowBrush);
				pDC->Ellipse(ShadowRect);
				pDC->SelectObject(&NewBrush);
				pDC->SelectObject(&BorderPen);
			}
			pDC->Ellipse(PointRect);
			break;

		case ptRectangle:
			if (m_bShadow)
			{
				pOldPen = pDC->SelectObject(&ShadowPen);
				pDC->SelectObject(&ShadowBrush);
				pDC->Rectangle(ShadowRect);
				pDC->SelectObject(&NewBrush);
				pDC->SelectObject(&BorderPen);
			}
			pDC->Rectangle(PointRect);
			break;

		case ptTriangle:
			{
				CPoint TrPoints[3];
				TrPoints[0].x = PointRect.left;
				TrPoints[0].y = PointRect.bottom;
				TrPoints[1].x = PointRect.right;
				TrPoints[1].y = PointRect.bottom;
				TrPoints[2].x = PointRect.left + (int)fabs((PointRect.left-PointRect.right)/2.0);
				TrPoints[2].y = PointRect.top;

				if (m_bShadow)
				{
					CPoint ShadowPoints[3];
					for (int i=0;i<3;i++)
					{
						ShadowPoints[i] = TrPoints[i] + CSize(m_iShadowDepth,m_iShadowDepth);
					}

					pOldPen = pDC->SelectObject(&ShadowPen);
					pDC->SelectObject(&ShadowBrush);
					pDC->Polygon(ShadowPoints,3);
					pDC->SelectObject(&NewBrush);
					pDC->SelectObject(&BorderPen);
				}
				pDC->Polygon(TrPoints,3);
			}
			break;
		}

	}

	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldPen);
	pDC->SelectObject(pOldBrush);
	DeleteObject(BorderPen);
	DeleteObject(NewBrush);
	DeleteObject(ShadowBrush);
	DeleteObject(ShadowPen);
}
Esempio n. 2
0
void CChartPointsSerie::DrawAll(CDC *pDC)
{
    if (!m_bIsVisible)
        return;

    CBrush NewBrush(m_ObjectColor);
    CBrush ShadowBrush(m_ShadowColor);
    CPen ShadowPen(PS_SOLID,1,m_ShadowColor);
    CPen* pOldPen;
    CBrush* pOldBrush;

    int iFirst=0, iLast=0;
    GetVisiblePoints(iFirst,iLast);

    if (pDC->GetSafeHdc())
    {
        pDC->SetBkMode(TRANSPARENT);
        //To have lines limited in the drawing rectangle :
        pDC->IntersectClipRect(m_ObjectRect);
        pOldBrush = pDC->SelectObject(&NewBrush);

        for (m_iLastDrawnPoint=iFirst;m_iLastDrawnPoint<=iLast;m_iLastDrawnPoint++)
        {
            CPoint ScreenPoint;
            ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint);

            CRect PointRect;
            PointRect.SetRect(ScreenPoint.x-m_iXPointSize/2,ScreenPoint.y-m_iYPointSize/2,ScreenPoint.x+m_iXPointSize/2,ScreenPoint.y+m_iYPointSize/2);
            CRect ShadowRect = PointRect + CSize(m_iShadowDepth,m_iShadowDepth);

            switch(m_iPointType)
            {
            case ptEllipse:
                if (m_bShadow)
                {
                    pOldPen = pDC->SelectObject(&ShadowPen);
                    pDC->SelectObject(&ShadowBrush);
                    pDC->Ellipse(ShadowRect);
                    pDC->SelectObject(&NewBrush);
                    pDC->SelectObject(pOldPen);
                }
                pDC->Ellipse(PointRect);
                break;

            case ptRectangle:
                if (m_bShadow)
                {
                    pOldPen = pDC->SelectObject(&ShadowPen);
                    pDC->SelectObject(&ShadowBrush);
                    pDC->Rectangle(ShadowRect);
                    pDC->SelectObject(&NewBrush);
                    pDC->SelectObject(pOldPen);
                }
                pDC->Rectangle(PointRect);
                break;

            case ptTriangle:
                {
                    CPoint TrPoints[3];
                    TrPoints[0].x = PointRect.left;
                    TrPoints[0].y = PointRect.bottom;
                    TrPoints[1].x = PointRect.right;
                    TrPoints[1].y = PointRect.bottom;
                    TrPoints[2].x = PointRect.left + (int)fabs((PointRect.left-PointRect.right)/2.0);
                    TrPoints[2].y = PointRect.top;

                    if (m_bShadow)
                    {
                        CPoint ShadowPoints[3];
                        for (int i=0;i<3;i++)
                        {
                            ShadowPoints[i] = TrPoints[i] + CSize(m_iShadowDepth,m_iShadowDepth);
                        }

                        pOldPen = pDC->SelectObject(&ShadowPen);
                        pDC->SelectObject(&ShadowBrush);
                        pDC->Polygon(ShadowPoints,3);
                        pDC->SelectObject(&NewBrush);
                        pDC->SelectObject(pOldPen);
                    }
                    pDC->Polygon(TrPoints,3);
                }
                break;
            }
        }

        pDC->SelectClipRgn(NULL);
        pDC->SelectObject(pOldBrush);
        DeleteObject(NewBrush);
    }
}