상속: IDisplaySet
예제 #1
0
        public override List <IDisplaySet> CreateDisplaySets(Series series)
        {
            var images = new List <IPresentationImage>();

            foreach (var sop in series.Sops)
            {
                // TODO CR (Oct 11): To be reworked before next Community release, since we do want this to show

                // only create placeholders for any non-image, non-presentation state SOPs
                if (sop.IsImage ||
                    sop.SopClassUid == SopClass.EncapsulatedPdfStorageUid ||
                    sop.SopClassUid == SopClass.GrayscaleSoftcopyPresentationStateStorageSopClassUid ||
                    sop.SopClassUid == SopClass.ColorSoftcopyPresentationStateStorageSopClassUid ||
                    sop.SopClassUid == SopClass.PseudoColorSoftcopyPresentationStateStorageSopClassUid ||
                    sop.SopClassUid == SopClass.BlendingSoftcopyPresentationStateStorageSopClassUid)
                {
                    continue;
                }

                images.Add(new PlaceholderPresentationImage(sop));
            }

            if (images.Count > 0)
            {
                var displaySet = new DisplaySet(new SeriesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory));
                foreach (var image in images)
                {
                    displaySet.PresentationImages.Add(image);
                }

                return(new List <IDisplaySet>(new[] { displaySet }));
            }

            return(new List <IDisplaySet>());
        }
예제 #2
0
        /// <summary>
        /// Creates zero or more <see cref="IDisplaySet"/>s from the given <see cref="Series"/>.
        /// </summary>
        /// <remarks>
        /// When the input <see cref="Series"/> does not have multiple echoes, no <see cref="IDisplaySet"/>s will be returned.
        /// Otherwise, at least 2 <see cref="IDisplaySet"/>s will be returned.
        /// </remarks>
        public override List <IDisplaySet> CreateDisplaySets(Series series)
        {
            List <IDisplaySet> displaySets = new List <IDisplaySet>();

            if (series.Modality == "MR")
            {
                SortedDictionary <int, List <Sop> > imagesByEchoNumber = SplitMREchos(series.Sops);
                if (imagesByEchoNumber.Count > 1)
                {
                    foreach (KeyValuePair <int, List <Sop> > echoImages in imagesByEchoNumber)
                    {
                        List <IPresentationImage> images = new List <IPresentationImage>();
                        foreach (ImageSop sop in echoImages.Value)
                        {
                            images.AddRange(PresentationImageFactory.CreateImages(sop));
                        }

                        if (images.Count > 0)
                        {
                            IDisplaySet displaySet = new DisplaySet(new MREchoDisplaySetDescriptor(series.GetIdentifier(), echoImages.Key, PresentationImageFactory));
                            foreach (IPresentationImage image in images)
                            {
                                displaySet.PresentationImages.Add(image);
                            }

                            displaySet.PresentationImages.Sort();
                            displaySets.Add(displaySet);
                        }
                    }
                }
            }

            return(displaySets);
        }
예제 #3
0
        private void Initialize(DisplaySet source, ICloningContext context)
        {
            context.CloneFields(source, this);

            foreach (IPresentationImage image in source.PresentationImages)
            {
                IPresentationImage clone = image.Clone();
                if (clone != null)
                {
                    PresentationImages.Add(clone);
                }
            }

            //keep the sort order.
            PresentationImages.SortComparer = source.PresentationImages.SortComparer;
        }
예제 #4
0
        private IDisplaySet CreateDisplaySet(Study study, IEnumerable <Series> modalitySeries)
        {
            var first = modalitySeries.FirstOrDefault();

            if (first == null)
            {
                return(null);
            }

            var modality = first.Modality;

            if (String.IsNullOrEmpty(modality))
            {
                return(null);
            }

            var displaySet  = new DisplaySet(new ModalityDisplaySetDescriptor(study.GetIdentifier(), modality, PresentationImageFactory));
            int seriesCount = 0;

            foreach (var series in modalitySeries)
            {
                bool added = false;
                foreach (var imageSop in series.Sops) //We don't want key images, references etc.
                {
                    foreach (var image in PresentationImageFactory.CreateImages(imageSop))
                    {
                        displaySet.PresentationImages.Add(image);
                        added = true;
                    }
                }

                if (added)
                {
                    ++seriesCount;
                }
            }

            // Degenerate case is one series, in which case we don't create this display set.
            if (seriesCount > 1)
            {
                return(displaySet);
            }

            displaySet.Dispose();
            return(null);
        }
