当前位置: 首页>>代码示例>>C++>>正文


C++ CDC::Ellipse方法代码示例

本文整理汇总了C++中CDC::Ellipse方法的典型用法代码示例。如果您正苦于以下问题:C++ CDC::Ellipse方法的具体用法?C++ CDC::Ellipse怎么用?C++ CDC::Ellipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDC的用法示例。


在下文中一共展示了CDC::Ellipse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawItem

// --------------------------------------------------------------------------
void CCalibrateControl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CameraDialog* dlg=(CameraDialog*)this->GetParent();
	image.Show(pDC->m_hDC, 0, 0, image.Width(), image.Height(), dlg->offsetx, dlg->offsety);
	
	CPen red(PS_SOLID, 1, RGB(255, 0, 0));
	CPen green(PS_SOLID, 1, RGB(0, 255, 0));
	CPen blue(PS_SOLID, 1, RGB(0, 0, 255));
	CPen aqua(PS_SOLID, 1, RGB(0, 255, 255));
	DrawLines(pDC, dlg->x, &red);
	DrawLines(pDC, dlg->y, &green);
	DrawLines(pDC, dlg->z, &blue);
	DrawLines(pDC, dlg->r, &aqua);
	
	
	// draw vanishing points !!!!!!!!!
	CvPoint VX = cvPointFrom32f(dlg->coordsHomo2Image(dlg->VX));
	CvPoint VY = cvPointFrom32f(dlg->coordsHomo2Image(dlg->VY));
	CvPoint VZ = cvPointFrom32f(dlg->coordsHomo2Image(dlg->VZ));
	CBrush bred(RGB(255, 0, 0));
	CBrush bgreen(RGB(0, 255, 0));
	CBrush bblue(RGB(0, 0, 255));
 	pDC->SelectObject(bred);
	pDC->Ellipse(VX.x-2*DOT-dlg->offsetx, VX.y-2*DOT-dlg->offsety, VX.x+2*DOT-dlg->offsetx, VX.y+2*DOT-dlg->offsety);
	pDC->SelectObject(bgreen);
	pDC->Ellipse(VY.x-2*DOT-dlg->offsetx, VY.y-2*DOT-dlg->offsety, VY.x+2*DOT-dlg->offsetx, VY.y+2*DOT-dlg->offsety);
	pDC->SelectObject(bblue);
	pDC->Ellipse(VZ.x-2*DOT-dlg->offsetx, VZ.y-2*DOT-dlg->offsety, VZ.x+2*DOT-dlg->offsetx, VZ.y+2*DOT-dlg->offsety);
	
}
开发者ID:githubbar,项目名称:NewVision,代码行数:31,代码来源:CameraDialog.cpp

示例2: DrawSeatedActiveCircle

void COpenHoldemView::DrawSeatedActiveCircle(const int chair) {
	CPen		*pTempPen = NULL, oldpen;
	CBrush	*pTempBrush = NULL, oldbrush;
	int			left = 0, top = 0, right = 0, bottom = 0;
	CDC			*pDC = GetDC();

	// Background color
	pDC->SetBkColor(COLOR_GRAY);

	// Figure placement of circle
	left = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] - CARDSIZEX - 6;
	top = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] - CARDSIZEX - 5;
	right = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] + CARDSIZEX + 5;
	bottom = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] + CARDSIZEX + 5;

	pTempPen = (CPen*)pDC->SelectObject(&_black_pen);
	oldpen.FromHandle((HPEN)pTempPen);					// Save old pen

	if (p_scraper_access->IsPlayerActive(chair))
	{
		pTempBrush = (CBrush*)pDC->SelectObject(&_white_brush);
	}
	else 
	{
		pTempBrush = (CBrush*)pDC->SelectObject(&_gray_brush);
	}
	oldbrush.FromHandle((HBRUSH)pTempBrush);			// Save old brush

	pDC->Ellipse(left, top, right, bottom);

	// Restore original pen and brush
	pDC->SelectObject(oldpen);
	pDC->SelectObject(oldbrush);
	ReleaseDC(pDC);
}
开发者ID:Haskabab,项目名称:openholdembot,代码行数:35,代码来源:OpenHoldemView.cpp

示例3: DrawDealerButton

