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::DrawMultiPenBrush(CDC *memDC,CPoint ePoint,std::vector<temSavePoint> &MultipsPoint,MultiInfo &GetMultiInfo,DWORD mouseid) { int Red,Green,Blue; Red=GetRValue(GetMultiInfo.penColor); Green=GetGValue(GetMultiInfo.penColor); Blue=GetBValue(GetMultiInfo.penColor); Graphics mGraphics(memDC->m_hDC); mGraphics.SetSmoothingMode(SmoothingModeAntiAlias); SolidBrush brush(Color(255,Red,Green,Blue)); UINT Size=MultipsPoint.size(); CPoint sPoint=MultipsPoint[Size-1].point; if(Size==1) { if(fwidth.find(mouseid)!=fwidth.end()) fwidth.erase(mouseid); fwidth.insert(std::map<DWORD,float>::value_type(mouseid,MultipsPoint[0].preWidth)); PushStart(ePoint,mouseid); } if(Push(sPoint,ePoint,mouseid)) { RectF headRect; RectF tailRect; float width,dx,dy; PointF lfCenter,rtCenter; mGraphics.FillPolygon(&brush,pts,npts); mGraphics.DrawPolygon(&Pen(Color(255,Red,Green,Blue),0.5f),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); } brush.SetColor(Color(255,Red,Green,Blue)); mGraphics.FillEllipse(&brush,headRect); mGraphics.FillEllipse(&brush,tailRect); temSavePoint addPoint; addPoint.point=ePoint; addPoint.alpha=MultipsPoint[Size-1].alpha; addPoint.preWidth=MultipsPoint[Size-1].preWidth; MultipsPoint.push_back(addPoint); } }