LDicomDir::OnInsertDicomFile
#include "Ltdic.h"
virtual L_UINT16 LDicomDir::OnInsertDicomFile(pszFileName, pDataSet, uStatus);
const L_TCHAR * pszFileName; |
/* name of the file being processed */ |
LDicomDS * pDataSet; |
/* pointer to an LDicomDS object */ |
L_UINT16 uStatus; |
/* status code */ |
Called for each DICOM file enumerated by LDicomDir::InsertDicomFile.
Parameter |
Description |
|
pszFileName |
Character string that contains the name of the file being added to the DICOM Directory. |
|
pDataSet |
Pointer to an LDicomDS object that specifies the Data Set contained by the DICOM file being processed. If the Data Set wasnt loaded successfully, this parameter is set to NULL. |
|
uStatus |
The status code. Possible values are: |
|
|
Value |
Meaning |
|
DICOMDIR_INSERTDICOMFILE_PREADD |
[300] The Data Set in the file was loaded successfully and the file is about to be added to the DICOM Directory. |
|
DICOM_SUCCESS |
[0] The file has been added successfully to the DICOM Directory. |
|
Any other value |
[> 0] An error occurred. Refer to Return Codes. |
Returns
0 |
The function was successful. |
> 0 |
An error occurred. Refer to Return Codes. |
Comments
If the parameter passed to LDicomDir::InsertDicomFile is NULL, then all files in the destination folder will be enumerated. If the bIncludeSubfolders member of a DICOMDIROPTIONS structure is set to TRUE and set using LDicomDir::SetOptions, and then LDicomDir::InsertDicomFile is called with pszFileName set to NULL, then all files in the destination folder and all files in all of the subfolders of the destination folder will be enumerated. For each file, the callback function OnInsertDicomFile is called once or twice:
The callback function is called just after
trying to load the Data Set in the file and before actually adding the
file to the Dicom Directory. If the Data Set was loaded successfully,
the parameter pDataSet specifies the loaded Data Set and the parameter
uStatus is set to DICOMDIR_INSERTDICOMFILE_PREADD. To skip the addition
of the file, the callback function should return DICOM_ERROR_FORMAT. If
the Data Set wasnt loaded successfully, the parameter pDataSet is set
to NULL and the parameter uStatus is set to an error code.
The callback function is called the second
time just after trying to add the loaded Data Set to the DICOM Directory.
The parameter pDataSet specifies the loaded Data Set. If the Data Set
was added successfully, the parameter uStatus is set to DICOM_SUCCESS.
Otherwise, it is set to an error code. This call to the callback function
is not made if a loading failure was reported in the first call to the
callback function, or the file addition was skipped in the first call
to the callback function.
If the callback function returned a value other than DICOM_SUCCESS or DICOM_ERROR_FORMAT, the function LDicomDir::InsertDicomFile will stop adding new files and will return the same value returned by the callback function. Therefore, to keep adding the DICOM files, the callback function should return DICOM_SUCCESS, or DICOM_ERROR_FORMAT if only the current file is to be skipped (which can be done during the first call).
The function LDicomDir::InsertDicomFile will stop adding new files if an error occurred and it will return an error value.
The implementation of the LDicomDir class for the function OnInsertDicomFile simply returns DICOM_SUCCESS. In order to make use of this callback function, you should create a new class derived from the LDicomDir class and override the function OnInsertDicomFile providing the desired implementation.
Required DLLs and Libraries
LTDIC For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application |
See Also
Functions: |
|
Topics: |
|
|
Example
class LUserDicomDir : public LDicomDir { public: LUserDicomDir(L_TCHAR* pszDICOMDIRDstFolder = NULL, L_TCHAR* pszPath = NULL) : LDicomDir(pszDICOMDIRDstFolder, pszPath) { } L_UINT16 OnInsertDicomFile(const L_TCHAR* pszFileName, LDicomDS* pDataSet, L_UINT16 uStatus) { UNREFERENCED_PARAMETER(pDataSet); L_TCHAR szBuffer[512]; if (uStatus == DICOMDIR_INSERTDICOMFILE_PREADD) { wsprintf(szBuffer, TEXT("About to add the file \"%s\".\n\nProceed?"), pszFileName); switch (MessageBox(NULL, szBuffer, TEXT("DICOM Directory Sample"), MB_YESNOCANCEL)) { case IDYES: // Add the file break; case IDNO: // Skip the file return DICOM_ERROR_FORMAT; case IDCANCEL: // Abort return DICOM_ERROR_END; } } else if (uStatus == DICOM_SUCCESS) { wsprintf(szBuffer, TEXT("The file \"%s\" has been added successfully.\n\nContinue?"), pszFileName); switch (MessageBox(NULL, szBuffer, TEXT("DICOM Directory Sample"), MB_YESNO)) { case IDYES: // Continue break; case IDNO: // Abort return DICOM_ERROR_END; } } return DICOM_SUCCESS; } }; L_INT LDicomDir_OnInsertDicomFileExample() { L_INT nRet; LUserDicomDir DicomDir(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 15.0\\Images\\Medical Images")); // Add all the DICOM files to the Directory nRet = DicomDir.InsertDicomFile(NULL); if(nRet != DICOM_SUCCESS) return nRet; // Save the DICOMDIR File nRet = DicomDir.SaveDicomDir(); if(nRet != DICOM_SUCCESS) return nRet; return DICOM_SUCCESS; }