예제 #5
0
        /// <summary>
        /// Creates a fresh copy of the <see cref="IDisplaySet"/>.
        /// </summary>
        /// <remarks>
        /// This will instantiate a fresh copy of this <see cref="IDisplaySet"/>
        /// using the same construction parameters as the original.
        /// </remarks>
        public IDisplaySet CreateFreshCopy()
        {
            DisplaySet displaySet = new DisplaySet(_descriptor.Clone());

            displaySet.ParentImageSet = this.ParentImageSet;

            foreach (IPresentationImage image in this.PresentationImages)
            {
                displaySet.PresentationImages.Add(image.CreateFreshCopy());
            }

            displaySet.PresentationImages.SortComparer = PresentationImages.SortComparer;

            if (ParentImageSet != null)
            {
                ((ImageSet)ParentImageSet).AddCopy(displaySet);
            }

            return(displaySet);
        }
예제 #6
0
        private IDisplaySet CreateSeriesDisplaySet(Series series)
        {
            IDisplaySet displaySet           = null;
            List <IPresentationImage> images = new List <IPresentationImage>();

            foreach (Sop sop in series.Sops)
            {
                images.AddRange(PresentationImageFactory.CreateImages(sop));
            }

            if (images.Count > 0)
            {
                DisplaySetDescriptor descriptor = new SeriesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory);
                displaySet = new DisplaySet(descriptor);
                foreach (IPresentationImage image in images)
                {
                    displaySet.PresentationImages.Add(image);
                }
            }

            return(displaySet);
        }
예제 #7
0
        /// <summary>
        /// Creates a deep copy of the <see cref="IDisplaySet"/>.
        /// </summary>
        /// <remarks>
        /// <see cref="IDisplaySet"/>s may not return null from this method.
        /// </remarks>
        public IDisplaySet Clone()
        {
            try
            {
                DisplaySet clone = CloneBuilder.Clone(this) as DisplaySet;
                //if (ParentImageSet != null)
                //    ((ImageSet)ParentImageSet).AddCopy(clone);

                if (clone != null)
                {
                    if (ImageViewer != null)
                    {
                        ImageViewer.EventBroker.OnCloneCreated(new CloneCreatedEventArgs(this, clone));
                    }
                }

                return(clone);
            }
            catch (Exception e)
            {
                throw new DisplaySetCloningException(this, e);
            }
        }
예제 #8
0
		/// <summary>
		/// Creates zero or more <see cref="IDisplaySet"/>s from the given <see cref="Series"/>.
		/// </summary>
		/// <remarks>When the input series does not contain a mixture of single and multiframe
		/// images, no <see cref="IDisplaySet"/>s will be returned.</remarks>
		public override List<IDisplaySet> CreateDisplaySets(Series series)
		{
			List<IDisplaySet> displaySets = new List<IDisplaySet>();

			List<ImageSop> singleFrames = new List<ImageSop>();
			List<ImageSop> multiFrames = new List<ImageSop>();

			foreach (Sop sop in series.Sops)
			{
				if (sop.IsImage)
				{
					ImageSop imageSop = (ImageSop)sop;
					if (imageSop.NumberOfFrames > 1)
						multiFrames.Add(imageSop);
					else
						singleFrames.Add(imageSop);
				}
			}

			if (multiFrames.Count > 1 || (singleFrames.Count > 0 && multiFrames.Count > 0))
			{
				if (singleFrames.Count > 0)
				{
					List<IPresentationImage> singleFrameImages = new List<IPresentationImage>();
					foreach (ImageSop singleFrame in singleFrames)
						singleFrameImages.AddRange(PresentationImageFactory.CreateImages(singleFrame));

					if (singleFrameImages.Count > 0)
					{
						var descriptor = new SingleImagesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory);
						var singleImagesDisplaySet = new DisplaySet(descriptor);

						foreach (IPresentationImage singleFrameImage in singleFrameImages)
							singleImagesDisplaySet.PresentationImages.Add(singleFrameImage);

                        singleImagesDisplaySet.PresentationImages.Sort();
						displaySets.Add(singleImagesDisplaySet);
					}
				}

				foreach (ImageSop multiFrame in multiFrames)
				{
					List<IPresentationImage> multiFrameImages = PresentationImageFactory.CreateImages(multiFrame);
					if (multiFrameImages.Count > 0)
					{
						MultiframeDisplaySetDescriptor descriptor =
							new MultiframeDisplaySetDescriptor(multiFrame.ParentSeries.GetIdentifier(), multiFrame.SopInstanceUid, multiFrame.InstanceNumber);
						DisplaySet displaySet = new DisplaySet(descriptor);

						foreach (IPresentationImage multiFrameImage in multiFrameImages)
							displaySet.PresentationImages.Add(multiFrameImage);

						displaySet.PresentationImages.Sort();
						displaySets.Add(displaySet);
					}
				}
			}

			return displaySets;
		}
