1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515 |
- using OpenCvSharp;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Instrument;
- using System;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
- using PaintDotNet.Base.DedicatedAnalysis.GrainSize;
- using Metis.ParameterSet;
- using PaintDotNet.Data.Param;
- using PaintDotNet.Base;
- using System.IO;
- using OpenCvSharp.Extensions;
- using PaintDotNet.Base.SettingModel;
- namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard
- {
- internal class GrainSizeStandardDialog : PdnBaseForm
- {
- /// <summary>
- /// 晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)
- /// </summary>
- private int grainMethodType = -1;
- /// <summary>
- /// 晶粒度标准集成
- /// </summary>
- protected GrainSizeStandardClass GSSClass = new GrainSizeStandardClass();
- #region 内部属性
- /// <summary>
- /// 主控件
- /// </summary>
- protected AppWorkspace appWorkspace;
- /// <summary>
- /// 平均截距
- /// </summary>
- private double value_111 = -1;
- /// <summary>
- /// 二值化集成
- /// </summary>
- protected BinaryClass binaryClass;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 图像面板
- /// </summary>
- protected DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- protected Mat imageMat;
- /// <summary>
- /// 相0的图片,处理多视场使用
- /// </summary>
- protected Mat PhaseModel0Mat
- {
- get
- {
- if (binaryClass.PhaseModels0Mat != null)
- return binaryClass.PhaseModels0Mat;
- return this.documentWorkspace.PhaseModels[0].mat;
- }
- }
- /// <summary>
- /// 防止进入页面时错误提示辅助线选项信息
- /// </summary>
- public bool comboboxChange = true;
- /// <summary>
- /// 当前选择图片的Index
- /// </summary>
- protected int selectPicture = -1;
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsFormGrid;
- private Panel panelC;
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- private 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> dataTable_Totals = new List<System.Data.DataTable>();
- /// <summary>
- /// GBT6394面积法 分析结果暂存 -视场面积(Dictionary<string, object>的key为"RectArea")
- /// </summary>
- private Dictionary<string, Dictionary<string, object>> dict_Totals = new Dictionary<string, Dictionary<string, object>>();
- /// <summary>
- /// 详细分析结果暂存
- /// </summary>
- protected List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 全部显示
- /// </summary>
- protected bool allShow = false;
- /// <summary>
- /// 详细列表需要求和的index集合
- /// </summary>
- protected List<int> IndexChangedFromIndex = new List<int>();
- /// <summary>
- /// 列表需要求和的index集合,value值为:1 求和 2:平均 3:级别计算 + [输入数据index位置,-1则需要调用自定义方法进行计算]
- /// </summary>
- protected Dictionary<int, int[]> IndexChangedToIndex = new Dictionary<int, int[]>();
- /// <summary>
- /// 详细列表不需要格式化的字符串数据
- /// </summary>
- protected List<int> DetailListStringIndex = new List<int>();
- /// <summary>
- /// 详细列表不需要按double排序的字符串数据
- /// </summary>
- protected List<int> DetailListNotDoubleIndex = new List<int>();
- /// <summary>
- /// 为了解决标题文字相同的标准,只能使用name赋值每列的数据
- /// </summary>
- protected bool HeaderTextUsable = true;
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- /// <summary>
- /// 数值大于0,则窗口初始化数据完成
- /// </summary>
- private int finishedLoadAction = -1;
- /// <summary>
- /// 当前菜单的唯一id
- /// </summary>
- private int menuId;
- private string menuName;
- /// <summary>
- /// 保存窗口参数
- /// </summary>
- private GrainSizeAnalysisModel analysisModel;
- /// <summary>
- /// 保存所有窗口的参数
- /// </summary>
- private Dictionary<string, GrainSizeAnalysisModel> analysisDict = new Dictionary<string, GrainSizeAnalysisModel>();
- /// <summary>
- /// 应用到全部之前,记住当前选择的窗口
- /// </summary>
- private int currentOldSelectIndex = -1;
- /// <summary>
- /// 晶界重现-保存所有窗口的参数 应用则计算,不应用则清空Mat。应用到全部则提前清空Mat和Model
- /// </summary>
- private Dictionary<string, Base.SettingModel.GrainBoundryDectModel> grainBoundaryDict = new Dictionary<string, Base.SettingModel.GrainBoundryDectModel>();
- /// <summary>
- /// 晶界重现-保存所有窗口的计算结果 应用则计算,不应用则清空
- /// </summary>
- protected Dictionary<string, Mat> grainBoundaryMatDict = new Dictionary<string, Mat>();
- protected Dictionary<string, Mat> everyImgPhaseDict = new Dictionary<string, Mat>();
- /// <summary>
- /// 面积法晶界颜色-保存所有窗口的计算结果 保存结果时一起保存,重新保存则替换
- /// </summary>
- protected Dictionary<string, Mat> grainColorsMatDict = new Dictionary<string, Mat>();
- //private Dictionary<string, Color> grainBoundaryColorDict = new Dictionary<string, Color>();
- //string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
- //bool createNewFile = !System.IO.File.Exists(xmlFilePath);
- // if (createNewFile)
- // return;
- // Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
- //sigma = grainBoundryDectModel.sigma;
- // textBox6.Text = sigma + "";
- // grainApplygrainboundaries = grainBoundryDectModel.grainApplygrainboundaries;
- // this.applyRadioButton1.Checked = (grainApplygrainboundaries == 1);
- // m_iStandardImage = grainBoundryDectModel.m_iStandardImage;
- protected static string ParamKey_displaygrainboundaries = "displaygrainboundaries";//显示晶界
- protected static string ParamKey_displaygrid = "displaygrid";//显示网格
- protected static string ParamKey_displaysections = "displaysections";//显示截点
- protected static string ParamKey_comboBox1SelectedItem = "comboBox1SelectedItem";//选择的辅助线
- protected static string ParamKey_ShowGrainNumber = "ShowGrainNumber";//显示晶粒编号
- protected static string ParamKey_ShowGrainColor = "ShowGrainColor";//用不同颜色显示晶粒
- protected static string ParamKey_CalculatorDecimalDigits = "CalculatorDecimalDigits";//小数点位数
- protected static string ParamKey_OpenWhileExportReport = "OpenWhileExportReport";//生成报告时打开设置//#22009 22010
- protected static string ParamKey_TargetSelection = "TargetSelection";//目标选择
- #endregion
- #region 组件
- private GroupBox groupBox_operating;
- protected GroupBox groupBox_img;
- protected 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 Button button_setting;
- private CheckBox checkBox_generateReport_opensetting;
- protected GroupBox groupBox3;
- private Button button9;
- protected ComboBox comboBox1;
- protected DataGridView dataGridView2;
- protected ListView listView2;
- private Button button16;
- private Button button12;
- private Button button11;
- private NumericUpDown numericUpDown1_0;
- private Button button1;
- private BinaryControlSmaller bc;
- protected DataGridView dataGridView_Total;
- protected Button btn_saveresult;
- protected Button button_ApplyToAll;
- protected Button button_SaveAll;
- private Button threeDButton;
- protected Button btn_Grainboundarytoreproduce;
- private Base.SettingModel.GrainBoundryDectModel GrainBoundryDectModel;
- private Mat OrgImg0;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="appWorkspace"></param>
- /// <param name="grainMethodType">晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)</param>
- public GrainSizeStandardDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem, MethodOfAssessment methodOfAssessment, int grainMethodType = 1)
- {
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- this.appWorkspace = appWorkspace;
- this.Icon = PdnInfo.AppIcon;
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
- if (GSSClass.InitDialogMethod(methodOfAssessment))
- {
- this.grainMethodType = grainMethodType;
- SetAnalyzeModelFromXml(GSSClass.methodOfAssessment.resourcesName);
- }
- else
- {
- this.grainMethodType = grainMethodType;
- if (!GSSClass.InitComboboxValue())
- {
- if (grainMethodType == 1)
- GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
- else if (grainMethodType == 0)
- GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
- }
- SetAnalyzeModelFromXml(getTemplateName());
- }
- InitializeComponent();
- this.binaryClass = new BinaryClass(menuId);
- this.binaryClass.ShowDrawClassView = ShowDrawClassView();
- InitializeLanguageText();
- Initialize();
- SubclassInitialize();
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null && (int)appWorkspace.ScriptCurrentParam.MenuId == menuId)
- {
- this.initScriptValues = true;//ScriptAutomatic
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- //获取晶界重现参数
- getBinary(arg.Key, arg.Value);
- }
- this.analysisModel = GrainSizeAnalysisModel.cloneListParamScript(param);
- foreach (var item in this.analysisModel.ListParam)
- item.setValue();
- getSonData();
- if (this.GrainBoundryDectModel != null) {
- string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
- string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainBoundryDectModel>(this.GrainBoundryDectModel);
- FileOperationHelper.WriteStringToFile(userInfoXml, xmlFilePath, FileMode.Create);
- this.applyDect();
- }
- }
- else
- {//读取上次关闭窗口时保存的参数
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
- foreach (var item in this.analysisModel.ListParam)
- item.setValue();
- }
- //初始化头
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = "";
- header0.Width = 180;
- this.listView2.Columns.Add(header0);
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItemsSmaller(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);//初始化相的工作结构
- //如果是脚本执行,将参数带入二值化集成2 之后:
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- //InitComboboxValue(null);
- this.button11.Visible = true;
- this.button16.Visible = false;
- this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
- }
- #region [晶界重现-脚本相关]
- /// <summary>
- /// 脚本获取晶界重现参数
- /// </summary>
- private void getBinary(string key, Object value)
- {
- GrainBoundryDectModel = new Base.SettingModel.GrainBoundryDectModel();
- switch (key)
- {
- case "GrainApplygrainboundaries":
- GrainBoundryDectModel.grainApplygrainboundaries = Convert.ToInt32(value);
- break;
- case "lineColor":
- GrainBoundryDectModel.grainColor = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_0":
- GrainBoundryDectModel.m_AdOutParam_0 = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_1":
- GrainBoundryDectModel.m_AdOutParam_1 = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_2":
- GrainBoundryDectModel.m_AdOutParam_2 = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_3":
- GrainBoundryDectModel.m_AdOutParam_3 = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_4":
- GrainBoundryDectModel.m_AdOutParam_4 = Convert.ToInt32(value);
- break;
- case "GrainAdOutParam_5":
- GrainBoundryDectModel.m_AdOutParam_5 = Convert.ToDouble(value);
- break;
- case "GrainAdOutParam_6":
- GrainBoundryDectModel.m_AdOutParam_6 = Convert.ToInt32(value);
- break;
- }
- }
- private void applyDect()
- {
- if (this.documentWorkspace.PhaseModels.Count == 0) return;
- Mat PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
- double adOutParam_5 = this.GrainBoundryDectModel.m_AdOutParam_5;
- int grainApplygrainboundaries = this.GrainBoundryDectModel.grainApplygrainboundaries;
- int adOutParam_0 = this.GrainBoundryDectModel.m_AdOutParam_0;
- int adOutParam_1 = this.GrainBoundryDectModel.m_AdOutParam_1;
- double adOutParam_2 = this.GrainBoundryDectModel.m_AdOutParam_2;
- double adOutParam_3 = this.GrainBoundryDectModel.m_AdOutParam_3;
- int adOutParam_4 = this.GrainBoundryDectModel.m_AdOutParam_4;
- int adOutParam_6 = this.GrainBoundryDectModel.m_AdOutParam_6;
- procClass = new ProgressThreadProcClass();
- procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
- if (OrgImg0 != null)
- {
- if (this.documentWorkspace.GraphicsList.IsExsitView() && ShowDrawClassView())
- {
- Vec4b vec4 = new Vec4b(0, 0, 0, 0);
- //视场图像
- Mat exsitViewMatOrg = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion());
- for (int y = 0; y < exsitViewMatOrg/*temp*/.Rows; y++)
- {
- for (int x = 0; x < exsitViewMatOrg/*temp*/.Cols; x++)
- {
- if (exsitViewMatOrg.At<Vec4b>(y, x).Item3 == 0)
- OrgImg0.Set(y, x, vec4);//不在视场图像范围内
- }
- }
- }
- this.documentWorkspace.PhaseModels[0].mat = OrgImg0.Clone();
- this.documentWorkspace.Refresh();
- if (PhaseModel0MatCopy != null)
- {
- PhaseModel0MatCopy.Dispose();
- PhaseModel0MatCopy = null;
- }
- PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
- //this.resetOperationsAction();
- OrgImg0.Dispose();/* //待测试是否有用 */ OrgImg0 = null;
- }
- }
- #endregion
- private void ShownChoiseItemAndInitData(object sender, EventArgs e)
- {
- //二值化集成3
- this.binaryClass.loadParams();
- this.binaryClass.guideClass = GSSClass.GuideClass;
- this.binaryClass.comboBox1 = this.comboBox1;
- if (index > -1)
- {
- //滚动到指定的行位置
- if (index >= 0 && index < this.lstView_img.Items.Count)
- this.lstView_img.EnsureVisible(index); //选中行 //##21319
- if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected || this.lstView_img.SelectedItems != null && this.lstView_img.SelectedItems.Count > 0)
- {
- if (this.selectPicture == index/*this.lstView_img.FocusedItem.Index*/)
- return;
- this.imageMat = this.appWorkspace.DocumentWorkspaces[index/*this.lstView_img.FocusedItem.Index*/].CompositionSurface.CreatedAliasedMat();
- //二值化集成4
- //if (!is###OtherGrainSizeStandardDialog)
- {
- if (ShowDrawClassView())
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
- else
- binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.imageMat.Clone(), getCurrentWorkTag());
- this.bcOriginCheckedChanged(null, null);
- }
- if (!this.analysisDict.ContainsKey(getCurrentWorkTag()))
- this.analysisDict.Add(getCurrentWorkTag(), this.analysisModel/*.cloneListParamModel(this.menuId)*/);
- else
- this.analysisDict[getCurrentWorkTag()] = this.analysisModel/*.cloneListParamModel(this.menuId)*/;
- //this.analysisModel = this.analysisDict[getCurrentWorkTag()];
- //if (GSSClass.massLabelPointsList != null && GSSClass.massLabelPointsList.Count > 0)
- //{
- // GSSClass.massLabelPointsList.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
- // this.documentWorkspace.Refresh();//######
- //}
- ////if (this.checkBox1.Checked)
- ////{
- //// this.documentWorkspace.PhaseModels[1].choise = true;//#########################
- //// this.applyDect();
- ////}
- this.selectPicture = index;// this.lstView_img.FocusedItem.Index;
- GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- //UpdateGuideStyle(true);//19845
- InitRectangleF(false);
- AddRectangleToRectangleFCaps();
- refreshWhileImgChanged();
- }
- InitComboboxValue(null);
- try
- {
- object ItemStringObject;
- if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject)) {
- try
- {
- this.comboBox1.SelectedIndex = Convert.ToInt32(ItemStringObject);
- }
- catch (Exception)
- {
- this.comboBox1.SelectedItem = (string)ItemStringObject;
- }
- }
- }
- catch (Exception exc)
- {
- System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
- }
- }
- //// 初始化数据
- //Bitmap bitmap = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreateAliasedBitmap();
- //Document document = Document.FromImage(bitmap);
- //this.documentWorkspace.Document = document;
- //this.documentWorkspace.Visible = true;
- //this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
- //this.applyButtonImpl(null, null);
- object ShowGrainBoundry;//#21752
- if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
- this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
- if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
- this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
- ////显示直方图
- //this.histogramControl1.CreateHistogram(this.bitmap, true, 339, 130, 0);
- this.finishedLoadAction++;
- if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
- this.startScriptAutomaticAction();
- }
- /// <summary>
- /// 执行脚本自动化的步骤
- /// </summary>
- private void startScriptAutomaticAction()
- {
- this.button_ApplyToAll.PerformClick();
- this.button_SaveAll.PerformClick();
- for (int j = 0; j < this.listView2.Items.Count; j++)
- this.listView2.Items[j].Selected = true;
- object ItemStringObject;
- if (GetParamValue1("ExportResults", out ItemStringObject)
- && (bool)ItemStringObject)//导出结果
- this.button_exportResults.PerformClick();
- if (GetParamValue1("ExportReports", out ItemStringObject)
- && (bool)ItemStringObject)//生成报告
- this.button_generateReport.PerformClick();
- if (GetParamValue1("ExportProjects", out ItemStringObject)
- && (bool)ItemStringObject)//导出项目
- this.button1.PerformClick();
- //List<Args> dedicatedLists = new List<Args>();
- //IntegerNumber seven = new IntegerNumber(0, 10);
- //seven.key = "CalculatorDecimalDigits";
- //seven.name = "小数点位数";
- //seven.initialValue = 2;
- //seven.value = 2;
- //dedicatedLists.Add(seven);
- //dedicatedLists.Add(new BooleanObject("OpenWhileExportReport", "生成报告时打开设置", true, null));
- //dedicatedLists.Add(new BooleanObject("ExportResults", "导出结果", true, null));
- //dedicatedLists.Add(new BooleanObject("ExportReports", "生成报告", true, null));
- //dedicatedLists.Add(new BooleanObject("ExportProjects", "导出项目", true, null));
- this.appWorkspace.ScriptAutomatic = false;
- this.Close();
- }
- public GrainSizeStandardDialog()
- {
- InitializeComponent();
- }
- #endregion
- #region 初始化组件
- private void InitializeLanguageText()
- {
- //
- // bc
- //
- this.bc = new PaintDotNet.CustomControl.BinaryControlSmaller();
- this.bc.BinaryBackColor = System.Drawing.Color.Red;
- this.bc.BinaryChecked = false;
- this.bc.BinaryStyle = 1;
- this.bc.Location = new System.Drawing.Point(176, 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, 247);
- this.bc.TabIndex = 38;
- this.Controls.Add(this.bc);
- this.Controls.SetChildIndex(this.bc, 0);
- this.button9.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Tools.GridLine.Text");
- this.button11.Text = PdnResources.GetString("Menu.Showall.text");
- this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.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.threeDButton.Text = PdnResources.GetString("Menu.threeD.text");
- this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.btn_Grainboundarytoreproduce.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
- this.button_ApplyToAll.Text = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Applytoall.text");
- this.button_SaveAll.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
- this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
- this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox_operating = new System.Windows.Forms.GroupBox();
- this.button_SaveAll = new System.Windows.Forms.Button();
- this.button_ApplyToAll = new System.Windows.Forms.Button();
- 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.btn_Grainboundarytoreproduce = 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.threeDButton = new System.Windows.Forms.Button();
- 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.dataGridView_Total = new System.Windows.Forms.DataGridView();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- 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.groupBox3 = new System.Windows.Forms.GroupBox();
- this.button9 = new System.Windows.Forms.Button();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- 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.dataGridView_Total)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox_analysisResult1.SuspendLayout();
- this.groupBox3.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.button_SaveAll);
- this.groupBox_operating.Controls.Add(this.button_ApplyToAll);
- 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.Controls.Add(this.btn_Grainboundarytoreproduce);
- 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;
- //
- // button_SaveAll
- //
- this.button_SaveAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button_SaveAll.Location = new System.Drawing.Point(993, 20);
- this.button_SaveAll.Name = "button_SaveAll";
- this.button_SaveAll.Size = new System.Drawing.Size(75, 23);
- this.button_SaveAll.TabIndex = 8;
- this.button_SaveAll.UseVisualStyleBackColor = true;
- this.button_SaveAll.Click += new System.EventHandler(this.button_SaveAll_Click);
- //
- // button_ApplyToAll
- //
- this.button_ApplyToAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button_ApplyToAll.Location = new System.Drawing.Point(751, 20);
- this.button_ApplyToAll.Name = "button_ApplyToAll";
- this.button_ApplyToAll.Size = new System.Drawing.Size(75, 23);
- this.button_ApplyToAll.TabIndex = 7;
- this.button_ApplyToAll.UseVisualStyleBackColor = true;
- this.button_ApplyToAll.Click += new System.EventHandler(this.button_ApplyToAll_Click);
- //
- // 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(912, 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);
- //
- // btn_Grainboundarytoreproduce
- //
- this.btn_Grainboundarytoreproduce.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(832, 20);
- this.btn_Grainboundarytoreproduce.Name = "btn_Grainboundarytoreproduce";
- this.btn_Grainboundarytoreproduce.Size = new System.Drawing.Size(75, 23);
- this.btn_Grainboundarytoreproduce.TabIndex = 2;
- this.btn_Grainboundarytoreproduce.UseVisualStyleBackColor = true;
- this.btn_Grainboundarytoreproduce.Click += new System.EventHandler(this.btn_Grainboundarytoreproduce_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, 502);
- 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, 468);
- 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(541, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(575, 502);
- 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.threeDButton);
- 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, 580);
- 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;
- //
- // threeDButton
- //
- this.threeDButton.Location = new System.Drawing.Point(28, 149);
- this.threeDButton.Name = "threeDButton";
- this.threeDButton.Size = new System.Drawing.Size(75, 23);
- this.threeDButton.TabIndex = 24;
- this.threeDButton.UseVisualStyleBackColor = true;
- this.threeDButton.Click += new System.EventHandler(this.threeDButton_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(29, 112);
- 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, 184);
- 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(26, 188);
- this.label_resultPrecision.Name = "label_resultPrecision";
- this.label_resultPrecision.Size = new System.Drawing.Size(0, 12);
- this.label_resultPrecision.TabIndex = 3;
- //
- // button_exportResults
- //
- this.button_exportResults.Location = new System.Drawing.Point(29, 73);
- 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, 34);
- 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.dataGridView_Total);
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView2);
- this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 580);
- this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
- this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(719, 218);
- this.groupBox6groupBox_analysisResult2.TabIndex = 32;
- this.groupBox6groupBox_analysisResult2.TabStop = false;
- //
- // dataGridView_Total
- //
- this.dataGridView_Total.AllowUserToAddRows = false;
- this.dataGridView_Total.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView_Total.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView_Total.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView_Total.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
- this.dataGridView_Total.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_Total.Location = new System.Drawing.Point(13, 144);
- this.dataGridView_Total.Name = "dataGridView_Total";
- this.dataGridView_Total.ReadOnly = true;
- this.dataGridView_Total.RowHeadersVisible = false;
- this.dataGridView_Total.RowTemplate.Height = 23;
- this.dataGridView_Total.Size = new System.Drawing.Size(693, 68);
- this.dataGridView_Total.TabIndex = 17;
- //
- // 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;
- dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Location = new System.Drawing.Point(13, 12);
- 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, 128);
- this.dataGridView2.TabIndex = 16;
- //
- // 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, 580);
- this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
- this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 218);
- 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(182, 149);
- 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);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.button9);
- this.groupBox3.Controls.Add(this.comboBox1);
- this.groupBox3.Location = new System.Drawing.Point(179, 320);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(355, 48);
- this.groupBox3.TabIndex = 34;
- this.groupBox3.TabStop = false;
- //
- // button9
- //
- this.button9.BackColor = System.Drawing.SystemColors.Control;
- this.button9.Location = new System.Drawing.Point(241, 15);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(92, 26);
- this.button9.TabIndex = 10;
- this.button9.UseVisualStyleBackColor = false;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(15, 18);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(220, 20);
- this.comboBox1.TabIndex = 0;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // GrainSizeStandardDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1127, 810);
- this.Controls.Add(this.groupBox3);
- 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.Name = "GrainSizeStandardDialog";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeStandardDialog_FormClosing);
- this.Load += new System.EventHandler(this.GrainSizeStandardDialog_Load);
- 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.Controls.SetChildIndex(this.groupBox3, 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.dataGridView_Total)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox_analysisResult1.ResumeLayout(false);
- this.groupBox3.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- private void DataGridView2_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
- {
- //DetailListNotDoubleIndex.Add(0); //DetailListNotDoubleIndex.Add(1);
- // 如果是学号或成绩列,则按浮点数处理
- if (DetailListNotDoubleIndex.Count > 0 && !DetailListNotDoubleIndex.Contains(e.Column.Index))
- {
- e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
- }
- //否则,按字符串比较
- else
- {
- e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2));
- }
- e.Handled = true;//不能省掉,不然没效果
- }
- /// <summary>
- /// 选中的左侧list的下标
- /// </summary>
- protected int index = 0;
- 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))
- {
- index = i;
- }
- }
- //
- // 初始化选中的数据
- //
- if (index >= 0 && index < this.lstView_img.Items.Count)
- this.lstView_img.Items[index].Selected = true; //选中行 //##21319
- //
- //初始化图像控件
- //
- 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.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;//禁止视场移动
- 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);
- ////
- //// 初始化选中的数据
- ////
- //this.lstView_img.Items[index].Selected = true; //选中行
- }
- #endregion
- #region 二值化相关方法
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GrainSizeStandardDialog_Load(object sender, EventArgs e)
- {
- this.threeDButton.Enabled = false;
- System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
- this.dataGridView2.SortCompare += DataGridView2_SortCompare;
- if (grainMethodType == 0)
- {
- GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
- AddRectangleToRectangleFCaps();
- }
- ////二值化集成3
- //this.binaryClass.loadParams();
- //this.binaryClass.guideClass = GSSClass.GuideClass;
- //this.binaryClass.comboBox1 = this.comboBox1;
- //object ShowGrainBoundry;//#21752
- //if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
- // this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
- //if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
- // this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
- this.finishedLoadAction++;
- if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
- this.startScriptAutomaticAction();
- }
- private bool bcBinaryChecked()
- {
- return bc != null && bc.BinaryChecked;
- }
- protected bool bcOriginChecked()
- {
- return bc != null && bc.OriginChecked;
- }
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
- this.documentWorkspace.Refresh();
- else//###############################################################
- AddRectangleToRectangleFCaps();
- }
- /// <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;
- if (getGrainBoundryChecked() && ShowGrainBoundryChecked())
- this.documentWorkspace.PhaseModels[1].choise = true;
- if (grainMethodType == 1 && ShowGrainColorChecked())
- this.documentWorkspace.PhaseModels[2].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.PhaseModels[1].choise = false;
- this.documentWorkspace.PhaseModels[2].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- #region 内部方法
- /// <summary>
- /// 设置按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_setting_Click(object sender, EventArgs e)
- {
- string templateName;
- try
- {
- templateName = getTemplateName();
- }
- catch (Exception)
- {
- templateName = GSSClass.methodOfAssessment.resourcesName;
- }
- AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);
- if (metallographicMethodSetDialog.hasModule)
- {
- metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
- metallographicMethodSetDialog.ShowDialog();
- }
- else
- {
- metallographicMethodSetDialog = null;
- }
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_saveresult_Click(object sender, EventArgs e)
- {
- if (this.lstView_img.Items.Count == 0) return;
- GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
- buildListBox_analysisResult(getCurrentWorkTag(), this.selectPicture);
- }
- /// <summary>
- /// 相1的图片,处理多视场使用
- /// </summary>
- protected Mat PhaseModels1Mat;
- protected Color PhaseModels1Color;
- /// <summary>
- /// 晶界重现
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_Grainboundarytoreproduce_Click(object sender, EventArgs e)
- {
- //if (this.documentWorkspace.PhaseModels.Count < 2 || /*this.documentWorkspace.PhaseModels[1].choise == true && */this.documentWorkspace.PhaseModels[1].mat == null)
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
- // return;
- //}
- if (this.imageMat == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- return;
- }
- //1013###19326 晶粒度的晶界编辑页面,需要把辅助线带过去(客户编辑只处理辅助线位置的晶界)
- GrainBoundaryEditingDialog boundaryEditingDialog = new GrainBoundaryEditingDialog(this.appWorkspace, this.menuId, this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index, this.documentWorkspace.PhaseModels[1].mat == null ? Color.Red : PhaseModels1Color/*this.panel1.BackColor*/
- , this.documentWorkspace.PhaseModels[1].mat == null ? null : this.documentWorkspace.PhaseModels[1].mat.Clone(), ShowDrawClassView());
- boundaryEditingDialog.GuideClass = GSSClass.GuideClass;
- boundaryEditingDialog.SelectedItem = this.comboBox1.SelectedItem;
- if (boundaryEditingDialog.ShowDialog() == DialogResult.OK && boundaryEditingDialog.PhaseMat != null)
- {
- string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
- if (System.IO.File.Exists(xmlFilePath))
- {
- Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
- //sigma = grainBoundryDectModel.sigma;
- if (!this.grainBoundaryDict.ContainsKey(getCurrentWorkTag()))
- this.grainBoundaryDict.Add(getCurrentWorkTag(), grainBoundryDectModel.cloneModel());
- else
- this.grainBoundaryDict[getCurrentWorkTag()] = grainBoundryDectModel.cloneModel();
- }
- if (this.grainBoundaryDict[getCurrentWorkTag()].grainApplygrainboundaries != 1)
- {//没有选择应用选项
- if (this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
- {
- this.grainBoundaryMatDict.Remove(getCurrentWorkTag());
- this.documentWorkspace.PhaseModels[1].mat = null;
- if (PhaseModels1Mat != null)
- {
- PhaseModels1Mat.Dispose();
- PhaseModels1Mat = null;
- }
- if (grainMethodType == 1)
- if (GetClassNumberOfGrains() == 0)
- this.documentWorkspace.Refresh();
- else
- AddRectangleToRectangleFCaps();
- this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
- //this.documentWorkspace.Refresh();
- if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
- this.documentWorkspace.Refresh();
- else//###############################################################//#20991
- AddRectangleToRectangleFCaps();
- }
- return;
- }
- PhaseModels1Color = boundaryEditingDialog.PhaseColor;
- if (PhaseModels1Mat != null)
- {
- PhaseModels1Mat.Dispose();
- PhaseModels1Mat = null;
- }
- if (getCurrentWorkspace().GraphicsList.IsExsitView())
- PhaseModels1Mat = boundaryEditingDialog.PhaseMat.Clone();
- this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
- if (!this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
- this.grainBoundaryMatDict.Add(getCurrentWorkTag(), boundaryEditingDialog.PhaseMat.Clone());
- else
- this.grainBoundaryMatDict[getCurrentWorkTag()] = boundaryEditingDialog.PhaseMat.Clone();
- //if (grainMethodType == 1)
- // if (GetClassNumberOfGrains() == 0)
- // this.documentWorkspace.Refresh();
- // else
- // AddRectangleToRectangleFCaps();
- this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
- if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
- this.documentWorkspace.Refresh();
- else//###############################################################//#20991
- AddRectangleToRectangleFCaps();
- this.documentWorkspace.Refresh();
- }
- }
- private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
- {
- if (this.selectPicture == this.lstView_img.FocusedItem.Index)
- return;
- this.refreshActionWhileImg_SelectedIndexChanged(false);
- }
- }
- /// <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>>();
- List<string> contentHeaderText2 = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- contentHeaderText2.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText2);
- foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText2.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- List<string> contentHeaderText = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- contentHeaderText.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)//################################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- List<string> pNamesList = new List<string>();
- //中间数据
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- int cal_Index = int.Parse(kv.Key.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- 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))
- {
- int cal_Index = int.Parse(item.Name.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- 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))
- {
- int cal_Index = int.Parse(rowItem.Name.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- bitList.Add(bitDic[rowItem.Name][0]);
- bitList.Add(bitDic[rowItem.Name][1]);
- }
- else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
- {
- int cal_Index = int.Parse(rowItem.Tag.ToString().Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- 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;
- }
- }
- }
- }
- string dictPath = Application.StartupPath + "\\temp";
- if (!System.IO.Directory.Exists(dictPath))
- {
- System.IO.Directory.CreateDirectory(dictPath);
- }
- DeleteFolder(dictPath);
- pNames = new Dictionary<string, string>();
- int insertIn = 0;
- for (int k = 0; k < bitList.Count; k += 2)
- {//保存处理后的图片
- List<Bitmap> tempBit = new List<Bitmap>();
- tempBit.Add((Bitmap)bitList[k].Clone());
- tempBit.Add((Bitmap)bitList[k+1].Clone());
- this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
- insertIn++;
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code, dictPath, pNames);
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- Dictionary<string, string> pNames = new Dictionary<string, string>();
- /// <summary>
- /// 保存图片到本地
- /// </summary>
- /// <param name="bitList"></param>
- private void SaveAllImage(List<Bitmap> bitList, string newPath, int originNum, int codeNum, string pName)
- {
- if (bitList != null && bitList.Count > 0)
- {
- for (int i = 0; i < bitList.Count; i++)
- {
- string bitPath = "";
- //分别为原图和处理后的图命名
- if (i % 2 == 0)
- {
- bitPath = newPath + "/" + "origin" + originNum + ".jpg";
- pNames.Add("origin" + originNum, pName);
- }
- else
- {
- bitPath = newPath + "/" + codeNum + ".jpg";
- pNames.Add(codeNum.ToString(), pName);
- }
- bitList[i].Save(bitPath);
- }
- }
- }
- public void DeleteFolder(string path)
- {
- foreach (string d in Directory.GetFileSystemEntries(path))
- {
- if (System.IO.File.Exists(d))
- {
- FileInfo fi = new FileInfo(d);
- if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
- fi.Attributes = FileAttributes.Normal;
- System.IO.File.Delete(d);//直接删除其中的文件
- }
- else
- {
- DirectoryInfo d1 = new DirectoryInfo(d);
- if (d1.GetFiles().Length != 0)
- {
- DeleteFolder(d1.FullName);
- }
- Directory.Delete(d);
- }
- }
- }
- /// <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)
- {
- List<System.Data.DataTable> list = new List<System.Data.DataTable>();
- System.Data.DataTable table1 = new System.Data.DataTable();
- table1.TableName = PdnResources.GetString("Menu.breakdown.text");
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- table1.Columns.Add(HeaderTextUsable ? c.HeaderText : c.Name);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = table1.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[HeaderTextUsable ? this.dataGridView2.Columns[c].HeaderText : this.dataGridView2.Columns[c].Name] = 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[HeaderTextUsable ? this.dataGridView2.Columns[c].HeaderText : this.dataGridView2.Columns[c].Name] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- table1.Rows.Add(dataRow);
- }
- System.Data.DataTable table2 = new System.Data.DataTable();
- table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- table2.Columns.Add(HeaderTextUsable ? c.HeaderText : c.Name);
- }
- for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = table2.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- {
- dataRow[HeaderTextUsable ? this.dataGridView_Total.Columns[c].HeaderText : this.dataGridView_Total.Columns[c].Name] = this.dataGridView_Total.Columns[c].HeaderText;
- }
- table2.Rows.Add(dataRow);
- }
- dataRow = table2.NewRow();
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- {
- dataRow[HeaderTextUsable ? this.dataGridView_Total.Columns[c].HeaderText : this.dataGridView_Total.Columns[c].Name] = this.dataGridView_Total.Rows[r].Cells[c].Value;
- }
- table2.Rows.Add(dataRow);
- }
- if (table2.Rows.Count > 0) list.Add(table2);
- if (table1.Rows.Count > 0) list.Add(table1);
- if (list.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 = this.Text + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
- saveFileDialog.RestoreDirectory = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, HeaderTextUsable, false, true);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
- }
- /// <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);
- }
- /// <summary>
- /// 计算汇总列表的平均晶粒度级别
- /// </summary>
- /// <returns></returns>
- protected virtual string getGradeTotalCal(DataGridViewRow dgvr, int digits = -1)
- {
- return "00A";
- }
- /// <summary>
- /// 取消全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button16_Click(object sender, EventArgs e)
- {
- this.button11.Visible = true;
- this.button16.Visible = false;
- this.button11.Focus();
- this.allShow = false;
- this.dataGridView2.Rows.Clear();
- if (this.listView2.SelectedItems.Count <= 0)
- {
- if (this.listView2.Items.Count > 0)
- {
- this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
- }
- else
- {
- return;
- }
- }
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;
- double small_l = 0;
- 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;
- for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- else
- {
- if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
- {
- dataTable1 = dataTable;
- for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- this.dataGridView_Total.Rows.Clear();
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = valueL.Average().ToString();
- else if (itemValue[0] == 3)//级别
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));//############
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- this.RefreshDataGridView4();
- return;
- }
- double grainNumber = 0;
- if (getGbtType() == 3)
- value_1 = 0;
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTable_Totals)
- {
- 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;
- }
- }
- grainNumber += double.Parse(dataTable1.Rows[0][grainMethodType == 1 ? 0 : 1].ToString());
- if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 += (double)valuePairs["RectArea"];
- }
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- else
- {
- dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- dgvr.Cells[2].Value = small_l.ToString();
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
- else
- dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- if (grainMethodType == 1)
- {
- if (dgvr.Cells.Count > 4)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- dgvr.Cells[4].Value = value_1.ToString();
- value_1 = value_1 * 0.001 * 0.001;
- }
- if (dgvr.Cells.Count > 5)
- {
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
- else
- dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- }
- //##
- this.RefreshDataGridView4();
- }
- /// <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;
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;
- double small_l = 0;
- 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[i].Tag.Equals(dataTable.TableName))
- {
- dataTable1 = dataTable;
- for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- this.dataGridView_Total.Rows.Clear();
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = valueL.Average().ToString();
- else if (itemValue[0] == 3)//级别
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- this.RefreshDataGridView4();
- return;
- }
- double grainNumber = 0;
- if (getGbtType() == 3)
- value_1 = 0;
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTable_Totals)
- {
- if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 += (double)valuePairs["RectArea"];
- }
- grainNumber += double.Parse(dataTable1.Rows[0][grainMethodType == 1 ? 0 : 1].ToString());//###21939
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- else
- {
- dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- dgvr.Cells[2].Value = small_l.ToString();
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
- else
- dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- if (grainMethodType == 1)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- if (dgvr.Cells.Count > 4)
- {
- dgvr.Cells[4].Value = value_1.ToString();
- value_1 = value_1 * 0.001 * 0.001;
- }
- if (dgvr.Cells.Count > 5)
- {
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
- else
- dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- }
- }
- this.dataGridView_Total.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;
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;
- double small_l = 0;
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- for (int rIndex = 0; rIndex < this.dataTables[i].Rows.Count; rIndex++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
- {
- dgvr.Cells[c].Value = this.dataTables[i].Rows[rIndex][c].ToString();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(this.dataTables[i].Rows[rIndex][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- this.dataGridView_Total.Rows.Clear();
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = valueL.Average().ToString();
- else if (itemValue[0] == 3)//级别
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- this.RefreshDataGridView4();
- return;
- }
- double grainNumber = 0;
- for (int i = 0; i < this.dataTable_Totals.Count; i++)
- {
- grainNumber += double.Parse(this.dataTable_Totals[i].Rows[0][grainMethodType == 1 ? 0 : 1].ToString());
- }
- if (getGbtType() == 3)
- value_1 = 0;
- for (int j = 0; j < this.listView2.Items.Count; j++)
- {
- if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 += (double)valuePairs["RectArea"];
- }
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- else
- {
- dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- dgvr.Cells[2].Value = small_l.ToString();
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
- else
- dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- if (grainMethodType == 1)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- if (dgvr.Cells.Count >= 5)
- {
- dgvr.Cells[4].Value = value_1.ToString();
- value_1 = value_1 * 0.001 * 0.001;
- }
- if (dgvr.Cells.Count >= 6)
- {
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
- else
- dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
- }
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 分析结果删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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.dataTable_Totals)
- {
- if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
- {
- this.dataTable_Totals.Remove(dataTable);
- break;
- }
- }
- if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
- this.dict_Totals.Remove(this.listView2.SelectedItems[i].Tag.ToString());
- for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
- {
- System.Data.DataTable dataTable1 = dataTables[dataTableI];
- if (dataTable1.TableName.Equals(this.listView2.SelectedItems[i].Tag/*tag*/))
- dataTables.RemoveAt(dataTableI);
- }
- 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.dataGridView_Total.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- this.threeDButton.Enabled = false;
- }
- else
- RefreshDataGridView4();
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 小数位数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
- {
- this.RefreshDataGridView4();
- this.RefreshWhileUpDown1_0ValueChanged();
- }
- /// <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<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- if (this.allShow)
- {
- //中间数据
- 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 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];
- //中间数据
- 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;
- }
- }
- }
- }
- int exportModelIndex = 0;
- //详细数据
- List<List<string>> analysisContent2;
- if (grainMethodType == 1 || tempDataModel == null || tempDataModel.Count == 0)
- analysisContent2 = null;
- else
- {
- analysisContent2 = new List<List<string>>();
- List<string> columnName2 = new List<string>();
- columnName2.Add(PdnResources.GetString("Menu.picture.Text"));
- columnName2.AddRange(exportModel[0].dataList[0]);
- analysisContent2.Add(columnName2);
- foreach (var tempData in exportModel)
- {
- List<List<string>> dataList = tempData.dataList;
- for (int k = 1; k < dataList.Count; k++)
- {
- List<string> strList = new List<string>();
- strList.Add(tempData.picName);
- strList.AddRange(dataList[k]);
- strList[1] = (++exportModelIndex).ToString();
- analysisContent2.Add(strList);
- }
- }
- }
- //分析结果
- List<List<string>> analysisContent = new List<List<string>>();
- List<string> contentHeaderText2 = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- contentHeaderText2.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText2);
- foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText2.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- List<string> contentHeaderText = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- contentHeaderText.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)//##########################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- List<string> pNamesList = new List<string>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- int cal_Index = int.Parse(kv.Key.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- 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))
- {
- int cal_Index = int.Parse(item.Name.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- 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))
- {
- int cal_Index = int.Parse(item.Name.Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- pNamesList.Add(imgName);
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- string dictPath = Application.StartupPath + "\\temp";
- if (!System.IO.Directory.Exists(dictPath))
- {
- System.IO.Directory.CreateDirectory(dictPath);
- }
- DeleteFolder(dictPath);
- pNames = new Dictionary<string, string>();
- int insertIn = 0;
- for (int k = 0; k < bitList.Count; k += 2)
- {//保存处理后的图片
- List<Bitmap> tempBit = new List<Bitmap>();
- tempBit.Add((Bitmap)bitList[k].Clone());
- tempBit.Add((Bitmap)bitList[k + 1].Clone());
- this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
- insertIn++;
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos, dictPath, pNames, analysisContent2);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- /// <summary>
- /// 切换辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- comboBox1SelectedItem = comboBox1.SelectedItem;
- if (GSSClass.GuideClass.guideModel != null)
- GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
- if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- if (this.imageMat == null)
- {
- int oldSelectIndex = -1;
- for (int i = 0; i < this.comboBox1.Items.Count; i++)
- {
- if (GSSClass.GuideClass.guideModel.oldSelectItem != null && GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
- {
- oldSelectIndex = i;
- }
- }
- if (this.comboBox1.SelectedIndex > 0)
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- if (oldSelectIndex > -1)
- {
- if (this.comboBox1.SelectedIndex != oldSelectIndex)
- this.comboBox1.SelectedIndex = oldSelectIndex;
- }
- else if (this.comboBox1.Items.Count > 0)
- this.comboBox1.SelectedIndex = 0;
- return;
- }
- UpdateGuideStyle(true && !(this.initScriptValues && this.appWorkspace.ScriptAutomatic));
- if (this.imageMat != null)
- {
- if (this.comboboxChange)
- {
- GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- }
- InitRectangleF(true);
- this.comboboxChange = true;
- }
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 辅助线设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.imageMat == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
- GrainGuideSettingsDialog grainGuideStyleSettingsDialog = new GrainGuideSettingsDialog(grainMethodType == 1 ? 1 : 0, GSSClass.methodOfAssessment != null ? GSSClass.methodOfAssessment.guideXmlName : getModelName(), getTypeNames(), this.imageMat/*.Clone()*/, this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index
- ].GetRuler(MeasurementUnit.Micron));
- grainGuideStyleSettingsDialog.StartPosition = FormStartPosition.CenterScreen;
- grainGuideStyleSettingsDialog.ShowDialog(this);
- }
- /// <summary>
- /// 返回小数点位数的数值
- /// </summary>
- /// <returns></returns>
- protected int getNumericUpDown1Value()
- {
- return Convert.ToInt32(this.numericUpDown1_0.Value);
- }
- /// <summary>
- /// 刷新晶粒编号/刷新晶粒颜色?//############
- /// </summary>
- /// <param name="pointFs"></param>
- /// <param name="rectangleF"></param>
- /// <returns>返回晶粒个数</returns>
- protected virtual double GetClassNumberOfGrains()
- {
- return 0.0;
- }
- /// <summary>
- /// 颜色点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void panel1_1_Click(object sender, EventArgs e)
- {
- this.panelC = (Panel)sender;
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
- this.colorsFormGrid.ShowDialog();
- }
- /// <summary>
- /// PanelC的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gridColorChanged(object sender, EventArgs e)
- {
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- if (this.panelC != null)
- {
- this.panelC.BackColor = color;
- this.ColorPanelChanged(this.panelC);
- this.panelC = null;
- }
- //关闭色板
- this.colorsFormGrid.Close();
- }
- #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
- #region 辅助线拖动
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- protected virtual void OnMouseDown(object sender, MouseEventArgs e)
- {
- if (grainMethodType == 1)
- {
- if (this.documentWorkspace.CompositionSurface == null)
- return;
- // 换算后的点
- PointF pointArea = documentWorkspace.GetScalePoint(e.Location);
- //辅助线缩放
- GSSClass.GuideClass.OnMouseDown(pointArea, sender, e);
- //辅助线移动
- if (e.Button == MouseButtons.Left && e.Clicks == 1)
- {
- if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(pointArea))
- {
- GSSClass.GuideClass.m_canMove = true;
- GSSClass.GuideClass.m_StartPoint = pointArea;
- }
- }
- return;
- }
- // 换算后的点
- PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- if (e.Button == MouseButtons.Left && e.Clicks == 1)
- {
- if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(point1))
- {
- GSSClass.GuideClass.m_canMove = true;
- GSSClass.GuideClass.m_StartPoint = point1;
- }
- }
- }
- /// <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 (grainMethodType == 0 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron))
- || grainMethodType == 1 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseAreaMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)))// 矩形缩放
- {//缩放
- GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
- this.AddRectangleToRectangleFCaps();
- this.documentWorkspace.Refresh();
- }
- else if (e.Button == MouseButtons.Left && GSSClass.GuideClass.m_canMove)
- {//移动
- //限制辅助线移动不能拖到图像外面
- PointF m222_StartPoint = new PointF(point1.X, point1.Y);
- double minX = GSSClass.GuideClass.m_StartPoint.X - GSSClass.GuideClass.guideModel.rectangleFLine.X;
- if (point1.X < minX)
- point1.X = (float)minX;
- double maxX = GSSClass.GuideClass.m_StartPoint.X + this.documentWorkspace.CompositionSurface.Width - GSSClass.GuideClass.guideModel.RectangleFLine.Right;
- if (point1.X > maxX)
- point1.X = (float)maxX;
- double minY = GSSClass.GuideClass.m_StartPoint.Y - GSSClass.GuideClass.guideModel.rectangleFLine.Y;
- if (point1.Y < minY)
- point1.Y = (float)minY;
- double maxY = GSSClass.GuideClass.m_StartPoint.Y + this.documentWorkspace.CompositionSurface.Height - GSSClass.GuideClass.guideModel.RectangleFLine.Bottom;
- if (point1.Y > maxY)
- point1.Y = (float)maxY;
- float offsetX = point1.X - GSSClass.GuideClass.m_StartPoint.X;
- float offsetY = point1.Y - GSSClass.GuideClass.m_StartPoint.Y;
- // 矩形偏移
- GSSClass.GuideClass.guideModel.rectangleFLine.Offset(offsetX, offsetY);
- GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
- GSSClass.GuideClass.m_StartPoint = m222_StartPoint;
- if (grainMethodType == 0 && !(!getGrainBoundryChecked() && !getBinaryChecked()))
- //##21247
- this.AddRectangleToRectangleFCaps();
- else if (grainMethodType == 0)
- {
- //##21247
- this.MoveOriginCutOffPoints(offsetX, offsetY);
- }
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void onMouseUp(object sender, MouseEventArgs e)
- {
- GSSClass.GuideClass.m_canMove = false;
- GSSClass.GuideClass.onMouseUp(sender, e);
- }
- #endregion
- #endregion
- #region 可调用方法
- /// <summary>
- /// 是否显示原图
- /// </summary>
- /// <returns></returns>
- protected Boolean showOrimat()
- {
- return bcOriginChecked();
- }
- /// <summary>
- /// 获取小数点保留位数的显示字符串
- /// </summary>
- /// <param name="doubleValue"></param>
- /// <returns></returns>
- protected string DecnumString(string doubleValue)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(doubleValue) ? "0" : doubleValue, out outValue))
- {
- return Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- return doubleValue;
- }
- /// <summary>
- /// 设置晶粒颜色
- /// </summary>
- protected void ShowGrainColorSettingDialog()
- {
- GrainColorSetting colorSettings = new GrainColorSetting(/*isAreaType ? 1 : 0, getModelName(), getTypeNames(), this.bitmap*/);
- colorSettings.StartPosition = FormStartPosition.CenterScreen;
- //colorSettings.ShowDialog(this)
- if (colorSettings.ShowDialog() == DialogResult.OK)
- {
- //获取设置颜色的集合,按照等级从小到大排序
- List<OpenCvSharp.Vec4b> colorOfGrades = colorSettings.getColorOfGrades();
- GSSClass.setColorOfGrades.Clear();
- GSSClass.setColorOfGrades.AddRange(colorOfGrades);
- setMat2ColorOfLabelMat(-1);
- };
- }
- /// <summary>
- /// 设置截点样式
- /// </summary>
- protected void ShowGrainSurveyPointStyleSettingDialog()
- {
- GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSurveyPointStyleSettingDialog();//###
- grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
- grainSurveyPointStyleSettingDialog.ShowDialog(this);
- }
- /// <summary>
- /// 根据等级设置晶粒颜色
- /// </summary>
- /// <param name="nccomps">连通域数量</param>
- private void setMat2ColorOfLabelMat(int nccomps)
- {
- Mat temp = GSSClass.getMat2ColorOfLabelMat(GSSClass.standardModel, nccomps, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
- if (temp != null)
- {
- if (grainMethodType == 1)
- {
- if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
- this.grainColorsMatDict[getCurrentWorkTag()] = temp.Clone();
- else
- this.grainColorsMatDict.Add(getCurrentWorkTag(), temp.Clone());
- }
- this.documentWorkspace.PhaseModels[2].mat = temp;
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 更新截点样式
- /// </summary>
- public void UpdateCupOffPointStyle()
- {
- GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
- AddRectangleToRectangleFCaps();
- }
- /// <summary>
- /// 刷新分析结果数据
- /// </summary>
- protected virtual void RefreshDataGridView4()
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;//面积法(汇总面积)、截点法(截点总数)
- double small_l = 0;//面积法(汇总截距)、截点法(网格总长度)
- this.dataGridView2.Rows.Clear();
- for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
- {
- for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
- {
- if (this.dataTables[dataTableIndex].TableName.Equals(this.listView2.SelectedItems[j].Tag))
- {
- 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);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
- {
- 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();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
- continue;
- }
- if (c == 3/*isAreaType && c == 3 || !isAreaType && c == 3*/)
- value_1 += outValue;
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += outValue;
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- this.dataGridView_Total.Rows.Clear();
- value_111 = -1;
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 3)//级别
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- return;
- }
- double grainNumber = 0;
- if (getGbtType() == 3)
- value_1 = 0;
- for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
- {
- int dataTableIndex = 0;
- for (int i = 0; i < this.dataTable_Totals.Count; i++)
- {
- if (this.dataTable_Totals[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
- dataTableIndex = i;
- }
- if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
- {
- grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
- }
- }
- if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[j].Tag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.SelectedItems[j].Tag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 += (double)valuePairs["RectArea"];
- }
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- {
- dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
- value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
- if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
- {
- RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
- //return;
- }
- if (grainMethodType == 1)
- {
- if (dgvr.Cells.Count > 4)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- value_1 = value_1 * 0.001 * 0.001;
- }
- if (dgvr.Cells.Count > 5)
- {
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- }
- }
- else if (this.listView2.Items.Count > 0)
- {
- var firstTag = this.listView2.Items[0].Tag;
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;
- double small_l = 0;
- this.dataGridView2.Rows.Clear();
- for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
- {
- if (this.dataTables[dataTableIndex].TableName.Equals(firstTag))
- {
- 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);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
- {
- 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();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += outValue;
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += outValue;
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- this.dataGridView_Total.Rows.Clear();
- value_111 = -1;
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 3)//级别
- {
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- return;
- ////##
- //this.RefreshDataGridView4();
- }
- double grainNumber = 0;
- //for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
- {
- int dataTableIndex = 0;
- for (int i = 0; i < this.dataTable_Totals.Count; i++)
- {
- if (this.dataTable_Totals[i].TableName.Equals(firstTag/*this.listView2.SelectedItems[j].Tag*/))
- dataTableIndex = i;
- }
- if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
- {
- grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
- }
- }
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 3)
- {
- if (this.dict_Totals.ContainsKey(firstTag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[firstTag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 = (double)valuePairs["RectArea"];
- }
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- {
- dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- //value_111 = small_l;
- dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
- value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
- if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
- {
- RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
- //return;
- }
- if (grainMethodType == 1)
- {
- if (dgvr.Cells.Count > 4)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- value_1 = value_1 * 0.001 * 0.001;
- }
- if (dgvr.Cells.Count > 5)
- {
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- }
- }
- }
- else
- {
- System.Data.DataTable dataTable;
- List<List<double>> valueList = new List<List<double>>();
- double value_1 = 0;
- double small_l = 0;
- this.dataGridView2.Rows.Clear();
- 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);
- }
- List<double> valueL = new List<double>();
- for (int c = 0; c < dataTable.Columns.Count; c++)
- {
- double outValue;
- if (double.TryParse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
- dataTable.Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
- {
- dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- if (IndexChangedFromIndex.Count > 0)
- {
- if (IndexChangedFromIndex.Contains(c))
- valueL.Add(double.Parse(dataTable.Rows[r][c].ToString()));
- continue;
- }
- if (c == 3)
- value_1 += outValue;
- if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
- small_l += outValue;
- }
- if (IndexChangedFromIndex.Count > 0)
- valueList.Add(valueL);
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- this.dataGridView_Total.Rows.Clear();
- if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- foreach (int itemkey in IndexChangedToIndex.Keys)
- {
- int[] itemValue = IndexChangedToIndex[itemkey];
- List<double> valueL = new List<double>();//级别时会多算一遍,应该不影响什么
- if (itemValue[1] >= 0)
- foreach (List<double> itemL in valueList)
- {
- valueL.Add(itemL[itemValue[1]]);
- }
- if (itemValue[0] == 1)//求和
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 2)//平均
- dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
- else if (itemValue[0] == 3)//级别
- if (itemValue[1] < 0)
- {
- dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- return;
- ////##
- //this.RefreshDataGridView4();
- }
- double grainNumber = 0;
- if (getGbtType() == 3)
- value_1 = 0;
- for (int j = 0; j < this.listView2.Items.Count; j++)
- {
- int dataTableIndex = 0;
- for (int i = 0; i < this.dataTable_Totals.Count; i++)
- {
- if (this.dataTable_Totals[i].TableName.Equals(this.listView2.Items[j].Tag))
- dataTableIndex = i;
- }
- if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
- {
- grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
- }
- }
- if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
- {
- Dictionary<string, object> valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
- if (valuePairs.ContainsKey("RectArea"))
- value_1 += (double)valuePairs["RectArea"];
- }
- }
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- value_1 = value_1 * 0.001 * 0.001;
- dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- else
- {
- dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (grainMethodType == 1 && grainNumber > 0)
- small_l = small_l / grainNumber;
- else if (grainMethodType == 0 && value_1 > 0)
- small_l = small_l / value_1;
- dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
- if (grainMethodType == 1)
- {
- if (grainNumber > 0)
- value_1 = value_1 / grainNumber;
- dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
- value_1 = value_1 * 0.001 * 0.001;
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
- else
- dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
- }
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- }
- }
- }
- /// <summary>
- /// 是否能取到二值的结果
- /// </summary>
- /// <returns></returns>
- protected Boolean getBinaryChecked()
- {
- return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
- }
- /// <summary>
- /// 是否能取到晶界重现的结果
- /// </summary>
- /// <returns></returns>
- protected Boolean getGrainBoundryChecked()
- {
- if (this.documentWorkspace.PhaseModels.Count > 0)
- {
- return (/*this.checkBox1.Checked && */this.documentWorkspace.PhaseModels[1].mat != null);
- }
- return false;
- }
- //public void SetItemOrdinal(int itemOrdinal)
- //{
- // if (this.progressDialog.InvokeRequired)
- // {
- // this.progressDialog.BeginInvoke(new Procedure<int>(SetItemOrdinal), new object[] { itemOrdinal });
- // }
- // else
- // {
- // this.itemOrdinal = itemOrdinal;
- // this.totalWork = 0;
- // this.totalProgress = 0;
- // UpdateUI();
- // }
- //}
- protected object comboBox1SelectedItem = null;
- /// <summary>
- /// 返回当前选择的辅助线名称
- /// </summary>
- /// <returns></returns>
- protected string getCurrentGuideName()
- {
- return comboBox1SelectedItem/*this.comboBox1.SelectedItem*/ != null ? comboBox1SelectedItem/*this.comboBox1.SelectedItem*/.ToString() : "";
- }
- /// <summary>
- /// 返回当前选择的图片内容
- /// </summary>
- /// <returns></returns>
- protected DocumentWorkspace getCurrentWorkspace()
- {
- if (this.lstView_img.FocusedItem == null && this.lstView_img.SelectedItems.Count == 0)
- return null;
- return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
- }
- /// <summary>
- /// 返回当前选择的图片tag
- /// </summary>
- /// <returns></returns>
- protected string getCurrentWorkTag()
- {
- return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
- }
- /// <summary>
- /// 获取面积法显示编号的颜色
- /// </summary>
- /// <returns></returns>
- protected Color getGrainBoundryColor()
- {
- return Color.Red;//#########################1 this.documentWorkspace.PhaseModels[1].color;// this.panel1.BackColor;
- }
- private double cal_gNum = 0;
- private Mat cal_temp = null;
- GrainSizeStandardModel cal1_StandardModel;
- GrainSizeGuideModel cal1_GuideModel;
- Mat cal1_Picture;
- Mat cal_analyzeMat;
- bool cal_BinaryChecked;
- string cal1_Tag;
- int cal1_Index;
- bool cal1_RectFlag = false;
- ProgressThreadProcClass procClass;
- /// <summary>
- /// 刷新晶粒编号
- /// </summary>
- /// <returns>返回晶粒个数</returns>
- protected double GetNumberOfGrains(GrainSizeStandardModel cal_StandardModel = null, GrainSizeGuideModel cal_GuideModel = null,
- string cal_Tag = null, int cal_Index = -1, bool isRectFlag = false)
- {
- bool isCurrentTag = false;
- if (cal_StandardModel == null)
- cal_StandardModel = GSSClass.standardModel;
- if (cal_GuideModel == null)
- cal_GuideModel = GSSClass.GuideClass.guideModel;
- if (cal_Tag == null || cal_Tag.Equals(getCurrentWorkTag()))
- {
- isCurrentTag = true;
- cal_Tag = getCurrentWorkTag();
- }
- if (cal_Index == -1)
- cal_Index = this.selectPicture;
- if (cal_StandardModel.linePointList.Count <= 0)
- return 0.0;//should never go here !
- Mat cal_Picture;
- Mat analyzeMat = new Mat();
- bool BinaryChecked;
- if (cal_Tag != null && !isCurrentTag)
- BinaryChecked = (binaryClass.getModelMat(cal_Tag) != null);
- else
- BinaryChecked = getBinaryChecked();
- if (getGrainBoundryChecked())
- {//######################
- cal_Picture = new Mat(/*cal_*/imageMat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
- Mat /*cal_*/oldMat = this.documentWorkspace.PhaseModels[1].mat;
- int Rows = oldMat.Rows;
- int Cols = oldMat.Cols;
- int[] point = new int[2];
- //多通道图像的格式化
- for (point[0] = 0; point[0] < Rows; point[0]++)
- {
- for (point[1] = 0; point[1] < Cols; point[1]++)
- {
- if (oldMat.At<Vec4b>(point[0], point[1]).Item3 > 0)
- {
- cal_Picture.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
- }
- }
- }
- Cv2.Erode(cal_Picture, cal_Picture, null, null, 1);
- /*cal_*/oldMat.CopyTo(analyzeMat);
- }
- else if (BinaryChecked)
- {
- Mat cal_Mat = (cal_Tag != null && !isCurrentTag) ? binaryClass.getModelMat(cal_Tag) : this.PhaseModel0Mat;
- cal_Picture = new Mat(cal_Mat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
- int Rows = cal_Mat.Rows;
- int Cols = cal_Mat.Cols;
- int[] point = new int[2];
- //多通道图像的格式化
- for (point[0] = 0; point[0] < Rows; point[0]++)
- {
- for (point[1] = 0; point[1] < Cols; point[1]++)
- {
- if (cal_Mat.At<Vec4b>(point[0], point[1]).Item3 > 0)
- {
- cal_Picture.Set<Vec4b>(point, new Vec4b(0, 0, 0, 255));
- }
- }
- }
- cal_Mat.CopyTo(analyzeMat);
- }
- else
- {
- Mat cal_Mat;// = cal_ImageMat; Mat cal_ImageMat;// = this.bitmap;
- if (cal_Tag != null && cal_Index >= 0 && cal_Index < this.appWorkspace.DocumentWorkspaces.Length)
- cal_Mat = this.appWorkspace.DocumentWorkspaces[cal_Index].CompositionSurface.CreatedAliasedMat();
- else
- cal_Mat = this.imageMat.Clone();
- cal_Picture = new Mat(cal_Mat/*matOrg*/.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
- cal_Mat.CopyTo(cal_Picture);
- cal_Mat.CopyTo(analyzeMat);
- }
- if (cal_temp != null)
- {
- cal_temp.Dispose();
- cal_temp = null;
- }
- cal_gNum = 0;
- cal1_StandardModel = cal_StandardModel;
- cal1_GuideModel = cal_GuideModel;
- cal1_Picture = cal_Picture;
- cal_analyzeMat = analyzeMat;
- cal1_Tag = cal_Tag;
- cal_BinaryChecked = BinaryChecked;
- cal1_Index = cal_Index;
- cal1_RectFlag = isRectFlag;
- //this.progressDialog = new TransferProgressDialog();
- //this.progressDialog.Text = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.TransferProgress.Title");
- //this.progressDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference);
- //this.progressDialog.Title = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemText.Initializing");
- //this.progressDialog.ProgressBar.Style = ProgressBarStyle.Marquee;
- //this.progressDialog.ProgressBar.Maximum = maxPBValue;
- //DoVerbHandler Delegate_do = new DoVerbHandler(ShowProcessWindow);
- //////Thread.Sleep(30000);//隔30秒后判断一下是否完成
- //////IAsyncResult result = Delegate_do.BeginInvoke(null, null);
- //////while (!result.IsCompleted)
- //////{
- ////// Console.WriteLine("子线程未完成2");
- ////// Thread.Sleep(10000);//每隔10秒判断一下是否完成
- //////}
- //////Console.WriteLine("-------子线程已完成-------");
- ////DoVerbHandler invoker = new DoVerbHandler(ShowProcessWindow);
- ////发起一个线程,异步执行打开一个新窗口
- ////this.progressDialog.BeginInvoke(new Procedure<int>(SetItemCount), new object[] { itemCount });
- //Delegate_do.BeginInvoke(null, null);
- //////你需要在窗体遮罩的时候要做的事情
- ////DoVerbMethod();
- //cal_gNum = GSSClass.GetNumberOfGrains(cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
- // this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
- //yourForm.Close();
- procClass = new ProgressThreadProcClass();
- procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(cal_Action/*applyDectAction*/), "正在处理"/*PdnResources.GetString("Menu.Grainboundarytoreproduce.text")*/);
- //ProgressThreadProcClass procClass = new ProgressThreadProcClass();
- //int itemCount = 100;
- //ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
- //System.Threading.ThreadStart copyThreadProc =
- // delegate ()
- // {
- // try
- // {
- // gNum = GSSClass.GetNumberOfGrains(cal_StandardModel, cal_GuideModel/*getCurrentGuideName()*/, cal_Picture, analyzeMat, getGrainBoundryChecked() || BinaryChecked/*getBinaryChecked()*/,
- // this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron), out temp);
- // }
- // catch (Exception ex)
- // {
- // }
- // finally
- // {
- // progressEvents.EndOperation(OperationResult.Finished);
- // }
- // };
- //procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
- //根据等级设置晶粒颜色
- if (cal_temp != null)
- {
- if (grainMethodType == 1)
- {
- if (this.grainColorsMatDict.ContainsKey(cal_Tag))
- this.grainColorsMatDict[cal_Tag] = cal_temp.Clone();
- else
- this.grainColorsMatDict.Add(cal_Tag, cal_temp.Clone());
- }
- if (cal_Index == this.selectPicture && cal_Tag == getCurrentWorkTag())
- {
- this.documentWorkspace.PhaseModels[2].mat = cal_temp;
- this.documentWorkspace.Refresh();
- }
- }
- return cal_gNum;
- }
- /// <summary>
- /// 事件处理示例方法
- /// </summary>
- /// <param name="arg"></param>
- private void DoVerbMethod()
- {
- for (int i = 0; i < 100; i++)
- {
- System.Threading.Thread.Sleep(100);
- }
- }
- private void ShowProcessWindow()
- {
- yourForm.StartPosition = FormStartPosition.CenterParent;
- yourForm.lblTitleBackColor = Color.Transparent;
- yourForm.ShowDialog();
- }
- /// <summary>
- /// 全局变量,yourForm为新窗口的名字
- /// </summary>
- TransferProgressDialog yourForm = new TransferProgressDialog();
- /// <summary>
- /// 你需要处理的事情的方法委托
- /// </summary>
- /// <param name="arg"></param>
- public delegate void DoVerbHandler(/*object arg*/);
- /// <summary>
- /// 目标选择 1不包含边缘 2边缘只处理内部 3边缘处理内外部
- /// </summary>
- public int TargetSelection = 2;
- private void cal_Action()
- {
- cal_gNum = GSSClass.GetNumberOfGrains(cal1_RectFlag, TargetSelection, cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
- this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
- if (procClass != null) procClass.DismissProgressAction(this);
- }
- /// <summary>
- /// 面积法组织分项数据列表的内容,并返回汇总截距(μm)和汇总面积(μm²)
- /// </summary>
- private double[] addNewRowsToDatagridView2(GrainSizeStandardModel cal_StandardModel, GrainSizeGuideModel cal_GuideModel, string cal_Tag, int cal_Index)
- {
- double small_l = 0;
- double area_sum = 0;
- //显示编号
- if (cal_StandardModel.massLabelPoints.Count > 0 && cal_StandardModel.currentStats != null)
- {
- this.dataGridView2.Rows.Clear();
- string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
- int index = 0;
- int label;
- //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
- //选择标尺的物理长度(1倍下的 微米/像素)
- //this.physical_length = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
- double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron);
- //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
- double aec;
- double grainNumber = 1.0;
- decimal NA;
- foreach (int kvLabel in cal_StandardModel.massLabelPoints.Keys)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- dgvr.Cells[0].Value = imgName;
- dgvr.Cells[1].Value = cal_GuideModel.oldSelectItem.ToString();
- dgvr.Cells[2].Value = (++index);//晶粒编号
- label = kvLabel;
- aec = cal_StandardModel.currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
- dgvr.Cells[3].Value = aec/*areaField1*/;
- area_sum += aec;
- aec = aec * 0.001 * 0.001;
- NA = Convert.ToDecimal(grainNumber / aec);
- ////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
- double[] lengths = {3.88, 7.75 , 10.96, 15.50, 21.92, 31.0, 43.84, 62.0,
- 87.68, 124, 175.36, 248, 350.73, 496, 701.45, 992, 1402.9, 1984.0, 2805.8, 3968.0, 5611.6,
- 7936.0, 11223.2, 15872.0, 22446.4, 31744.1, 44892.9, 63488.1, 89785.8, 126976.3};
- // 差值
- decimal differenceNew;
- decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)NA - 2.88, (double)NA - 126977.3)));
- int first = 0;
- if ((double)NA > lengths[lengths.Length - 1])
- first = lengths.Length - 1;
- else
- for (int firstI = 0; firstI < lengths.Length; firstI++)
- {
- double item = lengths[firstI];
- differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
- if (differenceNew < differenceOld)
- {
- differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
- first = firstI;
- }
- }
- string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
- "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
- "10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
- string[] valueG = {"452.5", "320.0" , "269.1", "226.3", "190.3", "160.0", "134.5", "113.1",
- "95.1", "80.0", "67.3", "56.6", "47.6", "40.0", "33.6", "28.3", "23.8", "20.0", "16.8", "14.1", "11.9",
- "10.0", "8.4", "7.1", "5.9", "5.0", "4.2", "3.5", "3.0", "2.5"};//微米##晶粒截距
- dgvr.Cells[4].Value = valueG[first];
- small_l += double.Parse(valueG[first]);
- dgvr.Cells[5].Value = valueGrade[first];
- this.dataGridView2.Rows.Add(dgvr);
- }
- for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
- {
- System.Data.DataTable dataTable1 = dataTables[dataTableI];
- if (dataTable1.TableName.Equals(cal_Tag))/*dataTable.TableName*/
- dataTables.RemoveAt(dataTableI);
- }
- System.Data.DataTable dataTable = new System.Data.DataTable();
- dataTable.TableName = cal_Tag;
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- dataTable.Rows.Add(dataRow);
- }
- this.dataTables.Add(dataTable);
- }
- return new double[] { small_l, area_sum };
- }
- #endregion
- #region 需继承方法
- /// <summary>
- /// 0,其他; 3,GBT6394的面积法; 4,ISO643
- /// </summary>
- /// <returns></returns>
- protected virtual int getGbtType()
- {
- return 0;
- }
- /// <summary>
- /// 返回保存的参数值-是否显示晶界,显示网格,显示截点
- /// </summary>
- /// <returns></returns>
- protected bool GetParamValue1(string param_key, out object ShowGrainBoundry)
- {
- bool foundItem = false;
- ShowGrainBoundry = true;
- foreach (var item in this.analysisModel.ListParam)
- {
- if (item.param_key.Equals(param_key) && item.menuId == this.menuId)//显示晶界
- {
- ShowGrainBoundry = item.value;
- foundItem = true;
- break;
- }
- }
- return foundItem;
- }
- /// <summary>
- /// 是否显示晶界
- /// </summary>
- /// <returns></returns>
- protected virtual Boolean ShowGrainBoundryChecked()
- {
- return true;
- }
- /// <summary>
- /// 是否显示网格
- /// </summary>
- /// <returns></returns>
- protected virtual Boolean drawDisplaySections()
- {
- return true;
- }
- /// <summary>
- /// 是否用不同颜色显示晶粒
- /// </summary>
- /// <returns></returns>
- protected virtual Boolean ShowGrainColorChecked()
- {
- return true;
- }
- /// <summary>
- /// 是否显示视场
- /// </summary>
- /// <returns></returns>
- protected virtual Boolean ShowDrawClassView()
- {
- return false;
- }
- /// <summary>
- /// 小数点位数后调用的事件
- /// </summary>
- protected virtual void RefreshWhileUpDown1_0ValueChanged()
- {
- }
- /// <summary>
- /// 图片索引改变后调用的事件
- /// </summary>
- protected virtual void refreshWhileImgChanged()
- {
- }
- /// <summary>
- /// 获取对应级别的方法
- /// </summary>
- /// <param name="smalll_index"></param>
- /// <returns></returns>
- protected virtual string getGradeValue(double smalll_index)
- {
- //对应级别 根据(smalll_index;//平均晶粒直径)
- //area_sum += aec;
- //aec = aec * 0.001 * 0.001;
- //NA = Convert.ToDecimal(grainNumber / aec);
- //////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
- decimal NA = Convert.ToDecimal(smalll_index);
- double[] lengths = {508.0, 359.2 , 302.1, 254.0, 213.6, 179.6, 151.0, 127.0,
- 106.8, 89.8, 75.5, 63.5, 53.4, 44.9, 37.8, 31.8, 26.7, 22.5, 18.9, 15.9, 13.3,
- 11.2, 9.4, 7.9, 6.7, 5.6, 4.7, 4.0, 3.3, 2.8};
- // 差值
- decimal differenceNew;
- decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max(smalll_index - 1.8, smalll_index - 509.0)));
- int first = lengths.Length - 1;
- for (int firstI = 0; firstI < lengths.Length; firstI++)
- {
- double item = lengths[firstI];
- differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
- if (differenceNew < differenceOld)
- {
- differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
- first = firstI;
- }
- }
- string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
- "3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
- "10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
- return valueGrade[first];
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- /// <param name="imagesKey">当前选择图片的tag</param>
- /// <param name="analysisPicture">当前选择图片的Index</param>
- protected virtual void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
- {
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(imagesKey))
- {
- add++;
- if (saveAll)
- {
- replace = true;
- break;
- }
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- break;
- }
- }
- if (!replace && this.listView2.Items.Count > 0 && add > 0)
- return;
- string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
- if (!replace)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + imagesKey;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- this.threeDButton.Enabled = true;
- }
- if (grainMethodType == 1)
- buildListBoxArea_analysisResult(imagesKey, analysisPicture);
- else
- buildListBoxCutOff_analysisResult(imagesKey, analysisPicture);
- }
- /// <summary>
- /// PanelC的调色板颜色改变
- /// </summary>
- protected virtual void ColorPanelChanged(Panel panel)
- {
- }
- /// <summary>
- /// 晶粒度辅助线: 计算当前不显示数据的过程
- /// </summary>
- /// <param name="imagesKey"></param>
- /// <param name="analysisPicture"></param>
- protected void calcOtherImgs(string imagesKey, int analysisPicture)
- {
- if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- GSSClass.GuideClass.guideDict.Add(imagesKey, GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/());
- GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
- //if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
- float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
- double multiple = 1.0;
- if (recWidth > this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width)
- {
- multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / recWidth;
- }
- if (this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height < recHeight * multiple)//#21714
- {
- multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / recHeight;
- }
- guideModel.rectangleFLineWidth = (float)(multiple * guideModel.rectangleFLineWidth);
- guideModel.rectangleFLineHeight = (float)(multiple * guideModel.rectangleFLineHeight);
- if (grainMethodType == 1)//#21714
- GSSClass.GuideClass.UpdateScaleGuideAreaStyle(guideModel.oldSelectItem, guideModel, multiple);
- else
- GSSClass.GuideClass.UpdateScaleGuideStyle(guideModel.oldSelectItem, guideModel, recWidth, recHeight
- , this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron), multiple);
- }
- guideModel.loctation = new PointF(this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / 2, this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / 2);
- //if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
- float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
- guideModel.RectangleFLine = new RectangleF(guideModel.loctation.X - recWidth / 2
- , guideModel.loctation.Y - recHeight / 2
- , recWidth, recHeight);//########################################
- bool foundItem = false;
- if (grainMethodType == 1)
- {
- if (this.imageMat != null && guideModel.oldSelectItem != null)
- GSSClass.GuideClass.updateGuideAreaRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
- }
- else
- if (this.imageMat != null && guideModel.oldSelectItem != null)
- GSSClass.GuideClass.updateGuideRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
- /////*this.*/
- ////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
- if (foundItem)
- AddRectangleToRectangleFCaps(imagesKey, analysisPicture);
- //this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 截点法组织分项数据列表的内容,并返回网格总长度(μm)和截点总数
- /// </summary>
- private double[] addCutOffNewRowsToDatagridView2(string imagesKey, int analysisPicture)
- {
- string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
- //string tag = getCurrentWorkTag();//imagesKey
- double small_l = 0;
- double count_sum = 0;
- this.dataGridView2.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- dgvr.Cells[0].Value = imgName;
- if (analysisPicture != this.selectPicture)//更新二值图片
- binaryClass.updateAnalysisData(imagesKey, analysisPicture);
- GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideModel;
- if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
- //else if (analysisPicture != this.selectPicture)//计算对应图片的数据
- //{
- // this.calcOtherImgs(imagesKey, analysisPicture);
- //}
- GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
- if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
- styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
- else//计算对应图片的数据
- {
- }
- if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
- this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
- if (guideModel.oldSelectItem == null)//#######################
- guideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
- //if (analysisPicture != this.selectPicture)//计算对应图片的数据
- //{
- // this.calcOtherImgs(imagesKey, analysisPicture);
- //}
- dgvr.Cells[1].Value = guideModel.oldSelectItem;// this.comboBox1.SelectedItem;
- double length = GSSClass.GuideClass.guideLength(guideModel/*this.comboBox1.SelectedItem*/);
- small_l += length;
- dgvr.Cells[2].Value = length;
- double countPoints = styleModel.getCountPoints();
- decimal M = 1;
- double PL = (double)M * countPoints / length;
- count_sum += countPoints;
- dgvr.Cells[3].Value = countPoints;
- dgvr.Cells[4].Value = 1.0 / PL;
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = -6.6439 * Math.Log10(1.0 / PL * 0.001) - 3.2877;
- else
- dgvr.Cells[5].Value = -6.643856 * Math.Log10(1.0 / PL * 0.001) - 3.288;
- this.dataGridView2.Rows.Add(dgvr);
- for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
- {
- System.Data.DataTable dataTable1 = dataTables[dataTableI];
- if (dataTable1.TableName.Equals(imagesKey))
- dataTables.RemoveAt(dataTableI);
- }
- System.Data.DataTable dataTable = new System.Data.DataTable();
- dataTable.TableName = imagesKey;
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- dataTable.Rows.Add(dataRow);
- }
- this.dataTables.Add(dataTable);
- return new double[] { small_l, count_sum };
- }
- /// <summary>
- /// 截点法-保存结果
- /// </summary>
- private void buildListBoxCutOff_analysisResult(string imagesKey, int analysisPicture)
- {
- //组织详细数据列表的内容,获取截距和截点数后,再进行平均的计算
- double[] res_arr = addCutOffNewRowsToDatagridView2(imagesKey, analysisPicture);
- double small_l = res_arr[0];
- double grainNumber = res_arr[1];
- this.dataGridView_Total.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = small_l;
- dgvr.Cells[1].Value = grainNumber;
- if (grainNumber > 0)
- small_l = small_l / grainNumber;
- dgvr.Cells[2].Value = small_l;
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
- else
- dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
- this.dataGridView_Total.Rows.Add(dgvr);
- System.Data.DataTable dataTable = new System.Data.DataTable();
- dataTable.TableName = imagesKey;
- foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTable_Totals.Remove(dataTable1);
- break;
- }
- }
- if (this.dict_Totals.ContainsKey(dataTable.TableName))
- this.dict_Totals.Remove(dataTable.TableName);
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- dataTable.Columns.Add(c.HeaderText);
- for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Rows[r].Cells[c].Value;
-
- dataTable.Rows.Add(dataRow);
- }
- this.dataTable_Totals.Add(dataTable);
- this.RefreshDataGridView4();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit;// this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- if (analysisPicture != this.selectPicture)//更新处理前的图片
- originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
- else
- originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (binaryClass.getModelMat(imagesKey) != null/*this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null*/)
- {//(imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat
- Mat targetMat = binaryClass.getModelMat(imagesKey);// this.PhaseModel0Mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- else if (imagesKey.Equals(getCurrentWorkTag()) && this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;// this.PhaseModel0Mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
- {
- Mat targetMat = this.grainBoundaryMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
- {
- Mat targetMat = this.grainColorsMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- //if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null
- // && !this.documentWorkspace.PhaseModels[2].mat.IsDisposed)
- //{
- // Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
- // graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- //}
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass/*Draw*/(graphics, imagesKey, analysisPicture);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(imagesKey))
- bitDic[imagesKey] = tempBit;
- else
- bitDic.Add(imagesKey, tempBit);
- ////this.
- //this.phy
- ////拼接中间数据
- //List<List<string>> dataList = new List<List<string>>();
- //List<string> columnName = new List<string>();
- //columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
- //columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
- //columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
- //columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
- //dataList.Add(columnName);
- GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
- if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
- styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
- //拼接中间数据
- List<List<string>> dataList = GSSClass.styleClass.getTableDataList(styleModel, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(imagesKey))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- ExportProjectModel newModel = new ExportProjectModel();
- newModel.tagName = imagesKey;
- newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();//##################################
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- /// <summary>
- /// 面积法-保存结果
- /// </summary>
- private void buildListBoxArea_analysisResult(string imagesKey, int analysisPicture)
- {
- if (analysisPicture != this.selectPicture)//更新二值图片
- binaryClass.updateAnalysisData(imagesKey, analysisPicture);
- GrainSizeGuideModel cal_GuideModel = this.GSSClass.GuideClass.guideModel;
- if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- cal_GuideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
- //else if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
- //{
- // this.calcOtherImgs(imagesKey, analysisPicture);
- //}
- if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
- this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
- if (cal_GuideModel.oldSelectItem == null)//##
- cal_GuideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
- GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
- if (imagesKey != null)
- {
- if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
- this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
- cal_StandardModel = this.GSSClass.standardDict[imagesKey];
- if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
- this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
- }
- if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
- //if (cal_StandardModel.linePointList.Count == 0)
- this.calcOtherImgs(imagesKey, analysisPicture);
- // 是否矩形辅助线
- int isRect;
- double aec0 = GSSClass.GuideClass.guideArea(cal_GuideModel, cal_GuideModel.oldSelectItem/*this.comboBox1.SelectedItem*/, out isRect, getGbtType());
- //aec = aec * 0.001 * 0.001;
- double grainNumber = GetNumberOfGrains(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture
- , isRect == 1) + isRect;//自查# //面积内的晶粒数N。
- //组织详细数据列表的内容,获取截距和面积后,再进行平均的计算<=>GBT6394面积法计算级别
- double[] res_arr = addNewRowsToDatagridView2(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture);
- //grainNumber = 8;
- double small_l = res_arr[0];
- double area_l = aec0;// res_arr[1];
- this.dataGridView_Total.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = grainNumber;
- if (getGbtType() == 3)
- {
- if (grainNumber > 0)
- area_l = area_l / grainNumber;
- double aec = area_l * 0.001 * 0.001;
- double NA = (double)1/*grainNumber*/ / aec;//自查# //计算出实际试样检测面上(1倍)的每平方毫米内晶粒数:。
- dgvr.Cells[1].Value = 3.321928 * Math.Log10(NA) - 2.954;//自查# //晶粒度级别数G计算
- }
- else
- {
- dgvr.Cells[1].Value = small_l;
- if (grainNumber > 0)
- small_l = small_l / grainNumber;
- dgvr.Cells[2].Value = small_l;
- if (getGbtType() == 4)
- dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
- else
- dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
- if (grainNumber > 0)
- area_l = area_l / grainNumber;
- dgvr.Cells[4].Value = area_l;
- double aec = area_l * 0.001 * 0.001;
- double NA = (double)1/*grainNumber*/ / aec;
- if (getGbtType() == 4)
- dgvr.Cells[5].Value = 3.32 * Math.Log10(NA) - 2.9542;
- else
- dgvr.Cells[5].Value = 3.321928 * Math.Log10(NA) - 2.954;//!!!!!!!!!!!!!................................
- }
- this.dataGridView_Total.Rows.Add(dgvr);
- System.Data.DataTable dataTable = new System.Data.DataTable();
- dataTable.TableName = imagesKey;
- foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTable_Totals.Remove(dataTable1);
- break;
- }
- }
- if (this.dict_Totals.ContainsKey(dataTable.TableName))
- this.dict_Totals.Remove(dataTable.TableName);
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Rows[r].Cells[c].Value;
- }
- dataTable.Rows.Add(dataRow);
- }
- this.dataTable_Totals.Add(dataTable);
- if (getGbtType() == 3)
- this.dict_Totals.Add(imagesKey, new Dictionary<string, object>() { { "RectArea", aec0 } });
- this.RefreshDataGridView4();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit;// this.bitmap;
- if (analysisPicture != this.selectPicture)//更新处理前的图片
- originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
- else
- originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (binaryClass.getModelMat(imagesKey) != null)
- {
- Mat targetMat = binaryClass.getModelMat(imagesKey);
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
- {
- Mat targetMat = this.grainBoundaryMatDict[imagesKey];
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
- {
- Mat targetMat = this.grainColorsMatDict[imagesKey];
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass(graphics, imagesKey, analysisPicture);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(imagesKey))
- bitDic[imagesKey] = tempBit;
- else
- bitDic.Add(imagesKey, tempBit);
- //拼接中间数据
- List<List<string>> dataList = new List<List<string>>();
- List<string> columnName = new List<string>();
- columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
- columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
- columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
- columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
- //Dictionary<MeasurementUnit, double> measurementUnitDictionary = Startup.instance.rules;
- //选择标尺的物理长度(1倍下的 微米/像素)
- //double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
- double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron);
- if (cal_StandardModel.currentStats != null && physical_area_length_Micron > 0)//##20544
- {
- columnName.Add("晶粒面积"/*PdnResources.GetString("Menu.Whethertheinternal.Text")*/);
- }
- //aec = currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
- dataList.Add(columnName);
- if (cal_StandardModel.massLabelPoints.Count > 0)
- {
- int index = 0;
- int outMaxIndex = cal_StandardModel.massLabelPoints.Count - 0 - cal_StandardModel.within;
- foreach (var label in cal_StandardModel.massLabelPoints.Keys)//####################
- {
- var item = cal_StandardModel.massLabelPoints[label];
- List<string> strList = new List<string>();
- strList.Add(("" + (++index)).ToString());
- strList.Add(item[2].ToString());
- strList.Add(item[3].ToString());
- if (outMaxIndex < index)
- strList.Add(PdnResources.GetString("Menu.Yes.text"));
- else
- strList.Add(PdnResources.GetString("Menu.no.text"));
- strList.Add((cal_StandardModel.currentStats.At<int>(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron).ToString());
- dataList.Add(strList);
- }
- }
- bool isExist = false;//是否已存在进行替换
- int modelIndex = -1;//要替换的下标
- for (int j = 0; j < tempDataModel.Count; j++)
- {
- if (tempDataModel[j].tagName.Equals(imagesKey))
- {
- isExist = true;
- modelIndex = j;
- break;
- }
- }
- if (isExist && modelIndex > -1)
- tempDataModel[modelIndex].dataList = dataList;
- else
- {
- Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
- newModel.tagName = imagesKey;
- newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
- newModel.dataList = dataList;
- tempDataModel.Add(newModel);
- }
- }
- /// <summary>
- /// 保存子窗体参数
- /// </summary>
- protected virtual void saveSonData()
- {
- }
- /// <summary>
- /// 获取子窗体参数
- /// </summary>
- protected virtual void getSonData()
- {
- }
- /// <summary>
- /// 保存子窗体录制参数
- /// </summary>
- protected virtual object saveRecordingData(string key)
- {
- return null;
- }
- protected virtual void SubclassInitialize()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 辅助线类型
- /// </summary>
- /// <returns></returns>
- protected virtual string[] getTypeNames()
- {
- return new string[] {
- "",
- ""};
- }
- /// <summary>
- /// 辅助线配置文件名称
- /// </summary>
- /// <returns></returns>
- protected virtual string getModelName()
- {
- 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();
- }
- /// <summary>
- /// 是否绘制辅助线
- /// </summary>
- /// <param name="graphics"></param>
- /// <returns></returns>
- protected virtual bool showGridChecked()
- {
- return false;
- }
- /// <summary>
- /// 是否绘制截点
- /// </summary>
- /// <param name="graphics"></param>
- /// <returns></returns>
- protected virtual bool drawGuidePoints()
- {
- return false;
- }
- /// <summary>
- /// 是否绘制编号
- /// </summary>
- /// <param name="graphics"></param>
- /// <returns></returns>
- protected virtual bool showGrainNumberChecked()
- {
- return false;
- }
- protected virtual void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
- {
- GrainSizeGuideModel cal_GuideModel = GSSClass.GuideClass.guideModel;
- if (imagesKey != null && GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- cal_GuideModel = GSSClass.GuideClass.guideDict[imagesKey];
- GrainPointStyleModel cal_StyleModel = GSSClass.styleClass.styleModel;
- if (imagesKey != null && GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
- cal_StyleModel = GSSClass.styleClass.styleDict[imagesKey];
- GrainSizeStandardModel cal_StandardModel = GSSClass.standardModel;
- if (imagesKey != null && GSSClass.standardDict.ContainsKey(imagesKey))
- cal_StandardModel = GSSClass.standardDict[imagesKey];
- //显示辅助线
- if (showGridChecked())
- if (grainMethodType == 1)
- GSSClass.GuideClass.DrawAreaGuide(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
- else
- GSSClass.GuideClass.DrawGuideLines(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
- //显示截点
- if (drawGuidePoints())
- cal_StyleModel.DrawGuidePoints(graphics);
- //显示编号
- if (showGrainNumberChecked() && cal_StandardModel.massLabelPoints.Count > 0)
- {
- int index = 0;
- Font myFont = new Font("宋体", 12);
- Brush bush = new SolidBrush(getGrainBoundryColor());//填充的颜色
- foreach (var item in cal_StandardModel.massLabelPoints.Values)
- {
- graphics.DrawString("" + (++index), myFont, bush, (float)item[2] - 5, (float)item[3] - 5);
- }
- }
- }
- /// <summary>
- /// 实现手动添加在原图情况下的截点位置跟随辅助线的移动而移动
- /// </summary>
- public void MoveOriginCutOffPoints(float offsetX, float offsetY)
- {
- Mat mat;
- if (!getGrainBoundryChecked() && !getBinaryChecked())
- {
- mat = imageMat.Clone();
- }
- else
- {
- if (getGrainBoundryChecked())
- {
- if (this.documentWorkspace.PhaseModels[1].mat != null)
- mat = this.documentWorkspace.PhaseModels[1].mat;
- else
- return;
- }
- else if (this.documentWorkspace.PhaseModels[0].mat != null)
- {
- mat = this.PhaseModel0Mat;
- }
- else
- return;
- }
- if (mat == null)
- return;
- //##21247
- GSSClass.MoveOriginCutOffPoints(offsetX, offsetY, this.getCurrentGuideName(), mat);
- }
- ///// <summary>
- ///// 刷新图形边线点集合//#########################################
- ///// </summary>
- /// <param name="imagesKey">计算当前不显示数据的过程</param>
- /// <param name="analysisPicture">计算当前不显示数据的过程</param>
- private void AddRectangleToRectangleFCaps(string imagesKey = null, int analysisPicture = -1)
- {
- if (/*grainMethodType == 1 && */this.imageMat == null)//####################
- return;
- if (grainMethodType == 1)
- {//###############################################
- Mat cal_ImageMat;//= this.bitmap;
- if (imagesKey != null && analysisPicture != -1)
- cal_ImageMat = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreatedAliasedMat();
- else
- cal_ImageMat = this.imageMat;
- string cal_GuideName = imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName();
- GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, cal_ImageMat, cal_GuideName, 0, null, (analysisPicture != -1 ? this.appWorkspace.DocumentWorkspaces[analysisPicture] : getCurrentWorkspace()).GetRuler(MeasurementUnit.Micron));
- this.documentWorkspace.Refresh();
- return;
- }
- //this.analysisDict.
- bool BinaryChecked;
- if (imagesKey != null)
- BinaryChecked = (binaryClass.getModelMat(imagesKey) != null);
- else
- BinaryChecked = getBinaryChecked();
- Mat mat;
- if (!getGrainBoundryChecked() && !BinaryChecked)//###########################
- {
- mat = imageMat.Clone();
- }
- else
- {
- if (getGrainBoundryChecked())
- {
- if (this.documentWorkspace.PhaseModels[1].mat != null)
- mat = this.documentWorkspace.PhaseModels[1].mat;
- else
- return;
- }
- else if (BinaryChecked/*this.documentWorkspace.PhaseModels[0].mat != null*/)
- {
- mat = (imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat;
- }
- else
- return;
- }
- if (mat == null)
- return;
- int matLevel = 0;
- if (getGrainBoundryChecked())
- matLevel = 2;
- else if (BinaryChecked/*getBinaryChecked()*/)
- matLevel = 1;
- else if (!getGrainBoundryChecked() && !BinaryChecked/*getBinaryChecked()*/)
- matLevel = 0;
- Mat cal_imageMat = this.imageMat;
- if (imagesKey != null)
- cal_imageMat = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreatedAliasedMat();
- GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, cal_imageMat, (imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName()), matLevel, mat, (analysisPicture == -1 ? getCurrentWorkspace() : this.appWorkspace.DocumentWorkspaces[analysisPicture]).GetRuler(MeasurementUnit.Micron));
- if (analysisPicture == -1 || analysisPicture == this.selectPicture)
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 初始化矩形
- /// </summary>
- private void InitRectangleF(bool guideTypeChanged)
- {
- if (this.imageMat != null && this.comboBox1.SelectedItem != null)
- {
- bool foundItem;
- if (grainMethodType == 1)
- GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideAreaRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
- else
- GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
- //if (foundItem)//#21756
- this.AddRectangleToRectangleFCaps();
- }
- }
- /// <summary>
- /// 更新辅助线及其样式
- /// </summary>
- protected virtual void UpdateGuideStyle(bool showMessageAlert)
- {
- if (getCurrentWorkspace() == null)//#21319
- return;
- if (grainMethodType == 1)
- GSSClass.GuideClass.UpdateGuideAreaStyle(this.imageMat, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
- else//##19846
- GSSClass.GuideClass.UpdateGuideStyle(imageMat, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
- }
- /// <summary>
- /// 添加辅助线后更新下拉列表信息
- /// </summary>
- /// <param name="arrayList"></param>
- public void AddComboboxValue(ArrayList arrayList)
- {
- if (!GSSClass.InitComboboxValue())
- {
- if (grainMethodType == 1)
- GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
- else
- GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
- }
- if (arrayList != null && arrayList.Count > 0)
- {
- this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //this.comboBox1.SelectedItem = (string)ItemStringObject;
- //comboBox1SelectedItem = comboBox1.SelectedItem;
- ////this.comboboxChange = false;
- arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
- this.comboBox1.DataSource = arrayList;
- //this.comboboxChange = false;
- int oldSelectIndex = -1;
- for (int i = 0; i < this.comboBox1.Items.Count; i++)
- {
- if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
- {
- oldSelectIndex = i;
- }
- }
- if (oldSelectIndex > -1)
- this.comboBox1.SelectedIndex = oldSelectIndex;
- else if (this.comboBox1.Items.Count > 0)
- this.comboBox1.SelectedIndex = 0;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- }
- //this.comboBox1.DataSource =
- }
- /// <summary>
- /// 辅助线维护
- /// </summary>
- public virtual void InitComboboxValue(ArrayList arrayList)
- {
- UpdateCupOffPointStyle();
- if (!GSSClass.InitComboboxValue())
- {
- if (grainMethodType == 1)
- GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
- else
- GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
- }
- this.comboBox1.DataSource = null;
- if (arrayList != null && arrayList.Count > 0)
- {
- this.comboboxChange = false;
- arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
- this.comboBox1.DataSource = arrayList;
- this.comboboxChange = false;
- int oldSelectIndex = -1;
- for (int i = 0; i < this.comboBox1.Items.Count; i++)
- {
- if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
- {
- oldSelectIndex = i;
- }
- }
- if (oldSelectIndex > -1)
- this.comboBox1.SelectedIndex = oldSelectIndex;
- else if (this.comboBox1.Items.Count > 0)
- this.comboBox1.SelectedIndex = 0;
- }
- else
- {
- ArrayList arrayList1;
- if (grainMethodType == 1)
- arrayList1 = GSSClass.GuideClass.getComboboxArrayAreaList1();
- else
- arrayList1 = GSSClass.GuideClass.getComboboxArrayList1();
- if (arrayList1.Count > 0)
- {
- this.comboBox1.DataSource = arrayList1;
- this.comboBox1.SelectedIndex = 0;
- }
- }
- UpdateGuideStyle(false);
- this.documentWorkspace.Refresh();
- }
- #endregion
- /// <summary>
- /// 保存参数的key,value和type
- /// </summary>
- /// <param name="param_key"></param>
- /// <param name="param_value"></param>
- /// <param name="param_type"></param>
- protected void saveParamValue(string param_key, string param_value, int param_type)
- {
- bool foundItem = false;
- foreach (var item in this.analysisModel.ListParam)
- {
- if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
- {
- item.param_value = param_value;
- item.setValue();
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- {
- GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
- analysisItem.menuId = this.menuId;
- analysisItem.param_key = param_key;
- analysisItem.param_type = param_type;
- analysisItem.param_value = param_value;
- analysisItem.setValue();
- this.analysisModel.ListParam.Add(analysisItem);
- }
- }
- /// <summary>
- /// 保存界面中的参数到model
- /// </summary>
- private void saveDialogParamValues()
- {
- saveParamValue(ParamKey_ShowGrainNumber, showGrainNumberChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶粒编号
- saveParamValue(ParamKey_ShowGrainColor, ShowGrainColorChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//用不同颜色显示晶粒
- saveParamValue(ParamKey_displaygrainboundaries, ShowGrainBoundryChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶界
- saveParamValue(ParamKey_displaygrid, showGridChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示网格
- saveParamValue(ParamKey_displaysections, drawDisplaySections() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示截点
- saveParamValue(ParamKey_comboBox1SelectedItem, comboBox1SelectedItem != null ? comboBox1SelectedItem.ToString() : "", (int)Base.Dtryt.ItemString);//选择的辅助线
- saveParamValue(ParamKey_CalculatorDecimalDigits, Convert.ToInt32(this.numericUpDown1_0.Value).ToString(), (int)Base.Dtryt.Interger);
- saveParamValue(ParamKey_OpenWhileExportReport, this.checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//生成报告时打开设置
- saveParamValue(ParamKey_TargetSelection, this.TargetSelection.ToString(), (int)Base.Dtryt.Interger);
- saveSonData();
- }
- private void GrainSizeStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- this.saveDialogParamValues();
- binaryClass.saveParams();
- //xml保存路径
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- foreach (var analysisItem in this.analysisModel.ListParam)
- {
- bool foundItem = false;
- foreach (var item in analysisModelXml.ListParam)
- {
- if (item.param_key.Equals(analysisItem.param_key) && item.menuId == this.menuId)
- {
- item.param_value = analysisItem.param_value;
- foundItem = true;
- break;
- }
- }
- if (!foundItem)
- {
- GrainSizeAnalysisModel newMod = analysisItem.cloneModel();
- newMod.value = null;//避免value为集合导致保存出错
- analysisModelXml.ListParam.Add(newMod);
- }
- //analysisModelXml.ListParam.Add(analysisItem.cloneModel());
- }
- //按路径和名称保存xml文件
- string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
- //保存xml
- FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
- }
- /// <summary>
- /// 应用到全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_ApplyToAll_Click(object sender, EventArgs e)
- {
- if (this.lstView_img.Items.Count == 0) return;
- if ((this.menuId != 11012101 && this.menuId != 11012102) && (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem)))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
- return;
- }
- //清空晶界重现除了当前图片之外的缓存数据
- foreach (var itemKey in this.imageList_img.Images.Keys)
- {
- if (itemKey.Equals(getCurrentWorkTag()))
- continue;
- if (this.grainBoundaryMatDict.ContainsKey(itemKey))
- this.grainBoundaryMatDict.Remove(itemKey);
- if (this.grainBoundaryDict.ContainsKey(itemKey))
- this.grainBoundaryDict.Remove(itemKey);
- }
- binaryClass.applyToAll(this.imageList_img.Images.Keys, getCurrentWorkTag());
- this.saveDialogParamValues();
- this.lstView_img.SelectedIndexChanged -= new System.EventHandler(this.lstView_img_SelectedIndexChanged);
- try
- {
- currentOldSelectIndex = this.selectPicture;
- for (int kselectPicture = 0; kselectPicture <= this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
- {
- if (currentOldSelectIndex == kselectPicture || kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
- {//跳过当前选择的窗口,并最后回到当前窗口数据
- if (kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
- {
- kselectPicture = currentOldSelectIndex;
- this.analysisModel = this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]];
- string imagesKeyCurrent = this.imageList_img.Images.Keys[kselectPicture];
- GSSClass.standardModel = GSSClass.standardDict[imagesKeyCurrent];
- GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[imagesKeyCurrent];
- GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[imagesKeyCurrent];
- this.lstView_img.EnsureVisible(kselectPicture);
- this.lstView_img.Items[kselectPicture].Focused = true;
- this.lstView_img.Items[kselectPicture].Selected = true;
- this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
- break;
- }
- continue;
- }
- if (this.analysisDict.ContainsKey(this.imageList_img.Images.Keys[kselectPicture]))
- this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]] = this.analysisModel.cloneListParamModel(this.menuId);
- string imagesKey = this.imageList_img.Images.Keys[kselectPicture];
- if (GSSClass.standardDict.ContainsKey(imagesKey))
- GSSClass.standardDict[imagesKey] = new GrainSizeStandardModel();// GSSClass.standardModel.cloneListParamModel();
- if (GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- GSSClass.GuideClass.guideDict[imagesKey] = GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/();
- if (GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
- GSSClass.styleClass.styleDict[imagesKey] = GSSClass.styleClass.styleModel.cloneListParamModel();
- this.lstView_img.EnsureVisible(kselectPicture);
- this.lstView_img.Items[kselectPicture].Focused = true;
- this.lstView_img.Items[kselectPicture].Selected = true;
- this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
- }
- }
- catch (Exception ex)
- {
- }
- finally
- {
- this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
- }
- }
- /// <summary>
- /// 保存全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_SaveAll_Click(object sender, EventArgs e)
- {
- if (this.imageList_img.Images.Keys.Count <= 1)
- {
- this.btn_saveresult.PerformClick();
- return;
- }
- for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
- {
- string imagesKey = /*toDeleteImageKeysList*/this.imageList_img.Images.Keys[kselectPicture];
- //string imagesKey = kselectPicture.ToString();
- if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- {
- MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
- return;
- }
- }
- bool replace = false;
- int add = 0;
- //#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
- List<string> toDeleteImageKeysList = new List<string>();
- for (int kselectPicture = 0; kselectPicture < this.imageList_img.Images.Keys.Count; kselectPicture++)
- toDeleteImageKeysList.Add(this.imageList_img.Images.Keys[kselectPicture]);
- for (int itemI = 0; itemI < this.listView2.Items.Count; itemI++)
- {
- ListViewItem item = this.listView2.Items[itemI];
- //if (item.Tag.Equals(imagesKey))
- if (this.imageList_img.Images.Keys.Contains(item.Tag.ToString()))
- {
- add++;
- if (itemI == 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?" /*+ "\n确定则全部替换,取消则跳过已保存的结果"*/, PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- //toDeleteImageKeysList.Clear();
- replace = false;
- }
- else
- {
- replace = true;
- break;
- }
- }
- toDeleteImageKeysList.Remove(item.Tag.ToString());
- }
- }
- if (toDeleteImageKeysList.Count == 0 && !replace && this.listView2.Items.Count > 0 && add > 0)
- return;
- for (int kselectPicture = 0; kselectPicture < toDeleteImageKeysList.Count; kselectPicture++)
- {
- //for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
- //{
- string imagesKey = toDeleteImageKeysList/*this.imageList_img.Images.Keys*/[kselectPicture];
- if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
- {
- MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
- return;
- }
- }
- if (replace)
- {
- this.dataGridView_Total.Rows.Clear();
- }
- //#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
- for (int k = 0; k < toDeleteImageKeysList.Count; k++)
- //for (int k = 0; k < this.appWorkspace.DocumentWorkspaces.Count(); k++)
- buildListBox_analysisResult(toDeleteImageKeysList[k], this.imageList_img.Images.Keys.IndexOf(toDeleteImageKeysList[k]), true);
- if (this.documentWorkspace.PhaseModels[2].mat != null && this.documentWorkspace.PhaseModels[2].mat.IsDisposed && this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
- {
- this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()];
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 刷新图片效果和数据时调用该方法
- /// </summary>
- /// <param name="applyingToAll"></param>
- private void refreshActionWhileImg_SelectedIndexChanged(bool applyingToAll, int toSelectIndex = -1)
- {
- GSSClass.styleClass.PointKb = 0;//##21997
- this.saveDialogParamValues();
- this.binaryClass.saveMat(this.imageList_img.Images.Keys[this.selectPicture]);
- //备份第一个显示图片的数据信息到dict中
- if (GSSClass.GuideClass.guideDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
- && !GSSClass.GuideClass.guideDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
- GSSClass.GuideClass.guideDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.GuideClass.guideModel);
- if (GSSClass.styleClass.styleDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
- && !GSSClass.styleClass.styleDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
- GSSClass.styleClass.styleDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.styleClass.styleModel);
- if (GSSClass.standardDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
- && !GSSClass.standardDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
- GSSClass.standardDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.standardModel);
- if (toSelectIndex >= 0/*applyingToAll*/)
- this.imageMat = this.appWorkspace.DocumentWorkspaces[toSelectIndex].CompositionSurface.CreatedAliasedMat();
- else
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- string toSelectImageKey = getCurrentWorkTag();
- if (toSelectIndex >= 0)
- toSelectImageKey = this.imageList_img.Images.Keys[toSelectIndex];
- if (!this.analysisDict.ContainsKey(toSelectImageKey))
- this.analysisDict.Add(toSelectImageKey, this.analysisModel.cloneListParamModel(this.menuId));
- //else
- // this.analysisDict[getCurrentWorkTag()] = this.analysisModel.cloneListParamModel(this.menuId);
- this.analysisModel = this.analysisDict[toSelectImageKey];
- bool existGuideModel = true;
- if (!GSSClass.GuideClass.guideDict.ContainsKey(toSelectImageKey))
- {
- if (/*toSelectIndex >= 0 && */GSSClass.GuideClass.guideModel.oldSelectItem == null && this.comboBox1.SelectedItem != null)
- GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
- GSSClass.GuideClass.guideDict.Add(toSelectImageKey, GSSClass.GuideClass.guideModel.cloneModel());
- existGuideModel = false;
- }
- GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[toSelectImageKey];
- if (toSelectIndex >= 0 && this.comboBox1.SelectedItem != null)
- GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
- if (!GSSClass.styleClass.styleDict.ContainsKey(toSelectImageKey))
- GSSClass.styleClass.styleDict.Add(toSelectImageKey, GSSClass.styleClass.styleModel.cloneModel());
- GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[toSelectImageKey];
- if (!GSSClass.standardDict.ContainsKey(toSelectImageKey))
- GSSClass.standardDict.Add(toSelectImageKey, GSSClass.standardModel.cloneModel());
- GSSClass.standardModel = GSSClass.standardDict[toSelectImageKey];
- //二值化集成4
- if (ShowDrawClassView())
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
- else
- binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.imageMat.Clone(), toSelectImageKey);//###21974
- //晶界重现
- if (this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
- && this.grainBoundaryDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture])
- && !this.grainBoundaryDict.ContainsKey(toSelectImageKey))
- {//如果首次切换到该图片,或者点击了应用到全部,则将参数赋值
- this.grainBoundaryDict.Add(toSelectImageKey, this.grainBoundaryDict[this.imageList_img.Images.Keys[this.selectPicture]].cloneModel());
- }
- if (toSelectIndex >= 0/*applyingToAll*/)
- this.selectPicture = toSelectIndex;
- else
- this.selectPicture = this.lstView_img.FocusedItem.Index;
- //选择了应用晶界重现但是没有计算结果,则进行晶界重现的计算
- if (this.grainBoundaryDict.ContainsKey(toSelectImageKey) && this.grainBoundaryDict[toSelectImageKey].grainApplygrainboundaries == 1
- && !this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
- {
- procClass = new ProgressThreadProcClass();
- procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
- }
- if (this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
- {
- this.documentWorkspace.PhaseModels[1].mat = this.grainBoundaryMatDict[toSelectImageKey].Clone();
- this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
- }
- else
- this.documentWorkspace.PhaseModels[1].mat = null;
- if (grainMethodType == 1)
- {
- if (this.grainColorsMatDict.ContainsKey(toSelectImageKey))
- {
- this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[toSelectImageKey].Clone();
- this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && ShowGrainColorChecked());
- }
- else
- this.documentWorkspace.PhaseModels[2].mat = null;
- }
- if (existGuideModel && !applyingToAll)//显示已经存在的数据即可,除非(还差应用到全部的信息没有处理),否则不必刷新
- {
- try
- {
- object ItemStringObject;
- if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
- {
- this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- this.comboBox1.SelectedItem = (string)ItemStringObject;
- comboBox1SelectedItem = comboBox1.SelectedItem;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- }
- }
- catch (Exception exc)
- {
- System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
- }
- this.documentWorkspace.Refresh();
- refreshWhileImgChanged();
- return;
- }
- DocumentWorkspace toSelectDocumentWorkspace = toSelectIndex >= 0 ? this.appWorkspace.DocumentWorkspaces[toSelectIndex] : getCurrentWorkspace();
- if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
- float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
- double multiple = 1.0;
- if (recWidth > this.documentWorkspace.CompositionSurface.Width)
- {
- multiple = this.documentWorkspace.CompositionSurface.Width / recWidth;
- }
- if (this.documentWorkspace.CompositionSurface.Height < recHeight * multiple)//#21714
- {
- multiple = this.documentWorkspace.CompositionSurface.Height / recHeight;
- }
- GSSClass.GuideClass.guideModel.rectangleFLineWidth = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineWidth);
- GSSClass.GuideClass.guideModel.rectangleFLineHeight = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineHeight);
- if (grainMethodType == 1)//#21714
- GSSClass.GuideClass.UpdateScaleGuideAreaStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel
- , multiple);
- else
- GSSClass.GuideClass.UpdateScaleGuideStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel, recWidth, recHeight
- , toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron), multiple);
- }
- GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- //UpdateGuideStyle(false);
- float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
- float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
- GSSClass.GuideClass.guideModel.RectangleFLine = new RectangleF(GSSClass.GuideClass.guideModel.loctation.X - recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/ / 2
- , GSSClass.GuideClass.guideModel.loctation.Y - recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/ / 2
- , recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/, recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/);
- bool foundItem = false;
- if (grainMethodType == 1)
- {
- if (this.imageMat != null && this.comboBox1.SelectedItem != null)
- GSSClass.GuideClass.updateGuideAreaRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
- }
- else
- if (this.imageMat != null && this.comboBox1.SelectedItem != null)
- GSSClass.GuideClass.updateGuideRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
- /////*this.*/
- ////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
- if (foundItem)
- AddRectangleToRectangleFCaps();
- //this.documentWorkspace.Refresh();
- }
- else
- InitRectangleF(false);
- refreshWhileImgChanged();//#################################################应用到全部时候计算其他图片不需要刷新界面参数信息?
- //InitComboboxValue(null);
- try
- {
- object ItemStringObject;
- if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
- this.comboBox1.SelectedItem = (string)ItemStringObject;
- }
- catch (Exception exc)
- {
- System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
- }
- UpdateGuideStyle(!applyingToAll);
- if (this.imageMat != null)
- {
- GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- InitRectangleF(true);
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 3D效果,正十四面体预览
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void threeDButton_Click(object sender, EventArgs e)
- {
- if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
- {
- RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
- return;
- }
- if (value_111 > 1)
- RegularTetrahedron3D.Run(Math.Min(value_111, 200));
- else
- RegularTetrahedron3D.Run(50/*this.appWorkspace*/);
- }
- private void applyDectAction()
- {
- string toSelectImageKey = this.imageList_img.Images.Keys[this.selectPicture];
- OrgImg0 = GrainBoundaryEditingDialog.runDect(Color.FromArgb(grainBoundaryDict[toSelectImageKey].grainColor) /*Color.Red*//*this.panel1.BackColor*/, this.imageMat.Clone(), grainBoundaryDict[toSelectImageKey].m_AdOutParam_0, grainBoundaryDict[toSelectImageKey].m_AdOutParam_1, (int)grainBoundaryDict[toSelectImageKey].m_AdOutParam_2, (int)grainBoundaryDict[toSelectImageKey].m_AdOutParam_3
- , grainBoundaryDict[toSelectImageKey].m_AdOutParam_4, grainBoundaryDict[toSelectImageKey].m_AdOutParam_5, grainBoundaryDict[toSelectImageKey].m_AdOutParam_6);
- this.grainBoundaryMatDict.Add(toSelectImageKey, OrgImg0);
- if (procClass != null) procClass.DismissProgressAction(this);
- }
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
- if (System.IO.File.Exists(xmlFilePath))
- {
- GrainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
- }
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- //找出二值相关参数 进行赋值
- List<Args> isNullList = args.Where(m => m.value == null).ToList();
- foreach (var item in isNullList)
- {
- item.value = binaryClass.setScriptRecording(item.key);
- }
- isNullList = args.Where(m => m.value == null).ToList();
- foreach (var item in isNullList)
- {
- item.value = saveRecordingData(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "ShowGrainNumber":
- value = showGrainNumberChecked();
- break;
- case "ShowGrainColor":
- value = ShowGrainColorChecked();
- break;
- case "displaygrainboundaries":
- value = ShowGrainBoundryChecked();
- break;
- case "displaygrid":
- value = showGridChecked();
- break;
- case "displaysections":
- value = drawDisplaySections();
- break;
- case "comboBox1SelectedItem":
- value = comboBox1SelectedItem;
- break;
- case "CalculatorDecimalDigits":
- value = Convert.ToInt32(this.numericUpDown1_0.Value);
- break;
- case "OpenWhileExportReport":
- value = this.checkBox_generateReport_opensetting.Checked;
- break;
- case "TargetSelection":
- value = this.TargetSelection;
- break;
- case "ExportResults":
- value = false;
- break;
- case "ExportReports":
- value = false;
- break;
- case "ExportProjects":
- value = false;
- break;
- case "GrainApplygrainboundaries":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.grainApplygrainboundaries;
- break;
- case "lineColor":
- value = GrainBoundryDectModel == null ? Color.Red.ToArgb() : GrainBoundryDectModel.grainColor;
- break;
- case "GrainAdOutParam_0":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_0;
- break;
- case "GrainAdOutParam_1":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_1;
- break;
- case "GrainAdOutParam_2":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_2;
- break;
- case "GrainAdOutParam_3":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_3;
- break;
- case "GrainAdOutParam_4":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_4;
- break;
- case "GrainAdOutParam_5":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_5;
- break;
- case "GrainAdOutParam_6":
- value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_6;
- break;
- }
- return value;
- }
- #endregion
- }
- }
|