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 void Apply(IPresentationImage image)
        {
            IImageSpatialTransform transform          = (IImageSpatialTransform)_operation.GetOriginator(image);
            IImageSpatialTransform referenceTransform = (IImageSpatialTransform)this.SelectedSpatialTransformProvider.SpatialTransform;

            transform.Scale      = referenceTransform.Scale;
            transform.ScaleToFit = referenceTransform.ScaleToFit;

            if (GetCheckedSync() == false)
            {
                return;
            }
            //
            IVoiLutLinear selectedLut = (IVoiLutLinear)this.SelectedVoiLutProvider.VoiLutManager.VoiLut;

            IVoiLutProvider provider = ((IVoiLutProvider)image);

            if (!(provider.VoiLutManager.VoiLut is IBasicVoiLutLinear))
            {
                BasicVoiLutLinear installLut = new BasicVoiLutLinear(selectedLut.WindowWidth, selectedLut.WindowCenter);
                provider.VoiLutManager.InstallVoiLut(installLut);
            }

            IBasicVoiLutLinear lut = (IBasicVoiLutLinear)provider.VoiLutManager.VoiLut;

            lut.WindowWidth  = selectedLut.WindowWidth;
            lut.WindowCenter = selectedLut.WindowCenter;
            //
            transform.TranslationX = this.SelectedSpatialTransformProvider.SpatialTransform.TranslationX;
            transform.TranslationY = this.SelectedSpatialTransformProvider.SpatialTransform.TranslationY;
        }
        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 Apply(IPresentationImage image)
        {
            IVoiLutLinear selectedLut = (IVoiLutLinear)SelectedVoiLutProvider.VoiLutManager.VoiLut;

            IVoiLutProvider provider = ((IVoiLutProvider)image);

            if (!(provider.VoiLutManager.VoiLut is IBasicVoiLutLinear))
            {
                BasicVoiLutLinear installLut = new BasicVoiLutLinear(selectedLut.WindowWidth, selectedLut.WindowCenter);
                provider.VoiLutManager.InstallVoiLut(installLut);
            }

            IBasicVoiLutLinear lut = (IBasicVoiLutLinear)provider.VoiLutManager.VoiLut;

            lut.WindowWidth  = selectedLut.WindowWidth;
            lut.WindowCenter = selectedLut.WindowCenter;
        }
        public void Apply(IPresentationImage image)
        {
            if (image == ReferenceImage)
            {
                return;
            }

            //Turn off scale to fit and start with scale=1, then adjust it.
            //We do this because images that have been "scaled to fit", but have not been shown yet,
            //have no client rectangle and their scale is often very small.  This is safer
            //and could produce a more accurate result.
            IImageSpatialTransform matchTransform = GetImageTransform(image);

            matchTransform.ScaleToFit = false;
            matchTransform.Scale      = 1;

            //get the displayed width (in mm) for the same size display rectangle in the image to be matched.
            float matchDisplayedWidth = GetDisplayedWidth(image, _referenceDisplayRectangle);
            float rescaleAmount       = matchDisplayedWidth / _referenceDisplayedWidth;

            matchTransform.Scale *= rescaleAmount;

            //ISpatialTransform transform = (ISpatialTransform)_operation.GetOriginator(image);
            matchTransform.TranslationX = this.SelectedSpatialTransformProvider.SpatialTransform.TranslationX;
            matchTransform.TranslationY = this.SelectedSpatialTransformProvider.SpatialTransform.TranslationY;

            IVoiLutLinear selectedLut = (IVoiLutLinear)this.SelectedVoiLutProvider.VoiLutManager.VoiLut;

            IVoiLutProvider provider = ((IVoiLutProvider)image);

            if (!(provider.VoiLutManager.VoiLut is IBasicVoiLutLinear))
            {
                BasicVoiLutLinear installLut = new BasicVoiLutLinear(selectedLut.WindowWidth, selectedLut.WindowCenter);
                provider.VoiLutManager.InstallVoiLut(installLut);
            }

            IBasicVoiLutLinear lut = (IBasicVoiLutLinear)provider.VoiLutManager.VoiLut;

            lut.WindowWidth  = selectedLut.WindowWidth;
            lut.WindowCenter = selectedLut.WindowCenter;
        }
        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 SetWindowWithUndo(double windowWidth, double windowCenter, out IBasicVoiLutLinear voiLut)
 {
     CaptureBeginState();
     SetWindow(windowWidth, windowCenter, out voiLut);
     CaptureEndState();
 }
        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();
        }
 private void SetWindowWithUndo(double windowWidth, double windowCenter, out IBasicVoiLutLinear voiLut)
 {
     CaptureBeginState();
     SetWindow(windowWidth, windowCenter, out voiLut);
     CaptureEndState();
 }