예제 #9
0
		/// <summary>
		/// Creates zero or more <see cref="IDisplaySet"/>s from the given <see cref="Series"/>.
		/// </summary>
		/// <remarks>
		/// When the input <see cref="Series"/> does not have multiple echoes, no <see cref="IDisplaySet"/>s will be returned.
		/// Otherwise, at least 2 <see cref="IDisplaySet"/>s will be returned.
		/// </remarks>
		public override List<IDisplaySet> CreateDisplaySets(Series series)
		{
			List<IDisplaySet> displaySets = new List<IDisplaySet>();

			if (series.Modality == "MR")
			{
				SortedDictionary<int, List<Sop>> imagesByEchoNumber = SplitMREchos(series.Sops);
				if (imagesByEchoNumber.Count > 1)
				{
					foreach (KeyValuePair<int, List<Sop>> echoImages in imagesByEchoNumber)
					{
						List<IPresentationImage> images = new List<IPresentationImage>();
						foreach (ImageSop sop in echoImages.Value)
							images.AddRange(PresentationImageFactory.CreateImages(sop));

						if (images.Count > 0)
						{
							IDisplaySet displaySet = new DisplaySet(new MREchoDisplaySetDescriptor(series.GetIdentifier(), echoImages.Key, PresentationImageFactory));
							foreach (IPresentationImage image in images)
								displaySet.PresentationImages.Add(image);

							displaySet.PresentationImages.Sort();
							displaySets.Add(displaySet);
						}
					}
				}
			}

			return displaySets;
		}
예제 #10
0
		private List<IDisplaySet> DoCreateSingleImageDisplaySets(Series series)
		{
			List<IDisplaySet> displaySets = new List<IDisplaySet>();
			int position = 0;

			foreach (Sop sop in series.Sops)
			{
				List<IPresentationImage> images = PresentationImageFactory.CreateImages(sop);
				if (images.Count == 0)
					continue;

                if (sop.IsImage)
				{
					ImageSop imageSop = (ImageSop)sop;
					DicomDisplaySetDescriptor descriptor;

					if (imageSop.NumberOfFrames == 1)
						descriptor = new SingleImageDisplaySetDescriptor(series.GetIdentifier(), imageSop, position++);
					else
						descriptor = new MultiframeDisplaySetDescriptor(series.GetIdentifier(), sop.SopInstanceUid, sop.InstanceNumber);

					DisplaySet displaySet = new DisplaySet(descriptor);
					foreach (IPresentationImage image in images)
						displaySet.PresentationImages.Add(image);

					displaySets.Add(displaySet);
				}
				else
				{
					//The sop is actually a container for other referenced sops, like key images.
					foreach (IPresentationImage image in images)
					{
						DisplaySetDescriptor descriptor = null;
						if (image is IImageSopProvider)
						{
							IImageSopProvider provider = (IImageSopProvider) image;
							if (provider.ImageSop.NumberOfFrames == 1)
								descriptor = new SingleImageDisplaySetDescriptor(series.GetIdentifier(), provider.ImageSop, position++);
							else
								descriptor = new SingleFrameDisplaySetDescriptor(series.GetIdentifier(), provider.Frame, position++);
						}
						else
						{
							//TODO (CR Jan 2010): this because the design here is funny... the factory here should actually know something about the key object series it is building for
							ISeriesIdentifier sourceSeries = series.GetIdentifier();
							descriptor = new BasicDisplaySetDescriptor();
							descriptor.Description = sourceSeries.SeriesDescription;
							descriptor.Name = string.Format("{0}: {1}", sourceSeries.SeriesNumber, sourceSeries.SeriesDescription);
							descriptor.Number = sourceSeries.SeriesNumber.GetValueOrDefault(0);
							descriptor.Uid = sourceSeries.SeriesInstanceUid;
						}

						DisplaySet displaySet = new DisplaySet(descriptor);
						displaySet.PresentationImages.Add(image);
						displaySets.Add(displaySet);
					}
				}
			}

            if (displaySets.Count == 1)
            {
                //Degenerate case; single image series, which we're not supposed to create.
                displaySets[0].Dispose();
                displaySets.Clear();
            }

		    return displaySets;
		}
