⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sbttuxing.cpp

📁 ISO9000质量管理小程序
💻 CPP
字号:
// SbtTuxing.cpp : implementation file
//

#include "stdafx.h"
#include "Ex07b.h"
#include "SbtTuxing.h"
#include "SbtDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSbtTuxing

IMPLEMENT_DYNCREATE(CSbtTuxing, CScrollView)

CSbtTuxing::CSbtTuxing()
{
}

CSbtTuxing::~CSbtTuxing()
{
}


BEGIN_MESSAGE_MAP(CSbtTuxing, CScrollView)
	//{{AFX_MSG_MAP(CSbtTuxing)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)  //Attention here!!!!
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)  //Attention here!!!!
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)  //Attention here!!!!


END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSbtTuxing drawing

void CSbtTuxing::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

void CSbtTuxing::OnDraw(CDC* pDC)
{
	CSbtDoc* pDoc = GetDocument();
	// TODO: add draw code here
	//定坐标

	int top=50;

	int b=350;
	float Hsx=80;					//横坐标起始点的X坐标
	int Hsy=b;
	int Hex=400;	//------终止点的-----
	int Hey=Hsy;
	int Zsx=Hsx;
	float Zsy=Hsy;
	int Zex=Zsx;
	float Zey=50;
//画坐标
	CPen pen1;
	pen1.CreatePen(PS_ENDCAP_ROUND,2,RGB(255,128,128));
	pDC->SelectObject(&pen1);
	pDC->MoveTo(Hsx,Hsy);
	pDC->LineTo(Hex,Hey);
	pDC->MoveTo(Zsx,Zsy);
	pDC->LineTo(Zex,Zey);
//画坐标箭头
	pDC->MoveTo(Hex,Hey);
	pDC->LineTo(Hex-10,Hey-3);
	pDC->MoveTo(Hex,Hey);
	pDC->LineTo(Hex-10,Hey+3);

	pDC->MoveTo(Zex,Zey);
	pDC->LineTo(Zex-3,Zey+10);
	pDC->MoveTo(Zex,Zey);
	pDC->LineTo(Zex+3,Zey+10);

//写坐标上的数据

	CPen pen2;
	pen2.CreatePen(PS_ENDCAP_ROUND,2,RGB(0,128,255));
	pDC->SelectObject(&pen2);
	float k=5;    //坐标的等份份数
	int Hpx=Hsx+40;
	int Hpy=Hsy;
	int Zpx=Zsx;
	int Zpy=Zsy-30;
	
	char str[64];
	float Hsj=pDoc->H_min;		//横坐标上的数据
	float Zsj=pDoc->Z_min;		//纵坐标上的数据
	float Hdf=(pDoc->H_max-pDoc->H_min)/k;//横坐标上数据每次的累加量
	float Zdf=(pDoc->Z_max-pDoc->Z_min)/k;


	for (int i=0;i<=k;i++)
	{
		pDC->MoveTo(Hpx,Hpy);
		pDC->LineTo(Hpx,Hpy-4);

		sprintf(str,"%6.0f",Hsj);
		pDC->TextOut(Hpx-20,Hpy+5,str);
		Hpx=Hpx+50;
		Hsj=Hsj+Hdf;
		
		pDC->MoveTo(Zpx,Zpy);
		pDC->LineTo(Zpx+4,Zpy);
		sprintf(str,"%6.0f",Zsj);
		pDC->TextOut(Zpx-50,Zpy-10,str);
		Zpy=Zpy-50;
		Zsj=Zsj+Zdf;

	}



	//绘点
	float x;
	float y;
	POSITION pos=pDoc->m_sbtdataList.GetHeadPosition();
	while (pos!=NULL)
	{
		CSbtsj *pSbtsj=pDoc->m_sbtdataList.GetNext(pos);


		x=Hsx+40+((Hpx-50)-(Hsx+40))*(pSbtsj->Xi-pDoc->H_min)/(pDoc->H_max-pDoc->H_min); //(Hex-Hsx-80)*pSbtsj->Xi/pDoc->H_max;
		//x=Hsx+40+(
//		y=b-30-((pSbtsj->Yi-pDoc->Z_min)*k*Zdf)/(pDoc->Z_max-pDoc->Z_min);
		y=Zey+30+(pDoc->Z_max-pSbtsj->Yi)*((Zsy-30)-(Zey+30))/(pDoc->Z_max-pDoc->Z_min);
		CRect rect(x-1.5,y-1.5,x+1.5,y+1.5);
		pDC->Ellipse(&rect);
	}



	
}

/////////////////////////////////////////////////////////////////////////////
// CSbtTuxing diagnostics

#ifdef _DEBUG
void CSbtTuxing::AssertValid() const
{
	CScrollView::AssertValid();
}

void CSbtTuxing::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}
#endif //_DEBUG

#ifdef _DEBUG

	 CSbtDoc * CSbtTuxing::GetDocument()
	{
		ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSbtDoc)));
		return (CSbtDoc*)m_pDocument;
	
	}
#endif

/////////////////////////////////////////////////////////////////////////////
// CSbtTuxing message handlers

void CSbtTuxing::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CScrollView::OnPrepareDC(pDC, pInfo);
	pDC->SetMapMode(MM_ANISOTROPIC);
	//转换坐标映射方式
  
	CSize size = CSize(800, 580);
	pDC->SetWindowExt(size);
	//确定窗口大小
 
	//得到实际设备每逻辑英寸的像素数量
	int xLogPixPerInch=pDC->GetDeviceCaps(LOGPIXELSX);
	int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
	//得到设备坐标和逻辑坐标的比例
 	long xExt = (long)size.cx * xLogPixPerInch/96 ;
    long yExt = (long)size.cy * yLogPixPerInch/96 ;

    pDC->SetViewportExt((int)xExt, (int)yExt);
	//确定视口大小


}

BOOL CSbtTuxing::OnPreparePrinting(CPrintInfo* pInfo) 
{
	// TODO: call DoPreparePrinting to invoke the Print dialog box
	
//	return CScrollView::OnPreparePrinting(pInfo);
	BOOL b=CView::DoPreparePrinting(pInfo);
	return b;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -