コード例 #1
0
        private static void UpdateVisibility(IDisplaySet displaySet, ShowHideOption option)
        {
            if (displaySet == null)
            {
                return;
            }

            //Have to update all images each time so that even ones that haven't been drawn are correct.
            //That way, even ones that are exported to the clipboard look right.
            switch (option)
            {
            case ShowHideOption.HideUnimportant:
                foreach (var image in displaySet.PresentationImages)
                {
                    image.GetOverlays().HideUnimportant(false);
                }
                break;

            case ShowHideOption.ShowSelected:
                foreach (var image in displaySet.PresentationImages)
                {
                    image.GetOverlays().ShowSelected(false);
                }
                break;

            case ShowHideOption.HideAll:
                foreach (var image in displaySet.PresentationImages)
                {
                    image.GetOverlays().HideAll(false);
                }
                break;
            }
        }
コード例 #2
0
        private void SetActiveViewer(IImageViewer viewer)
        {
            if (_activeViewer != null)
            {
                _activeViewer.EventBroker.ImageBoxSelected   -= OnImageBoxSelected;
                _activeViewer.EventBroker.DisplaySetSelected -= OnDisplaySetSelected;
            }

            _activeViewer = viewer;

            IDisplaySet displaySet = null;

            if (_activeViewer != null)
            {
                _activeViewer.EventBroker.ImageBoxSelected   += OnImageBoxSelected;
                _activeViewer.EventBroker.DisplaySetSelected += OnDisplaySetSelected;

                if (_activeViewer.SelectedImageBox != null)
                {
                    displaySet = _activeViewer.SelectedImageBox.DisplaySet;
                }
            }

            CurrentDisplaySet = displaySet;
        }
コード例 #3
0
        private IDisplaySet GetSourceDisplaySet()
        {
            IImageBox imageBox = base.Context.Viewer.SelectedImageBox;

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

            IDisplaySet currentDisplaySet = imageBox.DisplaySet;

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

            if (currentDisplaySet.ParentImageSet == null)
            {
                // if the display set doesn't have a parent image set, fall back to using the logical workspace and the UID fo the display set
                // this situation usually arises from dynamically generated alternate views of a display set which is part of an image set
                return(currentDisplaySet.ImageViewer != null?currentDisplaySet.ImageViewer.LogicalWorkspace.ImageSets.SelectMany(ims => ims.DisplaySets).FirstOrDefault(ds => ds.Uid == currentDisplaySet.Uid) : null);
            }

            return(CollectionUtils.SelectFirst(currentDisplaySet.ParentImageSet.DisplaySets, displaySet => displaySet.Uid == currentDisplaySet.Uid));
        }
コード例 #4
0
			public IEnumerable<IPresentationImage> GetImages(IDisplaySet displaySet)
			{
				if (_useInstanceNumbers)
				{
					foreach (IPresentationImage image in displaySet.PresentationImages)
					{
						if (image is IImageSopProvider)
						{
							IImageSopProvider provider = (IImageSopProvider)image;
							
							int maxValue = _endValue - _startValue;
							int testValue = provider.ImageSop.InstanceNumber - _startValue;

							if (testValue >= 0 && testValue <= maxValue && (0 == testValue % _selectionInterval))
								yield return image;
						}
					}
				}
				else
				{
					//selection indices are 1-based.
					for (int i = _startValue - 1; i < _endValue && i < displaySet.PresentationImages.Count; i += _selectionInterval)
						yield return displaySet.PresentationImages[i];
				}
			}
コード例 #5
0
        public VolumePresentationImage(IDisplaySet displaySet)
            : base(1, 1, 1)
        {
            _displaySet = displaySet;

            ValidateSliceData();
        }
コード例 #6
0
ファイル: ResliceTool.cs プロジェクト: bangush/server-1
            private void OnImageViewerImageBoxDrawing(object sender, ImageBoxDrawingEventArgs e)
            {
                IImageBox imageBox = this.SliceImageBox;

                IDisplaySet containingDisplaySet = null;

                if (_resliceGraphic.ParentPresentationImage != null)
                {
                    containingDisplaySet = _resliceGraphic.ParentPresentationImage.ParentDisplaySet;
                }

                if (containingDisplaySet != null && containingDisplaySet.ImageBox == e.ImageBox)
                {
                    // translocate the graphic if the user is stacking through the display set that the graphic sits in
                    // do not add this command to history - the stack command generates the actual action command
                    if (_lastTopLeftPresentationImageIndex != e.ImageBox.TopLeftPresentationImageIndex)
                    {
                        _lastTopLeftPresentationImageIndex = e.ImageBox.TopLeftPresentationImageIndex;
                        TranslocateGraphic(_resliceGraphic, e.ImageBox.TopLeftPresentationImage);
                    }
                }
                else if (imageBox != null && imageBox == e.ImageBox)
                {
                    // we're stacking on the set we control, so make sure the colourised display set name is replicated
                    IPresentationImage firstReslicedImage = imageBox.TopLeftPresentationImage;
                    ColorizeDisplaySetDescription(firstReslicedImage, this.NormalColor);

                    // and realign the slice line with the stacked position
                    if (_resliceGraphic.ParentPresentationImage != null && _resliceGraphic.ParentPresentationImage != firstReslicedImage)
                    {
                        _resliceGraphic.SetLine(imageBox.TopLeftPresentationImage, _resliceGraphic.ParentPresentationImage);
                        _resliceGraphic.Draw();
                    }
                }
            }
コード例 #7
0
		/// <summary>
		/// Initializes a new instance of <see cref="DisplaySetChangedEventArgs"/>.
		/// </summary>
		public DisplaySetChangedEventArgs(
			IDisplaySet oldDisplaySet,
			IDisplaySet newDisplaySet)
		{
			_oldDisplaySet = oldDisplaySet;
			_newDisplaySet = newDisplaySet;
		}
