Exemplo n.º 1
0
        private IActionSet GetContextMenuActionSet()
        {
            var          aimUserGraphics = GetAimUserGraphics();
            var          actionsList     = new List <IAction>();
            const string path            = "imageviewer-contextmenu/Visible AIM Users/";
            var          resolver        = new ResourceResolver(GetType(), true);

            foreach (var aimUser in aimUserGraphics.Keys)
            {
                if (aimUserGraphics.Count > 0)
                {
                    var user   = aimUser;
                    var action = new MenuAction(aimUser, new ActionPath(path + aimUser, resolver), ClickActionFlags.CheckAction, resolver);
                    action.Checked    = aimUserGraphics[aimUser][0].Visible;
                    action.Enabled    = true;
                    action.Persistent = false;
                    action.Label      = aimUser;
                    actionsList.Add(action);
                    action.SetClickHandler(
                        delegate
                    {
                        var visible = !action.Checked;
                        _displayMarkupPerUser[user] = visible;
                        action.Checked = visible;
                        SelectedPresentationImage.Draw();
                    });
                }
            }
            return(new ActionSet(actionsList));
        }
Exemplo n.º 2
0
        private void InitializeMagnificationImage()
        {
            if (_magnificationImage != null)
            {
                return;
            }

            if (SelectedPresentationImage == null)
            {
                throw new ArgumentException("The image cannot be null", "value");
            }

            if (!(SelectedPresentationImage is ISpatialTransformProvider))
            {
                throw new ArgumentException("The image must implement ISpatialTransformProvider", "value");
            }

            if (!(((ISpatialTransformProvider)SelectedPresentationImage).SpatialTransform is ImageSpatialTransform))
            {
                throw new ArgumentException("The image must provide an IImageSpatialTransform", "value");
            }

            DisposeMagnificationImage();

            _firstRender        = true;
            _magnificationImage = (PresentationImage)SelectedPresentationImage.Clone();

            HideOverlays();
        }
Exemplo n.º 3
0
        private void IncrementRotate(int xIncrement, int yIncrement)
        {
            if (!CanRotate())
            {
                return;
            }

            if (xIncrement == 0 && yIncrement == 0)
            {
                return;
            }

            var transform = (ISpatialTransform3D)_operation.GetOriginator(SelectedPresentationImage);

            // Because the rotation increment is in destination coordinates, we have to convert
            // them to source coordinates, since the transform translation is in source coordinates.
            // This will allow the rotate to work properly irrespective of the zoom, flip and rotation.
            var source  = SelectedSpatialTransformProvider.SpatialTransform.ConvertToSource(new SizeF(xIncrement, yIncrement));
            var sourceX = source.Width;
            var sourceY = source.Height;

            // choose the axis of rotation to be perpendicular to the rotation increment, in the plane of the view port
            var axis = new Vector3D(-sourceY, sourceX, 0).Normalize();

            // compute the magnitude of the rotation
            var angle = (float)Math.Sqrt(sourceX * sourceX + sourceY * sourceY);

            var rotation = transform.Rotation != null?transform.Rotation.Clone() : Matrix3D.GetIdentity();

            Rotate(rotation, angle, axis.X, axis.Y, axis.Z);
            transform.Rotation = rotation;

            SelectedPresentationImage.Draw();
        }
 private void DrawGraphic(IGraphic graphic)
 {
     if (SelectedOverlayGraphicsProvider == null)
     {
         return;
     }
     SelectedOverlayGraphicsProvider.OverlayGraphics.Add(new XStatefulGraphic(graphic));
     SelectedPresentationImage.Draw();
 }
Exemplo n.º 5
0
        private void ResetRotate()
        {
            if (!CanRotate())
            {
                return;
            }

            var transform = (ISpatialTransform3D)_operation.GetOriginator(SelectedPresentationImage);

            transform.Rotation = Matrix3D.GetIdentity();

            SelectedPresentationImage.Draw();
        }
Exemplo n.º 6
0
        private void IncrementPan(int xIncrement, int yIncrement)
        {
            if (!CanPan())
            {
                return;
            }

            ISpatialTransform transform = _operation.GetOriginator(SelectedPresentationImage);

            transform.Translate(xIncrement, yIncrement);

            SelectedPresentationImage.Draw();
        }
Exemplo n.º 7
0
        private void SetPatientOrientation(Vector3D rowDirectionPatient, Vector3D columnDirectionPatient)
        {
            if (!CanRotate())
            {
                return;
            }

            if (rowDirectionPatient == null || columnDirectionPatient == null || !rowDirectionPatient.IsOrthogonalTo(columnDirectionPatient, (float)(5 / 180d * Math.PI)))
            {
                return;
            }

            var patientPresentation = SelectedPresentationImage as IPatientPresentationProvider;

            if (patientPresentation == null || !patientPresentation.PatientPresentation.IsValid)
            {
                return;
            }

            // Note the inverted column orientation vectors in both matrices - this is due to implicit Y axis inversion in the 3D transform
            columnDirectionPatient = -columnDirectionPatient;

            var currentRowOrientation    = patientPresentation.PatientPresentation.OrientationX;
            var currentColumnOrientation = -patientPresentation.PatientPresentation.OrientationY;
            var currentOrientation       = Matrix3D.FromRows(currentRowOrientation.Normalize(), currentColumnOrientation.Normalize(), currentRowOrientation.Cross(currentColumnOrientation).Normalize());
            var requestedOrientation     = Matrix3D.FromRows(rowDirectionPatient.Normalize(), columnDirectionPatient.Normalize(), rowDirectionPatient.Cross(columnDirectionPatient).Normalize());

            var transform = _operation.GetOriginator(SelectedPresentationImage);

            // (because we're dealing with rotation matrices (i.e. orthogonal!), the Inverse is just Transpose)
            var rotation = requestedOrientation * currentOrientation.Transpose();

            transform.Rotation = rotation * transform.Rotation;           // this rotation is cumulative upon current rotation, since IPatientPresentationProvider is based on *current* view

            SelectedPresentationImage.Draw();
        }