///////////////////////////////////////////////////////////////////////////// // // Implementation of the CMainDlg class. // // Copyright © 2000-2001 Medicor Imaging. All rights reserved. // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "MainApp.h" #include "MainDlg.h" #include "IODMsg.h" #define UIDLEN 64 TCHAR INSTANCEGUID[UIDLEN]; //Generate a UID void CreateGUID() { SYSTEMTIME SystemTime; FILETIME FileTime; GetSystemTime(&SystemTime); SystemTimeToFileTime(&SystemTime,&FileTime); DWORD Tick=GetTickCount(); DWORD HighWord=FileTime.dwHighDateTime+0x146BF4; wsprintf( INSTANCEGUID, TEXT("1.2.840.114257.0.1%010u%05u%05u%05u%05u%05u%05u"), FileTime.dwLowDateTime, LOWORD(HighWord), HIWORD(HighWord |0x10000000), LOWORD(rand()), HIWORD(Tick), LOWORD(Tick), LOWORD(rand())); return ; } ///////////////////////////////////////////////////////////////////////////// CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/) : CDialog(CMainDlg::IDD, pParent) { //{{AFX_DATA_INIT(CMainDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_nRows = USER_DEFAULT_ROWS; m_nColumns = USER_DEFAULT_COLUMNS; m_szText = USER_DEFAULT_TEXT; m_nStep = 1; } ///////////////////////////////////////////////////////////////////////////// void CMainDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMainDlg) DDX_Control(pDX, IDC_TREE, m_IODTree); //}}AFX_DATA_MAP } ///////////////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CMainDlg, CDialog) //{{AFX_MSG_MAP(CMainDlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_STEP, OnStep) ON_BN_CLICKED(IDC_OVERLAY_HELP, OnOverlayHelp) ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// BOOL CMainDlg::OnInitDialog() { CDialog::OnInitDialog(); SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE); //Default values for the Overlay Plane Module SetDlgItemText(IDC_EDIT_TYPE, "G"); SetDlgItemText(IDC_EDIT_ORIGIN, "1/1"); SetDlgItemInt(IDC_EDIT_BPOSITION, 0); SetDlgItemInt(IDC_EDIT_BALLOCATED, 1); SetDlgItemInt(IDC_EDIT_ROWS, m_nRows); SetDlgItemInt(IDC_EDIT_COLUMNS, m_nColumns); SetDlgItemText(IDC_EDIT_TEXT, m_szText); SetDlgItemText(IDC_STEP, "1: Delete IOD Class"); Add_IOD_Tree(0, ""); return TRUE; } ///////////////////////////////////////////////////////////////////////////// // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CMainDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } ///////////////////////////////////////////////////////////////////////////// // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CMainDlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } ///////////////////////////////////////////////////////////////////////////// L_BOOL CMainDlg::Find_Delete_IOD() { DICOMIOD *pElementIOD, *pModuleIOD, *pClassIOD; DICOMUID *pElementUID; //Load default IOD structure m_IOD.Default(); /******************************************************/ /* Show how to find IOD classes, modules and elements */ /* in the LEAD predefined IOD tree structure */ /******************************************************/ // Find the specified class pClassIOD = m_IOD.FindClass(USER_CLASS); if (pClassIOD == NULL) { return FALSE; } // Find the specified module inside the class pModuleIOD = m_IOD.FindModule(USER_CLASS, MODULE_OVERLAY_IDENTIFICATION); if (pModuleIOD == NULL) { return FALSE; } Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE1)); // Find a specific element inside the module // In order to find the elements from the Module Overlay // Identification you must move the tree cursor to the element level pElementIOD = m_IOD.GetChild(pModuleIOD); pElementIOD = m_IOD.Find( pElementIOD, TAG_OVERLAY_NUMBER, IOD_TYPE_ELEMENT, TRUE); if (pElementIOD == NULL) { return FALSE; } Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE2)); /*********************************************************/ /* Show how to delete IOD classes, modules and elements */ /* in the LEAD predefined IOD tree structure. */ /* Please note that when you delete a class, all modules */ /* under that class get deleted and hence all the */ /* elements under those modules. In the steps below we */ /* delete an element from a module then a module from */ /* the class and then the class itself for illustration */ /* purposes . */ /*********************************************************/ // Delete element Overlay Name m_IOD.GetChild(pModuleIOD); // Find the element first pElementIOD = m_IOD.Find( pElementIOD, TAG_OVERLAY_NUMBER, IOD_TYPE_ELEMENT, TRUE); if (pElementIOD == NULL) { return FALSE; } // Then delete it m_IOD.Delete(pElementIOD); //Show a message indicating that the element was deleted Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE3)); // Delete module Overlay Identification and implicitly all elements from this // module (Overlay Number, Date, Time etc) m_IOD.Delete(pModuleIOD); //Show a message indicating that the Module was deleted Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE4)); //Delete class Overlay Storage and implicitly all modules from this class m_IOD.Delete(pClassIOD); //Delete the associate UID from LEAD predefined UID tree structure pElementUID = m_UID.Find(USER_CLASS_UID); m_UID.Delete(pElementUID); //Show a message indicating that the Class was deleted Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE5)); //All these functions will return errors (pElementIOD = NULL) pElementIOD = m_IOD.FindModule(USER_CLASS, MODULE_OVERLAY_IDENTIFICATION); Add_IOD_Tree(0, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE6)); pElementIOD = m_IOD.FindClass(USER_CLASS); Add_IOD_Tree(0, MAKEINTRESOURCE(IDS_DELETE_IOD_MESSAGE7)); pElementUID = m_UID.Find(USER_CLASS_UID); return TRUE; } L_BOOL CMainDlg::Add_IOD() { DICOMIOD *pElementIOD, *pModuleIOD, *pClassIOD; DICOMUID *pElementUID; /***************************************************/ /* In order to add a new IOD class we have to add */ /* 1. UID Class in UID LEAD table */ /* 2. IOD Class in IOD LEAD table */ /* 3. IOD Modules to the IOD Class */ /* 4. IOD Elements to the IOD Modules */ /***************************************************/ //Add UID and IOD for the Class pElementUID = m_UID.Insert(USER_CLASS_UID, "Standalone Overlay Storage", UID_TYPE_CLASS); if (pElementUID == FALSE) { return FALSE; } // Insert this class to the IOD table pClassIOD = m_IOD.Insert( NULL, FALSE, USER_CLASS, "Standalone Overlay Storage", IOD_TYPE_CLASS, 0, USER_CLASS_UID); if (pClassIOD == NULL) { return FALSE; } // Display a message indicating that we succeeded in inserting the class Add_IOD_Tree(0, MAKEINTRESOURCE(IDS_ADD_IOD_MESSAGE1)); //Add IOD Module Overlay Identification pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_OVERLAY_IDENTIFICATION, "Overlay Identification", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } // Display a message indicating that we succeeded in inserting the module Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_ADD_IOD_MESSAGE2)); //Add IOD Elements for the module Overlay Identification pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_NUMBER, "Overlay Number", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_ADD_IOD_MESSAGE3)); //Add IOD Module Patient pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_PATIENT, "Patient", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module Patient if(AddPatientModuleElements(pModuleIOD) != TRUE) { return FALSE; } //Add IOD Module General Study pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_GENERAL_STUDY, "General Study", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module General Study if(AddGeneralStudyModuleElements(pModuleIOD) != TRUE) { return FALSE; } //Add IOD Module General Series pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_GENERAL_SERIES, "General Series", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module General Series if(AddGeneralSeriesModuleElements(pModuleIOD) != TRUE) { return FALSE; } //Add IOD Module SOP Common pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_SOP_COMMON, "SOP Common", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module SOP Common pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_SOP_INSTANCE_UID, "SOP Instance UID", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); //Add IOD Elements for the module SOP Common pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_SOP_CLASS_UID, "SOP Class UID", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); //Add IOD Module General Equipment pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_GENERAL_EQUIPMENT, "General Equipment", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module General Equipment pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_MANUFACTURER, "Manufacturer", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); //Add IOD Module Overlay Plane pModuleIOD = m_IOD.Insert( pClassIOD, TRUE, MODULE_OVERLAY_PLANE, "Overlay Plane", IOD_TYPE_MODULE, IOD_USAGE_M, ""); if (pModuleIOD == NULL) { return FALSE; } //Add IOD Elements for the module Overlay Plane if (AddOverlayPlaneModuleElements(pModuleIOD) != TRUE) { return FALSE; } pElementIOD = m_IOD.FindClass(USER_CLASS); Add_IOD_Tree(pModuleIOD, MAKEINTRESOURCE(IDS_ADD_IOD_MESSAGE4)); return TRUE; } L_BOOL CMainDlg::Create_Class() { //Initialize a dataset with our new class m_DS.InitDS(USER_CLASS, DS_LITTLE_ENDIAN | DS_EXPLICIT_VR); return TRUE; } L_BOOL CMainDlg::Save_Class() { /******************************************************/ /* 1. Create a new dataset using our IOD class */ /* 2. Fill in the values for the module Overlay Plane */ /* 3. Save the data set */ /******************************************************/ DICOMELEMENT *pElement; BITMAPHANDLE hBitmap; RECT rct; HGLOBAL hFileInMemory=NULL; L_UINT32 uMemSize; L_INT16 nData; CString szFileName; L_INT nRet; //Set default values for the module //Patient, //General Study, //General Series, //Overlay Identification, //General Equipment AddDefaultValues(); //Set values for the module Overlay Plane elements //Set the element Overlay Bits Allocated nData = GetDlgItemInt(IDC_EDIT_BALLOCATED); pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_BITS_ALLOCATED, FALSE); m_DS.SetShortValue(pElement, &nData, 1); //Set the element Overlay Bit Position nData = GetDlgItemInt(IDC_EDIT_BPOSITION); pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_BIT_POSITION, FALSE); m_DS.SetShortValue(pElement, &nData, 1); //Set the element Overlay Origin nData = GetDlgItemInt(IDC_EDIT_ORIGIN); pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_ORIGIN, FALSE); m_DS.SetShortValue(pElement, &nData, 1); //Set the element Overlay Type pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_TYPE, FALSE); m_DS.SetStringValue(pElement, "G", 1); //Set the element Overlay Rows m_nRows = GetDlgItemInt(IDC_EDIT_ROWS); pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_ROWS, FALSE); m_DS.SetShortValue(pElement, &m_nRows, 1); //Set the element Overlay Columns m_nColumns = GetDlgItemInt(IDC_EDIT_COLUMNS); pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_COLUMNS, FALSE); m_DS.SetShortValue(pElement, &m_nColumns, 1); GetDlgItemText(IDC_EDIT_TEXT, m_szText); L_INITBITMAP( &hBitmap, sizeof(BITMAPHANDLE), m_nColumns, m_nRows, 24); //Create Overlay Data in memory nRet = L_CREATEBITMAP( &hBitmap, sizeof(BITMAPHANDLE), TYPE_CONV, m_nColumns, m_nRows, 24, ORDER_BGR, NULL, TOP_LEFT, NULL, 0); if (nRet != SUCCESS) { AfxMessageBox("Error creating the bitmap"); return FALSE; } rct.left = 0; rct.top = 0; rct.right = m_nColumns; rct.bottom = m_nRows; //Create memory contex for Overlay Data m_hDC = L_CREATELEADDC(&hBitmap); if (m_hDC == NULL) { L_FREEBITMAP(&hBitmap); AfxMessageBox("Error creating Lead DC"); return FALSE; } //Write text to Overlay Data L_EFXDRAW3DTEXT(m_hDC, (L_CHAR*)(LPCTSTR)m_szText, &rct, EFX_TEXT_NORMAL, 0, 0, RGB ( 255,255,255 ), RGB ( 0,0,0 ), RGB ( 0,0,0 ), (HFONT) GetStockObject(SYSTEM_FONT ), NULL); //Save Overlay Data to memory nRet = L_SAVEBITMAPMEMORY(&hFileInMemory, &hBitmap, FILE_RAW, 1, 0, &uMemSize, NULL); if (nRet != SUCCESS) { L_FREEBITMAP(&hBitmap); L_DELETELEADDC(m_hDC); AfxMessageBox("Error creating the bitmap"); return FALSE; } //Set the element Overlay Data pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_DATA, FALSE); m_DS.SetBinaryValue(pElement, hFileInMemory, uMemSize); //Get the DICOM file name TCHAR szFilters[] =_T ("DICOM Files (*.dic;*.dcm)|*.dic;*.dcm|All files (*.*)|*.*||"); CFileDialog dlg (FALSE, NULL, "",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilters); if (dlg.DoModal() == IDOK) { szFileName = dlg.GetPathName(); // Save the DICOM file m_DS.SaveDS((L_CHAR*)(LPCTSTR)szFileName, 0); } //Free resource used L_FREEBITMAP(&hBitmap); L_DELETELEADDC(m_hDC); GlobalFree(hFileInMemory); return TRUE; } void CMainDlg::OnStep() { CEdit *editData; L_INT nRet; CRect rct; CWnd *wnd; L_INT x, y; switch (m_nStep) { case 1: { //Step 1 //Call function for step 1 nRet = Find_Delete_IOD(); if (nRet == TRUE) { //Set the controls for step 1 wnd = GetDlgItem(IDC_MESSAGE_STEP2); //Move the Group box to the correct position wnd->GetWindowRect(&rct); ScreenToClient(&rct); y = rct.top - 10; x = rct.left - 5; wnd = GetDlgItem(IDC_RCT); wnd->GetWindowRect(&rct); ScreenToClient(&rct); rct.OffsetRect(x - rct.left, y - rct.top); wnd->MoveWindow(rct, TRUE); SetDlgItemText(IDC_STEP, "2: Add IOD Class"); m_nStep++; InvalidateRect(NULL, TRUE); } else { AfxMessageBox("Error. Delete IOD failure."); } break; } case 2: { //Step 2 //Call function for step 2 nRet = Add_IOD(); if (nRet == TRUE) { //Set the controls for step 2 SetDlgItemText(IDC_STEP, "3: Create DICOM"); //Move the Group box to the correct position wnd = GetDlgItem(IDC_MESSAGE_STEP3); wnd->GetWindowRect(&rct); ScreenToClient(&rct); y = rct.top - 10; x = rct.left - 5; wnd = GetDlgItem(IDC_RCT); wnd->GetWindowRect(&rct); ScreenToClient(&rct); rct.OffsetRect(x - rct.left, y - rct.top); wnd->MoveWindow(rct, TRUE); m_nStep++; InvalidateRect(NULL, TRUE); } else { AfxMessageBox("Error. Adding IOD failure."); } break; } case 3: { //Step 3 //Call function for step 3 nRet = Create_Class(); if (nRet == TRUE) { //Set the controls for step 3 editData = (CEdit*)GetDlgItem(IDC_EDIT_ROWS); editData->SetReadOnly(FALSE); editData = (CEdit*)GetDlgItem(IDC_EDIT_COLUMNS); editData->SetReadOnly(FALSE); editData = (CEdit*)GetDlgItem(IDC_EDIT_TEXT); editData->SetReadOnly(FALSE); //Move the Group box to the correct position wnd = GetDlgItem(IDC_MESSAGE_STEP4); wnd->GetWindowRect(&rct); ScreenToClient(&rct); y = rct.top - 10; x = rct.left - 5; wnd = GetDlgItem(IDC_RCT); wnd->GetWindowRect(&rct); ScreenToClient(&rct); rct.OffsetRect(x - rct.left, y - rct.top); wnd->MoveWindow(rct, TRUE); SetDlgItemText(IDC_STEP, "4: Save DICOM"); m_nStep++; InvalidateRect(NULL, TRUE); } else { AfxMessageBox("Error. Creating DICOM failure."); } break; } case 4: { //Step 4 //Call function for step 4 nRet = Save_Class(); if (nRet == TRUE) { //Set the controls for step 4 editData = (CEdit*)GetDlgItem(IDC_EDIT_ROWS); editData->SetReadOnly(TRUE); editData = (CEdit*)GetDlgItem(IDC_EDIT_COLUMNS); editData->SetReadOnly(TRUE); editData = (CEdit*)GetDlgItem(IDC_EDIT_TEXT); editData->SetReadOnly(TRUE); SetDlgItemText(IDC_STEP, "1: Delete IOD Class"); //Move the Group box to the correct position wnd = GetDlgItem(IDC_MESSAGE_STEP1); wnd->GetWindowRect(&rct); ScreenToClient(&rct); y = rct.top - 10; x = rct.left - 5; wnd = GetDlgItem(IDC_RCT); wnd->GetWindowRect(&rct); ScreenToClient(&rct); rct.OffsetRect(x - rct.left, y - rct.top); wnd->MoveWindow(rct, TRUE); InvalidateRect(NULL, TRUE); m_nStep = 1; } else { AfxMessageBox("Error. Saving DICOM failure."); } break; } } } L_BOOL CMainDlg::Add_IOD_Tree(DICOMIOD* pIOD, CString szText) { DICOMIOD *pElementIOD, *pModuleIOD, *pClassIOD; HTREEITEM hModuleItem, hClassItem, hItemSelected; CIODMessage dlgIOD; //Construct the IOD tree m_IODTree.DeleteAllItems(); //Find user IOD Class pClassIOD = m_IOD.FindClass(USER_CLASS); if (pClassIOD == NULL) { if (szText != "") { dlgIOD.m_szMessage = szText; dlgIOD.DoModal(); } return FALSE; } //Insert IOD Class hClassItem = m_IODTree.InsertItem(pClassIOD->pszName); pModuleIOD = m_IOD.GetChild(pClassIOD); while (pModuleIOD != NULL) { if (pModuleIOD->nUsage == IOD_USAGE_M) { //Insert IOD Module hModuleItem = m_IODTree.InsertItem(pModuleIOD->pszName, hClassItem); if (pModuleIOD == pIOD) { hItemSelected = hModuleItem; } } pElementIOD = m_IOD.GetChild(pModuleIOD); while (pElementIOD != NULL) { //Insert IOD Element type 1, 1C, 2, 2C if ((pElementIOD->nUsage == IOD_USAGE_1) || (pElementIOD->nUsage == IOD_USAGE_1C) || (pElementIOD->nUsage == IOD_USAGE_2) || (pElementIOD->nUsage == IOD_USAGE_2C)) { //Show the type for the specified element //sz.Format(" - Type :%d",pElementIOD->nUsage); //sz = pElementIOD->pszName + sz; if (pElementIOD == pIOD) { hItemSelected = m_IODTree.InsertItem(pElementIOD->pszName, hModuleItem); } else { m_IODTree.InsertItem(pElementIOD->pszName, hModuleItem); } } //Get next IOD element pElementIOD = m_IOD.GetNext(pElementIOD, TRUE); } //Get next IOD module pModuleIOD = m_IOD.GetNext(pModuleIOD, TRUE); } m_IODTree.Expand(hClassItem, TVE_EXPAND); //Display message if (szText != "") { m_IODTree.Expand(hItemSelected, TVE_EXPAND); dlgIOD.m_szMessage = szText; dlgIOD.DoModal(); } return TRUE; } L_BOOL CMainDlg::AddPatientModuleElements(DICOMIOD *pModuleIOD) { //Add all mandatory elements to the module Patient DICOMIOD *pElementIOD; pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_PATIENT_NAME, "Patient Name", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Patient ID pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_PATIENT_ID, "Patient ID", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Patient Birth Date pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_PATIENT_BIRTH_DATE, "Patient Birth Date", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Patient Sex pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_PATIENT_SEX, "Patient Sex", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } return TRUE; } L_BOOL CMainDlg::AddGeneralStudyModuleElements(DICOMIOD *pModuleIOD) { //Add all mandatory elements to the module General Study DICOMIOD *pElementIOD; //Insert element Study Instance UID pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_STUDY_INSTANCE_UID, "Study Instance UID", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Study Date pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_STUDY_DATE, "Study Date", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Study Type pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_STUDY_TIME, "Study Time", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Referring Physician Name pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_REFERRING_PHYSICIAN_NAME, "Study Referring Physician Name", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Study ID pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_STUDY_ID, "Study ID", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Accession Number pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_ACCESSION_NUMBER, "Accession Number", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } return TRUE; } L_BOOL CMainDlg::AddGeneralSeriesModuleElements(DICOMIOD *pModuleIOD) { //Add all mandatory elements to the module General Series DICOMIOD *pElementIOD; //Insert element Modality pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_MODALITY, "Modality", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Series Instance UID pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_SERIES_INSTANCE_UID, "Series Instance UID", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Series Number pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_SERIES_NUMBER, "Series Number", IOD_TYPE_ELEMENT, IOD_USAGE_2, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Laterality pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_LATERALITY, "Laterality", IOD_TYPE_ELEMENT, IOD_USAGE_2C, ""); if(NULL == pElementIOD) { return FALSE; } //Insert Patient Position pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_PATIENT_POSITION, "Patient Position", IOD_TYPE_ELEMENT, IOD_USAGE_2C, ""); if(NULL == pElementIOD) { return FALSE; } return TRUE; } L_BOOL CMainDlg::AddOverlayPlaneModuleElements(DICOMIOD *pModuleIOD) { //Add all mandatory elements to the module Overlay Plane DICOMIOD *pElementIOD; //Insert element Overlay Rows pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_ROWS, "Overlay Rows", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay Columns pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_COLUMNS, "Overlay Columns", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay type pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_TYPE, "Overlay Type", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay Origin pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_ORIGIN, "Overlay Origin", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay Bits Allocated pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_BITS_ALLOCATED, "Overlay Bits Allocated", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay Bit Position pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_BIT_POSITION, "Overlay Bit Position", IOD_TYPE_ELEMENT, IOD_USAGE_1, ""); if(NULL == pElementIOD) { return FALSE; } //Insert element Overlay Data pElementIOD = m_IOD.Insert(pModuleIOD, TRUE, TAG_OVERLAY_DATA, "Overlay Data", IOD_TYPE_ELEMENT, IOD_USAGE_1C, ""); if(NULL == pElementIOD) { return FALSE; } return TRUE; } L_VOID CMainDlg::AddDefaultValues() { //Set default values DICOMELEMENT *pElement; VALUEDATE dateValue; VALUETIME timeValue; //Set default value for the element Patient Name pElement = m_DS.FindFirstElement(NULL, TAG_PATIENT_NAME, FALSE); m_DS.SetStringValue(pElement, "John Doe", 1); //Set default value for the element Patient ID pElement = m_DS.FindFirstElement(NULL, TAG_PATIENT_ID, FALSE); m_DS.SetStringValue(pElement, "ID", 1); //Set default value for the element Patient Birth Date dateValue.nYear = 1900; dateValue.nMonth = 10; dateValue.nDay = 25; pElement = m_DS.FindFirstElement(NULL, TAG_PATIENT_BIRTH_DATE, FALSE); m_DS.SetDateValue(pElement, &dateValue, 1); //Set default value for the element Patient Sex pElement = m_DS.FindFirstElement(NULL, TAG_PATIENT_SEX, FALSE); m_DS.SetStringValue(pElement, "M", 1); //Set default value for the element Accession Number pElement = m_DS.FindFirstElement(NULL, TAG_ACCESSION_NUMBER, FALSE); m_DS.SetStringValue(pElement, "234", 1); //Set default value for the element Referring Physician Name pElement = m_DS.FindFirstElement(NULL, TAG_REFERRING_PHYSICIAN_NAME, FALSE); m_DS.SetStringValue(pElement, "John Doe", 1); //Set default value for the element Study Date dateValue.nYear = 1999; dateValue.nMonth = 4; dateValue.nDay = 15; pElement = m_DS.FindFirstElement(NULL, TAG_STUDY_DATE, FALSE); m_DS.SetDateValue(pElement, &dateValue, 1); //Set default value for the element Study ID pElement = m_DS.FindFirstElement(NULL, TAG_STUDY_ID, FALSE); m_DS.SetStringValue(pElement, "Study 1", 1); //Set value for the element Study Instance UID pElement = m_DS.FindFirstElement(NULL, TAG_STUDY_INSTANCE_UID, FALSE); CreateGUID(); m_DS.SetStringValue(pElement, INSTANCEGUID, 1); //Set default value for the element Study Time timeValue.nHours = 0; timeValue.nMinutes = 0; timeValue.nSeconds = 0; timeValue.nFractions = 0; pElement = m_DS.FindFirstElement(NULL, TAG_STUDY_TIME, FALSE); m_DS.SetTimeValue(pElement, &timeValue, 1); //Set default value for the element Laterality pElement = m_DS.FindFirstElement(NULL, TAG_LATERALITY, FALSE); m_DS.SetStringValue(pElement, "R", 1); //Set default value for the element Patient Position pElement = m_DS.FindFirstElement(NULL, TAG_PATIENT_POSITION, FALSE); m_DS.SetStringValue(pElement, "HFP", 1); //Set default value for the element Series Instance UID pElement = m_DS.FindFirstElement(NULL, TAG_SERIES_INSTANCE_UID, FALSE); CreateGUID(); m_DS.SetStringValue(pElement, INSTANCEGUID, 1); //Set default value for the element Series Number pElement = m_DS.FindFirstElement(NULL, TAG_SERIES_NUMBER, FALSE); m_DS.SetConvertValue(pElement, "1", 1); //Set default value for the element Manufacturer pElement = m_DS.FindFirstElement(NULL, TAG_MANUFACTURER, FALSE); m_DS.SetStringValue(pElement, "Brand Name", 1); //Set default value for the element Overlay Number pElement = m_DS.FindFirstElement(NULL, TAG_OVERLAY_NUMBER, FALSE); m_DS.SetConvertValue(pElement, "1", 1); CreateGUID(); pElement = m_DS.FindFirstElement(NULL, TAG_SOP_INSTANCE_UID, FALSE); m_DS.SetConvertValue(pElement, INSTANCEGUID, 1); } void CMainDlg::OnOverlayHelp() { L_CHAR strWinDir[MAX_PATH]; L_UINT16 uSize = MAX_PATH; CString AppName(AfxGetApp()->m_pszHelpFilePath); GetWindowsDirectory(strWinDir, uSize); strcat(strWinDir,"\\hh.exe"); _spawnl(_P_NOWAIT,strWinDir,strWinDir,AppName, NULL); } void CMainDlg::OnCancel() { // TODO: Add extra cleanup here } void CMainDlg::OnClose() { CDialog::OnCancel(); CDialog::OnClose(); }