SlopFocus.cs 8.3 KB

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