Esempio n. 1
0
/*=========================
//	Cross
//
===========================*/
void LineCross::Cross(CDC* pDC)
{
	pDC->SelectObject(CPen (PS_SOLID,2,RGB(255,0,0)));
	
	if(LCSCOUNT==4)
	{
		delta=(LCSP[1].x-LCSP[0].x)*(LCSP[2].y-LCSP[3].y)-(LCSP[2].x-LCSP[3].x)*(LCSP[1].y-LCSP[0].y);
		
		if (delta!=0)
		{
			rmd=((LCSP[2].x-LCSP[0].x)*(LCSP[2].y-LCSP[3].y)-(LCSP[2].x-LCSP[3].x)*(LCSP[2].y-LCSP[0].y))/delta;
			
			if (rmd>=0&&rmd<=1)
			{
				miu=((LCSP[1].x-LCSP[0].x)*(LCSP[2].y-LCSP[0].y)-(LCSP[2].x-LCSP[0].x)*(LCSP[1].y-LCSP[0].y))/delta;
				
				if (miu>=0&&miu<=1)//
				{
					temp.x=long(LCSP[0].x+rmd*(LCSP[1].x-LCSP[0].x));
					temp.y=long(LCSP[0].y+rmd*(LCSP[1].y-LCSP[0].y));
					
					ShowPoints(pDC,temp);
					
				}
			}
		}
		
		LCSCOUNT=0;
	}
	pDC->SetTextColor(RGB(65,180,65));
	pDC->TextOut(700,70,_T("两点画线"));
	pDC->TextOut(700,100,_T("两线求交"));
}
Esempio n. 2
0
void CDialog::OnPaint(CDC& rDC)
{
	// Not resizable OR size grip disabled?
	if (m_vGravities.empty() || m_bNoSizeGrip)
		return;

	// Get window dimensions.
	CRect rcClient = ClientRect();

	// Get bottom right co-ordinates.
	CPoint ptCorner(rcClient.right-1, rcClient.bottom-1);

	// Create pens.
	CPen oDarkPen (PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW));
	CPen oLightPen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHIGHLIGHT));
	CPen oFacePen (PS_SOLID, 0, ::GetSysColor(COLOR_BTNFACE));

	// For all lines.
	for (int i = 0; i < 12; ++i)
	{
		// Select the required pen.
		if ((i % 4) == 3)
			rDC.Select(oLightPen);
		else if ( ((i % 4) == 1) || ((i % 4) == 2) )
			rDC.Select(oDarkPen);
		else
			rDC.Select(oFacePen);

		// Draw the line.
		rDC.Line(ptCorner.x-i-1, ptCorner.y, ptCorner.x, ptCorner.y-i-1);
	}

	// Save grip position for later.
	m_rcOldGrip = CRect(CPoint(ptCorner.x-12, ptCorner.y-12), CSize(13, 13));

#ifdef _DEBUG
	// Passify BoundsChecker.
	rDC.Select(CPen(NULL_PEN));
#endif
}
Esempio n. 3
0
#include "StdAfx.h"
#include "DiaEntity.h"


CPen DiaEntity::m_penBlue = CPen(PS_SOLID, 5, RGB(0, 0, 255));

DiaEntity::DiaEntity(void) :
	m_penColor(RGB(0,0,0)),
	m_penStyle(PS_SOLID)
{	
	m_selected = false;
}


DiaEntity::~DiaEntity(void)
{
}

void DiaEntity::setSelected(bool value)
{
	m_selected = value;
}

bool DiaEntity::isSelected() const
{
	return m_selected;
}

void DiaEntity::setCentralPoint(CPoint point)
{
	CPoint oldPoint = getCentralPoint();