コード例 #1
0
 public virtual void Redo()
 {
     m_owner.P1     = HitUtil.PointOncircle(m_owner.Center, m_endValue, HitUtil.DegressToRadians(Angle1));
     m_owner.P2     = HitUtil.PointOncircle(m_owner.Center, m_endValue, HitUtil.DegressToRadians(Angle2));
     m_owner.P3     = HitUtil.PointOncircle(m_owner.Center, m_endValue, HitUtil.DegressToRadians(Angle3));
     m_owner.Radius = m_endValue;
 }
コード例 #2
0
        UnitPoint RadiusNodePoint(ICanvas canvas)
        {
            double r     = Radius + canvas.ToUnit(8);
            float  angle = StartAngle + SweepAngle / 2;

            return(HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(angle)));
        }
コード例 #3
0
 private UnitPoint EndAngleNodePoint(ICanvas canvas)
 {
     try
     {
         double r = Radius + canvas.ToUnit(8);
         return(HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(EndAngle)));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #4
0
 public void UpdateCenterNodeFromAngles()
 {
     try
     {
         float angle = StartAngle + SweepAngle / 2;
         P2 = HitUtil.PointOncircle(m_center, m_radius, HitUtil.DegressToRadians(angle));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #5
0
 private UnitPoint RadiusNodePoint(ICanvas canvas)
 {
     try
     {
         double r     = Radius + canvas.ToUnit(8);
         float  angle = StartAngle + SweepAngle / 2;
         return(HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(angle)));
     }
     catch (Exception ex)
     { throw ex; }
 }
コード例 #6
0
        public virtual void Finish()
        {
            //float Angle1 = (float)HitUtil.RadiansToDegrees(HitUtil.LineAngleR(m_owner.Center,m_owner.P1, 0));
            //float Angle2 = (float)HitUtil.RadiansToDegrees(HitUtil.LineAngleR(m_owner.Center, m_owner.P2, 0));
            //float Angle3 = (float)HitUtil.RadiansToDegrees(HitUtil.LineAngleR(m_owner.Center, m_owner.P3, 0));
            //Console.WriteLine(Angle1);
            m_owner.P1 = HitUtil.PointOncircle(m_clone.Center, m_clone.Radius, HitUtil.DegressToRadians(Angle1));
            m_owner.P2 = HitUtil.PointOncircle(m_clone.Center, m_clone.Radius, HitUtil.DegressToRadians(Angle2));
            m_owner.P3 = HitUtil.PointOncircle(m_clone.Center, m_clone.Radius, HitUtil.DegressToRadians(Angle3));

            m_endValue       = m_clone.Radius;
            m_owner.Radius   = m_clone.Radius;
            m_owner.Selected = true;
            m_clone          = null;
        }
コード例 #7
0
        /*
         * UnitPoint GetPoint()
         * {
         *      if (m_curPoint == Arc3Point.eCurrentPoint.p1)
         *              return m_clone.P1;
         *      if (m_curPoint == Arc3Point.eCurrentPoint.p2)
         *              return m_clone.P2;
         *      if (m_curPoint == Arc3Point.eCurrentPoint.p3)
         *              return m_clone.P3;
         *      if (m_curPoint == Arc3Point.eCurrentPoint.startangle)
         *              return m_clone.P1;
         *      if (m_curPoint == Arc3Point.eCurrentPoint.endangle)
         *              return m_clone.P3;
         *      if (m_curPoint == Arc3Point.eCurrentPoint.radius)
         *              return m_clone.P2;
         *      return UnitPoint.Empty;
         * }
         * */
        void SetPoint(Arc3Point arc, UnitPoint pos)
        {
            if (m_curPoint == Arc3Point.eCurrentPoint.p1)
            {
                arc.P1 = pos;
            }
            if (m_curPoint == Arc3Point.eCurrentPoint.p2)
            {
                arc.P2 = pos;
            }
            if (m_curPoint == Arc3Point.eCurrentPoint.p3)
            {
                arc.P3 = pos;
            }

            double angleToRound = 0;

            if (Control.ModifierKeys == Keys.Control)
            {
                angleToRound = HitUtil.DegressToRadians(45);
            }
            double angleR = HitUtil.LineAngleR(arc.Center, pos, angleToRound);

            if (m_curPoint == Arc3Point.eCurrentPoint.startangle)
            {
                arc.P1 = HitUtil.PointOncircle(arc.Center, arc.Radius, angleR);
            }
            if (m_curPoint == Arc3Point.eCurrentPoint.endangle)
            {
                arc.P3 = HitUtil.PointOncircle(arc.Center, arc.Radius, angleR);
            }
            if (m_curPoint == Arc3Point.eCurrentPoint.radius)
            {
                double radius = HitUtil.Distance(arc.Center, pos);
                arc.P1 = HitUtil.PointOncircle(arc.Center, radius, HitUtil.DegressToRadians(arc.StartAngle));
                arc.P2 = pos;
                arc.P3 = HitUtil.PointOncircle(arc.Center, radius, HitUtil.DegressToRadians(arc.EndAngle));
            }

            arc.UpdateArcFrom3Points();

            if ((m_curPoint == Arc3Point.eCurrentPoint.startangle) || (m_curPoint == Arc3Point.eCurrentPoint.endangle))
            {
                arc.UpdateCenterNodeFromAngles();
            }
        }
コード例 #8
0
        UnitPoint EndAngleNodePoint(ICanvas canvas)
        {
            double r = Radius + canvas.ToUnit(8);

            return(HitUtil.PointOncircle(m_center, r, HitUtil.DegressToRadians(EndAngle)));
        }
コード例 #9
0
        /// <summary>
        /// 根据角度来更新圆弧的中点
        /// </summary>
        public void UpdateCenterNodeFromAngles()
        {
            float angle = StartAngle + SweepAngle / 2;

            P2 = HitUtil.PointOncircle(m_center, m_radius, HitUtil.DegressToRadians(angle));
        }
コード例 #10
0
 protected UnitPoint AnglePoint(float angle)
 {
     return(HitUtil.PointOncircle(m_center, m_radius, HitUtil.DegressToRadians(angle)));
 }
コード例 #11
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(HitUtil.PointOncircle(m_center, m_radius, 0), point, thWidth))
                        {
                            return(new VertextSnapPoint(canvas, this, HitUtil.PointOncircle(m_center, m_radius, 0)));
                        }
                        if (HitUtil.PointInPoint(HitUtil.PointOncircle(m_center, m_radius, 360), point, thWidth))
                        {
                            return(new VertextSnapPoint(canvas, this, HitUtil.PointOncircle(m_center, m_radius, 360)));
                        }
                    }
                }
                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(DivisionSnapPoint))
            {
                double    angle = 360 / 8;
                UnitPoint p     = HitUtil.NearestPointOnCircle(m_center, m_radius, point, angle);
                if (p != UnitPoint.Empty)
                {
                    return(new DivisionSnapPoint(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);


            //       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(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;
        }