Exemplo n.º 1
0
 private CodeY <Angle> MyCoderY(LayoutX x, LayoutY y)
 {
     return(new CodeY <Angle>
     {
         Cy = GeoEu.Angle(0, 0, x.Lx, y.Ly),
     });
 }
Exemplo n.º 2
0
 private CodeX <Distance> MyCoderX(LayoutX x, LayoutY y)
 {
     return(new CodeX <Distance>
     {
         Cx = Distance.FromMeter(GeoEu.Length(x.Lx, y.Ly)),
     });
 }
Exemplo n.º 3
0
        public LayoutPos GetLayoutPos(Angle A)
        {
            var lw   = TargetProcess.PositionerX(CodeX <Distance> .From(TargetProcess.Width / 2 + Width / 2), CodeY <Distance> .From(TargetProcess.Height / 2 + Height / 2));
            var lh   = TargetProcess.PositionerY(CodeX <Distance> .From(TargetProcess.Width / 2 + Width / 2), CodeY <Distance> .From(TargetProcess.Height / 2 + Height / 2));
            var lpos = TargetProcess.GetLayoutPos();                  // Parts Location
            var lois = GeoEu.GetLocationOfInscribedSquareInCircle(A); // Connector Location Unit (0.7 times)

            return(LayoutPos.From(
                       lpos.X                // Parts Location
                       + lw * MathUtil.Root2 // R (Circle of the four vertices)
                       * lois.X,             // Location of inscribed square in circle
                       lpos.Y                // Parts Location
                       + lh * MathUtil.Root2 // R (Circle of the four vertices)
                       * lois.Y              // Location of inscribed square in circle
                       ));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Visualize
        /// </summary>
        /// <param name="dp"></param>
        public override void Draw(DrawProperty dp)
        {
            // Connector grip size
            var lcsz = LayoutSize.From(PositionerX(CodeX <Distance> .From(Width), null), PositionerY(null, CodeY <Distance> .From(Height)));
            var scsz = ScreenSize.From(dp.Pane, lcsz);

            // Process Size
            var spsz0 = ScreenSize.From(dp.Pane, LayoutSize.From(PositionerX(CodeX <Distance> .From(ProcessFrom.Width), null), PositionerY(null, CodeY <Distance> .From(ProcessFrom.Height))));
            var spsz1 = ScreenSize.From(dp.Pane, LayoutSize.From(PositionerX(CodeX <Distance> .From(ProcessTo.Width), null), PositionerY(null, CodeY <Distance> .From(ProcessTo.Height))));
            var sc0   = ProcessFrom.GetScreenPos(dp.Pane);
            var sc1   = ProcessTo.GetScreenPos(dp.Pane);

            _angle0 = GeoEu.Angle(sc0.X.Sx, sc0.Y.Sy, sc1.X.Sx, sc1.Y.Sy);
            var k0  = GeoEu.GetLocationOfInscribedSquareInCircle(_angle0);
            var sr0 = ScreenRect.FromCS(ScreenPos.From(sc0.X + k0.X * (spsz0.Width + scsz.Width) / MathUtil.Root2, sc0.Y + -k0.Y * (spsz0.Height + scsz.Height) / MathUtil.Root2), scsz);

            var a1  = GeoEu.Angle(sc1.X.Sx, sc1.Y.Sy, sc0.X.Sx, sc0.Y.Sy);
            var k1  = GeoEu.GetLocationOfInscribedSquareInCircle(a1);
            var sr1 = ScreenRect.FromCS(ScreenPos.From(sc1.X + k1.X * (spsz1.Width + scsz.Width) / MathUtil.Root2, sc1.Y + -k1.Y * (spsz1.Height + scsz.Height) / MathUtil.Root2), scsz);

            _p0 = sr0.C + ScreenPos.From(k0.X * sr0.Width / MathUtil.Root2, -k0.Y * sr0.Height / MathUtil.Root2);
            _p1 = sr1.C;

            // from: on the grip edge
            switch (State)
            {
            case States.SELECTING:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.Red);
                break;

            case States.HOVER:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.Cyan);
                break;

            default:
                dp.Graphics.DrawLine(_(_p0), _(_p1), Colors.White);
                break;
            }
            dp.Graphics.DrawRectangle(_(sr0), Colors.White);
            dp.Graphics.FillRectangle(_(sr1), Colors.White);
        }
