Esempio n. 1
0
 internal LineShape(Paint2DForm parent, Point2F point0, Point2F point1, float strokeWidth, int selectedBrush) : base(parent)
 {
     _point0             = point0;
     _point1             = point1;
     _strokeWidth        = strokeWidth;
     _selectedBrushIndex = selectedBrush;
 }
        private WaveGate CalWaveGate()
        {
            float r1 = (float)Tools.DistanceBetween(displayer.coordinateSystem.OriginalPoint, mouseDownPosition);
            float r2 = (float)Tools.DistanceBetween(displayer.coordinateSystem.OriginalPoint, mouseDragPosition);

            //拖动距离太小不处理,这个判断主要是排除鼠标点击操作
            if (Math.Abs(r1 - r2) < 5 || Math.Abs(beginAngle - dragAngle) < 1)
            {
                return(null);
            }
            //发送波门位置信息
            Point2F         dragPosition = mouseDragPosition;
            PolarCoordinate c            = displayer.coordinateSystem.PointToCoordinate(mouseDownPosition);
            //float dis1 = c.ProjectedDis;
            float dis1 = c.Dis;

            c = displayer.coordinateSystem.PointToCoordinate(dragPosition);
            //float dis2 = c.ProjectedDis;
            float dis2 = c.Dis;

            float begin = Tools.FindSmallArcBeginAngle(beginAngle, dragAngle);
            float end   = Tools.FindSmallArcEndAngle(beginAngle, dragAngle);

            return(new WaveGate(begin, end, dis1, dis2, isSemiAutoWaveGate));
        }
        public override void MouseMove(object sender, MouseEventArgs e)
        {
            if (!isMouseDown)
            {
                return;
            }
            if (displayer.coordinateSystem.PointOutOfRange(e.Location)) //拖动超出极坐标范围,直接返回
            {
                return;
            }

            if (Tools.DistanceBetween(displayer.coordinateSystem.OriginalPoint, Tools.PointToPoint2F(e.Location)) < 5)
            {
                return;
            }

            //记录师表拖动位置
            mouseDragPosition = Tools.PointToPoint2F(e.Location);

            //计算鼠标拖动点的径向距离
            mouseDragPositionRadius = (float)Tools.DistanceBetween(displayer.coordinateSystem.OriginalPoint, Tools.PointToPoint2F(e.Location));

            //计算鼠标点击点在mouseDragPositionRadius长度上对应的坐标
            displayer.CoordinateSystem.RadiusWiseZoomPosition(mouseDownPosition, mouseDragPositionRadius);

            //计算鼠标拖动点在mouseDownPositionRadius长度上对应的坐标
            displayer.CoordinateSystem.RadiusWiseZoomPosition(Tools.PointToPoint2F(e.Location), mouseDownPositionRadius);

            //计算拖拽位置和坐标原点连线的正北夹角
            dragAngle = Tools.AngleToNorth(displayer.coordinateSystem.OriginalPoint, Tools.PointToPoint2F(e.Location));
        }
Esempio n. 4
0
        public Point2F Get_parametric_pt(double u)
        {
            if (_points.Count < 2)
            {
                return(_points[0]);
            }

            double offset = u * _len;

            int seg = _seg_offsets.BinarySearch(offset);

            // if there is no exact element found, binary search returns 1's complemented index of the
            // first larger element, so we use it to find last smaller element
            if (seg < 0)
            {
                seg = ~seg - 1;
            }

            offset -= _seg_offsets[seg];

            Point2F p1   = _points[seg];
            Point2F p2   = _points[seg + 1];
            double  dist = p2.DistanceTo(p1);
            double  x    = p1.X + offset / dist * (p2.X - p1.X);
            double  y    = p1.Y + offset / dist * (p2.Y - p1.Y);

            return(new Point2F(x, y));
        }
Esempio n. 5
0
        /* Adapted from http://www.ryanjuckett.com/programming/biarc-interpolation
         */
        private static Point2F calc_pm(Point2F p1, Vector2d t1, Point2F p2, Vector2d t2)
        {
            Vector2d v         = new Vector2d(p2 - p1);
            Vector2d t         = t1 + t2;
            double   v_dot_t   = v * t;
            double   t1_dot_t2 = t1 * t2;

            double d2;
            double d2_denom = 2 * (1 - t1_dot_t2);

            if (d2_denom == 0)  // equal tangents
            {
                d2_denom = 4.0 * (v * t2);

                d2 = v * v / d2_denom;

                if (d2_denom == 0)  // v perpendicular to tangents
                {
                    return(p1 + (v * 0.5).Point);
                }
            }
            else    // normal case
            {
                double d2_num = -v_dot_t + Math.Sqrt(v_dot_t * v_dot_t + 2 * (1 - t1_dot_t2) * (v * v));
                d2 = d2_num / d2_denom;
            }

            return((p1 + p2 + (d2 * (t1 - t2)).Point) * 0.5);
        }