コード例 #8
0
		/// <summary>
		/// Initializes a new instance of <see cref="DisplaySetChangingEventArgs"/>.
		/// </summary>
		public DisplaySetChangingEventArgs(
			IDisplaySet currentDisplaySet,
			IDisplaySet newDisplaySet)
		{
			_currentDisplaySet = currentDisplaySet;
			_newDisplaySet = newDisplaySet;
		}
コード例 #9
0
            public IEnumerable <IPresentationImage> GetImages(IDisplaySet displaySet)
            {
                if (_useInstanceNumbers)
                {
                    foreach (IPresentationImage image in displaySet.PresentationImages)
                    {
                        if (image is IImageSopProvider)
                        {
                            IImageSopProvider provider = (IImageSopProvider)image;

                            int maxValue  = _endValue - _startValue;
                            int testValue = provider.ImageSop.InstanceNumber - _startValue;

                            if (testValue >= 0 && testValue <= maxValue && (0 == testValue % _selectionInterval))
                            {
                                yield return(image);
                            }
                        }
                    }
                }
                else
                {
                    //selection indices are 1-based.
                    for (int i = _startValue - 1; i < _endValue && i < displaySet.PresentationImages.Count; i += _selectionInterval)
                    {
                        yield return(displaySet.PresentationImages[i]);
                    }
                }
            }
コード例 #10
0
            internal ThumbnailGalleryItem(ThumbnailGalleryItemFactory factory, IDisplaySet displaySet, NameAndDescriptionFormat nameAndDescriptionFormat, bool suppressLoadingThumbnails)
                : base(displaySet)
            {
                _factory = factory;
                _suppressLoadingImage = suppressLoadingThumbnails;

                switch (nameAndDescriptionFormat)
                {
                case NameAndDescriptionFormat.NameAndDescription:
                    Name        = GetDisplaySetName(displaySet);
                    Description = GetDisplaySetDescription(displaySet);
                    break;

                case NameAndDescriptionFormat.NoDescription:
                    Name = GetDisplaySetName(displaySet);
                    break;

                case NameAndDescriptionFormat.VerboseNameNoDescription:
                    Name = GetDisplaySetDescription(displaySet);
                    break;

                case NameAndDescriptionFormat.VerboseNameAndDescription:
                    Name = Description = GetDisplaySetDescription(displaySet);
                    break;
                }
            }
コード例 #11
0
        public Bitmap CreateStackIcon(IDisplaySet displaySet)
        {
            Platform.CheckForNullReference(displaySet, "displaySet");
            IPresentationImage image = GetMiddlePresentationImage(displaySet);

            return(GetStackIcon(delegate(int width, int height) { return image.DrawToBitmap(width, height); }));
        }
コード例 #12
0
		private static string GetDisplaySetDirectoryPrefix(IDisplaySet displaySet)
		{
			string prefix = "DisplaySet";

			if (displaySet.PresentationImages.Count > 0 &&
					displaySet.PresentationImages[0] is IImageSopProvider)
			{
				IImageSopProvider provider = (IImageSopProvider)displaySet.PresentationImages[0];
				string seriesDescription = (provider.ImageSop.SeriesDescription ?? "").Trim();

				if (!String.IsNullOrEmpty(seriesDescription))
				{
					prefix = seriesDescription;
					if (prefix.Length > 16)
						prefix = prefix.Remove(16);
				}
				else
				{
					string modality = (provider.ImageSop.Modality ?? "").Trim();
					if (!String.IsNullOrEmpty(modality))
					{
						prefix = String.Format("{0}{1}", modality, provider.ImageSop.SeriesNumber);
						if (provider.ImageSop.NumberOfFrames > 1)
							prefix = String.Format("{0}.{1}", prefix, provider.ImageSop.InstanceNumber);
					}
				}
			}

			//This method returns a number of characters, including :\/*?
			foreach (char invalidChar in Path.GetInvalidFileNameChars())
				prefix = prefix.Replace(invalidChar, ' '); //replace invalid characters with spaces.

			return prefix.Trim();
		}
コード例 #13
0
        public void CreateVolume()
        {
            if (this.ImageViewer == null)
            {
                return;
            }

            if (this.ImageViewer.SelectedImageBox == null)
            {
                return;
            }

            IDisplaySet             selectedDisplaySet = this.ImageViewer.SelectedImageBox.DisplaySet;
            VolumePresentationImage image = new VolumePresentationImage(selectedDisplaySet);

            AddTissueLayers(image);

            IDisplaySet displaySet = new DisplaySet(String.Format("{0} (3D)", selectedDisplaySet.Name), String.Format("VTK.{0}", Guid.NewGuid().ToString()));

            displaySet.PresentationImages.Add(image);
            this.ImageViewer.LogicalWorkspace.ImageSets[0].DisplaySets.Add(displaySet);

            IImageBox imageBox = this.ImageViewer.SelectedImageBox;

            imageBox.DisplaySet = displaySet;
            imageBox.Draw();
            imageBox[0, 0].Select();

            NotifyAllPropertiesChanged();
        }
コード例 #14
0
ファイル: ImageSet.cs プロジェクト: ronmark1/ClearCanvas-1
 internal void RemoveCopy(IDisplaySet copy)
 {
     if (_displaySetCopies != null)
     {
         _displaySetCopies.Remove(copy);
     }
 }
コード例 #15
0
            internal ThumbnailGalleryItem(ThumbnailGalleryItemFactory factory, IDisplaySet displaySet, NameAndDescriptionFormat nameAndDescriptionFormat)
                : base(displaySet)
            {
                _factory = factory;

                switch (nameAndDescriptionFormat)
                {
                case NameAndDescriptionFormat.NameAndDescription:
                    Name        = GetDisplaySetName(displaySet);
                    Description = GetDisplaySetDescription(displaySet);
                    break;

                case NameAndDescriptionFormat.NoDescription:
                    Name = GetDisplaySetName(displaySet);
                    break;

                case NameAndDescriptionFormat.VerboseNameNoDescription:
                    Name = GetDisplaySetDescription(displaySet);
                    break;

                case NameAndDescriptionFormat.VerboseNameAndDescription:
                    Name = Description = GetDisplaySetDescription(displaySet);
                    break;
                }
            }
