OTSMeasureStatusWindow.cs 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using OTS.WinFormsUI.Docking;
  6. using System.IO;
  7. using System.Reflection;
  8. using OTSCLRINTERFACE;
  9. using System.Data;
  10. using System.Collections;
  11. using System.Drawing.Imaging;
  12. using OTSIncAGraph.Controls;
  13. using OTSModelSharp;
  14. using OTSDataType;
  15. using OTSModelSharp.ServiceCenter;
  16. using OTSMeasureApp._0_OTSModel.Measure.ParamData;
  17. namespace OTSMeasureApp
  18. {
  19. public enum idLine
  20. {
  21. //曲线
  22. GrayLine = 0,
  23. //灰度图
  24. GrayImage = 1
  25. }
  26. public partial class OTSMeasureStatusWindow : DockContent
  27. {
  28. #region 全部变量
  29. public OTSIncAMeasureAppForm m_MeasureAppForm;
  30. /* 接收图像数据 */
  31. public byte[] Imagedata = new byte[m_iWidth];
  32. static int m_iWidth = 0;
  33. static int m_iHeight = 0;
  34. //获取BSE图时最初的位置
  35. Point m_GetBSEImageInitPoint = new Point();
  36. // 调试图图片数据
  37. public byte[] originalBseData;
  38. //去背景图
  39. public byte[] removeBGBseData;
  40. public Bitmap coloredParticleImage;
  41. //灰度图数据
  42. public double[] dGrayLevelData;
  43. //灰度峰值
  44. public double dGrayLevelMax;
  45. //去背景灰度图数据
  46. public double[] dGrayAbandonLevelData;
  47. //去背景灰度峰值
  48. public double dGrayAbandonLevelMax;
  49. public string FileName;
  50. //原图Y轴
  51. int YSize = 0;
  52. int drawflag = 0;
  53. private int height = 0;
  54. private int width = 0;
  55. //画布大小
  56. private Bitmap bitmap;
  57. private Graphics graphics;
  58. private float Tension = 0.001f;
  59. //要画曲线的点y坐标值,x值为10s采集一次数据
  60. private float[] curvebuf = new float[] { 20.0f, 30.0f, 40.0f, 35.4f, 21.6f, 32.8f, 5.2f, 9.9f, 30f, 35.3f, 25.3f, 21.2f, 30.2f, 22.8f, 40.5f, 5.6f, 20.6f };
  61. //记录鼠标在BSE移动时 图像的位置
  62. double m_MouseMoveImageX = -1;
  63. double m_MouseMoveImageY = -1;
  64. //记录采集点
  65. List<Point> m_ElementSignPoint = new List<Point>();
  66. //绘制采集点对象
  67. public static List<CRectangleGDIObject> m_ElementPointGDIObjects;
  68. Point m_mouseCurrentPoint = new Point();
  69. //鼠标缩放倍数
  70. float m_CurrentMultiple = 0;
  71. float m_Multiple = 0.2f;
  72. int m_MaxMultipleRange = 4;
  73. //单击采集的鼠标位置
  74. double dMouseImgX = 0;
  75. double dMouseImgY = 0;
  76. NLog.Logger log;
  77. //国际化
  78. OTSCommon.Language lan;
  79. Hashtable table;
  80. #endregion
  81. #region 在右下角状态栏中显示鼠标当前位置所需要的参数
  82. double dPositionX = 0;
  83. double dPositionY = 0;
  84. //double dPositionR = 0;
  85. //double Magnification = 0;
  86. int FieldWitdh = 0;
  87. double FieldHeight = 0;
  88. private otsdataconst.OTS_SysType_ID m_systype;
  89. #endregion
  90. public enum ImageType
  91. {
  92. //BSE图
  93. BSEImage = 0,
  94. //去背景图
  95. RemoveBGImage = 1,
  96. //显示灰度曲线图
  97. GrayLevelChart = 2,
  98. //线扫描曲线
  99. GrayLevelLine = 3,
  100. //显示去背景BSE图灰度曲线
  101. GrayAbandonLevelChart = 4,
  102. //
  103. ColorParticleImage = 5
  104. }
  105. //图bfResult
  106. public static bool bfResult = false;
  107. //当前是否显示线扫描
  108. public static bool IsShowGrayLevelLine = false;
  109. //当前默认值
  110. ImageType m_imagetype = ImageType.BSEImage;
  111. ImageType m_IsShowImageType = ImageType.BSEImage;
  112. public OTSMeasureStatusWindow(OTSIncAMeasureAppForm MeasureApp)
  113. {
  114. InitializeComponent();
  115. m_MeasureAppForm = MeasureApp;
  116. m_ElementPointGDIObjects = new List<CRectangleGDIObject>();
  117. //进入时首先对XRayTable进行隐藏
  118. panelXray.Visible = false;
  119. //国际化
  120. lan = new OTSCommon.Language(this);
  121. table = lan.GetNameTable(this.Name);
  122. }
  123. /// <summary>
  124. /// 在控件中显示BSE图像
  125. /// </summary>
  126. /// <param name="m_iWidth"></param>
  127. /// <param name="m_iHeigh"></param>
  128. /// <param name="bBseData"></param>
  129. public void ShowImage(int m_iWidth, int m_iHeigh, byte[] bBseData)
  130. {
  131. try
  132. {
  133. Bitmap bitmap = CImageHandler.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
  134. pbBSEImage.Image = bitmap;
  135. //设置Pictrue显示位置
  136. pbBSEImage.Height = this.RestoreBounds.Height;
  137. pbBSEImage.Width = this.RestoreBounds.Height * 4 / 3;
  138. //获取黄线坐标位置
  139. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  140. m_GetBSEImageInitPoint = rectangle.Location;
  141. pointStart.X = rectangle.X;
  142. pointEnd.X = rectangle.X + rectangle.Width;
  143. pointStart.Y = rectangle.Y + (rectangle.Height) / 2;
  144. pointEnd.Y = rectangle.Y + (rectangle.Height) / 2;
  145. pbBSEImage.Left = 0;
  146. pbBSEImage.Top = 0;
  147. }
  148. catch (Exception ex)
  149. {
  150. log.Error("(LZMeasureStatusWindow.ShowImage) " + ex.ToString());
  151. }
  152. }
  153. public void ShowColoredImage(int m_iWidth, int m_iHeigh, Bitmap coloredImage)
  154. {
  155. try
  156. {
  157. pbBSEImage.Image = coloredImage;
  158. //设置Pictrue显示位置
  159. pbBSEImage.Height = this.RestoreBounds.Height;
  160. pbBSEImage.Width = this.RestoreBounds.Height * 4 / 3;
  161. //获取黄线坐标位置
  162. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  163. m_GetBSEImageInitPoint = rectangle.Location;
  164. pointStart.X = rectangle.X;
  165. pointEnd.X = rectangle.X + rectangle.Width;
  166. pointStart.Y = rectangle.Y + (rectangle.Height) / 2;
  167. pointEnd.Y = rectangle.Y + (rectangle.Height) / 2;
  168. pbBSEImage.Left = 0;
  169. pbBSEImage.Top = 0;
  170. }
  171. catch (Exception ex)
  172. {
  173. log.Error("(LZMeasureStatusWindow.ShowImage) " + ex.ToString());
  174. }
  175. }
  176. /// <summary>
  177. /// 在控件中显示图像
  178. /// </summary>
  179. /// <param name="m_iWidth"></param>
  180. /// <param name="m_iHeigh"></param>
  181. /// <param name="bBseData"></param>
  182. public Image ShowImageStatus(int m_iWidth, int m_iHeigh, byte[] bBseData)
  183. {
  184. try
  185. {
  186. return CImageHandler.ToGrayBitmap(bBseData, m_iWidth, m_iHeigh);
  187. }
  188. catch (Exception ex)
  189. {
  190. log.Error("(LZMeasureStatusWindow.ShowImage) " + ex.ToString());
  191. return null;
  192. }
  193. }
  194. //显示扫描曲线图方法
  195. #region 显示扫描曲线图方法
  196. private void DrawCurve(byte[] buf, PaintEventArgs e)
  197. {
  198. try
  199. {
  200. //创建位图
  201. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  202. double rate = (double)rectangle.Height / (double)pbBSEImage.Image.Height;
  203. width = rectangle.Width;
  204. height = rectangle.Height;
  205. bitmap = new Bitmap(width, height);
  206. //创建Graphics类对象
  207. graphics = Graphics.FromImage(bitmap);
  208. //清空图片背景色
  209. //graphics.Clear(Color.White);
  210. Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);
  211. Brush brush2 = new SolidBrush(Color.SaddleBrown);
  212. Brush brushPoint = new SolidBrush(Color.Red);
  213. Pen mypenRed = new Pen(Color.Red, 1);
  214. Pen mypenYellow = new Pen(Color.Yellow, 0.001f);//点颜色
  215. //画曲线
  216. if (drawflag == 1)
  217. {
  218. int len = Imagedata.Length;
  219. PointF[] CurvePointF = new PointF[len];//坐标点
  220. float pointX = 0;
  221. float pointY = 0;
  222. for (int i = 0; i < Imagedata.Length; i++)
  223. {
  224. pointX = (pbBSEImage.Width - rectangle.Width) / 2 + Convert.ToSingle(i * rate);
  225. float imagei = (int)GrayLevel.Max - Convert.ToInt32(Imagedata[i]);
  226. float imagerate = (Convert.ToSingle(Convert.ToDouble(rectangle.Height) / 510));
  227. pointY = imagei * imagerate + (rectangle.Height) / 4;
  228. if (pointY > ((rectangle.Height) * 3 / 4))
  229. {
  230. float ii = pointY;
  231. }
  232. CurvePointF[i] = new PointF(pointX, pointY);
  233. }
  234. e.Graphics.DrawCurve(mypenYellow, CurvePointF, Tension);//画曲线
  235. }
  236. }
  237. catch (Exception ex)
  238. {
  239. log.Error("(LZMeasureStatusWindow.DrawCurve) " + ex.ToString());
  240. }
  241. }
  242. #endregion
  243. //处理获取调试图菜单事件
  244. #region 处理获取调试图菜单事件
  245. private void AcquireBSEImage_Click(object sender, EventArgs e)
  246. {
  247. try
  248. {
  249. if (m_ElementPointGDIObjects != null)
  250. {
  251. m_ElementPointGDIObjects.Clear();
  252. }
  253. //设置右键菜单中的项 是否可编辑
  254. SetContextMenuEnabled(true);
  255. GetAcquireBSEImage();
  256. }
  257. catch (Exception ex)
  258. {
  259. MessageBox.Show(table["message20"].ToString() + ex.ToString());
  260. }
  261. try
  262. {
  263. DelElementPointGDIObjects();
  264. panelXray.Visible = false;
  265. m_CurrentMultiple = 0;
  266. }
  267. catch (Exception ex)
  268. {
  269. MessageBox.Show(table["message21"].ToString() + ex.ToString());
  270. }
  271. }
  272. /// <summary>
  273. /// 获取BSE图方法
  274. /// </summary>
  275. private void GetAcquireBSEImage()
  276. {
  277. try
  278. {
  279. //获取电镜中图像大小
  280. string str = m_MeasureAppForm.m_ProjParam.GetBSEImageResolution();// 举例:1024X768
  281. string[] sArray = str.Split('X');
  282. if (sArray[0] != "" && sArray[1] != "")
  283. {
  284. m_iWidth = Convert.ToInt32(sArray[0]);
  285. m_iHeight = Convert.ToInt32(sArray[1]);
  286. }
  287. //建立图像数据
  288. originalBseData = new byte[m_iWidth * m_iHeight];
  289. //获取图像数据
  290. int nDwellTime = 4;
  291. try
  292. {
  293. int level = (int)m_MeasureAppForm.m_ProjParam.GetResultData().GetWorkingSample().GetMsrParams().GetImageScanParam().GetScanImageSpeed();
  294. switch (level)
  295. {
  296. case 0:
  297. nDwellTime = 4;
  298. break;
  299. case 1:
  300. nDwellTime = 8;
  301. break;
  302. case 2:
  303. nDwellTime = 16;
  304. break;
  305. }
  306. }
  307. catch (Exception)
  308. {
  309. nDwellTime = 8;
  310. }
  311. int imageCount = GetScanImage(m_iWidth, m_iHeight, nDwellTime, ref originalBseData);
  312. //取图不成功就返回
  313. if (imageCount > 0)
  314. {
  315. bfResult = true;
  316. }
  317. if (!bfResult)
  318. {
  319. if (contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled == true)
  320. {
  321. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = false;
  322. }
  323. //显示单点扫描元素信息菜单
  324. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = false;
  325. pbBSEImage.Hide();
  326. return;
  327. }
  328. else
  329. {
  330. //显示单点扫描元素信息菜单
  331. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = true;
  332. }
  333. //获取灰度图数据
  334. dGrayLevelData = new double[(int)GrayLevel.Max];
  335. dGrayLevelData = GetGaryData(originalBseData, dGrayLevelData);
  336. //计算灰度最大值
  337. dGrayLevelMax = dGrayLevelData[0];
  338. for (int i = 1; i < (int)GrayLevel.Max; i++)
  339. {
  340. dGrayLevelMax = Math.Max(dGrayLevelMax, dGrayLevelData[i]);
  341. }
  342. SetClickMenuBSEImg();
  343. //更新当前的图
  344. UpdateImageOrChart(m_imagetype);
  345. myChart.Visible = false;
  346. //图像加载后的显示位置
  347. m_CurrentMultiple = 0;
  348. pbBSEImage.Height = this.RestoreBounds.Height;
  349. pbBSEImage.Left = 0;
  350. pbBSEImage.Top = 0;
  351. }
  352. catch (Exception ex)
  353. {
  354. log.Error("(LZMeasureStatusWindow.AcquireBSEImage_Click) " + ex.ToString());
  355. }
  356. }
  357. public double[] GetGaryData(byte[] Imagedata, double[] GrayLevelData)
  358. {
  359. try
  360. {
  361. //获得下标每一点的灰度值,并在数组里加一
  362. for (int i = 0; i < Imagedata.Length; i++)
  363. {
  364. byte graylevel = Imagedata[i];
  365. if (graylevel > 0 && graylevel < 255)
  366. {
  367. GrayLevelData[graylevel] += 1;
  368. }
  369. }
  370. return GrayLevelData;
  371. }
  372. catch (Exception ex)
  373. {
  374. log.Error(ex.ToString());
  375. return null;
  376. }
  377. }
  378. public int GetScanImage(int iWidth, int iHeigh, int iDwellTime, ref byte[] bImageData)
  379. {
  380. if (FileHelper.GetXMLInformations("SemControllerName") == "FEI")
  381. {
  382. ScanController m_ScanHardwareMgr = ScanController.GetScanController();
  383. m_ScanHardwareMgr.Init();
  384. m_ScanHardwareMgr.SetImageSize(iWidth, iHeigh);
  385. bImageData = m_ScanHardwareMgr.AcquireBSEImage(0, 0, iDwellTime).GetImageDataPtr();
  386. return 1;
  387. }
  388. else
  389. {
  390. //电镜设置对象
  391. COTSControlFunExport cfun = COTSControlFunExport.GetControllerInstance();
  392. int GetImgCount = 0;
  393. try
  394. {
  395. //连接电镜
  396. bool IsConnec = cfun.ConncetSem();
  397. if (!IsConnec)
  398. {
  399. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.ConncetSem() = false Failed";
  400. log.Error(strErrorInfo);
  401. return 0;
  402. }
  403. //实例电镜初始化
  404. bool IsScan = cfun.ScanInit();
  405. if (!IsScan)
  406. {
  407. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.ScanInit = false Failed";
  408. log.Error(strErrorInfo);
  409. return 0;
  410. }
  411. int a_ExternalMode = 0;
  412. //获取终止模式
  413. a_ExternalMode = cfun.GetSemExternalMode();
  414. //保存初始模式变量
  415. int a_oldMode = 0;
  416. //获取初始模式
  417. if (!cfun.GetSemScanMode(ref a_oldMode))
  418. {
  419. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemScanMode = false Failed";
  420. log.Error(strErrorInfo);
  421. return 0;
  422. }
  423. //设置当前模式
  424. if (!cfun.SetSemScanMode(a_ExternalMode))
  425. {
  426. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetSemScanMode = false Failed";
  427. log.Error(strErrorInfo);
  428. return 0;
  429. }
  430. #region BeamBlank
  431. int a_nBeamBlank = 0;
  432. //获取参数
  433. if (!cfun.GetSemBeamBlank(ref a_nBeamBlank))
  434. {
  435. cfun.SetSemScanMode(a_oldMode);
  436. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemBeamBlank = false Failed";
  437. log.Error(strErrorInfo);
  438. return 0;
  439. }
  440. //设置参数
  441. if (!cfun.SetSemBeamBlank(false))
  442. {
  443. cfun.SetSemScanMode(a_oldMode);
  444. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetSemBeamBlank = false Failed";
  445. log.Error(strErrorInfo);
  446. return 0;
  447. }
  448. #endregion
  449. #region 获得放大倍数
  450. //获得放大倍数
  451. double a_dMagnification = 0;
  452. //获取参数
  453. if (!cfun.GetSemMagnification(ref a_dMagnification))
  454. {
  455. cfun.SetSemScanMode(a_oldMode);
  456. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemMagnification = false Failed";
  457. log.Error(strErrorInfo);
  458. return 0;
  459. }
  460. #endregion
  461. #region 获取 电镜 X、Y轴 与角度
  462. //获取 电镜 X、Y轴 与角度
  463. double PositionX = 0;
  464. double PositionY = 0;
  465. double PositionR = 0;
  466. //获取参数
  467. if (!cfun.GetSemPositionXY(ref PositionX, ref PositionY, ref PositionR))
  468. {
  469. cfun.SetSemScanMode(a_oldMode);
  470. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.GetSemPositionXY = false Failed";
  471. log.Error(strErrorInfo);
  472. return 0;
  473. }
  474. #endregion
  475. #region 设置图像分辨率
  476. //设置宽度
  477. if (!cfun.SetImageSize(iWidth, iHeigh))
  478. {
  479. cfun.SetSemScanMode(a_oldMode);
  480. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetImageSize = false Failed";
  481. log.Error(strErrorInfo);
  482. return 0;
  483. }
  484. #endregion
  485. #region 采集时间
  486. //采集时间
  487. int nDwellTime = 4;
  488. if (!cfun.SetDwellTime(nDwellTime))
  489. {
  490. cfun.SetSemScanMode(a_oldMode);
  491. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.SetDwellTime = false Failed";
  492. log.Error(strErrorInfo);
  493. return 0;
  494. }
  495. #endregion
  496. #region MatrixSize
  497. //获得放大倍数
  498. int a_MatrixSize = 0;
  499. Size size = new Size();
  500. //获取参数
  501. size = cfun.GetMatrixSize(a_MatrixSize);
  502. #endregion
  503. //获取图像数据
  504. int resultCount = iWidth * iHeigh;
  505. GetImgCount = cfun.AcquireBSEImage(0, 0, 0, ref bImageData);
  506. //记录日志
  507. if (resultCount == GetImgCount)
  508. {
  509. //设置为原始 扫描模式
  510. cfun.SetSemScanMode(a_oldMode);
  511. }
  512. else
  513. {
  514. cfun.SetSemScanMode(a_oldMode);
  515. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) cfun.AcquireBSEImage = 0 Failed";
  516. log.Error(strErrorInfo);
  517. }
  518. }
  519. catch (Exception ex)
  520. {
  521. //记录日志
  522. log.Error(ex.Message.ToString());
  523. string strErrorInfo = "(OTSBSEImageFun.GetScanImage) Exception Error Happend";
  524. log.Error(strErrorInfo);
  525. }
  526. return GetImgCount;
  527. }
  528. }
  529. #endregion
  530. #region 设置点击BSE菜单
  531. public void SetClickMenuBSEImg()
  532. {
  533. //用于线扫描曲线
  534. m_IsShowImageType = ImageType.BSEImage;
  535. m_imagetype = ImageType.BSEImage;
  536. pbBSEImage.Show();
  537. }
  538. #endregion
  539. //更新当前的图
  540. #region 更新当前的图
  541. private void UpdateImageOrChart(ImageType imagetype)
  542. {
  543. try
  544. {
  545. switch (imagetype)
  546. {
  547. case ImageType.BSEImage:
  548. {
  549. //在控件中显示图像
  550. ShowImage(m_iWidth, m_iHeight, originalBseData);
  551. Imagedata = new byte[m_iWidth];
  552. IsShowGrayLevelLine = false;
  553. //获取默认Y轴
  554. GetYSize();
  555. //获取行数据
  556. GetLineImage(YSize, m_iWidth, ref Imagedata);
  557. }
  558. break;
  559. case ImageType.RemoveBGImage:
  560. {
  561. ShowImage(m_iWidth, m_iHeight, removeBGBseData);
  562. Imagedata = new byte[m_iWidth];
  563. IsShowGrayLevelLine = false;
  564. //获取默认Y轴
  565. GetYSize();
  566. //获取行数据
  567. GetLineImage(YSize, m_iWidth, ref Imagedata);
  568. }
  569. break;
  570. case ImageType.GrayLevelLine:
  571. {
  572. GetLineImage(YSize, m_iWidth, ref Imagedata);
  573. }
  574. break;
  575. case ImageType.ColorParticleImage:
  576. {
  577. ShowColoredImage(m_iWidth, m_iHeight, coloredParticleImage);
  578. Imagedata = new byte[m_iWidth];
  579. IsShowGrayLevelLine = false;
  580. //获取默认Y轴
  581. GetYSize();
  582. //获取行数据
  583. GetLineImage(YSize, m_iWidth, ref Imagedata);
  584. }
  585. break;
  586. default:
  587. { }
  588. break;
  589. }
  590. this.Refresh();
  591. }
  592. catch (Exception ex)
  593. {
  594. log.Error("(LZMeasureStatusWindow.UpdataImageChart) " + ex.ToString());
  595. }
  596. }
  597. #endregion
  598. //显示去背景图 = AUTO
  599. #region 显示去背景图
  600. private void ShowRemoveBGImage_Click(object sender, EventArgs e)
  601. {
  602. //设置右键菜单中的项 是否可编辑
  603. SetContextMenuEnabled(true);
  604. ShowRemoveBGImage();
  605. m_CurrentMultiple = 0;
  606. panelXray.Visible = false;
  607. }
  608. protected void ShowRemoveBGImage()
  609. {
  610. try
  611. {
  612. //获取电镜中图像大小
  613. string str = m_MeasureAppForm.m_ProjParam.GetBSEImageResolution();
  614. string[] sArray = str.Split('X');
  615. if (sArray[0] != "" && sArray[1] != "")
  616. {
  617. m_iWidth = Convert.ToInt32(sArray[0]);
  618. m_iHeight = Convert.ToInt32(sArray[1]);
  619. }
  620. //获取图像数据
  621. COTSSample WSample = m_MeasureAppForm.m_ProjData.GetWorkingSample();
  622. double pixelSize = WSample.CalculatePixelSize();
  623. var imageProcessParam = WSample.GetMsrParams().GetImageProcessParam();
  624. var imageHandle = new CImageHandler();
  625. m_systype = m_MeasureAppForm.m_ProjParam.GetResultData().m_systemTypeId;
  626. if (m_systype == otsdataconst.OTS_SysType_ID.CleannessA)
  627. {
  628. coloredParticleImage = new Bitmap(m_iWidth, m_iHeight);
  629. CBSEImgClr pImgNoBG = new CBSEImgClr(new Rectangle(0,0,m_iWidth,m_iHeight));
  630. bfResult = imageHandle.GetColoredImage(imageProcessParam, pixelSize, originalBseData, m_iWidth, m_iHeight, ref pImgNoBG,ref coloredParticleImage);
  631. m_imagetype = ImageType.ColorParticleImage;
  632. removeBGBseData = pImgNoBG.GetImageDataPtr();
  633. }
  634. else if(m_systype == otsdataconst.OTS_SysType_ID.IncA)
  635. {
  636. //bfResult = imageHandle.GetBSEImage(imageProcessParam, pixelSize, originalBseData, m_iWidth, m_iHeight, ref removeBGBseData);
  637. //m_IsShowImageType = ImageType.RemoveBGImage;
  638. //m_imagetype = ImageType.RemoveBGImage;
  639. coloredParticleImage = new Bitmap(m_iWidth, m_iHeight);
  640. CBSEImgClr pImgNoBG = new CBSEImgClr(new Rectangle(0, 0, m_iWidth, m_iHeight));
  641. bfResult = imageHandle.GetColoredImage(imageProcessParam, pixelSize, originalBseData, m_iWidth, m_iHeight, ref pImgNoBG, ref coloredParticleImage);
  642. m_imagetype = ImageType.ColorParticleImage;
  643. removeBGBseData = pImgNoBG.GetImageDataPtr();
  644. }
  645. //获取去背景灰度图数据
  646. dGrayAbandonLevelData = new double[(int)GrayLevel.Max];
  647. dGrayAbandonLevelData = GetGrayAbandonData(removeBGBseData, dGrayAbandonLevelData);
  648. //计算灰度去背景最大值
  649. dGrayAbandonLevelMax = dGrayAbandonLevelData[0];
  650. for (int i = 1; i < (int)GrayLevel.Max; i++)
  651. {
  652. dGrayAbandonLevelMax = Math.Max(dGrayAbandonLevelMax, dGrayAbandonLevelData[i]);
  653. }
  654. //取图不成功就返回
  655. if (!bfResult) { return; }
  656. //用于线扫描曲线
  657. UpdateImageOrChart(m_imagetype);
  658. myChart.Visible = false;
  659. pbBSEImage.Show();
  660. //切换显示至BSE图
  661. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  662. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  663. {
  664. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
  665. }
  666. else
  667. {
  668. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
  669. }
  670. }
  671. catch (Exception ex)
  672. {
  673. log.Error("(LZMeasureStatusWindow.ShowRemoveBGImage_Click) " + ex.ToString());
  674. }
  675. }
  676. #endregion
  677. //显示灰度曲线
  678. #region 显示灰度曲线
  679. private void ShowGrayLevelImage_Click(object sender, EventArgs e)
  680. {
  681. //设置右键菜单中的项 是否可编辑
  682. SetContextMenuEnabled(false);
  683. ShowGrayLevelImage();
  684. myChart.Visible = true;
  685. panelXray.Visible = false;
  686. IsShowGrayLevelLine = false;
  687. }
  688. protected void ShowGrayLevelImage()
  689. {
  690. try
  691. {
  692. m_imagetype = ImageType.GrayLevelChart;
  693. pbBSEImage.Hide();
  694. //切换显示至BSE图
  695. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  696. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  697. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  698. {
  699. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
  700. }
  701. else
  702. {
  703. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
  704. }
  705. UpdateImageOrChart(m_imagetype);
  706. int[] XData = new int[(int)GrayLevel.Max];
  707. for (int i = 0; i < (int)GrayLevel.Max; i++)
  708. {
  709. XData[i] = i + 1;
  710. }
  711. int[] YData = new int[dGrayLevelData.Length];
  712. for (int i = 0; i < dGrayLevelData.Length; i++)
  713. {
  714. YData[i] = (int)dGrayLevelData[i];
  715. }
  716. chartData(XData, YData);
  717. }
  718. catch (Exception ex)
  719. {
  720. log.Error("(LZMeasureStatusWindow.ShowGrayLevelImage_Click) "
  721. + ex.ToString());
  722. }
  723. }
  724. #endregion
  725. //显示线扫描曲线
  726. #region 显示线扫描曲线
  727. private void ShowGrayLevelLine_Click(object sender, EventArgs e)
  728. {
  729. panelXray.Visible = false;
  730. ShowGrayLevelLine();
  731. }
  732. protected void ShowGrayLevelLine()
  733. {
  734. try
  735. {
  736. m_imagetype = ImageType.GrayLevelLine;
  737. //取图不成功就返回
  738. if (!bfResult) { return; }
  739. UpdateImageOrChart(m_imagetype);
  740. //m_ImageData.Line = idLine.GrayLine;
  741. }
  742. catch (Exception ex)
  743. {
  744. log.Error("(LZMeasureStatusWindow.ShowGrayLevelLine_Click) " + ex.ToString());
  745. }
  746. }
  747. #endregion
  748. #region 扫描线轴X
  749. public Rectangle GetPictureBoxZoomSize(PictureBox p_PictureBox)
  750. {
  751. if (p_PictureBox != null)
  752. {
  753. PropertyInfo _ImageRectanglePropert = p_PictureBox.GetType().GetProperty("ImageRectangle", BindingFlags.Instance | BindingFlags.NonPublic);
  754. return (Rectangle)_ImageRectanglePropert.GetValue(p_PictureBox, null);
  755. }
  756. return new Rectangle(0, 0, 0, 0);
  757. }
  758. #endregion
  759. private void OTSMeasureStatusWindow_Load(object sender, EventArgs e)
  760. {
  761. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OTSMeasureStatusWindow));
  762. this.control_XRayTable1 = new Control_XRayTable();
  763. this.control_XRayTable1.BackColor = System.Drawing.Color.FromArgb(180, 255, 255);
  764. this.control_XRayTable1.Dock = System.Windows.Forms.DockStyle.Fill;
  765. this.control_XRayTable1.GBInfoStr = "";
  766. this.control_XRayTable1.GoodChineseName = "";
  767. this.control_XRayTable1.GoodName = "";
  768. this.control_XRayTable1.List_ShowElementInfo = ((System.Collections.Generic.List<OTSIncAGraph.Controls.ShowElementInfo>)(resources.GetObject("control_XRayTable1.List_ShowElementInfo")));
  769. this.control_XRayTable1.Location = new System.Drawing.Point(0, 0);
  770. this.control_XRayTable1.Margin = new System.Windows.Forms.Padding(2);
  771. this.control_XRayTable1.Name = "control_XRayTable1";
  772. this.control_XRayTable1.ShowAnalysisXray = true;
  773. this.control_XRayTable1.ShowSearchXray = false;
  774. this.control_XRayTable1.Size = new System.Drawing.Size(781, 200);
  775. this.control_XRayTable1.STDName = "";
  776. this.control_XRayTable1.TabIndex = 0;
  777. this.control_XRayTable1 = new OTSIncAGraph.Controls.Control_XRayTable();
  778. this.panelXray.Controls.Add(this.control_XRayTable1);
  779. //添加鼠标点击事件
  780. myChart.MouseClick += new MouseEventHandler(this.LZMeasureStatusWindow_MouseClick);
  781. pbBSEImage.MouseClick += new MouseEventHandler(HiddenXrayTablePanel_MouseClick);
  782. //
  783. // pbBSEImage添加鼠标操作
  784. //
  785. this.pbBSEImage.MouseUp += new MouseEventHandler(this.pbBSEImage_MouseUp);
  786. this.pbBSEImage.MouseDown += new MouseEventHandler(this.pbBSEImage_MouseDown);
  787. this.MouseUp += new MouseEventHandler(this.pbBSEImage_MouseUp);
  788. this.MouseDown += new MouseEventHandler(this.pbBSEImage_MouseDown);
  789. this.MouseWheel += new MouseEventHandler(this.pbBSEImage_MouseWheel);
  790. log = NLog.LogManager.GetCurrentClassLogger();
  791. }
  792. private void HiddenXrayTablePanel_MouseClick(object sender, MouseEventArgs e)
  793. {
  794. if (e.Button != MouseButtons.Right)
  795. {
  796. if (!IsShowGrayLevelLine)
  797. {
  798. if (m_ElementPointGDIObjects != null)
  799. {
  800. if (m_ElementPointGDIObjects.Count > 0)
  801. {
  802. foreach (var item in m_ElementPointGDIObjects)
  803. {
  804. //Rectangle rect = new Rectangle(e.Location, new Size(1, 1));
  805. if (Math.Abs(e.Y - item.GetOrigionalDrawRegionF().Y) < 5 && Math.Abs(e.X - item.GetOrigionalDrawRegionF().X) < 5)
  806. {
  807. //显示Xray图像
  808. panelXray.Visible = true;
  809. }
  810. else
  811. {
  812. panelXray.Visible = false;
  813. }
  814. }
  815. }
  816. }
  817. }
  818. }
  819. }
  820. private void LZMeasureStatusWindow_MouseClick(object sender, MouseEventArgs e)
  821. {
  822. try
  823. {
  824. if (e.Button == MouseButtons.Right && e.Clicks == 1)
  825. {
  826. contextMenuStrip1.Show(PointToScreen(e.Location));
  827. SetContentMenu();
  828. }
  829. }
  830. catch (Exception ex)
  831. {
  832. log.Error("(LZMeasureStatusWindow.LZMeasureStatusWindow_MouseClick) " + ex.ToString());
  833. }
  834. }
  835. #region 设置右键菜单中的项 是否可编辑
  836. protected void SetContextMenuEnabled(bool isEnabled)
  837. {
  838. //隐藏右键菜单中的项
  839. MenuItemLineScam.Checked = false;
  840. MenuItemLineScam.Enabled = isEnabled;
  841. PointScanElementMenuItem.Enabled = isEnabled;
  842. bool showExprot = m_ElementPointGDIObjects.Count > 0 ? true : false;
  843. ExportScanInfoMenuItem.Enabled = showExprot;
  844. IsShowGrayLevelLine = false;
  845. ViewStripMenuItem.Enabled = isEnabled;
  846. toolStripMenuItem1.Enabled = true;
  847. this.Cursor = Cursors.Default;
  848. this.Validate();
  849. }
  850. #endregion
  851. #region 获取行数据
  852. private void GetLineImage(int iHeight, int iWidth, ref byte[] bdata)
  853. {
  854. try
  855. {
  856. Stream stream = null;
  857. if (m_IsShowImageType == ImageType.BSEImage)
  858. {
  859. stream = new MemoryStream(originalBseData);
  860. }
  861. else if (m_IsShowImageType == ImageType.RemoveBGImage)
  862. {
  863. stream = new MemoryStream(removeBGBseData);
  864. }
  865. if (iHeight >= 0)
  866. {
  867. stream.Seek(iHeight * iWidth, SeekOrigin.Begin);
  868. }
  869. stream.Read(bdata, 0, iWidth);
  870. }
  871. catch (Exception ex)
  872. {
  873. log.Error("(LZMeasureStatusWindow.GetLineImage) " + ex.ToString());
  874. }
  875. }
  876. #endregion
  877. private void panel1_Click(object sender, EventArgs e)
  878. {
  879. pbBSEImage.Show();
  880. }
  881. private void contextMenuStrip1_Opened(object sender, EventArgs e)
  882. {
  883. try
  884. {
  885. if (bfResult)
  886. {
  887. SampleParaLock.Enabled = true;
  888. ToolStripMenuItem.Enabled = true;
  889. grayToolStripMenuItem.Enabled = true;
  890. AbandonGrayStripMenuItem.Enabled = true;
  891. if (0 <= m_MouseMoveImageX && m_MouseMoveImageX <= 1024)
  892. {
  893. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = true;
  894. }
  895. else
  896. {
  897. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = false;
  898. }
  899. if (!MenuItemLineScam.Checked)
  900. {
  901. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = true;
  902. bool showExprot = m_ElementPointGDIObjects.Count > 0 ? true : false;
  903. if (showExprot)
  904. {
  905. contextMenuStrip1.Items[(int)MeasureStateMenuType.ExportReport].Enabled = true;
  906. }
  907. }
  908. else
  909. {
  910. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = false;
  911. contextMenuStrip1.Items[(int)MeasureStateMenuType.ExportReport].Enabled = false;
  912. return;
  913. }
  914. if (myChart.Visible)
  915. {
  916. MenuItemLineScam.Enabled = false;
  917. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = false;
  918. contextMenuStrip1.Items[(int)MeasureStateMenuType.ExportReport].Enabled = false;
  919. }
  920. else
  921. {
  922. MenuItemLineScam.Enabled = true;
  923. contextMenuStrip1.Items[(int)MeasureStateMenuType.PointScanElementMenuItem].Enabled = true;
  924. bool showExprot = m_ElementPointGDIObjects.Count > 0 ? true : false;
  925. if (showExprot)
  926. {
  927. contextMenuStrip1.Items[(int)MeasureStateMenuType.ExportReport].Enabled = true;
  928. }
  929. }
  930. //根据去背景方式 设置可视化使用状态
  931. COTSSample WSample = m_MeasureAppForm.m_ProjData.GetWorkingSample();
  932. COTSImageProcParam ImgProcPrm = WSample.GetMsrParams().GetImageProcessParam();
  933. if (ImgProcPrm.GetBGRemoveType() == otsdataconst.OTS_BGREMOVE_TYPE.MANUAL)
  934. {
  935. contextMenuStrip1.Items[(int)MeasureStateMenuType.SetVisualGray].Enabled = true;
  936. }
  937. else
  938. {
  939. contextMenuStrip1.Items[(int)MeasureStateMenuType.SetVisualGray].Enabled = false;
  940. }
  941. }
  942. else
  943. {
  944. ToolStripMenuItem.Enabled = false;
  945. grayToolStripMenuItem.Enabled = false;
  946. MenuItemLineScam.Enabled = false;
  947. AbandonGrayStripMenuItem.Enabled = false;
  948. }
  949. }
  950. catch (Exception ex)
  951. {
  952. log.Error("(LZMeasureStatusWindow.contextMenuStrip1_Opened) " + ex.ToString());
  953. }
  954. }
  955. //拖动灰度线
  956. #region 拖动灰度线
  957. int LineX = 0;
  958. int LineXEnd = 0;
  959. public Point pointStart = new Point(100, 100);
  960. public Point pointEnd = new Point(400, 100);
  961. private bool m_bMouseDown = false;
  962. private void pictureBox1_Paint(object sender, PaintEventArgs e)
  963. {
  964. try
  965. {
  966. if (bfResult)
  967. {
  968. if (MenuItemLineScam.Checked)
  969. {
  970. IsShowGrayLevelLine = true;
  971. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  972. if (pointStart.Equals(pointEnd))
  973. {
  974. return;
  975. }
  976. Point start = new Point(100, pointStart.Y);
  977. Point end = new Point(500, pointEnd.Y);
  978. int lens = curvebuf.Length;
  979. if (lens <= 1)
  980. {
  981. drawflag = 0;
  982. MessageBox.Show(table["message22"].ToString(), table["message23"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  983. }
  984. else
  985. {
  986. drawflag = 1;
  987. //Y值
  988. double rate = (double)pbBSEImage.Image.Height / (double)rectangle.Height;
  989. int YSize = Convert.ToInt32((rate * (double)pointStart.Y));
  990. //显示线扫描 黄色线的曲线数据
  991. GetLineImage(YSize, m_iWidth, ref Imagedata);
  992. DrawCurve(Imagedata, e);
  993. }
  994. e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + (rectangle.Height) / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + (rectangle.Height) / 4));
  995. e.Graphics.DrawLine(new Pen(Color.Red), new Point(rectangle.X, rectangle.Y + rectangle.Height * 3 / 4), new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height * 3 / 4));
  996. e.Graphics.DrawLine(new Pen(Color.Blue), new Point(rectangle.X, pointStart.Y), new Point(rectangle.X + rectangle.Width, pointEnd.Y));
  997. #region 绘制刻度条
  998. float offHeight = (rectangle.Y + (rectangle.Height) / 4) - (rectangle.Y + rectangle.Height * 3 / 4);
  999. float grayValue = Math.Abs(offHeight / 255);
  1000. //设置文字对齐方式
  1001. StringFormat sf = new StringFormat();
  1002. sf.Alignment = StringAlignment.Center;
  1003. sf.LineAlignment = StringAlignment.Center;
  1004. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(100, Color.Red));
  1005. //字体大小 根据样品孔Rectangle大小
  1006. float fontSize = 15;
  1007. Font font = new Font("黑体", fontSize, FontStyle.Bold);
  1008. Pen pen = new Pen(Color.Red, 1);
  1009. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
  1010. pen.DashPattern = new float[] { 5, 5 };
  1011. int fontOffWidth = 50;
  1012. int fontOffHeight = 10;
  1013. int scaleLine = 0;
  1014. for (int i = 25; i <= 225; i += 25)
  1015. {
  1016. scaleLine = (int)(grayValue * i);
  1017. e.Graphics.DrawLine(pen, new Point(rectangle.X, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine), new Point(rectangle.X + fontOffWidth, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine));
  1018. e.Graphics.DrawString(i.ToString(), font, solidBrush, rectangle.X + 20, (rectangle.Y + rectangle.Height * 3 / 4) - scaleLine - fontOffHeight, sf);
  1019. }
  1020. #endregion
  1021. }
  1022. else
  1023. {
  1024. IsShowGrayLevelLine = false;
  1025. }
  1026. }
  1027. if (!MenuItemLineScam.Checked)
  1028. {
  1029. if (m_ElementPointGDIObjects != null)
  1030. {
  1031. if (m_ElementPointGDIObjects.Count > 0)
  1032. {
  1033. //绘制采集点标记
  1034. foreach (CRectangleGDIObject item in m_ElementPointGDIObjects)
  1035. {
  1036. if (item != null)
  1037. {
  1038. item.OnPaint(e);
  1039. }
  1040. }
  1041. }
  1042. }
  1043. }
  1044. }
  1045. catch (Exception ex)
  1046. {
  1047. log.Error("(LZMeasureStatusWindow.pictureBox1_Paint) " + ex.ToString());
  1048. }
  1049. }
  1050. private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
  1051. {
  1052. try
  1053. {
  1054. //如果pictureBox1中没有图像 则return退出
  1055. if (pbBSEImage.Image == null)
  1056. {
  1057. return;
  1058. }
  1059. Control lCtrl = (sender as Control);
  1060. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  1061. int startimageX = 0;
  1062. int startimageY = 0;
  1063. //处理灰度值
  1064. int grayValue = 0;
  1065. // 生成鼠标的位置
  1066. int MouseLine = e.X;
  1067. //当前鼠标所在图片中的位置
  1068. int imageX = 0;
  1069. int imageY = 0;
  1070. //当前pictrueBox与实际图片的X、Y比例
  1071. double rateX = 0;
  1072. double rateY = 0;
  1073. if (originalBseData != null)
  1074. {
  1075. if ((pbBSEImage.Width - rectangle.Width) / 2 < e.X && e.X < (pbBSEImage.Width - rectangle.Width) / 2 + rectangle.Width)
  1076. {
  1077. imageX = e.X - (pbBSEImage.Width - rectangle.Width) / 2;
  1078. rateX = (double)m_iWidth / (double)rectangle.Width;
  1079. startimageX = Convert.ToInt32(imageX * rateX);
  1080. m_MouseMoveImageX = startimageX;
  1081. if (MoveFlag)
  1082. {
  1083. pbBSEImage.Left += Convert.ToInt32(e.X - xPos);//设置x坐标.
  1084. pbBSEImage.Top += Convert.ToInt32(e.Y - yPos);//设置y坐标.
  1085. }
  1086. }
  1087. else
  1088. {
  1089. startimageX = 0;
  1090. m_MouseMoveImageX = -1;
  1091. }
  1092. if ((pbBSEImage.Height - rectangle.Height) / 2 < e.Y && e.Y < (pbBSEImage.Height - rectangle.Height) / 2 + rectangle.Height)
  1093. {
  1094. imageY = e.Y - (pbBSEImage.Height - rectangle.Height) / 2;
  1095. rateY = (double)m_iHeight / (double)rectangle.Height;
  1096. startimageY = Convert.ToInt32(imageY * rateY);
  1097. m_MouseMoveImageY = startimageY;
  1098. }
  1099. //如果当前鼠标在图像Y轴中
  1100. if (imageX > 0 && imageY > 0)
  1101. {
  1102. if (imageY > 1)
  1103. {
  1104. startimageX = startimageX + (startimageY * m_iWidth);
  1105. if (m_IsShowImageType == ImageType.BSEImage)
  1106. {
  1107. grayValue = originalBseData[startimageX];
  1108. }
  1109. else
  1110. {
  1111. grayValue = removeBGBseData[startimageX];
  1112. }
  1113. }
  1114. else if (startimageY == 1)
  1115. {
  1116. if (m_IsShowImageType == ImageType.BSEImage)
  1117. {
  1118. grayValue = originalBseData[startimageX];
  1119. }
  1120. else
  1121. {
  1122. grayValue = removeBGBseData[startimageX];
  1123. }
  1124. }
  1125. }
  1126. else
  1127. {
  1128. grayValue = 0;
  1129. }
  1130. }
  1131. LineX = rectangle.X + 1;
  1132. LineXEnd = rectangle.X + rectangle.Width;
  1133. if (LineX < MouseLine && MouseLine < LineXEnd)
  1134. {
  1135. if (MenuItemLineScam.Checked)
  1136. {
  1137. if (Math.Abs(e.Y - pointStart.Y) < 2)
  1138. {
  1139. this.Cursor = Cursors.SizeNS;
  1140. }
  1141. else
  1142. {
  1143. this.Cursor = Cursors.Default;
  1144. }
  1145. }
  1146. }
  1147. //Y值
  1148. double rate = (double)pbBSEImage.Image.Height / (double)rectangle.Height;
  1149. int YSize = Convert.ToInt32((rate * (double)e.Y));
  1150. //显示线扫描 黄色线的曲线数据
  1151. GetLineImage(YSize, m_iWidth, ref Imagedata);
  1152. string strGrayValue = grayValue.ToString();
  1153. switch (strGrayValue.ToString().Length)
  1154. {
  1155. case 1:
  1156. strGrayValue = " " + grayValue.ToString();
  1157. break;
  1158. case 2:
  1159. strGrayValue = " " + grayValue.ToString();
  1160. break;
  1161. }
  1162. //此处调接口显示灰度值
  1163. m_MeasureAppForm.ShowGrayVal(strGrayValue.ToString());
  1164. if (!IsShowGrayLevelLine)
  1165. {
  1166. if (m_ElementPointGDIObjects != null)
  1167. {
  1168. if (m_ElementPointGDIObjects.Count > 0)
  1169. {
  1170. foreach (var item in m_ElementPointGDIObjects)
  1171. {
  1172. Rectangle rect = new Rectangle(e.Location, new Size(1, 1));
  1173. if (Math.Abs(e.Y - item.GetOrigionalDrawRegionF().Y) < 5 && Math.Abs(e.X - item.GetOrigionalDrawRegionF().X) < 5)
  1174. {
  1175. //设置鼠标样式
  1176. this.Cursor = Cursors.Hand;
  1177. }
  1178. else
  1179. {
  1180. this.Cursor = Cursors.Default;
  1181. }
  1182. }
  1183. }
  1184. }
  1185. }
  1186. if (e.Button != MouseButtons.Left)
  1187. {
  1188. return;
  1189. }
  1190. pointStart = new Point(pointStart.X, e.Y);
  1191. pointEnd = new Point(pointEnd.X, e.Y);
  1192. pbBSEImage.Refresh();
  1193. }
  1194. catch (Exception ex)
  1195. {
  1196. log.Error("(LZMeasureStatusWindow.pictureBox1_MouseMove) " + ex.ToString());
  1197. }
  1198. }
  1199. private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
  1200. {
  1201. try
  1202. {
  1203. m_mouseCurrentPoint = e.Location;
  1204. if (e.Button != MouseButtons.Left)
  1205. {
  1206. return;
  1207. }
  1208. m_bMouseDown = !m_bMouseDown;
  1209. }
  1210. catch (Exception ex)
  1211. {
  1212. log.Error("(LZMeasureStatusWindow.pictureBox1_MouseDown) " + ex.ToString());
  1213. }
  1214. }
  1215. #endregion
  1216. //显示去背景BSE图得灰度曲线值
  1217. #region 显示去背景BSE图得灰度曲线值
  1218. private void ShowAbandonGrayLevelImage_Click(object sender, EventArgs e)
  1219. {
  1220. //设置右键菜单中的项 是否可编辑
  1221. SetContextMenuEnabled(false);
  1222. ShowAbandonGrayLevelImage();
  1223. myChart.Visible = true;
  1224. panelXray.Visible = false;
  1225. IsShowGrayLevelLine = false;
  1226. }
  1227. private double[] GetGrayAbandonData(byte[] Imagedata, double[] GrayAbandonLevelData)
  1228. {
  1229. try
  1230. {
  1231. //获得下标每一点的灰度值,并在数组里加一
  1232. for (int i = 0; i < Imagedata.Length; i++)
  1233. {
  1234. byte graylevel = Imagedata[i];
  1235. if (graylevel > 0 && graylevel < 255)
  1236. {
  1237. GrayAbandonLevelData[graylevel] += 1;
  1238. }
  1239. }
  1240. return GrayAbandonLevelData;
  1241. }
  1242. catch (Exception ex)
  1243. {
  1244. log.Error(ex.ToString());
  1245. return null;
  1246. }
  1247. }
  1248. protected void ShowAbandonGrayLevelImage()
  1249. {
  1250. try
  1251. {
  1252. m_imagetype = ImageType.GrayAbandonLevelChart;
  1253. COTSSample WSample = m_MeasureAppForm.m_ProjData.GetWorkingSample();
  1254. var pixelSize = WSample.CalculatePixelSize();
  1255. var imageHandle = new CImageHandler();
  1256. bfResult = imageHandle.GetBSEImage(WSample.GetMsrParams().GetImageProcessParam(), pixelSize, originalBseData, m_iWidth, m_iHeight, ref removeBGBseData);
  1257. if (bfResult)
  1258. {
  1259. dGrayAbandonLevelData = new double[(int)GrayLevel.Max];
  1260. GetGrayAbandonData(removeBGBseData, dGrayAbandonLevelData);
  1261. //计算灰度去背景最大值
  1262. dGrayAbandonLevelMax = dGrayAbandonLevelData[0];
  1263. for (int i = 0; i < (int)GrayLevel.Max; i++)
  1264. {
  1265. dGrayAbandonLevelMax = Math.Max(dGrayAbandonLevelMax, dGrayAbandonLevelData[i]);
  1266. }
  1267. }
  1268. pbBSEImage.Hide();
  1269. //切换显示至BSE图
  1270. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  1271. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  1272. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1273. {
  1274. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
  1275. }
  1276. else
  1277. {
  1278. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
  1279. }
  1280. UpdateImageOrChart(m_imagetype);
  1281. int[] XData = new int[(int)GrayLevel.Max];
  1282. for (int i = 0; i < (int)GrayLevel.Max; i++)
  1283. {
  1284. XData[i] = i + 1;
  1285. }
  1286. int[] YData = new int[dGrayAbandonLevelData.Length];
  1287. for (int i = 0; i < dGrayAbandonLevelData.Length; i++)
  1288. {
  1289. YData[i] = (int)dGrayAbandonLevelData[i];
  1290. }
  1291. chartData(XData, YData);
  1292. }
  1293. catch (Exception ex)
  1294. {
  1295. log.Error("(LZMeasureStatusWindow.ShowAbandonGrayLevelImage_Click) " + ex.ToString());
  1296. }
  1297. }
  1298. #endregion
  1299. private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
  1300. {
  1301. try
  1302. {
  1303. if (e.Button == MouseButtons.Right && e.Clicks == 1)
  1304. {
  1305. int XMenu = pbBSEImage.Left + e.Location.X;
  1306. int YMenu = pbBSEImage.Top + e.Location.Y;
  1307. Point mousePoint = new Point(XMenu, YMenu);
  1308. contextMenuStrip1.Show(PointToScreen(mousePoint));
  1309. //电镜位置信息
  1310. Point semLocatin = new Point((int)dPositionX, (int)dPositionY);
  1311. //Rectangle semRect = new Rectangle();
  1312. if (IsSEMLocationOnTheSampleStage(semLocatin))
  1313. {
  1314. SetContentMenu();
  1315. }
  1316. }
  1317. }
  1318. catch (Exception ex)
  1319. {
  1320. log.Error("(MeasureStatusWindow.pictureBox1_MouseClick) " + ex.ToString());
  1321. }
  1322. }
  1323. private void ChangeDiffImageShow_Click(object sender, EventArgs e)
  1324. {
  1325. //设置右键菜单中的项 是否可编辑
  1326. SetContextMenuEnabled(true);
  1327. //显示切换至BSE图
  1328. if (contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text == "切换显示至BSE图" || contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text == "SwitchDisplayToBSEDiagram")
  1329. {
  1330. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  1331. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1332. {
  1333. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE去背景图";
  1334. }
  1335. else
  1336. {
  1337. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEBackgroundImage";
  1338. }
  1339. //显示BSE图
  1340. if (originalBseData != null)
  1341. {
  1342. //用于线扫描曲线
  1343. m_IsShowImageType = ImageType.BSEImage;
  1344. m_imagetype = ImageType.BSEImage;
  1345. //在控件中显示图像
  1346. ShowImage(m_iWidth, m_iHeight, originalBseData);
  1347. pbBSEImage.Show();
  1348. //panel1.Visible = false;
  1349. }
  1350. }
  1351. else if (contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text == "切换显示至BSE去背景图" || contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text == "SwitchDisplayToBSEBackgroundImage")
  1352. {
  1353. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Enabled = true;
  1354. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1355. {
  1356. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "切换显示至BSE图";
  1357. }
  1358. else
  1359. {
  1360. contextMenuStrip1.Items[(int)MeasureStateMenuType.ChangeDiffImageShow].Text = "SwitchDisplayToBSEDiagram";
  1361. }
  1362. //显示去背景BSE图
  1363. if (originalBseData != null)
  1364. {
  1365. //用于线扫描曲线
  1366. m_IsShowImageType = ImageType.RemoveBGImage;
  1367. m_imagetype = ImageType.RemoveBGImage;
  1368. ShowImage(m_iWidth, m_iHeight, removeBGBseData);
  1369. pbBSEImage.Show();
  1370. }
  1371. }
  1372. myChart.Visible = false;
  1373. UpdateImageOrChart(m_imagetype);
  1374. GetLineImage(YSize, m_iWidth, ref Imagedata);
  1375. m_CurrentMultiple = 0;
  1376. panelXray.Visible = false;
  1377. }
  1378. #region 显示鼠标位置
  1379. /// <summary>
  1380. /// 显示鼠标位置
  1381. /// </summary>
  1382. /// <param name="eMouseLocation">当前处理后的鼠标路径 减去边缘</param>
  1383. /// <param name="imageRect">Pictrue中的图像尺寸与位置</param>
  1384. public void ShowMouseSEMCurrentLocation(Point eMouseLocation, Rectangle imageRect, Rectangle semRect)
  1385. {
  1386. //真实图像中心点
  1387. Point imgRealCenterPoint = new Point();
  1388. //显示图像中心点
  1389. Point imgCenterPoint = new Point();
  1390. int imgWidth = 0;
  1391. int imgHeight = 0;
  1392. //获取真实图片的分辨率
  1393. m_MeasureAppForm.m_ProjParam.GetBSEImageSize(ref imgWidth, ref imgHeight);
  1394. //根据真实图像的像素 获取真实图像中心点
  1395. imgRealCenterPoint.X = imgWidth / 2;
  1396. imgRealCenterPoint.Y = imgHeight / 2;
  1397. //图像与真是图像的宽高的比例
  1398. double witdhRote = 0;
  1399. double heightRote = 0;
  1400. //获取显示图像与真是图像的宽高的比例
  1401. witdhRote = (double)imageRect.Width / imgWidth;
  1402. heightRote = (double)imageRect.Height / imgHeight;
  1403. //获取每个单位中包含多少像素 根据帧图的长度 与 真实图像的长度计算
  1404. double lenghtInPixWidth = (double)FieldWitdh / imgWidth / witdhRote;
  1405. double lenghtInPixHeight = (double)FieldHeight / imgHeight / heightRote;
  1406. //通过鼠标当前位置 获取位置 原点为控件的左上角起始点
  1407. double MouseWidth = (double)eMouseLocation.X * lenghtInPixWidth;
  1408. double MouseHeight = (double)eMouseLocation.Y * lenghtInPixHeight;
  1409. //根据显示图像的像素 获取真实图像中心点
  1410. imgCenterPoint.X = imageRect.Width / 2;
  1411. imgCenterPoint.Y = imageRect.Height / 2;
  1412. //通过鼠标当前位置 获取位置 原点为控件的左上角起始点
  1413. double imgCenterWidth = (double)imgCenterPoint.X * lenghtInPixWidth;
  1414. double imgCenterHeight = (double)imgCenterPoint.Y * lenghtInPixHeight;
  1415. //获取当前鼠标坐标与SEM当前坐标的距离 单位毫米
  1416. double apartCenterPointWidth = MouseWidth - imgCenterWidth;
  1417. double apartCenterPointHeight = MouseHeight - imgCenterHeight;
  1418. //将微米转换为毫米
  1419. float mousePointX = Convert.ToSingle((apartCenterPointWidth / 1000).ToString("F3"));
  1420. float mousePointY = Convert.ToSingle((apartCenterPointHeight / 1000).ToString("F3"));
  1421. //根据Sem电镜当前位置 计算与SEM坐标起始点相差的距离
  1422. //1.获取电镜当前位置
  1423. double semX = dPositionX;
  1424. double semY = dPositionY;
  1425. //2.获取当前电镜位置与SEM原点位置的距离
  1426. string apartToSEMWidth = Convert.ToSingle(semX + mousePointX).ToString("F3");
  1427. string apartToSEMHeight = Convert.ToSingle(semY - mousePointY).ToString("F3");
  1428. //编辑显示内容
  1429. string STSemCoordinate = "X:" + apartToSEMWidth + "|Y:" + apartToSEMHeight + "";
  1430. }
  1431. #endregion
  1432. #region 设置测量状态初始化
  1433. /// <summary>
  1434. /// 设置测量状态初始化
  1435. /// </summary>
  1436. public void SetMeasureStatusInit()
  1437. {
  1438. pbBSEImage.Hide();
  1439. foreach (ToolStripItem item in contextMenuStrip1.Items)
  1440. {
  1441. if (item != contextMenuStrip1.Items[(int)MeasureStateMenuType.ReadBSEPic])
  1442. {
  1443. item.Enabled = false;
  1444. }
  1445. }
  1446. }
  1447. #endregion
  1448. #region 获取SEM当前位置
  1449. public void GetSEMLocation(ref double dPositionX, ref double dPositionY, ref double dPositionR)
  1450. {
  1451. try
  1452. {
  1453. COTSControlFunExport cfun = COTSControlFunExport.GetControllerInstance();
  1454. //获取SEM当前位置
  1455. cfun.GetSemPositionXY(ref dPositionX, ref dPositionY, ref dPositionR);
  1456. //m_ImageData.GetSemPositionXY(ref dPositionX, ref dPositionY, ref dPositionR);
  1457. }
  1458. catch (Exception ex)
  1459. {
  1460. MessageBox.Show(table["message24"].ToString() + ex.ToString());
  1461. }
  1462. }
  1463. #endregion
  1464. #region 鼠标是否在图像上移动
  1465. /// <summary>
  1466. /// 鼠标是否在图像上移动
  1467. /// </summary>
  1468. /// <param name="mouseCurrentLocation"></param>
  1469. /// <param name="picBox"></param>
  1470. /// <returns></returns>
  1471. public bool IsOnTheImage(Point mouseCurrentLocation, PictureBox picBox, ref Point mouseLocation, ref Rectangle imageRect)
  1472. {
  1473. //通过Pictrue获取图像尺寸位置
  1474. Rectangle rectangle = GetPictureBoxZoomSize(picBox);
  1475. imageRect = rectangle;
  1476. //当前鼠标坐标是否包含在图像中
  1477. bool result = imageRect.Contains(mouseCurrentLocation);
  1478. if (result)
  1479. {
  1480. //获取与边框的间隔
  1481. mouseLocation.X = mouseCurrentLocation.X - rectangle.X;
  1482. mouseLocation.Y = mouseCurrentLocation.Y;
  1483. return true;
  1484. }
  1485. return false;
  1486. }
  1487. #endregion
  1488. #region 判断当前电镜位置是否在样品台内部
  1489. /// <summary>
  1490. /// 判断当前电镜位置是否在样品台内部
  1491. /// </summary>
  1492. /// <param name="semLocation">电镜当前位置</param>
  1493. /// <param name="SampleStage">样品台尺寸与位置</param>
  1494. /// <returns></returns>
  1495. public bool IsSEMLocationOnTheSampleStage(Point semLocation)
  1496. {
  1497. return m_MeasureAppForm.m_SamplepaceWindow.m_visualStage.IfMouseInStage(semLocation);
  1498. }
  1499. #endregion
  1500. #region 设置右键菜单项是否可用
  1501. /// <summary>
  1502. /// 设置右键菜单项是否可用
  1503. /// </summary>
  1504. public void SetContentMenu()
  1505. {
  1506. int sampleCount = m_MeasureAppForm.m_ProjParam.GetSampleCount();
  1507. if (sampleCount == 0)
  1508. {
  1509. foreach (ToolStripItem item in contextMenuStrip1.Items)
  1510. {
  1511. item.Enabled = false;
  1512. }
  1513. }
  1514. else
  1515. {
  1516. if (m_MeasureAppForm.MeasureThreadRunFlag)
  1517. {
  1518. if (m_MeasureAppForm.m_MsrThreadWrapper.BgWorkIsPaused())
  1519. {
  1520. foreach (ToolStripItem item in contextMenuStrip1.Items)
  1521. {
  1522. item.Enabled = true;
  1523. }
  1524. }
  1525. else
  1526. {
  1527. foreach (ToolStripItem item in contextMenuStrip1.Items)
  1528. {
  1529. item.Enabled = false;
  1530. }
  1531. }
  1532. }
  1533. double iWDistance = 0;
  1534. double dMagni = 0;
  1535. m_MeasureAppForm.m_ProjParam.GetWorkingSampleSEMData(ref iWDistance, ref dMagni);
  1536. if (iWDistance != 0 && dMagni != 0)
  1537. {
  1538. contextMenuStrip1.Items[(int)MeasureStateMenuType.ReadBSEPic].Enabled = true;
  1539. }
  1540. }
  1541. }
  1542. #endregion
  1543. #region 获取线扫描初始位置
  1544. public void GetYSize()
  1545. {
  1546. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  1547. double rate = (double)pbBSEImage.Image.Height / (double)rectangle.Height;
  1548. YSize = Convert.ToInt32((rate * (double)pointStart.Y));
  1549. }
  1550. #endregion
  1551. public void chartData(int[] XData, int[] YData)
  1552. {
  1553. //添加数据
  1554. myChart.Series[0].Points.DataBindXY(XData, YData);
  1555. myChart.Series[0].Label = "";
  1556. myChart.Series[0].LegendText = "";
  1557. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1558. {
  1559. myChart.Series[0].Name = "曲线图";
  1560. }
  1561. else
  1562. {
  1563. myChart.Series[0].Name = "Graph";
  1564. }
  1565. myChart.Series[0].IsVisibleInLegend = false;
  1566. switch (m_imagetype)
  1567. {
  1568. case ImageType.GrayLevelChart:
  1569. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1570. {
  1571. myChart.Titles[0].Text = "灰度曲线图";
  1572. }
  1573. else
  1574. {
  1575. myChart.Titles[0].Text = "B-GrayCurve";
  1576. }
  1577. break;
  1578. case ImageType.GrayAbandonLevelChart:
  1579. if (OTSCommon.Language.ReadDefaultLanguage() == "ZH")
  1580. {
  1581. myChart.Titles[0].Text = "去背景灰度曲线图";
  1582. }
  1583. else
  1584. {
  1585. myChart.Titles[0].Text = "Background-freeGray-scaleCurve";
  1586. }
  1587. break;
  1588. default:
  1589. myChart.Titles[0].Text = "";
  1590. break;
  1591. }
  1592. }
  1593. private void PointScanElementMenuItem_Click(object sender, EventArgs e)
  1594. {
  1595. MenuItemLineScam.Checked = false;
  1596. //电镜设置对象
  1597. //控制类对象初始化
  1598. EDSController m_EDSHardwareMgr = EDSController.GetEDSController();
  1599. //1.连接电镜
  1600. if (m_EDSHardwareMgr.Connect())
  1601. {
  1602. bool initResult = false;
  1603. //线程调用 加载
  1604. initResult = m_EDSHardwareMgr.Init();
  1605. if (initResult)
  1606. {
  1607. COTSMsrPrjResultData cProjMgr = m_MeasureAppForm.m_ProjParam.GetResultData();
  1608. //获取工作样品对象
  1609. COTSSample sampleClr = cProjMgr.GetWorkingSample();
  1610. //清空之前记录的标识
  1611. if (m_ElementPointGDIObjects != null)
  1612. {
  1613. if (m_ElementPointGDIObjects.Count > 0)
  1614. {
  1615. //清空
  1616. m_ElementPointGDIObjects.Clear();
  1617. }
  1618. }
  1619. //2.获取鼠标在图像的位置
  1620. dMouseImgX = m_MouseMoveImageX;
  1621. dMouseImgY = m_MouseMoveImageY;
  1622. //3.根据所要扫描的位置进行元素分析
  1623. uint a_Milliseconds = 0;
  1624. //采集时间
  1625. a_Milliseconds = Convert.ToUInt32(sampleClr.GetMsrParams().GetXRayParam().GetMidAnalyAQTime());
  1626. //元素数量
  1627. ValueType a_nElementNum = 0;
  1628. //元素名称
  1629. string a_strElementName = "";
  1630. //元素Xray数据
  1631. uint[] a_ElementXrayData = new uint[2000];
  1632. //设置分辨率
  1633. m_EDSHardwareMgr.SetResolution(m_iWidth, m_iHeight);
  1634. //设置期望计数率
  1635. m_EDSHardwareMgr.SetAnalyExpCount(m_MeasureAppForm.m_ProjData.GetWorkingSample().GetMsrParams().GetXRayParam().GetAnalyExpCount());
  1636. if (m_EDSHardwareMgr.GetXRayAndElements(a_Milliseconds, (int)dMouseImgX, (int)dMouseImgY, ref a_ElementXrayData, ref a_nElementNum, ref a_strElementName))
  1637. {
  1638. log.Trace("--获取单点扫描数据:元素数量:'" + a_nElementNum + "' ,元素名称:'" + a_strElementName + "'--");
  1639. //4.在BSE上绘制扫描标记
  1640. //4-1 获取鼠标在BSE图上的位置
  1641. Point p_mouseCurrentTempPoint = m_mouseCurrentPoint;
  1642. //4-2 根据位置绘制标记
  1643. Point ImgPoint = new Point((int)dMouseImgX, (int)dMouseImgY);
  1644. Rectangle rect = new Rectangle(p_mouseCurrentTempPoint, new Size(1, 1));
  1645. CRectangleGDIObject createRect = new CRectangleGDIObject(rect, ImgPoint, m_CurrentMultiple, CreateRectangleType.DrawBSEElementSignPoint);
  1646. m_ElementPointGDIObjects.Add(createRect);
  1647. //5.获取成功后弹出对话框
  1648. //计数率
  1649. double electronicCount = 0;
  1650. uint[] u_ElementXrayData = new uint[2000];
  1651. for (int i = 0; i < a_ElementXrayData.Length; i++)
  1652. {
  1653. u_ElementXrayData[i] = (uint)a_ElementXrayData[i];
  1654. //累加计数率
  1655. electronicCount += a_ElementXrayData[i];
  1656. }
  1657. //显示Xray控件
  1658. panelXray.Visible = true;
  1659. //获取数据后,需要对xraytable设置
  1660. string[] strGroup = a_strElementName.Split('\n');
  1661. //get CElementChemistryClr list
  1662. List<ShowElementInfo> list_showelementinfo = new List<ShowElementInfo>();
  1663. for (int i = 0; i < strGroup.Length; i++)
  1664. {
  1665. if (!strGroup[i].Equals(""))
  1666. {
  1667. ShowElementInfo ls_sei = new ShowElementInfo();
  1668. ls_sei.ElementName = strGroup[i].Split(':')[0];
  1669. ls_sei.Percentage = Convert.ToDouble(strGroup[i].Split(':')[1]);
  1670. list_showelementinfo.Add(ls_sei);
  1671. }
  1672. }
  1673. //设置分析Xray数据
  1674. control_XRayTable1.SetXRayShowLineValue(new uint[2000], u_ElementXrayData, list_showelementinfo);
  1675. //需要显示计数率
  1676. string strElectronicCount = string.Empty;
  1677. if (electronicCount > 1000)
  1678. {
  1679. strElectronicCount = (Convert.ToDouble(electronicCount) / 1000).ToString("f2") + "kcps";
  1680. }
  1681. control_XRayTable1.List_ShowElementInfo = list_showelementinfo;
  1682. }
  1683. ExportScanInfoMenuItem.Enabled = true;
  1684. this.Invalidate();
  1685. }
  1686. }
  1687. }
  1688. public void DelElementPointGDIObjects()
  1689. {
  1690. if (m_ElementPointGDIObjects != null)
  1691. {
  1692. if (m_ElementPointGDIObjects.Count > 0)
  1693. {
  1694. //删除点标记
  1695. m_ElementPointGDIObjects.Clear();
  1696. this.Invalidate();
  1697. }
  1698. }
  1699. }
  1700. private void ExportScanInfoMenuItem_Click(object sender, EventArgs e)
  1701. {
  1702. try
  1703. {
  1704. //导出图片到报告中
  1705. ExportReport();
  1706. }
  1707. catch (Exception ex)
  1708. {
  1709. log.Error("ExportScanInfoMenuItem_Click: " + ex.ToString());
  1710. }
  1711. }
  1712. /// <summary>
  1713. /// 导出Image到报告
  1714. /// </summary>
  1715. private bool ExportReport()
  1716. {
  1717. string startupPath = System.Windows.Forms.Application.StartupPath + "\\TempReport\\";
  1718. if (!Directory.Exists(startupPath))
  1719. {
  1720. Directory.CreateDirectory(startupPath);
  1721. }
  1722. //保存Xray图片
  1723. string ImgFilePath = startupPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
  1724. Bitmap bseBM = new Bitmap(this.pbBSEImage.Width, this.pbBSEImage.Height);
  1725. this.pbBSEImage.DrawToBitmap(bseBM, new Rectangle(0, 0, this.pbBSEImage.Width, this.pbBSEImage.Height));
  1726. //保存图片
  1727. bseBM.Save(ImgFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  1728. //释放资源
  1729. bseBM.Dispose();
  1730. //保存Xray图片
  1731. string ImgXrayFilePath = startupPath + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
  1732. int xrayWidth = control_XRayTable1.Width;
  1733. int xrayHeight = control_XRayTable1.Height;
  1734. Bitmap xrayBM = new Bitmap(xrayWidth, xrayHeight);
  1735. this.control_XRayTable1.DrawToBitmap(xrayBM, new Rectangle(0, 0, xrayWidth, xrayHeight));
  1736. //保存图片
  1737. xrayBM.Save(ImgXrayFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);
  1738. //释放资源
  1739. xrayBM.Dispose();
  1740. List<string> listFilePath = new List<string>();
  1741. listFilePath.Add(ImgFilePath);
  1742. listFilePath.Add(ImgXrayFilePath);
  1743. List<ShowElementInfo> list_ElementInfo = control_XRayTable1.List_ShowElementInfo;
  1744. //1.编辑信息
  1745. DataTable dt = new DataTable();
  1746. dt.Columns.Add("元素名称");
  1747. dt.Columns.Add("原子数");
  1748. dt.Columns.Add("质量百分比");
  1749. dt.Columns.Add("摩尔比");
  1750. foreach (var item in list_ElementInfo)
  1751. {
  1752. //获取摩尔比与原子数
  1753. CElementChemistry cElementChemistry = new CElementChemistry();
  1754. cElementChemistry.SetName(item.ElementName);
  1755. cElementChemistry.SetPercentage(item.Percentage);
  1756. double molarValue = Math.Round(cElementChemistry.GetMolarPercentage(), 2);
  1757. int atomNum = (int)CElement.GetAtomicNum(item.ElementName);
  1758. DataRow dr = dt.NewRow();
  1759. dr[0] = item.ElementName;
  1760. dr[1] = atomNum;
  1761. dr[2] = item.Percentage;
  1762. dr[3] = molarValue;
  1763. dt.Rows.Add(dr);
  1764. }
  1765. DataGridView dgv = new DataGridView();
  1766. dgv.DataSource = dt.DefaultView;
  1767. List<DataTable> list_ElementData = new List<DataTable>();
  1768. list_ElementData.Add(dt);
  1769. //将数据插入Excel中
  1770. return InsertDataToExcelTable(list_ElementData, startupPath, listFilePath);
  1771. }
  1772. public bool InsertDataToExcelTable(List<System.Data.DataTable> a_list_ElementData, string a_filePath, List<string> a_ImgFilePath)
  1773. {
  1774. var m_xe = new ExcelEdit();
  1775. m_xe.Create();
  1776. Microsoft.Office.Interop.Excel.Worksheet ws = m_xe.GetSheet("Sheet1");
  1777. m_xe.m_ws = ws;
  1778. string str_ExcelFilePath = a_filePath + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
  1779. m_xe.m_ws.Shapes.AddPicture(a_ImgFilePath[0], Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0, 400, 300);
  1780. m_xe.m_ws.Shapes.AddPicture(a_ImgFilePath[1], Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 320, 400, 100);
  1781. if (str_ExcelFilePath.IndexOf(":") < 0)
  1782. {
  1783. return false;
  1784. }
  1785. if (m_xe.m_app == null)
  1786. {
  1787. return false;
  1788. }
  1789. //数据列表 行数
  1790. int dataRow = 30;
  1791. //写入标题
  1792. foreach (var dgv in a_list_ElementData)
  1793. {
  1794. for (int i = 0; i < dgv.Columns.Count; i++)
  1795. {
  1796. m_xe.m_ws.Cells[dataRow + 1, i + 1] = dgv.Columns[i].ColumnName;
  1797. }
  1798. //写入数值
  1799. for (int r = 0; r < dgv.Rows.Count; r++)
  1800. {
  1801. for (int i = 0; i < dgv.Columns.Count; i++)
  1802. {
  1803. m_xe.m_ws.Cells[dataRow + r + 2, i + 1] = dgv.Rows[r].ItemArray[i];
  1804. }
  1805. System.Windows.Forms.Application.DoEvents();
  1806. }
  1807. }
  1808. //列宽自适应
  1809. m_xe.m_ws.Columns.EntireColumn.AutoFit();
  1810. if (str_ExcelFilePath != "")
  1811. {
  1812. try
  1813. {
  1814. m_xe.m_wb.Saved = true;
  1815. m_xe.m_wb.SaveCopyAs(str_ExcelFilePath);
  1816. }
  1817. catch (Exception ex)
  1818. {
  1819. log.Error(ex.ToString());
  1820. }
  1821. }
  1822. //关闭excel
  1823. m_xe.Close();
  1824. //强行销毁
  1825. GC.Collect();
  1826. //干掉进程里的EXCEL
  1827. foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses())
  1828. {
  1829. if (p.ProcessName == "EXCEL")
  1830. {
  1831. p.Kill();
  1832. }
  1833. }
  1834. //删除图片文件
  1835. foreach (string imgPath in a_ImgFilePath)
  1836. {
  1837. if (File.Exists(imgPath))
  1838. {
  1839. //如果存在则删除
  1840. File.Delete(imgPath);
  1841. }
  1842. }
  1843. System.Diagnostics.Process.Start(str_ExcelFilePath);
  1844. return true;
  1845. }
  1846. public void HideXRayTable()
  1847. {
  1848. panelXray.Visible = false;
  1849. //清空元素标记对象
  1850. if (m_ElementPointGDIObjects != null)
  1851. {
  1852. if (m_ElementPointGDIObjects.Count > 0)
  1853. {
  1854. m_ElementPointGDIObjects.Clear();
  1855. }
  1856. }
  1857. }
  1858. //在picturebox的鼠标按下事件里,记录三个变量.
  1859. int xPos;
  1860. int yPos;
  1861. bool MoveFlag = false;
  1862. private void pbBSEImage_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  1863. {
  1864. if (e.Button == MouseButtons.Left)
  1865. {
  1866. //在线扫描未选中的情况下 设置移动标识与获取当前鼠标位置
  1867. if (!((System.Windows.Forms.ToolStripMenuItem)contextMenuStrip1.Items[(int)MeasureStateMenuType.MenuItemLineScam]).Checked)
  1868. {
  1869. MoveFlag = true;//已经按下.
  1870. xPos = e.X;//当前x坐标.
  1871. yPos = e.Y;//当前y坐标.
  1872. }
  1873. }
  1874. }
  1875. //在picturebox的鼠标按下事件里.
  1876. private void pbBSEImage_MouseUp(object sender, MouseEventArgs e)
  1877. {
  1878. MoveFlag = false;
  1879. }
  1880. //在picturebox鼠标移动
  1881. private void pbBSEImage_MouseMove(object sender, MouseEventArgs e)
  1882. {
  1883. if (MoveFlag)
  1884. {
  1885. pbBSEImage.Left = Convert.ToInt32(e.X - xPos);//设置x坐标.
  1886. pbBSEImage.Top = Convert.ToInt32(e.Y - yPos);//设置y坐标.
  1887. }
  1888. }
  1889. //在picturebox鼠标缩放
  1890. private void pbBSEImage_MouseWheel(object sender, MouseEventArgs e)
  1891. {
  1892. //鼠标滚动缩放 BSE图
  1893. if (e.Delta > 0)
  1894. {
  1895. if (m_CurrentMultiple < m_MaxMultipleRange)
  1896. {
  1897. m_CurrentMultiple += Convert.ToSingle(m_Multiple.ToString("f2"));
  1898. pbBSEImage.Width += Convert.ToInt32(m_iWidth * m_Multiple);
  1899. pbBSEImage.Height += Convert.ToInt32(m_iHeight * m_Multiple);
  1900. WheelElementPointGDIObjects(e.Location, m_CurrentMultiple);
  1901. }
  1902. }
  1903. else
  1904. {
  1905. m_CurrentMultiple -= Convert.ToSingle(m_Multiple.ToString("f2"));
  1906. if (m_CurrentMultiple > 0)
  1907. {
  1908. pbBSEImage.Width -= Convert.ToInt32(m_iWidth * m_Multiple);
  1909. pbBSEImage.Height -= Convert.ToInt32(m_iHeight * m_Multiple);
  1910. }
  1911. else
  1912. {
  1913. m_CurrentMultiple = 0;
  1914. pbBSEImage.Height = this.RestoreBounds.Height;
  1915. pbBSEImage.Width = this.RestoreBounds.Height * 4 / 3;
  1916. pbBSEImage.Left = 0;
  1917. pbBSEImage.Top = 0;
  1918. Rectangle rectangle = GetPictureBoxZoomSize(pbBSEImage);
  1919. Point sizeChangePoint = rectangle.Location;
  1920. //修改窗体宽度后,设置单点采集的位置
  1921. if (m_ElementPointGDIObjects != null)
  1922. {
  1923. if (m_ElementPointGDIObjects.Count > 0)
  1924. {
  1925. if (m_GetBSEImageInitPoint != sizeChangePoint)
  1926. {
  1927. int sizeChangeX = sizeChangePoint.X - m_GetBSEImageInitPoint.X;
  1928. int sizeChangeY = sizeChangePoint.Y - m_GetBSEImageInitPoint.Y;
  1929. RectangleF sizeChangeRectF = m_ElementPointGDIObjects[0].GetZoomedRegionF();
  1930. sizeChangeRectF.X = m_ElementPointGDIObjects[0].GetZoomedRegionF().X + sizeChangeX;
  1931. m_ElementPointGDIObjects[0].SetInitRegionF(sizeChangeRectF);
  1932. m_GetBSEImageInitPoint = sizeChangePoint;
  1933. }
  1934. }
  1935. }
  1936. }
  1937. WheelElementPointGDIObjects(e.Location, m_CurrentMultiple);
  1938. }
  1939. }
  1940. /// <summary>
  1941. /// 缩放时改变 单点标识位置
  1942. /// </summary>
  1943. /// <param name="m_CurrentMultiple"></param>
  1944. public void WheelElementPointGDIObjects(Point refPoint, float CurrentMultiple)
  1945. {
  1946. if (m_ElementPointGDIObjects.Count > 0)
  1947. {
  1948. foreach (CRectangleGDIObject item in m_ElementPointGDIObjects)
  1949. {
  1950. item.Zoom(refPoint, CurrentMultiple);
  1951. }
  1952. }
  1953. }
  1954. private void button1_Click(object sender, EventArgs e)
  1955. {
  1956. COTSSample cSample = m_MeasureAppForm.m_ProjParam.GetWorkSample();
  1957. int start = cSample.GetMsrParams().GetImageProcessParam().GetBGGray().GetStart();
  1958. int end = cSample.GetMsrParams().GetImageProcessParam().GetBGGray().GetEnd();
  1959. Image bInput = pbBSEImage.Image;
  1960. List<ColorMap> colorMapTemp = new List<ColorMap>();
  1961. for (int i = start; i <= end; i++)
  1962. {
  1963. ColorMap colorMap = new ColorMap();
  1964. string colorName = "#" + Color.FromArgb(i, i, i).Name.ToString();
  1965. colorMap.OldColor = ColorTranslator.FromHtml(colorName);
  1966. colorMap.NewColor = Color.Red;
  1967. colorMapTemp.Add(colorMap);
  1968. }
  1969. Bitmap outBitmap = new Bitmap(bInput);
  1970. //创建Graphics对象
  1971. Graphics g = Graphics.FromImage(outBitmap);
  1972. //生成的图像大小
  1973. int width = bInput.Width;
  1974. int height = bInput.Height;
  1975. //编辑被着急图像所要显示的位置
  1976. Rectangle DrawRect = new Rectangle(0, 0, 1024, 768);
  1977. //编辑输出画布中着色的位置
  1978. Rectangle ShowRect = new Rectangle(0, 0, 1024, 768);
  1979. ImageAttributes attr = new ImageAttributes();
  1980. attr.SetRemapTable(colorMapTemp.ToArray());
  1981. //从输入图像中截图至临时图像中
  1982. g.DrawImage(bInput, ShowRect, 0, 0, DrawRect.Width, DrawRect.Height, GraphicsUnit.Pixel, attr);
  1983. pbBSEImage.Image = outBitmap;
  1984. }
  1985. private void OTSMeasureStatusWindow_MouseClick(object sender, MouseEventArgs e)
  1986. {
  1987. try
  1988. {
  1989. if (e.Button == MouseButtons.Right && e.Clicks == 1)
  1990. {
  1991. //contextMenuStrip1.Show();
  1992. contextMenuStrip1.Show(PointToScreen(e.Location));
  1993. SetContentMenu();
  1994. }
  1995. }
  1996. catch (Exception ex)
  1997. {
  1998. log.Error("(OTSMeasureStatusWindow.OTSMeasureStatusWindow_MouseClick) " + ex.ToString());
  1999. }
  2000. }
  2001. private void ViewStripMenuItem_Click(object sender, EventArgs e)
  2002. {
  2003. if (m_iWidth == 0 || m_iHeight == 0)
  2004. {
  2005. string str = m_MeasureAppForm.m_ProjParam.GetBSEImageResolution();// 举例:1024X768
  2006. string[] sArray = str.Split('X');
  2007. if (sArray[0] != "" && sArray[1] != "")
  2008. {
  2009. m_iWidth = Convert.ToInt32(sArray[0]);
  2010. m_iHeight = Convert.ToInt32(sArray[1]);
  2011. }
  2012. }
  2013. ToolWindow toolWindow = new ToolWindow(m_MeasureAppForm, this);
  2014. int grayStart = 0;
  2015. int grayEnd = 0;
  2016. if (originalBseData != null)
  2017. {
  2018. Bitmap bitmap = CImageHandler.ToGrayBitmap(originalBseData, m_iWidth, m_iHeight);
  2019. toolWindow.BseImg = bitmap;
  2020. toolWindow.BBseData = originalBseData;
  2021. //获取去背景灰度值
  2022. grayStart = m_MeasureAppForm.m_ProjParam.GetWorkSample().GetMsrParams().GetImageProcessParam().GetBGGray().GetStart();
  2023. grayEnd = m_MeasureAppForm.m_ProjParam.GetWorkSample().GetMsrParams().GetImageProcessParam().GetBGGray().GetEnd();
  2024. //设置可视化中的属性
  2025. toolWindow.BseGrayMinValue = grayStart;
  2026. toolWindow.BseGrayMaxValue = grayEnd;
  2027. }
  2028. DialogResult dialogResult = toolWindow.ShowDialog();
  2029. if (dialogResult == DialogResult.Yes)
  2030. {
  2031. //获取去背景参数
  2032. grayStart = toolWindow.BseGrayMinValue;
  2033. grayEnd = toolWindow.BseGrayMaxValue;
  2034. //设置去背景参数
  2035. COTSImageProcParam cOTSImgProc = new COTSImageProcParam();
  2036. cOTSImgProc = m_MeasureAppForm.m_ProjParam.GetResultData().GetWorkingSample().GetMsrParams().GetImageProcessParam();
  2037. CIntRange cIntRange = new CIntRange();
  2038. cIntRange.SetStart(grayStart);
  2039. cIntRange.SetEnd(grayEnd);
  2040. cOTSImgProc.SetBGGray(cIntRange);
  2041. m_MeasureAppForm.m_ProjParam.GetResultData().GetWorkingSample().GetMsrParams().SetImageProcessParam(cOTSImgProc);
  2042. //更新属性窗口
  2043. m_MeasureAppForm.UpdatePropertyVal();
  2044. //确认后进行去背景
  2045. ShowRemoveBGImage();
  2046. return;
  2047. }
  2048. }
  2049. private void toolStripMenuItem1_Click(object sender, EventArgs e)
  2050. {
  2051. if (m_iWidth == 0 || m_iHeight == 0)
  2052. {
  2053. string str = m_MeasureAppForm.m_ProjParam.GetBSEImageResolution();// 举例:1024X768
  2054. string[] sArray = str.Split('X');
  2055. if (sArray[0] != "" && sArray[1] != "")
  2056. {
  2057. m_iWidth = Convert.ToInt32(sArray[0]);
  2058. m_iHeight = Convert.ToInt32(sArray[1]);
  2059. }
  2060. }
  2061. SpecialParticleForm specialParticleForm = new SpecialParticleForm(CSpecialGrayRangeParam.GetParamFileFullName(), m_MeasureAppForm, originalBseData, m_iWidth, m_iHeight, this);
  2062. DialogResult dialogResult = specialParticleForm.ShowDialog();
  2063. }
  2064. }
  2065. }