123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798 |
- using Microsoft.Office.Interop.Excel;
- using OpenCvSharp;
- using PaintDotNet.Annotation;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.Data.Action;
- using PaintDotNet.Data.Param;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Instrument;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- using Application = System.Windows.Forms.Application;
- using Button = System.Windows.Forms.Button;
- using CheckBox = System.Windows.Forms.CheckBox;
- using DataTable = System.Data.DataTable;
- using Font = System.Drawing.Font;
- using GroupBox = System.Windows.Forms.GroupBox;
- using Label = System.Windows.Forms.Label;
- using Point = System.Drawing.Point;
- using Rectangle = System.Drawing.Rectangle;
- namespace PaintDotNet.DedicatedAnalysis.PetroleumGeology.SYT6103
- {
- internal class PetroleumGeologyStandardDialog : PdnBaseForm
- {
- #region 属性
- /// <summary>
- /// 主控件
- /// </summary>
- protected AppWorkspace appWorkspace;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 图像面板
- /// </summary>
- protected DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- protected Bitmap bitmap;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- protected Mat matOrg;
- protected Mat matGeology;
- /// <summary>
- /// 选择标尺的物理长度(1倍下的 微米/像素)
- /// </summary>
- double physical_length = 1;
- protected string oldSelectItem;
- public bool comboboxChange = true;
- /// <summary>
- /// 图形位置
- /// </summary>
- private PointF m_StartPoint = Point.Empty;
- private PointF m_EndPoint = Point.Empty;
- protected bool m_canMove;
- private bool addPoint = false;
- //二值化集成1
- protected BinaryClass binaryClass;
- protected int menuId;
- protected string menuName;
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsFormGrid;
- /// <summary>
- /// 当前选择的颜色块
- /// </summary>
- private Panel colorsPanel;
- //分析结果列表的头标题
- /// <summary>
- /// PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), "网格面积", PdnResources.GetString("Menu.Numberofgrains.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text")
- /// </summary>
- List<string> contentHead;
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- protected List<Bitmap> bitList;
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- protected Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- /// <summary>
- /// 中间数据
- /// </summary>
- protected List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
- /// <summary>
- /// 分析结果暂存
- /// </summary>
- protected List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 孔隙的面积周边长等数据
- /// </summary>
- protected List<List<int>> lstAttribute = new List<List<int>>();
- /// <summary>
- /// 孔隙的面积周边长等数据与tag绑定关系并缓存起来
- /// </summary>
- protected Dictionary<string, List<List<int>>> lstAttriDict = new Dictionary<string, List<List<int>>>();
- /// <summary>
- /// 多图平均结果暂存
- /// </summary>
- protected List<System.Data.DataTable> dataPerTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 全部显示
- /// </summary>
- protected bool allShow = false;
- protected int defaultIndex = -1;
- #endregion
- #region 组件
- private GroupBox groupBox_operating;
- protected GroupBox groupBox_img;
- private ListView lstView_img;
- private ImageList imageList_img;
- private IContainer components;
- protected GroupBox groupBox_review;
- protected GroupBox groupBox_report;
- private Label label_resultPrecision;
- private Button button_exportResults;
- private Button button_generateReport;
- protected GroupBox groupBox6groupBox_analysisResult2;
- protected GroupBox groupBox_analysisResult1;
- private ToolTip toolTip_GrainSizeDetails;
- private Button button_setting;
- protected CheckBox checkBox_generateReport_opensetting;
- protected DataGridView dataGridView2;
- protected ListView listView2;
- private Button button16;
- private Button button12;
- private Button button11;
- protected NumericUpDown numericUpDown1_0;
- private Button button1;
- protected DataGridView dataGridView1;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn Column6;
- private DataGridViewTextBoxColumn Column7;
- private DataGridViewTextBoxColumn Column8;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
- private BinaryControl bc;
- private Button btn_saveresult;
- #endregion
- #region 构造函数
- public PetroleumGeologyStandardDialog(AppWorkspace appWorkspace, string dialogText, bool isAreaType, PdnMenuItem menuItem)
- {
- this.appWorkspace = appWorkspace;
- this.Text = dialogText;
- this.Icon = PdnInfo.AppIcon;
- this.Load += new System.EventHandler(this.PetroleumGeologyStandardDialog_Load);
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
- //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
- //physical_length = measurementUnitDictionary[MeasurementUnit.Micron];
- InitializeComponent();
- InitializeLanguageText();
- InitializeBC();
- contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.view.text"), PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.serialnumber.text"), PdnResources.GetString("Menu.Theporediameter.text"), PdnResources.GetString("Menu.Apparentporeratiosurface.text"), PdnResources.GetString("Menu.Shapefactor.text"), PdnResources.GetString("Menu.Porethroatthan.text"), PdnResources.GetString("Menu.Coordinationnumber.text") };
-
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
-
- binaryClass = new BinaryClass(menuId);
- Initialize();
- SubclassInitialize();
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"), PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- //初始化头
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = "";
- header0.Width = 180;
- this.listView2.Columns.Add(header0);
- this.button11.Visible = true;
- this.button16.Visible = false;
- SetAnalyzeModelFromXml(getTemplateName());
- }
- public PetroleumGeologyStandardDialog()
- {
- //this.Icon = PdnInfo.AppIcon;
- InitializeComponent();
- /*InitializeLanguageText();
- InitializeBC();
- binaryClass = new BinaryClass();*/
- }
- #endregion
- private void InitializeLanguageText()
- {
- this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.dataGridViewTextBoxColumn8.HeaderText = PdnResources.GetString("Menu.Averageporecoordinationnumber.text");
- this.dataGridViewTextBoxColumn7.HeaderText = PdnResources.GetString("Menu.Porediameterseparationcoefficient.text");
- this.dataGridViewTextBoxColumn6.HeaderText = PdnResources.GetString("Menu.Homogeneouscoefficient.text");
- this.dataGridViewTextBoxColumn5.HeaderText = PdnResources.GetString("Menu.Meanporethroatratio.text");
- this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Averageporeshapefactor.text");
- this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.Meanapparentporeratiosurface.text");
- this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Meanporediameter.text");
- this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Facerate.text");
- this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text")+":";
- this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
- this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.button11.Text = PdnResources.GetString("Menu.Showall.text");
- this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.Column8.HeaderText = PdnResources.GetString("Menu.Coordinationnumber.text");
- this.Column7.HeaderText = PdnResources.GetString("Menu.Porethroatthan.text");
- this.Column6.HeaderText = PdnResources.GetString("Menu.Shapefactor.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.Apparentporeratiosurface.text");
- this.Column4.HeaderText = PdnResources.GetString("Menu.Theporediameter.text");
- this.Column3.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.serialnumber.text");
- this.Column2.HeaderText = PdnResources.GetString("Menu.view.text");
- }
- private void InitializeBC()
- {
- 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(179, 70);
- 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 = 34;
- this.Controls.Add(this.bc);
- this.Controls.SetChildIndex(this.bc, 0);
- }
- #region 初始化组件
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox_operating = new System.Windows.Forms.GroupBox();
- this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
- this.button_setting = new System.Windows.Forms.Button();
- this.btn_saveresult = new System.Windows.Forms.Button();
- this.groupBox_img = new System.Windows.Forms.GroupBox();
- this.lstView_img = new System.Windows.Forms.ListView();
- this.imageList_img = new System.Windows.Forms.ImageList(this.components);
- this.groupBox_review = new System.Windows.Forms.GroupBox();
- this.groupBox_report = new System.Windows.Forms.GroupBox();
- this.button1 = new System.Windows.Forms.Button();
- this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
- this.label_resultPrecision = new System.Windows.Forms.Label();
- this.button_exportResults = new System.Windows.Forms.Button();
- this.button_generateReport = new System.Windows.Forms.Button();
- this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
- this.button11 = new System.Windows.Forms.Button();
- this.listView2 = new System.Windows.Forms.ListView();
- this.button16 = new System.Windows.Forms.Button();
- this.button12 = new System.Windows.Forms.Button();
- this.toolTip_GrainSizeDetails = new System.Windows.Forms.ToolTip(this.components);
- this.groupBox_operating.SuspendLayout();
- this.groupBox_img.SuspendLayout();
- this.groupBox_report.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
- this.groupBox6groupBox_analysisResult2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox_analysisResult1.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox_operating
- //
- this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
- this.groupBox_operating.Controls.Add(this.button_setting);
- this.groupBox_operating.Controls.Add(this.btn_saveresult);
- this.groupBox_operating.Location = new System.Drawing.Point(13, 12);
- this.groupBox_operating.Name = "groupBox_operating";
- this.groupBox_operating.Size = new System.Drawing.Size(1102, 53);
- this.groupBox_operating.TabIndex = 12;
- this.groupBox_operating.TabStop = false;
- //
- // checkBox_generateReport_opensetting
- //
- this.checkBox_generateReport_opensetting.AutoSize = true;
- this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
- this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
- this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
- this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(15, 14);
- this.checkBox_generateReport_opensetting.TabIndex = 6;
- this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
- //
- // button_setting
- //
- this.button_setting.Location = new System.Drawing.Point(6, 20);
- this.button_setting.Name = "button_setting";
- this.button_setting.Size = new System.Drawing.Size(75, 23);
- this.button_setting.TabIndex = 4;
- this.button_setting.UseVisualStyleBackColor = true;
- this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
- //
- // btn_saveresult
- //
- this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btn_saveresult.Location = new System.Drawing.Point(992, 20);
- this.btn_saveresult.Name = "btn_saveresult";
- this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
- this.btn_saveresult.TabIndex = 2;
- this.btn_saveresult.UseVisualStyleBackColor = true;
- this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
- //
- // groupBox_img
- //
- this.groupBox_img.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox_img.Controls.Add(this.lstView_img);
- this.groupBox_img.Location = new System.Drawing.Point(13, 72);
- this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox_img.Name = "groupBox_img";
- this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox_img.Size = new System.Drawing.Size(158, 522);
- this.groupBox_img.TabIndex = 13;
- this.groupBox_img.TabStop = false;
- //
- // lstView_img
- //
- this.lstView_img.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.lstView_img.HideSelection = false;
- this.lstView_img.LargeImageList = this.imageList_img;
- this.lstView_img.Location = new System.Drawing.Point(8, 26);
- this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
- this.lstView_img.MultiSelect = false;
- this.lstView_img.Name = "lstView_img";
- this.lstView_img.Size = new System.Drawing.Size(140, 488);
- this.lstView_img.TabIndex = 0;
- this.lstView_img.UseCompatibleStateImageBehavior = false;
- this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
- //
- // imageList_img
- //
- this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
- //
- // 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(545, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(571, 522);
- this.groupBox_review.TabIndex = 30;
- this.groupBox_review.TabStop = false;
- //
- // groupBox_report
- //
- this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_report.Controls.Add(this.button1);
- this.groupBox_report.Controls.Add(this.numericUpDown1_0);
- this.groupBox_report.Controls.Add(this.label_resultPrecision);
- this.groupBox_report.Controls.Add(this.button_exportResults);
- this.groupBox_report.Controls.Add(this.button_generateReport);
- this.groupBox_report.Location = new System.Drawing.Point(974, 600);
- this.groupBox_report.Name = "groupBox_report";
- this.groupBox_report.Size = new System.Drawing.Size(142, 218);
- this.groupBox_report.TabIndex = 33;
- this.groupBox_report.TabStop = false;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(29, 108);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 23;
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // numericUpDown1_0
- //
- this.numericUpDown1_0.Location = new System.Drawing.Point(63, 170);
- this.numericUpDown1_0.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown1_0.Name = "numericUpDown1_0";
- this.numericUpDown1_0.Size = new System.Drawing.Size(56, 21);
- this.numericUpDown1_0.TabIndex = 22;
- this.numericUpDown1_0.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
- //
- // label_resultPrecision
- //
- this.label_resultPrecision.AutoSize = true;
- this.label_resultPrecision.Location = new System.Drawing.Point(17, 174);
- this.label_resultPrecision.Name = "label_resultPrecision";
- this.label_resultPrecision.Size = new System.Drawing.Size(35, 12);
- this.label_resultPrecision.TabIndex = 3;
- this.label_resultPrecision.Text = "小数:";
- //
- // button_exportResults
- //
- this.button_exportResults.Location = new System.Drawing.Point(29, 69);
- this.button_exportResults.Name = "button_exportResults";
- this.button_exportResults.Size = new System.Drawing.Size(75, 23);
- this.button_exportResults.TabIndex = 1;
- this.button_exportResults.UseVisualStyleBackColor = true;
- this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
- //
- // button_generateReport
- //
- this.button_generateReport.Location = new System.Drawing.Point(29, 30);
- this.button_generateReport.Name = "button_generateReport";
- this.button_generateReport.Size = new System.Drawing.Size(75, 23);
- this.button_generateReport.TabIndex = 0;
- this.button_generateReport.UseVisualStyleBackColor = true;
- this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
- //
- // groupBox6groupBox_analysisResult2
- //
- this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView1);
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView2);
- this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 601);
- this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
- this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(719, 217);
- this.groupBox6groupBox_analysisResult2.TabIndex = 32;
- this.groupBox6groupBox_analysisResult2.TabStop = false;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.dataGridViewTextBoxColumn1,
- this.dataGridViewTextBoxColumn2,
- this.dataGridViewTextBoxColumn3,
- this.dataGridViewTextBoxColumn4,
- this.dataGridViewTextBoxColumn5,
- this.dataGridViewTextBoxColumn6,
- this.dataGridViewTextBoxColumn7,
- this.dataGridViewTextBoxColumn8});
- this.dataGridView1.Location = new System.Drawing.Point(13, 115);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.ReadOnly = true;
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.Size = new System.Drawing.Size(693, 98);
- this.dataGridView1.TabIndex = 17;
- //
- // dataGridViewTextBoxColumn1
- //
- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
- this.dataGridViewTextBoxColumn1.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn2
- //
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn3
- //
- this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn4
- //
- this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
- this.dataGridViewTextBoxColumn4.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn5
- //
- this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
- this.dataGridViewTextBoxColumn5.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn6
- //
- this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
- this.dataGridViewTextBoxColumn6.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn7
- //
- this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
- this.dataGridViewTextBoxColumn7.ReadOnly = true;
- //
- // dataGridViewTextBoxColumn8
- //
- this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
- this.dataGridViewTextBoxColumn8.ReadOnly = true;
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4,
- this.Column5,
- this.Column6,
- this.Column7,
- this.Column8});
- this.dataGridView2.Location = new System.Drawing.Point(13, 11);
- this.dataGridView2.Name = "dataGridView2";
- this.dataGridView2.ReadOnly = true;
- this.dataGridView2.RowHeadersVisible = false;
- this.dataGridView2.RowTemplate.Height = 23;
- this.dataGridView2.Size = new System.Drawing.Size(693, 98);
- this.dataGridView2.TabIndex = 16;
- //
- // Column1
- //
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
- // Column3
- //
- this.Column3.Name = "Column3";
- this.Column3.ReadOnly = true;
- //
- // Column4
- //
- this.Column4.Name = "Column4";
- this.Column4.ReadOnly = true;
- //
- // Column5
- //
- this.Column5.Name = "Column5";
- this.Column5.ReadOnly = true;
- //
- // Column6
- //
- this.Column6.Name = "Column6";
- this.Column6.ReadOnly = true;
- //
- // Column7
- //
- this.Column7.Name = "Column7";
- this.Column7.ReadOnly = true;
- //
- // Column8
- //
- this.Column8.Name = "Column8";
- this.Column8.ReadOnly = true;
- //
- // groupBox_analysisResult1
- //
- this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox_analysisResult1.Controls.Add(this.button11);
- this.groupBox_analysisResult1.Controls.Add(this.listView2);
- this.groupBox_analysisResult1.Controls.Add(this.button16);
- this.groupBox_analysisResult1.Controls.Add(this.button12);
- this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 601);
- this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
- this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 217);
- this.groupBox_analysisResult1.TabIndex = 31;
- this.groupBox_analysisResult1.TabStop = false;
- //
- // button11
- //
- this.button11.BackColor = System.Drawing.SystemColors.Control;
- this.button11.Location = new System.Drawing.Point(19, 22);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(63, 26);
- this.button11.TabIndex = 27;
- this.button11.UseVisualStyleBackColor = false;
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // listView2
- //
- this.listView2.FullRowSelect = true;
- this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
- this.listView2.HideSelection = false;
- this.listView2.Location = new System.Drawing.Point(19, 58);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(181, 153);
- this.listView2.TabIndex = 26;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
- //
- // button16
- //
- this.button16.BackColor = System.Drawing.SystemColors.Control;
- this.button16.Location = new System.Drawing.Point(19, 21);
- this.button16.Name = "button16";
- this.button16.Size = new System.Drawing.Size(93, 26);
- this.button16.TabIndex = 25;
- this.button16.UseVisualStyleBackColor = false;
- this.button16.Click += new System.EventHandler(this.button16_Click);
- //
- // button12
- //
- this.button12.BackColor = System.Drawing.SystemColors.Control;
- this.button12.Location = new System.Drawing.Point(149, 21);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(52, 26);
- this.button12.TabIndex = 24;
- this.button12.UseVisualStyleBackColor = false;
- this.button12.Click += new System.EventHandler(this.button12_Click);
- //
- // PetroleumGeologyStandardDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1127, 830);
- this.Controls.Add(this.groupBox_report);
- this.Controls.Add(this.groupBox6groupBox_analysisResult2);
- this.Controls.Add(this.groupBox_analysisResult1);
- this.Controls.Add(this.groupBox_review);
- this.Controls.Add(this.groupBox_img);
- this.Controls.Add(this.groupBox_operating);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Location = new System.Drawing.Point(0, 0);
- this.Name = "PetroleumGeologyStandardDialog";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing);
- this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
- this.Controls.SetChildIndex(this.groupBox_operating, 0);
- this.Controls.SetChildIndex(this.groupBox_img, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
- this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
- this.Controls.SetChildIndex(this.groupBox_report, 0);
- this.groupBox_operating.ResumeLayout(false);
- this.groupBox_operating.PerformLayout();
- this.groupBox_img.ResumeLayout(false);
- this.groupBox_report.ResumeLayout(false);
- this.groupBox_report.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
- this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox_analysisResult1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- private void ShowImgEvent(object sender, EventArgs e)
- {
- lstView_img.Focus();
- if (this.defaultIndex != -1)
- {
- this.lstView_img.Items[defaultIndex].Focused = true;
- this.lstView_img.Items[defaultIndex].Selected = true;
- }
- }
- public void Initialize()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
- this.lstView_img.Items.Add("", i);
- this.lstView_img.Items[i].ImageIndex = i;
- this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- defaultIndex = i;
- }
- }
- this.Shown += ShowImgEvent;
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
- this.documentWorkspace.Cursor = Cursors.Default;
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.Paint += Panel_Paint;
- this.documentWorkspace.panel.MouseMove += onMouseMove;
- this.documentWorkspace.panel.MouseUp += onMouseUp;
- this.groupBox_review.Controls.Add(this.documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- 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);
- groupBox_review.Controls.Add(this.commonControlButtons);
- }
- #endregion
- #region 事件
- #region 公共按钮
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- 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)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- #endregion
- /// <summary>
- /// 设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_setting_Click(object sender, EventArgs e)
- {
- string templateName = getTemplateName();
- AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);
- if (metallographicMethodSetDialog.hasModule)
- {
- metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
- metallographicMethodSetDialog.ShowDialog();
- }
- else
- {
- metallographicMethodSetDialog = null;
- }
- }
- private void btn_saveresult_Click(object sender, EventArgs e)
- {
- buildListBox_analysisResult();
- }
- private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
- {
- this.physical_length = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- //double physical_area_length_Micron = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
- //this.documentWorkspace.Document = Document.FromImage(this.documentItems[this.lstView_img.FocusedItem.Index].bitmap);
- //this.documentWorkspace.Visible = true;
- //this.documentWorkspace.activeTool = DrawToolType.InclusionNoEffect;
- //this.documentWorkspace.GraphicsList = this.documentItems[this.lstView_img.FocusedItem.Index].graphicsList;
- //this.documentWorkspace.PhaseModels = new List<PhaseModel>();
- //this.documentWorkspace.PhaseModels.AddRange(this.documentItems[this.lstView_img.FocusedItem.Index].phaseModels);
- this.bitmap = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- //if (!this.documentWorkspace.PhaseModels[0].choise)
- // this.checkBox10.Checked = false;
- bool existViewFlag = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.IsExsitView();
- if (!existViewFlag)
- {
- matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
- }
- else
- {
- matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetFullSizeWithRegion());
- }
- //二值化集成4
- binaryClass.listView1_SelectedIndexChanged(this.bitmap);
- if (bcOriginChecked())
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.Refresh();
- }
-
- //if (this.checkBox1.Checked)
- //{
- // this.applyDect();
- //}
- if (segmentedHolesMat != null)
- {
- segmentedHolesMat.Dispose();
- segmentedHolesMat = null;
- }
- lstAttribute.Clear();
- minLinePoints.Clear();
- refreshWhileImgChanged();
- }
- }
- #region 矩形拖动
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- protected virtual void OnMouseDown(object sender, MouseEventArgs e)
- {
- // 换算后的点
- //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- if (addPoint)
- {
- m_StartPoint = documentWorkspace.GetScalePoint(e.Location);
- }
- }
- /// <summary>
- /// 移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void onMouseMove(object sender, MouseEventArgs e)
- {
- //this.documentWorkspace.Refresh();
- // 换算后的点
- //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- if (addPoint && m_StartPoint.X > 0 && m_StartPoint.Y > 0)
- {
- m_EndPoint = documentWorkspace.GetScalePoint(e.Location);
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void onMouseUp(object sender, MouseEventArgs e)
- {
- if (this.bitmap != null && m_StartPoint.X > 0 && m_StartPoint.Y > 0 && m_StartPoint.X < this.bitmap.Width && m_StartPoint.Y < this.bitmap.Height
- && m_EndPoint.X > 0 && m_EndPoint.Y > 0 && m_EndPoint.X < this.bitmap.Width && m_EndPoint.Y < this.bitmap.Height)
- {
- Line lineI = new Line(new Point((int)m_StartPoint.X, (int)m_StartPoint.Y), new Point((int)m_EndPoint.X, (int)m_EndPoint.Y));
- minLinePoints.Add(new Point2d((int)((m_StartPoint.X + m_EndPoint.X) / 2), (int)((m_StartPoint.Y + m_EndPoint.Y) / 2)), lineI);
- if (segmentedHolesMat != null)
- {
- segmentedHolesMat.Dispose();
- segmentedHolesMat = null;
- }
- if (segmentedHolesMat == null && createSegmentedHoldsMat() || segmentedHolesMat != null)
- {
- m_StartPoint = Point.Empty;
- m_EndPoint = Point.Empty;
- m_canMove = false;
- //addPoint = false;
- return;
- }
- else
- //图像分割
- this.documentWorkspace.Refresh();
- }
- m_StartPoint = Point.Empty;
- m_EndPoint = Point.Empty;
- m_canMove = false;
- addPoint = false;
- this.documentWorkspace.Refresh();
- }
- #endregion
- /// <summary>
- /// 画布绘制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Panel_Paint(object sender, PaintEventArgs e)
- {
- if (this.documentWorkspace.CompositionSurface != null)
- {
- //
- // 以下是计算绘制图片的位置和大小并绘制图片
- //
- System.Drawing.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 : (rc.Width - width) / 2;
- int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
- //
- // 以下是绘制网格、标注、测量、视场等开始
- //
- e.Graphics.TranslateTransform(x, y);
- e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
- Draw(e.Graphics);
- e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
- e.Graphics.TranslateTransform(-x, -y);
- }
- }
- /// <summary>
- /// 绘制
- /// </summary>
- private void Draw(Graphics graphics)
- {
- // 抗锯齿
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass(graphics);
- }
- #endregion
- #region 内部方法
- /// <summary>
- /// 从末梢的点开始寻找截线的极小值点
- /// </summary>
- /// <param name="threshold_2">阈值的平方</param>
- /// <param name="point">从枝干末梢的坐标点根据抽骨架路径往里走</param>
- /// <param name="mat">抽骨架的mat</param>
- /// <param name="distance_temp">距离变换的mat</param>
- /// <param name="foundList">已经找到的极小值点</param>
- /// <param name="former1Distance">point点的距离</param>
- /// <param name="former2Distance">point前面的点的距离</param>
- /// <returns></returns>
- private Dictionary<Point2d, float> GetMinLabelPoint(int threshold_2, Point point, Mat mat, Mat distance_temp, Dictionary<Point2d, float> foundList, float former1Distance, float former2Distance)
- {
- //if (routePoints.FindAll(a => a.X == point.X && a.Y == point.Y).Count > 0)
- if (routePoints.Contains(point))
- return foundList;
- routePoints.Add(new Point(point.X, point.Y));
- bool firstValueOnBoundry;
- bool lastValueOnBoundry;
- Point lastPoint = new Point(point.X, point.Y);
- Point nextPoint = new Point(point.X - 1, point.Y - 1);
- float currDistance;
- int count;
- do
- {
- count = 0;
- if (point.X > mat.Width - 2 || point.X < 1 || point.Y > mat.Height - 2 || point.Y < 1)
- {
- }
- else
- {
- if (!routePoints.Contains(new Point(point.X - 1, point.Y - 1)) && mat.At<Vec4b>(point.Y - 1, point.X - 1).Item3 != 0)
- {
- nextPoint = new Point(point.X - 1, point.Y - 1);
- count++;
- firstValueOnBoundry = true;
- lastValueOnBoundry = true;
- }
- else
- {
- firstValueOnBoundry = false;
- lastValueOnBoundry = false;
- }
- if (!routePoints.Contains(new Point(point.X, point.Y - 1)) && mat.At<Vec4b>(point.Y - 1, point.X).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X, point.Y - 1);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X + 1, point.Y - 1)) && mat.At<Vec4b>(point.Y - 1, point.X + 1).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X + 1, point.Y - 1);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X + 1, point.Y)) && mat.At<Vec4b>(point.Y, point.X + 1).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X + 1, point.Y);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X + 1, point.Y + 1)) && mat.At<Vec4b>(point.Y + 1, point.X + 1).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X + 1, point.Y + 1);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X, point.Y + 1)) && mat.At<Vec4b>(point.Y + 1, point.X).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X, point.Y + 1);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X - 1, point.Y + 1)) && mat.At<Vec4b>(point.Y + 1, point.X - 1).Item3 != 0)
- {
- if (!lastValueOnBoundry)
- {
- nextPoint = new Point(point.X - 1, point.Y + 1);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- if (!routePoints.Contains(new Point(point.X - 1, point.Y)) && mat.At<Vec4b>(point.Y, point.X - 1).Item3 != 0)
- {
- if (!lastValueOnBoundry && !firstValueOnBoundry)
- {
- nextPoint = new Point(point.X - 1, point.Y);
- count++;
- }
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- }
- if (count == 1)
- {
- //if (routePoints.Count > 0)
- // routePoints.RemoveAt(routePoints.Count - 1);
- routePoints.Add(new Point(nextPoint.X, nextPoint.Y));
- }
- else if (count > 1)
- {
- routePoints.Add(new Point(nextPoint.X, nextPoint.Y));
- }
- if (count == 1)
- {
- //走到其中一条路径
- currDistance = distance_temp.At<float>(nextPoint.Y, nextPoint.X);
- if ((currDistance - former1Distance >= 0) && (former1Distance - former2Distance) <= 0 && former2Distance != float.MinValue)
- {
- if (/*foundList.Count == 0 || foundList.Count > 0 && */Math.Max(10, currDistance * currDistance * 9)/*threshold_2*/ < ((lastPoint.X - nextPoint.X) * (lastPoint.X - nextPoint.X) + (lastPoint.Y - nextPoint.Y) * (lastPoint.Y - nextPoint.Y)))
- {
- foundList.Add(new Point2d(point.X, point.Y), (int)(Math.Round(former1Distance * former1Distance)));
- lastPoint.X = nextPoint.X;
- lastPoint.Y = nextPoint.Y;
- }
- }
- point.X = nextPoint.X;
- point.Y = nextPoint.Y;
- former2Distance = former1Distance;
- former1Distance = currDistance;
- }
- } while (count == 1);
- return foundList;
- }
- /// <summary>
- /// 导出项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.checkBox_generateReport_opensetting.Checked)
- this.button_setting.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, getProjectEngineeringName(), this.analyzeSettingModel.savePath);
- if (nodeItem == null) return;
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.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>>();
- analysisContent.Add(contentHead);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHead.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- //中间数据
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- bitList.Add(kv.Value[0]);
- bitList.Add(kv.Value[1]);
- }
- //中间数据
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- }
- }
- else
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (bitDic.ContainsKey(item.Name))
- {
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- //中间数据
- foreach (ListViewItem rowItem in this.listView2.SelectedItems)
- {
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals(rowItem.Name))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- else if (model.tagName.Equals(rowItem.Tag.ToString()))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- }
- }
- }
- else if (this.listView2.Items.Count > 0)//###
- {
- ListViewItem rowItem = this.listView2.Items[0];
- if (bitDic.ContainsKey(rowItem.Name))
- {
- bitList.Add(bitDic[rowItem.Name][0]);
- bitList.Add(bitDic[rowItem.Name][1]);
- }
- else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
- {
- bitList.Add(bitDic[rowItem.Tag.ToString()][0]);
- bitList.Add(bitDic[rowItem.Tag.ToString()][1]);
- }
- //中间数据
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals(rowItem.Name))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- else if (model.tagName.Equals(rowItem.Tag.ToString()))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- /// <summary>
- /// 导出结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_exportResults_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- System.Data.DataSet ds = new DataSet();
- DataTable table1 = new DataTable();
- table1.TableName = PdnResources.GetString("Menu.breakdown.text");
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- table1.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- DataRow dataRow = table1.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Columns[c].HeaderText;
- }
- table1.Rows.Add(dataRow);
- }
- dataRow = table1.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- table1.Rows.Add(dataRow);
- }
- DataTable table2 = new DataTable();
- table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- table2.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
- {
- DataRow dataRow = table2.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Columns[c].HeaderText;
- }
- table2.Rows.Add(dataRow);
- }
- dataRow = table2.NewRow();
- for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
- }
- table2.Rows.Add(dataRow);
- }
- if (table1.Rows.Count > 0) ds.Tables.Add(table1);
- if (table2.Rows.Count > 0) ds.Tables.Add(table2);
- if (ds.Tables.Count > 0)
- DataToExcle(ds);
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
- }
- }
- /// <summary>
- /// 导出多 Sheet 报表
- /// </summary>
- /// <param name="ds">要导出的数据</param>
- public void DataToExcle(System.Data.DataSet ds)
- {
- try
- {
- if (ds.Tables == null || ds.Tables.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text")+"!");
- return;
- }
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.DefaultExt = "xlsx";
- saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
- saveFileDialog.FileName = PdnResources.GetString("Menu.estructurecharacteristics.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
- saveFileDialog.RestoreDirectory = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- List<System.Data.DataTable> list = new List<System.Data.DataTable>();
- foreach (System.Data.DataTable itemTable in ds.Tables)
- list.Add(itemTable);
- this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true, false, true);
- }
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- #endregion
- //二值化集成3
- #region 二值化相关方法
- private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- binaryClass.saveParams();
- }
- private void ShownChoiseItemAndInitData(object sender, EventArgs e)
- {
- binaryClass.RefreshHistogramControl1Values();
- }
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PetroleumGeologyStandardDialog_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 bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 显示原图/原图+二值图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bcOriginCheckedChanged(object sender, EventArgs e)
- {
- if (!bcOriginChecked())
- {
- if (bcBinaryChecked())
- this.documentWorkspace.PhaseModels[0].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- protected void panelColor_Click(object sender, EventArgs e)
- {
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
- this.colorsPanel = (Panel)sender;
- this.colorsFormGrid.ShowDialog();
- }
- /// <summary>
- /// Panel2的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gridColorChanged(object sender, EventArgs e)
- {
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- if (colorsPanel != null)
- {
- colorsPanel.BackColor = color;
- //刷新显示页面文字颜色
- this.documentWorkspace.Refresh();
- }
- //关闭色板
- this.colorsFormGrid.Close();
- }
- #region 可调用方法
- /// <summary>
- /// 是否显示原图
- /// </summary>
- /// <returns></returns>
- protected Boolean showOrimat()
- {
- return bcOriginChecked();
- }
- /// <summary>
- /// 是否能取到二值的结果
- /// </summary>
- /// <returns></returns>
- protected Boolean getBinaryChecked()
- {
- return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
- }
- /// <summary>
- /// 返回当前选择的图片内容
- /// </summary>
- /// <returns></returns>
- protected DocumentWorkspace getCurrentWorkspace()
- {
- return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index];
- }
- /// <summary>
- /// 返回当前选择的图片tag
- /// </summary>
- /// <returns></returns>
- protected string getCurrentWorkTag()
- {
- return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem.Index/*lstView_img.SelectedItems[0].Index*/];
- }
- protected bool holeNumberVisible = false;
- /// <summary>
- /// 喉道分割后的图片
- /// </summary>
- private Mat segmentedHolesMat;
- /// <summary>
- /// 显示、隐藏孔隙编号
- /// </summary>
- /// <param name="visible"></param>
- protected void controlHoleNumberVisible(bool visible)
- {
- holeNumberVisible = visible;
- if (holeNumberVisible && minLinePoints.Count > 0 &&
- /*成功获取喉道分割后的图片*/(segmentedHolesMat == null && createSegmentedHoldsMat() || segmentedHolesMat != null))
- {
- //this.documentWorkspace.PhaseModels[0].choise = false;
- //this.documentWorkspace.PhaseModels[1].choise = true;
- //this.documentWorkspace.PhaseModels[2].choise = true;
- }
- else
- {
- //this.documentWorkspace.PhaseModels[0].choise = true;
- //this.documentWorkspace.PhaseModels[1].choise = false;
- //this.documentWorkspace.PhaseModels[2].choise = false;
- holeNumberVisible = false;
- }
- this.documentWorkspace.PhaseModels[0].choise = true;
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 获取喉道分割后的图片
- /// </summary>
- private bool createSegmentedHoldsMat()
- {
- if (this.documentWorkspace.PhaseModels.Count > 0 && this.documentWorkspace.PhaseModels[0].choise == true && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- }
- else
- return false;
- Mat src = this.documentWorkspace.PhaseModels[0].mat;
- Mat distance_temp = new Mat();
- //灰度图
- Mat Inmat = BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat)/* //### .CvtColor(ColorConversionCodes.BGR2GRAY)*/;
- Cv2.DistanceTransform(Inmat, distance_temp, DistanceTypes.L2, DistanceMaskSize.Precise);
- Mat newMat = new Mat(src.Height, src.Width, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
- Bitmap newBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(newMat);
- Graphics graphics = Graphics.FromImage(newBit);
- Pen linePen = new Pen(Color.FromArgb(this.documentWorkspace.PhaseModels[0].color), 2/*1*/);
- foreach (var itemLine in minLinePoints.Values)
- {
- graphics.DrawLine(linePen, itemLine.startPoint, itemLine.endPoint);
- }
- Mat dst = new Mat();
- Mat mat1 = OpenCvSharp.Extensions.BitmapConverter.ToMat(newBit);
- int w = src.Width;
- int h = src.Height;
- int w1 = mat1.Width;
- int h1 = mat1.Height;
- Mat mat2 = new Mat(h, w, src.Type(), Scalar.All(0));
- Rect rect = new Rect(0, 0, Math.Min(w, w1), Math.Min(h, h1));
- Mat tempMat = mat1.Clone(rect);
- //复制用户选中的区域到原图像
- Mat mask = tempMat.CvtColor(ColorConversionCodes.RGBA2GRAY);
- Mat pos = new Mat(mat2, rect);
- tempMat.CopyTo(pos, mask);
- //Cv2.CopyMakeBorder(src, src, 0, maxh - src.Height, 0, maxw - src.Width, BorderTypes.Isolated);
- //Cv2.CopyMakeBorder(mat1, mat1, 0, maxh - mat1.Height, 0, maxw - mat1.Width, BorderTypes.Isolated);
- Mat tempMat0 = src.Clone(rect);
- //复制用户选中的区域到原图像
- Mat mask0 = tempMat0.CvtColor(ColorConversionCodes.RGBA2GRAY);
- Mat mat0 = new Mat(h, w, src.Type(), Scalar.All(/*255*/0));
- Mat pos0 = new Mat(mat0, rect);
- tempMat0.CopyTo(pos0, mask0);
- Cv2.Subtract(src/*待确认效果:mat0*/, mat2, dst);
- //Cv2.Subtract(src, mat1, dst);
- if (segmentedHolesMat != null)
- {
- segmentedHolesMat.Dispose();
- segmentedHolesMat = null;
- }
- segmentedHolesMat = dst.Clone();
- //this.documentWorkspace.PhaseModels[1].mat = dst;
- //显示连通域和编号信息
- Mat erzhi = dst;//.Clone();
- //Cv2.ImShow("erzhi1", erzhi);
- //Cv2.WaitKey();
- Cv2.CvtColor(erzhi, erzhi, ColorConversionCodes.BGR2GRAY);
- //Cv2.ImShow("erzhi2", erzhi);
- //Cv2.WaitKey();
- Cv2.Threshold(erzhi, erzhi, 10, 255, ThresholdTypes.Binary);
- //Cv2.ImShow("erzhi3", erzhi);
- //Cv2.WaitKey();
- OpenCvSharp.Point[][] contours;
- HierarchyIndex[] hierarchy;
- Cv2.FindContours(erzhi, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
- List<OpenCvSharp.Point[]> pointss = new List<OpenCvSharp.Point[]>();
- foreach (OpenCvSharp.Point[] contour in contours)
- {
- if (contour.Length < 10000/*100*/)
- {
- foreach (OpenCvSharp.Point point in contour)
- {
- erzhi.Set<byte>(point.Y, point.X, 255);
- }
- pointss.Add(contour);
- }
- }
- //Cv2.ImShow("dst", dst);
- //Cv2.ImShow("erzhi", erzhi);
- //Cv2.WaitKey();
- Cv2.FillPoly(erzhi, pointss, new Scalar(255));
- //// 二次轮廓
- //Cv2.FindContours(erzhi, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
- ////// 计算所有轮廓质点
- ////List<Point2d> massPoints = new List<Point2d>();
- ////foreach (OpenCvSharp.Point[] contour in contours)
- ////{
- //// OpenCvSharp.Moments moments = new OpenCvSharp.Moments(contour, false);
- //// massPoints.Add(new Point2d(moments.M10 / moments.M00, moments.M01 / moments.M00));
- ////}
- lstAttribute.Clear();
- Mat labelMat = new Mat();
- Mat stats = new Mat();
- Mat centroids = new Mat();
- // 连通域数量
- int nccomps = Cv2.ConnectedComponentsWithStats(erzhi, labelMat, stats, centroids, PixelConnectivity.Connectivity8);
- List<int> attribute;
- for (int hcomp = 1; hcomp < centroids.Height; hcomp++)
- {
- //double a = centroids.At<double>(h, 0);
- //double b = centroids.At<double>(h, 1);
- int x = (int)centroids.At<double>(hcomp, 0);// stats.At<int>(hcomp, 0);
- int y = (int)centroids.At<double>(hcomp, 1);// stats.At<int>(hcomp, 1);
- int width = stats.At<int>(hcomp, 2);
- int height = stats.At<int>(hcomp, 3);
- if (x < 0 || y < 0 || width > bitmap.Width || height > bitmap.Height || x >= bitmap.Width || y >= bitmap.Height)
- {
- continue;
- }
- int areaField1 = stats.At<int>(hcomp, 4);
- attribute = new List<int>();
- //int label = labelMat.At<int>(y, x);
- attribute.Add(hcomp);
- attribute.Add(x);
- attribute.Add(y);
- attribute.Add(width);
- attribute.Add(height);
- attribute.Add(areaField1);
- attribute.Add(0);//喉道数量
- attribute.Add(hcomp);//编号
- attribute.Add(0);//孔隙周边长,单位是像素
- attribute.Add(0);//与该空腔连通的喉道总宽度,单位是像素
- //attribute.Add(0);//长径
- //attribute.Add(0);//短径
- //attribute.Add(0);//平均径
- //lstAttribute.Add(attribute);
- ////double areaField = areaField1 * unitLength * unitLength;
- Point centerRadiusPoint = new Point(x, y);
- Point startPoint;
- Point endPoint;
- bool notFound;
- int matHeight = erzhi.Height;
- int matWidth = erzhi.Width;
- int step = -1;
- List<int> d2list = new List<int>();
- for (int rotateAngleV = 0; rotateAngleV < 360; rotateAngleV += 15)
- {
- notFound = true;
- startPoint = new Point(x, y);
- while (notFound)
- {
- startPoint.X += step;
- Point itemP11 = rotatedVPaiPoint(rotateAngleV * Math.PI / 180.0, startPoint.X, startPoint.Y, centerRadiusPoint.X, centerRadiusPoint.Y);
- if (itemP11.Y < 0 || itemP11.X < 0 || itemP11.Y >= matHeight || itemP11.X >= matWidth)
- {
- startPoint.X = itemP11.X;
- startPoint.Y = itemP11.Y;
- notFound = false;
- break;
- }
- Vec4b vec4B = erzhi/*binary_temp*/.At<Vec4b>(itemP11.Y, itemP11.X);
- if (vec4B.Item3 == 0)
- {
- startPoint.X = itemP11.X;
- startPoint.Y = itemP11.Y;
- notFound = false;
- break;
- }
- }
- notFound = true;
- endPoint = new Point(x, y);
- while (notFound)
- {
- endPoint.X -= step;
- Point itemP11 = rotatedVPaiPoint(rotateAngleV * Math.PI / 180.0, endPoint.X, endPoint.Y, centerRadiusPoint.X, centerRadiusPoint.Y);
- if (itemP11.Y < 0 || itemP11.X < 0 || itemP11.Y >= matHeight || itemP11.X >= matWidth)
- {
- endPoint.X = itemP11.X;
- endPoint.Y = itemP11.Y;
- notFound = false;
- break;
- }
- Vec4b vec4B = erzhi/*binary_temp*/.At<Vec4b>(itemP11.Y, itemP11.X);
- if (vec4B.Item3 == 0)
- {
- endPoint.X = itemP11.X;
- endPoint.Y = itemP11.Y;
- notFound = false;
- break;
- }
- }
- //int d2Value = (startPoint.X - endPoint.X) * (startPoint.X - endPoint.X) + (startPoint.Y - endPoint.Y) * (startPoint.Y - endPoint.Y);
- d2list.Add((startPoint.X - endPoint.X) * (startPoint.X - endPoint.X) + (startPoint.Y - endPoint.Y) * (startPoint.Y - endPoint.Y));
- //int insertIndex = 0;
- //for (int id2Index = 0; id2Index < d2list.Count; id2Index++)
- //{
- // if (d2Value > d2list[id2Index])
- // ++insertIndex;
- // else
- // break;
- //}
- //d2list.Insert(insertIndex, d2Value);
- }
- d2list.Sort();
- attribute.Add(d2list[d2list.Count-1]);//长径
- attribute.Add(d2list[0]);//短径
- attribute.Add(d2list.ToArray().Sum() / d2list.Count());//平均径
- lstAttribute.Add(attribute);
- }
- // 计算所有轮廓周边长(即孔隙周边长,单位是像素)
- int labelP2;
- int labelP3;
- //Mat dismat = new Mat(distance_temp.Height, distance_temp.Width, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
- Point[] offsetPoints1 = new Point[] { new Point(-1, -1), new Point(0, -1), new Point(1, -1), new Point(1, 0), new Point(1, 1), new Point(0, 1), new Point(-1, 1), new Point(-1, 0) };
- //float currDistance;
- for (int int_Y = 1; int_Y < distance_temp.Height - 1; int_Y++)
- {
- for (int int_X = 1; int_X < distance_temp.Width - 1; int_X++)
- {
- labelP2 = labelMat.At<int>(int_Y, int_X);
- if (labelP2 > 0)
- {
- //循环找内圈的轮廓点
- foreach (var itemOffset in offsetPoints1)
- {
- labelP3 = labelMat.At<int>(int_Y + itemOffset.Y, int_X + itemOffset.X);
- if (labelP3 == 0)
- {
- //dismat.Set<Vec4b>(int_Y, int_X, new Vec4b(0, 255, 0, 255));
- lstAttribute[labelP2 - 1][8] += 1;
- }
- }
- }
- else
- {
- //循环找外圈的轮廓点
- foreach (var itemOffset in offsetPoints1)
- {
- labelP2 = labelMat.At<int>(int_Y + itemOffset.Y, int_X + itemOffset.X);
- if (labelP2 > 0)
- {
- //dismat.Set<Vec4b>(int_Y, int_X, new Vec4b(0, 255, 0, 255));
- lstAttribute[labelP2 - 1][8] += 1;
- }
- }
- }
- //currDistance = distance_temp.At<float>(int_Y, int_X);
- //if (currDistance == 1 || int_Y == 0 || int_X == 0 || int_X == distance_temp.Width - 1 || int_Y == distance_temp.Height - 1)
- //{
- // dismat.Set<Vec4b>(int_Y, int_X, new Vec4b(0, 255, 0, 255));
- // labelP2 = labelMat.At<int>(int_Y, int_X);
- // if (labelP2 > 0)
- // {
- // lstAttribute[labelP2 - 1][8] += 1;
- // }
- //}
- }
- }
- foreach (var itemAttri in lstAttribute)
- {
- itemAttri[8] /= 6/*2*/;
- }
- for (int int_Y = 0; int_Y < distance_temp.Height; int_Y++)
- {
- int int_X = 0;
- labelP2 = labelMat.At<int>(int_Y, int_X);
- if (labelP2 > 0)
- lstAttribute[labelP2 - 1][8] += 1;
- }
- for (int int_Y = 0; int_Y < distance_temp.Height; int_Y++)
- {
- int int_X = distance_temp.Width - 1;
- labelP2 = labelMat.At<int>(int_Y, int_X);
- if (labelP2 > 0)
- lstAttribute[labelP2 - 1][8] += 1;
- }
- for (int int_X = 1; int_X < distance_temp.Width - 1; int_X++)
- {
- int int_Y = 0;
- labelP2 = labelMat.At<int>(int_Y, int_X);
- if (labelP2 > 0)
- lstAttribute[labelP2 - 1][8] += 1;
- }
- for (int int_X = 1; int_X < distance_temp.Width - 1; int_X++)
- {
- int int_Y = distance_temp.Height - 1;
- labelP2 = labelMat.At<int>(int_Y, int_X);
- if (labelP2 > 0)
- lstAttribute[labelP2 - 1][8] += 1;
- }
- //Cv2.ImShow("dis", dismat);
- //Cv2.WaitKey();
- //foreach (OpenCvSharp.Point[] contour in contours)
- //{
- // labelP2 = -1;
- // foreach (var itemP2 in contour)
- // {
- // labelP2 = labelMat.At<int>(itemP2.Y, itemP2.X);
- // if (labelP2 > 0 && lstAttribute[labelP2 - 1][8] == 0)
- // {
- // lstAttribute[labelP2 - 1][8] += contour.Length;
- // break;
- // }
- // }
- //}
- Point itemP;
- int matW = labelMat.Width;
- int matH = labelMat.Height;
- int countP;
- int labelP1;
- //int labelP2;
- Point[] offsetPoints = new Point[] { new Point(-1, -1), new Point(0, -1), new Point(1, -1), new Point(1, 0), new Point(1, 1), new Point(0, 1), new Point(-1, 1), new Point(-1, 0) ,
- new Point(0, -2), new Point(2, 0), new Point(0, 2), new Point(-2, 0), new Point(-2, -2), new Point(-2, 2), new Point(2, 2), new Point(2, -2) };
- //获取连通域的喉道信息
- foreach (var itemLine in minLinePoints.Values)
- {
- itemP = new Point((itemLine.startPoint.X + itemLine.endPoint.X) / 2, (itemLine.startPoint.Y + itemLine.endPoint.Y) / 2);
- if (itemP.Y < 2 || itemP.X < 2 || itemP.Y >= matH - 1 || itemP.X >= matW - 1)
- continue;
- countP = 0;
- labelP1 = -1;
- labelP2 = -1;
- foreach (var itemOffset in offsetPoints)
- {
- labelP2 = labelMat.At<int>(itemP.Y + itemOffset.Y, itemP.X + itemOffset.X);
- if (labelP2 > 0 && labelP2 != labelP1)
- {
- List<int> attributeP = lstAttribute[labelP2 - 1];
- attributeP[6] = attributeP[6] + 1;
- attributeP[9] = attributeP[9] + (int)Math.Sqrt((itemLine.startPoint.Y - itemLine.endPoint.Y) * (itemLine.startPoint.Y - itemLine.endPoint.Y) + (itemLine.startPoint.X - itemLine.endPoint.X) * (itemLine.startPoint.X - itemLine.endPoint.X));
- labelP1 = labelP2;
- if (++countP > 1)
- break;
- }
- }
- //graphics.DrawLine(linePen, itemLine.startPoint, itemLine.endPoint);
- }
- //// 连通域质点
- //Dictionary<int, Point2d> keyValues = new Dictionary<int, Point2d>();
- //massLabelPoints.Clear();
- //foreach (var item in massPoints)
- //{
- // if (double.IsNaN(item.Y) || double.IsNaN(item.X))
- // {
- // continue;
- // }
- // int label = labelMat.At<int>((int)item.Y, (int)item.X);
- // if (0 <= label/* && label <= nccomps*/)
- // {
- // keyValues[label] = item;
- // }
- //}
- //// 矩形边线上的连通域
- //ArrayList nccompSelect = new ArrayList();
- //Mat temp = new Mat(erzhi.Size(), MatType.CV_8UC4);
- //Random rd = new Random();
- //List<Vec4b> colors = new List<Vec4b>(nccomps);
- ////colors.Add(new Vec4b(0, 0, 0, 0));
- //for (int i = 0; i < nccomps; i++)
- //{
- // //colors.Add(new Vec3b(255, 255, 255));
- // colors.Add(new Vec4b(((byte)(rd.Next() % 256)), ((byte)(rd.Next() % 256)), ((byte)(rd.Next() % 256)), 255));
- //}
- //for (int y = 0; y < temp.Rows; y++)
- //{
- // for (int x = 0; x < temp.Cols; x++)
- // {
- // int label = labelMat.At<int>(y, x);
- // if (label > 0)
- // temp.Set<Vec4b>(y, x, colors[label]);
- // }
- //}
- ////foreach (var item in massPoints)
- ////{
- //// if (double.IsNaN(item.Y) || double.IsNaN(item.X))
- //// {
- //// continue;
- //// }
- //// temp.Set<Vec4b>((int)item.Y, (int)item.X, new Vec4b(0, 0, 255, 255));
- ////}
- //////Cv2.ImShow("temp", temp);
- //this.documentWorkspace.PhaseModels[2].mat = temp;
- this.documentWorkspace.Refresh();
- return true;
- }
- /// <summary>
- /// 用于枝干相交的坐标点集合
- /// </summary>
- List<Point2d> massLabelPoints = new List<Point2d>();
- /// <summary>
- /// 用于枝干末梢的坐标点集合
- /// </summary>
- List<Point2d> sideLabelPoints = new List<Point2d>();
- /// <summary>
- /// 用于枝干与轮廓截线长度为极小值的坐标点集合 key为点 value为距离值
- /// </summary>
- Dictionary<Point2d, float> minLabelPoints = new Dictionary<Point2d, float>();
- /// <summary>
- /// 用于枝干与轮廓截线长度为极小值的坐标点集合 key为点 value为线的坐标
- /// </summary>
- Dictionary<Point2d, Line> minLinePoints = new Dictionary<Point2d, Line>();
- /// <summary>
- /// 寻找极小值的坐标点集合,用来记录已经走过的点,避免路径重复
- /// </summary>
- List<Point> routePoints = new List<Point>();
- /// <summary>
- /// 手动分割
- /// </summary>
- protected void menuSegmentAction(Button sender)
- {
- addPoint = !addPoint;
- sender.Text = addPoint ? PdnResources.GetString("Menu.segmented.text") : PdnResources.GetString("Menu.Manualsegmentation.text");
- }
- /// <summary>
- /// 将多颜色图像转换为单颜色图像,避免抽骨架算不出结果
- /// </summary>
- /// <param name="phaseModel"></param>
- /// <returns></returns>
- private Mat getBinaryOneColorPicture(PhaseModel phaseModel)
- {
- if (phaseModel.mat == null)
- return null;
- Mat phaseModelMat = phaseModel.mat.Clone();
- Mat multipleMat = new Mat(phaseModelMat.Height/*Width*/, phaseModelMat.Width/*Height*/, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
- for (int int_Y = 0; int_Y < phaseModelMat.Height; int_Y++)
- {
- for (int int_X = 0; int_X < phaseModelMat.Width; int_X++)
- {
- if (phaseModelMat.At<Vec4b>(int_Y, int_X).Item3 > 0)
- multipleMat.Set<Vec4b>(int_Y, int_X, new Vec4b(0, 255, 0, 255));
- }
- }
- phaseModelMat.Dispose();
- phaseModelMat = null;
- return multipleMat;
- }
- ProgressThreadProcClass procClass;
- private int thresholdValue;
- /// <summary>
- /// 自动分割
- /// </summary>
- /// <param name="thresholdValue">阈值(μm)</param>
- protected void autoSegmentAction(int thresholdValue)
- {
- if (this.matOrg == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- if (this.documentWorkspace.PhaseModels.Count > 0 && this.documentWorkspace.PhaseModels[0].choise == true && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- //PhaseModel phasesCopy = new PhaseModel();
- //phasesCopy.mat = this.getBinaryOneColorPicture(this.documentWorkspace.PhaseModels[0]);// this.documentWorkspace.PhaseModels[0].mat.Clone();//对多相进行处理//#################
- ////phasesCopy.mat = this.documentWorkspace.PhaseModels[0].mat.Clone();//对多相进行处理//#################
- //phasesCopy.color = Color.Green/*panel2.BackColor*/.ToArgb();
- //action912.PerformProcess(phasesCopy, 1).CopyTo(matGeology);
- ////灰度图
- //Mat Inmat = this.documentWorkspace.PhaseModels[0].mat.CvtColor(ColorConversionCodes.BGR2GRAY);
- ////Cv2.ImShow("Inmat", Inmat);
- //Cv2.DistanceTransform(Inmat, distance_temp, DistanceTypes.L2, DistanceMaskSize.Precise);
- ////Cv2.ImShow("distance_temp", distance_temp);
- //binary_temp = this.documentWorkspace.PhaseModels[0].mat.Clone();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
- return;
- }
- this.thresholdValue = thresholdValue;
- procClass = new ProgressThreadProcClass();
- procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyAutoSegAction), "自动分割");
- if (segmentedHolesMat != null)
- {
- segmentedHolesMat.Dispose();
- segmentedHolesMat = null;
- }
- if (segmentedHolesMat == null && createSegmentedHoldsMat() || segmentedHolesMat != null)
- {
- }
- else
- //图像分割
- this.documentWorkspace.Refresh();
- }
- private void applyAutoSegAction()
- {
- //int matValue = 10;// (int)(thresholdValue / this.physical_length);
- Action912 action912 = new Action912();
- if (matGeology != null)
- matGeology.Dispose();
- matGeology = new Mat();
- Mat distance_temp = new Mat();
- Mat binary_temp = null;
- if (this.documentWorkspace.PhaseModels.Count > 0 && this.documentWorkspace.PhaseModels[0].choise == true && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- PhaseModel phasesCopy = new PhaseModel();
- phasesCopy.mat = this.getBinaryOneColorPicture(this.documentWorkspace.PhaseModels[0]);// this.documentWorkspace.PhaseModels[0].mat.Clone();//对多相进行处理//#################
- //phasesCopy.mat = this.documentWorkspace.PhaseModels[0].mat.Clone();//对多相进行处理//#################
- phasesCopy.color = Color.Green/*panel2.BackColor*/.ToArgb();
- action912.PerformProcess(phasesCopy, 1).CopyTo(matGeology);
- //灰度图
- Mat Inmat = BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat)/* //### .CvtColor(ColorConversionCodes.BGR2GRAY)*/;
- //Cv2.ImShow("Inmat", Inmat);
- Cv2.DistanceTransform(Inmat, distance_temp, DistanceTypes.L2, DistanceMaskSize.Precise);
- //Cv2.ImShow("distance_temp", distance_temp);
- binary_temp = this.documentWorkspace.PhaseModels[0].mat.Clone();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasebinarizefirst.text"));
- return;
- OpenCvSharp.Mat mat = action912.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
- if (mat != null)
- {
- mat.CopyTo(matGeology);
- //灰度图
- Mat Inmat = this.documentWorkspace.PhaseModels[0].mat.CvtColor(ColorConversionCodes.BGR2GRAY);
- Cv2.ImShow("Inmat", Inmat);
- Cv2.DistanceTransform(Inmat, distance_temp, DistanceTypes.L2, DistanceMaskSize.Precise);
- }
- //Document doc = Document.FromMat(mat);
- //this.documentWorkspace.Document = doc;
- //this.documentWorkspace.Refresh();
- }
- //标记所有相交和末梢的点
- massLabelPoints.Clear();
- sideLabelPoints.Clear();
- for (int index_x = 1; index_x < matGeology.Width - 1; index_x++)
- {
- for (int index_y = 1; index_y < matGeology.Height - 1; index_y++)
- {
- int countSideLines = GetBoundryCountDOfBinary(new Point(index_x, index_y), matGeology);
- if (countSideLines > 2)
- massLabelPoints.Add(new Point2d(index_x, index_y));
- else if (countSideLines == 1)
- sideLabelPoints.Add(new Point2d(index_x, index_y));
- }
- }
- //从末梢的点开始寻找截线的极小值点
- routePoints.Clear();
- minLabelPoints.Clear();
- foreach (Point2d pointSide in sideLabelPoints)
- {
- Dictionary<Point2d, float> minPoint = GetMinLabelPoint(thresholdValue * thresholdValue, new Point((int)pointSide.X, (int)pointSide.Y), matGeology, distance_temp, new Dictionary<Point2d, float>(), float.MinValue, float.MinValue);
- if (minPoint != null && minPoint.Count > 0)
- foreach (var item in minPoint)
- minLabelPoints.Add(item.Key, item.Value);
- }
- foreach (Point2d pointSide in massLabelPoints)
- {
- Dictionary<Point2d, float> minPoint = GetMinLabelPoint(thresholdValue * thresholdValue, new Point((int)pointSide.X, (int)pointSide.Y), matGeology, distance_temp, new Dictionary<Point2d, float>(), float.MinValue, float.MinValue);
- if (minPoint != null && minPoint.Count > 0)
- foreach (var item in minPoint)
- minLabelPoints.Add(item.Key, item.Value);
- }
- //根据极小值点获取截线
- minLinePoints.Clear();
- if (minLabelPoints.Count > 0 && binary_temp != null)
- {
- foreach (var item in minLabelPoints.Keys)
- {
- int radius = (int)(Math.Sqrt(minLabelPoints[new Point2d((int)item.X, (int)item.Y)]) + 1);
- Point line1Point = GetMinRadiusPoint(new Point((int)item.X, (int)item.Y), radius, matGeology, binary_temp);
- if (line1Point.X > 0 && line1Point.Y > 0)
- {
- Point line2Point = GetMinAnotherPoint(thresholdValue * thresholdValue, new Point((int)item.X, (int)item.Y), line1Point, radius, binary_temp);
- if (line2Point.X > 0 && line2Point.Y > 0)
- {
- Line lineI = new Line(line1Point, line2Point/*new Point((int)item.X, (int)item.Y)*/);
- if ((lineI.startPoint.X - lineI.endPoint.X) * (lineI.startPoint.X - lineI.endPoint.X) + (lineI.startPoint.Y - lineI.endPoint.Y) * (lineI.startPoint.Y - lineI.endPoint.Y)
- <= thresholdValue * thresholdValue / (this.physical_length * this.physical_length))
- minLinePoints.Add(new Point2d((int)item.X, (int)item.Y), lineI);
- }
- else
- {
- Line lineI = GetMinLinePoint(thresholdValue * thresholdValue, new Point((int)item.X, (int)item.Y), radius, binary_temp);
- if (lineI != null && (lineI.startPoint.X - lineI.endPoint.X) * (lineI.startPoint.X - lineI.endPoint.X) + (lineI.startPoint.Y - lineI.endPoint.Y) * (lineI.startPoint.Y - lineI.endPoint.Y)
- <= thresholdValue * thresholdValue / (this.physical_length * this.physical_length))
- {
- minLinePoints.Add(new Point2d((int)item.X, (int)item.Y), lineI);
- }
- }
- }
- }
- }
- //for (int lineIndex = minLinePoints.Count - 1; lineIndex >= 0; lineIndex--)
- //{
- // Line lineI = minLinePoints.Values[lineIndex];
- // if ((lineI.startPoint.X - lineI.endPoint.X) * (lineI.startPoint.X - lineI.endPoint.X) + (lineI.startPoint.Y - lineI.endPoint.Y) * (lineI.startPoint.Y - lineI.endPoint.Y)
- // <= thresholdValue * thresholdValue / (this.physical_length * this.physical_length))
- // {
- // }
- //}
- if (procClass != null) procClass.DismissProgressAction(this);
- }
- #endregion
- /// <summary>
- /// 根据圆心得到截线与轮廓的截线
- /// </summary>
- /// <param name="threshold_2">阈值的平方</param>
- /// <param name="center">圆心</param>
- /// <param name="radius">半径</param>
- /// <param name="binary_temp">二值提取的mat</param>
- /// <returns></returns>
- private Line GetMinLinePoint(int threshold_2, Point center, int radius, Mat binary_temp)
- {
- Line line = null;// new Line(new Point(int.MinValue, int.MinValue), new Point(int.MaxValue, int.MaxValue));
- int matW = binary_temp.Width;
- int matH = binary_temp.Height;
- int luntimes = radius * 10;
- int step = -1;
- int length_2 = 0;
- Point startPoint = new Point(center.X, center.Y);
- Point endPoint = new Point(center.X, center.Y);
- for (int rotateAngleV = 0; rotateAngleV < 361; rotateAngleV += 15)
- {
- startPoint = new Point(center.X, center.Y);
- step = -1;
- for (int i = 1; i < luntimes; i++)
- {
- startPoint.X += step;
- Point itemP = rotatedVPaiPoint(rotateAngleV * Math.PI / 180.0, startPoint.X, startPoint.Y, center.X, center.Y);
- if (itemP.Y < 0 || itemP.X < 0 || itemP.Y >= matH || itemP.X >= matW)
- continue;
- Vec4b vec4B = binary_temp.At<Vec4b>(itemP.Y, itemP.X);
- if (vec4B.Item3 == 0)
- {
- startPoint.X = itemP.X;
- startPoint.Y = itemP.Y;
- break;
- }
- }
- endPoint = new Point(center.X, center.Y);
- step = 1;
- for (int i = 1; i < luntimes; i++)
- {
- endPoint.X += step;
- Point itemP = rotatedVPaiPoint(rotateAngleV * Math.PI / 180.0, endPoint.X, endPoint.Y, center.X, center.Y);
- if (itemP.Y < 0 || itemP.X < 0 || itemP.Y >= matH || itemP.X >= matW)
- continue;
- Vec4b vec4B = binary_temp.At<Vec4b>(itemP.Y, itemP.X);
- if (vec4B.Item3 == 0)
- {
- endPoint.X = itemP.X;
- endPoint.Y = itemP.Y;
- break;
- }
- }
- if (line == null || ((startPoint.X - endPoint.X) * (startPoint.X - endPoint.X) + (startPoint.Y - endPoint.Y) * (startPoint.Y - endPoint.Y))
- < length_2)
- {
- line = new Line(new Point(startPoint.X, startPoint.Y), new Point(endPoint.X, endPoint.Y));
- length_2 = (line.startPoint.X - line.endPoint.X) * (line.startPoint.X - line.endPoint.X) + (line.startPoint.Y - line.endPoint.Y) * (line.startPoint.Y - line.endPoint.Y);
- }
- }
- if (radius > 1 && length_2 > radius * radius * 50 && length_2 < 10)
- {
- return null;
- }
- return line;
- }
- /// <summary>
- /// 根据圆心和其中一个交点得到截线与轮廓的另一个交点
- /// </summary>
- /// <param name="threshold_2">阈值的平方</param>
- /// <param name="center">圆心</param>
- /// <param name="startP">其中一个交点</param>
- /// <param name="radius">半径</param>
- /// <param name="binary_temp">二值提取的mat</param>
- /// <returns></returns>
- private Point GetMinAnotherPoint(int threshold_2, Point center, Point startP, int radius, Mat binary_temp)
- {
- Point line1Point = new Point(-1, -1);
- bool rotateFromY = true;
- Point startRotateFormerPoint = new Point(startP.X, startP.Y);
- if (Math.Abs(center.X - startP.X) > Math.Abs(center.Y - startP.Y))
- {
- startRotateFormerPoint.Y = center.Y;
- rotateFromY = false;
- }
- else
- {
- startRotateFormerPoint.X = center.X;
- rotateFromY = true;
- }
- int length = rotateFromY ? (center.Y - startP.Y) : (center.X - startP.X);
- if (length == 0)
- return line1Point;
- int count = Math.Abs(length);
- int step = length / count;
- int length_2 = 0;
- int matW = binary_temp.Width;
- int matH = binary_temp.Height;
- double rotateAngle = AngleText(new PointF(center.X, center.Y), new PointF(startRotateFormerPoint.X, startRotateFormerPoint.Y), new PointF(startP.X, startP.Y));
- Point endRotateFormerPoint = new Point(center.X, center.Y);
- int luntimes;
- if (count < 3)
- {
- luntimes = 4;
- }
- else
- {
- luntimes = count * 3;
- }
- if (rotateFromY)
- {
- for (int i = 1; i < luntimes; i++)
- {
- endRotateFormerPoint.Y += step;
- Point itemP = rotatedVPaiPoint(rotateAngle, endRotateFormerPoint.X, endRotateFormerPoint.Y, center.X, center.Y);
- if (itemP.Y < 0 || itemP.X < 0 || itemP.Y >= matH || itemP.X >= matW)
- continue;
- Vec4b vec4B = binary_temp.At<Vec4b>(itemP.Y, itemP.X);
- if (vec4B.Item3 == 0)
- {
- length_2 = (itemP.X - startP.X) * (itemP.X - startP.X) + (itemP.Y - startP.Y) * (itemP.Y - startP.Y);
- if (length_2 > 9)
- {
- line1Point = new Point(itemP.X, itemP.Y);
- }
- break;
- }
- }
- }
- else
- {
- for (int i = 1; i < luntimes; i++)
- {
- endRotateFormerPoint.X += step;
- Point itemP = rotatedVPaiPoint(rotateAngle, endRotateFormerPoint.X, endRotateFormerPoint.Y, center.X, center.Y);
- if (itemP.Y < 0 || itemP.X < 0 || itemP.Y >= matH || itemP.X >= matW)
- continue;
- Vec4b vec4B = binary_temp.At<Vec4b>(itemP.Y, itemP.X);
- if (vec4B.Item3 == 0)
- {
- length_2 = (itemP.X - startP.X) * (itemP.X - startP.X) + (itemP.Y - startP.Y) * (itemP.Y - startP.Y);
- if (length_2 > 9)
- {
- line1Point = new Point(itemP.X, itemP.Y);
- }
- break;
- }
- }
- }
- return line1Point;
- }
- /// <summary>
- /// 根据圆心和半径得到截线与其中一端轮廓的交点
- /// </summary>
- /// <param name="center">圆心</param>
- /// <param name="radius">半径</param>
- /// <param name="mat">抽骨架的mat</param>
- /// <param name="binary_temp">二值提取的mat</param>
- /// <returns></returns>
- private Point GetMinRadiusPoint(Point center, int radius, Mat mat, Mat binary_temp)
- {
- Point line1Point = new Point(-1, -1);// new Line(new Point(int.MinValue, int.MinValue), new Point(int.MaxValue, int.MaxValue));
- // 圆上的点集合
- Point[] points1 = roundOutline(center, radius);
- int matW = binary_temp.Width;
- int matH = binary_temp.Height;
- foreach (var itemP in points1)
- {
- if (itemP.Y < 0 || itemP.X < 0 || itemP.Y >= matH || itemP.X >= matW)
- continue;
- Vec4b vec4B = binary_temp.At<Vec4b>(itemP.Y, itemP.X);
- if (vec4B.Item3 == 0)
- {
- line1Point = new Point(itemP.X, itemP.Y);
- break;
- }
- }
- //for (int rotateAngleV = 0; rotateAngleV < 361; rotateAngleV += 15)
- //{
- // Point startPoint = new Point(-1, -1);
- // while (startPoint.X < -10)
- // {
- // }
- // for (int length = 0; length < 100; length++)
- // {
- // }
- //}
- return line1Point;
- }
- /// <summary>
- /// 根据圆心和半径得到截线与其中一端轮廓的交点
- /// </summary>
- /// <param name="point">圆心</param>
- /// <param name="radius">半径</param>
- /// <param name="mat">抽骨架的mat</param>
- /// <param name="binary_temp">二值提取的mat</param>
- /// <returns></returns>
- private Line GetMinRadiusLine(Point point, int radius, Mat mat, Mat binary_temp)
- {
- Line line = null;// new Line(new Point(int.MinValue, int.MinValue), new Point(int.MaxValue, int.MaxValue));
- for (int rotateAngleV = 0; rotateAngleV < 361; rotateAngleV += 15)
- {
- Point startPoint = new Point(-1, -1);
- while (startPoint.X < -10)
- {
- }
- for (int length = 0; length < 100; length++)
- {
- }
- }
- return line;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="point"></param>
- /// <param name="mat">抽骨架的mat</param>
- /// <param name="binary_temp">二值提取的mat</param>
- /// <returns></returns>
- private Line GetMinLabelLine(Point point, Mat mat, Mat binary_temp)
- {
- Line line = null;// new Line(new Point(int.MinValue, int.MinValue), new Point(int.MaxValue, int.MaxValue));
- for (int rotateAngleV = 0; rotateAngleV < 361; rotateAngleV += 15)
- {
- Point startPoint = new Point(-1, -1);
- while (startPoint.X < 0)
- {
- }
- for (int length = 0; length < 100; length++)
- {
- }
- }
- return line;
- }
- /// <summary>
- /// 三点角计算
- /// </summary>
- /// <param name="cen"></param>
- /// <param name="first"></param>
- /// <param name="second"></param>
- /// <returns></returns>
- public double AngleText(PointF cen, PointF first, PointF second)
- {
- double ma_x = first.X - cen.X;
- double ma_y = first.Y - cen.Y;
- double mb_x = second.X - cen.X;
- double mb_y = second.Y - cen.Y;
- double v1 = (ma_x * mb_x) + (ma_y * mb_y);
- double ma_val = Math.Sqrt(ma_x * ma_x + ma_y * ma_y);
- double mb_val = Math.Sqrt(mb_x * mb_x + mb_y * mb_y);
- double cosM = v1 / (ma_val * mb_val);
- double angleAMB = Math.Acos(cosM);// * 180 / M_PI;
- return angleAMB;
- }
- /// <summary>
- /// 获取旋转后的坐标点
- /// </summary>
- /// <param name="rotatedVPai">旋转角度</param>
- /// <param name="point_X">旋转前的X坐标</param>
- /// <param name="point_Y">旋转前的Y坐标</param>
- /// <param name="centerX">旋转中心点X坐标</param>
- /// <param name="centerY">旋转中心点Y坐标</param>
- /// <returns></returns>
- private Point rotatedVPaiPoint(double rotatedVPai, float point_X, float point_Y, float centerX, float centerY)
- {
- //double rotatedVPai = rotateAngleV * Math.PI / 180.0;
- double disX = point_X - centerX;
- double disY = point_Y - centerY;
- double outX = disX * Math.Cos(rotatedVPai) - disY * Math.Sin(rotatedVPai);
- double outY = disX * Math.Sin(rotatedVPai) + disY * Math.Cos(rotatedVPai);
- return new Point((int)(outX + centerX), (int)(outY + centerY));
- //return new PointF((float)outX + centerX, (float)outY + centerY);
- }
- /// <summary>
- /// 获取旋转后的坐标点
- /// </summary>
- /// <param name="rotateAngleV">旋转角度</param>
- /// <param name="point_X">旋转前的X坐标</param>
- /// <param name="point_Y">旋转前的Y坐标</param>
- /// <param name="centerX">旋转中心点X坐标</param>
- /// <param name="centerY">旋转中心点Y坐标</param>
- /// <returns></returns>
- private PointF rotatedPoint(int rotateAngleV, float point_X, float point_Y, float centerX, float centerY)
- {
- double rotatedVPai = rotateAngleV * Math.PI / 180.0;
- double disX = point_X - centerX;
- double disY = point_Y - centerY;
- double outX = disX * Math.Cos(rotatedVPai) - disY * Math.Sin(rotatedVPai);
- double outY = disX * Math.Sin(rotatedVPai) + disY * Math.Cos(rotatedVPai);
- return new PointF((float)outX + centerX, (float)outY + centerY);
- }
- #region 需继承方法
- protected virtual void drawSubclass(Graphics graphics)
- {
- if (showOrimat())
- return;
- ////if (matGeology != null && matGeology.Width > 0 && matGeology.Height > 0)
- ////{
- //// graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(matGeology), 0, 0);
- ////}
- //if (sideLabelPoints.Count > 0 && false)
- //{
- // Pen pointsPen = new Pen(Color.Yellow, 2);
- // foreach (var item in sideLabelPoints)
- // {
- // graphics.DrawEllipse(pointsPen, new RectangleF((float)item.X - 1, (float)item.Y - 1, 3, 3));
- // }
- //}
- ////if (minLabelPoints.Count > 0)
- ////{
- //// Pen pointsPen = new Pen(Color.Yellow, 1);
- //// foreach (var item in minLabelPoints.Keys)
- //// {
- //// graphics.DrawEllipse(pointsPen, new RectangleF((float)item.X, (float)item.Y, 1, 1));
- //// }
- ////}
- if (addPoint && m_StartPoint.X > 0 && m_StartPoint.Y > 0 && m_EndPoint.X > 0 && m_EndPoint.Y > 0)
- {
- Pen pointsPen = new Pen(Color.Blue, 1);
- graphics.DrawLine(pointsPen, new Point((int)m_StartPoint.X, (int)m_StartPoint.Y), new Point((int)m_EndPoint.X, (int)m_EndPoint.Y));
- }
- if (minLinePoints.Count > 0/* && !holeNumberVisible*/)
- {
- Pen pointsPen = new Pen(Color.Blue, 1);
- foreach (var item in minLinePoints.Values)
- {
- graphics.DrawLine(pointsPen, item.startPoint, item.endPoint);
- }
- }
- //if (lstAttribute.Count > 0 && holeNumberVisible)
- //{
- // Font myFont = new Font("宋体", 8/*, FontStyle.Bold*/);
- // Brush bush = new SolidBrush(/*this.panel1.BackColor*/Color.Black);//填充的颜色
- // foreach (var attribute in lstAttribute)
- // {
- // if (attribute[7] == 27)
- // {
- // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, new SolidBrush(/*this.panel1.BackColor*/Color.Green), (float)attribute[1] - 3, (float)attribute[2] - 3);
- // }
- // else
- // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, bush, (float)attribute[1] - 3, (float)attribute[2] - 3);
- // }
- //}
- //if (massLabelPoints.Count > 0 && false)
- //{
- // //int index = 0;
- // Pen pointsPen = new Pen(Color.Yellow, 2);
- // //Font myFont = new Font("宋体", 12/*, FontStyle.Bold*/);
- // //Brush bush = new SolidBrush(this.panel1.BackColor/*Color.Red*/);//填充的颜色
- // foreach (var item in massLabelPoints)
- // {
- // graphics.DrawEllipse(pointsPen, new RectangleF((float)item.X - 1, (float)item.Y - 1, 3, 3));
- // //graphics.DrawString("" + (++index), myFont, bush, (float)item.X - 5, (float)item.Y - 5);
- // }
- //}
- }
- /// <summary>
- /// 图片索引改变后调用的事件
- /// </summary>
- protected virtual void refreshWhileImgChanged()
- {
- }
- protected virtual void refreshPhaseModelChoise()
- {
- }
- /// <summary>
- /// 获取孔隙直径计算类型 1长径 2短径 3平均径 4等效圆直径 5φ值
- /// </summary>
- /// <returns></returns>
- protected virtual int getHolesType()
- {
- return 4;
- }
- /// <summary>
- /// 获取孔隙直径
- /// </summary>
- /// <param name="attribute"></param>
- /// <returns></returns>
- protected double getHolesD(List<int> attribute)
- {
- int holesType = getHolesType();
- switch (holesType)
- {
- case 1:
- return Math.Sqrt(attribute[10] * this.physical_length * this.physical_length);
- break;
- case 2:
- return Math.Sqrt(attribute[11] * this.physical_length * this.physical_length);
- break;
- case 3:
- return Math.Sqrt(attribute[12] * this.physical_length * this.physical_length);
- break;
- case 4:
- return Math.Sqrt(attribute[5] * this.physical_length * this.physical_length / Math.PI) * 2;
- break;
- case 5:
- return 0.3815 + 0.9027 * Math.Sqrt(attribute[10] * this.physical_length * this.physical_length);
- //{
- // double longD = Math.Sqrt(attribute[10] * this.physical_length * this.physical_length);
- // return 0.3815 + 0.9027 * Math.Sqrt(attribute[10] * this.physical_length * this.physical_length);
- //}
- //return Math.Sqrt(attribute[5] * this.physical_length * this.physical_length / Math.PI) * 2;
- break;
- default:
- return Math.Sqrt(attribute[5] * this.physical_length * this.physical_length / Math.PI) * 2;
- }
- //return Math.Sqrt(attribute[5] * this.physical_length * this.physical_length / Math.PI) * 2;
- }
- /// <summary>
- /// 获取视孔隙比表面
- /// </summary>
- /// <param name="attribute"></param>
- /// <returns></returns>
- private double getHolesS0(List<int> attribute)
- {
- return 4 * attribute[8] / (attribute[5] * this.physical_length * Math.PI);
- }
- /// <summary>
- /// 获取形状因子
- /// </summary>
- /// <param name="attribute"></param>
- /// <returns></returns>
- private double getHolesF(List<int> attribute)
- {
- return Math.Min(1.0, 4 * Math.PI * (attribute[5] - 0) / (attribute[8] * attribute[8]));
- }
- /// <summary>
- /// 获取孔喉比
- /// </summary>
- /// <param name="attribute"></param>
- /// <returns></returns>
- private string getHolesRpt(List<int> attribute)
- {
- return attribute[9] == 0 ? "无" : "" + Math.Sqrt(attribute[5] / Math.PI) * 2 * attribute[6] / attribute[9];
- }
- /// <summary>
- /// 获取孔喉比
- /// </summary>
- /// <param name="attribute"></param>
- /// <returns></returns>
- private double getHolesRptValue(List<int> attribute)
- {
- return attribute[9] == 0 ? 0 : Math.Sqrt(attribute[5] / Math.PI) * 2 * attribute[6] / attribute[9];
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- protected virtual void buildListBox_analysisResult()
- {
- if (this.matOrg == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- if (lstAttribute.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text"));
- return;
- }
- string imgName = getCurrentWorkspace().GetFriendlyName();
- string tag = getCurrentWorkTag();
- DataTable dataTable;
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- add++;
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- break;
- }
- }
- if (replace || this.listView2.Items.Count == 0 || add == 0)
- {
- if (!replace)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + tag;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- }
- this.dataGridView2.Rows.Clear();
- //this.dataTables.Clear();
- for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
- {
- System.Data.DataTable dataTable1 = dataTables[dataTableI];
- if (dataTable1.TableName.Equals(tag))
- dataTables.RemoveAt(dataTableI);
- }
- if (lstAttriDict.ContainsKey(tag))
- lstAttriDict.Remove(tag);
- List<List<int>> attriValues = new List<List<int>>();
- List<int> listValues;
- //添加视域的面积信息
- listValues = new List<int>();
- listValues.Add(this.bitmap.Width * this.bitmap.Height);
- //foreach (var itemInt in attribute)
- // listValues.Add(itemInt);
- attriValues.Add(listValues);
- DataGridViewRow dgvr;// = new DataGridViewRow();
- //attribute = new List<int>();
- //attribute.Add(hcomp);
- //attribute.Add(x);
- //attribute.Add(y);
- //attribute.Add(width);
- //attribute.Add(height);
- //attribute.Add(areaField1);
- //attribute.Add(0);//喉道数量
- //attribute.Add(hcomp);//编号
- //attribute.Add(0);//孔隙周边长,单位是像素
- //attribute.Add(0);//与该空腔连通的喉道总宽度,单位是像素
- //lstAttribute.Add(attribute);
- string value0 = imgName;
- string value1 = PdnResources.GetString("Menu.view.text")+"0";//视场
- //string value2;// = firRow.Cells[1].Value;//编号
- //int value3;// = firRow.Cells[2].Value;//孔隙直径
- //视孔隙比表面
- //形状因子
- //孔喉比
- //配位数
- foreach (var attribute in lstAttribute)
- {
- //if (attribute[5] < 5)
- // continue;
- listValues = new List<int>();
- foreach (var itemInt in attribute)
- listValues.Add(itemInt);
- attriValues.Add(listValues);
- dgvr = new DataGridViewRow();
- dgvr.Tag = tag;
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = value0;
- dgvr.Cells[1].Value = value1;
- dgvr.Cells[2].Value = attribute[7];//编号
- dgvr.Cells[3].Value = this.getHolesD(attribute);//孔隙直径
- dgvr.Cells[4].Value = this.getHolesS0(attribute);//视孔隙比表面(<--4/* * this.physical_length*/ * attribute[8] / (attribute[5]/* * this.physical_length*/ * this.physical_length * Math.PI);)
- dgvr.Cells[5].Value = this.getHolesF(attribute);//形状因子
- dgvr.Cells[6].Value = this.getHolesRpt(attribute);//孔喉比(<--Math.Sqrt(attribute[5] * this.physical_length * this.physical_length / Math.PI) * 2 / (attribute[9] * this.physical_length / attribute[6]))
- dgvr.Cells[7].Value = attribute[6];//配位数
- this.dataGridView2.Rows.Add(dgvr);
- dataTable = new DataTable();
- dataTable.TableName = tag;
- for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
- {
- dataTable.Columns.Add("" + i);
- }
- DataRow dataRow = dataTable.NewRow();
- dataRow["0"] = value0;
- dataRow["1"] = dgvr.Cells[1].Value;
- dataRow["2"] = dgvr.Cells[2].Value;
- dataRow["3"] = dgvr.Cells[3].Value;
- dataRow["4"] = dgvr.Cells[4].Value;
- dataRow["5"] = dgvr.Cells[5].Value;
- dataRow["6"] = dgvr.Cells[6].Value;
- dataRow["7"] = dgvr.Cells[7].Value;
- dataTable.Rows.Add(dataRow);
- this.dataTables.Add(dataTable);
- }
- lstAttriDict.Add(tag, attriValues);
- //if (this.allShow)
- // AllShow();
- this.RefreshDataGridView4();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- Draw(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- //中间数据-拼接中间数据
- List<List<string>> dataList = new List<List<string>>();
- //string value0 = imgName;//图片
- //string value1 = "视场0";//视场
- ////string value2;// = firRow.Cells[1].Value;//编号
- ////int value3;// = firRow.Cells[2].Value;//孔隙直径
- ////视孔隙比表面
- ////形状因子
- ////孔喉比
- ////配位数
- List<string> columnName = new List<string>();
- columnName.Add(PdnResources.GetString("Menu.picture.Text"));
- columnName.Add(PdnResources.GetString("Menu.view.text"));
- columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.serialnumber.text"));
- columnName.Add(PdnResources.GetString("Menu.Theporediameter.text"));
- columnName.Add(PdnResources.GetString("Menu.Apparentporeratiosurface.text"));
- columnName.Add(PdnResources.GetString("Menu.Shapefactor.text"));
- columnName.Add(PdnResources.GetString("Menu.Porethroatthan.text"));
- columnName.Add(PdnResources.GetString("Menu.Coordinationnumber.text"));
- dataList.Add(columnName);
- foreach (DataGridViewRow Row in this.dataGridView2/*dataGridView1*/.Rows)
- {
- List<string> strList = new List<string>();
- strList.Add(Row.Cells[0].Value.ToString());
- strList.Add(Row.Cells[1].Value.ToString());
- strList.Add(Row.Cells[2].Value.ToString());
- strList.Add(Row.Cells[3].Value.ToString());
- strList.Add(Row.Cells[4].Value.ToString());
- strList.Add(Row.Cells[5].Value.ToString());
- strList.Add(Row.Cells[6].Value.ToString());
- strList.Add(Row.Cells[7].Value.ToString());
- dataList.Add(strList);
- }
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(tag))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
- newModel.tagName = tag;
- newModel.picName = imgName;
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- //this.listBox_analysisResult.Items.Clear();
- ////foreach (var item in analysisResults.Keys)
- ////{
- //// this.listBox_analysisResult.Items.Add(new LocalListViewItem(item, item.GetFriendlyName()));
- ////}
- ////buildListView_analysisResult();
- }
- protected virtual void SubclassInitialize()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 报告模板命名
- /// </summary>
- /// <returns></returns>
- protected virtual string getTemplateName()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 项目工程内的文件夹路径名称
- /// </summary>
- /// <returns></returns>
- protected virtual string getProjectEngineeringName()
- {
- throw new NotImplementedException();
- }
- protected virtual void getScriptRecording()
- {
- }
- #endregion
- #region 内部类
- private int GetBoundryCountDOfBinary(Point point, Mat mat)
- {
- int count = 0;
- if (point.X > mat.Width - 2 || point.X < 1 || point.Y > mat.Height - 2 || point.Y < 1)
- {
- return count;
- }
- bool firstValueOnBoundry = false;
- bool lastValueOnBoundry = false;
- Vec4b vec4B = mat.At<Vec4b>(point.Y, point.X);
- if (vec4B.Item3 == 0)
- return -1;
- vec4B = mat.At<Vec4b>(point.Y - 1, point.X - 1);
- if (vec4B.Item3 != 0)
- {
- count++;
- firstValueOnBoundry = true;
- lastValueOnBoundry = true;
- }
- vec4B = mat.At<Vec4b>(point.Y - 1, point.X);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y - 1, point.X + 1);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y, point.X + 1);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y + 1, point.X + 1);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y + 1, point.X);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y + 1, point.X - 1);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry)
- count++;
- lastValueOnBoundry = true;
- }
- else lastValueOnBoundry = false;
- vec4B = mat.At<Vec4b>(point.Y, point.X - 1);
- if (vec4B.Item3 != 0)
- {
- if (!lastValueOnBoundry && !firstValueOnBoundry)
- count++;
- }
- return count;
- }
- internal class LocalListViewItem
- {
- public DocumentWorkspace Value { get; }
- public string Display { get; }
- public LocalListViewItem(DocumentWorkspace Value, string Display)
- {
- this.Value = Value;
- this.Display = Display;
- }
- }
- internal class DocumentItem
- {
- public Bitmap bitmap;
- public GraphicsList graphicsList;
- public List<PhaseModel> phaseModels;
- //public AnalysisResult analysisResult;
- public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
- {
- this.bitmap = bitmap;
- this.graphicsList = graphicsList;
- this.phaseModels = phaseModels;
- }
- }
- internal class Line
- {
- /// <summary>
- /// 直线的起点
- /// </summary>
- public System.Drawing.Point startPoint;
- /// <summary>
- /// 直线的终点
- /// </summary>
- public System.Drawing.Point endPoint;
- /// <summary>
- /// 构造方法
- /// </summary>
- /// <param name="s"></param>
- /// <param name="e"></param>
- public Line(System.Drawing.Point s, System.Drawing.Point e)
- {
- this.startPoint = s;
- this.endPoint = e;
- }
- }
- #endregion
- /// <summary>
- /// 使用圆心及半径得到圆的轮廓
- /// </summary>
- /// <param name="center">圆心</param>
- /// <param name="radius">半径</param>
- /// <returns></returns>
- public Point[] roundOutline(Point center, int radius)
- {
- if (radius < 1) radius = 1;
- Mat mat = new Mat((int)(radius * 2.1), (int)(radius * 2.1), MatType.CV_8UC1, new Scalar(0, 0, 0));
- OpenCvSharp.Point point = new OpenCvSharp.Point(mat.Cols / 2, mat.Rows / 2);
- Cv2.Circle(mat, point, radius, new Scalar(255, 255, 255), -1);
- OpenCvSharp.Point[][] contours;
- HierarchyIndex[] hierarchy;
- Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
- if (contours.Length > 0)
- {
- OpenCvSharp.Point[] roundOutline = contours[0];
- Point[] roundOutPoints = new Point[roundOutline.Length];
- for (int i = 0; i < roundOutline.Length; i++)
- {
- roundOutPoints[i].X = roundOutline[i].X - point.X + center.X;
- roundOutPoints[i].Y = roundOutline[i].Y - point.Y + center.Y;
- }
- return roundOutPoints;
- }
- return new Point[0];
- }
- private void button16_Click(object sender, EventArgs e)
- {
- this.button11.Visible = true;
- this.button16.Visible = false;
- this.button11.Focus();
- this.allShow = false;
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTables)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- else
- {
- if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- /// <summary>
- /// 添加显示并刷新dataGridView1的数据
- /// </summary>
- /// <param name="tempsAttribute"></param>
- protected void AddRowDataGridView1(List<List<int>> tempsAttribute)
- {
- DataTable dataTable;
- this.dataGridView1.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- //获取视域面积
- List<int> areaInt = tempsAttribute[0];
- //attribute = new List<int>();
- //attribute.Add(hcomp);
- //attribute.Add(x);
- //attribute.Add(y);
- //attribute.Add(width);
- //attribute.Add(height);
- //attribute.Add(areaField1);
- //attribute.Add(0);//喉道数量
- //attribute.Add(hcomp);//编号
- //attribute.Add(0);//孔隙周边长,单位是像素
- //attribute.Add(0);//与该空腔连通的喉道总宽度,单位是像素
- //lstAttribute.Add(attribute);
- double value0 = 0;//面孔率(第i个孔隙的面积)
- double value1_0 = 0;//第i个孔隙直径
- double value1 = 0;//平均孔隙直径
- double value2 = 0;//平均视孔隙比表面
- double value3 = 0;//平均孔隙形状因子
- double value4 = 0;//平均孔喉比
- double value5 = 0;//均质系数(最大孔隙直径)
- double value6 = 0;//孔隙直径分选系数
- double value7 = 0;//平均孔隙配位数
- for (int attributeI = 1; attributeI < lstAttribute.Count; attributeI++)
- {
- var attribute = lstAttribute[attributeI];
- //if (attribute[5] < 5)
- // continue;
- value0 += attribute[5];
- value1_0 = this.getHolesD(attribute);
- value1 += value1_0 * attribute[5] * 100.0 / areaInt[0];
- value2 += this.getHolesS0(attribute);
- value3 += this.getHolesF(attribute);
- value4 += this.getHolesRptValue(attribute);
- if (value1_0 > value5)
- value5 = value1_0;
- value7 += attribute[6];
- }
- dgvr.Tag = "tag";//<--tag
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- double outValue;
- //面孔率
- value0 = value0 * 100.0 / areaInt[0];
- if (double.TryParse(string.IsNullOrEmpty(value0.ToString()) ? "0" :
- value0.ToString(), out outValue))
- {
- dgvr.Cells[0].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[0].Value = value0.ToString();
- //平均孔隙直径
- value1 = value1 / 100.0;// areaInt[0]/*(lstAttribute.Count - 1)*/;
- if (double.TryParse(string.IsNullOrEmpty(value1.ToString()) ? "0" :
- value1.ToString(), out outValue))
- {
- dgvr.Cells[1].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[1].Value = value1.ToString();
- //平均视孔隙比表面
- value2 = value2 / (lstAttribute.Count - 1);
- if (double.TryParse(string.IsNullOrEmpty(value2.ToString()) ? "0" :
- value2.ToString(), out outValue))
- {
- dgvr.Cells[2].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[2].Value = value2.ToString();
- //平均孔隙形状因子
- value3 = 4 * Math.PI * value3 / (lstAttribute.Count - 1);
- if (double.TryParse(string.IsNullOrEmpty(value3.ToString()) ? "0" :
- value3.ToString(), out outValue))
- {
- dgvr.Cells[3].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[3].Value = value3.ToString();
- //平均孔喉比
- value4 = value4 / (lstAttribute.Count - 1);
- if (double.TryParse(string.IsNullOrEmpty(value4.ToString()) ? "0" :
- value4.ToString(), out outValue))
- {
- dgvr.Cells[4].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[4].Value = value4.ToString();
- //均质系数
- value5 = value1 / value5;
- if (double.TryParse(string.IsNullOrEmpty(value5.ToString()) ? "0" :
- value5.ToString(), out outValue))
- {
- dgvr.Cells[5].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[5].Value = value5.ToString();
- //孔隙直径分选系数
- value6 = 0;
- for (int attributeI = 1; attributeI < lstAttribute.Count; attributeI++)
- {
- var attribute = lstAttribute[attributeI];
- ////if (attribute[5] < 5)
- //// continue;
- //value0 += attribute[5];
- value1_0 = this.getHolesD(attribute) - value1;
- value1_0 = value1_0 * value1_0 * attribute[5] * 100.0 / areaInt[0];
- value6 += value1_0;
- }
- value6 = Math.Sqrt(value6 / 100.0);
- if (double.TryParse(string.IsNullOrEmpty(value6.ToString()) ? "0" :
- value6.ToString(), out outValue))
- {
- dgvr.Cells[6].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[6].Value = value6.ToString();
- //平均孔隙配位数
- value7 = value7 * 1.0 / (lstAttribute.Count - 1);
- if (double.TryParse(string.IsNullOrEmpty(value7.ToString()) ? "0" :
- value7.ToString(), out outValue))
- {
- dgvr.Cells[7].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[7].Value = value7.ToString();
- this.dataGridView1.Rows.Add(dgvr);
- //DataGridViewRow dgvr = new DataGridViewRow();
- //foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- //{
- // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- //}
- //for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- //{
- // //if (c == 2 || c == 3)
- // // dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- // // this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- // //else
- // if (c == 3 || c == 4 || c == 5 || c == 6 || c == 7)
- // {
- // double outValue;
- // if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- // this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue))
- // {
- // dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- // }
- // else
- // dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- // }
- // else
- // dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- //}
- //this.dataGridView2.Rows.Add(dgvr);
- }
- /// <summary>
- /// 刷新分析结果数据
- /// </summary>
- protected void RefreshDataGridView4()//####
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
- {
- int dataTableIndex = 0;
- if (lstAttriDict.ContainsKey(this.listView2.SelectedItems[j].Tag.ToString()))
- this.AddRowDataGridView1(lstAttriDict[this.listView2.SelectedItems[j].Tag.ToString()]);
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
- {
- dataTableIndex = i;
- if (this.dataTables.Count > dataTableIndex && this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- //if (c == 2 || c == 3)
- // dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- // this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- //else
- if (c == 3 || c == 4 || c == 5 || c == 6 || c == 7)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue))
- {
- dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- }
- else if (this.listView2.Items.Count > 0)
- {
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- var firstTag = this.listView2.Items[0].Tag;
- if (lstAttriDict.ContainsKey(this.listView2.Items[0].Tag.ToString()))
- this.AddRowDataGridView1(lstAttriDict[this.listView2.Items[0].Tag.ToString()]);
- int dataTableIndex = 0;
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (this.dataTables[i].TableName.Equals(firstTag))
- {
- dataTableIndex = i;
- if (this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- //if (c == 2 || c == 3)
- // dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- // this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- //else
- if (c == 3 || c == 4 || c == 5 || c == 6 || c == 7)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue))
- {
- dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- }
- else
- {
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- foreach (var itemlist in lstAttriDict.Values)
- {
- this.AddRowDataGridView1(itemlist);
- }
- //if (lstAttriDict.ContainsKey(this.listView2.Items[0].Tag.ToString()))
- // this.AddRowDataGridView1(lstAttriDict[this.listView2.Items[0].Tag.ToString()]);
- DataTable dataTable = new DataTable();
- for (int i = this.dataTables.Count - 1; i >= 0; i--)
- {
- dataTable = this.dataTables[i];
- for (int r = 0; r < dataTable.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable.Columns.Count; c++)
- {
- //if (c == 2 || c == 3)
- // dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
- // dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- //else
- if (c == 3 || c == 4 || c == 5 || c == 6 || c == 7)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
- dataTable.Rows[r][c].ToString(), out outValue))
- {
- dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- }
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- /// <summary>
- /// 切换分析结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listview2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTables)
- {
- if (lstAttriDict.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
- this.AddRowDataGridView1(lstAttriDict[this.listView2.SelectedItems[i].Tag.ToString()]);
- if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- }
- /// <summary>
- /// 全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button11_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- this.button11.Visible = false;
- this.button16.Visible = true;
- this.button16.Focus();
- this.allShow = true;
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- foreach (var itemlist in lstAttriDict.Values)
- {
- this.AddRowDataGridView1(itemlist);
- }
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
- {
- dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- private void button12_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- for (int i = this.listView2.SelectedItems.Count - 1; i >= 0; i--)
- {
- int selectIndex = this.listView2.SelectedItems[i].Index;
- foreach (var dataTable in this.dataTables)
- {
- if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
- {
- this.dataTables.Remove(dataTable);
- break;
- }
- }
- if (bitDic.ContainsKey((string)this.listView2.SelectedItems[i].Tag))
- bitDic.Remove((string)this.listView2.SelectedItems[i].Tag);
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals((string)this.listView2.SelectedItems[i].Tag))
- {
- this.tempDataModel.Remove(model);
- break;
- }
- }
- this.listView2.Items.RemoveAt(selectIndex);
- }
- if (this.listView2.Items.Count == 0)
- {
- this.dataGridView1.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- }
- else
- RefreshDataGridView4();
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
- {
- this.RefreshDataGridView4();
- }
- /// <summary>
- /// 生成报告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_generateReport_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.checkBox_generateReport_opensetting.Checked)
- this.button_setting.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.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>>();
- analysisContent.Add(contentHead);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHead.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- bitList.Add(kv.Value[0]);
- bitList.Add(kv.Value[1]);
- }
- }
- else
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- foreach (ListViewItem item in this.listView2.SelectedItems)
- {
- if (bitDic.ContainsKey(item.Name))
- {
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- else if (this.listView2.Items.Count > 0)//###
- {
- ListViewItem item = this.listView2.Items[0];
- if (bitDic.ContainsKey(item.Name))
- {
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- }
- }
|