Example #1
0
// --------------------------------------------------------------------------
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);
	
}
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);
}
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);
}
Example #4
0
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);
}
Example #5
0
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);
}
Example #6
0
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));
  }
}
Example #7
0
	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));
	}
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);
}
Example #9
0
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)));
}
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);
}
Example #11
0
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();
	}
}
Example #12
0
void CSurfaceView::OnDraw(CDC* pDC) 
{
//	return;
	// TODO: Add your specialized code here and/or call the base class
//	if(!CGeneral::RaftArray.size())	return;
	if(CGeneral::step == 0) return;
	CGeneral::is_draw_finished = false;

	clock_t startd, find;
	double	duration = 0;
	startd = clock();
	//yellow, cremovi
	static 	COLORREF colors[255*255*255];
	for(int r=0; r<255 ; r++)	{
		for(int g=0; g<255 ; g++)	{
			for(int b=0; b<255 ; b++)	{
				colors[r+g+b]= RGB( 255-r, 255-g, 255-b);
			}
		}
	}


	static 	COLORREF col[16] = { RGB( 255, 0, 0 ), RGB( 0, 255, 0 ), //krasnii-0, zelyonii-1
		RGB( 0, 0, 255), RGB( 0, 255, 255 ), //sinii-2, goluboiCian-3
		RGB( 255, 0, 255), RGB( 255, 255, 0 ), //malinovii-4, jyoltii-5
		RGB( 192, 192, 192), RGB( 80, 0, 80 ), //serii-6, t-malinovii-7
		RGB( 255, 255, 255), RGB( 80, 80, 0 ), //serii-8, t-jyoltii-9, 
		RGB( 80, 80, 0 ), RGB( 0, 0, 80 ), //4yornii-10, tyomn. golub - 11 
		RGB( 250, 166, 70 ), RGB( 207, 10, 243 ), //orange-12, tyomn. fioletovii - 13 
		RGB( 128, 128, 0 ), RGB( 0, 0, 0 )}; // seri 15

	GetClientRect(m_ClientRect );
	int oldBkMode = pDC->SetBkMode(TRANSPARENT);
	
	static int key = 1;

	DrawSize = (m_ClientRect.Width( ) < m_ClientRect.Height( ) )
		? m_ClientRect.Width( ) : m_ClientRect.Height( ) ;
	if(DrawSize > GRID_SIZE)  DrawSize = GRID_SIZE;
	else
	{	
		minZoom = (GRID_SIZE-1)/DrawSize + 1 ;
		if(m_PartGrid < minZoom)
		{
			m_PartGrid = minZoom;
		}
	}
	DrawSize = GRID_SIZE/m_PartGrid;
	m_OptionDlg->SetZoom(m_PartGrid, GRID_SIZE/m_PartGrid,num);
	int xp = (m_PartGridNum - 1)%m_PartGrid ;
	int yp = (m_PartGridNum - 1) / m_PartGrid ;
	X = 0 + DrawSize * xp;
	Y = 0 + DrawSize * yp;
	X1 = X + DrawSize; 
	Y1 = Y + DrawSize;


//-----------------------------------------------------------------		
	CDC * myDc;
	CDC memdc;
	CBitmap bmp, *poldbmp;
	isMemDc = IsMemDc && !( CGeneral::DrawRaftIndexes 
		|| CGeneral::DrawRecIndexes
		|| CGeneral::DrawSigMolInd || CGeneral::DrawSigMolNames
		|| CGeneral::DrawRecNames);

	if(isMemDc)
	{
		// Create a compatible memory DC
		memdc.CreateCompatibleDC( pDC);
		bmp.CreateCompatibleBitmap (pDC, m_ClientRect.Height(), m_ClientRect.Height()); 
		//bmp.CreateCompatibleBitmap (pDC, DrawSize, DrawSize); 
		// Select the new bitmap object into the memory device context. 
		poldbmp = memdc.SelectObject( &bmp );

		memdc.BitBlt( 0,0,m_ClientRect.Height(), m_ClientRect.Height(),&memdc, 0, 0, WHITENESS );  
		myDc = &memdc;
	}
	else myDc = pDC;
	myDc->SetMapMode(MM_ISOTROPIC);
	SetWindowExtEx(*myDc,DrawSize,DrawSize,NULL);
	SetViewportExtEx(*myDc,m_ClientRect.right, -m_ClientRect.bottom,NULL);
	SetViewportOrgEx(*myDc,0,m_ClientRect.bottom,NULL);	
//-----------------------------------------------------------------		





	double sd = sqrt(DrawSize /27.) ;

	if( CGeneral::DrawSigMol ){

		double sd_sm = sd-1;
		if(sd_sm < 1) sd_sm = 1; //   ?????????????????

		CBrush br;
		br.CreateSolidBrush(col[1]);

		for(int in=0; in<GRID_SIZE ; in++)
		{
			for(int in1=0; in1<GRID_SIZE ; in1++)
			{
				CBrush br1;
				double IFN_prot_conc = CGeneral::grid.m_Grid[in1][in].array[SM];
				if(IFN_prot_conc == 0){
					continue;
				}
				int normalized_IFN_prot_conc = floor(IFN_prot_conc);
				br1.CreateSolidBrush(colors[normalized_IFN_prot_conc]);
				CBrush* pSMBr = myDc->SelectObject( &br1 );

	//			myDc->Rectangle(in - X, in1 -Y,	in + sd_sm -X, in1 + sd_sm - Y); 
				CRect rect(in - X, in1 -Y, in + sd_sm -X, in1 + sd_sm - Y);
				myDc->FillRect(&rect ,&br1); 

				if(CGeneral::DrawSigMolNames)
				{
					char buf[30] = "IFNprot: ";
					char buf5[10];
					itoa(IFN_prot_conc,buf5,10);
					strncat(buf, buf5, 10);//add coma
					myDc->TextOut(in - X, in1 -Y, buf, strlen(buf));
				}	

			}
		}

	}



	/////////////////// begin drawing rafts //////////////////////////////////
	if( CGeneral::DrawRafts )
	{
		CBrush gray_hatch_br, red_br, grey_br;
		gray_hatch_br.CreateHatchBrush(HS_BDIAGONAL, col[15]);
		grey_br.CreateSolidBrush(col[15]);
		red_br.CreateSolidBrush(col[1]);


		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
			{
				CBrush brt,brt1;
				int val_msg;
				int val_prot;
				if(!CGeneral::DrawAgs) {//DDX58
//					if(CGeneral::DrawAgIndexes)//msg
						val_msg = p_Raft->GetRIGI_rna_conc();
//					else //prot
						val_prot = p_Raft->GetRIGI_prot_conc();
				}
				else {//IFNB1
//					if(CGeneral::DrawAgIndexes)//IFNB1
						val_msg = p_Raft->GetIFN_rna_conc();
//					else   //prot
						val_prot = p_Raft->GetIFN_prot_conc();
				}

				if( p_Raft->IsInfected() )//NOT UNFECTED		
				{
					brt.CreateSolidBrush(colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateSolidBrush(colors[val_msg]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 

/*					myDc->SetTextColor(col[0]); 
					char buf[30] = "*";
					myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
						buf, strlen(buf));
						*/

				} // if	  
				else//not infected
				{	
//					brt.CreateSolidBrush(colors[col[2]]);
					brt.CreateHatchBrush(HS_BDIAGONAL, colors[val_prot]);
					CBrush* pSMBr = myDc->SelectObject( &brt );
					myDc->Ellipse(p_Raft->Location.x - X-1, p_Raft->Location.y -Y-1,
								p_Raft->Location.x -X+sd+1, p_Raft->Location.y  - Y+sd+1); 

					brt1.CreateHatchBrush(HS_FDIAGONAL, colors[val_prot]);
					pSMBr = myDc->SelectObject( &brt1 );
					myDc->Ellipse(p_Raft->Location.x - X, p_Raft->Location.y -Y,
								p_Raft->Location.x -X+sd, p_Raft->Location.y  - Y+sd); 
				}
				
			}
			myDc->SetTextColor(col[0]); 
			int boundTypeIR = p_Raft->Get_boundTypeIR();
			if(boundTypeIR)	{
				char buf1[3] = "|";
				char buf2[3] = "--";
				char buf3[3]="";
				char buf[30] = "";
				char buf5[10];
				if((boundTypeIR%2)){
					strncat(buf3, buf1, 3);//add coma					
				}else{
					strncat(buf3, buf2, 3);//add coma					
				}
				myDc->TextOut(p_Raft->Location.x - X+1, p_Raft->Location.y -Y+1, 
					buf3, strlen(buf3));
			}
			myDc->SetTextColor(RGB(0,0,0)); 

			if( !p_Raft->IsInfected() ) {//not infected
			

			} 	           
			else {// infected
			
			}

			/*

			double rigI_rna_conc = p_Raft->GetRIGI_rna_conc();
			double normalized_rigI_rna_conc = rigI_rna_conc/CGeneral::RIGI_rna_maxLevel;
			double IFN_rna_conc = p_Raft->GetIFN_rna_conc();
			double normalized_IFN_rna_conc = IFN_rna_conc/CGeneral::IFN_rna_maxLevel;

			int sd_rna = sd+3;
			int val;
			if(CGeneral::DrawAgs)
				val = 255 - normalized_rigI_rna_conc * 255;
			else
				val = 255 - normalized_IFN_rna_conc * 255;
			CBrush br_rna;
			br_rna.CreateSolidBrush(RGB( val, val, val ));
			CBrush* pSMBr = myDc->SelectObject( &br_rna );
//			myDc->Ellipse(p_Raft->m_shape.Centroid().x - X, p_Raft->m_shape.Centroid().y -Y,
//				p_Raft->m_shape.Centroid().x + sd_rna -X, p_Raft->m_shape.Centroid().y + sd_rna - Y); 

*/



			if(CGeneral::DrawRaftIndexes)
			{
				char buf[30]="";
				char buf5[10]="";
				if(!CGeneral::DrawAgs){
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "DDX58: ", 10);//add coma
						itoa(p_Raft->GetRIGI_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
						strncat(buf, ", RIGI: ", 10);//add coma
						itoa(p_Raft->GetRIGI_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
				}
				else{
//					if(CGeneral::DrawAgIndexes)	{
						strncat(buf, "IFNB:", 10);//add coma
//						buf = "IFNB: ";
						itoa(p_Raft->GetIFN_rna_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));
//					}
//					else{
/*						strncat(buf, ", IFNb:", 10);//add coma
						itoa(p_Raft->GetIFN_prot_conc(),buf5,10);
						strncat(buf, buf5, 10);//add coma
						myDc->TextOut(p_Raft->Location.x - X, p_Raft->Location.y -Y, 
							buf, strlen(buf));*/
//					}

				}
			}

		}
		myDc->SelectObject( pOldBr);
		num++;
		myDc->SetBkMode(oldBkMode);
	}
//------------------------ end drawing rafts ---------------------------//

	
	if(isMemDc)
	{
		pDC->StretchBlt( 0,0,m_ClientRect.Height( ) ,m_ClientRect.Height( ),&memdc, 0, 0,
			DrawSize, DrawSize, SRCCOPY); 
		//pDC->BitBlt( 0,0,DrawSize, DrawSize,&memdc, 0, 0, SRCCOPY ); 
		bmp.DeleteObject();
		memdc.DeleteDC();
	}
	pDC->SetBkMode(oldBkMode);

	CGeneral::is_draw_finished = true;
	if(stepGl == 10 || stepGl == 1000 || stepGl == 10000
		|| stepGl == 100000 || stepGl == 300000 || stepGl == 2000000)
	{
		find = clock();
		duration = (double)(find - startd) / CLOCKS_PER_SEC;	
//		CGeneral::out << "\n Draw duration " << duration << " step " << stepGl << endl;
	}
}
Example #13
0
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

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

                dc.Ellipse(m_pointCenter.x - m_nCenterPointSize, m_pointCenter.y - m_nCenterPointSize,
                           m_pointCenter.x + m_nCenterPointSize, m_pointCenter.y + m_nCenterPointSize);

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

                dcPaint.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);

                dc.SelectObject(pOldBitmap);
            }
        }
    }
}
Example #14
0
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();
	}
}
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));

        memDC.SetTextColor(RGB(255,0,0));
        sprintf(txtBuffer, "Current: %.2f Deg: %.2f", _scan_data[picked_point].dist,  _scan_data[picked_point].angle);
        memDC.TextOutA(DEF_MARGIN, DEF_MARGIN + 20, txtBuffer);
    }

    dc.BitBlt(0, 0, clientRECT.Width(), clientRECT.Height()
        , memDC, 0, 0, SRCCOPY);

    memDC.SelectFont(oldFont);
    memDC.SelectBrush(oldBrush);
    memDC.SelectPen(oldPen);
    memDC.SelectBitmap(oldBitmap);

    
}
Example #16
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;
}
/*--------------------------------------*/
void CFrontier_API_SVDlg::OnPaitMap(void)
{
		if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		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;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
	int m_CXpos=0,m_CYpos=0,m_CorYLenth = 160,m_CorXLenth = 160;
	int GraphLimit;
	struct 
	{
		int RobRadia;// 机器人的半径
	}VisRobot = {25};// 机器人的图形显示参数
	CRect rect2,rect3;

	CWnd* pWnd = GetDlgItem(IDC_LOCDRAW);//
	CDC* pControlDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();

	pWnd->GetWindowRect(rect2);
	m_CXpos = (rect2.right-rect2.left)/2;
	m_CYpos = (rect2.bottom-rect2.top)/2;
	GraphLimit = 150;
	pControlDC->MoveTo(m_CXpos,m_CYpos-m_CorYLenth);// 机器人朝向,纵轴
	pControlDC->LineTo(m_CXpos,m_CYpos+m_CorYLenth);
	pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-5, m_CYpos-m_CorYLenth-5,m_CXpos+5, m_CYpos-m_CorYLenth+5 );

	pControlDC->MoveTo(m_CXpos-m_CorXLenth,m_CYpos);// 机器人横轴
	pControlDC->LineTo(m_CXpos+m_CorXLenth,m_CYpos);
	pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-m_CorXLenth-5, m_CYpos-5,m_CXpos-m_CorXLenth+5, m_CYpos+5 );

	pControlDC->SelectStockObject(HOLLOW_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-140-VisRobot.RobRadia, m_CYpos-140-VisRobot.RobRadia,m_CXpos+140+VisRobot.RobRadia, m_CYpos+140+VisRobot.RobRadia);	// 远处
	pControlDC->Ellipse(m_CXpos-20-VisRobot.RobRadia, m_CYpos-20-VisRobot.RobRadia,m_CXpos+20+VisRobot.RobRadia,m_CYpos+20+VisRobot.RobRadia);	//近处

	float temp_dist,temp_ang;
	int temp_far,temp_near;
	temp_far = 2500;
	temp_near = 300;
	int m_tempXPos;
	int m_tempYPos;
	BOOL temp_Blob[6];
	
	temp_Blob[0] = m_Blob1;
	temp_Blob[1] = m_Blob2;
	temp_Blob[2] = m_Blob3;
	temp_Blob[3] = m_Blob4;
	temp_Blob[4] = m_Blob5;
	temp_Blob[5] = m_Blob6;

	UpdateData(TRUE);

	/*------目标物显示------*/
	for (int k=0;k<6;k++)
	{
		if (temp_Blob[k] && VisionBlob[k][0].area>0)
		{	
			DISTANG temp_DistAng;
			memcpy(&temp_DistAng,&VisionDistAng[k][0],sizeof(temp_DistAng));
			CPen pen,*ppen;
			
			COLORREF ObjColor;
			ObjColor = ColorHLSToRGB((WORD)VisionBlob[k][0].hue,150,240);
			pen.CreatePen(PS_SOLID,1,ObjColor);
			CBrush ObjBrush;
			ObjBrush.CreateSolidBrush(ObjColor);
			pControlDC->SelectObject(&ObjBrush);
			ppen = pControlDC->SelectObject(&pen);
			
			if (temp_DistAng.Dist >= temp_far)
			{
				temp_dist = (float)temp_far;
			}
			else if (temp_DistAng.Dist <= temp_near)
			{
				temp_dist = (float)temp_near;
			}
			else
			{
				temp_dist = (float)temp_DistAng.Dist;
			}
			temp_dist = (temp_dist-temp_near)*120/(temp_far-temp_near+300)+(20+VisRobot.RobRadia);
			temp_ang = temp_DistAng.Angle;
			m_tempXPos = (int)(m_CXpos - temp_dist*sin(temp_ang*PI/180));
			m_tempYPos = (int)(m_CYpos - temp_dist*cos(temp_ang*PI/180));
			if (m_bVision)
				pControlDC->Ellipse(m_tempXPos-10,m_tempYPos-10,m_tempXPos+10,m_tempYPos+10);	
			pen.DeleteObject();
			ppen->DeleteObject();
		}
	}


	pWnd->ReleaseDC(pControlDC);
}
Example #18
0
void MyGraph::DrawSeriesLine(CDC& dc) const
{
	VALIDATE;
	ASSERT_VALID(&dc);
	_ASSERTE(!m_bStackedGraph);

	// Iterate the groups.
	CPoint ptLastLoc(0,0);
	int dataLastLoc(0);

	for (int nGroup = 0; nGroup < GetMaxSeriesSize(); nGroup++) {

		// How much space does each series get (includes inter series space)?
		int nSeriesSpace(0);

		if (m_saLegendLabels.GetSize()) {

			nSeriesSpace = (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)) /
				(int)m_olMyGraphSeries.GetCount();
		}
		else {
			nSeriesSpace = m_nXAxisWidth / (int)m_olMyGraphSeries.GetCount();
		}

		// Determine width of bars.
		int nMaxSeriesSize(GetMaxSeriesSize());
		nMaxSeriesSize = max(nMaxSeriesSize, 1);
		int nBarWidth(nSeriesSpace / nMaxSeriesSize);

		if (1 < m_olMyGraphSeries.GetCount()) {
			nBarWidth = (int) ((double) nBarWidth * INTERSERIES_PERCENT_USED);
		}

		// This is the width of the largest series (no inter series space).
		//int nMaxSeriesPlotSize(GetMaxSeriesSize() * nBarWidth);

		// Iterate the series.
		POSITION pos(m_olMyGraphSeries.GetHeadPosition());

		// Build objects.
		COLORREF crLine(m_dwaColors.GetAt(nGroup));
		CBrush br(crLine);
		CBrush* pBrushOld = dc.SelectObject(&br);
		ASSERT_VALID(pBrushOld);
		CPen penLine(PS_SOLID, 1, crLine);
		CPen* pPenOld = dc.SelectObject(&penLine);
		ASSERT_VALID(pPenOld);

		for (int nSeries = 0; nSeries < m_olMyGraphSeries.GetCount(); ++nSeries) {

			MyGraphSeries* pSeries = m_olMyGraphSeries.GetNext(pos);
			ASSERT_VALID(pSeries);

			// Get x and y location of center of ellipse.
			CPoint ptLoc(0,0);

			ptLoc.x = m_ptOrigin.x + (((nSeries + 1) * nSeriesSpace) -
				(nSeriesSpace / 2));

			int nMaxDataValue(GetMaxDataValue());
			nMaxDataValue = max(nMaxDataValue, 1);
			double dLineHeight(pSeries->GetData(nGroup) * m_nYAxisHeight /
				double(nMaxDataValue));

			ptLoc.y = (int) ((double) m_ptOrigin.y - dLineHeight);


			// Draw line back to last data member.
			if (nSeries > 0 && (pSeries->GetData(nGroup)!=0 || dataLastLoc != 0)) {

				dc.MoveTo(ptLastLoc.x, ptLastLoc.y - 1);
				VERIFY(dc.LineTo(ptLoc.x - 1, ptLoc.y - 1));
			}

			// Now draw ellipse.
			CRect rcEllipse(ptLoc.x - 3, ptLoc.y - 3, ptLoc.x + 3, ptLoc.y + 3);
			if(pSeries->GetData(nGroup)!=0){
				VERIFY(dc.Ellipse(rcEllipse));
			}
			if (m_olMyGraphSeries.GetCount() < 40)
			{
				pSeries->SetTipRegion(nGroup, rcEllipse);
			}

			// Save last pt and data
			ptLastLoc = ptLoc;
			dataLastLoc = pSeries->GetData(nGroup);
		}
		VERIFY(dc.SelectObject(pPenOld));
		penLine.DeleteObject();
		VERIFY(dc.SelectObject(pBrushOld));
		br.DeleteObject();
	}

	int nMaxDataValue = max(GetMaxDataValue(), 1);
	double barTop = m_ptOrigin.y - (double)m_nYAxisHeight *
		(GetAverageDataValue() / (double)nMaxDataValue);
	dc.MoveTo(m_ptOrigin.x, barTop);
	VERIFY(dc.LineTo(m_ptOrigin.x + (m_nXAxisWidth - m_rcLegend.Width() - (GAP_PIXELS * 2)), barTop));
}
Example #19
0
void CVideoWnd::OnPaint()
{
	CPaintDC dc(this);

	//WIDTHHEIGHT
	CRect clrect(m_rectWnd);
	clrect.right -= clrect.left;
	clrect.bottom -= clrect.top;
	clrect.left = 0;
	clrect.top = 0;

	int width = clrect.right - clrect.left;
	int height = clrect.bottom - clrect.top;

	CRect cRect(clrect);
	CDC memDC;
	memDC.CreateCompatibleDC(&dc);
	CDC *pDC = &memDC;
	CBitmap NewMemBmp;
	NewMemBmp.CreateCompatibleBitmap(&dc, width, height);
	CBitmap* pOldMemBmp = pDC->SelectObject(&NewMemBmp);
	if (!m_iStatus) {
		pDC->FillSolidRect(0, 0, clrect.Width(), clrect.Height(), RGB(255,255,255));
	} else if (m_ImageBitmap.GetSafeHandle()) {
		m_ImageBitmap.BitBlt(pDC, CPoint(0,0));
	}

	CFont dxfont;
	dxfont.CreateFontIndirect(&m_textfont);
	CFont* oldfont = (CFont *) pDC->SelectObject(&dxfont);

	//Draw Text
	int textlength = m_textstring.GetLength(); //get number of bytes
	pDC->SetBkMode(TRANSPARENT);
	pDC->SetTextColor(m_rgb);
	pDC->DrawText((char *)LPCTSTR(m_textstring), textlength, &m_tracker.m_rect, m_horzalign | DT_VCENTER | DT_WORDBREAK );

	pDC->SelectObject(oldfont);

	if ((m_bBorderYes) && (regionSHAPE == m_regionType)) {
		double rx = cRect.Width() * m_roundrectFactor;
		double ry = cRect.Height() * m_roundrectFactor;
		double rval = (rx > ry) ? ry : rx;

		CPen borderPen;
		borderPen.CreatePen( PS_SOLID , m_borderSize, m_borderColor );
		CPen* oldPen = (CPen *) pDC->SelectObject(&borderPen);

		LOGBRUSH logbrush;
		logbrush.lbStyle = BS_HOLLOW;
		CBrush borderBrush;
		borderBrush.CreateBrushIndirect(&logbrush);
		CBrush* oldBrush = (CBrush *) pDC->SelectObject(&borderBrush);

		int drawOffset = m_borderSize/2;

		if (m_regionPredefinedShape == regionROUNDRECT) {
			pDC->RoundRect(drawOffset-1, drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset, (int) rval, (int) rval);

		} else if (m_regionPredefinedShape == regionELLIPSE) {
			pDC->Ellipse(drawOffset-1,drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset);
		} else if (m_regionPredefinedShape == regionRECTANGLE) {
			pDC->Rectangle(drawOffset-1, drawOffset-1, cRect.Width()-1-drawOffset, cRect.Height()-1-drawOffset);
		}

		pDC->SelectObject(oldBrush);
		pDC->SelectObject(oldPen);
		borderPen.DeleteObject();
		borderBrush.DeleteObject();
	}

	CDC *pWinDC = &dc;
	pWinDC->BitBlt(0,0,clrect.Width(),clrect.Height(),pDC,0,0,SRCCOPY);

	pDC->SelectObject(pOldMemBmp);
	NewMemBmp.DeleteObject();
	memDC.DeleteDC();

	if (m_bTrackingOn) {
		m_tracker.Draw(pWinDC);
	}
}
Example #20
0
void CRoundSliderCtrl::OnPaint() 
{
	const int nMin = GetRangeMin();
	const int nMax = GetRangeMax()+1;

	const bool bDisabled = !IsWindowEnabled();

	CPaintDC dc(this); // device context for painting

#ifdef USE_MEM_DC
	CMemDC pDC(&dc);
#else
	CDC* pDC = &dc;
#endif

	int nRadius = m_nRadius;

	// Draw (clear) the background
	CRect rc;
	GetClientRect(rc);
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->SelectStockObject(NULL_PEN);
	pDC->FillSolidRect(rc, ::GetSysColor(COLOR_BTNFACE));

	// Draw the sliders channel
	if(!m_bDrawRadioButton)
	{
		DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT));
		DrawCircle(pDC, m_ptCenter, nRadius, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
	}

	int nPos = (((GetPos()-nMin)*360/(nMax-nMin)) + m_nZero + 360) % 360;
	if(m_bInverted) nPos = 360-nPos;

	const double dPos = ((double)(nPos))*pi/180.0;
	CPoint ptKnobCenter;

#pragma warning(disable:4244) // Disable warning "Converting 'double' to 'int', possible loss of data"
	if(m_bDrawRadioButton)
	{
		ptKnobCenter = CPoint(m_ptCenter.x + (nRadius-m_nKnobRadius) * sin(dPos), m_ptCenter.y - (nRadius-m_nKnobRadius) * cos(dPos));
	}
	else
	{
		ptKnobCenter = CPoint(m_ptCenter.x + (nRadius) * sin(dPos), m_ptCenter.y - (nRadius) * cos(dPos));
	}
#pragma warning(default:4244)

	m_ptKnobCenter = ptKnobCenter;

	if(m_bDrawRadioButton)
	{
		nRadius += 2;
	}
	else
	{
		nRadius -= 2;
	}

	if(!bDisabled)
	{
		CBrush* pOldBrush = pDC->SelectObject(CBrush::FromHandle(m_hDialBrush));
		pDC->Ellipse(m_ptCenter.x - nRadius + 1, m_ptCenter.y - nRadius + 1, m_ptCenter.x + nRadius + 1, m_ptCenter.y + nRadius + 1);
		pDC->SelectObject(pOldBrush);
	}

	DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW));
	DrawCircle(pDC, m_ptCenter, nRadius--, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));

	// Draw the knob
	int nKnobRadius = m_nKnobRadius;

	if(m_bDrawRadioButton)
	{
		nKnobRadius *= 4;
		nKnobRadius /= 5;
	}

	const CRect rcKnob(ptKnobCenter.x - nKnobRadius + 2, ptKnobCenter.y - nKnobRadius + 2, ptKnobCenter.x + nKnobRadius, ptKnobCenter.y + nKnobRadius);

	CRgn rgnKnob;
	rgnKnob.CreateEllipticRgnIndirect(rcKnob);
	if(bDisabled)
	{
		pDC->FillRgn(&rgnKnob, CBrush::FromHandle(::GetSysColorBrush(COLOR_BTNFACE)));
	}
	else
	{
		pDC->FillRgn(&rgnKnob, CBrush::FromHandle(m_hKnobBrush));
	}
	rgnKnob.DeleteObject();

	if(m_bDrawRadioButton || m_bDragging)
	{
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT));
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT));
	}
	else
	{
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW));
		DrawCircle(pDC, ptKnobCenter, --nKnobRadius, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW));
	}

	// Draw the focus circle on the inside of the knob
	if(!m_bDrawRadioButton && (GetFocus() == this))
	{
		DrawCircle(pDC, ptKnobCenter, nKnobRadius-2, RGB(0, 0, 0), TRUE);
	}

	// Draw the text
	const CString strFormattedText = OnFormatText();

	if(!strFormattedText.IsEmpty())
	{
		CFont* pOldFont = pDC->SelectObject(&m_font);

		const CSize szExtent = pDC->GetTextExtent(strFormattedText);
		const CPoint ptText = CPoint(m_ptCenter.x - szExtent.cx/2, m_ptCenter.y - szExtent.cy/2);
		const int nOldTextColor = pDC->SetTextColor(m_crText);

		pDC->SetBkMode(TRANSPARENT);
		if(bDisabled)
		{
			pDC->DrawState(ptText, szExtent, strFormattedText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
		}
		else
		{
			pDC->TextOut(ptText.x, ptText.y, strFormattedText);
		}

		// Clean up
		pDC->SelectObject(pOldFont);
		pDC->SetTextColor(nOldTextColor);
	}

	// Don't call CSliderCtrl::OnPaint()
}
Example #21
0
void CSmallPolygonsVisDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

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

		// Center icon in client rectangle
		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;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CPaintDC dc(this);

		CDC mem;
		mem.CreateCompatibleDC(&dc);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(&dc, DRAW_WIDTH, DRAW_HEIGHT);
		mem.SelectObject(&bmp);
		mem.SetBkMode(TRANSPARENT);
		mem.FillSolidRect(0, 0, DRAW_WIDTH, DRAW_HEIGHT, RGB(128, 128, 128));

		LOGFONT font = {};
		font.lfHeight = 12;
		font.lfCharSet = ANSI_CHARSET;
		_tcscpy(font.lfFaceName, _T("Terminal"));
		CFont Font;
		Font.CreateFontIndirect(&font);
		mem.SelectObject(Font);

		for (int i = 0; i < m_sp.Np; ++i) {
			int x = m_sp.x[i], y = m_sp.y[i];
			x = (x * DRAW_WIDTH) / MAX_COORDINATE;
			y = (y * DRAW_HEIGHT) / MAX_COORDINATE;
			TCHAR w[64];
			_stprintf(w, _T("%d"), i);
			mem.SetTextColor(RGB(255, 255, 255));
			mem.TextOut(x + 4, y, w);
		}

		CPen line;
		line.CreatePen(PS_SOLID, 0, RGB(0, 255, 0));
		mem.SelectObject(line);
		for (int start_node : m_sp.polygons) {
			int x = m_sp.x[start_node], y = m_sp.y[start_node];
			x = (x * DRAW_WIDTH) / MAX_COORDINATE;
			y = (y * DRAW_HEIGHT) / MAX_COORDINATE;
			mem.MoveTo(x, y);
			int node = start_node;
			do {
				int next_node = m_sp.connection[node].next;
				int x = m_sp.x[next_node], y = m_sp.y[next_node];
				x = (x * DRAW_WIDTH) / MAX_COORDINATE;
				y = (y * DRAW_HEIGHT) / MAX_COORDINATE;
				mem.LineTo(x, y);
				node = m_sp.connection[node].next;
			} while (node != start_node);
		}

		CBrush brush;
		brush.CreateSolidBrush(RGB(255, 0, 0));

		for (int start_node : m_sp.polygons) {
			int node = start_node;
			do {
				mem.SelectObject(brush);
				int x = m_sp.x[node], y = m_sp.y[node];
				x = (x * DRAW_WIDTH) / MAX_COORDINATE;
				y = (y * DRAW_HEIGHT) / MAX_COORDINATE;
				mem.Ellipse(x - 2, y - 2, x + 2, y + 2);

				node = m_sp.connection[node].next;
			} while (node != start_node);
		}

		BitBlt(dc.GetSafeHdc(), LEFT_OFFSET, TOP_OFFSET, DRAW_WIDTH, DRAW_HEIGHT, mem.GetSafeHdc(), 0, 0, SRCCOPY);

		CDialogEx::OnPaint();
	}
}
Example #22
0
void Point::draw(CDC& dc) {
  dc.SelectObject( getPen() );
  //dc.SelectObject( brush );
  dc.Ellipse( a_.x - 3, a_.y - 3, a_.x + 3, a_.y + 3 );
}