?? sbttuxing.cpp
字號(hào):
// 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
//定坐標(biāo)
int top=50;
int b=350;
float Hsx=80; //橫坐標(biāo)起始點(diǎn)的X坐標(biāo)
int Hsy=b;
int Hex=400; //------終止點(diǎn)的-----
int Hey=Hsy;
int Zsx=Hsx;
float Zsy=Hsy;
int Zex=Zsx;
float Zey=50;
//畫坐標(biāo)
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);
//畫坐標(biāo)箭頭
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);
//寫坐標(biāo)上的數(shù)據(jù)
CPen pen2;
pen2.CreatePen(PS_ENDCAP_ROUND,2,RGB(0,128,255));
pDC->SelectObject(&pen2);
float k=5; //坐標(biāo)的等份份數(shù)
int Hpx=Hsx+40;
int Hpy=Hsy;
int Zpx=Zsx;
int Zpy=Zsy-30;
char str[64];
float Hsj=pDoc->H_min; //橫坐標(biāo)上的數(shù)據(jù)
float Zsj=pDoc->Z_min; //縱坐標(biāo)上的數(shù)據(jù)
float Hdf=(pDoc->H_max-pDoc->H_min)/k;//橫坐標(biāo)上數(shù)據(jù)每次的累加量
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;
}
//繪點(diǎn)
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);
//轉(zhuǎn)換坐標(biāo)映射方式
CSize size = CSize(800, 580);
pDC->SetWindowExt(size);
//確定窗口大小
//得到實(shí)際設(shè)備每邏輯英寸的像素?cái)?shù)量
int xLogPixPerInch=pDC->GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
//得到設(shè)備坐標(biāo)和邏輯坐標(biāo)的比例
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;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -