OTSIncAReportFun.cs 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606
  1. 
  2. using NSOTSController;
  3. using OTSIncAReportApp.DataOperation.DataAccess;
  4. using OTSIncAReportApp.DataOperation.Model;
  5. using OTSIncAReportApp.SysMgrTools;
  6. using OTSIncAReportGraph.Class;
  7. using OTSIncAReportGraph.Controls;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Diagnostics;
  13. using System.Drawing;
  14. using System.Linq;
  15. namespace OTSIncAReportGraph.OTSIncAReportGraphFuncation
  16. {
  17. class OTSIncAReportFun
  18. {
  19. #region 枚举定义
  20. /// <summary>
  21. /// 样品台X轴方向
  22. /// </summary>
  23. enum OTS_X_AXIS_DIRECTION
  24. {
  25. LEFT_TOWARD = 0,
  26. RIGHT_TOWARD = 1
  27. }
  28. /// <summary>
  29. /// 样品台Y轴方向
  30. /// </summary>
  31. enum OTS_Y_AXIS_DIRECTION
  32. {
  33. UP_TOWARD = 0,
  34. DOWN_TOWARD = 1
  35. }
  36. #endregion
  37. #region 定义变量
  38. private ResultFile resultFile = null;
  39. //新版排序图窗体对象
  40. private Control_DrawDistrbutionSortImage m_Control_DrawdistrbutionsortImage = null;
  41. //新版分布图和BSE图整合对象
  42. private Control_DrawDistrbutionImageAndBSE m_Control_DrawDistrbutionImageAndBSE = null;
  43. //全局对象,为了能够快速的获取到xray数据,而做为一个临时变量进行保存,使用前应该判断是否为空
  44. public List<Field> m_list_COTSFieldMgrClr = null;
  45. NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
  46. //field的数量
  47. public int m_field_count = 0;
  48. //particle的数量
  49. public int m_particle_count = 0;
  50. //加载使用的时间
  51. public string m_time_str = "";
  52. //加载使用时间计算时间段2
  53. public string m_time_str2 = "";
  54. //防止segment过多的数量限制,先写300吧,过少也不好,过防止过多程序而卡死
  55. public int m_segment_overflownumber = 400;
  56. //电镜设置对象
  57. public NSOTSController.COTSControlFunExport m_cfun = null;
  58. //是否已经连接到了电镜
  59. public bool m_SEMConnectionState = false;
  60. //连接到电镜的ID号
  61. public int m_SEM_ID = 0;
  62. //国际化
  63. Language lan = new Language();
  64. Hashtable table;
  65. #endregion
  66. #region 构造函数
  67. /// <summary>
  68. /// 构造函数,接收新版分布图和排序图的构造函数
  69. /// </summary>
  70. /// <param name="in_Control_DrawDistrbutionImageAndBSE"></param>
  71. /// <param name="in_Cotsreportprojfilemgrclr"></param>
  72. public OTSIncAReportFun(Control_DrawDistrbutionImageAndBSE in_Control_DrawDistrbutionImageAndBSE, ResultFile result)
  73. {
  74. m_Control_DrawDistrbutionImageAndBSE = in_Control_DrawDistrbutionImageAndBSE;
  75. resultFile = result;
  76. table = lan.GetNameTable("OTSIncAReportFun");
  77. }
  78. /// <summary>
  79. /// 构造函数,接收新版颗粒排序图的构造
  80. /// </summary>
  81. /// <param name="in_Control_DrawDistrbutionSortimage"></param>
  82. /// <param name="in_Cotsreportprojfilemgrclr"></param>
  83. public OTSIncAReportFun(Control_DrawDistrbutionSortImage in_Control_DrawDistrbutionSortimage, ResultFile result)
  84. {
  85. m_Control_DrawdistrbutionsortImage = in_Control_DrawDistrbutionSortimage;
  86. resultFile = result;
  87. table = lan.GetNameTable("OTSIncAReportFun");
  88. }
  89. #endregion
  90. #region 封装自定义方法
  91. /// <summary>
  92. /// 根据颗粒排序图获取已经选择上的颗粒,返回被选择上的颗粒的列表
  93. /// </summary>
  94. /// <returns></returns>
  95. public List<Particle> GetSelectedParticleList_ForDrawDistrbutionImageAndBSE()
  96. {
  97. List<Particle> ls_list_cotsparticleclr = new List<Particle>();
  98. //防止为空校验判断
  99. if (m_list_COTSFieldMgrClr == null)
  100. return ls_list_cotsparticleclr;
  101. //先取出,所有被选择的dparticle列表的
  102. List<DParticle> ls_list_dp = new List<DParticle>();
  103. foreach (DParticle ls_dp in m_Control_DrawDistrbutionImageAndBSE.m_list_baseobject)
  104. {
  105. if (ls_dp.Operator == ParticleOperator.SELECTED)
  106. {
  107. ls_list_dp.Add(ls_dp);
  108. }
  109. }
  110. //并开始查找包含tagid和fieldid的cotsparticle的对象,保存到list当中
  111. for (int i = 0; i < ls_list_dp.Count(); i++)
  112. {
  113. for (int j = 0; j < m_list_COTSFieldMgrClr.Count(); j++)
  114. {
  115. //先获取该field中的所有particle
  116. List<Particle> list_cotsparticleclr = new List<Particle>();
  117. list_cotsparticleclr = m_list_COTSFieldMgrClr[j].ParticleList;
  118. for (int k = 0; k < list_cotsparticleclr.Count(); k++)
  119. {
  120. if (list_cotsparticleclr[k].ParticleId == ls_list_dp[i].CLRTagID
  121. && list_cotsparticleclr[k].FieldId == ls_list_dp[i].CLRFieldID)
  122. {
  123. ls_list_cotsparticleclr.Add(list_cotsparticleclr[k]);
  124. }
  125. }
  126. }
  127. }
  128. return ls_list_cotsparticleclr;
  129. }
  130. /// <summary>
  131. /// 计算像素总画面Image大小,及进行物理坐标与分辨率坐标的换算操作 传入物理坐标,及宽高,来
  132. /// </summary>
  133. /// <param name="in_list_point">传入的物理坐标数组</param>
  134. /// <param name="width">单个field宽</param>
  135. /// <param name="height">单个field高</param>
  136. /// <returns></returns>
  137. public Rectangle ConvertAndGetMaxRect(List<Point> in_list_point, int in_width, int in_height)
  138. {
  139. //首先要能确定下来,单个物理坐标的宽和高--------------------------------
  140. int i_wl_width = 0;
  141. int i_wl_height = 0;
  142. Rectangle ls_r = GetOneFieldWidthAndHeight(in_list_point);
  143. i_wl_width = ls_r.Width;
  144. i_wl_height = ls_r.Height;
  145. //-----------------------------------------------------------------------------
  146. int point_x_min = 10000000;
  147. int point_x_max = -10000000;
  148. int point_y_min = 10000000;
  149. int point_y_max = -10000000;
  150. for (int i = 0; i < in_list_point.Count(); i++)
  151. {
  152. Point ls_point = in_list_point[i];
  153. //取出正数最大x
  154. if (ls_point.X > point_x_max)
  155. point_x_max = ls_point.X;
  156. if (ls_point.Y > point_y_max)
  157. point_y_max = ls_point.Y;
  158. if (ls_point.X < point_x_min)
  159. point_x_min = ls_point.X;
  160. if (ls_point.Y < point_y_min)
  161. point_y_min = ls_point.Y;
  162. }
  163. //然后分别用最大值+abs(最小值),就是x,和y轴的总长值
  164. point_x_max = point_x_max - point_x_min;
  165. point_y_max = point_y_max - point_y_min;
  166. //该算法有个问题,就是不能直观的得到整个范围的大小,要除以倍数再补1能补充缺少的一个field视域**********
  167. point_x_max = ((point_x_max / i_wl_width) + 1) * i_wl_width;
  168. point_y_max = ((point_y_max / i_wl_height) + 1) * i_wl_height;
  169. //将物理宽高,变换成分辨率宽高
  170. if (i_wl_width != 0) point_x_max = (point_x_max / i_wl_width) * in_width; else point_x_max = 0;
  171. if (i_wl_height != 0) point_y_max = (point_y_max / i_wl_height) * in_height; else point_y_max = 0;
  172. Rectangle ret_rectangle = new Rectangle(0, 0, 0, 0);
  173. //判断一下防止出错,只有在有数据的情况下,进行赋值才行
  174. if (in_list_point.Count > 0)
  175. {
  176. ret_rectangle = new Rectangle(0, 0, point_x_max, point_y_max);
  177. }
  178. //这样返回是物理坐标的总大小,应该返回像素坐标大小才对
  179. return ret_rectangle;
  180. }
  181. /// <summary>
  182. /// 通过传入的各field物理坐标列表,和单个field的屏幕分辨率,及单个的field的物理坐标,来获取当前field在整个image中的屏幕像素坐标偏移,并且是OTS向上为正做了Y轴相反运算
  183. /// </summary>
  184. /// <param name="in_list_point"></param>
  185. /// <param name="in_screen_width"></param>
  186. /// <param name="in_screen_height"></param>
  187. /// <param name="in_physics_width"></param>
  188. /// <param name="in_physics_height"></param>
  189. /// <returns></returns>
  190. public Point GetFieldPhysicsConvertToScreen(List<Point> in_list_point, int in_screen_width, int in_screen_height, Point in_physics_point)
  191. {
  192. //先确定单个物理坐标的宽和高
  193. Rectangle rect_onefield_wl = GetOneFieldWidthAndHeight(in_list_point);
  194. //找出最小的x,y用来做偏移运算
  195. int i_offset_x = 1000000000;
  196. int i_offset_y = 1000000000;
  197. //先取出最小的x,y
  198. for (int i = 0; i < in_list_point.Count; i++)
  199. {
  200. if (i_offset_x > in_list_point[i].X)
  201. {
  202. i_offset_x = in_list_point[i].X;
  203. }
  204. if (i_offset_y > in_list_point[i].Y)
  205. {
  206. i_offset_y = in_list_point[i].Y;
  207. }
  208. }
  209. List<Point> list_point = new List<Point>();
  210. //将各Field的OTS坐标与屏幕左上角的坐标进行相减,取出与屏幕左上角的偏移量,也就是取出了屏幕坐标
  211. int index = 0;
  212. for (int i = 0; i < in_list_point.Count; i++)
  213. {
  214. list_point.Add(new Point(in_list_point[i].X - i_offset_x, in_list_point[i].Y - i_offset_y));
  215. //根据物理坐标的对应关系,找到了在数组中的位置,下面将用该位置对应得出像素坐标的位置,并进行返回
  216. if (in_list_point[i] == in_physics_point)
  217. {
  218. index = i;
  219. }
  220. }
  221. //再将物理像素list_point换算成像素list_point,再用index定位
  222. for (int i = 0; i < list_point.Count; i++)
  223. {
  224. //将单个物理像素变换成屏幕像素分辨率
  225. int i_bs_x = 0;
  226. int i_bs_y = 0;
  227. if (rect_onefield_wl.Width != 0)
  228. i_bs_x = list_point[i].X / rect_onefield_wl.Width;
  229. if (rect_onefield_wl.Height != 0)
  230. i_bs_y = list_point[i].Y / rect_onefield_wl.Height;
  231. //再将屏幕像素分辨率按倍数赋值给list_point
  232. //考虑到OTS坐标整体是Y轴向上为正,所以这里需要根据总高,减y轴就是向上为正
  233. list_point[i] = new Point(in_screen_width * i_bs_x, in_screen_height * i_bs_y);
  234. }
  235. #region Y轴向上为正转换---------------------------------------------------------------------------------------
  236. //但上面由于相减,会出现y轴为负的情况,所以这里要根据Y轴是否出现负值,再次做偏移运算
  237. //找到最小的y轴,也就是 [Y轴偏移量]
  238. int i_offset_y_second = 100000000;
  239. //找到最大的Y轴,用于做相反运算,Y轴向上
  240. int i_screen_y = -100000000;
  241. for (int i = 0; i < list_point.Count; i++)
  242. {
  243. if (i_offset_y_second > list_point[i].Y)
  244. {
  245. i_offset_y_second = list_point[i].Y;//这个偏移Y就是最小的Y,可能是负数,也可能是0
  246. }
  247. if (i_screen_y < list_point[i].Y)
  248. {
  249. i_screen_y = list_point[i].Y;
  250. }
  251. }
  252. //对Y轴进行反转,OTS坐标向屏幕坐标转换
  253. for (int i = 0; i < list_point.Count; i++)
  254. {
  255. list_point[i] = new Point(list_point[i].X, i_screen_y - list_point[i].Y);
  256. }
  257. //再将所有的Field与这个 [Y轴偏移量] 相加,防止OTS向上为正转换屏幕坐标,造成的Y轴为负的情况
  258. for (int i = 0; i < list_point.Count; i++)
  259. {
  260. list_point[i] = new Point(list_point[i].X, list_point[i].Y + Math.Abs(i_offset_y_second));
  261. }
  262. #endregion Y轴向上为正转换结束--------------------------------------------------------------------------
  263. return list_point[index];
  264. }
  265. /// <summary>
  266. /// 计算单个field的物理大小 传入field的list,还有测量结果管理类对象,在无法计算出单file的物理大小的情况下,到这里取再计算得出
  267. /// </summary>
  268. /// <returns></returns>
  269. public Rectangle GetOneFieldWidthAndHeight(List<Point> in_list_point)
  270. {
  271. int i_wl_width_max = -10000000;
  272. int i_wl_height_max = -10000000;
  273. int i_wl_width_max2 = -10000000;
  274. int i_wl_height_max2 = -10000000;
  275. //先找出最大的值,
  276. for (int i = 0; i < in_list_point.Count(); i++)
  277. {
  278. if (i_wl_width_max < in_list_point[i].X)
  279. i_wl_width_max = in_list_point[i].X;
  280. if (i_wl_height_max < in_list_point[i].Y)
  281. i_wl_height_max = in_list_point[i].Y;
  282. }
  283. //再找出第二大的值
  284. for (int i = 0; i < in_list_point.Count(); i++)
  285. {
  286. if (i_wl_width_max2 < in_list_point[i].X && i_wl_width_max != in_list_point[i].X)
  287. i_wl_width_max2 = in_list_point[i].X;
  288. if (i_wl_height_max2 < in_list_point[i].Y && i_wl_height_max != in_list_point[i].Y)
  289. i_wl_height_max2 = in_list_point[i].Y;
  290. }
  291. //需要针对第二大的值,获取时进行判断,感觉这里应该如果并未找到第二大的值的情况下,赋于0值,便于以后进行计算
  292. if (i_wl_width_max2 == -10000000)
  293. i_wl_width_max2 = 0;
  294. if (i_wl_height_max2 == -10000000)
  295. i_wl_height_max2 = 0;
  296. Rectangle ret_rect = new Rectangle(0, 0, i_wl_width_max - i_wl_width_max2, i_wl_height_max - i_wl_height_max2);
  297. //如果最后计算出的宽高有0则重新到测量数据中获取---------------------------------------
  298. if (ret_rect.Width == 0 || ret_rect.Height == 0)
  299. {
  300. //到参数中去取单个宽
  301. double d_onefilesize_width = Convert.ToDouble(((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["scanFieldSize"]);
  302. //然后再用单个宽去计算出高是多少
  303. double d_onefilesize_height = 0;
  304. if (d_onefilesize_width != 0)
  305. d_onefilesize_height = (d_onefilesize_width / 4) * 3;
  306. ret_rect.Width = (int)d_onefilesize_width;
  307. ret_rect.Height = (int)d_onefilesize_height;
  308. }
  309. ///-----------because all the fields 's height/width=0.75 so here we make an enforce. gsp add at 2019/10/31
  310. ///sometimes the gbfields are not conform to this for the cuting and merging operation.
  311. if (ret_rect.Height / ret_rect.Width != 0.75f)
  312. {
  313. ret_rect = new Rectangle(ret_rect.X, ret_rect.Y, ret_rect.Width, (int)(ret_rect.Width * 0.75f));
  314. }
  315. return ret_rect;
  316. }
  317. #endregion
  318. #region 电镜操作相关方法
  319. /// <summary>
  320. /// 连接电镜,分布图使用
  321. /// </summary>
  322. public void Connection_ForDrawDistrbutionImageAndBSE()
  323. {
  324. string str1 = "分布图准备开始连接SEM电镜";
  325. str1 = table["str1"].ToString();
  326. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str1);
  327. if (!m_SEMConnectionState)
  328. {
  329. m_cfun = new COTSControlFunExport();//重新new一下试试呢,不New并不好用 It's better to reinitialize, but it's not good to uninitialize
  330. //和电镜建立通讯连接
  331. m_SEMConnectionState = m_cfun.ConncetSem();
  332. string str2 = "调用连接后状态";
  333. str2 = table["str2"].ToString();
  334. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str2 + ":--" + m_SEMConnectionState + "---");
  335. ///获取当前电镜的ID号
  336. m_SEM_ID = m_cfun.GetSemType();
  337. string str3 = "获得电镜的ID";
  338. str3 = table["str3"].ToString();
  339. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str3 + ":--" + m_SEM_ID.ToString() + "---");
  340. }
  341. else
  342. {
  343. //断开电镜连接
  344. string str4 = "电镜是已经连接的状态,准备断开";
  345. str4 = table["str4"].ToString();
  346. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str4 + ":--" + m_SEMConnectionState + "---");
  347. //if (m_cfun.DisConnectSem())
  348. //{
  349. // string str5 = "电镜是已经连接的状态,完成断开后状态";
  350. // str5 = table["str5"].ToString();
  351. // log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str5 + ":--" + m_SEMConnectionState + "---");
  352. //}
  353. }
  354. }
  355. /// <summary>
  356. /// 连接电镜,排序图使用
  357. /// </summary>
  358. public void Connection_ForDrawDistrbutionSortImage()
  359. {
  360. string str6 = "分布图准备开始连接SEM电镜";
  361. str6 = table["str6"].ToString();
  362. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str6);
  363. if (!m_SEMConnectionState)
  364. {
  365. m_cfun = new COTSControlFunExport();//重新new一下试试呢,不New并不好用 It's better to reinitialize, but it's not good to uninitialize
  366. //和电镜建立通讯连接
  367. m_SEMConnectionState = m_cfun.ConncetSem();
  368. string str7 = "调用连接后状态";
  369. str7 = table["str7"].ToString();
  370. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str7 + ":--" + m_SEMConnectionState + "---");
  371. ///获取当前电镜的ID号
  372. m_SEM_ID = m_cfun.GetSemType();
  373. string str8 = "获得电镜的ID";
  374. str8 = table["str8"].ToString();
  375. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str8 + ":--" + m_SEM_ID.ToString() + "---");
  376. }
  377. else
  378. {
  379. //断开电镜连接
  380. string str9 = "电镜是已经连接的状态,准备断开";
  381. str9 = table["str9"].ToString();
  382. log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)str9:--" + m_SEMConnectionState + "---");
  383. //if (m_cfun.DisConnectSem())
  384. //{
  385. // string str10 = "电镜是已经连接的状态,完成断开后状态";
  386. // str10 = table["str10"].ToString();
  387. // log.Trace("(Connection_ForDrawDistrbutionImageAndBSE)" + str10 + ":--" + m_SEMConnectionState + "---");
  388. //}
  389. }
  390. }
  391. /// <summary>
  392. /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
  393. /// </summary>
  394. /// <param name="PositionX"></param>
  395. /// <param name="PositionY"></param>
  396. public void MoveSemToPointXY_ForDrawDistrbutionImageAndBSE(double in_PositionX, double in_PositionY)
  397. {
  398. string str11 = "分布图准备开始移动电镜到";
  399. str11 = table["str11"].ToString();
  400. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str11);
  401. //首先获取电镜当前的位置,并记录原R值
  402. double ls_PositionX = 0;
  403. double ls_PositionY = 0;
  404. double ls_PositionR = 0;
  405. if (m_SEMConnectionState)
  406. {
  407. m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
  408. string str12 = "获取原先电镜位置为X";
  409. str12 = table["str12"].ToString();
  410. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str12 + ":" + ls_PositionX.ToString() + " Y:" + ls_PositionY.ToString() + " R:" + ls_PositionR.ToString());
  411. }
  412. else
  413. {
  414. string str13 = "获取电镜位置时状态错误";
  415. str13 = table["str13"].ToString();
  416. log.Error("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str13);
  417. }
  418. if (m_SEMConnectionState)
  419. {
  420. m_cfun.MoveSEMToPoint(in_PositionX, in_PositionY, ls_PositionR);
  421. string str14 = "移动电镜到指定位置";
  422. str14 = table["str14"].ToString();
  423. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str14 + ":" + in_PositionX.ToString() + " Y:" + in_PositionY.ToString() + " R:" + ls_PositionR.ToString());
  424. }
  425. else
  426. {
  427. string str15 = "移动电镜时状态错误";
  428. str15 = table["str15"].ToString();
  429. log.Error("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str15);
  430. }
  431. }
  432. /// <summary>
  433. /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
  434. /// </summary>
  435. /// <param name="PositionX"></param>
  436. /// <param name="PositionY"></param>
  437. public void MoveSemToPointXY_ForDrawDistrbutionSortImage(double in_PositionX, double in_PositionY)
  438. {
  439. string str16 = "分布图准备开始移动电镜到";
  440. str16 = table["str16"].ToString();
  441. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str16);
  442. //首先获取电镜当前的位置,并记录原R值
  443. double ls_PositionX = 0;
  444. double ls_PositionY = 0;
  445. double ls_PositionR = 0;
  446. if (m_SEMConnectionState)
  447. {
  448. string str17 = "获取原先电镜位置为X";
  449. str17 = table["str17"].ToString();
  450. m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
  451. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str17 + ":" + ls_PositionX.ToString() + " Y:" + ls_PositionY.ToString() + " R:" + ls_PositionR.ToString());
  452. }
  453. else
  454. {
  455. string str18 = "获取电镜位置时状态错误";
  456. str18 = table["str18"].ToString();
  457. log.Error("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str18);
  458. }
  459. if (m_SEMConnectionState)
  460. {
  461. m_cfun.MoveSEMToPoint(in_PositionX, in_PositionY, ls_PositionR);
  462. string str19 = "移动电镜到指定位置";
  463. str19 = table["str19"].ToString();
  464. log.Trace("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str19 + ":" + in_PositionX.ToString() + " Y:" + in_PositionY.ToString() + " R:" + ls_PositionR.ToString());
  465. }
  466. else
  467. {
  468. string str20 = "移动电镜时状态错误";
  469. str20 = table["str20"].ToString();
  470. log.Error("(MoveSemToPointXY_ForDrawDistrbutionImageAndBSE)" + str20);
  471. }
  472. }
  473. /// <summary>
  474. /// 断开电镜连接
  475. /// </summary>
  476. public void DisConnectSEM_ForDrawDistrbutionImageAndBSE()
  477. {
  478. string str21 = "准备关闭电镜连接";
  479. str21 = table["str21"].ToString();
  480. log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str21);
  481. //if (m_cfun.DisConnectSem() == true)
  482. //{
  483. // string str22 = "准备关闭电镜连接";
  484. // str22 = table["str22"].ToString();
  485. // log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str22);
  486. //}
  487. string str23 = "准备释放DLL";
  488. str23 = table["str23"].ToString();
  489. log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str23);
  490. m_cfun.FreeHardware();
  491. m_SEMConnectionState = false;
  492. }
  493. /// <summary>
  494. /// 断开电镜连接
  495. /// </summary>
  496. public void DisConnectSEM_ForDrawDistrbutionSortImage()
  497. {
  498. string str24 = "准备关闭电镜连接";
  499. str24 = table["str24"].ToString();
  500. log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str24);
  501. //if (m_cfun.DisConnectSem() == true)
  502. //{
  503. // log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str24);
  504. //}
  505. string str25 = "准备释放DLL";
  506. str25 = table["str25"].ToString();
  507. log.Trace("(DisConnectSEM_ForDrawDistrbutionImageAndBSE)" + str25);
  508. m_cfun.FreeHardware();
  509. m_SEMConnectionState = false;
  510. }
  511. /// <summary>
  512. /// 移动SEM电镜到XY坐标,总过程方法
  513. /// </summary>
  514. /// <param name="PositionX"></param>
  515. /// <param name="PositionY"></param>
  516. public void MoveSemToXY_ForDrawDistrbutionImageAndBSE_Total(int PositionX, int PositionY)
  517. {
  518. //第一步,连接电镜
  519. Connection_ForDrawDistrbutionImageAndBSE();
  520. //第二步,移动到指定位置,先读取再设置
  521. if (m_SEMConnectionState == true)
  522. {
  523. MoveSemToPointXY_ForDrawDistrbutionImageAndBSE(PositionX, PositionY);
  524. }
  525. //第三步,断开电镜连接
  526. DisConnectSEM_ForDrawDistrbutionImageAndBSE();
  527. }
  528. #endregion
  529. #region //--------------------------------------颗粒分布图相关部份---------------------------------------------------------------------
  530. /// <summary>
  531. /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
  532. /// </summary>
  533. /// <param name="in_clr_tagid"></param>
  534. /// <param name="in_clr_fieldid"></param>
  535. /// <param name="Search_xray"></param>
  536. /// <param name="Analysis_xray"></param>
  537. 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)
  538. {
  539. Search_xray = new uint[2000];
  540. Analysis_xray = new uint[2000];
  541. xray_id = 0;
  542. list_celementchemistryclr = new List<Element>();
  543. //防止为空校验判断
  544. if (m_list_COTSFieldMgrClr == null)
  545. return;
  546. Particle particle = m_list_COTSFieldMgrClr.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
  547. if (particle.XrayId > -1)
  548. {
  549. for (int i = 0; i < 2000; i++)
  550. {
  551. Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
  552. }
  553. Search_xray = Analysis_xray;
  554. xray_id = particle.XrayId;
  555. list_celementchemistryclr = particle.ElementList;
  556. }
  557. }
  558. /// <summary>
  559. /// 传入所有的物理field坐标点,和单个物理field的宽高,返回所有field的左上角位置,和整个field组成的rect大小
  560. /// </summary>
  561. /// <param name="in_list_point"></param>
  562. /// <param name="in_width"></param>
  563. /// <param name="in_height"></param>
  564. /// <returns></returns>
  565. public Rectangle GetWlRectTopLeftAndRect(List<Point> in_list_point, int in_width, int in_height)
  566. {
  567. //分别获取整个rect的xy最小值和最大值
  568. int i_rect_x_min = 100000000;
  569. int i_rect_y_min = 100000000;
  570. int i_rect_x_max = -100000000;
  571. int i_rect_y_max = -100000000;
  572. for (int i = 0; i < in_list_point.Count; i++)
  573. {
  574. if (i_rect_x_min > in_list_point[i].X)
  575. i_rect_x_min = in_list_point[i].X;
  576. if (i_rect_y_min > in_list_point[i].Y)
  577. i_rect_y_min = in_list_point[i].Y;
  578. if (i_rect_x_max < in_list_point[i].X)
  579. i_rect_x_max = in_list_point[i].X;
  580. if (i_rect_y_max < in_list_point[i].Y)
  581. i_rect_y_max = in_list_point[i].Y;
  582. }
  583. Rectangle ret_rect = new Rectangle(i_rect_x_min, i_rect_y_min,
  584. i_rect_x_max - i_rect_x_min, i_rect_y_max - i_rect_y_min);
  585. return ret_rect;
  586. }
  587. /// <summary>
  588. /// 根据Field的ID,来获取Field列表中对应FIeld的OTS 坐标
  589. /// </summary>
  590. /// <param name="in_fieldid"></param>
  591. /// <returns></returns>
  592. public Point GetOTSPointByFieldID(List<DField> in_list_dfield, int in_fieldid)
  593. {
  594. Point ret_point = new Point(0, 0);
  595. for (int i = 0; i < in_list_dfield.Count; i++)
  596. {
  597. //这里TagID先代表的是底层返回的ID
  598. if (in_list_dfield[i].FieldID == in_fieldid.ToString())
  599. {
  600. ret_point = new Point(Convert.ToInt32(in_list_dfield[i].OTS_RECT.X), Convert.ToInt32(in_list_dfield[i].OTS_RECT.Y));
  601. }
  602. }
  603. return ret_point;
  604. }
  605. /// <summary>
  606. /// 将OTS坐标转换为Sem 坐标
  607. /// </summary>
  608. /// <param name="POTSCoord"></param>
  609. /// <returns></returns>
  610. public Point ChangeOTSToSemCoord(Point POTSCoord)
  611. {
  612. //first if m_semstagedata is null to get stage inforation
  613. Convert.ToDouble(((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["scanFieldSize"]);
  614. //after obtaining stage info,calc stage point data
  615. Point ret_SEM_point = new Point();
  616. // get center point, um
  617. long xStart = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["Members"])["XAxis"])["start"]);
  618. long xEnd = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["Members"])["XAxis"])["end"]);
  619. long xCenter = (xStart + xEnd) / 2;
  620. long yStart = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["Members"])["YAxis"])["start"]);
  621. long yEnd = Convert.ToInt64(((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["Members"])["YAxis"])["end"]);
  622. long yCenter = (yStart + yEnd) / 2;
  623. // delte = SEM - OTSa
  624. long deltex = xCenter - 0;
  625. long deltey = yCenter - 0;
  626. int xdir = Convert.ToInt32(((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["xAxisDir"]);
  627. int ydir = Convert.ToInt32(((Dictionary<string, object>)resultFile.ResultInfo["SEMStageData"])["yAxisDir"]);
  628. if (xdir == (int)OTS_X_AXIS_DIRECTION.LEFT_TOWARD)
  629. {
  630. ret_SEM_point.X = -1 * (POTSCoord.X - Convert.ToInt32(deltex));
  631. }
  632. else if (xdir == (int)OTS_X_AXIS_DIRECTION.RIGHT_TOWARD)
  633. {
  634. ret_SEM_point.X = POTSCoord.X + Convert.ToInt32(deltex);
  635. }
  636. if (ydir == (int)OTS_Y_AXIS_DIRECTION.UP_TOWARD)
  637. {
  638. ret_SEM_point.Y = POTSCoord.Y + Convert.ToInt32(deltey);
  639. }
  640. else if (ydir == (int)OTS_Y_AXIS_DIRECTION.DOWN_TOWARD)
  641. {
  642. ret_SEM_point.Y = -1 * (POTSCoord.Y - Convert.ToInt32(deltey));
  643. }
  644. return ret_SEM_point;
  645. }
  646. /// <summary>
  647. /// 获取组整个获取分布图和排序图图像数据的底层数据组建方式,的总过程
  648. /// </summary>
  649. public void GetDistrbutionImageAndBSE_Total()
  650. {
  651. string str27 = "开始从底层加载数据....";
  652. str27 = table["str27"].ToString();
  653. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(1, str27);
  654. //对底层加载速度进行计时
  655. Stopwatch stopwatch = new Stopwatch();
  656. stopwatch.Start();
  657. string path = resultFile.FilePath;
  658. FieldData fieldData = new FieldData(path);
  659. List<Field> fieldlist = fieldData.GetFieldList();
  660. //防止有时底层返回的Field的List是0,直接返回
  661. if (fieldlist.Count == 0)
  662. {
  663. string str28 = "底层返回视域数据数量为0....";
  664. str28 = table["str28"].ToString();
  665. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(100, str28);
  666. return;
  667. }
  668. //底层加载field对象结束
  669. stopwatch.Stop();
  670. TimeSpan timespan = stopwatch.Elapsed;
  671. //重置计数器,对组建和计算图像进行计时
  672. stopwatch.Reset();
  673. stopwatch.Start();
  674. string str29 = "开始组建图像视域....";
  675. str29 = table["str29"].ToString();
  676. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(15, str29);
  677. //将field的list对象给全局变量中,供后面获取xray使用,不需要再次重新加载数据,以提升速度
  678. m_list_COTSFieldMgrClr = fieldlist;
  679. //第一次循环,用来计算单个Field的像素分辨率,和将所有的物理位置存放到List当中
  680. List<Point> list_point = new List<Point>();
  681. int i_field_width = 0, i_field_height = 0;
  682. //获取到该field的分辨率大小,循环中都是一样的
  683. if (fieldlist.Count > 0)
  684. {
  685. Bitmap bitmp = DrawFuncation.ReadImageFile(fieldlist[0].FieldImage);
  686. i_field_width = bitmp.Width;
  687. i_field_height = bitmp.Height;
  688. }
  689. for (int i = 0; i < fieldlist.Count(); i++)
  690. {
  691. //然后取出物理坐标,这个一会要与分辨率坐标进行变算一下
  692. Point ls_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
  693. list_point.Add(ls_point);
  694. }
  695. //对单个视域的屏幕像素宽高,进行记录
  696. m_Control_DrawDistrbutionImageAndBSE.m_OneField_Screen_BackRectf = new RectangleF(0, 0, i_field_width, i_field_height);
  697. //获取单个OTS视域像素宽高,并进行记录
  698. Rectangle OTS_FieldRect = GetOneFieldWidthAndHeight(list_point);
  699. m_Control_DrawDistrbutionImageAndBSE.m_OneField_OTS_Rectf = OTS_FieldRect;
  700. //计算出整个绘制图像总Rectagnle的大小
  701. m_Control_DrawDistrbutionImageAndBSE.m_backrectf = ConvertAndGetMaxRect(list_point, i_field_width, i_field_height);
  702. string str30 = "计算标尺....";
  703. str30 = table["str30"].ToString();
  704. //更新进度条提示
  705. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(18, str30);
  706. #region //标尺相关------------------------------------------------------------------------------
  707. //在此处通过上面的i_field_width,ifield_height和list_point,来计算出个像素与实际物理值的比例
  708. Rectangle ls_jsblrect = GetOneFieldWidthAndHeight(list_point);
  709. //然后用宽度来除以i_field_width 获取单个的像素比例
  710. double d_onepixel_scale = Convert.ToDouble(ls_jsblrect.Width) / Convert.ToDouble(i_field_width);
  711. //再用该比例对标尺进行相应的赋值
  712. m_Control_DrawDistrbutionImageAndBSE.m_f_onepixel_size = (float)d_onepixel_scale;
  713. //对整个物理像素的范围进行获取与设置
  714. Rectangle ls_offsetandtopleftrect = GetWlRectTopLeftAndRect(list_point, ls_jsblrect.Width, ls_jsblrect.Height);
  715. m_Control_DrawDistrbutionImageAndBSE.m_back_wl_rectf = new RectangleF(ls_offsetandtopleftrect.X, ls_offsetandtopleftrect.Y
  716. , ls_offsetandtopleftrect.Width, ls_offsetandtopleftrect.Height);
  717. #endregion //---------------------------------------------------------------------------------------
  718. string str31 = "组建整图数据....";
  719. str31 = table["str31"].ToString();
  720. //更新进度条提示
  721. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(20, str31);
  722. //70的进度条给到下面的循环中,计算进度条各分类进度分配
  723. float ls_int_progresscalc = 0;
  724. if (fieldlist.Count > 0)
  725. ls_int_progresscalc = (float)70 / (float)fieldlist.Count;
  726. string str32 = "已完成第";
  727. str32 = table["str32"].ToString();
  728. string str33 = "个视域数据组建,共";
  729. str33 = table["str33"].ToString();
  730. string str34 = "个视域...";
  731. str34 = table["str34"].ToString();
  732. //再通过Field取到对应的Particle,循环一次
  733. for (int i = 0; i < fieldlist.Count(); i++)
  734. {
  735. //更新进度条提示
  736. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(20 + (int)(ls_int_progresscalc * (i + 1)), str32 + i.ToString() + str33 + m_list_COTSFieldMgrClr.Count.ToString() + str34);
  737. //先获取该Field中的所有Particle
  738. List<Particle> list_cotsparticleclr = new List<Particle>();
  739. list_cotsparticleclr = fieldlist[i].ParticleList;
  740. //取出该Field的物理坐标,将其转换成对应的屏幕像素坐标,屏幕左上角为原点(0,0)的偏移值,用于后面计算各Segment的位置使用
  741. //应该也就是这里根据OTS坐标转换到屏幕像素坐标,Y轴是反的,所以在这里对从OTS坐标转换成屏幕坐标的地方进行反转!
  742. Point thisfield_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
  743. Point offset_point = GetFieldPhysicsConvertToScreen(list_point, i_field_width, i_field_height, thisfield_point);
  744. //保存该Field最终在屏幕上显示的位置及大小
  745. DField df = new DField();
  746. df.FieldID = fieldlist[i].FieldID.ToString();
  747. df.Show_Rect = new Rectangle(offset_point, new Size(i_field_width, i_field_height));
  748. df.Current_Rect = new Rectangle(offset_point, new Size(i_field_width, i_field_height));
  749. df.OTS_RECT = new RectangleF(thisfield_point.X, thisfield_point.Y, OTS_FieldRect.Width, OTS_FieldRect.Height);
  750. m_Control_DrawDistrbutionImageAndBSE.m_list_dfield.Add(df);
  751. //然后将取出的数据,转换成Bitmap对象
  752. Bitmap ls_bt = DrawFuncation.ReadImageFile(fieldlist[i].FieldImage);
  753. //再循环计算所有的Particle对象
  754. foreach (Particle ls_cotsparticleclr in list_cotsparticleclr)
  755. {
  756. //从Clr中获取所有的Segment的List对象
  757. List<Feature> list_cotssegmentclr = new List<Feature>();
  758. list_cotssegmentclr = ls_cotsparticleclr.FeatureList;
  759. //创建颗粒分布图对应的类对象
  760. List<DSegment> list_dsegment = new List<DSegment>();
  761. //创建DParticle颗粒,保存与之对应的颗粒tagid和particleid,为了后面取xray数据及多选时获取多选cotsparticleclr列表
  762. DParticle ls_dp = new DParticle();
  763. ls_dp.CLRTagID = ls_cotsparticleclr.ParticleId;
  764. ls_dp.CLRFieldID = ls_cotsparticleclr.FieldId;
  765. ls_dp.STDTypeID = ls_cotsparticleclr.TypeId;
  766. ls_dp.TypeId = ls_cotsparticleclr.TypeId;
  767. ls_dp.TypeName = ls_cotsparticleclr.TypeName;
  768. ls_dp.XRayId = ls_cotsparticleclr.XrayId;
  769. ls_dp.SEMPosX = ls_cotsparticleclr.SEMPosX;
  770. ls_dp.SEMPosY = ls_cotsparticleclr.SEMPosY;
  771. //获取该颗粒在STD标准库中已分析出化合物对应的颜色
  772. ls_dp.Color = GetColorBySTDTypeIDForBSEAndSorImage(ls_cotsparticleclr.TypeColor, ls_cotsparticleclr.TypeId);
  773. //防止超大颗粒,会让程序死掉
  774. if (list_cotssegmentclr.Count < m_segment_overflownumber)
  775. {
  776. //再循环取出里面所有的segment
  777. foreach (Feature ls_cotssegmentclr in list_cotssegmentclr)
  778. {
  779. #region 创建DSegment对象,并将STD分析出的化合物颜色保存到DSegment对象中
  780. //对Particle里的Segment进行偏移的计算等,创建了DSegment的大小
  781. DSegment ds = new DSegment();
  782. ds.Rect = new Rectangle(ls_cotssegmentclr.Start + offset_point.X,
  783. //i_field_height - ls_cotssegmentclr.GetHeight() + offset_point.Y,//这是让单个Field的图像按Y轴反过来
  784. ls_cotssegmentclr.Height + offset_point.Y,
  785. ls_cotssegmentclr.Length,
  786. 1);
  787. ds.Color = ls_dp.Color;//将线的颜色对应到颗粒的颜色
  788. #endregion
  789. #region //这里是在Field中,抠取出原BSE图像到DSegment中--------------------------------
  790. //ls_bt.RotateFlip(RotateFlipType.Rotate180FlipX);//使用系统带的图像处理方法,进行Y轴的翻转,与上面记录位置对应
  791. //合成图像完成,开始抠取像素-----------------------------------------------------------------
  792. int i_ls_length = ls_cotssegmentclr.Length;
  793. List<Color> ls_list_colors = new List<Color>();
  794. for (int m = 0; m < i_ls_length; m++)
  795. {
  796. //这里实现一下代码保护
  797. int lsjs_x = ls_cotssegmentclr.Start + m;
  798. //int lsjs_y = i_field_height - ls_cotssegmentclr.GetHeight();//这个反转要与上面对应
  799. int lsjs_y = ls_cotssegmentclr.Height;
  800. if (lsjs_x < 0)
  801. lsjs_x = 0;
  802. if (lsjs_x >= i_field_width)
  803. lsjs_x = i_field_width - 1;
  804. if (lsjs_y < 0)
  805. lsjs_y = 0;
  806. if (lsjs_y >= i_field_height)
  807. lsjs_y = i_field_height - 1;
  808. //按理说这里应该加上个横向抠取像素颜色,这里需要再处理一下
  809. ls_list_colors.Add(ls_bt.GetPixel(lsjs_x,
  810. lsjs_y));
  811. }
  812. //保存原BSE图中的颜色列表
  813. ds.List_Colors = ls_list_colors;
  814. #endregion //------------------------------------------------------------------------------
  815. list_dsegment.Add(ds);
  816. //ls_bt.Dispose();
  817. }
  818. }
  819. //设置Particle在0.5F倍数以上时才进行显示
  820. ls_dp.Zoom_DisPlayMultiplier = 0.5f;
  821. ls_dp.Zoom_DisPlay = true;
  822. //将segment对应的设置到particle中
  823. ls_dp.DSegments = list_dsegment;
  824. //并对DParticle相关信息进行计算
  825. ls_dp.Rect = ls_dp.GetRectFromDSegment();
  826. ls_dp.GPath = ls_dp.GetRegionFromDSegments();
  827. ls_dp.SmallRect = ls_dp.GetSmallRectangleFromRect();
  828. //将每个颗粒添加到颗粒分布图中的列表中
  829. m_Control_DrawDistrbutionImageAndBSE.m_list_baseobject.Add(ls_dp);
  830. if (ls_dp.XRayId > -1)
  831. {
  832. m_Control_DrawDistrbutionImageAndBSE.m_list_usebject.Add(ls_dp);
  833. }
  834. }
  835. }
  836. string str35 = "转换分辨率...";
  837. str35 = table["str35"].ToString();
  838. //更新进度条相关显示
  839. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(90, str35);
  840. //然后这里还需要计算出,各field的宽和高,帧图边框分别需要显示多少个框
  841. if (i_field_width != 0 && i_field_height != 0)
  842. {
  843. m_Control_DrawDistrbutionImageAndBSE.m_i_grid_showlinesnumber_width = Convert.ToInt32(m_Control_DrawDistrbutionImageAndBSE.BackRectF.Width / i_field_width);
  844. m_Control_DrawDistrbutionImageAndBSE.m_i_grid_showlinesnumber_height = Convert.ToInt32(m_Control_DrawDistrbutionImageAndBSE.BackRectF.Height / i_field_height);
  845. }
  846. string str36 = "完成其它工作...";
  847. str36 = table["str36"].ToString();
  848. //结束组建计算图像计数
  849. stopwatch.Stop();
  850. TimeSpan timespan2 = stopwatch.Elapsed;
  851. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(95, str36);
  852. string str37 = "分钟 ";
  853. str37 = table["str37"].ToString();
  854. string str38 = "秒 共(";
  855. str38 = table["str38"].ToString();
  856. string str39 = ")毫秒";
  857. str39 = table["str39"].ToString();
  858. //相关计数
  859. m_field_count = fieldlist.Count;
  860. m_particle_count = m_Control_DrawDistrbutionImageAndBSE.m_list_baseobject.Count;
  861. m_time_str = timespan.TotalMinutes.ToString("0.00") + str37 + timespan.TotalSeconds.ToString("0.00") + str38 + timespan.TotalMilliseconds.ToString() + str39;
  862. m_time_str2 = timespan2.TotalMinutes.ToString("0.00") + str37 + timespan2.TotalSeconds.ToString("0.00") + str38 + timespan2.TotalMilliseconds.ToString() + str39;
  863. }
  864. //读取进度条,虚拟读取,直接通过所有时域
  865. void setPr(float ls_int_progresscalc, string str32, string str33, string str34)
  866. {
  867. for (int i = 0; i < m_list_COTSFieldMgrClr.Count; i++)
  868. {
  869. m_Control_DrawDistrbutionImageAndBSE.m_frm_userprogress.SetProgressValueAndText(20 + (int)(ls_int_progresscalc * (i + 1)), str32 + i.ToString() + str33 + m_list_COTSFieldMgrClr.Count.ToString() + str34);
  870. }
  871. }
  872. /// <summary>
  873. /// 分布图和BSE图中,从底层获取相关结果后,重新组织显示
  874. /// </summary>
  875. /// <param name="ls_cgriddataclr"></param>
  876. public void GetDrawDistrbutionImageAndBSE_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.OTSSampleMeaInfo sourceGridData)
  877. {
  878. var display = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 7);
  879. string display_type = display.itemVal.ToString();
  880. int disinde = display.comboDownList.IndexOf(display_type);
  881. var list = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 10);
  882. string size = list.itemVal.ToString();
  883. int inde = list.comboDownList.IndexOf(size);
  884. string size_cal_method_type = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 13).itemVal.ToString();
  885. string con = "";
  886. switch (size_cal_method_type)
  887. {
  888. case "DMAX":
  889. con = "DMAX";
  890. break;
  891. case "DMIN":
  892. con = "DMIN";
  893. break;
  894. case "Area":
  895. con = "Area";
  896. break;
  897. case "FERET":
  898. con = "DFERET";
  899. break;
  900. }
  901. string min = "0";
  902. string max = "999";
  903. if (inde != 0)
  904. {
  905. max = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 12).itemVal.ToString(); ;
  906. min = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 11).itemVal.ToString(); ;
  907. if (max.ToLower() == "max")
  908. {
  909. max = "999";
  910. }
  911. }
  912. string path = resultFile.FilePath;
  913. ParticleData particleData = new ParticleData(path);
  914. List<Particle> particles = particleData.GetParticleListByCon(con, max, min, disinde);
  915. foreach (DParticle ls_dp in m_Control_DrawDistrbutionImageAndBSE.m_list_baseobject)
  916. {
  917. int dis = 0;
  918. foreach (Particle particle in particles)
  919. {
  920. //找到对应的颗粒,将分类设置进去
  921. if (ls_dp.CLRTagID == particle.ParticleId && ls_dp.CLRFieldID == particle.FieldId)
  922. {
  923. //这里居然添加进来了7个,原来是这里,在底层直接取出了6个相同的颗粒到一起。
  924. ls_dp.ParticleFL = particle.TypeName;
  925. ls_dp.Operator = ParticleOperator.DISPLAY;
  926. dis = 1;
  927. break;
  928. }
  929. }
  930. if (dis == 0)
  931. {
  932. ls_dp.Operator = ParticleOperator.NODISPLAY;
  933. }
  934. }
  935. }
  936. #endregion
  937. #region //--------------------------------------颗粒排序图相关部份---------------------------------------------------------------------
  938. /// <summary>
  939. /// 根据颗粒排序图获取已经选择上的颗粒,返回被选择上的颗粒的列表
  940. /// </summary>
  941. /// <returns></returns>
  942. public List<Particle> GetSelectedParticleList_ForDrawDistrbutionSortImage()
  943. {
  944. List<Particle> ls_list_cotsparticleclr = new List<Particle>();
  945. //防止为空校验判断
  946. if (m_list_COTSFieldMgrClr == null)
  947. {
  948. return ls_list_cotsparticleclr;
  949. }
  950. //先取出,所有被选择的dparticle列表的
  951. List<DParticle> ls_list_dp = new List<DParticle>();
  952. foreach (SortParticleDistribution spd in m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution)
  953. {
  954. foreach (DParticle ls_dp in spd.List_DParticle)
  955. {
  956. if (ls_dp.Operator == ParticleOperator.SELECTED)
  957. {
  958. ls_list_dp.Add(ls_dp);
  959. }
  960. }
  961. }
  962. //并开始查找包含tagid和fieldid的cotsparticle的对象,保存到list当中
  963. for (int i = 0; i < ls_list_dp.Count(); i++)
  964. {
  965. for (int j = 0; j < m_list_COTSFieldMgrClr.Count(); j++)
  966. {
  967. //先获取该field中的所有particle
  968. List<Particle> list_cotsparticleclr = new List<Particle>();
  969. list_cotsparticleclr = m_list_COTSFieldMgrClr[j].ParticleList;
  970. for (int k = 0; k < list_cotsparticleclr.Count(); k++)
  971. {
  972. if (list_cotsparticleclr[k].ParticleId == ls_list_dp[i].CLRTagID
  973. && list_cotsparticleclr[k].FieldId == ls_list_dp[i].CLRFieldID)
  974. {
  975. //将cotsparticleclr保存到list当中
  976. ls_list_cotsparticleclr.Add(list_cotsparticleclr[k]);
  977. }
  978. }
  979. }
  980. }
  981. return ls_list_cotsparticleclr;
  982. }
  983. /// <summary>
  984. /// 根据传入的fieldid和tagid返回该颗粒的OTS坐标
  985. /// </summary>
  986. /// <param name="in_fieldid"></param>
  987. /// <param name="in_tagid"></param>
  988. /// <returns></returns>
  989. public Point GetOTSPointFromOld_list_sortparticledistribution(int in_fieldid, int in_tagid, Control_DrawDistrbutionSortImage in_control_drawdistrbutionsortimage)
  990. {
  991. Point ret_point = new Point(0, 0);
  992. if (m_list_COTSFieldMgrClr != null)
  993. {
  994. Field field = m_list_COTSFieldMgrClr.Find(x => x.FieldID == in_fieldid);
  995. ret_point = new Point() { X = field.FieldPosX, Y = field.FieldPosY };
  996. }
  997. return ret_point;
  998. }
  999. /// <summary>
  1000. /// 排序图获取底层数据,组建整张排序图的总方法过程
  1001. /// </summary>
  1002. public void GetDistrbutionSortImage_Total()
  1003. {
  1004. string str48 = "开始从底层加载数据....";
  1005. str48 = table["str48"].ToString();
  1006. m_Control_DrawdistrbutionsortImage.m_frm_userprogress.SetProgressValueAndText(1, str48);
  1007. string path = resultFile.FilePath;
  1008. FieldData fieldData = new FieldData(path);
  1009. List<Field> fieldlist = fieldData.GetFieldList();
  1010. //将field的list对象给全局变量中,供后面获取xray使用
  1011. m_list_COTSFieldMgrClr = fieldlist;
  1012. string str49 = "开始组建图像资源....";
  1013. str49 = table["str49"].ToString();
  1014. m_Control_DrawdistrbutionsortImage.m_frm_userprogress.SetProgressValueAndText(15, str49);
  1015. //第一次,用来计算,总大小等,获取Field的坐标,id,同时获取对应的ImgClr里的宽高,图像大小
  1016. List<Point> list_point = new List<Point>();
  1017. int i_field_width = 0, i_field_height = 0;
  1018. //获取到该field的分辨率大小,循环中都是一样的
  1019. if (fieldlist.Count > 0)
  1020. {
  1021. Bitmap bitmp = DrawFuncation.ReadImageFile(fieldlist[0].FieldImage);
  1022. i_field_width = bitmp.Width;
  1023. i_field_height = bitmp.Height;
  1024. }
  1025. for (int i = 0; i < fieldlist.Count(); i++)
  1026. {
  1027. //然后取出物理坐标,这个一会要与分辨率坐标进行变算一下
  1028. Point ls_point = new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY };
  1029. list_point.Add(ls_point);
  1030. }
  1031. //对单个Field视域的屏幕像素宽高,进行记录
  1032. m_Control_DrawdistrbutionsortImage.m_OneField_Screen_BackRectf = new RectangleF(0, 0, i_field_width, i_field_height);
  1033. //获取单个OTS视域像素宽高,并进行记录
  1034. Rectangle OTS_FieldRect = GetOneFieldWidthAndHeight(list_point);
  1035. m_Control_DrawdistrbutionsortImage.m_OneField_OTS_Rectf = OTS_FieldRect;
  1036. string str50 = "计算标尺....";
  1037. str50 = table["str50"].ToString();
  1038. m_Control_DrawdistrbutionsortImage.m_frm_userprogress.SetProgressValueAndText(18, str50);
  1039. #region //标尺相关------------------------------------------------------------------------------
  1040. //在此处通过上面的i_field_width,ifield_height和list_point,来计算出个像素与实际物理值的比例
  1041. Rectangle ls_jsblrect = GetOneFieldWidthAndHeight(list_point);
  1042. //然后用宽度来除以i_field_width 获取单个的像素比例
  1043. double d_onepixel_scale = Convert.ToDouble(ls_jsblrect.Width) / Convert.ToDouble(i_field_width);
  1044. //再用该比例对标尺进行相应的赋值
  1045. m_Control_DrawdistrbutionsortImage.m_f_onepixel_size = (float)d_onepixel_scale;
  1046. #endregion //---------------------------------------------------------------------------------------
  1047. string str51 = "组建整图数据....";
  1048. str51 = table["str51"].ToString();
  1049. m_Control_DrawdistrbutionsortImage.m_frm_userprogress.SetProgressValueAndText(20, str51);
  1050. //70的进度条给到下面的循环中
  1051. float ls_int_progresscalc = 0;
  1052. if (fieldlist.Count > 0)
  1053. ls_int_progresscalc = (float)80 / (float)fieldlist.Count;
  1054. string str52 = "已完成第";
  1055. str52 = table["str52"].ToString();
  1056. string str53 = "个数据,共";
  1057. str53 = table["str53"].ToString();
  1058. string str54 = "个数据...";
  1059. str54 = table["str54"].ToString();
  1060. //第二次,再通过Field取到对应的Particle,循环一次
  1061. for (int i = 0; i < fieldlist.Count(); i++)
  1062. {
  1063. m_Control_DrawdistrbutionsortImage.m_frm_userprogress.SetProgressValueAndText(20 + (int)(ls_int_progresscalc * (i + 1)), str52 + i.ToString() + str53 + m_list_COTSFieldMgrClr.Count.ToString() + str54);
  1064. //先获取该field中的所有particle
  1065. List<Particle> list_cotsparticleclr = new List<Particle>();
  1066. list_cotsparticleclr = fieldlist[i].ParticleList;
  1067. //取出该Field中,从物理坐标转换到像素坐标后.不知道该算法是否可靠,先进行测试判断
  1068. Point offset_point = GetFieldPhysicsConvertToScreen(list_point, i_field_width, i_field_height, new Point() { X = fieldlist[i].FieldPosX, Y = fieldlist[i].FieldPosY });
  1069. //然后将取出的数据,转换成Bitmap对象
  1070. Bitmap ls_bt = DrawFuncation.ReadImageFile(fieldlist[i].FieldImage);
  1071. //再循环取出所有的particle
  1072. foreach (Particle ls_cotsparticleclr in list_cotsparticleclr)
  1073. {
  1074. List<Feature> list_cotssegmentclr = new List<Feature>();
  1075. list_cotssegmentclr = ls_cotsparticleclr.FeatureList;
  1076. //创建颗粒分布图对应的类对象
  1077. List<DSegment> list_dsegment = new List<DSegment>();
  1078. //定义particle颗粒,并获取该颗粒与标准库中对应的颜色
  1079. DParticle ls_dp = new DParticle();
  1080. //ls_dp.Color = DrawFuncation.colorHx16toRGB(GetSTDItemClrByTypeIndex_ForDistrbutionSortImage(ls_cotsparticleclr.GetType()).GetColor());
  1081. ls_dp.CLRFieldID = ls_cotsparticleclr.FieldId; //为我封装的颗粒保存上,底层对应的FieldID
  1082. ls_dp.CLRTagID = ls_cotsparticleclr.ParticleId; //为我封装的颗粒对象保存上,底层对应的TagID
  1083. ls_dp.STDTypeID = ls_cotsparticleclr.TypeId; //为我封装的颗粒对象保存上,类型
  1084. ls_dp.TypeId = ls_cotsparticleclr.TypeId;
  1085. ls_dp.TypeName = ls_cotsparticleclr.TypeName;
  1086. ls_dp.XRayId = ls_cotsparticleclr.XrayId;
  1087. ls_dp.SEMPosX = ls_cotsparticleclr.SEMPosX;
  1088. ls_dp.SEMPosY = ls_cotsparticleclr.SEMPosY;
  1089. ls_dp.Color = GetColorBySTDTypeIDForBSEAndSorImage(ls_cotsparticleclr.TypeColor, ls_cotsparticleclr.TypeId);
  1090. //防止segment过多造成程序卡死
  1091. if (list_cotssegmentclr.Count < m_segment_overflownumber)
  1092. //再循环取出里面所有的segment
  1093. foreach (Feature ls_cotssegmentclr in list_cotssegmentclr)
  1094. {
  1095. //这里的坐标未转换
  1096. DSegment ds = new DSegment();
  1097. ds.Rect = new Rectangle(ls_cotssegmentclr.Start + offset_point.X,
  1098. //i_field_height - ls_cotssegmentclr.GetHeight() + offset_point.Y,
  1099. ls_cotssegmentclr.Height + offset_point.Y,
  1100. ls_cotssegmentclr.Length,
  1101. 1);
  1102. //图像上下反了,翻转一下,上下翻转
  1103. //ls_bt.RotateFlip(RotateFlipType.Rotate180FlipX);//使用系统带的图像处理方法,进行x轴的翻转
  1104. //合成图像完成,开始抠取像素---------------------为显示BSE原图而用--------------------------------------------
  1105. int i_ls_length = ls_cotssegmentclr.Length;
  1106. List<Color> ls_list_colors = new List<Color>();
  1107. for (int m = 0; m < i_ls_length; m++)
  1108. {
  1109. //这里实现一下代码保护
  1110. int lsjs_x = ls_cotssegmentclr.Start + m;
  1111. //int lsjs_y = i_field_height - ls_cotssegmentclr.GetHeight();
  1112. int lsjs_y = ls_cotssegmentclr.Height;
  1113. if (lsjs_x < 0)
  1114. lsjs_x = 0;
  1115. if (lsjs_x >= i_field_width)
  1116. lsjs_x = i_field_width - 1;
  1117. if (lsjs_y < 0)
  1118. lsjs_y = 0;
  1119. if (lsjs_y >= i_field_height)
  1120. lsjs_y = i_field_height - 1;
  1121. //按理说这里应该加上个横向抠取像素颜色,这里需要再处理一下
  1122. ls_list_colors.Add(ls_bt.GetPixel(lsjs_x,
  1123. lsjs_y));
  1124. }
  1125. //---------------------------------------------存入标准库相关的信息------------------------------------------------
  1126. ds.Color = ls_dp.Color;//将线的颜色对应到颗粒的颜色
  1127. //------------------------------------------------------------------------------------------------------
  1128. ds.List_Colors = ls_list_colors;
  1129. list_dsegment.Add(ds);
  1130. //ls_bt.Dispose();
  1131. }
  1132. ls_dp.Zoom_DisPlayMultiplier = 0.5f;
  1133. ls_dp.Zoom_DisPlay = true;
  1134. ls_dp.DSegments = list_dsegment; //将segment对应的设置到particle中
  1135. //并对DParticle相关信息进行计算
  1136. ls_dp.Rect = ls_dp.GetRectFromDSegment();
  1137. ls_dp.GPath = ls_dp.GetRegionFromDSegments();
  1138. ls_dp.SmallRect = ls_dp.GetSmallRectangleFromRect();
  1139. //将每个颗粒添加到颗粒分布图中的列表中
  1140. m_Control_DrawdistrbutionsortImage.m_list_baseobject.Add(ls_dp);
  1141. }
  1142. }
  1143. //--------------然后开始操作分布图定义的结构,接接所有的field,组成一个完整的image的rect大小,定义
  1144. }
  1145. /// <summary>
  1146. /// 根据type,从三种分类的分析库中提取当前分析物的颜色
  1147. /// </summary>
  1148. /// <param name="in_cotssampleclr"></param>
  1149. /// <param name="in_stdtypeid"></param>
  1150. /// <returns></returns>
  1151. public Color GetColorBySTDTypeIDForBSEAndSorImage(string in_cotssampleclr, int in_stdtypeid)
  1152. {
  1153. Color ret_c = new Color();
  1154. if (in_stdtypeid < 1000)
  1155. {
  1156. OTSSysSTDMgrClass osc = new OTSSysSTDMgrClass();
  1157. //小于1000,使用系统默认分类
  1158. ret_c = osc.GetColorByEnum(in_stdtypeid);
  1159. }
  1160. else if (in_stdtypeid >= 1000)
  1161. {
  1162. //大于等于1000,并且小于10000时,使用用户标准库来分析夹杂物名称
  1163. if (!in_cotssampleclr.Contains("#"))
  1164. {
  1165. ret_c = DrawFuncation.colorHx16toRGB("#" + in_cotssampleclr);//接收必须是#000000的格式
  1166. }
  1167. else
  1168. {
  1169. ret_c = DrawFuncation.colorHx16toRGB(in_cotssampleclr);//接收必须是#000000的格式
  1170. }
  1171. }
  1172. return ret_c;
  1173. }
  1174. /// <summary>
  1175. /// 颗粒排序图中的颗粒,重新组织显示颗粒排序规则
  1176. /// </summary>
  1177. public void GetDistrbutionSortimage_ByQuery(OTSIncAReportApp.OTSSampleReportInfo.OTSSampleMeaInfo sourceGridData)
  1178. {
  1179. List<string> FLNameList = new List<string>();
  1180. //List<int> FLID = new List<int>() { -1,0, 1, 2, 4, 6, 7, 8, 9 };
  1181. List<int> FLID = new List<int>() { 0, 1, 2, 4, 6, 9, 10};
  1182. List<string> NameList = new List<string>();
  1183. int fltype = 0;
  1184. //先清除list
  1185. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution.Clear();
  1186. m_Control_DrawdistrbutionsortImage.m_old_list_sortparticledistribution.Clear();
  1187. m_Control_DrawdistrbutionsortImage.m_f_zoom_record = 1;
  1188. //------------------------------------分解结果内容部份------------------------------------
  1189. string display_type = "";
  1190. string con = "";
  1191. var list = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 4);
  1192. string sort_type = list.itemVal.ToString();
  1193. int _type = list.comboDownList.IndexOf(sort_type);
  1194. switch (_type)
  1195. {
  1196. case 0:
  1197. fltype = 0;
  1198. break;
  1199. case 1:
  1200. fltype = 1;
  1201. break;
  1202. case 2:
  1203. fltype = 2;
  1204. display_type = sourceGridData.SampleDataList.Find(s => Convert.ToInt32(s.iItemId) == 13).itemVal.ToString();
  1205. switch (display_type)
  1206. {
  1207. case "DMAX":
  1208. con = "DMAX";
  1209. break;
  1210. case "DMIN":
  1211. con = "DMIN";
  1212. break;
  1213. case "Area":
  1214. con = "Area";
  1215. break;
  1216. case "FERET":
  1217. con = "DFERET";
  1218. break;
  1219. }
  1220. break;
  1221. }
  1222. string path = resultFile.FilePath;
  1223. ParticleData particleData = new ParticleData(path);
  1224. List<Particle> particles = particleData.GetParticleListByCon("", "", "", 0);
  1225. foreach (DParticle ls_dp in m_Control_DrawdistrbutionsortImage.m_list_baseobject)
  1226. {
  1227. int dis = 0;
  1228. foreach (Particle particle in particles)
  1229. {
  1230. //找到对应的颗粒,将分类设置进去
  1231. if (ls_dp.CLRTagID == particle.ParticleId && ls_dp.CLRFieldID == particle.FieldId)
  1232. {
  1233. if (!FLNameList.Contains(particle.TypeName) && particle.TypeName != "")
  1234. {
  1235. FLNameList.Add(particle.TypeName);
  1236. }
  1237. if (fltype == 0)
  1238. {
  1239. ls_dp.ParticleFL = particle.TypeId.ToString();
  1240. }
  1241. if (fltype == 1)
  1242. {
  1243. ls_dp.ParticleFL = particle.TypeName.ToString();
  1244. }
  1245. if (fltype == 2)
  1246. {
  1247. if (con == "DMAX")
  1248. ls_dp.ParticleFL = particle.DMAX.ToString();
  1249. if (con == "DMIN")
  1250. ls_dp.ParticleFL = particle.DMIN.ToString();
  1251. if (con == "Area")
  1252. ls_dp.ParticleFL = particle.Area.ToString();
  1253. if (con == "DFERET")
  1254. ls_dp.ParticleFL = particle.FERET.ToString();
  1255. }
  1256. ls_dp.Operator = ParticleOperator.DISPLAY;
  1257. dis = 1;
  1258. break;
  1259. }
  1260. }
  1261. if (dis == 0)
  1262. {
  1263. ls_dp.Operator = ParticleOperator.NODISPLAY;
  1264. }
  1265. }
  1266. if (fltype == 0)
  1267. {
  1268. //NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype7"].ToString(), table["partcletype8"].ToString(), table["partcletype9"].ToString(), table["partcletype10"].ToString() };
  1269. NameList = new List<string>() { table["partcletype0"].ToString(), table["partcletype1"].ToString(), table["partcletype2"].ToString(), table["partcletype4"].ToString(), table["partcletype6"].ToString(), table["partcletype9"].ToString(), table["partcletype10"].ToString() };
  1270. }
  1271. if (fltype == 1)
  1272. {
  1273. NameList = FLNameList;
  1274. }
  1275. if (fltype == 2)
  1276. {
  1277. //获取粒级表
  1278. string flpath = m_Control_DrawdistrbutionsortImage.m_ReportApp.m_RptConfigFile.FileFolderSize + m_Control_DrawdistrbutionsortImage.m_ReportApp.m_RptConfigFile.PartSizeFile;
  1279. DataSet ds = XMLoperate.GetXml(flpath);
  1280. string sizestr = ds.Tables[0].Rows[0]["Sizes"].ToString();
  1281. List<string> sizeList = new List<string>();
  1282. for (int i = 0; i < sizestr.Split(',').Length - 1; i++)
  1283. {
  1284. if (sizestr.Split(',')[i].Length > 0)
  1285. {
  1286. double d1 = Convert.ToDouble(sizestr.Split(',')[i]);
  1287. double d2 = Convert.ToDouble(sizestr.Split(',')[i + 1]);
  1288. sizeList.Add(d1.ToString() + "~" + d2.ToString());
  1289. }
  1290. }
  1291. double d = Convert.ToDouble(sizestr.Split(',')[sizestr.Split(',').Length - 1]);
  1292. sizeList.Add(d.ToString() + "~MAX");
  1293. NameList = sizeList;
  1294. }
  1295. //为颗粒排序图,创建分栏grid
  1296. foreach (string name in NameList)
  1297. {
  1298. SortParticleDistribution sortparticledistribution = new SortParticleDistribution();
  1299. sortparticledistribution.RectF = new RectangleF(m_Control_DrawdistrbutionsortImage.ClientRectangle.X, m_Control_DrawdistrbutionsortImage.ClientRectangle.Y,
  1300. 800, m_Control_DrawdistrbutionsortImage.ClientRectangle.Height);
  1301. sortparticledistribution.ShowStr = name;//设置分类grid
  1302. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution.Add(sortparticledistribution);
  1303. }
  1304. //然后再重新将list_baseobject中的颗粒,分别添加到对应的sortgrid中
  1305. foreach (DParticle ls_dp in m_Control_DrawdistrbutionsortImage.m_list_baseobject)
  1306. {
  1307. var sort = m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution;
  1308. for (int i = 0; i < sort.Count; i++)
  1309. {
  1310. if (fltype == 0)
  1311. {
  1312. if (ls_dp.STDTypeID == FLID[i])
  1313. {
  1314. //将对应的颗粒添加到分栏grid中
  1315. DParticle sort_dp = ls_dp.Clone() as DParticle;
  1316. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  1317. sort[i].List_DParticle.Add(sort_dp);
  1318. break;
  1319. }
  1320. else if (ls_dp.STDTypeID > 10000)
  1321. {
  1322. //将对应的颗粒添加到分栏grid中
  1323. DParticle sort_dp = ls_dp.Clone() as DParticle;
  1324. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  1325. sort[sort.Count - 1].List_DParticle.Add(sort_dp);
  1326. break;
  1327. }
  1328. }
  1329. else if (fltype == 1)
  1330. {
  1331. if (ls_dp.TypeName == NameList[i])
  1332. {
  1333. //将对应的颗粒添加到分栏grid中
  1334. DParticle sort_dp = ls_dp.Clone() as DParticle;
  1335. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  1336. sort[i].List_DParticle.Add(sort_dp);
  1337. break;
  1338. }
  1339. }
  1340. else if (fltype == 2)
  1341. {
  1342. double min = Convert.ToDouble(NameList[i].Split('~')[0]);
  1343. double max = 0;
  1344. if (NameList[i].Split('~')[1].ToLower() != "max")
  1345. { max = Convert.ToDouble(NameList[i].Split('~')[1]); }
  1346. else
  1347. {
  1348. max = 999;
  1349. }
  1350. double size = Convert.ToDouble(ls_dp.ParticleFL);
  1351. if (size <= max && size >= min)
  1352. {
  1353. //将对应的颗粒添加到分栏grid中
  1354. DParticle sort_dp = ls_dp.Clone() as DParticle;
  1355. sort_dp.Rect = sort_dp.GetRectFromDSegment();
  1356. sort[i].List_DParticle.Add(sort_dp);
  1357. break;
  1358. }
  1359. }
  1360. }
  1361. }
  1362. //循环分栏grid,对各分栏grid进行摆放
  1363. for (int i = 0; i < m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution.Count(); i++)
  1364. {
  1365. //计算y轴,的增量
  1366. float ls_height = 0;
  1367. if (i == 0)
  1368. {
  1369. ls_height = 0;
  1370. }
  1371. else
  1372. {
  1373. ls_height = m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i - 1].RectF.Y +
  1374. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i - 1].RectF.Height - 10;
  1375. }
  1376. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i].RectF = new RectangleF(
  1377. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i].RectF.X,
  1378. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i].RectF.Y + ls_height,
  1379. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i].RectF.Width,
  1380. m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution[i].GetSortGridHeight() + 50);//为每栏的高度增加了50补充,防止图像溢出
  1381. }
  1382. //然后再重新对分栏grid中的颗粒,重新进行摆放
  1383. foreach (SortParticleDistribution ls_spd in m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution)
  1384. {
  1385. ls_spd.SortDParticle(m_Control_DrawdistrbutionsortImage.FZOOMRecord);
  1386. }
  1387. //最后,将分栏grid,分别存放到old的分栏grid中
  1388. foreach (SortParticleDistribution ls_sortparticledistribution in m_Control_DrawdistrbutionsortImage.m_list_sortparticledistribution)
  1389. {
  1390. SortParticleDistribution old_sortparticledistribution = ls_sortparticledistribution.Clone() as SortParticleDistribution;
  1391. m_Control_DrawdistrbutionsortImage.m_old_list_sortparticledistribution.Add(old_sortparticledistribution);
  1392. foreach (DParticle ls_dp in old_sortparticledistribution.List_DParticle)
  1393. {
  1394. ls_dp.Rect = ls_dp.GetRectFromDSegment();
  1395. }
  1396. }
  1397. }
  1398. #endregion
  1399. }
  1400. }