void COpenHoldemView::DrawDealerButton(const int chair) {
	CPen		*pTempPen = NULL, oldpen;
	CBrush	*pTempBrush = NULL, oldbrush;
	int			left = 0, top = 0, right = 0, bottom = 0;
	CDC			*pDC = GetDC();

	// Background color
	pDC->SetBkColor(COLOR_GRAY);

	// Figure placement of circle
	left = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] - 8;
	top = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] - 8;
	right = _client_rect.right * pc[p_tablemap->nchairs()][chair][0] + 8;
	bottom = _client_rect.bottom * pc[p_tablemap->nchairs()][chair][1] + 8;

  pTempPen = (CPen*)pDC->SelectObject(&_black_pen);
	oldpen.FromHandle((HPEN)pTempPen);					// Save old pen
	pTempBrush = (CBrush*)pDC->SelectObject(&_red_brush);
	oldbrush.FromHandle((HBRUSH)pTempBrush);			// Save old brush

	pDC->Ellipse(left, top, right, bottom);

	// Restore original pen and brush
	pDC->SelectObject(oldpen);
	pDC->SelectObject(oldbrush);
	ReleaseDC(pDC);
}
开发者ID:Haskabab,项目名称:openholdembot,代码行数:27,代码来源:OpenHoldemView.cpp

示例4: OnPaint

void Cycle::OnPaint()
{
	CPaintDC dc(this); 
		
	CDC memDC;
	
	RECT dialog_Rect;
	this->GetClientRect(&dialog_Rect);

	CBitmap b;

	b.CreateCompatibleBitmap( &dc, dialog_Rect.right, dialog_Rect.bottom);
	memDC.CreateCompatibleDC( &dc ) ;
	
	memDC.SelectObject( &b );

	CRect rect(0, 0, 0 + lenghtBalloon, 0 + lenghtBalloon);	

	HBRUSH hBrush = CreateSolidBrush(lRGBMas[numRGB]);
	memDC.SelectObject(hBrush);
	memDC.Ellipse(&rect);

	DeleteObject(hBrush);
	
	dc.BitBlt(0, 0, dialog_Rect.right, dialog_Rect.bottom,
           &memDC,
           0, 0,
           SRCCOPY);
}
开发者ID:russov,项目名称:ssits,代码行数:29,代码来源:Cycle.cpp

示例5: DrawH

void CVslider::DrawH()
{
	CDC *pdc=GetDC();
	CDC dc;
	dc.CreateCompatibleDC(pdc);
	CBitmap map,*old;
	CRect rect;
	GetClientRect(&rect);
	map.CreateCompatibleBitmap(pdc,rect.right,rect.bottom);
	old=dc.SelectObject(&map);
	dc.BitBlt(0,0,rect.right,rect.bottom,&m_dcBk,0,0,SRCCOPY);
	int center=(rect.right-4)/2;
	dc.FillSolidRect(center,0,4,rect.bottom,RGB(239,248,255));
	CBrush brush,*oldbrush;
	brush.CreateSolidBrush(RGB(140,206,238));
	oldbrush=dc.SelectObject(&brush);
	dc.Ellipse(0,hx,rect.right,14+hx);
	pdc->BitBlt(0,0,rect.right,rect.bottom,&dc,0,0,SRCCOPY);
	dc.SelectObject(oldbrush);
	brush.DeleteObject();
	//pdc->Rectangle(0,hx,rect.right,8+hx);
	dc.SelectObject(old);
	dc.DeleteDC();
	this->ReleaseDC(pdc);
}
开发者ID:Cay0621,项目名称:Cpp,代码行数:25,代码来源:Vslider.cpp

示例6: paintPosition

