Creates a new compound graphic annotation.
public void CreateCompoundGraphic(
DicomElement graphicAnnSQItem,
DicomCompoundGraphic compoundGraphic,
bool checkLayer
)
Public Sub CreateCompoundGraphic( _
ByVal graphicAnnSQItem As DicomElement, _
ByVal compoundGraphic As DicomCompoundGraphic, _
ByVal checkLayer As Boolean _
)
public:
void CreateCompoundGraphic(
DicomElement^ graphicAnnSQItem,
DicomCompoundGraphic^ compoundGraphic,
bool checkLayer
)
graphicAnnSQItem
An item element under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module".
compoundGraphic
Compound Graphic attributes
checkLayer
true to verify the existence of the layer to which the new object will be added (the method will fail if the layer does not exist); false to add the new object without verifying the existence of the layer.
When checkLayer is set to true, the method checks if the layer specified in graphicObject exists. If it does not exist, the method will throw an exception.
This example will create two compound graphic objects (ruler, rectangle), add them to a presentation state, and then perform tests on the presentation state.
using Leadtools;
using Leadtools.Dicom;
///
// Creates a RULER compound graphic
private DicomCompoundGraphic CreateCompoundGraphicRuler(string layerName)
{
// Create a compound graphic
DicomCompoundGraphic compoundGraphic = new DicomCompoundGraphic();
compoundGraphic.LayerName = layerName;
compoundGraphic.Units = DicomAnnotationUnitsRelativityType.Pixel;
compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Ruler;
DicomAnnotationPoint[] pts = new DicomAnnotationPoint[2];
pts[0] = new DicomAnnotationPoint(300, 100);
pts[1] = new DicomAnnotationPoint(450, 100);
compoundGraphic.SetAnnotationPoints(pts, pts.Length);
compoundGraphic.CompoundGraphicInstanceId = 100;
compoundGraphic.GraphicGroupId = 0;
compoundGraphic.RotationAngle = 0.0;
compoundGraphic.RotationPoint = new DicomAnnotationPoint(0, 0);
compoundGraphic.GapLength = 0.0f;
compoundGraphic.DiameterOfVisibility = 0;
compoundGraphic.TickAlignment = DicomAnnotationTickAlignmentType.Center;
compoundGraphic.TickLabelAlignment = DicomAnnotationTickLabelAlignmentType.Bottom;
compoundGraphic.ShowTickLabel = true;
compoundGraphic.Filled = false;
compoundGraphic.Options = DicomAnnotationOptions.Line | DicomAnnotationOptions.Text | DicomAnnotationOptions.CompoundGraphicInstanceId;
// TextStyle
compoundGraphic.TextStyle = new DicomTextStyle();
compoundGraphic.TextStyle.TextOptions = DicomAnnotationTextOptions.FontName;
compoundGraphic.TextStyle.FontName = "Arial";
compoundGraphic.TextStyle.CssFontName = "serif";
compoundGraphic.TextStyle.TextColorCieLabValue = new ushort[3] { 34866, 53484, 50171 }; // Red
compoundGraphic.TextStyle.HorizontalAlign = DicomAnnotationHorizontalAlignmentType.Center;
compoundGraphic.TextStyle.VerticalAlign = DicomAnnotationVerticalAlignmentType.Center;
compoundGraphic.TextStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off;
compoundGraphic.TextStyle.Shadow.ShadowOffsetX = 0;
compoundGraphic.TextStyle.Shadow.ShadowOffsetY = 0;
compoundGraphic.TextStyle.Shadow.ShadowColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.TextStyle.Shadow.ShadowOpacity = 0.0f;
compoundGraphic.TextStyle.Underlined = false;
compoundGraphic.TextStyle.Italic = false;
compoundGraphic.TextStyle.Bold = false;
// LineStyle
compoundGraphic.LineStyle = new DicomLineStyle();
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.None;
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.PatternOffColorCielabValue | DicomAnnotationLineOptions.PatternOffOpacity;
compoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off;
compoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.LineStyle.PatternOnColorCieLabValue = new ushort[3] { 21169, 53249, 5175 }; // This is 'blue'
compoundGraphic.LineStyle.PatternOffColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.LineStyle.LineThickness = 1.0f;
compoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.Solid;
compoundGraphic.LineStyle.LinePattern = 0xFFFF;
compoundGraphic.LineStyle.PatternOnOpacity = 1.0f;
compoundGraphic.LineStyle.PatternOffOpacity = 0.0f;
// RULER does not have a fill style
// Major Ticks Sequence
int nTickCount = 4;
float fTickIncrement = (float)(1.0 / (float)nTickCount);
compoundGraphic.MajorTicks.Clear();
for (int i = 0; i < nTickCount; i++)
{
DicomMajorTick majorTickItem = new DicomMajorTick(i * fTickIncrement, "Label " + i.ToString());
compoundGraphic.MajorTicks.Add(majorTickItem);
}
return compoundGraphic;
}
// Creates a RECTANGLE compound graphic (rotated, filled)
private DicomCompoundGraphic CreateCompoundGraphicRectangle(string layerName)
{
// Create a compound graphic
DicomCompoundGraphic compoundGraphic = new DicomCompoundGraphic();
compoundGraphic.LayerName = layerName;
compoundGraphic.Units = DicomAnnotationUnitsRelativityType.Pixel;
compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Rectangle;
DicomAnnotationPoint[] pts = new DicomAnnotationPoint[2];
pts[0] = new DicomAnnotationPoint(100, 100);
pts[1] = new DicomAnnotationPoint(200, 200);
compoundGraphic.SetAnnotationPoints(pts, pts.Length);
compoundGraphic.CompoundGraphicInstanceId = 200;
compoundGraphic.GraphicGroupId = 0;
compoundGraphic.RotationAngle = 45.0;
compoundGraphic.RotationPoint = new DicomAnnotationPoint(150, 150);
compoundGraphic.Filled = true;
compoundGraphic.Options = DicomAnnotationOptions.Fill | DicomAnnotationOptions.Line | DicomAnnotationOptions.CompoundGraphicInstanceId;
// LineStyle
compoundGraphic.LineStyle = new DicomLineStyle();
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.None;
compoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off;
compoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0f;
compoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = new ushort[3] { 1, 2, 3 };
compoundGraphic.LineStyle.PatternOnColorCieLabValue = new ushort[3] { 24886, 53484, 50171 }; // red
compoundGraphic.LineStyle.PatternOffColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.LineStyle.LineThickness = 2.0f;
compoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.Solid;
compoundGraphic.LineStyle.LinePattern = 0xFFFF;
compoundGraphic.LineStyle.PatternOnOpacity = 1.0f;
compoundGraphic.LineStyle.PatternOffOpacity = 0.0f;
// FillStyle
compoundGraphic.FillStyle = new DicomFillStyle();
compoundGraphic.FillStyle.FillOptions = DicomAnnotationFillOptions.None;
compoundGraphic.FillStyle.PatternOnColorCieLabValue = new ushort[3] { 21169, 53249, 5175 }; // blue
compoundGraphic.FillStyle.PatternOffColorCieLabValue = new ushort[3] { 0, 0, 0 };
compoundGraphic.FillStyle.PatternOnOpacity = 1.0f;
compoundGraphic.FillStyle.PatternOffOpacity = 0.0f;
compoundGraphic.FillStyle.FillMode = DicomAnnotationFillModeType.Solid;
return compoundGraphic;
}
private void DicomCompoundGraphicTest(string layerName, string outFile)
{
DicomDataSet ds = new DicomDataSet();
ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryModulesOnly | DicomDataSetInitializeFlags.AddMandatoryElementsOnly);
ds.CreateGraphicAnnSQItem(0, layerName);
DicomElement firstGraphicAnnSQItem = ds.FindFirstGraphicAnnSQItem();
DicomCompoundGraphic ruler = CreateCompoundGraphicRuler(layerName);
ds.CreateCompoundGraphic(firstGraphicAnnSQItem, ruler, false);
DicomCompoundGraphic rotatedFilledRectangle = CreateCompoundGraphicRectangle(layerName);
ds.CreateCompoundGraphic(firstGraphicAnnSQItem, rotatedFilledRectangle, false);
// Save the presentation state (with annotations)
ds.Save(outFile, DicomDataSetSaveFlags.None);
MessageBox.Show("Presentation State Saved: " + outFile);
// Find the second CompoundGraphicElement item -- this should be the rectangle
DicomElement element = ds.GetCompoundGraphicElement(firstGraphicAnnSQItem, 0);
string type = ds.GetValue<string>(element, false, DicomTag.CompoundGraphicType, string.Empty);
Debug.Assert(type == "RULER");
// Now we have two compound graphic items: ruler, rectangle
// Count should be 2
int nCount = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem);
Debug.Assert(nCount == 2);
// Get the number of points of the first item (ruler) -- this should be 2
nCount = ds.GetCompoundGraphicPointCount(firstGraphicAnnSQItem, 0);
Debug.Assert(nCount == 2);
// Get the number of major ticks in the ruler -- this should be 4
nCount = ds.GetCompoundGraphicMajorTickCount(firstGraphicAnnSQItem, 0);
Debug.Assert(nCount == 4);
// Remove the first compound graphic (the ruler)
ds.RemoveCompoundGraphic(firstGraphicAnnSQItem, 0);
// Read the first compound graphic -- this should now be the rectangle
DicomCompoundGraphic compoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0);
Debug.Assert(compoundGraphic.Type == DicomAnnotationCompoundGraphicType.Rectangle);
// Change the rectangle from filled, to non-filled
compoundGraphic.Filled = false;
ds.SetCompoundGraphicInformation(firstGraphicAnnSQItem, 0, compoundGraphic);
// Verify that the rectangle is non-filled
compoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0);
Debug.Assert(compoundGraphic.Filled == false);
// Remove ALL compund graphics
ds.RemoveAllCompoundGraphics(firstGraphicAnnSQItem);
// Get the compound graphic count -- it should now be zero
nCount = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem);
Debug.Assert(nCount == 0);
}
Imports Leadtools
Imports Leadtools.Dicom
'''
' Creates a RULER compound graphic
Private Function CreateCompoundGraphicRuler(ByVal layerName As String) As DicomCompoundGraphic
' Create a compound graphic
Dim compoundGraphic As New DicomCompoundGraphic()
compoundGraphic.LayerName = layerName
compoundGraphic.Units = DicomAnnotationUnitsRelativityType.Pixel
compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Ruler
Dim pts(1) As DicomAnnotationPoint
pts(0) = New DicomAnnotationPoint(300, 100)
pts(1) = New DicomAnnotationPoint(450, 100)
compoundGraphic.SetAnnotationPoints(pts, pts.Length)
compoundGraphic.CompoundGraphicInstanceId = 100
compoundGraphic.GraphicGroupId = 0
compoundGraphic.RotationAngle = 0.0
compoundGraphic.RotationPoint = New DicomAnnotationPoint(0, 0)
compoundGraphic.GapLength = 0.0F
compoundGraphic.DiameterOfVisibility = 0
compoundGraphic.TickAlignment = DicomAnnotationTickAlignmentType.Center
compoundGraphic.TickLabelAlignment = DicomAnnotationTickLabelAlignmentType.Bottom
compoundGraphic.ShowTickLabel = True
compoundGraphic.Filled = False
compoundGraphic.Options = DicomAnnotationOptions.Line Or DicomAnnotationOptions.Text Or DicomAnnotationOptions.CompoundGraphicInstanceId
' TextStyle
compoundGraphic.TextStyle = New DicomTextStyle()
compoundGraphic.TextStyle.TextOptions = DicomAnnotationTextOptions.FontName
compoundGraphic.TextStyle.FontName = "Arial"
compoundGraphic.TextStyle.CssFontName = "serif"
compoundGraphic.TextStyle.TextColorCieLabValue = New UShort(2) {34866, 53484, 50171} ' Red
compoundGraphic.TextStyle.HorizontalAlign = DicomAnnotationHorizontalAlignmentType.Center
compoundGraphic.TextStyle.VerticalAlign = DicomAnnotationVerticalAlignmentType.Center
compoundGraphic.TextStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off
compoundGraphic.TextStyle.Shadow.ShadowOffsetX = 0
compoundGraphic.TextStyle.Shadow.ShadowOffsetY = 0
compoundGraphic.TextStyle.Shadow.ShadowColorCieLabValue = New UShort(2) {0, 0, 0}
compoundGraphic.TextStyle.Shadow.ShadowOpacity = 0.0F
compoundGraphic.TextStyle.Underlined = False
compoundGraphic.TextStyle.Italic = False
compoundGraphic.TextStyle.Bold = False
' LineStyle
compoundGraphic.LineStyle = New DicomLineStyle()
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.None
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.PatternOffColorCielabValue Or DicomAnnotationLineOptions.PatternOffOpacity
compoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off
compoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = New UShort(2) {0, 0, 0}
compoundGraphic.LineStyle.PatternOnColorCieLabValue = New UShort(2) {21169, 53249, 5175} ' This is 'blue'
compoundGraphic.LineStyle.PatternOffColorCieLabValue = New UShort(2) {0, 0, 0}
compoundGraphic.LineStyle.LineThickness = 1.0F
compoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.Solid
compoundGraphic.LineStyle.LinePattern = &HFFFF
compoundGraphic.LineStyle.PatternOnOpacity = 1.0F
compoundGraphic.LineStyle.PatternOffOpacity = 0.0F
' RULER does not have a fill style
' Major Ticks Sequence
Dim nTickCount As Integer = 4
Dim fTickIncrement As Single = CSng(1.0 / CSng(nTickCount))
compoundGraphic.MajorTicks.Clear()
For i As Integer = 0 To nTickCount - 1
Dim majorTickItem As New DicomMajorTick(i * fTickIncrement, "Label " & i.ToString())
compoundGraphic.MajorTicks.Add(majorTickItem)
Next i
Return compoundGraphic
End Function
' Creates a RECTANGLE compound graphic (rotated, filled)
Private Function CreateCompoundGraphicRectangle(ByVal layerName As String) As DicomCompoundGraphic
' Create a compound graphic
Dim compoundGraphic As New DicomCompoundGraphic()
compoundGraphic.LayerName = layerName
compoundGraphic.Units = DicomAnnotationUnitsRelativityType.Pixel
compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Rectangle
Dim pts(1) As DicomAnnotationPoint
pts(0) = New DicomAnnotationPoint(100, 100)
pts(1) = New DicomAnnotationPoint(200, 200)
compoundGraphic.SetAnnotationPoints(pts, pts.Length)
compoundGraphic.CompoundGraphicInstanceId = 200
compoundGraphic.GraphicGroupId = 0
compoundGraphic.RotationAngle = 45.0
compoundGraphic.RotationPoint = New DicomAnnotationPoint(150, 150)
compoundGraphic.Filled = True
compoundGraphic.Options = DicomAnnotationOptions.Fill Or DicomAnnotationOptions.Line Or DicomAnnotationOptions.CompoundGraphicInstanceId
' LineStyle
compoundGraphic.LineStyle = New DicomLineStyle()
compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.None
compoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.Off
compoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0F
compoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = New UShort(2) {1, 2, 3}
compoundGraphic.LineStyle.PatternOnColorCieLabValue = New UShort(2) {24886, 53484, 50171} ' red
compoundGraphic.LineStyle.PatternOffColorCieLabValue = New UShort(2) {0, 0, 0}
compoundGraphic.LineStyle.LineThickness = 2.0F
compoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.Solid
compoundGraphic.LineStyle.LinePattern = &HFFFF
compoundGraphic.LineStyle.PatternOnOpacity = 1.0F
compoundGraphic.LineStyle.PatternOffOpacity = 0.0F
' FillStyle
compoundGraphic.FillStyle = New DicomFillStyle()
compoundGraphic.FillStyle.FillOptions = DicomAnnotationFillOptions.None
compoundGraphic.FillStyle.PatternOnColorCieLabValue = New UShort(2) {21169, 53249, 5175} ' blue
compoundGraphic.FillStyle.PatternOffColorCieLabValue = New UShort(2) {0, 0, 0}
compoundGraphic.FillStyle.PatternOnOpacity = 1.0F
compoundGraphic.FillStyle.PatternOffOpacity = 0.0F
compoundGraphic.FillStyle.FillMode = DicomAnnotationFillModeType.Solid
Return compoundGraphic
End Function
Private Sub DicomCompoundGraphicTest(ByVal layerName As String, ByVal outFile As String)
Dim ds As New DicomDataSet()
ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryModulesOnly Or DicomDataSetInitializeFlags.AddMandatoryElementsOnly)
ds.CreateGraphicAnnSQItem(0, layerName)
Dim firstGraphicAnnSQItem As DicomElement = ds.FindFirstGraphicAnnSQItem()
Dim ruler As DicomCompoundGraphic = CreateCompoundGraphicRuler(layerName)
ds.CreateCompoundGraphic(firstGraphicAnnSQItem, ruler, False)
Dim rotatedFilledRectangle As DicomCompoundGraphic = CreateCompoundGraphicRectangle(layerName)
ds.CreateCompoundGraphic(firstGraphicAnnSQItem, rotatedFilledRectangle, False)
' Save the presentation state (with annotations)
ds.Save(outFile, DicomDataSetSaveFlags.None)
MessageBox.Show("Presentation State Saved: " & outFile)
' Find the second CompoundGraphicElement item -- this should be the rectangle
Dim element As DicomElement = ds.GetCompoundGraphicElement(firstGraphicAnnSQItem, 0)
Dim type As String = ds.GetValue(Of String)(element, False, DicomTag.CompoundGraphicType, String.Empty)
Debug.Assert(type = "RULER")
' Now we have two compound graphic items: ruler, rectangle
' Count should be 2
Dim nCount As Integer = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem)
Debug.Assert(nCount = 2)
' Get the number of points of the first item (ruler) -- this should be 2
nCount = ds.GetCompoundGraphicPointCount(firstGraphicAnnSQItem, 0)
Debug.Assert(nCount = 2)
' Get the number of major ticks in the ruler -- this should be 4
nCount = ds.GetCompoundGraphicMajorTickCount(firstGraphicAnnSQItem, 0)
Debug.Assert(nCount = 4)
' Remove the first compound graphic (the ruler)
ds.RemoveCompoundGraphic(firstGraphicAnnSQItem, 0)
' Read the first compound graphic -- this should now be the rectangle
Dim compoundGraphic As DicomCompoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0)
Debug.Assert(compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Rectangle)
' Change the rectangle from filled, to non-filled
compoundGraphic.Filled = False
ds.SetCompoundGraphicInformation(firstGraphicAnnSQItem, 0, compoundGraphic)
' Verify that the rectangle is non-filled
compoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0)
Debug.Assert(compoundGraphic.Filled = False)
' Remove ALL compund graphics
ds.RemoveAllCompoundGraphics(firstGraphicAnnSQItem)
' Get the compound graphic count -- it should now be zero
nCount = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem)
Debug.Assert(nCount = 0)
End Sub
FindFirstGraphicAnnSQItem Method
GetCompoundGraphicInformation Method
SetCompoundGraphicInformation Method
GetCompoundGraphicCount Method
RemoveAllCompoundGraphics Method
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document