Exemplo n.º 1
0
 private void Image_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
 {
     MarkerSet.Location location = sender == StartImage ? MarkerSet.Location.START_IMAGE : MarkerSet.Location.END_IMAGE;
     _morphingAlgorithm.MarkerSet.OnRightMouseButtonDown(location, ComputeRelativeImagePositionFromMouseEvent(sender, e),
                                                         new Vector(((Image)sender).ActualWidth, ((Image)sender).ActualHeight));
     UpdateOutputImageContent();
 }
Exemplo n.º 2
0
        public override void OnRightMouseButtonDown(MarkerSet.Location clickLocation, Vector imageCor, Vector imageSizePixel)
        {
            if (_dragedStartPoint >= 0)
            {
                _markerList.RemoveAt(_dragedStartPoint);
            }
            else if (_dragedEndPoint >= 0)
            {
                _markerList.RemoveAt(_dragedEndPoint);
            }
            else
            {
                int hit = PointHitTest(Lines.Select(x => x[clickLocation].End), imageCor, imageSizePixel);
                if (hit >= 0)
                {
                    _markerList.RemoveAt(hit);
                }
                else
                {
                    hit = PointHitTest(Lines.Select(x => x[clickLocation].Start), imageCor, imageSizePixel);
                    if (hit >= 0)
                    {
                        _markerList.RemoveAt(hit);
                    }
                }
            }

            _dragedStartPoint = -1;
            _dragedEndPoint   = -1;
        }
Exemplo n.º 3
0
        public override void OnLeftMouseButtonDown(MarkerSet.Location clickLocation, Vector imageCor, Vector imageSizePixel)
        {
            // selection?
            if (_hoveredStartPoint >= 0 || _hoveredEndPoint >= 0)
            {
                _dragedEndPoint   = _hoveredEndPoint;
                _dragedStartPoint = _hoveredStartPoint;
                return;
            }

            // add new
            _dragBoth       = true;
            _dragedEndPoint = _markerList.Count;
            LineMarker newLine = new LineMarker()
            {
                StartMarker = new Line()
                {
                    Start = imageCor, End = imageCor + new Vector(MIN_LINE_LENGTH, 0.0)
                },
                EndMarker = new Line()
                {
                    Start = imageCor, End = imageCor + new Vector(MIN_LINE_LENGTH, 0.0)
                },
                InterpolatedMarker = new Line()
                {
                    Start = imageCor, End = imageCor
                }
            };

            _markerList.Add(newLine);
        }
Exemplo n.º 4
0
 public override bool OnMouseMove(MarkerSet.Location clickLocation, Vector imageCor, Vector imageSizePixel)
 {
     if (_dragedStartPoint >= 0)
     {
         var marker = ((LineMarker)_markerList[_dragedStartPoint])[clickLocation];
         if ((marker.End - imageCor).Length > MIN_LINE_LENGTH)
         {
             marker.Start = imageCor;
         }
         if (_dragBoth)
         {
             marker = ((LineMarker)_markerList[_dragedStartPoint])[clickLocation == Location.START_IMAGE ? Location.END_IMAGE : Location.START_IMAGE];
             if ((marker.End - imageCor).Length > MIN_LINE_LENGTH)
             {
                 marker.Start = imageCor;
             }
         }
         _markerList[_dragedStartPoint].UpdateInterpolatedMarker(_lastInterpolationFactor);
         return(true);
     }
     else if (_dragedEndPoint >= 0)
     {
         var marker = ((LineMarker)_markerList[_dragedEndPoint])[clickLocation];
         if ((marker.Start - imageCor).Length > MIN_LINE_LENGTH)
         {
             marker.End = imageCor;
         }
         if (_dragBoth)
         {
             marker = ((LineMarker)_markerList[_dragedEndPoint])[clickLocation == Location.START_IMAGE ? Location.END_IMAGE : Location.START_IMAGE];
             if ((marker.Start - imageCor).Length > MIN_LINE_LENGTH)
             {
                 marker.End = imageCor;
             }
         }
         _markerList[_dragedEndPoint].UpdateInterpolatedMarker(_lastInterpolationFactor);
         return(true);
     }
     else
     {
         _hoveredEndPoint = PointHitTest(Lines.Select(x => x[clickLocation].End), imageCor, imageSizePixel);;
         if (_hoveredEndPoint < 0)
         {
             _hoveredStartPoint = PointHitTest(Lines.Select(x => x[clickLocation].Start), imageCor, imageSizePixel);
         }
         else
         {
             _hoveredStartPoint = -1;
         }
         return(false);
     }
 }
Exemplo n.º 5
0
        private void Image_MouseMove(object sender, MouseEventArgs e)
        {
            MarkerSet.Location location = sender == StartImage ? MarkerSet.Location.START_IMAGE : MarkerSet.Location.END_IMAGE;
            bool changedMarker          = _morphingAlgorithm.MarkerSet.OnMouseMove(location, ComputeRelativeImagePositionFromMouseEvent(sender, e),
                                                                                   new Vector(((Image)sender).ActualWidth, ((Image)sender).ActualHeight));

            if (!_animationPlayer.IsEnabled && changedMarker)
            {
                UpdateOutputImageContent();
            }
            else
            {
                UpdateMarkerCanvases(location);
            }
        }
Exemplo n.º 6
0
        public override bool OnMouseMove(MarkerSet.Location clickLocation, Vector imageCor, Vector imageSizePixel)
        {
            if (clickLocation == Location.NONE)
            {
                return(false);
            }

            _hoveredMarker = MarkerHitTest(clickLocation, imageCor, imageSizePixel);

            if (_selectedMarker >= 0)
            {
                ((PointMarker)_markerList[_selectedMarker])[clickLocation] = imageCor;
                _markerList[_selectedMarker].UpdateInterpolatedMarker(_lastInterpolationFactor);
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
        public override bool OnMouseMove(MarkerSet.Location clickLocation, Vector imageCor, Vector imageSizePixel)
        {
            if (clickLocation == Location.NONE)
            {
                return(false);
            }

            _hoveredMarker = MarkerHitTest(clickLocation, imageCor, imageSizePixel);

            if (_selectedMarker >= NUM_NONEDITABLE_MARKER)
            {
                ((Vertex)_markerList[_selectedMarker])[clickLocation] = imageCor;
                _markerList[_selectedMarker].UpdateInterpolatedMarker(_lastInterpolationFactor);

                // recompute delauny triangulation!
                _triangles = MIConvexHull.DelaunayTriangulation <Vertex, TriangleMarker> .Create(Vertices).Cells;

                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        private void UpdateMarkerCanvases(MarkerSet.Location location)
        {
            if (_morphingAlgorithm.MarkerSet != null)
            {
                switch (location)
                {
                case MarkerSet.Location.END_IMAGE:
                case MarkerSet.Location.START_IMAGE:
                    _morphingAlgorithm.MarkerSet.UpdateMarkerCanvas(MarkerSet.Location.START_IMAGE, StartImageMarkerCanvas,
                                                                    new Vector((StartImageMarkerCanvas.ActualWidth - StartImage.ActualWidth) / 2, (StartImageMarkerCanvas.ActualHeight - StartImage.ActualHeight) / 2),
                                                                    new Vector(StartImage.ActualWidth, StartImage.ActualHeight));
                    _morphingAlgorithm.MarkerSet.UpdateMarkerCanvas(MarkerSet.Location.END_IMAGE, EndImageMarkerCanvas,
                                                                    new Vector((EndImageMarkerCanvas.ActualWidth - EndImage.ActualWidth) / 2, (EndImageMarkerCanvas.ActualHeight - EndImage.ActualHeight) / 2),
                                                                    new Vector(EndImage.ActualWidth, EndImage.ActualHeight));
                    break;

                case MarkerSet.Location.OUTPUT_IMAGE:
                    _morphingAlgorithm.MarkerSet.UpdateMarkerCanvas(MarkerSet.Location.OUTPUT_IMAGE, OutputImageMarkerCanvas,
                                                                    new Vector((OutputImageMarkerCanvas.ActualWidth - OutputImage.ActualWidth) / 2, (OutputImageMarkerCanvas.ActualHeight - OutputImage.ActualHeight) / 2),
                                                                    new Vector(OutputImage.ActualWidth, OutputImage.ActualHeight));
                    break;
                }
            }
        }