public override void Apply(IPresentationImage presentationImage) { if (!AppliesTo(presentationImage)) { throw new InvalidOperationException("The input presentation image is not supported."); } IVoiLutManager manager = ((IVoiLutProvider)presentationImage).VoiLutManager; IVoiLut currentLut = manager.VoiLut; if (currentLut is MinMaxPixelCalculatedLinearLut) { return; } GrayscalePixelData pixelData = (GrayscalePixelData)((IImageGraphicProvider)presentationImage).ImageGraphic.PixelData; IModalityLutProvider modalityLutProvider = presentationImage as IModalityLutProvider; if (modalityLutProvider != null) { manager.InstallVoiLut(new MinMaxPixelCalculatedLinearLut(pixelData, modalityLutProvider.ModalityLut)); } else { manager.InstallVoiLut(new MinMaxPixelCalculatedLinearLut(pixelData)); } }
private void SetWindow(double windowWidth, double windowCenter, out IBasicVoiLutLinear voiLut) { voiLut = null; if (!CanWindowLevel()) { return; } IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; var linearLut = manager.VoiLut as IVoiLutLinear; var standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { standardLut = new BasicVoiLutLinear(windowWidth, windowCenter); manager.InstallVoiLut(standardLut); } else { standardLut.WindowWidth = windowWidth; standardLut.WindowCenter = windowCenter; } voiLut = standardLut; SelectedVoiLutProvider.Draw(); }
public override bool Track(IMouseInformation mouseInformation) { base.Track(mouseInformation); IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; IVoiLutLinear linearLut = manager.VoiLut as IVoiLutLinear; IBasicVoiLutLinear standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { BasicVoiLutLinear installLut = new BasicVoiLutLinear(linearLut.WindowWidth, linearLut.WindowCenter); manager.InstallVoiLut(installLut); } standardLut = manager.VoiLut as IBasicVoiLutLinear; double sensitivity = CurrentSensitivity; if ((Math.Abs(standardLut.WindowCenter) + Math.Abs(standardLut.WindowWidth)) < 1000) { sensitivity = 1.0; } IncrementWindow(DeltaX * sensitivity, DeltaY * sensitivity); return(true); }
private void CaptureBeginState() { if (!CanWindowLevel()) { return; } IVoiLutManager originator = GetSelectedImageVoiLutManager(); _applicator = new ImageOperationApplicator(SelectedPresentationImage, _operation); _memorableCommand = new MemorableUndoableCommand(originator); _memorableCommand.BeginState = originator.CreateMemento(); }
public void SetRealVoiLutManager(IVoiLutManager realVoiLutManager) { if (_realVoiLutManager != null) { Replicate(_realVoiLutManager, _placeholderVoiLutManager); } _realVoiLutManager = realVoiLutManager; if (_realVoiLutManager != null) { Replicate(_placeholderVoiLutManager, _realVoiLutManager); } }
private static Bitmap DrawLutFrame(Frame f, double ww, double wc) { IPresentationImage pres = PresentationImageFactory.Create(f); IVoiLutProvider provider = ((IVoiLutProvider)pres); IVoiLutManager manager = provider.VoiLutManager; var linearLut = manager.VoiLut as IVoiLutLinear; if (linearLut != null) { var standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { var installLut = new BasicVoiLutLinear(ww, wc); manager.InstallVoiLut(installLut); } else { standardLut.WindowWidth = ww; standardLut.WindowCenter = wc; } provider.Draw(); } try { var bmp = pres.DrawToBitmap(f.Columns, f.Rows); if (f.Columns == f.Rows) { if (f.Columns < 512) { bmp = ResizeBitmap(bmp, 512, 512); } } return(bmp); } catch { return(null); } }
private void DeserializeInvert(IDicomPresentationImage image) { if (!ShowGrayscaleInverted) { return; } if (!(image.ImageGraphic.PixelData is GrayscalePixelData)) { return; } if (!(image is IVoiLutProvider)) { return; } IVoiLutManager manager = ((IVoiLutProvider)image).VoiLutManager; //Invert can be true by default depending on photometric interpretation, //so we'll just assume the current value is the default and flip it. manager.Invert = !manager.Invert; }
private void IncrementWindow(double windowIncrement, double levelIncrement) { if (!CanWindowLevel()) { return; } IVoiLutManager manager = SelectedVoiLutProvider.VoiLutManager; IVoiLutLinear linearLut = manager.VoiLut as IVoiLutLinear; IBasicVoiLutLinear standardLut = linearLut as IBasicVoiLutLinear; if (standardLut == null) { BasicVoiLutLinear installLut = new BasicVoiLutLinear(linearLut.WindowWidth, linearLut.WindowCenter); manager.InstallVoiLut(installLut); } standardLut = manager.VoiLut as IBasicVoiLutLinear; standardLut.WindowWidth += windowIncrement; standardLut.WindowCenter += levelIncrement; SelectedVoiLutProvider.Draw(); }
private void Invert(IPresentationImage image) { IVoiLutManager manager = (IVoiLutManager)_operation.GetOriginator(image); manager.Invert = !manager.Invert; }
private bool CanWindowLevel() { IVoiLutManager manager = GetSelectedImageVoiLutManager(); return(manager != null && manager.Enabled && manager.VoiLut is IVoiLutLinear); }
/// <summary> /// Cloning constructor. /// </summary> /// <param name="source">The source object from which to clone.</param> /// <param name="context">The cloning context object.</param> protected VoiLutManagerProxy(VoiLutManagerProxy source, ICloningContext context) { context.CloneFields(source, this); _placeholderVoiLutManager = new VoiLutManager(new XVoiLutInstaller(source._realVoiLutManager ?? source._placeholderVoiLutManager), false); }
public VoiLutManagerProxy() { _placeholderVoiLutManager = new VoiLutManager(new XVoiLutInstaller(), false); }