Esempio n. 1
0
void CClock::DrawTime( CDC *pDc )
{
	CRect  rtClient;
	GetClientRect(&rtClient);
	CDC  dcTransparent;
	dcTransparent.CreateCompatibleDC(pDc);
	CBitmap bitTransParent;
	bitTransParent.CreateCompatibleBitmap(pDc, rtClient.Width(),rtClient.Height());
	dcTransparent.SelectObject(&bitTransParent);

	// 		CRect rectReal(ix1, iy1, ix2, iy2);
	dcTransparent.FillSolidRect(rtClient, RGB(255, 255, 255));
	// 		dcTransparent.Draw3dRect(rectReal, RGB(111, 147, 188), RGB(111, 147, 188));

	dcTransparent.BeginPath();
	dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2);
	dcTransparent.LineTo(rtClient.Width()/2-80, rtClient.Height()/2);

	float   fEnd = 90.0f;
	dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 120, -180.0f, 270.0f);
	dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2);

	dcTransparent.EndPath();
	CRgn rgn;
	rgn.CreateFromPath(&dcTransparent);
	dcTransparent.FillRgn(&rgn, &CBrush(RGB(188, 199, 216)));

	//内
	dcTransparent.BeginPath();
	dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2);
	dcTransparent.LineTo(rtClient.Width()/2-40, rtClient.Height()/2);

	dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 40, -180.0f, 270.0f);
	dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2);

	dcTransparent.EndPath();
	CRgn rgn1;
	rgn1.CreateFromPath(&dcTransparent);
	dcTransparent.FillRgn(&rgn1, &CBrush(RGB(255, 255, 0)));

	if( ::AlphaBlend == 0 )
	{
		pDc->StretchBlt(0, 0, rtClient.Width(), rtClient.Height(), 
			&dcTransparent, 0, 0, rtClient.Width(), rtClient.Height(), SRCINVERT );

	}else{

		BLENDFUNCTION bf;    
		memset( &bf, 0, sizeof( bf ) );
		bf.SourceConstantAlpha = 0x9f; //半透明
		bf.BlendOp = AC_SRC_OVER;

		::TransparentBlt(pDc->GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), 
			dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), RGB(255, 255, 255));
		// 			::AlphaBlend( memDC.GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), 
		// 				dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), bf );  
	}
	bitTransParent.DeleteObject();
	dcTransparent.DeleteDC();
}
Esempio n. 2
0
void MyObj::Draw(CDC &dc){
dc.MoveTo(m_dCenterX,m_dCenterY); 
dc.LineTo(m_dCenterX,m_dCenterY-m_dA/2+m_dA1); 
dc.MoveTo(m_dCenterX,m_dCenterY-m_dA+m_dA1/2); 
dc.AngleArc(m_dCenterX,m_dCenterY-m_dA/2,m_dA1,90,180); 
dc.MoveTo(m_dCenterX,m_dCenterY-m_dA+m_dA1/2); 
dc.LineTo(m_dCenterX,m_dCenterY-m_dA); 
dc.LineTo(m_dCenterX-m_dA+m_dA2,m_dCenterY-m_dA); 
dc.AngleArc(m_dCenterX-m_dA+m_dA2,m_dCenterY-m_dA+m_dA2,m_dA2,90,90); 
dc.LineTo(m_dCenterX-m_dA,m_dCenterY-m_dA3); 
dc.MoveTo(m_dCenterX-m_dA+m_dA3,m_dCenterY); 
dc.AngleArc(m_dCenterX-m_dA,m_dCenterY,m_dA3,0,90); 
dc.MoveTo(m_dCenterX-m_dA+m_dA3,m_dCenterY); 
dc.LineTo(m_dCenterX,m_dCenterY);
}
Esempio n. 3
0
// *****************************************************************
//		DrawDrawing()
// *****************************************************************
void CMapView::DrawDrawing(Gdiplus::Graphics* graphics, DrawList * dlist)
{
	HDC hdc = graphics->GetHDC();
	CDC* dc = CDC::FromHandle(hdc);
	
	CBrush * brush = new CBrush();
	CPen * pen = new CPen();

	CBrush * oldBrush = NULL;
	CPen * oldPen = NULL;

	CRect rect;

	double pixX, pixY;

	register int j;
	
	if( dlist->listType == dlScreenReferencedList )
	{
		for(unsigned i = 0; i < dlist->m_dpolygons.size(); i++)
		{	
			if( dlist->m_dpolygons[i]->numPoints > 0 )
			{	
				CPoint * pnts = new CPoint[dlist->m_dpolygons[i]->numPoints];
				long endcondition2 = dlist->m_dpolygons[i]->numPoints;
				for(j=0;j<endcondition2;j++)
				{
					//Rob Cairns 10 Jan 06
					int xpt = Utility::Rint(dlist->m_dpolygons[i]->xpnts[j]);
					int ypt = Utility::Rint(dlist->m_dpolygons[i]->ypnts[j]);
					pnts[j] = CPoint(xpt,ypt);
				}
				if( dlist->m_dpolygons[i]->fill )
				{	
					brush->CreateSolidBrush(dlist->m_dpolygons[i]->color);
					pen->CreatePen(PS_SOLID,dlist->m_dpolygons[i]->width,dlist->m_dpolygons[i]->color);
					oldBrush = dc->SelectObject(brush);
					oldPen = dc->SelectObject(pen);
					dc->Polygon(pnts,dlist->m_dpolygons[i]->numPoints);
					dc->SelectObject(oldBrush);
					dc->SelectObject(oldPen);
					pen->DeleteObject();
					brush->DeleteObject();
				}
				else
				{	
					pen->CreatePen(PS_SOLID,dlist->m_dpolygons[i]->width,dlist->m_dpolygons[i]->color);
					oldPen = dc->SelectObject(pen);
					dc->Polyline(pnts,dlist->m_dpolygons[i]->numPoints);
					dc->SelectObject(oldPen);
					pen->DeleteObject();
				}
				delete [] pnts;
			}
		}
		
		for(unsigned int i = 0; i < dlist->m_dcircles.size(); i++)
		{	
			if( dlist->m_dcircles[i]->fill )
			{	
				brush->CreateSolidBrush(dlist->m_dcircles[i]->color);
				pen->CreatePen(PS_SOLID,dlist->m_dcircles[i]->width,dlist->m_dcircles[i]->color);
				oldBrush = dc->SelectObject(brush);
				oldPen = dc->SelectObject(pen);
				dc->Ellipse((int)(dlist->m_dcircles[i]->x - dlist->m_dcircles[i]->radius),
							(int)(dlist->m_dcircles[i]->y - dlist->m_dcircles[i]->radius), 
							(int)(dlist->m_dcircles[i]->x + dlist->m_dcircles[i]->radius), 
							(int)(dlist->m_dcircles[i]->y + dlist->m_dcircles[i]->radius) );
				dc->SelectObject(oldBrush);
				dc->SelectObject(oldPen);
				pen->DeleteObject();
				brush->DeleteObject();
			}
			else
			{	
				pen->CreatePen(PS_SOLID,dlist->m_dcircles[i]->width,dlist->m_dcircles[i]->color);
				oldPen = dc->SelectObject(pen);
				dc->MoveTo((int)(dlist->m_dcircles[i]->x+dlist->m_dcircles[i]->radius), (int)dlist->m_dcircles[i]->y);
				dc->AngleArc((int)(dlist->m_dcircles[i]->x), (int)(dlist->m_dcircles[i]->y), (int)(dlist->m_dcircles[i]->radius),0,360);
				dc->SelectObject(oldPen);
				pen->DeleteObject();
			}
		}
		
		for(unsigned int i = 0 ; i < dlist->m_dlines.size(); i++)
		{	
			CPoint *pnts = new CPoint[2];
			pen->CreatePen(PS_SOLID,dlist->m_dlines[i]->width,dlist->m_dlines[i]->color);
			oldPen = dc->SelectObject(pen);
			//Rob Cairns 10 Jan 06
			int ptX1 = Utility::Rint(dlist->m_dlines[i]->x1);
			int ptY1 = Utility::Rint(dlist->m_dlines[i]->y1);	
			int ptX2 = Utility::Rint(dlist->m_dlines[i]->x2);
			int ptY2 = Utility::Rint(dlist->m_dlines[i]->y2);
			pnts[0]=CPoint(ptX1,ptY1);
			pnts[1]=CPoint(ptX2,ptY2);
			dc->Polyline(pnts,2);
			dc->SelectObject(oldPen);
			pen->DeleteObject();
			delete []pnts;
		}
		
		
		for(unsigned int i = 0;i < dlist->m_dpoints.size(); i++) 
		{	if( dlist->m_dpoints[i]->size == 1 )
			{	//Rob Cairns 10 Jan 06
				int pxX = Utility::Rint(dlist->m_dpoints[i]->x);
				int pxY = Utility::Rint(dlist->m_dpoints[i]->y);
				dc->SetPixelV(CPoint(pxX,pxY),dlist->m_dpoints[i]->color);
			}	
			else
			{	
				rect = CRect((int)dlist->m_dpoints[i]->x,(int)dlist->m_dpoints[i]->y, (int)dlist->m_dpoints[i]->x, (int)dlist->m_dpoints[i]->y);
				rect.left -= (long)(dlist->m_dpoints[i]->size * 0.5);
				rect.top -= (long)(dlist->m_dpoints[i]->size * 0.5);
				dc->FillSolidRect(rect.left,rect.top,dlist->m_dpoints[i]->size,dlist->m_dpoints[i]->size,dlist->m_dpoints[i]->color);
			}
		}
	}
	else	// if( dlist->listType == dlSpatiallyReferencedList )
	{
		for(unsigned int i = 0; i < dlist->m_dpolygons.size(); i++)
		{	
			if( dlist->m_dpolygons[i]->numPoints > 0 )
			{	
				CPoint * pnts = new CPoint[dlist->m_dpolygons[i]->numPoints];
				long endcondition2 = dlist->m_dpolygons[i]->numPoints;
				for(j=0;j<endcondition2;j++)
				{	
					PROJECTION_TO_PIXEL(dlist->m_dpolygons[i]->xpnts[j],dlist->m_dpolygons[i]->ypnts[j],pixX,pixY);
					//Rob Cairns 10 Jan 06
					int pxX = Utility::Rint(pixX);
					int pxY = Utility::Rint(pixY);	
					pnts[j] = CPoint(pxX,pxY);
				}
				
				if( dlist->m_dpolygons[i]->fill )
				{	
					brush->CreateSolidBrush(dlist->m_dpolygons[i]->color);
					pen->CreatePen(PS_SOLID,dlist->m_dpolygons[i]->width,dlist->m_dpolygons[i]->color);
					oldBrush = dc->SelectObject(brush);
					oldPen = dc->SelectObject(pen);
					dc->Polygon(pnts,dlist->m_dpolygons[i]->numPoints);
					dc->SelectObject(oldBrush);
					dc->SelectObject(oldPen);
					pen->DeleteObject();
					brush->DeleteObject();
				}
				else
				{	
					pen->CreatePen(PS_SOLID,dlist->m_dpolygons[i]->width,dlist->m_dpolygons[i]->color);
					oldPen = dc->SelectObject(pen);
					dc->Polyline(pnts,dlist->m_dpolygons[i]->numPoints);
					dc->SelectObject(oldPen);
					pen->DeleteObject();
				}
				delete [] pnts;
			}
		}
		
		for(unsigned int i = 0; i < dlist->m_dcircles.size(); i++)
		{	
			if( dlist->m_dcircles[i]->fill )
			{	
				brush->CreateSolidBrush(dlist->m_dcircles[i]->color);
				pen->CreatePen(PS_SOLID,dlist->m_dcircles[i]->width,dlist->m_dcircles[i]->color);
				oldBrush = dc->SelectObject(brush);
				oldPen = dc->SelectObject(pen);
				PROJECTION_TO_PIXEL(dlist->m_dcircles[i]->x,dlist->m_dcircles[i]->y,pixX,pixY);
				
				// lsu 25-apr-2010: we need to draw it in screen coordinates
				int pxX = Utility::Rint(pixX - dlist->m_dcircles[i]->radius * _pixelPerProjectionX);
				int pxY = Utility::Rint(pixY - dlist->m_dcircles[i]->radius * _pixelPerProjectionY);
				int pxX2 = Utility::Rint(pixX + dlist->m_dcircles[i]->radius * _pixelPerProjectionX);
				int pxY2 = Utility::Rint(pixY + dlist->m_dcircles[i]->radius * _pixelPerProjectionY);
				
				dc->Ellipse( pxX, pxY, pxX2, pxY2);
				dc->SelectObject(oldBrush);
				dc->SelectObject(oldPen);
				brush->DeleteObject();
			}
			else
			{	pen->CreatePen(PS_SOLID, dlist->m_dcircles[i]->width,dlist->m_dcircles[i]->color);
				oldPen = dc->SelectObject(pen);
				PROJECTION_TO_PIXEL(dlist->m_dcircles[i]->x,dlist->m_dcircles[i]->y,pixX,pixY);
				//Rob Cairns 10 Jan 06
				int pxX = Utility::Rint(pixX);
				int pxY = Utility::Rint(pixY);
				dc->MoveTo((int)(pxX + dlist->m_dcircles[i]->radius * _pixelPerProjectionX),pxY);
				dc->AngleArc(pxX, pxY, (int)(dlist->m_dcircles[i]->radius * _pixelPerProjectionX), 0, 360);
				dc->SelectObject(oldPen);
			}
			pen->DeleteObject();
		}
		
		for(unsigned int i=0; i < dlist->m_dlines.size(); i++)
		{	
			CPoint *pnts = new CPoint[2];
			pen->CreatePen(PS_SOLID,dlist->m_dlines[i]->width,dlist->m_dlines[i]->color);
			oldPen = dc->SelectObject(pen);
			PROJECTION_TO_PIXEL(dlist->m_dlines[i]->x1,dlist->m_dlines[i]->y1,pixX,pixY);
			//Rob Cairns 10 Jan 06
			int pxX = Utility::Rint(pixX);
			int pxY = Utility::Rint(pixY);
			pnts[0]=CPoint(pxX,pxY);
			PROJECTION_TO_PIXEL(dlist->m_dlines[i]->x2,dlist->m_dlines[i]->y2,pixX,pixY);
			//Rob Cairns 10 Jan 06
			pxX = Utility::Rint(pixX);
			pxY = Utility::Rint(pixY);
			pnts[1]=CPoint(pxX,pxY);
			dc->Polyline(pnts,2);
			dc->SelectObject(oldPen);
			pen->DeleteObject();
			delete []pnts;
		}
		
		for(unsigned int i=0; i < dlist->m_dpoints.size(); i++)
		{	
			if( dlist->m_dpoints[i]->size == 1 )
			{
				PROJECTION_TO_PIXEL(dlist->m_dpoints[i]->x,dlist->m_dpoints[i]->y,pixX,pixY);
				//Rob Cairns 10 Jan 06
				int pxX = Utility::Rint(pixX);
				int pxY = Utility::Rint(pixY);
				dc->SetPixelV(CPoint(pxX,pxY),dlist->m_dpoints[i]->color);
			}
			else
			{
				PROJECTION_TO_PIXEL(dlist->m_dpoints[i]->x,dlist->m_dpoints[i]->y,pixX,pixY);
				pixX -= dlist->m_dpoints[i]->size*.5;
				pixY -= dlist->m_dpoints[i]->size*.5;
				//Rob Cairns 10 Jan 06
				int pxX = Utility::Rint(pixX);
				int pxY = Utility::Rint(pixY);
				dc->FillSolidRect(pxX,pxY,dlist->m_dpoints[i]->size,dlist->m_dpoints[i]->size,dlist->m_dpoints[i]->color);
			}
		}
	}

	delete brush;
	delete pen;

	graphics->ReleaseHDC(hdc);
	dc = NULL;
}