예제 #11
0
		private IDisplaySet CreateSeriesDisplaySet(Series series)
		{
			IDisplaySet displaySet = null;
			List<IPresentationImage> images = new List<IPresentationImage>();
			foreach (Sop sop in series.Sops)
				images.AddRange(PresentationImageFactory.CreateImages(sop));

			if (images.Count > 0)
			{
				DisplaySetDescriptor descriptor = new SeriesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory);
				displaySet = new DisplaySet(descriptor);
				foreach (IPresentationImage image in images)
					displaySet.PresentationImages.Add(image);
			}

			return displaySet;
		}
예제 #12
0
 /// <summary>
 /// Called when a <see cref="DisplaySet"/> has been removed.
 /// </summary>
 protected virtual void OnDisplaySetRemoved(DisplaySet displaySet)
 {
     displaySet.ParentImageSet = null;
     displaySet.ImageViewer    = null;
 }
예제 #13
0
 /// <summary>
 /// Called when a new <see cref="DisplaySet"/> has been added.
 /// </summary>
 protected virtual void OnDisplaySetAdded(DisplaySet displaySet)
 {
     displaySet.ParentImageSet = this;
     displaySet.ImageViewer    = this.ImageViewer;
 }
예제 #14
0
		/// <summary>
		/// Creates a fresh copy of the <see cref="IDisplaySet"/>.
		/// </summary>
		/// <remarks>
		/// This will instantiate a fresh copy of this <see cref="IDisplaySet"/>
		/// using the same construction parameters as the original.
		/// </remarks>
		public IDisplaySet CreateFreshCopy()
		{
			DisplaySet displaySet = new DisplaySet(_descriptor.Clone());
			displaySet.ParentImageSet = this.ParentImageSet;

			foreach (IPresentationImage image in this.PresentationImages)
				displaySet.PresentationImages.Add(image.CreateFreshCopy());

			displaySet.PresentationImages.SortComparer = PresentationImages.SortComparer;

			if (ParentImageSet != null)
				((ImageSet)ParentImageSet).AddCopy(displaySet);

			return displaySet;
		}
