Examining Annotations (2) example for C++ 5.0 and later
void ExamineAnnotations2(ILEADDicomDSPtr& spPresStateDS)
{
_bstr_t sRefSOPInstanceUID;
// Pick one of the images referenced in the "Presentation State Module" and
// get its SOP Instance UID
if (spPresStateDS->FindFirstPresStateRefSeriesItem () == DICOM_SUCCESS)
{
if (spPresStateDS->GetPresStateImageRefCount () > 0)
{
sRefSOPInstanceUID = spPresStateDS->GetPresStateImageRefInstanceUID (0);
}
}
// Find the SOP Class UID of that image
if (spPresStateDS->FindPresStateRefImageItem(sRefSOPInstanceUID) == DICOM_SUCCESS)
{
if (spPresStateDS->MoveChildElement () == 0)
{
if (spPresStateDS->FindFirstElement (TAG_REFERENCED_SOP_CLASS_UID, VARIANT_TRUE) == 0)
{
if (spPresStateDS->GetStringValue (0, 1) == 0)
{
MessageBox(NULL, spPresStateDS->StringValues [0],
"Referenced SOP Class UID", MB_OK);
}
}
}
}
// Remove the reference to that image from the "Presentation State Module"
spPresStateDS->RemovePresStateImageRef(sRefSOPInstanceUID);
char szMsg[1024];
// Pick a Graphic Annotation Item
if (spPresStateDS->FindFirstGraphicAnnItem () == DICOM_SUCCESS)
{
long hGraphicAnnotationItem;
hGraphicAnnotationItem = spPresStateDS->GetCurrentElement()->hElement;
// Pick an image reference
if (spPresStateDS->GetLayerImageRefCount () > 0)
{
sRefSOPInstanceUID = spPresStateDS->GetLayerImageRefInstanceUID (0);
spPresStateDS->FindLayerRefImageItem(sRefSOPInstanceUID);
// Display one of the attributes of the Referenced Image Item
if (spPresStateDS->MoveChildElement () == 0)
{
if (spPresStateDS->FindFirstElement (TAG_REFERENCED_SOP_CLASS_UID, VARIANT_TRUE) == 0)
{
if (spPresStateDS->GetStringValue (0, 1) == 0)
{
wsprintf(szMsg, "Referenced SOP Class UID: %s",
spPresStateDS->StringValues [0].operator char *());
MessageBox(NULL, szMsg, "Referenced Image Item", MB_OK);
}
}
}
spPresStateDS->SetCurrentElement (hGraphicAnnotationItem);
// Remove the image reference
spPresStateDS->RemoveLayerImageRef (sRefSOPInstanceUID);
// Remove all references to images that are listed in this Graphic Annotation
// Item (this way, the annotations defined by this Item will be applied to all
// the images listed in the "Presentation State Module")
spPresStateDS->RemoveAllLayerImageRefs();
}
_bstr_t sGraphicLayer;
sGraphicLayer = spPresStateDS->GetLayerName ();
// Display some of the layer's attributes
spPresStateDS->GetLayerAttributes (spPresStateDS->GetLayerIndex (sGraphicLayer));
IDicomLayerAttributesPtr spLayerAttribs = spPresStateDS->LayerAttributes;
wsprintf(szMsg,
"Graphic Layer: %s\n"
"Graphic Layer Order: %li\n"
"Graphic Layer Description: %s\n",
spLayerAttribs->LayerName.operator char *(),
spLayerAttribs->LayerOrder,
spLayerAttribs->LayerDescription.operator char *());
MessageBox(NULL, szMsg, "Graphic Layer Attributes", MB_OK);
// Change the layer of this Graphic Annotation Item (the specified new
// layer should already be defined in the "Graphic Layer Module")
spPresStateDS->SetLayerName ("ANOTHER_LAYER");
// Pick a graphic annotation object
if (spPresStateDS->GetGraphicObjectCount () > 0)
{
spPresStateDS->FindGraphicObjectItem (0);
// Display one of the attributes of this object
if (spPresStateDS->MoveChildElement () == 0)
{
// Graphic Type (0070,0023)
if (spPresStateDS->FindFirstElement (0x00700023, VARIANT_TRUE) == 0)
{
if (spPresStateDS->GetStringValue (0, 1) == 0)
{
wsprintf(szMsg, "Graphic Type: %s",
spPresStateDS->StringValues [0].operator char *());
MessageBox(NULL, szMsg, "Graphic Annotation Object", MB_OK);
}
}
}
spPresStateDS->SetCurrentElement (hGraphicAnnotationItem);
// Remove the object
spPresStateDS->RemoveGraphicObject(0);
// Remove all the graphic annotation objects defined by this Graphic
// Annotation Item
spPresStateDS->RemoveAllGraphicObjects();
// Or:
//spPresStateDS->RemoveLayerGraphicObjects();
}
// Pick a text annotation object
if (spPresStateDS->GetTextObjectCount () > 0)
{
spPresStateDS->FindTextObjectItem (0);
// Display one of the attributes of this object
if (spPresStateDS->MoveChildElement () == 0)
{
// Unformatted Text Value (0070,0006)
if (spPresStateDS->FindFirstElement (0x00700006, VARIANT_TRUE) == 0)
{
if (spPresStateDS->GetStringValue (0, 1) == 0)
{
wsprintf(szMsg, "Unformatted Text Value: %s",
spPresStateDS->StringValues [0].operator char *());
MessageBox(NULL, szMsg, "Text Annotation Object", MB_OK);
}
}
}
spPresStateDS->SetCurrentElement (hGraphicAnnotationItem);
// Remove the object
spPresStateDS->RemoveTextObject(0);
// Remove all the text annotation objects defined by this Graphic
// Annotation Item
spPresStateDS->RemoveAllTextObjects ();
// Or:
//spPresStateDS->RemoveLayerTextObjects ();
}
}
// Remove all references to images that are listed in all the Graphic Annotation
// Items (this way, the annotations defined by all the Items will be applied to all
// the images listed in the "Presentation State Module")
spPresStateDS->RemoveAllLayersImageRefs();
// Remove all references to images from the "Presentation State Module"
spPresStateDS->RemoveAllPresStateImageRefs ();
// Pick one of the layers
if (spPresStateDS->LayerCount > 0)
{
_variant_t LayerIndex(short(0));
spPresStateDS->FindLayerItem(LayerIndex);
// Display one of the attributes of this layer
if (spPresStateDS->MoveChildElement () == 0)
{
// Graphic Layer (0070,0002)
if (spPresStateDS->FindFirstElement (0x00700002, VARIANT_TRUE) == 0)
{
if (spPresStateDS->GetStringValue (0, 1) == 0)
{
wsprintf(szMsg, "Graphic Layer: %s",
spPresStateDS->StringValues [0].operator char *());
MessageBox(NULL, szMsg, "Graphic Layer", MB_OK);
}
}
}
// Remove the layer
spPresStateDS->RemoveLayer(LayerIndex, VARIANT_TRUE);
// Remove all the layers defined in the "Graphic Layer Module"
spPresStateDS->RemoveAllLayers(VARIANT_TRUE);
}
}