Converting LEAD Annotation Objects to DICOM Annotation Objects Example for VB.NET
'This example uses the predefined variable "objPresState"
of type "LEADDicomDS" from "LEADTOOLS Toolkit".
Private Sub objPresState_OnConvertLEADAnnObjToDicomAnnObj(ByVal bGraphicObject
As Boolean)
Dim sMsg As String
' Display the attributes of the resulted
DICOM annotation object
Dim lCount, I As Integer
If bGraphicObject Then
' The resulted DICOM annotation object
is a graphic object
With objPresState.GraphicObjectAttributes
sMsg = "Graphic
Annotation Units: "
Select Case .Units
Case
LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL
sMsg
= sMsg & "PIXEL" & vbNewLine
Case
LTDICLib.DicomMeasureUnits.DICOM_UNIT_DISPLAY
sMsg
= sMsg & "DISPLAY" & vbNewLine
End Select
sMsg
= sMsg & "Graphic Type: "
Select Case .Type
Case
LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_POINT
sMsg
= sMsg & "POINT" & vbNewLine
Case
LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_POLYLINE
sMsg
= sMsg & "POLYLINE" & vbNewLine
Case
LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_INTERPOLATED
sMsg
= sMsg & "INTERPOLATED" & vbNewLine
Case
LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_CIRCLE
sMsg
= sMsg & "CIRCLE" & vbNewLine
Case
LTDICLib.DicomGraphicObjectTypes.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
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
MessageBox.Show(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
LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL
sMsg
= sMsg & "PIXEL" & vbNewLine
Case
LTDICLib.DicomMeasureUnits.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
LTDICLib.DicomTextJustificationTypes.DICOM_TEXT_JUSTIFICATION_LEFT
sMsg
= sMsg & "LEFT" & vbNewLine
Case
LTDICLib.DicomTextJustificationTypes.DICOM_TEXT_JUSTIFICATION_RIGHT
sMsg
= sMsg & "RIGHT" & vbNewLine
Case
LTDICLib.DicomTextJustificationTypes.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
LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL
sMsg
= sMsg & "PIXEL" & vbNewLine
Case
LTDICLib.DicomMeasureUnits.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
MessageBox.Show(sMsg,
"Text Annotation Object")
End With
End If
' If it is desired to stop the conversion
process... objPresState.EndConversion
objPresState.EndConversion( LTDicomKernelLib.DicomErrorCodes.DICOM_ERROR_ANN)
' Any error code, but not 0
End Sub
Private Sub LEADAnnToDicomAnn(ByRef objPresStateDS As LTDICLib.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 LTANNLib.LEADRasterAnnotation
' Let's create a LEAD rectangle annotation
object
With objRasterAnn .AnnCreate(LTANNLib.AnnObjectType.ANN_OBJECT_RECT,
False, False)
.AnnRectLeft(.AnnObject) = 150
.AnnRectTop(.AnnObject) = 175
.AnnRectWidth(.AnnObject) = 200
.AnnRectHeight(.AnnObject) = 100
.AnnSetFillMode(.AnnObject, LTANNLib.AnnFillModeConstants.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) = LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS Then
MessageBox.Show("The LEAD annotation
object was converted successfully.")
End If
' Destroy the LEAD annotation object
objRasterAnn.AnnDestroy(objRasterAnn.AnnObject, 0)
End Sub