// SaveODlg.cpp : implementation file // #include "stdafx.h" // #include "DICOM.h" // #include "SaveODlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSaveOptDlg dialog CSaveOptDlg::CSaveOptDlg(CWnd* pParent /*=NULL*/) : CDialog(CSaveOptDlg::IDD, pParent) { //{{AFX_DATA_INIT(CSaveOptDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_nFlags = 0; m_nVR = 0; m_nTransfer = 0; m_nMeta = 0; m_nGroupLen = 0; m_nLenEncoding = 0; } void CSaveOptDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSaveOptDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSaveOptDlg, CDialog) //{{AFX_MSG_MAP(CSaveOptDlg) ON_BN_CLICKED(IDC_RADIO1, OnRadio1) ON_BN_CLICKED(IDC_RADIO2, OnRadio2) ON_BN_CLICKED(IDC_RADIO3, OnRadio3) ON_BN_CLICKED(IDC_RADIO4, OnRadio4) ON_BN_CLICKED(IDC_RADIO5, OnRadio5) ON_BN_CLICKED(IDC_RADIO6, OnRadio6) ON_BN_CLICKED(IDC_RADIO7, OnRadio7) ON_BN_CLICKED(IDC_RADIO8, OnRadio8) ON_BN_CLICKED(IDC_RADIO9, OnRadio9) ON_BN_CLICKED(IDC_RADIO10, OnRadio10) ON_BN_CLICKED(IDC_RADIO11, OnRadio11) ON_BN_CLICKED(IDC_RADIO12, OnRadio12) ON_BN_CLICKED(IDC_RADIO13, OnRadio13) ON_BN_CLICKED(IDC_RADIO14, OnRadio14) ON_BN_CLICKED(IDC_RADIO15, OnRadio15) ON_BN_CLICKED(IDC_RADIO16, OnRadio16) ON_BN_CLICKED(IDC_RADIO17, OnRadio17) ON_BN_CLICKED(IDC_RADIO18, OnRadio18) ON_BN_CLICKED(IDC_RADIO19, OnRadio19) ON_BN_CLICKED(IDC_RADIO20, OnRadio20) ON_BN_CLICKED(IDC_RADIO21, OnRadio21) ON_BN_CLICKED(IDC_RADIO22, OnRadio22) ON_BN_CLICKED(IDC_RADIO23, OnRadio23) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSaveOptDlg message handlers BOOL CSaveOptDlg::OnInitDialog() { CDialog::OnInitDialog(); CheckDlgButton(IDC_RADIO1, m_nMeta==DS_METAHEADER_PRESENT ?TRUE:FALSE); CheckDlgButton(IDC_RADIO2, m_nMeta==DS_METAHEADER_ABSENT ?TRUE:FALSE); CheckDlgButton(IDC_RADIO3, m_nMeta==0 ?TRUE:FALSE); CheckDlgButton(IDC_RADIO4, m_nTransfer==DS_LITTLE_ENDIAN ?TRUE:FALSE); CheckDlgButton(IDC_RADIO5, m_nTransfer==DS_BIG_ENDIAN ?TRUE:FALSE); CheckDlgButton(IDC_RADIO6, m_nTransfer==0 ?TRUE:FALSE); CheckDlgButton(IDC_RADIO7, m_nVR==DS_EXPLICIT_VR ?TRUE:FALSE); CheckDlgButton(IDC_RADIO8, m_nVR==DS_IMPLICIT_VR ?TRUE:FALSE); CheckDlgButton(IDC_RADIO9, m_nVR==0 ?TRUE:FALSE); CheckDlgButton(IDC_RADIO10, m_nGroupLen==DS_GROUP_LENGTHS ?TRUE:FALSE); CheckDlgButton(IDC_RADIO11, m_nGroupLen==0 ?TRUE:FALSE); CheckDlgButton(IDC_RADIO12, m_nLenEncoding==0 ?TRUE:FALSE); CheckDlgButton(IDC_RADIO13, m_nLenEncoding==DS_LENGTH_EXPLICIT?TRUE:FALSE); switch (m_nCompression) { case DICOM_IMAGE_COMPRESSION_NONE: CheckDlgButton(IDC_RADIO14, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); break; case DICOM_IMAGE_COMPRESSION_RLE: CheckDlgButton(IDC_RADIO15, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); break; case DICOM_IMAGE_COMPRESSION_JPEG_LOSSY: CheckDlgButton(IDC_RADIO16, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), FALSE);//photometric palette ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), TRUE); break; case DICOM_IMAGE_COMPRESSION_JPEG_LOSSLESS: CheckDlgButton(IDC_RADIO17, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), FALSE);//photometric palette ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), FALSE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); break; } switch (m_nPhotometric) { case DICOM_IMAGE_PHOTOMETRIC_MONOCHROME2: CheckDlgButton(IDC_RADIO18, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO23), FALSE);//24 BPP break; case DICOM_IMAGE_PHOTOMETRIC_PALETTE_COLOR: CheckDlgButton(IDC_RADIO19, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO23), FALSE);//24 BPP break; case DICOM_IMAGE_PHOTOMETRIC_RGB: CheckDlgButton(IDC_RADIO20, TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), FALSE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP break; } switch (m_nBitsPerPixel) { case 8: CheckDlgButton(IDC_RADIO21, TRUE); break; case 16: CheckDlgButton(IDC_RADIO22, TRUE); break; case 24: CheckDlgButton(IDC_RADIO23, TRUE); break; } SetDlgItemInt(IDC_QFACTOR, m_nQFactor, FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CSaveOptDlg::OnRadio1() { m_nMeta = DS_METAHEADER_PRESENT; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio2() { m_nMeta = DS_METAHEADER_ABSENT; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio3() { m_nMeta = 0; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio4() { m_nTransfer = DS_LITTLE_ENDIAN; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO7), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO5), TRUE); if(IsDlgButtonChecked(IDC_RADIO8) == 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), TRUE); } } void CSaveOptDlg::OnRadio5() { m_nTransfer = DS_BIG_ENDIAN; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO8), FALSE); OnRadio14(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), FALSE); } void CSaveOptDlg::OnRadio6() { m_nTransfer = 0; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO8), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO5), TRUE); if(IsDlgButtonChecked(IDC_RADIO8) == 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), TRUE); } } void CSaveOptDlg::OnRadio7() { m_nVR = DS_EXPLICIT_VR; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO8), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO5), TRUE); if(IsDlgButtonChecked(IDC_RADIO5) == 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), TRUE); } } void CSaveOptDlg::OnRadio8() { m_nVR = DS_IMPLICIT_VR; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO5), FALSE); OnRadio14(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), FALSE); } void CSaveOptDlg::OnRadio9() { m_nVR = 0; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO8), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO5), TRUE); if(IsDlgButtonChecked(IDC_RADIO5) == 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO15), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO16), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO17), TRUE); } } void CSaveOptDlg::OnRadio10() { m_nGroupLen = DS_GROUP_LENGTHS; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio11() { m_nGroupLen = 0; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio12() { m_nLenEncoding = 0; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio13() { m_nLenEncoding = DS_LENGTH_EXPLICIT; m_nFlags = m_nMeta | m_nTransfer | m_nVR | m_nGroupLen | m_nLenEncoding; } void CSaveOptDlg::OnRadio14() { CheckDlgButton(IDC_RADIO14, 1); CheckDlgButton(IDC_RADIO15, 0); CheckDlgButton(IDC_RADIO16, 0); CheckDlgButton(IDC_RADIO17, 0); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO18), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO20), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); if(IsDlgButtonChecked(IDC_RADIO18) != 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), TRUE);//16 BPP } } void CSaveOptDlg::OnRadio15() { CheckDlgButton(IDC_RADIO14, 0); CheckDlgButton(IDC_RADIO15, 1); CheckDlgButton(IDC_RADIO16, 0); CheckDlgButton(IDC_RADIO17, 0); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO18), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO20), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); if(IsDlgButtonChecked(IDC_RADIO18) != 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), TRUE);//16 BPP } } void CSaveOptDlg::OnRadio16() { CheckDlgButton(IDC_RADIO14, 0); CheckDlgButton(IDC_RADIO15, 0); CheckDlgButton(IDC_RADIO16, 1); CheckDlgButton(IDC_RADIO17, 0); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO18), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO20), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), TRUE); if(IsDlgButtonChecked(IDC_RADIO18) != 0) ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP if(IsDlgButtonChecked(IDC_RADIO19) != 0) OnRadio20(); if(IsDlgButtonChecked(IDC_RADIO22) != 0) { OnRadio21(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP } } void CSaveOptDlg::OnRadio17() { CheckDlgButton(IDC_RADIO14, 0); CheckDlgButton(IDC_RADIO15, 0); CheckDlgButton(IDC_RADIO16, 0); CheckDlgButton(IDC_RADIO17, 1); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO18), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO19), FALSE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO20), TRUE); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_QFACTOR), FALSE); if(IsDlgButtonChecked(IDC_RADIO18) != 0) ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), FALSE);//8 BPP if(IsDlgButtonChecked(IDC_RADIO19) != 0) OnRadio20(); if(IsDlgButtonChecked(IDC_RADIO21) != 0) { OnRadio22(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), TRUE);//16 BPP } } void CSaveOptDlg::OnRadio18() { CheckDlgButton(IDC_RADIO18, 1); CheckDlgButton(IDC_RADIO19, 0); CheckDlgButton(IDC_RADIO20, 0); if(IsDlgButtonChecked(IDC_RADIO23) != 0) { if(IsDlgButtonChecked(IDC_RADIO17) != 0) OnRadio22(); else if(IsDlgButtonChecked(IDC_RADIO16) != 0) OnRadio21(); else OnRadio22(); } if(IsDlgButtonChecked(IDC_RADIO17) != 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), FALSE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), TRUE);//16 BPP } else if(IsDlgButtonChecked(IDC_RADIO16) != 0) { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP } else { ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), TRUE);//16 BPP } ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO23), FALSE);//24 BPP } void CSaveOptDlg::OnRadio19() { CheckDlgButton(IDC_RADIO18, 0); CheckDlgButton(IDC_RADIO19, 1); CheckDlgButton(IDC_RADIO20, 0); if(IsDlgButtonChecked(IDC_RADIO21) == 0) { OnRadio21(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), TRUE);//8 BPP } ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO23), FALSE);//24 BPP } void CSaveOptDlg::OnRadio20() { CheckDlgButton(IDC_RADIO18, 0); CheckDlgButton(IDC_RADIO19, 0); CheckDlgButton(IDC_RADIO20, 1); if(IsDlgButtonChecked(IDC_RADIO23) == 0) { OnRadio23(); ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO23), TRUE);//24 BPP } ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO21), FALSE);//8 BPP ::EnableWindow(::GetDlgItem(this->m_hWnd, IDC_RADIO22), FALSE);//16 BPP } void CSaveOptDlg::OnRadio21() { CheckDlgButton(IDC_RADIO21, 1); CheckDlgButton(IDC_RADIO22, 0); CheckDlgButton(IDC_RADIO23, 0); } void CSaveOptDlg::OnRadio22() { CheckDlgButton(IDC_RADIO21, 0); CheckDlgButton(IDC_RADIO22, 1); CheckDlgButton(IDC_RADIO23, 0); } void CSaveOptDlg::OnRadio23() { CheckDlgButton(IDC_RADIO21, 0); CheckDlgButton(IDC_RADIO22, 0); CheckDlgButton(IDC_RADIO23, 1); } void CSaveOptDlg::OnOK() { if(IsDlgButtonChecked(IDC_RADIO14) == 1) m_nCompression = DICOM_IMAGE_COMPRESSION_NONE; else if(IsDlgButtonChecked(IDC_RADIO15) == 1) m_nCompression = DICOM_IMAGE_COMPRESSION_RLE; else if(IsDlgButtonChecked(IDC_RADIO16) == 1) m_nCompression = DICOM_IMAGE_COMPRESSION_JPEG_LOSSY; else if(IsDlgButtonChecked(IDC_RADIO17) == 1) m_nCompression = DICOM_IMAGE_COMPRESSION_JPEG_LOSSLESS; if(IsDlgButtonChecked(IDC_RADIO18) == 1) m_nPhotometric = DICOM_IMAGE_PHOTOMETRIC_MONOCHROME2; else if(IsDlgButtonChecked(IDC_RADIO19) == 1) m_nPhotometric = DICOM_IMAGE_PHOTOMETRIC_PALETTE_COLOR; else if(IsDlgButtonChecked(IDC_RADIO20) == 1) m_nPhotometric = DICOM_IMAGE_PHOTOMETRIC_RGB; if(IsDlgButtonChecked(IDC_RADIO21) == 1) m_nBitsPerPixel = 8; else if(IsDlgButtonChecked(IDC_RADIO22) == 1) m_nBitsPerPixel = 16; else if(IsDlgButtonChecked(IDC_RADIO23) == 1) m_nBitsPerPixel = 24; m_nQFactor = GetDlgItemInt(IDC_QFACTOR, FALSE); CDialog::OnOK(); }