SlopFocus.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. OTSSamplespaceWindow oTSSamplespaceWindow;
  21. public bool result {get => m_result; set => m_result = value; }
  22. public SlopFocus(OTSSamplespaceWindow a_oTSSamplespaceWindow)
  23. {
  24. InitializeComponent();
  25. oTSSamplespaceWindow = a_oTSSamplespaceWindow;
  26. }
  27. public CSlopFocusParam GetCSlopFocusParam()
  28. {
  29. return slopFocusParam;
  30. }
  31. private void bn_OK_Click(object sender, EventArgs e)
  32. {
  33. double iPX1, iPY1, iPX2, iPY2, iPX3,iPY3;
  34. iPX1 = iPY1 = iPX2 = iPY2 = iPX3=iPY3 = 0;
  35. double dPW1, dPW2, dPW3;
  36. dPW1 = dPW2 = dPW3 = 0;
  37. 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))
  38. {
  39. MessageBox.Show("Please check Params!");
  40. return;
  41. }
  42. 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))
  43. {
  44. MessageBox.Show("Please select different points!");
  45. return;
  46. }
  47. if(slopFocusParam==null)
  48. {
  49. slopFocusParam = new CSlopFocusParam();
  50. }
  51. slopFocusParam.IsUsingSlopParam = cB_enable.Checked;
  52. slopFocusParam.FirstPoint = new Point((int)iPX1, (int)iPY1);
  53. slopFocusParam.FirstWD = dPW1;
  54. slopFocusParam.SecondPoint = new Point((int)iPX2, (int)iPY2);
  55. slopFocusParam.SecondWD = dPW2;
  56. slopFocusParam.ThirdPoint = new Point((int)iPX3, (int)iPY3);
  57. slopFocusParam.ThirdWD = dPW3;
  58. oTSSamplespaceWindow.setSlopFocusParam(this);
  59. this.Hide();
  60. }
  61. private void SlopFocus_Load(object sender, EventArgs e)
  62. {
  63. if(cfun==null)
  64. {
  65. cfun = COTSControlFunExport.GetControllerInstance();
  66. }
  67. }
  68. private void bn_FirstPoint_Click(object sender, EventArgs e)
  69. {
  70. //double a, b, c;
  71. //a = b = 20;
  72. //c = 20;
  73. //cfun.SetSemPositionXY(a, b, c);
  74. //cfun.SetSemWorkingDistance(c);
  75. double Px = 0;
  76. double Py = 0;
  77. double Pr = 0;
  78. if(cfun.GetSemPositionXY(ref Px,ref Py,ref Pr))
  79. {
  80. tB_FirstPointX.Text = Px.ToString();
  81. tB_FirstPointY.Text = Py.ToString();
  82. }
  83. double WD = 0;
  84. if(cfun.GetSemWorkingDistance(ref WD))
  85. {
  86. tB_FirstPointD.Text = WD.ToString();
  87. }
  88. }
  89. private void bn_SecondPoint_Click(object sender, EventArgs e)
  90. {
  91. //double a, b, c;
  92. //a = b = 10;
  93. //c = 10;
  94. //cfun.SetSemPositionXY(a, b, c);
  95. //cfun.SetSemWorkingDistance(c);
  96. double Px = 0;
  97. double Py = 0;
  98. double Pr = 0;
  99. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  100. {
  101. tB_SecondPointX.Text = Px.ToString();
  102. tB_SecondPointY.Text = Py.ToString();
  103. }
  104. double WD = 0;
  105. if (cfun.GetSemWorkingDistance(ref WD))
  106. {
  107. tB_SecondPointD.Text = WD.ToString();
  108. }
  109. }
  110. private void bn_ThirdPoint_Click(object sender, EventArgs e)
  111. {
  112. //double a, b, c;
  113. //a = b = 30;
  114. //c = 30;
  115. //cfun.SetSemPositionXY(a, b, c);
  116. //cfun.SetSemWorkingDistance(c);
  117. double Px = 0;
  118. double Py = 0;
  119. double Pr = 0;
  120. if (cfun.GetSemPositionXY(ref Px, ref Py, ref Pr))
  121. {
  122. tB_ThirdPointX.Text = Px.ToString();
  123. tB_ThirdPointY.Text = Py.ToString();
  124. }
  125. double WD = 0;
  126. if (cfun.GetSemWorkingDistance(ref WD))
  127. {
  128. tB_ThirdPointD.Text = WD.ToString();
  129. }
  130. }
  131. private void bn_Cancel_Click(object sender, EventArgs e)
  132. {
  133. m_result = false;
  134. this.Hide();
  135. }
  136. }
  137. }