public void RemoveGraphicObject(DicomElement graphicAnnSQItem,int graphicObjIndex)
public:void RemoveGraphicObject(DicomElement^ graphicAnnSQItem,int graphicObjIndex)
graphicAnnSQItem
An item element under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module".
graphicObjIndex
The zero-based index of the graphic annotation object to remove.
This method will remove the graphical annotation object at the specified index in the specified "Graphic Annotation Sequence" (0070,0001) item. The index is zero-based.
using Leadtools;using Leadtools.Dicom;public void GraphicAnnSequenceSample(){//Make sure to initialize the DICOM engine, this needs to be done only once//In the whole applicationDicomEngine.Startup();using (DicomDataSet dicomDataset = new DicomDataSet()){// We can also initialize in here the "Grayscale Softcopy Presentation State" classdicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian);dicomDataset.CreateGraphicAnnSQItem(0, "Layer0");DicomElement firstGraphicAnnSQItem = dicomDataset.FindFirstGraphicAnnSQItem();Debug.Assert(firstGraphicAnnSQItem != null);//If there was more than one item we can use//FindNextGraphicAnnSQItem to enumerate these itemsdicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1");Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) == "Layer1");// We can also call RemoveAllImageRefFromAllLayers or call// RemoveImageRefFromLayer to remove the referenced images one by one.// In any case this is for demonstration purposes only, since the dataset// doesn't have any referenced images right now.dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem);dicomDataset.AddPresentationStateImageReference(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm"), null, 0);// We know that the SOP instance UID for the dataset IMAGE2.dcm is// 1.2.840.114257.3.6.5.5.18900282dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282");Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) == 1);Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) == "1.2.840.114257.3.6.5.5.18900282");Debug.Assert(dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") != null);////////This section is for DICOM Graphic Object///////////////////DicomGraphicObject graphicObject = new DicomGraphicObject();DicomAnnotationPoint[] annotationPoints = new DicomAnnotationPoint[5];annotationPoints[0].X = 480.00F;annotationPoints[0].Y = 226.00F;annotationPoints[1].X = 480.00F;annotationPoints[1].Y = 418.00F;annotationPoints[2].X = 488.00F;annotationPoints[2].Y = 418.00F;annotationPoints[3].X = 488.00F;annotationPoints[3].Y = 226.00F;annotationPoints[4].X = 480.00F;annotationPoints[4].Y = 226.00F;graphicObject.SetAnnotationPoints(annotationPoints, 5);graphicObject.Filled = false;graphicObject.Type = DicomAnnotationType.Polyline;graphicObject.LayerName = "Layer1";graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel;Debug.Assert(graphicObject.AnnotationPointCount == 5);//Start Clean!//Can also call RemoveGraphicObject to remove individual objectsdicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem);dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, false);Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) == 1);Debug.Assert(dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) != null);Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) == 5);DicomGraphicObject graphicObject1 = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0);Debug.Assert(graphicObject1 != null);graphicObject1.Filled = true;dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1);////////This section is for DICOM Text Object/////////////////////Can also call RemoveTextObject to remove individual objectsdicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem);DicomTextObject textObject = new DicomTextObject();textObject.AnchorPointVisible = true;textObject.AnchorPoint = new DicomAnnotationPoint(1.1F, 1.1F);textObject.BRHCorner = new DicomAnnotationPoint(521.251343F, 328.190216F);textObject.TLHCorner = new DicomAnnotationPoint(466.642242F, 300.443268F);textObject.TextValue = "Text Value 1";textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;textObject.LayerName = "Layer1";textObject.TextJustification = TextAnnotationJustificationType.Left;dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, false);Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) == 1);Debug.Assert(dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) != null);DicomTextObject textObject1 = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0);Debug.Assert(textObject1 != null);textObject1.TextJustification = TextAnnotationJustificationType.Right;dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1);dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "GraphicAnnSequence.dcm"), DicomDataSetSaveFlags.None);}DicomEngine.Shutdown();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images";}
FindFirstGraphicAnnSQItem Method
GetGraphicObjectInformation Method
SetGraphicObjectInformation Method
RemoveAllGraphicObjects 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
