Exemplo n.º 1
0
        private static AnnPointerEventArgs ConvertPointerEventArgs(InteractiveEventArgs e, bool isDoubleTap)
        {
            // Convert the point
            var point = LeadPointD.Create(e.Position.X, e.Position.Y);

            // Convert the mouse button
            var mouseButton = AnnMouseButton.None;

            if (!isDoubleTap)
            {
                if (e.MouseButton == MouseButtons.Left)
                {
                    mouseButton = AnnMouseButton.Left;
                }
                if (e.MouseButton == MouseButtons.Right)
                {
                    mouseButton = AnnMouseButton.Right;
                }
            }
            else
            {
                mouseButton = AnnMouseButton.Left;
            }

            var args = AnnPointerEventArgs.Create(mouseButton, point);

            args.IsHandled = e.IsHandled;
            return(args);
        }
Exemplo n.º 2
0
        private void AdjustFusionImage_Edit(object sender, AnnRectangleObject fusionEditRect)
        {
            int subCellIndex = _cell.ActiveSubCell;
            int index        = _cmbFusedIndex.SelectedIndex;

            MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index];

            AnnContainer _Container = GetContainer(_cell, fusionEditRect);

            fusion.Rotation = (float)fusionEditRect.Angle;

            LeadPointD[] pt = new LeadPointD[1];


            LeadRectD rect = _Container.Mapper.RectFromContainerCoordinates(fusionEditRect.Rect, AnnFixedStateOperations.None);

            Rectangle displayRect = _cell.GetDisplayedImageRectangle();

            rect.Offset(-displayRect.Left, -displayRect.Top);


            pt[0].X = (float)(rect.X + rect.Width / 2);
            pt[0].Y = (float)(rect.Y + rect.Height / 2);

            LeadPointD point = LeadPointD.Create(pt[0].X, pt[0].Y);


            _cell.AutomationContainer.Mapper.Transform.TransformPoints(pt);

            float normalizedXPosition = (float)(((float)point.X - (float)displayRect.Width / 2) / fusion.FusedImage.Width * 100 / _cell.GetScale(subCellIndex));
            float normalizedYPosition = (float)(((float)point.Y - (float)displayRect.Height / 2) / fusion.FusedImage.Height * 100 / _cell.GetScale(subCellIndex));

            float scaleX = (float)((rect.Width / fusion.FusedImage.Width) * 100 / _cell.GetScale(subCellIndex));
            float scaleY = (float)((rect.Height / fusion.FusedImage.Height) * 100 / _cell.GetScale(subCellIndex));

            if (scaleX == 0)
            {
                scaleX = 0.1F;
            }

            if (scaleY == 0)
            {
                scaleY = 0.1F;
            }

            RectangleF rectangle = new RectangleF(normalizedXPosition, normalizedYPosition, Math.Abs(scaleX), Math.Abs(scaleY));

            fusion.DisplayRectangle = rectangle;

            UpdateFusionUI(index);

            CellData cellData = (CellData)_cell.Tag;

            if (cellData.SyncCellFusion)
            {
                UpdateCellFusions(fusion, subCellIndex, index);
            }

            _cell.Invalidate();
        }
Exemplo n.º 3
0
        LeadPointD GetPointExtension(LeadPointD point1, double angle, double distance, double factor)
        {
            double dXRatio = factor * distance * Math.Cos(angle);
            double dYRatio = factor * distance * Math.Sin(angle);

            LeadPointD resultPoint = LeadPointD.Create((point1.X + dXRatio), (point1.Y + dYRatio));

            return(resultPoint);
        }
        private void CalculateIntersectionPoint()
        {
            double firstLineLength, cos, sin, newX, firstLinePosition;

            if (Points.Count < 4)
            {
                _intersectionPoint = LeadPointD.Empty;

                return;
            }

            LeadPointD Line1FirstPoint  = Points[0];
            LeadPointD Line1SecondPoint = Points[1];
            LeadPointD Line2FirstPoint  = Points[2];
            LeadPointD Line2SecondPoint = Points[3];

            //If either line1 length is 0 or line2 length is 0 return empty point.
            if (LeadPointD.Equals(Line2FirstPoint, Line2SecondPoint))
            {
                _intersectionPoint = LeadPointD.Empty;

                return;
            }

            //Translate the system so that line1 first point is on the origin.
            Line1SecondPoint.X -= Line1FirstPoint.X; Line1SecondPoint.Y -= Line1FirstPoint.Y;
            Line2FirstPoint.X  -= Line1FirstPoint.X; Line2FirstPoint.Y -= Line1FirstPoint.Y;
            Line2SecondPoint.X -= Line1FirstPoint.X; Line2SecondPoint.Y -= Line1FirstPoint.Y;

            //Calculate first line length.
            firstLineLength = (float)Math.Sqrt((float)(Line1SecondPoint.X * Line1SecondPoint.X + Line1SecondPoint.Y * Line1SecondPoint.Y));

            //Rotate the system so that first line second point is on the positive X axis.
            cos  = Line1SecondPoint.X / firstLineLength;
            sin  = Line1SecondPoint.Y / firstLineLength;
            newX = Line2FirstPoint.X * cos + Line2FirstPoint.Y * sin;
            Line2FirstPoint.Y = Line2FirstPoint.Y * cos - Line2FirstPoint.X * sin; Line2FirstPoint.X = newX;
            newX = Line2SecondPoint.X * cos + Line2SecondPoint.Y * sin;
            Line2SecondPoint.Y = Line2SecondPoint.Y * cos - Line2SecondPoint.X * sin; Line2SecondPoint.X = newX;

            //If the lines are parallel return empty point.
            if (Line2FirstPoint.Y == Line2SecondPoint.Y)
            {
                _intersectionPoint = LeadPointD.Empty;

                return;
            }

            //Find the position of the intersection point along first line
            firstLinePosition = Line2SecondPoint.X + (Line2FirstPoint.X - Line2SecondPoint.X) * Line2SecondPoint.Y / (Line2SecondPoint.Y - Line2FirstPoint.Y);

            //Apply the founded position to first line in the original coordinate system.

            _intersectionPoint = LeadPointD.Create(Line1FirstPoint.X + firstLinePosition * cos, Line1FirstPoint.Y + firstLinePosition * sin);
        }
Exemplo n.º 5
0
        void CreateDefaultLayers()
        {
            string[] layers = new string[] { "Red", "Green", "Blue" };

            LeadRectD rect = new LeadRectD(LeadPointD.Create(860, 700), LeadPointD.Create(5200, 1850));

            foreach (string layer in layers)
            {
                CreateRectangle(rect, AnnSolidColorBrush.Create(layer), CreateLayer(string.Format("{0} Layer", layer)));
                rect.Offset(360, 360);
            }
        }
Exemplo n.º 6
0
        public static LeadPointD[] GetCornerPoints(LeadRectD rect)
        {
            bool isEmpty = rect.IsEmpty;

            LeadPointD[] corners =
            {
                !isEmpty ? LeadPointD.Create(rect.Left,  rect.Top) : LeadPointD.Create(0,    0),
                !isEmpty ? LeadPointD.Create(rect.Right, rect.Top) : LeadPointD.Create(0,    0),
                !isEmpty ? LeadPointD.Create(rect.Right, rect.Bottom) : LeadPointD.Create(0, 0),
                !isEmpty ? LeadPointD.Create(rect.Left,  rect.Bottom) : LeadPointD.Create(0, 0),
            };

            return(corners);
        }
Exemplo n.º 7
0
        protected override void RenderItemPlaceholder(ImageViewerRenderEventArgs e)
        {
            // This method is called while an item is being loaded and give us a chance
            // to offer a hint to the user

            // Lets render a Loading ... message on the item
            var transform = this.ImageViewer.GetItemImageTransform(e.Item);

            var graphics = e.PaintEventArgs.Graphics;
            var pt       = LeadPointD.Create(0, 0);

            pt = transform.Transform(pt);
            graphics.DrawString("Loading...", this.ImageViewer.Font, Brushes.Black, (float)pt.X, (float)pt.Y);
        }
        // Fire the AutomationPointerMove event
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (!IsAutomationAttached || !AutomationEnabled)
            {
                return;
            }

            if (AutomationPointerMove != null)
            {
                // Convert the point to automation location
                LeadPointD location = LeadPointD.Create(e.Location.X, e.Location.Y);
                AutomationPointerMove(this, AnnPointerEventArgs.Create(AnnMouseButton.Left, location));
            }
        }
