Ejemplo n.º 1
0
        void IStack.StackTo(int instanceNumber, int?frameNumber)
        {
            if (Context.Viewer.SelectedTile == null)
            {
                throw new InvalidOperationException("No tile selected.");
            }

            if (this.SelectedPresentationImage == null)
            {
                throw new InvalidOperationException("No image selected.");
            }

            var displaySet = Context.Viewer.SelectedPresentationImage.ParentDisplaySet;

            //First will throw if no such image exists.
            var image = (IPresentationImage)displaySet.PresentationImages.OfType <IImageSopProvider>().First(
                i => i.ImageSop.InstanceNumber == instanceNumber &&
                (!frameNumber.HasValue || (i.ImageSop.NumberOfFrames > 1 && frameNumber.Value == i.Frame.FrameNumber)));

            IImageBox imageBox = Context.Viewer.SelectedTile.ParentImageBox;

            CaptureBeginState(imageBox);
            imageBox.TopLeftPresentationImage = image;
            if (!CaptureEndState())
            {
                return;                 /// TODO (CR Dec 2011): Should we still select the top-left??
            }
            imageBox.Draw();
            imageBox.Tiles[0].Select();
        }
Ejemplo n.º 2
0
        private void Apply(IImageBox imageBox)
        {
            if (imageBox == null || imageBox.DisplaySet == null)
            {
                return;
            }

            //foreach (var presentationImage in imageBox.DisplaySet.PresentationImages.Where(i => i.GetModality() == ApplicableModality))

            foreach (var presentationImage in imageBox.DisplaySet.PresentationImages)
            {
                var imageOverlays = presentationImage.GetOverlays();
                foreach (var imageOverlay in imageOverlays)
                {
                    var source = Items.FirstOrDefault(i => i.Name == imageOverlay.Name);
                    if (source != null)
                    {
                        imageOverlay.IsSelected = source.IsSelected;
                    }

                    if (_parent.SelectedOverlaysVisible)
                    {
                        imageOverlay.ShowIfSelected();
                    }
                    else
                    {
                        imageOverlay.Hide();
                    }
                }
            }

            imageBox.Draw();
        }
Ejemplo n.º 3
0
        private void JumpToEnd()
        {
            if (Context.Viewer.SelectedTile == null)
            {
                return;
            }

            if (this.SelectedPresentationImage == null)
            {
                return;
            }

            IImageBox imageBox = Context.Viewer.SelectedTile.ParentImageBox;

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

            CaptureBeginState(imageBox);
            imageBox.TopLeftPresentationImageIndex = imageBox.DisplaySet.PresentationImages.Count - 1;
            if (CaptureEndState())
            {
                imageBox.Draw();
            }
        }
Ejemplo n.º 4
0
        public static void SetTileLayout(IImageViewer imageViewer, int rows, int columns)
        {
            Platform.CheckForNullReference(imageViewer, "imageViewer");
            Platform.CheckArgumentRange(rows, 1, LayoutSettings.MaximumTileRows, "rows");
            Platform.CheckArgumentRange(columns, 1, LayoutSettings.MaximumTileColumns, "columns");

            IImageBox imageBox = imageViewer.PhysicalWorkspace.SelectedImageBox;

            if (imageBox == null || imageBox.ParentPhysicalWorkspace.Locked)
            {
                return;
            }

            var memorableCommand = new MemorableUndoableCommand(imageBox)
            {
                BeginState = imageBox.CreateMemento()
            };

            int index = imageBox.TopLeftPresentationImageIndex;

            imageBox.SetTileGrid(rows, columns);
            imageBox.TopLeftPresentationImageIndex = index;
            imageBox.Draw();
            imageBox.SelectDefaultTile();

            memorableCommand.EndState = imageBox.CreateMemento();

            var historyCommand = new DrawableUndoableCommand(imageBox)
            {
                Name = SR.CommandLayoutTiles
            };

            historyCommand.Enqueue(memorableCommand);
            imageViewer.CommandHistory.AddCommand(historyCommand);
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
0
        private static void AdvanceImage(int increment, IImageBox selectedImageBox)
        {
            int prevTopLeftPresentationImageIndex = selectedImageBox.TopLeftPresentationImageIndex;

            selectedImageBox.TopLeftPresentationImageIndex += increment;

            if (selectedImageBox.TopLeftPresentationImageIndex != prevTopLeftPresentationImageIndex)
            {
                selectedImageBox.Draw();
            }
        }
Ejemplo n.º 7
0
        private static void UnselectCurrentGraphics(IImageBox imageBox)
        {
            if (imageBox == null)
            {
                return;
            }

            if (imageBox.TopLeftPresentationImage != null)
            {
                imageBox.TopLeftPresentationImage.SelectedGraphic = null;
                imageBox.Draw();
            }
        }
Ejemplo n.º 8
0
        private void JumpToBeginning()
        {
            if (Context.Viewer.SelectedTile == null)
            {
                return;
            }

            IImageBox imageBox = Context.Viewer.SelectedTile.ParentImageBox;

            CaptureBeginState(imageBox);
            imageBox.TopLeftPresentationImageIndex = 0;
            if (CaptureEndState())
            {
                imageBox.Draw();
            }
        }
Ejemplo n.º 9
0
            private static void Execute(IImageBox imageBox, object unexplodeMemento)
            {
                MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

                memorableCommand.BeginState = imageBox.CreateMemento();

                IDisplaySet        displaySet = imageBox.DisplaySet;
                IPresentationImage selectedImage;

                if (imageBox.SelectedTile != null)
                {
                    selectedImage = imageBox.SelectedTile.PresentationImage;
                }
                else
                {
                    selectedImage = imageBox.TopLeftPresentationImage;
                }

                imageBox.SetMemento(unexplodeMemento);

                //TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
                //This stuff with mementos is actually a hacky workaround.

                bool locked = imageBox.DisplaySetLocked;

                imageBox.DisplaySetLocked = false;
                imageBox.DisplaySet       = displaySet;
                imageBox.DisplaySetLocked = locked;

                if (selectedImage != null)
                {
                    imageBox.TopLeftPresentationImage = selectedImage;
                }

                imageBox.Draw();
                imageBox.SelectDefaultTile();

                memorableCommand.EndState = imageBox.CreateMemento();

                DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

                historyCommand.Name = SR.CommandExplodeTile;
                historyCommand.Enqueue(memorableCommand);
                imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);
            }
Ejemplo n.º 10
0
        private void AdvanceImage()
        {
            if (!_stopThread)
            {
                if (_memorableCommand == null)
                {
                    if (!CaptureBeginState())
                    {
                        StopCine();
                        return;
                    }
                }

                if (_reverse)
                {
                    if (_selectedImageBox.TopLeftPresentationImageIndex == 0)
                    {
                        _selectedImageBox.TopLeftPresentationImageIndex = _selectedImageBox.DisplaySet.PresentationImages.Count - 1;
                    }
                    else
                    {
                        --_selectedImageBox.TopLeftPresentationImageIndex;
                    }
                }
                else
                {
                    if (_selectedImageBox.TopLeftPresentationImageIndex == _selectedImageBox.DisplaySet.PresentationImages.Count - _selectedImageBox.Tiles.Count)
                    {
                        _selectedImageBox.TopLeftPresentationImageIndex = 0;
                    }
                    else
                    {
                        ++_selectedImageBox.TopLeftPresentationImageIndex;
                    }
                }

                _memorableCommand.EndState = _selectedImageBox.CreateMemento();
                _selectedImageBox.Draw();
            }

            lock (_threadLock)
            {
                Monitor.Pulse(_threadLock);
            }
        }
Ejemplo n.º 11
0
        public void AdvanceDisplaySet(int direction)
        {
            if (!Enabled)
            {
                return;
            }

            IDisplaySet sourceDisplaySet = GetSourceDisplaySet();

            if (sourceDisplaySet == null)
            {
                return;
            }

            IImageBox imageBox       = base.Context.Viewer.SelectedImageBox;
            IImageSet parentImageSet = sourceDisplaySet.ParentImageSet;

            int sourceDisplaySetIndex = parentImageSet.DisplaySets.IndexOf(sourceDisplaySet);

            sourceDisplaySetIndex += direction;

            if (sourceDisplaySetIndex < 0)
            {
                sourceDisplaySetIndex = parentImageSet.DisplaySets.Count - 1;
            }
            else if (sourceDisplaySetIndex >= parentImageSet.DisplaySets.Count)
            {
                sourceDisplaySetIndex = 0;
            }

            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

            memorableCommand.BeginState = imageBox.CreateMemento();

            imageBox.DisplaySet = parentImageSet.DisplaySets[sourceDisplaySetIndex].CreateFreshCopy();
            imageBox.Draw();

            memorableCommand.EndState = imageBox.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

            historyCommand.Enqueue(memorableCommand);
            base.Context.Viewer.CommandHistory.AddCommand(historyCommand);
        }
Ejemplo n.º 12
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);
            }
Ejemplo n.º 13
0
        private void Sort(ImageComparerList.Item item)
        {
            IImageBox   imageBox = ImageViewer.SelectedImageBox;
            IDisplaySet displaySet;

            if (imageBox == null || (displaySet = ImageViewer.SelectedImageBox.DisplaySet) == null)
            {
                return;
            }

            if (displaySet.PresentationImages.Count == 0)
            {
                return;
            }

            //try to keep the top-left image the same.
            IPresentationImage topLeftImage = imageBox.TopLeftPresentationImage;

            var command = new MemorableUndoableCommand(imageBox)
            {
                BeginState = imageBox.CreateMemento()
            };

            displaySet.PresentationImages.Sort(item.Comparer);
            imageBox.TopLeftPresentationImage = topLeftImage;
            imageBox.Draw();

            command.EndState = imageBox.CreateMemento();
            if (!command.BeginState.Equals(command.EndState))
            {
                var historyCommand = new DrawableUndoableCommand(imageBox)
                {
                    Name = SR.CommandSortImages
                };
                historyCommand.Enqueue(command);
                Context.Viewer.CommandHistory.AddCommand(historyCommand);
            }

            UpdateCheckState();
        }
            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);
            }
Ejemplo n.º 15
0
        private void ExplodeSelectedTile(IImageBox imageBox)
        {
            MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);

            memorableCommand.BeginState = imageBox.CreateMemento();

            //set this here so checked will be correct.
            object unexplodeMemento = memorableCommand.BeginState;

            _unexplodeCommands[imageBox] = new UnexplodeTileCommand(imageBox, unexplodeMemento, RemoveUnexplodeCommand);

            IDisplaySet        displaySet    = imageBox.DisplaySet;
            IPresentationImage selectedImage = imageBox.SelectedTile.PresentationImage;

            imageBox.SetTileGrid(1, 1);

            //TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
            //This stuff with mementos is actually a hacky workaround.

            bool locked = imageBox.DisplaySetLocked;

            imageBox.DisplaySetLocked = false;
            imageBox.DisplaySet       = displaySet;
            imageBox.DisplaySetLocked = locked;

            imageBox.TopLeftPresentationImage = selectedImage;

            memorableCommand.EndState = imageBox.CreateMemento();

            DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);

            historyCommand.Name = SR.CommandExplodeTile;
            historyCommand.Enqueue(memorableCommand);
            imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);

            imageBox.Draw();
            imageBox.SelectDefaultTile();
        }
Ejemplo n.º 16
0
        public void ShowImageWithAnnotation(string aimUid)
        {
            if (_activeViewer == null)
            {
                return;
            }

            // Find Annotation
            IAimAnnotationInstance annotationToShow = AvailableAnnotations.FirstOrDefault(annotation => annotation.UniqueIdentifier == aimUid);

            if (annotationToShow == null)
            {
                _activeViewer.DesktopWindow.ShowMessageBox("Could not locate annotation (UID = " + aimUid + ").", MessageBoxActions.Ok);
                return;
            }

            string studyInstanceUid;
            string seriesInstanceUid;
            string sopInstanceUid = null;
            int    frameNumber    = 1;

            if (annotationToShow is IAimImageAnnotationInstace)
            {
                var imageAnnotationToShow = (IAimImageAnnotationInstace)annotationToShow;
                studyInstanceUid  = imageAnnotationToShow.ImageStudyUid;
                seriesInstanceUid = imageAnnotationToShow.ImageSeriesUid;
                sopInstanceUid    = imageAnnotationToShow.FirstImageSopInstanceUid;
                frameNumber       = imageAnnotationToShow.FirstFrameNumber;
            }
            else
            {
                studyInstanceUid  = annotationToShow.ParentAimDocument.StudyInstanceUid;
                seriesInstanceUid = annotationToShow.ParentAimDocument.SeriesInstanceUid;
            }

            if (studyInstanceUid == null || seriesInstanceUid == null)
            {
                _activeViewer.DesktopWindow.ShowMessageBox("Error reading image information (annotation UID = " + aimUid + ").", MessageBoxActions.Ok);
                return;
            }

            // Search displayed images first
            foreach (IImageBox imageBox in _activeViewer.PhysicalWorkspace.ImageBoxes)
            {
                if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0)
                {
                    continue;
                }

                IImageSopProvider imageSopProvider = imageBox.DisplaySet.PresentationImages[0] as IImageSopProvider;
                if (imageSopProvider == null)
                {
                    continue;
                }

                if (imageSopProvider.ImageSop.StudyInstanceUid == studyInstanceUid &&
                    imageSopProvider.ImageSop.SeriesInstanceUid == seriesInstanceUid)
                {
                    foreach (IPresentationImage presentationImage in imageBox.DisplaySet.PresentationImages)
                    {
                        imageSopProvider = presentationImage as IImageSopProvider;
                        if (imageSopProvider == null)
                        {
                            continue;
                        }
                        // Note: will select the first image if there is no SOP Instance UID
                        if (sopInstanceUid == null ||
                            (imageSopProvider.ImageSop.SopInstanceUid == sopInstanceUid && imageSopProvider.Frame.FrameNumber == frameNumber))
                        {
                            try
                            {
                                // Unselect selected in a different image box
                                if (!imageBox.Selected)
                                {
                                    UnselectCurrentGraphics(_activeViewer.PhysicalWorkspace.SelectedImageBox);
                                }

                                imageBox.TopLeftPresentationImage = presentationImage;
                                imageBox.Tiles[0].Select();
                                SelectAimGraphic(presentationImage, aimUid);
                                imageBox.Draw();

                                return;
                            }
                            catch (Exception ex)
                            {
                                ExceptionHandler.Report(ex, _desktopWindow);
                            }
                        }
                    }
                }
            }

            // Search other available images
            foreach (IImageSet imageSet in _activeViewer.LogicalWorkspace.ImageSets)
            {
                foreach (IDisplaySet displaySet in imageSet.DisplaySets)
                {
                    if (displaySet.PresentationImages.Count > 0)
                    {
                        IImageSopProvider imageSopProvider = displaySet.PresentationImages[0] as IImageSopProvider;
                        if (imageSopProvider == null)
                        {
                            continue;
                        }

                        if (imageSopProvider.ImageSop.StudyInstanceUid == studyInstanceUid &&
                            imageSopProvider.ImageSop.SeriesInstanceUid == seriesInstanceUid)
                        {
                            foreach (IPresentationImage presentationImage in displaySet.PresentationImages)
                            {
                                imageSopProvider = presentationImage as IImageSopProvider;
                                if (imageSopProvider == null)
                                {
                                    continue;
                                }
                                // Note: will select the first image if there is no SOP Instance UID
                                if (sopInstanceUid == null ||
                                    (imageSopProvider.ImageSop.SopInstanceUid == sopInstanceUid && imageSopProvider.Frame.FrameNumber == frameNumber))
                                {
                                    try
                                    {
                                        IImageBox targetImageBox = _activeViewer.PhysicalWorkspace.SelectedImageBox ??
                                                                   (_activeViewer.PhysicalWorkspace.ImageBoxes.Count > 0 ? _activeViewer.PhysicalWorkspace.ImageBoxes[0] : null);
                                        if (targetImageBox == null)
                                        {
                                            _activeViewer.DesktopWindow.ShowMessageBox("Failed to find available display", MessageBoxActions.Ok);
                                            Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ").");
                                            return;
                                        }

                                        IDisplaySet        targetDisplaySet        = displaySet.CreateFreshCopy();
                                        IPresentationImage targetPresentationImage = FindRequiredImage(targetDisplaySet.PresentationImages,
                                                                                                       studyInstanceUid, seriesInstanceUid,
                                                                                                       sopInstanceUid, frameNumber);
                                        if (targetPresentationImage == null)
                                        {
                                            _activeViewer.DesktopWindow.ShowMessageBox("Failed to find required image", MessageBoxActions.Ok);
                                            Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ").");
                                            return;
                                        }

                                        // Unselect selected in a different image box
                                        if (!targetImageBox.Selected)
                                        {
                                            UnselectCurrentGraphics(_activeViewer.PhysicalWorkspace.SelectedImageBox);
                                        }

                                        targetImageBox.DisplaySet = targetDisplaySet;
                                        targetImageBox.TopLeftPresentationImage = targetPresentationImage;
                                        targetImageBox.Tiles[0].Select();
                                        SelectAimGraphic(targetPresentationImage, aimUid);
                                        targetImageBox.Draw();

                                        return;
                                    }
                                    catch (Exception ex)
                                    {
                                        ExceptionHandler.Report(ex, _desktopWindow);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public void AdvanceDisplaySet(int direction)
        {
            if (!Enabled)
            {
                return;
            }

            IDisplaySet sourceDisplaySet = GetSourceDisplaySet();

            if (sourceDisplaySet == null)
            {
                return;
            }

            IImageBox imageBox       = base.Context.Viewer.SelectedImageBox;
            IImageSet parentImageSet = sourceDisplaySet.ParentImageSet;

            int sourceDisplaySetIndex = parentImageSet.DisplaySets.IndexOf(sourceDisplaySet);

            sourceDisplaySetIndex += direction;
            try
            {
                if (sourceDisplaySetIndex < 0)
                {
#if SUINING
                    ImageSop sop = ((IImageSopProvider)imageBox.TopLeftPresentationImage).ImageSop;
                    if (sop.Modality == "DX" || sop.Modality == "CR")
                    {
                        return;
                    }
#endif
                    if (base.Context.Viewer.LogicalWorkspace.ImageSets.Count >= 2)
                    {
                        int tempNum = 0;
                        foreach (IImageSet set in base.Context.Viewer.LogicalWorkspace.ImageSets)
                        {
                            if (set.Equals(parentImageSet))
                            {
                                tempNum++;
                                break;
                            }
                            tempNum++;
                        }
                        if (tempNum >= base.Context.Viewer.LogicalWorkspace.ImageSets.Count)
                        {
                            tempNum = 0;
                        }
                        parentImageSet        = base.Context.Viewer.LogicalWorkspace.ImageSets[tempNum];
                        sourceDisplaySetIndex = 0;
                    }
                    else
                    {
                        sourceDisplaySetIndex = parentImageSet.DisplaySets.Count - 1;
                    }
                }
                else if (sourceDisplaySetIndex >= parentImageSet.DisplaySets.Count)
                {
#if SUINING
                    ImageSop sop = ((IImageSopProvider)imageBox.TopLeftPresentationImage).ImageSop;
                    if (sop.Modality == "DX" || sop.Modality == "CR" || sop.Modality == "RF")
                    {
                        return;
                    }
#endif

                    if (base.Context.Viewer.LogicalWorkspace.ImageSets.Count >= 2)
                    {
                        int tempNum = 0;
                        foreach (IImageSet set in base.Context.Viewer.LogicalWorkspace.ImageSets)
                        {
                            if (set.Equals(parentImageSet))
                            {
                                tempNum++;
                                break;
                            }
                            tempNum++;
                        }

                        if (tempNum >= base.Context.Viewer.LogicalWorkspace.ImageSets.Count)
                        {
                            tempNum = 0;
                        }
                        parentImageSet        = base.Context.Viewer.LogicalWorkspace.ImageSets[tempNum];
                        sourceDisplaySetIndex = 0;
                    }
                    else
                    {
                        sourceDisplaySetIndex = 0;
                    }
                }
                //MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
                //memorableCommand.BeginState = imageBox.CreateMemento();

                imageBox.DisplaySet = parentImageSet.DisplaySets[sourceDisplaySetIndex].CreateFreshCopy();
                if (direction < 0)
                {
                    imageBox.TopLeftPresentationImageIndex = imageBox.DisplaySet.PresentationImages.Count - 1;
                }

                thumbileChanged(imageBox.DisplaySet);

                imageBox.Draw();
            }
            catch (Exception ex)
            {
            }
            //memorableCommand.EndState = imageBox.CreateMemento();

            //DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
            //historyCommand.Enqueue(memorableCommand);
            //base.Context.Viewer.CommandHistory.AddCommand(historyCommand);
        }
Ejemplo n.º 18
0
        //private static void AdvanceImage(int increment, IImageBox selectedImageBox)
        private void AdvanceImage(int increment, IImageBox selectedImageBox)
        {
            if (increment > 0)
            {
                GlobalData.direct = 1;
            }
            else
            {
                GlobalData.direct = -1;
            }

            int prevTopLeftPresentationImageIndex = selectedImageBox.TopLeftPresentationImageIndex;

            selectedImageBox.TopLeftPresentationImageIndex += increment;


            if (selectedImageBox.TopLeftPresentationImageIndex != prevTopLeftPresentationImageIndex)
            {
                selectedImageBox.Draw();
            }

            else
            {
                ImageViewerComponent view = this.ImageViewer as ImageViewerComponent;
                ActionModelNode      node = view.ToolbarModel;

                ActionModelNode tempNode = null;
                IAction []      action   = null;
                foreach (ActionModelNode tempnode in node.ChildNodes)
                {
                    if (tempnode.PathSegment.ResourceKey == "ToolbarSynchronizeStacking")
                    {
                        tempNode = tempnode;
                        break;
                    }
                }
                if (tempNode != null)
                {
                    action = tempNode.GetActionsInOrder();
                }
                if ((action != null) && (action.Count() > 0))
                {
                    ButtonAction ac = action[0] as ButtonAction;
                    if (ac.Checked == true)
                    {
                        return;
                    }
                }
                if (selectedImageBox.TopLeftPresentationImage == null)
                {
                    return;
                }
#if SUINING
                ImageSop sop = ((IImageSopProvider)selectedImageBox.TopLeftPresentationImage).ImageSop;
                if (sop.Modality == "CT" || sop.Modality == "MR")
                {
                    return;
                }
#endif
                if (increment > 0)
                {
                    AdvanceDisplaySet(1);
                }
                else
                {
                    AdvanceDisplaySet(-1);
                }
            }
        }
        private static void UnselectCurrentGraphics(IImageBox imageBox)
        {
            if (imageBox == null)
                return;

            if (imageBox.TopLeftPresentationImage != null)
            {
                imageBox.TopLeftPresentationImage.SelectedGraphic = null;
                imageBox.Draw();
            }
        }
Ejemplo n.º 20
0
		private static void AdvanceImage(int increment, IImageBox selectedImageBox)
		{
		    int prevTopLeftPresentationImageIndex = selectedImageBox.TopLeftPresentationImageIndex;
			selectedImageBox.TopLeftPresentationImageIndex += increment;

            if (selectedImageBox.TopLeftPresentationImageIndex != prevTopLeftPresentationImageIndex)
                selectedImageBox.Draw(); 
		}
Ejemplo n.º 21
0
			private static void Execute(IImageBox imageBox, object unexplodeMemento)
			{
				MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
				memorableCommand.BeginState = imageBox.CreateMemento();

				IDisplaySet displaySet = imageBox.DisplaySet;
				IPresentationImage selectedImage;
				if (imageBox.SelectedTile != null)
					selectedImage = imageBox.SelectedTile.PresentationImage;
				else
					selectedImage = imageBox.TopLeftPresentationImage;

				imageBox.SetMemento(unexplodeMemento);

				//TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
				//This stuff with mementos is actually a hacky workaround.

				bool locked = imageBox.DisplaySetLocked;
				imageBox.DisplaySetLocked = false;
				imageBox.DisplaySet = displaySet;
				imageBox.DisplaySetLocked = locked;

				if (selectedImage != null)
					imageBox.TopLeftPresentationImage = selectedImage;

				imageBox.Draw();
                imageBox.SelectDefaultTile();

				memorableCommand.EndState = imageBox.CreateMemento();

				DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
				historyCommand.Name = SR.CommandExplodeTile;
				historyCommand.Enqueue(memorableCommand);
				imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);
			}
Ejemplo n.º 22
0
		private void ExplodeSelectedTile(IImageBox imageBox)
		{
			MemorableUndoableCommand memorableCommand = new MemorableUndoableCommand(imageBox);
			memorableCommand.BeginState = imageBox.CreateMemento();

			//set this here so checked will be correct.
			object unexplodeMemento = memorableCommand.BeginState;
			_unexplodeCommands[imageBox] = new UnexplodeTileCommand(imageBox, unexplodeMemento, RemoveUnexplodeCommand);
			
			IDisplaySet displaySet = imageBox.DisplaySet;
			IPresentationImage selectedImage = imageBox.SelectedTile.PresentationImage;
			imageBox.SetTileGrid(1, 1);

			//TODO (architecture): this wouldn't be necessary if we had a SetImageBoxGrid(imageBox[,]).
			//This stuff with mementos is actually a hacky workaround.

			bool locked = imageBox.DisplaySetLocked;
			imageBox.DisplaySetLocked = false;
			imageBox.DisplaySet = displaySet;
			imageBox.DisplaySetLocked = locked;

			imageBox.TopLeftPresentationImage = selectedImage;

			memorableCommand.EndState = imageBox.CreateMemento();

			DrawableUndoableCommand historyCommand = new DrawableUndoableCommand(imageBox);
			historyCommand.Name = SR.CommandExplodeTile;
			historyCommand.Enqueue(memorableCommand);
			imageBox.ParentPhysicalWorkspace.ImageViewer.CommandHistory.AddCommand(historyCommand);
		
			imageBox.Draw();
            imageBox.SelectDefaultTile();
        }
Ejemplo n.º 23
0
        public void ShowImageWithAnnotation(string aimUid)
        {
            if (_activeViewer == null)
            {
                return;
            }

            // Find Annotation
            aim_dotnet.Annotation annotationToShow = null;
            foreach (aim_dotnet.Annotation annotation in AvailableAnnotations)
            {
                if (annotation.UniqueIdentifier == aimUid)
                {
                    annotationToShow = annotation;
                    break;
                }
            }

            if (annotationToShow == null)
            {
                _activeViewer.DesktopWindow.ShowMessageBox("Could not locate annotation (UID = " + aimUid + ").", MessageBoxActions.Ok);
                return;
            }

            aim_dotnet.ImageStudy studyToOpen = AimStudyFromAnnotation(annotationToShow);
            if (studyToOpen == null)
            {
                _activeViewer.DesktopWindow.ShowMessageBox("Error reading image information (annotation UID = " + aimUid + ").", MessageBoxActions.Ok);
                return;
            }

            // Search displayed images first
            foreach (IImageBox imageBox in _activeViewer.PhysicalWorkspace.ImageBoxes)
            {
                if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0)
                {
                    continue;
                }

                IImageSopProvider imageSopProvider = imageBox.DisplaySet.PresentationImages[0] as IImageSopProvider;
                if (imageSopProvider == null)
                {
                    continue;
                }

                if (imageSopProvider.ImageSop.StudyInstanceUid == studyToOpen.InstanceUID &&
                    imageSopProvider.ImageSop.SeriesInstanceUid == studyToOpen.Series.InstanceUID)
                {
                    foreach (IPresentationImage presentationImage in imageBox.DisplaySet.PresentationImages)
                    {
                        imageSopProvider = presentationImage as IImageSopProvider;
                        if (imageSopProvider == null)
                        {
                            continue;
                        }
                        if (imageSopProvider.ImageSop.SopInstanceUid == studyToOpen.Series.ImageCollection[0].SopInstanceUID)
                        {
                            try
                            {
                                imageBox.TopLeftPresentationImage = presentationImage;
                                imageBox.Tiles[0].Select();
                                this.SelectAimGraphic(presentationImage, aimUid);
                                imageBox.Draw();

                                return;
                            }
                            catch (Exception ex)
                            {
                                ExceptionHandler.Report(ex, _desktopWindow);
                            }
                        }
                    }
                }
            }

            // Search other available images
            foreach (IImageSet imageSet in _activeViewer.LogicalWorkspace.ImageSets)
            {
                foreach (IDisplaySet displaySet in imageSet.DisplaySets)
                {
                    if (displaySet.PresentationImages.Count > 0)
                    {
                        IImageSopProvider imageSopProvider = displaySet.PresentationImages[0] as IImageSopProvider;
                        if (imageSopProvider == null)
                        {
                            continue;
                        }

                        if (imageSopProvider.ImageSop.StudyInstanceUid == studyToOpen.InstanceUID &&
                            imageSopProvider.ImageSop.SeriesInstanceUid == studyToOpen.Series.InstanceUID)
                        {
                            foreach (IPresentationImage presentationImage in displaySet.PresentationImages)
                            {
                                imageSopProvider = presentationImage as IImageSopProvider;
                                if (imageSopProvider == null)
                                {
                                    continue;
                                }
                                if (imageSopProvider.ImageSop.SopInstanceUid == studyToOpen.Series.ImageCollection[0].SopInstanceUID)
                                {
                                    try
                                    {
                                        IImageBox targetImageBox = _activeViewer.PhysicalWorkspace.SelectedImageBox ??
                                                                   (_activeViewer.PhysicalWorkspace.ImageBoxes.Count > 0 ? _activeViewer.PhysicalWorkspace.ImageBoxes[0] : null);
                                        if (targetImageBox == null)
                                        {
                                            _activeViewer.DesktopWindow.ShowMessageBox("Failed to find available display", MessageBoxActions.Ok);
                                            Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ").");
                                            return;
                                        }

                                        IDisplaySet        targetDisplaySet        = displaySet.CreateFreshCopy();
                                        IPresentationImage targetPresentationImage = FindRequiredImage(targetDisplaySet.PresentationImages,
                                                                                                       studyToOpen.InstanceUID, studyToOpen.Series.InstanceUID,
                                                                                                       studyToOpen.Series.ImageCollection[0].SopInstanceUID);
                                        if (targetPresentationImage == null)
                                        {
                                            _activeViewer.DesktopWindow.ShowMessageBox("Failed to find required image", MessageBoxActions.Ok);
                                            Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ").");
                                            return;
                                        }

                                        targetImageBox.DisplaySet = targetDisplaySet;
                                        targetImageBox.TopLeftPresentationImage = targetPresentationImage;
                                        targetImageBox.Tiles[0].Select();
                                        this.SelectAimGraphic(targetPresentationImage, aimUid);
                                        targetImageBox.Draw();

                                        return;
                                    }
                                    catch (Exception ex)
                                    {
                                        ExceptionHandler.Report(ex, _desktopWindow);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }