OTSIncAReportFun.cs 76 KB

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