// WavDoc.cpp : implementation of the CDicWavDoc class // #include "stdafx.h" #include "DicWav.h" #include "MainFrm.h" #include "WavDoc.H" #include "WavView.h" #include "WaveformAttributesDlg.h" #include "CreateBasicVoiceAudioDlg.h" #include "PlayeBasicVoiceAudioDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define IOD_VOICE_AUDIO 0 #define IOD_12_LEAD_ECG 1 #define IOD_GENERAL_ECG 2 #define IOD_AMBULARITY_ECG 3 #define IOD_HEMODYNAMIC 4 #define IOD_BASIC_CARDIAC_EP 5 #define MODALITY_IOD_VOICE_AUDIO "AU" #define MODALITY_IOD_12_LEAD_ECG "ECG" #define MODALITY_IOD_GENERAL_ECG "ECG" #define MODALITY_IOD_AMBULARITY_ECG "ECG" #define MODALITY_IOD_HEMODYNAMIC "HD" #define MODALITY_IOD_BASIC_CARDIAC_EP "EPS" ///////////////////////////////////////////////////////////////////////////// // CDicWavDoc IMPLEMENT_DYNCREATE(CDicWavDoc, CDocument) BEGIN_MESSAGE_MAP(CDicWavDoc, CDocument) //{{AFX_MSG_MAP(CDicWavDoc) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_VIEW_CHANNELINFO, OnViewChannelinfo) ON_UPDATE_COMMAND_UI(ID_VIEW_CHANNELINFO, OnUpdateViewChannelinfo) ON_COMMAND(ID_AUDIO_CREATEBASICVOICEAUDIOFILE, OnAudioCreatebasicvoiceaudiofile) ON_COMMAND(ID_AUDIO_PLAYBASICVOICEAUDIOFILE, OnAudioPlaybasicvoiceaudiofile) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDicWavDoc construction/destruction CDicWavDoc::CDicWavDoc() { // TODO: add one-time construction code here m_bDSIsLoaded = FALSE; m_bTrueSize = TRUE; //m_CurWaveformGrp.Reset(); } CDicWavDoc::~CDicWavDoc() { m_CurWaveformGrp.Reset(); } BOOL CDicWavDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CDicWavDoc serialization void CDicWavDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here } } ///////////////////////////////////////////////////////////////////////////// // CDicWavDoc diagnostics #ifdef _DEBUG void CDicWavDoc::AssertValid() const { CDocument::AssertValid(); } void CDicWavDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CDicWavDoc commands BOOL CDicWavDoc::OnOpenDocument(LPCTSTR lpszPathName) { return (TRUE); } CView* CDicWavDoc::GetView() { POSITION pos = GetFirstViewPosition(); return(GetNextView(pos)); } void CDicWavDoc::OnFileOpen() { TCHAR szFilters[] =_T ("DICOM Files (*.dcm)|*.dcm|DCM Files (*.dic)|*.dic|All files (*.*)|*.*||"); L_INT nLoadFlags = 0; CFileDialog dlg ( TRUE, _T ("All Files"), NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters); if (dlg.DoModal () == IDOK) { L_INT nRet = FAILURE; CDicWavView* pView = NULL; CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pView = (CDicWavView*) pMainFrame->GetRightPane(); } if(pView!=NULL) { L_UINT16 uDicomRet; pView->m_bLoadedWaveform = TRUE; CString strFileName = dlg.GetPathName(); // Load the DICOM file m_DS.ResetDS(); uDicomRet = m_DS.LoadDS((CHAR * )(LPCSTR)strFileName, DS_LOAD_CLOSE); if(uDicomRet != DICOM_SUCCESS) { AfxMessageBox("Load Failed",MB_ICONSTOP); return ; } m_bDSIsLoaded = TRUE; // Do we have any waveform groups at all L_UINT32 uCount = m_DS.GetWaveformGroupCount(); L_UINT16 nRet; if (uCount == 0) { AfxMessageBox("The DICOM file you are trying to load doesn't include any waveforms. ",MB_ICONSTOP ); return; } // There is at least one waveform group in this DS, the first waveform group will be loaded m_CurWaveformGrp.Reset(); nRet = m_DS.GetWaveformGroup(0, &m_CurWaveformGrp); if (nRet != DICOM_SUCCESS) { AfxMessageBox("Failed to load the first waveform group from the dataset.",MB_ICONSTOP ); } // Display the waveform data and other displayable information pView->m_bLoadedWaveform = TRUE; pView->RedrawWindow(); UpdateAllViews (NULL); } } } void CDicWavDoc::OnViewChannelinfo() { CWaveformAttributesDlg AttributesDlg; // Display the information about the waveform // group and different channels AttributesDlg.m_pWaveformGrp = &m_CurWaveformGrp; AttributesDlg.DoModal(); } void CDicWavDoc::OnUpdateViewChannelinfo(CCmdUI* pCmdUI) { pCmdUI->Enable (m_CurWaveformGrp.GetNumberOfChannels()); } void CDicWavDoc::OnAudioCreatebasicvoiceaudiofile() { // Create a Basic Voice Audio File CCreateBasicVoiceAudioDlg BasicVoiceAudioDlg; BasicVoiceAudioDlg.DoModal(); } void CDicWavDoc::OnAudioPlaybasicvoiceaudiofile() { CPlayeBasicVoiceAudioDlg PlayeBasicVoiceAudioDlg; PlayeBasicVoiceAudioDlg.DoModal(); }