123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558 |
- using OpenCvSharp;
- using PaintDotNet.Annotation;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Annotation.Label;
- using PaintDotNet.Annotation.PhysicalPhaseAction;
- using PaintDotNet.Base;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Data.Param;
- using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
- using static PaintDotNet.Base.SettingModel.LabelStyleModel;
- using PaintDotNet.CustomControl;
- using System.IO;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Instrument;
- using Metis.ParameterSet;
- namespace PaintDotNet.GeneralAnalysis
- {
- /// <summary>
- /// 物相间距
- /// </summary>
- internal class PolyphaseDistanceDialog : PdnBaseForm
- {
- #region 控件
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.ListView listView1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox_review;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.GroupBox groupBox7;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.ImageList imageList1;
- private DataGridView dataGridView_results;
- private Button button_remove;
- private Button button_all;
- private Button button5;
- private GroupBox groupBox8;
- private GroupBox groupBox9;
- private GroupBox groupBox10;
- private GroupBox groupBox11;
- private CheckBox checkBox3;
- private Label label3;
- private CustomControl.TriangleTrackBar triangleTrackBar1;
- private Label label5;
- private NumericUpDown numericUpDown1;
- private Label label6;
- private Panel panel2;
- private RadioButton rb_2;
- private RadioButton rb_1;
- private Panel panel3;
- private Label label7;
- private RadioButton rb_4;
- private RadioButton rb_3;
- private Label label8;
- private Label label9;
- private NumericUpDown numericUpDown2;
- private NumericUpDown numericUpDown3;
- private Label lbl_line;
- private System.Data.SQLite.SQLiteCommand sqLiteCommand1;
- private CustomControl.TriangleTrackBar triangleTrackBar2;
- private Label label13;
- private CheckBox checkBox4;
- private CheckBox checkBox5;
- private CheckBox checkBox6;
- private NumericUpDown numericUpDown5;
- private NumericUpDown numericUpDown4;
- private Label label11;
- private Label label10;
- private Panel panel4;
- private RadioButton radioButton1;
- private RadioButton radioButton2;
- private Label lbl_kl_max;
- private Label lbl_kl_min;
- private int imgIndex = -1;
- //二值化集成1
- BinaryClass binaryClass;
- private int menuId;
- private string menuName;
- private BinaryControl bc;
- private Button button9;
- private CheckedListBox listBox_analysisResult;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
- private Label label2;
- private GroupBox groupBox3;
- private IContainer components;
- private bool isCheck = false;
- private Mat original;
- #endregion
- #region InitializeComponent
- private void InitializeLanguageText()
- {
- //this.checkBox4.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
- this.Text = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
- this.label8.Text = PdnResources.GetString("Menu.shape.text");
- this.label7.Text = PdnResources.GetString("Menu.style.text");
- this.rb_4.Text = PdnResources.GetString("Menu.Hollow.text");
- this.rb_3.Text = PdnResources.GetString("Menu.solid.text");
- this.rb_2.Text = PdnResources.GetString("Menu.Square.text");
- this.rb_1.Text = PdnResources.GetString("Menu.circular.Text");
- this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
- this.checkBox6.Text = PdnResources.GetString("Menu.displaysections.text");
- this.checkBox5.Text = PdnResources.GetString("Menu.displaygrid.text");
- this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.groupBox8.Text = PdnResources.GetString("Menu.Measuringlinesetting.text");
- this.label6.Text = PdnResources.GetString("Menu.color.text");
- this.label5.Text = PdnResources.GetString("Menu.Linewidth.text");
- this.groupBox9.Text = PdnResources.GetString("Menu.operation.text");
- this.radioButton2.Text = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Thenumberofsections.text");
- this.radioButton1.Text = PdnResources.GetString("Menu.Measuringline.text");
- this.groupBox10.Text = PdnResources.GetString("Menu.Interceptformatting.text");
- this.label11.Text = PdnResources.GetString("Menu.error.text");
- this.label10.Text = PdnResources.GetString("Menu.color.text");
- this.lbl_line.Text = PdnResources.GetString("Menu.Linewidth.text");
- this.label9.Text = PdnResources.GetString("Menu.size.text");
- this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Averagespacing.text");
- this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.variance.text");
- this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.Numberofintercept.text");
- this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
- this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Particlescreening.text");
- this.label13.Text = PdnResources.GetString("Menu.max.text");
- this.label3.Text = PdnResources.GetString("Menu.minimum.text");
- this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.label2.Text = PdnResources.GetString("Menu.Decimal.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button5 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.lbl_kl_max = new System.Windows.Forms.Label();
- this.lbl_kl_min = new System.Windows.Forms.Label();
- this.triangleTrackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
- this.label13 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.triangleTrackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar();
- this.checkBox3 = new System.Windows.Forms.CheckBox();
- this.groupBox_review = new System.Windows.Forms.GroupBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
- this.button_remove = new System.Windows.Forms.Button();
- this.button_all = new System.Windows.Forms.Button();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.dataGridView_results = new System.Windows.Forms.DataGridView();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.label2 = new System.Windows.Forms.Label();
- this.button9 = new System.Windows.Forms.Button();
- this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label6 = new System.Windows.Forms.Label();
- this.panel2 = new System.Windows.Forms.Panel();
- this.label5 = new System.Windows.Forms.Label();
- this.groupBox9 = new System.Windows.Forms.GroupBox();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.groupBox10 = new System.Windows.Forms.GroupBox();
- this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
- this.label11 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.panel4 = new System.Windows.Forms.Panel();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.lbl_line = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.label9 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.panel3 = new System.Windows.Forms.Panel();
- this.label7 = new System.Windows.Forms.Label();
- this.rb_4 = new System.Windows.Forms.RadioButton();
- this.rb_3 = new System.Windows.Forms.RadioButton();
- this.rb_2 = new System.Windows.Forms.RadioButton();
- this.rb_1 = new System.Windows.Forms.RadioButton();
- this.groupBox11 = new System.Windows.Forms.GroupBox();
- this.checkBox6 = new System.Windows.Forms.CheckBox();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.sqLiteCommand1 = new System.Data.SQLite.SQLiteCommand();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.groupBox4.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox5.SuspendLayout();
- this.groupBox6.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
- this.groupBox7.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
- this.groupBox8.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.groupBox9.SuspendLayout();
- this.groupBox10.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.panel3.SuspendLayout();
- this.groupBox11.SuspendLayout();
- this.groupBox3.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox4.Controls.Add(this.listView1);
- this.groupBox4.Location = new System.Drawing.Point(13, 72);
- this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox4.Size = new System.Drawing.Size(158, 674);
- this.groupBox4.TabIndex = 9;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "图像索引";
- //
- // listView1
- //
- this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listView1.HideSelection = false;
- this.listView1.LargeImageList = this.imageList1;
- this.listView1.Location = new System.Drawing.Point(8, 26);
- this.listView1.Margin = new System.Windows.Forms.Padding(4);
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(140, 640);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged);
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.checkBox1);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(20, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1160, 53);
- this.groupBox1.TabIndex = 10;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(971, 20);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 3;
- this.button5.Text = "关闭";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button2
- //
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.Location = new System.Drawing.Point(1070, 20);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 2;
- this.button2.Text = "保存结果";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(98, 24);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(132, 16);
- this.checkBox1.TabIndex = 1;
- this.checkBox1.Text = "生成报告时打开设置";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(6, 24);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "设置";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.lbl_kl_max);
- this.groupBox2.Controls.Add(this.lbl_kl_min);
- this.groupBox2.Controls.Add(this.triangleTrackBar2);
- this.groupBox2.Controls.Add(this.label13);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.triangleTrackBar1);
- this.groupBox2.Controls.Add(this.checkBox3);
- this.groupBox2.Location = new System.Drawing.Point(6, 20);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(360, 76);
- this.groupBox2.TabIndex = 11;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "颗粒筛选";
- //
- // lbl_kl_max
- //
- this.lbl_kl_max.AutoSize = true;
- this.lbl_kl_max.Location = new System.Drawing.Point(302, 50);
- this.lbl_kl_max.Name = "lbl_kl_max";
- this.lbl_kl_max.Size = new System.Drawing.Size(11, 12);
- this.lbl_kl_max.TabIndex = 8;
- this.lbl_kl_max.Text = "0";
- //
- // lbl_kl_min
- //
- this.lbl_kl_min.AutoSize = true;
- this.lbl_kl_min.Location = new System.Drawing.Point(302, 21);
- this.lbl_kl_min.Name = "lbl_kl_min";
- this.lbl_kl_min.Size = new System.Drawing.Size(11, 12);
- this.lbl_kl_min.TabIndex = 7;
- this.lbl_kl_min.Text = "0";
- //
- // triangleTrackBar2
- //
- this.triangleTrackBar2.Location = new System.Drawing.Point(116, 44);
- this.triangleTrackBar2.Maximum = 10;
- this.triangleTrackBar2.Minimum = 0;
- this.triangleTrackBar2.Name = "triangleTrackBar2";
- this.triangleTrackBar2.Size = new System.Drawing.Size(177, 26);
- this.triangleTrackBar2.TabIndex = 6;
- this.triangleTrackBar2.Value = 0;
- this.triangleTrackBar2.TrackBarScroll += new System.EventHandler(this.triangleTrackBar2_TrackBarScroll);
- //
- // label13
- //
- this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(77, 50);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(29, 12);
- this.label13.TabIndex = 5;
- this.label13.Text = "最大";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(77, 21);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(29, 12);
- this.label3.TabIndex = 2;
- this.label3.Text = "最小";
- this.label3.Click += new System.EventHandler(this.label3_Click);
- //
- // triangleTrackBar1
- //
- this.triangleTrackBar1.Location = new System.Drawing.Point(116, 14);
- this.triangleTrackBar1.Maximum = 10;
- this.triangleTrackBar1.Minimum = 0;
- this.triangleTrackBar1.Name = "triangleTrackBar1";
- this.triangleTrackBar1.Size = new System.Drawing.Size(177, 26);
- this.triangleTrackBar1.TabIndex = 1;
- this.triangleTrackBar1.Value = 0;
- this.triangleTrackBar1.TrackBarScroll += new System.EventHandler(this.triangleTrackBar1_TrackBarScroll);
- //
- // checkBox3
- //
- this.checkBox3.AutoSize = true;
- this.checkBox3.Location = new System.Drawing.Point(18, 21);
- this.checkBox3.Name = "checkBox3";
- this.checkBox3.Size = new System.Drawing.Size(48, 16);
- this.checkBox3.TabIndex = 0;
- this.checkBox3.Text = "筛选";
- this.checkBox3.UseVisualStyleBackColor = true;
- this.checkBox3.Click += new System.EventHandler(this.checkBox3_BeforeCheckedChanged);
- //
- // groupBox_review
- //
- this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_review.Location = new System.Drawing.Point(556, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(624, 674);
- this.groupBox_review.TabIndex = 12;
- this.groupBox_review.TabStop = false;
- this.groupBox_review.Text = "预览";
- //
- // groupBox5
- //
- this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox5.Controls.Add(this.listBox_analysisResult);
- this.groupBox5.Controls.Add(this.button_remove);
- this.groupBox5.Controls.Add(this.button_all);
- this.groupBox5.Location = new System.Drawing.Point(13, 753);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(224, 156);
- this.groupBox5.TabIndex = 13;
- this.groupBox5.TabStop = false;
- //
- // listBox_analysisResult
- //
- this.listBox_analysisResult.CheckOnClick = true;
- this.listBox_analysisResult.FormattingEnabled = true;
- this.listBox_analysisResult.HorizontalScrollbar = true;
- this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
- this.listBox_analysisResult.Name = "listBox_analysisResult";
- this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
- this.listBox_analysisResult.TabIndex = 10;
- this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
- //
- // button_remove
- //
- this.button_remove.Location = new System.Drawing.Point(130, 24);
- this.button_remove.Name = "button_remove";
- this.button_remove.Size = new System.Drawing.Size(75, 23);
- this.button_remove.TabIndex = 8;
- this.button_remove.Text = "删除";
- this.button_remove.UseVisualStyleBackColor = true;
- this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
- //
- // button_all
- //
- this.button_all.Location = new System.Drawing.Point(14, 24);
- this.button_all.Name = "button_all";
- this.button_all.Size = new System.Drawing.Size(75, 23);
- this.button_all.TabIndex = 1;
- this.button_all.Text = "全部显示";
- this.button_all.UseVisualStyleBackColor = true;
- this.button_all.Click += new System.EventHandler(this.button_all_Click);
- //
- // groupBox6
- //
- this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6.Controls.Add(this.dataGridView_results);
- this.groupBox6.Location = new System.Drawing.Point(243, 753);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(721, 156);
- this.groupBox6.TabIndex = 14;
- this.groupBox6.TabStop = false;
- //
- // dataGridView_results
- //
- this.dataGridView_results.AllowUserToAddRows = false;
- this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column5,
- this.dataGridViewTextBoxColumn1,
- this.dataGridViewTextBoxColumn2,
- this.dataGridViewTextBoxColumn3});
- this.dataGridView_results.Location = new System.Drawing.Point(6, 13);
- this.dataGridView_results.Name = "dataGridView_results";
- this.dataGridView_results.RowHeadersVisible = false;
- this.dataGridView_results.RowHeadersWidth = 51;
- this.dataGridView_results.RowTemplate.Height = 27;
- this.dataGridView_results.Size = new System.Drawing.Size(709, 139);
- this.dataGridView_results.TabIndex = 1;
- //
- // Column5
- //
- this.Column5.HeaderText = "Column5";
- this.Column5.MinimumWidth = 6;
- this.Column5.Name = "Column5";
- this.Column5.Width = 150;
- //
- // dataGridViewTextBoxColumn1
- //
- this.dataGridViewTextBoxColumn1.HeaderText = "dataGridViewTextBoxColumn1";
- this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
- this.dataGridViewTextBoxColumn1.Width = 160;
- //
- // dataGridViewTextBoxColumn2
- //
- this.dataGridViewTextBoxColumn2.HeaderText = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.Width = 200;
- //
- // dataGridViewTextBoxColumn3
- //
- this.dataGridViewTextBoxColumn3.HeaderText = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.Width = 200;
- //
- // groupBox7
- //
- this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox7.Controls.Add(this.label2);
- this.groupBox7.Controls.Add(this.button9);
- this.groupBox7.Controls.Add(this.numericUpDown5);
- this.groupBox7.Controls.Add(this.label1);
- this.groupBox7.Controls.Add(this.button4);
- this.groupBox7.Controls.Add(this.button3);
- this.groupBox7.Location = new System.Drawing.Point(970, 753);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(210, 156);
- this.groupBox7.TabIndex = 15;
- this.groupBox7.TabStop = false;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(57, 126);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(29, 12);
- this.label2.TabIndex = 8;
- this.label2.Text = "小数";
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(59, 88);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(107, 23);
- this.button9.TabIndex = 7;
- this.button9.Text = "项目工程";
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // numericUpDown5
- //
- this.numericUpDown5.Location = new System.Drawing.Point(92, 124);
- this.numericUpDown5.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown5.Name = "numericUpDown5";
- this.numericUpDown5.Size = new System.Drawing.Size(74, 21);
- this.numericUpDown5.TabIndex = 5;
- this.numericUpDown5.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(57, 126);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(0, 12);
- this.label1.TabIndex = 3;
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(59, 54);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(107, 23);
- this.button4.TabIndex = 1;
- this.button4.Text = "导出结果";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(59, 20);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(107, 23);
- this.button3.TabIndex = 0;
- this.button3.Text = "生成报告";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // groupBox8
- //
- this.groupBox8.Controls.Add(this.numericUpDown1);
- this.groupBox8.Controls.Add(this.label6);
- this.groupBox8.Controls.Add(this.panel2);
- this.groupBox8.Controls.Add(this.label5);
- this.groupBox8.Location = new System.Drawing.Point(6, 102);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(360, 57);
- this.groupBox8.TabIndex = 18;
- this.groupBox8.TabStop = false;
- this.groupBox8.Text = "测量线设置";
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(64, 18);
- this.numericUpDown1.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(74, 21);
- this.numericUpDown1.TabIndex = 4;
- this.numericUpDown1.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(179, 20);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(29, 12);
- this.label6.TabIndex = 3;
- this.label6.Text = "颜色";
- //
- // panel2
- //
- this.panel2.BackColor = System.Drawing.Color.Blue;
- this.panel2.Location = new System.Drawing.Point(214, 20);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(96, 19);
- this.panel2.TabIndex = 2;
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(10, 20);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(29, 12);
- this.label5.TabIndex = 0;
- this.label5.Text = "线宽";
- //
- // groupBox9
- //
- this.groupBox9.Controls.Add(this.radioButton2);
- this.groupBox9.Controls.Add(this.radioButton1);
- this.groupBox9.Location = new System.Drawing.Point(6, 165);
- this.groupBox9.Name = "groupBox9";
- this.groupBox9.Size = new System.Drawing.Size(360, 50);
- this.groupBox9.TabIndex = 19;
- this.groupBox9.TabStop = false;
- this.groupBox9.Text = "操作";
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(181, 20);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(47, 16);
- this.radioButton2.TabIndex = 4;
- this.radioButton2.TabStop = true;
- this.radioButton2.Text = "截点";
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(65, 20);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(59, 16);
- this.radioButton1.TabIndex = 3;
- this.radioButton1.TabStop = true;
- this.radioButton1.Text = "测量线";
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
- //
- // groupBox10
- //
- this.groupBox10.Controls.Add(this.numericUpDown4);
- this.groupBox10.Controls.Add(this.label11);
- this.groupBox10.Controls.Add(this.label10);
- this.groupBox10.Controls.Add(this.panel4);
- this.groupBox10.Controls.Add(this.numericUpDown3);
- this.groupBox10.Controls.Add(this.lbl_line);
- this.groupBox10.Controls.Add(this.numericUpDown2);
- this.groupBox10.Controls.Add(this.label9);
- this.groupBox10.Controls.Add(this.label8);
- this.groupBox10.Controls.Add(this.panel3);
- this.groupBox10.Controls.Add(this.rb_2);
- this.groupBox10.Controls.Add(this.rb_1);
- this.groupBox10.Location = new System.Drawing.Point(6, 221);
- this.groupBox10.Name = "groupBox10";
- this.groupBox10.Size = new System.Drawing.Size(360, 102);
- this.groupBox10.TabIndex = 20;
- this.groupBox10.TabStop = false;
- this.groupBox10.Text = "截点格式设置";
- //
- // numericUpDown4
- //
- this.numericUpDown4.Location = new System.Drawing.Point(212, 72);
- this.numericUpDown4.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.numericUpDown4.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown4.Name = "numericUpDown4";
- this.numericUpDown4.Size = new System.Drawing.Size(74, 21);
- this.numericUpDown4.TabIndex = 24;
- this.numericUpDown4.Value = new decimal(new int[] {
- 30,
- 0,
- 0,
- 0});
- this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(179, 75);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(29, 12);
- this.label11.TabIndex = 23;
- this.label11.Text = "误差";
- //
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(179, 51);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(29, 12);
- this.label10.TabIndex = 22;
- this.label10.Text = "颜色";
- //
- // panel4
- //
- this.panel4.BackColor = System.Drawing.Color.Yellow;
- this.panel4.Location = new System.Drawing.Point(212, 48);
- this.panel4.Name = "panel4";
- this.panel4.Size = new System.Drawing.Size(100, 19);
- this.panel4.TabIndex = 21;
- this.panel4.Click += new System.EventHandler(this.panel4_Click);
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(65, 72);
- this.numericUpDown3.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(74, 21);
- this.numericUpDown3.TabIndex = 14;
- this.numericUpDown3.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // lbl_line
- //
- this.lbl_line.AutoSize = true;
- this.lbl_line.Location = new System.Drawing.Point(16, 75);
- this.lbl_line.Name = "lbl_line";
- this.lbl_line.Size = new System.Drawing.Size(29, 12);
- this.lbl_line.TabIndex = 13;
- this.lbl_line.Text = "线宽";
- //
- // numericUpDown2
- //
- this.numericUpDown2.Location = new System.Drawing.Point(64, 46);
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(74, 21);
- this.numericUpDown2.TabIndex = 10;
- this.numericUpDown2.Value = new decimal(new int[] {
- 20,
- 0,
- 0,
- 0});
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(16, 51);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(29, 12);
- this.label9.TabIndex = 9;
- this.label9.Text = "大小";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(16, 24);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(29, 12);
- this.label8.TabIndex = 8;
- this.label8.Text = "形状";
- //
- // panel3
- //
- this.panel3.Controls.Add(this.label7);
- this.panel3.Controls.Add(this.rb_4);
- this.panel3.Controls.Add(this.rb_3);
- this.panel3.Location = new System.Drawing.Point(178, 11);
- this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(176, 34);
- this.panel3.TabIndex = 5;
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(12, 11);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(29, 12);
- this.label7.TabIndex = 7;
- this.label7.Text = "样式";
- //
- // rb_4
- //
- this.rb_4.AutoSize = true;
- this.rb_4.Checked = true;
- this.rb_4.Location = new System.Drawing.Point(100, 9);
- this.rb_4.Name = "rb_4";
- this.rb_4.Size = new System.Drawing.Size(47, 16);
- this.rb_4.TabIndex = 6;
- this.rb_4.TabStop = true;
- this.rb_4.Text = "空心";
- this.rb_4.UseVisualStyleBackColor = true;
- this.rb_4.CheckedChanged += new System.EventHandler(this.rb_4_CheckedChanged);
- //
- // rb_3
- //
- this.rb_3.AutoSize = true;
- this.rb_3.Location = new System.Drawing.Point(47, 9);
- this.rb_3.Name = "rb_3";
- this.rb_3.Size = new System.Drawing.Size(47, 16);
- this.rb_3.TabIndex = 5;
- this.rb_3.Text = "实心";
- this.rb_3.UseVisualStyleBackColor = true;
- this.rb_3.CheckedChanged += new System.EventHandler(this.rb_3_CheckedChanged);
- //
- // rb_2
- //
- this.rb_2.AutoSize = true;
- this.rb_2.Location = new System.Drawing.Point(116, 20);
- this.rb_2.Name = "rb_2";
- this.rb_2.Size = new System.Drawing.Size(47, 16);
- this.rb_2.TabIndex = 1;
- this.rb_2.Text = "方形";
- this.rb_2.UseVisualStyleBackColor = true;
- this.rb_2.CheckedChanged += new System.EventHandler(this.rb_2_CheckedChanged);
- //
- // rb_1
- //
- this.rb_1.AutoSize = true;
- this.rb_1.Checked = true;
- this.rb_1.Location = new System.Drawing.Point(65, 20);
- this.rb_1.Name = "rb_1";
- this.rb_1.Size = new System.Drawing.Size(47, 16);
- this.rb_1.TabIndex = 0;
- this.rb_1.TabStop = true;
- this.rb_1.Text = "圆形";
- this.rb_1.UseVisualStyleBackColor = true;
- this.rb_1.CheckedChanged += new System.EventHandler(this.rb_1_CheckedChanged);
- //
- // groupBox11
- //
- this.groupBox11.Controls.Add(this.checkBox6);
- this.groupBox11.Controls.Add(this.checkBox5);
- this.groupBox11.Controls.Add(this.checkBox4);
- this.groupBox11.Location = new System.Drawing.Point(6, 329);
- this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(360, 47);
- this.groupBox11.TabIndex = 21;
- this.groupBox11.TabStop = false;
- //
- // checkBox6
- //
- this.checkBox6.AutoSize = true;
- this.checkBox6.Checked = true;
- this.checkBox6.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox6.Location = new System.Drawing.Point(245, 20);
- this.checkBox6.Name = "checkBox6";
- this.checkBox6.Size = new System.Drawing.Size(72, 16);
- this.checkBox6.TabIndex = 2;
- this.checkBox6.Text = "显示截点";
- this.checkBox6.UseVisualStyleBackColor = true;
- this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
- //
- // checkBox5
- //
- this.checkBox5.AutoSize = true;
- this.checkBox5.Checked = true;
- this.checkBox5.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox5.Location = new System.Drawing.Point(134, 20);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(72, 16);
- this.checkBox5.TabIndex = 1;
- this.checkBox5.Text = "显示网格";
- this.checkBox5.UseVisualStyleBackColor = true;
- this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
- //
- // checkBox4
- //
- this.checkBox4.AutoSize = true;
- this.checkBox4.Checked = true;
- this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox4.Location = new System.Drawing.Point(12, 20);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(96, 16);
- this.checkBox4.TabIndex = 0;
- this.checkBox4.Text = "显示二值数据";
- this.checkBox4.UseVisualStyleBackColor = true;
- this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
- //
- // sqLiteCommand1
- //
- this.sqLiteCommand1.CommandText = null;
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox3.Controls.Add(this.groupBox2);
- this.groupBox3.Controls.Add(this.groupBox8);
- this.groupBox3.Controls.Add(this.groupBox9);
- this.groupBox3.Controls.Add(this.groupBox10);
- this.groupBox3.Controls.Add(this.groupBox11);
- this.groupBox3.Location = new System.Drawing.Point(178, 365);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(372, 381);
- this.groupBox3.TabIndex = 22;
- this.groupBox3.TabStop = false;
- //
- // PolyphaseDistanceDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1192, 921);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox_review);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox4);
- this.Name = "PolyphaseDistanceDialog";
- this.Shown += new System.EventHandler(this.showImg);
- this.Resize += new System.EventHandler(this.PolyphaseDistanceDialog_Resize);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox4.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.groupBox5.ResumeLayout(false);
- this.groupBox6.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
- this.groupBox8.ResumeLayout(false);
- this.groupBox8.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.groupBox9.ResumeLayout(false);
- this.groupBox9.PerformLayout();
- this.groupBox10.ResumeLayout(false);
- this.groupBox10.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- this.panel3.ResumeLayout(false);
- this.panel3.PerformLayout();
- this.groupBox11.ResumeLayout(false);
- this.groupBox11.PerformLayout();
- this.groupBox3.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- private void InitializeComponent2()
- {
- this.bc = new PaintDotNet.CustomControl.BinaryControl();
- //
- // bc
- //
- this.bc.BinaryBackColor = System.Drawing.Color.Red;
- this.bc.BinaryChecked = false;
- this.bc.BinaryStyle = 1;
- this.bc.Location = new System.Drawing.Point(178, 72);
- this.bc.Name = "bc";
- this.bc.OriginChecked = false;
- this.bc.scope1End = 0D;
- this.bc.scope1Start = 0D;
- this.bc.scope2End = 0D;
- this.bc.scope2Start = 0D;
- this.bc.scope3End = 0D;
- this.bc.scope3Start = 0D;
- this.bc.Size = new System.Drawing.Size(360, 292);
- this.bc.TabIndex = 3;
- //
- this.Controls.Add(this.bc);
- this.Controls.SetChildIndex(this.bc, 0);
- }
- #endregion
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 主空间
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 选中图片的mat
- /// </summary>
- private Mat imageMat;
- /// <summary>
- /// 处理程序
- /// </summary>
- private ParamObject action = new Data.Action.Action1010();
- int decnum = 2;
- DrawAnalysisModel lineStyleModel = new DrawAnalysisModel();
- DrawAnalysisModel pointStyleModel = new DrawAnalysisModel();
- private ColorsForm colorsFormGrid;
- private ColorsForm lineColorsFormGrid;
- private ColorsForm PointcolorsFormGrid;
- List<PolyphaseDistanceResult> allResults = new List<PolyphaseDistanceResult>();
- private Dictionary<string, List<List<string>>> intermediateDataList = new Dictionary<string, List<List<string>>>();
- //0 画线 1 画截点
- private int drawaction = 0;
- List<PolyphaseDistanceLineResult> lineResults = new List<PolyphaseDistanceLineResult>();
- List<DrawObject> drawObjects = new List<DrawObject>();
- List<DrawObject> rmObjects = new List<DrawObject>();
- private int offsetHalfW = 0;
- private int offsetHalfH = 0;
- private int m_tolerance = 30;
- private int tolerance = 2;
- //0 画线 1 删除
- private int lineAction = 0;
- private decimal maxArea = 0;
- private System.Drawing.Point lineStartPos = new System.Drawing.Point();
- private DrawMulLineA activeLine = null;
- private PhaseModel activePhaseModel = null;
- //private List<Bitmap> bitList = new List<Bitmap>();
- private List<Bitmap> bitList = new List<Bitmap>();
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- private int is_all = 0;
- private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
- private int selectPicture = -1;
- private Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel> everyImgData = new Dictionary<string, GeneralAnalysisModel.PolyphaseDistanceModel>();
- private string selectedImg = string.Empty;
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- public PolyphaseDistanceDialog()
- {
- InitializeComponent();
- }
- #region 公共按钮
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- documentWorkspace.panel.MouseMove += Panel_MouseMove;
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- documentWorkspace.panel.MouseMove -= Panel_MouseMove;
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- #endregion
- public PolyphaseDistanceDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
- {
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- binaryClass = new BinaryClass(menuId);
- InitializeComponent();
- InitializeComponent2();
- InitializeLanguageText();
- this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.lineColorsFormGrid = new ColorsForm();
- this.lineColorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.PointcolorsFormGrid = new ColorsForm();
- this.PointcolorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.appWorkspace = appWorkspace;
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = false;
- documentWorkspace.ActiveTool = DrawToolType.NullTool;
- documentWorkspace.GraphicsList.UnselectAll();
- this.groupBox_review.Controls.Add(documentWorkspace);
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox_review.Controls.Add(commonControlButtons);
- documentWorkspace.panel.MouseDown += Panel_MouseDown;
- documentWorkspace.panel.MouseUp += Panel_MouseUp;
- documentWorkspace.panel.Paint += Panel_Paint;
- documentWorkspace.panel.MouseMove += Panel_MouseMove;
- InitPicList();
- SetAnalyzeModelFromXml("Template.Manager.item2.PolyphaseDistance");
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
- SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
- UpdateStyle();
- InitCommonButtonEvent();
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
- }
- /// <summary>
- /// 获取上次操作参数
- /// </summary>
- private void getLastData()
- {
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- if (!System.IO.File.Exists(filePath))
- {
- generalAnalysisModel = new GeneralAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
- generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
- generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
- generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
- generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
- generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
- generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
- generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
- generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
- generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
- generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
- }
- else
- {
- generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- if (generalAnalysisModel.PolyphaseDistanceModels == null)
- {
- generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
- }
- if (generalAnalysisModel.PolyphaseDistanceModels.hasUsed)
- {
- checkBox3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter1;
- if (generalAnalysisModel.PolyphaseDistanceModels.parameter2 <= triangleTrackBar1.Maximum)
- {
- triangleTrackBar1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter2;
- lbl_kl_min.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter2.ToString();
- }
- if (generalAnalysisModel.PolyphaseDistanceModels.parameter3 <= triangleTrackBar2.Maximum)
- {
- triangleTrackBar2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter3;
- lbl_kl_max.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter3.ToString();
- }
- if (checkBox3.Checked)
- {
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
- triangleTrackBar1.Maximum = (int)maxArea;
- triangleTrackBar2.Maximum = (int)maxArea;
- triangleTrackBar2_TrackBarScroll(null, null);
- }
- numericUpDown1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter4;
- panel2.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter5);
- radioButton1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? true : false;
- radioButton2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? false : true;
- rb_1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? true : false;
- rb_2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? false : true;
- rb_3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? true : false;
- rb_4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? false : true;
- numericUpDown2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter9;
- panel4.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter10);
- numericUpDown3.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter11;
- numericUpDown4.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter12;
- checkBox4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter13;
- checkBox5.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter14;
- checkBox6.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter15;
- numericUpDown5.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter16;
- GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
- checkBox1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter17;
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (everyImgData.ContainsKey(listView1.Items[i].Name))
- {
- everyImgData[listView1.Items[i].Name] = generalAnalysisModel.PolyphaseDistanceModels;
- }
- else
- {
- everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.PolyphaseDistanceModels);
- }
- }
- }
- }
- }
- /// <summary>
- /// 保存上次操作参数
- /// </summary>
- private void saveLastData(object sender, EventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- binaryClass.saveParams();
- if (generalAnalysisModel.PolyphaseDistanceModels == null)
- {
- generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
- }
- generalAnalysisModel.PolyphaseDistanceModels.hasUsed = true;
- generalAnalysisModel.PolyphaseDistanceModels.parameter1 = checkBox3.Checked;
- generalAnalysisModel.PolyphaseDistanceModels.parameter2 = triangleTrackBar1.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter3 = triangleTrackBar2.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter4 = (int)numericUpDown1.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter5 = panel2.BackColor.ToArgb();
- generalAnalysisModel.PolyphaseDistanceModels.parameter17 = checkBox1.Checked;
- if (radioButton1.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 1;
- }
- else if (radioButton2.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 2;
- }
- else
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 3;
- }
- if (rb_1.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 1;
- }
- else if (rb_2.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 2;
- }
- else
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 3;
- }
- if (rb_3.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 1;
- }
- else if (rb_4.Checked)
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 2;
- }
- else
- {
- generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 3;
- }
- generalAnalysisModel.PolyphaseDistanceModels.parameter9 = (int)numericUpDown2.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter10 = panel4.BackColor.ToArgb();
- generalAnalysisModel.PolyphaseDistanceModels.parameter11 = (int)numericUpDown3.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter12 = (int)numericUpDown4.Value;
- generalAnalysisModel.PolyphaseDistanceModels.parameter13 = checkBox4.Checked;
- generalAnalysisModel.PolyphaseDistanceModels.parameter14 = checkBox5.Checked;
- generalAnalysisModel.PolyphaseDistanceModels.parameter15 = checkBox6.Checked;
- generalAnalysisModel.PolyphaseDistanceModels.parameter16 = (int)numericUpDown5.Value;
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
- }
- #region [二值化相关方法]
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GrainSizeDialog_Load(object sender, EventArgs e)
- {
- this.binaryClass.loadParams();
- }
- private bool bcBinaryChecked()
- {
- return bc != null && bc.BinaryChecked;
- }
- private bool bcOriginChecked()
- {
- return bc != null && bc.OriginChecked;
- }
- /// <summary>
- /// 显示原图/原图+二值图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bcOriginCheckedChanged(object sender, EventArgs e)
- {
- if (!bcOriginChecked())
- {
- if (bcBinaryChecked())
- {
- if (checkBox4.Checked)
- {
- this.documentWorkspace.PhaseModels[0].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- }
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- if (!bcOriginChecked())
- {
- if (bcBinaryChecked())
- {
- if (checkBox4.Checked)
- {
- this.documentWorkspace.PhaseModels[0].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- this.drawObjects.RemoveAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
- if (!bcBinaryChecked())
- {
- this.rmObjects = this.drawObjects.FindAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
- }
- else
- {
- this.drawObjects.AddRange(this.rmObjects);
- this.rmObjects.Clear();
- UpdateLine();
- if (checkBox3.Checked)
- {
- GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
- }
- }
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- private void showImg(object sender, EventArgs e)
- {
- listView1.Focus();
- if (this.imgIndex != -1)
- {
- //滚动到指定的行位置
- this.listView1.EnsureVisible(this.imgIndex);
- this.selectPicture = this.imgIndex;
- this.listView1.Items[imgIndex].Focused = true;
- this.listView1.Items[imgIndex].Selected = true;
- }
- binaryClass.RefreshHistogramControl1Values();
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
- {
- this.initScriptValues = true;//ScriptAutomatic
- //Boolean initScriptValues = true;
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- getValue(arg.key, arg.Value);
- }
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- }
- else
- {//读取上次关闭窗口时保存的参数
- getLastData();
- }
- }
- private void Init()
- {
- this.drawObjects.Clear();
- this.lineResults.Clear();
- //this.documentWorkspace.phaseModels.Clear();
- //this.documentWorkspace.GraphicsList.Clear();
- }
- private void Panel_MouseMove(object sender, MouseEventArgs e)
- {
- System.Drawing.Point pointscroll = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
- if (e.Button == MouseButtons.Left&& documentWorkspace.ActiveTool == DrawToolType.NullTool)
- {
- if (drawaction == 0)
- {
- if (activeLine != null)
- {
- if (activeLine.pointArray.Count == 1)
- activeLine.pointArray.Add(pointscroll);
- else
- activeLine.pointArray[1] = pointscroll;
- }
- }
- this.documentWorkspace.Refresh();
- }
- }
- private void Panel_Paint(object sender, PaintEventArgs e)
- {
- Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
- int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
- int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
- int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
- int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
- e.Graphics.TranslateTransform(x, y);
- e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
- if (drawObjects != null)
- {
- foreach (DrawObject drobj in drawObjects)
- {
- drobj.Draw(e.Graphics);
- }
- }
- e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
- e.Graphics.TranslateTransform(-x, -y);
- }
- private void UpdateLine()
- {
- if (listView1.Items.Count == 0 || listView1.SelectedItems == null)
- {
- return;
- }
- List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
- Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
- if (mat.Channels() <= 3)
- {
- mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
- }
- Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
- foreach (var line in lines)
- {
- if (line == null || line.GetPoints().Count < 2)
- {
- continue;
- }
- PointF a = line.GetPoints()[0];
- PointF b = line.GetPoints()[1];
- List<System.Drawing.Point> points = new List<System.Drawing.Point>();
- int linkCount = 0;
- PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
- var ind = lineResults.IndexOf(lineResult);
- if (lineResult == null)
- {
- continue;
- }
- foreach (int pointid in lineResult.PointIDs.Keys)
- {
- DrawObject dr = drawObjects.Find(u => u.ID == pointid);
- if (dr != null)
- {
- this.drawObjects.Remove(dr);
- }
- }
- List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
- for (int i = 0; i < linePoints.Count; i++)
- {
- System.Drawing.Point ploc = linePoints[i];
- if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
- {
- Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
- if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
- {
- linkCount++;
- if (linkCount == 1)
- {
- points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- else if ((linkCount % m_tolerance) == 0)
- {
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- }
- else
- {
- linkCount = 0;
- }
- }
- }
- lineResults[ind] = lineResult;
- }
- }
- private void UpdateStyle()
- {
- lineStyleModel.lineColor = panel2.BackColor.ToArgb();
- lineStyleModel.lineWidth = (int)numericUpDown1.Value;
- pointStyleModel.lineWidth = (int)numericUpDown3.Value;
- pointStyleModel.size = (int)numericUpDown2.Value;
- if (checkBox6.Checked)
- {
- pointStyleModel.fillColor = panel4.BackColor.ToArgb();
- pointStyleModel.lineColor = panel4.BackColor.ToArgb();
- }
- else
- {
- pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
- pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
- }
- m_tolerance = (int)numericUpDown4.Value;
- if (rb_3.Checked)
- {
- pointStyleModel.fillType = 1;
- }
- else if (rb_4.Checked)
- {
- pointStyleModel.fillType = 0;
- }
- if (rb_1.Checked)
- {
- pointStyleModel.DrawType = 0;
- List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
- foreach (DrawObject lineObj in lines)
- {
- PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
- Hashtable newPoints = new Hashtable();
- if (lineResult == null)
- {
- continue;
- }
- foreach (int pointid in lineResult.PointIDs.Keys)
- {
- DrawObject dr = drawObjects.Find(u => u.ID == pointid);
- if (dr != null)
- {
- this.drawObjects.Remove(dr);
- }
- System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
- //lineResult.PointIDs.Remove(pointid);
- DrawCircleA squareA = new DrawCircleA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- newPoints.Add(squareA.ID, linePoint);
- this.drawObjects.Add(squareA);
- }
- lineResult.PointIDs = newPoints;
- }
- }
- else if (rb_2.Checked)
- {
- pointStyleModel.DrawType = 1;
- List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
- foreach (DrawObject lineObj in lines)
- {
- PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
- if (lineResult == null)
- {
- continue;
- }
- Hashtable newPoints = new Hashtable();
- foreach (int pointid in lineResult.PointIDs.Keys)
- {
- DrawObject dr = drawObjects.Find(u => u.ID == pointid);
- if (dr != null)
- {
- this.drawObjects.Remove(dr);
- }
- System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
- //lineResult.PointIDs.Remove(pointid);
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- newPoints.Add(squareA.ID, linePoint);
- this.drawObjects.Add(squareA);
- }
- lineResult.PointIDs = newPoints;
- //drawObjects[i].drawToolType = DrawToolType.DrawCircleA;
- //if (pointStyleModel.DrawType == 0)
- //{
- // DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
- // circleA.ISurfaceBox = documentWorkspace;
- // lineResult.PointIDs.Add(circleA.ID, linePoint);
- // this.drawObjects.Add(circleA);
- //}
- //else
- //{
- }
- }
- decnum = (int)numericUpDown5.Value;
- this.documentWorkspace.Refresh();
- }
- private DrawObject getDrawObjectsByLocation(PointF point, DrawToolType drawToolType)
- {
- foreach (DrawObject dr in drawObjects)
- {
- if (dr.drawToolType == drawToolType)
- {
- if (dr.drawToolType == DrawToolType.DrawMulLineA)
- {
- //判断线
- if (dr.GetPoints().Count > 1)
- {
- PointF a = dr.GetPoints()[0];
- PointF b = dr.GetPoints()[1];
- List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
- for (int i = 0; i < linePoints.Count; i++)
- {
- if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), linePoints[i], tolerance))
- {
- return dr;
- }
- }
- }
- }
- if (dr.drawToolType == drawToolType)
- {
- System.Drawing.Point pointLocation = new System.Drawing.Point((int)dr.GetPoints()[0].X, (int)dr.GetPoints()[0].Y);
- if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), pointLocation, tolerance))
- {
- return dr;
- }
- }
- }
- }
- return null;
- }
- private bool ComparePoint(System.Drawing.Point source, System.Drawing.Point target, int tolerance)
- {
- if ((source.X >= (target.X - tolerance)) && (source.X <= (target.X + tolerance)) && (source.Y >= (target.Y - tolerance)) && (source.Y <= (target.Y + tolerance)))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void Panel_MouseDown(object sender, MouseEventArgs e)
- {
- if (documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
- }
- if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
- {
- System.Drawing.Point loc = documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
- DrawObject line = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawMulLineA);
- //首先判断是否在线上
- if (line != null)
- {
- PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
- //List<System.Drawing.Point> activeLinePoints = (List<System.Drawing.Point>)linesPoints[line.ID];
- if (drawaction == 1)
- {
- DrawObject circleObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawCircleA);
- DrawObject squareObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawSquareA);
- if (circleObject == null && squareObject == null)
- {
- //碰撞检测,如未检测到对象则新增。
- if (line.GetPoints().Count >= 2)
- {
- PointF a = line.GetPoints()[0];
- PointF b = line.GetPoints()[1];
- List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
- System.Drawing.Point linePoint = linePoints.Find(u => ComparePoint(u, loc, tolerance));
- if (linePoint != null)
- {
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, linePoint);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, linePoint);
- this.drawObjects.Add(squareA);
- }
- //activeLinePoints.Add(linePoint);
- }
- }
- }
- else
- {
- if (e.Clicks > 1)
- {
- //如果存在截点,则删除截点
- if (circleObject != null)
- {
- this.drawObjects.Remove(circleObject);
- if (lineResult != null)
- {
- lineResult.PointIDs.Remove(circleObject.ID);
- }
- }
- if (squareObject != null)
- {
- this.drawObjects.Remove(squareObject);
- if (lineResult != null)
- {
- lineResult.PointIDs.Remove(squareObject.ID);
- }
- }
- }
- }
- }
- else
- {
- if (e.Clicks > 1)
- {
- //画线模式,发现线,则删除
- if (lineResult != null)
- {
- foreach (int pointid in lineResult.PointIDs.Keys)
- {
- DrawObject dr = drawObjects.Find(u => u.ID == pointid);
- if (dr != null)
- {
- this.drawObjects.Remove(dr);
- }
- }
- this.drawObjects.Remove(line);
- lineResults.RemoveAll(u => u.LineID == line.ID);
- activeLine = null;
- }
- }
- lineAction = 1;
- }
- }
- else
- {
- lineStartPos = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
- this.documentWorkspace.AnalysisStyleModel = lineStyleModel;
- activeLine = new DrawMulLineA(this.documentWorkspace, lineStartPos.X, lineStartPos.Y);
- this.drawObjects.Add(activeLine);
- lineAction = 0;
- }
- documentWorkspace.Refresh();
- }
- }
- int XiangSu = 1;
- /// <summary>
- /// Bresenham画线算法,给出两个点a,b
- /// </summary>
- /// PS:这里XiangSu是光栅的最小距离,因为我是在高分辨率的窗口中模拟低分辨率效果,
- /// 所以用这个XiangSu来控制模拟的光栅最小单元格的边的大小,实际运用中XiangSu=1
- /// <param name="a"></param>
- /// <param name="b"></param>
- List<System.Drawing.Point> Bresenhamline(System.Drawing.PointF a, System.Drawing.PointF b)
- {
- List<System.Drawing.Point> tempP = new List<System.Drawing.Point>();
- int x, y, dx, dy, s1, s2, p, temp, interchange, i;
- x = (int)a.X;
- y = (int)a.Y;
- dx = Math.Abs((int)b.X - (int)a.X);
- dy = Math.Abs((int)b.Y - (int)a.Y);
- if (b.X > a.X)
- s1 = XiangSu;
- else
- s1 = -XiangSu;
- if (b.Y > a.Y)
- s2 = XiangSu;
- else
- s2 = -XiangSu;
- if (dy > dx)
- {
- temp = dx;
- dx = dy;
- dy = temp;
- interchange = 1;
- }
- else
- interchange = 0;
- p = 2 * dy - dx;
- for (i = 1; i <= dx; i += XiangSu)
- {
- System.Drawing.Point tempp = new System.Drawing.Point(x, y);
- tempp.X = x;
- tempp.Y = y;
- tempP.Add(tempp);
- //Vram[x + y * 600] = true;//把该片内存置为边界标记
- if (p >= 0)
- {
- if (interchange == 0)
- y = y + s2;
- else
- x = x + s1;
- p = p - 2 * dx;
- }
- if (interchange == 0)
- x = x + s1;
- else
- y = y + s2;
- p = p + 2 * dy;
- }
- return tempP;
- }
- private void Panel_MouseUp(object sender, MouseEventArgs e)
- {
- //画线
- if (drawaction == 0)
- {
- if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
- {
- if (lineAction == 0)
- {
- if (activeLine != null && activeLine.GetPoints().Count > 1)
- {
- PointF a = activeLine.GetPoints()[0];
- PointF b = activeLine.GetPoints()[1];
- List<System.Drawing.Point> points = new List<System.Drawing.Point>();
- Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
- if (mat.Channels() <= 3)
- {
- mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
- }
- Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
- int linkCount = 0;
- PolyphaseDistanceLineResult lineResult = new PolyphaseDistanceLineResult();
- lineResult.LineID = activeLine.ID;
- List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
- for (int i = 0; i < linePoints.Count; i++)
- {
- System.Drawing.Point ploc = linePoints[i];
- if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
- {
- Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
- if (targetPoint[0] == color.B && targetPoint[1] == color.G &&
- targetPoint[2] == color.R && targetPoint[3] == 255)
- {
- linkCount++;
- if (linkCount == 1)
- {
- points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- else if ((linkCount % m_tolerance) == 0)
- {
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- }
- else
- {
- linkCount = 0;
- }
- }
- }
- lineResults.Add(lineResult);
- }
- }
- }
- }
- documentWorkspace.ActiveTool = DrawToolType.NullTool;
- documentWorkspace.Cursor = Cursors.Default;
- documentWorkspace.GraphicsList.UnselectAll();
- documentWorkspace.Refresh();
- }
- /// <summary>
- /// 初始化图片列表数据
- /// </summary>
- //public void InitPicList()
- //{
- // //初始化图片列表
- // for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- // {
- // this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
- // this.listView1.Items.Add("", i);
- // this.listView1.Items[i].ImageIndex = i;
- // this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- // this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- // }
- //}
- public void InitPicList()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (listView1.Items.Find(imageName, false).Count() > 0)
- {
- if (imageName.Split('.').Count() > 1)
- {
- imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
- }
- }
- this.listView1.Items[i].Text = imageName;
- this.listView1.Items[i].Name = imageName;
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- this.imgIndex = i;
- }
- }
- }
- /// <summary>
- /// ListView图片选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ListViewSelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
- {
- Init();
- if (!string.IsNullOrEmpty(selectedImg))
- {
- #region [保存参数]
- var model = new GeneralAnalysisModel.PolyphaseDistanceModel();
- model.parameter1 = checkBox3.Checked;
- model.parameter2 = triangleTrackBar1.Value;
- model.parameter3 = triangleTrackBar2.Value;
- model.parameter4 = (int)numericUpDown1.Value;
- model.parameter5 = panel2.BackColor.ToArgb();
- model.parameter17 = checkBox1.Checked;
- if (radioButton1.Checked)
- {
- model.parameter6 = 1;
- }
- else if (radioButton2.Checked)
- {
- model.parameter6 = 2;
- }
- else
- {
- model.parameter6 = 3;
- }
- if (rb_1.Checked)
- {
- model.parameter7 = 1;
- }
- else if (rb_2.Checked)
- {
- model.parameter7 = 2;
- }
- else
- {
- model.parameter7 = 3;
- }
- if (rb_3.Checked)
- {
- model.parameter8 = 1;
- }
- else if (rb_4.Checked)
- {
- model.parameter8 = 2;
- }
- else
- {
- model.parameter8 = 3;
- }
- model.parameter9 = (int)numericUpDown2.Value;
- model.parameter10 = panel4.BackColor.ToArgb();
- model.parameter11 = (int)numericUpDown3.Value;
- model.parameter12 = (int)numericUpDown4.Value;
- model.parameter13 = checkBox4.Checked;
- model.parameter14 = checkBox5.Checked;
- model.parameter15 = checkBox6.Checked;
- model.parameter16 = (int)numericUpDown5.Value;
- if (everyImgData.ContainsKey(selectedImg))
- {
- everyImgData[selectedImg] = model;
- }
- else
- {
- everyImgData.Add(selectedImg, model);
- }
- #endregion
- }
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- Document document = Document.FromImageMat(imageMat.Clone());
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- if (selectPicture != -1)
- {
- this.binaryClass.saveMat(this.imageList1.Images.Keys[selectPicture]);
- }
- selectPicture = this.listView1.FocusedItem.Index;
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), this.imageList1.Images.Keys[selectPicture]);
- if (this.documentWorkspace.phaseModels.Count > 0)
- {
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
- triangleTrackBar1.Maximum = (int)maxArea;
- triangleTrackBar2.Maximum = (int)maxArea;
- }
- else
- {
- triangleTrackBar1.Maximum = 10000;
- triangleTrackBar2.Maximum = 10000;
- }
- if (this.isCheck)
- {
- checkBox3_BeforeCheckedChanged(sender, e);
- triangleTrackBar2.Value = triangleTrackBar2.Maximum;
- lbl_kl_max.Text = triangleTrackBar2.Maximum.ToString();
- }
- #region [设置参数]
- this.selectedImg = this.listView1.FocusedItem.Name;
- if (everyImgData.ContainsKey(this.selectedImg))
- {
- var thisModel = everyImgData[this.selectedImg];
- checkBox3.Checked = thisModel.parameter1;
- if (thisModel.parameter2 <= triangleTrackBar1.Maximum)
- {
- triangleTrackBar1.Value = thisModel.parameter2;
- }
- else
- {
- triangleTrackBar1.Value = 0;
- }
- if (thisModel.parameter3 <= triangleTrackBar2.Maximum)
- {
- triangleTrackBar2.Value = thisModel.parameter3;
- }
- else
- {
- triangleTrackBar2.Value = 0;
- }
- lbl_kl_min.Text = thisModel.parameter2.ToString();
- lbl_kl_max.Text = thisModel.parameter3.ToString();
- numericUpDown1.Value = thisModel.parameter4;
- panel2.BackColor = Color.FromArgb(thisModel.parameter5);
- radioButton1.Checked = thisModel.parameter6 == 1 ? true : false;
- radioButton2.Checked = thisModel.parameter6 == 1 ? false : true;
- rb_1.Checked = thisModel.parameter7 == 1 ? true : false;
- rb_2.Checked = thisModel.parameter7 == 1 ? false : true;
- rb_3.Checked = thisModel.parameter8 == 1 ? true : false;
- rb_4.Checked = thisModel.parameter8 == 1 ? false : true;
- numericUpDown2.Value = thisModel.parameter9;
- panel4.BackColor = Color.FromArgb(thisModel.parameter10);
- numericUpDown3.Value = thisModel.parameter11;
- numericUpDown4.Value = thisModel.parameter12;
- checkBox4.Checked = thisModel.parameter13;
- checkBox5.Checked = thisModel.parameter14;
- checkBox6.Checked = thisModel.parameter15;
- numericUpDown5.Value = thisModel.parameter16;
- GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
- checkBox1.Checked = thisModel.parameter17;
- }
- #endregion
- if (this.documentWorkspace.phaseModels.Count > 0)
- {
- if (this.documentWorkspace.phaseModels[0].mat != null)
- {
- original = this.documentWorkspace.phaseModels[0].mat.Clone();
- }
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- if (this.appWorkspace.DocumentWorkspaces.Length == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
- return;
- }
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- if (listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.seselecttheimagethatyouwanttoan.Text") + "!");
- return;
- }
- if (lineResults.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
- return;
- }
- String tag = listView1.FocusedItem.Text;
- List<Bitmap> tempBit = new List<Bitmap>();
- double avgDistince = 0f;
- double distinceSum = 0f;
- //计算间距
- int distinceCount = 0;
- int pointCount = 0;
- List<List<string>> dataList = new List<List<string>>();
- List<string> titleList = new List<string>();
- titleList.Add(PdnResources.GetString("Menu.Thetotallength.Text"));
- titleList.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
- titleList.Add(PdnResources.GetString("Menu.Theaveragelengthof.Text"));
- dataList.Add(titleList);
- for (int i = 0; i < lineResults.Count; i++)
- {
- pointCount += lineResults[i].PointIDs.Count;
- System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
- lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
- pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
- for (int j = 0; j < pointArray.Count() - 1; j++)
- {
- double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10);
- distinceSum += distince * pxPerUnit;
- distinceCount++;
- }
- List<string> newList = new List<string>();
- if (distinceSum != 0)
- {
- newList.Add(distinceSum.ToString());
- newList.Add(pointArray.Count().ToString());
- newList.Add(Math.Round(distinceSum / (pointArray.Count() / 2), 2).ToString());
- dataList.Add(newList);
- }
- }
- if (intermediateDataList.ContainsKey(listView1.FocusedItem.Text.ToString()))
- {
- intermediateDataList[listView1.FocusedItem.Text.ToString()] = dataList;
- }
- else
- {
- intermediateDataList.Add(listView1.FocusedItem.Text.ToString(), dataList);
- }
- if (distinceCount > 0)
- {
- avgDistince = distinceSum / distinceCount;
- }
- //计算方差
- double dfSum = 0f;
- double fc = 0f;
- int fcCount = 0;
- for (int i = 0; i < lineResults.Count; i++)
- {
- System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
- lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
- pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
- for (int j = 0; j < pointArray.Count() - 1; j++)
- {
- double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10) * pxPerUnit;
- double df = Math.Pow((distince - avgDistince), 2);
- dfSum += df;
- fcCount++;
- }
- }
- if (fcCount > 0)
- {
- fc = dfSum / fcCount;
- }
- PolyphaseDistanceResult result = new PolyphaseDistanceResult(listView1.FocusedItem.Text.ToString(), avgDistince, fc, pointCount);
- if (listView1.SelectedItems.Count > 0)
- {
- List<PolyphaseDistanceResult> editResults = allResults.FindAll(item => item.GraphName.Equals(listView1.FocusedItem.Text));
- if (editResults.Count == 0)
- {
- listBox_analysisResult.Items.Add(this.listView1.FocusedItem.Text);
- allResults.Add(result);
- listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
- dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
- }
- else
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- if (dr != DialogResult.OK)
- {
- return;
- }
- int index = allResults.FindIndex(item => item.GraphName.Equals(listView1.FocusedItem.Text));
- allResults[index] = result;
- List<string> list = new List<string>();
- foreach (var s in this.listBox_analysisResult.Items)
- {
- list.Add(s.ToString());
- }
- this.listBox_analysisResult.Items.Clear();
- foreach (var s in list)
- {
- this.listBox_analysisResult.Items.Add(s);
- }
- var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
- this.dataGridView_results.Rows.Clear();
- listBox_analysisResult.SetItemChecked(thisindex, true);
- dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
- }
- double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- newBit.Tag = pantographRatio;
- Graphics graphics = Graphics.FromImage(newBit);
- Draw(graphics);
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- {
- bitDic[tag].Clear();
- bitDic[tag] = tempBit;
- }
- else
- {
- bitDic.Add(tag, tempBit);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- }
- }
- private void Draw(Graphics graphics)
- {
- if (this.documentWorkspace.phaseModels.Count > 0)
- {
- foreach (PhaseModel model in this.documentWorkspace.phaseModels)
- {
- if (model.choise && model.mat != null)
- {
- Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
- graphics.DrawImage(map, 0, 0, map.Width, map.Height);
- }
- }
- if (drawObjects != null)
- {
- foreach (DrawObject drobj in drawObjects)
- {
- drobj.Draw(graphics);
- }
- }
- }
- }
- private void button8_Click(object sender, EventArgs e)
- {
- drawaction = 1;
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- UpdateStyle();
- }
- private void rb_1_CheckedChanged(object sender, EventArgs e)
- {
- if (rb_1.Checked)
- {
- UpdateStyle();
- }
- }
- private void rb_2_CheckedChanged(object sender, EventArgs e)
- {
- if (rb_2.Checked)
- {
- UpdateStyle();
- }
- }
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- UpdateStyle();
- }
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- UpdateStyle();
- }
- private void rb_3_CheckedChanged(object sender, EventArgs e)
- {
- if (rb_3.Checked)
- {
- UpdateStyle();
- }
- }
- private void rb_4_CheckedChanged(object sender, EventArgs e)
- {
- if (rb_4.Checked)
- {
- UpdateStyle();
- }
- }
- private void panel2_Click(object sender, EventArgs e)
- {
- this.lineColorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
- this.lineColorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
- this.lineColorsFormGrid.ShowDialog();
- }
- private void lineColorChanged(object sender, EventArgs e)
- {
- Color color = this.lineColorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panel2.BackColor = color;
- //改变配置文件里面的相颜色
- //this.binaryExtractionModel.PhaseColor = color.ToArgb();
- //关闭色板
- UpdateStyle();
- this.lineColorsFormGrid.Close();
- }
- private void panel4_Click(object sender, EventArgs e)
- {
- this.PointcolorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
- this.PointcolorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.PointColorChanged));
- this.PointcolorsFormGrid.ShowDialog();
- }
- private void PointColorChanged(object sender, EventArgs e)
- {
- Color color = this.PointcolorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panel4.BackColor = color;
- //改变配置文件里面的相颜色
- //this.binaryExtractionModel.PhaseColor = color.ToArgb();
- //关闭色板
- UpdateStyle();
- this.PointcolorsFormGrid.Close();
- }
- private void checkBox6_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox6.Checked)
- {
- pointStyleModel.fillColor = panel4.BackColor.ToArgb();
- pointStyleModel.lineColor = panel4.BackColor.ToArgb();
- }
- else
- {
- pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
- pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
- }
- documentWorkspace.Refresh();
- }
- private void checkBox5_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox5.Checked)
- {
- lineStyleModel.lineColor = panel2.BackColor.ToArgb();
- }
- else
- {
- lineStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
- }
- documentWorkspace.Refresh();
- }
- private void checkBox4_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox4.Checked)
- {
- if (documentWorkspace.phaseModels.Count > 0)
- {
- documentWorkspace.phaseModels[0].choise = true;
- }
- }
- else
- {
- if (documentWorkspace.phaseModels.Count > 0)
- {
- documentWorkspace.phaseModels[0].choise = false;
- }
- }
- documentWorkspace.Refresh();
- }
- private void tb_2_Load(object sender, EventArgs e)
- {
- }
- private void triangleTrackBar2_TrackBarScroll(object sender, EventArgs e)
- {
- //Mat mat = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
- if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
- return;
- }
- this.documentWorkspace.phaseModels[0].mat = original.Clone();
- GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat.Clone());
- lbl_kl_max.Text = triangleTrackBar2.Value.ToString();
- redrawForTolerance();
- this.documentWorkspace.Refresh();
- }
- private void triangleTrackBar1_TrackBarScroll(object sender, EventArgs e)
- {
- if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
- return;
- }
- this.documentWorkspace.phaseModels[0].mat = original.Clone();
- GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
- lbl_kl_min.Text = triangleTrackBar1.Value.ToString();
- redrawForTolerance();
- this.documentWorkspace.Refresh();
- }
- private decimal getMaxArea(Mat pMat)
- {
- if (pMat == null)
- {
- return 10000;
- }
- double maxArea = 0;
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Count(); i++)
- {
- double area = Cv2.ContourArea(contours[i]);
- if (area > maxArea)
- {
- maxArea = area;
- }
- }
- return (decimal)maxArea;
- }
- private void checkBox3_BeforeCheckedChanged(object sender, EventArgs e)
- {
- if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
- this.checkBox3.Checked = false;
- return;
- }
- checkBox3_CheckedChanged(sender, e);
- }
- private void checkBox3_CheckedChanged(object sender, EventArgs e)
- {
- if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
- return;
- }
- this.isCheck = checkBox3.Checked;
- if (checkBox3.Checked)
- {
- if (this.documentWorkspace.phaseModels.Count > 0 && bcBinaryChecked())
- {
- //double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- //maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
- //triangleTrackBar1.Maximum = (int)maxArea;
- //triangleTrackBar2.Maximum = (int)maxArea;
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
- return;
- }
- }
- else
- {
- triangleTrackBar1.Value = 0;
- triangleTrackBar2.Value = 0;
- lbl_kl_max.Text = "0";
- lbl_kl_min.Text = "0";
- //binaryClass.applyButtonImpl();
- this.documentWorkspace.Refresh();
- }
- }
- private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
- {
- if (!checkBox3.Checked)
- {
- return;
- }
- List<OpenCvSharp.Point[]> selectContours = new List<OpenCvSharp.Point[]>();
- List<OpenCvSharp.Point[]> unSelectContours = new List<OpenCvSharp.Point[]>();
- Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- HierarchyIndex[] hierarchy;
- OpenCvSharp.Point[][] contours;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- for (int i = 0; i < contours.Length; i++)
- {
- double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)) - contours[i].Length / 2.0) * pxPerUnit * pxPerUnit;
- if (area < 0)
- {
- area = 0;
- }
- if (area >= (double)areaMin && area <= (double)areaMax)
- {
- selectContours.Add(contours[i]);
- }
- else
- {
- unSelectContours.Add(contours[i]);
- }
- }
- Cv2.DrawContours(documentWorkspace.phaseModels[0].mat, selectContours, -1, new Scalar(this.documentWorkspace.phaseModels[0].color), Cv2.FILLED);
- documentWorkspace.Refresh();
- }
- private void numericUpDown4_ValueChanged(object sender, EventArgs e)
- {
- m_tolerance = (int)numericUpDown4.Value;
- redrawForTolerance();
- this.documentWorkspace.Refresh();
- }
- private void redrawForTolerance()
- {
- if (drawaction == 0)
- {
- List<DrawObject> lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
- foreach (DrawObject lineObj in lines)
- {
- PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
- if (lineResult != null)
- {
- //删除原有点
- foreach (int pointid in lineResult.PointIDs.Keys)
- {
- DrawObject dr = drawObjects.Find(u => u.ID == pointid);
- if (dr != null)
- {
- this.drawObjects.Remove(dr);
- }
- }
- lineResult.PointIDs.Clear();
- //画新点
- if (lineObj != null && lineObj.GetPoints().Count > 1)
- {
- PointF a = lineObj.GetPoints()[0];
- PointF b = lineObj.GetPoints()[1];
- List<System.Drawing.Point> points = new List<System.Drawing.Point>();
- Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
- if (mat.Channels() <= 3)
- {
- mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
- }
- Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
- int linkCount = 0;
- lineResult.LineID = lineObj.ID;
- List<System.Drawing.Point> linePoints = Bresenhamline(a, b);
- for (int i = 0; i < linePoints.Count; i++)
- {
- System.Drawing.Point ploc = linePoints[i];
- if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
- {
- Vec4b targetPoint = mat.At<Vec4b>(ploc.Y, ploc.X);
- if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
- {
- linkCount++;
- if (linkCount == 1)
- {
- points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- else if ((linkCount % m_tolerance) == 0)
- {
- if (pointStyleModel.DrawType == 0)
- {
- DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- circleA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(circleA.ID, ploc);
- this.drawObjects.Add(circleA);
- }
- else
- {
- DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
- squareA.ISurfaceBox = documentWorkspace;
- lineResult.PointIDs.Add(squareA.ID, ploc);
- this.drawObjects.Add(squareA);
- }
- }
- }
- else
- {
- linkCount = 0;
- }
- }
- }//end for
- }//end if
- }//end if
- }// end foreach
- }//end for if
- }
- private void button_all_Click(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (this.is_all % 2 == 0)
- {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, false);
- }
- }
- else
- {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, true);
- }
- for (int i = 0; i < allResults.Count; i++)
- {
- PolyphaseDistanceResult editResult = allResults[i];
- dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count);
- }
- }
- this.is_all += 1;
- }
- private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- List<PolyphaseDistanceResult> editResults = allResults.FindAll(u => u.GraphName == s.ToString());
- for (int i = 0; i < editResults.Count; i++)
- {
- PolyphaseDistanceResult editResult = editResults[i];
- dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count, AnalysisTools.GetDecNum(editResult.medianAvr, decnum));
- }
- }
- }
- }
- private void button_remove_Click(object sender, EventArgs e)
- {
- var removeList = new List<string>();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- for (int i = 0; i < dataGridView_results.Rows.Count; i++)
- {
- if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
- {
- dataGridView_results.Rows.RemoveAt(i);
- }
- }
- allResults.RemoveAll(u => u.GraphName == s.ToString());
- removeList.Add(s.ToString());
- }
- foreach (var m in removeList)
- {
- listBox_analysisResult.Items.Remove(m);
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!");
- }
- }
- private void numericUpDown5_ValueChanged(object sender, EventArgs e)
- {
- decnum = (int)numericUpDown5.Value;
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- PolyphaseDistanceResult result = allResults.Find(u => u.GraphName == dataGridView_results.Rows[i].Cells[0].Value);
- if (result != null)
- {
- dataGridView_results.Rows[i].Cells[1].Value = AnalysisTools.GetDecNum(result.AvgDistince, decnum);
- dataGridView_results.Rows[i].Cells[2].Value = AnalysisTools.GetDecNum(result.Fc, decnum);
- }
- }
- }
- private void button5_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton1.Checked)
- {
- drawaction = 0;
- }
- }
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- if (radioButton2.Checked)
- {
- drawaction = 1;
- }
- }
- private void tb_1_Load(object sender, EventArgs e)
- {
- }
- private void label3_Click(object sender, EventArgs e)
- {
- }
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.Count > 0)
- {
- SaveFileDialog exe = new SaveFileDialog();
- exe.Filter = "Execl files (*.xlsx)|*.xlsx";
- exe.FilterIndex = 0;
- exe.RestoreDirectory = true;
- exe.Title = "Export Excel File";
- exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text") + PdnResources.GetString("Menu.Analysisresult.text");
- DialogResult dr = exe.ShowDialog();
- if (dr == DialogResult.OK)
- {
- DataTable dtb = new DataTable();
- foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
- {
- dtb.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
- {
- DataRow dataRow = dtb.NewRow();
- for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
- }
- dtb.Rows.Add(dataRow);
- }
- List<DataTable> list = new List<DataTable>();
- list.Add(dtb);
- this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (checkBox1.Checked)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- bitList.Clear();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- if (bitDic.ContainsKey(tag))
- {
- bitList.Add(bitDic[tag][0]);
- bitList.Add(bitDic[tag][1]);
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- }
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.analyzeSettingModel == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
- return;
- }
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.PhaseSpacing.Text", this.analyzeSettingModel.savePath);
- if (item != null)
- {
- //向文件夹内保存图片和报告
- if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- List<List<string>> inclusionList = new List<List<string>>();
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- List<Bitmap> bitImgList = new List<Bitmap>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- if (intermediateDataList.ContainsKey(tag))
- {
- ExportProjectModel exportProjectModel = new ExportProjectModel();
- exportProjectModel.dataList = intermediateDataList[tag];
- exportProjectModel.picName = tag;
- exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
- exportModel.Add(exportProjectModel);
- }
- if (bitDic.ContainsKey(tag))
- {
- bitImgList.Add(bitDic[tag][0]);
- bitImgList.Add(bitDic[tag][1]);
- }
- }
- try
- {
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- return;
- }
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
- }
- }
- private void PolyphaseDistanceDialog_Resize(object sender, EventArgs e)
- {
- if (dataGridView_results != null)
- {
- AutoSizeColumn(dataGridView_results, 10);
- }
- }
- private void getValue(string key, Object value)
- {
- switch (key)
- {
- case "parameter11":
- numericUpDown1.Value = Convert.ToDecimal(value);
- break;
- case "parameter12":
- panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
- break;
- case "parameter13":
- radioButton1.Checked = (int)value == 1 ? true : false;
- radioButton2.Checked = (int)value == 1 ? false : true;
- break;
- case "parameter14":
- rb_1.Checked = (int)value == 1 ? true : false;
- rb_2.Checked = (int)value == 1 ? false : true;
- break;
- case "parameter15":
- rb_3.Checked = (int)value == 1 ? true : false;
- rb_4.Checked = (int)value == 1 ? false : true;
- break;
- case "parameter16":
- numericUpDown2.Value = Convert.ToDecimal(value);
- break;
- case "parameter17":
- numericUpDown3.Value = Convert.ToDecimal(value);
- break;
- case "parameter18":
- numericUpDown4.Value = Convert.ToDecimal(value);
- break;
- case "parameter19":
- checkBox4.Checked = Convert.ToBoolean(value);
- break;
- case "parameter20":
- checkBox5.Checked = Convert.ToBoolean(value);
- break;
- case "parameter21":
- checkBox6.Checked = Convert.ToBoolean(value);
- break;
- case "parameter22":
- panel4.BackColor = Color.FromArgb(Convert.ToInt32(value));
- break;
- case "OpenWhileExportReport":
- checkBox1.Checked = Convert.ToBoolean(value);
- break;
- case "CalculatorDecimalDigits":
- numericUpDown5.Value = Convert.ToDecimal(value);
- break;
- }
- }
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- //找出二值相关参数 进行赋值
- List<Args> isNullList = args.Where(m => m.value == null).ToList();
- foreach (var item in isNullList)
- {
- item.value = binaryClass.setScriptRecording(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "parameter11":
- value = numericUpDown1.Value;
- break;
- case "parameter12":
- value = panel2.BackColor.ToArgb();
- break;
- case "parameter13":
- value = radioButton1.Checked ? 1 : 2;
- break;
- case "parameter14":
- value = rb_1.Checked ? 1 : 2;
- break;
- case "parameter15":
- value = rb_3.Checked ? 1 : 2;
- break;
- case "parameter16":
- value = numericUpDown2.Value;
- break;
- case "parameter17":
- value = numericUpDown3.Value;
- break;
- case "parameter18":
- value = numericUpDown4.Value;
- break;
- case "parameter19":
- value = checkBox4.Checked;
- break;
- case "parameter20":
- value = checkBox5.Checked;
- break;
- case "parameter21":
- value = checkBox6.Checked;
- break;
- case "parameter22":
- value = panel4.BackColor.ToArgb();
- break;
- case "OpenWhileExportReport":
- value = checkBox1.Checked;
- break;
- case "CalculatorDecimalDigits":
- value = numericUpDown5.Value;
- break;
- case "ExportResults":
- value = false;
- break;
- case "ExportReports":
- value = false;
- break;
- case "ExportProjects":
- value = false;
- break;
- }
- return value;
- }
- #endregion
- }
- }
|