// FBDlg.cpp : implementation file // #include "stdafx.h" #include "cldprn32.h" #include "FBDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define CREATE_TITLE TEXT("Create Film Box") #define UPDATE_TITLE TEXT("Update Film Box") #define CREATE_LABEL TEXT("&Create") #define UPDATE_LABEL TEXT("&Update") ///////////////////////////////////////////////////////////////////////////// // CFilmBoxDlg dialog CFilmBoxDlg::CFilmBoxDlg(CTreeCtrl& PresentationLUTsTree, CWnd* pParent /*=NULL*/) : CDialog(CFilmBoxDlg::IDD, pParent), m_bCreationMode(TRUE), m_PresentationLUTsTree(PresentationLUTsTree), m_bEnableAnnotationDisplayFormatID(TRUE), m_iMinDensity(-1), m_iMaxDensity(-1), m_iIllumination(-1), m_iReflectedAmbientLight(-1), m_AnnotationDisplayFormatIDChkBox(IDC_EDIT_ANNOTATIONDISPLAYFORMATID), m_FilmOrientationChkBox(IDC_COMBO_FILMORIENTATION), m_FilmSizeIDChkBox(IDC_COMBO_FILMSIZEID), m_MagnificationTypeChkBox(IDC_COMBO_MAGNIFICATIONTYPE), m_SmoothingTypeChkBox(IDC_EDIT_SMOOTHINGTYPE), m_BorderDensityChkBox(IDC_COMBO_BORDERDENSITY), m_EmptyImageDensityChkBox(IDC_COMBO_EMPTYIMAGEDENSITY), m_MinDensityChkBox(IDC_EDIT_MINDENSITY), m_MaxDensityChkBox(IDC_EDIT_MAXDENSITY), m_TrimChkBox(IDC_COMBO_TRIM), m_ConfigurationInformationChkBox(IDC_EDIT_CONFIGURATIONINFORMATION), m_IlluminationChkBox(IDC_EDIT_ILLUMINATION), m_ReflectedAmbientLightChkBox(IDC_EDIT_REFLECTEDAMBIENTLIGHT), m_RequestedResolutionIDChkBox(IDC_COMBO_REQUESTEDRESOLUTIONID), m_ReferencedPresentationLUTChkBox(IDC_COMBO_REFERENCEDPRESENTATIONLUT) { //{{AFX_DATA_INIT(CFilmBoxDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } void CFilmBoxDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFilmBoxDlg) DDX_Control(pDX, IDC_COMBO_REFERENCEDPRESENTATIONLUT, m_ReferencedPresentationLUTCombo); DDX_Control(pDX, IDC_COMBO_REQUESTEDRESOLUTIONID, m_RequestedResolutionIDCombo); DDX_Control(pDX, IDC_COMBO_TRIM, m_TrimCombo); DDX_Control(pDX, IDC_COMBO_EMPTYIMAGEDENSITY, m_EmptyImageDensityCombo); DDX_Control(pDX, IDC_COMBO_BORDERDENSITY, m_BorderDensityCombo); DDX_Control(pDX, IDC_COMBO_MAGNIFICATIONTYPE, m_MagnificationTypeCombo); DDX_Control(pDX, IDC_COMBO_FILMSIZEID, m_FilmSizeIDCombo); DDX_Control(pDX, IDC_COMBO_FILMORIENTATION, m_FilmOrientationCombo); DDX_Control(pDX, IDC_COMBO_IMAGEDISPLAYFORMAT, m_ImageDisplayFormatCombo); DDX_Control(pDX, IDC_CHECK_ANNOTATIONDISPLAYFORMATID, m_AnnotationDisplayFormatIDChkBox); DDX_Control(pDX, IDC_CHECK_FILMORIENTATION, m_FilmOrientationChkBox); DDX_Control(pDX, IDC_CHECK_FILMSIZEID, m_FilmSizeIDChkBox); DDX_Control(pDX, IDC_CHECK_MAGNIFICATIONTYPE, m_MagnificationTypeChkBox); DDX_Control(pDX, IDC_CHECK_SMOOTHINGTYPE, m_SmoothingTypeChkBox); DDX_Control(pDX, IDC_CHECK_BORDERDENSITY, m_BorderDensityChkBox); DDX_Control(pDX, IDC_CHECK_EMPTYIMAGEDENSITY, m_EmptyImageDensityChkBox); DDX_Control(pDX, IDC_CHECK_MINDENSITY, m_MinDensityChkBox); DDX_Control(pDX, IDC_CHECK_MAXDENSITY, m_MaxDensityChkBox); DDX_Control(pDX, IDC_CHECK_TRIM, m_TrimChkBox); DDX_Control(pDX, IDC_CHECK_CONFIGURATIONINFORMATION, m_ConfigurationInformationChkBox); DDX_Control(pDX, IDC_CHECK_ILLUMINATION, m_IlluminationChkBox); DDX_Control(pDX, IDC_CHECK_REFLECTEDAMBIENTLIGHT, m_ReflectedAmbientLightChkBox); DDX_Control(pDX, IDC_CHECK_REQUESTEDRESOLUTIONID, m_RequestedResolutionIDChkBox); DDX_Control(pDX, IDC_CHECK_REFERENCEDPRESENTATIONLUT, m_ReferencedPresentationLUTChkBox); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CFilmBoxDlg, CDialog) //{{AFX_MSG_MAP(CFilmBoxDlg) ON_CBN_SELCHANGE(IDC_COMBO_MAGNIFICATIONTYPE, OnSelChangeComboMagnificationType) ON_BN_CLICKED(IDC_BUTTON_CREATEUPDATE, OnButtonCreateUpdate) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CFilmBoxDlg::SetDefaults() { // Image Display Format m_sImageDisplayFormat = TEXT("STANDARD\\1,1"); // Annotation Display Format ID m_AnnotationDisplayFormatIDChkBox.m_bChecked = FALSE; m_sAnnotationDisplayFormatID = TEXT(""); // Film Orientation m_FilmOrientationChkBox.m_bChecked = FALSE; m_sFilmOrientation = TEXT(""); // Film Size ID m_FilmSizeIDChkBox.m_bChecked = FALSE; m_sFilmSizeID = TEXT(""); // Magnification Type m_MagnificationTypeChkBox.m_bChecked = FALSE; m_sMagnificationType = TEXT(""); // Smoothing Type m_SmoothingTypeChkBox.m_bChecked = FALSE; m_sSmoothingType = TEXT(""); // Border Density m_BorderDensityChkBox.m_bChecked = FALSE; m_sBorderDensity = TEXT(""); // Empty Image Density m_EmptyImageDensityChkBox.m_bChecked = FALSE; m_sEmptyImageDensity = TEXT(""); // Min Density m_MinDensityChkBox.m_bChecked = FALSE; m_iMinDensity = -1; // Max Density m_MaxDensityChkBox.m_bChecked = FALSE; m_iMaxDensity = -1; // Trim m_TrimChkBox.m_bChecked = FALSE; m_sTrim = TEXT(""); // Configuration Information m_ConfigurationInformationChkBox.m_bChecked = FALSE; m_sConfigurationInformation = TEXT(""); // Illumination m_IlluminationChkBox.m_bChecked = FALSE; m_iIllumination = -1; // Reflected Ambient Light m_ReflectedAmbientLightChkBox.m_bChecked = FALSE; m_iReflectedAmbientLight = -1; // Requested Resolution ID m_RequestedResolutionIDChkBox.m_bChecked = FALSE; m_sRequestedResolutionID = TEXT(""); // Referenced Presentation LUT m_ReferencedPresentationLUTChkBox.m_bChecked = FALSE; m_sReferencedPresentationLUT = TEXT(""); } void CFilmBoxDlg::InitializeFields() { // Image Display Format m_ImageDisplayFormatCombo.AddString(TEXT("STANDARD\\1,1")); m_ImageDisplayFormatCombo.AddString(TEXT("ROW\\1")); m_ImageDisplayFormatCombo.AddString(TEXT("COL\\1")); m_ImageDisplayFormatCombo.AddString(TEXT("SLIDE")); m_ImageDisplayFormatCombo.AddString(TEXT("SUPERSLIDE")); m_ImageDisplayFormatCombo.AddString(TEXT("CUSTOM\\1")); m_ImageDisplayFormatCombo.SetCurSel(0); if (m_sImageDisplayFormat.GetLength()) { m_ImageDisplayFormatCombo.SetWindowText(m_sImageDisplayFormat); } // Annotation Display Format ID SetDlgItemText(IDC_EDIT_ANNOTATIONDISPLAYFORMATID, m_sAnnotationDisplayFormatID); // Film Orientation m_FilmOrientationCombo.AddString(TEXT("PORTRAIT")); m_FilmOrientationCombo.AddString(TEXT("LANDSCAPE")); m_FilmOrientationCombo.SetCurSel(0); m_FilmOrientationCombo.SelectString(-1, m_sFilmOrientation); // Film Size ID m_FilmSizeIDCombo.AddString(TEXT("8INX10IN")); m_FilmSizeIDCombo.AddString(TEXT("8_5INX11IN")); m_FilmSizeIDCombo.AddString(TEXT("10INX12IN")); m_FilmSizeIDCombo.AddString(TEXT("10INX14IN")); m_FilmSizeIDCombo.AddString(TEXT("11INX14IN")); m_FilmSizeIDCombo.AddString(TEXT("11INX17IN")); m_FilmSizeIDCombo.AddString(TEXT("14INX14IN")); m_FilmSizeIDCombo.AddString(TEXT("14INX17IN")); m_FilmSizeIDCombo.AddString(TEXT("24CMX24CM")); m_FilmSizeIDCombo.AddString(TEXT("24CMX30CM")); m_FilmSizeIDCombo.AddString(TEXT("A4")); m_FilmSizeIDCombo.AddString(TEXT("A3")); m_FilmSizeIDCombo.SetCurSel(0); m_FilmSizeIDCombo.SelectString(-1, m_sFilmSizeID); // Magnification Type m_MagnificationTypeCombo.AddString(TEXT("REPLICATE")); m_MagnificationTypeCombo.AddString(TEXT("BILINEAR")); m_MagnificationTypeCombo.AddString(TEXT("CUBIC")); m_MagnificationTypeCombo.AddString(TEXT("NONE")); m_MagnificationTypeCombo.SetCurSel(0); m_MagnificationTypeCombo.SelectString(-1, m_sMagnificationType); // Smoothing Type SetDlgItemText(IDC_EDIT_SMOOTHINGTYPE, m_sSmoothingType); UpdateSmoothingTypeControlsState(); // Border Density m_BorderDensityCombo.AddString(TEXT("BLACK")); m_BorderDensityCombo.AddString(TEXT("WHITE")); m_BorderDensityCombo.AddString(TEXT("150")); m_BorderDensityCombo.SetCurSel(0); if (m_sBorderDensity.GetLength()) { m_BorderDensityCombo.SetWindowText(m_sBorderDensity); } // Empty Image Density m_EmptyImageDensityCombo.AddString(TEXT("BLACK")); m_EmptyImageDensityCombo.AddString(TEXT("WHITE")); m_EmptyImageDensityCombo.AddString(TEXT("150")); m_EmptyImageDensityCombo.SetCurSel(0); if (m_sEmptyImageDensity.GetLength()) { m_EmptyImageDensityCombo.SetWindowText(m_sEmptyImageDensity); } // Min Density if (m_iMinDensity >= 0) { SetDlgItemInt(IDC_EDIT_MINDENSITY, m_iMinDensity, FALSE); } // Max Density if (m_iMaxDensity >= 0) { SetDlgItemInt(IDC_EDIT_MAXDENSITY, m_iMaxDensity, FALSE); } // Trim m_TrimCombo.AddString(TEXT("YES")); m_TrimCombo.AddString(TEXT("NO")); m_TrimCombo.SetCurSel(0); m_TrimCombo.SelectString(-1, m_sTrim); // Configuration Information SetDlgItemText(IDC_EDIT_CONFIGURATIONINFORMATION, m_sConfigurationInformation); // Illumination if (m_iIllumination >= 0) { SetDlgItemInt(IDC_EDIT_ILLUMINATION, m_iIllumination, FALSE); } // Reflected Ambient Light if (m_iReflectedAmbientLight >= 0) { SetDlgItemInt(IDC_EDIT_REFLECTEDAMBIENTLIGHT, m_iReflectedAmbientLight, FALSE); } // Requested Resolution ID m_RequestedResolutionIDCombo.AddString(TEXT("STANDARD")); m_RequestedResolutionIDCombo.AddString(TEXT("HIGH")); m_RequestedResolutionIDCombo.SetCurSel(0); m_RequestedResolutionIDCombo.SelectString(-1, m_sRequestedResolutionID); // Referenced Presentation LUT if (m_PresentationLUTsTree.GetCount() <= 0) { m_ReferencedPresentationLUTChkBox.m_bChecked = FALSE; m_ReferencedPresentationLUTChkBox.EnableWindow(FALSE); } else { int iIndex, iCurSel; LPCTSTR pszInstanceUID; CString sItemText; if (!m_bCreationMode) { // If the Film Box references a Presentation LUT, then updating the Film Box while // specifying an empty string will remove that reference. iIndex = m_ReferencedPresentationLUTCombo.AddString(TEXT("")); m_ReferencedPresentationLUTCombo.SetItemData(iIndex, 0); } iCurSel = 0; HTREEITEM hPresLUTItem = m_PresentationLUTsTree.GetRootItem(); while (hPresLUTItem) { sItemText = m_PresentationLUTsTree.GetItemText(hPresLUTItem); pszInstanceUID = (LPCTSTR) m_PresentationLUTsTree.GetItemData(hPresLUTItem); iIndex = m_ReferencedPresentationLUTCombo.AddString(sItemText); m_ReferencedPresentationLUTCombo.SetItemData(iIndex, DWORD(pszInstanceUID)); if (m_sReferencedPresentationLUT == pszInstanceUID) { iCurSel = iIndex; } hPresLUTItem = m_PresentationLUTsTree.GetNextItem(hPresLUTItem, TVGN_NEXT); } m_ReferencedPresentationLUTCombo.SetCurSel(iCurSel); } m_ReferencedPresentationLUTChkBox.Initialize(); } void CFilmBoxDlg::UpdateSmoothingTypeControlsState() { // The Smoothing Type is only valid for Magnification Type = CUBIC if (m_MagnificationTypeChkBox.GetCheck() == 1) { CString sValue; m_MagnificationTypeCombo.GetWindowText(sValue); m_SmoothingTypeChkBox.EnableWindow(sValue == TEXT("CUBIC")); } else { m_SmoothingTypeChkBox.EnableWindow(FALSE); } } ///////////////////////////////////////////////////////////////////////////// // CFilmBoxDlg message handlers BOOL CFilmBoxDlg::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(m_bCreationMode ? CREATE_TITLE : UPDATE_TITLE); SetDlgItemText(IDC_BUTTON_CREATEUPDATE, m_bCreationMode ? CREATE_LABEL : UPDATE_LABEL); m_AnnotationDisplayFormatIDChkBox.Initialize(); m_FilmOrientationChkBox.Initialize(); m_FilmSizeIDChkBox.Initialize(); m_MagnificationTypeChkBox.Initialize(); m_SmoothingTypeChkBox.Initialize(); m_BorderDensityChkBox.Initialize(); m_EmptyImageDensityChkBox.Initialize(); m_MinDensityChkBox.Initialize(); m_MaxDensityChkBox.Initialize(); m_TrimChkBox.Initialize(); m_ConfigurationInformationChkBox.Initialize(); m_IlluminationChkBox.Initialize(); m_ReflectedAmbientLightChkBox.Initialize(); m_RequestedResolutionIDChkBox.Initialize(); // Not all the Attributes that are specified at the creation time can be updated GetDlgItem(IDC_COMBO_IMAGEDISPLAYFORMAT)->EnableWindow(m_bCreationMode); m_AnnotationDisplayFormatIDChkBox.EnableWindow(m_bCreationMode && m_bEnableAnnotationDisplayFormatID); m_FilmOrientationChkBox.EnableWindow(m_bCreationMode); m_FilmSizeIDChkBox.EnableWindow(m_bCreationMode); m_RequestedResolutionIDChkBox.EnableWindow(m_bCreationMode); InitializeFields(); return TRUE; } void CFilmBoxDlg::OnButtonCreateUpdate() { // If we are updating the Film Box, then at least one attribute must be specified if (!m_bCreationMode) { CAttribCheckBox* AttribCheckBoxes[] = { &m_AnnotationDisplayFormatIDChkBox, &m_FilmOrientationChkBox, &m_FilmSizeIDChkBox, &m_MagnificationTypeChkBox, &m_SmoothingTypeChkBox, &m_BorderDensityChkBox, &m_EmptyImageDensityChkBox, &m_MinDensityChkBox, &m_MaxDensityChkBox, &m_TrimChkBox, &m_ConfigurationInformationChkBox, &m_IlluminationChkBox, &m_ReflectedAmbientLightChkBox, &m_RequestedResolutionIDChkBox, &m_ReferencedPresentationLUTChkBox }; int iCount = sizeof(AttribCheckBoxes) / sizeof(AttribCheckBoxes[0]); for (int i = 0; i < iCount; i++) { if (AttribCheckBoxes[i]->m_bEnabled && AttribCheckBoxes[i]->m_bChecked) break; } if (i >= iCount) { MessageBox(TEXT("Please specify at least one attribute to be updated."), TEXT("Print SCU"), MB_ICONEXCLAMATION); return; } } CString sValue; // Image Display Format m_ImageDisplayFormatCombo.GetWindowText(m_sImageDisplayFormat); // Annotation Display Format ID GetDlgItemText(IDC_EDIT_ANNOTATIONDISPLAYFORMATID, m_sAnnotationDisplayFormatID); // Film Orientation m_FilmOrientationCombo.GetWindowText(m_sFilmOrientation); // Film Size ID m_FilmSizeIDCombo.GetWindowText(m_sFilmSizeID); // Magnification Type m_MagnificationTypeCombo.GetWindowText(m_sMagnificationType); // Smoothing Type GetDlgItemText(IDC_EDIT_SMOOTHINGTYPE, m_sSmoothingType); // Border Density m_BorderDensityCombo.GetWindowText(m_sBorderDensity); // Empty Image Density m_EmptyImageDensityCombo.GetWindowText(m_sEmptyImageDensity); // Min Density GetDlgItemText(IDC_EDIT_MINDENSITY, sValue); if (!m_MinDensityChkBox.m_bChecked && sValue.IsEmpty()) { m_iMinDensity = -1; } else { m_iMinDensity = atoi(sValue); } // Max Density GetDlgItemText(IDC_EDIT_MAXDENSITY, sValue); if (!m_MaxDensityChkBox.m_bChecked && sValue.IsEmpty()) { m_iMaxDensity = -1; } else { m_iMaxDensity = atoi(sValue); } // Trim m_TrimCombo.GetWindowText(m_sTrim); // Configuration Information GetDlgItemText(IDC_EDIT_CONFIGURATIONINFORMATION, m_sConfigurationInformation); // Illumination GetDlgItemText(IDC_EDIT_ILLUMINATION, sValue); if (!m_IlluminationChkBox.m_bChecked && sValue.IsEmpty()) { m_iIllumination = -1; } else { m_iIllumination = atoi(sValue); } // Reflected Ambient Light GetDlgItemText(IDC_EDIT_REFLECTEDAMBIENTLIGHT, sValue); if (!m_ReflectedAmbientLightChkBox.m_bChecked && sValue.IsEmpty()) { m_iReflectedAmbientLight = -1; } else { m_iReflectedAmbientLight = atoi(sValue); } // Requested Resolution ID m_RequestedResolutionIDCombo.GetWindowText(m_sRequestedResolutionID); // Referenced Presentation LUT LPCTSTR pszInstanceUID = NULL; int iCurSel = m_ReferencedPresentationLUTCombo.GetCurSel(); if (iCurSel >= 0) { pszInstanceUID = (LPCTSTR) m_ReferencedPresentationLUTCombo.GetItemData(iCurSel); } m_sReferencedPresentationLUT = pszInstanceUID ? pszInstanceUID : TEXT(""); CDialog::OnOK(); } void CFilmBoxDlg::OnCancel() { m_AnnotationDisplayFormatIDChkBox.m_bChecked = m_AnnotationDisplayFormatIDChkBox.m_bInitiallyChecked; m_FilmOrientationChkBox.m_bChecked = m_FilmOrientationChkBox.m_bInitiallyChecked; m_FilmSizeIDChkBox.m_bChecked = m_FilmSizeIDChkBox.m_bInitiallyChecked; m_MagnificationTypeChkBox.m_bChecked = m_MagnificationTypeChkBox.m_bInitiallyChecked; m_SmoothingTypeChkBox.m_bChecked = m_SmoothingTypeChkBox.m_bInitiallyChecked; m_BorderDensityChkBox.m_bChecked = m_BorderDensityChkBox.m_bInitiallyChecked; m_EmptyImageDensityChkBox.m_bChecked = m_EmptyImageDensityChkBox.m_bInitiallyChecked; m_MinDensityChkBox.m_bChecked = m_MinDensityChkBox.m_bInitiallyChecked; m_MaxDensityChkBox.m_bChecked = m_MaxDensityChkBox.m_bInitiallyChecked; m_TrimChkBox.m_bChecked = m_TrimChkBox.m_bInitiallyChecked; m_ConfigurationInformationChkBox.m_bChecked = m_ConfigurationInformationChkBox.m_bInitiallyChecked; m_IlluminationChkBox.m_bChecked = m_IlluminationChkBox.m_bInitiallyChecked; m_ReflectedAmbientLightChkBox.m_bChecked = m_ReflectedAmbientLightChkBox.m_bInitiallyChecked; m_RequestedResolutionIDChkBox.m_bChecked = m_RequestedResolutionIDChkBox.m_bInitiallyChecked; m_ReferencedPresentationLUTChkBox.m_bChecked = m_ReferencedPresentationLUTChkBox.m_bInitiallyChecked; CDialog::OnCancel(); } BOOL CFilmBoxDlg::OnCommand(WPARAM wParam, LPARAM lParam) { if (wParam == IDC_CHECK_MAGNIFICATIONTYPE) { UpdateSmoothingTypeControlsState(); } return CDialog::OnCommand(wParam, lParam); } void CFilmBoxDlg::OnSelChangeComboMagnificationType() { UpdateSmoothingTypeControlsState(); }