/// <summary> /// Sets the slicing plane for the specified slice set based on two points on the specified source image. /// </summary> private static void SetSlicePlane(IMprStandardSliceSet sliceSet, IPresentationImage sourceImage, Vector3D startPoint, Vector3D endPoint) { IImageSopProvider imageSopProvider = sourceImage as IImageSopProvider; if (imageSopProvider == null) { return; } ImageOrientationPatient orientation = imageSopProvider.Frame.ImageOrientationPatient; Vector3D orientationRow = new Vector3D((float)orientation.RowX, (float)orientation.RowY, (float)orientation.RowZ); Vector3D orientationColumn = new Vector3D((float)orientation.ColumnX, (float)orientation.ColumnY, (float)orientation.ColumnZ); if (sliceSet != null && !sliceSet.IsReadOnly) { IImageBox imageBox = FindImageBox(sliceSet, sourceImage.ImageViewer as MprViewerComponent); sliceSet.SlicerParams = VolumeSlicerParams.Create(sliceSet.VolumeHeader, orientationColumn, orientationRow, startPoint, endPoint); IPresentationImage closestImage = GetClosestSlice(startPoint + (endPoint - startPoint) * 2, imageBox.DisplaySet); if (closestImage == null) { imageBox.TopLeftPresentationImageIndex = imageBox.DisplaySet.PresentationImages.Count / 2; } else { imageBox.TopLeftPresentationImage = closestImage; } } }
protected override IEnumerable <MprViewerTool> CreateTools() { int index = 0; if (this.ImageViewer == null) { yield break; } // create one instance of the slave tool for each mutable slice set foreach (IMprVolume volume in this.ImageViewer.Volumes) { foreach (IMprSliceSet sliceSet in volume.SliceSets) { IMprStandardSliceSet standardSliceSet = sliceSet as IMprStandardSliceSet; if (standardSliceSet != null && !standardSliceSet.IsReadOnly) { ResliceTool tool = new ResliceTool(this); tool.SliceSet = standardSliceSet; tool.HotColor = _colors[index, 0]; tool.NormalColor = _colors[index, 1]; index = (index + 1) % _colors.Length; // advance to next color yield return(tool); } } } }
private void DisposeResetAll() { if (this.ImageViewer == null) { return; } foreach (IImageSet imageSet in this.ImageViewer.MprWorkspace.ImageSets) { foreach (MprDisplaySet displaySet in imageSet.DisplaySets) { IMprStandardSliceSet sliceSet = displaySet.SliceSet as IMprStandardSliceSet; if (sliceSet != null) { sliceSet.SlicerParamsChanged -= OnSliceSetSlicerParamsChanged; } } } }
private void InitializeResetAll() { if (this.ImageViewer == null) { return; } _canReset = false; foreach (IImageSet imageSet in this.ImageViewer.MprWorkspace.ImageSets) { foreach (MprDisplaySet displaySet in imageSet.DisplaySets) { IMprStandardSliceSet sliceSet = displaySet.SliceSet as IMprStandardSliceSet; if (sliceSet != null && !sliceSet.IsReadOnly) { sliceSet.SlicerParamsChanged += OnSliceSetSlicerParamsChanged; } } } }
public override void SetMemento(object memento) { MprDisplaySetMemento mprDisplaySetMemento = memento as MprDisplaySetMemento; if (mprDisplaySetMemento == null) { return; } IMprStandardSliceSet sliceSet = _sliceSet as IMprStandardSliceSet; if (sliceSet != null && !sliceSet.IsReadOnly && mprDisplaySetMemento.SlicerParams != null) { sliceSet.SlicerParams = mprDisplaySetMemento.SlicerParams; } if (this.ImageBox != null && mprDisplaySetMemento.SliceIndex >= 0 && mprDisplaySetMemento.SliceIndex < this.PresentationImages.Count) { this.ImageBox.TopLeftPresentationImage = this.PresentationImages[mprDisplaySetMemento.SliceIndex]; } base.SetMemento(mprDisplaySetMemento.DisplaySetMemento); }