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