// PStrPage.cpp : implementation file // #include "stdafx.h" #include "cldprn32.h" #include "PStrPage.h" #include "PrnSheet.h" #include "SPStrDlg.h" #include "PJobPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define TRIM(String) \ String.TrimLeft(); \ String.TrimRight() ///////////////////////////////////////////////////////////////////////////// // CPullStoredPrintPage property page IMPLEMENT_DYNCREATE(CPullStoredPrintPage, CPropertyPage) CPullStoredPrintPage::CPullStoredPrintPage() : CPropertyPage(CPullStoredPrintPage::IDD), m_bPullPrintRequestCreated(FALSE), m_bReset(FALSE), m_bPendingOperation(FALSE), m_NumberOfCopiesChkBox(IDC_EDIT_NUMBEROFCOPIES), m_PrintPriorityChkBox(IDC_COMBO_PRINTPRIORITY), m_MediumTypeChkBox(IDC_COMBO_MEDIUMTYPE), m_FilmDestinationChkBox(IDC_COMBO_FILMDESTINATION), m_FilmSessionLabelChkBox(IDC_EDIT_FILMSESSIONLABEL), m_MemoryAllocationChkBox(IDC_EDIT_MEMORYALLOCATION), m_OwnerIDChkBox(IDC_EDIT_OWNERID) { //{{AFX_DATA_INIT(CPullStoredPrintPage) //}}AFX_DATA_INIT } CPullStoredPrintPage::~CPullStoredPrintPage() { } void CPullStoredPrintPage::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPullStoredPrintPage) DDX_Control(pDX, IDC_COMBO_FILMDESTINATION, m_FilmDestinationCombo); DDX_Control(pDX, IDC_COMBO_MEDIUMTYPE, m_MediumTypeCombo); DDX_Control(pDX, IDC_COMBO_PRINTPRIORITY, m_PrintPriorityCombo); DDX_Control(pDX, IDC_LIST_STOREDINSTANCES, m_StoredPrintInstancesListCtrl); DDX_Control(pDX, IDC_CHECK_NUMBEROFCOPIES, m_NumberOfCopiesChkBox); DDX_Control(pDX, IDC_CHECK_PRINTPRIORITY, m_PrintPriorityChkBox); DDX_Control(pDX, IDC_CHECK_MEDIUMTYPE, m_MediumTypeChkBox); DDX_Control(pDX, IDC_CHECK_FILMDESTINATION, m_FilmDestinationChkBox); DDX_Control(pDX, IDC_CHECK_FILMSESSIONLABEL, m_FilmSessionLabelChkBox); DDX_Control(pDX, IDC_CHECK_MEMORYALLOCATION, m_MemoryAllocationChkBox); DDX_Control(pDX, IDC_CHECK_OWNERID, m_OwnerIDChkBox); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPullStoredPrintPage, CPropertyPage) //{{AFX_MSG_MAP(CPullStoredPrintPage) ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd) ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit) ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove) ON_NOTIFY(NM_DBLCLK, IDC_LIST_STOREDINSTANCES, OnDblClkListStoredInstances) ON_BN_CLICKED(IDC_BUTTON_MORE, OnButtonMore) ON_BN_CLICKED(IDC_BUTTON_CREATE, OnButtonCreate) ON_BN_CLICKED(IDC_BUTTON_PRINT, OnButtonPrint) ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete) //}}AFX_MSG_MAP END_MESSAGE_MAP() void CPullStoredPrintPage::Reset() { m_bPullPrintRequestCreated = FALSE; m_bReset = FALSE; } void CPullStoredPrintPage::UpdateControlsState() { CPrintSCU& PrintSCU = ((CPrintScuSheet*) GetParent())->m_PrintSCU; BOOL bPullStoredPMSupported = PrintSCU.IsClassSupported(PRINTSCU_PULL_STORED_PM_META_SOP_CLASS); BOOL bStoredPrintInstanceInfoAdded = m_StoredPrintInstancesListCtrl.GetItemCount() > 0; BOOL bSupportedAndNotCreated = bPullStoredPMSupported && !m_bPullPrintRequestCreated; m_StoredPrintInstancesListCtrl.EnableWindow(bPullStoredPMSupported); GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(bSupportedAndNotCreated); GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(bSupportedAndNotCreated && bStoredPrintInstanceInfoAdded); GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(bSupportedAndNotCreated && bStoredPrintInstanceInfoAdded); m_NumberOfCopiesChkBox.EnableWindow(bSupportedAndNotCreated); m_PrintPriorityChkBox.EnableWindow(bSupportedAndNotCreated); m_MediumTypeChkBox.EnableWindow(bSupportedAndNotCreated); m_FilmDestinationChkBox.EnableWindow(bSupportedAndNotCreated); m_FilmSessionLabelChkBox.EnableWindow(bSupportedAndNotCreated); m_MemoryAllocationChkBox.EnableWindow(bSupportedAndNotCreated); m_OwnerIDChkBox.EnableWindow(bSupportedAndNotCreated); GetDlgItem(IDC_BUTTON_MORE)->EnableWindow(bSupportedAndNotCreated); GetDlgItem(IDC_BUTTON_CREATE)->EnableWindow(bSupportedAndNotCreated && bStoredPrintInstanceInfoAdded && !m_bPendingOperation); GetDlgItem(IDC_BUTTON_PRINT)->EnableWindow(bPullStoredPMSupported && m_bPullPrintRequestCreated && !m_bPendingOperation); GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(bPullStoredPMSupported && m_bPullPrintRequestCreated && !m_bPendingOperation); } void CPullStoredPrintPage::InitializeFields() { // Number of Copies SetDlgItemInt(IDC_EDIT_NUMBEROFCOPIES, 1); m_NumberOfCopiesChkBox.m_bChecked = TRUE; // Print Priority m_PrintPriorityCombo.AddString(TEXT("HIGH")); m_PrintPriorityCombo.AddString(TEXT("MED")); m_PrintPriorityCombo.AddString(TEXT("LOW")); m_PrintPriorityCombo.SetCurSel(1); m_PrintPriorityChkBox.m_bChecked = TRUE; // Medium Type m_MediumTypeCombo.AddString(TEXT("PAPER")); m_MediumTypeCombo.AddString(TEXT("CLEAR FILM")); m_MediumTypeCombo.AddString(TEXT("BLUE FILM")); m_MediumTypeCombo.SetCurSel(0); // Film Destination m_FilmDestinationCombo.AddString(TEXT("MAGAZINE")); m_FilmDestinationCombo.AddString(TEXT("PROCESSOR")); m_FilmDestinationCombo.AddString(TEXT("BIN_1")); m_FilmDestinationCombo.SetCurSel(0); } void CPullStoredPrintPage::EnableControls(BOOL bEnable) { GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(bEnable); m_NumberOfCopiesChkBox.EnableWindow(bEnable); m_PrintPriorityChkBox.EnableWindow(bEnable); m_MediumTypeChkBox.EnableWindow(bEnable); m_FilmDestinationChkBox.EnableWindow(bEnable); m_FilmSessionLabelChkBox.EnableWindow(bEnable); m_MemoryAllocationChkBox.EnableWindow(bEnable); m_OwnerIDChkBox.EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_MORE)->EnableWindow(bEnable); } ///////////////////////////////////////////////////////////////////////////// // CPullStoredPrintPage message handlers BOOL CPullStoredPrintPage::OnInitDialog() { CPropertyPage::OnInitDialog(); InitializeFields(); m_NumberOfCopiesChkBox.Initialize(); m_PrintPriorityChkBox.Initialize(); m_MediumTypeChkBox.Initialize(); m_FilmDestinationChkBox.Initialize(); m_FilmSessionLabelChkBox.Initialize(); m_MemoryAllocationChkBox.Initialize(); m_OwnerIDChkBox.Initialize(); // Prepare the list control of the Stored Print Storage SOP Instances m_StoredPrintInstancesListCtrl.InsertColumn(0, TEXT("Retrieve AE Title"), LVCFMT_LEFT, 100, 0); m_StoredPrintInstancesListCtrl.InsertColumn(1, TEXT("Ref. SOP Instance UID"), LVCFMT_LEFT, 130, 1); m_StoredPrintInstancesListCtrl.InsertColumn(2, TEXT("Study Instance UID"), LVCFMT_LEFT, 110, 2); m_StoredPrintInstancesListCtrl.InsertColumn(3, TEXT("Series Instance UID"), LVCFMT_LEFT, 110, 3); m_StoredPrintInstancesListCtrl.InsertColumn(4, TEXT("Patient ID"), LVCFMT_LEFT, 60, 4); m_StoredPrintInstancesListCtrl.SetExtendedStyle(m_StoredPrintInstancesListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP); return TRUE; } BOOL CPullStoredPrintPage::OnSetActive() { if (m_bReset) { Reset(); } UpdateControlsState(); return CPropertyPage::OnSetActive(); } void CPullStoredPrintPage::OnButtonAdd() { CStoredPrintStorageDlg StoredPrintStorageDlg; // Display the dialog box if (StoredPrintStorageDlg.DoModal() != IDOK) { return; } TRIM(StoredPrintStorageDlg.m_sRetrieveAETitle); TRIM(StoredPrintStorageDlg.m_sRefSOPInstanceUID); TRIM(StoredPrintStorageDlg.m_sStudyInstanceUID); TRIM(StoredPrintStorageDlg.m_sSeriesInstanceUID); TRIM(StoredPrintStorageDlg.m_sPatientID); int iIndex = m_StoredPrintInstancesListCtrl.InsertItem(m_StoredPrintInstancesListCtrl.GetItemCount(), StoredPrintStorageDlg.m_sRetrieveAETitle); if (iIndex != -1) { m_StoredPrintInstancesListCtrl.SetItemText(iIndex, 1, StoredPrintStorageDlg.m_sRefSOPInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iIndex, 2, StoredPrintStorageDlg.m_sStudyInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iIndex, 3, StoredPrintStorageDlg.m_sSeriesInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iIndex, 4, StoredPrintStorageDlg.m_sPatientID); m_StoredPrintInstancesListCtrl.SetItemState(iIndex, LVIS_SELECTED, LVIS_SELECTED); GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(TRUE); GetDlgItem(IDC_BUTTON_CREATE)->EnableWindow(TRUE); } } void CPullStoredPrintPage::OnButtonEdit() { POSITION pos = m_StoredPrintInstancesListCtrl.GetFirstSelectedItemPosition(); if (!pos) return; int iSelectedItemIndex = m_StoredPrintInstancesListCtrl.GetNextSelectedItem(pos); CStoredPrintStorageDlg StoredPrintStorageDlg; StoredPrintStorageDlg.m_sRetrieveAETitle = m_StoredPrintInstancesListCtrl.GetItemText(iSelectedItemIndex, 0); StoredPrintStorageDlg.m_sRefSOPInstanceUID = m_StoredPrintInstancesListCtrl.GetItemText(iSelectedItemIndex, 1); StoredPrintStorageDlg.m_sStudyInstanceUID = m_StoredPrintInstancesListCtrl.GetItemText(iSelectedItemIndex, 2); StoredPrintStorageDlg.m_sSeriesInstanceUID = m_StoredPrintInstancesListCtrl.GetItemText(iSelectedItemIndex, 3); StoredPrintStorageDlg.m_sPatientID = m_StoredPrintInstancesListCtrl.GetItemText(iSelectedItemIndex, 4); // Display the dialog box if (StoredPrintStorageDlg.DoModal() != IDOK) { return; } TRIM(StoredPrintStorageDlg.m_sRetrieveAETitle); TRIM(StoredPrintStorageDlg.m_sRefSOPInstanceUID); TRIM(StoredPrintStorageDlg.m_sStudyInstanceUID); TRIM(StoredPrintStorageDlg.m_sSeriesInstanceUID); TRIM(StoredPrintStorageDlg.m_sPatientID); m_StoredPrintInstancesListCtrl.SetItemText(iSelectedItemIndex, 0, StoredPrintStorageDlg.m_sRetrieveAETitle); m_StoredPrintInstancesListCtrl.SetItemText(iSelectedItemIndex, 1, StoredPrintStorageDlg.m_sRefSOPInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iSelectedItemIndex, 2, StoredPrintStorageDlg.m_sStudyInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iSelectedItemIndex, 3, StoredPrintStorageDlg.m_sSeriesInstanceUID); m_StoredPrintInstancesListCtrl.SetItemText(iSelectedItemIndex, 4, StoredPrintStorageDlg.m_sPatientID); } void CPullStoredPrintPage::OnButtonRemove() { POSITION pos = m_StoredPrintInstancesListCtrl.GetFirstSelectedItemPosition(); if (!pos) return; int iSelectedItemIndex = m_StoredPrintInstancesListCtrl.GetNextSelectedItem(pos); m_StoredPrintInstancesListCtrl.DeleteItem(iSelectedItemIndex); int iCount = m_StoredPrintInstancesListCtrl.GetItemCount(); if (iCount == 0) { GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_EDIT)->EnableWindow(FALSE); GetDlgItem(IDC_BUTTON_CREATE)->EnableWindow(FALSE); } else { int iIndex = (iSelectedItemIndex == iCount) ? iSelectedItemIndex - 1 : iSelectedItemIndex; m_StoredPrintInstancesListCtrl.SetItemState(iIndex, LVIS_SELECTED, LVIS_SELECTED); } } void CPullStoredPrintPage::OnButtonMore() { m_PullStoredPrintParametersDlg.DoModal(); } void CPullStoredPrintPage::OnButtonCreate() { CPrintScuSheet& PrintScuSheet = *((CPrintScuSheet*) GetParent()); CPrintSCU& PrintSCU = PrintScuSheet.m_PrintSCU; // Get the Stored Print Storage SOP Instances Info int iCount = m_StoredPrintInstancesListCtrl.GetItemCount(); if (iCount == 0) return; CString* Strings = new CString[5 * iCount]; if (!Strings) { PrintScuSheet.DisplayError(DICOM_ERROR_MEMORY); return; } pSTOREDPRINTSTORAGEINSTANCEINFO InstancesInfo = new STOREDPRINTSTORAGEINSTANCEINFO[iCount]; if (!InstancesInfo) { delete [] Strings; PrintScuSheet.DisplayError(DICOM_ERROR_MEMORY); return; } int i, j; for (i = 0; i < iCount; i++) { InstancesInfo[i].uStructSize = sizeof(STOREDPRINTSTORAGEINSTANCEINFO); for (j = 0; j < 5; j++) { Strings[5 * i + j] = m_StoredPrintInstancesListCtrl.GetItemText(i, j); switch (j) { case 0: InstancesInfo[i].pszRetrieveAETitle = Strings[5 * i + j]; break; case 1: InstancesInfo[i].pszReferencedSOPInstanceUID = Strings[5 * i + j]; break; case 2: InstancesInfo[i].pszStudyInstanceUID = Strings[5 * i + j]; break; case 3: InstancesInfo[i].pszSeriesInstanceUID = Strings[5 * i + j]; break; case 4: InstancesInfo[i].pszPatientID = Strings[5 * i + j]; break; } } } // END: Get the Stored Print Storage SOP Instances Info PULLPRINTREQUESTPARAMETERS Parameters; Parameters.uStructSize = sizeof(PULLPRINTREQUESTPARAMETERS); // Parameters on the property page int iNumberOfCopies = GetDlgItemInt(IDC_EDIT_NUMBEROFCOPIES); CString sPrintPriority; m_PrintPriorityCombo.GetWindowText(sPrintPriority); CString sMediumType; m_MediumTypeCombo.GetWindowText(sMediumType); CString sFilmDestination; m_FilmDestinationCombo.GetWindowText(sFilmDestination); CString sFilmSessionLabel; GetDlgItemText(IDC_EDIT_FILMSESSIONLABEL, sFilmSessionLabel); int iMemoryAllocation = GetDlgItemInt(IDC_EDIT_MEMORYALLOCATION); CString sOwnerID; GetDlgItemText(IDC_EDIT_OWNERID, sOwnerID); SET_NPARAM(Parameters.nNumberOfCopies, m_NumberOfCopiesChkBox, iNumberOfCopies); SET_SPARAM(Parameters.pszPrintPriority, m_PrintPriorityChkBox, sPrintPriority); SET_SPARAM(Parameters.pszMediumType, m_MediumTypeChkBox, sMediumType); SET_SPARAM(Parameters.pszFilmDestination, m_FilmDestinationChkBox, sFilmDestination); SET_SPARAM(Parameters.pszFilmSessionLabel, m_FilmSessionLabelChkBox, sFilmSessionLabel); SET_NPARAM(Parameters.nMemoryAllocation, m_MemoryAllocationChkBox, iMemoryAllocation); SET_SPARAM(Parameters.pszOwnerID, m_OwnerIDChkBox, sOwnerID); // END: Parameters on the property page // More parameters SET_SPARAM(Parameters.pszColorImagePrintingFlag, m_PullStoredPrintParametersDlg.m_ColorImagePrintingFlagChkBox, m_PullStoredPrintParametersDlg.m_sColorImagePrintingFlag); SET_SPARAM(Parameters.pszAnnotationFlag, m_PullStoredPrintParametersDlg.m_AnnotationFlagChkBox, m_PullStoredPrintParametersDlg.m_sAnnotationFlag); SET_SPARAM(Parameters.pszImageOverlayFlag, m_PullStoredPrintParametersDlg.m_ImageOverlayFlagChkBox, m_PullStoredPrintParametersDlg.m_sImageOverlayFlag); SET_SPARAM(Parameters.pszPresentationLUTFlag, m_PullStoredPrintParametersDlg.m_PresentationLUTFlagChkBox, m_PullStoredPrintParametersDlg.m_sPresentationLUTFlag); SET_SPARAM(Parameters.pszImageBoxPresentationLUTFlag, m_PullStoredPrintParametersDlg.m_ImageBoxPresentationLUTFlagChkBox, m_PullStoredPrintParametersDlg.m_sImageBoxPresentationLUTFlag); SET_SPARAM(Parameters.pszConfigurationInformation, m_PullStoredPrintParametersDlg.m_ConfigurationInformationChkBox, m_PullStoredPrintParametersDlg.m_sConfigurationInformation); SET_SPARAM(Parameters.pszCollationFlag, m_PullStoredPrintParametersDlg.m_CollationFlagChkBox, m_PullStoredPrintParametersDlg.m_sCollationFlag); SET_NPARAM(Parameters.nIllumination, m_PullStoredPrintParametersDlg.m_IlluminationChkBox, m_PullStoredPrintParametersDlg.m_iIllumination); SET_NPARAM(Parameters.nReflectedAmbientLight, m_PullStoredPrintParametersDlg.m_ReflectedAmbientLightChkBox, m_PullStoredPrintParametersDlg.m_iReflectedAmbientLight); PrintScuSheet.FlagPendingOperation(); EnableControls(FALSE); // Now ask the Print SCP to create a Pull Print Request SOP Instance L_INT iRet = PrintSCU.CreatePullPrintRequest(InstancesInfo, iCount, &Parameters); if (iRet != DICOM_SUCCESS) { delete [] InstancesInfo; delete [] Strings; PrintScuSheet.DisplayError(iRet); PrintScuSheet.FlagPendingOperation(FALSE); return; } delete [] InstancesInfo; delete [] Strings; m_bPullPrintRequestCreated = TRUE; PrintScuSheet.FlagPendingOperation(FALSE); } void CPullStoredPrintPage::OnButtonPrint() { CPrintScuSheet& PrintScuSheet = *((CPrintScuSheet*) GetParent()); CPrintSCU& PrintSCU = PrintScuSheet.m_PrintSCU; PrintScuSheet.FlagPendingOperation(); L_INT iRet = PrintSCU.PrintPullPrintRequestSession(); if (iRet != DICOM_SUCCESS) { PrintScuSheet.DisplayError(iRet); PrintScuSheet.FlagPendingOperation(FALSE); return; } PrintScuSheet.FlagPendingOperation(FALSE); // If the Print Job SOP Class is supported, then a Print Job SOP Instance UID should // have been sent by the Print SCP if (PrintSCU.IsClassSupported(PRINTSCU_PRINT_JOB_SOP_CLASS)) { PrintScuSheet.SetActivePage(&PrintScuSheet.m_PrintJobsPage); PrintScuSheet.m_PrintJobsPage.AddPrintJob(PrintSCU.GetPrintJobInstanceUID()); } } void CPullStoredPrintPage::OnButtonDelete() { CPrintScuSheet& PrintScuSheet = *((CPrintScuSheet*) GetParent()); CPrintSCU& PrintSCU = PrintScuSheet.m_PrintSCU; PrintScuSheet.FlagPendingOperation(); // Ask the Print SCP to delete the Pull Print Request SOP Instance L_INT iRet = PrintSCU.DeletePullPrintRequest(); if (iRet != DICOM_SUCCESS) { PrintScuSheet.DisplayError(iRet); PrintScuSheet.FlagPendingOperation(FALSE); return; } m_bPullPrintRequestCreated = FALSE; PrintScuSheet.FlagPendingOperation(FALSE); } void CPullStoredPrintPage::OnDblClkListStoredInstances(NMHDR* pNMHDR, LRESULT* pResult) { if (GetDlgItem(IDC_BUTTON_EDIT)->IsWindowEnabled()) { CPoint Point; ::GetCursorPos(&Point); m_StoredPrintInstancesListCtrl.ScreenToClient(&Point); int iIndex = m_StoredPrintInstancesListCtrl.HitTest(Point); if (iIndex != -1) { OnButtonEdit(); } } *pResult = 0; }