Esempio n. 6
0
        protected override PathGeometry GetPathGeometry(SweepSection s, RenderTarget t)
        {
            var pbegin = CalIntersectionPoint(s.Begin + RotateAngle);
            var pend   = CalIntersectionPoint(s.End + RotateAngle);

            PathGeometry sweepSectionGraphic = t.Factory.CreatePathGeometry();
            GeometrySink gs     = sweepSectionGraphic.Open();
            Point2F      oPoint = ReferenceSystem.ScreenOriginalPoint.ToPoint2F();

            gs.BeginFigure(oPoint, FigureBegin.Filled);
            gs.AddLine(pbegin.ToPoint2F());
            //扇形的X轴Y轴半径是矩形框width的一半
            SizeF size = new SizeF((float)ReferenceSystem.ScreenWidth / 2, (float)ReferenceSystem.ScreenWidth / 2);

            //添加弧线
            ArcSegment arc = new ArcSegment(pend.ToPoint2F(), size, 0, SweepDirection.Clockwise, ArcSize.Small);

            gs.AddArc(arc);

            //添加第二条线
            gs.AddLine(oPoint);
            gs.EndFigure(FigureEnd.Closed);
            gs.Close();
            gs.Dispose();

            return(sweepSectionGraphic);
        }
Esempio n. 7
0
 public bool isOverlap(Point2F q)
 {
     bool inside = false;
     Point2F p1 = points[points.Length - 1];
     bool isP1yBigger = (p1.Y >= q.Y);
     for (int i = 0; i < points.Length; i++) {
         Point2F p2 = points[i];
         bool isP2yBigger = (p2.Y >= q.Y);
         // p1.y_ < q.y_ <= p2.y_ || p2.y_ < q.y_ <= p1.y_
         if (isP1yBigger != isP2yBigger) {
             /*
              * (p1.x_(p2.y_ - q.y_) - p2.x_(p1.y_ - q.y_)) / (p2.y_ - p1.y_) >= q.x_
              * isP2yBigger == true  �� p1.x_(p2.y_ - q.y_) - p2.x_(p1.y_ - q.y_) >= q.x_(p2.y_ - p1.y_)
              * isP2yBigger == false �� p1.x_(p2.y_ - q.y_) - p2.x_(p1.y_ - q.y_) <= q.x_(p2.y_ - p1.y_)
              */
             if (((p2.Y - q.Y) * (p1.X - p2.X)
                  >= (p2.X - q.X) * (p1.Y - p2.Y)) == isP2yBigger) {
                 inside = !inside;
             }
         }
         p1 = p2;
         isP1yBigger = isP2yBigger;
     }
     return inside;
 }
        const int dashStyleTimes = 10; //显示边界风格切换的次数,到达10次之后切换边界风格,DashDot->Dash或Dash->DashDot

        public GraphicWaveGateView(WaveGate waveGate, OverViewDisplayer ovd)
        {
            displayer = ovd;
            canvas    = displayer.Canvas;

            this.waveGate = waveGate;

            waveGateBrush = canvas.CreateSolidColorBrush(waveGate.IsSemiAuto ?
                                                         Tools.GetColorFFromRgb(255, 255, 0) :
                                                         Tools.GetColorFFromRgb(245, 222, 179));

            coodinateSystem = displayer.coordinateSystem;

            //Selected = false;

            PolarCoordinate c = new PolarCoordinate
            {
                Az = waveGate.BeginAngle,
                //ProjectedDis = waveGate.BeginDistance;    //之前版本将距离赋给ProjectedDis
                Dis = waveGate.BeginDistance
            };

            innerLeft = coodinateSystem.CoordinateToPoint(c);

            c.Az = waveGate.EndAngle;
            //c.ProjectedDis = waveGate.EndDistance;  //之前版本将距离赋给projectedDis
            c.Dis       = waveGate.EndDistance;
            outterRight = coodinateSystem.CoordinateToPoint(c);

            geometry = coodinateSystem.BuildWaveGateGeometry(innerLeft, outterRight);
        }