Exemplo n.º 9
0
        private void UpdateFusionEditRectangle(int index)
        {
            int subCellIndex = _cell.ActiveSubCell;

            MedicalViewerSubCell subCell        = _cell.SubCells[subCellIndex];
            MedicalViewerFusion  fusion         = _cell.SubCells[subCellIndex].Fusion[index];
            AnnRectangleObject   fusionEditRect = ((AnnRectangleObject)subCell.AnnotationContainer.Children[index]);
            double scaleRatio = _cell.GetScale(subCellIndex) / 100;

            Point location = _cell.GetDisplayedImageRectangle().Location;

            AnnContainer container = subCell.AnnotationContainer;
            double       scale     = _cell.GetScale(subCellIndex);

            LeadSizeD fusionEditRectSize = new LeadSizeD();

            fusionEditRectSize.Width  = fusion.FusedImage.Width * fusion.DisplayRectangle.Width * scale / 100;
            fusionEditRectSize.Height = fusion.FusedImage.Height * fusion.DisplayRectangle.Height * scale / 100;

            fusionEditRectSize = container.Mapper.SizeToContainerCoordinates(fusionEditRectSize);

            LeadPointD fusionEditRectPos = new LeadPointD();

            fusionEditRectPos.X = (subCell.AnnotationContainer.Size.Width - fusionEditRectSize.Width) / 2;
            fusionEditRectPos.Y = (subCell.AnnotationContainer.Size.Height - fusionEditRectSize.Height) / 2;

            //container.Bounds
            fusionEditRect.Rect = new LeadRectD(fusionEditRectPos, fusionEditRectSize);

            AnnContainer _Container = GetContainer(_cell, fusionEditRect);

            fusionEditRect.Rotate(fusion.Rotation, new LeadPointD(_Container.Size.Width / 2, _Container.Size.Height / 2));
            LeadPointD point = LeadPointD.Create(fusion.DisplayRectangle.X * fusion.FusedImage.Width * scaleRatio + location.X, fusion.DisplayRectangle.Y * fusion.FusedImage.Height * scaleRatio + location.Y);

            point = _Container.Mapper.PointToContainerCoordinates(point);
            fusionEditRect.Translate(point.X, point.Y);

            fusionEditRect.RotateCenter = new LeadPointD(fusionEditRect.Rect.Left + (fusionEditRect.Rect.Width / 2), fusionEditRect.Rect.Top + (fusionEditRect.Rect.Height / 2));

            _cell.RefreshAnnotation();
            _cell.Automation.Invalidate(LeadRectD.Empty);
            _cell.Invalidate();
        }
Exemplo n.º 10
0
        public override LeadPointD[] GetThumbLocations()
        {
            LeadPointD[] locations = null;

            LeadPointD[] points      = TargetObject.Points.ToArray();
            int          pointsCount = points.Length / 2;

            LeadPointD[] pts = new LeadPointD[pointsCount];

            for (int i = 0; i < pointsCount; ++i)
            {
                int        index = i * 2;
                LeadPointD start = points[index];
                LeadPointD end   = points[index + 1];
                pts[i] = LeadPointD.Create((start.X + end.X) / 2, (start.Y + end.Y) / 2);
            }

            locations = pts;

            return(locations);
        }
Exemplo n.º 11
0
        protected override bool EndWorking()
        {
            LeadPointD[] points = _objectTemplate.Points.ToArray();

            if (points != null && points.Length > 0)
            {
                _annParallelLinesObject.Points.Add(points[0]);
                _annParallelLinesObject.Points.Add(points[1]);

                int lineCount = LinesCount - 2;
                if (LinesCount > 0)
                {
                    int    x      = (lineCount + 1);
                    double height = _objectTemplate.Rect.Height / x;

                    LeadPointD start = points[0];
                    LeadPointD end   = points[1];

                    for (int i = 0; i < lineCount; ++i)
                    {
                        start = LeadPointD.Create(start.X, start.Y + height);
                        end   = LeadPointD.Create(end.X, end.Y + height);

                        _annParallelLinesObject.Points.Add(SnapPointToGrid(start, false));
                        _annParallelLinesObject.Points.Add(SnapPointToGrid(end, false));
                    }
                }

                _annParallelLinesObject.Points.Add(points[2]);
                _annParallelLinesObject.Points.Add(points[3]);
            }

            _annParallelLinesObject.Labels["AnnObjectName"] = _objectTemplate.Labels["AnnObjectName"].Clone();

            Container.Children.Remove(_objectTemplate);
            TargetObject = _annParallelLinesObject;
            Container.Children.Add(_annParallelLinesObject);
            return(base.EndWorking());
        }
Exemplo n.º 12
0
        private void _rasterImageViewer_MouseMove(object sender, MouseEventArgs e)
        {
            string str;

            if (_rasterImageViewer.Image != null)
            {
                // Show the mouse position in physical and logical (inches) coordinates

                PointF physical = new PointF(e.X, e.Y);
                PointF pixels;

                LeadMatrix  LeadM = _rasterImageViewer.ImageTransform;
                Matrix      M     = new Matrix((float)LeadM.M11, (float)LeadM.M12, (float)LeadM.M21, (float)LeadM.M22, (float)LeadM.OffsetX, (float)LeadM.OffsetY);
                Transformer trans = new Transformer(M);
                pixels = trans.PointToLogical(physical);

                // Convert the logical point to inches
                LeadPointD inches = Automation.Container.Mapper.PointFromContainerCoordinates(LeadPointD.Create((int)pixels.X, (int)pixels.Y), AnnFixedStateOperations.Scrolling | AnnFixedStateOperations.Zooming);

                str = string.Format("{0},{1} px {2},{3} in", (int)pixels.X, (int)pixels.Y, inches.X.ToString("F02"), inches.Y.ToString("F02"));
            }
            else
            {
                str = string.Empty;
            }

            _mousePositionLabel.Text = str;
        }