private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
 {
     if (e.NewDisplaySet != null)
     {
         UpdateVisibility(e.NewDisplaySet, SelectedOverlaysVisible ? ShowHideOption.ShowSelected : ShowHideOption.HideUnimportant);
     }
 }
Exemple #2
0
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            _deferSynchronizeUntilDisplaySetChanged = false;

            SynchronizeNewDisplaySet(e.NewDisplaySet);
            _coordinator.OnSynchronizedImageBoxes();
        }
        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);
                    }
                }
            }
        }
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            lock (_syncLock)
            {
                if (e.NewDisplaySet != null)
                {
                    if (_imageBoxStrategies.ContainsKey(e.NewDisplaySet.ImageBox))
                    {
                        _imageBoxStrategies[e.NewDisplaySet.ImageBox].OnDisplaySetChanged();
                    }
                }

                Monitor.PulseAll(_syncLock);
            }
        }
Exemple #5
0
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.NewDisplaySet == null)
            {
                return;
            }

            var clock = new CodeClock();

            clock.Start();

            UpdateVisibility(e.NewDisplaySet, SelectedOverlaysVisible ? ShowHideOption.ShowSelected : ShowHideOption.HideUnimportant);

            clock.Stop();
            Trace.WriteLine(String.Format("{0} - UpdateVisibility took {1}", GetType().FullName, clock.Seconds));
        }
        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);
                    }
                }
            }
        }
Exemple #7
0
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.NewDisplaySet == null)
            {
                return;
            }

            CodeClock clock = new CodeClock();

            clock.Start();

            UpdateVisibility(e.NewDisplaySet, Checked);

            clock.Stop();
            Platform.Log(LogLevel.Debug, "{0} - UpdateVisibility took {1}", GetType().FullName, clock.Seconds);

            //The display set will be drawn externally because it just changed.
        }
Exemple #8
0
 private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs displaySetChangedEventArgs)
 {
     // Display details for the newly selected AIM annotation if it's a part of selection
     if (displaySetChangedEventArgs.NewDisplaySet != null && displaySetChangedEventArgs.NewDisplaySet.Selected)
     {
         foreach (IPresentationImage presentationImage in displaySetChangedEventArgs.NewDisplaySet.PresentationImages)
         {
             if (presentationImage.SelectedGraphic != null && presentationImage.SelectedGraphic.Selected)
             {
                 SetSelectedGraphic(presentationImage.SelectedGraphic, "Display set selected changed");
                 break;
             }
         }
     }
     else if (displaySetChangedEventArgs.NewDisplaySet == null)
     {
         SetSelectedGraphic(null, "display set selection changed");
     }
 }
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.OldDisplaySet != null)
            {
                _fusionDisplaySets.Remove(e.OldDisplaySet);
            }

            if (e.NewDisplaySet != null && e.NewDisplaySet.Descriptor is PETFusionDisplaySetDescriptor)
            {
                if (e.NewDisplaySet.ImageBox != null)
                {
                    _fusionDisplaySets.Add(e.NewDisplaySet);

                    // no point doing all this to find an appropriate VOI LUT if there are no images in the display set - but do update the fusionDisplaySets list!
                    if (e.NewDisplaySet.PresentationImages.Count == 0)
                    {
                        return;
                    }

                    // find any available display set containing the same series as the individual layers and capture its VOI LUT
                    IVoiLut baseVoiLut = null, overlayVoiLut = null;
                    Frame   baseFrame = null, overlayFrame = null;
                    var     descriptor = (PETFusionDisplaySetDescriptor)e.NewDisplaySet.Descriptor;
                    foreach (IImageBox imageBox in ImageViewer.PhysicalWorkspace.ImageBoxes)
                    {
                        var selectedImage = imageBox.TopLeftPresentationImage;
                        if (imageBox.DisplaySet == null || imageBox.DisplaySet.Descriptor is PETFusionDisplaySetDescriptor ||
                            !(selectedImage is IImageSopProvider && selectedImage is IVoiLutProvider))
                        {
                            continue;
                        }

                        var seriesUid = ((IImageSopProvider)selectedImage).ImageSop.SeriesInstanceUid;
                        if (baseVoiLut == null && seriesUid == descriptor.SourceSeries.SeriesInstanceUid)
                        {
                            baseVoiLut = ((IVoiLutProvider)selectedImage).VoiLutManager.VoiLut;
                            baseFrame  = ((IImageSopProvider)selectedImage).Frame;
                        }
                        else if (overlayVoiLut == null && seriesUid == descriptor.PETSeries.SeriesInstanceUid)
                        {
                            overlayVoiLut = ((IVoiLutProvider)selectedImage).VoiLutManager.VoiLut;
                            overlayFrame  = ((IImageSopProvider)selectedImage).Frame;
                        }

                        if (baseVoiLut != null && overlayVoiLut != null)
                        {
                            break;
                        }
                    }

                    if (baseVoiLut == null || overlayVoiLut == null)
                    {
                        var fusionImage = (FusionPresentationImage)e.NewDisplaySet.PresentationImages[0];
                        if (baseVoiLut == null)
                        {
                            baseVoiLut = GetInitialVoiLut(baseFrame = fusionImage.Frame);
                        }
                        if (overlayVoiLut == null)
                        {
                            overlayVoiLut = GetInitialVoiLut(overlayFrame = fusionImage.OverlayFrameData.OverlayData.Frames[0]);
                        }
                    }

                    // replicate the captured VOI LUTs to the fusion images
                    foreach (FusionPresentationImage image in e.NewDisplaySet.PresentationImages)
                    {
                        if (baseVoiLut != null)
                        {
                            InstallVoiLut(image, baseVoiLut, baseFrame, false);
                        }
                        if (overlayVoiLut != null)
                        {
                            InstallVoiLut(image, overlayVoiLut, overlayFrame, true);
                        }
                    }
                }
            }
        }
        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();
                }
            }
        }
