Click here to Skip to main content
15,892,927 members
Articles / Programming Languages / C++

ECG recording, storing, filtering and recognition

Rate me:
Please Sign up or sign in to vote.
4.72/5 (110 votes)
14 Apr 200411 min read 733.3K   38.4K   156  
Full open code project for making driver and application software for ECG medical measurements.
// DlgPulseMeter.cpp : implementation file
//

#include "stdafx.h"
#include "ECG_1.h"
#include "DlgPulseMeter.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgPulseMeter dialog


CDlgPulseMeter::CDlgPulseMeter(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgPulseMeter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgPulseMeter)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDlgPulseMeter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgPulseMeter)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgPulseMeter, CDialog)
	//{{AFX_MSG_MAP(CDlgPulseMeter)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgPulseMeter message handlers

void CDlgPulseMeter::DrawPulse()
{
	CClientDC dc(this);
	CRect rect;
	GetWindowRect(rect);

	CBitmap Bitmap;
	CBitmap* pbmOld = NULL;//Pointer to the CBitmap object
	CDC dcMem;
	CRect BmpRect;
	BmpRect.SetRect(0,0,rect.right,rect.bottom);
	dcMem.CreateCompatibleDC(&dc);//Greate painting object
	Bitmap.CreateCompatibleBitmap(&dc,BmpRect.Width(),BmpRect.Height());
	//In to DCMem is getting the object bitmap
	pbmOld = dcMem.SelectObject(&Bitmap);
	//Creates the bitmap rectangle
	dcMem.PatBlt(0,0,rect.right,rect.bottom,WHITENESS);
	//Draw curr pulse
	DrawCurrPulse(&dcMem,&BmpRect);
	//Draw past pulse in last minute
	DrawPastPulse(&dcMem,&BmpRect);

	//Shows the bitmap on the dlg screen dY=100
	dc.BitBlt(0,0,rect.right,
		rect.bottom,&dcMem,0,0,SRCCOPY);

	dcMem.SelectObject(pbmOld);
	dcMem.DeleteDC();
}

void CDlgPulseMeter::DrawCurrPulse(CDC *pDC,CRect *lpRect)
{
	CFont Font;
	CRect rect;
	GetClientRect(rect);

//	s_CurrPulse = "4";

	int text_lenght = s_CurrPulse.GetLength();
	int fHeight = rect.Height();
	int fWidth = rect.Width()/(4*text_lenght);
	
	
	int x = ((3*rect.Width()/4) - (fWidth*text_lenght)/2);

	
	Font.CreateFont(fHeight,fWidth,0,0,
		FW_DONTCARE,FALSE,FALSE,0,
		DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
		CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,
		"Arial");

	CFont* pOldFont = pDC->SelectObject(&Font);
	pDC->TextOut(x,10,s_CurrPulse);		
	pDC->MoveTo(rect.Width()/2,rect.top);
	pDC->LineTo(rect.Width()/2,rect.bottom);
	pDC->SelectObject(pOldFont);
}

void CDlgPulseMeter::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	DrawPulse();
	
	// Do not call CDialog::OnPaint() for painting messages
}

void CDlgPulseMeter::DrawPastPulse(CDC *pDC, CRect lprect)
{
	CFont Font;
	CRect rect;
	GetClientRect(rect);

//	s_PastPulse = "708";
	int text_lenght = s_PastPulse.GetLength();
	int fHeight = rect.Height();
	int fWidth = rect.Width()/(4*text_lenght);
	
	int x = ((rect.Width()/4) - (fWidth*text_lenght)/2);

	Font.CreateFont(fHeight,fWidth,0,0,
		FW_DONTCARE,FALSE,FALSE,1,
		DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
		CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,
		"Arial");

	CFont* pOldFont = pDC->SelectObject(&Font);
	pDC->TextOut(x,10,s_PastPulse);			
	pDC->SelectObject(pOldFont);

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Systems Engineer
Bulgaria Bulgaria
PhD, Cum Laude in digital automation systems
M.S. in Telemommunication management
B.S. in Telecommunication systems engineering
Programming: CUDA, C/C++, VHDL
Software and Hardware development and consulting:
data acquisition, image processing, medical instrumentation

Comments and Discussions