Commit 32f60895 LN

多PCB模式可调整间距。多点位投影功能。

1 个父辈 cb69a316
......@@ -74,6 +74,31 @@ namespace TSA_V.DeviceLibrary
/// 多PCB模式-列间距(mm)
/// </summary>
public int pcbColValue { get; set; } = 1;
/// <summary>
/// 多点位投射功能,=true所有点位同时显示。
/// </summary>
public bool mPointsProjection { get; set; } = false;
/// <summary>
/// 多pcb模式,每个PCB针对PCB1的偏移坐标。key=pcb索引号,value =偏移坐标
/// </summary>
public Dictionary<int, Point> mPCbOffsetMap = new Dictionary<int, Point>();
public Point GetPCBOffsetPoint(int pcbIndex)
{
if (mPCbOffsetMap.ContainsKey(pcbIndex))
{
return mPCbOffsetMap[pcbIndex];
}
else
{
return new Point(0, 0);
}
}
public void SetPCBOffset(int pcbIndex, Point value)
{
mPCbOffsetMap[pcbIndex] = value;
}
public int PointColor = Color.White.ToArgb();
......@@ -221,7 +246,8 @@ namespace TSA_V.DeviceLibrary
public List<SMTPointInfo> getCalPoint()
{
try
{
SMTPointInfo lefup = new SMTPointInfo();
lefup.PositionX = 0;
lefup.PositionY = 0;
......@@ -235,8 +261,15 @@ namespace TSA_V.DeviceLibrary
right.NodePositionY = calInfo.rightBottomPoint.Y;
List<SMTPointInfo> checkOKList = new List<SMTPointInfo>() { lefup, right };
return checkOKList;
}
catch (Exception ex)
{
LogUtil.error(boardName + "获取校准点列表出错:" + ex.ToString());
}
return new List<SMTPointInfo>();
}
public CalibrateBean calInfo = null;
......
......@@ -580,5 +580,6 @@ namespace TSA_V.DeviceLibrary
}
}
}
using System;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Drawing;
......@@ -152,6 +152,73 @@ namespace TSA_V.DeviceLibrary
}
public static Point CalPCBAreaNodePosition(Point position, List<SMTPointInfo> checkOKList, int type)
{
Point nodePosition = new Point(0,0);
try
{
if (checkOKList.Count < 2)
{
return nodePosition;
}
SMTPointInfo APoint = checkOKList[0];
SMTPointInfo BPoint = checkOKList[1];
//计算坐标
if (Math.Abs(position.X - APoint.PositionX) < 0.01)
{
nodePosition.X =(int) APoint.NodePositionX;
}
else
{
nodePosition.X =(int)( APoint.NodePositionX + (BPoint.NodePositionX - APoint.NodePositionX) * (position.X - APoint.PositionX) / (BPoint.PositionX - APoint.PositionX));
if (double.IsNaN(nodePosition.X) || double.IsInfinity(nodePosition.X))
{
nodePosition.X =(int) APoint.NodePositionX;
}
}
if (Math.Abs(position.Y - APoint.PositionY) < 0.01)
{
nodePosition.Y = (int)APoint.NodePositionY;
}
else
{
nodePosition.Y =(int)( APoint.NodePositionY + (BPoint.NodePositionY - APoint.NodePositionY) * (position.Y - APoint.PositionY) / (BPoint.PositionY - APoint.PositionY));
if (double.IsNaN(nodePosition.Y) || double.IsInfinity(nodePosition.Y))
{
nodePosition.Y =(int) APoint.NodePositionY;
}
}
if (nodePosition.X <= 0)
{
nodePosition.X = 1;
}
else if (nodePosition.X > BoundsWidth)
{
nodePosition.X = BoundsWidth;
}
if (nodePosition.Y <= 0)
{
nodePosition.Y = 1;
}
else if (nodePosition.Y > BoundsHeight)
{
nodePosition.Y = BoundsHeight;
}
//LogUtil.info($" 【{smtPoint.PN}】图片坐标【{smtPoint.PositionX},{smtPoint.PositionY}】旧坐标【{oldX},{oldY}】新坐标【{smtPoint.NodePositionX},{smtPoint.NodePositionY}】" +
// $"点尺寸({smtPoint.PointSizeX},{smtPoint.PointSizeY}),画笔宽{smtPoint.PenWidth}");
//return smtPoint;
}
catch (Exception ex)
{
LogUtil.error(" CalPointNodePosition 多PCB基准点计算错误【 图片坐标【" + position.X + "," + position.Y + "】校准坐标出错:" + ex.ToString());
}
return nodePosition;
}
private SMTPointInfo GetPoint(SMTPointInfo smtPoint, List<SMTPointInfo> checkOKList)
{
......@@ -193,6 +260,100 @@ namespace TSA_V.DeviceLibrary
return projectorPInfoList;
}
/// <summary>
/// 多板拷贝点
/// </summary>
/// <param name="board"></param>
/// <param name="sMTPoint"></param>
/// <param name="targetRow"></param>
/// <param name="targetCol"></param>
/// <param name="targetRowValue"></param>
/// <param name="targetColValue"></param>
/// <returns></returns>
public static List<List<Point>> GetCopyArea(BoardInfo board, int targetRow = 0, int targetCol = 0, int targetRowValue = 0, int targetColValue = 0)
{
List<List<Point>> result = new List<List<Point>>();
if (board == null || board.calInfo == null || board.calInfo.leftUpPoint == null || board.calInfo.rightBottomPoint == null)
{
return result;
}
try
{
result.Add(new List<Point>() { board.calInfo.leftUpPoint, board.calInfo.rightBottomPoint });
List<SMTPointInfo> checkOKList = board.getCalPoint();
if (board == null || checkOKList == null || checkOKList.Count < 2 || board.PCBCount == 1)
{
return result;
}
if (board.pcbRow <= 1 && board.pcbCol <= 1)
{
return result;
}
int pcbRow = targetRow > 0 ? targetRow : board.pcbRow;
int pcbCol = targetCol > 0 ? targetCol : board.pcbCol;
int pcbColValue = targetColValue > 0 ? targetColValue : board.pcbColValue;
int pcbRowValue = targetRowValue > 0 ? targetRowValue : board.pcbRowValue;
for (int currR = 1; currR <= pcbRow; currR++)
{
for (int currC = 1; currC <= pcbCol; currC++)
{
int index = (currR - 1) * pcbCol + currC;
if (index == 1) continue; // PCB1 为基准
// 默认按均匀间距计算
int dx = (currC - 1) * pcbColValue;
int dy = (currR - 1) * pcbRowValue;
// 若设置了某个PCB相对PCB1的偏移,则覆盖默认值
try
{
if (board.mPCbOffsetMap != null && board.mPCbOffsetMap.ContainsKey(index))
{
var pOffset = board.mPCbOffsetMap[index];
dx = pOffset.X;
dy = pOffset.Y;
}
}
catch { }
Point leftPoint = new Point(dx, dy);
Point rightPoint = new Point(dx + board.boardWidth, dy + board.boardLength);
if (checkOKList != null)
{
Point leftNodePoint = XYConvertManager.CalPCBAreaNodePosition(leftPoint, checkOKList, 1);
Point rightNodePoint = XYConvertManager.CalPCBAreaNodePosition(rightPoint, checkOKList, 2);
result.Add(new List<Point>() { leftNodePoint, rightNodePoint });
}
}
}
}
catch (Exception ex)
{
LogUtil.error("获取" + board.boardName + "拷贝点出错:" + ex.ToString());
}
finally
{
}
return result;
}
/// <summary>
/// 多板拷贝点
/// </summary>
/// <param name="board"></param>
/// <param name="sMTPoint"></param>
/// <param name="targetRow"></param>
/// <param name="targetCol"></param>
/// <param name="targetRowValue"></param>
/// <param name="targetColValue"></param>
/// <returns></returns>
public static List<SMTPointInfo> GetCopyPointCR(BoardInfo board, SMTPointInfo sMTPoint = null,int targetRow=0,int targetCol=0,int targetRowValue=0,int targetColValue=0)
{
List<SMTPointInfo> pointList = new List<SMTPointInfo>();
......@@ -205,7 +366,7 @@ namespace TSA_V.DeviceLibrary
if (board != null)
{
basePoints = new List<SMTPointInfo>(board.smtList);
basePoints = new List<SMTPointInfo>(board.GetSmtList());
}
else
{
......@@ -241,26 +402,11 @@ namespace TSA_V.DeviceLibrary
{
return pointList;
}
int pcbRow = board.pcbRow;
if (targetRow > 0)
{
pcbRow = targetRow;
}
int pcbCol = board.pcbCol;
if(targetCol > 0)
{
pcbCol = targetCol;
}
int pcbColValue = board.pcbColValue;
if (targetRowValue > 0)
{
pcbColValue = targetRowValue;
}
int pcbRowValue = board.pcbRowValue;
if(targetColValue > 0)
{
pcbRowValue = targetColValue;
}
int pcbRow =targetRow>0?targetRow: board.pcbRow;
int pcbCol = targetCol > 0?targetCol: board.pcbCol;
int pcbColValue = targetColValue > 0?targetColValue: board.pcbColValue;
int pcbRowValue = targetRowValue > 0 ? targetRowValue: board.pcbRowValue;
for (int currR = 1; currR <= pcbRow; currR++)
{
for (int currC = 1; currC <= pcbCol; currC++)
......@@ -272,8 +418,22 @@ namespace TSA_V.DeviceLibrary
{
SMTPointInfo newPoint = new SMTPointInfo(point);
newPoint.pointNum = baseCount + point.pointNum;
newPoint.PositionX = newPoint.PositionX + (currC - 1) * pcbColValue;
newPoint.PositionY = newPoint.PositionY + (currR - 1) * pcbRowValue;
// 默认按均匀间距计算
int dx = (currC - 1) * pcbColValue;
int dy = (currR - 1) * pcbRowValue;
// 若设置了某个PCB相对PCB1的偏移,则覆盖默认值
try
{
if (board.mPCbOffsetMap != null && board.mPCbOffsetMap.ContainsKey(index))
{
var pOffset = board.mPCbOffsetMap[index];
dx = pOffset.X;
dy = pOffset.Y;
}
}
catch { }
newPoint.PositionX = newPoint.PositionX + dx;
newPoint.PositionY = newPoint.PositionY + dy;
newPoint.Group = index;
newPoint.TagNo = point.TagNo + "-" + index;
newPoint.PointSizeX = point.PointSizeX;
......
......@@ -353,16 +353,16 @@ namespace TSA_V.DeviceLibrary
}
LogUtil.info(Name + "重置中 " + resetStep + ":InitNode 所有节点 ");
}
public delegate bool ShowPointDelegate(params ProjectorPInfo[] p);
public delegate bool ShowPointDelegate(BoardInfo board,params SMTPointInfo[] point);
public static event ShowPointDelegate ShowPointEvent;
//public static void ShowPoint(double x, double y, int type = 1,int polaritiesType=0,int angle, int sizex = 1, int sizey = 1, int penWidth = 2, string name = "",int color=-1)
//{
// ProjectorPInfo p = new ProjectorPInfo((int)x, (int)y, type, polaritiesType,angle, sizex, sizey, penWidth, name,color);
// ShowPointEvent?.Invoke(p);
//}
public static void ShowPoint(params ProjectorPInfo[] p)
public static void ShowPoint(BoardInfo board, params SMTPointInfo[] point)
{
ShowPointEvent?.Invoke(p);
ShowPointEvent?.Invoke(board,point);
}
......
......@@ -309,10 +309,11 @@ namespace TSA_V.DeviceLibrary
if (TSAVBean.IsValidPosition(currPoint.NodePositionX, currPoint.NodePositionY))
{
LogUtil.info(" 程序【" + currBoard.boardName + "】插件【" + currPoint.TagNo + "_" + currPoint.PN + "】,X轴【" + currPoint.NodePositionX + "】,Y轴【" + currPoint.NodePositionY + "】显示投影光标");
List<ProjectorPInfo> projectorPInfos = XYConvertManager.GetCopyProjectPointCR(currBoard, currPoint);
TSAVBean.ShowPoint(projectorPInfos.ToArray());
//List<ProjectorPInfo> projectorPInfos = XYConvertManager.GetCopyProjectPointCR(currBoard, currPoint);
//TSAVBean.ShowPoint(projectorPInfos.ToArray());
//TSAVBean.ShowPoint( currPoint.GetScreenShowPInfo());
//TSAVBean.ShowPoint(currPoint.NodePositionX, currPoint.NodePositionY, currPoint.PointType,currPoint.PolaritiesType, currPoint.PointSizeX, currPoint.PointSizeY, currPoint.PenWidth, currPoint.ShowText, currBoard.PointColor);
TSAVBean.ShowPoint(currBoard, currPoint);
waitList.Add(WaitResultInfo.WaitTime(1000));
}
else
......
......@@ -150,8 +150,9 @@ namespace TSA_V
}
SetListCurrCell(index);
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, pointList.ToArray( ));
//FrmProjectorScreen.instance.ClearPoint();
//FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, pointList.ToArray( ));
FrmProjectorScreen.instance.ShowAreaAndPoint(updateBoardInfo, false, pointList.ToArray());
this.Cursor = Cursors.Default;
//重新加载
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.TrainOK, "坐标校准完成!"));
......
......@@ -377,10 +377,11 @@ namespace TSA_V
HandClientManager.StartClient();
}
private bool TSAVBean_ShowPointEvent(params ProjectorPInfo[] p)
private bool TSAVBean_ShowPointEvent(BoardInfo board, params SMTPointInfo[] p)
{
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(p);
//FrmProjectorScreen.instance.ShowPoint(p);
FrmProjectorScreen.instance.WorkingShowPoint(board,true,p);
return true;
}
......
......@@ -2829,5 +2829,13 @@
<data name = "FrmMPcbConfig_label7_Text" xml:space = "preserve"> <value> Rows: </value> </data>
<data name = "FrmMPcbConfig_btnClose_Text" xml:space = "preserve"> <value> Back </value> </data>
<data name = "FrmMPcbConfig_btnSave_Text" xml:space = "preserve"> <value> Save </value> </data>
<data name = "FrmPCbOffsetConfig_Text" xml:space = "preserve"> <value>Set PCB{0} Relative Offset (mm)</value> </data>
<data name = "FrmPCbOffsetConfig_labelX_Text" xml:space = "preserve"> <value>X Offset (mm): </value> </data>
<data name = "FrmPCbOffsetConfig_labelY_Text" xml:space = "preserve"> <value>Y Offset (mm): </value> </data>
<data name = "FrmPCbOffsetConfig_btnOK_Text" xml:space = "preserve"> <value>OK</value> </data>
<data name = "FrmPCbOffsetConfig_btnCancel_Text" xml:space = "preserve"> <value>Cancel</value> </data>
<data name = "MPCBTips" xml:space = "preserve"> <value>Click the PCB block below to set its offset relative to PCB1 (Unit: mm). If not set, it will be arranged evenly according to the row/column spacing above.</value> </data>
<data name = "Pcb1Fixed" xml:space = "preserve"> <value>PCB1 is used as the reference, and its offset is fixed at (0,0)</value> </data>
<data name = "FrmBoardInfo_chbMPoint_Text" xml:space = "preserve"> <value>Multi-Points Projection </value> </data>
</root>
\ No newline at end of file
......@@ -2807,4 +2807,12 @@
<data name = "FrmMPcbConfig_label7_Text" xml:space = "preserve"> <value> 行: </value> </data>
<data name = "FrmMPcbConfig_btnClose_Text" xml:space = "preserve"> <value> 返回 </value> </data>
<data name = "FrmMPcbConfig_btnSave_Text" xml:space = "preserve"> <value> 保存 </value> </data>
<data name = "FrmPCbOffsetConfig_Text" xml:space = "preserve"> <value> 设置 PCB{0} 相对偏移(mm)</value> </data>
<data name = "FrmPCbOffsetConfig_labelX_Text" xml:space = "preserve"> <value> X偏移(mm): </value> </data>
<data name = "FrmPCbOffsetConfig_labelY_Text" xml:space = "preserve"> <value> Y偏移(mm): </value> </data>
<data name = "FrmPCbOffsetConfig_btnOK_Text" xml:space = "preserve"> <value> 确定 </value> </data>
<data name = "FrmPCbOffsetConfig_btnCancel_Text" xml:space = "preserve"> <value> 取消 </value> </data>
<data name = "MPCBTips" xml:space = "preserve"> <value> 点击下方PCB块可设置其相对PCB1的偏移(单位:mm)。未设置则按上方行/列间距均匀排布 </value> </data>
<data name = "Pcb1Fixed" xml:space = "preserve"> <value> PCB1作为基准,偏移固定为(0,0) </value> </data>
<data name = "FrmBoardInfo_chbMPoint_Text" xml:space = "preserve"> <value> 多点位投影功能 </value> </data>
</root>
\ No newline at end of file
......@@ -3051,4 +3051,12 @@
<data name = "FrmMPcbConfig_label7_Text" xml:space = "preserve"> <value> 行: </value> </data>
<data name = "FrmMPcbConfig_btnClose_Text" xml:space = "preserve"> <value> 返回 </value> </data>
<data name = "FrmMPcbConfig_btnSave_Text" xml:space = "preserve"> <value> 保存 </value> </data>
<data name = "FrmPCbOffsetConfig_Text" xml:space = "preserve"> <value> 设置 PCB{0} 相对偏移(mm)</value> </data>
<data name = "FrmPCbOffsetConfig_labelX_Text" xml:space = "preserve"> <value> X偏移(mm): </value> </data>
<data name = "FrmPCbOffsetConfig_labelY_Text" xml:space = "preserve"> <value> Y偏移(mm): </value> </data>
<data name = "FrmPCbOffsetConfig_btnOK_Text" xml:space = "preserve"> <value> 确定 </value> </data>
<data name = "FrmPCbOffsetConfig_btnCancel_Text" xml:space = "preserve"> <value> 取消 </value> </data>
<data name = "MPCBTips" xml:space = "preserve"> <value> 点击下方PCB块可设置其相对PCB1的偏移(单位:mm)。未设置则按上方行/列间距均匀排布 </value> </data>
<data name = "Pcb1Fixed" xml:space = "preserve"> <value> PCB1作为基准,偏移固定为(0,0) </value> </data>
<data name = "FrmBoardInfo_chbMPoint_Text" xml:space = "preserve"> <value> 多点位投影功能 </value> </data>
</root>
\ No newline at end of file
......@@ -179,6 +179,12 @@
<Compile Include="frmBoard\FrmMPcbConfig.Designer.cs">
<DependentUpon>FrmMPcbConfig.cs</DependentUpon>
</Compile>
<Compile Include="frmBoard\FrmPCbOffsetConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmBoard\FrmPCbOffsetConfig.Designer.cs">
<DependentUpon>FrmPCbOffsetConfig.cs</DependentUpon>
</Compile>
<Compile Include="frmBoard\FrmEditMPoint.cs">
<SubType>Form</SubType>
</Compile>
......@@ -469,6 +475,9 @@
<EmbeddedResource Include="frmBoard\FrmNImageViewer.resx">
<DependentUpon>FrmNImageViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmBoard\FrmPCbOffsetConfig.resx">
<DependentUpon>FrmPCbOffsetConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmCom\FrmAddCom.resx">
<DependentUpon>FrmAddCom.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -127,6 +127,7 @@
this.button1 = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.chbMPoint = new System.Windows.Forms.CheckBox();
this.contextMenuStrip1.SuspendLayout();
this.contextMenuStrip2.SuspendLayout();
this.panel1.SuspendLayout();
......@@ -311,13 +312,12 @@
this.btnMPCbMode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnMPCbMode.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMPCbMode.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMPCbMode.Location = new System.Drawing.Point(1336, 588);
this.btnMPCbMode.Location = new System.Drawing.Point(1336, 571);
this.btnMPCbMode.Name = "btnMPCbMode";
this.btnMPCbMode.Size = new System.Drawing.Size(120, 45);
this.btnMPCbMode.TabIndex = 287;
this.btnMPCbMode.Text = "多PCB模式";
this.btnMPCbMode.UseVisualStyleBackColor = false;
this.btnMPCbMode.Visible = true;
this.btnMPCbMode.Click += new System.EventHandler(this.btnMPCbMode_Click);
//
// btnMEdit
......@@ -325,7 +325,7 @@
this.btnMEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnMEdit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnMEdit.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnMEdit.Location = new System.Drawing.Point(355, 588);
this.btnMEdit.Location = new System.Drawing.Point(355, 571);
this.btnMEdit.Name = "btnMEdit";
this.btnMEdit.Size = new System.Drawing.Size(120, 45);
this.btnMEdit.TabIndex = 297;
......@@ -338,7 +338,7 @@
this.linkDis.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkDis.AutoSize = true;
this.linkDis.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linkDis.Location = new System.Drawing.Point(118, 593);
this.linkDis.Location = new System.Drawing.Point(118, 576);
this.linkDis.Name = "linkDis";
this.linkDis.Size = new System.Drawing.Size(56, 17);
this.linkDis.TabIndex = 296;
......@@ -351,7 +351,7 @@
this.linkEnable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkEnable.AutoSize = true;
this.linkEnable.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.linkEnable.Location = new System.Drawing.Point(6, 593);
this.linkEnable.Location = new System.Drawing.Point(6, 576);
this.linkEnable.Name = "linkEnable";
this.linkEnable.Size = new System.Drawing.Size(56, 17);
this.linkEnable.TabIndex = 295;
......@@ -364,7 +364,7 @@
this.btnCalibrate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCalibrate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCalibrate.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCalibrate.Location = new System.Drawing.Point(230, 588);
this.btnCalibrate.Location = new System.Drawing.Point(230, 571);
this.btnCalibrate.Name = "btnCalibrate";
this.btnCalibrate.Size = new System.Drawing.Size(120, 45);
this.btnCalibrate.TabIndex = 294;
......@@ -377,7 +377,7 @@
this.btnColorChange.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnColorChange.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnColorChange.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnColorChange.Location = new System.Drawing.Point(1086, 588);
this.btnColorChange.Location = new System.Drawing.Point(1086, 571);
this.btnColorChange.Name = "btnColorChange";
this.btnColorChange.Size = new System.Drawing.Size(120, 45);
this.btnColorChange.TabIndex = 293;
......@@ -391,7 +391,7 @@
this.btnOpenFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnOpenFile.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOpenFile.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOpenFile.Location = new System.Drawing.Point(1210, 588);
this.btnOpenFile.Location = new System.Drawing.Point(1210, 571);
this.btnOpenFile.Name = "btnOpenFile";
this.btnOpenFile.Size = new System.Drawing.Size(120, 45);
this.btnOpenFile.TabIndex = 260;
......@@ -404,7 +404,7 @@
this.btnCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCheck.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCheck.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCheck.Location = new System.Drawing.Point(230, 588);
this.btnCheck.Location = new System.Drawing.Point(230, 571);
this.btnCheck.Name = "btnCheck";
this.btnCheck.Size = new System.Drawing.Size(120, 45);
this.btnCheck.TabIndex = 291;
......@@ -417,6 +417,7 @@
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.chbMPoint);
this.groupBox2.Controls.Add(this.btnConfigAOI);
this.groupBox2.Controls.Add(this.label8);
this.groupBox2.Controls.Add(this.label122);
......@@ -434,7 +435,7 @@
this.groupBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupBox2.Location = new System.Drawing.Point(634, 3);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(822, 99);
this.groupBox2.Size = new System.Drawing.Size(829, 99);
this.groupBox2.TabIndex = 290;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "图片信息";
......@@ -593,7 +594,7 @@
this.chbNormal.Checked = true;
this.chbNormal.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbNormal.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbNormal.Location = new System.Drawing.Point(761, 593);
this.chbNormal.Location = new System.Drawing.Point(761, 576);
this.chbNormal.Name = "chbNormal";
this.chbNormal.Size = new System.Drawing.Size(87, 21);
this.chbNormal.TabIndex = 281;
......@@ -606,7 +607,7 @@
this.lblMousePosition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.lblMousePosition.AutoSize = true;
this.lblMousePosition.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMousePosition.Location = new System.Drawing.Point(823, 625);
this.lblMousePosition.Location = new System.Drawing.Point(823, 608);
this.lblMousePosition.Name = "lblMousePosition";
this.lblMousePosition.Size = new System.Drawing.Size(33, 16);
this.lblMousePosition.TabIndex = 287;
......@@ -619,7 +620,7 @@
this.chbShowName.Checked = true;
this.chbShowName.CheckState = System.Windows.Forms.CheckState.Checked;
this.chbShowName.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbShowName.Location = new System.Drawing.Point(902, 593);
this.chbShowName.Location = new System.Drawing.Point(902, 576);
this.chbShowName.Name = "chbShowName";
this.chbShowName.Size = new System.Drawing.Size(75, 21);
this.chbShowName.TabIndex = 280;
......@@ -635,7 +636,7 @@
this.焊点列表.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.焊点列表.Location = new System.Drawing.Point(4, 108);
this.焊点列表.Name = "焊点列表";
this.焊点列表.Size = new System.Drawing.Size(624, 474);
this.焊点列表.Size = new System.Drawing.Size(624, 457);
this.焊点列表.TabIndex = 286;
this.焊点列表.TabStop = false;
this.焊点列表.Text = "组装信息(使用键盘上的上下键可更改选中行)";
......@@ -685,7 +686,7 @@
this.dgvList.RowHeadersWidth = 30;
this.dgvList.RowTemplate.Height = 23;
this.dgvList.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvList.Size = new System.Drawing.Size(616, 448);
this.dgvList.Size = new System.Drawing.Size(616, 431);
this.dgvList.TabIndex = 31;
this.dgvList.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
this.dgvList.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvList_CellMouseDown);
......@@ -968,7 +969,7 @@
this.panel3.Controls.Add(this.panBoard);
this.panel3.Location = new System.Drawing.Point(646, 123);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(812, 459);
this.panel3.Size = new System.Drawing.Size(819, 442);
this.panel3.TabIndex = 277;
//
// panBoard
......@@ -978,7 +979,7 @@
this.panBoard.Dock = System.Windows.Forms.DockStyle.Fill;
this.panBoard.Location = new System.Drawing.Point(0, 0);
this.panBoard.Name = "panBoard";
this.panBoard.Size = new System.Drawing.Size(812, 459);
this.panBoard.Size = new System.Drawing.Size(819, 442);
this.panBoard.TabIndex = 261;
this.panBoard.Paint += new System.Windows.Forms.PaintEventHandler(this.panBoard_Paint);
//
......@@ -1103,7 +1104,7 @@
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(605, 588);
this.button1.Location = new System.Drawing.Point(605, 571);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(120, 45);
this.button1.TabIndex = 41;
......@@ -1116,7 +1117,7 @@
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnSave.Location = new System.Drawing.Point(480, 588);
this.btnSave.Location = new System.Drawing.Point(480, 571);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(120, 45);
this.btnSave.TabIndex = 40;
......@@ -1134,9 +1135,21 @@
this.panel2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.panel2.Location = new System.Drawing.Point(631, 106);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(827, 474);
this.panel2.Size = new System.Drawing.Size(834, 457);
this.panel2.TabIndex = 292;
//
// chbMPoint
//
this.chbMPoint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chbMPoint.AutoSize = true;
this.chbMPoint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbMPoint.Location = new System.Drawing.Point(560, 23);
this.chbMPoint.Name = "chbMPoint";
this.chbMPoint.Size = new System.Drawing.Size(111, 21);
this.chbMPoint.TabIndex = 287;
this.chbMPoint.Text = "多点位投影功能";
this.chbMPoint.UseVisualStyleBackColor = true;
//
// FrmBoardInfo
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -1266,5 +1279,6 @@
private System.Windows.Forms.DataGridViewLinkColumn Column_Up;
private System.Windows.Forms.DataGridViewLinkColumn Column_Down;
private System.Windows.Forms.Button btnMPCbMode;
private System.Windows.Forms.CheckBox chbMPoint;
}
}
\ No newline at end of file
......@@ -284,7 +284,7 @@ namespace TSA_V
dgvList.Rows.Add(setPointInfo(null, point));
}
}
chbMPoint.Checked = updateBoardInfo.mPointsProjection;
}
private DataGridViewRow setPointInfo(DataGridViewRow view, SMTPointInfo point)
......@@ -566,6 +566,7 @@ namespace TSA_V
board.LineWidth = FormUtil.GetIntValue(txtLineWidth);
board.PointColor = btnColorChange.BackColor.ToArgb();
board.boardCode = FormUtil.getValue(txtCode);
board.mPointsProjection = chbMPoint.Checked;
board.orgType = orgType;
if (cmbAOIFile.SelectedIndex == 0)
board.AOIProName = "";
......@@ -1560,8 +1561,10 @@ namespace TSA_V
if (updateBoardInfo.PointColor != btnColorChange.BackColor.ToArgb())
{
updateBoardInfo.PointColor = btnColorChange.BackColor.ToArgb();
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, allPointInfo().ToArray());
//FrmProjectorScreen.instance.ClearPoint();
//FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, allPointInfo().ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(updateBoardInfo, false, allPointInfo().ToArray());
BoardManager.Update(updateBoardInfo);
}
}
......@@ -1601,8 +1604,10 @@ namespace TSA_V
}
SetListCurrCell(index);
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, updateBoardInfo.smtList.ToArray());
//FrmProjectorScreen.instance.ClearPoint();
//FrmProjectorScreen.instance.ShowPoint(false, updateBoardInfo.PointColor, updateBoardInfo.smtList.ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(updateBoardInfo, false, updateBoardInfo.smtList.ToArray());
this.Cursor = Cursors.Default;
//重新加载
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.TrainOK, "坐标校准完成!"));
......
......@@ -129,7 +129,9 @@ namespace TSA_V
LoadPoint(board);
loadPictureBoxSize(board);
FrmProjectorScreen.instance.ShowPoint(false,board.PointColor, board.smtList.ToArray());
//FrmProjectorScreen.instance.ShowPoint(false,board.PointColor, board.smtList.ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(board, false, board.smtList.ToArray());
}
}
......
......@@ -273,8 +273,10 @@ namespace TSA_V.frmBoard
currBoard.calInfo.CurrStep = 3;
currBoard.smtList = pointList;
BoardManager.Update(currBoard);
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(false, currBoard.PointColor, pointList.ToArray());
//FrmProjectorScreen.instance.ClearPoint();
//FrmProjectorScreen.instance.ShowPoint(false, currBoard.PointColor, pointList.ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(currBoard, false, pointList.ToArray());
this.Cursor = Cursors.Default;
//重新加载
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.TrainOK, "坐标校准完成!"));
......
......@@ -36,6 +36,8 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.btnTest = new System.Windows.Forms.Button();
this.groupCopy = new System.Windows.Forms.GroupBox();
this.numCol = new System.Windows.Forms.NumericUpDown();
this.numRow = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
......@@ -47,16 +49,11 @@
this.label7 = new System.Windows.Forms.Label();
this.btnClose = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.numRow = new System.Windows.Forms.NumericUpDown();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.numCol = new System.Windows.Forms.NumericUpDown();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.groupCopy.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numRow)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numCol)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numRow)).BeginInit();
this.SuspendLayout();
//
// dataGridViewImageColumn1
......@@ -105,7 +102,6 @@
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.numericUpDown1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 17);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
......@@ -114,6 +110,7 @@
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(821, 314);
this.tableLayoutPanel1.TabIndex = 0;
this.tableLayoutPanel1.Tag = "SKIPUIPRO";
//
// btnTest
//
......@@ -142,21 +139,65 @@
this.groupCopy.Controls.Add(this.label11);
this.groupCopy.Controls.Add(this.label7);
this.groupCopy.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.groupCopy.Location = new System.Drawing.Point(12, 21);
this.groupCopy.Location = new System.Drawing.Point(12, 12);
this.groupCopy.Name = "groupCopy";
this.groupCopy.Size = new System.Drawing.Size(827, 137);
this.groupCopy.Size = new System.Drawing.Size(827, 149);
this.groupCopy.TabIndex = 292;
this.groupCopy.TabStop = false;
//
// numCol
//
this.numCol.Location = new System.Drawing.Point(156, 60);
this.numCol.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numCol.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numCol.Name = "numCol";
this.numCol.Size = new System.Drawing.Size(95, 23);
this.numCol.TabIndex = 306;
this.numCol.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// numRow
//
this.numRow.Location = new System.Drawing.Point(156, 23);
this.numRow.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numRow.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numRow.Name = "numRow";
this.numRow.Size = new System.Drawing.Size(95, 23);
this.numRow.TabIndex = 305;
this.numRow.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(108, 103);
this.label1.Location = new System.Drawing.Point(4, 119);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(191, 17);
this.label1.Size = new System.Drawing.Size(815, 17);
this.label1.TabIndex = 304;
this.label1.Text = "*多PCB模式时,PCB必须均匀放置";
this.label1.Text = "点击下方PCB块可设置其相对PCB1的偏移(单位:mm)。未设置则按上方行/列间距均匀排布";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
......@@ -264,57 +305,6 @@
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// numRow
//
this.numRow.Location = new System.Drawing.Point(156, 23);
this.numRow.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numRow.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numRow.Name = "numRow";
this.numRow.Size = new System.Drawing.Size(95, 23);
this.numRow.TabIndex = 305;
this.numRow.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(3, 3);
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(120, 21);
this.numericUpDown1.TabIndex = 0;
//
// numCol
//
this.numCol.Location = new System.Drawing.Point(156, 60);
this.numCol.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numCol.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numCol.Name = "numCol";
this.numCol.Size = new System.Drawing.Size(95, 23);
this.numCol.TabIndex = 306;
this.numCol.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// FrmMPcbConfig
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -324,15 +314,13 @@
this.Name = "FrmMPcbConfig";
this.Text = "多PCB模式配置";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBoardInfo_FormClosing);
this.Load += new System.EventHandler(this.FrmBoardInfo_Load);
this.Shown += new System.EventHandler(this.FrmBoardInfo_Shown);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.groupCopy.ResumeLayout(false);
this.groupCopy.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numRow)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numCol)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numRow)).EndInit();
this.ResumeLayout(false);
}
......@@ -356,7 +344,6 @@
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.NumericUpDown numCol;
private System.Windows.Forms.NumericUpDown numRow;
}
......

