Commit 0fd67cd7 几米阳光

坐标转换修改

1 个父辈 3ea74c66
...@@ -195,6 +195,9 @@ namespace URSoldering.DeviceLibrary ...@@ -195,6 +195,9 @@ namespace URSoldering.DeviceLibrary
public double RobotRY { get; set; } public double RobotRY { get; set; }
public double RobotRZ { get; set; } public double RobotRZ { get; set; }
public int ImageX = -1;
public int ImageY = -1;
/// <summary> /// <summary>
/// 预热温度 /// 预热温度
/// </summary> /// </summary>
......
...@@ -286,6 +286,9 @@ namespace URSoldering.Client ...@@ -286,6 +286,9 @@ namespace URSoldering.Client
view.Cells[Column_pointType.Index].Value = point.pointType; view.Cells[Column_pointType.Index].Value = point.pointType;
view.Cells[Column_isClear.Index].Value = point.isNeedClear.ToString(); view.Cells[Column_isClear.Index].Value = point.isNeedClear.ToString();
view.Cells[Column_ClearTime.Index].Value = point.ClearTime; view.Cells[Column_ClearTime.Index].Value = point.ClearTime;
view.Cells[Column_ImageX.Index].Value = point.ImageX;
view.Cells[Column_ImageY.Index].Value = point.ImageY;
return view; return view;
} }
private bool isRun = false; private bool isRun = false;
...@@ -360,7 +363,7 @@ namespace URSoldering.Client ...@@ -360,7 +363,7 @@ namespace URSoldering.Client
MessageBox.Show("保存失败,焊点Z坐标(" + point.Z + ")不能低于最低Z点(" + URRobotControl.Robot_LIM_Z + ")"); MessageBox.Show("保存失败,焊点Z坐标(" + point.Z + ")不能低于最低Z点(" + URRobotControl.Robot_LIM_Z + ")");
return; return;
} }
AddNewPoint(point); AddNewPoint(point,-1,-1);
liUpdateTime_LinkClicked(null, null); liUpdateTime_LinkClicked(null, null);
} }
...@@ -780,6 +783,8 @@ namespace URSoldering.Client ...@@ -780,6 +783,8 @@ namespace URSoldering.Client
point.isNeedClear = Convert.ToBoolean(row.Cells[this.Column_isClear.Name].Value.ToString()); point.isNeedClear = Convert.ToBoolean(row.Cells[this.Column_isClear.Name].Value.ToString());
point.pointType = Convert.ToInt32(row.Cells[this.Column_pointType.Name].Value.ToString()); point.pointType = Convert.ToInt32(row.Cells[this.Column_pointType.Name].Value.ToString());
point.ClearTime=Convert.ToInt32(row.Cells[this.Column_ClearTime.Name].Value.ToString()); point.ClearTime=Convert.ToInt32(row.Cells[this.Column_ClearTime.Name].Value.ToString());
point.ImageX = Convert.ToInt32(row.Cells[this.Column_ImageX.Name].Value.ToString());
point.ImageY = Convert.ToInt32(row.Cells[this.Column_ImageY.Name].Value.ToString());
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -873,8 +878,9 @@ namespace URSoldering.Client ...@@ -873,8 +878,9 @@ namespace URSoldering.Client
int pointHight = 16; int pointHight = 16;
float x, y; float x, y;
GetPicPointByUrPoint(weld.GetURPoint(), out x, out y); GetPicPointByUrPoint(weld.GetURPoint(), out x, out y);
x = weld.ImageX;
LogUtil.debug("显示焊点:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】"); y = weld.ImageY;
LogUtil.debug("显示焊点【"+weld.pointName+"】:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】");
g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight); g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight);
if (index > 0) if (index > 0)
{ {
...@@ -1039,7 +1045,7 @@ namespace URSoldering.Client ...@@ -1039,7 +1045,7 @@ namespace URSoldering.Client
URPointValue point = GetUrPointByPicPoint( ); URPointValue point = GetUrPointByPicPoint( );
LogUtil.info("新增焊点:X【" + m_MouseDownPoint.X + "】Y【" + m_MouseDownPoint.Y + "】,坐标 【" + point.ToShowStr() + "】 "); LogUtil.info("新增焊点:X【" + m_MouseDownPoint.X + "】Y【" + m_MouseDownPoint.Y + "】,坐标 【" + point.ToShowStr() + "】 ");
AddNewPoint(point); AddNewPoint(point, m_MouseDownPoint.X, m_MouseDownPoint.Y);
liUpdateTime_LinkClicked(null, null); liUpdateTime_LinkClicked(null, null);
} }
...@@ -1055,13 +1061,13 @@ namespace URSoldering.Client ...@@ -1055,13 +1061,13 @@ namespace URSoldering.Client
//判断AD点是否有效 //判断AD点是否有效
if (APointValue.IsValid() && DPointValue.IsValid()) if (APointValue.IsValid() && DPointValue.IsValid())
{ {
x = (float)((point.X-APointValue.X) * width / (DPointValue.X - APointValue.X)); x = (float)((point.X - APointValue.X) * width / (DPointValue.X - APointValue.X));
y = (float)((point.Y-APointValue.Y) * height / (DPointValue.Y - APointValue.Y)); y = (float)((point.Y - APointValue.Y) * height / (DPointValue.Y - APointValue.Y));
} }
else if (BPointValue.IsValid() && CPointValue.IsValid()) else if (BPointValue.IsValid() && CPointValue.IsValid())
{ {
x = (float)((point.X-BPointValue.X) * width / (CPointValue.X - BPointValue.X)); x = (float)((point.X - BPointValue.X) * width / (CPointValue.X - BPointValue.X));
y = (float)((point.Y-CPointValue.Y) * height / (BPointValue.Y - CPointValue.Y)); y = (float)((point.Y - CPointValue.Y) * height / (BPointValue.Y - CPointValue.Y));
} }
else else
{ {
...@@ -1069,7 +1075,7 @@ namespace URSoldering.Client ...@@ -1069,7 +1075,7 @@ namespace URSoldering.Client
y = -1; y = -1;
} }
} }
private URPointValue GetUrPointByPicPoint( ) private URPointValue GetUrPointByPicPoint()
{ {
URPointValue currPoint = GetCurrRobotPoint(); URPointValue currPoint = GetCurrRobotPoint();
URPointValue point = new URPointValue(0, 0, currPoint.Z, currPoint.RX, currPoint.RY, currPoint.RZ); URPointValue point = new URPointValue(0, 0, currPoint.Z, currPoint.RX, currPoint.RY, currPoint.RZ);
...@@ -1082,31 +1088,42 @@ namespace URSoldering.Client ...@@ -1082,31 +1088,42 @@ namespace URSoldering.Client
int width = picBoard.Width; int width = picBoard.Width;
int height = picBoard.Height; int height = picBoard.Height;
//if (APointValue.IsValid() && DPointValue.IsValid())
//{
// double x = APointValue.X + m_MouseDownPoint.X * (DPointValue.X - APointValue.X) / width;
// double y = APointValue.Y + m_MouseDownPoint.Y * (DPointValue.Y - APointValue.Y) / height;
// point.X = x;
// point.Y = y;
//}
//else if (BPointValue.IsValid() && CPointValue.IsValid())
//{
// double x = BPointValue.X + m_MouseDownPoint.X * (CPointValue.X - BPointValue.X) / width;
// double y = CPointValue.Y + m_MouseDownPoint.Y * (BPointValue.Y - CPointValue.Y) / height;
// point.X = x;
// point.Y = y;
//}
//判断AD点是否有效 //判断AD点是否有效
if (APointValue.IsValid() && DPointValue.IsValid()) if (APointValue.IsValid() && CPointValue.IsValid() && BPointValue.IsValid())
{ {
double x = APointValue.X + m_MouseDownPoint.X * (DPointValue.X - APointValue.X) / width; double x = APointValue.X + m_MouseDownPoint.Y * (BPointValue.X - APointValue.X) / height +
double y= APointValue.Y+m_MouseDownPoint.Y*(DPointValue.Y - APointValue.Y) / height; m_MouseDownPoint.X * (CPointValue.X - APointValue.X) / width;
point.X = x; double y = APointValue.Y + m_MouseDownPoint.Y * (BPointValue.Y - APointValue.Y) / height +
point.Y = y; m_MouseDownPoint.X * (CPointValue.Y - APointValue.Y) / width;
}else if (BPointValue.IsValid() && CPointValue.IsValid()) point.X = Math.Round(x, 2);
{ point.Y = Math.Round(y, 2);
double x =BPointValue.X+ m_MouseDownPoint.X * (CPointValue.X - BPointValue.X) / width; LogUtil.info("图片坐标【" + m_MouseDownPoint.X + "," + m_MouseDownPoint.Y + "】宽【" + width + "】高【" + height + "】机械臂坐标【" + point.X + "," + point.Y + "】");
double y =CPointValue.Y+ m_MouseDownPoint.Y * (BPointValue.Y - CPointValue.Y) / height; }
point.X = x;
point.Y = y;
}
return point; return point;
} }
private void AddNewPoint(URPointValue robotP) private void AddNewPoint(URPointValue robotP,int ImageX,int ImageY)
{ {
WeldPointInfo point = new WeldPointInfo(); WeldPointInfo point = new WeldPointInfo();
string name = "P" + (dgvList.Rows.Count + 1); string name = "P" + (dgvList.Rows.Count + 1);
//FrmPointInfo fwpi = new FrmPointInfo(name,robotP); //FrmPointInfo fwpi = new FrmPointInfo(name,robotP);
//DialogResult result = fwpi.ShowDialog(); //DialogResult result = fwpi.ShowDialog();
FrmPointInfo fwpi = new FrmPointInfo(name, robotP); FrmPointInfo fwpi = new FrmPointInfo(name, robotP,ImageX,ImageY);
fwpi.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) fwpi.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
......
...@@ -475,6 +475,12 @@ ...@@ -475,6 +475,12 @@
<metadata name="Column_ClearTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column_ClearTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column_ImageX.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_ImageY.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column_getPosition.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Column_getPosition.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
......
...@@ -236,7 +236,8 @@ namespace URSoldering.Client ...@@ -236,7 +236,8 @@ namespace URSoldering.Client
int pointHight = 16; int pointHight = 16;
float x, y; float x, y;
GetPicPointByUrPoint(board, weld.GetURPoint(), out x, out y); GetPicPointByUrPoint(board, weld.GetURPoint(), out x, out y);
x = weld.ImageX;
y = weld.ImageY;
LogUtil.debug("显示焊点:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】"); LogUtil.debug("显示焊点:X【" + x + "】Y【" + y + "】,坐标X【" + weld.RobotX + "】坐标Y【" + weld.RobotY + "】");
g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight); g.FillEllipse(Brushes.Red, x - pointHight / 2, y - pointHight / 2, pointHight, pointHight);
if (index > 0) if (index > 0)
......
...@@ -14,6 +14,8 @@ namespace URSoldering.Client ...@@ -14,6 +14,8 @@ namespace URSoldering.Client
{ {
public partial class FrmPointInfo : FrmBase public partial class FrmPointInfo : FrmBase
{ {
private int ImageX = 0;
private int ImageY = 0;
public delegate void OpClose(DialogResult result,WeldPointInfo point); public delegate void OpClose(DialogResult result,WeldPointInfo point);
public event OpClose OnCloseEnd; public event OpClose OnCloseEnd;
public WeldPointInfo weldPointInfo = new WeldPointInfo(); public WeldPointInfo weldPointInfo = new WeldPointInfo();
...@@ -24,8 +26,12 @@ namespace URSoldering.Client ...@@ -24,8 +26,12 @@ namespace URSoldering.Client
cmbPointType.SelectedIndex = 0; cmbPointType.SelectedIndex = 0;
groupPoint.Text = "新增焊点"; groupPoint.Text = "新增焊点";
} }
public FrmPointInfo(string name,URPointValue point) public FrmPointInfo(string name,URPointValue point,int imageX,int imageY)
{ {
this.ImageX = imageX;
this.ImageY = imageY;
weldPointInfo.ImageX = ImageX;
weldPointInfo.ImageY = ImageY;
InitializeComponent(); InitializeComponent();
this.Text = "新增焊点"; this.Text = "新增焊点";
groupPoint.Text = "新增焊点"; groupPoint.Text = "新增焊点";
......
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
this.groupBox6 = new System.Windows.Forms.GroupBox(); this.groupBox6 = new System.Windows.Forms.GroupBox();
this.markControl = new UserFromControl.URRobotMControl(); this.markControl = new UserFromControl.URRobotMControl();
this.groupBox7 = new System.Windows.Forms.GroupBox(); this.groupBox7 = new System.Windows.Forms.GroupBox();
this.txtMarkX = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.txtMarkY = new System.Windows.Forms.TextBox(); this.txtMarkY = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.txtMarkX = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox4.SuspendLayout();
...@@ -302,25 +302,10 @@ ...@@ -302,25 +302,10 @@
this.groupBox7.TabStop = false; this.groupBox7.TabStop = false;
this.groupBox7.Text = "坐标偏移Mark点的图片坐标"; this.groupBox7.Text = "坐标偏移Mark点的图片坐标";
// //
// txtMarkX
//
this.txtMarkX.Location = new System.Drawing.Point(51, 27);
this.txtMarkX.Name = "txtMarkX";
this.txtMarkX.Size = new System.Drawing.Size(106, 23);
this.txtMarkX.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(28, 17);
this.label1.TabIndex = 6;
this.label1.Text = "X:";
//
// txtMarkY // txtMarkY
// //
this.txtMarkY.Location = new System.Drawing.Point(212, 27); this.txtMarkY.Location = new System.Drawing.Point(212, 27);
this.txtMarkY.MaxLength = 10;
this.txtMarkY.Name = "txtMarkY"; this.txtMarkY.Name = "txtMarkY";
this.txtMarkY.Size = new System.Drawing.Size(106, 23); this.txtMarkY.Size = new System.Drawing.Size(106, 23);
this.txtMarkY.TabIndex = 9; this.txtMarkY.TabIndex = 9;
...@@ -334,6 +319,23 @@ ...@@ -334,6 +319,23 @@
this.label2.TabIndex = 8; this.label2.TabIndex = 8;
this.label2.Text = "Y:"; this.label2.Text = "Y:";
// //
// txtMarkX
//
this.txtMarkX.Location = new System.Drawing.Point(51, 27);
this.txtMarkX.MaxLength = 10;
this.txtMarkX.Name = "txtMarkX";
this.txtMarkX.Size = new System.Drawing.Size(106, 23);
this.txtMarkX.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(17, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(28, 17);
this.label1.TabIndex = 6;
this.label1.Text = "X:";
//
// FrmSetting // FrmSetting
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
......
...@@ -137,12 +137,18 @@ namespace URSoldering.Client ...@@ -137,12 +137,18 @@ namespace URSoldering.Client
double x = FormUtil.getDoubleValue(txtMarkX); double x = FormUtil.getDoubleValue(txtMarkX);
double y = FormUtil.getDoubleValue(txtMarkY); double y = FormUtil.getDoubleValue(txtMarkY);
if (x <= 0 || y <= 0) if (!txtMarkX.Text.Equals(x.ToString()) )
{ {
MessageBox.Show("请输入正确的Mark的图片坐标"); MessageBox.Show("请输入正确的Mark的图片X坐标");
txtMarkX.Focus(); txtMarkX.Focus();
return; return;
} }
if (!txtMarkY.Text.Equals(y.ToString()))
{
MessageBox.Show("请输入正确的Mark的图片Y坐标");
txtMarkY.Focus();
return;
}
WeldRobotBean.MarkImgPosition = new PositionResult(x, y); WeldRobotBean.MarkImgPosition = new PositionResult(x, y);
ConfigAppSettings.SaveValue(Setting_Init.MarkDefaultPosition, WeldRobotBean.MarkImgPosition.ToJosonStr()); ConfigAppSettings.SaveValue(Setting_Init.MarkDefaultPosition, WeldRobotBean.MarkImgPosition.ToJosonStr());
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!