Esempio n. 1
0
void CArcUnit::ErasedDraw(CDC *memDC,DataInfo &pDataInfo, HRGN ErasedRgn)
{
	CRect rect;
	CPoint sPoint,ePoint;
	int Red,Green,Blue;
	Red=GetRValue(pDataInfo.penColor);
	Green=GetGValue(pDataInfo.penColor);
	Blue=GetBValue(pDataInfo.penColor);
	sPoint=CaculatePoint(pDataInfo.StartPoint,pDataInfo);
	ePoint=CaculatePoint(pDataInfo.EndPoint,pDataInfo);
	Graphics mGraphics(memDC->m_hDC);
	///////////////////////////////////
	Matrix matrix;
	Region tRgn;
	Region *ptRgn=tRgn.FromHRGN(ErasedRgn);	
	mGraphics.ExcludeClip(ptRgn);
	matrix.Reset();
	delete ptRgn;
	////////////////////////////////////
	mGraphics.TranslateTransform(pDataInfo.CenterPoint.x,pDataInfo.CenterPoint.y);
	mGraphics.RotateTransform(pDataInfo.RotateAngle);
	mGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
	Pen mPen(Color(255,Red,Green,Blue),pDataInfo.penWidth);
	SetLineStyle(mPen,pDataInfo.LineStyle);
	if(int(pDataInfo.startAngle)==270&&int(pDataInfo.sweepAngle)==90)
	{
		rect.left=2*sPoint.x-ePoint.x;
		rect.top=sPoint.y;
		rect.right=ePoint.x;
		rect.bottom=2*ePoint.y-sPoint.y;
	}
	if(int(pDataInfo.startAngle)==270&&int(pDataInfo.sweepAngle)==-90)
	{
		rect.left=sPoint.x;
		rect.top=sPoint.y;
		rect.right=2*ePoint.x-sPoint.x;
		rect.bottom=2*ePoint.y-sPoint.y;
	}
	if(int(pDataInfo.startAngle)==90&&int(pDataInfo.sweepAngle)==90)
	{
		rect.left=sPoint.x;
		rect.top=2*sPoint.y-ePoint.y;
		rect.right=2*ePoint.x-sPoint.x;
		rect.bottom=ePoint.y;
	}
	if(int(pDataInfo.startAngle)==90&&int(pDataInfo.sweepAngle)==-90)
	{
		rect.left=2*sPoint.x-ePoint.x;
		rect.top=2*sPoint.y-ePoint.y;
		rect.right=ePoint.x;
		rect.bottom=ePoint.y;
	}
	mGraphics.DrawArc(&mPen,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,pDataInfo.startAngle,pDataInfo.sweepAngle);
	mGraphics.ResetTransform();	
}
Esempio n. 2
0
void CArcUnit::ReDraw(CDC* memDC,DataInfo &pDataInfo)
{
	CPoint sPoint,ePoint;
	int Red,Green,Blue;
	Red=GetRValue(pDataInfo.penColor);
	Green=GetGValue(pDataInfo.penColor);
	Blue=GetBValue(pDataInfo.penColor);
	sPoint=CaculatePoint(pDataInfo.StartPoint,pDataInfo);
	ePoint=CaculatePoint(pDataInfo.EndPoint,pDataInfo);
	Graphics mGraphics(memDC->m_hDC);
	mGraphics.TranslateTransform(pDataInfo.CenterPoint.x,pDataInfo.CenterPoint.y);
	mGraphics.RotateTransform(pDataInfo.RotateAngle);
	mGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
	mGraphics.ScaleTransform(pDataInfo.xScale,pDataInfo.yScale);
	///////////////////////////////////
	Region tRgn;
	Region *ptRgn=tRgn.FromHRGN(pDataInfo.hRgn);
	if(ptRgn != NULL)
	mGraphics.ExcludeClip(ptRgn);	
	delete ptRgn;
	////////////////////////////////////
	Pen mPen(Color(255,Red,Green,Blue),pDataInfo.penWidth);
	SetLineStyle(mPen,pDataInfo.LineStyle);
	float dx,dy;
	dx=ePoint.x-sPoint.y;
	dy=ePoint.y-sPoint.y;
	CPoint ptCenter,ptRadius;
	ptCenter.x=sPoint.x+dx*pDataInfo.AllRate[0].xRate;
	ptCenter.y=sPoint.y+dy*pDataInfo.AllRate[0].yRate;
	ptRadius.x=sPoint.x+dx*pDataInfo.AllRate[1].xRate;
	ptRadius.y=sPoint.y+dy*pDataInfo.AllRate[1].yRate;
	dx=ptRadius.x-ptCenter.x;
	dy=ptRadius.y-ptCenter.y;
	float Radius=sqrt(dx*dx+dy*dy);
	CRect rect(ptCenter.x-Radius,ptCenter.y-Radius,ptCenter.x+Radius,ptCenter.y+Radius);
	//pDataInfo.startAngle = 0;
	//pDataInfo.sweepAngle = 90;
	mGraphics.DrawArc(&mPen,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,pDataInfo.startAngle,pDataInfo.sweepAngle);
	//mGraphics.DrawPie(&mPen,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,pDataInfo.startAngle,pDataInfo.sweepAngle);
	mGraphics.ResetTransform();
}
void CPenBrushUnit::ReDraw(CDC* memDC,DataInfo &pDataInfo)
{
	CPoint sPoint,ePoint,psPoint,pePoint,ptPoint;	
	double dx,dy,xlen,ylen;
	double preWidth,nWidth;
	Matrix matrix;
	int count=1;
	int alpha;
	int v=0;
	int Red,Green,Blue;
	Red=GetRValue(pDataInfo.penColor);
	Green=GetGValue(pDataInfo.penColor);
	Blue=GetBValue(pDataInfo.penColor);
	SolidBrush brush(Color(255,Red,Green,Blue));
	SolidBrush brush1(Color(200,Red,Green,Blue));
	Graphics mGraphics(memDC->m_hDC);
	mGraphics.TranslateTransform(pDataInfo.CenterPoint.x,pDataInfo.CenterPoint.y);
	mGraphics.RotateTransform(pDataInfo.RotateAngle);
	mGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
	mGraphics.ScaleTransform(pDataInfo.xScale,pDataInfo.yScale);
	///////////////////////////////////
	Region tRgn;
	Region *ptRgn=tRgn.FromHRGN(pDataInfo.hRgn);
	if(ptRgn != NULL)
	mGraphics.ExcludeClip(ptRgn);	
	delete ptRgn;
	////////////////////////////////////
	int Size=pDataInfo.AllRate.size();
	sPoint=CaculatePoint(pDataInfo.StartPoint,pDataInfo);
	ePoint=CaculatePoint(pDataInfo.EndPoint,pDataInfo);
	xlen=ePoint.x-sPoint.x;
	ylen=ePoint.y-sPoint.y;
	if(xlen<1)
		xlen=1;
	if(ylen<1)
		ylen=1;
	if(fwidth.size()!=0)
		fwidth.clear();
	fwidth.insert(std::map<DWORD,float>::value_type(0,pDataInfo.AllRate[0].preWidth));
	alpha=pDataInfo.AllRate[0].alpha;

	psPoint.x=sPoint.x+xlen*pDataInfo.AllRate[0].xRate;
	psPoint.y=sPoint.y+ylen*pDataInfo.AllRate[0].yRate;
	for(int Index=1;Index<Size;Index++)	
	{
		pePoint.x=sPoint.x+xlen*pDataInfo.AllRate[Index].xRate;
		pePoint.y=sPoint.y+ylen*pDataInfo.AllRate[Index].yRate;

		if(Index==1)
			PushStart(psPoint,0);
		if(Push(psPoint,pePoint,0))
		{
			RectF headRect;
			RectF tailRect;
			float width,dx,dy;
			PointF lfCenter,rtCenter;
			mGraphics.FillPolygon(&brush,pts,npts);
			mGraphics.DrawPolygon(&Pen(Color(200,Red,Green,Blue),1),pts,npts);
			if(npts==4)
			{
				headRect=RectF((pts[0].X+pts[3].X)/2.0f,(pts[0].Y+pts[3].Y)/2.0f,0.0f,0.0f);
				tailRect=RectF((pts[1].X+pts[2].X)/2.0f,(pts[1].Y+pts[2].Y)/2.0f,0.0f,0.0f);
				dx=pts[3].X-pts[0].X;
				dy=pts[3].Y-pts[0].Y;
				width=sqrt(dx*dx+dy*dy)/2.0f+0.5f;
				headRect.Inflate(width,width);
				dx=pts[2].X-pts[1].X;
				dy=pts[2].Y-pts[1].Y;
				width=sqrt(dx*dx+dy*dy)/2.0f+0.5f;
				tailRect.Inflate(width,width);
			}
			else
			{
				headRect=RectF((pts[0].X+pts[9].X)/2.0f,(pts[0].Y+pts[9].Y)/2.0f,0.0f,0.0f);
				tailRect=RectF((pts[4].X+pts[5].X)/2.0f,(pts[4].Y+pts[5].Y)/2.0f,0.0f,0.0f);
				dx=pts[9].X-pts[0].X;
				dy=pts[9].Y-pts[0].Y;
				width=sqrt(dx*dx+dy*dy)/2.0f+0.5f;
				headRect.Inflate(width,width);
				dx=pts[5].X-pts[4].X;
				dy=pts[5].Y-pts[4].Y;
				width=sqrt(dx*dx+dy*dy)/2.0f+0.5f;
				tailRect.Inflate(width,width);
			}
			mGraphics.FillEllipse(&brush1,headRect);
			mGraphics.FillEllipse(&brush1,tailRect);


			//preWidth=nWidth;
			psPoint=pePoint;
		}
	}
	mGraphics.ResetTransform();
}
void CPenBrushUnit::ErasedDraw(CDC *memDC, DataInfo &pDataInfo,HRGN ErasedRgn)
{
	CPoint sPoint,ePoint,psPoint,pePoint,ptPoint;
	double dx,dy,xlen,ylen;
	double preWidth,nWidth;
	int count=1;
	int alpha;
	int v=0;
	int Red,Green,Blue;
	Red=GetRValue(pDataInfo.penColor);
	Green=GetGValue(pDataInfo.penColor);
	Blue=GetBValue(pDataInfo.penColor);
	Color colors[]={Color(10,Red,Green,Blue)};
	Graphics mGraphics(memDC->m_hDC);
	///////////////////////////////////
	Matrix matrix;
	Region tRgn;
	Region *ptRgn=tRgn.FromHRGN(ErasedRgn);	
	mGraphics.ExcludeClip(ptRgn);
	matrix.Reset();
	delete ptRgn;
	////////////////////////////////////
	mGraphics.TranslateTransform(pDataInfo.CenterPoint.x,pDataInfo.CenterPoint.y);
	mGraphics.RotateTransform(pDataInfo.RotateAngle);
	mGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
	sPoint=CaculatePoint(pDataInfo.StartPoint,pDataInfo);
	ePoint=CaculatePoint(pDataInfo.EndPoint,pDataInfo);
	xlen=ePoint.x-sPoint.x;
	ylen=ePoint.y-sPoint.y;
	preWidth=pDataInfo.AllRate[0].preWidth;
	alpha=pDataInfo.AllRate[0].alpha;
	psPoint.x=sPoint.x+xlen*pDataInfo.AllRate[0].xRate;
	psPoint.y=sPoint.y+ylen*pDataInfo.AllRate[0].yRate; 
	int Size=pDataInfo.AllRate.size();
	for(int Index=1;Index<Size;Index++)
	{
		pePoint.x=sPoint.x+xlen*pDataInfo.AllRate[Index].xRate;
		pePoint.y=sPoint.y+ylen*pDataInfo.AllRate[Index].yRate;
		dx=(pePoint.x-psPoint.x);
		dy=(pePoint.y-psPoint.y);
		nWidth=pDataInfo.AllRate[0].preWidth;
		float Angle=atan2(dy,dx)*Rate;
		GraphicsPath path(FillModeWinding);
		GraphicsPath path1,path2,path3,path4;
		RectF sRectF(psPoint.x,psPoint.y,0,0);
		sRectF.Inflate(preWidth,preWidth);
		RectF eRectF(pePoint.x,pePoint.y,0,0);
		eRectF.Inflate(nWidth,nWidth);
		///////////////////////////////////////////
		REAL  left=sRectF.GetLeft();
		REAL  top=sRectF.GetTop();
		REAL  bottom=sRectF.GetBottom();
		REAL  right=sRectF.GetRight();
		Point pts0[]={Point((left+right)/2,top),Point((left+right)/2,bottom)};
		matrix.RotateAt(Angle,PointF(psPoint.x,psPoint.y));
		matrix.TransformPoints(pts0,2);
		Point LeftTop(pts0[0].X,pts0[0].Y);
		Point LeftBottom(pts0[1].X,pts0[1].Y);
		path1.AddArc(sRectF,270.0f,-180.0f);
		path1.Transform(&matrix);
		matrix.Reset();

		top=eRectF.GetTop();
		bottom=eRectF.GetBottom();
		right=eRectF.GetRight();
		left=eRectF.GetLeft();
		Point pts1[]={Point((right+left)/2,bottom),Point((right+left)/2,top)};
		matrix.RotateAt(Angle,PointF(pePoint.x,pePoint.y));
		matrix.TransformPoints(pts1,2);
		Point RightBottom(pts1[0].X,pts1[0].Y);
		Point RightTop(pts1[1].X,pts1[1].Y);
		path3.AddArc(eRectF,90.0f,-180.0f);
		path3.Transform(&matrix);
		matrix.Reset();
		Point pts[]={LeftTop,RightTop,RightBottom,LeftBottom};
		///////////////////////////////////////////
		path2.AddLine(LeftBottom,RightBottom);
		path4.AddLine(RightTop,LeftTop);
		path.AddPath(&path1,true);
		path.AddPath(&path2,true);
		path.AddPath(&path3,true);
		path.AddPath(&path4,true);

		SolidBrush brush(Color(255,Red,Green,Blue));
		mGraphics.FillPath(&brush,&path);
		Pen pen(Color(255,Red,Green,Blue),1);
		mGraphics.DrawPath(&pen,&path);

		preWidth=nWidth;
		psPoint=pePoint;
	}
	mGraphics.ResetTransform();
}