Esempio n. 9
0
 /// <summary>
 /// Peels the top shape at a given point,
 /// updates the render targets and puts the peeled shape to the stack of peelings.
 /// Used to enable removing a child shape - eg. a top shape in a layer
 /// </summary>
 /// <param name="point"></param>
 /// <param name="shapes"></param>
 /// <returns></returns>
 private DrawingShape PeelAtRecursive(Point2F point, IList <DrawingShape> shapes)
 {
     for (int i = shapes.Count - 1; i >= 0; i--)
     {
         if (shapes[i].HitTest(point))
         {
             if (shapes[i].ChildShapes == null)
             {
                 string statName = shapes[i].GetType().Name.Replace("Shape", " count");
                 UpdateStats(statName, -1);
                 peelings.Push(shapes[i]);
                 shapes.RemoveAt(i);
                 RefreshAll();
                 return(peelings.Peek());
             }
             DrawingShape shapePeeled = PeelAtRecursive(point, shapes[i].ChildShapes);
             if (shapePeeled == null)
             {
                 string statName = shapes[i].GetType().Name.Replace("Shape", " count");
                 UpdateStats(statName, -1);
                 peelings.Push(shapes[i]);
                 shapes.RemoveAt(i);
                 RefreshAll();
                 return(peelings.Peek());
             }
             return(shapePeeled);
         }
     }
     return(null);
 }
Esempio n. 10
0
        public void Point2F_IsConstructedProperly()
        {
            var result = new Point2F(123.45f, 456.78f);

            TheResultingValue(result)
                .ShouldBe(123.45f, 456.78f);
        }
Esempio n. 11
0
        public bool Contains_point(Point2F pt)
        {
            ulong[] h = hash(pt);

            for (int i = 0; i < 4; i++)
            {
                if (!_pool.ContainsKey(h[i]))
                {
                    continue;
                }

                foreach (Line2F seg in _pool[h[i]])
                {
                    if (pt.DistanceTo(seg.p1) < _tolerance)
                    {
                        return(true);
                    }
                    if (pt.DistanceTo(seg.p2) < _tolerance)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 12
0
        }                                                           //找矩形中心点

        public static float AngleToNorth(Point2F center, Point2F p) //两点连线与垂直线的夹角
        {
            var distance = (float)DistanceBetween(center, p);
            var x        = p.X - center.X;
            var angleR   = (float)Math.Asin(x / distance);
            var angle    = RadianToDegree(angleR);

            //float y = center.Y - p.Y;
            //double angleR1 = Math.Acos(y / distance);
            //angleR1 = RadianToDegree(angleR1);

            if (p.X >= center.X && p.Y <= center.Y)   //第一象限
            {
            }
            else if (p.X >= center.X && p.Y > center.Y) //第二象限
            {
                angle = 180 - angle;
            }
            else if (p.X < center.X && p.Y > center.Y) //第三象限
            {
                angle = 180 + Math.Abs(angle);
            }
            else//第四象限
            {
                angle = 360 + angle;
            }

            return((float)angle);
        }
Esempio n. 13
0
        public static double RadianToDegree(double radian) => 180 * radian / Math.PI; //弧度转角度

        public static Rect ZoomRectangle(Rect rect, double percent)                   //以rect的中心点为中心,将rect放缩percent的百分比
        {
            var    r = new Rect();
            var    location = new Point2F();
            double offsetX, offsetY;

            r.Width  = (int)(rect.Width * percent);
            r.Height = (int)(rect.Height * percent);

            if (percent < 1)    //缩小
            {
                offsetX    = (double)(rect.Width - r.Width) / 2;
                offsetY    = (double)(rect.Height - r.Height) / 2;
                location.X = rect.Left + (int)offsetX;
                location.Y = rect.Top + (int)offsetY;
            }
            else   //放大
            {
                offsetX    = (double)(r.Width - rect.Width) / 2;
                offsetY    = (double)(r.Height - rect.Height) / 2;
                location.X = rect.Left - (int)offsetX;
                location.Y = rect.Top - (int)offsetY;
            }

            r.Left    = (int)location.X + rect.Left;
            r.Top     = (int)location.Y + rect.Top;
            r.Right  += (int)(location.X);
            r.Bottom += (int)location.Y;
            return(r);
        }
Esempio n. 14
0
 public override bool HitTest(Point2F point)
 {
     return DestRect.Top <= point.Y &&
            DestRect.Bottom >= point.Y &&
            DestRect.Left <= point.X &&
            DestRect.Right >= point.X;
 }
Esempio n. 15
0
        //-------------------------------------------------------------------
        Arc2F arc(double r, bool large, bool sweep)
        {
            Point3F aLast = _poly.LastPoint;

            double[] rr = _parent.scale(r, r);
            double[] p1 = new double[2] {
                aLast.X, aLast.Y
            };
            double[] p2   = _parent.calc(_cursor.X, _cursor.Y);
            bool     left = (rr[0] == rr[1]) ? (sweep != large) : (sweep == large);

            double[]          c1  = Geometry.circle_center(p1, p2, rr [0], left);
            double[]          c2  = Geometry.circle_center(p1, p2, rr [0], !left);
            RotationDirection dir = (sweep == (rr[0] == rr[1])) ? RotationDirection.CCW : RotationDirection.CW;

            _parent.trace("arc    ... c1=[{0}]  c2=[{1}] p1=[{2}]  p2=[{3}] d={4}"
                          , ToString(c1), ToString(c2)
                          , ToString(p1), ToString(p2)
                          , dir);
            //RotationDirection dir = (p1 [0] < p2 [0] && sweep)
            //	? RotationDirection.CCW : RotationDirection.CW;
            Point2F aCC = new Point2F(c1 [0], c1 [1]);
            Point2F aP1 = new Point2F(p1 [0], p1 [1]);
            Point2F aP2 = new Point2F(p2 [0], p2 [1]);
            Arc2F   arc = new Arc2F(aCC, aP1, aP2, dir);

            return(arc);
        }
 public override bool HitTest(Point2F point)
 {
     return point.X >= rect.Left &&
         point.X <= rect.Right &&
         point.Y >= rect.Top &&
         point.Y <= rect.Bottom;
 }
 void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) != 0)
     {
         _start = new Point2F(e.X, e.Y);
     }
 }
