internal void OnDisplaySetChanged(DisplaySetChangedEventArgs args) { EventsHelper.Fire(_displaySetChanged, this, args); }
private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e) { if (e.NewDisplaySet != null && e.NewDisplaySet.Visible) { var uidCnt = new Dictionary<string, int>(); foreach (var img in e.NewDisplaySet.PresentationImages) { var imageSopPrivider = img as IImageSopProvider; if (imageSopPrivider != null) { var studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid; if (uidCnt.ContainsKey(studyInstanceUID)) uidCnt[studyInstanceUID] += 1; else uidCnt[studyInstanceUID] = 1; } } var annotationList = new List<aim_dotnet.Annotation>(); var dcmModel = new aim_dotnet.DcmModel(); foreach (var studyInstanceUID in uidCnt.Keys) { InitializeAnnotationList(studyInstanceUID); var annotationSopsInfo = _annotationDictionary[studyInstanceUID]; if (annotationSopsInfo == null) continue; foreach (var information in annotationSopsInfo) { try { annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName)); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex); } } } foreach (var annotation in annotationList) { foreach (var img in e.NewDisplaySet.PresentationImages) { AimHelpers.ReadGraphicsFromAnnotation(annotation, img); } } } }
internal void OnDisplaySetChanged(DisplaySetChangedEventArgs args) { EventsHelper.Fire(_displaySetChanged, this, args); }
private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e) { // toDO - init annotation dictionary here! Console.WriteLine("OnDisplaySetChanged"); // TODO - add/remove DisplaySet.PresentationImages.ItemAdded event handlers if (e.NewDisplaySet != null && e.NewDisplaySet.Visible) { Dictionary<string, int> uidCnt = new Dictionary<string, int>(); foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages) { IImageSopProvider imageSopPrivider = img as IImageSopProvider; if (imageSopPrivider != null) { string studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid; if (uidCnt.ContainsKey(studyInstanceUID)) uidCnt[studyInstanceUID] += 1; else uidCnt[studyInstanceUID] = 1; } } // 1. Init annotation objects List<aim_dotnet.Annotation> annotationList = new List<aim_dotnet.Annotation>(); aim_dotnet.DcmModel dcmModel = new aim_dotnet.DcmModel(); foreach (string studyInstanceUID in uidCnt.Keys) { InitializeAnnotationList(studyInstanceUID); List<AimSopInstanceInformation> annotationSopsInfo = _annotationDictionary[studyInstanceUID]; if (annotationSopsInfo == null) continue; foreach (AimSopInstanceInformation information in annotationSopsInfo) { try { annotationList.AddRange(dcmModel.ReadAnnotationsFromFile(information.InstanceFileName)); } catch (Exception ex) { Platform.Log(LogLevel.Error, ex); } } } // 2. put markup on the images foreach (aim_dotnet.Annotation annotation in annotationList) { foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages) { AimHelpers.ReadGraphicsFromAnnotation(annotation, img); } } } }
private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e) { Console.WriteLine("OnDisplaySetChanged"); // TODO - add/remove DisplaySet.PresentationImages.ItemAdded event handlers if (e.NewDisplaySet != null && e.NewDisplaySet.Visible) { Dictionary<string, int> uidCnt = new Dictionary<string, int>(); foreach (var imageSopPrivider in e.NewDisplaySet.PresentationImages.OfType<IImageSopProvider>().Where(imageSopPrivider => imageSopPrivider != null)) { if (imageSopPrivider != null) { string studyInstanceUID = imageSopPrivider.ImageSop.StudyInstanceUid; if (uidCnt.ContainsKey(studyInstanceUID)) uidCnt[studyInstanceUID] += 1; else uidCnt[studyInstanceUID] = 1; } } // 1. Init annotation objects var aimAnnotations = new List<AimManager.IAimDocumentInstance>(); foreach (string studyInstanceUid in uidCnt.Keys) { var studyAnnotations = AimManager.AimManager.Instance.LoadLocalAnnotationsForStudy(studyInstanceUid); if (studyAnnotations != null) aimAnnotations.AddRange(studyAnnotations); } // 2. put markup on the images foreach (var annotation in aimAnnotations) { foreach (IPresentationImage img in e.NewDisplaySet.PresentationImages) { AimManager.AimManager.Instance.ReadGraphicsFromAnnotation(annotation, img); } } } }
private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e) { if (e.NewDisplaySet != null && e.NewDisplaySet.Visible) { var studyToSeriesAndInstanceDictionary = new Dictionary<string, Dictionary<string, IImageSopProvider>>(); foreach ( IImageSopProvider imageSopPrivider in e.NewDisplaySet.PresentationImages.OfType<IImageSopProvider>().Where( imageSopPrivider => imageSopPrivider != null)) { if (imageSopPrivider != null) { string studyInstanceUid = imageSopPrivider.ImageSop.StudyInstanceUid; string seriesInstanceUid = imageSopPrivider.ImageSop.SeriesInstanceUid; Dictionary<string, IImageSopProvider> seriesToSopInstanceDict; if (studyToSeriesAndInstanceDictionary.ContainsKey(studyInstanceUid)) { seriesToSopInstanceDict = studyToSeriesAndInstanceDictionary[studyInstanceUid]; } else { seriesToSopInstanceDict = new Dictionary<string, IImageSopProvider>(); studyToSeriesAndInstanceDictionary[studyInstanceUid] = seriesToSopInstanceDict; } // Store one SOP Instance for each series if (!seriesToSopInstanceDict.ContainsKey(seriesInstanceUid)) seriesToSopInstanceDict[seriesInstanceUid] = imageSopPrivider; } } bool updateComponent = false; foreach (string studyInstanceUid in studyToSeriesAndInstanceDictionary.Keys) { List<Sop> segmentationSopInstances = LoadSegmentationSopsForStudy(studyInstanceUid); if (segmentationSopInstances != null) { foreach (Sop segSop in segmentationSopInstances) { SegmentationDocument segmentationDocument = new SegmentationDeserializer(segSop).DeserializeSegmenationDocument(); if (segmentationDocument != null && !SegmentationGraphicsHelpers.IsSegmentationDocumentGraphicLoaded(segmentationDocument, e.NewDisplaySet)) { foreach (Seg seg in segmentationDocument.Segs) { IPresentationImage segPresentationImage = null; if (seg.ImageSeriesUid == null) { if (seg.SegmentImageData != null && seg.SegmentImageData.SegmentFrameData != null && seg.SegmentImageData.SegmentFrameData.Count > 0) { segPresentationImage = SegmentationGraphicsHelpers. PresentationImageFromPositionOrientation( seg.SegmentImageData.SegmentFrameData[0].ImagePositionPatient, seg.SegmentImageData.SegmentFrameData[0].ImageOrientationPatient, e.NewDisplaySet, seg.SegmentImageData.FrameOfReferenceUid); //var sop = segPresentationImage as IImageSopProvider; //if (sop != null) //{ // seg.ImageSeriesUid = sop.Frame.SeriesInstanceUid; //} } } else if ( studyToSeriesAndInstanceDictionary[studyInstanceUid].ContainsKey( seg.ImageSeriesUid)) { segPresentationImage = studyToSeriesAndInstanceDictionary[studyInstanceUid][seg.ImageSeriesUid] as IPresentationImage; } if (segPresentationImage == null) { Platform.Log(LogLevel.Info, "Failed to find a series and image to display a segmentation frame on (SOP Instance UID={0}, Label = {1})", segmentationDocument.SopInstanceUid, seg.Label); } else { SegmentationGraphicsHelpers.CreateSeriesGraphicsForSeg( segPresentationImage, seg, segmentationDocument, segSop.DataSource as IDicomMessageSopDataSource); updateComponent = true; } var sopProvider = segPresentationImage as ISopProvider; if (sopProvider != null) AddSegmentationMenuInfo(segmentationDocument, seg, sopProvider.Sop); } } } } } // Update component if new graphics is loaded if (updateComponent) UpdateSegmentationTreeInComponent(); } }