/// <summary> /// 描画 /// </summary> /// <param name="dp"></param> public override void Draw(DrawParam dp) { if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.PTH | (ulong)MbeLayer.LayerValue.STS | (ulong)MbeLayer.LayerValue.STC | (ulong)MbeLayer.LayerValue.DRL)) == 0) { return; } if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.STS | (ulong)MbeLayer.LayerValue.STC)) != 0) { if (no_ResistMask) { return; } } Point pt = this.GetPos(0); pt = ToDrawDim(pt, dp.scale); Color col; //Color cold; int w = 0; int h = 0; int wd = 0; int hd = 0; Rectangle rc; SolidBrush brush; Pen pen; #region 描画サイズの設定 switch (dp.layer) { case MbeLayer.LayerValue.PTH: w = (int)(PadSize.Width / dp.scale) | 1; h = (int)(PadSize.Height / dp.scale) | 1; break; case MbeLayer.LayerValue.STC: case MbeLayer.LayerValue.STS: w = (int)((PadSize.Width + SrMargin * 2) / dp.scale) | 1; h = (int)((PadSize.Height + SrMargin * 2) / dp.scale) | 1; break; } if (w == 1) { w++; } if (h == 1) { h++; } if ((dp.layer == MbeLayer.LayerValue.PTH) || (dp.layer == MbeLayer.LayerValue.DRL)) { int drillDia; if ((dp.option & (uint)MbeDrawOption.CenterPunchMode) != 0) { drillDia = PrintCenterPunchModeDiameter(Diameter); } else { drillDia = Diameter; } wd = (int)(drillDia / dp.scale) | 1; if (dp.layer == MbeLayer.LayerValue.PTH) { if (wd >= w) { wd = w - 2; } if (wd >= h) { wd = h - 2; } } hd = wd; } #endregion #region 色の設定 if (dp.mode == MbeDrawMode.Print) { if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0) //カラー印刷 { uint nColor; switch (dp.layer) { case MbeLayer.LayerValue.PTH: nColor = MbeColors.PRINT_PTH; break; case MbeLayer.LayerValue.STC: nColor = MbeColors.PRINT_STC; break; case MbeLayer.LayerValue.STS: nColor = MbeColors.PRINT_STS; break; case MbeLayer.LayerValue.DRL: default: nColor = MbeColors.PRINT_DRL; break; } col = Color.FromArgb(unchecked ((int)nColor)); col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col); } else { col = Color.Black; } } else { uint nColor; switch (dp.layer) { case MbeLayer.LayerValue.PTH: nColor = MbeColors.PTH; break; case MbeLayer.LayerValue.STC: nColor = MbeColors.STC; break; case MbeLayer.LayerValue.STS: nColor = MbeColors.STS; break; case MbeLayer.LayerValue.DRL: default: nColor = MbeColors.DRL; break; } if (dp.mode == MbeDrawMode.Temp || connectionCheckActive) { col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor)); } else { col = Color.FromArgb(unchecked ((int)nColor)); col = Color.FromArgb(MBE_OBJ_ALPHA, col); } } #endregion #region 実際の描画の実行 switch (dp.layer) { case MbeLayer.LayerValue.PTH: case MbeLayer.LayerValue.STC: case MbeLayer.LayerValue.STS: rc = new Rectangle(pt.X - w / 2, pt.Y - h / 2, w, h); if (Shape == PadShape.Rect) { brush = new SolidBrush(col); dp.g.FillRectangle(brush, rc); brush.Dispose(); } else { if (w == h) { brush = new SolidBrush(col); dp.g.FillEllipse(brush, rc); brush.Dispose(); } else { pen = new Pen(col, (w < h ? w : h)); pen.StartCap = LineCap.Round; pen.EndCap = LineCap.Round; if (w < h) { int k = (h - w + 1) / 2; dp.g.DrawLine(pen, pt.X, pt.Y - k, pt.X, pt.Y + k); } else { int k = (w - h + 1) / 2; dp.g.DrawLine(pen, pt.X - k, pt.Y, pt.X + k, pt.Y); } pen.Dispose(); } } if (dp.layer == MbeLayer.LayerValue.PTH) { if (dp.mode != MbeDrawMode.Print) { if (wd >= 3) { rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd); Color cold = MbeColors.ColorBackground; if (dp.mode == MbeDrawMode.Temp) { cold = Color.FromArgb(MBE_OBJ_ALPHA, cold); } brush = new SolidBrush(cold); //brush = new SolidBrush(MbeColors.ColorBackground); dp.g.FillEllipse(brush, rc); brush.Dispose(); } if (drawSnapMark) { int marksize = (w < h ? w : h) / 2; DrawSnapPointMark(dp.g, pt, marksize, selectFlag[0]); } if (DrawPinNumFlag) { int fontsize = (w < h ? w : h) / 2; //高さと幅の小さい方 bool vertical = (w < h); //幅が大きければ縦書き DrawPinNum(dp.g, PinNum, pt, fontsize, vertical); } } else { rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd); brush = new SolidBrush(Color.White); dp.g.FillEllipse(brush, rc); brush.Dispose(); } } break; case MbeLayer.LayerValue.DRL: rc = new Rectangle(pt.X - wd / 2, pt.Y - hd / 2, wd, hd); if (dp.mode == MbeDrawMode.Print) { brush = new SolidBrush(Color.White); dp.g.FillEllipse(brush, rc); brush.Dispose(); if ((dp.visibleLayer & (ulong)MbeLayer.LayerValue.PTH) == 0) { int penw = (int)(500 / dp.scale) | 1; if ((dp.option & (uint)MbeDrawOption.ToolMarkMode) != 0) { if ((dp.visibleLayer & MbeLayer.PatternFilmLayer) == 0) { MbeView.DrawDrillMark(GetPos(0), Diameter, dp, col, penw); return; } } pen = new Pen(col, penw); dp.g.DrawEllipse(pen, rc); pen.Dispose(); } } else { pen = new Pen(col); dp.g.DrawEllipse(pen, rc); pen.Dispose(); } break; } #endregion }
/// <summary> /// 描画 /// </summary> /// <param name="dp"></param> public override void Draw(DrawParam dp) { if (((ulong)dp.layer & ((ulong)MbeLayer.LayerValue.STS | (ulong)MbeLayer.LayerValue.STC | (ulong)MbeLayer.LayerValue.DRL)) == 0) { return; } //if (dp.layer != MbeLayer.LayerValue.DRL) return; Point pt = this.GetPos(0); pt = ToDrawDim(pt, dp.scale); Color col; Color cold; //int w = 0; //int h = 0; int wd = 0; //int hd = 0; Rectangle rc; SolidBrush brush; Pen pen; bool centerPunchMode = false; int drillDia; if ((dp.option & (uint)MbeDrawOption.CenterPunchMode) != 0) { drillDia = PrintCenterPunchModeDiameter(Diameter); centerPunchMode = true; } else { drillDia = Diameter; } switch (dp.layer) { case MbeLayer.LayerValue.DRL: wd = (int)(drillDia / dp.scale) | 1; break; case MbeLayer.LayerValue.STC: case MbeLayer.LayerValue.STS: wd = (int)((Diameter + DEFAULT_SRMARGIN * 2) / dp.scale) | 1; break; } //wd = (int)(Diameter / dp.scale) | 1; #region 色の設定 if (dp.mode == MbeDrawMode.Print) { cold = Color.White; if ((dp.option & (uint)MbeDrawOption.PrintColor) != 0) //カラー印刷 { uint nColor; switch (dp.layer) { case MbeLayer.LayerValue.STC: nColor = MbeColors.PRINT_STC; break; case MbeLayer.LayerValue.STS: nColor = MbeColors.PRINT_STS; break; case MbeLayer.LayerValue.DRL: default: nColor = MbeColors.PRINT_DRL; break; } col = Color.FromArgb(unchecked ((int)nColor)); col = Color.FromArgb(MBE_OBJ_PRINT_ALPHA, col); } else { col = Color.Black; } } else { uint nColor; switch (dp.layer) { case MbeLayer.LayerValue.STC: nColor = MbeColors.STC; break; case MbeLayer.LayerValue.STS: nColor = MbeColors.STS; break; case MbeLayer.LayerValue.DRL: default: nColor = MbeColors.DRL; break; } cold = MbeColors.ColorBackground; if (dp.mode == MbeDrawMode.Temp) { col = Color.FromArgb(MBE_OBJ_ALPHA, MbeColors.HighLighten(nColor)); cold = Color.FromArgb(0x20, cold); } else { col = Color.FromArgb(unchecked ((int)nColor)); col = Color.FromArgb(MBE_OBJ_ALPHA, col); } } #endregion rc = new Rectangle(pt.X - wd / 2, pt.Y - wd / 2, wd, wd); if (dp.layer == MbeLayer.LayerValue.DRL) { if (dp.mode != MbeDrawMode.Print) { cold = Color.FromArgb(0x90, cold); } brush = new SolidBrush(cold); dp.g.FillEllipse(brush, rc); brush.Dispose(); //DRLレイヤーへの描画では、輪郭を描く。 //印刷時はプリンタの能力に左右されにくいように幅を設定する。 //センターポンチモードでは、感光基板による自作を想定してやや太めのラインとする。 int w = 1; if (dp.mode == MbeDrawMode.Print) { if (centerPunchMode && (dp.visibleLayer & ((ulong)MbeLayer.LayerValue.PTH | (ulong)MbeLayer.LayerValue.CMP | (ulong)MbeLayer.LayerValue.SOL)) != 0) { w = 1000; } else { w = 500; } w = (int)(w / dp.scale) | 1; if ((dp.option & (uint)MbeDrawOption.ToolMarkMode) != 0) { if ((dp.visibleLayer & MbeLayer.PatternFilmLayer) == 0) { MbeView.DrawDrillMark(GetPos(0), Diameter, dp, col, w); return; } } } pen = new Pen(col, w); dp.g.DrawEllipse(pen, rc); pen.Dispose(); if (drawSnapMark && dp.mode != MbeDrawMode.Print) { int marksize = wd / 2; DrawSnapPointMark(dp.g, pt, marksize, selectFlag[0]); } } else { brush = new SolidBrush(col); dp.g.FillEllipse(brush, rc); brush.Dispose(); } }