Exemple #1
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     if (move.GrabType == GrabTypes.SingleVertex || move.GrabType == GrabTypes.Radius)             // not sure how I want to display them graphically yet, but the functionality will be the same
     {
         int    index    = move.ShapeIndex;
         int    previous = (index + 3) % 4;
         int    next     = (index + 1) % 4;
         int    opposite = (index + 2) % 4;
         PointF target   = Geometry.ClosestPointOnLine(Vertices[opposite], Vertices[index], move.Current.Exact);
         if (target.ApproxEqual(Vertices[opposite]))
         {
             return;
         }
         Vertices[index] = target;
         SizeF  vector = Vertices[opposite].VectorTo(Vertices[index]).MultiplyBy(0.5f);
         PointF centre = Vertices[opposite] + vector;
         vector             = new SizeF(-vector.Height, vector.Width);
         Vertices[previous] = centre + vector;
         Vertices[next]     = centre - vector;
         DiscardPath();
     }
     else
     {
         base.DoGrabMove(move);
     }
 }
Exemple #2
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            // Cannot use the base version, because it will try and move vertices (1) rather than the last vertex
            if (move.GrabType != GrabTypes.SingleVertex)
            {
                Utilities.LogSubError("Connector: unexpected grab move type");
                return;
            }
            int index;             // the index of the vertex; objMove.Index is the end index (0|1)

            switch (move.ShapeIndex)
            {
            case 0:
                index = 0;
                break;

            case 1:
                index = Vertices.Count - 1;
                break;

            default:
                Utilities.LogSubError("Connector: unexpected grab move index");
                return;
            }
            PointF newPoint = Vertices[index];

            move.Transform.TransformPoint(ref newPoint);
            Vertices[index] = newPoint;
            UpdateLink(move.ShapeIndex, move.Current);
            PositionLine();
        }
Exemple #3
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            // although any point can be moved, we cannot use the base class which assumes they are completely independent
            if (move.GrabType == GrabTypes.SingleVertex)
            {
                PointF centre = Geometry.MidPoint(Vertices[0], Vertices[2]);
                if (move.Current.Snapped.ApproxEqual(centre))
                {
                    return;
                }
                int index = move.ShapeIndex;
                // calculation is done on the vector from centre point to the moving point.  The direction of this is maintained (so this cannot rotate the rhombus)
                // (technically, it would be possible to do a rotation and update all 4 points, but it's probably a bit odd from a UI perspective)
                SizeF existingVector = centre.VectorTo(Vertices[index]);
                SizeF requested      = centre.VectorTo(move.Current.Snapped);
                SizeF resultVector   = Geometry.ProjectionVector(requested, existingVector);

                int opposite = (index + 2) % 4;
                // check it is not degenerate:
                Vertices[index]    = centre + resultVector;
                Vertices[opposite] = centre - resultVector;
                m_Bounds           = CalculateBounds();
                DiscardPath();
            }
            else
            {
                base.DoGrabMove(move);
            }
        }
Exemple #4
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     // although any point can be moved, we cannot use the base class which assumes they are completely independent
     if (move.GrabType == GrabTypes.SingleVertex)
     {
         // the indices of the other points:
         int index    = move.ShapeIndex;
         int previous = (index + 3) % 4;
         int next     = (index + 1) % 4;
         int opposite = (index + 2) % 4;
         // check it is not degenerate:
         if (Geometry.PointApproxOnLine(Vertices[previous], Vertices[next], move.Current.Snapped))
         {
             return;
         }
         Vertices[index]    = move.Current.Snapped;
         Vertices[opposite] = Vertices[previous] + Vertices[index].VectorTo(Vertices[next]);
         m_Bounds           = CalculateBounds();
         DiscardPath();
     }
     else
     {
         base.DoGrabMove(move);
     }
 }
Exemple #5
0
 internal override void DoGrabAngleSnap(GrabMovement move)
 {
     if (move.GrabType != GrabTypes.SingleVertex)
     {
         base.DoGrabAngleSnap(move);
     }
 }
Exemple #6
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            switch (move.GrabType)
            {
            case GrabTypes.SingleVertex:
                PointF ptNew = Vertices[1];
                move.Transform.TransformPoint(ref ptNew);
                if (ptNew.ApproxEqual(Vertices[0]))
                {
                    return;
                }
                if (HasCaret)
                {
                    CaretRealculateCoordinates(false);
                }
                Vertices[1] = ptNew;
                ClearTextCache();
                m_Bounds = CalculateBounds();
                break;

            default:
                base.DoGrabMove(move);
                break;
            }
        }
Exemple #7
0
 internal override void DoGrabAngleSnap(GrabMovement move)
 {
     if (move.GrabType == GrabTypes.SingleVertex)
     {
         if (Closed() || move.ShapeIndex > 0 || move.ShapeIndex < Vertices.Count - 1)
         {
             int previous = move.ShapeIndex > 0 ? move.ShapeIndex - 1 : Vertices.Count - 1;
             int next     = (move.ShapeIndex + 1) % Vertices.Count;
             move.Current.Snapped = Geometry.AngleSnapFromTwoPoints(move.Current.Exact, Vertices[previous], Vertices[next], false);
         }
         else if (move.ShapeIndex == 0)
         {
             // moving first point unclosed - just snap to pt2
             move.Current.Snapped = Geometry.AngleSnapPoint(move.Current.Exact, Vertices[1]);
         }
         else
         {
             Debug.Assert(move.ShapeIndex == Vertices.Count - 1);
             move.Current.Snapped = Geometry.AngleSnapPoint(move.Current.Exact, Vertices[Vertices.Count - 2]);
         }
     }
     else
     {
         base.DoGrabAngleSnap(move);
     }
 }
Exemple #8
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            switch (move.GrabType)
            {
            case GrabTypes.SingleVertex:
            case GrabTypes.Bezier:
            case GrabTypes.BezierInactive:
                MaskShape.GrabMove(move);
                break;

            case GrabTypes.Fixed:                    // does nowt
                break;

            // these act just as base class would - use transform (which will be applied to both shapes)
            case GrabTypes.Move:
            case GrabTypes.Rotate:
            case GrabTypes.Radius:
            case GrabTypes.EdgeMoveV:
            case GrabTypes.EdgeMoveH:
            case GrabTypes.CornerResize:
            case GrabTypes.TextSelection:
                ApplyTransformation(move.Transform);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #9
0
 public bool MoveWithin(List <Shape> shapes, PointF target, GrabMovement move, Transaction transaction)
 {
     if (!(Element is IShapeContainer))
     {
         return(false);
     }
     return(ElementAsContainer.MoveWithin(shapes, target, move, transaction));
 }
Exemple #10
0
 internal override bool StartGrabMove(GrabMovement grab)
 {
     if (grab.SnapMode == SnapModes.Grid)
     {
         grab.SnapMode = SnapModes.Off;
     }
     return(base.StartGrabMove(grab));
 }
Exemple #11
0
 internal override void DoGrabAngleSnap(GrabMovement move)
 {
     if (move.GrabType != GrabTypes.SingleVertex)
     {
         base.DoGrabAngleSnap(move);
     }
     else
     {
         move.Current.Snapped = Geometry.AngleSnapPoint(move.Current.Exact, Vertices[0]);
     }
 }
Exemple #12
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     base.DoGrabMove(move);
     if (move.GrabType == GrabTypes.SingleVertex && m_Closed && move.ShapeIndex == 0)
     {
         // if moving the initial point, we must also move the closing point
         Vertices[Vertices.Count - 1] = Vertices[0];
     }
     this.SetControlPoints(0);             //Math.Max(objMove.Index - 1, 0))
     m_Bounds = RectangleF.Empty;
 }
Exemple #13
0
 internal override bool StartGrabMove(GrabMovement grab)
 {
     switch (grab.GrabType)
     {
     case GrabTypes.SingleVertex:
     case GrabTypes.Bezier:
     case GrabTypes.BezierInactive:
         grab.IncludeShape(Image);
         grab.IncludeShape(MaskShape);
         break;
     }
     return(base.StartGrabMove(grab));
 }
Exemple #14
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            switch (move.GrabType)
            {
            case GrabTypes.SingleVertex:
            {
                int index    = move.ShapeIndex;
                int previous = (index + 3) % 4;
                int next     = (index + 1) % 4;
                int opposite = (index + 2) % 4;
                // keep orientation unchanged.  Opposite point is only invariant.  Calc vectors from this to the 2 semi-moving points
                SizeF previousVector = Vertices[opposite].VectorTo(Vertices[previous]);
                SizeF nextVector     = Vertices[opposite].VectorTo(Vertices[next]);
                SizeF movingVector   = Vertices[opposite].VectorTo(move.Current.Snapped);
                previousVector = Geometry.ProjectionVector(movingVector, previousVector);
                nextVector     = Geometry.ProjectionVector(movingVector, nextVector);
                if (previousVector.Length() < Geometry.THINLINE || nextVector.Length() < Geometry.THINLINE)
                {
                    return;                                     // degenerate
                }
                Vertices[next]     = Vertices[opposite] + nextVector;
                Vertices[previous] = Vertices[opposite] + previousVector;
                Vertices[index]    = Vertices[previous] + nextVector;
                m_Bounds           = CalculateBounds();
            }
            break;

            case GrabTypes.Radius:
            {
                int    vertex    = move.ShapeIndex;                           // vertex at start of line
                int    end       = (move.ShapeIndex + 1) % 4;                 // and end of line
                int    previous  = (move.ShapeIndex + 3) % 4;                 // vertex at start of previous line leading to intVertex
                int    opposite  = (move.ShapeIndex + 2) % 4;                 // and at opposite corner; end of line leading from intEnd
                PointF newPoint  = Geometry.ClosestPointOnLine(Vertices[previous], Vertices[vertex], move.Current.Snapped);
                SizeF  newVector = Vertices[previous].VectorTo(newPoint);     // new length of the sides which are being stretched
                if (newVector.Length() < Geometry.THINLINE)
                {
                    return;
                }
                Vertices[vertex] = newPoint;
                Vertices[end]    = Vertices[opposite] + newVector;
                m_Bounds         = CalculateBounds();
            }
            break;

            default:
                base.DoGrabMove(move);
                break;
            }
            DiscardPath();
        }
Exemple #15
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            switch (move.GrabType)
            {
            case GrabTypes.SingleVertex:
                if (move.ShapeIndex != 1)
                {
                    Debug.Fail("Isosceles.DoGrabMove(SingleVertex): index must be 1");
                    return;
                }
                if (move.Current.Snapped.ApproxEqual(Vertices[0]))
                {
                    return;
                }
                int   direction      = base.TurnDirection();                  // maintain the same winding direction, and transverse length (i.e. from baseline to third point)
                float transverseSize = Geometry.DistancePointToLine(Vertices[0], Vertices[1], Vertices[2]);
                Vertices[1] = move.Current.Snapped;
                SizeF transverseVector = BaseVector().Perpendicular(direction);
                transverseVector = transverseVector.ChangeLength(transverseSize);                         // the correct, new vector from the midpoint of the baseline
                Vertices[2]      = PointF.Add(Geometry.MidPoint(Vertices[0], Vertices[1]), transverseVector);
                m_Bounds         = CalculateBounds();
                break;

            case GrabTypes.Radius:                     // this moves the last point
                if (move.ShapeIndex != 2)
                {
                    Debug.Fail("Isosceles.DoGrabMove(Radius): index must be 1");
                    return;
                }
                PointF original   = Vertices[2];
                SizeF  baseVector = BaseVector().MultiplyBy(0.5f);                        // actually half the base vector
                Vertices[2] = Geometry.PerpendicularPoint(Vertices[0], Vertices[0] + baseVector, move.Current.Exact);
                if (VerticesFormLine(0))
                {
                    Vertices[2] = original;                             // cannot store this
                }
                m_Bounds = CalculateBounds();
                break;

            default:
                base.DoGrabMove(move);
                break;
            }
            DiscardPath();
        }
Exemple #16
0
        protected virtual float GetAngularStep(Page objPage) => Geometry.PI / 4;         // 1 eighth of a circle - ie any multiple of 45°

        protected internal override void DoGrabMove(GrabMovement move)
        {
            switch (move.GrabType)
            {
            case GrabTypes.SingleVertex:
                //we need to ignore the transformation matrix and apply our adjustment
                if (AdjustPoint(move.ShapeIndex, move.Current))
                {
                    PointF pt = move.Current.Snapped;
                    Vertices[move.ShapeIndex] = pt;
                    m_Bounds = RectangleF.Empty;
                }
                break;

            default:
                base.DoGrabMove(move);
                break;
            }
        }
Exemple #17
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     if (move.GrabType == GrabTypes.Radius)
     {
         PointF centre = Centre;                 // because Centre function may not be all that fast
         if (centre.ApproxEqual(move.Current.Snapped))
         {
             return;
         }
         // update the radius, changing all points
         float radius = Geometry.DistanceBetween(centre, move.Current.Snapped);
         for (int vertex = 0; vertex <= Vertices.Count - 1; vertex++)
         {
             Vertices[vertex] = centre + centre.VectorTo(Vertices[vertex]).ChangeLength(radius);
         }
         DiscardPath();
         m_Bounds = RectangleF.Empty;
     }
     else
     {
         base.DoGrabMove(move);
     }
 }
Exemple #18
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     if (move.GrabType == GrabTypes.SingleVertex)
     {
         if (move.ShapeIndex != 1)
         {
             Debug.Fail("Equilateral.DoGrabMove(SingleVertex): index must be 1");
             return;
         }
         if (move.Current.Exact.ApproxEqual(Vertices[0]))
         {
             return;
         }
         int direction = base.TurnDirection();                 // maintain the same winding direction
         Vertices[1] = move.Current.Snapped;
         PlaceThird(direction);
         DiscardPath();
     }
     else
     {
         base.DoGrabMove(move);
     }
 }
Exemple #19
0
        protected internal override void DoGrabMove(GrabMovement move)
        {
            // we must implement the functionality at the base class, because we cannot use the version of this in Curve
            // however if we disallow single vertex movement there is almost no base functionality to be fitted
            m_Targets = null;
            // not really needed; but at the moment I have been leaving the targets in place for diagnostics
            switch (move.GrabType)
            {
            case GrabTypes.Move:
                this.ApplyTransformation(move.Transform);                         // will transform the control points
                m_Bounds = RectangleF.Empty;
                break;

            case GrabTypes.SingleVertex:
                PointF newPoint = Vertices[move.ShapeIndex];
                move.Transform.TransformPoint(ref newPoint);
                // we need to check that this point does not collide with the previous or next ones before actually storing it
                if (move.ShapeIndex > 0 && newPoint.ApproxEqual(Vertices[move.ShapeIndex - 1]))
                {
                    return;
                }
                if (move.ShapeIndex < Vertices.Count - 1 && newPoint.ApproxEqual(Vertices[move.ShapeIndex + 1]))
                {
                    return;
                }
                Vertices[move.ShapeIndex] = newPoint;
                if (move.GrabType == GrabTypes.SingleVertex && m_Closed && move.ShapeIndex == 0)
                {
                    // if moving the initial point, we must also move the closing point
                    Vertices[Vertices.Count - 1] = Vertices[0];
                }
                // and we move the previous and next control points by a similar amount
                if (move.ShapeIndex > 0 || m_Closed)
                {
                    int previous = move.ShapeIndex * 2 - 1;
                    if (move.ShapeIndex == 0)
                    {
                        previous = m_ControlPoints.Count - 1;
                    }
                    PointF temp = m_ControlPoints[previous];
                    move.Transform.TransformPoint(ref temp);
                    m_ControlPoints[previous] = temp;
#if DEBUG
                    if (m_ControlPoints[previous].ApproxEqual(Vertices[move.ShapeIndex]))
                    {
                        // splatter won't like this.  Shouldn't have been created in first place, but Andrew's doc had this
                        m_ControlPoints[previous] = Geometry.Interpolate(Vertices[move.ShapeIndex], Vertices[move.ShapeIndex - 1 % Vertices.Count], 0.25F);
                    }
#endif
                }
                if (move.ShapeIndex < m_DefinedVertices - 1 || m_Closed)
                {
                    int    control = move.ShapeIndex * 2 % (Vertices.Count * 2 - 2);
                    PointF temp    = m_ControlPoints[control];
                    move.Transform.TransformPoint(ref temp);
                    m_ControlPoints[control] = temp;
#if DEBUG
                    if (m_ControlPoints[control].ApproxEqual(Vertices[move.ShapeIndex]))
                    {
                        m_ControlPoints[control] = Geometry.Interpolate(Vertices[move.ShapeIndex], Vertices[(move.ShapeIndex + 1) % Vertices.Count], 0.25F);
                    }
#endif
                }
                m_Bounds = RectangleF.Empty;
                break;

            case GrabTypes.Rotate:
                base.DoGrabMove(move);
                break;

            default:
                Debug.Fail("Unexpected GrabSpot movement type in Pencil curve: " + move.GrabType);
                break;
            }
        }
Exemple #20
0
 internal override void DoGrabAngleSnap(GrabMovement move)
 {
     Element.DoGrabAngleSnap(move);
 }
Exemple #21
0
 protected internal override void DoGrabMove(GrabMovement move)
 {
     //base.DoGrabMove(move);
     Element.GrabMove(move);
 }
Exemple #22
0
 internal override bool StartGrabMove(GrabMovement grab)
 {
     base.StartGrabMove(grab);
     return(Element.StartGrabMove(grab));
 }
Exemple #23
0
 internal override bool StartGrabMove(GrabMovement grab)
 {
     base.StartGrabMove(grab);
     grab.SnapMode = SnapModes.Socket;
     return(true);
 }
Exemple #24
0
 internal override void DoGrabAngleSnap(GrabMovement move)
 {
     // can be ignored
 }
Exemple #25
0
 public void FinishedModifyingContents(Transaction transaction, GrabMovement move = null)
 {
     ElementAsContainer?.FinishedModifyingContents(transaction, move);
 }