Converts all the LEAD Annotation objects in an AnnContainer into one or more DICOM annotation objects, and stores (overwrites) the result in a Leadtools.Dicom.DicomDataSet.
public DicomElement FromAnnContainerToDataSet(DicomDataSet ds,AnnContainer annContainer,DicomDataSet dsImage,string newSeriesInstanceUid,string newSopInstanceUid)
ds
The Leadtools.Dicom.DicomDataSet where the resulting DICOM Annotation objects are stored.
annContainer
The Leadtools.Annotations.Engine.AnnContainer that contains a list of Leadtools.Annotations.Engine.AnnObject objects that are to be converted.
dsImage
The Leadtools.Dicom.DicomDataSet on which the annotations are rendered.
newSeriesInstanceUid
The SeriesInstanceUID of the resulting ds. Pass string.Empty to auto-generate.
newSopInstanceUid
The SopInstanceUID of the resulting ds. Pass string.Empty to auto-generate.
A Leadtools.Dicom.DicomDataSet of type DicomUidType.GrayscaleSoftcopyPresentationStateStorage containing all the annotations in annContainer.
This method converts a LEAD Leadtools.Annotations.Engine.AnnContainer of Leadtools.Annotations.Engine.AnnObject objects into one or more DICOM annotation objects (text, graphic, and compound graphic), and stores (overwrites) the result inside the ds parameter.
If the resulting DICOM annotation object is:
The dsImage is a Leadtools.Dicom.DicomDataSet that contains an image on which the annotations are to be rendered.
Patient, Study, and series information is copied from dsImage and stored in the resulting ds, including:
Patient Information:
PatientStudy Information:
Study Information:
Series Information:
This overload overwrites any existing annotations in ds.
To append annotations, use FromAnnContainerToDataSet(DicomDataSet,AnnContainer,DicomDataSet,string,string,FromAnnContainerToDataSetOptions).
using Leadtools;using Leadtools.Dicom;using Leadtools.Dicom.Annotations;using Leadtools.Annotations;using Leadtools.Annotations.Engine;// This example stores DICOM annotations for two different DICOM instances in the same DICOM presentation file// The DICOM annotations are then loaded separately for each DICOM instance// When running this sample, you must pass two different DICOM instances for the same PatientID// The following DICOM files can be used:// 1. C:\LEADTOOLSxx\Examples\DotNet\PACSFramework\CS\PACSDatabaseConfigurationDemo\Resources\cr1.dcm// 2. C:\LEADTOOLSxx\Examples\DotNet\PACSFramework\CS\PACSDatabaseConfigurationDemo\Resources\cr1.dcmprivate void DicomAnnotationsUtilities_FromAnnContainerToDataSet2(DicomDataSet dsImage1, DicomDataSet dsImage2, string outfilePresentationState){// Create an AnnRectangleObject (rotated, filled)AnnRectangleObject rectangleObject = new AnnRectangleObject();rectangleObject.Stroke.Stroke = AnnSolidColorBrush.Create("red");rectangleObject.Fill = AnnSolidColorBrush.Create("blue");rectangleObject.Points.Add(ConvertLeadPointD(100, 100));rectangleObject.Points.Add(ConvertLeadPointD(200, 100));rectangleObject.Points.Add(ConvertLeadPointD(200, 200));rectangleObject.Points.Add(ConvertLeadPointD(100, 200));rectangleObject.Rotate(45.0, ConvertLeadPointD(150, 150));// Create a polyline objectAnnPolylineObject polylineObject = new AnnPolylineObject();polylineObject.Stroke.Stroke = AnnSolidColorBrush.Create("red");polylineObject.Points.Clear();polylineObject.Points.Add(ConvertLeadPointD(300, 100));polylineObject.Points.Add(ConvertLeadPointD(400, 200));// Add them to the AnnContainerAnnContainer annContainer = new AnnContainer();annContainer.Mapper = new AnnContainerMapper(96, 96, 96, 96);annContainer.Children.Add(rectangleObject);annContainer.Children.Add(polylineObject);// Create a DicomDataSetusing (DicomDataSet dsPS = new DicomDataSet()){dsPS.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryModulesOnly | DicomDataSetInitializeFlags.AddMandatoryElementsOnly);// Delete the empty referenced Series SequenceDicomElement referencedSeriesSequence = dsPS.FindFirstElement(null, DicomTag.ReferencedSeriesSequence, true);if (referencedSeriesSequence != null){dsPS.DeleteElement(referencedSeriesSequence);}// Add a new Referenced Series SequencedsPS.AddPresentationStateImageReference(dsImage1, null, 0);// Set up the DicomAnnotationsUtilities converterDicomAnnotationsUtilities du = new DicomAnnotationsUtilities();// Change the DICOM Unique Identifier Organization Root// The SOPInstanceUID of the presentation state will start with this prefixdu.DicomUidOrgRoot = "1.2.840.1111.2222.3333";// Set defaultsdu.UseMapper = true;du.ContainerMapper = annContainer.Mapper;du.DefaultObject = new DicomTextObject();du.ImageDpiX = 96.0;du.ImageDpiY = 96.0;du.DisplayWidth = 200;du.DisplayHeight = 200;du.LayerName = "Layer 0";// Set up the presentation state modulePresentationStateIdentificationModule ps = new PresentationStateIdentificationModule();ps.ContentCreatorName = "My Content Creator Name";ps.ContentDescription = "My Content Description";ps.ContentLabel = "My Content Label";DateTime now = DateTime.Now;ps.CreationDate = new DicomDateValue(now);ps.CreationTime = new DicomTimeValue(now);ps.InstanceNumber = 123;du.PresentationStateIdentification = ps;// Convert LEAD annotations to DICOM annotations// Note that dsImage1 and dsImage2 must have the same PatientID// The images can be from different studies and series// 1. Add annotations for dsImage1du.FromAnnContainerToDataSet(dsPS, annContainer, dsImage1, string.Empty, string.Empty, FromAnnContainerToDataSetOptions.Create);// 2. Add annotations for dsImage2annContainer.Children.Clear();// Create an AnnEllipseObject (rotated, filled)AnnEllipseObject ellipseObject = new AnnEllipseObject();ellipseObject.Stroke.Stroke = AnnSolidColorBrush.Create("red");ellipseObject.Fill = AnnSolidColorBrush.Create("yellow");ellipseObject.Points.Add(ConvertLeadPointD(100, 100));ellipseObject.Points.Add(ConvertLeadPointD(200, 100));ellipseObject.Points.Add(ConvertLeadPointD(200, 200));ellipseObject.Points.Add(ConvertLeadPointD(100, 200));annContainer.Children.Add(ellipseObject);du.FromAnnContainerToDataSet(dsPS, annContainer, dsImage2, string.Empty, string.Empty, FromAnnContainerToDataSetOptions.Append);// Save the presentation statedsPS.Save(outfilePresentationState, DicomDataSetSaveFlags.None);// Read the annotations for dsImage1 -- there should be two objectsAnnContainer annContainer1 = du.FromDataSetToAnnContainer(dsPS, null, dsImage1);Debug.Assert(annContainer1.Children.Count == 2);// Read the annotations for dsImage2 -- there should be one objectAnnContainer annContainer2 = du.FromDataSetToAnnContainer(dsPS, null, dsImage2);Debug.Assert(annContainer2.Children.Count == 1);MessageBox.Show("Presentation State Saved: " + outfilePresentationState);}}LeadPointD ConvertLeadPointD(double x, double y){double imageDpi = 96.0;return new LeadPointD(x * 720.0 / imageDpi, y * 720.0 / imageDpi);}