Converting LEAD Annotation Objects to DICOM Annotation Objects Example for Visual Basic
' [General][Declarations]
'Private WithEvents objPresState As LEADDicomDS
Private Sub objPresState_OnConvertLEADAnnObjToDicomAnnObj(ByVal bGraphicObject As Boolean)
Dim sMsg As String
' Display the attributes of the resulted DICOM annotation object
If bGraphicObject Then ' The resulted DICOM annotation object is a graphic object
With objPresState.GraphicObjectAttributes
sMsg = "Graphic Annotation Units: "
Select Case .Units
Case DICOM_UNIT_PIXEL
sMsg = sMsg & "PIXEL" & vbNewLine
Case DICOM_UNIT_DISPLAY
sMsg = sMsg & "DISPLAY" & vbNewLine
End Select
sMsg = sMsg & "Graphic Type: "
Select Case .Type
Case DICOM_GRAPHIC_OBJECT_TYPE_POINT
sMsg = sMsg & "POINT" & vbNewLine
Case DICOM_GRAPHIC_OBJECT_TYPE_POLYLINE
sMsg = sMsg & "POLYLINE" & vbNewLine
Case DICOM_GRAPHIC_OBJECT_TYPE_INTERPOLATED
sMsg = sMsg & "INTERPOLATED" & vbNewLine
Case DICOM_GRAPHIC_OBJECT_TYPE_CIRCLE
sMsg = sMsg & "CIRCLE" & vbNewLine
Case DICOM_GRAPHIC_OBJECT_TYPE_ELLIPSE
sMsg = sMsg & "ELLIPSE" & vbNewLine
End Select
sMsg = sMsg & "Graphic Filled: "
If .Filled Then
sMsg = sMsg & "Y" & vbNewLine
Else
sMsg = sMsg & "N" & vbNewLine
End If
Dim lCount As Long, I As Long
lCount = .PointCount
sMsg = sMsg & "Number of Graphic Points: " & lCount & vbNewLine
If lCount < 10 Then
sMsg = sMsg & "Graphic Data: " & vbNewLine
For I = 0 To lCount - 1
sMsg = sMsg & " " & _
"X" & I + 1 & ", Y" & I + 1 & " = " & _
.PointsX (I) & ", " & .PointsY (I) & vbNewLine
Next
End If
MsgBox sMsg, , "Graphic Annotation Object"
End With
Else ' The resulted DICOM annotation object is a text object
With objPresState.TextObjectAttributes
If .BoundingBoxUsed Then
sMsg = "Unformatted Text Value: " & .TextValue & vbNewLine
sMsg = sMsg & "Bounding Box Annotation Units: "
Select Case .BoundingBoxUnits
Case DICOM_UNIT_PIXEL
sMsg = sMsg & "PIXEL" & vbNewLine
Case DICOM_UNIT_DISPLAY
sMsg = sMsg & "DISPLAY" & vbNewLine
End Select
sMsg = sMsg & _
"Bounding Box Top Left Hand Corner: " & _
.BoundingBoxTLHCornerX & ", " & _
.BoundingBoxTLHCornerY & vbNewLine
sMsg = sMsg & _
"Bounding Box Bottom Right Hand Corner: " & _
.BoundingBoxBRHCornerX & ", " & _
.BoundingBoxBRHCornerY & vbNewLine
sMsg = sMsg & "Bounding Box Text Horizontal Justification: "
Select Case .BoundingBoxTextJustification
Case DICOM_TEXT_JUSTIFICATION_LEFT
sMsg = sMsg & "LEFT" & vbNewLine
Case DICOM_TEXT_JUSTIFICATION_RIGHT
sMsg = sMsg & "RIGHT" & vbNewLine
Case DICOM_TEXT_JUSTIFICATION_CENTER
sMsg = sMsg & "CENTER" & vbNewLine
End Select
Else
sMsg = "Unformatted Text Value: " & .TextValue & vbNewLine
sMsg = sMsg & "Anchor Point Annotation Units: "
Select Case .AnchorPointUnits
Case DICOM_UNIT_PIXEL
sMsg = sMsg & "PIXEL" & vbNewLine
Case DICOM_UNIT_DISPLAY
sMsg = sMsg & "DISPLAY" & vbNewLine
End Select
sMsg = sMsg & "Anchor Point: " & _
.AnchorPointX & ", " & _
.AnchorPointY & vbNewLine
sMsg = sMsg & "Anchor Point Visibility: "
If .AnchorPointVisible Then
sMsg = sMsg & "Y"
Else
sMsg = sMsg & "N"
End If
End If
MsgBox sMsg, , "Text Annotation Object"
End With
End If
' If it is desired to stop the conversion process...
'objPresState.EndConversion DICOM_ERROR_ANN ' Any error code, but not 0
End Sub
Private Sub LEADAnnToDicomAnn(objPresStateDS As LEADDicomDS)
' Update the CurrentElement property with a Graphic Annotation Item so
' that the resulted DICOM annotation objects are added to the Data Set
If objPresStateDS.FindFirstGraphicAnnItem () <> 0 Then
' (Make sure that the specified layer is already defined in the
' "Graphic Layer Module")
objPresStateDS.CreateGraphicAnnItem 0, "LAYER_0"
objPresStateDS.FindFirstGraphicAnnItem
End If
Dim objRasterAnn As New LEADRasterAnnotation
' Let's create a LEAD rectangle annotation object
With objRasterAnn
.AnnCreate ANN_OBJECT_RECT, False, False
.AnnRectLeft(.AnnObject) = 150
.AnnRectTop(.AnnObject) = 175
.AnnRectWidth(.AnnObject) = 200
.AnnRectHeight(.AnnObject) = 100
.AnnSetFillMode .AnnObject, ANN_FILLMODE_TRANSPARENT, False
End With
' Convert the LEAD annotation object. Now, for each resulted DICOM annotation
' object, the OnConvertLEADAnnObjToDicomAnnObj event gets fired. By handling
' the event, you can inspect the resulted object.
If objPresStateDS.ConvertLEADAnnObjToDicomAnnObjs(objRasterAnn.AnnObject, 0) = DICOM_SUCCESS Then
MsgBox "The LEAD annotation object was converted successfully."
End If
' Destroy the LEAD annotation object
objRasterAnn.AnnDestroy objRasterAnn.AnnObject, 0
End Sub