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

📄 心跳检测view.cpp

📁 这个程序实现心电波形的提取
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 心跳检测View.cpp : implementation of the CMyView class
//

#include "stdafx.h"
#include "心跳检测.h"
#include "math.h"

#include "心跳检测Doc.h"
#include "心跳检测View.h"
#include "Mainfrm.h"
#include <windowsx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyView

IMPLEMENT_DYNCREATE(CMyView, CFormView)

BEGIN_MESSAGE_MAP(CMyView, CFormView)
	//{{AFX_MSG_MAP(CMyView)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_EXIT, OnExit)
	ON_BN_CLICKED(IDC_PRINT, OnMyPrint)
	ON_BN_CLICKED(IDC_OPEN, OnOpen)
	ON_BN_CLICKED(IDC_SAVE, OnSave)
	ON_BN_CLICKED(IDC_STOP, OnStop)
	ON_BN_CLICKED(IDC_PLAY, OnPlay)
	ON_BN_CLICKED(IDC_REFURBISH, OnRefurbish)
	ON_WM_CREATE()
	ON_BN_CLICKED(IDC_BITMAP, OnBitmap)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyView construction/destruction

CMyView::CMyView()
	: CFormView(CMyView::IDD)
{
	//{{AFX_DATA_INIT(CMyView)
	m_StartT = 0;
	m_EndT = 0;
	m_TopE = 0;
	m_BottomE = 0;
	m_E = _T("");
	m_F = _T("");
	//}}AFX_DATA_INIT
	// TODO: add construction code here
	m_TopE=100;
	m_EndT=1;

    m_pMemDC=new CDC;
	//m_pBitmap=new CBitmap;
}

CMyView::~CMyView()
{
	delete m_pMemDC;
	//delete m_pBitmap;
}

void CMyView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyView)
	DDX_Text(pDX, IDC_START_T, m_StartT);
	DDV_MinMaxInt(pDX, m_StartT, 0, 29);
	DDX_Text(pDX, IDC_END_T, m_EndT);
	DDV_MinMaxInt(pDX, m_EndT, 1, 30);
	DDX_Text(pDX, IDC_TOP_E, m_TopE);
	DDX_Text(pDX, IDC_BOTTOM_E, m_BottomE);
	DDX_Text(pDX, IDC_E, m_E);
	DDX_Text(pDX, IDC_F, m_F);
	//}}AFX_DATA_MAP
	DDX_Control(pDX, IDC_PLAY, m_Play);
	DDX_Control(pDX, IDC_STOP, m_Stop);
	DDX_Control(pDX, IDC_TRANSACT, m_Transact);
	DDX_Control(pDX, IDC_SAVE, m_Save);
	DDX_Control(pDX, IDC_OPEN, m_Open);
	DDX_Control(pDX, IDC_PRINT, m_Print);
	DDX_Control(pDX, IDC_EXIT, m_Exit);
	DDX_Control(pDX, IDC_REFURBISH,m_Refurbish);
}

BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CMyView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
//	GetParentFrame()->RecalcLayout();
//	ResizeParentToFit();



	m_Play.SetIcon(IDI_PLAY);
	m_Play.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Play.DrawFlatFocus(TRUE);
//	m_Play.SetTooltipText(_T("开始运行"));

	m_Stop.SetIcon(IDI_STOP);
	m_Stop.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Stop.DrawFlatFocus(TRUE);

	m_Transact.SetIcon(IDI_TRANSACT);
	m_Transact.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Transact.DrawFlatFocus(TRUE);

	m_Save.SetIcon(IDI_SAVE);
	m_Save.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Save.DrawFlatFocus(TRUE);

	m_Open.SetIcon(IDI_OPEN);
	m_Open.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Open.DrawFlatFocus(TRUE);

	m_Print.SetIcon(IDI_PRINT);
	m_Print.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Print.DrawFlatFocus(TRUE);

	m_Exit.SetIcon(IDI_EXIT1,IDI_EXIT);
	m_Exit.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Exit.DrawFlatFocus(TRUE);	

	m_Refurbish.SetIcon(IDI_REFURBISH1,IDI_REFURBISH);
	m_Refurbish.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 50);
	m_Refurbish.DrawFlatFocus(TRUE);	

}