Exemple #11
0
        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)
		{
			if (e.OldDisplaySet != null)
			{
				_fusionDisplaySets.Remove(e.OldDisplaySet);
			}

			if (e.NewDisplaySet != null && e.NewDisplaySet.Descriptor is PETFusionDisplaySetDescriptor)
			{
				if (e.NewDisplaySet.ImageBox != null)
				{
					_fusionDisplaySets.Add(e.NewDisplaySet);

					// no point doing all this to find an appropriate VOI LUT if there are no images in the display set - but do update the fusionDisplaySets list!
					if (e.NewDisplaySet.PresentationImages.Count == 0)
						return;

					// find any available display set containing the same series as the individual layers and capture its VOI LUT
					IVoiLut baseVoiLut = null, overlayVoiLut = null;
					Frame baseFrame = null, overlayFrame = null;
					var descriptor = (PETFusionDisplaySetDescriptor) e.NewDisplaySet.Descriptor;
					foreach (IImageBox imageBox in ImageViewer.PhysicalWorkspace.ImageBoxes)
					{
						var selectedImage = imageBox.TopLeftPresentationImage;
						if (imageBox.DisplaySet == null || imageBox.DisplaySet.Descriptor is PETFusionDisplaySetDescriptor
						    || !(selectedImage is IImageSopProvider && selectedImage is IVoiLutProvider))
							continue;

						var seriesUid = ((IImageSopProvider) selectedImage).ImageSop.SeriesInstanceUid;
						if (baseVoiLut == null && seriesUid == descriptor.SourceSeries.SeriesInstanceUid)
						{
							baseVoiLut = ((IVoiLutProvider) selectedImage).VoiLutManager.VoiLut;
							baseFrame = ((IImageSopProvider) selectedImage).Frame;
						}
						else if (overlayVoiLut == null && seriesUid == descriptor.PETSeries.SeriesInstanceUid)
						{
							overlayVoiLut = ((IVoiLutProvider) selectedImage).VoiLutManager.VoiLut;
							overlayFrame = ((IImageSopProvider)selectedImage).Frame;
						}

						if (baseVoiLut != null && overlayVoiLut != null)
							break;
					}

					if (baseVoiLut == null || overlayVoiLut == null)
					{
						var fusionImage = (FusionPresentationImage) e.NewDisplaySet.PresentationImages[0];
						if (baseVoiLut == null)
							baseVoiLut = GetInitialVoiLut(baseFrame = fusionImage.Frame);
						if (overlayVoiLut == null)
							overlayVoiLut = GetInitialVoiLut(overlayFrame = fusionImage.OverlayFrameData.OverlayData.Frames[0]);
					}

					// replicate the captured VOI LUTs to the fusion images
					foreach (FusionPresentationImage image in e.NewDisplaySet.PresentationImages)
					{
						if (baseVoiLut != null)
							InstallVoiLut(image, baseVoiLut, baseFrame, false);
						if (overlayVoiLut != null)
							InstallVoiLut(image, overlayVoiLut, overlayFrame, true);
					}
				}
			}
		}
		private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
		{
			_deferSynchronizeUntilDisplaySetChanged = false;

			SynchronizeNewDisplaySet(e.NewDisplaySet);
			_coordinator.OnSynchronizedImageBoxes();
		}
        private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
        {
            if (e.NewDisplaySet == null)
                return;

            var clock = new CodeClock();
            clock.Start();

            UpdateVisibility(e.NewDisplaySet, SelectedOverlaysVisible ? ShowHideOption.ShowSelected : ShowHideOption.HideUnimportant);

            clock.Stop();
            Trace.WriteLine(String.Format("{0} - UpdateVisibility took {1}", GetType().FullName, clock.Seconds));
        }
 private void OnDisplaySetChanged(object sender, DisplaySetChangedEventArgs e)
 {
     if (e.NewDisplaySet != null)
         UpdateVisibility(e.NewDisplaySet, SelectedOverlaysVisible ? ShowHideOption.ShowSelected : ShowHideOption.HideUnimportant);
 }