SlopFocus.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using OTSCLRINTERFACE;
  2. using OTSDataType;
  3. using OTSMeasureApp._0_OTSModel.OTSDataType;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace OTSMeasureApp._5_OTSMeasureStatuImageFun
  14. {
  15. public partial class SlopFocus : Form
  16. {
  17. COTSControlFunExport cfun;
  18. CSlopFocusParam slopFocusParam;
  19. bool m_result=false;
  20. public bool result {get => m_result; set => m_result = value; }
  21. public SlopFocus()
  22. {
  23. InitializeComponent();
  24. }
  25. public CSlopFocusParam GetCSlopFocusParam()
  26. {
  27. return slopFocusParam;
  28. }
  29. private void bn_OK_Click(object sender, EventArgs e)
  30. {
  31. int iPX1, iPY1, iPX2, iPY2, iPX3,iPY3;
  32. iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0;
  33. double dPW1, dPW2, dPW3;
  34. dPW1 = dPW2 = dPW3 = 0;
  35. if(!int.TryParse(tB_FirstPointX.Text,out iPX1)|| !int.TryParse(tB_FirstPointY.Text, out iPY1) || !int.TryParse(tB_SecondPointX.Text, out iPX2) || !int.TryParse(tB_SecondPointY.Text, out iPY2) || !int.TryParse(tB_ThirdPointX.Text, out iPX3) || !int.TryParse(tB_ThirdPointY.Text, out iPY3) || !double.TryParse(tB_FirstPointD.Text, out dPW1) || !double.TryParse(tB_SecondPointD.Text, out dPW2) || !double.TryParse(tB_ThirdPointD.Text, out dPW3))
  36. {
  37. MessageBox.Show("Please check Params!");
  38. return;
  39. }
  40. if((tB_FirstPointX.Text== tB_SecondPointX.Text&& tB_FirstPointY.Text== tB_SecondPointY.Text)||(tB_FirstPointX.Text== tB_ThirdPointX.Text&& tB_FirstPointY.Text== tB_ThirdPointY.Text)||(tB_SecondPointX.Text== tB_ThirdPointX.Text&& tB_SecondPointY.Text== tB_ThirdPointY.Text))
  41. {
  42. MessageBox.Show("Please select different points!");
  43. return;
  44. }
  45. if(slopFocusParam==null)
  46. {
  47. slopFocusParam = new CSlopFocusParam();
  48. }
  49. slopFocusParam.IsUsingSlopParam = cB_enable.Checked;
  50. slopFocusParam.FirstPoint = new Point(iPX1, iPY1);
  51. slopFocusParam.FirstWD = dPW1;
  52. slopFocusParam.SecondPoint = new Point(iPX2, iPY2);
  53. slopFocusParam.SecondWD = dPW2;
  54. slopFocusParam.ThirdPoint = new Point(iPX3, iPY3);
  55. slopFocusParam.ThirdWD = dPW3;
  56. m_result=true;
  57. }
  58. private void SlopFocus_Load(object sender, EventArgs e)
  59. {
  60. if(cfun==null)
  61. {
  62. cfun = COTSControlFunExport.GetControllerInstance();
  63. }
  64. }
  65. private void bn_FirstPoint_Click(object sender, EventArgs e)
  66. {
  67. //double a, b, c;
  68. //a = b = 20;
  69. //c = 20;
  70. //cfun.SetSemPositionXY(a, b, c);
  71. //cfun.SetSemWorkingDistance(c);
  72. double Px = 0;
  73. double Py = 0;
  74. double Pr = 0;
  75. if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr))
  76. {
  77. tB_FirstPointX.Text = Px.ToString();
  78. tB_FirstPointY.Text = Py.ToString();
  79. }
  80. double WD = 0;
  81. if(cfun.GetSemWorkingDistance(ref WD))
  82. {
  83. tB_FirstPointD.Text = WD.ToString();
  84. }
  85. }
  86. private void bn_SecondPoint_Click(object sender, EventArgs e)
  87. {
  88. //double a, b, c;
  89. //a = b =10;
  90. //c = 10;
  91. //cfun.SetSemPositionXY(a,b,c);
  92. //cfun.SetSemWorkingDistance(c);
  93. double Px = 0;
  94. double Py = 0;
  95. double Pr = 0;
  96. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  97. {
  98. tB_SecondPointX.Text = Px.ToString();
  99. tB_SecondPointY.Text = Py.ToString();
  100. }
  101. double WD = 0;
  102. if (cfun.GetSemWorkingDistance(ref WD))
  103. {
  104. tB_SecondPointD.Text = WD.ToString();
  105. }
  106. }
  107. private void bn_ThirdPoint_Click(object sender, EventArgs e)
  108. {
  109. //double a, b, c;
  110. //a = b = 30;
  111. //c = 30;
  112. //cfun.SetSemPositionXY(a, b, c);
  113. //cfun.SetSemWorkingDistance(c);
  114. double Px = 0;
  115. double Py = 0;
  116. double Pr = 0;
  117. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  118. {
  119. tB_ThirdPointX.Text = Px.ToString();
  120. tB_ThirdPointY.Text = Py.ToString();
  121. }
  122. double WD = 0;
  123. if (cfun.GetSemWorkingDistance(ref WD))
  124. {
  125. tB_ThirdPointD.Text = WD.ToString();
  126. }
  127. }
  128. private void bn_Cancel_Click(object sender, EventArgs e)
  129. {
  130. m_result = false;
  131. this.Close();
  132. }
  133. }
  134. }