Ejemplo n.º 1
0
void CChartLineSerie::Draw(CDC* pDC)
{
    if (!m_bIsVisible)
        return;

    // If shadow is enabled, the all series must be redrawn.
    if (m_bShadow)
    {
        DrawAll(pDC);
        return;
    }

    if (pDC->GetSafeHdc())
    {
        CPen NewPen;
        if (m_iPenStyle != PS_SOLID)
        {
            LOGBRUSH lb;
            lb.lbStyle = BS_SOLID;
            lb.lbColor = m_ObjectColor;
            NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
        }
        else
        {
            NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ObjectColor);
        }
        CPen* pOldPen;

        pDC->SetBkMode(TRANSPARENT);
        //To have lines limited in the drawing rectangle :
        pDC->IntersectClipRect(m_ObjectRect);
        pOldPen = pDC->SelectObject(&NewPen);

        //Draw all points that haven't been drawn yet
        for (m_iLastDrawnPoint;m_iLastDrawnPoint<(int)GetPointsCount()-1;m_iLastDrawnPoint++)
        {
            //We don't draw a line between the origin and the first point -> we must have
            // a least 2 points before begining drawing
        //  if (m_vPoints<1)
        //      break;

            CPoint ScreenPoint;
            ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint);
            pDC->MoveTo(ScreenPoint.x,ScreenPoint.y);

            ValueToScreen(m_vPoints[m_iLastDrawnPoint+1].X,m_vPoints[m_iLastDrawnPoint+1].Y,ScreenPoint);
            pDC->LineTo(ScreenPoint.x,ScreenPoint.y);
        }

        pDC->SelectClipRgn(NULL);
        pDC->SelectObject(pOldPen);
        DeleteObject(NewPen);
    }
}
Ejemplo n.º 2
0
void CChartLineSerie::Draw(CDC* pDC)
{
	if (!m_bIsVisible)
		return;

	// If shadow or smooth is enabled, then the complete series
	// must be redrawn.
	if (m_bShadow || m_bSmooth)
	{
		DrawAll(pDC);
		return;
	}

	if (pDC->GetSafeHdc())
	{
		CPen NewPen;
		if (m_iPenStyle != PS_SOLID)
		{
			LOGBRUSH lb;
			lb.lbStyle = BS_SOLID;
			lb.lbColor = m_SerieColor;
			NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
		}
		else
		{
			NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_SerieColor);
		}
		CPen* pOldPen;

		pDC->SetBkMode(TRANSPARENT);
		//To have lines limited in the drawing rectangle :
		pDC->IntersectClipRect(m_pParentCtrl->GetPlottingRect());
		pOldPen = pDC->SelectObject(&NewPen);

		//Draw all points that haven't been drawn yet
		for (m_uLastDrawnPoint;m_uLastDrawnPoint<GetPointsCount()-1;m_uLastDrawnPoint++)
		{
			SChartXYPoint Point = GetPoint(m_uLastDrawnPoint);
			CPoint ScreenPoint;
			ValueToScreen(Point.X, Point.Y, ScreenPoint);
			pDC->MoveTo(ScreenPoint.x,ScreenPoint.y);

			Point = GetPoint(m_uLastDrawnPoint+1);
			ValueToScreen(Point.X, Point.Y, ScreenPoint);
			pDC->LineTo(ScreenPoint.x,ScreenPoint.y);
		}

		pDC->SelectClipRgn(NULL);
		pDC->SelectObject(pOldPen);
		DeleteObject(NewPen);
	}
}
Ejemplo n.º 3
0
bool CChartPointsSerie::IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const 
{ 
	uIndex = INVALID_POINT;
	if (!m_bIsVisible)
        return false;

	unsigned uFirst=0, uLast=0;
	if (!GetVisiblePoints(uFirst, uLast))
		return false;

	bool bResult = false;
	for (unsigned i=uFirst ; i < uLast ; i++)
	{
		SChartXYPoint Point = GetPoint(i);
		CPoint ValuePoint;
		ValueToScreen(Point.X, Point.Y, ValuePoint);

		int xDist = abs(screenPoint.x - ValuePoint.x);
		int yDist = abs(screenPoint.y - ValuePoint.y);
		if (xDist<=5 && yDist<=5)
		{
			uIndex = i;
			bResult = true;
			break;
		}
    }
    return bResult;
}
Ejemplo n.º 4
0
int		LinkTimeControl::HitTestFCurves( ParamDimensionBase *dim, TrackHitTab& hits, Rect& rcHit, Rect& rcGraph,			
			float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags )
{
	int h = rcGraph.h()-1;

	bool hit = false;

	const int n = NumKeys();
	for ( int i=0; i<n; ++i )
	{
		BOOL sel = IsKeySelected( i );
		if ( ( flags & HITTRACK_SELONLY ) && !sel )
			continue;
		if ( ( flags & HITTRACK_UNSELONLY ) && sel )
			continue;
		TimeValue t = GetKeyTime( i );
		int x = TimeToScreen( t, tzoom, tscroll );
		float val;
		Interval valid;
		GetValue( t, &val, valid );
		int y = ValueToScreen( dim->Convert(val), h, vzoom, vscroll );
		if ( rcHit.Contains( IPoint2( x, y ) ) )
		{
			hit = true;
			TrackHitRecord rec( i, 0 );
			hits.Append( 1, &rec );
			if ( flags & HITTRACK_ABORTONHIT )
				break;
		}
	}

	return hit ?  HITCURVE_KEY : HITCURVE_NONE;
}
Ejemplo n.º 5
0
void CChartPointsSerie::Draw(CDC *pDC)
{
	if (!m_bIsVisible)
		return;

	CBrush NewBrush(m_ObjectColor);
	CBrush* pOldBrush;

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

		//Draw all points that haven't been drawn yet
		for (m_iLastDrawnPoint;m_iLastDrawnPoint<(int)m_vPoints.size();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);

			switch(m_iPointType)
			{
			case ptEllipse:
				pDC->Ellipse(PointRect);
				break;

			case ptRectangle:
				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;

					pDC->Polygon(TrPoints,3);
				}
				break;
			}
		}

		pDC->SelectClipRgn(NULL);
		pDC->SelectObject(pOldBrush);
	}
}
Ejemplo n.º 6
0
bool CChartLineSerie::IsPointOnSerie(const CPoint& screenPoint, unsigned& uIndex) const
{
	uIndex = INVALID_POINT;
	if (!m_bIsVisible)
        return false;

	unsigned uFirst=0, uLast=0;
	if (!GetVisiblePoints(uFirst, uLast))
		return false;
	if (uFirst>0)
		uFirst--;
	if (uLast<GetPointsCount()-1)
		uLast++;

	bool bResult = false;
	for (unsigned i=uFirst ; i < uLast ; i++)
	{
		SChartXYPoint PointOrig = GetPoint(i);
		SChartXYPoint PointDest = GetPoint(i+1);
		CPoint ScreenPointOrig, ScreenPointDest;
		ValueToScreen(PointOrig.X, PointOrig.Y, ScreenPointOrig);
		ValueToScreen(PointDest.X, PointDest.Y, ScreenPointDest);

		if (IsNearLine(ScreenPointOrig.x, ScreenPointOrig.y, ScreenPointDest.x, ScreenPointDest.y, screenPoint.x, screenPoint.y))
		{
			// Check if the click is close to one of the two points.
			int xDist = abs(screenPoint.x - ScreenPointOrig.x);
			int yDist = abs(screenPoint.y - ScreenPointOrig.y);
			if (xDist<=5 && yDist<=5)
				uIndex = i;
			xDist = abs(screenPoint.x - ScreenPointDest.x);
			yDist = abs(screenPoint.y - ScreenPointDest.y);
			if (xDist<=5 && yDist<=5)
				uIndex = i+1;

			bResult = true;
			break;
		}
    }
    return bResult;
}
Ejemplo n.º 7
0
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
	size_t count = m_vPoints.size();
	CPoint* pPoints = new CPoint[count+2];

	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	for (size_t i=0; i<count; i++)
	{
		ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i+1]);
	}

	if (m_bHorizontal)
	{
		pPoints[0].x = pPoints[1].x;
		pPoints[count+1].x = pPoints[count].x;

		float Position = m_pHorizontalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));

		pPoints[0].y = AxisPos;
		pPoints[count+1].y = AxisPos;
	}
	else
	{
		pPoints[0].y = pPoints[1].y;
		pPoints[count+1].y = pPoints[count].y;

		float Position = m_pVerticalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));

		pPoints[0].x = AxisPos;
		pPoints[count+1].x = AxisPos;
	}

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

	pDC->Polygon(pPoints,count+2);
	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);

	delete[] pPoints;
}
Ejemplo n.º 8
0
void CChartSurfaceSerie::DrawAll(CDC* pDC)
{
	int iFirst=0, iLast=0;
	GetVisiblePoints(iFirst,iLast);

	if (iFirst>0)
		iFirst--;
	if (iLast<(int)GetPointsCount())
		iLast++;
	int iCount = iLast - iFirst;
	CPoint* pPoints = new CPoint[iCount+2];

	CBrush NewBrush;
	if (m_FillStyle == fsSolid)
		NewBrush.CreateSolidBrush(m_ObjectColor);
	else
	{
		int nIndex = 0;
		switch (m_FillStyle)
		{
		case fsHatchDownDiag:
			nIndex = HS_FDIAGONAL;
			break;
		case fsHatchUpDiag:
			nIndex = HS_BDIAGONAL;
			break;
		case fsHatchCross:
			nIndex = HS_CROSS;
			break;
		case fsHatchDiagCross:
			nIndex = HS_DIAGCROSS;
			break;
		case fsHatchHorizontal:
			nIndex = HS_HORIZONTAL;
			break;
		case fsHatchVertical:
			nIndex = HS_VERTICAL;
			break;
		}
		NewBrush.CreateHatchBrush(nIndex,m_ObjectColor);
	}

	CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

	for (int i=iFirst; i<iLast; i++)
	{
		ValueToScreen(m_vPoints[i].X,m_vPoints[i].Y,pPoints[i-iFirst+1]);
	}

	if (m_bHorizontal)
	{
		pPoints[0].x = pPoints[1].x;
		pPoints[iCount+1].x = pPoints[iCount].x;

		double Position = m_pHorizontalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.top + (int)(Position * (m_ObjectRect.bottom-m_ObjectRect.top));

		pPoints[0].y = AxisPos;
		pPoints[iCount+1].y = AxisPos;
	}
	else
	{
		pPoints[0].y = pPoints[1].y;
		pPoints[iCount+1].y = pPoints[iCount].y;

		double Position = m_pVerticalAxis->GetPosition()/100.00;
		int AxisPos = m_ObjectRect.left + (int)(Position * (m_ObjectRect.right-m_ObjectRect.left));

		pPoints[0].x = AxisPos;
		pPoints[iCount+1].x = AxisPos;
	}

	pDC->SetBkMode(TRANSPARENT);
	//To have lines limited in the drawing rectangle :
	CRect TempClipRect(m_ObjectRect);
	TempClipRect.DeflateRect(1,1);
	pDC->SetBkMode(TRANSPARENT);
	pDC->IntersectClipRect(TempClipRect);

	pDC->Polygon(pPoints,iCount+2);
	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldBrush);
	DeleteObject(NewBrush);

	delete[] pPoints;
}
Ejemplo n.º 9
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);
}
Ejemplo n.º 10
0
int		LinkTimeControl::PaintFCurves( ParamDimensionBase *dim, HDC hdc, Rect& rcGraph, Rect& rcPaint,
			float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags )
{
	const int n = NumKeys();
	if ( n == 0 )
		return 0;

	Interval valid;
	int h = rcGraph.h()-1;
	HPEN dpen,spen;
	BOOL init=FALSE;		
	Interval range = GetTimeRange(TIMERANGE_ALL);	
	SetBkMode(hdc,TRANSPARENT);	

	dpen = CreatePen(PS_DOT,0,GetColorManager()->GetColor(kFunctionCurveFloat));
	spen = CreatePen(PS_SOLID,0,GetColorManager()->GetColor(kFunctionCurveFloat));

	SIZE size;
	GetTextExtentPoint( hdc, _T("0"), 1, &size );

	float val;
	TimeValue leftTime = ScreenToTime(rcPaint.left,tzoom,tscroll);
	TimeValue rightTime = ScreenToTime(rcPaint.right,tzoom,tscroll);
	int x, y;

	// dotted line to left of keys
	if ( leftTime < range.Start() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.Start(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,rcPaint.left,y,NULL);
		LineTo(hdc,TimeToScreen(range.Start(),tzoom,tscroll),y);
	}

	SelectObject(hdc,spen);

	// first node text
	{
		TimeValue t = GetKeyTime( 0 );
		if ( t >= leftTime && t <= rightTime )
		{
			GetValue(t,&val,valid);
			y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
			x = TimeToScreen(t,tzoom,tscroll);
			INode* node = fOwner->GetNode( 0 );
			DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
		}
	}

	// solid line between keys
	for ( int i=1; i<n; ++i )
	{
		TimeValue t0 = GetKeyTime( i-1 );
		TimeValue t1 = GetKeyTime( i );
		if ( t1 < leftTime || t0 > rightTime )
			continue;
		GetValue(t0,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(t0,tzoom,tscroll),y,NULL);
		x = TimeToScreen(t1,tzoom,tscroll);
		LineTo(hdc,x,y);
		GetValue(t1,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		LineTo(hdc,x,y);

		INode* node = fOwner->GetNode( i );
		DLTextOut( hdc, x, y-1-size.cy, node ? node->GetName() : _T("World") );
	}

	// dotted line to right of keys
	if ( rightTime > range.End() )
	{
		SelectObject(hdc,dpen);
		GetValue(range.End(),&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		MoveToEx(hdc,TimeToScreen(range.End(),tzoom,tscroll),y,NULL);
		LineTo(hdc,rcPaint.right,y);
	}

	SelectObject( hdc, spen );
	HBRUSH hUnselBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarKeys));
	HBRUSH hSelBrush = CreateSolidBrush(GetColorManager()->GetColor(kTrackbarSelKeys));

	// render keys themselves
	for ( int i=0; i<n; ++i )
	{
		TimeValue t = GetKeyTime( i );
		if ( t < leftTime || t > rightTime )
			continue;
		GetValue(t,&val,valid);
		y = ValueToScreen(dim->Convert(val),h,vzoom,vscroll);
		x = TimeToScreen(t,tzoom,tscroll);
		SelectObject( hdc, IsKeySelected( i ) ? hSelBrush : hUnselBrush );
		Rectangle(hdc,x-3,y-3,x+3,y+3);
	}

	SetBkMode(hdc,OPAQUE);
	SelectObject(hdc,GetStockObject(BLACK_PEN));	

	DeleteObject(spen);
	DeleteObject(dpen);
	DeleteObject(hUnselBrush);
	DeleteObject(hSelBrush);

	return 0;
}
Ejemplo n.º 11
0
void CChartLineSerie::DrawAll(CDC *pDC)
{
	if (!m_bIsVisible)
		return;
	if (!pDC->GetSafeHdc())
		return;

	unsigned uFirst=0, uLast=0;
	if (!GetVisiblePoints(uFirst,uLast))
		return;

	if (uFirst>0)
		uFirst--;
	if (uLast<GetPointsCount()-1)
		uLast++;
	if (uLast-uFirst < 1)
		return;

	CPen NewPen;
	CPen ShadowPen;
	if (m_iPenStyle != PS_SOLID)
	{
		LOGBRUSH lb;
		lb.lbStyle = BS_SOLID;
		lb.lbColor = m_SerieColor;
		NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
		lb.lbColor = m_ShadowColor;
		ShadowPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
	}
	else
	{
		NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_SerieColor);
		ShadowPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ShadowColor);
	}
	CPen* pOldPen;

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

	if (m_bSmooth)
	{
		// For a Bezier curve, all points must be drawn.
		uFirst = 0;
		uLast = GetPointsCount() - 1;
		SChartXYPoint* pKnots = NULL;
		SChartXYPoint* pFirstControlPts = NULL;
		SChartXYPoint* pSecondControlPts = NULL;
		GetBezierControlPoints(uFirst,uLast,pKnots,pFirstControlPts,pSecondControlPts);

		unsigned Count = uLast - uFirst;
		CPoint* pBezierPts = new CPoint[3*(Count-1)+1];
		CPoint* pShadowPts = NULL;
		if (m_bShadow)
			pShadowPts = new CPoint[3*(Count-1)+1];

		unsigned index = 0;
		for (unsigned n=0; n<Count-1; n++)
		{
			ValueToScreen(pKnots[n].X, pKnots[n].Y, pBezierPts[index]);
			ValueToScreen(pFirstControlPts[n].X, pFirstControlPts[n].Y, pBezierPts[index+1]);
			ValueToScreen(pSecondControlPts[n].X, pSecondControlPts[n].Y, pBezierPts[index+2]);

			if (m_bShadow)
			{
				pShadowPts[index] = pBezierPts[index];
				pShadowPts[index].Offset(m_iShadowDepth,m_iShadowDepth);
				pShadowPts[index+1] = pBezierPts[index+1];
				pShadowPts[index+1].Offset(m_iShadowDepth,m_iShadowDepth);
				pShadowPts[index+2] = pBezierPts[index+2];
				pShadowPts[index+2].Offset(m_iShadowDepth,m_iShadowDepth);
			}
			index += 3;
		}
		ValueToScreen(pKnots[Count-1].X, pKnots[Count-1].Y, pBezierPts[index]);
		if (m_bShadow)
		{
			pShadowPts[index] = pBezierPts[index];
			pShadowPts[index].Offset(m_iShadowDepth,m_iShadowDepth);
			pDC->SelectObject(&ShadowPen);
			pDC->PolyBezier(pShadowPts,3*(Count-1)+1);
			pDC->SelectObject(&NewPen);
			delete[] pShadowPts;
		}
		pDC->PolyBezier(pBezierPts,3*(Count-1)+1);

		delete[] pKnots;
		delete[] pFirstControlPts;
		delete[] pSecondControlPts;
		delete[] pBezierPts;
	}
	else	// Non-smoothed curve
	{
		if (uLast-uFirst >= 1)
		{
			CPoint* pPoints = new CPoint[uLast-uFirst+1];
			CPoint* pShadow = NULL;
			if (m_bShadow)
				pShadow = new CPoint[uLast-uFirst+1];

			unsigned long pointsCount = 0;
			CPoint LastScreenPoint;
			for (m_uLastDrawnPoint=uFirst;m_uLastDrawnPoint<=uLast;m_uLastDrawnPoint++)
			{
				//We don't draw a line between the origin and the first point -> we must have
				// a least 2 points before begining drawing
				SChartXYPoint Point = GetPoint(m_uLastDrawnPoint);
				CPoint ScreenPoint;
				ValueToScreen(Point.X, Point.Y, ScreenPoint);

				if(LastScreenPoint != ScreenPoint)
				{
					//Only collate the unique points
					pPoints[pointsCount] = ScreenPoint;
					LastScreenPoint = ScreenPoint;

					if (m_bShadow)
					{
						ScreenPoint.Offset(m_iShadowDepth,m_iShadowDepth);
						pShadow[pointsCount] = ScreenPoint;
					}
					pointsCount++;
				}
			}

			// We have to do that in order for the Draw function to work properly.
			m_uLastDrawnPoint--;
			if (m_bShadow)
			{
				pDC->SelectObject(&ShadowPen);
				pDC->Polyline(pShadow, pointsCount);
			}
			pDC->SelectObject(&NewPen);
			pDC->Polyline(pPoints, pointsCount);

			delete[] pPoints;
			delete[] pShadow;
		}
	}

	pDC->SelectClipRgn(NULL);
	pDC->SelectObject(pOldPen);
	NewPen.DeleteObject();
	ShadowPen.DeleteObject();
}
Ejemplo n.º 12
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);
    }
}
Ejemplo n.º 13
0
void CChartLineSerie::DrawAll(CDC *pDC)
{
    if (!m_bIsVisible)
        return;

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

    if (iFirst>0)
        iFirst--;
    if (iLast<(int)GetPointsCount()-1)
        iLast++;
    if (pDC->GetSafeHdc())
    {
        CPen NewPen;
        CPen ShadowPen;
        if (m_iPenStyle != PS_SOLID)
        {
            LOGBRUSH lb;
            lb.lbStyle = BS_SOLID;
            lb.lbColor = m_ObjectColor;
            NewPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
            lb.lbColor = m_ShadowColor;
            ShadowPen.CreatePen(PS_GEOMETRIC | m_iPenStyle, m_iLineWidth, &lb);
        }
        else
        {
            NewPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ObjectColor);
            ShadowPen.CreatePen(m_iPenStyle, m_iLineWidth, m_ShadowColor);
        }
        CPen* pOldPen;

        pDC->SetBkMode(TRANSPARENT);
        //To have lines limited in the drawing rectangle :
        pDC->IntersectClipRect(m_ObjectRect);
        pOldPen = pDC->SelectObject(&NewPen);

        for (m_iLastDrawnPoint=iFirst;m_iLastDrawnPoint<iLast;m_iLastDrawnPoint++)
        {
            //We don't draw a line between the origin and the first point -> we must have
            // a least 2 points before begining drawing

            CPoint ScreenPoint;

            if (m_bShadow)
            {
                pDC->SelectObject(&ShadowPen);
                ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint);
                pDC->MoveTo(ScreenPoint.x+m_iShadowDepth,ScreenPoint.y+m_iShadowDepth);
                ValueToScreen(m_vPoints[m_iLastDrawnPoint+1].X,m_vPoints[m_iLastDrawnPoint+1].Y,ScreenPoint);
                pDC->LineTo(ScreenPoint.x+m_iShadowDepth,ScreenPoint.y+m_iShadowDepth);

                pDC->SelectObject(&NewPen);
            }

            ValueToScreen(m_vPoints[m_iLastDrawnPoint].X,m_vPoints[m_iLastDrawnPoint].Y,ScreenPoint);
            pDC->MoveTo(ScreenPoint.x,ScreenPoint.y);
            ValueToScreen(m_vPoints[m_iLastDrawnPoint+1].X,m_vPoints[m_iLastDrawnPoint+1].Y,ScreenPoint);
            pDC->LineTo(ScreenPoint.x,ScreenPoint.y);
        }

        pDC->SelectClipRgn(NULL);
        pDC->SelectObject(pOldPen);
        NewPen.DeleteObject();
        ShadowPen.DeleteObject();
    }
}