// CompressionSettingsDlg.cpp : implementation file // #include "stdafx.h" #include "dicomvid.h" #include "MainFrm.h" #include "CompressionSettingsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CCompressionSettingsDlg dialog CCompressionSettingsDlg::CCompressionSettingsDlg(CWnd* pParent /*=NULL*/) : CDialog(CCompressionSettingsDlg::IDD, pParent) { //{{AFX_DATA_INIT(CCompressionSettingsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CCompressionSettingsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CCompressionSettingsDlg) DDX_Control(pDX, IDC_COMBO_Q_FACTOR, m_cmbQFactor); DDX_Control(pDX, IDC_COMBO_COMPRESSION_TYPE, m_cmbCompressionType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CCompressionSettingsDlg, CDialog) //{{AFX_MSG_MAP(CCompressionSettingsDlg) ON_CBN_EDITCHANGE(IDC_COMBO_COMPRESSION_TYPE, OnEditchangeComboCompressionType) ON_CBN_SELCHANGE(IDC_COMBO_COMPRESSION_TYPE, OnSelchangeComboCompressionType) ON_BN_CLICKED(IDC_BUTTON_MPEG2_ENCODER_OPTIONS, OnButtonMpeg2EncoderOptions) ON_BN_CLICKED(IDC_BUTTON_MPEG2_AUDIO_ENCODER_OPTIONS, OnButtonMpeg2AudioEncoderOptions) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CCompressionSettingsDlg message handlers void CCompressionSettingsDlg::OnOK() { // enable preview now that we finished changing the compressor settings EnablePreview(VARIANT_TRUE); CDialog::OnOK(); } void CCompressionSettingsDlg::OnCancel() { SetQFactor(m_cmbQFactor.GetCurSel() + Q_FACTOR_MIN); // enable preview now that we finished changing the compressor settings EnablePreview(VARIANT_TRUE); CDialog::OnCancel(); } DICOMVID_IMAGE_COMPRESSION CCompressionSettingsDlg::GetCompression() { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { return pMainFrame->GetCompression(); } return DICOMVID_IMAGE_COMPRESSION_NONE; } void CCompressionSettingsDlg::SetCompression(DICOMVID_IMAGE_COMPRESSION ImageCompression) { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pMainFrame->SetCompression(ImageCompression); } } BOOL CCompressionSettingsDlg::OnInitDialog() { CDialog::OnInitDialog(); CString strTmp; for(int i = 0 ; i < (sizeof(CompressionStringPair) / sizeof(CompressionStringPair[0])) ;i++) { m_cmbCompressionType.AddString(CompressionStringPair[i].pszName); } m_cmbCompressionType.SetCurSel(GetCompressionIndex(GetCompression())); for(i = Q_FACTOR_MIN ; i <= Q_FACTOR_MAX ; i++) { strTmp.Format("%d",i); m_cmbQFactor.AddString(strTmp); } m_cmbQFactor.SetCurSel(GetQFactor() - Q_FACTOR_MIN); EnableQFactorCombo(); EnableMPEG2Options(); // disable preview while we are changing compressor settings EnablePreview(VARIANT_FALSE); return TRUE; } void CCompressionSettingsDlg::EnableQFactorCombo() { CWnd * pWnd = GetDlgItem(IDC_COMBO_Q_FACTOR); if(pWnd) { switch(GetCompression()) { case DICOMVID_IMAGE_COMPRESSION_JPEGLOSSY: case DICOMVID_IMAGE_COMPRESSION_J2KLOSSY: pWnd->EnableWindow(TRUE); break; default: pWnd->EnableWindow(FALSE); } } } void CCompressionSettingsDlg::OnEditchangeComboCompressionType() { } void CCompressionSettingsDlg::OnSelchangeComboCompressionType() { int nCursel = m_cmbCompressionType.GetCurSel(); if(nCursel != -1) { SetCompression(CompressionStringPair[nCursel].ImageCompression); } EnableQFactorCombo(); EnableMPEG2Options(); } void CCompressionSettingsDlg::EnableMPEG2Options() { CWnd * pWnd = GetDlgItem(IDC_BUTTON_MPEG2_ENCODER_OPTIONS); if(pWnd) { switch(GetCompression()) { case DICOMVID_IMAGE_COMPRESSION_MPEG2: pWnd->EnableWindow(TRUE); break; default: pWnd->EnableWindow(FALSE); } } pWnd = GetDlgItem(IDC_BUTTON_MPEG2_AUDIO_ENCODER_OPTIONS); if(pWnd) { switch(GetCompression()) { case DICOMVID_IMAGE_COMPRESSION_MPEG2: pWnd->EnableWindow(TRUE); break; default: pWnd->EnableWindow(FALSE); } } } void CCompressionSettingsDlg::SetQFactor(int nQFactor) { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pMainFrame->SetQFactor(nQFactor); } } int CCompressionSettingsDlg::GetQFactor() { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { return pMainFrame->GetQFactor(); } return Q_FACTOR_MIN; } void CCompressionSettingsDlg::OnButtonMpeg2EncoderOptions() { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pMainFrame->ShowMPEG2OptionsDlg(); } } void CCompressionSettingsDlg::EnablePreview(VARIANT_BOOL bPreview) { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pMainFrame->m_capture->put_Preview(bPreview); } } void CCompressionSettingsDlg::OnButtonMpeg2AudioEncoderOptions() { CMainFrame * pMainFrame = (CMainFrame * )AfxGetMainWnd( ); if(pMainFrame) { pMainFrame->ShowMPEG2AudioOptionsDlg(); } }