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));
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private void CaptureBeginState()
        {
            if (!CanWindowLevel())
            {
                return;
            }

            IVoiLutManager originator = GetSelectedImageVoiLutManager();

            _applicator                  = new ImageOperationApplicator(SelectedPresentationImage, _operation);
            _memorableCommand            = new MemorableUndoableCommand(originator);
            _memorableCommand.BeginState = originator.CreateMemento();
        }
コード例 #5
0
        public void SetRealVoiLutManager(IVoiLutManager realVoiLutManager)
        {
            if (_realVoiLutManager != null)
            {
                Replicate(_realVoiLutManager, _placeholderVoiLutManager);
            }

            _realVoiLutManager = realVoiLutManager;

            if (_realVoiLutManager != null)
            {
                Replicate(_placeholderVoiLutManager, _realVoiLutManager);
            }
        }
コード例 #6
0
    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); }
    }
コード例 #7
0
        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;
        }
コード例 #8
0
        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();
        }
コード例 #9
0
ファイル: InvertTool.cs プロジェクト: hksonngan/Xian
        private void Invert(IPresentationImage image)
        {
            IVoiLutManager manager = (IVoiLutManager)_operation.GetOriginator(image);

            manager.Invert = !manager.Invert;
        }
コード例 #10
0
        private bool CanWindowLevel()
        {
            IVoiLutManager manager = GetSelectedImageVoiLutManager();

            return(manager != null && manager.Enabled && manager.VoiLut is IVoiLutLinear);
        }
コード例 #11
0
        /// <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);
        }
コード例 #12
0
 public VoiLutManagerProxy()
 {
     _placeholderVoiLutManager = new VoiLutManager(new XVoiLutInstaller(), false);
 }