#include "stdafx.h" #include "drawfunc.h" void drawarrowhead(CDC * pDC, int x, int y, int size, int xory) { CPoint pt[3]; if(xory){ pt[0]=CPoint(-1,1); pt[1]=CPoint(-1,-1); pt[2]=CPoint(1,0); } else { pt[0]=CPoint(-1,1); pt[1]=CPoint(1,1); pt[2]=CPoint(0,-1); } int i; for(i=0; i<3; i++) { pt[i].x*=size; pt[i].y*=size; pt[i]+=CPoint(x,y); } pDC->Polygon(pt,3); } void drawxaxis(CDC * pDC, int xbegin, int xend, int y, int thick, COLORREF color) { CPen pen1(PS_SOLID,1,color); CPen pen2(PS_SOLID,5,color); CPen * pOldPen=NULL; CBrush brush(color); CBrush * pOldBrush=NULL; pOldPen = pDC->SelectObject(&pen1); pOldBrush = pDC->SelectObject(&brush); drawarrowhead(pDC,xend+thick,y,2*thick,1); pDC->SelectObject(&pen2); pDC->MoveTo(xbegin, y); pDC->LineTo(xend, y); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); } void drawyaxis(CDC * pDC, int ybegin, int yend, int x, int thick, COLORREF color) { CPen pen1(PS_SOLID,1,color); CPen pen2(PS_SOLID,5,color); CPen * pOldPen=NULL; CBrush brush(color); CBrush * pOldBrush=NULL; pOldPen = pDC->SelectObject(&pen1); pOldBrush = pDC->SelectObject(&brush); drawarrowhead(pDC,x,ybegin-thick,2*thick,0); pDC->SelectObject(&pen2); pDC->MoveTo(x, ybegin); pDC->LineTo(x, yend); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); } void drawxscale(CDC * pDC, int x, int y, CString & label) { pDC->MoveTo(x,y); pDC->LineTo(x,y+5); pDC->SetTextAlign(TA_CENTER | TA_TOP); pDC->TextOut(x,y+5,label); } void drawyscale(CDC * pDC, int x, int y, CString & label) { pDC->MoveTo(x,y); pDC->LineTo(x-5,y); pDC->SetTextAlign(TA_RIGHT | TA_BASELINE); pDC->TextOut(x-5,y+12,label); }