AnnCount Example for C++ 6.0 and later
{
//This example
// 1. Opens a dataset with annotations
// 2. Finds the location of one of the annotation files
// 3. Loads the annotations
// 4. Flips the annotations
// 5. Saves the annotations to index to slots 250 through 255
// 6. Deletes the annotation files from slot 253
int nRet;
int i;
CString strMsg;
CString strTmp;
int nIndexAnn;
ILEADRasterIO *pRasterIO=NULL;
ILEADRasterAnnotation *pRasterAnn = NULL;
CoCreateInstance(
CLSID_LEADRasterAnnotation,
NULL,
CLSCTX_ALL,
IID_ILEADRasterAnnotation,
(void**)&pRasterAnn);
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
pRasterIO->EnableMethodErrors = FALSE;
pRasterIO->Load(m_LEADRasterView1.GetRaster(), "c:\\1.cmp", 0, 0, 1);
pRasterIO->Release();
// Open the dataset with annotations
nRet = m_pLEADDicomDS->LoadDS("c:\\1.dic", 0);
if (nRet != DICOM_SUCCESS) return;
// Find the location of one of the annotation files
m_pLEADDicomDS->AnnCount();
if (nRet != DICOM_SUCCESS) return;
strMsg.Format("Private Creator Tag: 0x%x\n", m_pLEADDicomDS->GetAnnPrivateCreatorTag());
for (i = 0; i<=255; i++)
{
if (m_pLEADDicomDS->GetAnnEntries(i))
{
nIndexAnn = i;
strTmp.Format("\t%d\n", i);
strMsg = strMsg + strTmp;
}
}
MessageBox(strMsg);
// Loads the annotations
m_pLEADDicomDS->AnnLoad(nIndexAnn, 1);
//Attach the annotation object to the raster view control
IDispatch *pDispatch=NULL;
LPUNKNOWN pIUnknownNoRelease = m_LEADRasterView1.GetControlUnknown();
pIUnknownNoRelease->QueryInterface(IID_IDispatch, (void**)&pDispatch);
pRasterAnn->PutAnnParentRasterView(pDispatch);
if(pDispatch)
pDispatch->Release();
// Flip the annotations
pRasterAnn->put_AnnContainer(m_pLEADDicomDS->GetAnnContainer());
pRasterAnn->AnnFlip(TRUE, m_LEADRasterView1.GetRaster().GetBitmapHeight()/ 2, FALSE);
m_pLEADDicomDS->AnnContainer = pRasterAnn->GetAnnContainer ();
// Save the annotations to index to slots 250 through 255
for (i = 250; i<=255; i++)
nRet = m_pLEADDicomDS->AnnSave(i, ANN_FMT_NATIVE, FALSE, SAVE_OVERWRITE, 1);
// Delete the annotation files from slot 253
m_pLEADDicomDS->AnnDelete(253, -1);
// Display file info
m_pLEADDicomDS->AnnCount();
if (nRet != DICOM_SUCCESS) return;
strMsg.Format("Private Creator Tag: 0x%x\n", m_pLEADDicomDS->GetAnnPrivateCreatorTag());
for (i = 0; i<=255; i++)
{
if (m_pLEADDicomDS->GetAnnEntries(i))
{
strTmp.Format("\t%d\n", i);
strMsg = strMsg + strTmp;
}
}
MessageBox(strMsg);
// Save the data set
m_pLEADDicomDS->SaveDS("e:\\erase\\dicom.dic", 0);
pRasterAnn->Release();
}