protected void SerializeGraphicAnnotation(GraphicAnnotationModuleIod graphicAnnotationModule, DicomPresentationImageCollection <T> images) { List <GraphicAnnotationSequenceItem> annotations = new List <GraphicAnnotationSequenceItem>(); foreach (T image in images) { DicomGraphicsPlane psGraphic = DicomGraphicsPlane.GetDicomGraphicsPlane(image, false); if (psGraphic != null) { foreach (ILayer layerGraphic in (IEnumerable <ILayer>)psGraphic.Layers) { foreach (IGraphic graphic in layerGraphic.Graphics) { GraphicAnnotationSequenceItem annotation = new GraphicAnnotationSequenceItem(); if (GraphicAnnotationSerializer.SerializeGraphic(graphic, annotation) && AnyContent(annotation)) { SetAllSpecificCharacterSets(annotation, DataSet.SpecificCharacterSet); annotation.GraphicLayer = layerGraphic.Id.ToUpperInvariant(); annotation.ReferencedImageSequence = new[] { CreateImageSopInstanceReference(image.Frame) }; annotations.Add(annotation); } } } } foreach (IGraphic graphic in image.OverlayGraphics) { GraphicAnnotationSequenceItem annotation = new GraphicAnnotationSequenceItem(); if (GraphicAnnotationSerializer.SerializeGraphic(graphic, annotation) && AnyContent(annotation)) { SetAllSpecificCharacterSets(annotation, DataSet.SpecificCharacterSet); annotation.GraphicLayer = _annotationsLayerId; annotation.ReferencedImageSequence = new[] { CreateImageSopInstanceReference(image.Frame) }; annotations.Add(annotation); } } } if (annotations.Count > 0) { graphicAnnotationModule.GraphicAnnotationSequence = annotations.ToArray(); } }
protected void DeserializeGraphicAnnotation(GraphicAnnotationModuleIod module, RectangleF displayedArea, T image) { DicomGraphicsPlane graphic = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true); var sqItems = module.GraphicAnnotationSequence; if (sqItems != null) { foreach (var annotation in sqItems.Select(sqItem => new { LayerId = sqItem.GraphicLayer ?? string.Empty, Graphic = DicomGraphicsFactory.CreateGraphicAnnotation(image.Frame, sqItem, displayedArea, DeserializeInteractiveAnnotations) }).Where(g => g.Graphic != null)) { graphic.Layers[annotation.LayerId].Graphics.Add(annotation.Graphic); } } }
protected void DeserializeGraphicAnnotation(GraphicAnnotationModuleIod module, RectangleF displayedArea, T image) { DicomGraphicsPlane graphic = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true); var sqItems = module.GraphicAnnotationSequence; if (sqItems != null) { var interactiveAnnotations = DeserializeOptions.HasFlag(DicomSoftcopyPresentationStateDeserializeOptions.InteractiveAnnotations); var ignoreImageRelationships = DeserializeIgnoreImageRelationship; foreach (var annotation in sqItems.Select(sqItem => new { LayerId = sqItem.GraphicLayer ?? string.Empty, Graphic = DicomGraphicsFactory.CreateGraphicAnnotation(image.Frame, sqItem, displayedArea, interactiveAnnotations, ignoreImageRelationships) }).Where(g => g.Graphic != null)) { graphic.Layers[annotation.LayerId].Graphics.Add(annotation.Graphic); } } }
public static IEnumerable <DicomGraphicAnnotation> CreateGraphicAnnotations(Frame frame, GraphicAnnotationModuleIod annotationsFromPresentationState, RectangleF displayedArea) { List <DicomGraphicAnnotation> list = new List <DicomGraphicAnnotation>(); GraphicAnnotationSequenceItem[] annotationSequences = annotationsFromPresentationState.GraphicAnnotationSequence; if (annotationSequences != null) { foreach (GraphicAnnotationSequenceItem sequenceItem in annotationSequences) { ImageSopInstanceReferenceDictionary dictionary = new ImageSopInstanceReferenceDictionary(sequenceItem.ReferencedImageSequence, true); if (dictionary.ReferencesFrame(frame.ParentImageSop.SopInstanceUid, frame.FrameNumber)) { list.Add(new DicomGraphicAnnotation(sequenceItem, displayedArea)); } } } return(list.AsReadOnly()); }
public static IEnumerable <DicomGraphicAnnotation> CreateGraphicAnnotations(Frame frame, GraphicAnnotationModuleIod annotationsFromPresentationState, RectangleF displayedArea, bool interactive = false) { GraphicAnnotationSequenceItem[] annotationSequences = annotationsFromPresentationState.GraphicAnnotationSequence; if (annotationSequences == null) { return(Enumerable.Empty <DicomGraphicAnnotation>().ToList()); } return(annotationSequences.Select(sqItem => CreateGraphicAnnotation(frame, sqItem, displayedArea, interactive)).Where(g => g != null).ToList()); }