Esempio n. 18
0
        public void Point2F_IsConstructedProperly()
        {
            var result = new Point2F(123.45f, 456.78f);

            TheResultingValue(result)
            .ShouldBe(123.45f, 456.78f);
        }
Esempio n. 19
0
        private double calc_ted(Point2F tool_center, double tool_r)
        {
            Circle2F parent_wall = new Circle2F(_parent.Center, _parent.Radius + tool_r);

            // find the points tool touching parent wall
            Circle2F cut_circle = new Circle2F(tool_center, tool_r);
            Line2F   insects    = cut_circle.CircleIntersect(parent_wall);

            if (insects.p1.IsUndefined || insects.p2.IsUndefined)
            {
                Logger.err("no wall intersections #0");
                return(0);
            }

            // we're interested in tool head point, so choose more advanced point in mill direction

            Vector2d v1 = new Vector2d(_parent.Center, insects.p1);
            Vector2d v_parent_to_tool_center = new Vector2d(_parent.Center, tool_center);
            Point2F  cut_head = v_parent_to_tool_center.Det(v1) * (int)this.Dir > 0 ? insects.p1 : insects.p2;

            // project headpoint to the center find TED
            Vector2d v_me_to_tool_center = new Vector2d(this.Center, tool_center);
            Vector2d v_me_to_cut_head    = new Vector2d(this.Center, cut_head);

            double ted = this.Radius + tool_r - v_me_to_cut_head * v_me_to_tool_center.Unit();

            return(ted > 0 ? ted : 0);
        }
Esempio n. 20
0
        public double Get_dist_to_wall(Point2F pt)
        {
            populate_t4();

            double radius = double.MaxValue;

            foreach (object item in _t4.Get_nearest_objects(pt.X, pt.Y))
            {
                double dist = 0;
                if (item is Line2F)
                {
                    ((Line2F)item).NearestPoint(pt, ref dist);
                }
                else
                {
                    ((Arc2F)item).NearestPoint(pt, ref dist);
                }
                if (dist < radius)
                {
                    radius = dist;
                }
            }

            return(radius);
        }
Esempio n. 21
0
        private (Point2F, Point2F) CalCenterSectorBorderIntersectorPoints()
        {
            Point2F sectorAngle2Point = displayer.coordinateSystem.CalIntersectionPoint(Tools.StandardAngle(_centerSectorBorderAngle1));
            Point2F sectorAngle3Point = displayer.coordinateSystem.CalIntersectionPoint(Tools.StandardAngle(_centerSectorBorderAngle2));

            return(sectorAngle2Point, sectorAngle3Point);
        }
Esempio n. 22
0
 /// <summary>
 /// Peels the top shape at a given point,
 /// updates the render targets and puts the peeled shape to the stack of peelings.
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 internal DrawingShape PeelAt(Point2F point)
 {
     lock (renderSyncObject)
     {
         return(PeelAtRecursive(point, drawingShapes));
     }
 }
Esempio n. 23
0
        private void insert_in_t4(Polyline p)
        {
            for (int i = 0; i < p.NumSegments; i++)
            {
                object  seg = p.GetSegment(i);
                T4_rect rect;

                if (seg is Line2F)
                {
                    Line2F line = ((Line2F)seg);
                    rect = new T4_rect(Math.Min(line.p1.X, line.p2.X),
                                       Math.Min(line.p1.Y, line.p2.Y),
                                       Math.Max(line.p1.X, line.p2.X),
                                       Math.Max(line.p1.Y, line.p2.Y));
                }
                else if (seg is Arc2F)
                {
                    Point2F min = Point2F.Undefined;
                    Point2F max = Point2F.Undefined;
                    ((Arc2F)seg).GetExtrema(ref min, ref max);
                    rect = new T4_rect(min.X, min.Y, max.X, max.Y);
                }
                else
                {
                    throw new Exception("unknown segment type");
                }

                _t4.Add(rect, seg);
            }
        }
        protected CoordinateTargetView(Target target, RenderTarget canvas, D2DFactory factory, CoordinateSystem coordinateSystem)
            : base(target)
        {
            if (target == null)
            {
                return;
            }

            this.canvas      = canvas;
            this.factory     = factory;
            CoordinateSystem = coordinateSystem;

            position = coordinateSystem.CoordinateToPoint(target.CurrentCoordinate);     //计算显示坐标

            activeRect = new Rect
            {
                Left   = (int)position.X - activeRectRadius,
                Top    = (int)position.Y - activeRectRadius,
                Right  = (int)position.X + activeRectRadius,
                Bottom = (int)position.Y + activeRectRadius
            };

            targetController = TargetManagerFactory.CreateTargetManagerController();
            targetViewBrush  = canvas.CreateSolidColorBrush(Tools.GetColorFFromRgb(255, 128, 0)); //橘黄
        }
Esempio n. 25
0
        private bool should_flip_opened_startpoint(Polyline poly, Point2F startpoint)
        {
            Point2F start = (Point2F)poly.FirstPoint;
            Point2F end   = (Point2F)poly.LastPoint;

            return(startpoint.DistanceTo(end) < startpoint.DistanceTo(start));
        }
Esempio n. 26
0
 public override bool HitTest(Point2F point)
 {
     return(DestRect.Top <= point.Y &&
            DestRect.Bottom >= point.Y &&
            DestRect.Left <= point.X &&
            DestRect.Right >= point.X);
 }
Esempio n. 27
0
        public void Point2F_SerializesToJson_WhenNullable()
        {
            var point = new Point2F(1.2f, 2.3f);
            var json  = JsonConvert.SerializeObject((Point2F?)point);

            TheResultingString(json).ShouldBe(@"{""x"":1.2,""y"":2.3}");
        }
Esempio n. 28
0
        public TextTargetView(Target target, TextDisplayer displayer, Point2F drawPoint) : base(target)
        {
            _displayer   = displayer;
            leftTop      = drawPoint;
            _columnWidth = displayer.ColumnWidth;
            _rects       = CalculateRects();
            activeRect   = CalculateActiveRect();
            _texts       = new List <string>();
            TargetTrack track = (TargetTrack)target;

            _texts.Add(track.TrackId.ToString());
            _texts.Add(track.Az.ToString("0.0"));
            _texts.Add(track.El.ToString("0.0"));
            _texts.Add(track.Dis.ToString("0.0"));
            _texts.Add(track.Speed.ToString("0.0"));

            _borderBrush = displayer.Canvas.CreateSolidColorBrush(new ColorF(1, 1, 1));
            DWriteFactory dw = DWriteFactory.CreateFactory();

            _inactiveTextFormat = dw.CreateTextFormat("宋体", 20);
            _inactiveTextFormat.TextAlignment = TextAlignment.Center;
            _inactiveBrush = displayer.Canvas.CreateSolidColorBrush(new ColorF(0, 1, 1));

            _activeBrush = displayer.Canvas.CreateSolidColorBrush(new ColorF(0, 0, 1));
        }
 public override bool HitTest(Point2F point)
 {
     EllipseGeometry g = d2DFactory.CreateEllipseGeometry(ellipse);
     bool ret = g.FillContainsPoint(point, 1);
     g.Dispose();
     return ret;
 }
Esempio n. 30
0
 public override bool HitTest(Point2F point)
 {
     return(point.X >= layoutRect.Left &&
            point.Y >= layoutRect.Top &&
            point.X <= layoutRect.Right &&
            point.Y <= layoutRect.Bottom);
 }
Esempio n. 31
0
        // with the manual startpoint, which is a hint
        private static Point2F prepare_segments_w_hinted_starpoint(Topographer topo, List <Line2F> segments, Segpool pool, double min_dist_to_wall, double general_tolerance, Point2F startpoint)
        {
            // same as automatic, but seek the segment with the closest end to startpoint
            double  min_dist   = double.MaxValue;
            Point2F tree_start = Point2F.Undefined;

            foreach (Line2F seg in segments)
            {
                double r1 = topo.Get_dist_to_wall(seg.p1);
                double r2 = topo.Get_dist_to_wall(seg.p2);

                if (r1 >= min_dist_to_wall)
                {
                    pool.Add(seg, false);
                    double dist = startpoint.DistanceTo(seg.p1);
                    if (dist < min_dist)
                    {
                        min_dist   = dist;
                        tree_start = seg.p1;
                    }
                }
                if (r2 >= min_dist_to_wall)
                {
                    pool.Add(seg, true);
                    double dist = startpoint.DistanceTo(seg.p2);
                    if (dist < min_dist)
                    {
                        min_dist   = dist;
                        tree_start = seg.p2;
                    }
                }
            }

            return(tree_start);
        }
 void SetDefualtValue()
 {
     BeginLinePoint = displayer.coordinateSystem.OriginalPoint;
     DragLinePoint  = displayer.coordinateSystem.OriginalPoint;
     BeginAngle     = 0f;
     DragAngle      = 0f;
 }
Esempio n. 33
0
        private void calc_teds(double tool_r)
        {
            // expand both slices to form walls
            Circle2F parent_wall = new Circle2F(_parent.Center, _parent.Radius + tool_r);
            Circle2F this_wall   = new Circle2F(this.Center, this.Radius + tool_r);

            // find the point of cut start (intersection of walls)
            Line2F wall_insects = parent_wall.CircleIntersect(this_wall);

            if (wall_insects.p1.IsUndefined || wall_insects.p2.IsUndefined)
            {
                Logger.err("no wall intersections #1");
                return;
            }

            Vector2d v_move   = new Vector2d(_parent.Center, this.Center);
            Vector2d v1       = new Vector2d(_parent.Center, wall_insects.p1);
            Point2F  cut_tail = v_move.Det(v1) * (int)this.Dir < 0 ? wall_insects.p1 : wall_insects.p2;
            Vector2d v_tail   = new Vector2d(this.Center, cut_tail);

            Point2F entry_tool_center = this.Center + (v_tail.Unit() * this.Radius).Point;

            _entry_ted = calc_ted(entry_tool_center, tool_r);

            Point2F mid_tool_center = this.Center + (v_move.Unit() * this.Radius).Point;

            _mid_ted = calc_ted(mid_tool_center, tool_r);
        }
Esempio n. 34
0
 public static float DistanceBetweenTwoPoint(Point2F pPoint1, Point2F pPoint2)
 {
     return((float)Math.Sqrt(
                Math.Pow(pPoint2.X - pPoint1.X, 2) +
                Math.Pow(pPoint2.Y - pPoint1.Y, 2)
                ));
 }
Esempio n. 35
0
        public void Point2F_Parse_CanRoundTrip()
        {
            var size1 = Point2F.Parse("123.4 456.7");
            var size2 = Point2F.Parse(size1.ToString());

            TheResultingValue(size1 == size2).ShouldBe(true);
        }
Esempio n. 36
0
 public override bool HitTest(Point2F point)
 {
     RoundedRectangleGeometry g = d2DFactory.CreateRoundedRectangleGeometry(rect);
     bool ret = g.FillContainsPoint(point, 1);
     g.Dispose();
     return ret;
 }
Esempio n. 37
0
 internal EllipseShape(Paint2DForm parent, Ellipse ellipse, float strokeWidth, int selectedBrush, bool fill)
     : base(parent, fill)
 {
     _startPoint = ellipse.Point;
     _ellipse = ellipse;
     _strokeWidth = strokeWidth;
     _selectedBrushIndex = selectedBrush;
 }
        internal LineShape(Paint2DForm parent, Point2F point0, Point2F point1, float strokeWidth, int selectedBrush) : base(parent)
        {
            _point0 = point0;
            _point1 = point1;
            _strokeWidth = strokeWidth;
            _selectedBrushIndex = selectedBrush;

        }
 internal GeometryShape(Paint2DForm parent, Point2F point0, float strokeWidth, int selectedBrush, bool fill)
     : base(parent)
 {
     _points = new List<Point2F> { point0 };
     _strokeWidth = strokeWidth;
     _selectedBrushIndex = selectedBrush;
     _fill = fill;
 }
Esempio n. 40
0
        public void Point2F_EqualsObject()
        {
            var size1 = new Point2F(123.45f, 456.78f);
            var size2 = new Point2F(123.45f, 456.78f);

            TheResultingValue(size1.Equals((Object)size2)).ShouldBe(true);
            TheResultingValue(size1.Equals("This is a test")).ShouldBe(false);
        }
Esempio n. 41
0
 public override bool HitTest(Point2F point)
 {
     return parameters.ContentBounds.Top <= point.Y &&
            parameters.ContentBounds.Bottom >= point.Y &&
            parameters.ContentBounds.Left <= point.X &&
            parameters.ContentBounds.Right >= point.X &&
            (GeometricMaskShape != null ? GeometricMaskShape.Geometry.FillContainsPoint(point, 5) : true) &&
            parameters.Opacity > 0;
 }
Esempio n. 42
0
 internal TextShape(Paint2DForm parent, TextLayout textLayout, Point2F startPoint, float maxX, float maxY, int selectedBrush)
     : base(parent)
 {
     _maxX = maxX;
     _maxY = maxY;
     _textLayout = textLayout;
     _selectedBrushIndex = selectedBrush;
     _point0 = startPoint;
 }
 public LineShape(RenderTarget initialRenderTarget, Random random, D2DFactory d2DFactory, D2DBitmap bitmap)
     : base(initialRenderTarget, random, d2DFactory, bitmap)
 {
     point0 = RandomPoint();
     point1 = RandomPoint();
     PenBrush = RandomBrush();
     StrokeWidth = RandomStrokeWidth();
     if (CoinFlip)
         StrokeStyle = RandomStrokeStyle();
 }
