Examining Annotations (2) Example for Visual Basic
Private Sub ExamineAnnotations2(objPresStateDS As LEADDicomDS)
Dim sRefSOPInstanceUID As String
' Pick one of the images referenced in the "Presentation State Module" and
' get its SOP Instance UID
If objPresStateDS.FindFirstPresStateRefSeriesItem () = DICOM_SUCCESS Then
If objPresStateDS.GetPresStateImageRefCount () > 0 Then
sRefSOPInstanceUID = objPresStateDS.GetPresStateImageRefInstanceUID (0)
End If
End If
' Find the SOP Class UID of that image
If objPresStateDS.FindPresStateRefImageItem(sRefSOPInstanceUID) = DICOM_SUCCESS Then
If objPresStateDS.MoveChildElement () = 0 Then
If objPresStateDS.FindFirstElement (TAG_REFERENCED_SOP_CLASS_UID, True) = 0 Then
If objPresStateDS.GetStringValue (0, 1) = 0 Then
MsgBox objPresStateDS.StringValues(0), , "Referenced SOP Class UID"
End If
End If
End If
End If
' Remove the reference to that image from the "Presentation State Module"
objPresStateDS.RemovePresStateImageRef sRefSOPInstanceUID
' Pick a Graphic Annotation Item
If objPresStateDS.FindFirstGraphicAnnItem () = DICOM_SUCCESS Then
Dim hGraphicAnnotationItem As Long
hGraphicAnnotationItem = objPresStateDS.CurrentElement.hElement
' Pick an image reference
If objPresStateDS.GetLayerImageRefCount () > 0 Then
sRefSOPInstanceUID = objPresStateDS.GetLayerImageRefInstanceUID (0)
objPresStateDS.FindLayerRefImageItem sRefSOPInstanceUID
' Display one of the attributes of the Referenced Image Item
If objPresStateDS.MoveChildElement () = 0 Then
If objPresStateDS.FindFirstElement (TAG_REFERENCED_SOP_CLASS_UID, True) = 0 Then
If objPresStateDS.GetStringValue (0, 1) = 0 Then
MsgBox "Referenced SOP Class UID: " & _
objPresStateDS.StringValues (0), , _
"Referenced Image Item"
End If
End If
End If
objPresStateDS.SetCurrentElement hGraphicAnnotationItem
' Remove the image reference
objPresStateDS.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")
objPresStateDS.RemoveAllLayerImageRefs
End If
Dim sGraphicLayer As String
sGraphicLayer = objPresStateDS.GetLayerName ()
' Display some of the layer's attributes
objPresStateDS.GetLayerAttributes objPresStateDS.GetLayerIndex (sGraphicLayer)
With objPresStateDS.LayerAttributes
MsgBox "Graphic Layer: " & .LayerName & vbNewLine & _
"Graphic Layer Order: " & .LayerOrder & vbNewLine & _
"Graphic Layer Description: " & .LayerDescription, , _
"Graphic Layer Attributes"
End With
' Change the layer of this Graphic Annotation Item (the specified new
' layer should already be defined in the "Graphic Layer Module")
objPresStateDS.SetLayerName "ANOTHER_LAYER"
' Pick a graphic annotation object
If objPresStateDS.GetGraphicObjectCount () > 0 Then
objPresStateDS.FindGraphicObjectItem 0
' Display one of the attributes of this object
If objPresStateDS.MoveChildElement () = 0 Then
' Graphic Type (0070,0023)
If objPresStateDS.FindFirstElement (&H700023, True) = 0 Then
If objPresStateDS.GetStringValue (0, 1) = 0 Then
MsgBox "Graphic Type: " & objPresStateDS.StringValues (0), , _
"Graphic Annotation Object"
End If
End If
End If
objPresStateDS.SetCurrentElement hGraphicAnnotationItem
' Remove the object
objPresStateDS.RemoveGraphicObject 0
' Remove all the graphic annotation objects defined by this Graphic
' Annotation Item
objPresStateDS.RemoveAllGraphicObjects
' Or:
'objPresStateDS.RemoveLayerGraphicObjects
End If
' Pick a text annotation object
If objPresStateDS.GetTextObjectCount () > 0 Then
objPresStateDS.FindTextObjectItem 0
' Display one of the attributes of this object
If objPresStateDS.MoveChildElement () = 0 Then
' Unformatted Text Value (0070,0006)
If objPresStateDS.FindFirstElement (&H700006, True) = 0 Then
If objPresStateDS.GetStringValue (0, 1) = 0 Then
MsgBox "Unformatted Text Value: " & _
objPresStateDS.StringValues (0), , _
"Text Annotation Object"
End If
End If
End If
objPresStateDS.SetCurrentElement hGraphicAnnotationItem
' Remove the object
objPresStateDS.RemoveTextObject 0
' Remove all the text annotation objects defined by this Graphic
' Annotation Item
objPresStateDS.RemoveAllTextObjects
' Or:
'objPresStateDS.RemoveLayerTextObjects
End If
End If
' 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")
objPresStateDS.RemoveAllLayersImageRefs
' Remove all references to images from the "Presentation State Module"
objPresStateDS.RemoveAllPresStateImageRefs
' Pick one of the layers
If objPresStateDS.LayerCount > 0 Then
objPresStateDS.FindLayerItem 0
' Display one of the attributes of this layer
If objPresStateDS.MoveChildElement () = 0 Then
' Graphic Layer (0070,0002)
If objPresStateDS.FindFirstElement (&H700002, True) = 0 Then
If objPresStateDS.GetStringValue (0, 1) = 0 Then
MsgBox "Graphic Layer: " & objPresStateDS.StringValues (0), , _
"Graphic Layer"
End If
End If
End If
' Remove the layer
objPresStateDS.RemoveLayer 0, True
' Remove all the layers defined in the "Graphic Layer Module"
objPresStateDS.RemoveAllLayers True
End If
End Sub