コード例 #1
0
void CToolRegularRuler::Draw(CDC* pDC, CRect& rcInvalid)
{
	if(m_nPtCount <= 1)
	{
		return;
	}

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);
	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	Pen penDraw(m_crColor, 2);

	RectF rcf(m_ptary[0].X, m_ptary[0].Y,
		m_ptary[1].X - m_ptary[0].X,
		m_ptary[1].Y - m_ptary[0].Y);

	DrawRulerMarks(graph);
	graph.DrawRectangle(&penDraw, rcf);

	if(m_bSelected || m_bEdit)
	{
		DrawHotShape(graph);
	}
}
コード例 #2
0
void CFlatBrushPen::Draw(CDC* pDC,CRect& rcInvalid)
{
	if(m_nPtCount <= 1)
	{
		return;
	}

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeHighQuality);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	Pen penDraw(m_crColor, (float)m_nWidth * m_fScale);
	penDraw.ScaleTransform(1, 2.0f / m_nWidth, MatrixOrderAppend);
	penDraw.RotateTransform(m_ftransAngle, MatrixOrderAppend);

	if(m_bSelected || m_bEdit)
	{
		graph.SetSmoothingMode(SmoothingModeAntiAlias);
		DrawHotShape(graph);
	}

	if(!m_bFinish)
	{
		Rect	rc(rcInvalid.left, rcInvalid.top, rcInvalid.Width(), rcInvalid.Height());
		graph.SetClip(rc);
	}

	graph.ExcludeClip(&m_RgnErase);

	PointF* pPt = m_ptary.GetData();
	graph.DrawLines(&penDraw, pPt, m_nPtCount);
}
コード例 #3
0
void CRectangle::DrawSquare(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	if(m_bFinish)
	{
		graph.DrawRectangle(&penDraw,rc.left,rc.top,rc.Width(),rc.Height());
	}
	else
	{
		float fWidth = (float)min(rc.Width(),rc.Height());
		float fleft = 0,ftop = 0;
		if(m_ptary[0].X <= m_ptary[1].X)
		{
			fleft = m_ptary[0].X;
		}
		else 
		{
			fleft = m_ptary[0].X - fWidth;
		}
		if(m_ptary[0].Y <= m_ptary[1].Y)
		{
			ftop = m_ptary[0].Y;
		}
		else
		{
			ftop = m_ptary[0].Y - fWidth;
		}
		graph.DrawRectangle(&penDraw,fleft,ftop,fWidth,fWidth);
	}
}
コード例 #4
0
void CNormalPen::Draw(CDC* pDC)
{
	if(m_nPtCount == 0)
		return;
	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);
	
	Pen penDraw(m_crColor,(float)m_nWidth);
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetStartCap(m_nStartCap);

	PointF* pPt = m_ptary.GetData();
	if(m_bFinish)
	{
		penDraw.SetEndCap(m_nEndCap);
		penDraw.SetLineJoin(LineJoinRound);
		graph.DrawCurve(&penDraw,pPt,m_nPtCount,0.8f);
	}
	else
	{
		graph.DrawCurve(&penDraw,pPt,m_nPtCount - 1,0.8f);
	}
	if(m_bSelected)
	{
		DrawHotShape(graph);
	}
}
コード例 #5
0
void CAngleLabel::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::White);
	Pen penDraw(Color::Blue, 3);

	PointF ptLT;
	ptLT.X = m_ptary[0].X - m_nWidth;
	ptLT.Y = m_ptary[0].Y - m_nWidth;

	Rect rect((int)ptLT.X, (int)ptLT.Y, m_nWidth * 2, m_nWidth * 2);
	graph.DrawEllipse(&penDraw, rect);
	graph.FillEllipse(&sbrush, rect);

	ptLT.X = m_ptary[1].X - m_nWidth;
	ptLT.Y = m_ptary[1].Y - m_nWidth;

	rect.X = (int)ptLT.X;
	rect.Y = (int)ptLT.Y;
	rect.Width = m_nWidth * 2;
	rect.Height = m_nWidth * 2;

	graph.DrawEllipse(&penDraw, rect);
	graph.FillEllipse(&sbrush, rect);

	ptLT.X = m_ptary[2].X - m_nWidth;
	ptLT.Y = m_ptary[2].Y - m_nWidth;

	rect.X = (int)ptLT.X;
	rect.Y = (int)ptLT.Y;
	rect.Width = m_nWidth * 2;
	rect.Height = m_nWidth * 2;

	graph.DrawEllipse(&penDraw, rect);
	graph.FillEllipse(&sbrush, rect);
}
コード例 #6
0
ファイル: CDiamond.cpp プロジェクト: lilingshui/code-refrence
void CDiamond::Draw(CDC* pDC,CRect& rcInvalid)
{
	if(m_nPtCount <= 0)
		return;

	Pen penDraw(m_crColor,(float)m_nWidth);
	penDraw.SetLineJoin(LineJoinRound);
	penDraw.SetDashStyle(m_nDashStyle);

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	if(m_nPtCount <= 1)
	{
		return;
	}
	else 
	{
		if(m_bFinish && (m_bSelected || m_bEdit))
		{
			DrawHotShape(graph);
		}

		graph.ExcludeClip(&m_RgnErase);
		PointF* pPt = m_ptary.GetData();
		graph.DrawPolygon(&penDraw,pPt,4);
	}
}
コード例 #7
0
void CRectangle::DrawRoundRect(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	INT offsetX = (rc.right - rc.left) * 20/100;  
	INT offsetY = (rc.bottom - rc.top) * 20/100;
	GraphicsPath pt;
	pt.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
	pt.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
	pt.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
	pt.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
	pt.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);

	graph.DrawPath(&penDraw,&pt);
}
コード例 #8
0
void CLTriangle::SetRegion()
{
	PointF* pPt = m_ptary.GetData();
	Pen penDraw(Color(255, 0, 255, 0));
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetWidth((float)m_nWidth);
	
	GraphicsPath path;
	path.AddPolygon(pPt,m_nPtCount);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #9
0
ファイル: CNormalPen.cpp プロジェクト: chenboo/code-refrence
void CNormalPen::Draw(CDC* pDC,CRect& rcInvalid)
{
	if(m_nPtCount == 0)
	{
		return;
	}

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);
	Rect rc(rcInvalid.left, rcInvalid.top, rcInvalid.Width(), rcInvalid.Height());

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	if(m_bSelected || m_bEdit)
	{
		DrawHotShape(graph);
	}

	graph.ExcludeClip(&m_RgnErase);
	
	Pen penDraw(m_crColor,(float)m_nWidth);
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetStartCap(m_nStartCap);
	penDraw.SetLineJoin(LineJoinRound);

	int nCount = (int)m_ptary.GetCount();
	PointF* pPt = m_ptary.GetData();

	if(!m_bFinish)
	{
		graph.SetClip(rc);

		if(DashStyleSolid == m_nDashStyle)
		{
			penDraw.SetEndCap(m_nEndCap);
		}
	}
	else
	{
		penDraw.SetEndCap(m_nEndCap);
		penDraw.SetWidth(m_fScale * m_nWidth);
	}

	graph.DrawCurve(&penDraw, pPt, nCount);
}
コード例 #10
0
void CToolRegularRuler::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::Green);
	Pen penDraw(Color::Blue, 2);
	penDraw.SetDashStyle(DashStyleDot);

	PointF pt((m_ptary[0].X + m_ptary[1].X) / 2, m_ptary[0].Y);
	
	graph.DrawLine(&penDraw, pt, m_HotPts.ptRotate);
	graph.FillEllipse(&sbrush, m_HotPts.ptRotate.X - HOTINTERVAL,
					  m_HotPts.ptRotate.Y - HOTINTERVAL,
					  2.0 * HOTINTERVAL, 2.0 * HOTINTERVAL);

	penDraw.SetDashStyle(DashStyleDash);
	penDraw.SetColor(Color::Red);

	graph.DrawRectangle(&penDraw, m_rcGrip.left, m_rcGrip.top, m_rcGrip.Width(), m_rcGrip.Height());
}
コード例 #11
0
void CFlatBrushPen::SetRegion()
{
	ASSERT(m_bFinish);
	PointF* pPt = m_ptary.GetData();
	float fwidth = m_nWidth * m_fScale;

	Pen penDraw(m_crColor, fwidth);
	penDraw.ScaleTransform(1, 2.0f / fwidth, MatrixOrderAppend);
	penDraw.RotateTransform(m_ftransAngle, MatrixOrderAppend);

	GraphicsPath path;
	path.AddCurve(pPt, m_nPtCount);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #12
0
void CTransparentPen::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	Pen penDraw(m_crColor);
	penDraw.SetStartCap(LineCapRound);
	penDraw.SetEndCap(LineCapRound);
	penDraw.SetLineJoin(LineJoinRound);
	penDraw.SetWidth(m_nWidth * m_fScale);

	GraphicsPath path;
	path.AddCurve(pPt,m_nPtCount,0.8f);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #13
0
void CNTriangle::Draw(CDC* pDC,CRect& rcInvalid)
{
	if(m_nPtCount <= 0)
	{
		return;
	}

	Pen penDraw(m_crColor,(float)m_nWidth);
	penDraw.SetLineJoin(LineJoinRound);
	penDraw.SetDashStyle(m_nDashStyle);

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	if(!m_bFinish)
	{
		PointF* pPt = m_ptary.GetData();

		if(m_bhas3temppts)
		{
			Pen penPrev(Color::Blue, (float)m_nWidth);
			penPrev.SetDashStyle(DashStyleDash);
			graph.DrawLine(&penPrev, m_ptary[0], m_ptary[2]);
		}

		graph.DrawLines(&penDraw, pPt, m_nPtCount + 1);
	}
	else if(m_nPtCount == 3)
	{
		if(m_bSelected || m_bEdit)
		{
			DrawHotShape(graph);
		}

		graph.ExcludeClip(&m_RgnErase);
		PointF* pPt = m_ptary.GetData();
		graph.DrawPolygon(&penDraw, pPt, m_nPtCount);
	}
}
コード例 #14
0
void CToolRegularRuler::DrawRulerMarks(Graphics& graph)
{
	int nNumber = 0;
	int nbegin = m_rcHot.left + 10;
	int nend = m_rcHot.right - 10;

	CString strNumber;
	Font fontNumber(L"Arial", 10);
	SolidBrush brush(Color::Black);
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);

	Pen penDraw(Color::Black, 1);
	PointF ptBegin((float)nbegin, m_rcHot.top + 1.0f);
	PointF ptEnd = ptBegin;
	graph.SetTextRenderingHint(TextRenderingHintAntiAlias);

	for(int i = nbegin; i < nend; i+= 10)
	{
		ptEnd.X = (float)i;
		ptBegin.X = (float)i;
		if((i - nbegin) % 100 == 0)
		{
			ptEnd.Y = ptBegin.Y + 30;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
			nNumber = (i - nbegin) / 100;
			strNumber.Format(_T("%d"), nNumber);
			
			graph.DrawString(strNumber, strNumber.GetLength(), &fontNumber, ptEnd, &format, &brush);
		}
		else if((i - nbegin) % 50 == 0)
		{
			ptEnd.Y = ptBegin.Y + 20;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
		else
		{
			ptEnd.Y = ptBegin.Y + 10;
			graph.DrawLine(&penDraw, ptBegin, ptEnd);
		}
	}
}
コード例 #15
0
void CTriangle::Draw(CDC* pDC)
{
	if(m_nPtCount <= 0)
		return;

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	Pen penDraw(m_crColor,(float)m_nWidth);
	penDraw.SetLineJoin(LineJoinRound);

	if(m_nPtCount == 2)
	{

		Pen pent(Color::Blue,2);
		pent.SetDashStyle(DashStyleDot);

		CPoint ptLT;
		CPoint ptRB;
		ptLT.x = (int)m_ptary[0].X;
		ptLT.y = (int)m_ptary[0].Y;
		ptRB.x = (int)m_ptary[1].X;
		ptRB.y = (int)m_ptary[1].Y;
		CRect rc(ptLT,ptRB);
		rc.NormalizeRect();
		graph.DrawRectangle(&pent,rc.left,rc.top,rc.Width(),rc.Height());
	}
	else if(m_nPtCount == 3)
	{
		PointF* pPt = m_ptary.GetData();
		graph.DrawPolygon(&penDraw,pPt,m_nPtCount);

		if(m_bSelected)
		{
			DrawHotShape(graph);
		}
	}
}
コード例 #16
0
void CAngleLabel::Draw(CDC* pDC, CRect& rcInvalid)
{
	if(m_nPtCount <= 0)
	{
		return;
	}

	Pen penDraw(m_crColor, (float)m_nWidth);
	penDraw.SetLineJoin(LineJoinRound);
	penDraw.SetEndCap(LineCapRound);
	penDraw.SetStartCap(LineCapRound);
	penDraw.SetDashStyle(m_nDashStyle);

	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle, m_ptCenter);
	graph.SetTransform(&mat);
	PointF* pPt = m_ptary.GetData();

	if(m_bhas3temppts || m_bFinish)
	{
		PointF ptd[3];
		ptd[0] = pPt[1];
		ptd[1] = pPt[0];
		ptd[2] = pPt[2];

		graph.ExcludeClip(&m_RgnErase);
		graph.DrawLines(&penDraw, ptd, 3);
		DrawAngleLabelMark(graph);
	}
	else
	{
		graph.DrawLine(&penDraw, pPt[0], pPt[1]);
	}

	if(m_bSelected || m_bEdit)
	{
		DrawHotShape(graph);
	}
}
コード例 #17
0
ファイル: CNormalPen.cpp プロジェクト: chenboo/code-refrence
void CNormalPen::SetRegion()
{
	ASSERT(m_bFinish);
	PointF* pPt = m_ptary.GetData();
	Pen penDraw(m_crColor);
	penDraw.SetWidth(m_nWidth * m_fScale);

	penDraw.SetEndCap(m_nEndCap);
	penDraw.SetStartCap(m_nStartCap);
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetLineJoin(LineJoinRound);

	GraphicsPath path;
	path.AddCurve(pPt,m_nPtCount);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #18
0
void CAngleLabel::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	PointF ptd[3];
	ptd[0] = pPt[1];
	ptd[1] = pPt[0];
	ptd[2] = pPt[2];

	Pen penDraw(Color(255, 0, 255, 0));
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetWidth((float)m_nWidth);
	
	GraphicsPath path;
	path.AddLines(ptd, m_nPtCount);

	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #19
0
void CRectangle::SetRegion()
{
	float left = min(m_ptary[0].X,m_ptary[1].X);
	float top = min(m_ptary[0].Y,m_ptary[1].Y);
	float width = fabs(m_ptary[0].X - m_ptary[1].X);
	float height = fabs(m_ptary[0].Y - m_ptary[1].Y);

	Pen penDraw(Color(255, 0, 255, 0));
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetWidth((float)m_nWidth);
	
	GraphicsPath path;
	if(RS_ROUND == m_nRStyle)
	{
		CRect rc((int)left,(int)top,(int)(left + width),(int)(top + height));
		INT offsetX = (rc.right - rc.left) * 20/100;  
		INT offsetY = (rc.bottom - rc.top) * 20/100;
		path.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
		path.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
		path.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
		path.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
		path.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);
	}
	else
	{

		RectF rcf(left,top,width,height);
		path.AddRectangle(rcf);
	}

	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #20
0
void CNormalPen::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	int nWidth = m_nWidth;
	if(m_nWidth < 3)
	{
		nWidth = 3;
	}

	Pen penDraw(m_crColor,(float)nWidth);
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetStartCap(m_nStartCap);
	penDraw.SetEndCap(m_nEndCap);
	penDraw.SetLineJoin(LineJoinRound);

	GraphicsPath path;
	path.AddCurve(pPt,m_nPtCount);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
コード例 #21
0
void CRectangle::DrawRectangle(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	graph.DrawRectangle(&penDraw,rc.left,rc.top,rc.Width(),rc.Height());
}
コード例 #22
0
void CAngleLabel::DrawAngleLabelMark(Graphics& graph)
{
	CPoint pt2((int)m_ptary[1].X, (int)m_ptary[1].Y);
	CPoint pt3((int)m_ptary[2].X, (int)m_ptary[2].Y);

	float fAngle3 = 0.0f;
	float fAngle1 = CalcRotateAngle(pt2, m_ptary[0]) - 90.0f;
	float fAngle2 = CalcRotateAngle(pt3, m_ptary[0]) - 90.0f;

	if(fAngle1 > - 90 && fAngle1 <= 0)
	{
		if(fAngle2 >= 180 && fAngle2 <= 270)
		{
			fAngle2 -= 360;
		}
		else if(fAngle2 - fAngle1 >= 180)
		{
			fAngle1 += 360;
		}
	}
	else if(fAngle1 >= 0 && fAngle1 <= 90)
	{
		if(fAngle2 >= 180)
		{
			if(fAngle2 - fAngle1 >= 180)
			{
				fAngle2 -= 360;
			}
		}
	}
	else if(fAngle1 >= 90 && fAngle1 <= 180)
	{
		if(fAngle2 >= -90 && fAngle2 <= 0)
		{
			if(fAngle1 - fAngle2 >= 180)
			{
				fAngle2 += 360;
			}
		}
	}
	else if(fAngle1 >= 180 && fAngle1 <= 270)
	{
		if(fAngle2 >= 0 && fAngle2 <= 90)
		{
			if(fAngle1 - fAngle2 >= 180)
			{
				fAngle2 += 360;
			}
		}
		else if(fAngle2 >= -90 && fAngle2 <= 0)
		{
			fAngle2 += 360;
		}
	}

	fAngle3 = (fAngle1 + fAngle2) / 2.0f;
	PointF ptDraw;
	ptDraw.Y = m_ptary[0].Y;

	if(fabs(fAngle1 - fAngle2) <= 20)
	{
		ptDraw.X = 100 + m_ptary[0].X;
	}
	else if(fabs(fAngle1 - fAngle2) <= 30)
	{
		ptDraw.X = 80 + m_ptary[0].X;
	}
	else
	{
		ptDraw.X = 60 + m_ptary[0].X;
	}

	Matrix mat;
	mat.RotateAt(fAngle3, m_ptary[0]);
	mat.TransformPoints(&ptDraw, 1);

	Pen penDraw(Color::Blue, 2);
	RectF rcf(m_ptary[0].X - 30, m_ptary[0].Y - 30, 60, 60);
	graph.DrawArc(&penDraw, rcf, fAngle1, fAngle2 - fAngle1);

	Font myFont(_T("Arial"), 12);
	SolidBrush brush(Color::Red);
	StringFormat format;
	format.SetAlignment(StringAlignmentCenter);

	int nAngle = CalLinesAngle();
	m_strAngle.Format(_T("%dбу"), nAngle);

	graph.SetTextRenderingHint(TextRenderingHintAntiAlias);
	graph.DrawString(m_strAngle, m_strAngle.GetLength(), &myFont, ptDraw, &format, &brush);
}