Esempio n. 44
0
        public void Point2F_OpInequality()
        {
            var size1 = new Point2F(123.45f, 456.78f);
            var size2 = new Point2F(123.45f, 456.78f);
            var size3 = new Point2F(123.45f, 555.55f);
            var size4 = new Point2F(222.22f, 456.78f);

            TheResultingValue(size1 != size2).ShouldBe(false);
            TheResultingValue(size1 != size3).ShouldBe(true);
            TheResultingValue(size1 != size4).ShouldBe(true);
        }
Esempio n. 45
0
 public override bool HitTest(Point2F point)
 {
     //bool isTrailingHit, isInside;
     //TextLayout.HitTestPoint(point.X, point.Y, out isTrailingHit, out isInside);
     //return (isTrailingHit || isInside);
     //the method below checks the layout box hit test instead of the DirectWrite method
     return point.X >= Point0.X &&
         point.Y >= Point0.Y &&
         point.X <= Point0.X + TextLayout.MaxWidth &&
         point.Y <= Point0.Y + TextLayout.MaxHeight;
 }
Esempio n. 46
0
        public void Point2F_EqualsPoint2F()
        {
            var size1 = new Point2F(123.45f, 456.78f);
            var size2 = new Point2F(123.45f, 456.78f);
            var size3 = new Point2F(123.45f, 555.55f);
            var size4 = new Point2F(222.22f, 456.78f);

            TheResultingValue(size1.Equals(size2)).ShouldBe(true);
            TheResultingValue(size1.Equals(size3)).ShouldBe(false);
            TheResultingValue(size1.Equals(size4)).ShouldBe(false);
        }
        private void GetSmoothingPoints(int i, out Point2F cp1, out Point2F cp2)
        {
            float smoothing = .25f; //0 - no smoothing
            float lx = _points[i].X - _points[i - 1].X;
            float ly = _points[i].Y - _points[i - 1].Y;
            float l = (float)Math.Sqrt(lx * lx + ly * ly); // distance from previous point
            float l1x = _points[i].X - _points[i - 2].X;
            float l1y = _points[i].Y - _points[i - 2].Y;
            float l1 = (float)Math.Sqrt(l1x * l1x + l1y * l1y); // distance between two points back and current point
            float l2x = _points[i + 1].X - _points[i - 1].X;
            float l2y = _points[i + 1].Y - _points[i - 1].Y;
            float l2 = (float)Math.Sqrt(l2x * l2x + l2y * l2y); //distance between previous point and the next point

            cp1 = new Point2F(
                _points[i - 1].X + (l1x == 0 ? 0 : (smoothing * l * l1x / l1)),
                _points[i - 1].Y + (l1y == 0 ? 0 : (smoothing * l * l1y / l1))
                );
            cp2 = new Point2F(
                _points[i].X - (l2x == 0 ? 0 : (smoothing * l * l2x / l2)),
                _points[i].Y - (l2y == 0 ? 0 : (smoothing * l * l2y / l2))
                );
        }
Esempio n. 48
0
 public override bool HitTest(Point2F point)
 {
     return geometry.FillContainsPoint(point, FlatteningTolerance);
 }
Esempio n. 49
0
        public override bool HitTest(Point2F point)
        {
            foreach (var ellipse in ellipses)
            {

                EllipseGeometry g = d2DFactory.CreateEllipseGeometry(new Ellipse(
                    new Point2F(
                        (ellipse.rect.Left + ellipse.rect.Right) / 2,
                        (ellipse.rect.Top + ellipse.rect.Bottom) / 2),
                        ellipse.rect.Width / 2,
                        ellipse.rect.Height / 2));
                bool ret = g.FillContainsPoint(point, 1);
                g.Dispose();
                if (ret)
                    return true;
            }
            return false;
        }
Esempio n. 50
0
/// <summary>
/// (Point2 pos) - gets the terrain height at the specified position.				@param pos The world space point, minus the z (height) value Can be formatted as either (\"x y\") or (x,y)				@return Returns the terrain height at the given point as an F32 value.				@hide)
/// </summary>
public  float getTerrainHeight(Point2F pos){


return m_ts.fn_getTerrainHeight(pos.AsString());
}
Esempio n. 51
0
/// <summary>
/// Return the integer character code value corresponding to the first character in the given string.
/// )
/// 
/// </summary>
public  Point2F dnt_testcase_7(Point2F chr){


return new Point2F ( m_ts.fn_dnt_testcase_7(chr.AsString()));
}
Esempio n. 52
0
        public void Point2F_SerializesToJson_WhenNullable()
        {
            var point = new Point2F(1.2f, 2.3f);
            var json = JsonConvert.SerializeObject((Point2F?)point);

            TheResultingString(json).ShouldBe(@"{""x"":1.2,""y"":2.3}");
        }
Esempio n. 53
0
/// <summary>
///  Set the width and height of the control.   @hide )
/// </summary>
public  void GuiControl_setExtent(string guicontrol, Point2F ext){


m_ts.fn_GuiControl_setExtent(guicontrol, ext.AsString());
}
Esempio n. 54
0
 public TextLayoutShape(RenderTarget initialRenderTarget, Random random, D2DFactory d2DFactory, D2DBitmap bitmap, DWriteFactory dwriteFactory)
     : base(initialRenderTarget, random, d2DFactory, bitmap, dwriteFactory)
 {
     RandomizeTextLayout();
     Point0 = RandomPoint();
 }
 /// <summary>
 /// Wraps the specified unit test result for evaluation.
 /// </summary>
 /// <param name="value">The value to wrap.</param>
 /// <returns>The wrapped value.</returns>
 protected static Point2FResult TheResultingValue(Point2F value)
 {
     return new Point2FResult(value);
 }
Esempio n. 56
0
 public override bool HitTest(Point2F point)
 {
     if (geometry != null)
     {
         return geometry.HitTest(point);
     }
     if (triangles != null)
     {
         foreach (var triangle in triangles)
         {
             if (IsPointInTriangle(triangle, point))
                 return true;
         }
     }
     return false;
 }
public  void setOrigin(Point2F pos){

pInvokes.m_ts.fn_GuiTerrPreviewCtrl_setOrigin(_ID, pos.AsString());
}
Esempio n. 58
0
 private static bool IsPointInTriangle(Triangle triangle, Point2F point)
 {
     //no time to implement the proper algorithm, so let's just use a bounding rectangle...
     float left = Math.Min(triangle.Point1.X, Math.Min(triangle.Point2.X, triangle.Point3.X));
     float right = Math.Max(triangle.Point1.X, Math.Max(triangle.Point2.X, triangle.Point3.X));
     float top = Math.Min(triangle.Point1.Y, Math.Min(triangle.Point2.Y, triangle.Point3.Y));
     float bottom = Math.Max(triangle.Point1.Y, Math.Max(triangle.Point2.Y, triangle.Point3.Y));
     return point.X >= left &&
         point.X <= right &&
         point.Y >= top &&
         point.Y <= bottom;
 }
Esempio n. 59
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="point"></param>
        /// <param name="extent"></param>
        public RectF(Point2F point, Point2F extent)
        {
            _mPoint_x = point.x;
            _mPoint_y = point.y;
            _mExtent_x = extent.x;
            _mExtent_y = extent.y;

            //_mPoint = point;
            //_mPoint.DetachAllEvents();
            //_mExtent = extent;
            //_mExtent.DetachAllEvents();
            //_mExtent.OnChangeNotification += __OnChangeNotification;
            //_mPoint.OnChangeNotification += __OnChangeNotification;
        }
        private void renderControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (!isDrawing)
                return;

            isDragging = true;
            startPoint.X = e.X;
            startPoint.Y = e.Y;
            endPoint = startPoint;

            switch (currentShapeType)
            {
                case Shape.Line:
                    currentShape = new LineShape(this, startPoint, startPoint, currentStrokeSize, currentBrushIndex);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.Bitmap:
                    currentShape = new BitmapShape(
                            this,
                            new RectF(startPoint.X, startPoint.Y, startPoint.X + 5, startPoint.Y + 5),
                            currentBitmap, currentTransparency);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.RoundedRectangle:
                    currentShape = new RoundRectangleShape(this,
                            new RoundedRect(
                                new RectF(startPoint.X, startPoint.Y, startPoint.X, startPoint.Y),
                                20f, 20f),
                                currentStrokeSize,
                                currentBrushIndex, fill);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.Rectangle:
                    currentShape = new RectangleShape(this,
                                new RectF(startPoint.X, startPoint.Y, startPoint.X, startPoint.Y),
                                currentStrokeSize,
                                currentBrushIndex, fill);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.Ellipse:
                    currentShape = new EllipseShape(this,
                                new Ellipse(startPoint, 0, 0),
                                currentStrokeSize,
                                currentBrushIndex, fill);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.Text:
                    currentShape = new TextShape(this, textDialog.TextLayout, startPoint, 100, 100, currentBrushIndex);
                    drawingShapes.Add(currentShape);
                    break;
                case Shape.Geometry:
                    currentShape = new GeometryShape(this, startPoint, currentStrokeSize, currentBrushIndex, fill);
                    drawingShapes.Add(currentShape);
                    break;
            }
            Invalidate();
        }