OTSIncAReportGridsFun.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. 
  2. using OTSIncAReportApp.DataOperation.Model;
  3. using OTSIncAReportApp.SysMgrTools;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.Linq;
  9. namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
  10. {
  11. public class OTSIncAReportGridsFun
  12. {
  13. #region 枚举定义
  14. ////切换窗体枚举定义
  15. //public enum DisplayPicutureType
  16. //{
  17. // //分析图
  18. // AnalyzeImg = 1,
  19. // //分析数据图
  20. // AnalyzeDataChart = 2,
  21. // //分析数据表
  22. // AnalyzeDataTable = 3
  23. //}
  24. ///// <summary>
  25. ///// 样品台X轴方向
  26. ///// </summary>
  27. //enum OTS_X_AXIS_DIRECTION
  28. //{
  29. // LEFT_TOWARD = 0,
  30. // RIGHT_TOWARD = 1
  31. //}
  32. ///// <summary>
  33. ///// 样品台Y轴方向
  34. ///// </summary>
  35. //enum OTS_Y_AXIS_DIRECTION
  36. //{
  37. // UP_TOWARD = 0,
  38. // DOWN_TOWARD = 1
  39. //}
  40. #endregion
  41. #region 定义变量
  42. //电镜设置对象
  43. public NSOTSController.COTSControlFunExport m_cfun = null;
  44. //为了加快颗粒列表抠图的速度,这里保存一个全局变量
  45. public List<Field> m_list_COTSFieldMgrClr = null;
  46. //是否已经连接到了电镜
  47. public bool m_SEMConnectionState = false;
  48. //连接到电镜的ID号
  49. public int m_SEM_ID = 0;
  50. //国际化
  51. Language lan = new Language();
  52. Hashtable table;
  53. OTSIncAReportApp.frmReportApp m_frmReportApp = null;
  54. #endregion
  55. #region 构造函数
  56. /// <summary>
  57. /// 需传入,主窗体对象,与要获取数据窗体的对象
  58. /// </summary>
  59. /// <param name="in_frmReportApp"></param>
  60. /// <param name="form"></param>
  61. public OTSIncAReportGridsFun(OTSIncAReportApp.frmReportApp in_frmReportApp, System.Windows.Forms.UserControl form)
  62. {
  63. //国际化
  64. lan = new Language(form);
  65. table = lan.GetNameTable(form.Name);
  66. m_frmReportApp = in_frmReportApp;
  67. m_cfun = new NSOTSController.COTSControlFunExport();//重新new一下试试呢,不new不好使 It's better to reinitialize, but it's not good to uninitialize
  68. }
  69. #endregion
  70. #region 自定义方法封装
  71. /// <summary>
  72. /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
  73. /// </summary>
  74. /// <param name="in_clr_tagid"></param>
  75. /// <param name="in_clr_fieldid"></param>
  76. /// <param name="Search_xray"></param>
  77. /// <param name="Analysis_xray"></param>
  78. public void GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray, out int xray_id, out List<Element> list_celementchemistryclr)
  79. {
  80. Search_xray = new uint[2000];
  81. Analysis_xray = new uint[2000];
  82. xray_id = 0;
  83. list_celementchemistryclr = new List<Element>();
  84. //防止为空校验判断
  85. if (m_list_COTSFieldMgrClr == null)
  86. return;
  87. Particle particle = m_list_COTSFieldMgrClr.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
  88. if (particle.XrayId > -1)
  89. {
  90. for (int i = 0; i < 2000; i++)
  91. {
  92. Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
  93. }
  94. Search_xray = Analysis_xray;
  95. xray_id = particle.XrayId;
  96. list_celementchemistryclr = particle.ElementList;
  97. }
  98. }
  99. /// <summary>
  100. /// 临时创建一个用于组建particle类的小segment类结构
  101. /// </summary>
  102. class ShowSegment
  103. {
  104. Rectangle m_rect = new Rectangle();
  105. List<Color> m_list_color = new List<Color>();
  106. public Rectangle Rect
  107. {
  108. get { return m_rect; }
  109. set { m_rect = value; }
  110. }
  111. public List<Color> List_Color
  112. {
  113. get { return m_list_color; }
  114. set { m_list_color = value; }
  115. }
  116. /// <summary>
  117. /// 传入showsegment的list对象列表,返回从该对象列表计算出的外边rect矩形[目前宽度计算错误]
  118. /// </summary>
  119. /// <param name="in_list_showsegment"></param>
  120. /// <returns></returns>
  121. public Rectangle GetRectByListRectangle(List<ShowSegment> in_list_showsegment)
  122. {
  123. int x = 10000, y = 10000;
  124. int width = 0, height = 0;
  125. for (int i = 0; i < in_list_showsegment.Count(); i++)
  126. {
  127. if (x > in_list_showsegment[i].Rect.X)
  128. x = in_list_showsegment[i].Rect.X;
  129. if (y > in_list_showsegment[i].Rect.Y)
  130. y = in_list_showsegment[i].Rect.Y;
  131. if (width < in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width)
  132. width = in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width;
  133. if (height < in_list_showsegment[i].Rect.Height)
  134. height = in_list_showsegment[i].Rect.Height;
  135. }
  136. width = width - x;//计算时已增加了x在里面,计算完成后,再将x的值去掉
  137. //height就是线的数量
  138. return new Rectangle(x, y, width + 3, in_list_showsegment.Count() + 3);
  139. }
  140. }
  141. #endregion
  142. #region 连接电镜相关
  143. /// <summary>
  144. /// 连接电镜,颗粒列表使用
  145. /// </summary>
  146. public void Connection_ForParticlesGrid()
  147. {
  148. if (!m_SEMConnectionState)
  149. {
  150. //和电镜建立通讯连接
  151. m_SEMConnectionState = m_cfun.ConncetSem();
  152. ///获取当前电镜的ID号
  153. m_SEM_ID = m_cfun.GetSemType();
  154. }
  155. else
  156. {
  157. //if (m_cfun.DisConnectSem())
  158. //{
  159. //}
  160. }
  161. }
  162. /// <summary>
  163. /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
  164. /// </summary>
  165. /// <param name="PositionX"></param>
  166. /// <param name="PositionY"></param>
  167. public void MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
  168. {
  169. //首先获取电镜当前的位置,并记录原R值
  170. double ls_PositionX = 0;
  171. double ls_PositionY = 0;
  172. double ls_PositionR = 0;
  173. if (m_SEMConnectionState)
  174. {
  175. m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
  176. }
  177. else
  178. {
  179. }
  180. if (m_SEMConnectionState)
  181. {
  182. m_cfun.MoveSEMToPoint(in_PositionX, in_PositionY, ls_PositionR);
  183. }
  184. else
  185. {
  186. }
  187. }
  188. /// <summary>
  189. /// 断开电镜连接
  190. /// </summary>
  191. public void DisConnectSEM_ForParticlesGrid()
  192. {
  193. //if (m_cfun.DisConnectSem() == true)
  194. //{
  195. //}
  196. //m_cfun.FreeDll();
  197. m_SEMConnectionState = false;
  198. }
  199. #endregion
  200. #region 获取数据_测量结果概况
  201. #endregion
  202. #region 保留国标Clr部份代码
  203. #endregion
  204. }
  205. }