📄 waveshowerdoc.cpp
字号:
// WaveShowerDoc.cpp : implementation of the CWaveShowerDoc class
//
#include "stdafx.h"
#include "WaveShower.h"
#include "WaveShowerDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWaveShowerDoc
IMPLEMENT_DYNCREATE(CWaveShowerDoc, CDocument)
BEGIN_MESSAGE_MAP(CWaveShowerDoc, CDocument)
//{{AFX_MSG_MAP(CWaveShowerDoc)
ON_COMMAND(IDM_CONVERTER, OnConverter)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaveShowerDoc construction/destruction
CWaveShowerDoc::CWaveShowerDoc()
{
// TODO: add one-time construction code here
}
CWaveShowerDoc::~CWaveShowerDoc()
{
}
BOOL CWaveShowerDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CWaveShowerDoc serialization
void CWaveShowerDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CWaveShowerDoc diagnostics
#ifdef _DEBUG
void CWaveShowerDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CWaveShowerDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWaveShowerDoc commands
void CWaveShowerDoc::OnConverter()
{
// TODO: Add your command handler code here
CString filename;
CFileDialog filedlg(TRUE);
filedlg.m_ofn.lpstrTitle="打开心电图原始文件";
filedlg.m_ofn.lpstrFilter="心电图文件(*.dat)\0*.dat\0\0";
if(filedlg.DoModal()==IDOK)
{
filename=filedlg.GetFileName();
CFile file;
file.Open(filename,CFile::modeRead,NULL);
int filelen;
filelen=file.GetLength();
unsigned char* buffer0;
unsigned char* totabuffer;
totabuffer= new unsigned char[filelen];
buffer0=new unsigned char[filelen/3*2];
file.Read(totabuffer,filelen);
file.Close();
unsigned char tmpval;
for(int i=0;i<filelen/3;i++)
{
tmpval=totabuffer[3*i+2];
buffer0[2*i+1]=tmpval;
tmpval=totabuffer[3*i+1];
tmpval=0xf0&tmpval;
tmpval=tmpval>>4;
buffer0[2*i]=tmpval;
}
CFile ecgfile;
ecgfile.Open("ecg0.dat",CFile::modeCreate|CFile::modeWrite,NULL);
ecgfile.Write(buffer0,filelen/3*2);
ecgfile.Close();
delete buffer0;
delete totabuffer;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -