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 graphicprivate DicomCompoundGraphic CreateCompoundGraphicRuler(string layerName){// Create a compound graphicDicomCompoundGraphic 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;// TextStylecompoundGraphic.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 }; // RedcompoundGraphic.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;// LineStylecompoundGraphic.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 Sequenceint 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 graphicDicomCompoundGraphic 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;// LineStylecompoundGraphic.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 }; // redcompoundGraphic.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;// FillStylecompoundGraphic.FillStyle = new DicomFillStyle();compoundGraphic.FillStyle.FillOptions = DicomAnnotationFillOptions.None;compoundGraphic.FillStyle.PatternOnColorCieLabValue = new ushort[3] { 21169, 53249, 5175 }; // bluecompoundGraphic.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);Console.WriteLine("Presentation State Saved: " + outFile);// Find the second CompoundGraphicElement item -- this should be the rectangleDicomElement 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 2int nCount = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem);Debug.Assert(nCount == 2);// Get the number of points of the first item (ruler) -- this should be 2nCount = ds.GetCompoundGraphicPointCount(firstGraphicAnnSQItem, 0);Debug.Assert(nCount == 2);// Get the number of major ticks in the ruler -- this should be 4nCount = 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 rectangleDicomCompoundGraphic compoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0);Debug.Assert(compoundGraphic.Type == DicomAnnotationCompoundGraphicType.Rectangle);// Change the rectangle from filled, to non-filledcompoundGraphic.Filled = false;ds.SetCompoundGraphicInformation(firstGraphicAnnSQItem, 0, compoundGraphic);// Verify that the rectangle is non-filledcompoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0);Debug.Assert(compoundGraphic.Filled == false);// Remove ALL compund graphicsds.RemoveAllCompoundGraphics(firstGraphicAnnSQItem);// Get the compound graphic count -- it should now be zeronCount = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem);Debug.Assert(nCount == 0);}
Imports LeadtoolsImports Leadtools.Dicom'''' Creates a RULER compound graphicPrivate Function CreateCompoundGraphicRuler(ByVal layerName As String) As DicomCompoundGraphic' Create a compound graphicDim compoundGraphic As New DicomCompoundGraphic()compoundGraphic.LayerName = layerNamecompoundGraphic.Units = DicomAnnotationUnitsRelativityType.PixelcompoundGraphic.Type = DicomAnnotationCompoundGraphicType.RulerDim pts(1) As DicomAnnotationPointpts(0) = New DicomAnnotationPoint(300, 100)pts(1) = New DicomAnnotationPoint(450, 100)compoundGraphic.SetAnnotationPoints(pts, pts.Length)compoundGraphic.CompoundGraphicInstanceId = 100compoundGraphic.GraphicGroupId = 0compoundGraphic.RotationAngle = 0.0compoundGraphic.RotationPoint = New DicomAnnotationPoint(0, 0)compoundGraphic.GapLength = 0.0FcompoundGraphic.DiameterOfVisibility = 0compoundGraphic.TickAlignment = DicomAnnotationTickAlignmentType.CentercompoundGraphic.TickLabelAlignment = DicomAnnotationTickLabelAlignmentType.BottomcompoundGraphic.ShowTickLabel = TruecompoundGraphic.Filled = FalsecompoundGraphic.Options = DicomAnnotationOptions.Line Or DicomAnnotationOptions.Text Or DicomAnnotationOptions.CompoundGraphicInstanceId' TextStylecompoundGraphic.TextStyle = New DicomTextStyle()compoundGraphic.TextStyle.TextOptions = DicomAnnotationTextOptions.FontNamecompoundGraphic.TextStyle.FontName = "Arial"compoundGraphic.TextStyle.CssFontName = "serif"compoundGraphic.TextStyle.TextColorCieLabValue = New UShort(2) {34866, 53484, 50171} ' RedcompoundGraphic.TextStyle.HorizontalAlign = DicomAnnotationHorizontalAlignmentType.CentercompoundGraphic.TextStyle.VerticalAlign = DicomAnnotationVerticalAlignmentType.CentercompoundGraphic.TextStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.OffcompoundGraphic.TextStyle.Shadow.ShadowOffsetX = 0compoundGraphic.TextStyle.Shadow.ShadowOffsetY = 0compoundGraphic.TextStyle.Shadow.ShadowColorCieLabValue = New UShort(2) {0, 0, 0}compoundGraphic.TextStyle.Shadow.ShadowOpacity = 0.0FcompoundGraphic.TextStyle.Underlined = FalsecompoundGraphic.TextStyle.Italic = FalsecompoundGraphic.TextStyle.Bold = False' LineStylecompoundGraphic.LineStyle = New DicomLineStyle()compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.NonecompoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.PatternOffColorCielabValue Or DicomAnnotationLineOptions.PatternOffOpacitycompoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.OffcompoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0FcompoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0FcompoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0FcompoundGraphic.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.0FcompoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.SolidcompoundGraphic.LineStyle.LinePattern = &HFFFFcompoundGraphic.LineStyle.PatternOnOpacity = 1.0FcompoundGraphic.LineStyle.PatternOffOpacity = 0.0F' RULER does not have a fill style' Major Ticks SequenceDim nTickCount As Integer = 4Dim fTickIncrement As Single = CSng(1.0 / CSng(nTickCount))compoundGraphic.MajorTicks.Clear()For i As Integer = 0 To nTickCount - 1Dim majorTickItem As New DicomMajorTick(i * fTickIncrement, "Label " & i.ToString())compoundGraphic.MajorTicks.Add(majorTickItem)Next iReturn compoundGraphicEnd Function' Creates a RECTANGLE compound graphic (rotated, filled)Private Function CreateCompoundGraphicRectangle(ByVal layerName As String) As DicomCompoundGraphic' Create a compound graphicDim compoundGraphic As New DicomCompoundGraphic()compoundGraphic.LayerName = layerNamecompoundGraphic.Units = DicomAnnotationUnitsRelativityType.PixelcompoundGraphic.Type = DicomAnnotationCompoundGraphicType.RectangleDim pts(1) As DicomAnnotationPointpts(0) = New DicomAnnotationPoint(100, 100)pts(1) = New DicomAnnotationPoint(200, 200)compoundGraphic.SetAnnotationPoints(pts, pts.Length)compoundGraphic.CompoundGraphicInstanceId = 200compoundGraphic.GraphicGroupId = 0compoundGraphic.RotationAngle = 45.0compoundGraphic.RotationPoint = New DicomAnnotationPoint(150, 150)compoundGraphic.Filled = TruecompoundGraphic.Options = DicomAnnotationOptions.Fill Or DicomAnnotationOptions.Line Or DicomAnnotationOptions.CompoundGraphicInstanceId' LineStylecompoundGraphic.LineStyle = New DicomLineStyle()compoundGraphic.LineStyle.LineOptions = DicomAnnotationLineOptions.NonecompoundGraphic.LineStyle.Shadow.ShadowStyle = DicomAnnotationShadowStyleType.OffcompoundGraphic.LineStyle.Shadow.ShadowOpacity = 0.0FcompoundGraphic.LineStyle.Shadow.ShadowOffsetX = 0.0FcompoundGraphic.LineStyle.Shadow.ShadowOffsetY = 0.0FcompoundGraphic.LineStyle.Shadow.ShadowColorCieLabValue = New UShort(2) {1, 2, 3}compoundGraphic.LineStyle.PatternOnColorCieLabValue = New UShort(2) {24886, 53484, 50171} ' redcompoundGraphic.LineStyle.PatternOffColorCieLabValue = New UShort(2) {0, 0, 0}compoundGraphic.LineStyle.LineThickness = 2.0FcompoundGraphic.LineStyle.LineDashingStyle = DicomAnnotationDashStyleType.SolidcompoundGraphic.LineStyle.LinePattern = &HFFFFcompoundGraphic.LineStyle.PatternOnOpacity = 1.0FcompoundGraphic.LineStyle.PatternOffOpacity = 0.0F' FillStylecompoundGraphic.FillStyle = New DicomFillStyle()compoundGraphic.FillStyle.FillOptions = DicomAnnotationFillOptions.NonecompoundGraphic.FillStyle.PatternOnColorCieLabValue = New UShort(2) {21169, 53249, 5175} ' bluecompoundGraphic.FillStyle.PatternOffColorCieLabValue = New UShort(2) {0, 0, 0}compoundGraphic.FillStyle.PatternOnOpacity = 1.0FcompoundGraphic.FillStyle.PatternOffOpacity = 0.0FcompoundGraphic.FillStyle.FillMode = DicomAnnotationFillModeType.SolidReturn compoundGraphicEnd FunctionPrivate 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 rectangleDim 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 2Dim nCount As Integer = ds.GetCompoundGraphicCount(firstGraphicAnnSQItem)Debug.Assert(nCount = 2)' Get the number of points of the first item (ruler) -- this should be 2nCount = ds.GetCompoundGraphicPointCount(firstGraphicAnnSQItem, 0)Debug.Assert(nCount = 2)' Get the number of major ticks in the ruler -- this should be 4nCount = 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 rectangleDim compoundGraphic As DicomCompoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0)Debug.Assert(compoundGraphic.Type = DicomAnnotationCompoundGraphicType.Rectangle)' Change the rectangle from filled, to non-filledcompoundGraphic.Filled = Falseds.SetCompoundGraphicInformation(firstGraphicAnnSQItem, 0, compoundGraphic)' Verify that the rectangle is non-filledcompoundGraphic = ds.GetCompoundGraphicInformation(firstGraphicAnnSQItem, 0)Debug.Assert(compoundGraphic.Filled = False)' Remove ALL compund graphicsds.RemoveAllCompoundGraphics(firstGraphicAnnSQItem)' Get the compound graphic count -- it should now be zeronCount = 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