예제 #15
0
        /// <summary>
        /// Creates zero or more <see cref="IDisplaySet"/>s from the given <see cref="Series"/>.
        /// </summary>
        /// <remarks>When the input series does not contain a mixture of single and multiframe
        /// images, no <see cref="IDisplaySet"/>s will be returned.</remarks>
        public override List <IDisplaySet> CreateDisplaySets(Series series)
        {
            List <IDisplaySet> displaySets = new List <IDisplaySet>();

            List <ImageSop> singleFrames = new List <ImageSop>();
            List <ImageSop> multiFrames  = new List <ImageSop>();

            foreach (Sop sop in series.Sops)
            {
                if (sop.IsImage)
                {
                    ImageSop imageSop = (ImageSop)sop;
                    if (imageSop.NumberOfFrames > 1)
                    {
                        multiFrames.Add(imageSop);
                    }
                    else
                    {
                        singleFrames.Add(imageSop);
                    }
                }
            }

            if (multiFrames.Count > 1 || (singleFrames.Count > 0 && multiFrames.Count > 0))
            {
                if (singleFrames.Count > 0)
                {
                    List <IPresentationImage> singleFrameImages = new List <IPresentationImage>();
                    foreach (ImageSop singleFrame in singleFrames)
                    {
                        singleFrameImages.AddRange(PresentationImageFactory.CreateImages(singleFrame));
                    }

                    if (singleFrameImages.Count > 0)
                    {
                        var descriptor             = new SingleImagesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory);
                        var singleImagesDisplaySet = new DisplaySet(descriptor);

                        foreach (IPresentationImage singleFrameImage in singleFrameImages)
                        {
                            singleImagesDisplaySet.PresentationImages.Add(singleFrameImage);
                        }

                        singleImagesDisplaySet.PresentationImages.Sort();
                        displaySets.Add(singleImagesDisplaySet);
                    }
                }

                foreach (ImageSop multiFrame in multiFrames)
                {
                    List <IPresentationImage> multiFrameImages = PresentationImageFactory.CreateImages(multiFrame);
                    if (multiFrameImages.Count > 0)
                    {
                        MultiframeDisplaySetDescriptor descriptor =
                            new MultiframeDisplaySetDescriptor(multiFrame.ParentSeries.GetIdentifier(), multiFrame.SopInstanceUid, multiFrame.InstanceNumber);
                        DisplaySet displaySet = new DisplaySet(descriptor);

                        foreach (IPresentationImage multiFrameImage in multiFrameImages)
                        {
                            displaySet.PresentationImages.Add(multiFrameImage);
                        }

                        displaySet.PresentationImages.Sort();
                        displaySets.Add(displaySet);
                    }
                }
            }

            return(displaySets);
        }
예제 #16
0
        private List <IDisplaySet> DoCreateSingleImageDisplaySets(Series series)
        {
            List <IDisplaySet> displaySets = new List <IDisplaySet>();
            int position = 0;

            foreach (Sop sop in series.Sops)
            {
                List <IPresentationImage> images = PresentationImageFactory.CreateImages(sop);
                if (images.Count == 0)
                {
                    continue;
                }

                if (sop.IsImage)
                {
                    ImageSop imageSop = (ImageSop)sop;
                    DicomDisplaySetDescriptor descriptor;

                    if (imageSop.NumberOfFrames == 1)
                    {
                        descriptor = new SingleImageDisplaySetDescriptor(series.GetIdentifier(), imageSop, position++);
                    }
                    else
                    {
                        descriptor = new MultiframeDisplaySetDescriptor(series.GetIdentifier(), sop.SopInstanceUid, sop.InstanceNumber);
                    }

                    DisplaySet displaySet = new DisplaySet(descriptor);
                    foreach (IPresentationImage image in images)
                    {
                        displaySet.PresentationImages.Add(image);
                    }

                    displaySets.Add(displaySet);
                }
                else
                {
                    //The sop is actually a container for other referenced sops, like key images.
                    foreach (IPresentationImage image in images)
                    {
                        DisplaySetDescriptor descriptor = null;
                        if (image is IImageSopProvider)
                        {
                            IImageSopProvider provider = (IImageSopProvider)image;
                            if (provider.ImageSop.NumberOfFrames == 1)
                            {
                                descriptor = new SingleImageDisplaySetDescriptor(series.GetIdentifier(), provider.ImageSop, position++);
                            }
                            else
                            {
                                descriptor = new SingleFrameDisplaySetDescriptor(series.GetIdentifier(), provider.Frame, position++);
                            }
                        }
                        else
                        {
                            //TODO (CR Jan 2010): this because the design here is funny... the factory here should actually know something about the key object series it is building for
                            ISeriesIdentifier sourceSeries = series.GetIdentifier();
                            descriptor             = new BasicDisplaySetDescriptor();
                            descriptor.Description = sourceSeries.SeriesDescription;
                            descriptor.Name        = string.Format("{0}: {1}", sourceSeries.SeriesNumber, sourceSeries.SeriesDescription);
                            descriptor.Number      = sourceSeries.SeriesNumber.GetValueOrDefault(0);
                            descriptor.Uid         = sourceSeries.SeriesInstanceUid;
                        }

                        DisplaySet displaySet = new DisplaySet(descriptor);
                        displaySet.PresentationImages.Add(image);
                        displaySets.Add(displaySet);
                    }
                }
            }

            if (displaySets.Count == 1)
            {
                //Degenerate case; single image series, which we're not supposed to create.
                displaySets[0].Dispose();
                displaySets.Clear();
            }

            return(displaySets);
        }
