SlopFocus.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using OTSMeasureApp._0_OTSModel.OTSDataType;
  2. using OTSModelSharp.ServiceCenter;
  3. using System;
  4. using System.Collections;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. namespace OTSMeasureApp
  8. {
  9. public partial class SlopFocus : Form
  10. {
  11. ISemController cfun;
  12. CSlopFocusParam slopFocusParam;
  13. bool m_result=false;
  14. OTSSamplespaceWindow oTSSamplespaceWindow;
  15. public bool result {get => m_result; set => m_result = value; }
  16. //国际化
  17. OTSCommon.Language lan;
  18. Hashtable table;
  19. public SlopFocus(OTSSamplespaceWindow a_oTSSamplespaceWindow)
  20. {
  21. InitializeComponent();
  22. oTSSamplespaceWindow = a_oTSSamplespaceWindow;
  23. //国际化
  24. lan = new OTSCommon.Language(this);
  25. table = lan.GetNameTable(this.Name);
  26. CSlopFocusParam cSlopFocusParam = oTSSamplespaceWindow.getSlopFocusParam();
  27. if(cSlopFocusParam!=null)
  28. {
  29. slopFocusParam = cSlopFocusParam;
  30. cB_enable.Checked = slopFocusParam.IsUsingSlopParam;
  31. tB_FirstPointX.Text = slopFocusParam.FirstPoint.X.ToString();
  32. tB_FirstPointY.Text = slopFocusParam.FirstPoint.Y.ToString();
  33. tB_FirstPointD.Text = slopFocusParam.FirstWD.ToString();
  34. tB_SecondPointX.Text = slopFocusParam.SecondPoint.X.ToString();
  35. tB_SecondPointY.Text = slopFocusParam.SecondPoint.Y.ToString();
  36. tB_SecondPointD.Text = slopFocusParam.SecondWD.ToString();
  37. tB_ThirdPointX.Text = slopFocusParam.ThirdPoint.X.ToString();
  38. tB_ThirdPointY.Text = slopFocusParam.ThirdPoint.Y.ToString();
  39. tB_ThirdPointD.Text = slopFocusParam.ThirdWD.ToString();
  40. }
  41. }
  42. public CSlopFocusParam GetCSlopFocusParam()
  43. {
  44. return slopFocusParam;
  45. }
  46. private void bn_OK_Click(object sender, EventArgs e)
  47. {
  48. double iPX1, iPY1, iPX2, iPY2, iPX3,iPY3;
  49. iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0;
  50. double dPW1, dPW2, dPW3;
  51. dPW1 = dPW2 = dPW3 = 0;
  52. if(!double.TryParse(tB_FirstPointX.Text,out iPX1)|| !double.TryParse(tB_FirstPointY.Text, out iPY1) || !double.TryParse(tB_SecondPointX.Text, out iPX2) || !double.TryParse(tB_SecondPointY.Text, out iPY2) || !double.TryParse(tB_ThirdPointX.Text, out iPX3) || !double.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))
  53. {
  54. MessageBox.Show("Please check Params!");
  55. return;
  56. }
  57. 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))
  58. {
  59. MessageBox.Show("Please select different points!");
  60. return;
  61. }
  62. if(slopFocusParam==null)
  63. {
  64. slopFocusParam = new CSlopFocusParam();
  65. }
  66. slopFocusParam.IsUsingSlopParam = cB_enable.Checked;
  67. slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1);
  68. slopFocusParam.FirstWD = dPW1;
  69. slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2);
  70. slopFocusParam.SecondWD = dPW2;
  71. slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3);slopFocusParam.ThirdWD = dPW3;
  72. oTSSamplespaceWindow.setSlopFocusParam(this);
  73. this.Close();
  74. }
  75. private void SlopFocus_Load(object sender, EventArgs e)
  76. {
  77. if(cfun==null)
  78. {
  79. cfun = SemController.GetSEMController();
  80. }
  81. }
  82. private void bn_FirstPoint_Click(object sender, EventArgs e)
  83. {
  84. //double a, b, c;
  85. //a = b = 20;
  86. //c = 20;
  87. //cfun.SetSemPositionXY(a, b, c);
  88. //cfun.SetSemWorkingDistance(c);
  89. double Px = 0;
  90. double Py = 0;
  91. double Pr = 0;
  92. if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr))
  93. {
  94. tB_FirstPointX.Text = Px.ToString();
  95. tB_FirstPointY.Text = Py.ToString();
  96. }
  97. double WD = 0;
  98. if(cfun.GetWorkingDistance(ref WD))
  99. {
  100. tB_FirstPointD.Text = WD.ToString();
  101. }
  102. }
  103. private void bn_SecondPoint_Click(object sender, EventArgs e)
  104. {
  105. //double a, b, c;
  106. //a = b = 10;
  107. //c = 10;
  108. //cfun.SetSemPositionXY(a, b, c);
  109. //cfun.SetSemWorkingDistance(c);
  110. double Px = 0;
  111. double Py = 0;
  112. double Pr = 0;
  113. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  114. {
  115. tB_SecondPointX.Text = Px.ToString();
  116. tB_SecondPointY.Text = Py.ToString();
  117. }
  118. double WD = 0;
  119. if (cfun.GetWorkingDistance(ref WD))
  120. {
  121. tB_SecondPointD.Text = WD.ToString();
  122. }
  123. }
  124. private void bn_ThirdPoint_Click(object sender, EventArgs e)
  125. {
  126. //double a, b, c;
  127. //a = b = 30;
  128. //c = 30;
  129. //cfun.SetSemPositionXY(a, b, c);
  130. //cfun.SetSemWorkingDistance(c);
  131. double Px = 0;
  132. double Py = 0;
  133. double Pr = 0;
  134. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  135. {
  136. tB_ThirdPointX.Text = Px.ToString();
  137. tB_ThirdPointY.Text = Py.ToString();
  138. }
  139. double WD = 0;
  140. if (cfun.GetWorkingDistance(ref WD))
  141. {
  142. tB_ThirdPointD.Text = WD.ToString();
  143. }
  144. }
  145. private void bn_Cancel_Click(object sender, EventArgs e)
  146. {
  147. m_result = false;
  148. this.Close();
  149. }
  150. private void SlopFocus_FormClosing(object sender, FormClosingEventArgs e)
  151. {
  152. //e.Cancel = true;
  153. this.Close();
  154. }
  155. private void button1_Click(object sender, EventArgs e)
  156. {
  157. //double a, b, c;
  158. //a = b = 20;
  159. //c = 20;
  160. //cfun.SetSemPositionXY(a, b, c);
  161. //cfun.SetSemWorkingDistance(c);
  162. if (tB_FirstPointD.Text == "")
  163. {
  164. MessageBox.Show("Please read first!");
  165. return;
  166. }
  167. double Px = Convert.ToDouble(tB_FirstPointX.Text);
  168. double Py = Convert.ToDouble(tB_FirstPointY.Text);
  169. double wd=Convert.ToDouble(tB_FirstPointD.Text);
  170. if (cfun.MoveSEMToPoint( Px, Py))
  171. {
  172. cfun.SetWorkingDistance(wd);
  173. }
  174. }
  175. private void button2_Click(object sender, EventArgs e)
  176. {
  177. if (tB_SecondPointD.Text == "")
  178. {
  179. MessageBox.Show("Please read first!");
  180. return;
  181. }
  182. double Px = Convert.ToDouble(tB_SecondPointX.Text);
  183. double Py = Convert.ToDouble(tB_SecondPointY.Text);
  184. double wd = Convert.ToDouble(tB_SecondPointD.Text);
  185. if (cfun.MoveSEMToPoint(Px, Py))
  186. {
  187. cfun.SetWorkingDistance(wd);
  188. }
  189. }
  190. private void button3_Click(object sender, EventArgs e)
  191. {
  192. if (tB_ThirdPointD.Text == "")
  193. {
  194. MessageBox.Show("Please read first!");
  195. return;
  196. }
  197. double Px = Convert.ToDouble(tB_ThirdPointX.Text);
  198. double Py = Convert.ToDouble(tB_ThirdPointY.Text);
  199. double wd = Convert.ToDouble(tB_ThirdPointD.Text);
  200. if (cfun.MoveSEMToPoint(Px, Py))
  201. {
  202. cfun.SetWorkingDistance(wd);
  203. }
  204. }
  205. }
  206. }