예제 #1
0
int CDrawGrid::GetLinesPerPage()
/* ============================================================
	Function :		CDrawGrid::GetLinesPerPage
	Description :	Gets the number of lines in the grid for a 
					single page.
	Access :		

	Return :		int		-	Number of lines
	Parameters :	none
					
	Usage :			Call to get the lines fitting to a single 
					page.

   ============================================================*/
{

	CDoubleRect rect = GetPosition();
	return static_cast< int >( rect.Height() * static_cast< double >( GetLPI() ) );

}
예제 #2
0
void CDSegment::Draw(CDC *pDC, CDoubleRect DrawPlace, int iWidth) const
{
	int i, nBez,b;
	CPoint * paPoints;
	double daContr[4];
	double *pBezPts;
	double dRelWidth, dRelHeight;

	paPoints = new CPoint[m_nCount];
	if (paPoints == NULL) return;

	dRelWidth = DrawPlace.Width() / iWidth;
	dRelHeight = DrawPlace.Height() / NORM_DIGIHEIGHT;
	for (i = 0; i < m_nCount; i++)
	{
		if (m_paTypes[i] != PT_BEZIERTO)
		{
			paPoints[i] = CPoint(DrawPlace.left + dRelWidth	 * m_paPoints[i].x + 0.5,
								 DrawPlace.top  + dRelHeight * m_paPoints[i].y + 0.5);
		}
	}

	for (i = 0; i < m_nCount; i++)
	{
		if (m_paTypes[i] == PT_MOVETO)
		{
			pDC->MoveTo(paPoints[i]);
		}
		else if (m_paTypes[i] == PT_LINETO)
		{
			VERIFY(pDC->LineTo(paPoints[i]));
		}
		else if (m_paTypes[i] == PT_BEZIERTO)
		{
			// Look for the first non-bezier point(This is the EndPoint)...
			nBez = 0;
			do
			{
				nBez++;
			} while (m_paTypes[i+nBez] == PT_BEZIERTO);

			pBezPts = new double[2*(nBez+2)];
			for (b = 0; b < (nBez+2)*2; b += 2)
			{
				pBezPts[b  ] = DrawPlace.left + dRelWidth	* m_paPoints[i-1+b/2].x; 
				pBezPts[b+1] = DrawPlace.top  + dRelHeight	* m_paPoints[i-1+b/2].y;
			}
			CalcBezier(pBezPts, 2*(nBez+2), daContr);
			delete[] pBezPts;

			paPoints[i  ].x	= daContr[0] + 0.5;
			paPoints[i  ].y	= daContr[1] + 0.5;
			paPoints[i+1].x	= daContr[2] + 0.5;
			paPoints[i+1].y	= daContr[3] + 0.5;
			paPoints[i+2]	= paPoints[i+nBez];

			VERIFY(pDC->PolyBezierTo(&paPoints[i], 3));
			i += nBez;
		}
	} // for
	delete[] paPoints;
}