예제 #17
0
		/// <summary>
		/// Called when a <see cref="DisplaySet"/> has been removed.
		/// </summary>
		protected virtual void OnDisplaySetRemoved(DisplaySet displaySet)
		{
			displaySet.ParentImageSet = null;
			displaySet.ImageViewer = null;
		}
예제 #18
0
		private void Initialize(DisplaySet source, ICloningContext context)
		{
			context.CloneFields(source, this);

			foreach (IPresentationImage image in source.PresentationImages)
			{
				IPresentationImage clone = image.Clone();
				if (clone != null)
					PresentationImages.Add(clone);
			}

			//keep the sort order.
			PresentationImages.SortComparer = source.PresentationImages.SortComparer;
		}
예제 #19
0
        private IDisplaySet CreateDisplaySet(Study study, IEnumerable<Series> modalitySeries)
        {
            var first = modalitySeries.FirstOrDefault();
            if (first == null)
                return null; 

            var modality = first.Modality;
            if (String.IsNullOrEmpty(modality))
                return null;

            var displaySet = new DisplaySet(new ModalityDisplaySetDescriptor(study.GetIdentifier(), modality, PresentationImageFactory));
            int seriesCount = 0;
            foreach (var series in modalitySeries)
            {
                bool added = false;
                foreach (var imageSop in series.Sops) //We don't want key images, references etc.
                {
                    foreach (var image in PresentationImageFactory.CreateImages(imageSop))
                    {
                        displaySet.PresentationImages.Add(image);
                        added = true;
                    }
                }

                if (added)
                    ++seriesCount;
            }

            // Degenerate case is one series, in which case we don't create this display set.
            if (seriesCount > 1)
                return displaySet;

            displaySet.Dispose();
            return null;
        }
예제 #20
0
		/// <summary>
		/// Called when a new <see cref="DisplaySet"/> has been added.
		/// </summary>
		protected virtual void OnDisplaySetAdded(DisplaySet displaySet)
		{
			displaySet.ParentImageSet = this;
			displaySet.ImageViewer = this.ImageViewer;
		}
예제 #21
0
        public override List<IDisplaySet> CreateDisplaySets(Series series)
        {
            var images = new List<IPresentationImage>();
            foreach (var sop in series.Sops)
            {
                // TODO CR (Oct 11): To be reworked before next Community release, since we do want this to show

                // only create placeholders for any non-image, non-presentation state SOPs
                if (sop.IsImage
                    || sop.SopClassUid == SopClass.EncapsulatedPdfStorageUid
                    || sop.SopClassUid == SopClass.GrayscaleSoftcopyPresentationStateStorageSopClassUid
                    || sop.SopClassUid == SopClass.ColorSoftcopyPresentationStateStorageSopClassUid
                    || sop.SopClassUid == SopClass.PseudoColorSoftcopyPresentationStateStorageSopClassUid
                    || sop.SopClassUid == SopClass.BlendingSoftcopyPresentationStateStorageSopClassUid)
                    continue;

                images.Add(new PlaceholderPresentationImage(sop));
            }

            if (images.Count > 0)
            {
                var displaySet = new DisplaySet(new SeriesDisplaySetDescriptor(series.GetIdentifier(), PresentationImageFactory));
                foreach (var image in images)
                    displaySet.PresentationImages.Add(image);

                return new List<IDisplaySet>(new[] { displaySet });
            }

            return new List<IDisplaySet>();
        }
		/// <summary>
		/// Gets the values to be compared for a given <see cref="IDisplaySet"/>.
		/// </summary>
		/// <remarks>
		/// Returns <see cref="IDisplaySet.Number"/>, then <see cref="IDisplaySet.Name"/>.
		/// </remarks>
		protected IEnumerable<IComparable> GetCompareValues(DisplaySet displaySet)
		{
			yield return displaySet.Number;
			yield return displaySet.Name;
		}