www.pudn.com > 人体步态跟踪识别bate版.rar > humantrackView.cpp


// humantrackView.cpp : implementation of the CHumantrackView class 
// 
 
#include "stdafx.h" 
#include "humantrack.h" 
#include "human.h" 
#include "math.h" 
#include "humantrackDoc.h" 
#include "humantrackView.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView 
 
IMPLEMENT_DYNCREATE(CHumantrackView, CScrollView) 
 
BEGIN_MESSAGE_MAP(CHumantrackView, CScrollView) 
	//{{AFX_MSG_MAP(CHumantrackView) 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
	ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint) 
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview) 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView construction/destruction 
 
CHumantrackView::CHumantrackView() 
{ 
	// TODO: add construction code here 
 
} 
 
CHumantrackView::~CHumantrackView() 
{ 
} 
 
BOOL CHumantrackView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CScrollView::PreCreateWindow(cs); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView drawing 
 
void CHumantrackView::OnDraw(CDC* pDC) 
{ 
	CHumantrackDoc* pDoc = GetDocument(); 
	ASSERT_VALID(pDoc); 
	// TODO: add draw code for native data here 
 
	HDIB hDIB = pDoc->GetHDIB(); 
	if (hDIB != NULL) 
	{ 
		LPSTR lpDIB = (LPSTR) ::GlobalLock((HGLOBAL) hDIB); 
		int cxDIB = (int) ::DIBWidth(lpDIB);         //DIB图像的宽度 
		int cyDIB = (int) ::DIBHeight(lpDIB);        //DIB图像的高度 
		::GlobalUnlock((HGLOBAL) hDIB); 
		CRect rcDIB; 
		rcDIB.left = 10; 
		rcDIB.top = 10; 
		rcDIB.right = cxDIB; 
		rcDIB.bottom = cyDIB; 
		CRect rcDest; 
		if (pDC->IsPrinting())   // 打印 DC 
		{ 
			// get size of printer page (in pixels) 
			int cxPage = pDC->GetDeviceCaps(HORZRES); 
			int cyPage = pDC->GetDeviceCaps(VERTRES); 
			// get printer pixels per inch 
			int cxInch = pDC->GetDeviceCaps(LOGPIXELSX); 
			int cyInch = pDC->GetDeviceCaps(LOGPIXELSY); 
			 
			// 
			// Best Fit case -- create a rectangle which preserves 
			// the DIB's aspect ratio, and fills the page horizontally. 
			// 
			// The formula in the "->bottom" field below calculates the Y 
			// position of the printed bitmap, based on the size of the 
			// bitmap, the width of the page, and the relative size of 
			// a printed pixel (cyInch / cxInch). 
			// 
			rcDest.top =0; 
			rcDest.left = 0; 
			rcDest.bottom = (int)(((double)cyDIB * cxPage * cyInch)/ ((double)cxDIB * cxInch)); 
			rcDest.right = cxPage; 
		} 
		else   // not printer DC 
		{ 
			rcDest = rcDIB; 
		} 
	//绘制人体原始图像 
	::PaintDIB(pDC->m_hDC, &rcDest, pDoc->GetHDIB(),&rcDIB, pDoc->GetDocPalette()); 
	//绘制人体运动的整个序列 
	if (pDoc->tm.m_JointP[0].GetSize()!=0)  
		{ 
		 pDoc->tm.sh.DrawStickHuman(pDC); 
 //      pDoc->tm.DrawSequenceHuman(pDC);  //显示整个图像序列人体 
		}	 	 
	} 
} 
 
void CHumantrackView::OnInitialUpdate() 
{ 
	CScrollView::OnInitialUpdate(); 
 
	CSize sizeTotal; 
	// TODO: calculate the total size of this view 
	sizeTotal.cx = sizeTotal.cy = 3000; 
	CSize sizeLine = CSize(sizeTotal.cx / 5,sizeTotal.cy / 5); 
	SetScrollSizes(MM_TEXT, sizeLine,sizeTotal,sizeTotal); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView printing 
 
BOOL CHumantrackView::OnPreparePrinting(CPrintInfo* pInfo) 
{ 
	// default preparation 
	return DoPreparePrinting(pInfo); 
} 
 
void CHumantrackView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add extra initialization before printing 
} 
 
void CHumantrackView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) 
{ 
	// TODO: add cleanup after printing 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView diagnostics 
 
#ifdef _DEBUG 
void CHumantrackView::AssertValid() const 
{ 
	CScrollView::AssertValid(); 
} 
 
void CHumantrackView::Dump(CDumpContext& dc) const 
{ 
	CScrollView::Dump(dc); 
} 
 
CHumantrackDoc* CHumantrackView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHumantrackDoc))); 
	return (CHumantrackDoc*)m_pDocument; 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CHumantrackView message handlers