SlopFocus.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. }
  35. public CSlopFocusParam GetCSlopFocusParam()
  36. {
  37. return slopFocusParam;
  38. }
  39. private void bn_OK_Click(object sender, EventArgs e)
  40. {
  41. double iPX1, iPY1, iPX2, iPY2, iPX3,iPY3;
  42. iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0;
  43. double dPW1, dPW2, dPW3;
  44. dPW1 = dPW2 = dPW3 = 0;
  45. 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))
  46. {
  47. MessageBox.Show("Please check Params!");
  48. return;
  49. }
  50. 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))
  51. {
  52. MessageBox.Show("Please select different points!");
  53. return;
  54. }
  55. if(slopFocusParam==null)
  56. {
  57. slopFocusParam = new CSlopFocusParam();
  58. }
  59. slopFocusParam.IsUsingSlopParam = cB_enable.Checked;
  60. slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1);
  61. slopFocusParam.FirstWD = dPW1;
  62. slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2);
  63. slopFocusParam.SecondWD = dPW2;
  64. slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3);
  65. slopFocusParam.ThirdWD = dPW3;
  66. oTSSamplespaceWindow.setSlopFocusParam(this);
  67. this.Hide();
  68. }
  69. private void SlopFocus_Load(object sender, EventArgs e)
  70. {
  71. if(cfun==null)
  72. {
  73. cfun = SemController.GetSEMController();
  74. }
  75. }
  76. private void bn_FirstPoint_Click(object sender, EventArgs e)
  77. {
  78. //double a, b, c;
  79. //a = b = 20;
  80. //c = 20;
  81. //cfun.SetSemPositionXY(a, b, c);
  82. //cfun.SetSemWorkingDistance(c);
  83. double Px = 0;
  84. double Py = 0;
  85. double Pr = 0;
  86. if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr))
  87. {
  88. tB_FirstPointX.Text = Px.ToString();
  89. tB_FirstPointY.Text = Py.ToString();
  90. }
  91. double WD = 0;
  92. if(cfun.GetWorkingDistance(ref WD))
  93. {
  94. tB_FirstPointD.Text = WD.ToString();
  95. }
  96. }
  97. private void bn_SecondPoint_Click(object sender, EventArgs e)
  98. {
  99. //double a, b, c;
  100. //a = b = 10;
  101. //c = 10;
  102. //cfun.SetSemPositionXY(a, b, c);
  103. //cfun.SetSemWorkingDistance(c);
  104. double Px = 0;
  105. double Py = 0;
  106. double Pr = 0;
  107. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  108. {
  109. tB_SecondPointX.Text = Px.ToString();
  110. tB_SecondPointY.Text = Py.ToString();
  111. }
  112. double WD = 0;
  113. if (cfun.GetWorkingDistance(ref WD))
  114. {
  115. tB_SecondPointD.Text = WD.ToString();
  116. }
  117. }
  118. private void bn_ThirdPoint_Click(object sender, EventArgs e)
  119. {
  120. //double a, b, c;
  121. //a = b = 30;
  122. //c = 30;
  123. //cfun.SetSemPositionXY(a, b, c);
  124. //cfun.SetSemWorkingDistance(c);
  125. double Px = 0;
  126. double Py = 0;
  127. double Pr = 0;
  128. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  129. {
  130. tB_ThirdPointX.Text = Px.ToString();
  131. tB_ThirdPointY.Text = Py.ToString();
  132. }
  133. double WD = 0;
  134. if (cfun.GetWorkingDistance(ref WD))
  135. {
  136. tB_ThirdPointD.Text = WD.ToString();
  137. }
  138. }
  139. private void bn_Cancel_Click(object sender, EventArgs e)
  140. {
  141. m_result = false;
  142. this.Hide();
  143. }
  144. private void SlopFocus_FormClosing(object sender, FormClosingEventArgs e)
  145. {
  146. e.Cancel = true;
  147. this.Hide();
  148. }
  149. private void button1_Click(object sender, EventArgs e)
  150. {
  151. //double a, b, c;
  152. //a = b = 20;
  153. //c = 20;
  154. //cfun.SetSemPositionXY(a, b, c);
  155. //cfun.SetSemWorkingDistance(c);
  156. if (tB_FirstPointD.Text == "")
  157. {
  158. MessageBox.Show("Please read first!");
  159. return;
  160. }
  161. double Px = Convert.ToDouble(tB_FirstPointX.Text);
  162. double Py = Convert.ToDouble(tB_FirstPointY.Text);
  163. double wd=Convert.ToDouble(tB_FirstPointD.Text);
  164. if (cfun.MoveSEMToPoint( Px, Py))
  165. {
  166. cfun.SetWorkingDistance(wd);
  167. }
  168. }
  169. private void button2_Click(object sender, EventArgs e)
  170. {
  171. if (tB_SecondPointD.Text == "")
  172. {
  173. MessageBox.Show("Please read first!");
  174. return;
  175. }
  176. double Px = Convert.ToDouble(tB_SecondPointX.Text);
  177. double Py = Convert.ToDouble(tB_SecondPointY.Text);
  178. double wd = Convert.ToDouble(tB_SecondPointD.Text);
  179. if (cfun.MoveSEMToPoint(Px, Py))
  180. {
  181. cfun.SetWorkingDistance(wd);
  182. }
  183. }
  184. private void button3_Click(object sender, EventArgs e)
  185. {
  186. if (tB_ThirdPointD.Text == "")
  187. {
  188. MessageBox.Show("Please read first!");
  189. return;
  190. }
  191. double Px = Convert.ToDouble(tB_ThirdPointX.Text);
  192. double Py = Convert.ToDouble(tB_ThirdPointY.Text);
  193. double wd = Convert.ToDouble(tB_ThirdPointD.Text);
  194. if (cfun.MoveSEMToPoint(Px, Py))
  195. {
  196. cfun.SetWorkingDistance(wd);
  197. }
  198. }
  199. }
  200. }