/////////////////////////////////////////////////////////////////////////////
// CMyView printing

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CMyView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics

#ifdef _DEBUG
void CMyView::AssertValid() const
{
	CFormView::AssertValid();
}

void CMyView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
	return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers

void CMyView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CBitmap* pOldBitmap=m_pMemDC->SelectObject(&m_pBitmap);
   //copy the memory DC to show DC
	dc.BitBlt(170,50,m_MaxX-150,m_MaxY-50,m_pMemDC,0,0,SRCCOPY);

	m_pMemDC->SelectObject(pOldBitmap);	
//	DrawCordinate(&dc);
//	DrawLine(&dc);
	// Do not call CFormView::OnPaint() for painting messages
}

void CMyView::OnExit() 
{
	// TODO: Add your control notification handler code here
	PostMessage(WM_QUIT);
}

void CMyView::OnMyPrint() 
{
	// TODO: Add your control notification handler code here
	ShellExecute(GetSafeHwnd(),"open","C:\\Program Files\\office\\Office\\Winword.exe",NULL,NULL,SW_SHOWNORMAL);
}

void CMyView::OnOpen() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(TRUE,"dot",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
			"心跳检测数据(*.dot)|*.dot|所有文件(*.*)|*.*||",this);
    if(dlg.DoModal()==IDCANCEL)
		 return;	
	PathName=dlg.GetPathName();	
	CStdioFile file;
	if(file.Open(PathName,CFile::modeRead)==0)
	{
		MessageBox("打文件"+PathName+"失败!","提示",MB_OK+MB_ICONWARNING);
		return;
	}
	//save the data
	Openfile(&file);
	//close the file
	file.Close();
}

void CMyView::OnSave() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlg(FALSE,"dot","未命名",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
			"心跳检测数据(*.dot)|*.dot|所有文件(*.*)|*.*||",this);
    if(dlg.DoModal()==IDCANCEL)
		 return;	
	PathName=dlg.GetPathName();	
	CStdioFile file;
	if(file.Open(PathName,CFile::modeCreate|CFile::modeWrite)==0)
	{
		MessageBox("打文件"+PathName+"失败!","提示",MB_OK+MB_ICONWARNING);
		return;
	}
	//save the data
	SaveFile(&file);
	//close the file
	
}



void CMyView::OnStop() 
{
	// TODO: Add your control notification handler code here
	CMainFrame *m_pFrm=(CMainFrame *)AfxGetMainWnd();
	m_pFrm->TP.runing=FALSE;	
}

void CMyView::OnPlay() 
{
	// TODO: Add your control notification handler code here
	CMainFrame *m_pFrm=(CMainFrame *)AfxGetMainWnd();
	OnStop();
	Sleep(100);

	m_pFrm->TP.PointNumber=0;

/*	for(int i=0;i<=m_pFrm->TP.WholeNumber;i++)
	{
		m_pFrm->TP.data[i]=0;
		m_pFrm->TP.data1[i]=0;
	}
*/

/*	for(int i=0;i<100;i++)
	{
		m_pFrm->TP.data[i]=fsimpf(i);
		m_pFrm->TP.data1[i]=fsimp(0,i,0.00001);
	}
*/

	m_pFrm->TP.runing=TRUE;
	::PostThreadMessage(m_pFrm->m_JiqiThreadID,WM_CELIANG,long(&m_pFrm->TP),NULL);
}

void CMyView::OnRefurbish() 
{
	// TODO: Add your control notification handler code here
	
}

void CMyView::Draw(int Point)
{
//	Invalidate(FALSE);
	CMainFrame *m_pFrm=(CMainFrame *)AfxGetMainWnd();
	m_E.Format("%3.3f",m_pFrm->TP.data[Point]);
	m_F.Format("%3.3f",float(Point));
	UpdateData(FALSE);

	DrawCordinate();
	DrawLine();
}


int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFormView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	InitData();

	CDC* pDC=GetDC();

⌨️ 快捷键说明

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