Examining Annotations (2) Example for VB.NET
Private Sub ExamineAnnotations2(ByRef objPresStateDS As LTDICLib.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() = LTDicomKernelLib.DicomErrorCodes.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) = LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS Then
If objPresStateDS.MoveChildElement() = 0 Then
If objPresStateDS.FindFirstElement(LTDICLib.DicomDataSetTagConstants1.TAG_REFERENCED_SOP_CLASS_UID, True) = 0 Then
If objPresStateDS.GetStringValue(0, 1) = 0 Then
MessageBox.Show(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
Dim hGraphicAnnotationItem
As Integer
Dim sGraphicLayer
As String
If objPresStateDS.FindFirstGraphicAnnItem()
= LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS Then
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(LTDICLib.DicomDataSetTagConstants1.TAG_REFERENCED_SOP_CLASS_UID, True) = 0 Then
If objPresStateDS.GetStringValue(0, 1) = 0 Then
MessageBox.Show("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
sGraphicLayer = objPresStateDS.GetLayerName()
'
Display some of the layer's attributes
objPresStateDS.GetLayerAttributes(objPresStateDS.GetLayerIndex(sGraphicLayer))
With
objPresStateDS.LayerAttributes
MessageBox.Show("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
MessageBox.Show("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
MessageBox.Show("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
MessageBox.Show("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