MethodArea2Dialog.cs 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442
  1. using OpenCvSharp;
  2. using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Drawing;
  7. using System.Windows.Forms;
  8. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.GBT14999
  9. {
  10. internal class MethodArea2Dialog : GrainSizeStandardDialog
  11. {
  12. /// <summary>
  13. /// 各个视场属性集合,索引0-横坐标,1-纵坐标,2-视场宽度,3-视场高度,4-视场面积
  14. /// </summary>
  15. protected List<List<int>> lstAttribute = new List<List<int>>();
  16. protected static string ParamKey_ShowCheckGrainDiameter = "ShowCheckGrainDiameter";//晶粒直径
  17. protected static string ParamKey_ShowGrainDiameter = "ShowGrainDiameter";//晶粒直径
  18. protected static string ParamKey_ShowRibbonCrystalGrain = "ShowRibbonCrystalGrain";//显示带状晶粒颜色
  19. protected static string ParamKey_ShowRibbonCrystalGrainColor = "ShowRibbonCrystalGrainColor";//颜色
  20. protected static string ParamKey_ShowRibbonCrystalGrainDiameter = "ShowRibbonCrystalGrainDiameter";//显示带状晶粒直径
  21. protected static string ParamKey_ShowRibbonCrystalGrainDiameterFontSize = "ShowRibbonCrystalGrainDiameterFontSize";//字号
  22. protected static string ParamKey_ShowRibbonCrystalGrainDiameterColor = "ShowRibbonCrystalGrainDiameterColor";//颜色
  23. #region 组件
  24. private GroupBox groupBox_AddParamSetting;
  25. private GroupBox groupBox_ShowParamSetting;
  26. private Panel panel1_1;
  27. private Panel panel1_2;
  28. private Label label2_1;
  29. private Label label2_2;
  30. private Label label2_3;
  31. private TextBox textBox1_1;
  32. private CheckBox checkBox_ShowAECLengh;
  33. private CheckBox checkBox_ShowAEC_Color;
  34. private DataGridViewTextBoxColumn ColumnTotal1;
  35. private DataGridViewTextBoxColumn ColumnTotal2;
  36. private DataGridViewTextBoxColumn ColumnTotal3;
  37. private DataGridViewTextBoxColumn ColumnTotal4;
  38. private DataGridViewTextBoxColumn ColumnTotal5;
  39. private DataGridViewTextBoxColumn ColumnTotal6;
  40. private DataGridViewTextBoxColumn ColumnTotal7;
  41. private DataGridViewTextBoxColumn ColumnTotal8;
  42. private DataGridViewTextBoxColumn Colum01;
  43. private DataGridViewTextBoxColumn Colum02;
  44. private DataGridViewTextBoxColumn Colum03;
  45. private DataGridViewTextBoxColumn Colum04;
  46. private DataGridViewTextBoxColumn Colum05;
  47. private DataGridViewTextBoxColumn Colum06;
  48. private DataGridViewTextBoxColumn Colum07;
  49. private DataGridViewTextBoxColumn Colum08;
  50. private DataGridViewTextBoxColumn Colum09;
  51. private DataGridViewTextBoxColumn Colum10;
  52. private Label label2;
  53. private ComboBox comboBox4;
  54. private Label label4;
  55. private Label label3;
  56. private TextBox textBox1;
  57. private Mat saveMat;
  58. private bool hasView;
  59. private Mat phaseMat;
  60. #endregion 组件
  61. #region 构造函数
  62. public MethodArea2Dialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, new Base.DedicatedAnalysis.GrainSize.Standard.GBT14999.MethodArea2())
  63. {
  64. binaryClass.processWholeMat = true;
  65. this.Load += new System.EventHandler(this.MethodArea2Dialog_Load);
  66. }
  67. /// <summary>
  68. /// 加载后控制窗口变化
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void MethodArea2Dialog_Load(object sender, EventArgs e)
  73. {
  74. //this.button_ApplyToAll.Visible = false;
  75. //this.button_SaveAll.Visible = false;
  76. //this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
  77. //this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
  78. this.panel1_1.Click += new System.EventHandler(this.panel1_1_Click);
  79. this.panel1_2.Click += new System.EventHandler(this.panel1_1_Click);
  80. this.groupBox_ShowParamSetting.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  81. this.checkBox_ShowAECLengh.Text = "显示带状晶粒直径";// PdnResources.GetString("Menu.displaygrid.text");
  82. this.checkBox_ShowAEC_Color.Text = "显示带状晶粒颜色";// PdnResources.GetString("Menu.displaygrainboundaries.text");
  83. this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  84. this.ColumnTotal1,
  85. this.ColumnTotal2,
  86. this.ColumnTotal3,
  87. this.ColumnTotal4,
  88. this.ColumnTotal5,
  89. this.ColumnTotal6,
  90. this.ColumnTotal7,
  91. this.ColumnTotal8});
  92. //
  93. // ColumnTotal1
  94. //
  95. this.ColumnTotal1.HeaderText = "条带平均卡规直径";
  96. this.ColumnTotal1.Name = "ColumnTotal1";
  97. this.ColumnTotal1.ReadOnly = true;
  98. //
  99. // ColumnTotal2
  100. //
  101. this.ColumnTotal2.HeaderText = "条带晶粒总面积";
  102. this.ColumnTotal2.Name = "ColumnTotal2";
  103. this.ColumnTotal2.ReadOnly = true;
  104. //
  105. // ColumnTotal3
  106. //
  107. this.ColumnTotal3.HeaderText = "面积百分数";
  108. this.ColumnTotal3.Name = "ColumnTotal3";
  109. this.ColumnTotal3.ReadOnly = true;
  110. //
  111. // ColumnTotal4
  112. //
  113. this.ColumnTotal4.HeaderText = "对应级别";
  114. this.ColumnTotal4.Name = "ColumnTotal4";
  115. this.ColumnTotal4.ReadOnly = true;
  116. //
  117. // ColumnTotal5
  118. //
  119. this.ColumnTotal5.HeaderText = "非条带平均卡规直径";
  120. this.ColumnTotal5.Name = "ColumnTotal5";
  121. this.ColumnTotal5.ReadOnly = true;
  122. //
  123. // ColumnTotal6
  124. //
  125. this.ColumnTotal6.HeaderText = "非条带晶粒总面积";
  126. this.ColumnTotal6.Name = "ColumnTotal6";
  127. this.ColumnTotal6.ReadOnly = true;
  128. //
  129. // ColumnTotal7
  130. //
  131. this.ColumnTotal7.HeaderText = "面积百分数";
  132. this.ColumnTotal7.Name = "ColumnTotal7";
  133. this.ColumnTotal7.ReadOnly = true;
  134. //
  135. // ColumnTotal8
  136. //
  137. this.ColumnTotal8.HeaderText = "对应级别";
  138. this.ColumnTotal8.Name = "ColumnTotal8";
  139. this.ColumnTotal8.ReadOnly = true;
  140. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  141. this.Colum01,
  142. this.Colum02,
  143. this.Colum03,
  144. this.Colum04,
  145. this.Colum05,
  146. this.Colum06,
  147. this.Colum07,
  148. this.Colum08,
  149. this.Colum09,
  150. this.Colum10});
  151. //
  152. // Colum01
  153. //
  154. this.Colum01.HeaderText = PdnResources.GetString("Menu.picture.Text");
  155. this.Colum01.Name = "Colum01";
  156. this.Colum01.ReadOnly = true;
  157. //
  158. // Colum02
  159. //
  160. this.Colum02.HeaderText = "视场";// PdnResources.GetString("Menu.Tools.GridLine.Text");
  161. this.Colum02.Name = "Colum02";
  162. this.Colum02.ReadOnly = true;
  163. //
  164. // Colum03
  165. //
  166. this.Colum03.HeaderText = "条带平均卡规直径";
  167. this.Colum03.Name = "Colum03";
  168. this.Colum03.ReadOnly = true;
  169. //
  170. // Colum04
  171. //
  172. this.Colum04.HeaderText = "条带晶粒总面积";// PdnResources.GetString("Menu.Graisize.Text") + "(μm²)";
  173. this.Colum04.Name = "Colum04";
  174. this.Colum04.ReadOnly = true;
  175. //
  176. // Colum05
  177. //
  178. this.Colum05.HeaderText = "面积百分数";
  179. this.Colum05.Name = "Colum05";
  180. this.Colum05.ReadOnly = true;
  181. //
  182. // Colum06
  183. //
  184. this.Colum06.HeaderText = "对应级别";// PdnResources.GetString("Menu.Graingrade.Text");
  185. this.Colum06.Name = "Colum06";
  186. this.Colum06.ReadOnly = true;
  187. //
  188. // Colum07
  189. //
  190. this.Colum07.HeaderText = "非条带平均卡规直径";
  191. this.Colum07.Name = "Colum07";
  192. this.Colum07.ReadOnly = true;
  193. //
  194. // Colum08
  195. //
  196. this.Colum08.HeaderText = "非条带晶粒总面积";
  197. this.Colum08.Name = "Colum08";
  198. this.Colum08.ReadOnly = true;
  199. //
  200. // Colum09
  201. //
  202. this.Colum09.HeaderText = "面积百分数";
  203. this.Colum09.Name = "Colum09";
  204. this.Colum09.ReadOnly = true;
  205. //
  206. // Colum10
  207. //
  208. this.Colum10.HeaderText = "对应级别";
  209. this.Colum10.Name = "Colum10";
  210. this.Colum10.ReadOnly = true;
  211. HeaderTextUsable = false;
  212. DetailListStringIndex.Add(5);
  213. DetailListStringIndex.Add(9);
  214. DetailListNotDoubleIndex.Add(5);
  215. DetailListNotDoubleIndex.Add(9);
  216. IndexChangedFromIndex.Clear();
  217. IndexChangedToIndex.Clear();
  218. IndexChangedFromIndex.Add(2);
  219. IndexChangedFromIndex.Add(3);
  220. IndexChangedFromIndex.Add(4);
  221. IndexChangedFromIndex.Add(6);
  222. IndexChangedFromIndex.Add(7);
  223. IndexChangedFromIndex.Add(8);
  224. IndexChangedToIndex.Add(0, new int[] { 2, 0 });//平均
  225. IndexChangedToIndex.Add(1, new int[] { 1, 1 });//求和
  226. IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
  227. IndexChangedToIndex.Add(3, new int[] { 3, 0 });//级别
  228. IndexChangedToIndex.Add(4, new int[] { 2, 3 });//平均
  229. IndexChangedToIndex.Add(5, new int[] { 1, 4 });//求和
  230. IndexChangedToIndex.Add(6, new int[] { 2, 5 });//平均
  231. IndexChangedToIndex.Add(7, new int[] { 3, 4 });//级别
  232. this.groupBox3.Visible = false;
  233. getSonData();
  234. }
  235. #endregion 构造函数
  236. #region 初始化组件和实现组件事件
  237. private void InitializeComponent()
  238. {
  239. this.groupBox_AddParamSetting = new System.Windows.Forms.GroupBox();
  240. this.label4 = new System.Windows.Forms.Label();
  241. this.label3 = new System.Windows.Forms.Label();
  242. this.textBox1 = new System.Windows.Forms.TextBox();
  243. this.comboBox4 = new System.Windows.Forms.ComboBox();
  244. this.label2 = new System.Windows.Forms.Label();
  245. this.groupBox_ShowParamSetting = new System.Windows.Forms.GroupBox();
  246. this.label2_1 = new System.Windows.Forms.Label();
  247. this.label2_2 = new System.Windows.Forms.Label();
  248. this.label2_3 = new System.Windows.Forms.Label();
  249. this.textBox1_1 = new System.Windows.Forms.TextBox();
  250. this.panel1_2 = new System.Windows.Forms.Panel();
  251. this.panel1_1 = new System.Windows.Forms.Panel();
  252. this.checkBox_ShowAECLengh = new System.Windows.Forms.CheckBox();
  253. this.checkBox_ShowAEC_Color = new System.Windows.Forms.CheckBox();
  254. this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  255. this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  256. this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  257. this.ColumnTotal4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  258. this.ColumnTotal5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  259. this.ColumnTotal6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  260. this.ColumnTotal7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  261. this.ColumnTotal8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  262. this.Colum01 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  263. this.Colum02 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  264. this.Colum03 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  265. this.Colum04 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  266. this.Colum05 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  267. this.Colum06 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  268. this.Colum07 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  269. this.Colum08 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  270. this.Colum09 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  271. this.Colum10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  272. this.groupBox_analysisResult1.SuspendLayout();
  273. this.groupBox3.SuspendLayout();
  274. this.groupBox_AddParamSetting.SuspendLayout();
  275. this.groupBox_ShowParamSetting.SuspendLayout();
  276. this.SuspendLayout();
  277. //
  278. // groupBox_AddParamSetting
  279. //
  280. this.groupBox_AddParamSetting.Controls.Add(this.label4);
  281. this.groupBox_AddParamSetting.Controls.Add(this.label3);
  282. this.groupBox_AddParamSetting.Controls.Add(this.textBox1);
  283. this.groupBox_AddParamSetting.Controls.Add(this.comboBox4);
  284. this.groupBox_AddParamSetting.Controls.Add(this.label2);
  285. this.groupBox_AddParamSetting.Location = new System.Drawing.Point(179, 320);
  286. this.groupBox_AddParamSetting.Name = "groupBox_AddParamSetting";
  287. this.groupBox_AddParamSetting.Size = new System.Drawing.Size(355, 48);
  288. this.groupBox_AddParamSetting.TabIndex = 134;
  289. this.groupBox_AddParamSetting.TabStop = false;
  290. this.groupBox_AddParamSetting.Text = "参数设置";
  291. //
  292. // label4
  293. //
  294. this.label4.AutoSize = true;
  295. this.label4.Location = new System.Drawing.Point(261, 19);
  296. this.label4.Name = "label4";
  297. this.label4.Size = new System.Drawing.Size(77, 12);
  298. this.label4.TabIndex = 35;
  299. this.label4.Text = "记为带状晶粒";
  300. //
  301. // label3
  302. //
  303. this.label3.AutoSize = true;
  304. this.label3.Location = new System.Drawing.Point(229, 19);
  305. this.label3.Name = "label3";
  306. this.label3.Size = new System.Drawing.Size(23, 12);
  307. this.label3.TabIndex = 34;
  308. this.label3.Text = "μm";
  309. //
  310. // textBox1
  311. //
  312. this.textBox1.Location = new System.Drawing.Point(179, 15);
  313. this.textBox1.Name = "textBox1";
  314. this.textBox1.Size = new System.Drawing.Size(45, 21);
  315. this.textBox1.TabIndex = 33;
  316. this.textBox1.Text = "0.5";
  317. //
  318. // comboBox4
  319. //
  320. this.comboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  321. this.comboBox4.FormattingEnabled = true;
  322. this.comboBox4.Items.AddRange(new object[] {
  323. ">=",
  324. "<=",
  325. ">",
  326. "<"});
  327. this.comboBox4.Location = new System.Drawing.Point(72, 16);
  328. this.comboBox4.Name = "comboBox4";
  329. this.comboBox4.Size = new System.Drawing.Size(98, 20);
  330. this.comboBox4.TabIndex = 32;
  331. this.comboBox4.SelectedIndexChanged += new System.EventHandler(this.comboBox4_SelectedIndexChanged);
  332. //
  333. // label2
  334. //
  335. this.label2.AutoSize = true;
  336. this.label2.Location = new System.Drawing.Point(7, 20);
  337. this.label2.Name = "label2";
  338. this.label2.Size = new System.Drawing.Size(59, 12);
  339. this.label2.TabIndex = 31;
  340. this.label2.Text = "卡规直径:";
  341. //
  342. // groupBox_ShowParamSetting
  343. //
  344. this.groupBox_ShowParamSetting.Controls.Add(this.label2_1);
  345. this.groupBox_ShowParamSetting.Controls.Add(this.label2_2);
  346. this.groupBox_ShowParamSetting.Controls.Add(this.label2_3);
  347. this.groupBox_ShowParamSetting.Controls.Add(this.textBox1_1);
  348. this.groupBox_ShowParamSetting.Controls.Add(this.panel1_2);
  349. this.groupBox_ShowParamSetting.Controls.Add(this.panel1_1);
  350. this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowAECLengh);
  351. this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowAEC_Color);
  352. this.groupBox_ShowParamSetting.Location = new System.Drawing.Point(178, 370);
  353. this.groupBox_ShowParamSetting.Name = "groupBox_ShowParamSetting";
  354. this.groupBox_ShowParamSetting.Size = new System.Drawing.Size(356, 74);
  355. this.groupBox_ShowParamSetting.TabIndex = 38;
  356. this.groupBox_ShowParamSetting.TabStop = false;
  357. //
  358. // label2_1
  359. //
  360. this.label2_1.AutoSize = true;
  361. this.label2_1.Location = new System.Drawing.Point(248, 25);
  362. this.label2_1.Name = "label2_1";
  363. this.label2_1.Size = new System.Drawing.Size(35, 12);
  364. this.label2_1.TabIndex = 311;
  365. this.label2_1.Text = "颜色:";
  366. //
  367. // label2_2
  368. //
  369. this.label2_2.AutoSize = true;
  370. this.label2_2.Location = new System.Drawing.Point(248, 45);
  371. this.label2_2.Name = "label2_2";
  372. this.label2_2.Size = new System.Drawing.Size(35, 12);
  373. this.label2_2.TabIndex = 312;
  374. this.label2_2.Text = "颜色:";
  375. //
  376. // label2_3
  377. //
  378. this.label2_3.AutoSize = true;
  379. this.label2_3.Location = new System.Drawing.Point(162, 45);
  380. this.label2_3.Name = "label2_3";
  381. this.label2_3.Size = new System.Drawing.Size(35, 12);
  382. this.label2_3.TabIndex = 312;
  383. this.label2_3.Text = "字号:";
  384. //
  385. // textBox1_1
  386. //
  387. this.textBox1_1.Location = new System.Drawing.Point(199, 41);
  388. this.textBox1_1.Name = "textBox1_1";
  389. this.textBox1_1.Size = new System.Drawing.Size(45, 21);
  390. this.textBox1_1.TabIndex = 33;
  391. this.textBox1_1.Text = "12";
  392. //
  393. // panel1_2
  394. //
  395. this.panel1_2.BackColor = System.Drawing.Color.Black;
  396. this.panel1_2.Location = new System.Drawing.Point(291, 42);
  397. this.panel1_2.Name = "panel1_2";
  398. this.panel1_2.Size = new System.Drawing.Size(52, 21);
  399. this.panel1_2.TabIndex = 18;
  400. //
  401. // panel1_1
  402. //
  403. this.panel1_1.BackColor = System.Drawing.Color.Red;
  404. this.panel1_1.Location = new System.Drawing.Point(291, 18);
  405. this.panel1_1.Name = "panel1_1";
  406. this.panel1_1.Size = new System.Drawing.Size(52, 21);
  407. this.panel1_1.TabIndex = 18;
  408. //
  409. // checkBox_ShowAECLengh
  410. //
  411. this.checkBox_ShowAECLengh.AutoSize = true;
  412. this.checkBox_ShowAECLengh.Location = new System.Drawing.Point(15, 44);
  413. this.checkBox_ShowAECLengh.Name = "checkBox_ShowAECLengh";
  414. this.checkBox_ShowAECLengh.Size = new System.Drawing.Size(15, 14);
  415. this.checkBox_ShowAECLengh.TabIndex = 1;
  416. this.checkBox_ShowAECLengh.UseVisualStyleBackColor = true;
  417. this.checkBox_ShowAECLengh.CheckedChanged += new System.EventHandler(this.checkBox_ShowAECLengh_CheckedChanged);
  418. //
  419. // checkBox_ShowAEC_Color
  420. //
  421. this.checkBox_ShowAEC_Color.AutoSize = true;
  422. this.checkBox_ShowAEC_Color.Location = new System.Drawing.Point(15, 22);
  423. this.checkBox_ShowAEC_Color.Name = "checkBox_ShowAEC_Color";
  424. this.checkBox_ShowAEC_Color.Size = new System.Drawing.Size(15, 14);
  425. this.checkBox_ShowAEC_Color.TabIndex = 0;
  426. this.checkBox_ShowAEC_Color.UseVisualStyleBackColor = true;
  427. this.checkBox_ShowAEC_Color.CheckedChanged += new System.EventHandler(this.checkBox_ShowAEC_Color_CheckedChanged);
  428. //
  429. // ColumnTotal1
  430. //
  431. this.ColumnTotal1.Name = "ColumnTotal1";
  432. //
  433. // ColumnTotal2
  434. //
  435. this.ColumnTotal2.Name = "ColumnTotal2";
  436. //
  437. // ColumnTotal3
  438. //
  439. this.ColumnTotal3.Name = "ColumnTotal3";
  440. //
  441. // ColumnTotal4
  442. //
  443. this.ColumnTotal4.Name = "ColumnTotal4";
  444. //
  445. // ColumnTotal5
  446. //
  447. this.ColumnTotal5.Name = "ColumnTotal5";
  448. //
  449. // ColumnTotal6
  450. //
  451. this.ColumnTotal6.Name = "ColumnTotal6";
  452. //
  453. // ColumnTotal7
  454. //
  455. this.ColumnTotal7.Name = "ColumnTotal7";
  456. //
  457. // ColumnTotal8
  458. //
  459. this.ColumnTotal8.Name = "ColumnTotal8";
  460. //
  461. // Colum01
  462. //
  463. this.Colum01.Name = "Colum01";
  464. //
  465. // Colum02
  466. //
  467. this.Colum02.Name = "Colum02";
  468. //
  469. // Colum03
  470. //
  471. this.Colum03.Name = "Colum03";
  472. //
  473. // Colum04
  474. //
  475. this.Colum04.Name = "Colum04";
  476. //
  477. // Colum05
  478. //
  479. this.Colum05.Name = "Colum05";
  480. //
  481. // Colum06
  482. //
  483. this.Colum06.Name = "Colum06";
  484. //
  485. // Colum07
  486. //
  487. this.Colum07.Name = "Colum07";
  488. //
  489. // Colum08
  490. //
  491. this.Colum08.Name = "Colum08";
  492. //
  493. // Colum09
  494. //
  495. this.Colum09.Name = "Colum09";
  496. //
  497. // Colum10
  498. //
  499. this.Colum10.Name = "Colum10";
  500. //
  501. // MethodArea2Dialog
  502. //
  503. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  504. this.ClientSize = new System.Drawing.Size(1127, 810);
  505. this.Controls.Add(this.groupBox_AddParamSetting);
  506. this.Controls.Add(this.groupBox_ShowParamSetting);
  507. this.Name = "MethodArea2Dialog";
  508. this.Text = "GBT14999_2012(双重晶粒度评级)";
  509. this.Controls.SetChildIndex(this.groupBox3, 0);
  510. this.Controls.SetChildIndex(this.groupBox_img, 0);
  511. this.Controls.SetChildIndex(this.groupBox_review, 0);
  512. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  513. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  514. this.Controls.SetChildIndex(this.groupBox_report, 0);
  515. this.Controls.SetChildIndex(this.groupBox_ShowParamSetting, 0);
  516. this.Controls.SetChildIndex(this.groupBox_AddParamSetting, 0);
  517. this.groupBox_analysisResult1.ResumeLayout(false);
  518. this.groupBox3.ResumeLayout(false);
  519. this.groupBox_AddParamSetting.ResumeLayout(false);
  520. this.groupBox_AddParamSetting.PerformLayout();
  521. this.groupBox_ShowParamSetting.ResumeLayout(false);
  522. this.groupBox_ShowParamSetting.PerformLayout();
  523. this.ResumeLayout(false);
  524. }
  525. /// <summary>
  526. /// 字号改变
  527. /// </summary>
  528. /// <param name="sender"></param>
  529. /// <param name="e"></param>
  530. private void TextBox1_1_TextChanged(object sender, EventArgs e)
  531. {
  532. if (checkBox_ShowAECLengh.Checked)
  533. this.documentWorkspace.Refresh();
  534. }
  535. /// <summary>
  536. /// 输入阈值改变
  537. /// </summary>
  538. /// <param name="sender"></param>
  539. /// <param name="e"></param>
  540. private void TextBox1_TextChanged(object sender, EventArgs e)
  541. {
  542. GetClassNumberOfGrains();//setMat2ColorOfLabelMat
  543. }
  544. /// <summary>
  545. /// 显示带状晶粒颜色改变
  546. /// </summary>
  547. /// <param name="sender"></param>
  548. /// <param name="e"></param>
  549. private void checkBox_ShowAEC_Color_CheckedChanged(object sender, EventArgs e)
  550. {
  551. if (this.documentWorkspace.PhaseModels.Count > 0)
  552. {
  553. this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && checkBox_ShowAEC_Color.Checked);
  554. if (checkBox_ShowAEC_Color.Checked)
  555. setMat2ColorOfLabelMat/*GetClassNumberOfGrains*/();
  556. else
  557. this.documentWorkspace.Refresh();
  558. }
  559. }
  560. /// <summary>
  561. /// 显示带状晶粒直径改变
  562. /// </summary>
  563. /// <param name="sender"></param>
  564. /// <param name="e"></param>
  565. private void checkBox_ShowAECLengh_CheckedChanged(object sender, EventArgs e)
  566. {
  567. this.documentWorkspace.Refresh();
  568. }
  569. private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
  570. {
  571. //根据等级设置晶粒颜色
  572. setMat2ColorOfLabelMat(/*nccomps*/);
  573. }
  574. #endregion 初始化组件和实现组件事件
  575. /// <summary>
  576. /// 刷新晶粒编号/刷新晶粒颜色?//############
  577. /// </summary>
  578. /// <param name="pointFs"></param>
  579. /// <param name="rectangleF"></param>
  580. /// <returns>返回晶粒个数</returns>
  581. protected override double GetClassNumberOfGrains()
  582. {
  583. if (saveMat == null)
  584. return 0.1;
  585. bool existViewFlag = this.hasView;
  586. //Mat exsitViewMatOrg = null;//视场图像
  587. //if (existViewFlag)
  588. //// //matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  589. ////else
  590. // exsitViewMatOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(getCurrentWorkspace().GetFullSizeWithRegion());
  591. ////Bitmap bitmap = getCurrentWorkspace().GetCutSizeWithColorWhiteOrTransparentColor(false);
  592. ////Mat oldMap = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  593. Mat OrgViewMat;
  594. Mat analyzeMat = new Mat();
  595. if (getGrainBoundryChecked())
  596. {
  597. OrgViewMat = new Mat(saveMat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  598. Mat oldMat = PhaseModels1Mat != null ? PhaseModels1Mat : this.documentWorkspace.PhaseModels[1].mat;
  599. int Rows = oldMat.Rows;
  600. int Cols = oldMat.Cols;
  601. int[] point = new int[2];
  602. //多通道图像的格式化
  603. for (point[0] = 0; point[0] < Rows; point[0]++)
  604. {
  605. for (point[1] = 0; point[1] < Cols; point[1]++)
  606. {
  607. if (oldMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  608. {
  609. OrgViewMat.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
  610. }
  611. }
  612. }
  613. Cv2.Erode(OrgViewMat, OrgViewMat, null, null, 1);
  614. oldMat.CopyTo(analyzeMat);
  615. }
  616. else if (getBinaryChecked())
  617. {
  618. OrgViewMat = new Mat(saveMat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  619. //Mat oldMat = this.PhaseModel0Mat;
  620. Mat oldMat = this.phaseMat;
  621. int Rows = oldMat.Rows;
  622. int Cols = oldMat.Cols;
  623. int[] point = new int[2];
  624. //多通道图像的格式化
  625. for (point[0] = 0; point[0] < Rows; point[0]++)
  626. {
  627. for (point[1] = 0; point[1] < Cols; point[1]++)
  628. {
  629. if (oldMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
  630. {
  631. OrgViewMat.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
  632. }
  633. }
  634. }
  635. oldMat.CopyTo(analyzeMat);
  636. }
  637. else
  638. {
  639. OrgViewMat = new Mat(saveMat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
  640. saveMat.CopyTo(OrgViewMat);
  641. saveMat.CopyTo(analyzeMat);
  642. }
  643. List<Mat> OrgMatLists = new List<Mat>();
  644. //视场个数
  645. int sumFieldl = 1;
  646. //各个视场属性集合,索引0-横坐标,1-纵坐标,2-视场宽度,3-视场高度,4-视场面积
  647. if (lstAttribute.Count > 0)
  648. lstAttribute.Clear();
  649. //获取多视场图片
  650. if (existViewFlag)
  651. {
  652. //寻找并标记区域个数
  653. Mat orgLabelMat = new Mat();
  654. Mat orgStats = new Mat();
  655. Mat orgCentroids = new Mat();
  656. Bitmap bitmap = this.documentWorkspace.GetCutSizeWithColorWhiteOrTransparentColor(false);
  657. Mat oldMap = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  658. int nonenum = Cv2.ConnectedComponentsWithStats(BinaryClass.BGRA2GRAY(oldMap)/* //### .CvtColor(ColorConversionCodes.BGR2GRAY)*/, orgLabelMat, orgStats, orgCentroids, PixelConnectivity.Connectivity8);
  659. sumFieldl = nonenum/*centroids.Height*/ - 1;
  660. List<int> attribute;//单视场属性集合
  661. for (int h = 1; h < orgCentroids.Height; h++)
  662. {
  663. attribute = new List<int>();
  664. int x = orgStats.At<int>(h, 0);
  665. int y = orgStats.At<int>(h, 1);
  666. int width = orgStats.At<int>(h, 2);
  667. int height = orgStats.At<int>(h, 3);
  668. int areaField1 = orgStats.At<int>(h, 4);
  669. attribute.Add(x);
  670. attribute.Add(y);
  671. attribute.Add(width);
  672. attribute.Add(height);
  673. attribute.Add(areaField1);
  674. lstAttribute.Add(attribute);
  675. //double areaField = areaField1 * unitLength * unitLength;
  676. if (x < 0 || y < 0 || width > bitmap.Width || height > bitmap.Height)
  677. {
  678. continue;
  679. }
  680. Mat ImageROI1;
  681. try
  682. {
  683. Rect roi1 = new Rect(x, y, width, height);
  684. ImageROI1 = new Mat(OrgViewMat, roi1).Clone();
  685. for (int label_y = 0; label_y < height; label_y++)
  686. {
  687. for (int label_x = 0; label_x < width; label_x++)
  688. {
  689. if (orgLabelMat.At<int>(y + label_y, x + label_x) != h)
  690. {
  691. ImageROI1.Set(label_y, label_x, new Vec4b(0, 0, 0, 0));
  692. }
  693. }
  694. }
  695. }
  696. catch (Exception)
  697. {
  698. ImageROI1 = oldMap;//should never go here!
  699. }
  700. OrgMatLists.Add(ImageROI1);
  701. }
  702. }
  703. else
  704. {
  705. List<int> attribute = new List<int>();//单视场属性集合
  706. attribute.Add(0);
  707. attribute.Add(0);
  708. attribute.Add(OrgViewMat.Width);
  709. attribute.Add(OrgViewMat.Height);
  710. attribute.Add(OrgViewMat.Width * OrgViewMat.Height);
  711. lstAttribute.Add(attribute);
  712. OrgMatLists.Add(OrgViewMat);
  713. }
  714. //存储矩阵数据
  715. if (GSSClass.CurrentStatsArray != null && GSSClass.CurrentStatsArray.Length > 0)
  716. GSSClass.CurrentStatsArray = null;
  717. GSSClass.standardModel.currentStatsArray = new Mat[sumFieldl];
  718. if (GSSClass.CurrentLabelMatArray != null && GSSClass.CurrentLabelMatArray.Length > 0)
  719. GSSClass.CurrentLabelMatArray = null;
  720. GSSClass.CurrentLabelMatArray = new Mat[sumFieldl];
  721. if (GSSClass.standardModel.massLabelPointsList.Count > 0)
  722. GSSClass.standardModel.massLabelPointsList.Clear();
  723. int matIndex = 0;
  724. foreach (Mat OriginalPicture in OrgMatLists)
  725. {
  726. int offsetX = lstAttribute[matIndex][0];
  727. int offsetY = lstAttribute[matIndex][1];
  728. Mat erzhi = OriginalPicture;
  729. Cv2.CvtColor(erzhi, erzhi, ColorConversionCodes.BGR2GRAY);
  730. Cv2.Threshold(erzhi, erzhi, 100, 255, ThresholdTypes.Binary);//##
  731. OpenCvSharp.Point[][] contours;
  732. HierarchyIndex[] hierarchy;
  733. Cv2.FindContours(erzhi, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  734. List<OpenCvSharp.Point[]> pointss = new List<OpenCvSharp.Point[]>();
  735. foreach (OpenCvSharp.Point[] contour in contours)
  736. {
  737. if (contour.Length < 100)
  738. {
  739. foreach (OpenCvSharp.Point point in contour)
  740. {
  741. erzhi.Set<byte>(point.Y, point.X, 255);
  742. }
  743. pointss.Add(contour);
  744. }
  745. }
  746. Cv2.FillPoly(erzhi, pointss, new Scalar(255));
  747. Mat labelMat = new Mat();
  748. Mat stats = new Mat();
  749. Mat centroids = new Mat();
  750. // 连通域数量
  751. int nccomps = Cv2.ConnectedComponentsWithStats(erzhi, labelMat, stats, centroids, PixelConnectivity.Connectivity8);
  752. GSSClass.standardModel.currentLabelMatArray[matIndex] = labelMat.Clone();
  753. //存储矩阵数据
  754. GSSClass.standardModel.currentStatsArray[matIndex] = stats.Clone();
  755. // 连通域质点
  756. Dictionary<int, Point2d> keyValues = new Dictionary<int, Point2d>();
  757. Dictionary<int, List<double>> massLabelPoints = new Dictionary<int, List<double>>();
  758. // 矩形边线上的连通域
  759. ArrayList nccompSelect = new ArrayList();
  760. double aec;
  761. double aec_length;
  762. //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
  763. //选择标尺的物理长度(1倍下的 微米/像素)
  764. //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
  765. double physical_area_length_Micron = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  766. //if (exsitViewMatOrg == null || currentLabelMat == null || currentStats == null)
  767. {
  768. for (int label = 1; label < centroids.Height; label++)
  769. {
  770. keyValues[label] = new Point2d((int)centroids.At<double>(label, 0) + offsetX, (int)centroids.At<double>(label, 1) + offsetY);
  771. nccompSelect.Add(label);
  772. aec = stats/*currentStats*/.At<int>(label, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
  773. aec_length = Math.Sqrt(aec);
  774. massLabelPoints.Add(label, new List<double>() { aec_length, 1/*0*/, keyValues[label].X, keyValues[label].Y, aec });
  775. }
  776. }
  777. GSSClass.standardModel.massLabelPointsList.Add(massLabelPoints);
  778. matIndex++;
  779. }
  780. analyzeMat.Dispose();
  781. analyzeMat = null;
  782. // 矩形内的连通域
  783. GSSClass.standardModel.within = 0;
  784. ArrayList inccompSelect = new ArrayList();
  785. //根据等级设置晶粒颜色
  786. setMat2ColorOfLabelMat(/*nccomps*/);
  787. return GSSClass.standardModel.within/* + (double)nccompSelect.Count / 2*/;
  788. }
  789. /// <summary>
  790. /// 根据等级设置晶粒颜色,并计算复合条件的label集合到currentNccompSelectList
  791. /// </summary>
  792. /// <param name="nccomps">连通域数量</param>
  793. private void setMat2ColorOfLabelMat(/*int nccomps*/)
  794. {
  795. if (matOrg == null || GSSClass.standardModel.massLabelPointsList.Count == 0 || GSSClass.CurrentLabelMatArray.Length == 0 || GSSClass.standardModel.massLabelPointsList.Count != GSSClass.CurrentLabelMatArray.Length/* || currentStatsArray.Length == 0 || currentLabelMatArray.Length != currentStatsArray.Length*/)
  796. {
  797. if (matOrg != null)
  798. GetClassNumberOfGrains();
  799. return;
  800. }
  801. double lengthValue;
  802. if (!double.TryParse(this.textBox1.Text.ToString(), out lengthValue))
  803. return;
  804. //Mat exsitViewMatOrg = null;//视场图像
  805. //if (getCurrentWorkspace().GraphicsList.IsExsitView())
  806. // exsitViewMatOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(getCurrentWorkspace().GetFullSizeWithRegion());
  807. Mat temp = new Mat(matOrg.Size(), MatType.CV_8UC4, new Scalar(0, 0, 0, 0));//##
  808. if (GSSClass.standardModel.currentNccompSelectList.Count > 0)
  809. {
  810. GSSClass.standardModel.currentNccompSelectList.Clear();
  811. }
  812. for (int matIndex = 0; matIndex < GSSClass.CurrentLabelMatArray.Length; matIndex++)
  813. {
  814. int offsetX = lstAttribute[matIndex][0];
  815. int offsetY = lstAttribute[matIndex][1];
  816. int offsetWidth = lstAttribute[matIndex][2];
  817. int offsetHeight = lstAttribute[matIndex][3];
  818. if (offsetX < 0 || offsetY < 0 || offsetWidth > matOrg.Width || offsetHeight > matOrg.Height)
  819. {
  820. continue;//should never go here!
  821. }
  822. ArrayList currentNccompSelect = new ArrayList();//每个晶粒只计算一次
  823. Mat currentLabelMat = GSSClass.standardModel.currentLabelMatArray[matIndex];
  824. Dictionary<int, List<double>> massLabelPoints = GSSClass.standardModel.massLabelPointsList[matIndex];
  825. int label;
  826. double aec_length;
  827. Vec4b vec4 = new Vec4b(panel1_1.BackColor.B, panel1_1.BackColor.G, panel1_1.BackColor.R, Math.Max((byte)1, panel1_1.BackColor.A));
  828. for (int y = 0; y < offsetHeight; y++)
  829. {
  830. for (int x = 0; x < offsetWidth; x++)
  831. {
  832. //if (exsitViewMatOrg != null && exsitViewMatOrg.At<Vec4b>(y, x).Item3 == 0)
  833. // continue;//不在视场图像范围内
  834. label = currentLabelMat.At<int>(y, x);
  835. if (currentNccompSelect.Contains(label))
  836. {//已经找到的复合条件直接赋值颜色
  837. temp.Set(y + offsetY, x + offsetX, vec4);
  838. continue;
  839. }
  840. if (!massLabelPoints.ContainsKey(label))
  841. continue;
  842. aec_length = massLabelPoints[label][0];
  843. if (comboBox4.SelectedIndex == 0 && aec_length >= lengthValue || comboBox4.SelectedIndex == 2 && aec_length > lengthValue
  844. || comboBox4.SelectedIndex == 1 && aec_length <= lengthValue || comboBox4.SelectedIndex == 3 && aec_length < lengthValue)
  845. {
  846. if (!currentNccompSelect.Contains(label))
  847. currentNccompSelect.Add(label);
  848. temp.Set(y + offsetY, x + offsetX, vec4);
  849. }
  850. }
  851. }
  852. GSSClass.standardModel.currentNccompSelectList.Add(currentNccompSelect);
  853. }
  854. this.documentWorkspace.PhaseModels[2].mat = temp;
  855. this.documentWorkspace.Refresh();
  856. }
  857. /// <summary>
  858. /// 面积法组织分项数据列表的内容,并返回 条带/非条带的:平均直径(μm)、汇总晶粒总面积(μm²)、面积比和对应级别
  859. /// </summary>
  860. private double[] addNewRowsToDatagridView2(GrainSizeStandardModel cal_StandardModel, string imgName, string tag, double physical_area_length_Micron,out string gradeValue_1, out string gradeValue_2)
  861. {
  862. this.dataGridView2.Rows.Clear();
  863. if ((cal_StandardModel.massLabelPointsList.Count == 0 && GetClassNumberOfGrains() == 0 && cal_StandardModel.massLabelPointsList.Count == 0 /* //#21108 */) || GSSClass.CurrentLabelMatArray == null || GSSClass.CurrentLabelMatArray.Length != GSSClass.standardModel.massLabelPointsList.Count
  864. || GSSClass.CurrentStatsArray == null || GSSClass.CurrentStatsArray.Length != cal_StandardModel.massLabelPointsList.Count)
  865. {
  866. gradeValue_1 = "00";
  867. gradeValue_2 = "00";
  868. return new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 };//should never go here!
  869. }
  870. double small_l_1 = 0;//汇总直径
  871. int small_count_1 = 0;//汇总晶粒个数
  872. double area_sum_1 = 0;//汇总晶粒总面积
  873. double area_view_1 = 0;//面积百分数
  874. double small_l_2 = 0;//汇总直径
  875. int small_count_2 = 0;//汇总晶粒个数
  876. double area_sum_2 = 0;//汇总晶粒总面积
  877. double area_view_2 = 0;//面积百分数
  878. //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
  879. //选择标尺的物理长度(1倍下的 微米/像素)
  880. //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
  881. for (int matIndex = 0; matIndex < cal_StandardModel.massLabelPointsList.Count; matIndex++)
  882. {
  883. Dictionary<int, List<double>> massLabelPoints = cal_StandardModel.massLabelPointsList[matIndex];
  884. Mat currentStats = cal_StandardModel.currentStatsArray[matIndex];
  885. //显示编号
  886. if (/*massLabelPoints.Count == 0 || */ /* //#21108 */currentStats == null)
  887. continue;
  888. DataGridViewRow dgvr = new DataGridViewRow();
  889. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  890. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  891. dgvr.Cells[0].Value = imgName;
  892. dgvr.Cells[1].Value = "视场" + (1 + matIndex);//视场编号
  893. double smalll_index_1 = 0.0;
  894. double aec_index_1 = 0.0;
  895. double smalll_index_2 = 0.0;
  896. double aec_index_2 = 0.0;
  897. ArrayList currentNccompSelect = new ArrayList();
  898. if (matIndex < cal_StandardModel.currentNccompSelectList.Count) {
  899. currentNccompSelect = cal_StandardModel.currentNccompSelectList[matIndex];
  900. }
  901. int grainNumber_1 = Math.Max(1, currentNccompSelect.Count);
  902. int grainNumber_2 = Math.Max(1, massLabelPoints.Keys.Count - currentNccompSelect.Count);
  903. //decimal NA;//这里计算的值可以取到
  904. foreach (int kvLabel in /*currentNccompSelect*/massLabelPoints.Keys)
  905. {
  906. if (currentNccompSelect.Contains(kvLabel))
  907. {
  908. smalll_index_1 += massLabelPoints[kvLabel][0];
  909. aec_index_1 += massLabelPoints[kvLabel][4];//晶粒面积
  910. }
  911. else
  912. {
  913. smalll_index_2 += massLabelPoints[kvLabel][0];
  914. aec_index_2 += massLabelPoints[kvLabel][4];//晶粒面积
  915. }
  916. }
  917. double area_index = lstAttribute[matIndex][4] * physical_area_length_Micron * physical_area_length_Micron;//视场总面积
  918. //保证两个晶粒面积相加是100%
  919. if (area_index > 0)
  920. {
  921. double aec_scale = (aec_index_1 + aec_index_2) / area_index;
  922. if (aec_scale == 0)
  923. aec_scale = 1.0;
  924. aec_index_1 = aec_index_1 / aec_scale;
  925. aec_index_2 = aec_index_2 / aec_scale;
  926. }
  927. smalll_index_1 = smalll_index_1 / grainNumber_1;
  928. small_l_1 += smalll_index_1;//汇总直径
  929. small_count_1 += 1;//汇总晶粒个数
  930. area_sum_1 += aec_index_1;//汇总晶粒总面积
  931. area_view_1 += (area_index == 0 ? 100.0 : (aec_index_1 * 100.0 / area_index));//面积百分数
  932. dgvr.Cells[2].Value = smalll_index_1;//平均晶粒直径
  933. dgvr.Cells[3].Value = aec_index_1;//条带晶粒总面积
  934. dgvr.Cells[4].Value = area_index == 0 ? 100.0 : (aec_index_1 * 100.0 / area_index);//面积百分数
  935. dgvr.Cells[5].Value = getGradeValue(smalll_index_1);
  936. smalll_index_2 = smalll_index_2 / grainNumber_2;
  937. small_l_2 += smalll_index_2;//汇总直径
  938. small_count_2 += 1;//汇总晶粒个数
  939. area_sum_2 += aec_index_2;//汇总晶粒总面积
  940. area_view_2 += (area_index == 0 ? 100.0 : (aec_index_2 * 100.0 / area_index));//面积百分数
  941. dgvr.Cells[6].Value = smalll_index_2;//平均晶粒直径
  942. dgvr.Cells[7].Value = aec_index_2;//条带晶粒总面积
  943. dgvr.Cells[8].Value = area_index == 0 ? 100.0 : (aec_index_2 * 100.0 / area_index);//面积百分数
  944. dgvr.Cells[9].Value = getGradeValue(smalll_index_2);
  945. this.dataGridView2.Rows.Add(dgvr);
  946. }
  947. for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
  948. {
  949. System.Data.DataTable dataTable1 = dataTables[dataTableI];
  950. if (dataTable1.TableName.Equals(tag))/*dataTable.TableName*/
  951. dataTables.RemoveAt(dataTableI);
  952. }
  953. System.Data.DataTable dataTable = new System.Data.DataTable();
  954. dataTable.TableName = tag;
  955. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  956. {
  957. dataTable.Columns.Add(c.Name);
  958. }
  959. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  960. {
  961. System.Data.DataRow dataRow = dataTable.NewRow();
  962. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  963. {
  964. dataRow[this.dataGridView2.Columns[c].Name] = this.dataGridView2.Rows[r].Cells[c].Value;
  965. }
  966. dataTable.Rows.Add(dataRow);
  967. }
  968. this.dataTables.Add(dataTable);
  969. gradeValue_1 = getGradeValue(small_l_1 / Math.Max(1, small_count_1));
  970. gradeValue_2 = getGradeValue(small_l_2 / Math.Max(1, small_count_2));
  971. return new double[] { small_l_1 / Math.Max(1, small_count_1), area_sum_1, area_view_1 / Math.Max(1, small_count_1)/*, grade_v */
  972. ,small_l_2 / Math.Max(1, small_count_2), area_sum_2, area_view_2 / Math.Max(1, small_count_2)};//平均直径(μm)、汇总晶粒总面积(μm²)、面积比和对应级别
  973. //double small_l = 0;//汇总直径
  974. //int small_count = 0;//汇总晶粒个数
  975. //double area_sum = 0;//汇总晶粒总面积
  976. //double area_view = 0;//汇总视场总面积
  977. //double grade_v = 0;//对应级别
  978. }
  979. #region 需继承方法
  980. /// <summary>
  981. /// 保存参数
  982. /// </summary>
  983. protected override void saveSonData()
  984. {
  985. saveParamValue(ParamKey_ShowCheckGrainDiameter, comboBox4.SelectedIndex.ToString(), (int)Base.Dtryt.Interger);//晶粒直径
  986. saveParamValue(ParamKey_ShowGrainDiameter, Convert.ToDecimal(textBox1.Text).ToString(), (int)Base.Dtryt.Decimal);//晶粒直径
  987. saveParamValue(ParamKey_ShowRibbonCrystalGrain, checkBox_ShowAEC_Color.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示带状晶粒颜色
  988. saveParamValue(ParamKey_ShowRibbonCrystalGrainColor, panel1_1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);//颜色
  989. saveParamValue(ParamKey_ShowRibbonCrystalGrainDiameter, checkBox_ShowAECLengh.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示带状晶粒直径
  990. saveParamValue(ParamKey_ShowRibbonCrystalGrainDiameterFontSize, textBox1_1.Text, (int)Base.Dtryt.Interger);//字号
  991. saveParamValue(ParamKey_ShowRibbonCrystalGrainDiameterColor, panel1_2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);//颜色
  992. }
  993. /// <summary>
  994. /// 获取参数
  995. /// </summary>
  996. protected override void getSonData()
  997. {
  998. object ShowGrainBoundry;
  999. if (GetParamValue1(ParamKey_ShowCheckGrainDiameter, out ShowGrainBoundry))
  1000. comboBox4.SelectedIndex = Convert.ToInt32(ShowGrainBoundry);
  1001. if (GetParamValue1(ParamKey_ShowGrainDiameter, out ShowGrainBoundry))
  1002. textBox1.Text = ShowGrainBoundry.ToString();
  1003. if (GetParamValue1(ParamKey_ShowRibbonCrystalGrain, out ShowGrainBoundry))
  1004. checkBox_ShowAEC_Color.Checked = Convert.ToBoolean(ShowGrainBoundry);
  1005. if (GetParamValue1(ParamKey_ShowRibbonCrystalGrainColor, out ShowGrainBoundry))
  1006. panel1_1.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
  1007. if (GetParamValue1(ParamKey_ShowRibbonCrystalGrainDiameter, out ShowGrainBoundry))
  1008. checkBox_ShowAECLengh.Checked = Convert.ToBoolean(ShowGrainBoundry);
  1009. if (GetParamValue1(ParamKey_ShowRibbonCrystalGrainDiameterFontSize, out ShowGrainBoundry))
  1010. textBox1_1.Text = ShowGrainBoundry.ToString();
  1011. if (GetParamValue1(ParamKey_ShowRibbonCrystalGrainDiameterColor, out ShowGrainBoundry))
  1012. panel1_2.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
  1013. }
  1014. /// <summary>
  1015. /// 获取参数
  1016. /// </summary>
  1017. protected override object saveRecordingData(string key)
  1018. {
  1019. object value = null;
  1020. switch (key)
  1021. {
  1022. case "ShowCheckGrainDiameter":
  1023. value = comboBox4.SelectedIndex;
  1024. break;
  1025. case "ShowGrainDiameter":
  1026. value = textBox1.Text;
  1027. break;
  1028. case "ShowRibbonCrystalGrain":
  1029. value = checkBox_ShowAEC_Color.Checked;
  1030. break;
  1031. case "ShowRibbonCrystalGrainColor":
  1032. value = panel1_1.BackColor.ToArgb();
  1033. break;
  1034. case "ShowRibbonCrystalGrainDiameter":
  1035. value = checkBox_ShowAECLengh.Checked;
  1036. break;
  1037. case "ShowRibbonCrystalGrainDiameterFontSize":
  1038. value = textBox1_1.Text;
  1039. break;
  1040. case "ShowRibbonCrystalGrainDiameterColor":
  1041. value = panel1_2.BackColor.ToArgb();
  1042. break;
  1043. }
  1044. return value;
  1045. }
  1046. /// <summary>
  1047. /// 保存结果
  1048. /// </summary>
  1049. protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
  1050. {
  1051. if (!saveAll)
  1052. {
  1053. if (this.matOrg == null)
  1054. {
  1055. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  1056. return;
  1057. }
  1058. }
  1059. string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
  1060. string tag = imagesKey;
  1061. bool replace = false;
  1062. int add = 0;
  1063. foreach (ListViewItem item in this.listView2.Items)
  1064. {
  1065. if (item.Tag.Equals(tag))
  1066. {
  1067. add++;
  1068. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1069. if (dr == DialogResult.OK)
  1070. {
  1071. replace = true;
  1072. }
  1073. break;
  1074. }
  1075. }
  1076. if (!replace && this.listView2.Items.Count > 0 && add > 0)
  1077. return;
  1078. if (!replace)
  1079. {
  1080. ListViewItem listViewItem = new ListViewItem();
  1081. listViewItem.SubItems[0].Text = imgName;
  1082. listViewItem.Tag = "" + tag;
  1083. if (this.listView2.Items.Count == 0)
  1084. this.listView2.Items.Add(listViewItem);
  1085. else
  1086. this.listView2.Items.Insert(0, listViewItem);
  1087. }
  1088. if (analysisPicture != this.selectPicture)//更新二值图片
  1089. binaryClass.updateAnalysisData(imagesKey, analysisPicture);
  1090. //组织详细数据列表的内容,获取截距和面积后,再进行平均的计算
  1091. GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
  1092. if (imagesKey != null)
  1093. {
  1094. if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
  1095. {
  1096. this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
  1097. cal_StandardModel = this.GSSClass.standardDict[imagesKey];
  1098. }
  1099. if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
  1100. {
  1101. this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
  1102. cal_StandardModel = this.GSSClass.standardDict[imagesKey];
  1103. }
  1104. }
  1105. Bitmap bitmap = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  1106. hasView = this.appWorkspace.DocumentWorkspaces[analysisPicture].GraphicsList.IsExsitView();
  1107. double ruler = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron);
  1108. string gradeValue1, gradeValue2;
  1109. double[] res_arr = addNewRowsToDatagridView2(cal_StandardModel,imgName,tag, ruler, out gradeValue1, out gradeValue2);
  1110. //double small_l = res_arr[0];
  1111. //double area_l = aec0;// res_arr[1];
  1112. this.dataGridView_Total.Rows.Clear();
  1113. DataGridViewRow dgvr = new DataGridViewRow();
  1114. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  1115. {
  1116. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  1117. }
  1118. dgvr.Cells[0].Value = res_arr[0];
  1119. dgvr.Cells[1].Value = res_arr[1];
  1120. dgvr.Cells[2].Value = res_arr[2];
  1121. dgvr.Cells[3].Value = gradeValue1;
  1122. dgvr.Cells[4].Value = res_arr[3];
  1123. dgvr.Cells[5].Value = res_arr[4];
  1124. dgvr.Cells[6].Value = res_arr[5];
  1125. dgvr.Cells[7].Value = gradeValue2;
  1126. this.dataGridView_Total.Rows.Add(dgvr);
  1127. System.Data.DataTable dataTable = new System.Data.DataTable();
  1128. dataTable.TableName = tag;
  1129. foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
  1130. {
  1131. if (dataTable1.TableName.Equals(dataTable.TableName))
  1132. {
  1133. dataTable_Totals.Remove(dataTable1);
  1134. break;
  1135. }
  1136. }
  1137. foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
  1138. {
  1139. dataTable.Columns.Add(c.Name);
  1140. }
  1141. for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
  1142. {
  1143. System.Data.DataRow dataRow = dataTable.NewRow();
  1144. for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
  1145. {
  1146. dataRow[this.dataGridView_Total.Columns[c].Name] = this.dataGridView_Total.Rows[r].Cells[c].Value;
  1147. }
  1148. dataTable.Rows.Add(dataRow);
  1149. }
  1150. this.dataTable_Totals.Add(dataTable);
  1151. //to youhua//###############################
  1152. this.RefreshDataGridView4();
  1153. //保存处理后的图片
  1154. double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.selectPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1155. List<Bitmap> tempBit = new List<Bitmap>();
  1156. Bitmap originalBit = this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1157. originalBit.Tag = pantographRatio;
  1158. tempBit.Add(originalBit);
  1159. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1160. Graphics graphics = Graphics.FromImage(newBit);
  1161. //if (true)
  1162. //{ }//0914###18810
  1163. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  1164. {
  1165. Mat targetMat = this.PhaseModel0Mat;
  1166. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1167. }
  1168. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  1169. {
  1170. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  1171. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1172. }
  1173. if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null)
  1174. {
  1175. Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
  1176. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1177. }
  1178. graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  1179. drawSubclass/*Draw*/(graphics);
  1180. newBit.Tag = pantographRatio;
  1181. tempBit.Add(newBit);
  1182. if (bitDic.ContainsKey(tag))
  1183. bitDic[tag] = tempBit;
  1184. else
  1185. bitDic.Add(tag, tempBit);
  1186. //拼接中间数据
  1187. List<List<string>> dataList = new List<List<string>>();
  1188. List<string> columnName = new List<string>();
  1189. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  1190. columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
  1191. columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
  1192. columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
  1193. dataList.Add(columnName);
  1194. if (GSSClass.standardModel.massLabelPoints.Count > 0)
  1195. {
  1196. int index = 0;
  1197. int outMaxIndex = GSSClass.standardModel.massLabelPoints.Count - 0 - GSSClass.standardModel.within;
  1198. foreach (var item in GSSClass.standardModel.massLabelPoints.Values)//####################
  1199. {
  1200. List<string> strList = new List<string>();
  1201. strList.Add(("" + (++index)).ToString());
  1202. strList.Add(item[2].ToString());
  1203. strList.Add(item[3].ToString());
  1204. if (outMaxIndex < index)
  1205. strList.Add(PdnResources.GetString("Menu.Yes.text"));
  1206. else
  1207. strList.Add(PdnResources.GetString("Menu.no.text"));
  1208. dataList.Add(strList);
  1209. }
  1210. }
  1211. bool isExist = false;//是否已存在进行替换
  1212. int modelIndex = -1;//要替换的下标
  1213. for (int j = 0; j < tempDataModel.Count; j++)
  1214. {
  1215. if (tempDataModel[j].tagName.Equals(tag))
  1216. {
  1217. isExist = true;
  1218. modelIndex = j;
  1219. break;
  1220. }
  1221. }
  1222. if (isExist && modelIndex > -1)
  1223. tempDataModel[modelIndex].dataList = dataList;
  1224. else
  1225. {
  1226. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  1227. newModel.tagName = tag;
  1228. newModel.picName = imgName;
  1229. newModel.dataList = dataList;
  1230. tempDataModel.Add(newModel);
  1231. }
  1232. }
  1233. ////数据库的name(报告模板)
  1234. //protected override string getTemplateName()
  1235. //{
  1236. // return "Template.Manager.item3.GrainSizeArea214999Method";//#################################
  1237. //}
  1238. //语言包的name(项目工程)
  1239. protected override string getProjectEngineeringName()
  1240. {
  1241. return "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text";
  1242. }
  1243. ////配置文件名称(辅助线)
  1244. //protected override string getModelName()
  1245. //{
  1246. // return "GrainSizeGuideAreaMethodModel.xml";
  1247. //}
  1248. //辅助线类型名称
  1249. protected override string[] getTypeNames()
  1250. {
  1251. return new string[] {
  1252. PdnResources.GetString("Menu.circular.Text"),
  1253. PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text")};
  1254. }
  1255. protected override void SubclassInitialize()
  1256. {
  1257. InitializeComponent();
  1258. }
  1259. /// <summary>
  1260. /// 小数点位数后调用的事件
  1261. /// </summary>
  1262. protected override void RefreshWhileUpDown1_0ValueChanged()
  1263. {
  1264. this.documentWorkspace.Refresh();
  1265. }
  1266. //切换图片时控制前一张图的信息不遗留显示
  1267. protected override void refreshWhileImgChanged()
  1268. {
  1269. if (this.bitmap != null && matOrg != null)
  1270. {
  1271. try
  1272. {
  1273. this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && checkBox_ShowAEC_Color.Checked);
  1274. if (checkBox_ShowAEC_Color.Checked || checkBox_ShowAECLengh.Checked)
  1275. {
  1276. Bitmap bitmap = this.documentWorkspace.CompositionSurface.CreateAliasedBitmap();
  1277. saveMat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  1278. if (binaryClass.PhaseModels0Mat != null)
  1279. {
  1280. phaseMat = binaryClass.PhaseModels0Mat;
  1281. }
  1282. else
  1283. {
  1284. phaseMat = this.documentWorkspace.phaseModels[0].mat;
  1285. }
  1286. GetClassNumberOfGrains();
  1287. }
  1288. else
  1289. this.documentWorkspace.Refresh();
  1290. }
  1291. catch (Exception)
  1292. {
  1293. }
  1294. }
  1295. else
  1296. {
  1297. this.documentWorkspace.PhaseModels[2].mat = null;//清空前一张图的信息不遗留显示
  1298. GSSClass.standardModel.massLabelPoints.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
  1299. //1013###18808(切换图片的时候前一张图的信息不遗留显示)
  1300. this.documentWorkspace.Refresh();
  1301. }
  1302. }
  1303. /// <summary>
  1304. /// 是否用不同颜色显示晶粒
  1305. /// </summary>
  1306. /// <returns></returns>
  1307. protected override Boolean ShowGrainColorChecked()
  1308. {
  1309. return checkBox_ShowAEC_Color.Checked;
  1310. }
  1311. /// <summary>
  1312. /// 是否显示视场
  1313. /// </summary>
  1314. /// <returns></returns>
  1315. protected override Boolean ShowDrawClassView()
  1316. {
  1317. return true;
  1318. }
  1319. protected override void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
  1320. {
  1321. //显示带状晶粒直径
  1322. if (!checkBox_ShowAECLengh.Checked || GSSClass.standardModel.massLabelPointsList.Count == 0 || GSSClass.standardModel.currentNccompSelectList.Count == 0 || GSSClass.standardModel.currentNccompSelectList.Count != GSSClass.standardModel.massLabelPointsList.Count)
  1323. return;
  1324. for (int matIndex = 0; matIndex < GSSClass.standardModel.massLabelPointsList.Count; matIndex++)
  1325. {
  1326. Dictionary<int, List<double>> massLabelPoints = GSSClass.standardModel.massLabelPointsList[matIndex];
  1327. ArrayList currentNccompSelect = GSSClass.standardModel.currentNccompSelectList[matIndex];
  1328. int index = 0;
  1329. float fontsize;
  1330. if (!float.TryParse(this.textBox1_1.Text.ToString(), out fontsize))
  1331. fontsize = 12;
  1332. Font myFont = new Font("宋体", fontsize);
  1333. Brush bush = new SolidBrush(this.panel1_2.BackColor);//填充的颜色
  1334. foreach (var item in massLabelPoints.Values)
  1335. {
  1336. index += 1;//should == label!
  1337. if (currentNccompSelect.Contains(index))
  1338. graphics.DrawString("" + DecnumString(item[0].ToString())/*index*/, myFont, bush, (float)item[2] - 5, (float)item[3] - 5);
  1339. }
  1340. }
  1341. }
  1342. /// <summary>
  1343. /// PanelC的调色板颜色改变
  1344. /// </summary>
  1345. protected override void ColorPanelChanged(Panel panel)
  1346. {
  1347. //根据等级设置晶粒颜色
  1348. if (panel == this.panel1_1)
  1349. setMat2ColorOfLabelMat(/*nccomps*/);
  1350. else
  1351. this.documentWorkspace.Refresh();
  1352. }
  1353. #endregion
  1354. }
  1355. }