123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903 |
- using OpenCvSharp;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.GBT32461
- {
- internal class MethodAreaDialog : GrainSizeStandardDialog
- {
- #region 组件
- private GroupBox groupBox11;
- private Button button4;
- private Button button2;
- private CheckBox checkBox11;
- private CheckBox checkBox5_0;
- private CheckBox checkBox4_0;
- private CheckBox checkBox3_0;
- private DataGridViewTextBoxColumn ColumnTotal1;
- private DataGridViewTextBoxColumn ColumnTotal2;
- private GroupBox groupBox7;
- private Button button10;
- private Button button3;
- private Button button8;
- private RadioButton radioButton5;
- private RadioButton radioButton4;
- private RadioButton radioButton3;
- private DataGridViewTextBoxColumn ColumnTotal3;
- #endregion 组件
- #region 构造函数
- public MethodAreaDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, new Base.DedicatedAnalysis.GrainSize.Standard.GBT32461.MethodArea())
- {
- }
- #endregion 构造函数
- #region 初始化组件
- private void InitializeLanguageText()
- {
- this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
- this.button4.Text = PdnResources.GetString("Menu.Refresh.text");
- this.button2.Text = PdnResources.GetString("Menu.Setting.Text");
- this.checkBox11.Text = PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text");
- this.checkBox5_0.Text = PdnResources.GetString("Menu.Displaygrainnumber.text");
- this.checkBox4_0.Text = PdnResources.GetString("Menu.displaygrid.text");
- this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
- this.Text = "GBT32461(" + PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Averagegraimethod.text") + ")";
- this.Load += new System.EventHandler(this.MethodAreaDialog_Load);
- }
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private DataGridViewTextBoxColumn Column5;
- private void MethodAreaDialog_Load(object sender, EventArgs e)
- {
- //this.button_ApplyToAll.Visible = false;
- //this.button_SaveAll.Visible = false;
- //this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
- //this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
- object ShowGrainBoundry;
- if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
- this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
- if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
- this.checkBox4_0.Checked = (bool)ShowGrainBoundry;
- if (GetParamValue1(ParamKey_ShowGrainNumber, out ShowGrainBoundry))//显示晶粒编号
- this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
- if (GetParamValue1(ParamKey_ShowGrainColor, out ShowGrainBoundry))//用不同颜色显示晶粒
- this.checkBox11.Checked = (bool)ShowGrainBoundry;
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
- // Column3
- //
- this.Column3.Name = "Column3";
- this.Column3.ReadOnly = true;
- //
- // Column4
- //
- this.Column4.Name = "Column4";
- this.Column4.ReadOnly = true;
- //
- // Column5
- //
- this.Column5.Name = "Column5";
- this.Column5.ReadOnly = true;
- this.Column5.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
- this.Column4.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
- this.Column3.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
- this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
- this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4,
- this.Column5});
- this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.ColumnTotal1,
- this.ColumnTotal2,
- this.ColumnTotal3});
- //
- // ColumnTotal1
- //
- this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
- this.ColumnTotal1.Name = "ColumnTotal1";
- this.ColumnTotal1.ReadOnly = true;
- //
- // ColumnTotal2
- //
- this.ColumnTotal2.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
- this.ColumnTotal2.Name = "ColumnTotal2";
- this.ColumnTotal2.ReadOnly = true;
- //
- // ColumnTotal3
- //
- this.ColumnTotal3.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
- this.ColumnTotal3.Name = "ColumnTotal3";
- this.ColumnTotal3.ReadOnly = true;
- DetailListStringIndex.Add(0);
- DetailListStringIndex.Add(1);
- DetailListStringIndex.Add(3);
- DetailListStringIndex.Add(4/*5*/);//##############
- DetailListNotDoubleIndex.Add(0);
- DetailListNotDoubleIndex.Add(1);
- DetailListNotDoubleIndex.Add(3);
- DetailListNotDoubleIndex.Add(4);
- IndexChangedFromIndex.Clear();
- IndexChangedToIndex.Clear();
- IndexChangedFromIndex.Add(2);
- IndexChangedFromIndex.Add(3);
- IndexChangedToIndex.Add(0, new int[] { 2/*1*/, 0 });//求和
- IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//求和
- //IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
- IndexChangedToIndex.Add(2, new int[] { 3, -1/*0*/ });//级别
- this.button3.FlatStyle = FlatStyle.Flat;
- this.button3.FlatAppearance.BorderSize = 0;
- this.button3.BackgroundImageLayout = ImageLayout.Zoom;
- this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
- this.button3.Click += new EventHandler(this.button3_click);
- this.button10.FlatStyle = FlatStyle.Flat;
- this.button10.FlatAppearance.BorderSize = 0;
- this.button10.BackgroundImageLayout = ImageLayout.Zoom;
- this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- this.button10.Click += new EventHandler(this.button10_click);
- this.button8.FlatStyle = FlatStyle.Flat;
- this.button8.FlatAppearance.BorderSize = 0;
- this.button8.BackgroundImageLayout = ImageLayout.Zoom;
- this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button8.Click += new EventHandler(this.button8_click);
- getSonData();
- }
- /// <summary>
- /// 获取参数
- /// </summary>
- protected override void getSonData()
- {
- object ShowGrainBoundry;
- if (GetParamValue1(ParamKey_TargetSelection, out ShowGrainBoundry))//目标选择
- {
- int value = Convert.ToInt32(ShowGrainBoundry);
- switch (value)
- {
- case 1:
- this.button8_click(null, null);
- break;
- case 2:
- this.button3_click(null, null);
- break;
- case 3:
- this.button10_click(null, null);
- break;
- }
- }
- }
- private void button3_click(object sender, EventArgs e)
- {
- this.TargetSelection = 2;
- this.radioButton4.Checked = true;
- this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
- this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- private void button10_click(object sender, EventArgs e)
- {
- this.TargetSelection = 3;
- this.radioButton5.Checked = true;
- this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
- this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
- this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- }
- private void button8_click(object sender, EventArgs e)
- {
- this.TargetSelection = 1;
- this.radioButton3.Checked = true;
- this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
- this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
- this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
- }
- /// <summary>
- /// 计算汇总列表的平均晶粒度级别
- /// </summary>
- /// <returns></returns>
- protected override string getGradeTotalCal(DataGridViewRow dgvr, int digits)
- {
- double aec = double.Parse(dgvr.Cells[0].Value.ToString());
- double grainNumber = double.Parse(dgvr.Cells[1].Value.ToString());
- aec = aec * 0.001 * 0.001;
- decimal M = 1;// this.getGainMultiple();
- double small_l = (grainNumber * (double)M * (double)M) / aec;
- decimal A = Convert.ToDecimal(small_l * 1);
- double[] lengths = {3.88, 7.75 , 11.0, 15.50, 21.9, 25.0, 31.0, 43.8, 62.0, 69.4,
- 87.7, 100, 124, 175, 204, 248, 278, 351, 400, 496, 625, 701, 816,
- 992, 1111 , 1403, 1600, 1980, 2500, 2810, 3970, 4440, 5610,
- 7940, 10000, 11220, 12350, 15870, 20410, 22450, 27780, 31710, 40000, 44900, 63500, 89800
- , 111100, 127000, 160000};
- // 差值
- decimal differenceNew;
- decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 2.22, (double)A - 160001)));
- int first = 0;
- if ((double)A > lengths[lengths.Length - 1])
- first = lengths.Length - 1;
- else
- for (int firstI = 0; firstI < lengths.Length; firstI++)
- {
- double item = lengths[firstI];
- differenceNew = Math.Abs(A - Convert.ToDecimal(item));
- if (differenceNew < differenceOld)
- {
- differenceOld = Math.Abs(A - Convert.ToDecimal(item));
- first = firstI;
- }
- }
- string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5", "2.0", "2.5", "3.0", "3.0",
- "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
- "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
- "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
- , "13.5", "14.0", "14.0"};
- return valueG[first];
- }
- private void InitializeComponent()
- {
- this.groupBox11 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.checkBox11 = new System.Windows.Forms.CheckBox();
- this.checkBox5_0 = new System.Windows.Forms.CheckBox();
- this.checkBox4_0 = new System.Windows.Forms.CheckBox();
- this.checkBox3_0 = new System.Windows.Forms.CheckBox();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.button10 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button8 = new System.Windows.Forms.Button();
- this.radioButton5 = new System.Windows.Forms.RadioButton();
- this.radioButton4 = new System.Windows.Forms.RadioButton();
- this.radioButton3 = new System.Windows.Forms.RadioButton();
- this.groupBox_img.SuspendLayout();
- this.groupBox_analysisResult1.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.groupBox11.SuspendLayout();
- this.groupBox7.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox11
- //
- this.groupBox11.Controls.Add(this.button2);
- this.groupBox11.Controls.Add(this.button4);
- this.groupBox11.Controls.Add(this.checkBox11);
- this.groupBox11.Controls.Add(this.checkBox5_0);
- this.groupBox11.Controls.Add(this.checkBox4_0);
- this.groupBox11.Controls.Add(this.checkBox3_0);
- this.groupBox11.Location = new System.Drawing.Point(179, 373);
- this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(356, 71);
- this.groupBox11.TabIndex = 38;
- this.groupBox11.TabStop = false;
- //
- // button2
- //
- this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.button2.Location = new System.Drawing.Point(271, 41);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 22);
- this.button2.TabIndex = 19;
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button4
- //
- this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.button4.Location = new System.Drawing.Point(271, 17);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 22);
- this.button4.TabIndex = 18;
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // checkBox11
- //
- this.checkBox11.AutoSize = true;
- this.checkBox11.Checked = true;
- this.checkBox11.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox11.Location = new System.Drawing.Point(139, 44);
- this.checkBox11.Name = "checkBox11";
- this.checkBox11.Size = new System.Drawing.Size(15, 14);
- this.checkBox11.TabIndex = 3;
- this.checkBox11.UseVisualStyleBackColor = true;
- this.checkBox11.CheckedChanged += new System.EventHandler(this.checkBox11_CheckedChanged);
- //
- // checkBox5_0
- //
- this.checkBox5_0.AutoSize = true;
- this.checkBox5_0.Checked = true;
- this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox5_0.Location = new System.Drawing.Point(140, 22);
- this.checkBox5_0.Name = "checkBox5_0";
- this.checkBox5_0.Size = new System.Drawing.Size(15, 14);
- this.checkBox5_0.TabIndex = 2;
- this.checkBox5_0.UseVisualStyleBackColor = true;
- this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
- //
- // checkBox4_0
- //
- this.checkBox4_0.AutoSize = true;
- this.checkBox4_0.Checked = true;
- this.checkBox4_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox4_0.Location = new System.Drawing.Point(15, 44);
- this.checkBox4_0.Name = "checkBox4_0";
- this.checkBox4_0.Size = new System.Drawing.Size(15, 14);
- this.checkBox4_0.TabIndex = 1;
- this.checkBox4_0.UseVisualStyleBackColor = true;
- this.checkBox4_0.CheckedChanged += new System.EventHandler(this.checkBox4_0_CheckedChanged);
- //
- // checkBox3_0
- //
- this.checkBox3_0.AutoSize = true;
- this.checkBox3_0.Checked = true;
- this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox3_0.Location = new System.Drawing.Point(15, 22);
- this.checkBox3_0.Name = "checkBox3_0";
- this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
- this.checkBox3_0.TabIndex = 0;
- this.checkBox3_0.UseVisualStyleBackColor = true;
- this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
- //
- // groupBox7
- //
- this.groupBox7.Controls.Add(this.button10);
- this.groupBox7.Controls.Add(this.button3);
- this.groupBox7.Controls.Add(this.button8);
- this.groupBox7.Controls.Add(this.radioButton5);
- this.groupBox7.Controls.Add(this.radioButton4);
- this.groupBox7.Controls.Add(this.radioButton3);
- this.groupBox7.Location = new System.Drawing.Point(179, 450);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(356, 77);
- this.groupBox7.TabIndex = 41;
- this.groupBox7.TabStop = false;
- this.groupBox7.Text = "目标选择";
- //
- // button10
- //
- this.button10.Location = new System.Drawing.Point(60, 21);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(40, 40);
- this.button10.TabIndex = 5;
- this.button10.UseVisualStyleBackColor = true;
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(14, 21);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(40, 40);
- this.button3.TabIndex = 4;
- this.button3.UseVisualStyleBackColor = true;
- //
- // button8
- //
- this.button8.Location = new System.Drawing.Point(106, 21);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(40, 40);
- this.button8.TabIndex = 3;
- this.button8.UseVisualStyleBackColor = true;
- this.button8.Visible = false;
- //
- // radioButton5
- //
- this.radioButton5.AutoSize = true;
- this.radioButton5.Location = new System.Drawing.Point(238, 55);
- this.radioButton5.Name = "radioButton5";
- this.radioButton5.Size = new System.Drawing.Size(14, 13);
- this.radioButton5.TabIndex = 2;
- this.radioButton5.UseVisualStyleBackColor = true;
- this.radioButton5.Visible = false;
- //
- // radioButton4
- //
- this.radioButton4.AutoSize = true;
- this.radioButton4.Checked = true;
- this.radioButton4.Location = new System.Drawing.Point(297, 44);
- this.radioButton4.Name = "radioButton4";
- this.radioButton4.Size = new System.Drawing.Size(14, 13);
- this.radioButton4.TabIndex = 1;
- this.radioButton4.TabStop = true;
- this.radioButton4.UseVisualStyleBackColor = true;
- this.radioButton4.Visible = false;
- //
- // radioButton3
- //
- this.radioButton3.AutoSize = true;
- this.radioButton3.Location = new System.Drawing.Point(279, 21);
- this.radioButton3.Name = "radioButton3";
- this.radioButton3.Size = new System.Drawing.Size(14, 13);
- this.radioButton3.TabIndex = 0;
- this.radioButton3.UseVisualStyleBackColor = true;
- this.radioButton3.Visible = false;
- //
- // MethodAreaDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1127, 810);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox11);
- this.Name = "MethodAreaDialog";
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox_img, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
- this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
- this.Controls.SetChildIndex(this.groupBox_report, 0);
- this.Controls.SetChildIndex(this.groupBox11, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.groupBox_img.ResumeLayout(false);
- this.groupBox_analysisResult1.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.groupBox11.ResumeLayout(false);
- this.groupBox11.PerformLayout();
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- this.ResumeLayout(false);
- }
- #endregion 初始化组件
- #region 需继承方法
- protected override Boolean ShowGrainBoundryChecked()
- {
- return !showOrimat() && checkBox3_0.Checked;
- }
- protected override void refreshWhileImgChanged()
- {
- if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
- this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()];
- if (this.bitmap != null && this.documentWorkspace.PhaseModels[2].mat != null)
- {
- //try
- //{
- // GetNumberOfGrains();
- //}
- //catch (Exception)
- //{
- //}
- }
- else
- {
- this.documentWorkspace.PhaseModels[2].mat = null;//清空前一张图的信息不遗留显示##效果考虑优化
- GSSClass.standardModel.massLabelPoints.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 是否用不同颜色显示晶粒
- /// </summary>
- /// <returns></returns>
- protected override Boolean ShowGrainColorChecked()
- {
- return checkBox11.Checked;
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
- {
- if (this.matOrg == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- if (this.comboBox1.SelectedItem != null && !PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
- {
- string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
- string tag = imagesKey;
- System.Data.DataTable dataTable = new System.Data.DataTable();
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- add++;
- if (saveAll)
- {
- replace = true;
- break;
- }
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- break;
- }
- }
- if (replace || this.listView2.Items.Count == 0 || add == 0)
- {
- if (!replace)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + tag;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- }
- this.dataGridView2.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = imgName;
- dgvr.Cells[1].Value = this.comboBox1.SelectedItem;
- if (analysisPicture != this.selectPicture)//更新二值图片
- binaryClass.updateAnalysisData(imagesKey, analysisPicture);
- GrainSizeGuideModel cal_GuideModel = this.GSSClass.GuideClass.guideModel;
- if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- cal_GuideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
- //else if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
- //{
- // this.calcOtherImgs(imagesKey, analysisPicture);
- //}
- if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
- this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
- if (cal_GuideModel.oldSelectItem == null)//##
- cal_GuideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
- GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
- if (imagesKey != null)
- {
- if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
- this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
- cal_StandardModel = this.GSSClass.standardDict[imagesKey];
- if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
- this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
- }
- // 是否矩形辅助线
- int isRect;
- double aec = GSSClass.GuideClass.guideArea(cal_GuideModel, cal_GuideModel.oldSelectItem, out isRect, 0/*this.gbtType*/);
- dgvr.Cells[2].Value = aec;
- aec = aec * 0.001 * 0.001;
- double grainNumber = GetNumberOfGrains(/*#########*/cal_StandardModel, cal_GuideModel, imagesKey/*getCurrentWorkTag()*/, analysisPicture/*this.selectPicture*/);
- if (grainNumber > (int)grainNumber)
- {
- grainNumber = grainNumber + 0.5;
- }
- dgvr.Cells[3].Value = grainNumber;
- decimal M = 1;// this.getGainMultiple();
- double small_l = (grainNumber * (double)M * (double)M) / aec;
- decimal A = Convert.ToDecimal(small_l * 1);
- double[] lengths = {3.88, 7.75 , 11.0, 15.50, 21.9, 25.0, 31.0, 43.8, 62.0, 69.4,
- 87.7, 100, 124, 175, 204, 248, 278, 351, 400, 496, 625, 701, 816,
- 992, 1111 , 1403, 1600, 1980, 2500, 2810, 3970, 4440, 5610,
- 7940, 10000, 11220, 12350, 15870, 20410, 22450, 27780, 31710, 40000, 44900, 63500, 89800
- , 111100, 127000, 160000};
- // 差值
- decimal differenceNew;//##20716
- decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 2.88, (double)A - 160001)));
- int first = 0;
- if ((double)A > lengths[lengths.Length - 1])
- first = lengths.Length - 1;
- else
- for (int firstI = 0; firstI < lengths.Length; firstI++)
- {
- double item = lengths[firstI];
- differenceNew = Math.Abs(A - Convert.ToDecimal(item));
- if (differenceNew < differenceOld)
- {
- differenceOld = Math.Abs(A - Convert.ToDecimal(item));
- first = firstI;
- }
- }
- string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5"/**/, "2.0", "2.5", "3.0", "3.0",
- "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
- "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
- "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
- , "13.5", "14.0", "14.0"};
- dgvr.Cells[4].Value = valueG[first];
- this.dataGridView2.Rows.Add(dgvr);
- dataTable.TableName = tag;
- foreach (System.Data.DataTable dataTable1 in dataTables)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTables.Remove(dataTable1);
- break;
- }
- }
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- dataTable.Rows.Add(dataRow);
- }
- this.dataTables.Add(dataTable);
- this.RefreshDataGridView4();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture/*this.selectPicture*/].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (binaryClass.getModelMat(imagesKey) != null)
- {
- Mat targetMat = binaryClass.getModelMat(imagesKey);
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
- {
- Mat targetMat = this.grainBoundaryMatDict[imagesKey];
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
- {
- Mat targetMat = this.grainColorsMatDict[imagesKey];
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- //拼接中间数据
- List<List<string>> dataList = new List<List<string>>();
- List<string> columnName = new List<string>();
- columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
- columnName.Add("X"+ PdnResources.GetString("Menu.coordinates.Text"));
- columnName.Add("Y"+ PdnResources.GetString("Menu.coordinates.Text"));
- columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
- dataList.Add(columnName);
- if (cal_StandardModel.massLabelPoints.Count > 0)
- {
- int index = 0;
- int outMaxIndex = cal_StandardModel.massLabelPoints.Count - 0 - cal_StandardModel.within;
- foreach (var item in cal_StandardModel.massLabelPoints.Values)
- {
- List<string> strList = new List<string>();
- strList.Add(("" + (++index)).ToString());
- strList.Add(item[2].ToString());
- strList.Add(item[3].ToString());
- if (outMaxIndex < index)
- strList.Add(PdnResources.GetString("Menu.Yes.text"));
- else
- strList.Add(PdnResources.GetString("Menu.no.text"));
- dataList.Add(strList);
- }
- }
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(tag))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
- newModel.tagName = tag;
- newModel.picName = imgName;
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text")+"!");
- }
- }
- protected override void SubclassInitialize()
- {
- InitializeComponent();
- InitializeLanguageText();
- }
- //是否绘制辅助线
- protected override bool showGridChecked()
- {
- return checkBox4_0.Checked;
- }
- ////是否绘制截点
- //protected override bool drawGuidePoints()
- //{
- // return (matOrg != null && this.checkBox5_0.Checked);
- //}
- ////是否显示截点
- //protected override Boolean drawDisplaySections()//##1
- //{
- // return this.checkBox5_0.Checked;
- //}
- //是否绘制编号
- protected override bool showGrainNumberChecked()
- {
- return this.checkBox5_0.Checked;
- }
- //辅助线类型
- protected override string[] getTypeNames()
- {
- return new string[] {
- PdnResources.GetString("Menu.circular.Text")};
- }
- //protected override string getTemplateName()
- //{
- // return "Template.Manager.item3.GrainSizeArea_GBT32461";
- //}
- protected override string getProjectEngineeringName()
- {
- return "Menu.DedicatedAnalysis.NonferrousMetal.AluminiumAlloy.Text";
- }
- //protected override string getModelName()
- //{
- // return "GrainGBT32461AreaMethodModel.xml";
- //}
- #endregion
- /// <summary>
- /// 设置晶粒颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- //if (this.matOrg == null)
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
- // return;
- //}
- ShowGrainColorSettingDialog();
- }
- /// <summary>
- /// 刷新晶粒编号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.matOrg == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text"));
- return;
- }
- GetNumberOfGrains();
- }
- /// <summary>
- /// 是否显示晶界
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
- {
- if (!showOrimat() && getGrainBoundryChecked() && checkBox3_0.Checked)
- {
- this.documentWorkspace.PhaseModels[1].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[1].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- private void checkBox4_0_CheckedChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- private void checkBox11_CheckedChanged(object sender, EventArgs e)
- {
- if (!showOrimat() && checkBox11.Checked)
- {
- this.documentWorkspace.PhaseModels[2].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[2].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- }
- }
|