コード例 #16
0
        private bool IsKeyImageDisplaySet(IDisplaySet displaySet)
        {
            if (displaySet == null || displaySet.PresentationImages.Count == 0)
            {
                return(false);
            }

            var descriptor = displaySet.Descriptor as IDicomDisplaySetDescriptor;

            if (descriptor == null)
            {
                return(false);
            }

            const string koModality = "KO";

            if (descriptor.SourceSeries != null && descriptor.SourceSeries.Modality == koModality)
            {
                return(true);
            }

            var allImagesDescriptor = descriptor as ModalityDisplaySetDescriptor;

            return(allImagesDescriptor != null && allImagesDescriptor.Modality == koModality);
        }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of <see cref="DisplaySetChangingEventArgs"/>.
 /// </summary>
 public DisplaySetChangingEventArgs(
     IDisplaySet currentDisplaySet,
     IDisplaySet newDisplaySet)
 {
     _currentDisplaySet = currentDisplaySet;
     _newDisplaySet     = newDisplaySet;
 }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of <see cref="DisplaySetChangedEventArgs"/>.
 /// </summary>
 public DisplaySetChangedEventArgs(
     IDisplaySet oldDisplaySet,
     IDisplaySet newDisplaySet)
 {
     _oldDisplaySet = oldDisplaySet;
     _newDisplaySet = newDisplaySet;
 }
コード例 #19
0
ファイル: ImageBoxMemento.cs プロジェクト: hksonngan/Xian
        public ImageBoxMemento(
            IDisplaySet displaySet,
            bool displaySetLocked,
            object displaySetMemento,
            int rows,
            int columns,
            int topLeftPresentationImageIndex,
            RectangleF normalizedRectangle,
            int indexOfSelectedTile)
        {
            // displaySet can be null, as that would correspond to an
            // empty imageBox
            Platform.CheckNonNegative(rows, "rows");
            Platform.CheckNonNegative(columns, "columns");
            Platform.CheckNonNegative(_topLeftPresentationImageIndex, "_topLeftPresentationImageIndex");

            _displaySet        = displaySet;
            _displaySetLocked  = displaySetLocked;
            _displaySetMemento = displaySetMemento;
            _rows    = rows;
            _columns = columns;
            _topLeftPresentationImageIndex = topLeftPresentationImageIndex;
            _normalizedRectangle           = normalizedRectangle;
            _indexOfSelectedTile           = indexOfSelectedTile;
        }
コード例 #20
0
        public static IPresentationImage PresentationImageFromPositionOrientation(
            double[] imagePositionPatientValues,
            double[] imageOrientationPatientValues,
            IDisplaySet displaySet,
            string frameOfReferenceUid)
        {
            Platform.CheckForNullReference(displaySet, "displaySet");

            if (imagePositionPatientValues != null && imagePositionPatientValues.Length > 2 &&
                imageOrientationPatientValues != null && imageOrientationPatientValues.Length > 5)
            {
                var imagePositionPatient = new ImagePositionPatient(
                    imagePositionPatientValues[0],
                    imagePositionPatientValues[1],
                    imagePositionPatientValues[2]);
                var imageOrientationPatient = new ImageOrientationPatient(
                    imageOrientationPatientValues[0],
                    imageOrientationPatientValues[1],
                    imageOrientationPatientValues[2],
                    imageOrientationPatientValues[3],
                    imageOrientationPatientValues[4],
                    imageOrientationPatientValues[5]);

                return(PresentationImageFromPositionOrientation(
                           imagePositionPatient,
                           imageOrientationPatient,
                           displaySet,
                           frameOfReferenceUid));
            }

            return(null);
        }
コード例 #21
0
        /// <summary>
        /// Compares two <see cref="IDisplaySet"/>s.
        /// </summary>
        public override int Compare(IDisplaySet x, IDisplaySet y)
        {
            if (x.PresentationImages.Count == 0 || y.PresentationImages.Count == 0)
            {
                return(0);
            }

            IImageSopProvider provider1 = x.PresentationImages[0] as IImageSopProvider;
            IImageSopProvider provider2 = y.PresentationImages[0] as IImageSopProvider;

            if (provider1 == null)
            {
                if (provider2 == null)
                {
                    return(0);                    // x == y
                }
                else
                {
                    return(-ReturnValue);                    // x > y (because we want it at the end for non-reverse sorting)
                }
            }
            else
            {
                if (provider2 == null)
                {
                    return(ReturnValue);                    // x < y (because we want it at the end for non-reverse sorting)
                }
            }

            return(Compare(provider1.ImageSop, provider2.ImageSop));
        }
コード例 #22
0
ファイル: Clipboard.cs プロジェクト: nhannd/Xian
		/// <summary>
		/// Adds an <see cref="IDisplaySet"/> to the clipboard.
		/// </summary>
		/// <param name="displaySet"></param>
		/// <param name="selectionStrategy"></param>
		/// <remarks>
		/// When called, a copy of the specified <see cref="IPresentationImage"/>s
		/// (as determined by the <paramref name="selectionStrategy"/>) is made and stored
		/// in the clipbaord.  This ensures that the <see cref="IPresentationImage"/> is in fact a
		/// snapshot and not a reference that could be changed in unpredictable ways.
		/// Pixel data, however, is not replicated.
		/// </remarks>
		public static void Add(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy)
		{
			Platform.CheckForNullReference(displaySet, "displaySet");
			Platform.CheckForNullReference(selectionStrategy, "selectionStrategy");

			Items.Add(ClipboardComponent.CreateDisplaySetItem(displaySet, selectionStrategy));
		}
コード例 #23
0
        private void SynchronizeNewDisplaySet(IDisplaySet newDisplaySet)
        {
            if (!SynchronizeActive || newDisplaySet == null)
            {
                return;
            }

            IImageBox changedImageBox  = newDisplaySet.ImageBox;
            IImageBox selectedImageBox = this.Context.Viewer.SelectedImageBox;

            if (selectedImageBox == null || selectedImageBox == changedImageBox)
            {
                // if there is no selected image box or the new one is selected, try
                // to sync it up with the other ones.

                // Do a reverse synchronization; sync the newly selected one with all the others.
                foreach (IImageBox imageBox in GetTargetImageBoxes(changedImageBox))
                {
                    if (imageBox != selectedImageBox)
                    {
                        SynchronizeImageBox(imageBox, changedImageBox);
                    }
                }
            }
            else
            {
                SynchronizeImageBox(selectedImageBox, changedImageBox);
            }
        }
コード例 #24
0
ファイル: OverlayToolBase.cs プロジェクト: hksonngan/Xian
 protected virtual void UpdateVisibility(IDisplaySet displaySet, bool visible)
 {
     foreach (var image in displaySet.PresentationImages)
     {
         UpdateVisibility(image, visible);
     }
 }
コード例 #25
0
        /// <summary>
        /// Adds an <see cref="IDisplaySet"/> to the clipboard.
        /// </summary>
        /// <param name="displaySet"></param>
        /// <param name="selectionStrategy"></param>
        /// <remarks>
        /// When called, a copy of the specified <see cref="IPresentationImage"/>s
        /// (as determined by the <paramref name="selectionStrategy"/>) is made and stored
        /// in the clipbaord.  This ensures that the <see cref="IPresentationImage"/> is in fact a
        /// snapshot and not a reference that could be changed in unpredictable ways.
        /// Pixel data, however, is not replicated.
        /// </remarks>
        public static void Add(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy)
        {
            Platform.CheckForNullReference(displaySet, "displaySet");
            Platform.CheckForNullReference(selectionStrategy, "selectionStrategy");

            Items.Add(ClipboardComponent.CreateDisplaySetItem(displaySet, selectionStrategy));
        }
コード例 #26
0
        public void TestSeriesSplittingMREcho()
        {
            const int             numberOfSeries     = 5;
            const int             instancesPerSeries = 10;
            List <TestDataSource> dataSources        = CreateMRStudyDataSources(numberOfSeries, instancesPerSeries, "1.2.3");
            StudyTree             studyTree          = CreateStudyTree(ConvertToSops(dataSources));

            MREchoDisplaySetFactory factory = new MREchoDisplaySetFactory();

            factory.SetStudyTree(studyTree);
            List <IDisplaySet> allDisplaySets = new List <IDisplaySet>();

            try
            {
                Patient patient = studyTree.Patients[0];
                Study   study   = patient.Studies[0];

                Assert.AreEqual(numberOfSeries, study.Series.Count, "There should be exactly {0} series", numberOfSeries);

                Series series2 = study.Series[1];
                Series series3 = study.Series[2];

                MakeEchoSeries(series2);
                MakeEchoSeries(series3);

                foreach (Series series in study.Series)
                {
                    Assert.AreEqual(instancesPerSeries, series.Sops.Count, "There should be exactly {0} sops", instancesPerSeries);
                    List <IDisplaySet> displaySets = factory.CreateDisplaySets(series);
                    allDisplaySets.AddRange(displaySets);

                    if (series == series2 || series == series3)
                    {
                        IDisplaySet displaySet = displaySets[0];
                        Assert.AreEqual(2, displaySets.Count, "There should be exactly 2 display sets");
                        Assert.AreEqual(series.Sops.Count / 2, displaySet.PresentationImages.Count, "#presentation images should be #Sops/2");
                        Assert.AreNotEqual(series.SeriesInstanceUid, displaySet.Descriptor.Uid, "Series UID and Display Set UID don't match");
                        Assert.AreEqual(typeof(MREchoDisplaySetDescriptor), displaySet.Descriptor.GetType(), "Wrong display set descriptor type");
                        Assert.IsTrue(displaySet.Name.Contains("Echo"), "Display Set name not correct");

                        ValidateEchoDisplaySet(displaySets[0], 1);
                        ValidateEchoDisplaySet(displaySets[1], 2);
                    }
                    else
                    {
                        Assert.AreEqual(0, displaySets.Count, "There should be no display sets");
                    }
                }
            }
            finally
            {
                foreach (IDisplaySet displaySet in allDisplaySets)
                {
                    displaySet.Dispose();
                }

                studyTree.Dispose();
            }
        }
コード例 #27
0
        protected override void OnPresentationImageSelected(object sender, PresentationImageSelectedEventArgs e)
        {
            base.OnPresentationImageSelected(sender, e);
            IPresentationImage selectedPresentationImage = base.SelectedPresentationImage;
            IDisplaySet        set = (selectedPresentationImage != null) ? selectedPresentationImage.ParentDisplaySet : null;

            base.Enabled = set != null;
        }
コード例 #28
0
 private static IPresentationImage GetMiddlePresentationImage(IDisplaySet displaySet)
 {
     if (displaySet.PresentationImages.Count == 0)
     {
         throw new ArgumentException("The display set must contain at least one image.");
     }
     return(displaySet.PresentationImages[(displaySet.PresentationImages.Count - 1) / 2]);
 }
コード例 #29
0
ファイル: Clipboard.cs プロジェクト: ronmark1/ClearCanvas-1
        /// <summary>
        /// Adds an <see cref="IDisplaySet"/> to the clipboard.
        /// </summary>
        /// <param name="displaySet"></param>
        /// <remarks>
        /// When called, a copy of the specified <see cref="IDisplaySet"/> is made and stored
        /// in the clipbaord.  This ensures that the <see cref="IDisplaySet"/> is in fact a
        /// snapshot and not a reference that could be changed in unpredictable ways.
        /// Pixel data, however, is not replicated.
        /// </remarks>
        public static void Add(IDisplaySet displaySet)
        {
            Platform.CheckForNullReference(displaySet, "displaySet");

            var clipboard = Default;

            clipboard._items.Add(clipboard.CreateDisplaySetItem(displaySet));
        }
コード例 #30
0
 protected virtual IArgumentHintResolver BuildArgumentHints(IDisplaySet displaySet)
 {
     if (displaySet == null)
     {
         return(new ArgumentHintResolver());
     }
     return(BuildArgumentHints(displaySet.PresentationImages));
 }
コード例 #31
0
		internal static string BuildMessage(IDisplaySet sourceDisplaySet)
		{
			string message = "An error has occurred while attempting to clone a display set";
			if (!String.IsNullOrEmpty(sourceDisplaySet.Name))
				message += string.Format(" (name = {0})", sourceDisplaySet.Name);
			
			message += ".";
			return message;
		}
コード例 #32
0
ファイル: Clipboard.cs プロジェクト: ronmark1/ClearCanvas-1
        /// <summary>
        /// Adds an <see cref="IDisplaySet"/> to the clipboard.
        /// </summary>
        /// <param name="displaySet"></param>
        /// <param name="selectionStrategy"></param>
        /// <remarks>
        /// When called, a copy of the specified <see cref="IPresentationImage"/>s
        /// (as determined by the <paramref name="selectionStrategy"/>) is made and stored
        /// in the clipbaord.  This ensures that the <see cref="IPresentationImage"/> is in fact a
        /// snapshot and not a reference that could be changed in unpredictable ways.
        /// Pixel data, however, is not replicated.
        /// </remarks>
        public static void Add(IDisplaySet displaySet, IImageSelectionStrategy selectionStrategy)
        {
            Platform.CheckForNullReference(displaySet, "displaySet");
            Platform.CheckForNullReference(selectionStrategy, "selectionStrategy");

            var clipboard = Default;

            clipboard._items.Add(clipboard.CreateDisplaySetItem(displaySet, selectionStrategy));
        }
コード例 #33
0
		internal static string BuildMessage(IDisplaySet sourceDisplaySet)
		{
			string message = "An error has occurred while attempting to clone a display set";
			if (!String.IsNullOrEmpty(sourceDisplaySet.Name))
				message += string.Format(" (name = {0})", sourceDisplaySet.Name);
			
			message += ".";
			return message;
		}
コード例 #34
0
 private IEnumerable <IPresentationImage> GetAllLinkedImages(IDisplaySet displaySet)
 {
     foreach (IPresentationImage image in displaySet.LinkedPresentationImages)
     {
         if (image != _referenceImage)
         {
             yield return(image);
         }
     }
 }
コード例 #35
0
        private static int Enqueue(ICollection <IPresentationImage> queue, IDisplaySet dSet)
        {
            int count = 0;

            foreach (IPresentationImage pImage in dSet.PresentationImages)
            {
                count += Enqueue(queue, pImage);
            }
            return(count);
        }
コード例 #36
0
        public static void Create(IDesktopWindow desktopWindow, IImageViewer viewer)
        {
            IDisplaySet selectedDisplaySet = viewer.SelectedImageBox.DisplaySet;
            string      name         = String.Format("{0} - Dynamic TE", selectedDisplaySet.Name);
            IDisplaySet t2DisplaySet = new DisplaySet(name, "");

            double currentSliceLocation = 0.0;

            BackgroundTask task = new BackgroundTask(
                delegate(IBackgroundTaskContext context)
            {
                int i = 0;

                foreach (IPresentationImage image in selectedDisplaySet.PresentationImages)
                {
                    IImageSopProvider imageSopProvider = image as IImageSopProvider;

                    if (imageSopProvider == null)
                    {
                        continue;
                    }

                    ImageSop imageSop = imageSopProvider.ImageSop;
                    Frame frame       = imageSopProvider.Frame;

                    if (frame.SliceLocation != currentSliceLocation)
                    {
                        currentSliceLocation = frame.SliceLocation;

                        try
                        {
                            DynamicTePresentationImage t2Image = CreateT2Image(imageSop, frame);
                            t2DisplaySet.PresentationImages.Add(t2Image);
                        }
                        catch (Exception e)
                        {
                            Platform.Log(LogLevel.Error, e);
                            desktopWindow.ShowMessageBox("Unable to create T2 series.  Please check the log for details.",
                                                         MessageBoxActions.Ok);
                            break;
                        }
                    }

                    string message = String.Format("Processing {0} of {1} images", i, selectedDisplaySet.PresentationImages.Count);
                    i++;

                    BackgroundTaskProgress progress = new BackgroundTaskProgress(i, selectedDisplaySet.PresentationImages.Count, message);
                    context.ReportProgress(progress);
                }
            }, false);

            ProgressDialog.Show(task, desktopWindow, true, ProgressBarStyle.Blocks);

            viewer.LogicalWorkspace.ImageSets[0].DisplaySets.Add(t2DisplaySet);
        }
コード例 #37
0
ファイル: BuildTreeTest.cs プロジェクト: nhannd/Xian
		private void CreateObjects()
		{
			_viewer = new ImageViewerComponent();
			_imageBox = new ImageBox();
			_tile1 = new Tile();
			_tile2 = new Tile();

			_imageSet = new ImageSet();
			_displaySet = new DisplaySet();
			_image1 = new TestPresentationImage();
			_image2 = new TestPresentationImage();
		}
コード例 #38
0
		public IEnumerable<ImageFileNamePair> GetImagesAndFileNames(IDisplaySet displaySet, string fileExtension)
		{
			string displaySetDirectory = GetDisplaySetDirectory(displaySet, _baseDirectory);
			Directory.CreateDirectory(displaySetDirectory);

			int numberOfZeroes = displaySet.PresentationImages.Count.ToString().Length;

			int startNumber = 1;
			foreach(IPresentationImage image in displaySet.PresentationImages)
			{
				string filePath = GetImageFileName(displaySetDirectory, "Image", fileExtension, numberOfZeroes, ref startNumber);
				yield return new ImageFileNamePair(image, filePath);
			}
		}
コード例 #39
0
ファイル: VolumeLoader.cs プロジェクト: UIKit0/ClearCanvas
		public static Volume Create(IDisplaySet displaySet, CreateVolumeProgressCallback callback)
		{
			Platform.CheckForNullReference(displaySet, "displaySet");
			List<Frame> frames = new List<Frame>();

			foreach (IPresentationImage image in displaySet.PresentationImages)
			{
				IImageSopProvider imageSopProvider = image as IImageSopProvider;
				if (imageSopProvider == null)
					throw new ArgumentException("Images must be valid IImageSopProviders.");
				frames.Add(imageSopProvider.Frame);
			}
			return Create(frames, callback);
		}
コード例 #40
0
		/// <summary>
		/// Compares two <see cref="IDisplaySet"/>s.
		/// </summary>
		public override int Compare(IDisplaySet x, IDisplaySet y)
		{
			DisplaySet displaySet1 = x as DisplaySet;
			DisplaySet displaySet2 = y as DisplaySet;
			
			if (ReferenceEquals(displaySet1, displaySet2))
				return 0; //same object or both are null

			//at this point, at least one of x or y is non-null and they are not the same object

			if (displaySet1 == null)
				return -ReturnValue; // x > y (because we want x at the end for non-reverse sorting)
			if (displaySet2 == null)
				return ReturnValue; // x < y (because we want y at the end for non-reverse sorting)

			return base.Compare(GetCompareValues(displaySet1), GetCompareValues(displaySet2));
		}
コード例 #41
0
ファイル: TestTree.cs プロジェクト: m-berkani/ClearCanvas
		public TestTree()
		{
			_viewer = new ImageViewerComponent();

			_imageBox1 = new ImageBox();
			_imageBox2 = new ImageBox();

			_tile1 = new Tile();
			_tile2 = new Tile();
			_tile3 = new Tile();
			_tile4 = new Tile();

			_imageSet1 = new ImageSet();

			_displaySet1 = new DisplaySet();
			_displaySet2 = new DisplaySet();

			_image1 = new TestPresentationImage();
			_image2 = new TestPresentationImage();
			_image3 = new TestPresentationImage();
			_image4 = new TestPresentationImage();

			_viewer.PhysicalWorkspace.ImageBoxes.Add(_imageBox1);
			_viewer.PhysicalWorkspace.ImageBoxes.Add(_imageBox2);

			_imageBox1.Tiles.Add(_tile1);
			_imageBox1.Tiles.Add(_tile2);
			_imageBox2.Tiles.Add(_tile3);
			_imageBox2.Tiles.Add(_tile4);

			_viewer.LogicalWorkspace.ImageSets.Add(_imageSet1);

			_imageSet1.DisplaySets.Add(_displaySet1);
			_imageSet1.DisplaySets.Add(_displaySet2);

			_displaySet1.PresentationImages.Add(_image1);
			_displaySet1.PresentationImages.Add(_image2);
			_displaySet2.PresentationImages.Add(_image3);
			_displaySet2.PresentationImages.Add(_image4);

			_imageBox1.DisplaySet = _displaySet1;
			_imageBox2.DisplaySet = _displaySet2;
		}
コード例 #42
0
		private static ModalityOverlayStates GetDefaultOverlayStates(IDisplaySet displaySet)
		{
			if (displaySet == null)
				return GetDefaultOverlayStates();

			var data = GetDefaultOverlayStates(displaySet.ImageViewer);
			if (data != null)
				return data;

			//Cache all the per-modality defaults in the display set so it can be looked up fast for its images.
			data = displaySet.ExtensionData[typeof (Key)] as ModalityOverlayStates;
			if (data == null)
			{
				data = GetDefaultOverlayStates();
				displaySet.ExtensionData[typeof (Key)] = data;
			}

			return data;
		}
コード例 #43
0
			internal static void AssignDisplaySetToImageBox(IImageBox imageBox, IDisplaySet displaySet)
			{
                MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
                memorableCommand.BeginState = imageBox.CreateMemento();

                // always create a 'fresh copy' to show in the image box.  We never want to show
                // the 'originals' (e.g. the ones in IImageSet.DisplaySets) because we want them 
                // to remain clean and unaltered - consider them to be templates for what actually
                // gets shown.
                imageBox.DisplaySet = displaySet.CreateFreshCopy();

                imageBox.Draw();
                //this.ImageViewer.SelectedImageBox[0, 0].Select();

                memorableCommand.EndState = imageBox.CreateMemento();

                DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
                historyCommand.Enqueue(memorableCommand);
                imageBox.ImageViewer.CommandHistory.AddCommand(historyCommand);
            }
コード例 #44
0
ファイル: IconCreator.cs プロジェクト: nhannd/Xian
		public static Bitmap CreateDisplaySetIcon(IDisplaySet displaySet, Rectangle displayedClientRectangle)
		{
			Bitmap bmp = new Bitmap(_iconWidth, _iconHeight);
			int numImages = 3;
			float aspectRatio = _iconHeight / (float)_iconWidth;
			int offsetX = 10;
			int offsetY = (int)(aspectRatio * offsetX);
			int subIconWidth = _iconWidth - ((numImages - 1) * offsetX);
			int subIconHeight = (int)(aspectRatio * subIconWidth);

			System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);

			int dimension = Math.Max(displayedClientRectangle.Width, displayedClientRectangle.Height);

			IPresentationImage image = GetMiddlePresentationImage(displaySet);

			// rendered twice to rasterize the invariant text first and then downsample to icon size
			Bitmap img = DrawToIcon(image, dimension, (int)(dimension * aspectRatio));
			Bitmap iconBmp = new Bitmap(img, subIconWidth, subIconHeight);
			img.Dispose();

			Pen pen = new Pen(Color.DarkGray);

			g.Clear(Color.Black);

			for (int i = 0; i < numImages; i++)
			{
				int x = offsetX * ((numImages - 1) - i);
				int y = offsetY * i;


				g.DrawImage(iconBmp, new Point(x, y));
				g.DrawRectangle(pen, x, y, subIconWidth - 1, subIconHeight - 1);
			}

			pen.Dispose();
			iconBmp.Dispose();
			g.Dispose();

			return bmp;
		}
コード例 #45
0
ファイル: ThumbnailGalleryItem.cs プロジェクト: nhannd/Xian
            internal ThumbnailGalleryItem(ThumbnailGalleryItemFactory factory, IDisplaySet displaySet, NameAndDescriptionFormat nameAndDescriptionFormat)
                : base(displaySet)
            {
                _factory = factory;

                switch (nameAndDescriptionFormat)
                {
                    case NameAndDescriptionFormat.NameAndDescription:
                        Name = GetDisplaySetName(displaySet);
                        Description = GetDisplaySetDescription(displaySet);
                        break;
                    case NameAndDescriptionFormat.NoDescription:
                        Name = GetDisplaySetName(displaySet);
                        break;
                    case NameAndDescriptionFormat.VerboseNameNoDescription:
                        Name = GetDisplaySetDescription(displaySet);
                        break;
                    case NameAndDescriptionFormat.VerboseNameAndDescription:
                        Name = Description = GetDisplaySetDescription(displaySet);
                        break;
                }
            }
コード例 #46
0
            internal ThumbnailGalleryItem(ThumbnailGalleryItemFactory factory, IDisplaySet displaySet, NameAndDescriptionFormat nameAndDescriptionFormat, bool suppressLoadingThumbnails)
                : base(displaySet)
            {
                _factory = factory;
                _suppressLoadingImage = suppressLoadingThumbnails;

                switch (nameAndDescriptionFormat)
                {
                    case NameAndDescriptionFormat.NameAndDescription:
                        Name = GetDisplaySetName(displaySet);
                        Description = GetDisplaySetDescription(displaySet);
                        break;
                    case NameAndDescriptionFormat.NoDescription:
                        Name = GetDisplaySetName(displaySet);
                        break;
                    case NameAndDescriptionFormat.VerboseNameNoDescription:
                        Name = GetDisplaySetDescription(displaySet);
                        break;
                    case NameAndDescriptionFormat.VerboseNameAndDescription:
                        Name = Description = GetDisplaySetDescription(displaySet);
                        break;
                }
            }
コード例 #47
0
ファイル: DisplaySetFactoryTests.cs プロジェクト: nhannd/Xian
		private void ValidateEchoDisplaySet(IDisplaySet displaySet, int echoNumber)
		{
			string seriesInstanceUid = null;
			foreach (IPresentationImage presentationImage in displaySet.PresentationImages)
			{
				ImageSop sop = ((IImageSopProvider)presentationImage).ImageSop;
				seriesInstanceUid = sop.SeriesInstanceUid;
				Assert.AreEqual(echoNumber, sop[DicomTags.EchoNumbers].GetUInt32(0, 0), "Echo number must be {0} for each image in the series", echoNumber);
			}

			Assert.IsNotNull(seriesInstanceUid);
			Assert.AreEqual(String.Format("{0}:Echo{1}", seriesInstanceUid, echoNumber), displaySet.Uid);
		}
コード例 #48
0
ファイル: MultipleImageExporter.cs プロジェクト: nhannd/Xian
			private void ExportDisplaySet(IDisplaySet displaySet, ExportImageParams exportParams)
			{
				foreach (ImageFileNamePair pair in _fileNamingStrategy.GetImagesAndFileNames(displaySet, FileExtension))
				{
					if (IsAsynchronous && _taskContext.CancelRequested)
						break;

					IPresentationImage image = GetImageForExport(pair.Image);
					SelectedImageExporter.Export(image, pair.FileName, exportParams);

					ReportProgress(pair.FileName, ++_progress);
				}
			}
コード例 #49
0
		    internal static void AssignDisplaySetToImageBox(IImageViewer viewer, IDisplaySet displaySet)
			{
                AssignDisplaySetToImageBox(viewer.SelectedImageBox, displaySet);
			}
コード例 #50
0
		public VolumePresentationImage(IDisplaySet displaySet)
		{
			_displaySet = displaySet;

			ValidateSliceData();
		}
コード例 #51
0
 private static int Enqueue(ICollection<IPresentationImage> queue, IDisplaySet dSet)
 {
     int count = 0;
     foreach (IPresentationImage pImage in dSet.PresentationImages)
     {
         count += Enqueue(queue, pImage);
     }
     return count;
 }
コード例 #52
0
			public IEnumerable<IPresentationImage> GetImages(IDisplaySet displaySet)
			{
				List<IPresentationImage> images = new List<IPresentationImage>();

				if (_useInstanceNumbers)
				{
					foreach (IPresentationImage image in displaySet.PresentationImages)
					{
						if (!images.Contains(image))
						{
							if (image is IImageSopProvider)
							{
								int instanceNumber = ((IImageSopProvider)image).ImageSop.InstanceNumber;
								foreach (Range range in _ranges)
								{
									if (instanceNumber >= range.Start && instanceNumber <= range.End)
										images.Add(image);
								}
							}
						}
					}
				}
				else
				{
					foreach (Range range in _ranges)
					{
						for (int j = range.Start - 1; j <= range.End - 1; ++j)
						{
							if (j >= displaySet.PresentationImages.Count)
								break;

							if (!images.Contains(displaySet.PresentationImages[j]))
								images.Add(displaySet.PresentationImages[j]);
						}
					}
				}

				return images;
			}
コード例 #53
0
ファイル: Clipboard.cs プロジェクト: UIKit0/ClearCanvas
		/// <summary>
		/// Adds an <see cref="IDisplaySet"/> to the clipboard.
		/// </summary>
		/// <param name="displaySet"></param>
		/// <remarks>
		/// When called, a copy of the specified <see cref="IDisplaySet"/> is made and stored
		/// in the clipbaord.  This ensures that the <see cref="IDisplaySet"/> is in fact a
		/// snapshot and not a reference that could be changed in unpredictable ways.
		/// Pixel data, however, is not replicated.
		/// </remarks>
		public static void Add(IDisplaySet displaySet)
		{
			Platform.CheckForNullReference(displaySet, "displaySet");

			Items.Add(ClipboardComponent.CreateDisplaySetItem(displaySet));
		}
