| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603 |
- #pragma once
- #include "stdafx.h"
- #include "resource.h"
- #include "ReportProjFileMgr.h"
- #include "MeasureResultInfo.h"
- #include "BSEImgFileMgr.h"
- #include "PosXrayFileMgr.h"
- #include "PartSizeFileMgr.h"
- #include "TrioCal.h"
- #include "CGBCalculate.h"
- #include "GBFieldData.h"
- #include "OTSHelper.h"
- #include "OTSFileSys.h"
- #include "RptParamFileMgr.h"
- #include "GBImgPropCal.h"
- namespace OTSMODEL {
- using namespace std;
- // constructor
- CReportProjFileMgr::CReportProjFileMgr(CReportProjFilePtr a_pReportProjFile)
- {
- m_pReportProjFile = a_pReportProjFile;
- m_listPropParams.clear();
- m_listSmplMgrs.clear();
- m_bModify = FALSE;
- m_strPathName = _T("");
- m_nWorkingSampeIndex = -1;
- m_nPartSizeIndex = -1;
- //load param file
- CRptParamFileMgr paramFleMgr;
- paramFleMgr.Load(OTSMODEL::OTS_SOFT_PACKAGE_ID::OTSIncA);
- m_rptparamfile = paramFleMgr.GetRptParamFile();
- double dScale = m_rptparamfile->GetScale();
- m_pReportProjFile->SetScale(dScale);
- }
- // destructor
- CReportProjFileMgr::~CReportProjFileMgr()
- {
- }
- CRptParamFilePtr CReportProjFileMgr::GetRptParamFilePtr()
- {
- return m_rptparamfile;
- }
- // class methods
- // public
- void CReportProjFileMgr::SetPropertyParams(CPropParamsList a_listPropertyParams)
- {
- m_listPropParams.clear();
- m_listPropParams = a_listPropertyParams;
- }
- // property parameters
- CPropParamPtr CReportProjFileMgr::GetPropertyParamImage()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::IMAGE];
- }
- CPropParamPtr CReportProjFileMgr::GetPropertyParamGrid()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::TABLE];
- }
- CPropParamPtr CReportProjFileMgr::GetPropertyParamChart()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::CHART];
- }
- // reset property parameters
- BOOL CReportProjFileMgr::ResetPropertyParams(BOOL a_bClear /*= FALSE*/)
- {
- // clear property parameters list
- if (a_bClear)
- {
- m_listPropParams.clear();
- }
- // get data source names list
- std::vector<CString> listDataSourceNames = GetDataSourceNamesList();
- // data source names list can't be empty
- if (listDataSourceNames.empty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty data source name list."));
- return FALSE;
- }
- // particle STD data
- CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- ASSERT(pPartSTDData);
- if (!pPartSTDData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: STD data empty."));
- return FALSE;
- }
- // trio chart mode
- // add property parameters into the list
- if (m_listPropParams.empty())
- {
- //Image display picture's property
- CPropParamPtr pPropParam = CPropParamPtr(new CPropParamImage());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
- pPropParam->SetWorkingSTDLib(pPartSTDData);
- pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
- if (*pPartSTDData.get() == CPartSTDData())
- {
- pPropParam->SetSTDId(0);
- }
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::IMAGE);
- m_listPropParams.push_back(pPropParam);
- //grid table display picture's property
- pPropParam = CPropParamPtr(new CPropParamGrid());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
- pPropParam->SetWorkingSTDLib(pPartSTDData);
- pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
- if (*pPartSTDData.get() == CPartSTDData())
- {
- pPropParam->SetSTDId(0);
- }
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::TABLE);
- m_listPropParams.push_back(pPropParam);
- //chart display picture's property object
- pPropParam = CPropParamPtr(new CPropParamChart());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
- pPropParam->SetWorkingSTDLib(pPartSTDData);
- pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
- pPropParam->SetTriTempFile(m_rptparamfile->GetTriTempFile());
- if (*pPartSTDData.get() == CPartSTDData())
- {
- pPropParam->SetSTDId(0);
- }
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::CHART);
- m_listPropParams.push_back(pPropParam);
- }
- else
- {
- for (auto pPropParam : m_listPropParams)
- {
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
- pPropParam->SetWorkingSTDLib(pPartSTDData);
- }
- }
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::NewFile()
- {
- // set file name
- SetPathName(UNTITLED_NEW_FILE_NAME);
- return TRUE;
- }
- // Load
- BOOL CReportProjFileMgr::Load(CString a_strPathname /*= _T("")*/)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // check file name
- a_strPathname.Trim();
- if (a_strPathname.IsEmpty())
- {
- // open
- CFileDialog dlg(TRUE, REPORT_PROJRCT_FILE_EXT, NULL, OFN_FILEMUSTEXIST, REPORT_PROJRCT_FILE_FILTER);
- if (dlg.DoModal() != IDOK)
- {
- // user canceled loading
- LogTrace(__FILE__, __LINE__, _T("Load: user canceled loading."));
- return FALSE;
- }
- a_strPathname = dlg.GetPathName();
- }
- // open the file (for read)
- // create report project file file
- CReportProjFilePtr pReportProjFile = CReportProjFilePtr(new CReportProjFile());
- // load from file
- tinyxml2::XMLDocument doc;
- doc.LoadFile(a_strPathname);//载入xml文件
- tinyxml2::XMLElement *rootNode;
- rootNode = doc.FirstChildElement(RootClassName);
- pReportProjFile->Serialize(false, &doc, rootNode);
- SetPathName(a_strPathname);
- // file version
- CString strFileVersion = pReportProjFile->GetFileVersion();
- DWORD nFileVersion = COTSHelper::GetVersionFromString(strFileVersion);
- if (nFileVersion == 0)
- {
- // invalid file
- LogErrorTrace(__FILE__, __LINE__, _T("Load: invalid sample measure result file %s"), a_strPathname);
- return FALSE;
- }
- // set report project file
- m_pReportProjFile = pReportProjFile;
- // load sample measure result files
- m_listSmplMgrs.clear();
- std::vector<CString> listSmplMsrResultFilePathNames;
- for (auto strSmplMsrResultFilePathName : m_pReportProjFile->GetSmplMsrResultFilePathNames())
- {
- if (strSmplMsrResultFilePathName.IsEmpty())
- {
- // sample measure result file pathname can't be an empty string
- LogTrace(__FILE__, __LINE__, _T("Load: sample measure result file pathname can't be an empty string."));
- SetModify();
- continue;
- }
- // create a sample measure result manager
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strSmplMsrResultFilePathName));
- if (!pSmplMsrResultFileMgr->Load(strSmplMsrResultFilePathName))
- {
- // failed to load sample measure result file
- LogTrace(__FILE__, __LINE__, _T("Load: failed to load sample measure result file (%s)."), strSmplMsrResultFilePathName);
- SetModify();
- continue;
- }
- // this file is ok
- listSmplMsrResultFilePathNames.push_back(strSmplMsrResultFilePathName);
- m_listSmplMgrs.push_back(pSmplMsrResultFileMgr);
- }
- m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
- // set working sample
- if (m_listSmplMgrs.size() > 0)
- {
- m_nWorkingSampeIndex = 0;
- }
- else
- {
- m_nWorkingSampeIndex = -1;
- }
- ResetPropertyParams();
- return TRUE;
- }
- // Save
- BOOL CReportProjFileMgr::Save()
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // safety check
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("Save: invalid report project file pointer."));
- return FALSE;
- }
- // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
- CString strPathName = GetPathName();
- // is this a new file?
- strPathName.Trim();
- if (strPathName.CompareNoCase(UNTITLED_NEW_FILE_NAME) == 0)
- {
- // this is a new file
- // return save as result
- return SaveAs();
- }
- // store data to file
- tinyxml2::XMLDocument doc;
- doc.LoadFile(strPathName);//载入xml文件
- doc.Clear();
- tinyxml2::XMLDeclaration* declaration = doc.NewDeclaration();//添加xml文件头申明
- doc.InsertFirstChild(declaration);
- tinyxml2::XMLElement *rootNode;
- rootNode = doc.NewElement(RootClassName);
- doc.InsertEndChild(rootNode);
- m_pReportProjFile->Serialize(true, &doc, rootNode);
- int result = doc.SaveFile(strPathName);
- // set modify flag to FALSE
- SetModify(FALSE);
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::SaveAs()
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // safety check
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("SaveAs: invalid report project file pointer."));
- return FALSE;
- }
- // save file dialog
- CString strFileName = _T("");
- // file save as dialog
- CFileDialog dlg(FALSE, REPORT_PROJRCT_FILE_EXT, NULL, OFN_OVERWRITEPROMPT, REPORT_PROJRCT_FILE_FILTER);
- if (dlg.DoModal() != IDOK)
- {
- // user canceled loading
- LogTrace(__FILE__, __LINE__, _T("Save: user canceled save."));
- return FALSE;
- }
- // get file pathname
- strFileName = dlg.GetPathName();
- // Open the file
- // store to file
- tinyxml2::XMLDocument doc;
- doc.LoadFile(strFileName);//载入xml文件
- doc.Clear();
- tinyxml2::XMLDeclaration* declaration = doc.NewDeclaration();//添加xml文件头申明
- doc.InsertFirstChild(declaration);
- tinyxml2::XMLElement *rootNode;
- rootNode = doc.NewElement(RootClassName);
- doc.InsertEndChild(rootNode);
- m_pReportProjFile->Serialize(true, &doc, rootNode);
- int result = doc.SaveFile(strFileName);
- // set file modify flag
- m_bModify = FALSE;
- // Set project Path
- SetPathName(strFileName);
- // Ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::IsValid()
- {
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IsValid: not invalid report project file pointer."));
- return FALSE;
- }
- // triangle template file
- CTriTempFilePtr pTriTemp = m_pReportProjFile->GetTriTemp();
- // Ok, return TRUE
- return TRUE;
- }
- // particle STD data
- CPartSTDDataPtr CReportProjFileMgr::GetPartSTDData()
- {
- // check report project file pointer
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("GetPartSTDData: invalid report project file pointer."));
- return FALSE;
- }
- return m_pReportProjFile->GetPartSTDData();
- }
- BOOL CReportProjFileMgr::SetPartSTDData(CPartSTDDataPtr a_pPartSTDData)
- {
- // input check
- ASSERT(a_pPartSTDData);
- if (!a_pPartSTDData)
- {
- // invalid particle STD data pointer
- LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid particle STD data pointer."));
- return FALSE;
- }
- // check report project file pointer
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid report project file pointer."));
- return FALSE;
- }
- // create a copy of the particle STD data
- //CPartSTDDataPtr pPartSTDData = CPartSTDDataPtr(new CPartSTDData(a_pPartSTDData.get()));
- CPartSTDDataPtr pPartSTDData = a_pPartSTDData;
- // set particle STD data
- m_pReportProjFile->SetPartSTDData(pPartSTDData);
- // ok, return TRUE
- return TRUE;
- }
- // sample measure result files
- BOOL CReportProjFileMgr::AddASmplMsrResultMgr(CString a_strPathName /*= _T("")*/)
- {
- /*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
- tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
- _CrtSetDbgFlag(tmpFlag);*/
- //_CrtSetBreakAlloc(351380);
- // check report project file pointer
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid report project file pointer."));
- return FALSE;
- }
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgrPtr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(a_strPathName));
- // load sample result file
- if (!pSmplMsrResultFileMgrPtr->Load(a_strPathName))
- {
- return FALSE;
- }
- //判断新打开的测量结果文件名,是否已经在打开的测量结果列表名中,是的话,不打开,防止同名
- CString strSampleNameNew = pSmplMsrResultFileMgrPtr->GetSmplMsrResultFile()->GetSample()->GetName();
- for (int i = 0; i < m_listSmplMgrs.size(); i++)
- {
- if (m_listSmplMgrs[i]->GetSmplMsrResultFile()->GetSample()->GetName() == strSampleNameNew)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: The measurement result name is already included."));
- return FALSE;
- }
- }
- // get the particle STD data of the sample result file
- CPartSTDDataPtr pPartSTDData = pSmplMsrResultFileMgrPtr->GetPartSTDData();
- ASSERT(pPartSTDData);
- if (!pPartSTDData)
- {
- // sample result file particle STD data invalid
- LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: sample result file particle STD data invalid."));
- return FALSE;
- }
- // is the first sample result file in the list?
- if (m_listSmplMgrs.empty())
- {
- // yes
- // set particle STD data
- if (!SetPartSTDData(pPartSTDData))
- {
- // failed to call SetPartSTDData method
- LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: failed to call SetPartSTDData method."));
- return FALSE;
- }
- }
- else
- {
- // not
- // check if the particle STD data of the input sample result file is same with the project file
- CPartSTDDataPtr pPartSTDDataProj = m_pReportProjFile->GetPartSTDData();
- ASSERT(pPartSTDDataProj);
- if (!pPartSTDDataProj)
- {
- // invalid report project particle STD data file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: invalid report project particle STD data file pointer."));
- return FALSE;
- }
- if (!(*(pPartSTDData.get()) == *(pPartSTDDataProj.get())))
- {
- // the two particle std data dis-matched
- LogTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: the particle std data file of the newly added file is mis-matched with the other files in the report project file."));
- return FALSE;
- }
- //if file name is same and path name is also same, not add
- CString strWorkingFolder = pSmplMsrResultFileMgrPtr->GetWorkingFolderStr();
- // pathname
- CString strPathname = pSmplMsrResultFileMgrPtr->GetPathName();
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [strWorkingFolder, strPathname](CSmplMsrResultFileMgrPtr p) { return ((p->GetPathName().CompareNoCase(strPathname) == 0) && (p->GetWorkingFolderStr().CompareNoCase(strWorkingFolder) == 0)); });
- if (itr != m_listSmplMgrs.end())
- {
- // the two particle std data dis-matched
- LogTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: the sample measure result file has been inserted into current report file."));
- return FALSE;
- }
- }
- // add the file path name into file path names list
- CString strPathname = pSmplMsrResultFileMgrPtr->GetPathName();
- std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
- listSmplMsrResultFilePathNames.push_back(strPathname);
- m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
- // add the sample result file into sample measure result files list
- m_listSmplMgrs.push_back(pSmplMsrResultFileMgrPtr);
- // set modify flag to TRUE
- SetModify();
- // set working sample
- m_nWorkingSampeIndex = (int)m_listSmplMgrs.size() - 1;
- // reset property parameters
- ResetPropertyParams();
- // ok, return TRUE
- return TRUE;
- }
- void CReportProjFileMgr::SetSmplMsrResultMgrs(CSmplMsrResultFileMgrList a_listSmplMsrResultFileMgr)
- {
- for (auto pSmplMsrResultMgr : a_listSmplMsrResultFileMgr)
- {
- CString strWorkingFolder = pSmplMsrResultMgr->GetWorkingFolderStr();
- CSmplMsrResultFileMgrPtr pSmplMsrResultMgrNew = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strWorkingFolder));
- CString strPathname = pSmplMsrResultMgr->GetPathName();
- pSmplMsrResultMgrNew->SetPathName(strPathname);
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
- CSmplMsrResultFilePtr pSmplMsrResultFileNew = CSmplMsrResultFilePtr(new CSmplMsrResultFile(pSmplMsrResultFile.get()));
- pSmplMsrResultMgrNew->SetSmplMsrResultFile(pSmplMsrResultFileNew);
- m_listSmplMgrs.push_back(pSmplMsrResultMgrNew);
- }
- }
- CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrById(int a_nIndex)
- {
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- return nullptr;
- }
- return m_listSmplMgrs[a_nIndex];
- }
- CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrByPathName(CString a_strPathName)
- {
- a_strPathName.Trim();
- if (a_strPathName.IsEmpty())
- {
- return nullptr;
- }
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
- if (itr == m_listSmplMgrs.end())
- {
- return nullptr;
- }
- return *itr;
- }
- CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrByFileName(CString a_strFileName)
- {
- a_strFileName.Trim();
- if (a_strFileName.IsEmpty())
- {
- return nullptr;
- }
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strFileName](CSmplMsrResultFileMgrPtr p)
- {
- CString strDataSource = COTSHelper::GetFileName(p->GetPathName());
- return strDataSource.CompareNoCase(a_strFileName) == 0;
- });
- if (itr == m_listSmplMgrs.end())
- {
- return nullptr;
- }
- return *itr;
- }
- BOOL CReportProjFileMgr::DeleteASmplMsrResultMgrById(int a_nIndex)
- {
- // check the index
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- // invalid input sample index
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteSampleByIndex::input sample index"));
- return a_nIndex;
- }
- // delete path from project file;
- std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
- // check number of file path names
- if ((int)listSmplMsrResultFilePathNames.size() != (int)m_listSmplMgrs.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrById: file path names list has different size with sample result file number."));
- return FALSE;
- }
- // calculate new working sample index
- int nNewWorkingSampeIndex;
- if (a_nIndex < m_nWorkingSampeIndex)
- {
- nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
- }
- else if (a_nIndex > m_nWorkingSampeIndex)
- {
- nNewWorkingSampeIndex = m_nWorkingSampeIndex;
- }
- else
- {
- // deleting working sample.
- if (a_nIndex == (int)m_listSmplMgrs.size() - 1)
- {
- // this is the last sample, select the above sample as working sample
- // if this is only sample in the list working sample index will be -1;
- nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
- }
- else
- {
- // select next sample as working sample
- nNewWorkingSampeIndex = m_nWorkingSampeIndex;
- }
- }
- // delete the sample
- m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
- // the file is modified.
- SetModify();
- // reset working sample index
- m_nWorkingSampeIndex = nNewWorkingSampeIndex;
- // delete the sample path name
- listSmplMsrResultFilePathNames.erase(listSmplMsrResultFilePathNames.begin() + a_nIndex);
- m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
- // reset property parameters
- ResetPropertyParams();
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::DeleteASmplMsrResultMgrByPathName(CString a_strPathName)
- {
- // check report project file pointer
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid report project file pointer
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: invalid report project file pointer."));
- return FALSE;
- }
- a_strPathName.Trim();
- if (a_strPathName.IsEmpty())
- {
- return FALSE;
- }
- auto itrObj = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
- if (itrObj == m_listSmplMgrs.end())
- {
- // failed to find sample measure result file
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file."));
- return FALSE;
- }
- std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
- auto itrPathName = std::find_if(listSmplMsrResultFilePathNames.begin(), listSmplMsrResultFilePathNames.end(), [a_strPathName](CString strPathName) { return strPathName.CompareNoCase(a_strPathName) == 0; });
- if (itrPathName == listSmplMsrResultFilePathNames.end())
- {
- // failed to find sample measure result file pathname
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file pathname."));
- return FALSE;
- }
- m_listSmplMgrs.erase(itrObj);
- // listSmplMsrResultFilePathNames.erase(itrPathName);
- m_pReportProjFile->GetSmplMsrResultFilePathNames().erase(itrPathName);
- // reset property parameters
- ResetPropertyParams();
- // set modify flag to TRUE
- SetModify();
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::EditASmplMsrResultMgrById(int a_nIndex, CSmplMsrResultFileMgrPtr a_pSmpFileMgr)
- {
- ASSERT(a_pSmpFileMgr);
- if (!a_pSmpFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById:invalid sample measure result manager pointer."));
- return FALSE;
- }
- // check if the working sample index
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById: invalid sample measure result manager index."));
- // invalid working sample index
- return FALSE;
- }
- m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
- m_listSmplMgrs.insert(m_listSmplMgrs.begin() + a_nIndex, a_pSmpFileMgr);
- return TRUE;
- }
- CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetWorkingSmplMsrReslMgr()
- {
- // check if the working sample index
- if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSmplMgrs.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSmplMsrReslMgr: invalid working sample measure result manager index."));
- // invalid working sample index
- return FALSE;
- }
- return GetASmplMsrResultMgrById(m_nWorkingSampeIndex);
- }
- CString CReportProjFileMgr::GetWorkingSampleName()
- {
- CString strRet = _T("");
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = GetWorkingSmplMsrReslMgr();
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result manager."));
- return _T("");
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result file."));
- return _T("");
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample."));
- return _T("");
- }
- strRet = pSample->GetName();
- return strRet;
- }
- BOOL CReportProjFileMgr::SetWorkingSmplMsrReslMgr(CSmplMsrResultFileMgrPtr a_pSmplMsrResultMgr)
- {
- ASSERT(a_pSmplMsrResultMgr);
- if (!a_pSmplMsrResultMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result manager pointer."));
- return FALSE;
- }
- if (!EditASmplMsrResultMgrById(m_nWorkingSampeIndex, a_pSmplMsrResultMgr))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: can't edit working sample measure result file."));
- return FALSE;
- }
- return TRUE;
- }
- CString CReportProjFileMgr::GetFileName()
- {
- // make a copy of file path name
- CString strPathName = m_strPathName;
- // is this a new file?
- strPathName.Trim();
- if (strPathName.CompareNoCase(UNTITLED_NEW_FILE_NAME) == 0)
- {
- return strPathName;
- }
- // get file name
- CString strFileName = COTSHelper::GetFileNameWithoutExtension(strPathName);
- strFileName = COTSHelper::GetFileName(strFileName);
- // return file name
- return strFileName;
- }
- // grid computing
- CGridDatasList CReportProjFileMgr::GridDataTransfer()
- {
- CGridDatasList listGridData;
- listGridData.clear();
- // calculate table type
- CPropParamPtr prop = m_CurrentPropParam;
- //COMPUTE_TABLE_TYPE nCalTableType = a_pGridIn->GetCalTableType();
- BOOL bRet = FALSE;
- TrioCal trio(this);
- CGBCalculate GBCal(this);
- MeasureResultInfo Msr(this);
- switch (prop->GetType())
- {
- case DISPLAY_PICTURE_TYPE::IMAGE:
- {
- IMAGE_DISPLAY_TYPE nImgDisType = prop->GetImageDisplayType();
- switch (nImgDisType)
- {
- case IMAGE_DISPLAY_TYPE::GENERAL:
- listGridData = CompDistribution();
- break;
- case IMAGE_DISPLAY_TYPE::IMAGE_GRID:
- {
- MEASURE_DATA_TYPE meaType = prop->GetMeasureDataType();
- switch (meaType)
- {
- case MEASURE_DATA_TYPE::ALL_PARTICLE:
- listGridData = CompSortClass();
- break;
- case MEASURE_DATA_TYPE::ANYLYSIS_PARTICLE:
- listGridData = CompSortKind();
- break;
- case MEASURE_DATA_TYPE::PARTICALE_SIZE_DISTRIBUTION:
- listGridData = CompSortSize();
- break;
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- break;
- }
- case DISPLAY_PICTURE_TYPE::TABLE:
- {
- CALCULATE_TABLE_TYPE nCalTableType = prop->GetCalTableType();
- switch (nCalTableType)
- {
- case CALCULATE_TABLE_TYPE::MEASURE_INFO:
- listGridData = Msr.GetMeasureResultInfo();
- break;
- case CALCULATE_TABLE_TYPE::PARTICALE_GENE_INFO://识别颗粒信息表
- listGridData = CompParticleGenInfo();
- break;
- case CALCULATE_TABLE_TYPE::PARTICALE_COMP://颗粒成分表,即颗粒识别出的物质名称
- listGridData = CompParticleComponent();
- break;
- case CALCULATE_TABLE_TYPE::ELEMENT_COMP://元素成分表,即物质的元素百分比
- listGridData = CompElementComponent();
- break;
- case CALCULATE_TABLE_TYPE::PARTICALE_SIZE_DISTRIBUTION://颗粒尺寸分布
- listGridData = CompParticleSizeDistribution();
- break;
- case CALCULATE_TABLE_TYPE::AVE_ELEMENT_COMP:
- listGridData = CompAveElemnetComponent();//元素平均重量百分比
- break;
- case CALCULATE_TABLE_TYPE::GB_Method1:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::GB_Method2:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::ASTM:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::DIN:
- listGridData = GBCal.GetGBInclusion();
- break;
- default:
- break;
- }
- break;
- }
- case DISPLAY_PICTURE_TYPE::CHART:
- {
- CALCULATE_CHART_TYPE nCalChartType = prop->GetCalChartType();
- switch (nCalChartType)
- {
- case CALCULATE_CHART_TYPE::PARTICALE_COMP:
- listGridData = CompChartParticleComp();
- break;
- case CALCULATE_CHART_TYPE::ELEMENT_COMP:
- listGridData = CompChartElementComp();
- break;
- case CALCULATE_CHART_TYPE::PARTICALE_SIZE_DISTRIBUTION:
- listGridData = CompChartParticleSize();
- break;
- case CALCULATE_CHART_TYPE::TRIO_CHART:
- listGridData = trio.CompParticleTrioInfo();
- break;
- case CALCULATE_CHART_TYPE::COMMON_FIVE:
- listGridData = CompChartCommonFive();
- break;
- default:
- break;
- }
- break;
- }
- }
- return listGridData;
- }
- // reclassify measure result
- BOOL CReportProjFileMgr::ReClassify()
- {
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: empty report project file."));
- return FALSE;
- }
- // particle STD data
- CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- ASSERT(pPartSTDData);
- if (!pPartSTDData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: empty STD file."));
- return FALSE;
- }
- // sample measure result files
- for (auto pSmplMsrResultMgr : m_listSmplMgrs)
- {
- // particle list, need compute
- COTSParticleList listParticleOld = pSmplMsrResultMgr->GetParticleList();
- // analysis x-ray list
- CPosXraysList listAnalysisXray = pSmplMsrResultMgr->GetAnalysisXray();
- if (listParticleOld.empty() || listAnalysisXray.empty())
- {
- // need to reload the result
- COTSFieldMgrList listFieldMgr = pSmplMsrResultMgr->GetOTSFldMgrListAndAnalysisXrayList();
- if (listFieldMgr.empty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't reload file."));
- return FALSE;
- }
- if (!pSmplMsrResultMgr->ComputeParticleList())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't compute particle list."));
- return FALSE;
- }
- listParticleOld = pSmplMsrResultMgr->GetParticleList();
- listAnalysisXray = pSmplMsrResultMgr->GetAnalysisXray();
- }
- COTSParticleList listAnalysisParticle;
- listAnalysisParticle.clear();
- for (auto pParticle : listParticleOld)
- {
- int nType = pParticle->GetType();
- //All particles that contain X-ray data
- if (nType > (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listAnalysisParticle.push_back(pParticleNew);
- }
- }
- // 1. Update particle message
- if (!ClassifyParticles(listAnalysisParticle, listAnalysisXray))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't classify particle list."));
- return FALSE;
- }
- COTSParticleList listParticle;
- listParticle.clear();
- for (auto pParticle : listParticleOld)
- {
- int nType = pParticle->GetType();
- if (nType < (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listParticle.push_back(pParticleNew);
- }
- }
- for (auto pParticle : listAnalysisParticle)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listParticle.push_back(pParticleNew);
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample measure result file."));
- return FALSE;
- }
- COTSFieldDataList listFieldData = pSmplMsrResultFile->GetFieldData();
- for (auto pFieldData : listFieldData)
- {
- int nID = pFieldData->GetId();
- COTSParticleList listFieldParticle;
- for (auto pParticle : listParticle)
- {
- int nFieldId = pParticle->GetFieldId();
- if (nFieldId == nID)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listFieldParticle.push_back(pParticleNew);
- }
- }
- pFieldData->SetParticleList(listFieldParticle);
- //update basedata add code 2019-6-18
- CString strFieldFileFolder = pFieldData->GetFieldFileFolder();
- CString strIncAFilename = strFieldFileFolder + SMPL_MSR_RESULT_INCLUSION_FILE;
- CIncAFileMgrPtr pIncAFileMgr = CIncAFileMgrPtr(new CIncAFileMgr(strIncAFilename));
- pIncAFileMgr->SetParticleList(listFieldParticle, TRUE);
- if (!pIncAFileMgr->Update(strIncAFilename))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SaveFieldFiles: save inclusion file failed."));
- return FALSE;
- }
- }
- pSmplMsrResultFile->SetFieldData(listFieldData);
- // 2. Update measure result message.
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample pointer."));
- return FALSE;
- }
- CMsrResultsPtr poMsrResults = CMsrResultsPtr(new CMsrResults());
- // go through the particles list
- for (auto pParticle : listParticle)
- {
- // create a measure result item
- CMsrResultItemPtr pMsrResultItem = CMsrResultItemPtr(new CMsrResultItem());
- pMsrResultItem->SetTypeId(pParticle->GetType());
- pMsrResultItem->SetArea((int)(pParticle->GetArea() + 0.5));
- pMsrResultItem->SetNumber(1);
- // add the particle into to field data
- poMsrResults->CumulateMeasureResults(pMsrResultItem);
- }
- pSample->SetMsrResults(poMsrResults);
- // 3. Update sample STD
- CMsrParamsPtr poMsrParams = pSample->GetMsrParams();
- ASSERT(poMsrParams);
- if (!poMsrParams)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample parameter pointer."));
- return FALSE;
- }
- poMsrParams->SetPartSTDData(pPartSTDData);
- // 4. write sample measure result file.
- // sample measure result file
- CString strFilePathName = pSmplMsrResultMgr->GetPathName();
- if (!pSmplMsrResultMgr->Save(strFilePathName))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample pointer."));
- return FALSE;
- }
- }
- return TRUE;
- }
- // get inclusion index
- double CReportProjFileMgr::GetInclusionIndex()
- {
- // get folder name from general parameter.
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: Can't find the folder."));
- return -1;
- }
- double dScale = m_pReportProjFile->GetScale();
- double dTotalMeasuredArea = 0.0;
- double dInclusionArea = 0.0;
- CSmplMsrResultFileMgrList m_listSmplMsrResultMgrs;
- for (auto pSmplMsrResultMgr : m_listSmplMsrResultMgrs)
- {
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample measure result file pointer."));
- return -1;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample pointer."));
- return -1;
- }
- CMsrResultsPtr poMsrResults = pSample->GetMsrResults();
- ASSERT(poMsrResults);
- if (!poMsrResults)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample measure result pointer."));
- return -1;
- }
- dTotalMeasuredArea += poMsrResults->GetMeasuredArea();
- CMsrResultItemsList listResultItems = poMsrResults->GetResultItems();
- for (auto pItem : listResultItems)
- {
- int nType = pItem->GetTypeId();
- if (nType > (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- dInclusionArea += pItem->GetArea();
- }
- }
- }
- return dInclusionArea / dTotalMeasuredArea * dScale;
- }
- // classify particles
- BOOL CReportProjFileMgr::ClassifyParticles(COTSParticleList& a_listAnalysisParticles, CPosXraysList& a_listAnalysisXRay)
- {
- // make sure the two lists are same size
- int nSize = (int)a_listAnalysisParticles.size();
- if (nSize != (int)a_listAnalysisXRay.size())
- {
- // particles list size is different with x-ray size
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: particles list size is different with x-ray size."));
- return FALSE;
- }
- // go through all analysis particles
- for (int i = 0; i < nSize; ++i)
- {
- COTSParticlePtr pParticle = a_listAnalysisParticles[i];
- int nAnalysisXrayId = pParticle->GetAnalysisId();
- if (nAnalysisXrayId < 0 || nAnalysisXrayId >= nSize)
- {
- // particles list size is different with x-ray size
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: particles xray id is wrong."));
- return FALSE;
- }
- int nFieldId = pParticle->GetFieldId();
- //using on classify debug,trace fieldid and analysisxrayid
- if (nFieldId == 135 && nAnalysisXrayId == 38)
- {
- int a = 0;
- }
- auto itr = std::find_if(a_listAnalysisXRay.begin(), a_listAnalysisXRay.end(), [nAnalysisXrayId, nFieldId](CPosXrayPtr p) { return (p->GetScanFieldId() == nFieldId && p->GetIndex() == nAnalysisXrayId); });
- if (itr == a_listAnalysisXRay.end())
- {
- return FALSE;
- }
- CPosXrayPtr pXray = *itr;
- if (!ClassifyParticle(pParticle, pXray))
- {
- // failed to call ClassifyParticle method
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: failed to call ClassifyParticle method."));
- return FALSE;
- }
- }
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::ClassifyParticle(COTSParticlePtr a_pParticle, CPosXrayPtr a_pXRay)
- {
- // safety check
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- // invalid sample pointer.
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid sample pointer."));
- return FALSE;
- }
- ASSERT(a_pParticle);
- if (!a_pParticle)
- {
- // invalid particle pointer.
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid particle pointer."));
- return FALSE;
- }
- ASSERT(a_pXRay);
- if (!a_pXRay)
- {
- // invalid x-ray pointer.
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid x-ray pointer."));
- return FALSE;
- }
- //2019.3.28 code changes
- //initial inclusion ID is NOT_IDENTIFIED
- int nIncId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
- //get STDData from Reportprojfile
- CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- //get element chemistries list from xray
- CElementChemistriesList listElementChemistriesOld = a_pXRay->GetElementQuantifyData();
- auto pSample = m_listSmplMgrs[m_nWorkingSampeIndex]->GetSmplMsrResultFile()->GetSample();
- //get the parameter MsrParam object
- CMsrParamsPtr pMsrParam = pSample->GetMsrParams();
- //get the steel technology parameter
- STEEL_TECHNOLOGY steelTech = pMsrParam->GetSteelTechnology();
- //get standard database item which will be used when classify.
- //third setp.the particle are classified
- if (!COTSClassifyEng::ClassifyXray(pPartSTDData, steelTech, listElementChemistriesOld, nIncId))
- {// invalid x-ray pointer.
- LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: can't identify the particle as any inclusion."));
- return FALSE;
- }
- if (nIncId < 8)
- {
- nIncId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
- }
- a_pParticle->SetType(nIncId);
- // ok, return TRUE
- return TRUE;
- }
- // protected
- // get data source name list
- std::vector<CString> CReportProjFileMgr::GetDataSourceNamesList()
- {
- std::vector<CString> listDataSourceNames;
- CString strComSourceName = _T("");
- int nComNum = 0;
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
- {
- // sample measure result file
- CString strFilePathName = pSmplMsrResultFileMgr->GetPathName();
- // get data source name
- CString strDataSource = COTSHelper::GetFileName(strFilePathName);
- // get compound source name
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
- break;
- }
- BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
- if (bSwitch)
- {
- strComSourceName += strDataSource + _T("+");
- nComNum++;
- }
- // add data source name into the list
- listDataSourceNames.push_back(strDataSource);
- }
- if (nComNum > 1)
- {
- //listDataSourceNames.push_back(strComSourceName);
- strComSourceName.TrimRight(_T("+"));//去掉最后的+号
- listDataSourceNames.insert(listDataSourceNames.begin(), strComSourceName);
- }
- return listDataSourceNames;
- }
- std::vector<int> CReportProjFileMgr::GetDataSourcePosList()
- {
- std::vector<int> listDataSourcePos;
- if (!IsHaveMultiDataSource())
- {
- return listDataSourcePos;
- }
- int nPos = -1;
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
- {
- nPos++;
- // get compound source name
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
- break;
- }
- BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
- if (bSwitch)
- {
- listDataSourcePos.push_back(nPos);
- }
- }
- return listDataSourcePos;
- }
- // get property parameter
- // compute particle general information
- CGridDatasList CReportProjFileMgr::CompParticleGenInfo()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- std::vector<int> listSelectedPos;
- if (IsHaveMultiDataSource() && (int)listSelectedDataSource.size() > 1)
- {
- listSelectedPos = GetDataSourcePosList();
- if ((int)listSelectedPos.size() != (int)listSelectedDataSource.size())
- {
- return listGridData;
- }
- }
- int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- //// data source id
- pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
- int nDataSourceId = -1;
- if (IsHaveMultiDataSource())
- {
- if (listSelectedDataSource.size() > 1)
- {
- nDataSourceId = listSelectedPos[nIndex];
- }
- else
- {
- nDataSourceId = m_CurrentPropParam->GetDataSourceId() - 1;
- }
- }
- else
- {
- nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- }
- pGridData->SetDataSourceId(nDataSourceId);
- //------------select xray data add 2019-06-15-----------------
- COTSParticleList listParticleAll;
- listParticleAll.clear();
- CPosXraysList listXrayOut;
- listXrayOut.clear();
- CPosXraysList listXray;
- listXray.clear();
- COTSParticleList selectedParts = m_CurrentPropParam->GetSelectParticle();
- // add filter select particle
- COTSParticleList* pSelectedParts;
- listXrayOut = GetAnalysisXrayList(strDataSourceName);
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- listParticleAll = m_CurrentPropParam->GetSelectParticle();
- pSelectedParts = &selectedParts;
- for (auto pParticle : listParticleAll)
- {
- int nIndex = pParticle->GetAnalysisId();
- int nField = pParticle->GetFieldId();
- auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
- if (itr == listXrayOut.end())
- {
- continue;
- }
- else
- {
- CPosXrayPtr pXray = *itr;
- listXray.push_back(pXray);
- }
- }
- }
- else
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- pSelectedParts = &listParticleAll;
- for (auto pXray : listXrayOut)
- {
- //CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
- listXray.push_back(pXray);
- }
- }
- //-----------------------------------------------------------
- //get pixel size
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample result file manager."));
- return listGridData;
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample result file."));
- return listGridData;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample."));
- return listGridData;
- }
- double dPixelSize = pSample->CalculatePixelSize();
- if (!GetGenInfoFromParticleList(*pSelectedParts, listXray, dPixelSize, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- nIndex++;
- }
- return listGridData;
- }
- COTSParticleList CReportProjFileMgr::GetAnalysisParticleList(CString a_DataSourceName)
- {
- COTSParticleList listParticleAll;
- // compound sample measure result files
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
- if (!pSmplMsrResultFileMgr->ComputeParticleList())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAnalysisParticleList: can't get particle list."));
- return listParticleAll;
- }
- listParticleAll = pSmplMsrResultFileMgr->GetParticleList();
- return listParticleAll;
- }
- CPosXraysList CReportProjFileMgr::GetAnalysisXrayList(CString a_DataSourceName)
- {
- CPosXraysList listAnalysisXray;
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
- pSmplMsrResultFileMgr->GetOTSFldMgrListAndAnalysisXrayList();
- // should first read x ray data from data base.
- listAnalysisXray = pSmplMsrResultFileMgr->GetAnalysisXray();
- return listAnalysisXray;
- }
- CSTDItemPtr CReportProjFileMgr::GetParticleSTDItem(int STDItemId) {
- // std
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: empty project file."));
- return nullptr;
- }
- CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- ASSERT(pPartSTDData);
- if (!pPartSTDData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: invalid STD data."));
- return nullptr;
- }
- CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
- if (listSTDItem.empty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: empty STD Item."));
- return nullptr;
- }
- auto itr = std::find_if(listSTDItem.begin(), listSTDItem.end(), [STDItemId](CSTDItemPtr p) {return (p->GetSTDId() == STDItemId); });
- if (itr == listSTDItem.end()) //没有找到,标明这是一个未识别颗粒,类型为7
- {
- return nullptr;
- }
- CSTDItemPtr p = *itr;
- return p;
- }
- bool CReportProjFileMgr::GetSTDMapedParticleList(const COTSParticleList& a_listParticle, map<int, COTSParticleList>* mapSameSTDPartList)
- {
- //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
- map<int, COTSParticleList>::iterator partListIter;
- //get the same type particle together
- for (auto pParticle : a_listParticle)
- {
- int nType = pParticle->GetType();
- //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
- if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- partListIter = mapSameSTDPartList->find(nType);
- if (partListIter == mapSameSTDPartList->end())
- {
- COTSParticleList listParticle;
- listParticle.push_back(pParticle);
- mapSameSTDPartList->insert(pair<int, COTSParticleList>(nType, listParticle));
- }
- else
- {
- partListIter->second.push_back(pParticle);
- }
- }
- }
- return true;
- }
- // compute particle general information according to particle list
- BOOL CReportProjFileMgr::GetGenInfoFromParticleList(COTSParticleList a_listParticle, CPosXraysList a_listXray, double a_dPixelSize, CGridDataPtr a_pGridData)
- {
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetGenInfoFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- COTSParticleList listPartReport;
- map<int, COTSParticleList> mapSameSTDItemPartList;
- this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
- COTSParticleList listNotIdentified;
- COTSParticleList listSiC;
- COTSParticleList listFeO;
- for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
- {
- if (partListIter->first != (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- listPartReport.insert(listPartReport.end(), partListIter->second.begin(), partListIter->second.end());
- }
- else if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- listSiC = partListIter->second;
- }
- else if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
- {
- listFeO = partListIter->second;
- }
- else
- {
- listNotIdentified = partListIter->second;
- }
- }
- listPartReport.insert(listPartReport.end(), listSiC.begin(), listSiC.end());
- listPartReport.insert(listPartReport.end(), listFeO.begin(), listFeO.end());
- listPartReport.insert(listPartReport.end(), listNotIdentified.begin(), listNotIdentified.end());
- int nColumnNum = ((int)(REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MAX) - (int)(REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_PARTICLE_GEN_INFO_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: Can't get column name number."));
- return FALSE;
- }
- //将元素进行分栏显示汇总集合
- vector< CElementChemistriesList> vec_CElementChemistriesList;
- vec_CElementChemistriesList.clear();
- CGridColumnsList listGridColumn;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- int nType = 0;
- int nPos = 0;
- double a_dPartFTD;
- double a_dMinWidth;
- double a_dMaxLength;
- //double a_dRatio;
- switch (i)
- {
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::NAME:
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- nType = pParticle->GetType();
- if (nType >= (int)OTS_PARTCLE_TYPE::IDENTIFIED)
- {
- std::string strName = pParticle->TypeName();
- pGridRow->SetStringValue(strName.c_str());
- }
- else
- {
- int nColumnNum = ((int)(REPORT_SORT_CLASS_GRID_CLUMN::MAX) - (int)(REPORT_SORT_CLASS_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_SORT_CLASS_START, nColumnNum);
- if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_IDENTIFIED]);//未知颗粒
- }
- else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_SIC]);//SiC
- }
- else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
- {
- pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_FEO]);//FeO
- }
- }
- listGridRows.push_back(pGridRow);
- //获取element数据
- int XrayId = pParticle->GetAnalysisId();
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
- CPosXrayPtr pXray = *itr;
- CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
- //将获取到的元素先都添加到元素的List当中
- vec_CElementChemistriesList.push_back(listTpElement);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::IMAGE:
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- //COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- pGridRow->SetParticle(pParticle);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MAXLENGTH://最长直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- a_dMaxLength = pParticle->GetDMax();
- pGridRow->SetDoubleValue(a_dMaxLength);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MINLENGTH://最短直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- a_dMinWidth = pParticle->GetDMin();
- pGridRow->SetDoubleValue(a_dMinWidth);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::AXIALRATIO://长短直径比
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- a_dMinWidth = pParticle->GetDMax();
- a_dMaxLength = pParticle->GetDMin();
- double d_axialratio = 0;
- if (a_dMinWidth != 0)
- {
- d_axialratio = a_dMaxLength / a_dMinWidth;
- }
- pGridRow->SetDoubleValue(d_axialratio);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::EquivalentCircleDiameter://等效圆直径
- listGridRows.clear();
- //double Diameter;
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double Diameter = pParticle->GetEqualCircleDiameter();
- pGridRow->SetDoubleValue(Diameter);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::FerretDiameter://费雷特直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- a_dPartFTD = (pParticle->GetDMax() + pParticle->GetDMin()) / 2;
- //a_dPartFTD = pParticle->GetFeretDiameter();
- pGridRow->SetDoubleValue(a_dPartFTD);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::SIZE:
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dSize = pParticle->GetArea();
- pGridRow->SetDoubleValue(dSize);
- listGridRows.push_back(pGridRow);
- //pParticle->GetFeretDiameter();
- }
- break;
- //2020-4-11 add new calc type
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::PERP: //正交直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dPerp = pParticle->GetDPerp();
- pGridRow->SetDoubleValue(dPerp);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::PERI: //周长
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dPeri = pParticle->GetPerimeter();
- pGridRow->SetDoubleValue(dPeri);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::INSCR: //内接圆直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dInscr = pParticle->GetDInscr();
- pGridRow->SetDoubleValue(dInscr);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MEAN: //内接圆平均直径
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dMean = pParticle->GetDMean();
- pGridRow->SetDoubleValue(dMean);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ELONG: //展开长度
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dElong = pParticle->GetDElong();
- pGridRow->SetDoubleValue(dElong);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ASPECT_ELONG: //展开长度比
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dAspectElong = pParticle->GetAspectElong();
- pGridRow->SetDoubleValue(dAspectElong);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ASPECT_MAX: //展开直径比
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dAspectRatio = pParticle->GetAspectRatio();
- pGridRow->SetDoubleValue(dAspectRatio);
- listGridRows.push_back(pGridRow);
- }
- break;
- case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::Orientation: //朝向角度
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dOrientation = pParticle->GetOrientation();
- pGridRow->SetDoubleValue(dOrientation);
- listGridRows.push_back(pGridRow);
- }
- break;
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- //定义一个不显示的元素字符列表
- vector<CString> vec_NotDisplayed;
- vec_NotDisplayed.clear();
- //上面获取完成vector CElementChemistriesList 后,再对该列表取出不同元素名的所有元素的总数
- vector<CString> vec_CString;
- vec_CString.clear();
- for (auto pListTpElement : vec_CElementChemistriesList)
- {
- for (auto pCElementChemistry : pListTpElement)
- {
- CString ls_CString = pCElementChemistry->GetName();
- //判断是否已经添加完在字符列表中了
- bool b_sfcz = false;
- for (int i = 0; i < vec_CString.size(); i++)
- {
- if (vec_CString[i] == ls_CString)
- {
- b_sfcz = true;
- break;
- }
- }
- //判断是否在不显示的元素列表中
- for (int i = 0; i < vec_NotDisplayed.size(); i++)
- {
- if (vec_NotDisplayed[i] == ls_CString)
- {
- b_sfcz = true;
- break;
- }
- }
- //未添加进列表中,及不在不显示的元素列表中的话,对该元素进行添加
- if (b_sfcz == false)
- {
- vec_CString.push_back(ls_CString);
- }
- }
- }
- ////获得了总数后,再添加Column,
- for (unsigned int i = 0; i < vec_CString.size(); i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(vec_CString[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- for (auto pParticle : listPartReport)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- int XrayId = pParticle->GetAnalysisId();
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
- if (itr == a_listXray.end())
- {
- break;
- }
- else
- {
- //找到了的情况下,与之对应取出
- CPosXrayPtr pXray = *itr;
- CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
- for (int k = 0; k < (int)listTpElement.size(); k++)
- {
- if (listTpElement[k]->GetName() == vec_CString[i])
- {
- //对应到了该列,将重量比添加到row中
- pGridRow->SetDoubleValue(listTpElement[k]->GetPercentage());
- }
- }
- //pGridRow->SetDoubleValue(listTpElement[0]->GetPercentage());
- }
- //从该颗粒中,查找与vec_CString[i]对应的元素,找到的话,取出重量比
- listGridRows.push_back(pGridRow);
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- //reset load param file
- //过滤要显示的列
- CGridColumnsList::iterator itr = listGridColumn.begin();
- while (itr != listGridColumn.end())
- {
- if (EstimateShowColumn((*itr)->GetName()) == false)
- {
- itr = listGridColumn.erase(itr);
- continue;
- }
- itr++;
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- //判断该列是否要显示
- BOOL CReportProjFileMgr::EstimateShowColumn(CString a_strColName)
- {
- CString str_Area_Enum = "Area";
- CString str_MaxDiameter_Enum = "MaxDiameter";
- CString str_MinDiameter_Enum = "MinDiameter";
- CString str_DiameterRatio_Enum = "DiameterRatio";
- CString str_EquivalentCircleDiameter_Enum = "EquivalentCircleDiameter";
- CString str_FerretDiameter_Enum = "FerretDiameter";
- CString str_Area_CN = "颗粒面积";
- CString str_MaxDiameter_CN = "最长直径";
- CString str_MinDiameter_CN = "最短直径";
- CString str_DiameterRatio_CN = "长短直径比";
- CString str_EquivalentCircleDiameter_CN = "等效圆直径";
- CString str_FerretDiameter_CN = "费雷特直径";
- //最后再根据设置默认显示列名,对不需要显示的列进行屏蔽
- CString s_DefaultComputedColName = m_rptparamfile->GetDefaultComputedColName();
- if (a_strColName.Find(str_Area_CN, 0) > -1 || a_strColName.Find(str_MaxDiameter_CN, 0) > -1 ||
- a_strColName.Find(str_MinDiameter_CN, 0) > -1 || a_strColName.Find(str_DiameterRatio_CN, 0) > -1 ||
- a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1 || a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
- {
- //面积
- if (s_DefaultComputedColName.Find(str_Area_Enum) > -1 && a_strColName.Find(str_Area_CN, 0) > -1)
- {
- return true;
- }
- //最长直径
- if (s_DefaultComputedColName.Find(str_MaxDiameter_Enum) > -1 && a_strColName.Find(str_MaxDiameter_CN, 0) > -1)
- {
- return true;
- }
- //最短直径
- if (s_DefaultComputedColName.Find(str_MinDiameter_Enum) > -1 && a_strColName.Find(str_MinDiameter_CN, 0) > -1)
- {
- return true;
- }
- //长短直径比
- if (s_DefaultComputedColName.Find(str_DiameterRatio_Enum) > -1 && a_strColName.Find(str_DiameterRatio_CN, 0) > -1)
- {
- return true;
- }
- //等效圆直径
- if (s_DefaultComputedColName.Find(str_EquivalentCircleDiameter_Enum) > -1 && a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1)
- {
- return true;
- }
- //费雷特直径
- if (s_DefaultComputedColName.Find(str_FerretDiameter_Enum) > -1 && a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
- {
- return true;
- }
- return false;
- }
- return true;
- }
- // compute particle component
- CGridDatasList CReportProjFileMgr::CompParticleComponent()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
- pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
- COTSParticleList* pSelectidParts;
- COTSParticleList listParticleAll;
- COTSParticleList seleParticles;
- // add filter select particle
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- seleParticles = m_CurrentPropParam->GetSelectParticle();
- pSelectidParts = &seleParticles;
- }
- else
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- pSelectidParts = &listParticleAll;
- }
- //get pixel size
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample result file manager."));
- return listGridData;
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample result file."));
- return listGridData;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample."));
- return listGridData;
- }
- double dPixelSize = pSample->CalculatePixelSize();
- if (!GetComponentFromParticleList(*pSelectidParts, m_CurrentPropParam->GetSizeCalMethodType(), dPixelSize, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::GetComponentFromParticleList(COTSParticleList a_listParticle, OTSMODEL::SIZE_CAL_METHOD_TYPE a_nMethod, double a_dPixelSize, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- //// std
- //ASSERT(m_pReportProjFile);
- //if (!m_pReportProjFile)
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty project file."));
- // return FALSE;
- //}
- //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- //ASSERT(pPartSTDData);
- //if (!pPartSTDData)
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid STD data."));
- // return FALSE;
- //}
- //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
- //if (listSTDItem.empty())
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty STD Item."));
- // return FALSE;
- //}
- //get the same type particle together
- map<int, COTSParticleList> mapSameSTDItemPartList;
- map<int, COTSParticleList>::iterator partListIter;
- this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
- /*CSTDItemsList listHavePartSTDItem;
- for (auto STDItem : listSTDItem)
- {
- auto partListIter = mapSameSTDItemPartList.find(STDItem->GetSTDId());
- if (partListIter != mapSameSTDItemPartList.end())
- {
- listHavePartSTDItem.push_back(STDItem);
- }
- }*/
- int nColumnNum = ((int)(REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MAX) - (int)(REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_PARTICLE_COMPONENT_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: Can't get column name number."));
- return FALSE;
- }
- CGridColumnsList listGridColumn;
- COTSParticleList listPartReport;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- switch (i)
- {
- case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::NAME:
- {
- // std item name
- listGridRows.clear();
- for (auto STDPart : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- std::string name = STDPart.second[0]->TypeName();
- //pGridRow->SetStringValue(STDPart->GetName ());
- pGridRow->SetStringValue(name.c_str());
- listGridRows.push_back(pGridRow);
- }
- auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
- if (itr != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strUndefined;
- strUndefined = MultiLang::GetInstance().GetCStringByKey(IDS_UNDEFINED_PARTICLE);
- pGridRowUndefined->SetStringValue(strUndefined);
- listGridRows.push_back(pGridRowUndefined);
- }
- auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strSiC;
- strSiC = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);
- pGridRowSiC->SetStringValue(strSiC);
- listGridRows.push_back(pGridRowSiC);
- }
- auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strFeO;
- strFeO = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);
- pGridRowFeO->SetStringValue(strFeO);
- listGridRows.push_back(pGridRowFeO);
- }
- }
- break;
- case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::COLOUR:
- {
- // std item color
- listGridRows.clear();
- for (auto STDPart : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- std::string color = STDPart.second[0]->TypeColor();
- pGridRow->SetStringValue(color.c_str());
- listGridRows.push_back(pGridRow);
- }
- auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
- if (itr != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strUndefinedColour = _T("");
- pGridRowUndefined->SetStringValue(strUndefinedColour);
- listGridRows.push_back(pGridRowUndefined);
- }
- auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strSiCColour = _T("");
- pGridRowSiC->SetStringValue(strSiCColour);
- listGridRows.push_back(pGridRowSiC);
- }
- auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strFeOColour = _T("");
- pGridRowFeO->SetStringValue(strFeOColour);
- listGridRows.push_back(pGridRowFeO);
- }
- }
- break;
- case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::PARTICLE_NUM:
- { // get each type particle num
- int nParticleUndefined = 0;
- int nParticleSiC = 0;
- int nParticleFeO = 0;
- for (auto pSTDItem : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- int nParticleNum = pSTDItem.second.size();
- pGridRow->SetIntValue(nParticleNum);
- listGridRows.push_back(pGridRow);
- }
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
- if (itr != mapSameSTDItemPartList.end())
- {
- nParticleUndefined = itr->second.size();
- }
- else
- {
- nParticleUndefined = 0;
- }
- if (0 != nParticleUndefined)
- {
- pGridRowUndefined->SetIntValue(nParticleUndefined);
- listGridRows.push_back(pGridRowUndefined);
- }
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- nParticleSiC = itrSiC->second.size();
- }
- else
- {
- nParticleSiC = 0;
- }
- if (0 != nParticleSiC)
- {
- pGridRowSiC->SetIntValue(nParticleSiC);
- listGridRows.push_back(pGridRowSiC);
- }
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- nParticleFeO = itrFeO->second.size();
- }
- else
- {
- nParticleFeO = 0;
- }
- if (0 != nParticleFeO)
- {
- pGridRowFeO->SetIntValue(nParticleFeO);
- listGridRows.push_back(pGridRowFeO);
- }
- }
- break;
- case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::AVE_VALUE:
- {
- // get particle average area
- int nParticleUndefined = 0;
- double dAveValueUndefined = 0;
- int nParticleSiC = 0;
- double dAveValueSiC = 0;
- int nParticleFeO = 0;
- double dAveValueFeO = 0;
- for (auto pSTDPart : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- int nParticleNum = 0;
- double dAveValue = 0;
- COTSParticleList listPartReport = pSTDPart.second;
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- nParticleNum++;
- dAveValue += dValue;
- }
- if (nParticleNum != 0)
- {
- dAveValue = dAveValue / (double)nParticleNum;
- }
- pGridRow->SetDoubleValue(dAveValue);
- listGridRows.push_back(pGridRow);
- }
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
- if (itr != mapSameSTDItemPartList.end())
- {
- nParticleUndefined = itr->second.size();
- listPartReport = itr->second;
- }
- else
- {
- nParticleUndefined = 0;
- }
- if (nParticleUndefined != 0)
- {
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- dAveValueUndefined += dValue;
- }
- if (nParticleUndefined != 0)
- {
- dAveValueUndefined = dAveValueUndefined / (double)nParticleUndefined;
- }
- pGridRow->SetDoubleValue(dAveValueUndefined);
- listGridRows.push_back(pGridRow);
- }
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- nParticleSiC = itrSiC->second.size();
- listPartReport = itrSiC->second;
- }
- else
- {
- nParticleSiC = 0;
- }
- if (nParticleSiC != 0)
- {
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- dAveValueSiC += dValue;
- }
- if (nParticleSiC != 0)
- {
- dAveValueSiC = dAveValueSiC / (double)nParticleSiC;
- }
- pGridRowSiC->SetDoubleValue(dAveValueSiC);
- listGridRows.push_back(pGridRowSiC);
- }
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- nParticleFeO = itrFeO->second.size();
- listPartReport = itrFeO->second;
- }
- else
- {
- nParticleFeO = 0;
- }
- if (nParticleFeO != 0)
- {
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- dAveValueFeO += dValue;
- }
- if (nParticleFeO != 0)
- {
- dAveValueFeO = dAveValueFeO / (double)nParticleFeO;
- }
- pGridRowFeO->SetDoubleValue(dAveValueFeO);
- listGridRows.push_back(pGridRowFeO);
- }
- }
- break;
- case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MAX_VALUE:
- {
- // get particle max area
- double dMaxValueUndefined = 0;
- double dMaxValueSiC = 0;
- double dMaxValueFeO = 0;
- double dMaxValue = 0;
- for (auto pSTDPart : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- dMaxValue = 0;
- COTSParticleList listPartReport = pSTDPart.second;
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- if (dValue > dMaxValue)
- {
- dMaxValue = dValue;
- }
- }
- pGridRow->SetDoubleValue(dMaxValue);
- listGridRows.push_back(pGridRow);
- }
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
- listPartReport.clear();
- if (itr != mapSameSTDItemPartList.end())
- {
- listPartReport = itr->second;
- }
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- if (dValue > dMaxValueUndefined)
- {
- dMaxValueUndefined = dValue;
- }
- }
- if (itr != mapSameSTDItemPartList.end())
- {
- pGridRowUndefined->SetDoubleValue(dMaxValueUndefined);
- listGridRows.push_back(pGridRowUndefined);
- }
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
- listPartReport.clear();
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- listPartReport = itrSiC->second;
- }
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- if (dValue > dMaxValueSiC)
- {
- dMaxValueSiC = dValue;
- }
- }
- if (itrSiC != mapSameSTDItemPartList.end())
- {
- pGridRowSiC->SetDoubleValue(dMaxValueSiC);
- listGridRows.push_back(pGridRowSiC);
- }
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
- listPartReport.clear();
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- listPartReport = itrFeO->second;
- }
- for (auto pParticle : listPartReport)
- {
- double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
- if (dValue > dMaxValueFeO)
- {
- dMaxValueFeO = dValue;
- }
- }
- if (itrFeO != mapSameSTDItemPartList.end())
- {
- pGridRowFeO->SetDoubleValue(dMaxValueFeO);
- listGridRows.push_back(pGridRowFeO);
- }
- }
- break;
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute element component
- CGridDatasList CReportProjFileMgr::CompElementComponent()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
- pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
- COTSParticleList listParticleAll;
- listParticleAll.clear();
- CPosXraysList listXrayOut;
- listXrayOut.clear();
- CPosXraysList listXray;
- listXray.clear();
- listXrayOut = GetAnalysisXrayList(strDataSourceName);
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::ALL)
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- for (auto pXray : listXrayOut)
- {
- CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
- listXray.push_back(pXrayNew);
- }
- }
- else if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- listParticleAll = m_CurrentPropParam->GetSelectParticle();
- for (auto pParticle : listParticleAll)
- {
- int nIndex = pParticle->GetAnalysisId();
- int nField = pParticle->GetFieldId();
- auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
- if (itr == listXrayOut.end())
- {
- continue;
- }
- else
- {
- CPosXrayPtr pXray = *itr;
- CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
- listXray.push_back(pXrayNew);
- }
- }
- }
- if (!GetElementComponentFromParticleList(listParticleAll, listXray, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::GetElementComponentFromParticleList(COTSParticleList a_listParticleAll, CPosXraysList a_listXray, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- // std
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: empty project file."));
- return FALSE;
- }
- int nColumnNum = ((int)(REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MAX) - (int)(REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_ELEMENT_COMPONENT_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: Can't get column name number."));
- return FALSE;
- }
- COTSParticleList listParticleAnalysis;
- listParticleAnalysis.clear();
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listParticleAnalysis.push_back(pParticleNew);
- }
- }
- CElementChemistriesList listElementResult = GetUndefinedElementList(listParticleAnalysis, a_listXray);
- //Draw the grid
- CGridColumnsList listGridColumn;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- switch (i)
- {
- case (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NAME:
- { // std item name
- listGridRows.clear();
- for (auto pElement : listElementResult)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strElementName = pElement->GetName();
- pGridRow->SetStringValue(strElementName);
- listGridRows.push_back(pGridRow);
- }
- }
- break;
- case (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NUM:
- { // std item name
- listGridRows.clear();
- for (auto pElement : listElementResult)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strElementNum = _T("");
- double dPercent = pElement->GetPercentage();
- strElementNum.Format(_T("%f"), dPercent);
- strElementNum += "%";
- pGridRow->SetStringValue(strElementNum);
- listGridRows.push_back(pGridRow);
- }
- }
- break;
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute particle size distribution
- CGridDatasList CReportProjFileMgr::CompParticleSizeDistribution()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList* pSelectidParts;
- COTSParticleList listParticleAll;
- COTSParticleList seleParticles;
- // add filter select particle
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- seleParticles = m_CurrentPropParam->GetSelectParticle();
- pSelectidParts = &seleParticles;
- }
- else
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- pSelectidParts = &listParticleAll;
- }
- //get pixel size
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample result file manager."));
- return listGridData;
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample result file."));
- return listGridData;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample."));
- return listGridData;
- }
- double dPixelSize = pSample->CalculatePixelSize();
- if (!GetSizeDistributionFromParticleList(*pSelectidParts, pGridData, dPixelSize))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::IsHaveMultiDataSource()
- {
- int nMultiCount = 0;
- for (auto SmplMgr : m_listSmplMgrs)
- {
- CSmplMsrResultFilePtr pSmpl = SmplMgr->GetSmplMsrResultFile();
- if (pSmpl->GetSwitch())
- {
- nMultiCount++;
- }
- }
- if (nMultiCount > 1)
- {
- return TRUE;
- }
- return FALSE;
- }
- BOOL CReportProjFileMgr::GetSizeDistributionFromParticleList(COTSParticleList a_listParticle, CGridDataPtr a_pGridData, double a_dPixelSize)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- //size
- CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
- ASSERT(pPartSize);
- if (!pPartSize)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid pPartSize data."));
- return FALSE;
- }
- CPartSizeItemList listPartSize = pPartSize->GetPartSizeList();
- if (listPartSize.empty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: empty pPartSize Item."));
- return FALSE;
- }
- //get the same type particle together
- map<int, COTSParticleList> mapSameSTDItemPartList;
- map<int, COTSParticleList>::iterator partListIter;
- this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
- COTSParticleList listNotIdentified;
- for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
- {
- if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- listNotIdentified = partListIter->second;
- }
- }
- COTSParticleList listSiC;
- for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
- {
- if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- listSiC = partListIter->second;
- }
- }
- COTSParticleList listFeO;
- for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
- {
- if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
- {
- listFeO = partListIter->second;
- }
- }
- int nColumnNum = ((int)(REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MAX) - (int)(REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_PARTICLE_COMPONENT_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: Can't get column name number."));
- return FALSE;
- }
- CGridColumnsList listGridColumn;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- switch (i)
- {
- case (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::NAME:
- {
- // std item name
- listGridRows.clear();
- for (auto sItemName : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- pGridRow->SetStringValue(sItemName.second[0]->TypeName().c_str());
- listGridRows.push_back(pGridRow);
- }
- if (!listNotIdentified.empty())
- {
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strUndefined;
- strUndefined = MultiLang::GetInstance().GetCStringByKey(IDS_UNDEFINED_PARTICLE);//“未识别颗粒”
- pGridRowUndefined->SetStringValue(strUndefined);
- listGridRows.push_back(pGridRowUndefined);
- }
- if (!listSiC.empty())
- {
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strSIC;
- strSIC = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);//“未识别颗粒SiC”
- pGridRowSiC->SetStringValue(strSIC);
- listGridRows.push_back(pGridRowSiC);
- }
- if (!listFeO.empty())
- {
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strFeO;
- strFeO = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);//“未识别颗粒”
- pGridRowFeO->SetStringValue(strFeO);
- listGridRows.push_back(pGridRowFeO);
- }
- //个数
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strNum;
- strNum = MultiLang::GetInstance().GetCStringByKey(IDS_NUM);
- pGridRowNum->SetStringValue(strNum);
- listGridRows.push_back(pGridRowNum);
- break;
- }
- case (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::COLOUR:
- {
- // std item colour
- listGridRows.clear();
- for (auto parts : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- pGridRow->SetStringValue(parts.second[0]->TypeColor().c_str());
- listGridRows.push_back(pGridRow);
- }
- if (!listNotIdentified.empty())
- {
- CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
- pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strUndefinedColour = _T("");
- pGridRowUndefined->SetStringValue(strUndefinedColour);
- listGridRows.push_back(pGridRowUndefined);
- }
- if (!listSiC.empty())
- {
- CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
- pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strSiCColour = _T("");
- pGridRowSiC->SetStringValue(strSiCColour);
- listGridRows.push_back(pGridRowSiC);
- }
- if (!listFeO.empty())
- {
- CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
- pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strFeOColour = _T("");
- pGridRowFeO->SetStringValue(strFeOColour);
- listGridRows.push_back(pGridRowFeO);
- }
- //颜色行补齐行
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strColorNumber = _T("");
- pGridRowNum->SetStringValue(strColorNumber);
- listGridRows.push_back(pGridRowNum);
- break;
- }
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- //ParticleAmount
- double dParticleAmount = 0;
- for (unsigned int i = 0; i < a_listParticle.size(); i++)
- {
- if (a_listParticle[i]->GetAnalysisId() > -1)
- dParticleAmount++;
- }
- //add item
- for (auto partsizeItem : listPartSize)
- {
- CDoubleRangePtr level = partsizeItem->GetSizeLevel();
- double dStart = level->GetStart();
- double dEnd = level->GetEnd();
- CString ColumnName = _T("");
- //ColumnName = dStart + "-" + dEnd;
- ColumnName = partsizeItem->GetName();
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(ColumnName);
- double dColumnAmount = 0;
- CGridRowsList listGridRows;
- listGridRows.clear();
- int nTypeId;
- double dParticleUndefined = (double)listNotIdentified.size();
- double dParticleSiC = (double)listNotIdentified.size();
- double dParticleFeO = (double)listNotIdentified.size();
- for (auto pSTDPart : mapSameSTDItemPartList)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- bool bAdd = true;
- double dParticleNum = 0;
- for (auto pParticle : pSTDPart.second)
- {
- SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
- double dValue = GetValueAsMethod(pParticle, Method, a_dPixelSize);
- if (dValue >= dStart && dValue < dEnd)
- {
- dParticleNum++;
- }
- }
- pGridRow->SetIntValue((int)dParticleNum);
- listGridRows.push_back(pGridRow);
- dColumnAmount += dParticleNum;
- }
- if (!listNotIdentified.empty())
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- double dParticleNumCount = 0;
- for (auto undefinedPart : listNotIdentified)
- {
- SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
- double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
- if (dValue >= dStart && dValue < dEnd)
- {
- dParticleNumCount++;
- }
- }
- pGridRow->SetIntValue((int)dParticleNumCount);
- listGridRows.push_back(pGridRow);
- dColumnAmount += dParticleNumCount;
- }
- //percent
- if (!listSiC.empty())
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- int dParticleNumCount = 0;
- for (auto undefinedPart : listSiC)
- {
- SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
- double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
- if (dValue >= dStart && dValue < dEnd)
- {
- dParticleNumCount++;
- }
- }
- pGridRow->SetIntValue((int)dParticleNumCount);
- listGridRows.push_back(pGridRow);
- dColumnAmount += dParticleNumCount;
- }
- //percent
- if (!listFeO.empty())
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- int dParticleNumCount = 0;
- for (auto undefinedPart : listFeO)
- {
- SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
- double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
- if (dValue >= dStart && dValue < dEnd)
- {
- dParticleNumCount++;
- }
- }
- pGridRow->SetIntValue((int)dParticleNumCount);
- listGridRows.push_back(pGridRow);
- dColumnAmount += dParticleNumCount;
- }
- CGridRowPtr pGridRow2 = CGridRowPtr(new CGridRow());
- pGridRow2->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- double dAPercent = dColumnAmount / dParticleAmount;
- char cColumnAmount[256];
- sprintf(cColumnAmount, "%.0lf", dColumnAmount);
- char cRes[256];
- sprintf(cRes, "%.2lf%%\n", dAPercent * 100);
- CString strResult = cRes;
- strResult = "" + (CString)cColumnAmount + "(" + strResult + ")";
- pGridRow2->SetStringValue(strResult);
- listGridRows.push_back(pGridRow2);
- //addcolum
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute average element component
- CGridDatasList CReportProjFileMgr::CompAveElemnetComponent()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList listParticleAll;
- listParticleAll.clear();
- CPosXraysList listXrayOut;
- listXrayOut.clear();
- CPosXraysList listXray;
- listXray.clear();
- listXrayOut = GetAnalysisXrayList(strDataSourceName);
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::ALL)
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- for (auto pXray : listXrayOut)
- {
- CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
- listXray.push_back(pXrayNew);
- }
- }
- else if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- listParticleAll = m_CurrentPropParam->GetSelectParticle();
- for (auto pParticle : listParticleAll)
- {
- int nIndex = pParticle->GetAnalysisId();
- int nField = pParticle->GetFieldId();
- auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
- if (itr == listXrayOut.end())
- {
- continue;
- }
- else
- {
- CPosXrayPtr pXray = *itr;
- CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
- listXray.push_back(pXrayNew);
- }
- }
- }
- if (!GetAveElementFromParticleList(listParticleAll, listXray, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- //nIndex++;
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::GetAveElementFromParticleList(COTSParticleList a_listParticleAll, CPosXraysList a_listXray, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- // std
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: empty project file."));
- return FALSE;
- }
- std::set<int> allTypeIds;
- allTypeIds.clear();
- COTSParticleList listNotIdentifiedParticle;
- listNotIdentifiedParticle.clear();
- COTSParticleList listSiCParticle;
- listSiCParticle.clear();
- COTSParticleList listFeOParticle;
- listFeOParticle.clear();
- COTSParticleList listIdentifiedParticle;
- listIdentifiedParticle.clear();
- std::vector<CElementChemistriesList> listElementChemistriesList;
- listElementChemistriesList.clear();
- for (auto pParticle : a_listParticleAll)
- {
- int nType = (int)pParticle->GetType();
- // get undefined particle and analysis particle
- if (nType >= (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- if (nType == (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)//不与考虑
- {
- //listNoAnalysisParticle.push_back(pParticleNew);
- }
- else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- listNotIdentifiedParticle.push_back(pParticleNew);
- }
- else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
- {
- listSiCParticle.push_back(pParticleNew);
- }
- else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
- {
- listFeOParticle.push_back(pParticleNew);
- }
- else if (nType >= (int)OTS_PARTCLE_TYPE::USER_DEFINED_MIN)//类型ID号至少1000以上
- {
- listIdentifiedParticle.push_back(pParticleNew);
- allTypeIds.insert(nType);
- }
- }
- }
- //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- //ASSERT(pPartSTDData);
- //if (!pPartSTDData)
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid STD data."));
- // return FALSE;
- //}
- //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
- //if (listSTDItem.empty())
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: empty STD Item."));
- // return FALSE;
- //}
- COTSParticleList listPartReport;
- //get the same type particle together
- map<int, COTSParticleList> mapSameSTDItemPartList;
- map<int, COTSParticleList>::iterator partListIter;
- this->GetSTDMapedParticleList(a_listParticleAll, &mapSameSTDItemPartList);
- // make the first two columns: particle type and area
- CGridColumnsList listGridColumn;
- CGridRowsList listParticleGridRows;
- listParticleGridRows.clear();
- CGridRowsList listAreaGridRows;
- listAreaGridRows.clear();
- COTSParticleList listParticleType;
- COTSParticleList particlesOfThisType;
- listParticleType.clear();
- particlesOfThisType.clear();
- double dAreaTotal = 0;
- for (auto typeId : allTypeIds)
- {
- auto iterParts = mapSameSTDItemPartList.find(typeId);
- if (iterParts == mapSameSTDItemPartList.end())
- {
- continue;
- }
- else
- {
- particlesOfThisType = iterParts->second;
- }
- CGridRowPtr pParticleGridRow = CGridRowPtr(new CGridRow());
- pParticleGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- //CSTDItemPtr STDItem = GetParticleSTDItem(typeId);
- //CSTDItemPtr STDItem = particlesOfThisType[0]->TypeName();
- CString strPartName = particlesOfThisType[0]->TypeName().c_str();
- pParticleGridRow->SetStringValue(strPartName);
- listParticleGridRows.push_back(pParticleGridRow);
- CGridRowPtr pAreaGridRow = CGridRowPtr(new CGridRow());
- pAreaGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- double dArea = 0;
- for (auto pPatTp : particlesOfThisType)
- {
- double dAreaC = pPatTp->GetArea();
- dArea += dAreaC;
- }
- pAreaGridRow->SetDoubleValue(dArea);
- listAreaGridRows.push_back(pAreaGridRow);
- dAreaTotal += dArea;
- // compute Element
- COTSParticlePtr pParticle = particlesOfThisType[0];
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- listParticleType.push_back(pParticleNew);
- int XrayId = pParticle->GetAnalysisId();
- if (XrayId < 0 || XrayId >(int)a_listXray.size())
- {
- continue;
- }
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
- if (itr == a_listXray.end())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't find x-ray."));
- return FALSE;
- }
- CPosXrayPtr pXray = *itr;
- CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
- listElementChemistriesList.push_back(listTpElement);
- }
- //undefined particle area
- double dAreaNotIden = 0;
- for (auto pPUn : listNotIdentifiedParticle)
- {
- double dA = pPUn->GetArea();
- dAreaNotIden += dA;
- }
- dAreaTotal += dAreaNotIden;
- double dAreaSiC = 0;
- for (auto pPUn : listSiCParticle)
- {
- double dA = pPUn->GetArea();
- dAreaSiC += dA;
- }
- dAreaTotal += dAreaSiC;
- double dAreaFeO = 0;
- for (auto pPUn : listFeOParticle)
- {
- double dA = pPUn->GetArea();
- dAreaFeO += dA;
- }
- dAreaTotal += dAreaFeO;
- // area row of undefined and total analysis
- if (!listNotIdentifiedParticle.empty())
- {
- CGridRowPtr pAreaGridRow = CGridRowPtr(new CGridRow());
- pAreaGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pAreaGridRow->SetDoubleValue(dAreaNotIden);
- listAreaGridRows.push_back(pAreaGridRow);
- }
- if (!listSiCParticle.empty())
- {
- CGridRowPtr pAreaSiCGridRow = CGridRowPtr(new CGridRow());
- pAreaSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pAreaSiCGridRow->SetDoubleValue(dAreaSiC);
- listAreaGridRows.push_back(pAreaSiCGridRow);
- }
- if (!listFeOParticle.empty())
- {
- CGridRowPtr pAreaFeOGridRow = CGridRowPtr(new CGridRow());
- pAreaFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pAreaFeOGridRow->SetDoubleValue(dAreaFeO);
- listAreaGridRows.push_back(pAreaFeOGridRow);
- }
- CGridRowPtr pAreaToTalGridRow = CGridRowPtr(new CGridRow());
- pAreaToTalGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pAreaToTalGridRow->SetDoubleValue(dAreaTotal);
- listAreaGridRows.push_back(pAreaToTalGridRow);
- // particle type of undefined and analysis particle
- if (!listNotIdentifiedParticle.empty())
- {
- CGridRowPtr pParticleGridRow = CGridRowPtr(new CGridRow());
- pParticleGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strUndefineName = _T("");
- strUndefineName = MultiLang::GetInstance().GetCStringByKey(IDS_PARTICL_UNDEFINED);
- pParticleGridRow->SetStringValue(strUndefineName);
- listParticleGridRows.push_back(pParticleGridRow);
- }
- if (!listSiCParticle.empty())
- {
- CGridRowPtr pParticleSiCGridRow = CGridRowPtr(new CGridRow());
- pParticleSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strSiCName = _T("");
- strSiCName = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);
- pParticleSiCGridRow->SetStringValue(strSiCName);
- listParticleGridRows.push_back(pParticleSiCGridRow);
- }
- if (!listFeOParticle.empty())
- {
- CGridRowPtr pParticleFeOGridRow = CGridRowPtr(new CGridRow());
- pParticleFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strFeOName = _T("");
- strFeOName = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);
- pParticleFeOGridRow->SetStringValue(strFeOName);
- listParticleGridRows.push_back(pParticleFeOGridRow);
- }
- CGridRowPtr pParticleAGridRow = CGridRowPtr(new CGridRow());
- pParticleAGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
- CString strAnalysisdName = _T("");
- strAnalysisdName = MultiLang::GetInstance().GetCStringByKey(IDS_PARTICL_ANALYSIS);
- pParticleAGridRow->SetStringValue(strAnalysisdName);
- listParticleGridRows.push_back(pParticleAGridRow);
- if (!((int)listParticleGridRows.size() == (int)listAreaGridRows.size()))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: particle num and area num are different."));
- return FALSE;
- }
- // column name of particle type and area
- int nColumnNum = ((int)(REPORT_AVE_ELEMENT_GRID_CLUMN::MAX) - (int)(REPORT_AVE_ELEMENT_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_AVE_ELEMENT_START, nColumnNum);
- // particle type
- CGridColumnPtr pParticleColumn = CGridColumnPtr(new CGridColumn());
- pParticleColumn->SetName(listColumnName[0]);
- pParticleColumn->SetGridRowsList(listParticleGridRows);
- // area
- CGridColumnPtr pAreaColumn = CGridColumnPtr(new CGridColumn());
- pAreaColumn->SetName(listColumnName[1]);
- pAreaColumn->SetGridRowsList(listAreaGridRows);
- listGridColumn.push_back(pParticleColumn);
- listGridColumn.push_back(pAreaColumn);
- // get element area list from particle list
- CElementChemistriesList listUndefinedElement;
- if (!listNotIdentifiedParticle.empty())
- {
- listUndefinedElement = GetUndefinedElementList(listNotIdentifiedParticle, a_listXray);
- listElementChemistriesList.push_back(listUndefinedElement);
- }
- // get element area list from particle list
- CElementChemistriesList listSiCElement;
- if (!listSiCParticle.empty())
- {
- listSiCElement = GetUndefinedElementList(listSiCParticle, a_listXray);
- listElementChemistriesList.push_back(listSiCElement);
- }
- CElementChemistriesList listFeOElement;
- if (!listFeOParticle.empty())
- {
- listFeOElement = GetUndefinedElementList(listFeOParticle, a_listXray);
- listElementChemistriesList.push_back(listFeOElement);
- }
- std::vector<CString> listElementName;
- listElementName.clear();
- for (auto listElement : listElementChemistriesList)
- {
- for (auto pElement : listElement)
- {
- CString strElementName = pElement->GetName();
- if (strElementName.Compare("Fe") == 0)
- {
- continue;
- }
- auto itr = std::find(listElementName.begin(), listElementName.end(), strElementName);
- if (itr == listElementName.end())
- {
- listElementName.push_back(strElementName);
- }
- }
- }
- for (auto strName : listElementName)
- {
- //2020-2-17修改,c元素不再包含显示在元素列表中,并将显示的其它元素重新进行归一化。
- if (strName == "C")
- continue;
- // particle type
- CGridColumnPtr pElementColumn = CGridColumnPtr(new CGridColumn());
- pElementColumn->SetName(strName);
- CGridRowsList listElementGridRows;
- listElementGridRows.clear();
- double dTotalArea = 0.0;
- int nRowNum = 0;
- // analysis particle
- for (auto pParticle : listParticleType)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- int XrayId = pParticle->GetAnalysisId();
- if (XrayId < 0 || XrayId >(int)a_listXray.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get x ray."));
- return FALSE;
- }
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
- if (itr == a_listXray.end())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't find x-ray."));
- return FALSE;
- }
- CPosXrayPtr pXray = *itr;
- CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
- auto itrE = std::find_if(listTpElement.begin(), listTpElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itrE == listTpElement.end())
- {
- pGridRow->SetDoubleValue(0.0);
- }
- else
- {
- CElementChemistriesList listElementNoFe = CPosXray::RemoveFe(listTpElement);
- auto itr = std::find_if(listElementNoFe.begin(), listElementNoFe.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itr == listElementNoFe.end())
- {
- pGridRow->SetDoubleValue(0.0);
- }
- else
- {
- CElementChemistryPtr pElement = *itr;
- double dPercent = pElement->GetPercentage();
- pGridRow->SetDoubleValue(dPercent);
- if (nRowNum < 0 || nRowNum >(int) listAreaGridRows.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get area."));
- return FALSE;
- }
- dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
- }
- }
- nRowNum++;
- listElementGridRows.push_back(pGridRow);
- }
- // undefined particle
- if (!listNotIdentifiedParticle.empty())
- {
- CGridRowPtr pUndefinedGridRow = CGridRowPtr(new CGridRow());
- pUndefinedGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- // get element area list from particle list
- auto itr = std::find_if(listUndefinedElement.begin(), listUndefinedElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itr == listUndefinedElement.end())
- {
- pUndefinedGridRow->SetDoubleValue(0.0);
- }
- else
- {
- CElementChemistryPtr pElement = *itr;
- double dPercent = pElement->GetPercentage();
- pUndefinedGridRow->SetDoubleValue(dPercent);
- dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
- }
- nRowNum++;
- listElementGridRows.push_back(pUndefinedGridRow);
- }
- if (!listSiCParticle.empty())
- {
- CGridRowPtr pSiCGridRow = CGridRowPtr(new CGridRow());
- pSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- // get element area list from particle list
- auto itrSiC = std::find_if(listSiCElement.begin(), listSiCElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itrSiC == listSiCElement.end())
- {
- pSiCGridRow->SetDoubleValue(0.0);
- }
- else
- {
- CElementChemistryPtr pElement = *itrSiC;
- double dPercent = pElement->GetPercentage();
- pSiCGridRow->SetDoubleValue(dPercent);
- dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
- }
- nRowNum++;
- listElementGridRows.push_back(pSiCGridRow);
- }
- if (!listFeOParticle.empty())
- {
- CGridRowPtr pFeOGridRow = CGridRowPtr(new CGridRow());
- pFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- // get element area list from particle list
- auto itrFeO = std::find_if(listFeOElement.begin(), listFeOElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itrFeO == listFeOElement.end())
- {
- pFeOGridRow->SetDoubleValue(0.0);
- }
- else
- {
- CElementChemistryPtr pElement = *itrFeO;
- double dPercent = pElement->GetPercentage();
- pFeOGridRow->SetDoubleValue(dPercent);
- dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
- }
- nRowNum++;
- listElementGridRows.push_back(pFeOGridRow);
- }
- int nAreaSize = (int)listAreaGridRows.size();
- if (!((nRowNum + 1) == nAreaSize))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get area."));
- return FALSE;
- }
- dTotalArea = dTotalArea / listAreaGridRows[nAreaSize - 1]->GetDoubleValue();
- // total particle
- CGridRowPtr pTotalGridRow = CGridRowPtr(new CGridRow());
- pTotalGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pTotalGridRow->SetDoubleValue(dTotalArea);
- listElementGridRows.push_back(pTotalGridRow);
- pElementColumn->SetGridRowsList(listElementGridRows);
- listGridColumn.push_back(pElementColumn);
- }
- //2020-2-17 Modify and standardize
- double d_allelement_subtotal = 0;
- for (unsigned int i_row = 0; i_row < listGridColumn[0]->GetRowList().size(); i_row++)
- {
- //first,So let's take out all the sums
- d_allelement_subtotal = 0;
- for (unsigned int icolumn = 2; icolumn < listGridColumn.size(); icolumn++)
- {
- double ls_dd = listGridColumn[icolumn]->GetRowList()[i_row]->GetDoubleValue();
- if (ls_dd < 0)
- continue;
- d_allelement_subtotal = d_allelement_subtotal + ls_dd;
- }
- //second,Then calculate the normalized values
- for (unsigned int icolumn = 2; icolumn < listGridColumn.size(); icolumn++)
- {
- double ls_dd = listGridColumn[icolumn]->GetRowList()[i_row]->GetDoubleValue();
- if (ls_dd < 0)
- continue;
- listGridColumn[icolumn]->GetRowList()[i_row]->SetDoubleValue(ls_dd / d_allelement_subtotal * 100);
- }
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute sort image class
- CGridDatasList CReportProjFileMgr::CompSortClass()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
- if (!GetSortClassFromParticleList(listParticleAll, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- // get sort class from particle list
- BOOL CReportProjFileMgr::GetSortClassFromParticleList(COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
- {
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- // std
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: empty project file."));
- return FALSE;
- }
- int nColumnNum = ((int)(REPORT_SORT_CLASS_GRID_CLUMN::MAX) - (int)(REPORT_SORT_CLASS_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_SORT_CLASS_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: Can't get column name number."));
- return FALSE;
- }
- CGridColumnsList listGridColumn;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- switch (i)
- {
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::TOO_SMALL:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::SMALL;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::OVER_SIZE:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::OVERSIZE;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::GRAY_NO_INTERS:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::AVE_GRAY_NOT_INRANRE;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::LOW_COUNT:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::LOW_COUNT;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::NO_INTEREST_ELEMENTS:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::NO_INTEREST_ELEMENTS;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_SIC:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_FEO:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_IDENTIFIED:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType == nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- case (int)REPORT_SORT_CLASS_GRID_CLUMN::IDENTIFIED:
- {
- listGridRows.clear();
- int nTypeId = (int)OTS_PARTCLE_TYPE::IDENTIFIED;
- for (auto pParticle : a_listParticleAll)
- {
- int nType = pParticle->GetType();
- if (nType >= nTypeId)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- break;
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute sort image kind
- CGridDatasList CReportProjFileMgr::CompSortKind()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
- if (!GetSortKindFromParticleList(listParticleAll, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- // compute sort king from particle list
- BOOL CReportProjFileMgr::GetSortKindFromParticleList(COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- int nColumnNum = ((int)(REPORT_SORT_KIND_GRID_CLUMN::MAX) - (int)(REPORT_SORT_KIND_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_SORT_KIND_START, nColumnNum);
- map<int, COTSParticleList> mapSameSTDItemPartList;
- this->GetSTDMapedParticleList(a_listParticleAll, &mapSameSTDItemPartList);
- CGridColumnsList listGridColumn;
- nColumnNum = mapSameSTDItemPartList.size();
- for (auto itr = mapSameSTDItemPartList.begin(); itr != mapSameSTDItemPartList.end(); itr++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- std::string typeName = itr->second[0]->TypeName();
- pColumn->SetName(typeName.c_str());
- CGridRowsList listGridRows;
- listGridRows.clear();
- COTSParticleList thisTypeParts = itr->second;
- for (auto pParticle : thisTypeParts)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute sort image size
- CGridDatasList CReportProjFileMgr::CompSortSize()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
- //get pixel size
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file manager."));
- return listGridData;
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file."));
- return listGridData;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample."));
- return listGridData;
- }
- double dPixelSize = pSample->CalculatePixelSize();
- if (!GetSortSizeFromParticleList(listParticleAll, dPixelSize, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- //nIndex++;
- }
- return listGridData;
- }
- // compute sort size from particle list
- BOOL CReportProjFileMgr::GetSortSizeFromParticleList(COTSParticleList a_listParticleAll, double a_dPixelSize, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortSizeFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- // particle size file
- CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
- ASSERT(pPartSize);
- if (!pPartSize)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortSizeFromParticleList: invalid part size data."));
- return FALSE;
- }
- int nColumnNum = ((int)(REPORT_SORT_SIZE_GRID_CLUMN::MAX) - (int)(REPORT_SORT_SIZE_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_SORT_SIZE_START, nColumnNum);
- CPartSizeItemList& listSizes = pPartSize->GetPartSizeList();
- for (auto pSize : listSizes)
- {
- CString strSizeName = pSize->GetName();
- listColumnName.push_back(strSizeName);
- nColumnNum++;
- }
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: Can't get column name number."));
- return FALSE;
- }
- CGridColumnsList listGridColumn;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- double dSizeMax = 0.0;
- double dSizeMin = 0.0;
- if (i == 0)
- {
- dSizeMin = m_CurrentPropParam->GetGrainSizeMin();
- dSizeMax = m_CurrentPropParam->GetGrainSizeMax();
- }
- else
- {
- dSizeMin = listSizes[i - 1]->GetSizeLevel()->GetStart();
- dSizeMax = listSizes[i - 1]->GetSizeLevel()->GetEnd();
- }
- for (auto pParticle : a_listParticleAll)
- {
- double dValue = GetValueAsMethod(pParticle, m_CurrentPropParam->GetSizeCalMethodType(), a_dPixelSize);
- if (dValue < dSizeMax && dValue > dSizeMin)
- {
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- //reverse funcation for size particle sort
- reverse(listGridColumn.begin(), listGridColumn.end());
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // compute sort image size
- CGridDatasList CReportProjFileMgr::CompDistribution()//CGridInPtr a_pGridIn
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- CPropParamPtr propParam = this->GetPropertyParamImage();
- std::vector<CString> listDataSource = this->GetPropertyParamImage()->GetDataSourceList();
- int nSelectedDataSourceIndex = propParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = propParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = propParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
- //get pixel size
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file manager."));
- return listGridData;
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file."));
- return listGridData;
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample."));
- return listGridData;
- }
- double dPixelSize = pSample->CalculatePixelSize();
- if (!GetDistributionFromParticleList(propParam, dPixelSize, listParticleAll, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get particle list."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- nIndex++;
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::GetDistributionFromParticleList(CPropParamPtr propParam, double a_dPixelSize, COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- // std
- ASSERT(m_pReportProjFile);
- if (!m_pReportProjFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: empty project file."));
- return FALSE;
- }
- // particle size file
- CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
- ASSERT(pPartSize);
- if (!pPartSize)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: invalid part size data."));
- return FALSE;
- }
- CPartSizeItemList& listSizes = pPartSize->GetPartSizeList();
- std::vector<CString> listSizeClassTables;
- LoadColumnString(listSizeClassTables, (UINT)IDS_SIZE_CLASS_DEFUALT_FIRST, (int)(SIZE_CLASS_DEFUALT::MAX) - (int)(SIZE_CLASS_DEFUALT::MIN) + 1);
- if ((pPartSize.get() != nullptr))
- {
- CPartSizeItemList listSizeItem = pPartSize->GetPartSizeList();
- for (auto pItem : listSizeItem)
- {
- CString strValue = pItem->GetName();
- listSizeClassTables.push_back(strValue);
- }
- }
- CGridColumnsList listGridColumn;
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(_T(""));
- CGridRowsList listGridRows;
- listGridRows.clear();
- PARTICLE_TYPE nSelectType = propParam->GetPartType();
- int nSTDId = propParam->GetSTDId();
- int nSizeClassType;
- double dSizeMax = 0;
- double dSizeMin = 0;
- dSizeMin = propParam->GetGrainSizeMin();
- dSizeMax = propParam->GetGrainSizeMax();
- //因GridIn参数中没有传递具体选择什么类型的粒级分类数据,因此用SizeLevel的两个限值来区分,都为0 时就认为是选择了全部,其他的就按选择具体的档级处理。
- if (dSizeMax == 0 && dSizeMin == 0)//当DSizeMax==0 和 dSizeMin==0 时表明“粒级”栏选择的是 “全部”或“自定义”上下限填写的是0.
- {
- nSizeClassType = 0;//等于0表明选择“全部”也就是默认取全部粒级表的尺寸数据
- }
- else
- {
- nSizeClassType = 1;//等于1表明选择的是单个某个粒级的数据档 如“3~5”
- }
- for (auto pParticle : a_listParticleAll)
- {
- int nTypeParticle = pParticle->GetType();
- double dValue = GetValueAsMethod(pParticle, propParam->GetSizeCalMethodType(), a_dPixelSize);
- COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
- switch ((int)nSelectType)
- {
- case (int)PARTICLE_TYPE::ALL:
- if (nSizeClassType == 0)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- else
- {
- if (dValue > dSizeMin && dValue < dSizeMax)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- break;
- case (int)PARTICLE_TYPE::ANALYSISED:
- if (nSizeClassType == 0)
- {
- if (nSTDId == 0) //全部颗粒
- {
- if (nSizeClassType == 0)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- else
- {
- if (dValue > dSizeMin && dValue < dSizeMax)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- else if (nSTDId == 1) // 未识别颗粒
- {
- if (nTypeParticle == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- else
- {
- if (nTypeParticle == (nSTDId - 1))
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- }
- else
- {
- if (dValue > dSizeMin && dValue < dSizeMax)
- {
- CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
- pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
- pGridRow->SetParticle(pParticleNew);
- listGridRows.push_back(pGridRow);
- }
- }
- break;
- default:
- break;
- }
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- // load column name string
- void CReportProjFileMgr::LoadColumnString(std::vector<CString>& a_listStrings, UINT a_nFirstStringID, int a_nCount)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- for (int i = 0; i < a_nCount; ++i)
- {
- CString str;
- str = MultiLang::GetInstance().GetCStringByKey(a_nFirstStringID + i);
- a_listStrings.push_back(str);
- }
- }
- // get undefined element list from particle list
- CElementChemistriesList CReportProjFileMgr::GetUndefinedElementList(COTSParticleList a_listParticle, CPosXraysList a_listXray)
- {
- CElementChemistriesList listElementChemistry;
- // safety check to get xray data and element number
- int nXraySize = (int)a_listXray.size();
- int nParticleSize = (int)a_listParticle.size();
- if (nParticleSize > nXraySize)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get xray number is not enough."));
- return listElementChemistry;
- }
- CElementAreaList listElementArea;
- // get element area
- double dTotalArea = 0;
- for (auto pParticle : a_listParticle)
- {
- int nXrayId = pParticle->GetAnalysisId();
- if (nXrayId < 0 || nXrayId >(int) a_listXray.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get wrong xray id."));
- return listElementChemistry;
- }
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [nXrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == nXrayId)); });
- if (itr == a_listXray.end())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: can't find x-ray."));
- return listElementChemistry;
- }
- CPosXrayPtr pXray = *itr;
- // remove Fe
- CElementChemistriesList listElementChemistryCurrent = pXray->GetElementQuantifyData();
- CElementChemistriesList listElementChemistryNew1 = CPosXray::RemoveFe(listElementChemistryCurrent);
- CElementChemistriesList listElementChemistryNew = CPosXray::RemoveC(listElementChemistryNew1);
- double t = 0;
- CElementChemistriesList listElementChemistryG1;
- for (auto pElementChemistry : listElementChemistryNew)
- {
- t += pElementChemistry->GetPercentage();
- }
- if (t == 0)
- {
- continue;
- }
- for (auto pElementChemistry : listElementChemistryNew)
- {
- double dPecent = 100.0 *pElementChemistry->GetPercentage() / t;
- CElementChemistryPtr pElementNew = CElementChemistryPtr(new CElementChemistry(*pElementChemistry.get()));
- pElementNew->SetPercentage(dPecent);
- listElementChemistryG1.push_back(pElementNew);
- }
- CElementAreaPtr pElementArea = CElementAreaPtr(new CElementArea());
- double dArea = pParticle->GetArea();
- pElementArea->SetArea(dArea);
- pElementArea->SetElementList(listElementChemistryG1);
- listElementArea.push_back(pElementArea);
- dTotalArea += dArea;
- }
- for (auto pElementArea : listElementArea)
- {
- CElementChemistriesList listElementChemistryCurrent = pElementArea->GetElementList();
- for (auto pElement : listElementChemistryCurrent)
- {
- CString strName = pElement->GetName();
- double dPercentNorm = 1.0;
- auto itr = std::find_if(listElementChemistry.begin(), listElementChemistry.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itr == listElementChemistry.end())
- {
- double dArea = pElementArea->GetArea();
- double dPercent = pElement->GetPercentage();
- dPercentNorm = dArea * dPercent / dTotalArea;
- }
- else
- {
- CElementChemistryPtr pElementChemistry = *itr;
- double dAreaOld = pElementChemistry->GetPercentage() * dTotalArea * 0.01;
- double dArea = pElementArea->GetArea();
- double dPercent = pElement->GetPercentage();
- dPercentNorm = 100 * (0.01 * dArea * dPercent + dAreaOld) / dTotalArea;
- listElementChemistry.erase(itr);
- }
- CElementChemistryPtr pElement = CElementChemistryPtr(new CElementChemistry());
- pElement->SetName(strName);
- pElement->SetPercentage(dPercentNorm);
- listElementChemistry.push_back(pElement);
- }
- }
- return listElementChemistry;
- }
- CGridDatasList CReportProjFileMgr::CompChartParticleComp()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CGridDatasList pGridList = CompParticleComponent();
- for (CGridDataPtr pGrid : pGridList)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- ASSERT(pGrid);
- if (!pGrid)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid grid in data pointer."));
- return listGridData;
- }
- CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
- // particle column
- CGridColumnPtr pParticleCol = listGridColumn[(int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::NAME - (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN];
- CGridRowsList listGridParticleRows = pParticleCol->GetRowList();
- // particle num column
- CGridColumnPtr pParticleNumCol = listGridColumn[(int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::PARTICLE_NUM - (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN];
- CGridRowsList listGridParticleNumRows = pParticleNumCol->GetRowList();
- if (!((int)listGridParticleRows.size() == (int)listGridParticleNumRows.size()))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid name and num are different."));
- return listGridData;
- }
- CGridColumnsList listCol;
- listCol.clear();
- int nIndex = 0;
- for (auto pNameRow : listGridParticleRows)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- // name
- CString strName = pNameRow->GetStringValue();
- pColumn->SetName(strName);
- // list of rows
- CGridRowsList listRows;
- CGridRowPtr pRow = CGridRowPtr(new CGridRow());
- pRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- CGridRowPtr pGridRow = listGridParticleNumRows[nIndex];
- ASSERT(pGridRow);
- if (!pGridRow)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid name and num are different."));
- return listGridData;
- }
- int nValue = pGridRow->GetIntValue();
- pRow->SetIntValue(nValue);
- listRows.push_back(pRow);
- pColumn->SetGridRowsList(listRows);
- listCol.push_back(pColumn);
- nIndex++;
- }
- pGridData->SetGridColumnList(listCol);
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- CGridDatasList CReportProjFileMgr::CompChartElementComp()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- CGridDatasList listGridDataEEE = CompElementComponent();
- for (CGridDataPtr pGrid : listGridDataEEE)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
- //获取第一列所有元素名称
- CGridColumnPtr element = listGridColumn[0];
- //获取第二列所有占比
- CGridColumnPtr Comp = listGridColumn[1];
- CGridRowsList listGridNameRows = element->GetRowList();
- CGridColumnsList listGridValid; // first two column is particle name and area, they are invalid
- listGridValid.clear();
- //循环第一列所有行,创建新表结构列
- for (CGridRowPtr row : listGridNameRows)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- // name
- CString strName = row->GetStringValue();
- pColumn->SetName(strName);
- listGridValid.push_back(pColumn);
- }
- //添加数据
- CGridColumnsList listCol;
- listCol.clear();
- for (int i = 0; i < listGridValid.size(); i++)
- {
- auto pGridColumn = listGridValid[i];
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- // name
- CString strName = pGridColumn->GetName();
- pColumn->SetName(strName);
- // list of rows
- CGridRowsList listRows;
- CGridRowPtr pRow = CGridRowPtr(new CGridRow());
- pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- CString sValue = Comp->GetRowList()[i]->GetStringValue();
- sValue.Replace('%', '0');
- double dValue;
- dValue = atof(sValue);
- pRow->SetDoubleValue(dValue);
- listRows.push_back(pRow);
- pColumn->SetGridRowsList(listRows);
- listCol.push_back(pColumn);
- }
- pGridData->SetGridColumnList(listCol);
- listGridData.push_back(pGridData);
- }
- // use the dll resource
- //AFX_MANAGE_STATE(AfxGetStaticModuleState());
- //CGridDatasList listGridData;
- //listGridData.clear();
- //// depart compound source name
- //std::vector<int> listWorkIndex;
- //std::vector<int> listPos;
- //std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- //int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- //
- //int nIndex = 0;
- //CGridDatasList pGridList = CompAveElemnetComponent();
- //
- //for (CGridDataPtr pGrid : pGridList)
- //{
- // CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // // data source id
- // std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- // pGridData->SetDataSourceList(listDataSource);
- // int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- // pGridData->SetDataSourceId(nDataSourceId);
- //
- //
- // ASSERT(pGrid);
- // if (!pGrid)
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid grid in data pointer."));
- // return listGridData;
- // }
- // CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
- // int nSTDId = m_CurrentPropParam->GetSTDId();
- // CGridColumnPtr pParticleName = listGridColumn[(int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NAME - (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MIN];
- // CGridRowsList listGridNameRows = pParticleName->GetRowList();
- // if (nSTDId < -1 || nSTDId >(int)listGridNameRows.size())
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid STD id."));
- // return listGridData;
- // }
- // if (nSTDId == 0)// all element
- // {
- // nSTDId = (int)listGridNameRows.size() - 1;
- // }
- // else if (nSTDId == 1) // undefined element
- // {
- // nSTDId = (int)listGridNameRows.size() - 2;
- // }
- // else
- // {
- // nSTDId = nSTDId - 1;
- // }
- // if ((int)listGridColumn.size() < 3)
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: no element is checked out."));
- // return listGridData;
- // }
- // CGridColumnsList listGridValid; // first two column is particle name and area, they are invalid
- // listGridValid.clear();
- // for (int i = 2; i < (int)listGridColumn.size(); i++)
- // {
- // CGridColumnPtr pNewGridColumn = listGridColumn[i];
- // ASSERT(pNewGridColumn);
- // if (!pNewGridColumn)
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid column."));
- // return listGridData;
- // }
- // listGridValid.push_back(pNewGridColumn);
- // }
- // CGridColumnsList listCol;
- // listCol.clear();
- // for (auto pGridColumn : listGridValid)
- // {
- // CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- // // name
- // CString strName = pGridColumn->GetName();
- // pColumn->SetName(strName);
- // // list of rows
- // CGridRowsList listRows;
- // CGridRowPtr pRow = CGridRowPtr(new CGridRow());
- // pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- // CGridRowsList listGridRows = pGridColumn->GetRowList();
- // if (!((int)listGridRows.size() == (int)listGridNameRows.size()))
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: row lengths are different."));
- // return listGridData;
- // }
- // CGridRowPtr pGridRow = listGridRows[nSTDId];
- // ASSERT(pGridRow);
- // if (!pGridRow)
- // {
- // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid name and num are different."));
- // return listGridData;
- // }
- // double dValue = pGridRow->GetDoubleValue();
- // pRow->SetDoubleValue(dValue);
- // listRows.push_back(pRow);
- // pColumn->SetGridRowsList(listRows);
- // listCol.push_back(pColumn);
- // }
- // pGridData->SetGridColumnList(listCol);
- // listGridData.push_back(pGridData);
- //}
- return listGridData;
- }
- CGridDatasList CReportProjFileMgr::CompChartParticleSize()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- // depart compound source name
- std::vector<int> listWorkIndex;
- std::vector<int> listPos;
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CGridDatasList pGridList = CompParticleSizeDistribution();
- for (CGridDataPtr pGrid : pGridList)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- std::vector<CString> listDataSource;
- listDataSource.clear();
- listDataSource = m_CurrentPropParam->GetDataSourceList();
- pGridData->SetDataSourceList(listDataSource);
- int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
- pGridData->SetDataSourceId(nDataSourceId);
- //CGridDataPtr pGrid = pGridList[0];
- ASSERT(pGrid);
- if (!pGrid)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid grid in data pointer."));
- return listGridData;
- }
- //amounts
- CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
- int nCols = (int)listGridColumn.size();
- int nAmounts = 0;
- int nSTDId = m_CurrentPropParam->GetSTDId();
- CGridColumnPtr pParticleName = listGridColumn[(int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::NAME - (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MIN];
- CGridRowsList listGridNameRows = pParticleName->GetRowList();
- if (nSTDId < -1 || nSTDId >(int)listGridNameRows.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid STD id."));
- return listGridData;
- }
- CGridColumnsList listCol;
- listCol.clear();
- int nCIndex = 0;
- int nCAmount = 0;
- for (auto gridColumn : listGridColumn)
- {
- nCIndex++;
- if (nCIndex > (((int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MAX) + 1))
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- CString strName = gridColumn->GetName();
- pColumn->SetName(strName);
- CGridRowsList listGridRows = gridColumn->GetRowList();
- CGridRowsList listRows;
- int nRows = (int)listGridRows.size();
- CGridRowPtr pGridRow = listGridRows[nRows - 1];
- ASSERT(pGridRow);
- if (!pGridRow)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid name and num are different."));
- return listGridData;
- }
- CString strValue = pGridRow->GetStringValue();
- double dValue = atof(strValue);
- CGridRowPtr pRow = CGridRowPtr(new CGridRow());
- pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
- pRow->SetDoubleValue(dValue);
- listRows.push_back(pRow);
- pColumn->SetGridRowsList(listRows);
- listCol.push_back(pColumn);
- }
- }
- //double dValue = nCAmount / nAmounts;
- pGridData->SetGridColumnList(listCol);
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- // compute common five classification
- CGridDatasList CReportProjFileMgr::CompChartCommonFive()
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- CGridDatasList listGridData;
- listGridData.clear();
- std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
- int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
- CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
- std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
- //int nIndex = 0;
- for (auto strDataSourceName : listSelectedDataSource)
- {
- CGridDataPtr pGridData = CGridDataPtr(new CGridData());
- // data source id
- pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
- pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
- COTSParticleList* pSelectidParts;
- COTSParticleList listParticleAll;
- COTSParticleList seleParticles;
- // add filter select particle
- if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
- {
- seleParticles = m_CurrentPropParam->GetSelectParticle();
- pSelectidParts = &seleParticles;
- }
- else
- {
- listParticleAll = GetAnalysisParticleList(strDataSourceName);
- pSelectidParts = &listParticleAll;
- }
- if (!GetCommonFiveFromParticleList(*pSelectidParts, pGridData))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
- return listGridData;
- }
- listGridData.push_back(pGridData);
- }
- return listGridData;
- }
- BOOL CReportProjFileMgr::GetCommonClass(
- COTSParticlePtr a_pPart,
- INC_COMMON_CLASSIFY_TYPE& a_nType)
- {
- // safety check
- ASSERT(a_pPart);
- if (!a_pPart)
- {
- // something wrong
- LogErrorTrace(__FILE__, __LINE__, _T("GetCommonClass: invalid CParticlePtr."));
- return FALSE;
- }
- int nType = a_pPart->GetType();
- //CString sIncName = GetSTDItemNameById(a_listSTDItems, nType);
- //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
- if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
- {
- if ((nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPIEL_OXICE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SPIEL_OXICE_MAX)
- || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_NITRIDE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_NITRIDE_MAX)
- || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_SULFIDE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SIMPLE_OXIDE_SULFIDE_MAX))
- {
- a_nType = INC_COMMON_CLASSIFY_TYPE::SPINEL;
- }
- else if (nType >= (int)OTS_STD_ITEM_VALUE::SYS_OXIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_OXIDE_MAX)
- {
- a_nType = INC_COMMON_CLASSIFY_TYPE::OXIDE;
- }
- else if ((nType >= (int)OTS_STD_ITEM_VALUE::SYS_SIMPLE_OXIDE_SULFIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_SIMPLE_OXIDE_SULFIDE_MAX)
- || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_COMPLEX_OXIDE_SULFIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_COMPLEX_OXIDE_SULFIDE_MAX)
- || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_OXIDE_SULFIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_OXIDE_SULFIDE_MAX))
- {
- a_nType = INC_COMMON_CLASSIFY_TYPE::SULFIDE_OXIDE;
- }
- else if (nType > (int)OTS_STD_ITEM_VALUE::SYS_NITRIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_NITRIDE_MAX)
- {
- a_nType = INC_COMMON_CLASSIFY_TYPE::NITRIDE;
- }
- else if (nType > (int)OTS_STD_ITEM_VALUE::SYS_SUL_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_SUL_MAX)
- {
- a_nType = INC_COMMON_CLASSIFY_TYPE::SULFIDE;
- }
- }
- else
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetCommonClass: this particle is not a common particle."));
- return FALSE;
- }
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportProjFileMgr::GetCommonFiveFromParticleList(COTSParticleList a_listParticle, CGridDataPtr a_pGridData)
- {
- // use the dll resource
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- ASSERT(a_pGridData);
- if (!a_pGridData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: invalid grid data pointer."));
- return FALSE;
- }
- //// std
- //ASSERT(m_pReportProjFile);
- //if (!m_pReportProjFile)
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: empty project file."));
- // return FALSE;
- //}
- //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
- //ASSERT(pPartSTDData);
- //if (!pPartSTDData)
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid STD data."));
- // return FALSE;
- //}
- //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
- //if (listSTDItem.empty())
- //{
- // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty STD Item."));
- // return FALSE;
- //}
- int nNumSulfideOxide = 0;
- int nNumOxide = 0;
- int nNumSulfide = 0;
- int nNumNitrides = 0;
- int nNumSpinel = 0;
- for (auto pPart : a_listParticle)
- {
- INC_COMMON_CLASSIFY_TYPE nCommonType = INC_COMMON_CLASSIFY_TYPE::INVALID;
- if (GetCommonClass(pPart, nCommonType))
- {
- if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SULFIDE_OXIDE)
- {
- nNumSulfideOxide++;
- }
- else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::OXIDE)
- {
- nNumOxide++;
- }
- else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SULFIDE)
- {
- nNumSulfide++;
- }
- else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::NITRIDE)
- {
- nNumNitrides++;
- }
- else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SPINEL)
- {
- nNumSpinel++;
- }
- }
- }
- int nColumnNum = ((int)(REPORT_COMMON_FIVE_GRID_CLUMN::MAX) - (int)(REPORT_COMMON_FIVE_GRID_CLUMN::MIN) + 1);
- std::vector<CString> listColumnName;
- LoadColumnString(listColumnName, IDS_COMMON_FIVE_START, nColumnNum);
- if ((int)listColumnName.size() != nColumnNum)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: Can't get column name number."));
- return FALSE;
- }
- CGridColumnsList listGridColumn;
- COTSParticleList listPartReport;
- for (int i = 0; i < nColumnNum; i++)
- {
- CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
- pColumn->SetName(listColumnName[i]);
- CGridRowsList listGridRows;
- listGridRows.clear();
- switch (i)
- {
- case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SULFIDE_OXIDE:
- {
- listGridRows.clear();
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- pGridRowNum->SetIntValue(nNumSulfideOxide);
- listGridRows.push_back(pGridRowNum);
- }
- break;
- case (int)REPORT_COMMON_FIVE_GRID_CLUMN::OXIDE:
- {
- listGridRows.clear();
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- pGridRowNum->SetIntValue(nNumOxide);
- listGridRows.push_back(pGridRowNum);
- }
- break;
- case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SULFIDE:
- {
- listGridRows.clear();
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- pGridRowNum->SetIntValue(nNumSulfide);
- listGridRows.push_back(pGridRowNum);
- }
- break;
- case (int)REPORT_COMMON_FIVE_GRID_CLUMN::NITRIDES:
- {
- listGridRows.clear();
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- pGridRowNum->SetIntValue(nNumNitrides);
- listGridRows.push_back(pGridRowNum);
- }
- break;
- case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SPINEL:
- {
- listGridRows.clear();
- CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
- pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
- pGridRowNum->SetIntValue(nNumSpinel);
- listGridRows.push_back(pGridRowNum);
- }
- break;
- }
- pColumn->SetGridRowsList(listGridRows);
- listGridColumn.push_back(pColumn);
- }
- a_pGridData->SetGridColumnList(listGridColumn);
- return TRUE;
- }
- double CReportProjFileMgr::GetValueAsMethod(COTSParticlePtr a_pParticle, OTSMODEL::SIZE_CAL_METHOD_TYPE a_nMethod, double a_dPixelSize)
- {
- double dValue = 0;
- double dArea = a_pParticle->GetArea();
- double dDiameter = 2 * sqrt(dArea / Pi);
- double dFltD;
- double dMinWidth;
- double dMaxLength;
- double dRatio;
- if (!OTSIMGPROC::CGBImgPropCal::GetParticleFTD(a_pParticle, a_dPixelSize, dFltD, dMinWidth, dMaxLength, dRatio))
- {
- return dValue;
- }
- switch ((int)a_nMethod)
- {
- case (int)SIZE_CAL_METHOD_TYPE::CIRCLE:
- dValue = dDiameter;
- break;
- case (int)SIZE_CAL_METHOD_TYPE::AREA:
- dValue = dArea;
- break;
- case (int)SIZE_CAL_METHOD_TYPE::FLTD:
- dValue = dFltD;
- break;
- case (int)SIZE_CAL_METHOD_TYPE::LENGTH:
- dValue = dMaxLength;
- break;
- case (int)SIZE_CAL_METHOD_TYPE::WIDTH:
- dValue = dMinWidth;
- break;
- }
- return dValue;
- }
- void CReportProjFileMgr::SetSelectedPicture(RETORT_PROP_GRID_PARAM_TYPE a_nType)
- {
- if (m_listPropParams.size() == 0)
- {
- ResetPropertyParams();
- }
- if (m_listPropParams.size() > 0)
- {
- switch (a_nType)
- {
- case RETORT_PROP_GRID_PARAM_TYPE::IMAGE:
- m_CurrentPropParam = m_listPropParams[0];
- break;
- case RETORT_PROP_GRID_PARAM_TYPE::TABLE:
- m_CurrentPropParam = m_listPropParams[1];
- break;
- case RETORT_PROP_GRID_PARAM_TYPE::CHART:
- m_CurrentPropParam = m_listPropParams[2];
- break;
- default:
- break;
- }
- }
- }
- }
|