void AbstractGame::paintPosition(CDC &dc, int pos) {
  const Point2D &p = m_brickPositions[pos];
  dc.Ellipse((int)(p.x-POSSIZE),(int)(p.y-POSSIZE),(int)(p.x+POSSIZE),(int)(p.y+POSSIZE));

  if(m_showNumbers && isOccupied(pos)) {
    textOut(dc, (int)(p.x - ((pos>9)?8:4)), (int)(p.y-8), format(_T("%d"), pos));
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:8,代码来源:Game.cpp

示例7: draw

	void GUIEdge::draw(CDC& context) const
	{
		context.CreatePen(PS_SOLID, 1, visible ? RGB(0, 0, 0) : RGB(223, 223, 223));
		context.MoveTo(side1->getX(), side1->getY());
		context.LineTo(side2->getX(), side2->getY());
		if (blocked)
			context.Ellipse(getX() - 16, getY() - 16, getX() + 16, getY() + 16);
		drawLabel(context, 0, 16);
		context.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	}
开发者ID:Quantumplation,项目名称:SimonLDPi,代码行数:10,代码来源:GUIEdge.cpp

示例8: OnDaraRound

void CMyView::OnDaraRound()
{
    // TODO: Add your command handler code here
    CDC *PDC;
    //CPen mypen(PS_DOT,1,RGB(0,255,0));
    CPen mypen(PS_DASH,1,RGB(0,255,0));
    PDC=GetDC();
    CPen *pOldPen=PDC->SelectObject(&mypen);
    PDC->Ellipse(10,20,110,120);      //画圆
    PDC->SelectObject(pOldPen);
    ReleaseDC(PDC);
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:12,代码来源:绘图程序View.cpp

示例9: brush

static void 
MakeLightBitmap(CBitmap *bitmap, CPaintDC *dc, CRect *rect, COLORREF color)
{
	CBrush brush(dc->GetNearestColor(GetSysColor(COLOR_3DFACE)));
	CBrush colorBrush(dc->GetNearestColor(color));
	CPen pen(PS_SOLID, 1, dc->GetNearestColor(GetSysColor(COLOR_3DFACE)));
	CDC lightDC;
	CRect workRect;

	//Make the bitmap we'll work on:
	lightDC.CreateCompatibleDC(dc);
	bitmap->CreateCompatibleBitmap(dc,
							rect->Width(), 
							rect->Height());
	lightDC.SelectObject(bitmap);

	//The first step is to blank out the background
	lightDC.SelectObject(&brush);
	lightDC.SelectObject(&pen);

	lightDC.Rectangle(0, 0, rect->Width(), rect->Height());

	//Next, get a black pen and make a circle...
	pen.DeleteObject();
	pen.CreatePen(PS_SOLID, 1, dc->GetNearestColor(RGB(0, 0, 0)));
	lightDC.SelectObject(&pen);
	lightDC.Ellipse(rect);
	workRect = *rect;
	workRect.DeflateRect(LIGHT_WIDTH / 4, LIGHT_HEIGHT / 4);
	lightDC.Ellipse(workRect);

	//Last, fill it with the appropriate color:
	//Next, get a black pen and make a circle...
	lightDC.SelectObject(colorBrush);
	lightDC.FloodFill(LIGHT_WIDTH / 2, 
					  LIGHT_HEIGHT / 2, 
					  dc->GetNearestColor(RGB(0, 0, 0)));
}
开发者ID:ysangkok,项目名称:pgpfone,代码行数:38,代码来源:CSoundLight.cpp

示例10: OnDrawEllipse

void CMyView::OnDrawEllipse()
{
    // TODO: Add your command handler code here
    CDC *pDC;
    pDC=GetWindowDC();

    pDC->SetROP2(R2_XORPEN);

    CBrush mybrush(HS_CROSS,RGB(0,255,0));
    CBrush *pOldBrush=pDC->SelectObject(&mybrush);

    pDC->Ellipse(35,110,225,210);       //画椭圆

    pDC->SelectObject(pOldBrush);
    ReleaseDC(pDC);
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:16,代码来源:绘图程序View.cpp

示例11: draw

void  MyCircle::draw(CDC& dc)const
{
	if (enable)
	if (isPoint())
	{
		return ;
	}
	else
	{
		CPen pen(m_style,m_width,m_clr); 
		CPen *penOld = dc.SelectObject( &pen ); 
		dc.SelectStockObject(NULL_BRUSH);   
		
		int r = (int)sqrt((_x1-_x2)*(_x1-_x2)+(_y1-_y2)*(_y1-_y2));
		dc.Ellipse(_x1-r,_y1-r,_x1+r,_y1+r);

		dc.SelectObject(penOld);
		pen.DeleteObject();
	}
}
开发者ID:fxia22,项目名称:PicManage,代码行数:20,代码来源:MyCircle.cpp

示例12: OnDraw


//.........这里部分代码省略.........


		CBrush* pOldBr = myDc->SelectObject( &gray_hatch_br );

		std::vector<CCell>::iterator raft_iter;
		raft_iter = CGeneral::CellArray.begin();
		CCell * p_Raft = raft_iter;
		for(; raft_iter  != CGeneral::CellArray.end(); raft_iter++)
		{
			p_Raft = raft_iter;



			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
//			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_prot_conc = p_Raft->GetIFN_prot_conc();
//			double normalized_IFN_prot_conc = IFN_prot_conc/CGeneral::IFN_prot_maxLevel;

			if( p_Raft->IsActivated() )
			{
				CBrush br;
 				double RIGI_rna_conc = p_Raft->GetRIGI_rna_conc();
				int val=0;
				if(CGeneral::DrawAgs)
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
				else
					double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();


				if( !p_Raft->IsInfected() )//not infected
				{
					br.CreateHatchBrush(HS_BDIAGONAL, RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x  -X, p_Raft->Location.y - Y); 

				} 	           
				else// infected
				{
					if( CGeneral::step != 1)
					{
						CBrush* pSMBr = myDc->SelectObject( &red_br );
						myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
									p_Raft->Location.x  -X, p_Raft->Location.y  - Y); 
					}
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}

					br.CreateSolidBrush(RGB( 128, 128, 128 ));
					CBrush* pSMBr = myDc->SelectObject( &br );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X, p_Raft->Location.y - Y); 
					if(p_Raft->m_blinking_counter == p_Raft->m_blinking_const)
					{
						p_Raft->m_blinking_counter = 0;
						p_Raft->m_justChangedStatus = !p_Raft->m_justChangedStatus;
					}
					else{p_Raft->m_blinking_counter++;}
				}

			} // if	                 
			else // not activated
开发者ID:ls233,项目名称:abm1.7P,代码行数:67,代码来源:SurfaceView.cpp

示例13: OnPaint

void CTestClockDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트

        SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

        // 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // 아이콘을 그립니다.
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CPaintDC dcPaint(this); // device context for painting

        CDC dc;
        if (dc.CreateCompatibleDC(&dcPaint))
        {
            CRect rect;
            GetClientRect(rect);

            CBitmap bitmap;
            if (bitmap.CreateCompatibleBitmap(&dcPaint, rect.Width(), rect.Height()))
            {
                CBitmap* pOldBitmap = dc.SelectObject(&bitmap);

                CBrush bgBrush;
                bgBrush.CreateSolidBrush(GetSysColor(COLOR_3DFACE));

                dc.FillRect(rect, &bgBrush);

                // Draw the minute gradation

                CPen* pOldPen = static_cast<CPen*>(dc.SelectStockObject(BLACK_PEN));
                CBrush* pOldBrush = static_cast<CBrush*>(dc.SelectStockObject(DKGRAY_BRUSH));

                int i;

                for (i = 0; i < MINUTE_COUNT; i++)
                    dc.Ellipse(m_arrMinuteGrad[i].x - m_nMinuteGradSize, m_arrMinuteGrad[i].y - m_nMinuteGradSize,
                               m_arrMinuteGrad[i].x + m_nMinuteGradSize, m_arrMinuteGrad[i].y + m_nMinuteGradSize);

                dc.SelectObject(pOldBrush);

                // Draw the hour gradation

                CPen bluePen;
                bluePen.CreatePen(PS_SOLID, 1, RGB(0, 0, 255));

                pOldPen = dc.SelectObject(&bluePen);

                CBrush lightBlueBrush;
                lightBlueBrush.CreateSolidBrush(RGB(0, 128, 192));

                pOldBrush = dc.SelectObject(&lightBlueBrush);

                for (i = 0; i < HOUR_COUNT; i++)
                    dc.Ellipse(m_arrHourGrad[i].x - m_nHourGradSize, m_arrHourGrad[i].y - m_nHourGradSize,
                               m_arrHourGrad[i].x + m_nHourGradSize, m_arrHourGrad[i].y + m_nHourGradSize);

                dc.SelectObject(pOldBrush);
                dc.SelectObject(pOldPen);

                // Draw the hour hand

                pOldPen = static_cast<CPen*>(dc.SelectStockObject(BLACK_PEN));
                pOldBrush = static_cast<CBrush*>(dc.SelectStockObject(LTGRAY_BRUSH));

                dc.Polygon(m_pointHour, HOUR_HAND_POLYGON_COUNT);

                dc.SelectObject(pOldBrush);

                // Draw the minute hand

                pOldBrush = static_cast<CBrush*>(dc.SelectStockObject(GRAY_BRUSH));

                dc.Polygon(m_pointMinute, MINUTE_HAND_POLYGON_COUNT);

                dc.SelectObject(pOldBrush);
                dc.SelectObject(pOldPen);

                // Draw the second hand

                CPen penSecondHand;
                penSecondHand.CreatePen(PS_SOLID, m_nSecondHandSize, RGB(0, 0, 0));

                pOldPen = dc.SelectObject(&penSecondHand);

                dc.MoveTo(m_pointSecondFrom);
                dc.LineTo(m_pointSecondTo);

                // Draw the center point
//.........这里部分代码省略.........
开发者ID:reveur2016,项目名称:TestClock,代码行数:101,代码来源:TestClockDlg.cpp

示例14: OnPaint

void CDoubleBufferDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트입니다.

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// 아이콘을 그립니다.
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
#ifndef DOUBLE
		CPaintDC dc(this);
		int x, y;
		CRect rect;
		GetClientRect(&rect);

		CPen *oldPen;
		CPen BlackPen(PS_SOLID, 1, RGB(0,0,0));
		CPen GreenPen(PS_SOLID, 1, RGB(0,255,0));
		CPen BluePen(PS_SOLID, 5, RGB(0,0,255));
		oldPen = dc.SelectObject(&BlackPen);

		for (x = 0; x < rect.right; x += 10)
		{
			dc.MoveTo(x, 0);
			dc.LineTo(x, rect.bottom);
		}

		for (y = 0; y < rect.bottom; y += 10)
		{
			dc.MoveTo(0, y);
			dc.LineTo(rect.right, y);
		}

		dc.SelectObject(&GreenPen);

		dc.Ellipse(ex - r, ey - r, r * 2, r * 2);
		dc.SelectObject(&BluePen);
		dc.Ellipse(ex - r, ey - r, r * 2, r * 2);

		dc.SelectObject(oldPen);
#else
		CPaintDC paintdc(this);
		CDC dc;
		CBitmap dcBitmap, *pOldBitmap;
		CPen BlackPen(PS_SOLID, 1, RGB(0,0,0));
		CPen GreenPen(PS_SOLID, 1, RGB(0,255,0));
		CPen BluePen(PS_SOLID, 5, RGB(0,0,255));
		CPen *pOldPen;

		int x, y;
		CRect rect;
		GetClientRect(&rect);

		dc.CreateCompatibleDC(&paintdc);
		dcBitmap.CreateCompatibleBitmap(&paintdc, rect.Width(), rect.Height());
		pOldBitmap = dc.SelectObject(&dcBitmap);
		dc.PatBlt(0, 0, rect.Width(), rect.Height(), WHITENESS);

		pOldPen = dc.SelectObject(&BlackPen);

		for (x = 0; x < rect.right; x += 10)
		{
			dc.MoveTo(x, 0);
			dc.LineTo(x, rect.bottom);
		}

		for (y = 0; y < rect.bottom; y += 10)
		{
			dc.MoveTo(0, y);
			dc.LineTo(rect.right, y);
		}

		dc.SelectObject(&GreenPen);

		dc.Ellipse(ex - r, ey - r, ex - r + r * 2, ey - r + r * 2);
		dc.SelectObject(&BluePen);
		dc.Ellipse(ex - r, ey - r, ex - r + r * 2, ey - r + r * 2);

		paintdc.BitBlt(0, 0, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
		
		dc.SelectObject(pOldPen);
		dc.SelectObject(pOldBitmap);
		
		ReleaseDC(&dc);
		DeleteDC(dc);
#endif
		CDialogEx::OnPaint();
	}
//.........这里部分代码省略.........
开发者ID:enildne,项目名称:zest,代码行数:101,代码来源:DoubleBufferDlg.cpp

示例15: onDrawSelf

void CScanView::onDrawSelf(CDCHandle dc)
{
    CDC memDC;
    CBitmap memBitmap;
    memDC.CreateCompatibleDC(dc);
    CRect clientRECT;
    this->GetClientRect(&clientRECT);

    memBitmap.CreateCompatibleBitmap(dc,clientRECT.Width() , clientRECT.Height());
    HBITMAP oldBitmap = memDC.SelectBitmap(memBitmap);

    HPEN oldPen = memDC.SelectStockPen(DC_PEN);
   
    HBRUSH oldBrush = memDC.SelectStockBrush(NULL_BRUSH);
    HFONT  oldFont  = memDC.SelectFont(stdfont);

    memDC.SetBkMode(0);
    memDC.SetTextColor(RGB(90, 90, 90));
    memDC.SetTextAlign(TA_CENTER | TA_BASELINE);

    memDC.SetDCPenColor(RGB(60,60,60));

    CPoint centerPt(clientRECT.Width()/2, clientRECT.Height()/2);
    const int maxPixelR = min(clientRECT.Width(), clientRECT.Height())/2 - DEF_MARGIN;
    const float distScale = (float)maxPixelR/_current_display_range;

    char txtBuffer[100];

    // plot rings
    for (int angle = 0; angle<360; angle += 30) {
        float rad = (float)(angle*PI/180.0);

        float endptX = sin(rad)*(maxPixelR+DEF_MARGIN/2) + centerPt.x;
        float endptY = centerPt.y - cos(rad)*(maxPixelR+DEF_MARGIN/2);

        memDC.MoveTo(centerPt);
        memDC.LineTo((int)endptX, (int)endptY);

        sprintf(txtBuffer, "%d", angle);
        memDC.TextOutA((int)endptX, (int)endptY, txtBuffer);

    }

    for (int plotR = maxPixelR; plotR>0; plotR-=DISP_RING_ABS_DIST)
    {
        memDC.Ellipse(centerPt.x-plotR, centerPt.y-plotR,
            centerPt.x+plotR, centerPt.y+plotR);

        sprintf(txtBuffer, "%.1f", (float)plotR/distScale);
        memDC.TextOutA(centerPt.x, centerPt.y-plotR, txtBuffer);
    }

    memDC.SelectStockBrush(DC_BRUSH);
    memDC.SelectStockPen(NULL_PEN);

    int picked_point = 0;
    float min_picked_dangle = 100;

    for (int pos =0; pos < (int)_scan_data.size(); ++pos) {
        float distPixel = _scan_data[pos].dist*distScale;
        float rad = (float)(_scan_data[pos].angle*PI/180.0);
        float endptX = sin(rad)*(distPixel) + centerPt.x;
        float endptY = centerPt.y - cos(rad)*(distPixel);

        float dangle = fabs(rad - _mouse_angle);

        if (dangle<min_picked_dangle) {
            min_picked_dangle = dangle;
            picked_point = pos;
        }

        int brightness = (_scan_data[pos].quality<<1) + 128;
        if (brightness>255) brightness=255;

        memDC.FillSolidRect((int)endptX-1,(int)endptY-1, 2, 2,RGB(0,brightness,brightness));
    }

    memDC.SelectFont(bigfont);

    memDC.SetTextAlign(TA_LEFT | TA_BASELINE);
    memDC.SetTextColor(RGB(255,255,255));

    sprintf(txtBuffer, "%.1f Hz (%d RPM)", _scan_speed, (int)(_scan_speed*60));
    memDC.TextOutA(DEF_MARGIN, DEF_MARGIN + 40, txtBuffer);

    if ((int)_scan_data.size() > picked_point) {
        float distPixel = _scan_data[picked_point].dist*distScale;
        float rad = (float)(_scan_data[picked_point].angle*PI/180.0);
        float endptX = sin(rad)*(distPixel) + centerPt.x;
        float endptY = centerPt.y - cos(rad)*(distPixel);


        memDC.SetDCPenColor(RGB(129,10,16));
        memDC.SelectStockPen(DC_PEN);
        memDC.MoveTo(centerPt.x,centerPt.y);
        memDC.LineTo((int)endptX,(int)endptY);
        memDC.SelectStockPen(NULL_PEN);

        memDC.FillSolidRect((int)endptX-1,(int)endptY-1, 2, 2,RGB(255,0,0));

//.........这里部分代码省略.........
开发者ID:RutgersRoboticsResearch,项目名称:Slam-Bot,代码行数:101,代码来源:scanView.cpp


注:本文中的CDC::Ellipse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。