pline.cpp

来自「一个很不错的求Voronoi线与最小凸壳的vc++源程序」· C++ 代码 · 共 69 行

CPP
69
字号
// Pline.cpp: implementation of the CPline class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Voronoi.h"
#include "Pline.h"
#include "VoronoiDoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

extern CGraphPara *p_GraphPara;
extern void RPtoLP(double x,double y,int *X,int *Y);
extern int RLtoLL(double l);
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPline::CPline()
{
  m_Number=0;
}

CPline::~CPline()
{
  if(m_Number>0)
	  delete m_PointList;
}
void CPline::Draw(CDC *pDC,int m_DrawMode,int m_DrawModel,short BackColor,int id)
{
	int x1,y1;
	if(b_Delete)
		return;
	short LineType=m_LineType;
	short LineWide=max(1,RLtoLL(m_LineWide));
	short ColorPen=m_ColorPen;
	if(m_DrawModel==1)
	{
		if(m_LineType!=2)
			LineType=2;
		else
			LineType++;
	}
	else if(m_DrawModel==2)
	{
		ColorPen=BackColor;
	}
	CPen pen(LineType,LineWide,p_GraphPara->GetColor(ColorPen));
	CPen* pOldPen=pDC->SelectObject(&pen);
 	if(m_DrawMode==0)
		pDC->SetROP2(R2_COPYPEN);
  	else if(m_DrawMode==1)
		pDC->SetROP2(R2_NOT);
//	POINT* ppoint=new POINT[m_Number+1];
	for(int i=0;i<m_Number;i++)
	{
		RPtoLP(m_PointList[i].x,m_PointList[i].y,&x1,&y1);
		if(i==0)
			pDC->MoveTo(x1,y1);
		else
			pDC->LineTo(x1,y1);
	}
	pDC->SelectObject(pOldPen);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?