コード例 #54
0
		private static string GetDisplaySetDirectory(IDisplaySet displaySet, string baseDirectory)
		{
			string prefix = GetDisplaySetDirectoryPrefix(displaySet);

			int i = 0;
			string directory = prefix;

			while (true)
			{
				string path = String.Format("{0}\\{1}", baseDirectory, directory);
				if (!Directory.Exists(path))
					return path;

				directory = string.Format("{0}{1}", prefix, ++i);
			}
		}
コード例 #55
0
ファイル: DisplaySet.cs プロジェクト: m-berkani/ClearCanvas
			public DisplaySetMemento(IDisplaySet displaySet)
			{
				Comparer = displaySet.PresentationImages.SortComparer;
			}
コード例 #56
0
ファイル: VolumeBuilder.cs プロジェクト: tcchau/ClearCanvas
		/// <summary>
		/// Validates the specified display set as suitable source data for <see cref="Volume"/>.
		/// </summary>
		/// <param name="displaySet">The display set to validate.</param>
		/// <exception cref="ArgumentNullException">Thrown if the parameter was NULL.</exception>
		/// <exception cref="CreateVolumeException">Thrown if the specified source data is not suitable for creating a <see cref="Volume"/>.</exception>
		public static void Validate(IDisplaySet displaySet)
		{
			Platform.CheckForNullReference(displaySet, "displaySet");
			Validate(displaySet.PresentationImages.Cast<IImageSopProvider>().Select(i => i.Frame));
		}
コード例 #57
0
		internal DisplaySetCloningException(IDisplaySet sourceDisplaySet, Exception innerException)
			: base(BuildMessage(sourceDisplaySet), innerException)
		{

		}
コード例 #58
0
ファイル: LaunchMprTool.cs プロジェクト: nhannd/Xian
		private void UpdateEnabled(IDisplaySet selectedDisplaySet)
		{
			base.Enabled = selectedDisplaySet != null && selectedDisplaySet.PresentationImages.Count > 1;
		}
コード例 #59
0
ファイル: LaunchMprTool.cs プロジェクト: nhannd/Xian
		private static IEnumerable<Frame> FilterSourceFrames(IDisplaySet displaySet, IPresentationImage currentImage)
		{
			// this method tries to filter the source display set based on the currently selected image before passing it to MPR
			// we need this because sometimes MPR-able content is found in a series concatenated with other frames (e.g. 3-plane loc)
			if (currentImage is IImageSopProvider)
			{
				Frame currentFrame = ((IImageSopProvider) currentImage).Frame;
				string studyInstanceUid = currentFrame.StudyInstanceUid;
				string seriesInstanceUid = currentFrame.SeriesInstanceUid;
				string frameOfReferenceUid = currentFrame.FrameOfReferenceUid;
				ImageOrientationPatient imageOrientationPatient = currentFrame.ImageOrientationPatient;

				// if the current frame is missing any of the matching parameters, then it is always an error
				if (string.IsNullOrEmpty(studyInstanceUid) || string.IsNullOrEmpty(seriesInstanceUid))
					throw new NullSourceSeriesException();
				if (string.IsNullOrEmpty(frameOfReferenceUid))
					throw new NullFrameOfReferenceException();
				if (imageOrientationPatient == null || imageOrientationPatient.IsNull)
				{
					if (currentFrame.ParentImageSop.NumberOfFrames > 1)
						throw new UnsupportedMultiFrameSourceImagesException(new NullImageOrientationException());
					throw new NullImageOrientationException();
				}

				// if the current frame is not a supported pixel format, then it is always an error
				if (currentFrame.BitsAllocated != 16)
					throw new UnsupportedPixelFormatSourceImagesException();

				// perform a very basic filtering of the selected display set based on the currently selected image
				var filteredFrames = new List<Frame>();
				foreach (IPresentationImage image in displaySet.PresentationImages)
				{
					if (image == currentImage)
					{
						filteredFrames.Add(currentFrame);
					}
					else if (image is IImageSopProvider)
					{
						Frame frame = ((IImageSopProvider) image).Frame;
						if (frame.StudyInstanceUid == studyInstanceUid
						    && frame.SeriesInstanceUid == seriesInstanceUid
						    && frame.FrameOfReferenceUid == frameOfReferenceUid
						    && !frame.ImageOrientationPatient.IsNull
						    && frame.ImageOrientationPatient.EqualsWithinTolerance(imageOrientationPatient, .01f))
							filteredFrames.Add(frame);
					}
				}

				// if we found at least 3 frames matching the current image, then return those to MPR
				if (filteredFrames.Count > 3)
					return filteredFrames;

				// JY: #6164 - Error message not accurate for MPR with no location information
				// if we don't find 3 matching frames, then MPR fails on the minimum frames error
				// which masks the fact that there *were* enough frames, just not enough frames matching some aspect filter criteria
				// we don't know what was the specific failed criterion, so we'll just pass all frames unfiltered
				// this lets MPR decide what's wrong with the display set here and throw the correct exception
				return CollectionUtils.Map<IPresentationImage, Frame>(displaySet.PresentationImages, img => img is IImageSopProvider ? ((IImageSopProvider) img).Frame : null);
			}
			else
			{
				throw new UnsupportedSourceImagesException();
			}
		}
コード例 #60
0
ファイル: IconCreator.cs プロジェクト: m-berkani/ClearCanvas
		private static IPresentationImage GetMiddlePresentationImage(IDisplaySet displaySet)
		{
			if (displaySet.PresentationImages.Count == 0)
				throw new ArgumentException("The display set must contain at least one image.");

			if (displaySet.PresentationImages.Count <= 2)
				return displaySet.PresentationImages[0];

			return displaySet.PresentationImages[displaySet.PresentationImages.Count/2];
		}