using log4net;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Drawing;
......@@ -26,6 +27,8 @@ namespace TSA_V
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;
LanguagePro();
// 确保打开对话框时立即加载并显示正确的网格文本
//try { LoadBoardInfo(); } catch {}
}
public void LoadForm()
{
......@@ -38,7 +41,7 @@ namespace TSA_V
}
private void FrmBoardInfo_Load(object sender, EventArgs e)
private void FrmBoardInfo_Shown(object sender, EventArgs e)
{
LoadBoardInfo();
}
......@@ -50,17 +53,44 @@ namespace TSA_V
try
{
// 使用已有配置填充界面
numRow.Text = (currBoardInfo.pcbRow > 0 ? currBoardInfo.pcbRow : 1).ToString();
numCol.Text = (currBoardInfo.pcbCol > 0 ? currBoardInfo.pcbCol : 1).ToString();
numRow.Value = (currBoardInfo.pcbRow > 0 ? currBoardInfo.pcbRow : 1);
numCol.Value = (currBoardInfo.pcbCol > 0 ? currBoardInfo.pcbCol : 1);
txtRowS.Text = (currBoardInfo.pcbRowValue > 0 ? currBoardInfo.pcbRowValue : 1).ToString();
txtColS.Text = (currBoardInfo.pcbColValue > 0 ? currBoardInfo.pcbColValue : 1).ToString();
// 更新提示文案:可单独设置相对偏移
try { label1.Text = ResourceControl.GetString("MPCBTips" ,"*点击下方PCB块可设置其相对PCB1的偏移(单位:mm)。未设置则按上方行/列间距均匀排布"); } catch { }
// 打开界面时,根据当前行列值模拟显示
int rows =(int)numRow.Value;
int cols = (int)numCol.Value;
if (rows < 1) rows = 1;
if (cols < 1) cols = 1;
SimulatePcbGrid(rows, cols);
//SimulatePcbGrid(rows, cols);
try
{
if (FrmProjectorScreen.instance != null)
{
//List<SMTPointInfo> pointList = XYConvertManager.GetCopyPointCR(currBoardInfo);
//FrmProjectorScreen.instance.ShowPoint(false, currBoardInfo.PointColor, pointList.ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(currBoardInfo,false, currBoardInfo.GetSmtList().ToArray());
}
}
catch (Exception ex)
{
LogUtil.info("测试投影效果失败: " + ex.Message);
}
try
{
SimulatePcbGrid(rows, cols,currBoardInfo.pcbRowValue,currBoardInfo.pcbColValue);
}
catch (Exception ex)
{
LogUtil.info("模拟PCB布局失败: " + ex.Message);
}
}
catch (Exception ex)
{
......@@ -93,7 +123,7 @@ namespace TSA_V
{
if (currBoardInfo == null)
{
MessageBox.Show("板卡信息为空,无法保存。");
MessageBox.Show(ResourceControl.GetString("BoardNull", "板卡信息为空,无法测试。"));
return;
}
......@@ -190,45 +220,20 @@ namespace TSA_V
// 安全获取校准点,若未校准则按原点位直接使用
List<SMTPointInfo> pointList = XYConvertManager.GetCopyPointCR(currBoardInfo,null,pcbRow, pcbCol, pcbRowValue, pcbColValue);
//List<SMTPointInfo> pointList = new List<SMTPointInfo>();
//pointList.AddRange(currBoardInfo.smtList);
//int baseCount = currBoardInfo.smtList.Count;
//string msg = "";
//for (int currR = 1; currR <= pcbRow; currR++)
//{
// for (int currC = 1; currC <= pcbCol; currC++)
// {
// int index = (currR - 1) * pcbCol + currC;
// if (index == 1) continue; // PCB1 为基准
// foreach (SMTPointInfo point in currBoardInfo.smtList)
// {
// SMTPointInfo newPoint = new SMTPointInfo(point);
// newPoint.pointNum = baseCount + point.pointNum;
// newPoint.PositionX = newPoint.PositionX + (currC - 1) * pcbColValue;
// newPoint.PositionY = newPoint.PositionY + (currR - 1) * pcbRowValue;
// newPoint.Group = index;
// newPoint.TagNo = point.TagNo + "-" + index;
// newPoint.PointSizeX = point.PointSizeX;
// newPoint.CheckOK = false;
// if (checkOKList != null)
// {
// try { newPoint = XYConvertManager.CalPointNodePosition(newPoint, checkOKList); } catch { }
// }
// msg += "\r\n" + point.pointName + "_" + point.PN + $",更改组={index} , X={newPoint.PositionX},Y={newPoint.PositionY},投影X={newPoint.NodePositionX},投影Y={newPoint.NodePositionY}";
// pointList.Add(newPoint);
// }
// }
//}
try
{
if (FrmProjectorScreen.instance != null)
{
FrmProjectorScreen.instance.ShowPoint(false, currBoardInfo.PointColor, pointList.ToArray());
BoardInfo board = currBoardInfo.Copy();
board.pcbRow = pcbRow;
board.pcbCol = pcbCol;
board.pcbRowValue = pcbRowValue;
board.pcbColValue = pcbColValue;
FrmProjectorScreen.instance.ShowAreaAndPoint(board, true );
//List<SMTPointInfo> pointList = XYConvertManager.GetCopyPointCR(currBoardInfo, null, pcbRow, pcbCol, pcbRowValue, pcbColValue);
//FrmProjectorScreen.instance.ShowPoint(false, currBoardInfo.PointColor, pointList.ToArray());
}
}
catch(Exception ex)
......@@ -238,7 +243,7 @@ namespace TSA_V
try
{
SimulatePcbGrid(pcbRow, pcbCol);
SimulatePcbGrid(pcbRow, pcbCol,pcbRowValue,pcbColValue);
}
catch (Exception ex)
{
......@@ -246,7 +251,7 @@ namespace TSA_V
}
}
private void SimulatePcbGrid(int rows, int cols)
private void SimulatePcbGrid(int rows, int cols,int pcbRowValue,int pcbColValue)
{
if (tableLayoutPanel1 == null) return;
tableLayoutPanel1.SuspendLayout();
......@@ -275,33 +280,66 @@ namespace TSA_V
Color refBack = Color.FromArgb(255, 255, 230, 200); // 淡橙(基准)
Color refFore = Color.FromArgb(120, 60, 0);
// 读取行/列间距,作为默认偏移计算依据
//int colGap = FormUtil.GetIntValue(txtColS);
//if (colGap <= 0) colGap = currBoardInfo != null && currBoardInfo.pcbColValue > 0 ? currBoardInfo.pcbColValue : 1;
//int rowGap = FormUtil.GetIntValue(txtRowS);
//if (rowGap <= 0) rowGap = currBoardInfo != null && currBoardInfo.pcbRowValue > 0 ? currBoardInfo.pcbRowValue : 1;
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
int index = r * cols + c + 1;
Label lbl = new Label();
lbl.Dock = DockStyle.Fill;
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Margin = new Padding(6);
lbl.AutoSize = false;
lbl.Font = new Font("微软雅黑", 12f, FontStyle.Bold);
lbl.Text = "PCB" + index;
// 计算默认偏移(均匀排布)
int defDx = c * pcbColValue;
int defDy = r * pcbRowValue;
// 如果有单独设置,则使用已设置的值
int showDx = defDx;
int showDy = defDy;
try
{
if (currBoardInfo != null)
{
var p = currBoardInfo.GetPCBOffsetPoint(index);
if (index == 1)
{
showDx = 0; showDy = 0; // PCB1 固定为(0,0)
}
else if (p.X != 0 || p.Y != 0)
{
showDx = p.X; showDy = p.Y;
}
}
}
catch { }
Label lblPcbInfo = new Label();
lblPcbInfo.Dock = DockStyle.Fill;
lblPcbInfo.TextAlign = ContentAlignment.MiddleCenter;
lblPcbInfo.Margin = new Padding(6);
lblPcbInfo.AutoSize = false;
lblPcbInfo.Font = new Font("微软雅黑", 12f, FontStyle.Bold);
lblPcbInfo.Text = $"PCB{index}({showDx},{showDy})";
lblPcbInfo.Tag = index;
lblPcbInfo.Cursor = Cursors.Hand;
lblPcbInfo.Click += LabelPcb_Click;
if (index == 1)
{
lbl.BackColor = refBack;
lbl.ForeColor = refFore;
lbl.BorderStyle = BorderStyle.FixedSingle;
lblPcbInfo.BackColor = refBack;
lblPcbInfo.ForeColor = refFore;
lblPcbInfo.BorderStyle = BorderStyle.FixedSingle;
lblPcbInfo.Cursor = Cursors.No;
}
else
{
lbl.BackColor = baseBack;
lbl.ForeColor = baseFore;
lbl.BorderStyle = BorderStyle.FixedSingle;
lblPcbInfo.BackColor = baseBack;
lblPcbInfo.ForeColor = baseFore;
lblPcbInfo.BorderStyle = BorderStyle.FixedSingle;
}
tableLayoutPanel1.Controls.Add(lbl, c, r);
tableLayoutPanel1.Controls.Add(lblPcbInfo, c, r);
}
}
}
......@@ -310,6 +348,82 @@ namespace TSA_V
tableLayoutPanel1.ResumeLayout();
}
}
private void LabelPcb_Click(object sender, EventArgs e)
{
try
{
var lbl = sender as Label;
if (lbl == null) return;
int index = (int)lbl.Tag;
if (index == 1)
{
MessageBox.Show(ResourceControl.GetString("Pcb1Fixed", "PCB1作为基准,偏移固定为(0,0)。", ResourceCulture.GetString("MsgTitle", "提示"), MessageBoxButtons.OK, MessageBoxIcon.Information));
return;
}
// 计算当前默认偏移:若已有单独设置则用已设置值,否则按行列间距均匀排布
int rows = (int)numRow.Value;
int cols = (int)numCol.Value;
int colGap = FormUtil.GetIntValue(txtColS);
if (colGap <= 0) colGap = currBoardInfo != null && currBoardInfo.pcbColValue > 0 ? currBoardInfo.pcbColValue : 1;
int rowGap = FormUtil.GetIntValue(txtRowS);
if (rowGap <= 0) rowGap = currBoardInfo != null && currBoardInfo.pcbRowValue > 0 ? currBoardInfo.pcbRowValue : 1;
int r0 = (index - 1) / Math.Max(1, cols);
int c0 = (index - 1) % Math.Max(1, cols);
int defDx = c0 * colGap;
int defDy = r0 * rowGap;
int currDx = defDx;
int currDy = defDy;
try
{
var p = currBoardInfo.GetPCBOffsetPoint(index);
if (p.X != 0 || p.Y != 0)
{
currDx = p.X;
currDy = p.Y;
}
}
catch { }
using (var dlg = new TSA_V.frmBoard.FrmPCbOffsetConfig(index, currDx, currDy))
{
if (dlg.ShowDialog(this) == DialogResult.OK)
{
int x = dlg.OffsetX;
int y = dlg.OffsetY;
currBoardInfo.SetPCBOffset(index, new Point(x, y));
// 更新标签显示
lbl.Text = $"PCB{index}({x},{y})";
try
{
if (FrmProjectorScreen.instance != null)
{
//List<SMTPointInfo> pointList = XYConvertManager.GetCopyPointCR(currBoardInfo, null, rows, cols, rowGap, colGap);
//FrmProjectorScreen.instance.ShowPoint(false, currBoardInfo.PointColor, pointList.ToArray());
BoardInfo board = currBoardInfo.Copy() ;
board.pcbRow = rows;
board.pcbCol = cols;
board.pcbRowValue = rowGap;
board.pcbColValue = colGap;
FrmProjectorScreen.instance.ShowAreaAndPoint(board, true);
}
}
catch (Exception ex)
{
LogUtil.info("测试投影效果失败: " + ex.Message);
}
}
}
}
catch (Exception ex)
{
LogUtil.info("编辑PCB偏移失败:" + ex.Message);
}
}
}
......
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace TSA_V.frmBoard
{
partial class FrmPCbOffsetConfig
{
private IContainer components = null;
private Label labelX;
private Label labelY;
private NumericUpDown numX;
private NumericUpDown numY;
private Button btnOK;
private Button btnCancel;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.labelX = new System.Windows.Forms.Label();
this.labelY = new System.Windows.Forms.Label();
this.numX = new System.Windows.Forms.NumericUpDown();
this.numY = new System.Windows.Forms.NumericUpDown();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).BeginInit();
this.SuspendLayout();
//
// labelX
//
this.labelX.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelX.Location = new System.Drawing.Point(52, 29);
this.labelX.Name = "labelX";
this.labelX.Size = new System.Drawing.Size(100, 24);
this.labelX.TabIndex = 0;
this.labelX.Text = "X偏移(mm):";
this.labelX.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// labelY
//
this.labelY.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.labelY.Location = new System.Drawing.Point(52, 65);
this.labelY.Name = "labelY";
this.labelY.Size = new System.Drawing.Size(100, 24);
this.labelY.TabIndex = 2;
this.labelY.Text = "Y偏移(mm):";
this.labelY.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// numX
//
this.numX.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.numX.Location = new System.Drawing.Point(158, 27);
this.numX.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numX.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numX.Name = "numX";
this.numX.Size = new System.Drawing.Size(160, 23);
this.numX.TabIndex = 1;
//
// numY
//
this.numY.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.numY.Location = new System.Drawing.Point(158, 65);
this.numY.Maximum = new decimal(new int[] {
100000,
0,
0,
0});
this.numY.Minimum = new decimal(new int[] {
100000,
0,
0,
-2147483648});
this.numY.Name = "numY";
this.numY.Size = new System.Drawing.Size(160, 23);
this.numY.TabIndex = 3;
//
// btnOK
//
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOK.Location = new System.Drawing.Point(55, 110);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(125, 39);
this.btnOK.TabIndex = 4;
this.btnOK.Text = "确定";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCancel.Location = new System.Drawing.Point(186, 110);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(125, 39);
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// FrmPCbOffsetConfig
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(371, 170);
this.Controls.Add(this.labelX);
this.Controls.Add(this.numX);
this.Controls.Add(this.labelY);
this.Controls.Add(this.numY);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnCancel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "FrmPCbOffsetConfig";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Load += new System.EventHandler(this.FrmPCbOffsetConfig_Load);
this.Shown += new System.EventHandler(this.FrmPCbOffsetConfig_Shown);
((System.ComponentModel.ISupportInitialize)(this.numX)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numY)).EndInit();
this.ResumeLayout(false);
}
}
}
\ No newline at end of file
using System;
using System.Windows.Forms;
namespace TSA_V.frmBoard
{
public partial class FrmPCbOffsetConfig : FrmBase
{
public int OffsetX { get; private set; }
public int OffsetY { get; private set; }
private readonly int pcbIndex;
private readonly int defaultX;
private readonly int defaultY;
public FrmPCbOffsetConfig(int pcbIndex, int defaultX, int defaultY)
{
this.pcbIndex = pcbIndex;
this.defaultX = defaultX;
this.defaultY = defaultY;
InitializeComponent();
this.Text = ResourceControl.GetString("FrmPCbOffsetConfig_Text", "设置 PCB{0} 相对偏移(mm)", pcbIndex+"");
// 初始化控件默认值
try
{
numX.Value = defaultX;
numY.Value = defaultY;
}
catch { }
}
private void btnOK_Click(object sender, EventArgs e)
{
OffsetX = (int)numX.Value;
OffsetY = (int)numY.Value;
this.DialogResult = DialogResult.OK;
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void FrmPCbOffsetConfig_Load(object sender, EventArgs e)
{
}
private void FrmPCbOffsetConfig_Shown(object sender, EventArgs e)
{
this.Text = ResourceControl.GetString("FrmPCbOffsetConfig_Text", "设置 PCB{0} 相对偏移(mm)", pcbIndex + "");
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using log4net.Filter;
using log4net.Filter;
using System;
using System.CodeDom;
using System.Collections.Generic;
......@@ -232,8 +232,22 @@ namespace TSA_V
{
SMTPointInfo newPoint = new SMTPointInfo(point);
newPoint.pointNum = baseCount + point.pointNum;
newPoint.PositionX = newPoint.PositionX + (currC - 1) * pcbColValue;
newPoint.PositionY = newPoint.PositionY + (currR - 1) * pcbRowValue;
// 默认按均匀间距计算
int dx = (currC - 1) * pcbColValue;
int dy = (currR - 1) * pcbRowValue;
// 若设置了某个PCB相对PCB1的偏移,则覆盖默认值
try
{
if (board.mPCbOffsetMap != null && board.mPCbOffsetMap.ContainsKey(index))
{
var pOffset = board.mPCbOffsetMap[index];
dx = pOffset.X;
dy = pOffset.Y;
}
}
catch { }
newPoint.PositionX = newPoint.PositionX + dx;
newPoint.PositionY = newPoint.PositionY + dy;
newPoint.Group = index;
newPoint.TagNo = point.TagNo + "-" + index;
newPoint.PointSizeX = point.PointSizeX;
......
......@@ -104,7 +104,7 @@ namespace TSA_V
panAoi.BackColor = Color.Black;
panAoi.Visible = false;
}
public void DrawArea()
private void DrawArea()
{
if (!ISShow)
{
......@@ -151,64 +151,65 @@ namespace TSA_V
}
grfx.Dispose();
}
public void DrawLine()
{
if (!ISShow)
{
return;
}
int startX = 0;
int startY = 0;
int Point_X_Length = 21;
int Point_Y_Length = 21;
//public void DrawLine()
//{
// if (!ISShow)
// {
// return;
// }
// int startX = 0;
// int startY = 0;
// int Point_X_Length = 21;
// int Point_Y_Length = 21;
int lineWidth = (BoundsWidth - startX * 2) / (Point_X_Length - 1);
int lineHeight = (BoundsHeight - startY * 2) / (Point_Y_Length - 1);
// int lineWidth = (BoundsWidth - startX * 2) / (Point_X_Length - 1);
// int lineHeight = (BoundsHeight - startY * 2) / (Point_Y_Length - 1);
Graphics grfx = panel1.CreateGraphics();
Color color = Color.White;
grfx.SmoothingMode = SmoothingMode.HighQuality;
// Graphics grfx = panel1.CreateGraphics();
// Color color = Color.White;
// grfx.SmoothingMode = SmoothingMode.HighQuality;
//循环画线
for (int i = 0; i <= Point_X_Length; i++)
{
float line = 0.2F;
float picLocationX = startX + lineWidth * i;
if (i.Equals(Point_X_Length / 2))
{
line = 1;
}
else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_X_Length))
{
line = 0.5F;
}
// //循环画线
// for (int i = 0; i <= Point_X_Length; i++)
// {
// float line = 0.2F;
// float picLocationX = startX + lineWidth * i;
// if (i.Equals(Point_X_Length / 2))
// {
// line = 1;
// }
// else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_X_Length))
// {
// line = 0.5F;
// }
grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, BoundsHeight);
// grfx.DrawLine(new Pen(color, line), picLocationX, startY, picLocationX, BoundsHeight);
}
for (int i = 0; i <= Point_Y_Length; i++)
{
float line = 0.2F;
float picLocationY = startY + lineHeight * i;
if (i.Equals(Point_Y_Length / 2))
{
line = 1;
}
else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_Y_Length))
{
line = 0.5F;
}
grfx.DrawLine(new Pen(color, line), startX, picLocationY, BoundsWidth, picLocationY);
}
grfx.Dispose();
}
// }
// for (int i = 0; i <= Point_Y_Length; i++)
// {
// float line = 0.2F;
// float picLocationY = startY + lineHeight * i;
// if (i.Equals(Point_Y_Length / 2))
// {
// line = 1;
// }
// else if (((i % 5).Equals(0)) && (i > 0) && (i < Point_Y_Length))
// {
// line = 0.5F;
// }
// grfx.DrawLine(new Pen(color, line), startX, picLocationY, BoundsWidth, picLocationY);
// }
// grfx.Dispose();
//}
private Color CurrColor = Color.White;
//private Color CurrColor = Color.White;
public void ClearPoint()
{
preMPointMode = false;
try
{
if (!ISShow)
......@@ -389,7 +390,7 @@ namespace TSA_V
}
}
}
public static int StrLength(string inputString)
private static int StrLength(string inputString)
{
System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
int tempLen = 0;
......@@ -403,16 +404,17 @@ namespace TSA_V
}
return tempLen;
}
private Color getPointColor(int rgbColor = -1)
{
if (rgbColor >= 0xffffff)
{
rgbColor = Color.White.ToArgb();
}
return Color.FromArgb(rgbColor);
}
//private Color getPointColor(int rgbColor = -1)
//{
// if (rgbColor >= 0xffffff)
// {
// rgbColor = Color.White.ToArgb();
// }
// return Color.FromArgb(rgbColor);
//}
public void ShowPoint(params DeviceLibrary.ProjectorPInfo[] pList )
{
preMPointMode = false;
if (!ISShow)
{
return;
......@@ -427,64 +429,105 @@ namespace TSA_V
}
public void ShowPoint(bool showName,int rgbColor, params SMTPointInfo[] points)
{
preMPointMode = false;
if (!ISShow)
{
return;
}
Color pColor = Color.FromArgb(rgbColor);
List<SMTPointInfo> pointInfos=new List<SMTPointInfo>(points);
ClearPoint();
Graphics g = panel1.CreateGraphics();
foreach (SMTPointInfo point in points)
{
int type = point.PointType;
int x = (int)point.NodePositionX;
int y = (int)point.NodePositionY;
int sizex = point.PointSizeX;
int sizey = point.PointSizeY;
DrawPoint(pColor, g, x, y, type, point.PolaritiesType,point.PolarityAngle, sizex, sizey, point.PenWidth, "");
DrawPointList(g, pointInfos, pColor, showName);
if (showName)
g.Dispose();
}
/// <summary>
/// 自动判断是否显示电路板区域,自动显示多PCB点位
/// </summary>
/// <param name="board"></param>
/// <param name="showName"></param>
/// <param name="rgbColor"></param>
/// <param name="points"></param>
public void ShowAreaAndPoint(BoardInfo board, bool showName, params SMTPointInfo[] points)
{
int size = (sizex + sizey) / 2;
if (!CloseShowName)
preMPointMode = false;
if (!ISShow)
{
if (point.CheckOK && (points.Length > 1))
return;
}
int rgbColor = board.PointColor;
Color pColor = Color.FromArgb(rgbColor);
//处理多PCB点位
List<SMTPointInfo> pointInfos = new List<SMTPointInfo>();
if (points.Length == 1)
{
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.Red, x - size / 2 + 5, y + size / 2 + 2);
pointInfos = XYConvertManager.GetCopyPointCR(board, points[0]);
}
else
{
Brush brush = new SolidBrush(pColor);
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), brush, x - size / 2 + 5, y + size / 2 + 2);
}
}
pointInfos = XYConvertManager.GetCopyPointCR(board);
}
ClearPoint();
Graphics g = panel1.CreateGraphics();
//如果当前是简洁模式,显示电路板区域
if (Setting_NInit.Device_SoftMode)
{
DrawBoardArea(g, board);
}
DrawPointList(g, pointInfos, pColor, showName);
g.Dispose();
}
private bool preMPointMode = false;
private string preBoardName = "";
private int prePointCount = 0;
/// <summary>
/// 预留电路板点位列表,自动显示多PCB点位
/// 工作状态显示点位
/// </summary>
/// <param name="board"></param>
/// <param name="showName"></param>
/// <param name="rgbColor"></param>
/// <param name="points"></param>
public void ShowBoardPoint(BoardInfo board, bool showName, int rgbColor, params SMTPointInfo[] points)
public void WorkingShowPoint(BoardInfo board, bool showName, params SMTPointInfo[] points)
{
if (!ISShow)
{
return;
}
int rgbColor = board.PointColor;
Color pColor = Color.FromArgb(rgbColor);
ClearPoint();
Graphics g = panel1.CreateGraphics();
if (board != null && board.calInfo != null && board.calInfo.leftUpPoint != null && board.calInfo.rightBottomPoint != null)
{
DrawBoardArea(g, board.calInfo.leftUpPoint, board.calInfo.rightBottomPoint);
}
//处理多PCB点位
List<SMTPointInfo> pointInfos = new List<SMTPointInfo>();
//如果是多点位模式
if (board.mPointsProjection)
{
pointInfos = XYConvertManager.GetCopyPointCR(board);
if (preMPointMode)
{
if (preBoardName.Equals(board.boardName) && prePointCount == pointInfos.Count)
{
//点位一样,不需要重画
return;
}
}
else
{
preMPointMode = true;
preBoardName = board.boardName;
prePointCount = pointInfos.Count;
}
}
else
{
preMPointMode = false;
if (points.Length == 1)
{
pointInfos = XYConvertManager.GetCopyPointCR(board, points[0]);
......@@ -493,6 +536,28 @@ namespace TSA_V
{
pointInfos = XYConvertManager.GetCopyPointCR(board);
}
}
ClearPoint();
Graphics g = panel1.CreateGraphics();
//如果当前是简洁模式,显示电路板区域
if (Setting_NInit.Device_SoftMode)
{
DrawBoardArea(g, board);
}
DrawPointList(g, pointInfos, pColor, showName);
g.Dispose();
if (board.mPointsProjection)
{
preMPointMode = true;
preBoardName = board.boardName;
prePointCount = pointInfos.Count;
}
}
private void DrawPointList(Graphics g, List<SMTPointInfo> pointInfos,Color pColor,bool showName)
{
foreach (SMTPointInfo point in pointInfos)
{
int type = point.PointType;
......@@ -500,18 +565,18 @@ namespace TSA_V
int y = (int)point.NodePositionY;
int sizex = point.PointSizeX;
int sizey = point.PointSizeY;
DrawPoint(pColor, g, x, y, type, point.PolaritiesType,point.PolarityAngle, sizex, sizey, point.PenWidth, "");
DrawPoint(pColor, g, x, y, type, point.PolaritiesType, point.PolarityAngle, sizex, sizey, point.PenWidth, "");
if (showName)
{
int size = (sizex + sizey) / 2;
if (!CloseShowName)
{
if (point.CheckOK && (points.Length > 1))
{
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.Red, x - size / 2 + 5, y + size / 2 + 2);
}
else
//if (point.CheckOK && (points.Length > 1))
//{
// g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), Brushes.Red, x - size / 2 + 5, y + size / 2 + 2);
//}
//else
{
Brush brush = new SolidBrush(pColor);
g.DrawString(point.ShowText, new Font("Arial ", size, FontStyle.Regular), brush, x - size / 2 + 5, y + size / 2 + 2);
......@@ -519,26 +584,52 @@ namespace TSA_V
}
}
}
g.Dispose();
}
public void DrawBoardArea(Graphics g,Point point1,Point point2)
private void DrawBoardArea(Graphics g, BoardInfo board)
{
if (!ISShow)
{
return;
}
if (board != null && board.calInfo != null && board.calInfo.leftUpPoint != null && board.calInfo.rightBottomPoint != null)
{
Color boardColor = Color.LightGray;
List<List<Point>> mpcbAreas=XYConvertManager.GetCopyArea(board);
if(mpcbAreas.Count>0)
{
foreach(List<Point> area in mpcbAreas)
{
if (area.Count == 2)
{
Color boardColor = Color.LightGray;
Point point1 = area[0];
Point point2 = area[1];
int line = 1;
g.DrawRectangle(new Pen(boardColor,line),new Rectangle( point1.X,point1.Y,(point2.X-point1.X),(point2.Y-point1.Y)));
g.DrawRectangle(new Pen(boardColor, line), new Rectangle(point1.X, point1.Y, (point2.X - point1.X), (point2.Y - point1.Y)));
}
}
}
else
{
Color boardColor = Color.LightGray;
Point point1 = board.calInfo.leftUpPoint;
Point point2 = board.calInfo.rightBottomPoint;
int line = 1;
g.DrawRectangle(new Pen(boardColor, line), new Rectangle(point1.X, point1.Y, (point2.X - point1.X), (point2.Y - point1.Y)));
}
//多pcb模式时,需要画多个区域
//g.DrawLine(new Pen(boardColor, line), point1.X, point1.Y, point2.X,point1.Y);
//g.DrawLine(new Pen(boardColor, line), point1.X, point1.Y, point1.X, point2.Y);
//g.DrawLine(new Pen(boardColor, line), point1.X, point2.Y, point2.X, point2.Y);
//g.DrawLine(new Pen(boardColor, line), point2.X, point2.Y, point1.X, point2.Y);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
......
......@@ -113,15 +113,15 @@ namespace TSA_V
LogUtil.info("切换到新板子:" + board.boardName+",保存当前工作的程序名称");
Setting_NInit.Work_ProcedureName= board.boardName;
BoardInfo showBoard = chbSoftMode.Checked ? board : null;
if (showBoard != null)
{
FrmProjectorScreen.instance.ShowBoardPoint(showBoard, false, board.PointColor, board.GetSmtList().ToArray());
}
else
{
FrmProjectorScreen.instance.ClearPoint();
FrmProjectorScreen.instance.ShowPoint(XYConvertManager.GetCopyProjectPointCR(board).ToArray());
}
//if (showBoard != null)
//{
FrmProjectorScreen.instance.ShowAreaAndPoint(board, false, board.GetSmtList().ToArray());
//}
//else
//{
// FrmProjectorScreen.instance.ClearPoint();
// FrmProjectorScreen.instance.ShowPoint(XYConvertManager.GetCopyProjectPointCR(board).ToArray());
//}
}
}
}
......
......@@ -543,7 +543,7 @@ namespace TSA_V
if(Setting_NInit.Device_SoftMode)
{
FrmProjectorScreen.instance.ShowBoardPoint(BoardManager.CurrBoard, true, BoardManager.CurrBoard.PointColor, board.GetSmtList().ToArray());
FrmProjectorScreen.instance.ShowAreaAndPoint(BoardManager.CurrBoard, true , board.GetSmtList().ToArray());
}
timer.Start();
LogUtil.info(Name + " Shown end ");
......@@ -947,16 +947,15 @@ namespace TSA_V
}
LogUtil.debug($"投影点位:{smtPoint.PN}-{smtPoint.TagNo}-{smtPoint.PositionNum}");
if (Setting_NInit.Device_SoftMode)
{
FrmProjectorScreen.instance.ShowBoardPoint(BoardManager.CurrBoard, true, BoardManager.CurrBoard.PointColor, smtPoint);
}
else
{
List<SMTPointInfo> sMTPointInfos = XYConvertManager.GetCopyPointCR(BoardManager.CurrBoard, smtPoint);
FrmProjectorScreen.instance.ShowPoint(true, BoardManager.CurrBoard.PointColor, sMTPointInfos.ToArray());
}
//if (Setting_NInit.Device_SoftMode)
//{
FrmProjectorScreen.instance.WorkingShowPoint(BoardManager.CurrBoard, true, smtPoint);
//}
//else
//{
// List<SMTPointInfo> sMTPointInfos = XYConvertManager.GetCopyPointCR(BoardManager.CurrBoard, smtPoint);
// FrmProjectorScreen.instance.ShowPoint(true, BoardManager.CurrBoard.PointColor, sMTPointInfos.ToArray());
//}
int leftCount = workSmtList.Count - 1 - preIndex;
if (preIndex.Equals(0))
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!