MethodAreaDialog.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Drawing.Drawing2D;
  11. using System.Windows.Forms;
  12. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.YST347
  13. {
  14. internal class MethodAreaDialog : GrainSizeStandardDialog
  15. {
  16. #region 组件
  17. private GroupBox groupBox11;
  18. private Button button4;
  19. private Button button2;
  20. private CheckBox checkBox11;
  21. private CheckBox checkBox5_0;
  22. private CheckBox checkBox4_0;
  23. private CheckBox checkBox3_0;
  24. private DataGridViewTextBoxColumn ColumnTotal1;
  25. private DataGridViewTextBoxColumn ColumnTotal2;
  26. private DataGridViewTextBoxColumn ColumnTotal3;
  27. private GroupBox groupBox7;
  28. private Button button10;
  29. private Button button3;
  30. private Button button8;
  31. private RadioButton radioButton5;
  32. private RadioButton radioButton4;
  33. private RadioButton radioButton3;
  34. private RadioButton radioButton_DarkGray;
  35. #endregion 组件
  36. #region 构造函数
  37. public MethodAreaDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, new Base.DedicatedAnalysis.GrainSize.Standard.YST347.MethodArea())
  38. {
  39. }
  40. #endregion 构造函数
  41. #region 初始化组件
  42. private void InitializeLanguageText()
  43. {
  44. this.radioButton_DarkGray.Text = PdnResources.GetString("Menu.Darkgray.text");
  45. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  46. this.button4.Text = PdnResources.GetString("Menu.Refresh.text");
  47. this.button2.Text = PdnResources.GetString("Menu.Setting.Text");
  48. this.checkBox11.Text = PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text");
  49. this.checkBox5_0.Text = PdnResources.GetString("Menu.Displaygrainnumber.text");
  50. this.checkBox4_0.Text = PdnResources.GetString("Menu.displaygrid.text");
  51. this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  52. this.Text = "YST347(" + PdnResources.GetString("Menu.Areamethod.text") + ")";
  53. this.Load += new System.EventHandler(this.MethodAreaDialog_Load);
  54. }
  55. private DataGridViewTextBoxColumn Column1;
  56. private DataGridViewTextBoxColumn Column2;
  57. private DataGridViewTextBoxColumn Column3;
  58. private DataGridViewTextBoxColumn Column4;
  59. private DataGridViewTextBoxColumn Column5;
  60. private void MethodAreaDialog_Load(object sender, EventArgs e)
  61. {
  62. //this.button_ApplyToAll.Visible = false;
  63. //this.button_SaveAll.Visible = false;
  64. //this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
  65. //this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
  66. object ShowGrainBoundry;
  67. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
  68. this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
  69. if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
  70. this.checkBox4_0.Checked = (bool)ShowGrainBoundry;
  71. if (GetParamValue1(ParamKey_ShowGrainNumber, out ShowGrainBoundry))//显示晶粒编号
  72. this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
  73. if (GetParamValue1(ParamKey_ShowGrainColor, out ShowGrainBoundry))//用不同颜色显示晶粒
  74. this.checkBox11.Checked = (bool)ShowGrainBoundry;
  75. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  76. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  77. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  78. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  79. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  80. this.Column1.Name = "Column1";
  81. this.Column1.ReadOnly = true;
  82. //
  83. // Column2
  84. //
  85. this.Column2.Name = "Column2";
  86. this.Column2.ReadOnly = true;
  87. //
  88. // Column3
  89. //
  90. this.Column3.Name = "Column3";
  91. this.Column3.ReadOnly = true;
  92. //
  93. // Column4
  94. //
  95. this.Column4.Name = "Column4";
  96. this.Column4.ReadOnly = true;
  97. //
  98. // Column5
  99. //
  100. this.Column5.Name = "Column5";
  101. this.Column5.ReadOnly = true;
  102. this.Column5.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  103. this.Column4.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
  104. this.Column3.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
  105. this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
  106. this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  107. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  108. this.Column1,
  109. this.Column2,
  110. this.Column3,
  111. this.Column4,
  112. this.Column5});
  113. this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  114. this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  115. this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  116. this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  117. this.ColumnTotal1,
  118. this.ColumnTotal2,
  119. this.ColumnTotal3});
  120. //
  121. // ColumnTotal1
  122. //
  123. this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
  124. this.ColumnTotal1.Name = "ColumnTotal1";
  125. this.ColumnTotal1.ReadOnly = true;
  126. //
  127. // ColumnTotal2
  128. //
  129. this.ColumnTotal2.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
  130. this.ColumnTotal2.Name = "ColumnTotal2";
  131. this.ColumnTotal2.ReadOnly = true;
  132. //
  133. // ColumnTotal3
  134. //
  135. this.ColumnTotal3.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  136. this.ColumnTotal3.Name = "ColumnTotal3";
  137. this.ColumnTotal3.ReadOnly = true;
  138. DetailListStringIndex.Add(0);
  139. DetailListStringIndex.Add(1);
  140. DetailListStringIndex.Add(3);
  141. //DetailListStringIndex.Add(4/*5*/);//##############20734
  142. DetailListNotDoubleIndex.Add(0);
  143. DetailListNotDoubleIndex.Add(1);
  144. DetailListNotDoubleIndex.Add(3);
  145. IndexChangedFromIndex.Clear();
  146. IndexChangedToIndex.Clear();
  147. IndexChangedFromIndex.Add(2);
  148. IndexChangedFromIndex.Add(3);
  149. IndexChangedToIndex.Add(0, new int[] { 2/*1*/, 0 });//求和
  150. IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//求和
  151. //IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
  152. IndexChangedToIndex.Add(2, new int[] { 3, -1/*0*/ });//级别
  153. this.button3.FlatStyle = FlatStyle.Flat;
  154. this.button3.FlatAppearance.BorderSize = 0;
  155. this.button3.BackgroundImageLayout = ImageLayout.Zoom;
  156. this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
  157. this.button3.Click += new EventHandler(this.button3_click);
  158. this.button10.FlatStyle = FlatStyle.Flat;
  159. this.button10.FlatAppearance.BorderSize = 0;
  160. this.button10.BackgroundImageLayout = ImageLayout.Zoom;
  161. this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  162. this.button10.Click += new EventHandler(this.button10_click);
  163. this.button8.FlatStyle = FlatStyle.Flat;
  164. this.button8.FlatAppearance.BorderSize = 0;
  165. this.button8.BackgroundImageLayout = ImageLayout.Zoom;
  166. this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  167. this.button8.Click += new EventHandler(this.button8_click);
  168. getSonData();
  169. }
  170. /// <summary>
  171. /// 获取参数
  172. /// </summary>
  173. protected override void getSonData()
  174. {
  175. object ShowGrainBoundry;
  176. if (GetParamValue1(ParamKey_TargetSelection, out ShowGrainBoundry))//目标选择
  177. {
  178. int value = Convert.ToInt32(ShowGrainBoundry);
  179. switch (value)
  180. {
  181. case 1:
  182. this.button8_click(null, null);
  183. break;
  184. case 2:
  185. this.button3_click(null, null);
  186. break;
  187. case 3:
  188. this.button10_click(null, null);
  189. break;
  190. }
  191. }
  192. }
  193. private void button3_click(object sender, EventArgs e)
  194. {
  195. this.TargetSelection = 2;
  196. this.radioButton4.Checked = true;
  197. this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
  198. this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  199. this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  200. }
  201. private void button10_click(object sender, EventArgs e)
  202. {
  203. this.TargetSelection = 3;
  204. this.radioButton5.Checked = true;
  205. this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
  206. this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
  207. this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  208. }
  209. private void button8_click(object sender, EventArgs e)
  210. {
  211. this.TargetSelection = 1;
  212. this.radioButton3.Checked = true;
  213. this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
  214. this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
  215. this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
  216. }
  217. /// <summary>
  218. /// 计算汇总列表的平均晶粒度级别
  219. /// </summary>
  220. /// <returns></returns>
  221. protected override string getGradeTotalCal(DataGridViewRow dgvr, int digits)
  222. {
  223. double aec = double.Parse(dgvr.Cells[0].Value.ToString());
  224. double grainNumber = double.Parse(dgvr.Cells[1].Value.ToString());
  225. aec = aec * 0.001 * 0.001;
  226. decimal M = 1;// this.getGainMultiple();
  227. double small_l = (grainNumber * (double)M * (double)M) / aec;
  228. return "" + Math.Round(3.3219 * Math.Log10(small_l) - 2.9542, digits);
  229. }
  230. private void InitializeComponent()
  231. {
  232. this.radioButton_DarkGray = new System.Windows.Forms.RadioButton();
  233. this.groupBox11 = new System.Windows.Forms.GroupBox();
  234. this.button2 = new System.Windows.Forms.Button();
  235. this.button4 = new System.Windows.Forms.Button();
  236. this.checkBox11 = new System.Windows.Forms.CheckBox();
  237. this.checkBox5_0 = new System.Windows.Forms.CheckBox();
  238. this.checkBox4_0 = new System.Windows.Forms.CheckBox();
  239. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  240. this.groupBox7 = new System.Windows.Forms.GroupBox();
  241. this.button10 = new System.Windows.Forms.Button();
  242. this.button3 = new System.Windows.Forms.Button();
  243. this.button8 = new System.Windows.Forms.Button();
  244. this.radioButton5 = new System.Windows.Forms.RadioButton();
  245. this.radioButton4 = new System.Windows.Forms.RadioButton();
  246. this.radioButton3 = new System.Windows.Forms.RadioButton();
  247. this.groupBox_img.SuspendLayout();
  248. this.groupBox_analysisResult1.SuspendLayout();
  249. this.groupBox3.SuspendLayout();
  250. this.groupBox11.SuspendLayout();
  251. this.groupBox7.SuspendLayout();
  252. this.SuspendLayout();
  253. //
  254. // radioButton_DarkGray
  255. //
  256. this.radioButton_DarkGray.AutoSize = true;
  257. this.radioButton_DarkGray.Location = new System.Drawing.Point(178, 20);
  258. this.radioButton_DarkGray.Name = "radioButton_DarkGray";
  259. this.radioButton_DarkGray.Size = new System.Drawing.Size(59, 16);
  260. this.radioButton_DarkGray.TabIndex = 38;
  261. this.radioButton_DarkGray.TabStop = true;
  262. this.radioButton_DarkGray.UseVisualStyleBackColor = true;
  263. //
  264. // groupBox11
  265. //
  266. this.groupBox11.Controls.Add(this.button2);
  267. this.groupBox11.Controls.Add(this.button4);
  268. this.groupBox11.Controls.Add(this.checkBox11);
  269. this.groupBox11.Controls.Add(this.checkBox5_0);
  270. this.groupBox11.Controls.Add(this.checkBox4_0);
  271. this.groupBox11.Controls.Add(this.checkBox3_0);
  272. this.groupBox11.Location = new System.Drawing.Point(179, 373);
  273. this.groupBox11.Name = "groupBox11";
  274. this.groupBox11.Size = new System.Drawing.Size(356, 71);
  275. this.groupBox11.TabIndex = 38;
  276. this.groupBox11.TabStop = false;
  277. //
  278. // button2
  279. //
  280. this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  281. this.button2.Location = new System.Drawing.Point(271, 41);
  282. this.button2.Name = "button2";
  283. this.button2.Size = new System.Drawing.Size(75, 22);
  284. this.button2.TabIndex = 19;
  285. this.button2.UseVisualStyleBackColor = true;
  286. this.button2.Click += new System.EventHandler(this.button2_Click);
  287. //
  288. // button4
  289. //
  290. this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
  291. this.button4.Location = new System.Drawing.Point(271, 17);
  292. this.button4.Name = "button4";
  293. this.button4.Size = new System.Drawing.Size(75, 22);
  294. this.button4.TabIndex = 18;
  295. this.button4.UseVisualStyleBackColor = true;
  296. this.button4.Click += new System.EventHandler(this.button4_Click);
  297. //
  298. // checkBox11
  299. //
  300. this.checkBox11.AutoSize = true;
  301. this.checkBox11.Checked = true;
  302. this.checkBox11.CheckState = System.Windows.Forms.CheckState.Checked;
  303. this.checkBox11.Location = new System.Drawing.Point(139, 44);
  304. this.checkBox11.Name = "checkBox11";
  305. this.checkBox11.Size = new System.Drawing.Size(15, 14);
  306. this.checkBox11.TabIndex = 3;
  307. this.checkBox11.UseVisualStyleBackColor = true;
  308. this.checkBox11.CheckedChanged += new System.EventHandler(this.checkBox11_CheckedChanged);
  309. //
  310. // checkBox5_0
  311. //
  312. this.checkBox5_0.AutoSize = true;
  313. this.checkBox5_0.Checked = true;
  314. this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
  315. this.checkBox5_0.Location = new System.Drawing.Point(140, 22);
  316. this.checkBox5_0.Name = "checkBox5_0";
  317. this.checkBox5_0.Size = new System.Drawing.Size(15, 14);
  318. this.checkBox5_0.TabIndex = 2;
  319. this.checkBox5_0.UseVisualStyleBackColor = true;
  320. this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
  321. //
  322. // checkBox4_0
  323. //
  324. this.checkBox4_0.AutoSize = true;
  325. this.checkBox4_0.Checked = true;
  326. this.checkBox4_0.CheckState = System.Windows.Forms.CheckState.Checked;
  327. this.checkBox4_0.Location = new System.Drawing.Point(15, 44);
  328. this.checkBox4_0.Name = "checkBox4_0";
  329. this.checkBox4_0.Size = new System.Drawing.Size(15, 14);
  330. this.checkBox4_0.TabIndex = 1;
  331. this.checkBox4_0.UseVisualStyleBackColor = true;
  332. this.checkBox4_0.CheckedChanged += new System.EventHandler(this.checkBox4_0_CheckedChanged);
  333. //
  334. // checkBox3_0
  335. //
  336. this.checkBox3_0.AutoSize = true;
  337. this.checkBox3_0.Checked = true;
  338. this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
  339. this.checkBox3_0.Location = new System.Drawing.Point(15, 22);
  340. this.checkBox3_0.Name = "checkBox3_0";
  341. this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
  342. this.checkBox3_0.TabIndex = 0;
  343. this.checkBox3_0.UseVisualStyleBackColor = true;
  344. this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
  345. //
  346. // groupBox7
  347. //
  348. this.groupBox7.Controls.Add(this.button10);
  349. this.groupBox7.Controls.Add(this.button3);
  350. this.groupBox7.Controls.Add(this.button8);
  351. this.groupBox7.Controls.Add(this.radioButton5);
  352. this.groupBox7.Controls.Add(this.radioButton4);
  353. this.groupBox7.Controls.Add(this.radioButton3);
  354. this.groupBox7.Location = new System.Drawing.Point(179, 450);
  355. this.groupBox7.Name = "groupBox7";
  356. this.groupBox7.Size = new System.Drawing.Size(356, 77);
  357. this.groupBox7.TabIndex = 41;
  358. this.groupBox7.TabStop = false;
  359. this.groupBox7.Text = "目标选择";
  360. //
  361. // button10
  362. //
  363. this.button10.Location = new System.Drawing.Point(60, 21);
  364. this.button10.Name = "button10";
  365. this.button10.Size = new System.Drawing.Size(40, 40);
  366. this.button10.TabIndex = 5;
  367. this.button10.UseVisualStyleBackColor = true;
  368. //
  369. // button3
  370. //
  371. this.button3.Location = new System.Drawing.Point(14, 21);
  372. this.button3.Name = "button3";
  373. this.button3.Size = new System.Drawing.Size(40, 40);
  374. this.button3.TabIndex = 4;
  375. this.button3.UseVisualStyleBackColor = true;
  376. //
  377. // button8
  378. //
  379. this.button8.Location = new System.Drawing.Point(106, 21);
  380. this.button8.Name = "button8";
  381. this.button8.Size = new System.Drawing.Size(40, 40);
  382. this.button8.TabIndex = 3;
  383. this.button8.UseVisualStyleBackColor = true;
  384. this.button8.Visible = false;
  385. //
  386. // radioButton5
  387. //
  388. this.radioButton5.AutoSize = true;
  389. this.radioButton5.Location = new System.Drawing.Point(238, 55);
  390. this.radioButton5.Name = "radioButton5";
  391. this.radioButton5.Size = new System.Drawing.Size(14, 13);
  392. this.radioButton5.TabIndex = 2;
  393. this.radioButton5.UseVisualStyleBackColor = true;
  394. this.radioButton5.Visible = false;
  395. //
  396. // radioButton4
  397. //
  398. this.radioButton4.AutoSize = true;
  399. this.radioButton4.Checked = true;
  400. this.radioButton4.Location = new System.Drawing.Point(297, 44);
  401. this.radioButton4.Name = "radioButton4";
  402. this.radioButton4.Size = new System.Drawing.Size(14, 13);
  403. this.radioButton4.TabIndex = 1;
  404. this.radioButton4.TabStop = true;
  405. this.radioButton4.UseVisualStyleBackColor = true;
  406. this.radioButton4.Visible = false;
  407. //
  408. // radioButton3
  409. //
  410. this.radioButton3.AutoSize = true;
  411. this.radioButton3.Location = new System.Drawing.Point(279, 21);
  412. this.radioButton3.Name = "radioButton3";
  413. this.radioButton3.Size = new System.Drawing.Size(14, 13);
  414. this.radioButton3.TabIndex = 0;
  415. this.radioButton3.UseVisualStyleBackColor = true;
  416. this.radioButton3.Visible = false;
  417. //
  418. // MethodAreaDialog
  419. //
  420. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  421. this.ClientSize = new System.Drawing.Size(1127, 810);
  422. this.Controls.Add(this.groupBox7);
  423. this.Controls.Add(this.groupBox11);
  424. this.Name = "MethodAreaDialog";
  425. this.Controls.SetChildIndex(this.groupBox3, 0);
  426. this.Controls.SetChildIndex(this.groupBox_img, 0);
  427. this.Controls.SetChildIndex(this.groupBox_review, 0);
  428. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  429. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  430. this.Controls.SetChildIndex(this.groupBox_report, 0);
  431. this.Controls.SetChildIndex(this.groupBox11, 0);
  432. this.Controls.SetChildIndex(this.groupBox7, 0);
  433. this.groupBox_img.ResumeLayout(false);
  434. this.groupBox_analysisResult1.ResumeLayout(false);
  435. this.groupBox3.ResumeLayout(false);
  436. this.groupBox11.ResumeLayout(false);
  437. this.groupBox11.PerformLayout();
  438. this.groupBox7.ResumeLayout(false);
  439. this.groupBox7.PerformLayout();
  440. this.ResumeLayout(false);
  441. }
  442. #endregion 初始化组件
  443. #region 需继承方法
  444. protected override Boolean ShowGrainBoundryChecked()
  445. {
  446. return !showOrimat() && checkBox3_0.Checked;
  447. }
  448. protected override void refreshWhileImgChanged()
  449. {
  450. if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
  451. this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()];
  452. if (this.imageMat != null && this.documentWorkspace.PhaseModels[2].mat != null)
  453. {
  454. //try
  455. //{
  456. // GetNumberOfGrains();
  457. //}
  458. //catch (Exception)
  459. //{
  460. //}
  461. }
  462. else
  463. {
  464. this.documentWorkspace.PhaseModels[2].mat = null;//清空前一张图的信息不遗留显示##效果考虑优化
  465. GSSClass.standardModel.massLabelPoints.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
  466. this.documentWorkspace.Refresh();
  467. }
  468. }
  469. /// <summary>
  470. /// 是否用不同颜色显示晶粒
  471. /// </summary>
  472. /// <returns></returns>
  473. protected override Boolean ShowGrainColorChecked()
  474. {
  475. return checkBox11.Checked;
  476. }
  477. /// <summary>
  478. /// 保存结果
  479. /// </summary>
  480. protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
  481. {
  482. if (this.imageMat == null)
  483. {
  484. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  485. return;
  486. }
  487. if (this.comboBox1.SelectedItem != null && !PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
  488. {
  489. string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
  490. string tag = imagesKey;
  491. System.Data.DataTable dataTable = new System.Data.DataTable();
  492. bool replace = false;
  493. int add = 0;
  494. foreach (ListViewItem item in this.listView2.Items)
  495. {
  496. if (item.Tag.Equals(tag))
  497. {
  498. add++;
  499. if (saveAll)
  500. {
  501. replace = true;
  502. break;
  503. }
  504. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  505. if (dr == DialogResult.OK)
  506. {
  507. replace = true;
  508. }
  509. break;
  510. }
  511. }
  512. if (replace || this.listView2.Items.Count == 0 || add == 0)
  513. {
  514. if (!replace)
  515. {
  516. ListViewItem listViewItem = new ListViewItem();
  517. listViewItem.SubItems[0].Text = imgName;
  518. listViewItem.Tag = "" + tag;
  519. if (this.listView2.Items.Count == 0)
  520. this.listView2.Items.Add(listViewItem);
  521. else
  522. this.listView2.Items.Insert(0, listViewItem);
  523. }
  524. this.dataGridView2.Rows.Clear();
  525. DataGridViewRow dgvr = new DataGridViewRow();
  526. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  527. {
  528. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  529. }
  530. dgvr.Cells[0].Value = imgName;
  531. dgvr.Cells[1].Value = this.comboBox1.SelectedItem;
  532. if (analysisPicture != this.selectPicture)//更新二值图片
  533. binaryClass.updateAnalysisData(imagesKey, analysisPicture);
  534. GrainSizeGuideModel cal_GuideModel = this.GSSClass.GuideClass.guideModel;
  535. if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
  536. cal_GuideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
  537. if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
  538. this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
  539. if (cal_GuideModel.oldSelectItem == null)//##
  540. cal_GuideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
  541. GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
  542. if (imagesKey != null)
  543. {
  544. if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
  545. this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
  546. cal_StandardModel = this.GSSClass.standardDict[imagesKey];
  547. if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
  548. this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
  549. }
  550. // 是否矩形辅助线
  551. int isRect;
  552. double aec = GSSClass.GuideClass.guideArea(cal_GuideModel, cal_GuideModel.oldSelectItem, out isRect, 0/*this.gbtType*/);
  553. dgvr.Cells[2].Value = aec;
  554. aec = aec * 0.001 * 0.001;
  555. double grainNumber = GetNumberOfGrains(/*#########*/cal_StandardModel, cal_GuideModel, imagesKey, this.selectPicture);
  556. if (grainNumber > (int)grainNumber)
  557. {
  558. grainNumber = grainNumber + 0.5;
  559. }
  560. dgvr.Cells[3].Value = grainNumber;
  561. decimal M = 1;// this.getGainMultiple();
  562. double small_l = (grainNumber * (double)M * (double)M) / aec;
  563. dgvr.Cells[4].Value = 3.3219 * Math.Log10(small_l) - 2.9542;
  564. this.dataGridView2.Rows.Add(dgvr);
  565. dataTable.TableName = tag;
  566. foreach (System.Data.DataTable dataTable1 in dataTables)
  567. {
  568. if (dataTable1.TableName.Equals(dataTable.TableName))
  569. {
  570. dataTables.Remove(dataTable1);
  571. break;
  572. }
  573. }
  574. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  575. {
  576. dataTable.Columns.Add(c.HeaderText);
  577. }
  578. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  579. {
  580. DataRow dataRow = dataTable.NewRow();
  581. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  582. {
  583. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
  584. }
  585. dataTable.Rows.Add(dataRow);
  586. }
  587. this.dataTables.Add(dataTable);
  588. this.RefreshDataGridView4();
  589. //保存处理后的图片
  590. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  591. List<Bitmap> tempBit = new List<Bitmap>();
  592. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
  593. originalBit.Tag = pantographRatio;
  594. tempBit.Add(originalBit);
  595. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  596. Graphics graphics = Graphics.FromImage(newBit);
  597. //if (true)
  598. //{ }//0914###18810
  599. if (binaryClass.getModelMat(imagesKey) != null)
  600. {
  601. Mat targetMat = binaryClass.getModelMat(imagesKey);
  602. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  603. }
  604. if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
  605. {
  606. Mat targetMat = this.grainBoundaryMatDict[imagesKey];
  607. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  608. }
  609. if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
  610. {
  611. Mat targetMat = this.grainColorsMatDict[imagesKey];
  612. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  613. }
  614. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  615. drawSubclass/*Draw*/(graphics);
  616. newBit.Tag = pantographRatio;
  617. tempBit.Add(newBit);
  618. if (bitDic.ContainsKey(tag))
  619. bitDic[tag] = tempBit;
  620. else
  621. bitDic.Add(tag, tempBit);
  622. //拼接中间数据
  623. List<List<string>> dataList = new List<List<string>>();
  624. List<string> columnName = new List<string>();
  625. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  626. columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
  627. columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
  628. columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
  629. dataList.Add(columnName);
  630. if (cal_StandardModel.massLabelPoints.Count > 0)
  631. {
  632. int index = 0;
  633. int outMaxIndex = cal_StandardModel.massLabelPoints.Count - 0 - cal_StandardModel.within;
  634. foreach (var item in cal_StandardModel.massLabelPoints.Values)
  635. {
  636. List<string> strList = new List<string>();
  637. strList.Add(("" + (++index)).ToString());
  638. strList.Add(item[2].ToString());
  639. strList.Add(item[3].ToString());
  640. if (outMaxIndex < index)
  641. strList.Add(PdnResources.GetString("Menu.Yes.text"));
  642. else
  643. strList.Add(PdnResources.GetString("Menu.no.text"));
  644. dataList.Add(strList);
  645. }
  646. }
  647. bool isExist = false;//是否已存在进行替换
  648. int modelIndex = -1;//要替换的下标
  649. for (int j = 0; j < tempDataModel.Count; j++)
  650. {
  651. if (tempDataModel[j].tagName.Equals(tag))
  652. {
  653. isExist = true;
  654. modelIndex = j;
  655. break;
  656. }
  657. }
  658. if (isExist && modelIndex > -1)
  659. tempDataModel[modelIndex].dataList = dataList;
  660. else
  661. {
  662. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  663. newModel.tagName = tag;
  664. newModel.picName = imgName;
  665. newModel.dataList = dataList;
  666. tempDataModel.Add(newModel);
  667. }
  668. }
  669. }
  670. else
  671. {
  672. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text")+"!");
  673. }
  674. }
  675. protected override void SubclassInitialize()
  676. {
  677. InitializeComponent();
  678. InitializeLanguageText();
  679. }
  680. //是否绘制辅助线
  681. protected override bool showGridChecked()
  682. {
  683. return checkBox4_0.Checked;
  684. }
  685. ////是否绘制截点
  686. //protected override bool drawGuidePoints()
  687. //{
  688. // return (matOrg != null && this.checkBox5_0.Checked);
  689. //}
  690. //是否绘制编号
  691. protected override bool showGrainNumberChecked()
  692. {
  693. return this.checkBox5_0.Checked;
  694. }
  695. //辅助线类型
  696. protected override string[] getTypeNames()
  697. {
  698. return new string[] {
  699. PdnResources.GetString("Menu.circular.Text")};
  700. }
  701. //protected override string getTemplateName()
  702. //{
  703. // return "Template.Manager.item3.GrainSizeArea_YST347";
  704. //}
  705. protected override string getProjectEngineeringName()
  706. {
  707. return "Menu.DedicatedAnalysis.NonferrousMetal.CopperAlloy.Text";
  708. }
  709. //protected override string getModelName()
  710. //{
  711. // return "GrainGBT32461AreaMethodModel.xml";
  712. //}
  713. #endregion
  714. /// <summary>
  715. /// 设置晶粒颜色
  716. /// </summary>
  717. /// <param name="sender"></param>
  718. /// <param name="e"></param>
  719. private void button2_Click(object sender, EventArgs e)
  720. {
  721. //if (this.matOrg == null)
  722. //{
  723. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  724. // return;
  725. //}
  726. ShowGrainColorSettingDialog();
  727. }
  728. /// <summary>
  729. /// 刷新晶粒编号
  730. /// </summary>
  731. /// <param name="sender"></param>
  732. /// <param name="e"></param>
  733. private void button4_Click(object sender, EventArgs e)
  734. {
  735. if (this.imageMat == null)
  736. {
  737. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
  738. return;
  739. }
  740. GetNumberOfGrains();
  741. }
  742. /// <summary>
  743. /// 是否显示晶界
  744. /// </summary>
  745. /// <param name="sender"></param>
  746. /// <param name="e"></param>
  747. private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
  748. {
  749. if (!showOrimat() && getGrainBoundryChecked() && checkBox3_0.Checked)
  750. {
  751. this.documentWorkspace.PhaseModels[1].choise = true;
  752. }
  753. else
  754. {
  755. this.documentWorkspace.PhaseModels[1].choise = false;
  756. }
  757. this.documentWorkspace.Refresh();
  758. }
  759. private void checkBox4_0_CheckedChanged(object sender, EventArgs e)
  760. {
  761. this.documentWorkspace.Refresh();
  762. }
  763. private void checkBox11_CheckedChanged(object sender, EventArgs e)
  764. {
  765. if (!showOrimat() && checkBox11.Checked)
  766. {
  767. this.documentWorkspace.PhaseModels[2].choise = true;
  768. }
  769. else
  770. {
  771. this.documentWorkspace.PhaseModels[2].choise = false;
  772. }
  773. this.documentWorkspace.Refresh();
  774. }
  775. private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
  776. {
  777. this.documentWorkspace.Refresh();
  778. }
  779. }
  780. }