Esempio n. 1
0
        public override INodePoint NodePoint(ICanvas canvas, UnitPoint point)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(Center, point, thWidth))
            {
                return(new NodePointArcCenter(this));
            }
            bool radiushit = HitUtil.PointInPoint(AnglePoint(0), point, thWidth);

            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(90), point, thWidth);
            }
            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(180), point, thWidth);
            }
            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(270), point, thWidth);
            }
            if (radiushit)
            {
                m_curPoint  = eCurrentPoint.radius;
                m_lastPoint = Center;
                return(new NodePointArcRadius(this));
            }
            return(null);
        }
Esempio n. 2
0
        public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(m_center, point, thWidth))
            {
                return(new NodePointArcCenter(this));
            }
            if (HitUtil.PointInPoint(StartAnglePoint, point, thWidth))
            {
                m_curPoint  = eCurrentPoint.startAngle;
                m_lastPoint = m_center;
                return(new NodePointArcAngle(this));
            }
            if (HitUtil.PointInPoint(EndAnglePoint, point, thWidth))
            {
                m_curPoint  = eCurrentPoint.endAngle;
                m_lastPoint = m_center;
                return(new NodePointArcAngle(this));
            }
            if (HitUtil.PointInPoint(RadiusPoint, point, thWidth))
            {
                m_curPoint  = eCurrentPoint.radius;
                m_lastPoint = m_center;
                return(new NodePointArcRadius(this));
            }
            return(null);
        }
Esempio n. 3
0
        public ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List <IDrawObject> otherobj, Type[] runningsnaptypes, Type usersnaptype)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (runningsnaptypes != null)
            {
                foreach (Type snaptype in runningsnaptypes)
                {
                    UnitPoint ptemp = UnitPoint.Empty;
                    if (snaptype == typeof(VertextSnapPoint))
                    {
                        ptemp = GetPointFromVertexId(eVertexId.LeftTopCorner);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new VertextSnapPoint(canvas, this, ptemp, (int)eVertexId.LeftTopCorner));//left top corner
                        }
                        ptemp = GetPointFromVertexId(eVertexId.RightBottomCorner);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new VertextSnapPoint(canvas, this, ptemp, (int)eVertexId.RightBottomCorner));//right bottom corner
                        }
                    }
                    if (snaptype == typeof(MidpointSnapPoint))
                    {
                        ptemp = GetPointFromVertexId(eVertexId.BottomEdgeMidPoint);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.BottomEdgeMidPoint));//bottom edge center
                        }
                        ptemp = GetPointFromVertexId(eVertexId.TopEdgeMidPoint);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.TopEdgeMidPoint));//top edge center
                        }
                        ptemp = GetPointFromVertexId(eVertexId.LeftEdgeMidPoint);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.LeftEdgeMidPoint));//left edge center
                        }
                        ptemp = GetPointFromVertexId(eVertexId.RigthEdgeMidPoint);
                        if (HitUtil.CircleHitPoint(ptemp, thWidth, point))
                        {
                            return(new MidpointSnapPoint(canvas, this, ptemp, (int)eVertexId.RigthEdgeMidPoint));//right edge center
                        }
                    }
                    if (snaptype == typeof(CenterSnapPoint))
                    {
                        if (HitUtil.PointInPoint(m_center, point, thWidth))
                        {
                            return(new CenterSnapPoint(canvas, this, m_center));
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 4
0
        public INodePoint NodePoint(UnitPoint unitPoint)
        {
            float thWidth = UCCanvas.GetThresholdWidth();

            for (int i = 0; i < this.SideCount; i++)
            {
                if (HitUtil.PointInPoint(this.hexagonPoints[i], unitPoint, thWidth))
                {
                    return(new NodeHexagon(this, i));
                }
            }
            return(null);
        }
Esempio n. 5
0
        public INodePoint NodePoint(UnitPoint unitPoint)
        {
            float thWidth = UCCanvas.GetThresholdWidth();

            for (int i = 0; i < this.MultiLinePoints.Count; i++)
            {
                if (HitUtil.PointInPoint(this.MultiLinePoints[i], unitPoint, thWidth))
                {
                    INodePoint nodePoint = new NodeMultiLine(this, i);
                    this.currentNodeIndex = i;
                    return(nodePoint);
                }
            }
            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// 判断指定点是否在绘图对象中
        /// </summary>
        /// <param name="canvas"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public virtual bool PointInObject(ICanvas canvas, UnitPoint point)
        {
            RectangleF boundingrect = GetBoundingRect(canvas);

            if (boundingrect.Contains(point.Point) == false)
            {
                return(false);
            }
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(m_center, point, thWidth))
            {
                return(true);
            }
            return(HitUtil.IsPointInCircle(m_center, m_radius, point, thWidth / 2));
        }
Esempio n. 7
0
        public bool PointInObject(UnitPoint unitPoint)
        {
            RectangleF rectangleF = this.GetBoundingRectangle(BoundingRectangleType.All);

            if (rectangleF.Contains(unitPoint.Point) == false)
            {
                return(false);
            }
            float thresholdWidth = UCCanvas.GetThresholdWidth();

            if (HitUtil.PointInPoint(this.P1, unitPoint, thresholdWidth))
            {
                return(true);
            }
            return(HitUtil.IsPointInCircle(this.P1, this.radius, unitPoint, thresholdWidth / 2));
        }
Esempio n. 8
0
        public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(P1, point, thWidth))
            {
                m_lastPoint = P1;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.p1));
            }
            if (HitUtil.PointInPoint(P2, point, thWidth))
            {
                m_lastPoint = P2;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.p2));
            }
            if (HitUtil.PointInPoint(P3, point, thWidth))
            {
                m_lastPoint = P3;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.p3));
            }
            UnitPoint p = StartAngleNodePoint(canvas);

            if (HitUtil.PointInPoint(p, point, thWidth))
            {
                m_lastPoint = p;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.startangle));
            }
            p = EndAngleNodePoint(canvas);
            if (HitUtil.PointInPoint(p, point, thWidth))
            {
                m_lastPoint = p;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.endangle));
            }
            p = RadiusNodePoint(canvas);
            if (HitUtil.PointInPoint(p, point, thWidth))
            {
                m_lastPoint = p;
                return(new NodePointArc3PointPoint(this, eCurrentPoint.radius));
            }
            return(null);
        }
Esempio n. 9
0
        public INodePoint NodePoint(UnitPoint unitPoint)
        {
            float thresholdWidth = UCCanvas.GetThresholdWidth();

            if (HitUtil.PointInPoint(this.LeftTopPoint, unitPoint, thresholdWidth))
            {
                return(new NodePointRectangle(this, NodePosition.LeftTop));
            }
            if (HitUtil.PointInPoint(this.RightTopPoint, unitPoint, thresholdWidth))
            {
                return(new NodePointRectangle(this, NodePosition.RightTop));
            }
            if (HitUtil.PointInPoint(this.RightBottomPoint, unitPoint, thresholdWidth))
            {
                return(new NodePointRectangle(this, NodePosition.RightBottom));
            }
            if (HitUtil.PointInPoint(this.LeftBottomPoint, unitPoint, thresholdWidth))
            {
                return(new NodePointRectangle(this, NodePosition.LeftBottom));
            }
            return(null);
        }
Esempio n. 10
0
        public virtual ISnapPoint SnapPoint(ICanvas canvas, UnitPoint point, List <IDrawObject> otherobj, Type[] runningsnaptypes, Type usersnaptype)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (runningsnaptypes != null)
            {
                foreach (Type snaptype in runningsnaptypes)
                {
                    if (snaptype == typeof(QuadrantSnapPoint))
                    {
                        UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 90);
                        if (p != UnitPoint.Empty && HitUtil.PointInPoint(p, point, thWidth))
                        {
                            return(new QuadrantSnapPoint(canvas, this, p));
                        }
                    }

                    //if (snaptype == typeof(DivisionSnapPoint))
                    //{
                    //    double angle = 360 / 8;
                    //    UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, angle);
                    //    if (p != UnitPoint.Empty && HitUtil.PointInPoint(p, point, thWidth))
                    //        return new DivisionSnapPoint(canvas, this, p);
                    //}

                    if (snaptype == typeof(CenterSnapPoint))
                    {
                        if (HitUtil.PointInPoint(m_center, point, thWidth))
                        {
                            return(new CenterSnapPoint(canvas, this, m_center));
                        }
                    }

                    if (snaptype == typeof(VertextSnapPoint))
                    {
                        if (HitUtil.PointInPoint(P1, point, thWidth))
                        {
                            return(new VertextSnapPoint(canvas, this, P1));
                        }
                        if (HitUtil.PointInPoint(P3, point, thWidth))
                        {
                            return(new VertextSnapPoint(canvas, this, P3));
                        }
                    }
                }
                return(null);
            }

            if (usersnaptype == typeof(NearestSnapPoint))
            {
                UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 0);
                if (p != UnitPoint.Empty)
                {
                    return(new NearestSnapPoint(canvas, this, p));
                }
            }
            if (usersnaptype == typeof(PerpendicularSnapPoint))
            {
                UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 0);
                if (p != UnitPoint.Empty)
                {
                    return(new PerpendicularSnapPoint(canvas, this, p));
                }
            }
            if (usersnaptype == typeof(QuadrantSnapPoint))
            {
                UnitPoint p = HitUtil.NearestPointOnCircle(m_center, m_radius, point, 90);
                if (p != UnitPoint.Empty)
                {
                    return(new QuadrantSnapPoint(canvas, this, p));
                }
            }
            if (usersnaptype == typeof(TangentSnapPoint))
            {
                IDrawObject drawingObject = canvas.CurrentObject;
                UnitPoint   p             = UnitPoint.Empty;
                if (drawingObject is LineEdit)
                {
                    UnitPoint mousepoint = point;
                    point = ((LineEdit)drawingObject).P1;
                    UnitPoint p1 = HitUtil.TangentPointOnCircle(m_center, m_radius, point, false);
                    UnitPoint p2 = HitUtil.TangentPointOnCircle(m_center, m_radius, point, true);
                    double    d1 = HitUtil.Distance(mousepoint, p1);
                    double    d2 = HitUtil.Distance(mousepoint, p2);
                    if (d1 <= d2)
                    {
                        return(new TangentSnapPoint(canvas, this, p1));
                    }
                    else
                    {
                        return(new TangentSnapPoint(canvas, this, p2));
                    }
                }
                //if (p != PointF.Empty)
                return(new TangentSnapPoint(canvas, this, p));
            }
            if (usersnaptype == typeof(CenterSnapPoint))
            {
                return(new CenterSnapPoint(canvas, this, m_center));
            }

            return(null);
        }
Esempio n. 11
0
        public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point)
        {
            //Console.WriteLine(m_p1.X+" "+m_p1.Y);
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(Center, point, thWidth))//圓心位移
            {
                return(new NodePointCircleCenter(this));
            }
            bool radiushit = HitUtil.PointInPoint(m_p1, point, thWidth);

            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(m_p2, point, thWidth);
            }
            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(m_p3, point, thWidth);
            }
            if (radiushit)
            {
                m_curPoint  = eCurrentPoint.radius;
                m_lastPoint = Center;
                return(new NodePointCircleRadius(this));
            }
            return(null);

            //float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);
            //if (HitUtil.PointInPoint(P1, point, thWidth))
            //{
            //    m_lastPoint = P1;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p1);
            //}
            //if (HitUtil.PointInPoint(P2, point, thWidth))
            //{
            //    m_lastPoint = P2;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p2);
            //}
            //if (HitUtil.PointInPoint(P3, point, thWidth))
            //{
            //    m_lastPoint = P3;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p3);
            //}
            //UnitPoint p = StartAngleNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.startangle);
            //}
            //p = EndAngleNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.endangle);
            //}
            //p = RadiusNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.radius);
            //}
            return(null);
        }
        private void MouseDownSetStartMovePoint(MouseEventArgs e)
        {
            UnitPoint   mousePoint = this.ToUnit(this.mouseDownPoint);
            IDrawObject hitObject  = this.Model.GetHitObject(mousePoint);

            if (hitObject != null && leadLineDone && hitObject.IsCloseFigure)
            {
                LineInOutParamsModel leadInOutParamsModel = CopyUtil.DeepCopy(hitObject.LeadInOutParams);
                leadInOutParamsModel.LinePosition      = LinePositions.FigureTotalLength;
                leadInOutParamsModel.FigureTotalLength = this.CalPercentByPoint(hitObject, mousePoint);
                this.Model.DoSetLeadwire(new List <IDrawObject>()
                {
                    hitObject
                }, new List <LineInOutParamsModel>()
                {
                    leadInOutParamsModel
                });
                this.DoInvalidate(true);
            }
            else//绘制引入线
            {
                if (this.leadLine == null)
                {
                    this.leadLine     = new LeadLine(mousePoint);
                    this.leadLineDone = false;
                }
                else
                {
                    if (hitObject != null)
                    {
                        LineInOutParamsModel leadInOutParamsModel = CopyUtil.DeepCopy(hitObject.LeadInOutParams);
                        leadInOutParamsModel.LinePosition = LinePositions.FigureTotalLength;
                        leadInOutParamsModel.LineInType   = CommomModel.DrawModel.LeadLine.LeadLineType.Line;
                        if (hitObject.IsCloseFigure)
                        {
                            DrawObjectMouseDown result = this.leadLine.OnMouseDown(mousePoint);
                            this.leadLine.CalLeadLineParams(hitObject, leadInOutParamsModel);
                            this.Model.DoSetLeadwire(new List <IDrawObject>()
                            {
                                hitObject
                            }, new List <LineInOutParamsModel>()
                            {
                                leadInOutParamsModel
                            });
                        }
                        else if (HitUtil.PointInPoint(mousePoint, hitObject.FirstDrawPoint, GetThresholdWidth()))
                        {
                            DrawObjectMouseDown result = this.leadLine.OnMouseDown(hitObject.FirstDrawPoint);
                            this.leadLine.CalLeadLineParams(hitObject, leadInOutParamsModel);
                            this.Model.DoSetLeadwire(new List <IDrawObject>()
                            {
                                hitObject
                            }, new List <LineInOutParamsModel>()
                            {
                                leadInOutParamsModel
                            });
                        }
                        this.leadLine     = null;
                        this.leadLineDone = true;
                    }
                    else
                    {
                        this.leadLine = new LeadLine(mousePoint);
                    }
                    this.DoInvalidate(true);
                }
            }
        }
Esempio n. 13
0
        public virtual INodePoint NodePoint(ICanvas canvas, UnitPoint point)
        {
            float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);

            if (HitUtil.PointInPoint(Center, point, thWidth))
            {
                return(new NodePointArcCenter(this));
            }
            bool radiushit = HitUtil.PointInPoint(AnglePoint(0), point, thWidth);

            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(90), point, thWidth);
            }
            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(180), point, thWidth);
            }
            if (radiushit == false)
            {
                radiushit = HitUtil.PointInPoint(AnglePoint(270), point, thWidth);
            }
            if (radiushit)
            {
                m_curPoint  = eCurrentPoint.radius;
                m_lastPoint = Center;
                return(new NodePointArcRadius(this));
            }
            return(null);

            //float thWidth = Line.ThresholdWidth(canvas, Width, ThresholdPixel);
            //if (HitUtil.PointInPoint(P1, point, thWidth))
            //{
            //    m_lastPoint = P1;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p1);
            //}
            //if (HitUtil.PointInPoint(P2, point, thWidth))
            //{
            //    m_lastPoint = P2;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p2);
            //}
            //if (HitUtil.PointInPoint(P3, point, thWidth))
            //{
            //    m_lastPoint = P3;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.p3);
            //}
            //UnitPoint p = StartAngleNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.startangle);
            //}
            //p = EndAngleNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.endangle);
            //}
            //p = RadiusNodePoint(canvas);
            //if (HitUtil.PointInPoint(p, point, thWidth))
            //{
            //    m_lastPoint = p;
            //    return new NodePointArc3PointPoint(this, eCurrentPoint.radius);
            //}
            //return null;
        }