diff --git a/HexcalMC/Motion/EtalonForm.cs b/HexcalMC/Motion/EtalonForm.cs index fe1a102..93bf6c6 100644 --- a/HexcalMC/Motion/EtalonForm.cs +++ b/HexcalMC/Motion/EtalonForm.cs @@ -13,6 +13,7 @@ using System.Threading; using System.Threading.Tasks; using System.Timers; using System.Windows.Forms; +using System.Windows.Media; using ACS.SPiiPlusNET; using HexcalMC.Base; using Plot3D; @@ -78,8 +79,8 @@ namespace HexcalMC private eDemo me_Demo; private eColorScheme me_ColorScheme; private System.Windows.Forms.Timer mi_StatusTimer = new System.Windows.Forms.Timer(); - private cMessgData mi_MesgTop = new cMessgData("", -7, 7, Color.Blue); // For special hint - private cMessgData mi_MesgBottom = new cMessgData("", -7, -7, Color.Gray); // For selection mode + private cMessgData mi_MesgTop = new cMessgData("", -7, 7, System.Drawing.Color.Blue); // For special hint + private cMessgData mi_MesgBottom = new cMessgData("", -7, -7, System.Drawing.Color.Gray); // For selection mode // Only for demo "Animation" private System.Windows.Forms.Timer mi_AnimationTimer = new System.Windows.Forms.Timer(); @@ -99,6 +100,7 @@ namespace HexcalMC private readonly MainFrom mainFrom; private readonly Api _acs; //ACS控制器 + private double dwellTime = 2000; //停顿时间 public Axis[] axes = { @@ -217,7 +219,7 @@ namespace HexcalMC editor3D.Normalize = eNormalize.Separate; editor3D.AddRenderData(i_ShapeData, i_LineData); - editor3D.Selection.HighlightColor = Color.FromArgb(90, 90, 90); + editor3D.Selection.HighlightColor = System.Drawing.Color.FromArgb(90, 90, 90); editor3D.Selection.Callback = OnSelectEvent; editor3D.Selection.MultiSelect = true; editor3D.Selection.Enabled = true; @@ -407,7 +409,7 @@ namespace HexcalMC } // 创建多点运动 - double dwellTime = dwellTimes.Average() * 1000; //将秒转换为毫秒 + dwellTime = dwellTimes.Average() * 1000; //将秒转换为毫秒 DebugDfn.AddLogText("平均停顿时间(毫秒):" + dwellTime); _acs.MultiPointM(MotionFlags.ACSC_NONE, axes, dwellTime); @@ -500,12 +502,10 @@ namespace HexcalMC mainFrom.StopCounting(); refresh_time.Stop(); timer_move.Stop(); - currentIndex = 0; + currentIndex = 0; + } - - } - - private void btn_etalon_import_Click(object sender, EventArgs e) //解析Etalon文件 + private void btn_etalon_import_Click(object sender, EventArgs e) //解析Etalon文件 { //打开文件对号框,选择 mpf格式文件 OpenFileDialog i_Dlg = new OpenFileDialog(); @@ -561,6 +561,7 @@ namespace HexcalMC etalon_points.Clear(); filteredPoints.Clear(); dwellTimes.Clear(); + currentIndex = 0; //重置当前点 //读取文件 string[] lines = File.ReadAllLines(mpf_file_path); @@ -661,7 +662,7 @@ namespace HexcalMC editor3D.Normalize = eNormalize.Separate; editor3D.AddRenderData(i_ShapeData, i_LineData); - editor3D.Selection.HighlightColor = Color.FromArgb(90, 90, 90); + editor3D.Selection.HighlightColor = System.Drawing.Color.FromArgb(90, 90, 90); editor3D.Selection.Callback = OnSelectEvent; editor3D.Selection.MultiSelect = true; editor3D.Selection.Enabled = true; @@ -686,19 +687,16 @@ namespace HexcalMC cScatterData i_ShapeData = new cScatterData(); //currentIndex = mainFrom.GetInPosCount();//获取当前点的数量 - if (currentIndex < filteredPoints.Count) + for (int i = 0; i < filteredPoints.Count; i++) //遍历所有点 { - - - // 更新点的颜色 - for (int i = 0; i <= currentIndex; i++) + if (i < currentIndex-1) //小于的部分,已跑完 为绿色 { double d_X = filteredPoints[i].X; double d_Y = filteredPoints[i].Y; double d_Z = filteredPoints[i].Z; cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point"); - SolidBrush i_brush = new SolidBrush(Color.Red); + SolidBrush i_brush = new SolidBrush(System.Drawing.Color.Green); // You can store the returned shape in a variable and later modify it's properties cShape3D i_Shape = i_ShapeData.AddShape( i_Point, @@ -708,16 +706,31 @@ namespace HexcalMC null ); } - - // 对于剩余部分的点,不做颜色更新 - for (int i = currentIndex; i < filteredPoints.Count; i++) + else if (i == currentIndex-1) //当前点为橙黄色 { double d_X = filteredPoints[i].X; double d_Y = filteredPoints[i].Y; double d_Z = filteredPoints[i].Z; cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point"); - SolidBrush i_brush = new SolidBrush(Color.Gray); + SolidBrush i_brush = new SolidBrush(System.Drawing.Color.OrangeRed); + // You can store the returned shape in a variable and later modify it's properties + cShape3D i_Shape = i_ShapeData.AddShape( + i_Point, + eScatterShape.Circle, + 5, + i_brush, + null + ); + } + else + { + double d_X = filteredPoints[i].X; + double d_Y = filteredPoints[i].Y; + double d_Z = filteredPoints[i].Z; + + cPoint3D i_Point = new cPoint3D(d_X, d_Y, d_Z, "Scatter Point"); + SolidBrush i_brush = new SolidBrush(System.Drawing.Color.Gray); // You can store the returned shape in a variable and later modify it's properties cShape3D i_Shape = i_ShapeData.AddShape( i_Point, @@ -728,11 +741,11 @@ namespace HexcalMC ); } - editor3D.Clear(); - editor3D.Normalize = eNormalize.Separate; - editor3D.AddRenderData(i_ShapeData); - editor3D.Invalidate(); - } + editor3D.Clear(); + editor3D.Normalize = eNormalize.Separate; + editor3D.AddRenderData(i_ShapeData); + editor3D.Invalidate(); + } } #endregion @@ -751,21 +764,29 @@ namespace HexcalMC { if (filteredPoints.Count > 0 && currentIndex < filteredPoints.Count) { - //增加2秒延时 - Thread.Sleep(2000); + //增加2秒延时 + Thread.Sleep((int)dwellTime); - Point nextPoint = filteredPoints[currentIndex]; + Point nextPoint = filteredPoints[currentIndex]; //打印 nextPoint - DebugDfn.AddLogText("下发指令:" + currentIndex + " 点:" + nextPoint.X + " " + nextPoint.Y + " " + nextPoint.Z ); - - mainFrom.SetPositionXyz(Point.FromPoint(nextPoint)); //移动到下一个点 - + DebugDfn.AddLogText( + "下发指令:" + + currentIndex + + " 点:" + + nextPoint.X + + " " + + nextPoint.Y + + " " + + nextPoint.Z + ); currentIndex++; + mainFrom.SetPositionXyz(Point.FromPoint(nextPoint)); //移动到下一个点 } else { DebugDfn.AddLogText("All points have been visited."); timer_move.Stop(); + currentIndex = 0; } } diff --git a/HexcalMC/bin/x64/Debug/HexcalMC.application b/HexcalMC/bin/x64/Debug/HexcalMC.application index c55418f..e966abb 100644 --- a/HexcalMC/bin/x64/Debug/HexcalMC.application +++ b/HexcalMC/bin/x64/Debug/HexcalMC.application @@ -21,7 +21,7 @@ - 5BAu5mmkGH6UcqUDfkL6WCaAYDZ3v+HSBDiHWDwiFF0= + z2mLqy08XuUV8hlnpHyZ0pykJWrtzR1mUJK4Iyn9kS4= diff --git a/HexcalMC/bin/x64/Debug/HexcalMC.exe b/HexcalMC/bin/x64/Debug/HexcalMC.exe index 525c080..b7dfda6 100644 Binary files a/HexcalMC/bin/x64/Debug/HexcalMC.exe and b/HexcalMC/bin/x64/Debug/HexcalMC.exe differ diff --git a/HexcalMC/bin/x64/Debug/HexcalMC.exe.manifest b/HexcalMC/bin/x64/Debug/HexcalMC.exe.manifest index 13156c5..71bae51 100644 --- a/HexcalMC/bin/x64/Debug/HexcalMC.exe.manifest +++ b/HexcalMC/bin/x64/Debug/HexcalMC.exe.manifest @@ -62,7 +62,7 @@ - cGpoIhg/anGo/O6Lnll6V35Q+gP3ExIYb7ltMw03hpA= + 4DR1ksKlokf+OktGK8d+8M0auawSIh8axvkUM7xdmUc= diff --git a/HexcalMC/bin/x64/Debug/HexcalMC.pdb b/HexcalMC/bin/x64/Debug/HexcalMC.pdb index ed4e33d..951bf27 100644 Binary files a/HexcalMC/bin/x64/Debug/HexcalMC.pdb and b/HexcalMC/bin/x64/Debug/HexcalMC.pdb differ diff --git a/HexcalMC/bin/x64/Debug/app.publish/HexcalMC.exe b/HexcalMC/bin/x64/Debug/app.publish/HexcalMC.exe index cc1f403..a7ac2ed 100644 Binary files a/HexcalMC/bin/x64/Debug/app.publish/HexcalMC.exe and b/HexcalMC/bin/x64/Debug/app.publish/HexcalMC.exe differ