private void RotateImage(RotationOperation operation)
        {
            vtkImageReslice reslice   = vtkImageReslice.New();
            vtkTransform    transform = vtkTransform.New();

            transform.PostMultiply();

            double[] center = { 75, 100, 0 };
            transform.Translate(-center[0], -center[1], -center[2]);
            if (operation == RotationOperation.Forward)
            {
                transform.RotateZ(90);
            }
            else if (operation == RotationOperation.Back)
            {
                transform.RotateZ(-90);
            }
            transform.Translate(+center[0], +center[1], +center[2]);

            transform.Update();
            reslice.SetInput(_viewer.GetInput());
            reslice.SetResliceTransform(transform);
            reslice.Update();

            _viewer.SetInput(reslice.GetOutput());

            UpdateViewer();
        }
Пример #2
0
 public ArrangerElement(int x1, int y1, DataSource dataFile, BitAddress address, IGraphicsCodec codec, Palette palette)
 {
     X1            = x1;
     Y1            = y1;
     Source        = dataFile;
     SourceAddress = address;
     Codec         = codec;
     Palette       = palette;
     Mirror        = MirrorOperation.None;
     Rotation      = RotationOperation.None;
 }
Пример #3
0
 public ArrangerElement(int x1, int y1)
 {
     X1            = x1;
     Y1            = y1;
     SourceAddress = BitAddress.Zero;
     Source        = null;
     Codec         = null;
     Palette       = null;
     Mirror        = MirrorOperation.None;
     Rotation      = RotationOperation.None;
 }
        private void RotateImage(RotationOperation operation)
        {
            vtkImageReslice reslice = vtkImageReslice.New();
            vtkTransform transform = vtkTransform.New();
            transform.PostMultiply();

            double[] center = { 75, 100, 0 };
            transform.Translate(-center[0], -center[1], -center[2]);
            if (operation == RotationOperation.Forward)
            {
                transform.RotateZ(90);
            }
            else if (operation == RotationOperation.Back)
            {
                transform.RotateZ(-90);
            }
            transform.Translate(+center[0], +center[1], +center[2]);

            transform.Update();
            reslice.SetInput(_viewer.GetInput());
            reslice.SetResliceTransform(transform);
            reslice.Update();

            _viewer.SetInput(reslice.GetOutput());
            UpdateViewer();
        }
Пример #5
0
    public static MagitekResult TryRotateElement(this Arranger arranger, int elementX, int elementY, RotationOperation rotate)
    {
        if (rotate == RotationOperation.None)
        {
            return(MagitekResult.SuccessResult);
        }

        if (elementX > arranger.ArrangerElementSize.Width || elementY > arranger.ArrangerElementSize.Height)
        {
            return(new MagitekResult.Failed($"Location ({elementX}, {elementY}) is outside of the arranger"));
        }

        if (arranger.GetElement(elementX, elementY) is ArrangerElement el)
        {
            if (el.Width != el.Height)
            {
                return(new MagitekResult.Failed("Only square elements may be rotated"));
            }

            var newRotation = (el.Rotation, rotate) switch
            {
                (RotationOperation.Left, RotationOperation.Left) => RotationOperation.Turn,
                (RotationOperation.Turn, RotationOperation.Left) => RotationOperation.Right,
                (RotationOperation.Right, RotationOperation.Left) => RotationOperation.None,

                (RotationOperation.Left, RotationOperation.Right) => RotationOperation.None,
                (RotationOperation.Turn, RotationOperation.Right) => RotationOperation.Left,
                (RotationOperation.Right, RotationOperation.Right) => RotationOperation.Turn,

                (RotationOperation.Left, RotationOperation.Turn) => RotationOperation.Right,
                (RotationOperation.Turn, RotationOperation.Turn) => RotationOperation.None,
                (RotationOperation.Right, RotationOperation.Turn) => RotationOperation.Left,

                (RotationOperation.None, _) => rotate,
                (_, RotationOperation.None) => el.Rotation,
                _ => el.Rotation
            };

            var rotatedElement = el.WithRotation(newRotation);
            arranger.SetElement(rotatedElement, elementX, elementY);

            return(MagitekResult.SuccessResult);
        }

        return(new MagitekResult.Failed($"No element present at position ({elementX}, {elementY}) to be rotated"));
    }
Пример #6
0
 public RotateElementHistoryAction(int elementX, int elementY, RotationOperation rotation)
 {
     ElementX = elementX;
     ElementY = elementY;
     Rotation = rotation;
 }