Exemplo n.º 5
0
        public override float SelectingScore(IDrawArea pane, ScreenPos pos)
        {
            var width = 6.0f;
            var l     = _p0.LengthTo(_p1);
            var a     = _p0.AngleTo(_p1);
            var ml    = _p0.LengthTo(pos);
            var ma    = _p0.AngleTo(pos);

            GeoEu.Position(0, 0, ma - a, ml, out var mpx, out var mpy);

            var ret = (float)(Math.Abs(mpy) / width);

            if (ret <= 1.0f)
            {
                if (mpx < 0 || mpx > l)
                {
                    ret = float.PositiveInfinity;
                }
            }
            return(ret);
        }
Exemplo n.º 6
0
        public Angle GetAngle(LayoutPos lpos)
        {
            var lpos0 = TargetProcess.GetLayoutPos(); // Parts Location

            return(GeoEu.Angle(0.0, 0.0, lpos.X.Lx - lpos0.X.Lx, -(lpos.Y.Ly - lpos0.Y.Ly)));
        }
Exemplo n.º 7
0
        /// <summary>
        /// マウスWheelイベント
        /// </summary>
        /// <param name="e"></param>
        public void OnMouseWheel(MouseState e)
        {
            if (e.Attr.Equals(_trigger))
            {
                // 選択ペーンの描画領域の中心をズームのセンターの設定
                var _posDown = new ScreenPos
                {
                    X = e.Pane.GetPaneRect().LT.X + e.Pos.X - e.Pane.GetPaneRect().LT.X,
                    Y = e.Pane.GetPaneRect().LT.Y + e.Pos.Y - e.Pane.GetPaneRect().LT.Y
                };
                var _scrollDown = (ScreenPos)Pane.Scroll.Clone();
                var _zoomDown   = (XyBase)Pane.Zoom.Clone();
                var vol         = (int)(GeoEu.Length(Pane.Zoom.X, Pane.Zoom.Y) / 1000 * e.Delta.Y * 0.1);

                // 画面の拡大/縮小

                XyBase zoomNow;
                if (_isX && !_isY)
                {
                    zoomNow = Pane.Zoom + XyBase.FromInt(vol, 0);          // ズーム値の算出
                }
                else if (!_isX && _isY)
                {
                    zoomNow = Pane.Zoom + XyBase.FromInt(0, vol);          // ズーム値の算出
                }
                else
                {
                    zoomNow = Pane.Zoom + vol;                          // ズーム値の算出
                }
                // ズーム値を規定範囲内に収める
                if (zoomNow.X > 4000)
                {
                    zoomNow.X = 4000;
                }

                if (zoomNow.Y > 4000)
                {
                    zoomNow.Y = 4000;
                }

                if (zoomNow.X < 5)
                {
                    zoomNow.X = 5;
                }

                if (zoomNow.Y < 5)
                {
                    zoomNow.Y = 5;
                }

                Pane.Zoom = (XyBase)zoomNow.Clone();           // ズーム値の反映

                // クリックした位置を基準にしてズームするように画面をスクロールする。
                var ZoomRatioX = (double)zoomNow.X / _zoomDown.X;                     // X方向のズーム率の算出
                var ZoomRatioY = (double)zoomNow.Y / _zoomDown.Y;                     // Y方向のズーム率の算出

                var beforeDownPos = _posDown - _scrollDown - e.Pane.GetPaneRect().LT; //
                var afterDownPos  = ScreenPos.FromInt((int)(ZoomRatioX * beforeDownPos.X), (int)(ZoomRatioY * beforeDownPos.Y));

                if (_noscrollmove.value == false)
                {
                    Pane.Scroll = _scrollDown - (afterDownPos - beforeDownPos);
                }
                else
                {
                    _noscrollmove.value = false;
                }
                Pane.Invalidate(null);
            }
            else
            {
                OnMouseUp(e);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// selection score
        /// </summary>
        /// <param name="pane"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        public float SelectingScore(IDrawArea pane, ScreenPos pos)
        {
            var s1 = GetScreenPos(pane);

            return((float)GeoEu.Length(s1.X.Sx, s1.Y.Sy, pos.X.Sx, pos.Y.Sy) / DotR);
        }