Exemplo n.º 1
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// 両端点が選ばれると自動的に中心も選択
        /// </remarks>
        public override bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            bool result = base.SelectIt(rc, layerMask, pointMode);

            if (result)
            {
                if (selectFlag[0])
                {
                    //selectFlag[1]=true;
                    //selectFlag[2]=true;
                }
                else if (selectFlag[1] && selectFlag[2])
                {
                    if (!selectFlag[0])
                    {
                        if (LimitStartEnd())
                        {
                            selectFlag[2] = false;
                        }
                        else
                        {
                            //selectFlag[0] = true;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// ConChkのための種の取得
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <returns></returns>
        public override MbeObj ConChkSeed(MbeRect rc, ulong layerMask)
        {
            if (DeleteCount >= 0)
            {
                return(null);
            }


            if (contentsObj != null)
            {
                foreach (MbeObj obj in contentsObj)
                {
                    if (obj.Id() == MbeObjID.MbePTH ||
                        obj.Id() == MbeObjID.MbePinSMD ||
                        obj.Id() == MbeObjID.MbeLine)
                    {
                        if (obj.SelectIt(rc, layerMask, true))
                        {
                            obj.ClearAllSelectFlag();
                            return(obj);
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        public bool ScanData(Point startPoint, ulong _layerMask, LinkedList <MbeObj> objList)
        {
            Point   ptLT = new Point(startPoint.X - 1, startPoint.Y + 1);
            Point   ptRB = new Point(startPoint.X + 1, startPoint.Y - 1);
            MbeRect rc   = new MbeRect(ptLT, ptRB);

            MbeObj startObj = null;

            ulong layerMask = _layerMask & ((ulong)MbeLayer.LayerValue.PTH |
                                            (ulong)MbeLayer.LayerValue.CMP |
                                            (ulong)MbeLayer.LayerValue.L2 |
                                            (ulong)MbeLayer.LayerValue.L3 |
                                            (ulong)MbeLayer.LayerValue.SOL);



            foreach (MbeObj obj in objList)
            {
                if (obj.DeleteCount >= 0)
                {
                    continue;
                }
                startObj = obj.ConChkSeed(rc, layerMask);
                if (startObj != null)
                {
                    break;
                }
            }
            if (startObj == null)
            {
                return(false);
            }

            return(ScanData(startObj, objList));
        }
Exemplo n.º 4
0
 /// <summary>
 /// ConChkのための種の取得
 /// </summary>
 /// <param name="rc"></param>
 /// <param name="layerMask"></param>
 /// <returns></returns>
 public override MbeObj ConChkSeed(MbeRect rc, ulong layerMask)
 {
     if (SelectIt(rc, layerMask, true))
     {
         ClearAllSelectFlag();
         return(this);
     }
     return(null);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 描画範囲を得る
        /// </summary>
        /// <returns></returns>
        public virtual MbeRect OccupationRect()
        {
            MbeRect rc = new MbeRect();

            rc = new MbeRect(GetPos(0), GetPos(0));

            for (int i = 1; i < PosCount; i++)
            {
                rc.Or(GetPos(i));
            }
            return(rc);
        }
Exemplo n.º 6
0
 /// <summary>
 /// ConChkのための種の取得
 /// </summary>
 /// <param name="rc"></param>
 /// <param name="layerMask"></param>
 /// <returns></returns>
 public override MbeObj ConChkSeed(MbeRect rc, ulong layerMask)
 {
     if (SelectIt(rc, layerMask, true))
     {
         if (selectFlag[1] || selectFlag[2])     //選択座標が中心を示すときは接続対象と見做さない。
         {
             ClearAllSelectFlag();
             return(this);
         }
     }
     ClearAllSelectFlag();
     return(null);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// </remarks>
        public override bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            //if ((layerMask & (ulong)layer) == 0) return false;
            if (DeleteCount >= 0)
            {
                return(false);
            }

            // Test selection of the REFERENCE-NUMBER.
            //21 May 2011. Version 0.51.01
            // Moved priority to top.
            if (refNum.SelectIt(rc, layerMask, false))
            {
                if (pointMode)
                {
                    return(true);
                }
            }

            // Test selection by the ORIGIN-POINT-of-COMPONENT.
            if ((layerMask & (ulong)layer) != 0 && rc.Contains(posArray[0]))
            {
                SetAllSelectFlag();
                return(true);
            }

            // Test selection if it contains the MbeObjects(PTH, PAD, LINE and etc).
            if (contentsObj != null)
            {
                foreach (MbeObj obj in contentsObj)
                {
                    if (obj.Id() == MbeObjID.MbePTH ||
                        obj.Id() == MbeObjID.MbePinSMD ||
                        obj.Id() == MbeObjID.MbeHole)
                    {
                        if (obj.SelectIt(rc, layerMask, pointMode))
                        {
                            SetAllSelectFlag();
                            return(true);
                        }
                    }
                }
            }

            return(false);

            //return refNum.SelectIt(rc,layerMask,false);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 多角形の枠線の生成
        /// </summary>
        /// <param name="polygon"></param>
        /// <returns></returns>
        protected bool SetFrame(MbeObjPolygon polygon)
        {
            if (!polygon.IsValid())
            {
                return(false);
            }

            //frameLineList.Clear();

            int posCouont = polygon.PosCount;

            //layer = polygon.Layer;
            //traceWidth = polygon.TraceWidth;

            ptConnect = polygon.GetPos(0);
            for (int i = 1; i < posCouont; i++)
            {
                int index2 = i + 1;
                if (index2 >= posCouont)
                {
                    index2 = 1;
                }
                Point pt0 = polygon.GetPos(i);
                Point pt1 = polygon.GetPos(index2);
                if (i == 1)
                {
                    rcArea = new MbeRect(pt0, pt1);
                }
                else if (index2 > 1)
                {
                    rcArea.Or(pt1);
                }
                MbeGapChkObjLine objLine;
                objLine        = new MbeGapChkObjLine();
                objLine.status = LINE_STATUS_FRAME;
                objLine.layer  = layer;
                objLine.SetLineValue(pt0, pt1, traceWidth);
                orgFrameLineList.AddLast(objLine);
                objLine        = new MbeGapChkObjLine();
                objLine.status = LINE_STATUS_FRAME;
                objLine.layer  = layer;
                objLine.SetLineValue(pt0, pt1, traceWidth);
                frameLineList.AddLast(objLine);
            }
            return(true);
        }
Exemplo n.º 9
0
 public void Or(MbeRect rc)
 {
     if (pt1.X > rc.L)
     {
         pt1.X = rc.L;
     }
     if (pt2.X < rc.R)
     {
         pt2.X = rc.R;
     }
     if (pt1.Y < rc.T)
     {
         pt1.Y = rc.T;
     }
     if (pt2.Y > rc.B)
     {
         pt2.Y = rc.B;
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 描画範囲を得る
        /// </summary>
        /// <returns></returns>
        /// <remarks>不完全版 2008/08/15</remarks>
        public override MbeRect OccupationRect()
        {
            MbeRect rc = new MbeRect();

            rc = new MbeRect(GetPos(0), GetPos(0));

            foreach (MbeObj obj in contentsObj)
            {
                rc.Or(obj.OccupationRect());
            }

            rc.Or(refNum.OccupationRect());

            return(rc);

            //int wm = (rc.Width+40000) / 2;
            //int hm = (rc.Height+40000) / 2;

            //return new MbeRect(new Point(rc.L - wm, rc.T + hm), new Point(rc.R + wm, rc.B - hm));
        }
Exemplo n.º 11
0
        public void SetPanelSize()
        {
            if (mbeComponent == null)
            {
                AutoScrollMinSize = new Size(1, 1);
                return;
            }

            MbeRect rc     = mbeComponent.OccupationRect();
            int     width  = ((-rc.L > rc.R ? -rc.L : rc.R) + 10000) * 2;
            int     height = ((-rc.B > rc.T ? -rc.B : rc.T) + 10000) * 2;


            //int wm = (rc.Width+40000) / 2;
            //int hm = (rc.Height+40000) / 2;
            //rc = new MbeRect(new Point(rc.L - wm, rc.T + hm), new Point(rc.R + wm, rc.B - hm));


            width  = (int)Math.Round(width / displayScale);
            height = (int)Math.Round(height / displayScale);

            AutoScrollMinSize = new Size(width, height);


            int scrollWidth = width - ClientSize.Width;

            if (scrollWidth < 0)
            {
                scrollWidth = 0;
            }

            int scrollHeight = height - ClientSize.Height;

            if (scrollHeight < 0)
            {
                scrollHeight = 0;
            }

            AutoScrollPosition = new Point(scrollWidth / 2, scrollHeight / 2);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// </remarks>
        public virtual bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            if ((layerMask & (ulong)layer) == 0)
            {
                return(false);
            }
            if (DeleteCount >= 0)
            {
                return(false);
            }

            bool result = false;

            for (int i = 0; i < posCount; i++)
            {
                if (rc.Contains(posArray[i]))
                {
                    selectFlag[i] = true;
                    result        = true;
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする</remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            //if (param.layer != Layer) return;
            int   distance;
            Point pt0 = GetPos(0);

            Point[] pt;

            distance = (Diameter + param.traceWidth) / 2 + param.gap * 11 / 10;;

            int     left   = param.rc.L - distance;
            int     top    = param.rc.T + distance;
            int     right  = param.rc.R + distance;
            int     bottom = param.rc.B - distance;
            MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

            if (Util.PointIsOutsideLTRB(pt0, rcArea))
            {
                return;
            }
            Util.PointOutlineData(pt0, distance, out pt);

            for (int j = 0; j < 8; j++)
            {
                int j2 = j + 1;
                if (j2 == 8)
                {
                    j2 = 0;
                }
                if (!Util.LineIsOutsideLTRB(pt[j], pt[j2], param.rc))
                {
                    MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                    objLine.SetLineValue(pt[j], pt[j2], param.traceWidth);
                    outlineList.AddLast(objLine);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>
        /// ここで生成する輪郭データは内側に重なっていても良いものとする
        /// 2009/01/01 ラインアウトラインの端点キャップ省略を止める。常に端点キャップ生成
        /// </remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            if (param.layer != Layer)
            {
                return;
            }

            Point ptVia;
            bool  bendMode = getPointVia(out ptVia);

            Point[] pt = new Point[3];
            int     lines;

            if (bendMode)
            {
                pt[0] = GetPos(0);
                pt[1] = ptVia;
                pt[2] = GetPos(1);
                lines = 2;
            }
            else
            {
                pt[0] = GetPos(0);
                pt[1] = GetPos(1);
                lines = 1;
            }

            int distance = (LineWidth + param.traceWidth) / 2 + param.gap * 11 / 10;


            int left   = param.rc.L - distance;
            int top    = param.rc.T + distance;
            int right  = param.rc.R + distance;
            int bottom = param.rc.B - distance;

            MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

            Point[] ptOutline;


            for (int i = 0; i < lines; i++)
            {
                if (Util.LineIsOutsideLTRB(pt[i], pt[i + 1], rcArea))
                {
                    continue;
                }
                bool revBeginEnd;
                Util.LineOutlineData(pt[i], pt[i + 1], distance, out ptOutline, out revBeginEnd);


                bool p0Nocap = false;
                bool p1Nocap = false;
                if (bendMode)
                {
                    if (i == 0)
                    {
                        if (revBeginEnd)
                        {
                            p1Nocap = (param.option & GenOutlineParam.P0_NO_LINECAP) != 0;
                        }
                        else
                        {
                            p0Nocap = (param.option & GenOutlineParam.P0_NO_LINECAP) != 0;
                        }
                    }
                    else if (i == 1)
                    {
                        if (revBeginEnd)
                        {
                            p0Nocap = (param.option & GenOutlineParam.P1_NO_LINECAP) != 0;
                        }
                        else
                        {
                            p1Nocap = (param.option & GenOutlineParam.P1_NO_LINECAP) != 0;
                        }
                    }
                }
                else
                {
                    if (revBeginEnd)
                    {
                        p1Nocap = (param.option & GenOutlineParam.P0_NO_LINECAP) != 0;
                        p0Nocap = (param.option & GenOutlineParam.P1_NO_LINECAP) != 0;
                    }
                    else
                    {
                        p0Nocap = (param.option & GenOutlineParam.P0_NO_LINECAP) != 0;
                        p1Nocap = (param.option & GenOutlineParam.P1_NO_LINECAP) != 0;
                    }
                }



                for (int j = 0; j < 8; j++)
                {
                    int j2 = j + 1;
                    if (j2 == 8)
                    {
                        j2 = 0;
                    }

                    //不要なときはラインキャップを生成しない
                    //if (bendMode) {
                    //    if (p0Nocap && i == 0) {
                    //        if (j >= 5 && j <= 7) continue;
                    //    }
                    //    if (p1Nocap && i == 1) {
                    //        if (j >= 1 && j <= 3) continue;
                    //    }
                    //} else {
                    if (p0Nocap)
                    {
                        //System.Diagnostics.Debug.WriteLine("Skip begin cap");
                        if (j >= 5 && j <= 7)
                        {
                            continue;
                        }
                    }
                    if (p1Nocap)
                    {
                        //System.Diagnostics.Debug.WriteLine("Skip end cap");
                        if (j >= 1 && j <= 3)
                        {
                            continue;
                        }
                    }
                    //}


                    if (!Util.LineIsOutsideLTRB(ptOutline[j], ptOutline[j2], param.rc))
                    {
                        MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                        objLine.SetLineValue(ptOutline[j], ptOutline[j2], param.traceWidth);
                        outlineList.AddLast(objLine);
                    }
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする</remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            if (!doneFillFlag)
            {
                return;
            }
            //if (fillLineList.Count == 0) return;
            if (param.layer != Layer)
            {
                return;
            }
            if (posCount <= 3)
            {
                return;
            }

            int distance;

            if (restrictMask)
            {
                distance = (RESTRICT_TRACE_WIDTH + param.traceWidth) / 2 + RESTRICT_GAP * 11 / 10;
                //distance = (traceWidth + param.traceWidth) / 2 + param.gap * 11 / 10;
            }
            else
            {
                distance = (traceWidth + param.traceWidth) / 2 + param.gap * 11 / 10;
            }

            int left   = param.rc.L - distance;
            int top    = param.rc.T + distance;
            int right  = param.rc.R + distance;
            int bottom = param.rc.B - distance;

            MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

            Point[] ptOutline;

            for (int i = 1; i < PosCount; i++)
            {
                int i2 = i + 1;
                if (i2 == PosCount)
                {
                    i2 = 1;
                }
                Point p0 = GetPos(i);
                Point p1 = GetPos(i2);
                if (Util.LineIsOutsideLTRB(p0, p1, rcArea))
                {
                    continue;
                }
                bool dummyParam;
                Util.LineOutlineData(p0, p1, distance, out ptOutline, out dummyParam);
                for (int j = 0; j < 8; j++)
                {
                    int j2 = j + 1;
                    if (j2 == 8)
                    {
                        j2 = 0;
                    }
                    if (!Util.LineIsOutsideLTRB(ptOutline[j], ptOutline[j2], param.rc))
                    {
                        MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                        objLine.SetLineValue(ptOutline[j], ptOutline[j2], param.traceWidth);
                        outlineList.AddLast(objLine);
                    }
                }
            }
        }
Exemplo n.º 16
0
 public void SetRectValue(Point ptCenter, int width, int height)
 {
     rc = new MbeRect(new Point(ptCenter.X - width / 2, ptCenter.Y + height / 2),                //Left, Top
                      new Point(ptCenter.X + width / 2, ptCenter.Y - height / 2));               //Right, Bottom
 }
Exemplo n.º 17
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする</remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            if (param.layer != Layer)
            {
                return;
            }
            int distance = (LineWidth + param.traceWidth) / 2 + param.gap;

            distance = distance * 11 / 10;
            int insideRadius  = radius - distance;
            int outsideRadius = (radius + distance) * 1005 / 1000;

            distance = outsideRadius - radius;

            int left   = param.rc.L - distance;
            int top    = param.rc.T + distance;
            int right  = param.rc.R + distance;
            int bottom = param.rc.B - distance;

            Point[] pt;
            MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

            //--------------------------------------------
            int _endAngle;

            if (LimitStartEnd())
            {
                _endAngle = startAngle + 3600;
            }
            else
            {
                _endAngle = endAngle;
                if (_endAngle == startAngle)
                {
                    _endAngle = startAngle + 3600;
                }
                else if (_endAngle < startAngle)
                {
                    _endAngle += 3600;
                }
            }

            if ((startAngle % 3600) != (_endAngle % 3600))
            {
                for (int i = 1; i <= 2; i++)
                {
                    if (!Util.PointIsOutsideLTRB(GetPos(i), rcArea))
                    {
                        Util.PointOutlineData(GetPos(i), distance, out pt);
                        for (int j = 0; j < 8; j++)
                        {
                            int j2 = j + 1;
                            if (j2 == 8)
                            {
                                j2 = 0;
                            }
                            if (!Util.LineIsOutsideLTRB(pt[j], pt[j2], param.rc))
                            {
                                MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                                objLine.SetLineValue(pt[j], pt[j2], param.traceWidth);
                                outlineList.AddLast(objLine);
                            }
                        }
                    }
                }
            }


            //--------------------------------------------
            //int _endAngle;

            //if (LimitStartEnd()) {
            //    _endAngle = startAngle + 3600;
            //} else {
            //    _endAngle = endAngle;
            //    if (_endAngle == startAngle) _endAngle = startAngle + 3600;
            //    else if (_endAngle < startAngle) _endAngle += 3600;
            //}

            int angle = startAngle;

            bool   endFlag = false;
            int    x;
            int    y;
            double angleRad;

            angleRad = (double)angle / 1800.0 * Math.PI;
            x        = (int)Math.Round(outsideRadius * Math.Cos(angleRad)) + posArray[0].X;
            y        = (int)Math.Round(outsideRadius * Math.Sin(angleRad)) + posArray[0].Y;
            Point pt0 = new Point(x, y);
            Point pt1;

            while (!endFlag)
            {
                angle += 3600 / OUTLINE_DIVISION;
                if (angle >= _endAngle)
                {
                    endFlag = true;
                    angle   = _endAngle;
                }
                angleRad = (double)angle / 1800.0 * Math.PI;
                x        = (int)Math.Round(outsideRadius * Math.Cos(angleRad)) + posArray[0].X;
                y        = (int)Math.Round(outsideRadius * Math.Sin(angleRad)) + posArray[0].Y;
                pt1      = new Point(x, y);

                if (!pt0.Equals(pt1))                  //ゼロ長データは削除
                {
                    if (!Util.LineIsOutsideLTRB(pt0, pt1, param.rc))
                    {
                        MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                        objLine.SetLineValue(pt0, pt1, param.traceWidth);
                        outlineList.AddLast(objLine);
                    }
                    pt0 = pt1;
                }
            }

            //--------------------------------------------

            if (insideRadius > 10)
            {
                int division = (insideRadius > 10000 ? OUTLINE_DIVISION : 8);
                angle    = startAngle;
                endFlag  = false;
                angleRad = (double)angle / 1800.0 * Math.PI;
                x        = (int)Math.Round(insideRadius * Math.Cos(angleRad)) + posArray[0].X;
                y        = (int)Math.Round(insideRadius * Math.Sin(angleRad)) + posArray[0].Y;
                pt0      = new Point(x, y);
                while (!endFlag)
                {
                    angle += 3600 / division;
                    if (angle >= _endAngle)
                    {
                        endFlag = true;
                        angle   = _endAngle;
                    }
                    angleRad = (double)angle / 1800.0 * Math.PI;
                    x        = (int)Math.Round(insideRadius * Math.Cos(angleRad)) + posArray[0].X;
                    y        = (int)Math.Round(insideRadius * Math.Sin(angleRad)) + posArray[0].Y;
                    pt1      = new Point(x, y);

                    if (!pt0.Equals(pt1))                      //ゼロ長データは削除
                    {
                        if (!Util.LineIsOutsideLTRB(pt0, pt1, param.rc))
                        {
                            MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                            objLine.SetLineValue(pt0, pt1, param.traceWidth);
                            outlineList.AddLast(objLine);
                        }
                        pt0 = pt1;
                    }
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// </remarks>
        public override bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            if ((layerMask & (ulong)layer) == 0)
            {
                return(false);
            }
            if (DeleteCount >= 0)
            {
                return(false);
            }

            bool result = false;

            if (MbeView.ViewPolygonFrame)
            {
                if (!pointMode)
                {
                    result = base.SelectIt(rc, layerMask, pointMode);
                    if (restrictMask)
                    {
                        result        = false;
                        selectFlag[0] = false;
                        for (int i = 1; i < posCount; i++)
                        {
                            if (selectFlag[i])
                            {
                                result = true;
                            }
                        }
                    }
                    if (result)
                    {
                        return(true);
                    }
                }
                else
                {
                    Point ptC = rc.Center();

                    int threshold;
                    int startPointIndex;
                    if (restrictMask)
                    {
                        threshold       = MIN_TRACE_WIDTH / 2;
                        startPointIndex = 1;
                    }
                    else
                    {
                        threshold       = this.TraceWidth / 2;
                        startPointIndex = 0;
                    }


                    for (int index = startPointIndex; index < posCount; index++)
                    {
                        if (threshold >= (int)Util.DistancePointPoint(ptC, GetPos(index)))
                        {
                            selectFlag[index] = true;
                            return(true);
                        }
                    }

                    if (posCount >= 4)
                    {
                        for (int index = 1; index < posCount; index++)
                        {
                            int index2 = index + 1;
                            if (index2 >= posCount)
                            {
                                index2 = 1;
                            }

                            if (threshold >= (int)Util.DistancePointLine(ptC, GetPos(index), GetPos(index2)))
                            {
                                result = true;
                                break;
                            }
                        }
                        if (result)
                        {
                            for (int index = startPointIndex; index < posCount; index++)
                            {
                                selectFlag[index] = true;
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 19
0
 /// <summary>
 /// ConChkのための種の取得
 /// </summary>
 /// <param name="rc"></param>
 /// <param name="layerMask"></param>
 /// <returns></returns>
 public virtual MbeObj ConChkSeed(MbeRect rc, ulong layerMask)
 {
     return(null);
 }
Exemplo n.º 20
0
        public override MbeRect OccupationRect()
        {
            LinkedList <CamOutBaseData> camdataLList = new LinkedList <CamOutBaseData>();
            bool reverse;

            switch (layer)
            {
            case MbeLayer.LayerValue.PLS:
            case MbeLayer.LayerValue.STS:
            case MbeLayer.LayerValue.SOL:
                reverse = true;
                break;

            default:
                reverse = false;
                break;
            }
            MbeView.boardFont.GenerateCamDataString(camdataLList, 0, 0, reverse, signame, TextHeight, LineWidth);
            int   l        = System.Int32.MaxValue;
            int   t        = System.Int32.MinValue;
            int   r        = System.Int32.MinValue;
            int   b        = System.Int32.MaxValue;
            Point ptz      = new Point(0, 0);
            Point ptOrigin = GetPos(0);

            foreach (CamOutBaseData camd in camdataLList)
            {
                if (dir != 0)
                {
                    camd.RotateStep90(dir, ptz);
                }
                camd.Move(ptOrigin);
                if (camd.ctype == CamOutBaseData.CamType.VECTOR)
                {
                    if (l > camd.pt0.X)
                    {
                        l = camd.pt0.X;
                    }
                    if (l > camd.pt1.X)
                    {
                        l = camd.pt1.X;
                    }
                    if (r < camd.pt0.X)
                    {
                        r = camd.pt0.X;
                    }
                    if (r < camd.pt1.X)
                    {
                        r = camd.pt1.X;
                    }

                    if (b > camd.pt0.Y)
                    {
                        b = camd.pt0.Y;
                    }
                    if (b > camd.pt1.Y)
                    {
                        b = camd.pt1.Y;
                    }
                    if (t < camd.pt0.Y)
                    {
                        t = camd.pt0.Y;
                    }
                    if (t < camd.pt1.Y)
                    {
                        t = camd.pt1.Y;
                    }
                }
            }
            l -= LineWidth / 2;
            t += LineWidth / 2;
            r += LineWidth / 2;
            b -= LineWidth / 2;
            MbeRect rc = new MbeRect(new Point(l, t), new Point(r, b));

            return(rc);
        }
Exemplo n.º 21
0
 public void SetRectValue(MbeRect _rc)
 {
     rc = _rc;
 }
Exemplo n.º 22
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする</remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            //if (param.layer != Layer) return;
            int   distance;
            Point ptCenter = GetPos(0);

            Point[] pt;
            int     pointCount;
            int     x = ptCenter.X;
            int     y = ptCenter.Y;


            if (shape == PadShape.Rect)
            {
                distance   = param.traceWidth / 2 + param.gap;
                pt         = new Point[4];
                pointCount = 4;
                int xoffset = Width / 2 + distance;
                int yoffset = Height / 2 + distance;
                pt[0] = new Point(x - xoffset, y + yoffset);
                pt[1] = new Point(x + xoffset, y + yoffset);
                pt[2] = new Point(x + xoffset, y - yoffset);
                pt[3] = new Point(x - xoffset, y - yoffset);
            }
            else
            {
                int   lineW;
                int   lineL;
                Point pt0;
                Point pt1;
                if (Width < Height)
                {
                    lineW = Width;
                    lineL = Height - lineW;
                    pt0   = new Point(x, y - lineL / 2);
                    pt1   = new Point(x, y + lineL / 2);
                }
                else
                {
                    lineW = Height;
                    lineL = Width - lineW;
                    pt0   = new Point(x - lineL / 2, y);
                    pt1   = new Point(x + lineL / 2, y);
                }

                distance = (lineW + param.traceWidth) / 2 + param.gap * 11 / 10;

                int left   = param.rc.L - distance;
                int top    = param.rc.T + distance;
                int right  = param.rc.R + distance;
                int bottom = param.rc.B - distance;

                MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

                if (Util.LineIsOutsideLTRB(pt0, pt1, rcArea))
                {
                    return;
                }
                bool dummyParam;
                Util.LineOutlineData(pt0, pt1, distance, out pt, out dummyParam);
                pointCount = 8;
            }

            for (int j = 0; j < pointCount; j++)
            {
                int j2 = j + 1;
                if (j2 == pointCount)
                {
                    j2 = 0;
                }
                if (!Util.LineIsOutsideLTRB(pt[j], pt[j2], param.rc))
                {
                    MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                    objLine.SetLineValue(pt[j], pt[j2], param.traceWidth);
                    outlineList.AddLast(objLine);
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする
        /// 文字列をマジメに一画ごとに処理すると、線分の量が半端でなく大きくなる
        /// とりあえずは全体を矩形で囲む輪郭を生成する。
        /// </remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            if (layer != param.layer)
            {
                return;
            }

            MbeRect rc = OccupationRect();

            //LinkedList<CamOutBaseData> camdataLList = new LinkedList<CamOutBaseData>();

            //bool reverse;
            //switch (layer) {
            //    case MbeLayer.LayerValue.PLS:
            //    case MbeLayer.LayerValue.STS:
            //    case MbeLayer.LayerValue.SOL:
            //        reverse = true;
            //        break;
            //    default:
            //        reverse = false;
            //        break;
            //}
            //MbeView.boardFont.GenerateCamDataString(camdataLList, 0, 0, reverse, signame, TextHeight, LineWidth);
            //int l = System.Int32.MaxValue;
            //int t = System.Int32.MinValue;
            //int r = System.Int32.MinValue;
            //int b = System.Int32.MaxValue;
            //Point ptz = new Point(0, 0);
            //Point ptOrigin = GetPos(0);
            //foreach (CamOutBaseData camd in camdataLList) {
            //    if (dir != 0) {
            //        camd.RotateStep90(dir, ptz);
            //    }
            //    camd.Move(ptOrigin);
            //    if (camd.ctype == CamOutBaseData.CamType.VECTOR) {
            //        if (l > camd.pt0.X) l = camd.pt0.X;
            //        if (l > camd.pt1.X) l = camd.pt1.X;
            //        if (r < camd.pt0.X) r = camd.pt0.X;
            //        if (r < camd.pt1.X) r = camd.pt1.X;

            //        if (b > camd.pt0.Y) b = camd.pt0.Y;
            //        if (b > camd.pt1.Y) b = camd.pt1.Y;
            //        if (t < camd.pt0.Y) t = camd.pt0.Y;
            //        if (t < camd.pt1.Y) t = camd.pt1.Y;
            //    }
            //}
            int distance = param.traceWidth / 2 + param.gap;

            int l = rc.L - distance;
            int t = rc.T + distance;
            int r = rc.R + distance;
            int b = rc.B - distance;

            Point[] pt = new Point[4];
            pt[0] = new Point(l, t);
            pt[1] = new Point(r, t);
            pt[2] = new Point(r, b);
            pt[3] = new Point(l, b);
            for (int j = 0; j < 4; j++)
            {
                int j2 = j + 1;
                if (j2 == 4)
                {
                    j2 = 0;
                }
                if (!Util.LineIsOutsideLTRB(pt[j], pt[j2], param.rc))
                {
                    MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                    objLine.SetLineValue(pt[j], pt[j2], param.traceWidth);
                    outlineList.AddLast(objLine);
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// </remarks>
        public override bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            if ((layerMask & (ulong)layer) == 0)
            {
                return(false);
            }
            if (DeleteCount >= 0)
            {
                return(false);
            }

            if (!pointMode)
            {
                return(base.SelectIt(rc, layerMask, pointMode));
            }

            int   areaWidth  = 0;
            int   areaHeight = 0;
            Point ptC        = rc.Center();

            //まず、パッドの矩形範囲内に入っているかどうかのチェック
            //長円パッドでは、両端の半円を除くエリアをチェックする
            if (Shape == PadShape.Obround)
            {
                if (Height < Width)
                {
                    areaHeight = Height;
                    areaWidth  = Width - Height;
                }
                else if (Height > Width)
                {
                    areaHeight = Height - Width;
                    areaWidth  = Width;
                }
                else
                {
                    //幅と高さが同じ場合は、矩形エリアが存在しない。
                    //中心点から検査点までの距離が半径内に収まっているかどうかのチェックだけ
                    if (Util.DistancePointPoint(ptC, GetPos(0)) <= Width / 2)
                    {
                        selectFlag[0] = true;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else                        //矩形パッドなら矩形パッド全体でいい
            {
                areaHeight = Height;
                areaWidth  = Width;
            }

            int x = GetPos(0).X;
            int y = GetPos(0).Y;
            int l = x - areaWidth / 2;
            int r = x + areaWidth / 2;
            int t = y + areaHeight / 2;
            int b = y - areaHeight / 2;


            //矩形エリア内チェック
            if (l <= ptC.X && ptC.X <= r && b <= ptC.Y && ptC.Y < t)
            {
                selectFlag[0] = true;
                return(true);
            }

            //長円の場合は、両端半円内チェックを行う。
            if (Shape == PadShape.Obround)
            {
                int x0  = 0;
                int y0  = 0;
                int x1  = 0;
                int y1  = 0;
                int rad = 0;                    //半径
                if (Height < Width)
                {
                    rad = Height / 2;
                    x0  = l;
                    x1  = r;
                    y0  = y1 = y;
                }
                else if (Height > Width)
                {
                    rad = Width / 2;
                    x0  = x1 = x;
                    y0  = b;
                    y1  = t;
                }
                if (Util.DistancePointPoint(ptC, new Point(x0, y0)) <= rad ||
                    Util.DistancePointPoint(ptC, new Point(x1, y1)) <= rad)
                {
                    selectFlag[0] = true;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 25
0
        /// <summary>
        /// ポリゴンのための輪郭データを生成する。
        /// </summary>
        /// <param name="outlineList"></param>
        /// <param name="param"></param>
        /// <remarks>ここで生成する輪郭データは内側に重なっていても良いものとする</remarks>
        public override void GenerateOutlineData(LinkedList <MbeGapChkObjLine> outlineList, GenOutlineParam param)
        {
            //if (param.layer != Layer) return;
            int   distance;
            Point ptCenter = GetPos(0);

            Point[] pt;
            int     pointCount;
            int     x = ptCenter.X;
            int     y = ptCenter.Y;


            if (param.layer == MbeLayer.LayerValue.L2 || param.layer == MbeLayer.LayerValue.L3)
            {
                //内層のときは非接続時はドリル径+0.4mm。(ただし、表層padサイズを超えない)接続時はpadSizeのWidthかHeightの小さい方
                int landDia;
                if (((ulong)param.layer & innerLayerConnectionInfo) == 0)
                {
                    landDia = dia + 4000;
                    if (landDia > InnerLandDia)
                    {
                        landDia = InnerLandDia;
                    }
                }
                else
                {
                    landDia = InnerLandDia;
                }
                Point pt0 = new Point(x, y);

                distance = (landDia + param.traceWidth) / 2 + param.gap * 11 / 10;

                int left   = param.rc.L - distance;
                int top    = param.rc.T + distance;
                int right  = param.rc.R + distance;
                int bottom = param.rc.B - distance;

                MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

                if (Util.LineIsOutsideLTRB(pt0, pt0, rcArea))
                {
                    return;
                }
                bool dummyParam;
                Util.LineOutlineData(pt0, pt0, distance, out pt, out dummyParam);
                pointCount = 8;
            }
            else if (shape == PadShape.Rect)
            {
                distance   = param.traceWidth / 2 + param.gap;
                pt         = new Point[4];
                pointCount = 4;
                int xoffset = Width / 2 + distance;
                int yoffset = Height / 2 + distance;
                pt[0] = new Point(x - xoffset, y + yoffset);
                pt[1] = new Point(x + xoffset, y + yoffset);
                pt[2] = new Point(x + xoffset, y - yoffset);
                pt[3] = new Point(x - xoffset, y - yoffset);
            }
            else
            {
                int   lineW;
                int   lineL;
                Point pt0;
                Point pt1;
                if (Width < Height)
                {
                    lineW = Width;
                    lineL = Height - lineW;
                    pt0   = new Point(x, y - lineL / 2);
                    pt1   = new Point(x, y + lineL / 2);
                }
                else
                {
                    lineW = Height;
                    lineL = Width - lineW;
                    pt0   = new Point(x - lineL / 2, y);
                    pt1   = new Point(x + lineL / 2, y);
                }

                distance = (lineW + param.traceWidth) / 2 + param.gap * 11 / 10;

                int left   = param.rc.L - distance;
                int top    = param.rc.T + distance;
                int right  = param.rc.R + distance;
                int bottom = param.rc.B - distance;

                MbeRect rcArea = new MbeRect(new Point(left, top), new Point(right, bottom));

                if (Util.LineIsOutsideLTRB(pt0, pt1, rcArea))
                {
                    return;
                }
                bool dummyParam;
                Util.LineOutlineData(pt0, pt1, distance, out pt, out dummyParam);
                pointCount = 8;
            }

            for (int j = 0; j < pointCount; j++)
            {
                int j2 = j + 1;
                if (j2 == pointCount)
                {
                    j2 = 0;
                }
                if (!Util.LineIsOutsideLTRB(pt[j], pt[j2], param.rc))
                {
                    MbeGapChkObjLine objLine = new MbeGapChkObjLine();
                    objLine.SetLineValue(pt[j], pt[j2], param.traceWidth);
                    outlineList.AddLast(objLine);
                }
            }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 選択を行う
        /// </summary>
        /// <param name="rc"></param>
        /// <param name="layerMask"></param>
        /// <param name="pointMode"></param>
        /// <returns>選択対象だったときにtrueを返す</returns>
        /// <remarks>
        /// 選択対象だった場合には選択フラグがセットされる。
        /// </remarks>
        public override bool SelectIt(MbeRect rc, ulong layerMask, bool pointMode)
        {
            if ((layerMask & (ulong)layer) == 0)
            {
                return(false);
            }
            if (DeleteCount >= 0)
            {
                return(false);
            }

            bool result = false;

            if (!pointMode)
            {
                result = base.SelectIt(rc, layerMask, pointMode);
                if (result)
                {
                    return(true);
                }
            }
            else
            {
                Point ptC = rc.Center();

                int threshold = LineWidth / 2;

                if (threshold >= (int)Util.DistancePointPoint(ptC, GetPos(0)))
                {
                    selectFlag[0] = true;
                    return(true);
                }

                if (threshold >= (int)Util.DistancePointPoint(ptC, GetPos(1)))
                {
                    selectFlag[1] = true;
                    return(true);
                }

                Point ptVia;
                //Point ptDummy;
                bool bendMode = getPointVia(out ptVia);

                if (bendMode)
                {
                    if (threshold >= (int)Util.DistancePointLine(ptC, GetPos(0), ptVia) ||
                        threshold >= (int)Util.DistancePointLine(ptC, GetPos(1), ptVia))
                    {
                        result = true;
                    }
                }
                else
                {
                    if (threshold >= (int)Util.DistancePointLine(ptC, GetPos(0), GetPos(1)))
                    {
                        result = true;
                    }
                }
                if (result)
                {
                    selectFlag[0] = true;
                    selectFlag[1] = true;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 27
0
 public MbeGapChkObjRect()
 {
     rc = new MbeRect(new Point(0, 0), new Point(0, 0));
 }