ReportProjFileMgr.cpp 162 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "resource.h"
  4. #include "ReportProjFileMgr.h"
  5. #include "MeasureResultInfo.h"
  6. #include "BSEImgFileMgr.h"
  7. #include "PosXrayFileMgr.h"
  8. #include "PartSizeFileMgr.h"
  9. #include "TrioCal.h"
  10. #include "CGBCalculate.h"
  11. #include "GBFieldData.h"
  12. #include "OTSHelper.h"
  13. #include "OTSFileSys.h"
  14. #include "RptParamFileMgr.h"
  15. #include "GBImgPropCal.h"
  16. namespace OTSMODEL {
  17. using namespace std;
  18. // constructor
  19. CReportProjFileMgr::CReportProjFileMgr(CReportProjFilePtr a_pReportProjFile)
  20. {
  21. m_pReportProjFile = a_pReportProjFile;
  22. m_listPropParams.clear();
  23. m_listSmplMgrs.clear();
  24. m_bModify = FALSE;
  25. m_strPathName = _T("");
  26. m_nWorkingSampeIndex = -1;
  27. m_nPartSizeIndex = -1;
  28. //load param file
  29. CRptParamFileMgr paramFleMgr;
  30. paramFleMgr.Load(OTSMODEL::OTS_SOFT_PACKAGE_ID::OTSIncA);
  31. m_rptparamfile = paramFleMgr.GetRptParamFile();
  32. double dScale = m_rptparamfile->GetScale();
  33. m_pReportProjFile->SetScale(dScale);
  34. }
  35. // destructor
  36. CReportProjFileMgr::~CReportProjFileMgr()
  37. {
  38. }
  39. CRptParamFilePtr CReportProjFileMgr::GetRptParamFilePtr()
  40. {
  41. return m_rptparamfile;
  42. }
  43. // class methods
  44. // public
  45. void CReportProjFileMgr::SetPropertyParams(CPropParamsList a_listPropertyParams)
  46. {
  47. m_listPropParams.clear();
  48. m_listPropParams = a_listPropertyParams;
  49. }
  50. // property parameters
  51. CPropParamPtr CReportProjFileMgr::GetPropertyParamImage()
  52. {
  53. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::IMAGE];
  54. }
  55. CPropParamPtr CReportProjFileMgr::GetPropertyParamGrid()
  56. {
  57. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::TABLE];
  58. }
  59. CPropParamPtr CReportProjFileMgr::GetPropertyParamChart()
  60. {
  61. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::CHART];
  62. }
  63. // reset property parameters
  64. BOOL CReportProjFileMgr::ResetPropertyParams(BOOL a_bClear /*= FALSE*/)
  65. {
  66. // clear property parameters list
  67. if (a_bClear)
  68. {
  69. m_listPropParams.clear();
  70. }
  71. // get data source names list
  72. std::vector<CString> listDataSourceNames = GetDataSourceNamesList();
  73. // data source names list can't be empty
  74. if (listDataSourceNames.empty())
  75. {
  76. LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty data source name list."));
  77. return FALSE;
  78. }
  79. // particle STD data
  80. CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  81. ASSERT(pPartSTDData);
  82. if (!pPartSTDData)
  83. {
  84. LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: STD data empty."));
  85. return FALSE;
  86. }
  87. // trio chart mode
  88. // add property parameters into the list
  89. if (m_listPropParams.empty())
  90. {
  91. //Image display picture's property
  92. CPropParamPtr pPropParam = CPropParamPtr(new CPropParamImage());
  93. pPropParam->SetDataSourceList(listDataSourceNames);
  94. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  95. pPropParam->SetWorkingSTDLib(pPartSTDData);
  96. pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
  97. if (*pPartSTDData.get() == CPartSTDData())
  98. {
  99. pPropParam->SetSTDId(0);
  100. }
  101. pPropParam->SetType(DISPLAY_PICTURE_TYPE::IMAGE);
  102. m_listPropParams.push_back(pPropParam);
  103. //grid table display picture's property
  104. pPropParam = CPropParamPtr(new CPropParamGrid());
  105. pPropParam->SetDataSourceList(listDataSourceNames);
  106. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  107. pPropParam->SetWorkingSTDLib(pPartSTDData);
  108. pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
  109. if (*pPartSTDData.get() == CPartSTDData())
  110. {
  111. pPropParam->SetSTDId(0);
  112. }
  113. pPropParam->SetType(DISPLAY_PICTURE_TYPE::TABLE);
  114. m_listPropParams.push_back(pPropParam);
  115. //chart display picture's property object
  116. pPropParam = CPropParamPtr(new CPropParamChart());
  117. pPropParam->SetDataSourceList(listDataSourceNames);
  118. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  119. pPropParam->SetWorkingSTDLib(pPartSTDData);
  120. pPropParam->SetSizeClassFileFolder(m_rptparamfile->GetSizeFileFolder());
  121. pPropParam->SetTriTempFile(m_rptparamfile->GetTriTempFile());
  122. if (*pPartSTDData.get() == CPartSTDData())
  123. {
  124. pPropParam->SetSTDId(0);
  125. }
  126. pPropParam->SetType(DISPLAY_PICTURE_TYPE::CHART);
  127. m_listPropParams.push_back(pPropParam);
  128. }
  129. else
  130. {
  131. for (auto pPropParam : m_listPropParams)
  132. {
  133. pPropParam->SetDataSourceList(listDataSourceNames);
  134. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  135. pPropParam->SetWorkingSTDLib(pPartSTDData);
  136. }
  137. }
  138. // ok, return TRUE
  139. return TRUE;
  140. }
  141. BOOL CReportProjFileMgr::NewFile()
  142. {
  143. // set file name
  144. SetPathName(UNTITLED_NEW_FILE_NAME);
  145. return TRUE;
  146. }
  147. // Load
  148. BOOL CReportProjFileMgr::Load(CString a_strPathname /*= _T("")*/)
  149. {
  150. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  151. // check file name
  152. a_strPathname.Trim();
  153. if (a_strPathname.IsEmpty())
  154. {
  155. // open
  156. CFileDialog dlg(TRUE, REPORT_PROJRCT_FILE_EXT, NULL, OFN_FILEMUSTEXIST, REPORT_PROJRCT_FILE_FILTER);
  157. if (dlg.DoModal() != IDOK)
  158. {
  159. // user canceled loading
  160. LogTrace(__FILE__, __LINE__, _T("Load: user canceled loading."));
  161. return FALSE;
  162. }
  163. a_strPathname = dlg.GetPathName();
  164. }
  165. // open the file (for read)
  166. // create report project file file
  167. CReportProjFilePtr pReportProjFile = CReportProjFilePtr(new CReportProjFile());
  168. // load from file
  169. tinyxml2::XMLDocument doc;
  170. doc.LoadFile(a_strPathname);//载入xml文件
  171. tinyxml2::XMLElement *rootNode;
  172. rootNode = doc.FirstChildElement(RootClassName);
  173. pReportProjFile->Serialize(false, &doc, rootNode);
  174. SetPathName(a_strPathname);
  175. // file version
  176. CString strFileVersion = pReportProjFile->GetFileVersion();
  177. DWORD nFileVersion = COTSHelper::GetVersionFromString(strFileVersion);
  178. if (nFileVersion == 0)
  179. {
  180. // invalid file
  181. LogErrorTrace(__FILE__, __LINE__, _T("Load: invalid sample measure result file %s"), a_strPathname);
  182. return FALSE;
  183. }
  184. // set report project file
  185. m_pReportProjFile = pReportProjFile;
  186. // load sample measure result files
  187. m_listSmplMgrs.clear();
  188. std::vector<CString> listSmplMsrResultFilePathNames;
  189. for (auto strSmplMsrResultFilePathName : m_pReportProjFile->GetSmplMsrResultFilePathNames())
  190. {
  191. if (strSmplMsrResultFilePathName.IsEmpty())
  192. {
  193. // sample measure result file pathname can't be an empty string
  194. LogTrace(__FILE__, __LINE__, _T("Load: sample measure result file pathname can't be an empty string."));
  195. SetModify();
  196. continue;
  197. }
  198. // create a sample measure result manager
  199. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strSmplMsrResultFilePathName));
  200. if (!pSmplMsrResultFileMgr->Load(strSmplMsrResultFilePathName))
  201. {
  202. // failed to load sample measure result file
  203. LogTrace(__FILE__, __LINE__, _T("Load: failed to load sample measure result file (%s)."), strSmplMsrResultFilePathName);
  204. SetModify();
  205. continue;
  206. }
  207. // this file is ok
  208. listSmplMsrResultFilePathNames.push_back(strSmplMsrResultFilePathName);
  209. m_listSmplMgrs.push_back(pSmplMsrResultFileMgr);
  210. }
  211. m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
  212. // set working sample
  213. if (m_listSmplMgrs.size() > 0)
  214. {
  215. m_nWorkingSampeIndex = 0;
  216. }
  217. else
  218. {
  219. m_nWorkingSampeIndex = -1;
  220. }
  221. ResetPropertyParams();
  222. return TRUE;
  223. }
  224. // Save
  225. BOOL CReportProjFileMgr::Save()
  226. {
  227. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  228. // safety check
  229. ASSERT(m_pReportProjFile);
  230. if (!m_pReportProjFile)
  231. {
  232. // invalid report project file pointer
  233. LogErrorTrace(__FILE__, __LINE__, _T("Save: invalid report project file pointer."));
  234. return FALSE;
  235. }
  236. // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
  237. CString strPathName = GetPathName();
  238. // is this a new file?
  239. strPathName.Trim();
  240. if (strPathName.CompareNoCase(UNTITLED_NEW_FILE_NAME) == 0)
  241. {
  242. // this is a new file
  243. // return save as result
  244. return SaveAs();
  245. }
  246. // store data to file
  247. tinyxml2::XMLDocument doc;
  248. doc.LoadFile(strPathName);//载入xml文件
  249. doc.Clear();
  250. tinyxml2::XMLDeclaration* declaration = doc.NewDeclaration();//添加xml文件头申明
  251. doc.InsertFirstChild(declaration);
  252. tinyxml2::XMLElement *rootNode;
  253. rootNode = doc.NewElement(RootClassName);
  254. doc.InsertEndChild(rootNode);
  255. m_pReportProjFile->Serialize(true, &doc, rootNode);
  256. int result = doc.SaveFile(strPathName);
  257. // set modify flag to FALSE
  258. SetModify(FALSE);
  259. // ok, return TRUE
  260. return TRUE;
  261. }
  262. BOOL CReportProjFileMgr::SaveAs()
  263. {
  264. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  265. // safety check
  266. ASSERT(m_pReportProjFile);
  267. if (!m_pReportProjFile)
  268. {
  269. // invalid report project file pointer
  270. LogErrorTrace(__FILE__, __LINE__, _T("SaveAs: invalid report project file pointer."));
  271. return FALSE;
  272. }
  273. // save file dialog
  274. CString strFileName = _T("");
  275. // file save as dialog
  276. CFileDialog dlg(FALSE, REPORT_PROJRCT_FILE_EXT, NULL, OFN_OVERWRITEPROMPT, REPORT_PROJRCT_FILE_FILTER);
  277. if (dlg.DoModal() != IDOK)
  278. {
  279. // user canceled loading
  280. LogTrace(__FILE__, __LINE__, _T("Save: user canceled save."));
  281. return FALSE;
  282. }
  283. // get file pathname
  284. strFileName = dlg.GetPathName();
  285. // Open the file
  286. // store to file
  287. tinyxml2::XMLDocument doc;
  288. doc.LoadFile(strFileName);//载入xml文件
  289. doc.Clear();
  290. tinyxml2::XMLDeclaration* declaration = doc.NewDeclaration();//添加xml文件头申明
  291. doc.InsertFirstChild(declaration);
  292. tinyxml2::XMLElement *rootNode;
  293. rootNode = doc.NewElement(RootClassName);
  294. doc.InsertEndChild(rootNode);
  295. m_pReportProjFile->Serialize(true, &doc, rootNode);
  296. int result = doc.SaveFile(strFileName);
  297. // set file modify flag
  298. m_bModify = FALSE;
  299. // Set project Path
  300. SetPathName(strFileName);
  301. // Ok, return TRUE
  302. return TRUE;
  303. }
  304. BOOL CReportProjFileMgr::IsValid()
  305. {
  306. ASSERT(m_pReportProjFile);
  307. if (!m_pReportProjFile)
  308. {
  309. LogErrorTrace(__FILE__, __LINE__, _T("IsValid: not invalid report project file pointer."));
  310. return FALSE;
  311. }
  312. // triangle template file
  313. CTriTempFilePtr pTriTemp = m_pReportProjFile->GetTriTemp();
  314. // Ok, return TRUE
  315. return TRUE;
  316. }
  317. // particle STD data
  318. CPartSTDDataPtr CReportProjFileMgr::GetPartSTDData()
  319. {
  320. // check report project file pointer
  321. ASSERT(m_pReportProjFile);
  322. if (!m_pReportProjFile)
  323. {
  324. // invalid report project file pointer
  325. LogErrorTrace(__FILE__, __LINE__, _T("GetPartSTDData: invalid report project file pointer."));
  326. return FALSE;
  327. }
  328. return m_pReportProjFile->GetPartSTDData();
  329. }
  330. BOOL CReportProjFileMgr::SetPartSTDData(CPartSTDDataPtr a_pPartSTDData)
  331. {
  332. // input check
  333. ASSERT(a_pPartSTDData);
  334. if (!a_pPartSTDData)
  335. {
  336. // invalid particle STD data pointer
  337. LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid particle STD data pointer."));
  338. return FALSE;
  339. }
  340. // check report project file pointer
  341. ASSERT(m_pReportProjFile);
  342. if (!m_pReportProjFile)
  343. {
  344. // invalid report project file pointer
  345. LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid report project file pointer."));
  346. return FALSE;
  347. }
  348. // create a copy of the particle STD data
  349. //CPartSTDDataPtr pPartSTDData = CPartSTDDataPtr(new CPartSTDData(a_pPartSTDData.get()));
  350. CPartSTDDataPtr pPartSTDData = a_pPartSTDData;
  351. // set particle STD data
  352. m_pReportProjFile->SetPartSTDData(pPartSTDData);
  353. // ok, return TRUE
  354. return TRUE;
  355. }
  356. // sample measure result files
  357. BOOL CReportProjFileMgr::AddASmplMsrResultMgr(CString a_strPathName /*= _T("")*/)
  358. {
  359. /*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
  360. tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
  361. _CrtSetDbgFlag(tmpFlag);*/
  362. //_CrtSetBreakAlloc(351380);
  363. // check report project file pointer
  364. ASSERT(m_pReportProjFile);
  365. if (!m_pReportProjFile)
  366. {
  367. // invalid report project file pointer
  368. LogErrorTrace(__FILE__, __LINE__, _T("SetPartSTDData: invalid report project file pointer."));
  369. return FALSE;
  370. }
  371. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgrPtr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(a_strPathName));
  372. // load sample result file
  373. if (!pSmplMsrResultFileMgrPtr->Load(a_strPathName))
  374. {
  375. return FALSE;
  376. }
  377. //判断新打开的测量结果文件名,是否已经在打开的测量结果列表名中,是的话,不打开,防止同名
  378. CString strSampleNameNew = pSmplMsrResultFileMgrPtr->GetSmplMsrResultFile()->GetSample()->GetName();
  379. for (int i = 0; i < m_listSmplMgrs.size(); i++)
  380. {
  381. if (m_listSmplMgrs[i]->GetSmplMsrResultFile()->GetSample()->GetName() == strSampleNameNew)
  382. {
  383. LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: The measurement result name is already included."));
  384. return FALSE;
  385. }
  386. }
  387. // get the particle STD data of the sample result file
  388. CPartSTDDataPtr pPartSTDData = pSmplMsrResultFileMgrPtr->GetPartSTDData();
  389. ASSERT(pPartSTDData);
  390. if (!pPartSTDData)
  391. {
  392. // sample result file particle STD data invalid
  393. LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: sample result file particle STD data invalid."));
  394. return FALSE;
  395. }
  396. // is the first sample result file in the list?
  397. if (m_listSmplMgrs.empty())
  398. {
  399. // yes
  400. // set particle STD data
  401. if (!SetPartSTDData(pPartSTDData))
  402. {
  403. // failed to call SetPartSTDData method
  404. LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: failed to call SetPartSTDData method."));
  405. return FALSE;
  406. }
  407. }
  408. else
  409. {
  410. // not
  411. // check if the particle STD data of the input sample result file is same with the project file
  412. CPartSTDDataPtr pPartSTDDataProj = m_pReportProjFile->GetPartSTDData();
  413. ASSERT(pPartSTDDataProj);
  414. if (!pPartSTDDataProj)
  415. {
  416. // invalid report project particle STD data file pointer
  417. LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: invalid report project particle STD data file pointer."));
  418. return FALSE;
  419. }
  420. if (!(*(pPartSTDData.get()) == *(pPartSTDDataProj.get())))
  421. {
  422. // the two particle std data dis-matched
  423. 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."));
  424. return FALSE;
  425. }
  426. //if file name is same and path name is also same, not add
  427. CString strWorkingFolder = pSmplMsrResultFileMgrPtr->GetWorkingFolderStr();
  428. // pathname
  429. CString strPathname = pSmplMsrResultFileMgrPtr->GetPathName();
  430. 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)); });
  431. if (itr != m_listSmplMgrs.end())
  432. {
  433. // the two particle std data dis-matched
  434. LogTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: the sample measure result file has been inserted into current report file."));
  435. return FALSE;
  436. }
  437. }
  438. // add the file path name into file path names list
  439. CString strPathname = pSmplMsrResultFileMgrPtr->GetPathName();
  440. std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
  441. listSmplMsrResultFilePathNames.push_back(strPathname);
  442. m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
  443. // add the sample result file into sample measure result files list
  444. m_listSmplMgrs.push_back(pSmplMsrResultFileMgrPtr);
  445. // set modify flag to TRUE
  446. SetModify();
  447. // set working sample
  448. m_nWorkingSampeIndex = (int)m_listSmplMgrs.size() - 1;
  449. // reset property parameters
  450. ResetPropertyParams();
  451. // ok, return TRUE
  452. return TRUE;
  453. }
  454. void CReportProjFileMgr::SetSmplMsrResultMgrs(CSmplMsrResultFileMgrList a_listSmplMsrResultFileMgr)
  455. {
  456. for (auto pSmplMsrResultMgr : a_listSmplMsrResultFileMgr)
  457. {
  458. CString strWorkingFolder = pSmplMsrResultMgr->GetWorkingFolderStr();
  459. CSmplMsrResultFileMgrPtr pSmplMsrResultMgrNew = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strWorkingFolder));
  460. CString strPathname = pSmplMsrResultMgr->GetPathName();
  461. pSmplMsrResultMgrNew->SetPathName(strPathname);
  462. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
  463. CSmplMsrResultFilePtr pSmplMsrResultFileNew = CSmplMsrResultFilePtr(new CSmplMsrResultFile(pSmplMsrResultFile.get()));
  464. pSmplMsrResultMgrNew->SetSmplMsrResultFile(pSmplMsrResultFileNew);
  465. m_listSmplMgrs.push_back(pSmplMsrResultMgrNew);
  466. }
  467. }
  468. CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrById(int a_nIndex)
  469. {
  470. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  471. {
  472. return nullptr;
  473. }
  474. return m_listSmplMgrs[a_nIndex];
  475. }
  476. CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrByPathName(CString a_strPathName)
  477. {
  478. a_strPathName.Trim();
  479. if (a_strPathName.IsEmpty())
  480. {
  481. return nullptr;
  482. }
  483. auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
  484. if (itr == m_listSmplMgrs.end())
  485. {
  486. return nullptr;
  487. }
  488. return *itr;
  489. }
  490. CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetASmplMsrResultMgrByFileName(CString a_strFileName)
  491. {
  492. a_strFileName.Trim();
  493. if (a_strFileName.IsEmpty())
  494. {
  495. return nullptr;
  496. }
  497. auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strFileName](CSmplMsrResultFileMgrPtr p)
  498. {
  499. CString strDataSource = COTSHelper::GetFileName(p->GetPathName());
  500. return strDataSource.CompareNoCase(a_strFileName) == 0;
  501. });
  502. if (itr == m_listSmplMgrs.end())
  503. {
  504. return nullptr;
  505. }
  506. return *itr;
  507. }
  508. BOOL CReportProjFileMgr::DeleteASmplMsrResultMgrById(int a_nIndex)
  509. {
  510. // check the index
  511. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  512. {
  513. // invalid input sample index
  514. LogErrorTrace(__FILE__, __LINE__, _T("DeleteSampleByIndex::input sample index"));
  515. return a_nIndex;
  516. }
  517. // delete path from project file;
  518. std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
  519. // check number of file path names
  520. if ((int)listSmplMsrResultFilePathNames.size() != (int)m_listSmplMgrs.size())
  521. {
  522. LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrById: file path names list has different size with sample result file number."));
  523. return FALSE;
  524. }
  525. // calculate new working sample index
  526. int nNewWorkingSampeIndex;
  527. if (a_nIndex < m_nWorkingSampeIndex)
  528. {
  529. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  530. }
  531. else if (a_nIndex > m_nWorkingSampeIndex)
  532. {
  533. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  534. }
  535. else
  536. {
  537. // deleting working sample.
  538. if (a_nIndex == (int)m_listSmplMgrs.size() - 1)
  539. {
  540. // this is the last sample, select the above sample as working sample
  541. // if this is only sample in the list working sample index will be -1;
  542. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  543. }
  544. else
  545. {
  546. // select next sample as working sample
  547. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  548. }
  549. }
  550. // delete the sample
  551. m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
  552. // the file is modified.
  553. SetModify();
  554. // reset working sample index
  555. m_nWorkingSampeIndex = nNewWorkingSampeIndex;
  556. // delete the sample path name
  557. listSmplMsrResultFilePathNames.erase(listSmplMsrResultFilePathNames.begin() + a_nIndex);
  558. m_pReportProjFile->SetSmplMsrResultFilePathNames(listSmplMsrResultFilePathNames);
  559. // reset property parameters
  560. ResetPropertyParams();
  561. // ok, return TRUE
  562. return TRUE;
  563. }
  564. BOOL CReportProjFileMgr::DeleteASmplMsrResultMgrByPathName(CString a_strPathName)
  565. {
  566. // check report project file pointer
  567. ASSERT(m_pReportProjFile);
  568. if (!m_pReportProjFile)
  569. {
  570. // invalid report project file pointer
  571. LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: invalid report project file pointer."));
  572. return FALSE;
  573. }
  574. a_strPathName.Trim();
  575. if (a_strPathName.IsEmpty())
  576. {
  577. return FALSE;
  578. }
  579. auto itrObj = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
  580. if (itrObj == m_listSmplMgrs.end())
  581. {
  582. // failed to find sample measure result file
  583. LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file."));
  584. return FALSE;
  585. }
  586. std::vector<CString> listSmplMsrResultFilePathNames = m_pReportProjFile->GetSmplMsrResultFilePathNames();
  587. auto itrPathName = std::find_if(listSmplMsrResultFilePathNames.begin(), listSmplMsrResultFilePathNames.end(), [a_strPathName](CString strPathName) { return strPathName.CompareNoCase(a_strPathName) == 0; });
  588. if (itrPathName == listSmplMsrResultFilePathNames.end())
  589. {
  590. // failed to find sample measure result file pathname
  591. LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file pathname."));
  592. return FALSE;
  593. }
  594. m_listSmplMgrs.erase(itrObj);
  595. // listSmplMsrResultFilePathNames.erase(itrPathName);
  596. m_pReportProjFile->GetSmplMsrResultFilePathNames().erase(itrPathName);
  597. // reset property parameters
  598. ResetPropertyParams();
  599. // set modify flag to TRUE
  600. SetModify();
  601. // ok, return TRUE
  602. return TRUE;
  603. }
  604. BOOL CReportProjFileMgr::EditASmplMsrResultMgrById(int a_nIndex, CSmplMsrResultFileMgrPtr a_pSmpFileMgr)
  605. {
  606. ASSERT(a_pSmpFileMgr);
  607. if (!a_pSmpFileMgr)
  608. {
  609. LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById:invalid sample measure result manager pointer."));
  610. return FALSE;
  611. }
  612. // check if the working sample index
  613. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  614. {
  615. LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById: invalid sample measure result manager index."));
  616. // invalid working sample index
  617. return FALSE;
  618. }
  619. m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
  620. m_listSmplMgrs.insert(m_listSmplMgrs.begin() + a_nIndex, a_pSmpFileMgr);
  621. return TRUE;
  622. }
  623. CSmplMsrResultFileMgrPtr CReportProjFileMgr::GetWorkingSmplMsrReslMgr()
  624. {
  625. // check if the working sample index
  626. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSmplMgrs.size())
  627. {
  628. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSmplMsrReslMgr: invalid working sample measure result manager index."));
  629. // invalid working sample index
  630. return FALSE;
  631. }
  632. return GetASmplMsrResultMgrById(m_nWorkingSampeIndex);
  633. }
  634. CString CReportProjFileMgr::GetWorkingSampleName()
  635. {
  636. CString strRet = _T("");
  637. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = GetWorkingSmplMsrReslMgr();
  638. ASSERT(pSmplMsrResultFileMgr);
  639. if (!pSmplMsrResultFileMgr)
  640. {
  641. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result manager."));
  642. return _T("");
  643. }
  644. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  645. ASSERT(pSmplMsrResultFile);
  646. if (!pSmplMsrResultFile)
  647. {
  648. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result file."));
  649. return _T("");
  650. }
  651. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  652. ASSERT(pSample);
  653. if (!pSample)
  654. {
  655. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample."));
  656. return _T("");
  657. }
  658. strRet = pSample->GetName();
  659. return strRet;
  660. }
  661. BOOL CReportProjFileMgr::SetWorkingSmplMsrReslMgr(CSmplMsrResultFileMgrPtr a_pSmplMsrResultMgr)
  662. {
  663. ASSERT(a_pSmplMsrResultMgr);
  664. if (!a_pSmplMsrResultMgr)
  665. {
  666. LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result manager pointer."));
  667. return FALSE;
  668. }
  669. if (!EditASmplMsrResultMgrById(m_nWorkingSampeIndex, a_pSmplMsrResultMgr))
  670. {
  671. LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: can't edit working sample measure result file."));
  672. return FALSE;
  673. }
  674. return TRUE;
  675. }
  676. CString CReportProjFileMgr::GetFileName()
  677. {
  678. // make a copy of file path name
  679. CString strPathName = m_strPathName;
  680. // is this a new file?
  681. strPathName.Trim();
  682. if (strPathName.CompareNoCase(UNTITLED_NEW_FILE_NAME) == 0)
  683. {
  684. return strPathName;
  685. }
  686. // get file name
  687. CString strFileName = COTSHelper::GetFileNameWithoutExtension(strPathName);
  688. strFileName = COTSHelper::GetFileName(strFileName);
  689. // return file name
  690. return strFileName;
  691. }
  692. // grid computing
  693. CGridDatasList CReportProjFileMgr::GridDataTransfer()
  694. {
  695. CGridDatasList listGridData;
  696. listGridData.clear();
  697. // calculate table type
  698. CPropParamPtr prop = m_CurrentPropParam;
  699. //COMPUTE_TABLE_TYPE nCalTableType = a_pGridIn->GetCalTableType();
  700. BOOL bRet = FALSE;
  701. TrioCal trio(this);
  702. CGBCalculate GBCal(this);
  703. MeasureResultInfo Msr(this);
  704. switch (prop->GetType())
  705. {
  706. case DISPLAY_PICTURE_TYPE::IMAGE:
  707. {
  708. IMAGE_DISPLAY_TYPE nImgDisType = prop->GetImageDisplayType();
  709. switch (nImgDisType)
  710. {
  711. case IMAGE_DISPLAY_TYPE::GENERAL:
  712. listGridData = CompDistribution();
  713. break;
  714. case IMAGE_DISPLAY_TYPE::IMAGE_GRID:
  715. {
  716. MEASURE_DATA_TYPE meaType = prop->GetMeasureDataType();
  717. switch (meaType)
  718. {
  719. case MEASURE_DATA_TYPE::ALL_PARTICLE:
  720. listGridData = CompSortClass();
  721. break;
  722. case MEASURE_DATA_TYPE::ANYLYSIS_PARTICLE:
  723. listGridData = CompSortKind();
  724. break;
  725. case MEASURE_DATA_TYPE::PARTICALE_SIZE_DISTRIBUTION:
  726. listGridData = CompSortSize();
  727. break;
  728. default:
  729. break;
  730. }
  731. break;
  732. }
  733. default:
  734. break;
  735. }
  736. break;
  737. }
  738. case DISPLAY_PICTURE_TYPE::TABLE:
  739. {
  740. CALCULATE_TABLE_TYPE nCalTableType = prop->GetCalTableType();
  741. switch (nCalTableType)
  742. {
  743. case CALCULATE_TABLE_TYPE::MEASURE_INFO:
  744. listGridData = Msr.GetMeasureResultInfo();
  745. break;
  746. case CALCULATE_TABLE_TYPE::PARTICALE_GENE_INFO://识别颗粒信息表
  747. listGridData = CompParticleGenInfo();
  748. break;
  749. case CALCULATE_TABLE_TYPE::PARTICALE_COMP://颗粒成分表,即颗粒识别出的物质名称
  750. listGridData = CompParticleComponent();
  751. break;
  752. case CALCULATE_TABLE_TYPE::ELEMENT_COMP://元素成分表,即物质的元素百分比
  753. listGridData = CompElementComponent();
  754. break;
  755. case CALCULATE_TABLE_TYPE::PARTICALE_SIZE_DISTRIBUTION://颗粒尺寸分布
  756. listGridData = CompParticleSizeDistribution();
  757. break;
  758. case CALCULATE_TABLE_TYPE::AVE_ELEMENT_COMP:
  759. listGridData = CompAveElemnetComponent();//元素平均重量百分比
  760. break;
  761. case CALCULATE_TABLE_TYPE::GB_Method1:
  762. listGridData = GBCal.GetGBInclusion();
  763. break;
  764. case CALCULATE_TABLE_TYPE::GB_Method2:
  765. listGridData = GBCal.GetGBInclusion();
  766. break;
  767. case CALCULATE_TABLE_TYPE::ASTM:
  768. listGridData = GBCal.GetGBInclusion();
  769. break;
  770. case CALCULATE_TABLE_TYPE::DIN:
  771. listGridData = GBCal.GetGBInclusion();
  772. break;
  773. default:
  774. break;
  775. }
  776. break;
  777. }
  778. case DISPLAY_PICTURE_TYPE::CHART:
  779. {
  780. CALCULATE_CHART_TYPE nCalChartType = prop->GetCalChartType();
  781. switch (nCalChartType)
  782. {
  783. case CALCULATE_CHART_TYPE::PARTICALE_COMP:
  784. listGridData = CompChartParticleComp();
  785. break;
  786. case CALCULATE_CHART_TYPE::ELEMENT_COMP:
  787. listGridData = CompChartElementComp();
  788. break;
  789. case CALCULATE_CHART_TYPE::PARTICALE_SIZE_DISTRIBUTION:
  790. listGridData = CompChartParticleSize();
  791. break;
  792. case CALCULATE_CHART_TYPE::TRIO_CHART:
  793. listGridData = trio.CompParticleTrioInfo();
  794. break;
  795. case CALCULATE_CHART_TYPE::COMMON_FIVE:
  796. listGridData = CompChartCommonFive();
  797. break;
  798. default:
  799. break;
  800. }
  801. break;
  802. }
  803. }
  804. return listGridData;
  805. }
  806. // reclassify measure result
  807. BOOL CReportProjFileMgr::ReClassify()
  808. {
  809. ASSERT(m_pReportProjFile);
  810. if (!m_pReportProjFile)
  811. {
  812. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: empty report project file."));
  813. return FALSE;
  814. }
  815. // particle STD data
  816. CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  817. ASSERT(pPartSTDData);
  818. if (!pPartSTDData)
  819. {
  820. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: empty STD file."));
  821. return FALSE;
  822. }
  823. // sample measure result files
  824. for (auto pSmplMsrResultMgr : m_listSmplMgrs)
  825. {
  826. // particle list, need compute
  827. COTSParticleList listParticleOld = pSmplMsrResultMgr->GetParticleList();
  828. // analysis x-ray list
  829. CPosXraysList listAnalysisXray = pSmplMsrResultMgr->GetAnalysisXray();
  830. if (listParticleOld.empty() || listAnalysisXray.empty())
  831. {
  832. // need to reload the result
  833. COTSFieldMgrList listFieldMgr = pSmplMsrResultMgr->GetOTSFldMgrListAndAnalysisXrayList();
  834. if (listFieldMgr.empty())
  835. {
  836. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't reload file."));
  837. return FALSE;
  838. }
  839. if (!pSmplMsrResultMgr->ComputeParticleList())
  840. {
  841. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't compute particle list."));
  842. return FALSE;
  843. }
  844. listParticleOld = pSmplMsrResultMgr->GetParticleList();
  845. listAnalysisXray = pSmplMsrResultMgr->GetAnalysisXray();
  846. }
  847. COTSParticleList listAnalysisParticle;
  848. listAnalysisParticle.clear();
  849. for (auto pParticle : listParticleOld)
  850. {
  851. int nType = pParticle->GetType();
  852. //All particles that contain X-ray data
  853. if (nType > (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)
  854. {
  855. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  856. listAnalysisParticle.push_back(pParticleNew);
  857. }
  858. }
  859. // 1. Update particle message
  860. if (!ClassifyParticles(listAnalysisParticle, listAnalysisXray))
  861. {
  862. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't classify particle list."));
  863. return FALSE;
  864. }
  865. COTSParticleList listParticle;
  866. listParticle.clear();
  867. for (auto pParticle : listParticleOld)
  868. {
  869. int nType = pParticle->GetType();
  870. if (nType < (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  871. {
  872. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  873. listParticle.push_back(pParticleNew);
  874. }
  875. }
  876. for (auto pParticle : listAnalysisParticle)
  877. {
  878. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  879. listParticle.push_back(pParticleNew);
  880. }
  881. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
  882. ASSERT(pSmplMsrResultFile);
  883. if (!pSmplMsrResultFile)
  884. {
  885. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample measure result file."));
  886. return FALSE;
  887. }
  888. COTSFieldDataList listFieldData = pSmplMsrResultFile->GetFieldData();
  889. for (auto pFieldData : listFieldData)
  890. {
  891. int nID = pFieldData->GetId();
  892. COTSParticleList listFieldParticle;
  893. for (auto pParticle : listParticle)
  894. {
  895. int nFieldId = pParticle->GetFieldId();
  896. if (nFieldId == nID)
  897. {
  898. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  899. listFieldParticle.push_back(pParticleNew);
  900. }
  901. }
  902. pFieldData->SetParticleList(listFieldParticle);
  903. //update basedata add code 2019-6-18
  904. CString strFieldFileFolder = pFieldData->GetFieldFileFolder();
  905. CString strIncAFilename = strFieldFileFolder + SMPL_MSR_RESULT_INCLUSION_FILE;
  906. CIncAFileMgrPtr pIncAFileMgr = CIncAFileMgrPtr(new CIncAFileMgr(strIncAFilename));
  907. pIncAFileMgr->SetParticleList(listFieldParticle, TRUE);
  908. if (!pIncAFileMgr->Update(strIncAFilename))
  909. {
  910. LogErrorTrace(__FILE__, __LINE__, _T("SaveFieldFiles: save inclusion file failed."));
  911. return FALSE;
  912. }
  913. }
  914. pSmplMsrResultFile->SetFieldData(listFieldData);
  915. // 2. Update measure result message.
  916. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  917. ASSERT(pSample);
  918. if (!pSample)
  919. {
  920. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample pointer."));
  921. return FALSE;
  922. }
  923. CMsrResultsPtr poMsrResults = CMsrResultsPtr(new CMsrResults());
  924. // go through the particles list
  925. for (auto pParticle : listParticle)
  926. {
  927. // create a measure result item
  928. CMsrResultItemPtr pMsrResultItem = CMsrResultItemPtr(new CMsrResultItem());
  929. pMsrResultItem->SetTypeId(pParticle->GetType());
  930. pMsrResultItem->SetArea((int)(pParticle->GetArea() + 0.5));
  931. pMsrResultItem->SetNumber(1);
  932. // add the particle into to field data
  933. poMsrResults->CumulateMeasureResults(pMsrResultItem);
  934. }
  935. pSample->SetMsrResults(poMsrResults);
  936. // 3. Update sample STD
  937. CMsrParamsPtr poMsrParams = pSample->GetMsrParams();
  938. ASSERT(poMsrParams);
  939. if (!poMsrParams)
  940. {
  941. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample parameter pointer."));
  942. return FALSE;
  943. }
  944. poMsrParams->SetPartSTDData(pPartSTDData);
  945. // 4. write sample measure result file.
  946. // sample measure result file
  947. CString strFilePathName = pSmplMsrResultMgr->GetPathName();
  948. if (!pSmplMsrResultMgr->Save(strFilePathName))
  949. {
  950. LogErrorTrace(__FILE__, __LINE__, _T("ReClassify: can't get sample pointer."));
  951. return FALSE;
  952. }
  953. }
  954. return TRUE;
  955. }
  956. // get inclusion index
  957. double CReportProjFileMgr::GetInclusionIndex()
  958. {
  959. // get folder name from general parameter.
  960. ASSERT(m_pReportProjFile);
  961. if (!m_pReportProjFile)
  962. {
  963. LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: Can't find the folder."));
  964. return -1;
  965. }
  966. double dScale = m_pReportProjFile->GetScale();
  967. double dTotalMeasuredArea = 0.0;
  968. double dInclusionArea = 0.0;
  969. CSmplMsrResultFileMgrList m_listSmplMsrResultMgrs;
  970. for (auto pSmplMsrResultMgr : m_listSmplMsrResultMgrs)
  971. {
  972. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
  973. ASSERT(pSmplMsrResultFile);
  974. if (!pSmplMsrResultFile)
  975. {
  976. LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample measure result file pointer."));
  977. return -1;
  978. }
  979. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  980. ASSERT(pSample);
  981. if (!pSample)
  982. {
  983. LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample pointer."));
  984. return -1;
  985. }
  986. CMsrResultsPtr poMsrResults = pSample->GetMsrResults();
  987. ASSERT(poMsrResults);
  988. if (!poMsrResults)
  989. {
  990. LogErrorTrace(__FILE__, __LINE__, _T("GetInclusionIndex: invalid sample measure result pointer."));
  991. return -1;
  992. }
  993. dTotalMeasuredArea += poMsrResults->GetMeasuredArea();
  994. CMsrResultItemsList listResultItems = poMsrResults->GetResultItems();
  995. for (auto pItem : listResultItems)
  996. {
  997. int nType = pItem->GetTypeId();
  998. if (nType > (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  999. {
  1000. dInclusionArea += pItem->GetArea();
  1001. }
  1002. }
  1003. }
  1004. return dInclusionArea / dTotalMeasuredArea * dScale;
  1005. }
  1006. // classify particles
  1007. BOOL CReportProjFileMgr::ClassifyParticles(COTSParticleList& a_listAnalysisParticles, CPosXraysList& a_listAnalysisXRay)
  1008. {
  1009. // make sure the two lists are same size
  1010. int nSize = (int)a_listAnalysisParticles.size();
  1011. if (nSize != (int)a_listAnalysisXRay.size())
  1012. {
  1013. // particles list size is different with x-ray size
  1014. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: particles list size is different with x-ray size."));
  1015. return FALSE;
  1016. }
  1017. // go through all analysis particles
  1018. for (int i = 0; i < nSize; ++i)
  1019. {
  1020. COTSParticlePtr pParticle = a_listAnalysisParticles[i];
  1021. int nAnalysisXrayId = pParticle->GetAnalysisId();
  1022. if (nAnalysisXrayId < 0 || nAnalysisXrayId >= nSize)
  1023. {
  1024. // particles list size is different with x-ray size
  1025. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: particles xray id is wrong."));
  1026. return FALSE;
  1027. }
  1028. int nFieldId = pParticle->GetFieldId();
  1029. //using on classify debug,trace fieldid and analysisxrayid
  1030. if (nFieldId == 135 && nAnalysisXrayId == 38)
  1031. {
  1032. int a = 0;
  1033. }
  1034. auto itr = std::find_if(a_listAnalysisXRay.begin(), a_listAnalysisXRay.end(), [nAnalysisXrayId, nFieldId](CPosXrayPtr p) { return (p->GetScanFieldId() == nFieldId && p->GetIndex() == nAnalysisXrayId); });
  1035. if (itr == a_listAnalysisXRay.end())
  1036. {
  1037. return FALSE;
  1038. }
  1039. CPosXrayPtr pXray = *itr;
  1040. if (!ClassifyParticle(pParticle, pXray))
  1041. {
  1042. // failed to call ClassifyParticle method
  1043. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticles: failed to call ClassifyParticle method."));
  1044. return FALSE;
  1045. }
  1046. }
  1047. // ok, return TRUE
  1048. return TRUE;
  1049. }
  1050. BOOL CReportProjFileMgr::ClassifyParticle(COTSParticlePtr a_pParticle, CPosXrayPtr a_pXRay)
  1051. {
  1052. // safety check
  1053. ASSERT(m_pReportProjFile);
  1054. if (!m_pReportProjFile)
  1055. {
  1056. // invalid sample pointer.
  1057. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid sample pointer."));
  1058. return FALSE;
  1059. }
  1060. ASSERT(a_pParticle);
  1061. if (!a_pParticle)
  1062. {
  1063. // invalid particle pointer.
  1064. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid particle pointer."));
  1065. return FALSE;
  1066. }
  1067. ASSERT(a_pXRay);
  1068. if (!a_pXRay)
  1069. {
  1070. // invalid x-ray pointer.
  1071. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: invalid x-ray pointer."));
  1072. return FALSE;
  1073. }
  1074. //2019.3.28 code changes
  1075. //initial inclusion ID is NOT_IDENTIFIED
  1076. int nIncId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
  1077. //get STDData from Reportprojfile
  1078. CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  1079. //get element chemistries list from xray
  1080. CElementChemistriesList listElementChemistriesOld = a_pXRay->GetElementQuantifyData();
  1081. auto pSample = m_listSmplMgrs[m_nWorkingSampeIndex]->GetSmplMsrResultFile()->GetSample();
  1082. //get the parameter MsrParam object
  1083. CMsrParamsPtr pMsrParam = pSample->GetMsrParams();
  1084. //get the steel technology parameter
  1085. STEEL_TECHNOLOGY steelTech = pMsrParam->GetSteelTechnology();
  1086. //get standard database item which will be used when classify.
  1087. //third setp.the particle are classified
  1088. if (!COTSClassifyEng::ClassifyXray(pPartSTDData, steelTech, listElementChemistriesOld, nIncId))
  1089. {// invalid x-ray pointer.
  1090. LogErrorTrace(__FILE__, __LINE__, _T("ClassifyParticle: can't identify the particle as any inclusion."));
  1091. return FALSE;
  1092. }
  1093. if (nIncId < 8)
  1094. {
  1095. nIncId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
  1096. }
  1097. a_pParticle->SetType(nIncId);
  1098. // ok, return TRUE
  1099. return TRUE;
  1100. }
  1101. // protected
  1102. // get data source name list
  1103. std::vector<CString> CReportProjFileMgr::GetDataSourceNamesList()
  1104. {
  1105. std::vector<CString> listDataSourceNames;
  1106. CString strComSourceName = _T("");
  1107. int nComNum = 0;
  1108. for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
  1109. {
  1110. // sample measure result file
  1111. CString strFilePathName = pSmplMsrResultFileMgr->GetPathName();
  1112. // get data source name
  1113. CString strDataSource = COTSHelper::GetFileName(strFilePathName);
  1114. // get compound source name
  1115. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  1116. ASSERT(pSmplMsrResultFile);
  1117. if (!pSmplMsrResultFile)
  1118. {
  1119. LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
  1120. break;
  1121. }
  1122. BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
  1123. if (bSwitch)
  1124. {
  1125. strComSourceName += strDataSource + _T("+");
  1126. nComNum++;
  1127. }
  1128. // add data source name into the list
  1129. listDataSourceNames.push_back(strDataSource);
  1130. }
  1131. if (nComNum > 1)
  1132. {
  1133. //listDataSourceNames.push_back(strComSourceName);
  1134. strComSourceName.TrimRight(_T("+"));//去掉最后的+号
  1135. listDataSourceNames.insert(listDataSourceNames.begin(), strComSourceName);
  1136. }
  1137. return listDataSourceNames;
  1138. }
  1139. std::vector<int> CReportProjFileMgr::GetDataSourcePosList()
  1140. {
  1141. std::vector<int> listDataSourcePos;
  1142. if (!IsHaveMultiDataSource())
  1143. {
  1144. return listDataSourcePos;
  1145. }
  1146. int nPos = -1;
  1147. for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
  1148. {
  1149. nPos++;
  1150. // get compound source name
  1151. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  1152. ASSERT(pSmplMsrResultFile);
  1153. if (!pSmplMsrResultFile)
  1154. {
  1155. LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
  1156. break;
  1157. }
  1158. BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
  1159. if (bSwitch)
  1160. {
  1161. listDataSourcePos.push_back(nPos);
  1162. }
  1163. }
  1164. return listDataSourcePos;
  1165. }
  1166. // get property parameter
  1167. // compute particle general information
  1168. CGridDatasList CReportProjFileMgr::CompParticleGenInfo()
  1169. {
  1170. // use the dll resource
  1171. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1172. CGridDatasList listGridData;
  1173. listGridData.clear();
  1174. // depart compound source name
  1175. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  1176. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  1177. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  1178. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  1179. std::vector<int> listSelectedPos;
  1180. if (IsHaveMultiDataSource() && (int)listSelectedDataSource.size() > 1)
  1181. {
  1182. listSelectedPos = GetDataSourcePosList();
  1183. if ((int)listSelectedPos.size() != (int)listSelectedDataSource.size())
  1184. {
  1185. return listGridData;
  1186. }
  1187. }
  1188. int nIndex = 0;
  1189. for (auto strDataSourceName : listSelectedDataSource)
  1190. {
  1191. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  1192. //// data source id
  1193. pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
  1194. int nDataSourceId = -1;
  1195. if (IsHaveMultiDataSource())
  1196. {
  1197. if (listSelectedDataSource.size() > 1)
  1198. {
  1199. nDataSourceId = listSelectedPos[nIndex];
  1200. }
  1201. else
  1202. {
  1203. nDataSourceId = m_CurrentPropParam->GetDataSourceId() - 1;
  1204. }
  1205. }
  1206. else
  1207. {
  1208. nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  1209. }
  1210. pGridData->SetDataSourceId(nDataSourceId);
  1211. //------------select xray data add 2019-06-15-----------------
  1212. COTSParticleList listParticleAll;
  1213. listParticleAll.clear();
  1214. CPosXraysList listXrayOut;
  1215. listXrayOut.clear();
  1216. CPosXraysList listXray;
  1217. listXray.clear();
  1218. COTSParticleList selectedParts = m_CurrentPropParam->GetSelectParticle();
  1219. // add filter select particle
  1220. COTSParticleList* pSelectedParts;
  1221. listXrayOut = GetAnalysisXrayList(strDataSourceName);
  1222. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  1223. {
  1224. listParticleAll = m_CurrentPropParam->GetSelectParticle();
  1225. pSelectedParts = &selectedParts;
  1226. for (auto pParticle : listParticleAll)
  1227. {
  1228. int nIndex = pParticle->GetAnalysisId();
  1229. int nField = pParticle->GetFieldId();
  1230. auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
  1231. if (itr == listXrayOut.end())
  1232. {
  1233. continue;
  1234. }
  1235. else
  1236. {
  1237. CPosXrayPtr pXray = *itr;
  1238. listXray.push_back(pXray);
  1239. }
  1240. }
  1241. }
  1242. else
  1243. {
  1244. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  1245. pSelectedParts = &listParticleAll;
  1246. for (auto pXray : listXrayOut)
  1247. {
  1248. //CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
  1249. listXray.push_back(pXray);
  1250. }
  1251. }
  1252. //-----------------------------------------------------------
  1253. //get pixel size
  1254. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
  1255. ASSERT(pSmplMsrResultFileMgr);
  1256. if (!pSmplMsrResultFileMgr)
  1257. {
  1258. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample result file manager."));
  1259. return listGridData;
  1260. }
  1261. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  1262. ASSERT(pSmplMsrResultFile);
  1263. if (!pSmplMsrResultFile)
  1264. {
  1265. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample result file."));
  1266. return listGridData;
  1267. }
  1268. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  1269. ASSERT(pSample);
  1270. if (!pSample)
  1271. {
  1272. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get sample."));
  1273. return listGridData;
  1274. }
  1275. double dPixelSize = pSample->CalculatePixelSize();
  1276. if (!GetGenInfoFromParticleList(*pSelectedParts, listXray, dPixelSize, pGridData))
  1277. {
  1278. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: can't get general information."));
  1279. return listGridData;
  1280. }
  1281. listGridData.push_back(pGridData);
  1282. nIndex++;
  1283. }
  1284. return listGridData;
  1285. }
  1286. COTSParticleList CReportProjFileMgr::GetAnalysisParticleList(CString a_DataSourceName)
  1287. {
  1288. COTSParticleList listParticleAll;
  1289. // compound sample measure result files
  1290. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
  1291. if (!pSmplMsrResultFileMgr->ComputeParticleList())
  1292. {
  1293. LogErrorTrace(__FILE__, __LINE__, _T("GetAnalysisParticleList: can't get particle list."));
  1294. return listParticleAll;
  1295. }
  1296. listParticleAll = pSmplMsrResultFileMgr->GetParticleList();
  1297. return listParticleAll;
  1298. }
  1299. CPosXraysList CReportProjFileMgr::GetAnalysisXrayList(CString a_DataSourceName)
  1300. {
  1301. CPosXraysList listAnalysisXray;
  1302. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
  1303. pSmplMsrResultFileMgr->GetOTSFldMgrListAndAnalysisXrayList();
  1304. // should first read x ray data from data base.
  1305. listAnalysisXray = pSmplMsrResultFileMgr->GetAnalysisXray();
  1306. return listAnalysisXray;
  1307. }
  1308. CSTDItemPtr CReportProjFileMgr::GetParticleSTDItem(int STDItemId) {
  1309. // std
  1310. ASSERT(m_pReportProjFile);
  1311. if (!m_pReportProjFile)
  1312. {
  1313. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: empty project file."));
  1314. return nullptr;
  1315. }
  1316. CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  1317. ASSERT(pPartSTDData);
  1318. if (!pPartSTDData)
  1319. {
  1320. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: invalid STD data."));
  1321. return nullptr;
  1322. }
  1323. CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
  1324. if (listSTDItem.empty())
  1325. {
  1326. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: empty STD Item."));
  1327. return nullptr;
  1328. }
  1329. auto itr = std::find_if(listSTDItem.begin(), listSTDItem.end(), [STDItemId](CSTDItemPtr p) {return (p->GetSTDId() == STDItemId); });
  1330. if (itr == listSTDItem.end()) //没有找到,标明这是一个未识别颗粒,类型为7
  1331. {
  1332. return nullptr;
  1333. }
  1334. CSTDItemPtr p = *itr;
  1335. return p;
  1336. }
  1337. bool CReportProjFileMgr::GetSTDMapedParticleList(const COTSParticleList& a_listParticle, map<int, COTSParticleList>* mapSameSTDPartList)
  1338. {
  1339. //把颗粒根据类型分组,类型 ID做key,颗粒列表做value
  1340. map<int, COTSParticleList>::iterator partListIter;
  1341. //get the same type particle together
  1342. for (auto pParticle : a_listParticle)
  1343. {
  1344. int nType = pParticle->GetType();
  1345. //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
  1346. if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  1347. {
  1348. partListIter = mapSameSTDPartList->find(nType);
  1349. if (partListIter == mapSameSTDPartList->end())
  1350. {
  1351. COTSParticleList listParticle;
  1352. listParticle.push_back(pParticle);
  1353. mapSameSTDPartList->insert(pair<int, COTSParticleList>(nType, listParticle));
  1354. }
  1355. else
  1356. {
  1357. partListIter->second.push_back(pParticle);
  1358. }
  1359. }
  1360. }
  1361. return true;
  1362. }
  1363. // compute particle general information according to particle list
  1364. BOOL CReportProjFileMgr::GetGenInfoFromParticleList(COTSParticleList a_listParticle, CPosXraysList a_listXray, double a_dPixelSize, CGridDataPtr a_pGridData)
  1365. {
  1366. ASSERT(a_pGridData);
  1367. if (!a_pGridData)
  1368. {
  1369. LogErrorTrace(__FILE__, __LINE__, _T("GetGenInfoFromParticleList: invalid grid data pointer."));
  1370. return FALSE;
  1371. }
  1372. COTSParticleList listPartReport;
  1373. map<int, COTSParticleList> mapSameSTDItemPartList;
  1374. this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
  1375. COTSParticleList listNotIdentified;
  1376. COTSParticleList listSiC;
  1377. COTSParticleList listFeO;
  1378. for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
  1379. {
  1380. if (partListIter->first != (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  1381. {
  1382. listPartReport.insert(listPartReport.end(), partListIter->second.begin(), partListIter->second.end());
  1383. }
  1384. else if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  1385. {
  1386. listSiC = partListIter->second;
  1387. }
  1388. else if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
  1389. {
  1390. listFeO = partListIter->second;
  1391. }
  1392. else
  1393. {
  1394. listNotIdentified = partListIter->second;
  1395. }
  1396. }
  1397. listPartReport.insert(listPartReport.end(), listSiC.begin(), listSiC.end());
  1398. listPartReport.insert(listPartReport.end(), listFeO.begin(), listFeO.end());
  1399. listPartReport.insert(listPartReport.end(), listNotIdentified.begin(), listNotIdentified.end());
  1400. int nColumnNum = ((int)(REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MAX) - (int)(REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MIN) + 1);
  1401. std::vector<CString> listColumnName;
  1402. LoadColumnString(listColumnName, IDS_PARTICLE_GEN_INFO_START, nColumnNum);
  1403. if ((int)listColumnName.size() != nColumnNum)
  1404. {
  1405. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleGenInfo: Can't get column name number."));
  1406. return FALSE;
  1407. }
  1408. //将元素进行分栏显示汇总集合
  1409. vector< CElementChemistriesList> vec_CElementChemistriesList;
  1410. vec_CElementChemistriesList.clear();
  1411. CGridColumnsList listGridColumn;
  1412. for (int i = 0; i < nColumnNum; i++)
  1413. {
  1414. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  1415. pColumn->SetName(listColumnName[i]);
  1416. CGridRowsList listGridRows;
  1417. listGridRows.clear();
  1418. int nType = 0;
  1419. int nPos = 0;
  1420. double a_dPartFTD;
  1421. double a_dMinWidth;
  1422. double a_dMaxLength;
  1423. //double a_dRatio;
  1424. switch (i)
  1425. {
  1426. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::NAME:
  1427. listGridRows.clear();
  1428. for (auto pParticle : listPartReport)
  1429. {
  1430. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1431. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1432. nType = pParticle->GetType();
  1433. if (nType >= (int)OTS_PARTCLE_TYPE::IDENTIFIED)
  1434. {
  1435. std::string strName = pParticle->TypeName();
  1436. pGridRow->SetStringValue(strName.c_str());
  1437. }
  1438. else
  1439. {
  1440. int nColumnNum = ((int)(REPORT_SORT_CLASS_GRID_CLUMN::MAX) - (int)(REPORT_SORT_CLASS_GRID_CLUMN::MIN) + 1);
  1441. std::vector<CString> listColumnName;
  1442. LoadColumnString(listColumnName, IDS_SORT_CLASS_START, nColumnNum);
  1443. if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  1444. {
  1445. pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_IDENTIFIED]);//未知颗粒
  1446. }
  1447. else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  1448. {
  1449. pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_SIC]);//SiC
  1450. }
  1451. else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
  1452. {
  1453. pGridRow->SetStringValue(listColumnName[(int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_FEO]);//FeO
  1454. }
  1455. }
  1456. listGridRows.push_back(pGridRow);
  1457. //获取element数据
  1458. int XrayId = pParticle->GetAnalysisId();
  1459. int nFieldId = pParticle->GetFieldId();
  1460. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
  1461. CPosXrayPtr pXray = *itr;
  1462. CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
  1463. //将获取到的元素先都添加到元素的List当中
  1464. vec_CElementChemistriesList.push_back(listTpElement);
  1465. }
  1466. break;
  1467. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::IMAGE:
  1468. listGridRows.clear();
  1469. for (auto pParticle : listPartReport)
  1470. {
  1471. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1472. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  1473. //COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  1474. pGridRow->SetParticle(pParticle);
  1475. listGridRows.push_back(pGridRow);
  1476. }
  1477. break;
  1478. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MAXLENGTH://最长直径
  1479. listGridRows.clear();
  1480. for (auto pParticle : listPartReport)
  1481. {
  1482. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1483. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1484. a_dMaxLength = pParticle->GetDMax();
  1485. pGridRow->SetDoubleValue(a_dMaxLength);
  1486. listGridRows.push_back(pGridRow);
  1487. }
  1488. break;
  1489. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MINLENGTH://最短直径
  1490. listGridRows.clear();
  1491. for (auto pParticle : listPartReport)
  1492. {
  1493. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1494. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1495. a_dMinWidth = pParticle->GetDMin();
  1496. pGridRow->SetDoubleValue(a_dMinWidth);
  1497. listGridRows.push_back(pGridRow);
  1498. }
  1499. break;
  1500. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::AXIALRATIO://长短直径比
  1501. listGridRows.clear();
  1502. for (auto pParticle : listPartReport)
  1503. {
  1504. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1505. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1506. a_dMinWidth = pParticle->GetDMax();
  1507. a_dMaxLength = pParticle->GetDMin();
  1508. double d_axialratio = 0;
  1509. if (a_dMinWidth != 0)
  1510. {
  1511. d_axialratio = a_dMaxLength / a_dMinWidth;
  1512. }
  1513. pGridRow->SetDoubleValue(d_axialratio);
  1514. listGridRows.push_back(pGridRow);
  1515. }
  1516. break;
  1517. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::EquivalentCircleDiameter://等效圆直径
  1518. listGridRows.clear();
  1519. //double Diameter;
  1520. for (auto pParticle : listPartReport)
  1521. {
  1522. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1523. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1524. double Diameter = pParticle->GetEqualCircleDiameter();
  1525. pGridRow->SetDoubleValue(Diameter);
  1526. listGridRows.push_back(pGridRow);
  1527. }
  1528. break;
  1529. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::FerretDiameter://费雷特直径
  1530. listGridRows.clear();
  1531. for (auto pParticle : listPartReport)
  1532. {
  1533. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1534. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1535. a_dPartFTD = (pParticle->GetDMax() + pParticle->GetDMin()) / 2;
  1536. //a_dPartFTD = pParticle->GetFeretDiameter();
  1537. pGridRow->SetDoubleValue(a_dPartFTD);
  1538. listGridRows.push_back(pGridRow);
  1539. }
  1540. break;
  1541. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::SIZE:
  1542. listGridRows.clear();
  1543. for (auto pParticle : listPartReport)
  1544. {
  1545. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1546. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1547. double dSize = pParticle->GetArea();
  1548. pGridRow->SetDoubleValue(dSize);
  1549. listGridRows.push_back(pGridRow);
  1550. //pParticle->GetFeretDiameter();
  1551. }
  1552. break;
  1553. //2020-4-11 add new calc type
  1554. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::PERP: //正交直径
  1555. listGridRows.clear();
  1556. for (auto pParticle : listPartReport)
  1557. {
  1558. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1559. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1560. double dPerp = pParticle->GetDPerp();
  1561. pGridRow->SetDoubleValue(dPerp);
  1562. listGridRows.push_back(pGridRow);
  1563. }
  1564. break;
  1565. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::PERI: //周长
  1566. listGridRows.clear();
  1567. for (auto pParticle : listPartReport)
  1568. {
  1569. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1570. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1571. double dPeri = pParticle->GetPerimeter();
  1572. pGridRow->SetDoubleValue(dPeri);
  1573. listGridRows.push_back(pGridRow);
  1574. }
  1575. break;
  1576. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::INSCR: //内接圆直径
  1577. listGridRows.clear();
  1578. for (auto pParticle : listPartReport)
  1579. {
  1580. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1581. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1582. double dInscr = pParticle->GetDInscr();
  1583. pGridRow->SetDoubleValue(dInscr);
  1584. listGridRows.push_back(pGridRow);
  1585. }
  1586. break;
  1587. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::MEAN: //内接圆平均直径
  1588. listGridRows.clear();
  1589. for (auto pParticle : listPartReport)
  1590. {
  1591. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1592. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1593. double dMean = pParticle->GetDMean();
  1594. pGridRow->SetDoubleValue(dMean);
  1595. listGridRows.push_back(pGridRow);
  1596. }
  1597. break;
  1598. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ELONG: //展开长度
  1599. listGridRows.clear();
  1600. for (auto pParticle : listPartReport)
  1601. {
  1602. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1603. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1604. double dElong = pParticle->GetDElong();
  1605. pGridRow->SetDoubleValue(dElong);
  1606. listGridRows.push_back(pGridRow);
  1607. }
  1608. break;
  1609. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ASPECT_ELONG: //展开长度比
  1610. listGridRows.clear();
  1611. for (auto pParticle : listPartReport)
  1612. {
  1613. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1614. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1615. double dAspectElong = pParticle->GetAspectElong();
  1616. pGridRow->SetDoubleValue(dAspectElong);
  1617. listGridRows.push_back(pGridRow);
  1618. }
  1619. break;
  1620. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::ASPECT_MAX: //展开直径比
  1621. listGridRows.clear();
  1622. for (auto pParticle : listPartReport)
  1623. {
  1624. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1625. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1626. double dAspectRatio = pParticle->GetAspectRatio();
  1627. pGridRow->SetDoubleValue(dAspectRatio);
  1628. listGridRows.push_back(pGridRow);
  1629. }
  1630. break;
  1631. case (int)REPORT_PARTICLE_GEN_INFO_GRID_CLUMN::Orientation: //朝向角度
  1632. listGridRows.clear();
  1633. for (auto pParticle : listPartReport)
  1634. {
  1635. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1636. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1637. double dOrientation = pParticle->GetOrientation();
  1638. pGridRow->SetDoubleValue(dOrientation);
  1639. listGridRows.push_back(pGridRow);
  1640. }
  1641. break;
  1642. }
  1643. pColumn->SetGridRowsList(listGridRows);
  1644. listGridColumn.push_back(pColumn);
  1645. }
  1646. //定义一个不显示的元素字符列表
  1647. vector<CString> vec_NotDisplayed;
  1648. vec_NotDisplayed.clear();
  1649. //上面获取完成vector CElementChemistriesList 后,再对该列表取出不同元素名的所有元素的总数
  1650. vector<CString> vec_CString;
  1651. vec_CString.clear();
  1652. for (auto pListTpElement : vec_CElementChemistriesList)
  1653. {
  1654. for (auto pCElementChemistry : pListTpElement)
  1655. {
  1656. CString ls_CString = pCElementChemistry->GetName();
  1657. //判断是否已经添加完在字符列表中了
  1658. bool b_sfcz = false;
  1659. for (int i = 0; i < vec_CString.size(); i++)
  1660. {
  1661. if (vec_CString[i] == ls_CString)
  1662. {
  1663. b_sfcz = true;
  1664. break;
  1665. }
  1666. }
  1667. //判断是否在不显示的元素列表中
  1668. for (int i = 0; i < vec_NotDisplayed.size(); i++)
  1669. {
  1670. if (vec_NotDisplayed[i] == ls_CString)
  1671. {
  1672. b_sfcz = true;
  1673. break;
  1674. }
  1675. }
  1676. //未添加进列表中,及不在不显示的元素列表中的话,对该元素进行添加
  1677. if (b_sfcz == false)
  1678. {
  1679. vec_CString.push_back(ls_CString);
  1680. }
  1681. }
  1682. }
  1683. ////获得了总数后,再添加Column,
  1684. for (unsigned int i = 0; i < vec_CString.size(); i++)
  1685. {
  1686. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  1687. pColumn->SetName(vec_CString[i]);
  1688. CGridRowsList listGridRows;
  1689. listGridRows.clear();
  1690. for (auto pParticle : listPartReport)
  1691. {
  1692. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1693. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  1694. int XrayId = pParticle->GetAnalysisId();
  1695. int nFieldId = pParticle->GetFieldId();
  1696. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
  1697. if (itr == a_listXray.end())
  1698. {
  1699. break;
  1700. }
  1701. else
  1702. {
  1703. //找到了的情况下,与之对应取出
  1704. CPosXrayPtr pXray = *itr;
  1705. CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
  1706. for (int k = 0; k < (int)listTpElement.size(); k++)
  1707. {
  1708. if (listTpElement[k]->GetName() == vec_CString[i])
  1709. {
  1710. //对应到了该列,将重量比添加到row中
  1711. pGridRow->SetDoubleValue(listTpElement[k]->GetPercentage());
  1712. }
  1713. }
  1714. //pGridRow->SetDoubleValue(listTpElement[0]->GetPercentage());
  1715. }
  1716. //从该颗粒中,查找与vec_CString[i]对应的元素,找到的话,取出重量比
  1717. listGridRows.push_back(pGridRow);
  1718. }
  1719. pColumn->SetGridRowsList(listGridRows);
  1720. listGridColumn.push_back(pColumn);
  1721. }
  1722. //reset load param file
  1723. //过滤要显示的列
  1724. CGridColumnsList::iterator itr = listGridColumn.begin();
  1725. while (itr != listGridColumn.end())
  1726. {
  1727. if (EstimateShowColumn((*itr)->GetName()) == false)
  1728. {
  1729. itr = listGridColumn.erase(itr);
  1730. continue;
  1731. }
  1732. itr++;
  1733. }
  1734. a_pGridData->SetGridColumnList(listGridColumn);
  1735. return TRUE;
  1736. }
  1737. //判断该列是否要显示
  1738. BOOL CReportProjFileMgr::EstimateShowColumn(CString a_strColName)
  1739. {
  1740. CString str_Area_Enum = "Area";
  1741. CString str_MaxDiameter_Enum = "MaxDiameter";
  1742. CString str_MinDiameter_Enum = "MinDiameter";
  1743. CString str_DiameterRatio_Enum = "DiameterRatio";
  1744. CString str_EquivalentCircleDiameter_Enum = "EquivalentCircleDiameter";
  1745. CString str_FerretDiameter_Enum = "FerretDiameter";
  1746. CString str_Area_CN = "颗粒面积";
  1747. CString str_MaxDiameter_CN = "最长直径";
  1748. CString str_MinDiameter_CN = "最短直径";
  1749. CString str_DiameterRatio_CN = "长短直径比";
  1750. CString str_EquivalentCircleDiameter_CN = "等效圆直径";
  1751. CString str_FerretDiameter_CN = "费雷特直径";
  1752. //最后再根据设置默认显示列名,对不需要显示的列进行屏蔽
  1753. CString s_DefaultComputedColName = m_rptparamfile->GetDefaultComputedColName();
  1754. if (a_strColName.Find(str_Area_CN, 0) > -1 || a_strColName.Find(str_MaxDiameter_CN, 0) > -1 ||
  1755. a_strColName.Find(str_MinDiameter_CN, 0) > -1 || a_strColName.Find(str_DiameterRatio_CN, 0) > -1 ||
  1756. a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1 || a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
  1757. {
  1758. //面积
  1759. if (s_DefaultComputedColName.Find(str_Area_Enum) > -1 && a_strColName.Find(str_Area_CN, 0) > -1)
  1760. {
  1761. return true;
  1762. }
  1763. //最长直径
  1764. if (s_DefaultComputedColName.Find(str_MaxDiameter_Enum) > -1 && a_strColName.Find(str_MaxDiameter_CN, 0) > -1)
  1765. {
  1766. return true;
  1767. }
  1768. //最短直径
  1769. if (s_DefaultComputedColName.Find(str_MinDiameter_Enum) > -1 && a_strColName.Find(str_MinDiameter_CN, 0) > -1)
  1770. {
  1771. return true;
  1772. }
  1773. //长短直径比
  1774. if (s_DefaultComputedColName.Find(str_DiameterRatio_Enum) > -1 && a_strColName.Find(str_DiameterRatio_CN, 0) > -1)
  1775. {
  1776. return true;
  1777. }
  1778. //等效圆直径
  1779. if (s_DefaultComputedColName.Find(str_EquivalentCircleDiameter_Enum) > -1 && a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1)
  1780. {
  1781. return true;
  1782. }
  1783. //费雷特直径
  1784. if (s_DefaultComputedColName.Find(str_FerretDiameter_Enum) > -1 && a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
  1785. {
  1786. return true;
  1787. }
  1788. return false;
  1789. }
  1790. return true;
  1791. }
  1792. // compute particle component
  1793. CGridDatasList CReportProjFileMgr::CompParticleComponent()
  1794. {
  1795. // use the dll resource
  1796. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1797. CGridDatasList listGridData;
  1798. listGridData.clear();
  1799. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  1800. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  1801. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  1802. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  1803. //int nIndex = 0;
  1804. for (auto strDataSourceName : listSelectedDataSource)
  1805. {
  1806. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  1807. // data source id
  1808. pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
  1809. pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
  1810. COTSParticleList* pSelectidParts;
  1811. COTSParticleList listParticleAll;
  1812. COTSParticleList seleParticles;
  1813. // add filter select particle
  1814. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  1815. {
  1816. seleParticles = m_CurrentPropParam->GetSelectParticle();
  1817. pSelectidParts = &seleParticles;
  1818. }
  1819. else
  1820. {
  1821. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  1822. pSelectidParts = &listParticleAll;
  1823. }
  1824. //get pixel size
  1825. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
  1826. ASSERT(pSmplMsrResultFileMgr);
  1827. if (!pSmplMsrResultFileMgr)
  1828. {
  1829. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample result file manager."));
  1830. return listGridData;
  1831. }
  1832. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  1833. ASSERT(pSmplMsrResultFile);
  1834. if (!pSmplMsrResultFile)
  1835. {
  1836. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample result file."));
  1837. return listGridData;
  1838. }
  1839. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  1840. ASSERT(pSample);
  1841. if (!pSample)
  1842. {
  1843. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get sample."));
  1844. return listGridData;
  1845. }
  1846. double dPixelSize = pSample->CalculatePixelSize();
  1847. if (!GetComponentFromParticleList(*pSelectidParts, m_CurrentPropParam->GetSizeCalMethodType(), dPixelSize, pGridData))
  1848. {
  1849. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  1850. return listGridData;
  1851. }
  1852. listGridData.push_back(pGridData);
  1853. }
  1854. return listGridData;
  1855. }
  1856. BOOL CReportProjFileMgr::GetComponentFromParticleList(COTSParticleList a_listParticle, OTSMODEL::SIZE_CAL_METHOD_TYPE a_nMethod, double a_dPixelSize, CGridDataPtr a_pGridData)
  1857. {
  1858. // use the dll resource
  1859. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1860. ASSERT(a_pGridData);
  1861. if (!a_pGridData)
  1862. {
  1863. LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid grid data pointer."));
  1864. return FALSE;
  1865. }
  1866. //// std
  1867. //ASSERT(m_pReportProjFile);
  1868. //if (!m_pReportProjFile)
  1869. //{
  1870. // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty project file."));
  1871. // return FALSE;
  1872. //}
  1873. //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  1874. //ASSERT(pPartSTDData);
  1875. //if (!pPartSTDData)
  1876. //{
  1877. // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid STD data."));
  1878. // return FALSE;
  1879. //}
  1880. //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
  1881. //if (listSTDItem.empty())
  1882. //{
  1883. // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty STD Item."));
  1884. // return FALSE;
  1885. //}
  1886. //get the same type particle together
  1887. map<int, COTSParticleList> mapSameSTDItemPartList;
  1888. map<int, COTSParticleList>::iterator partListIter;
  1889. this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
  1890. /*CSTDItemsList listHavePartSTDItem;
  1891. for (auto STDItem : listSTDItem)
  1892. {
  1893. auto partListIter = mapSameSTDItemPartList.find(STDItem->GetSTDId());
  1894. if (partListIter != mapSameSTDItemPartList.end())
  1895. {
  1896. listHavePartSTDItem.push_back(STDItem);
  1897. }
  1898. }*/
  1899. int nColumnNum = ((int)(REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MAX) - (int)(REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN) + 1);
  1900. std::vector<CString> listColumnName;
  1901. LoadColumnString(listColumnName, IDS_PARTICLE_COMPONENT_START, nColumnNum);
  1902. if ((int)listColumnName.size() != nColumnNum)
  1903. {
  1904. LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: Can't get column name number."));
  1905. return FALSE;
  1906. }
  1907. CGridColumnsList listGridColumn;
  1908. COTSParticleList listPartReport;
  1909. for (int i = 0; i < nColumnNum; i++)
  1910. {
  1911. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  1912. pColumn->SetName(listColumnName[i]);
  1913. CGridRowsList listGridRows;
  1914. listGridRows.clear();
  1915. switch (i)
  1916. {
  1917. case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::NAME:
  1918. {
  1919. // std item name
  1920. listGridRows.clear();
  1921. for (auto STDPart : mapSameSTDItemPartList)
  1922. {
  1923. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1924. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1925. std::string name = STDPart.second[0]->TypeName();
  1926. //pGridRow->SetStringValue(STDPart->GetName ());
  1927. pGridRow->SetStringValue(name.c_str());
  1928. listGridRows.push_back(pGridRow);
  1929. }
  1930. auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
  1931. if (itr != mapSameSTDItemPartList.end())
  1932. {
  1933. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  1934. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1935. CString strUndefined;
  1936. strUndefined = MultiLang::GetInstance().GetCStringByKey(IDS_UNDEFINED_PARTICLE);
  1937. pGridRowUndefined->SetStringValue(strUndefined);
  1938. listGridRows.push_back(pGridRowUndefined);
  1939. }
  1940. auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
  1941. if (itrSiC != mapSameSTDItemPartList.end())
  1942. {
  1943. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  1944. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1945. CString strSiC;
  1946. strSiC = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);
  1947. pGridRowSiC->SetStringValue(strSiC);
  1948. listGridRows.push_back(pGridRowSiC);
  1949. }
  1950. auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
  1951. if (itrFeO != mapSameSTDItemPartList.end())
  1952. {
  1953. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  1954. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1955. CString strFeO;
  1956. strFeO = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);
  1957. pGridRowFeO->SetStringValue(strFeO);
  1958. listGridRows.push_back(pGridRowFeO);
  1959. }
  1960. }
  1961. break;
  1962. case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::COLOUR:
  1963. {
  1964. // std item color
  1965. listGridRows.clear();
  1966. for (auto STDPart : mapSameSTDItemPartList)
  1967. {
  1968. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  1969. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1970. std::string color = STDPart.second[0]->TypeColor();
  1971. pGridRow->SetStringValue(color.c_str());
  1972. listGridRows.push_back(pGridRow);
  1973. }
  1974. auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
  1975. if (itr != mapSameSTDItemPartList.end())
  1976. {
  1977. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  1978. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1979. CString strUndefinedColour = _T("");
  1980. pGridRowUndefined->SetStringValue(strUndefinedColour);
  1981. listGridRows.push_back(pGridRowUndefined);
  1982. }
  1983. auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
  1984. if (itrSiC != mapSameSTDItemPartList.end())
  1985. {
  1986. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  1987. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1988. CString strSiCColour = _T("");
  1989. pGridRowSiC->SetStringValue(strSiCColour);
  1990. listGridRows.push_back(pGridRowSiC);
  1991. }
  1992. auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
  1993. if (itrFeO != mapSameSTDItemPartList.end())
  1994. {
  1995. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  1996. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  1997. CString strFeOColour = _T("");
  1998. pGridRowFeO->SetStringValue(strFeOColour);
  1999. listGridRows.push_back(pGridRowFeO);
  2000. }
  2001. }
  2002. break;
  2003. case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::PARTICLE_NUM:
  2004. { // get each type particle num
  2005. int nParticleUndefined = 0;
  2006. int nParticleSiC = 0;
  2007. int nParticleFeO = 0;
  2008. for (auto pSTDItem : mapSameSTDItemPartList)
  2009. {
  2010. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2011. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2012. int nParticleNum = pSTDItem.second.size();
  2013. pGridRow->SetIntValue(nParticleNum);
  2014. listGridRows.push_back(pGridRow);
  2015. }
  2016. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  2017. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2018. auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
  2019. if (itr != mapSameSTDItemPartList.end())
  2020. {
  2021. nParticleUndefined = itr->second.size();
  2022. }
  2023. else
  2024. {
  2025. nParticleUndefined = 0;
  2026. }
  2027. if (0 != nParticleUndefined)
  2028. {
  2029. pGridRowUndefined->SetIntValue(nParticleUndefined);
  2030. listGridRows.push_back(pGridRowUndefined);
  2031. }
  2032. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  2033. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2034. auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
  2035. if (itrSiC != mapSameSTDItemPartList.end())
  2036. {
  2037. nParticleSiC = itrSiC->second.size();
  2038. }
  2039. else
  2040. {
  2041. nParticleSiC = 0;
  2042. }
  2043. if (0 != nParticleSiC)
  2044. {
  2045. pGridRowSiC->SetIntValue(nParticleSiC);
  2046. listGridRows.push_back(pGridRowSiC);
  2047. }
  2048. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  2049. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2050. auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
  2051. if (itrFeO != mapSameSTDItemPartList.end())
  2052. {
  2053. nParticleFeO = itrFeO->second.size();
  2054. }
  2055. else
  2056. {
  2057. nParticleFeO = 0;
  2058. }
  2059. if (0 != nParticleFeO)
  2060. {
  2061. pGridRowFeO->SetIntValue(nParticleFeO);
  2062. listGridRows.push_back(pGridRowFeO);
  2063. }
  2064. }
  2065. break;
  2066. case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::AVE_VALUE:
  2067. {
  2068. // get particle average area
  2069. int nParticleUndefined = 0;
  2070. double dAveValueUndefined = 0;
  2071. int nParticleSiC = 0;
  2072. double dAveValueSiC = 0;
  2073. int nParticleFeO = 0;
  2074. double dAveValueFeO = 0;
  2075. for (auto pSTDPart : mapSameSTDItemPartList)
  2076. {
  2077. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2078. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2079. int nParticleNum = 0;
  2080. double dAveValue = 0;
  2081. COTSParticleList listPartReport = pSTDPart.second;
  2082. for (auto pParticle : listPartReport)
  2083. {
  2084. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2085. nParticleNum++;
  2086. dAveValue += dValue;
  2087. }
  2088. if (nParticleNum != 0)
  2089. {
  2090. dAveValue = dAveValue / (double)nParticleNum;
  2091. }
  2092. pGridRow->SetDoubleValue(dAveValue);
  2093. listGridRows.push_back(pGridRow);
  2094. }
  2095. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2096. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2097. auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
  2098. if (itr != mapSameSTDItemPartList.end())
  2099. {
  2100. nParticleUndefined = itr->second.size();
  2101. listPartReport = itr->second;
  2102. }
  2103. else
  2104. {
  2105. nParticleUndefined = 0;
  2106. }
  2107. if (nParticleUndefined != 0)
  2108. {
  2109. for (auto pParticle : listPartReport)
  2110. {
  2111. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2112. dAveValueUndefined += dValue;
  2113. }
  2114. if (nParticleUndefined != 0)
  2115. {
  2116. dAveValueUndefined = dAveValueUndefined / (double)nParticleUndefined;
  2117. }
  2118. pGridRow->SetDoubleValue(dAveValueUndefined);
  2119. listGridRows.push_back(pGridRow);
  2120. }
  2121. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  2122. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2123. auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
  2124. if (itrSiC != mapSameSTDItemPartList.end())
  2125. {
  2126. nParticleSiC = itrSiC->second.size();
  2127. listPartReport = itrSiC->second;
  2128. }
  2129. else
  2130. {
  2131. nParticleSiC = 0;
  2132. }
  2133. if (nParticleSiC != 0)
  2134. {
  2135. for (auto pParticle : listPartReport)
  2136. {
  2137. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2138. dAveValueSiC += dValue;
  2139. }
  2140. if (nParticleSiC != 0)
  2141. {
  2142. dAveValueSiC = dAveValueSiC / (double)nParticleSiC;
  2143. }
  2144. pGridRowSiC->SetDoubleValue(dAveValueSiC);
  2145. listGridRows.push_back(pGridRowSiC);
  2146. }
  2147. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  2148. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2149. auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
  2150. if (itrFeO != mapSameSTDItemPartList.end())
  2151. {
  2152. nParticleFeO = itrFeO->second.size();
  2153. listPartReport = itrFeO->second;
  2154. }
  2155. else
  2156. {
  2157. nParticleFeO = 0;
  2158. }
  2159. if (nParticleFeO != 0)
  2160. {
  2161. for (auto pParticle : listPartReport)
  2162. {
  2163. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2164. dAveValueFeO += dValue;
  2165. }
  2166. if (nParticleFeO != 0)
  2167. {
  2168. dAveValueFeO = dAveValueFeO / (double)nParticleFeO;
  2169. }
  2170. pGridRowFeO->SetDoubleValue(dAveValueFeO);
  2171. listGridRows.push_back(pGridRowFeO);
  2172. }
  2173. }
  2174. break;
  2175. case (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MAX_VALUE:
  2176. {
  2177. // get particle max area
  2178. double dMaxValueUndefined = 0;
  2179. double dMaxValueSiC = 0;
  2180. double dMaxValueFeO = 0;
  2181. double dMaxValue = 0;
  2182. for (auto pSTDPart : mapSameSTDItemPartList)
  2183. {
  2184. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2185. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2186. dMaxValue = 0;
  2187. COTSParticleList listPartReport = pSTDPart.second;
  2188. for (auto pParticle : listPartReport)
  2189. {
  2190. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2191. if (dValue > dMaxValue)
  2192. {
  2193. dMaxValue = dValue;
  2194. }
  2195. }
  2196. pGridRow->SetDoubleValue(dMaxValue);
  2197. listGridRows.push_back(pGridRow);
  2198. }
  2199. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  2200. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2201. auto itr = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED);
  2202. listPartReport.clear();
  2203. if (itr != mapSameSTDItemPartList.end())
  2204. {
  2205. listPartReport = itr->second;
  2206. }
  2207. for (auto pParticle : listPartReport)
  2208. {
  2209. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2210. if (dValue > dMaxValueUndefined)
  2211. {
  2212. dMaxValueUndefined = dValue;
  2213. }
  2214. }
  2215. if (itr != mapSameSTDItemPartList.end())
  2216. {
  2217. pGridRowUndefined->SetDoubleValue(dMaxValueUndefined);
  2218. listGridRows.push_back(pGridRowUndefined);
  2219. }
  2220. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  2221. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2222. auto itrSiC = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC);
  2223. listPartReport.clear();
  2224. if (itrSiC != mapSameSTDItemPartList.end())
  2225. {
  2226. listPartReport = itrSiC->second;
  2227. }
  2228. for (auto pParticle : listPartReport)
  2229. {
  2230. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2231. if (dValue > dMaxValueSiC)
  2232. {
  2233. dMaxValueSiC = dValue;
  2234. }
  2235. }
  2236. if (itrSiC != mapSameSTDItemPartList.end())
  2237. {
  2238. pGridRowSiC->SetDoubleValue(dMaxValueSiC);
  2239. listGridRows.push_back(pGridRowSiC);
  2240. }
  2241. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  2242. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2243. auto itrFeO = mapSameSTDItemPartList.find((int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO);
  2244. listPartReport.clear();
  2245. if (itrFeO != mapSameSTDItemPartList.end())
  2246. {
  2247. listPartReport = itrFeO->second;
  2248. }
  2249. for (auto pParticle : listPartReport)
  2250. {
  2251. double dValue = GetValueAsMethod(pParticle, a_nMethod, a_dPixelSize);
  2252. if (dValue > dMaxValueFeO)
  2253. {
  2254. dMaxValueFeO = dValue;
  2255. }
  2256. }
  2257. if (itrFeO != mapSameSTDItemPartList.end())
  2258. {
  2259. pGridRowFeO->SetDoubleValue(dMaxValueFeO);
  2260. listGridRows.push_back(pGridRowFeO);
  2261. }
  2262. }
  2263. break;
  2264. }
  2265. pColumn->SetGridRowsList(listGridRows);
  2266. listGridColumn.push_back(pColumn);
  2267. }
  2268. a_pGridData->SetGridColumnList(listGridColumn);
  2269. return TRUE;
  2270. }
  2271. // compute element component
  2272. CGridDatasList CReportProjFileMgr::CompElementComponent()
  2273. {
  2274. // use the dll resource
  2275. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2276. CGridDatasList listGridData;
  2277. listGridData.clear();
  2278. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  2279. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  2280. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  2281. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  2282. //int nIndex = 0;
  2283. for (auto strDataSourceName : listSelectedDataSource)
  2284. {
  2285. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  2286. // data source id
  2287. pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
  2288. pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
  2289. COTSParticleList listParticleAll;
  2290. listParticleAll.clear();
  2291. CPosXraysList listXrayOut;
  2292. listXrayOut.clear();
  2293. CPosXraysList listXray;
  2294. listXray.clear();
  2295. listXrayOut = GetAnalysisXrayList(strDataSourceName);
  2296. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::ALL)
  2297. {
  2298. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  2299. for (auto pXray : listXrayOut)
  2300. {
  2301. CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
  2302. listXray.push_back(pXrayNew);
  2303. }
  2304. }
  2305. else if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  2306. {
  2307. listParticleAll = m_CurrentPropParam->GetSelectParticle();
  2308. for (auto pParticle : listParticleAll)
  2309. {
  2310. int nIndex = pParticle->GetAnalysisId();
  2311. int nField = pParticle->GetFieldId();
  2312. auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
  2313. if (itr == listXrayOut.end())
  2314. {
  2315. continue;
  2316. }
  2317. else
  2318. {
  2319. CPosXrayPtr pXray = *itr;
  2320. CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
  2321. listXray.push_back(pXrayNew);
  2322. }
  2323. }
  2324. }
  2325. if (!GetElementComponentFromParticleList(listParticleAll, listXray, pGridData))
  2326. {
  2327. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  2328. return listGridData;
  2329. }
  2330. listGridData.push_back(pGridData);
  2331. }
  2332. return listGridData;
  2333. }
  2334. BOOL CReportProjFileMgr::GetElementComponentFromParticleList(COTSParticleList a_listParticleAll, CPosXraysList a_listXray, CGridDataPtr a_pGridData)
  2335. {
  2336. // use the dll resource
  2337. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2338. ASSERT(a_pGridData);
  2339. if (!a_pGridData)
  2340. {
  2341. LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: invalid grid data pointer."));
  2342. return FALSE;
  2343. }
  2344. // std
  2345. ASSERT(m_pReportProjFile);
  2346. if (!m_pReportProjFile)
  2347. {
  2348. LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: empty project file."));
  2349. return FALSE;
  2350. }
  2351. int nColumnNum = ((int)(REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MAX) - (int)(REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MIN) + 1);
  2352. std::vector<CString> listColumnName;
  2353. LoadColumnString(listColumnName, IDS_ELEMENT_COMPONENT_START, nColumnNum);
  2354. if ((int)listColumnName.size() != nColumnNum)
  2355. {
  2356. LogErrorTrace(__FILE__, __LINE__, _T("GetElementComponentFromParticleList: Can't get column name number."));
  2357. return FALSE;
  2358. }
  2359. COTSParticleList listParticleAnalysis;
  2360. listParticleAnalysis.clear();
  2361. for (auto pParticle : a_listParticleAll)
  2362. {
  2363. int nType = pParticle->GetType();
  2364. if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  2365. {
  2366. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  2367. listParticleAnalysis.push_back(pParticleNew);
  2368. }
  2369. }
  2370. CElementChemistriesList listElementResult = GetUndefinedElementList(listParticleAnalysis, a_listXray);
  2371. //Draw the grid
  2372. CGridColumnsList listGridColumn;
  2373. for (int i = 0; i < nColumnNum; i++)
  2374. {
  2375. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  2376. pColumn->SetName(listColumnName[i]);
  2377. CGridRowsList listGridRows;
  2378. listGridRows.clear();
  2379. switch (i)
  2380. {
  2381. case (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NAME:
  2382. { // std item name
  2383. listGridRows.clear();
  2384. for (auto pElement : listElementResult)
  2385. {
  2386. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2387. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2388. CString strElementName = pElement->GetName();
  2389. pGridRow->SetStringValue(strElementName);
  2390. listGridRows.push_back(pGridRow);
  2391. }
  2392. }
  2393. break;
  2394. case (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NUM:
  2395. { // std item name
  2396. listGridRows.clear();
  2397. for (auto pElement : listElementResult)
  2398. {
  2399. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2400. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2401. CString strElementNum = _T("");
  2402. double dPercent = pElement->GetPercentage();
  2403. strElementNum.Format(_T("%f"), dPercent);
  2404. strElementNum += "%";
  2405. pGridRow->SetStringValue(strElementNum);
  2406. listGridRows.push_back(pGridRow);
  2407. }
  2408. }
  2409. break;
  2410. }
  2411. pColumn->SetGridRowsList(listGridRows);
  2412. listGridColumn.push_back(pColumn);
  2413. }
  2414. a_pGridData->SetGridColumnList(listGridColumn);
  2415. return TRUE;
  2416. }
  2417. // compute particle size distribution
  2418. CGridDatasList CReportProjFileMgr::CompParticleSizeDistribution()
  2419. {
  2420. // use the dll resource
  2421. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2422. CGridDatasList listGridData;
  2423. listGridData.clear();
  2424. // depart compound source name
  2425. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  2426. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  2427. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  2428. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  2429. //int nIndex = 0;
  2430. for (auto strDataSourceName : listSelectedDataSource)
  2431. {
  2432. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  2433. // data source id
  2434. std::vector<CString> listDataSource;
  2435. listDataSource.clear();
  2436. listDataSource = m_CurrentPropParam->GetDataSourceList();
  2437. pGridData->SetDataSourceList(listDataSource);
  2438. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  2439. pGridData->SetDataSourceId(nDataSourceId);
  2440. COTSParticleList* pSelectidParts;
  2441. COTSParticleList listParticleAll;
  2442. COTSParticleList seleParticles;
  2443. // add filter select particle
  2444. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  2445. {
  2446. seleParticles = m_CurrentPropParam->GetSelectParticle();
  2447. pSelectidParts = &seleParticles;
  2448. }
  2449. else
  2450. {
  2451. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  2452. pSelectidParts = &listParticleAll;
  2453. }
  2454. //get pixel size
  2455. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
  2456. ASSERT(pSmplMsrResultFileMgr);
  2457. if (!pSmplMsrResultFileMgr)
  2458. {
  2459. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample result file manager."));
  2460. return listGridData;
  2461. }
  2462. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  2463. ASSERT(pSmplMsrResultFile);
  2464. if (!pSmplMsrResultFile)
  2465. {
  2466. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample result file."));
  2467. return listGridData;
  2468. }
  2469. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  2470. if (!pSample)
  2471. {
  2472. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get sample."));
  2473. return listGridData;
  2474. }
  2475. double dPixelSize = pSample->CalculatePixelSize();
  2476. if (!GetSizeDistributionFromParticleList(*pSelectidParts, pGridData, dPixelSize))
  2477. {
  2478. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleSizeDistribution: can't get general information."));
  2479. return listGridData;
  2480. }
  2481. listGridData.push_back(pGridData);
  2482. }
  2483. return listGridData;
  2484. }
  2485. BOOL CReportProjFileMgr::IsHaveMultiDataSource()
  2486. {
  2487. int nMultiCount = 0;
  2488. for (auto SmplMgr : m_listSmplMgrs)
  2489. {
  2490. CSmplMsrResultFilePtr pSmpl = SmplMgr->GetSmplMsrResultFile();
  2491. if (pSmpl->GetSwitch())
  2492. {
  2493. nMultiCount++;
  2494. }
  2495. }
  2496. if (nMultiCount > 1)
  2497. {
  2498. return TRUE;
  2499. }
  2500. return FALSE;
  2501. }
  2502. BOOL CReportProjFileMgr::GetSizeDistributionFromParticleList(COTSParticleList a_listParticle, CGridDataPtr a_pGridData, double a_dPixelSize)
  2503. {
  2504. // use the dll resource
  2505. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2506. ASSERT(a_pGridData);
  2507. if (!a_pGridData)
  2508. {
  2509. LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid grid data pointer."));
  2510. return FALSE;
  2511. }
  2512. //size
  2513. CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
  2514. ASSERT(pPartSize);
  2515. if (!pPartSize)
  2516. {
  2517. LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid pPartSize data."));
  2518. return FALSE;
  2519. }
  2520. CPartSizeItemList listPartSize = pPartSize->GetPartSizeList();
  2521. if (listPartSize.empty())
  2522. {
  2523. LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: empty pPartSize Item."));
  2524. return FALSE;
  2525. }
  2526. //get the same type particle together
  2527. map<int, COTSParticleList> mapSameSTDItemPartList;
  2528. map<int, COTSParticleList>::iterator partListIter;
  2529. this->GetSTDMapedParticleList(a_listParticle, &mapSameSTDItemPartList);
  2530. COTSParticleList listNotIdentified;
  2531. for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
  2532. {
  2533. if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  2534. {
  2535. listNotIdentified = partListIter->second;
  2536. }
  2537. }
  2538. COTSParticleList listSiC;
  2539. for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
  2540. {
  2541. if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  2542. {
  2543. listSiC = partListIter->second;
  2544. }
  2545. }
  2546. COTSParticleList listFeO;
  2547. for (auto partListIter = mapSameSTDItemPartList.begin(); partListIter != mapSameSTDItemPartList.end(); partListIter++)
  2548. {
  2549. if (partListIter->first == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
  2550. {
  2551. listFeO = partListIter->second;
  2552. }
  2553. }
  2554. int nColumnNum = ((int)(REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MAX) - (int)(REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MIN) + 1);
  2555. std::vector<CString> listColumnName;
  2556. LoadColumnString(listColumnName, IDS_PARTICLE_COMPONENT_START, nColumnNum);
  2557. if ((int)listColumnName.size() != nColumnNum)
  2558. {
  2559. LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: Can't get column name number."));
  2560. return FALSE;
  2561. }
  2562. CGridColumnsList listGridColumn;
  2563. for (int i = 0; i < nColumnNum; i++)
  2564. {
  2565. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  2566. pColumn->SetName(listColumnName[i]);
  2567. CGridRowsList listGridRows;
  2568. listGridRows.clear();
  2569. switch (i)
  2570. {
  2571. case (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::NAME:
  2572. {
  2573. // std item name
  2574. listGridRows.clear();
  2575. for (auto sItemName : mapSameSTDItemPartList)
  2576. {
  2577. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2578. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2579. pGridRow->SetStringValue(sItemName.second[0]->TypeName().c_str());
  2580. listGridRows.push_back(pGridRow);
  2581. }
  2582. if (!listNotIdentified.empty())
  2583. {
  2584. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  2585. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2586. CString strUndefined;
  2587. strUndefined = MultiLang::GetInstance().GetCStringByKey(IDS_UNDEFINED_PARTICLE);//“未识别颗粒”
  2588. pGridRowUndefined->SetStringValue(strUndefined);
  2589. listGridRows.push_back(pGridRowUndefined);
  2590. }
  2591. if (!listSiC.empty())
  2592. {
  2593. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  2594. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2595. CString strSIC;
  2596. strSIC = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);//“未识别颗粒SiC”
  2597. pGridRowSiC->SetStringValue(strSIC);
  2598. listGridRows.push_back(pGridRowSiC);
  2599. }
  2600. if (!listFeO.empty())
  2601. {
  2602. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  2603. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2604. CString strFeO;
  2605. strFeO = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);//“未识别颗粒”
  2606. pGridRowFeO->SetStringValue(strFeO);
  2607. listGridRows.push_back(pGridRowFeO);
  2608. }
  2609. //个数
  2610. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  2611. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2612. CString strNum;
  2613. strNum = MultiLang::GetInstance().GetCStringByKey(IDS_NUM);
  2614. pGridRowNum->SetStringValue(strNum);
  2615. listGridRows.push_back(pGridRowNum);
  2616. break;
  2617. }
  2618. case (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::COLOUR:
  2619. {
  2620. // std item colour
  2621. listGridRows.clear();
  2622. for (auto parts : mapSameSTDItemPartList)
  2623. {
  2624. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2625. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2626. pGridRow->SetStringValue(parts.second[0]->TypeColor().c_str());
  2627. listGridRows.push_back(pGridRow);
  2628. }
  2629. if (!listNotIdentified.empty())
  2630. {
  2631. CGridRowPtr pGridRowUndefined = CGridRowPtr(new CGridRow());
  2632. pGridRowUndefined->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2633. CString strUndefinedColour = _T("");
  2634. pGridRowUndefined->SetStringValue(strUndefinedColour);
  2635. listGridRows.push_back(pGridRowUndefined);
  2636. }
  2637. if (!listSiC.empty())
  2638. {
  2639. CGridRowPtr pGridRowSiC = CGridRowPtr(new CGridRow());
  2640. pGridRowSiC->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2641. CString strSiCColour = _T("");
  2642. pGridRowSiC->SetStringValue(strSiCColour);
  2643. listGridRows.push_back(pGridRowSiC);
  2644. }
  2645. if (!listFeO.empty())
  2646. {
  2647. CGridRowPtr pGridRowFeO = CGridRowPtr(new CGridRow());
  2648. pGridRowFeO->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2649. CString strFeOColour = _T("");
  2650. pGridRowFeO->SetStringValue(strFeOColour);
  2651. listGridRows.push_back(pGridRowFeO);
  2652. }
  2653. //颜色行补齐行
  2654. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  2655. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2656. CString strColorNumber = _T("");
  2657. pGridRowNum->SetStringValue(strColorNumber);
  2658. listGridRows.push_back(pGridRowNum);
  2659. break;
  2660. }
  2661. }
  2662. pColumn->SetGridRowsList(listGridRows);
  2663. listGridColumn.push_back(pColumn);
  2664. }
  2665. //ParticleAmount
  2666. double dParticleAmount = 0;
  2667. for (unsigned int i = 0; i < a_listParticle.size(); i++)
  2668. {
  2669. if (a_listParticle[i]->GetAnalysisId() > -1)
  2670. dParticleAmount++;
  2671. }
  2672. //add item
  2673. for (auto partsizeItem : listPartSize)
  2674. {
  2675. CDoubleRangePtr level = partsizeItem->GetSizeLevel();
  2676. double dStart = level->GetStart();
  2677. double dEnd = level->GetEnd();
  2678. CString ColumnName = _T("");
  2679. //ColumnName = dStart + "-" + dEnd;
  2680. ColumnName = partsizeItem->GetName();
  2681. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  2682. pColumn->SetName(ColumnName);
  2683. double dColumnAmount = 0;
  2684. CGridRowsList listGridRows;
  2685. listGridRows.clear();
  2686. int nTypeId;
  2687. double dParticleUndefined = (double)listNotIdentified.size();
  2688. double dParticleSiC = (double)listNotIdentified.size();
  2689. double dParticleFeO = (double)listNotIdentified.size();
  2690. for (auto pSTDPart : mapSameSTDItemPartList)
  2691. {
  2692. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2693. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2694. bool bAdd = true;
  2695. double dParticleNum = 0;
  2696. for (auto pParticle : pSTDPart.second)
  2697. {
  2698. SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
  2699. double dValue = GetValueAsMethod(pParticle, Method, a_dPixelSize);
  2700. if (dValue >= dStart && dValue < dEnd)
  2701. {
  2702. dParticleNum++;
  2703. }
  2704. }
  2705. pGridRow->SetIntValue((int)dParticleNum);
  2706. listGridRows.push_back(pGridRow);
  2707. dColumnAmount += dParticleNum;
  2708. }
  2709. if (!listNotIdentified.empty())
  2710. {
  2711. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2712. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2713. double dParticleNumCount = 0;
  2714. for (auto undefinedPart : listNotIdentified)
  2715. {
  2716. SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
  2717. double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
  2718. if (dValue >= dStart && dValue < dEnd)
  2719. {
  2720. dParticleNumCount++;
  2721. }
  2722. }
  2723. pGridRow->SetIntValue((int)dParticleNumCount);
  2724. listGridRows.push_back(pGridRow);
  2725. dColumnAmount += dParticleNumCount;
  2726. }
  2727. //percent
  2728. if (!listSiC.empty())
  2729. {
  2730. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2731. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2732. int dParticleNumCount = 0;
  2733. for (auto undefinedPart : listSiC)
  2734. {
  2735. SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
  2736. double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
  2737. if (dValue >= dStart && dValue < dEnd)
  2738. {
  2739. dParticleNumCount++;
  2740. }
  2741. }
  2742. pGridRow->SetIntValue((int)dParticleNumCount);
  2743. listGridRows.push_back(pGridRow);
  2744. dColumnAmount += dParticleNumCount;
  2745. }
  2746. //percent
  2747. if (!listFeO.empty())
  2748. {
  2749. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  2750. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  2751. int dParticleNumCount = 0;
  2752. for (auto undefinedPart : listFeO)
  2753. {
  2754. SIZE_CAL_METHOD_TYPE Method = m_CurrentPropParam->GetSizeCalMethodType();
  2755. double dValue = GetValueAsMethod(undefinedPart, Method, a_dPixelSize);
  2756. if (dValue >= dStart && dValue < dEnd)
  2757. {
  2758. dParticleNumCount++;
  2759. }
  2760. }
  2761. pGridRow->SetIntValue((int)dParticleNumCount);
  2762. listGridRows.push_back(pGridRow);
  2763. dColumnAmount += dParticleNumCount;
  2764. }
  2765. CGridRowPtr pGridRow2 = CGridRowPtr(new CGridRow());
  2766. pGridRow2->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2767. double dAPercent = dColumnAmount / dParticleAmount;
  2768. char cColumnAmount[256];
  2769. sprintf(cColumnAmount, "%.0lf", dColumnAmount);
  2770. char cRes[256];
  2771. sprintf(cRes, "%.2lf%%\n", dAPercent * 100);
  2772. CString strResult = cRes;
  2773. strResult = "" + (CString)cColumnAmount + "(" + strResult + ")";
  2774. pGridRow2->SetStringValue(strResult);
  2775. listGridRows.push_back(pGridRow2);
  2776. //addcolum
  2777. pColumn->SetGridRowsList(listGridRows);
  2778. listGridColumn.push_back(pColumn);
  2779. }
  2780. a_pGridData->SetGridColumnList(listGridColumn);
  2781. return TRUE;
  2782. }
  2783. // compute average element component
  2784. CGridDatasList CReportProjFileMgr::CompAveElemnetComponent()
  2785. {
  2786. // use the dll resource
  2787. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2788. CGridDatasList listGridData;
  2789. listGridData.clear();
  2790. // depart compound source name
  2791. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  2792. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  2793. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  2794. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  2795. //int nIndex = 0;
  2796. for (auto strDataSourceName : listSelectedDataSource)
  2797. {
  2798. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  2799. // data source id
  2800. std::vector<CString> listDataSource;
  2801. listDataSource.clear();
  2802. listDataSource = m_CurrentPropParam->GetDataSourceList();
  2803. pGridData->SetDataSourceList(listDataSource);
  2804. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  2805. pGridData->SetDataSourceId(nDataSourceId);
  2806. COTSParticleList listParticleAll;
  2807. listParticleAll.clear();
  2808. CPosXraysList listXrayOut;
  2809. listXrayOut.clear();
  2810. CPosXraysList listXray;
  2811. listXray.clear();
  2812. listXrayOut = GetAnalysisXrayList(strDataSourceName);
  2813. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::ALL)
  2814. {
  2815. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  2816. for (auto pXray : listXrayOut)
  2817. {
  2818. CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
  2819. listXray.push_back(pXrayNew);
  2820. }
  2821. }
  2822. else if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  2823. {
  2824. listParticleAll = m_CurrentPropParam->GetSelectParticle();
  2825. for (auto pParticle : listParticleAll)
  2826. {
  2827. int nIndex = pParticle->GetAnalysisId();
  2828. int nField = pParticle->GetFieldId();
  2829. auto itr = std::find_if(listXrayOut.begin(), listXrayOut.end(), [nIndex, nField](CPosXrayPtr p) { return (p->GetIndex() == nIndex && p->GetScanFieldId() == nField); });
  2830. if (itr == listXrayOut.end())
  2831. {
  2832. continue;
  2833. }
  2834. else
  2835. {
  2836. CPosXrayPtr pXray = *itr;
  2837. CPosXrayPtr pXrayNew = CPosXrayPtr(new CPosXray(*pXray.get()));
  2838. listXray.push_back(pXrayNew);
  2839. }
  2840. }
  2841. }
  2842. if (!GetAveElementFromParticleList(listParticleAll, listXray, pGridData))
  2843. {
  2844. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  2845. return listGridData;
  2846. }
  2847. listGridData.push_back(pGridData);
  2848. //nIndex++;
  2849. }
  2850. return listGridData;
  2851. }
  2852. BOOL CReportProjFileMgr::GetAveElementFromParticleList(COTSParticleList a_listParticleAll, CPosXraysList a_listXray, CGridDataPtr a_pGridData)
  2853. {
  2854. // use the dll resource
  2855. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2856. ASSERT(a_pGridData);
  2857. if (!a_pGridData)
  2858. {
  2859. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: invalid grid data pointer."));
  2860. return FALSE;
  2861. }
  2862. // std
  2863. ASSERT(m_pReportProjFile);
  2864. if (!m_pReportProjFile)
  2865. {
  2866. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: empty project file."));
  2867. return FALSE;
  2868. }
  2869. std::set<int> allTypeIds;
  2870. allTypeIds.clear();
  2871. COTSParticleList listNotIdentifiedParticle;
  2872. listNotIdentifiedParticle.clear();
  2873. COTSParticleList listSiCParticle;
  2874. listSiCParticle.clear();
  2875. COTSParticleList listFeOParticle;
  2876. listFeOParticle.clear();
  2877. COTSParticleList listIdentifiedParticle;
  2878. listIdentifiedParticle.clear();
  2879. std::vector<CElementChemistriesList> listElementChemistriesList;
  2880. listElementChemistriesList.clear();
  2881. for (auto pParticle : a_listParticleAll)
  2882. {
  2883. int nType = (int)pParticle->GetType();
  2884. // get undefined particle and analysis particle
  2885. if (nType >= (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)
  2886. {
  2887. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  2888. if (nType == (int)OTS_PARTCLE_TYPE::NO_ANALYSIS_X_RAY)//不与考虑
  2889. {
  2890. //listNoAnalysisParticle.push_back(pParticleNew);
  2891. }
  2892. else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  2893. {
  2894. listNotIdentifiedParticle.push_back(pParticleNew);
  2895. }
  2896. else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC)
  2897. {
  2898. listSiCParticle.push_back(pParticleNew);
  2899. }
  2900. else if (nType == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO)
  2901. {
  2902. listFeOParticle.push_back(pParticleNew);
  2903. }
  2904. else if (nType >= (int)OTS_PARTCLE_TYPE::USER_DEFINED_MIN)//类型ID号至少1000以上
  2905. {
  2906. listIdentifiedParticle.push_back(pParticleNew);
  2907. allTypeIds.insert(nType);
  2908. }
  2909. }
  2910. }
  2911. //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  2912. //ASSERT(pPartSTDData);
  2913. //if (!pPartSTDData)
  2914. //{
  2915. // LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: invalid STD data."));
  2916. // return FALSE;
  2917. //}
  2918. //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
  2919. //if (listSTDItem.empty())
  2920. //{
  2921. // LogErrorTrace(__FILE__, __LINE__, _T("GetSizeDistributionFromParticleList: empty STD Item."));
  2922. // return FALSE;
  2923. //}
  2924. COTSParticleList listPartReport;
  2925. //get the same type particle together
  2926. map<int, COTSParticleList> mapSameSTDItemPartList;
  2927. map<int, COTSParticleList>::iterator partListIter;
  2928. this->GetSTDMapedParticleList(a_listParticleAll, &mapSameSTDItemPartList);
  2929. // make the first two columns: particle type and area
  2930. CGridColumnsList listGridColumn;
  2931. CGridRowsList listParticleGridRows;
  2932. listParticleGridRows.clear();
  2933. CGridRowsList listAreaGridRows;
  2934. listAreaGridRows.clear();
  2935. COTSParticleList listParticleType;
  2936. COTSParticleList particlesOfThisType;
  2937. listParticleType.clear();
  2938. particlesOfThisType.clear();
  2939. double dAreaTotal = 0;
  2940. for (auto typeId : allTypeIds)
  2941. {
  2942. auto iterParts = mapSameSTDItemPartList.find(typeId);
  2943. if (iterParts == mapSameSTDItemPartList.end())
  2944. {
  2945. continue;
  2946. }
  2947. else
  2948. {
  2949. particlesOfThisType = iterParts->second;
  2950. }
  2951. CGridRowPtr pParticleGridRow = CGridRowPtr(new CGridRow());
  2952. pParticleGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  2953. //CSTDItemPtr STDItem = GetParticleSTDItem(typeId);
  2954. //CSTDItemPtr STDItem = particlesOfThisType[0]->TypeName();
  2955. CString strPartName = particlesOfThisType[0]->TypeName().c_str();
  2956. pParticleGridRow->SetStringValue(strPartName);
  2957. listParticleGridRows.push_back(pParticleGridRow);
  2958. CGridRowPtr pAreaGridRow = CGridRowPtr(new CGridRow());
  2959. pAreaGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  2960. double dArea = 0;
  2961. for (auto pPatTp : particlesOfThisType)
  2962. {
  2963. double dAreaC = pPatTp->GetArea();
  2964. dArea += dAreaC;
  2965. }
  2966. pAreaGridRow->SetDoubleValue(dArea);
  2967. listAreaGridRows.push_back(pAreaGridRow);
  2968. dAreaTotal += dArea;
  2969. // compute Element
  2970. COTSParticlePtr pParticle = particlesOfThisType[0];
  2971. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  2972. listParticleType.push_back(pParticleNew);
  2973. int XrayId = pParticle->GetAnalysisId();
  2974. if (XrayId < 0 || XrayId >(int)a_listXray.size())
  2975. {
  2976. continue;
  2977. }
  2978. int nFieldId = pParticle->GetFieldId();
  2979. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
  2980. if (itr == a_listXray.end())
  2981. {
  2982. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't find x-ray."));
  2983. return FALSE;
  2984. }
  2985. CPosXrayPtr pXray = *itr;
  2986. CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
  2987. listElementChemistriesList.push_back(listTpElement);
  2988. }
  2989. //undefined particle area
  2990. double dAreaNotIden = 0;
  2991. for (auto pPUn : listNotIdentifiedParticle)
  2992. {
  2993. double dA = pPUn->GetArea();
  2994. dAreaNotIden += dA;
  2995. }
  2996. dAreaTotal += dAreaNotIden;
  2997. double dAreaSiC = 0;
  2998. for (auto pPUn : listSiCParticle)
  2999. {
  3000. double dA = pPUn->GetArea();
  3001. dAreaSiC += dA;
  3002. }
  3003. dAreaTotal += dAreaSiC;
  3004. double dAreaFeO = 0;
  3005. for (auto pPUn : listFeOParticle)
  3006. {
  3007. double dA = pPUn->GetArea();
  3008. dAreaFeO += dA;
  3009. }
  3010. dAreaTotal += dAreaFeO;
  3011. // area row of undefined and total analysis
  3012. if (!listNotIdentifiedParticle.empty())
  3013. {
  3014. CGridRowPtr pAreaGridRow = CGridRowPtr(new CGridRow());
  3015. pAreaGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3016. pAreaGridRow->SetDoubleValue(dAreaNotIden);
  3017. listAreaGridRows.push_back(pAreaGridRow);
  3018. }
  3019. if (!listSiCParticle.empty())
  3020. {
  3021. CGridRowPtr pAreaSiCGridRow = CGridRowPtr(new CGridRow());
  3022. pAreaSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3023. pAreaSiCGridRow->SetDoubleValue(dAreaSiC);
  3024. listAreaGridRows.push_back(pAreaSiCGridRow);
  3025. }
  3026. if (!listFeOParticle.empty())
  3027. {
  3028. CGridRowPtr pAreaFeOGridRow = CGridRowPtr(new CGridRow());
  3029. pAreaFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3030. pAreaFeOGridRow->SetDoubleValue(dAreaFeO);
  3031. listAreaGridRows.push_back(pAreaFeOGridRow);
  3032. }
  3033. CGridRowPtr pAreaToTalGridRow = CGridRowPtr(new CGridRow());
  3034. pAreaToTalGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3035. pAreaToTalGridRow->SetDoubleValue(dAreaTotal);
  3036. listAreaGridRows.push_back(pAreaToTalGridRow);
  3037. // particle type of undefined and analysis particle
  3038. if (!listNotIdentifiedParticle.empty())
  3039. {
  3040. CGridRowPtr pParticleGridRow = CGridRowPtr(new CGridRow());
  3041. pParticleGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  3042. CString strUndefineName = _T("");
  3043. strUndefineName = MultiLang::GetInstance().GetCStringByKey(IDS_PARTICL_UNDEFINED);
  3044. pParticleGridRow->SetStringValue(strUndefineName);
  3045. listParticleGridRows.push_back(pParticleGridRow);
  3046. }
  3047. if (!listSiCParticle.empty())
  3048. {
  3049. CGridRowPtr pParticleSiCGridRow = CGridRowPtr(new CGridRow());
  3050. pParticleSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  3051. CString strSiCName = _T("");
  3052. strSiCName = MultiLang::GetInstance().GetCStringByKey(IDS_SIC);
  3053. pParticleSiCGridRow->SetStringValue(strSiCName);
  3054. listParticleGridRows.push_back(pParticleSiCGridRow);
  3055. }
  3056. if (!listFeOParticle.empty())
  3057. {
  3058. CGridRowPtr pParticleFeOGridRow = CGridRowPtr(new CGridRow());
  3059. pParticleFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  3060. CString strFeOName = _T("");
  3061. strFeOName = MultiLang::GetInstance().GetCStringByKey(IDS_FEO);
  3062. pParticleFeOGridRow->SetStringValue(strFeOName);
  3063. listParticleGridRows.push_back(pParticleFeOGridRow);
  3064. }
  3065. CGridRowPtr pParticleAGridRow = CGridRowPtr(new CGridRow());
  3066. pParticleAGridRow->SetDataType(REPORT_GRID_DATA_TYPE::STRING);
  3067. CString strAnalysisdName = _T("");
  3068. strAnalysisdName = MultiLang::GetInstance().GetCStringByKey(IDS_PARTICL_ANALYSIS);
  3069. pParticleAGridRow->SetStringValue(strAnalysisdName);
  3070. listParticleGridRows.push_back(pParticleAGridRow);
  3071. if (!((int)listParticleGridRows.size() == (int)listAreaGridRows.size()))
  3072. {
  3073. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: particle num and area num are different."));
  3074. return FALSE;
  3075. }
  3076. // column name of particle type and area
  3077. int nColumnNum = ((int)(REPORT_AVE_ELEMENT_GRID_CLUMN::MAX) - (int)(REPORT_AVE_ELEMENT_GRID_CLUMN::MIN) + 1);
  3078. std::vector<CString> listColumnName;
  3079. LoadColumnString(listColumnName, IDS_AVE_ELEMENT_START, nColumnNum);
  3080. // particle type
  3081. CGridColumnPtr pParticleColumn = CGridColumnPtr(new CGridColumn());
  3082. pParticleColumn->SetName(listColumnName[0]);
  3083. pParticleColumn->SetGridRowsList(listParticleGridRows);
  3084. // area
  3085. CGridColumnPtr pAreaColumn = CGridColumnPtr(new CGridColumn());
  3086. pAreaColumn->SetName(listColumnName[1]);
  3087. pAreaColumn->SetGridRowsList(listAreaGridRows);
  3088. listGridColumn.push_back(pParticleColumn);
  3089. listGridColumn.push_back(pAreaColumn);
  3090. // get element area list from particle list
  3091. CElementChemistriesList listUndefinedElement;
  3092. if (!listNotIdentifiedParticle.empty())
  3093. {
  3094. listUndefinedElement = GetUndefinedElementList(listNotIdentifiedParticle, a_listXray);
  3095. listElementChemistriesList.push_back(listUndefinedElement);
  3096. }
  3097. // get element area list from particle list
  3098. CElementChemistriesList listSiCElement;
  3099. if (!listSiCParticle.empty())
  3100. {
  3101. listSiCElement = GetUndefinedElementList(listSiCParticle, a_listXray);
  3102. listElementChemistriesList.push_back(listSiCElement);
  3103. }
  3104. CElementChemistriesList listFeOElement;
  3105. if (!listFeOParticle.empty())
  3106. {
  3107. listFeOElement = GetUndefinedElementList(listFeOParticle, a_listXray);
  3108. listElementChemistriesList.push_back(listFeOElement);
  3109. }
  3110. std::vector<CString> listElementName;
  3111. listElementName.clear();
  3112. for (auto listElement : listElementChemistriesList)
  3113. {
  3114. for (auto pElement : listElement)
  3115. {
  3116. CString strElementName = pElement->GetName();
  3117. if (strElementName.Compare("Fe") == 0)
  3118. {
  3119. continue;
  3120. }
  3121. auto itr = std::find(listElementName.begin(), listElementName.end(), strElementName);
  3122. if (itr == listElementName.end())
  3123. {
  3124. listElementName.push_back(strElementName);
  3125. }
  3126. }
  3127. }
  3128. for (auto strName : listElementName)
  3129. {
  3130. //2020-2-17修改,c元素不再包含显示在元素列表中,并将显示的其它元素重新进行归一化。
  3131. if (strName == "C")
  3132. continue;
  3133. // particle type
  3134. CGridColumnPtr pElementColumn = CGridColumnPtr(new CGridColumn());
  3135. pElementColumn->SetName(strName);
  3136. CGridRowsList listElementGridRows;
  3137. listElementGridRows.clear();
  3138. double dTotalArea = 0.0;
  3139. int nRowNum = 0;
  3140. // analysis particle
  3141. for (auto pParticle : listParticleType)
  3142. {
  3143. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3144. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3145. int XrayId = pParticle->GetAnalysisId();
  3146. if (XrayId < 0 || XrayId >(int)a_listXray.size())
  3147. {
  3148. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get x ray."));
  3149. return FALSE;
  3150. }
  3151. int nFieldId = pParticle->GetFieldId();
  3152. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [XrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == XrayId)); });
  3153. if (itr == a_listXray.end())
  3154. {
  3155. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't find x-ray."));
  3156. return FALSE;
  3157. }
  3158. CPosXrayPtr pXray = *itr;
  3159. CElementChemistriesList listTpElement = pXray->GetElementQuantifyData();
  3160. auto itrE = std::find_if(listTpElement.begin(), listTpElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  3161. if (itrE == listTpElement.end())
  3162. {
  3163. pGridRow->SetDoubleValue(0.0);
  3164. }
  3165. else
  3166. {
  3167. CElementChemistriesList listElementNoFe = CPosXray::RemoveFe(listTpElement);
  3168. auto itr = std::find_if(listElementNoFe.begin(), listElementNoFe.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  3169. if (itr == listElementNoFe.end())
  3170. {
  3171. pGridRow->SetDoubleValue(0.0);
  3172. }
  3173. else
  3174. {
  3175. CElementChemistryPtr pElement = *itr;
  3176. double dPercent = pElement->GetPercentage();
  3177. pGridRow->SetDoubleValue(dPercent);
  3178. if (nRowNum < 0 || nRowNum >(int) listAreaGridRows.size())
  3179. {
  3180. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get area."));
  3181. return FALSE;
  3182. }
  3183. dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
  3184. }
  3185. }
  3186. nRowNum++;
  3187. listElementGridRows.push_back(pGridRow);
  3188. }
  3189. // undefined particle
  3190. if (!listNotIdentifiedParticle.empty())
  3191. {
  3192. CGridRowPtr pUndefinedGridRow = CGridRowPtr(new CGridRow());
  3193. pUndefinedGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3194. // get element area list from particle list
  3195. auto itr = std::find_if(listUndefinedElement.begin(), listUndefinedElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  3196. if (itr == listUndefinedElement.end())
  3197. {
  3198. pUndefinedGridRow->SetDoubleValue(0.0);
  3199. }
  3200. else
  3201. {
  3202. CElementChemistryPtr pElement = *itr;
  3203. double dPercent = pElement->GetPercentage();
  3204. pUndefinedGridRow->SetDoubleValue(dPercent);
  3205. dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
  3206. }
  3207. nRowNum++;
  3208. listElementGridRows.push_back(pUndefinedGridRow);
  3209. }
  3210. if (!listSiCParticle.empty())
  3211. {
  3212. CGridRowPtr pSiCGridRow = CGridRowPtr(new CGridRow());
  3213. pSiCGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3214. // get element area list from particle list
  3215. auto itrSiC = std::find_if(listSiCElement.begin(), listSiCElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  3216. if (itrSiC == listSiCElement.end())
  3217. {
  3218. pSiCGridRow->SetDoubleValue(0.0);
  3219. }
  3220. else
  3221. {
  3222. CElementChemistryPtr pElement = *itrSiC;
  3223. double dPercent = pElement->GetPercentage();
  3224. pSiCGridRow->SetDoubleValue(dPercent);
  3225. dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
  3226. }
  3227. nRowNum++;
  3228. listElementGridRows.push_back(pSiCGridRow);
  3229. }
  3230. if (!listFeOParticle.empty())
  3231. {
  3232. CGridRowPtr pFeOGridRow = CGridRowPtr(new CGridRow());
  3233. pFeOGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3234. // get element area list from particle list
  3235. auto itrFeO = std::find_if(listFeOElement.begin(), listFeOElement.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  3236. if (itrFeO == listFeOElement.end())
  3237. {
  3238. pFeOGridRow->SetDoubleValue(0.0);
  3239. }
  3240. else
  3241. {
  3242. CElementChemistryPtr pElement = *itrFeO;
  3243. double dPercent = pElement->GetPercentage();
  3244. pFeOGridRow->SetDoubleValue(dPercent);
  3245. dTotalArea += listAreaGridRows[nRowNum]->GetDoubleValue() * dPercent;
  3246. }
  3247. nRowNum++;
  3248. listElementGridRows.push_back(pFeOGridRow);
  3249. }
  3250. int nAreaSize = (int)listAreaGridRows.size();
  3251. if (!((nRowNum + 1) == nAreaSize))
  3252. {
  3253. LogErrorTrace(__FILE__, __LINE__, _T("GetAveElementFromParticleList: can't get area."));
  3254. return FALSE;
  3255. }
  3256. dTotalArea = dTotalArea / listAreaGridRows[nAreaSize - 1]->GetDoubleValue();
  3257. // total particle
  3258. CGridRowPtr pTotalGridRow = CGridRowPtr(new CGridRow());
  3259. pTotalGridRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  3260. pTotalGridRow->SetDoubleValue(dTotalArea);
  3261. listElementGridRows.push_back(pTotalGridRow);
  3262. pElementColumn->SetGridRowsList(listElementGridRows);
  3263. listGridColumn.push_back(pElementColumn);
  3264. }
  3265. //2020-2-17 Modify and standardize
  3266. double d_allelement_subtotal = 0;
  3267. for (unsigned int i_row = 0; i_row < listGridColumn[0]->GetRowList().size(); i_row++)
  3268. {
  3269. //first,So let's take out all the sums
  3270. d_allelement_subtotal = 0;
  3271. for (unsigned int icolumn = 2; icolumn < listGridColumn.size(); icolumn++)
  3272. {
  3273. double ls_dd = listGridColumn[icolumn]->GetRowList()[i_row]->GetDoubleValue();
  3274. if (ls_dd < 0)
  3275. continue;
  3276. d_allelement_subtotal = d_allelement_subtotal + ls_dd;
  3277. }
  3278. //second,Then calculate the normalized values
  3279. for (unsigned int icolumn = 2; icolumn < listGridColumn.size(); icolumn++)
  3280. {
  3281. double ls_dd = listGridColumn[icolumn]->GetRowList()[i_row]->GetDoubleValue();
  3282. if (ls_dd < 0)
  3283. continue;
  3284. listGridColumn[icolumn]->GetRowList()[i_row]->SetDoubleValue(ls_dd / d_allelement_subtotal * 100);
  3285. }
  3286. }
  3287. a_pGridData->SetGridColumnList(listGridColumn);
  3288. return TRUE;
  3289. }
  3290. // compute sort image class
  3291. CGridDatasList CReportProjFileMgr::CompSortClass()
  3292. {
  3293. // use the dll resource
  3294. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3295. CGridDatasList listGridData;
  3296. listGridData.clear();
  3297. // depart compound source name
  3298. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  3299. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  3300. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  3301. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  3302. //int nIndex = 0;
  3303. for (auto strDataSourceName : listSelectedDataSource)
  3304. {
  3305. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  3306. // data source id
  3307. std::vector<CString> listDataSource;
  3308. listDataSource.clear();
  3309. listDataSource = m_CurrentPropParam->GetDataSourceList();
  3310. pGridData->SetDataSourceList(listDataSource);
  3311. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  3312. pGridData->SetDataSourceId(nDataSourceId);
  3313. COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
  3314. if (!GetSortClassFromParticleList(listParticleAll, pGridData))
  3315. {
  3316. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  3317. return listGridData;
  3318. }
  3319. listGridData.push_back(pGridData);
  3320. }
  3321. return listGridData;
  3322. }
  3323. // get sort class from particle list
  3324. BOOL CReportProjFileMgr::GetSortClassFromParticleList(COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
  3325. {
  3326. ASSERT(a_pGridData);
  3327. if (!a_pGridData)
  3328. {
  3329. LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: invalid grid data pointer."));
  3330. return FALSE;
  3331. }
  3332. // std
  3333. ASSERT(m_pReportProjFile);
  3334. if (!m_pReportProjFile)
  3335. {
  3336. LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: empty project file."));
  3337. return FALSE;
  3338. }
  3339. int nColumnNum = ((int)(REPORT_SORT_CLASS_GRID_CLUMN::MAX) - (int)(REPORT_SORT_CLASS_GRID_CLUMN::MIN) + 1);
  3340. std::vector<CString> listColumnName;
  3341. LoadColumnString(listColumnName, IDS_SORT_CLASS_START, nColumnNum);
  3342. if ((int)listColumnName.size() != nColumnNum)
  3343. {
  3344. LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: Can't get column name number."));
  3345. return FALSE;
  3346. }
  3347. CGridColumnsList listGridColumn;
  3348. for (int i = 0; i < nColumnNum; i++)
  3349. {
  3350. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  3351. pColumn->SetName(listColumnName[i]);
  3352. CGridRowsList listGridRows;
  3353. listGridRows.clear();
  3354. switch (i)
  3355. {
  3356. case (int)REPORT_SORT_CLASS_GRID_CLUMN::TOO_SMALL:
  3357. {
  3358. listGridRows.clear();
  3359. int nTypeId = (int)OTS_PARTCLE_TYPE::SMALL;
  3360. for (auto pParticle : a_listParticleAll)
  3361. {
  3362. int nType = pParticle->GetType();
  3363. if (nType == nTypeId)
  3364. {
  3365. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3366. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3367. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3368. pGridRow->SetParticle(pParticleNew);
  3369. listGridRows.push_back(pGridRow);
  3370. }
  3371. }
  3372. }
  3373. break;
  3374. case (int)REPORT_SORT_CLASS_GRID_CLUMN::OVER_SIZE:
  3375. {
  3376. listGridRows.clear();
  3377. int nTypeId = (int)OTS_PARTCLE_TYPE::OVERSIZE;
  3378. for (auto pParticle : a_listParticleAll)
  3379. {
  3380. int nType = pParticle->GetType();
  3381. if (nType == nTypeId)
  3382. {
  3383. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3384. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3385. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3386. pGridRow->SetParticle(pParticleNew);
  3387. listGridRows.push_back(pGridRow);
  3388. }
  3389. }
  3390. }
  3391. break;
  3392. case (int)REPORT_SORT_CLASS_GRID_CLUMN::GRAY_NO_INTERS:
  3393. {
  3394. listGridRows.clear();
  3395. int nTypeId = (int)OTS_PARTCLE_TYPE::AVE_GRAY_NOT_INRANRE;
  3396. for (auto pParticle : a_listParticleAll)
  3397. {
  3398. int nType = pParticle->GetType();
  3399. if (nType == nTypeId)
  3400. {
  3401. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3402. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3403. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3404. pGridRow->SetParticle(pParticleNew);
  3405. listGridRows.push_back(pGridRow);
  3406. }
  3407. }
  3408. }
  3409. break;
  3410. case (int)REPORT_SORT_CLASS_GRID_CLUMN::LOW_COUNT:
  3411. {
  3412. listGridRows.clear();
  3413. int nTypeId = (int)OTS_PARTCLE_TYPE::LOW_COUNT;
  3414. for (auto pParticle : a_listParticleAll)
  3415. {
  3416. int nType = pParticle->GetType();
  3417. if (nType == nTypeId)
  3418. {
  3419. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3420. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3421. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3422. pGridRow->SetParticle(pParticleNew);
  3423. listGridRows.push_back(pGridRow);
  3424. }
  3425. }
  3426. }
  3427. break;
  3428. case (int)REPORT_SORT_CLASS_GRID_CLUMN::NO_INTEREST_ELEMENTS:
  3429. {
  3430. listGridRows.clear();
  3431. int nTypeId = (int)OTS_PARTCLE_TYPE::NO_INTEREST_ELEMENTS;
  3432. for (auto pParticle : a_listParticleAll)
  3433. {
  3434. int nType = pParticle->GetType();
  3435. if (nType == nTypeId)
  3436. {
  3437. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3438. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3439. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3440. pGridRow->SetParticle(pParticleNew);
  3441. listGridRows.push_back(pGridRow);
  3442. }
  3443. }
  3444. }
  3445. break;
  3446. case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_SIC:
  3447. {
  3448. listGridRows.clear();
  3449. int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_SIC;
  3450. for (auto pParticle : a_listParticleAll)
  3451. {
  3452. int nType = pParticle->GetType();
  3453. if (nType == nTypeId)
  3454. {
  3455. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3456. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3457. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3458. pGridRow->SetParticle(pParticleNew);
  3459. listGridRows.push_back(pGridRow);
  3460. }
  3461. }
  3462. }
  3463. break;
  3464. case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_INCLUSION_FEO:
  3465. {
  3466. listGridRows.clear();
  3467. int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED_FEO;
  3468. for (auto pParticle : a_listParticleAll)
  3469. {
  3470. int nType = pParticle->GetType();
  3471. if (nType == nTypeId)
  3472. {
  3473. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3474. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3475. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3476. pGridRow->SetParticle(pParticleNew);
  3477. listGridRows.push_back(pGridRow);
  3478. }
  3479. }
  3480. }
  3481. break;
  3482. case (int)REPORT_SORT_CLASS_GRID_CLUMN::NOT_IDENTIFIED:
  3483. {
  3484. listGridRows.clear();
  3485. int nTypeId = (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED;
  3486. for (auto pParticle : a_listParticleAll)
  3487. {
  3488. int nType = pParticle->GetType();
  3489. if (nType == nTypeId)
  3490. {
  3491. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3492. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3493. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3494. pGridRow->SetParticle(pParticleNew);
  3495. listGridRows.push_back(pGridRow);
  3496. }
  3497. }
  3498. }
  3499. break;
  3500. case (int)REPORT_SORT_CLASS_GRID_CLUMN::IDENTIFIED:
  3501. {
  3502. listGridRows.clear();
  3503. int nTypeId = (int)OTS_PARTCLE_TYPE::IDENTIFIED;
  3504. for (auto pParticle : a_listParticleAll)
  3505. {
  3506. int nType = pParticle->GetType();
  3507. if (nType >= nTypeId)
  3508. {
  3509. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3510. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3511. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3512. pGridRow->SetParticle(pParticleNew);
  3513. listGridRows.push_back(pGridRow);
  3514. }
  3515. }
  3516. }
  3517. break;
  3518. }
  3519. pColumn->SetGridRowsList(listGridRows);
  3520. listGridColumn.push_back(pColumn);
  3521. }
  3522. a_pGridData->SetGridColumnList(listGridColumn);
  3523. return TRUE;
  3524. }
  3525. // compute sort image kind
  3526. CGridDatasList CReportProjFileMgr::CompSortKind()
  3527. {
  3528. // use the dll resource
  3529. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3530. CGridDatasList listGridData;
  3531. listGridData.clear();
  3532. // depart compound source name
  3533. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  3534. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  3535. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  3536. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  3537. //int nIndex = 0;
  3538. for (auto strDataSourceName : listSelectedDataSource)
  3539. {
  3540. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  3541. // data source id
  3542. std::vector<CString> listDataSource;
  3543. listDataSource.clear();
  3544. listDataSource = m_CurrentPropParam->GetDataSourceList();
  3545. pGridData->SetDataSourceList(listDataSource);
  3546. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  3547. pGridData->SetDataSourceId(nDataSourceId);
  3548. COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
  3549. if (!GetSortKindFromParticleList(listParticleAll, pGridData))
  3550. {
  3551. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  3552. return listGridData;
  3553. }
  3554. listGridData.push_back(pGridData);
  3555. }
  3556. return listGridData;
  3557. }
  3558. // compute sort king from particle list
  3559. BOOL CReportProjFileMgr::GetSortKindFromParticleList(COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
  3560. {
  3561. // use the dll resource
  3562. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3563. ASSERT(a_pGridData);
  3564. if (!a_pGridData)
  3565. {
  3566. LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: invalid grid data pointer."));
  3567. return FALSE;
  3568. }
  3569. int nColumnNum = ((int)(REPORT_SORT_KIND_GRID_CLUMN::MAX) - (int)(REPORT_SORT_KIND_GRID_CLUMN::MIN) + 1);
  3570. std::vector<CString> listColumnName;
  3571. LoadColumnString(listColumnName, IDS_SORT_KIND_START, nColumnNum);
  3572. map<int, COTSParticleList> mapSameSTDItemPartList;
  3573. this->GetSTDMapedParticleList(a_listParticleAll, &mapSameSTDItemPartList);
  3574. CGridColumnsList listGridColumn;
  3575. nColumnNum = mapSameSTDItemPartList.size();
  3576. for (auto itr = mapSameSTDItemPartList.begin(); itr != mapSameSTDItemPartList.end(); itr++)
  3577. {
  3578. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  3579. std::string typeName = itr->second[0]->TypeName();
  3580. pColumn->SetName(typeName.c_str());
  3581. CGridRowsList listGridRows;
  3582. listGridRows.clear();
  3583. COTSParticleList thisTypeParts = itr->second;
  3584. for (auto pParticle : thisTypeParts)
  3585. {
  3586. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3587. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3588. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3589. pGridRow->SetParticle(pParticleNew);
  3590. listGridRows.push_back(pGridRow);
  3591. }
  3592. pColumn->SetGridRowsList(listGridRows);
  3593. listGridColumn.push_back(pColumn);
  3594. }
  3595. a_pGridData->SetGridColumnList(listGridColumn);
  3596. return TRUE;
  3597. }
  3598. // compute sort image size
  3599. CGridDatasList CReportProjFileMgr::CompSortSize()
  3600. {
  3601. // use the dll resource
  3602. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3603. CGridDatasList listGridData;
  3604. listGridData.clear();
  3605. // depart compound source name
  3606. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  3607. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  3608. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  3609. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  3610. //int nIndex = 0;
  3611. for (auto strDataSourceName : listSelectedDataSource)
  3612. {
  3613. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  3614. // data source id
  3615. std::vector<CString> listDataSource;
  3616. listDataSource.clear();
  3617. listDataSource = m_CurrentPropParam->GetDataSourceList();
  3618. pGridData->SetDataSourceList(listDataSource);
  3619. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  3620. pGridData->SetDataSourceId(nDataSourceId);
  3621. COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
  3622. //get pixel size
  3623. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
  3624. ASSERT(pSmplMsrResultFileMgr);
  3625. if (!pSmplMsrResultFileMgr)
  3626. {
  3627. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file manager."));
  3628. return listGridData;
  3629. }
  3630. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  3631. ASSERT(pSmplMsrResultFile);
  3632. if (!pSmplMsrResultFile)
  3633. {
  3634. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file."));
  3635. return listGridData;
  3636. }
  3637. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  3638. ASSERT(pSample);
  3639. if (!pSample)
  3640. {
  3641. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample."));
  3642. return listGridData;
  3643. }
  3644. double dPixelSize = pSample->CalculatePixelSize();
  3645. if (!GetSortSizeFromParticleList(listParticleAll, dPixelSize, pGridData))
  3646. {
  3647. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  3648. return listGridData;
  3649. }
  3650. listGridData.push_back(pGridData);
  3651. //nIndex++;
  3652. }
  3653. return listGridData;
  3654. }
  3655. // compute sort size from particle list
  3656. BOOL CReportProjFileMgr::GetSortSizeFromParticleList(COTSParticleList a_listParticleAll, double a_dPixelSize, CGridDataPtr a_pGridData)
  3657. {
  3658. // use the dll resource
  3659. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3660. ASSERT(a_pGridData);
  3661. if (!a_pGridData)
  3662. {
  3663. LogErrorTrace(__FILE__, __LINE__, _T("GetSortSizeFromParticleList: invalid grid data pointer."));
  3664. return FALSE;
  3665. }
  3666. // particle size file
  3667. CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
  3668. ASSERT(pPartSize);
  3669. if (!pPartSize)
  3670. {
  3671. LogErrorTrace(__FILE__, __LINE__, _T("GetSortSizeFromParticleList: invalid part size data."));
  3672. return FALSE;
  3673. }
  3674. int nColumnNum = ((int)(REPORT_SORT_SIZE_GRID_CLUMN::MAX) - (int)(REPORT_SORT_SIZE_GRID_CLUMN::MIN) + 1);
  3675. std::vector<CString> listColumnName;
  3676. LoadColumnString(listColumnName, IDS_SORT_SIZE_START, nColumnNum);
  3677. CPartSizeItemList& listSizes = pPartSize->GetPartSizeList();
  3678. for (auto pSize : listSizes)
  3679. {
  3680. CString strSizeName = pSize->GetName();
  3681. listColumnName.push_back(strSizeName);
  3682. nColumnNum++;
  3683. }
  3684. if ((int)listColumnName.size() != nColumnNum)
  3685. {
  3686. LogErrorTrace(__FILE__, __LINE__, _T("GetSortClassFromParticleList: Can't get column name number."));
  3687. return FALSE;
  3688. }
  3689. CGridColumnsList listGridColumn;
  3690. for (int i = 0; i < nColumnNum; i++)
  3691. {
  3692. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  3693. pColumn->SetName(listColumnName[i]);
  3694. CGridRowsList listGridRows;
  3695. listGridRows.clear();
  3696. double dSizeMax = 0.0;
  3697. double dSizeMin = 0.0;
  3698. if (i == 0)
  3699. {
  3700. dSizeMin = m_CurrentPropParam->GetGrainSizeMin();
  3701. dSizeMax = m_CurrentPropParam->GetGrainSizeMax();
  3702. }
  3703. else
  3704. {
  3705. dSizeMin = listSizes[i - 1]->GetSizeLevel()->GetStart();
  3706. dSizeMax = listSizes[i - 1]->GetSizeLevel()->GetEnd();
  3707. }
  3708. for (auto pParticle : a_listParticleAll)
  3709. {
  3710. double dValue = GetValueAsMethod(pParticle, m_CurrentPropParam->GetSizeCalMethodType(), a_dPixelSize);
  3711. if (dValue < dSizeMax && dValue > dSizeMin)
  3712. {
  3713. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3714. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3715. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3716. pGridRow->SetParticle(pParticleNew);
  3717. listGridRows.push_back(pGridRow);
  3718. }
  3719. }
  3720. pColumn->SetGridRowsList(listGridRows);
  3721. listGridColumn.push_back(pColumn);
  3722. }
  3723. //reverse funcation for size particle sort
  3724. reverse(listGridColumn.begin(), listGridColumn.end());
  3725. a_pGridData->SetGridColumnList(listGridColumn);
  3726. return TRUE;
  3727. }
  3728. // compute sort image size
  3729. CGridDatasList CReportProjFileMgr::CompDistribution()//CGridInPtr a_pGridIn
  3730. {
  3731. // use the dll resource
  3732. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3733. CGridDatasList listGridData;
  3734. listGridData.clear();
  3735. // depart compound source name
  3736. CPropParamPtr propParam = this->GetPropertyParamImage();
  3737. std::vector<CString> listDataSource = this->GetPropertyParamImage()->GetDataSourceList();
  3738. int nSelectedDataSourceIndex = propParam->GetDataSourceId();
  3739. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  3740. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  3741. int nIndex = 0;
  3742. for (auto strDataSourceName : listSelectedDataSource)
  3743. {
  3744. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  3745. // data source id
  3746. std::vector<CString> listDataSource;
  3747. listDataSource.clear();
  3748. listDataSource = propParam->GetDataSourceList();
  3749. pGridData->SetDataSourceList(listDataSource);
  3750. int nDataSourceId = propParam->GetDataSourceId();
  3751. pGridData->SetDataSourceId(nDataSourceId);
  3752. COTSParticleList listParticleAll = GetAnalysisParticleList(strDataSourceName);
  3753. //get pixel size
  3754. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(strDataSourceName);
  3755. ASSERT(pSmplMsrResultFileMgr);
  3756. if (!pSmplMsrResultFileMgr)
  3757. {
  3758. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file manager."));
  3759. return listGridData;
  3760. }
  3761. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  3762. ASSERT(pSmplMsrResultFile);
  3763. if (!pSmplMsrResultFile)
  3764. {
  3765. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample result file."));
  3766. return listGridData;
  3767. }
  3768. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  3769. ASSERT(pSample);
  3770. if (!pSample)
  3771. {
  3772. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get sample."));
  3773. return listGridData;
  3774. }
  3775. double dPixelSize = pSample->CalculatePixelSize();
  3776. if (!GetDistributionFromParticleList(propParam, dPixelSize, listParticleAll, pGridData))
  3777. {
  3778. LogErrorTrace(__FILE__, __LINE__, _T("CompDistribution: can't get particle list."));
  3779. return listGridData;
  3780. }
  3781. listGridData.push_back(pGridData);
  3782. nIndex++;
  3783. }
  3784. return listGridData;
  3785. }
  3786. BOOL CReportProjFileMgr::GetDistributionFromParticleList(CPropParamPtr propParam, double a_dPixelSize, COTSParticleList a_listParticleAll, CGridDataPtr a_pGridData)
  3787. {
  3788. // use the dll resource
  3789. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3790. ASSERT(a_pGridData);
  3791. if (!a_pGridData)
  3792. {
  3793. LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: invalid grid data pointer."));
  3794. return FALSE;
  3795. }
  3796. // std
  3797. ASSERT(m_pReportProjFile);
  3798. if (!m_pReportProjFile)
  3799. {
  3800. LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: empty project file."));
  3801. return FALSE;
  3802. }
  3803. // particle size file
  3804. CPartSizeFilePtr pPartSize = m_CurrentPropParam->GetWorkingSizeFile();
  3805. ASSERT(pPartSize);
  3806. if (!pPartSize)
  3807. {
  3808. LogErrorTrace(__FILE__, __LINE__, _T("GetDistributionFromParticleList: invalid part size data."));
  3809. return FALSE;
  3810. }
  3811. CPartSizeItemList& listSizes = pPartSize->GetPartSizeList();
  3812. std::vector<CString> listSizeClassTables;
  3813. LoadColumnString(listSizeClassTables, (UINT)IDS_SIZE_CLASS_DEFUALT_FIRST, (int)(SIZE_CLASS_DEFUALT::MAX) - (int)(SIZE_CLASS_DEFUALT::MIN) + 1);
  3814. if ((pPartSize.get() != nullptr))
  3815. {
  3816. CPartSizeItemList listSizeItem = pPartSize->GetPartSizeList();
  3817. for (auto pItem : listSizeItem)
  3818. {
  3819. CString strValue = pItem->GetName();
  3820. listSizeClassTables.push_back(strValue);
  3821. }
  3822. }
  3823. CGridColumnsList listGridColumn;
  3824. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  3825. pColumn->SetName(_T(""));
  3826. CGridRowsList listGridRows;
  3827. listGridRows.clear();
  3828. PARTICLE_TYPE nSelectType = propParam->GetPartType();
  3829. int nSTDId = propParam->GetSTDId();
  3830. int nSizeClassType;
  3831. double dSizeMax = 0;
  3832. double dSizeMin = 0;
  3833. dSizeMin = propParam->GetGrainSizeMin();
  3834. dSizeMax = propParam->GetGrainSizeMax();
  3835. //因GridIn参数中没有传递具体选择什么类型的粒级分类数据,因此用SizeLevel的两个限值来区分,都为0 时就认为是选择了全部,其他的就按选择具体的档级处理。
  3836. if (dSizeMax == 0 && dSizeMin == 0)//当DSizeMax==0 和 dSizeMin==0 时表明“粒级”栏选择的是 “全部”或“自定义”上下限填写的是0.
  3837. {
  3838. nSizeClassType = 0;//等于0表明选择“全部”也就是默认取全部粒级表的尺寸数据
  3839. }
  3840. else
  3841. {
  3842. nSizeClassType = 1;//等于1表明选择的是单个某个粒级的数据档 如“3~5”
  3843. }
  3844. for (auto pParticle : a_listParticleAll)
  3845. {
  3846. int nTypeParticle = pParticle->GetType();
  3847. double dValue = GetValueAsMethod(pParticle, propParam->GetSizeCalMethodType(), a_dPixelSize);
  3848. COTSParticlePtr pParticleNew = COTSParticlePtr(new COTSParticle(*pParticle.get()));
  3849. switch ((int)nSelectType)
  3850. {
  3851. case (int)PARTICLE_TYPE::ALL:
  3852. if (nSizeClassType == 0)
  3853. {
  3854. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3855. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3856. pGridRow->SetParticle(pParticleNew);
  3857. listGridRows.push_back(pGridRow);
  3858. }
  3859. else
  3860. {
  3861. if (dValue > dSizeMin && dValue < dSizeMax)
  3862. {
  3863. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3864. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3865. pGridRow->SetParticle(pParticleNew);
  3866. listGridRows.push_back(pGridRow);
  3867. }
  3868. }
  3869. break;
  3870. case (int)PARTICLE_TYPE::ANALYSISED:
  3871. if (nSizeClassType == 0)
  3872. {
  3873. if (nSTDId == 0) //全部颗粒
  3874. {
  3875. if (nSizeClassType == 0)
  3876. {
  3877. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3878. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3879. pGridRow->SetParticle(pParticleNew);
  3880. listGridRows.push_back(pGridRow);
  3881. }
  3882. else
  3883. {
  3884. if (dValue > dSizeMin && dValue < dSizeMax)
  3885. {
  3886. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3887. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3888. pGridRow->SetParticle(pParticleNew);
  3889. listGridRows.push_back(pGridRow);
  3890. }
  3891. }
  3892. }
  3893. else if (nSTDId == 1) // 未识别颗粒
  3894. {
  3895. if (nTypeParticle == (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  3896. {
  3897. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3898. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3899. pGridRow->SetParticle(pParticleNew);
  3900. listGridRows.push_back(pGridRow);
  3901. }
  3902. }
  3903. else
  3904. {
  3905. if (nTypeParticle == (nSTDId - 1))
  3906. {
  3907. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3908. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3909. pGridRow->SetParticle(pParticleNew);
  3910. listGridRows.push_back(pGridRow);
  3911. }
  3912. }
  3913. }
  3914. else
  3915. {
  3916. if (dValue > dSizeMin && dValue < dSizeMax)
  3917. {
  3918. CGridRowPtr pGridRow = CGridRowPtr(new CGridRow());
  3919. pGridRow->SetDataType(REPORT_GRID_DATA_TYPE::PARTICLE);
  3920. pGridRow->SetParticle(pParticleNew);
  3921. listGridRows.push_back(pGridRow);
  3922. }
  3923. }
  3924. break;
  3925. default:
  3926. break;
  3927. }
  3928. }
  3929. pColumn->SetGridRowsList(listGridRows);
  3930. listGridColumn.push_back(pColumn);
  3931. a_pGridData->SetGridColumnList(listGridColumn);
  3932. return TRUE;
  3933. }
  3934. // load column name string
  3935. void CReportProjFileMgr::LoadColumnString(std::vector<CString>& a_listStrings, UINT a_nFirstStringID, int a_nCount)
  3936. {
  3937. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  3938. for (int i = 0; i < a_nCount; ++i)
  3939. {
  3940. CString str;
  3941. str = MultiLang::GetInstance().GetCStringByKey(a_nFirstStringID + i);
  3942. a_listStrings.push_back(str);
  3943. }
  3944. }
  3945. // get undefined element list from particle list
  3946. CElementChemistriesList CReportProjFileMgr::GetUndefinedElementList(COTSParticleList a_listParticle, CPosXraysList a_listXray)
  3947. {
  3948. CElementChemistriesList listElementChemistry;
  3949. // safety check to get xray data and element number
  3950. int nXraySize = (int)a_listXray.size();
  3951. int nParticleSize = (int)a_listParticle.size();
  3952. if (nParticleSize > nXraySize)
  3953. {
  3954. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get xray number is not enough."));
  3955. return listElementChemistry;
  3956. }
  3957. CElementAreaList listElementArea;
  3958. // get element area
  3959. double dTotalArea = 0;
  3960. for (auto pParticle : a_listParticle)
  3961. {
  3962. int nXrayId = pParticle->GetAnalysisId();
  3963. if (nXrayId < 0 || nXrayId >(int) a_listXray.size())
  3964. {
  3965. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get wrong xray id."));
  3966. return listElementChemistry;
  3967. }
  3968. int nFieldId = pParticle->GetFieldId();
  3969. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [nXrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == nXrayId)); });
  3970. if (itr == a_listXray.end())
  3971. {
  3972. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: can't find x-ray."));
  3973. return listElementChemistry;
  3974. }
  3975. CPosXrayPtr pXray = *itr;
  3976. // remove Fe
  3977. CElementChemistriesList listElementChemistryCurrent = pXray->GetElementQuantifyData();
  3978. CElementChemistriesList listElementChemistryNew1 = CPosXray::RemoveFe(listElementChemistryCurrent);
  3979. CElementChemistriesList listElementChemistryNew = CPosXray::RemoveC(listElementChemistryNew1);
  3980. double t = 0;
  3981. CElementChemistriesList listElementChemistryG1;
  3982. for (auto pElementChemistry : listElementChemistryNew)
  3983. {
  3984. t += pElementChemistry->GetPercentage();
  3985. }
  3986. if (t == 0)
  3987. {
  3988. continue;
  3989. }
  3990. for (auto pElementChemistry : listElementChemistryNew)
  3991. {
  3992. double dPecent = 100.0 *pElementChemistry->GetPercentage() / t;
  3993. CElementChemistryPtr pElementNew = CElementChemistryPtr(new CElementChemistry(*pElementChemistry.get()));
  3994. pElementNew->SetPercentage(dPecent);
  3995. listElementChemistryG1.push_back(pElementNew);
  3996. }
  3997. CElementAreaPtr pElementArea = CElementAreaPtr(new CElementArea());
  3998. double dArea = pParticle->GetArea();
  3999. pElementArea->SetArea(dArea);
  4000. pElementArea->SetElementList(listElementChemistryG1);
  4001. listElementArea.push_back(pElementArea);
  4002. dTotalArea += dArea;
  4003. }
  4004. for (auto pElementArea : listElementArea)
  4005. {
  4006. CElementChemistriesList listElementChemistryCurrent = pElementArea->GetElementList();
  4007. for (auto pElement : listElementChemistryCurrent)
  4008. {
  4009. CString strName = pElement->GetName();
  4010. double dPercentNorm = 1.0;
  4011. auto itr = std::find_if(listElementChemistry.begin(), listElementChemistry.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  4012. if (itr == listElementChemistry.end())
  4013. {
  4014. double dArea = pElementArea->GetArea();
  4015. double dPercent = pElement->GetPercentage();
  4016. dPercentNorm = dArea * dPercent / dTotalArea;
  4017. }
  4018. else
  4019. {
  4020. CElementChemistryPtr pElementChemistry = *itr;
  4021. double dAreaOld = pElementChemistry->GetPercentage() * dTotalArea * 0.01;
  4022. double dArea = pElementArea->GetArea();
  4023. double dPercent = pElement->GetPercentage();
  4024. dPercentNorm = 100 * (0.01 * dArea * dPercent + dAreaOld) / dTotalArea;
  4025. listElementChemistry.erase(itr);
  4026. }
  4027. CElementChemistryPtr pElement = CElementChemistryPtr(new CElementChemistry());
  4028. pElement->SetName(strName);
  4029. pElement->SetPercentage(dPercentNorm);
  4030. listElementChemistry.push_back(pElement);
  4031. }
  4032. }
  4033. return listElementChemistry;
  4034. }
  4035. CGridDatasList CReportProjFileMgr::CompChartParticleComp()
  4036. {
  4037. // use the dll resource
  4038. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4039. CGridDatasList listGridData;
  4040. listGridData.clear();
  4041. // depart compound source name
  4042. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4043. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  4044. CGridDatasList pGridList = CompParticleComponent();
  4045. for (CGridDataPtr pGrid : pGridList)
  4046. {
  4047. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  4048. // data source id
  4049. std::vector<CString> listDataSource;
  4050. listDataSource.clear();
  4051. listDataSource = m_CurrentPropParam->GetDataSourceList();
  4052. pGridData->SetDataSourceList(listDataSource);
  4053. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  4054. pGridData->SetDataSourceId(nDataSourceId);
  4055. ASSERT(pGrid);
  4056. if (!pGrid)
  4057. {
  4058. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid grid in data pointer."));
  4059. return listGridData;
  4060. }
  4061. CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
  4062. // particle column
  4063. CGridColumnPtr pParticleCol = listGridColumn[(int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::NAME - (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN];
  4064. CGridRowsList listGridParticleRows = pParticleCol->GetRowList();
  4065. // particle num column
  4066. CGridColumnPtr pParticleNumCol = listGridColumn[(int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::PARTICLE_NUM - (int)REPORT_PARTICLE_COMPONENT_GRID_CLUMN::MIN];
  4067. CGridRowsList listGridParticleNumRows = pParticleNumCol->GetRowList();
  4068. if (!((int)listGridParticleRows.size() == (int)listGridParticleNumRows.size()))
  4069. {
  4070. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid name and num are different."));
  4071. return listGridData;
  4072. }
  4073. CGridColumnsList listCol;
  4074. listCol.clear();
  4075. int nIndex = 0;
  4076. for (auto pNameRow : listGridParticleRows)
  4077. {
  4078. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4079. // name
  4080. CString strName = pNameRow->GetStringValue();
  4081. pColumn->SetName(strName);
  4082. // list of rows
  4083. CGridRowsList listRows;
  4084. CGridRowPtr pRow = CGridRowPtr(new CGridRow());
  4085. pRow->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4086. CGridRowPtr pGridRow = listGridParticleNumRows[nIndex];
  4087. ASSERT(pGridRow);
  4088. if (!pGridRow)
  4089. {
  4090. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleComp: invalid name and num are different."));
  4091. return listGridData;
  4092. }
  4093. int nValue = pGridRow->GetIntValue();
  4094. pRow->SetIntValue(nValue);
  4095. listRows.push_back(pRow);
  4096. pColumn->SetGridRowsList(listRows);
  4097. listCol.push_back(pColumn);
  4098. nIndex++;
  4099. }
  4100. pGridData->SetGridColumnList(listCol);
  4101. listGridData.push_back(pGridData);
  4102. }
  4103. return listGridData;
  4104. }
  4105. CGridDatasList CReportProjFileMgr::CompChartElementComp()
  4106. {
  4107. // use the dll resource
  4108. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4109. CGridDatasList listGridData;
  4110. listGridData.clear();
  4111. CGridDatasList listGridDataEEE = CompElementComponent();
  4112. for (CGridDataPtr pGrid : listGridDataEEE)
  4113. {
  4114. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  4115. // data source id
  4116. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4117. pGridData->SetDataSourceList(listDataSource);
  4118. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  4119. pGridData->SetDataSourceId(nDataSourceId);
  4120. CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
  4121. //获取第一列所有元素名称
  4122. CGridColumnPtr element = listGridColumn[0];
  4123. //获取第二列所有占比
  4124. CGridColumnPtr Comp = listGridColumn[1];
  4125. CGridRowsList listGridNameRows = element->GetRowList();
  4126. CGridColumnsList listGridValid; // first two column is particle name and area, they are invalid
  4127. listGridValid.clear();
  4128. //循环第一列所有行,创建新表结构列
  4129. for (CGridRowPtr row : listGridNameRows)
  4130. {
  4131. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4132. // name
  4133. CString strName = row->GetStringValue();
  4134. pColumn->SetName(strName);
  4135. listGridValid.push_back(pColumn);
  4136. }
  4137. //添加数据
  4138. CGridColumnsList listCol;
  4139. listCol.clear();
  4140. for (int i = 0; i < listGridValid.size(); i++)
  4141. {
  4142. auto pGridColumn = listGridValid[i];
  4143. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4144. // name
  4145. CString strName = pGridColumn->GetName();
  4146. pColumn->SetName(strName);
  4147. // list of rows
  4148. CGridRowsList listRows;
  4149. CGridRowPtr pRow = CGridRowPtr(new CGridRow());
  4150. pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  4151. CString sValue = Comp->GetRowList()[i]->GetStringValue();
  4152. sValue.Replace('%', '0');
  4153. double dValue;
  4154. dValue = atof(sValue);
  4155. pRow->SetDoubleValue(dValue);
  4156. listRows.push_back(pRow);
  4157. pColumn->SetGridRowsList(listRows);
  4158. listCol.push_back(pColumn);
  4159. }
  4160. pGridData->SetGridColumnList(listCol);
  4161. listGridData.push_back(pGridData);
  4162. }
  4163. // use the dll resource
  4164. //AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4165. //CGridDatasList listGridData;
  4166. //listGridData.clear();
  4167. //// depart compound source name
  4168. //std::vector<int> listWorkIndex;
  4169. //std::vector<int> listPos;
  4170. //std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4171. //int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  4172. //
  4173. //int nIndex = 0;
  4174. //CGridDatasList pGridList = CompAveElemnetComponent();
  4175. //
  4176. //for (CGridDataPtr pGrid : pGridList)
  4177. //{
  4178. // CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  4179. // // data source id
  4180. // std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4181. // pGridData->SetDataSourceList(listDataSource);
  4182. // int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  4183. // pGridData->SetDataSourceId(nDataSourceId);
  4184. //
  4185. //
  4186. // ASSERT(pGrid);
  4187. // if (!pGrid)
  4188. // {
  4189. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid grid in data pointer."));
  4190. // return listGridData;
  4191. // }
  4192. // CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
  4193. // int nSTDId = m_CurrentPropParam->GetSTDId();
  4194. // CGridColumnPtr pParticleName = listGridColumn[(int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::NAME - (int)REPORT_ELEMENT_COMPONENT_GRID_CLUMN::MIN];
  4195. // CGridRowsList listGridNameRows = pParticleName->GetRowList();
  4196. // if (nSTDId < -1 || nSTDId >(int)listGridNameRows.size())
  4197. // {
  4198. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid STD id."));
  4199. // return listGridData;
  4200. // }
  4201. // if (nSTDId == 0)// all element
  4202. // {
  4203. // nSTDId = (int)listGridNameRows.size() - 1;
  4204. // }
  4205. // else if (nSTDId == 1) // undefined element
  4206. // {
  4207. // nSTDId = (int)listGridNameRows.size() - 2;
  4208. // }
  4209. // else
  4210. // {
  4211. // nSTDId = nSTDId - 1;
  4212. // }
  4213. // if ((int)listGridColumn.size() < 3)
  4214. // {
  4215. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: no element is checked out."));
  4216. // return listGridData;
  4217. // }
  4218. // CGridColumnsList listGridValid; // first two column is particle name and area, they are invalid
  4219. // listGridValid.clear();
  4220. // for (int i = 2; i < (int)listGridColumn.size(); i++)
  4221. // {
  4222. // CGridColumnPtr pNewGridColumn = listGridColumn[i];
  4223. // ASSERT(pNewGridColumn);
  4224. // if (!pNewGridColumn)
  4225. // {
  4226. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid column."));
  4227. // return listGridData;
  4228. // }
  4229. // listGridValid.push_back(pNewGridColumn);
  4230. // }
  4231. // CGridColumnsList listCol;
  4232. // listCol.clear();
  4233. // for (auto pGridColumn : listGridValid)
  4234. // {
  4235. // CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4236. // // name
  4237. // CString strName = pGridColumn->GetName();
  4238. // pColumn->SetName(strName);
  4239. // // list of rows
  4240. // CGridRowsList listRows;
  4241. // CGridRowPtr pRow = CGridRowPtr(new CGridRow());
  4242. // pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  4243. // CGridRowsList listGridRows = pGridColumn->GetRowList();
  4244. // if (!((int)listGridRows.size() == (int)listGridNameRows.size()))
  4245. // {
  4246. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: row lengths are different."));
  4247. // return listGridData;
  4248. // }
  4249. // CGridRowPtr pGridRow = listGridRows[nSTDId];
  4250. // ASSERT(pGridRow);
  4251. // if (!pGridRow)
  4252. // {
  4253. // LogErrorTrace(__FILE__, __LINE__, _T("CompChartElementComp: invalid name and num are different."));
  4254. // return listGridData;
  4255. // }
  4256. // double dValue = pGridRow->GetDoubleValue();
  4257. // pRow->SetDoubleValue(dValue);
  4258. // listRows.push_back(pRow);
  4259. // pColumn->SetGridRowsList(listRows);
  4260. // listCol.push_back(pColumn);
  4261. // }
  4262. // pGridData->SetGridColumnList(listCol);
  4263. // listGridData.push_back(pGridData);
  4264. //}
  4265. return listGridData;
  4266. }
  4267. CGridDatasList CReportProjFileMgr::CompChartParticleSize()
  4268. {
  4269. // use the dll resource
  4270. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4271. CGridDatasList listGridData;
  4272. listGridData.clear();
  4273. // depart compound source name
  4274. std::vector<int> listWorkIndex;
  4275. std::vector<int> listPos;
  4276. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4277. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  4278. CGridDatasList pGridList = CompParticleSizeDistribution();
  4279. for (CGridDataPtr pGrid : pGridList)
  4280. {
  4281. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  4282. // data source id
  4283. std::vector<CString> listDataSource;
  4284. listDataSource.clear();
  4285. listDataSource = m_CurrentPropParam->GetDataSourceList();
  4286. pGridData->SetDataSourceList(listDataSource);
  4287. int nDataSourceId = m_CurrentPropParam->GetDataSourceId();
  4288. pGridData->SetDataSourceId(nDataSourceId);
  4289. //CGridDataPtr pGrid = pGridList[0];
  4290. ASSERT(pGrid);
  4291. if (!pGrid)
  4292. {
  4293. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid grid in data pointer."));
  4294. return listGridData;
  4295. }
  4296. //amounts
  4297. CGridColumnsList listGridColumn = pGrid->GetGridColumnList();
  4298. int nCols = (int)listGridColumn.size();
  4299. int nAmounts = 0;
  4300. int nSTDId = m_CurrentPropParam->GetSTDId();
  4301. CGridColumnPtr pParticleName = listGridColumn[(int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::NAME - (int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MIN];
  4302. CGridRowsList listGridNameRows = pParticleName->GetRowList();
  4303. if (nSTDId < -1 || nSTDId >(int)listGridNameRows.size())
  4304. {
  4305. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid STD id."));
  4306. return listGridData;
  4307. }
  4308. CGridColumnsList listCol;
  4309. listCol.clear();
  4310. int nCIndex = 0;
  4311. int nCAmount = 0;
  4312. for (auto gridColumn : listGridColumn)
  4313. {
  4314. nCIndex++;
  4315. if (nCIndex > (((int)REPORT_SIZE_DISTRIBUTION_GRID_CLUMN::MAX) + 1))
  4316. {
  4317. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4318. CString strName = gridColumn->GetName();
  4319. pColumn->SetName(strName);
  4320. CGridRowsList listGridRows = gridColumn->GetRowList();
  4321. CGridRowsList listRows;
  4322. int nRows = (int)listGridRows.size();
  4323. CGridRowPtr pGridRow = listGridRows[nRows - 1];
  4324. ASSERT(pGridRow);
  4325. if (!pGridRow)
  4326. {
  4327. LogErrorTrace(__FILE__, __LINE__, _T("CompChartParticleSize: invalid name and num are different."));
  4328. return listGridData;
  4329. }
  4330. CString strValue = pGridRow->GetStringValue();
  4331. double dValue = atof(strValue);
  4332. CGridRowPtr pRow = CGridRowPtr(new CGridRow());
  4333. pRow->SetDataType(REPORT_GRID_DATA_TYPE::FLOAT);
  4334. pRow->SetDoubleValue(dValue);
  4335. listRows.push_back(pRow);
  4336. pColumn->SetGridRowsList(listRows);
  4337. listCol.push_back(pColumn);
  4338. }
  4339. }
  4340. //double dValue = nCAmount / nAmounts;
  4341. pGridData->SetGridColumnList(listCol);
  4342. listGridData.push_back(pGridData);
  4343. }
  4344. return listGridData;
  4345. }
  4346. // compute common five classification
  4347. CGridDatasList CReportProjFileMgr::CompChartCommonFive()
  4348. {
  4349. // use the dll resource
  4350. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4351. CGridDatasList listGridData;
  4352. listGridData.clear();
  4353. std::vector<CString> listDataSource = m_CurrentPropParam->GetDataSourceList();
  4354. int nSelectedDataSourceIndex = m_CurrentPropParam->GetDataSourceId();
  4355. CString sDataSourceNames = listDataSource[nSelectedDataSourceIndex];
  4356. std::vector<CString> listSelectedDataSource = COTSHelper::SplitString(sDataSourceNames, _T("+"));
  4357. //int nIndex = 0;
  4358. for (auto strDataSourceName : listSelectedDataSource)
  4359. {
  4360. CGridDataPtr pGridData = CGridDataPtr(new CGridData());
  4361. // data source id
  4362. pGridData->SetDataSourceList(m_CurrentPropParam->GetDataSourceList());
  4363. pGridData->SetDataSourceId(m_CurrentPropParam->GetDataSourceId());
  4364. COTSParticleList* pSelectidParts;
  4365. COTSParticleList listParticleAll;
  4366. COTSParticleList seleParticles;
  4367. // add filter select particle
  4368. if (m_CurrentPropParam->GetDataSourceType() == DATA_SOURCE_TYPE::SELECTION)
  4369. {
  4370. seleParticles = m_CurrentPropParam->GetSelectParticle();
  4371. pSelectidParts = &seleParticles;
  4372. }
  4373. else
  4374. {
  4375. listParticleAll = GetAnalysisParticleList(strDataSourceName);
  4376. pSelectidParts = &listParticleAll;
  4377. }
  4378. if (!GetCommonFiveFromParticleList(*pSelectidParts, pGridData))
  4379. {
  4380. LogErrorTrace(__FILE__, __LINE__, _T("CompParticleComponent: can't get general information."));
  4381. return listGridData;
  4382. }
  4383. listGridData.push_back(pGridData);
  4384. }
  4385. return listGridData;
  4386. }
  4387. BOOL CReportProjFileMgr::GetCommonClass(
  4388. COTSParticlePtr a_pPart,
  4389. INC_COMMON_CLASSIFY_TYPE& a_nType)
  4390. {
  4391. // safety check
  4392. ASSERT(a_pPart);
  4393. if (!a_pPart)
  4394. {
  4395. // something wrong
  4396. LogErrorTrace(__FILE__, __LINE__, _T("GetCommonClass: invalid CParticlePtr."));
  4397. return FALSE;
  4398. }
  4399. int nType = a_pPart->GetType();
  4400. //CString sIncName = GetSTDItemNameById(a_listSTDItems, nType);
  4401. //只有"NOT_IDENTIFIED"以上的颗粒类型需要考虑
  4402. if (nType >= (int)OTS_PARTCLE_TYPE::NOT_IDENTIFIED)
  4403. {
  4404. if ((nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPIEL_OXICE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SPIEL_OXICE_MAX)
  4405. || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_NITRIDE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_NITRIDE_MAX)
  4406. || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_SPINEL_OXIDE_SULFIDE_MIN && nType <= (int)OTS_STD_ITEM_VALUE::SYS_SIMPLE_OXIDE_SULFIDE_MAX))
  4407. {
  4408. a_nType = INC_COMMON_CLASSIFY_TYPE::SPINEL;
  4409. }
  4410. else if (nType >= (int)OTS_STD_ITEM_VALUE::SYS_OXIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_OXIDE_MAX)
  4411. {
  4412. a_nType = INC_COMMON_CLASSIFY_TYPE::OXIDE;
  4413. }
  4414. 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)
  4415. || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_COMPLEX_OXIDE_SULFIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_COMPLEX_OXIDE_SULFIDE_MAX)
  4416. || (nType >= (int)OTS_STD_ITEM_VALUE::SYS_OXIDE_SULFIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_OXIDE_SULFIDE_MAX))
  4417. {
  4418. a_nType = INC_COMMON_CLASSIFY_TYPE::SULFIDE_OXIDE;
  4419. }
  4420. else if (nType > (int)OTS_STD_ITEM_VALUE::SYS_NITRIDE_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_NITRIDE_MAX)
  4421. {
  4422. a_nType = INC_COMMON_CLASSIFY_TYPE::NITRIDE;
  4423. }
  4424. else if (nType > (int)OTS_STD_ITEM_VALUE::SYS_SUL_MIN && nType <= (int)(int)OTS_STD_ITEM_VALUE::SYS_SUL_MAX)
  4425. {
  4426. a_nType = INC_COMMON_CLASSIFY_TYPE::SULFIDE;
  4427. }
  4428. }
  4429. else
  4430. {
  4431. LogErrorTrace(__FILE__, __LINE__, _T("GetCommonClass: this particle is not a common particle."));
  4432. return FALSE;
  4433. }
  4434. // ok, return TRUE
  4435. return TRUE;
  4436. }
  4437. BOOL CReportProjFileMgr::GetCommonFiveFromParticleList(COTSParticleList a_listParticle, CGridDataPtr a_pGridData)
  4438. {
  4439. // use the dll resource
  4440. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  4441. ASSERT(a_pGridData);
  4442. if (!a_pGridData)
  4443. {
  4444. LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: invalid grid data pointer."));
  4445. return FALSE;
  4446. }
  4447. //// std
  4448. //ASSERT(m_pReportProjFile);
  4449. //if (!m_pReportProjFile)
  4450. //{
  4451. // LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: empty project file."));
  4452. // return FALSE;
  4453. //}
  4454. //CPartSTDDataPtr pPartSTDData = m_pReportProjFile->GetPartSTDData();
  4455. //ASSERT(pPartSTDData);
  4456. //if (!pPartSTDData)
  4457. //{
  4458. // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: invalid STD data."));
  4459. // return FALSE;
  4460. //}
  4461. //CSTDItemsList listSTDItem = pPartSTDData->GetSTDItemsList();
  4462. //if (listSTDItem.empty())
  4463. //{
  4464. // LogErrorTrace(__FILE__, __LINE__, _T("GetComponentFromParticleList: empty STD Item."));
  4465. // return FALSE;
  4466. //}
  4467. int nNumSulfideOxide = 0;
  4468. int nNumOxide = 0;
  4469. int nNumSulfide = 0;
  4470. int nNumNitrides = 0;
  4471. int nNumSpinel = 0;
  4472. for (auto pPart : a_listParticle)
  4473. {
  4474. INC_COMMON_CLASSIFY_TYPE nCommonType = INC_COMMON_CLASSIFY_TYPE::INVALID;
  4475. if (GetCommonClass(pPart, nCommonType))
  4476. {
  4477. if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SULFIDE_OXIDE)
  4478. {
  4479. nNumSulfideOxide++;
  4480. }
  4481. else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::OXIDE)
  4482. {
  4483. nNumOxide++;
  4484. }
  4485. else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SULFIDE)
  4486. {
  4487. nNumSulfide++;
  4488. }
  4489. else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::NITRIDE)
  4490. {
  4491. nNumNitrides++;
  4492. }
  4493. else if ((int)nCommonType == (int)INC_COMMON_CLASSIFY_TYPE::SPINEL)
  4494. {
  4495. nNumSpinel++;
  4496. }
  4497. }
  4498. }
  4499. int nColumnNum = ((int)(REPORT_COMMON_FIVE_GRID_CLUMN::MAX) - (int)(REPORT_COMMON_FIVE_GRID_CLUMN::MIN) + 1);
  4500. std::vector<CString> listColumnName;
  4501. LoadColumnString(listColumnName, IDS_COMMON_FIVE_START, nColumnNum);
  4502. if ((int)listColumnName.size() != nColumnNum)
  4503. {
  4504. LogErrorTrace(__FILE__, __LINE__, _T("GetCommonFiveFromParticleList: Can't get column name number."));
  4505. return FALSE;
  4506. }
  4507. CGridColumnsList listGridColumn;
  4508. COTSParticleList listPartReport;
  4509. for (int i = 0; i < nColumnNum; i++)
  4510. {
  4511. CGridColumnPtr pColumn = CGridColumnPtr(new CGridColumn());
  4512. pColumn->SetName(listColumnName[i]);
  4513. CGridRowsList listGridRows;
  4514. listGridRows.clear();
  4515. switch (i)
  4516. {
  4517. case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SULFIDE_OXIDE:
  4518. {
  4519. listGridRows.clear();
  4520. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  4521. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4522. pGridRowNum->SetIntValue(nNumSulfideOxide);
  4523. listGridRows.push_back(pGridRowNum);
  4524. }
  4525. break;
  4526. case (int)REPORT_COMMON_FIVE_GRID_CLUMN::OXIDE:
  4527. {
  4528. listGridRows.clear();
  4529. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  4530. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4531. pGridRowNum->SetIntValue(nNumOxide);
  4532. listGridRows.push_back(pGridRowNum);
  4533. }
  4534. break;
  4535. case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SULFIDE:
  4536. {
  4537. listGridRows.clear();
  4538. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  4539. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4540. pGridRowNum->SetIntValue(nNumSulfide);
  4541. listGridRows.push_back(pGridRowNum);
  4542. }
  4543. break;
  4544. case (int)REPORT_COMMON_FIVE_GRID_CLUMN::NITRIDES:
  4545. {
  4546. listGridRows.clear();
  4547. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  4548. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4549. pGridRowNum->SetIntValue(nNumNitrides);
  4550. listGridRows.push_back(pGridRowNum);
  4551. }
  4552. break;
  4553. case (int)REPORT_COMMON_FIVE_GRID_CLUMN::SPINEL:
  4554. {
  4555. listGridRows.clear();
  4556. CGridRowPtr pGridRowNum = CGridRowPtr(new CGridRow());
  4557. pGridRowNum->SetDataType(REPORT_GRID_DATA_TYPE::INT);
  4558. pGridRowNum->SetIntValue(nNumSpinel);
  4559. listGridRows.push_back(pGridRowNum);
  4560. }
  4561. break;
  4562. }
  4563. pColumn->SetGridRowsList(listGridRows);
  4564. listGridColumn.push_back(pColumn);
  4565. }
  4566. a_pGridData->SetGridColumnList(listGridColumn);
  4567. return TRUE;
  4568. }
  4569. double CReportProjFileMgr::GetValueAsMethod(COTSParticlePtr a_pParticle, OTSMODEL::SIZE_CAL_METHOD_TYPE a_nMethod, double a_dPixelSize)
  4570. {
  4571. double dValue = 0;
  4572. double dArea = a_pParticle->GetArea();
  4573. double dDiameter = 2 * sqrt(dArea / Pi);
  4574. double dFltD;
  4575. double dMinWidth;
  4576. double dMaxLength;
  4577. double dRatio;
  4578. if (!OTSIMGPROC::CGBImgPropCal::GetParticleFTD(a_pParticle, a_dPixelSize, dFltD, dMinWidth, dMaxLength, dRatio))
  4579. {
  4580. return dValue;
  4581. }
  4582. switch ((int)a_nMethod)
  4583. {
  4584. case (int)SIZE_CAL_METHOD_TYPE::CIRCLE:
  4585. dValue = dDiameter;
  4586. break;
  4587. case (int)SIZE_CAL_METHOD_TYPE::AREA:
  4588. dValue = dArea;
  4589. break;
  4590. case (int)SIZE_CAL_METHOD_TYPE::FLTD:
  4591. dValue = dFltD;
  4592. break;
  4593. case (int)SIZE_CAL_METHOD_TYPE::LENGTH:
  4594. dValue = dMaxLength;
  4595. break;
  4596. case (int)SIZE_CAL_METHOD_TYPE::WIDTH:
  4597. dValue = dMinWidth;
  4598. break;
  4599. }
  4600. return dValue;
  4601. }
  4602. void CReportProjFileMgr::SetSelectedPicture(RETORT_PROP_GRID_PARAM_TYPE a_nType)
  4603. {
  4604. if (m_listPropParams.size() == 0)
  4605. {
  4606. ResetPropertyParams();
  4607. }
  4608. if (m_listPropParams.size() > 0)
  4609. {
  4610. switch (a_nType)
  4611. {
  4612. case RETORT_PROP_GRID_PARAM_TYPE::IMAGE:
  4613. m_CurrentPropParam = m_listPropParams[0];
  4614. break;
  4615. case RETORT_PROP_GRID_PARAM_TYPE::TABLE:
  4616. m_CurrentPropParam = m_listPropParams[1];
  4617. break;
  4618. case RETORT_PROP_GRID_PARAM_TYPE::CHART:
  4619. m_CurrentPropParam = m_listPropParams[2];
  4620. break;
  4621. default:
  4622. break;
  4623. }
  4624. }
  4625. }
  4626. }