123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773 |
- #pragma once
- #include "stdafx.h"
- #include "resource.h"
- #include "ReportMgr.h"
- #include "BSEImgFileMgr.h"
- #include "PosXrayFileMgr.h"
- #include "CGBCalculate.h"
- #include "GBFieldData.h"
- #include "OTSHelper.h"
- #include "OTSFileSys.h"
- #include "RptParamFileMgr.h"
- #include "GBImgPropCal.h"
- using namespace OTSGBCalculate;
- namespace OTSMODEL {
- using namespace std;
- // constructor
- CReportMgr::CReportMgr()
- {
-
- m_listPropParams.clear();
- m_listSmplMgrs.clear();
-
- m_nWorkingSampeIndex = -1;
-
- //load param file
- CRptParamFileMgr paramFleMgr;
- paramFleMgr.Load(OTSMODEL::OTS_SOFT_PACKAGE_ID::OTSIncA);
- m_rptparamfile = paramFleMgr.GetRptParamFile();
- double dScale = m_rptparamfile->GetScale();
- }
- // destructor
- CReportMgr::~CReportMgr()
- {
- }
- CRptParamFilePtr CReportMgr::GetRptParamFilePtr()
- {
- return m_rptparamfile;
- }
- // class methods
- // public
- // property parameters
- CPropParamPtr CReportMgr::GetPropertyParamImage()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::IMAGE];
- }
- CPropParamPtr CReportMgr::GetPropertyParamGrid()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::TABLE];
- }
- CPropParamPtr CReportMgr::GetPropertyParamChart()
- {
- return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::CHART];
- }
- // reset property parameters
- BOOL CReportMgr::ResetPropertyParams(BOOL a_bClear /*= FALSE*/)
- {
- // clear property parameters list
- if (a_bClear)
- {
- m_listPropParams.clear();
- }
- // get data source names list
- std::vector<CString> listDataSourceNames = GetDataSourceNamesList();
- // data source names list can't be empty
- if (listDataSourceNames.empty())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty data source name list."));
- return FALSE;
- }
- // add property parameters into the list
- if (m_listPropParams.empty())
- {
- //Image display picture's property
- CPropParamPtr pPropParam = CPropParamPtr(new CPropParamImage());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
-
-
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::IMAGE);
- m_listPropParams.push_back(pPropParam);
- //grid table display picture's property
- pPropParam = CPropParamPtr(new CPropParamGrid());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
-
-
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::TABLE);
- m_listPropParams.push_back(pPropParam);
- //chart display picture's property object
- pPropParam = CPropParamPtr(new CPropParamChart());
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
-
-
- pPropParam->SetType(DISPLAY_PICTURE_TYPE::CHART);
- m_listPropParams.push_back(pPropParam);
- }
- else
- {
- for (auto pPropParam : m_listPropParams)
- {
- pPropParam->SetDataSourceList(listDataSourceNames);
- pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
-
- }
- }
- // ok, return TRUE
- return TRUE;
- }
-
- // sample measure result files
- BOOL CReportMgr::AddASmplMsrResultMgr(CString a_strPathName /*= _T("")*/)
- {
- /*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
- tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
- _CrtSetDbgFlag(tmpFlag);*/
- //_CrtSetBreakAlloc(351380);
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgrPtr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(a_strPathName));
- // load sample result file
- if (!pSmplMsrResultFileMgrPtr->Load(a_strPathName))
- {
- return FALSE;
- }
- //判断新打开的测量结果文件名,是否已经在打开的测量结果列表名中,是的话,不打开,防止同名
- CString strSampleNameNew = pSmplMsrResultFileMgrPtr->GetSmplMsrResultFile()->GetSample()->GetName();
- for (int i = 0; i < m_listSmplMgrs.size(); i++)
- {
- if (m_listSmplMgrs[i]->GetSmplMsrResultFile()->GetSample()->GetName() == strSampleNameNew)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: The measurement result name is already included."));
- return FALSE;
- }
- }
- // add the file path name into file path names list
-
- // add the sample result file into sample measure result files list
- m_listSmplMgrs.push_back(pSmplMsrResultFileMgrPtr);
-
- // set working sample
- m_nWorkingSampeIndex = (int)m_listSmplMgrs.size() - 1;
- // reset property parameters
- ResetPropertyParams();
- // ok, return TRUE
- return TRUE;
- }
- void CReportMgr::SetSmplMsrResultMgrs(CSmplMsrResultFileMgrList a_listSmplMsrResultFileMgr)
- {
- for (auto pSmplMsrResultMgr : a_listSmplMsrResultFileMgr)
- {
- CString strWorkingFolder = pSmplMsrResultMgr->GetWorkingFolderStr();
- CSmplMsrResultFileMgrPtr pSmplMsrResultMgrNew = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strWorkingFolder));
- CString strPathname = pSmplMsrResultMgr->GetPathName();
- pSmplMsrResultMgrNew->SetPathName(strPathname);
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
- CSmplMsrResultFilePtr pSmplMsrResultFileNew = CSmplMsrResultFilePtr(new CSmplMsrResultFile(pSmplMsrResultFile.get()));
- pSmplMsrResultMgrNew->SetSmplMsrResultFile(pSmplMsrResultFileNew);
- m_listSmplMgrs.push_back(pSmplMsrResultMgrNew);
- }
- }
- CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrById(int a_nIndex)
- {
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- return nullptr;
- }
- return m_listSmplMgrs[a_nIndex];
- }
- CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrByPathName(CString a_strPathName)
- {
- a_strPathName.Trim();
- if (a_strPathName.IsEmpty())
- {
- return nullptr;
- }
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
- if (itr == m_listSmplMgrs.end())
- {
- return nullptr;
- }
- return *itr;
- }
- CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrByFileName(CString a_strFileName)
- {
- a_strFileName.Trim();
- if (a_strFileName.IsEmpty())
- {
- return nullptr;
- }
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strFileName](CSmplMsrResultFileMgrPtr p)
- {
- CString strDataSource = COTSHelper::GetFileName(p->GetPathName());
- return strDataSource.CompareNoCase(a_strFileName) == 0;
- });
- if (itr == m_listSmplMgrs.end())
- {
- return nullptr;
- }
- return *itr;
- }
- BOOL CReportMgr::DeleteASmplMsrResultMgrById(int a_nIndex)
- {
- // check the index
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- // invalid input sample index
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteSampleByIndex::input sample index"));
- return a_nIndex;
- }
- // calculate new working sample index
- int nNewWorkingSampeIndex;
- if (a_nIndex < m_nWorkingSampeIndex)
- {
- nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
- }
- else if (a_nIndex > m_nWorkingSampeIndex)
- {
- nNewWorkingSampeIndex = m_nWorkingSampeIndex;
- }
- else
- {
- // deleting working sample.
- if (a_nIndex == (int)m_listSmplMgrs.size() - 1)
- {
- // this is the last sample, select the above sample as working sample
- // if this is only sample in the list working sample index will be -1;
- nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
- }
- else
- {
- // select next sample as working sample
- nNewWorkingSampeIndex = m_nWorkingSampeIndex;
- }
- }
- // delete the sample
- m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
- // reset working sample index
- m_nWorkingSampeIndex = nNewWorkingSampeIndex;
- // reset property parameters
- ResetPropertyParams();
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportMgr::DeleteASmplMsrResultMgrByPathName(CString a_strPathName)
- {
- // check report project file pointer
- a_strPathName.Trim();
- if (a_strPathName.IsEmpty())
- {
- return FALSE;
- }
- auto itrObj = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
- if (itrObj == m_listSmplMgrs.end())
- {
- // failed to find sample measure result file
- LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file."));
- return FALSE;
- }
- m_listSmplMgrs.erase(itrObj);
- // reset property parameters
- ResetPropertyParams();
- // ok, return TRUE
- return TRUE;
- }
- BOOL CReportMgr::EditASmplMsrResultMgrById(int a_nIndex, CSmplMsrResultFileMgrPtr a_pSmpFileMgr)
- {
- ASSERT(a_pSmpFileMgr);
- if (!a_pSmpFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById:invalid sample measure result manager pointer."));
- return FALSE;
- }
- // check if the working sample index
- if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById: invalid sample measure result manager index."));
- // invalid working sample index
- return FALSE;
- }
- m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
- m_listSmplMgrs.insert(m_listSmplMgrs.begin() + a_nIndex, a_pSmpFileMgr);
- return TRUE;
- }
- CSmplMsrResultFileMgrPtr CReportMgr::GetWorkingSmplMsrReslMgr()
- {
- // check if the working sample index
- if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSmplMgrs.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSmplMsrReslMgr: invalid working sample measure result manager index."));
- // invalid working sample index
- return FALSE;
- }
- return GetASmplMsrResultMgrById(m_nWorkingSampeIndex);
- }
- CString CReportMgr::GetWorkingSampleName()
- {
- CString strRet = _T("");
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = GetWorkingSmplMsrReslMgr();
- ASSERT(pSmplMsrResultFileMgr);
- if (!pSmplMsrResultFileMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result manager."));
- return _T("");
- }
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result file."));
- return _T("");
- }
- COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
- ASSERT(pSample);
- if (!pSample)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample."));
- return _T("");
- }
- strRet = pSample->GetName();
- return strRet;
- }
- BOOL CReportMgr::SetWorkingSmplMsrReslMgr(CSmplMsrResultFileMgrPtr a_pSmplMsrResultMgr)
- {
- ASSERT(a_pSmplMsrResultMgr);
- if (!a_pSmplMsrResultMgr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result manager pointer."));
- return FALSE;
- }
- if (!EditASmplMsrResultMgrById(m_nWorkingSampeIndex, a_pSmplMsrResultMgr))
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: can't edit working sample measure result file."));
- return FALSE;
- }
- return TRUE;
- }
- // grid computing
- CGridDatasList CReportMgr::GridDataTransfer(CPropParamPtr thePropParam)
- {
- CGridDatasList listGridData;
- listGridData.clear();
-
-
-
- CGBCalculate GBCal(this);
-
-
- CALCULATE_TABLE_TYPE nCalTableType = thePropParam->GetCalTableType();
- switch (nCalTableType)
- {
-
- case CALCULATE_TABLE_TYPE::GB_Method1:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::GB_Method2:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::ASTM:
- listGridData = GBCal.GetGBInclusion();
- break;
- case CALCULATE_TABLE_TYPE::DIN:
- listGridData = GBCal.GetGBInclusion();
- break;
- default:
- break;
- }
-
-
- return listGridData;
- }
- // protected
- // get data source name list
- std::vector<CString> CReportMgr::GetDataSourceNamesList()
- {
- std::vector<CString> listDataSourceNames;
- CString strComSourceName = _T("");
- int nComNum = 0;
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
- {
- // sample measure result file
- CString strFilePathName = pSmplMsrResultFileMgr->GetPathName();
- // get data source name
- CString strDataSource = COTSHelper::GetFileName(strFilePathName);
- // get compound source name
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
- break;
- }
- BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
- if (bSwitch)
- {
- strComSourceName += strDataSource + _T("+");
- nComNum++;
- }
- // add data source name into the list
- listDataSourceNames.push_back(strDataSource);
- }
- if (nComNum > 1)
- {
- //listDataSourceNames.push_back(strComSourceName);
- strComSourceName.TrimRight(_T("+"));//去掉最后的+号
- listDataSourceNames.insert(listDataSourceNames.begin(), strComSourceName);
- }
- return listDataSourceNames;
- }
- std::vector<int> CReportMgr::GetDataSourcePosList()
- {
- std::vector<int> listDataSourcePos;
- if (!IsHaveMultiDataSource())
- {
- return listDataSourcePos;
- }
- int nPos = -1;
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
- {
- nPos++;
- // get compound source name
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
- ASSERT(pSmplMsrResultFile);
- if (!pSmplMsrResultFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
- break;
- }
- BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
- if (bSwitch)
- {
- listDataSourcePos.push_back(nPos);
- }
- }
- return listDataSourcePos;
- }
- // get property parameter
- COTSParticleList CReportMgr::GetAnalysisParticleList(CString a_DataSourceName)
- {
- COTSParticleList listParticleAll;
- // compound sample measure result files
- CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
- if (!pSmplMsrResultFileMgr->ComputeParticleList())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetAnalysisParticleList: can't get particle list."));
- return listParticleAll;
- }
- listParticleAll = pSmplMsrResultFileMgr->GetParticleList();
- return listParticleAll;
- }
- //CPosXraysList CReportMgr::GetAnalysisXrayList(CString a_DataSourceName)
- //{
- // CPosXraysList listAnalysisXray;
- // CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
- // pSmplMsrResultFileMgr->GetOTSFldMgrListAndAnalysisXrayList();
- // // should first read x ray data from data base.
- // listAnalysisXray = pSmplMsrResultFileMgr->GetAnalysisXray();
- // return listAnalysisXray;
- //}
-
- //判断该列是否要显示
- BOOL CReportMgr::EstimateShowColumn(CString a_strColName)
- {
- CString str_Area_Enum = "Area";
- CString str_MaxDiameter_Enum = "MaxDiameter";
- CString str_MinDiameter_Enum = "MinDiameter";
- CString str_DiameterRatio_Enum = "DiameterRatio";
- CString str_EquivalentCircleDiameter_Enum = "EquivalentCircleDiameter";
- CString str_FerretDiameter_Enum = "FerretDiameter";
- CString str_Area_CN = "颗粒面积";
- CString str_MaxDiameter_CN = "最长直径";
- CString str_MinDiameter_CN = "最短直径";
- CString str_DiameterRatio_CN = "长短直径比";
- CString str_EquivalentCircleDiameter_CN = "等效圆直径";
- CString str_FerretDiameter_CN = "费雷特直径";
- //最后再根据设置默认显示列名,对不需要显示的列进行屏蔽
- CString s_DefaultComputedColName = m_rptparamfile->GetDefaultComputedColName();
- if (a_strColName.Find(str_Area_CN, 0) > -1 || a_strColName.Find(str_MaxDiameter_CN, 0) > -1 ||
- a_strColName.Find(str_MinDiameter_CN, 0) > -1 || a_strColName.Find(str_DiameterRatio_CN, 0) > -1 ||
- a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1 || a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
- {
- //面积
- if (s_DefaultComputedColName.Find(str_Area_Enum) > -1 && a_strColName.Find(str_Area_CN, 0) > -1)
- {
- return true;
- }
- //最长直径
- if (s_DefaultComputedColName.Find(str_MaxDiameter_Enum) > -1 && a_strColName.Find(str_MaxDiameter_CN, 0) > -1)
- {
- return true;
- }
- //最短直径
- if (s_DefaultComputedColName.Find(str_MinDiameter_Enum) > -1 && a_strColName.Find(str_MinDiameter_CN, 0) > -1)
- {
- return true;
- }
- //长短直径比
- if (s_DefaultComputedColName.Find(str_DiameterRatio_Enum) > -1 && a_strColName.Find(str_DiameterRatio_CN, 0) > -1)
- {
- return true;
- }
- //等效圆直径
- if (s_DefaultComputedColName.Find(str_EquivalentCircleDiameter_Enum) > -1 && a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1)
- {
- return true;
- }
- //费雷特直径
- if (s_DefaultComputedColName.Find(str_FerretDiameter_Enum) > -1 && a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
- {
- return true;
- }
- return false;
- }
- return true;
- }
-
- BOOL CReportMgr::IsHaveMultiDataSource()
- {
- int nMultiCount = 0;
- for (auto SmplMgr : m_listSmplMgrs)
- {
- CSmplMsrResultFilePtr pSmpl = SmplMgr->GetSmplMsrResultFile();
- if (pSmpl->GetSwitch())
- {
- nMultiCount++;
- }
- }
- if (nMultiCount > 1)
- {
- return TRUE;
- }
- return FALSE;
- }
-
- // get undefined element list from particle list
- CElementChemistriesList CReportMgr::GetUndefinedElementList(COTSParticleList a_listParticle, CPosXraysList a_listXray)
- {
- CElementChemistriesList listElementChemistry;
- // safety check to get xray data and element number
- int nXraySize = (int)a_listXray.size();
- int nParticleSize = (int)a_listParticle.size();
- if (nParticleSize > nXraySize)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get xray number is not enough."));
- return listElementChemistry;
- }
- CElementAreaList listElementArea;
- // get element area
- double dTotalArea = 0;
- for (auto pParticle : a_listParticle)
- {
- int nXrayId = pParticle->GetAnalysisId();
- if (nXrayId < 0 || nXrayId >(int) a_listXray.size())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get wrong xray id."));
- return listElementChemistry;
- }
- int nFieldId = pParticle->GetFieldId();
- auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [nXrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == nXrayId)); });
- if (itr == a_listXray.end())
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: can't find x-ray."));
- return listElementChemistry;
- }
- CPosXrayPtr pXray = *itr;
- // remove Fe
- CElementChemistriesList listElementChemistryCurrent = pXray->GetElementQuantifyData();
- CElementChemistriesList listElementChemistryNew1 = CPosXray::RemoveFe(listElementChemistryCurrent);
- CElementChemistriesList listElementChemistryNew = CPosXray::RemoveC(listElementChemistryNew1);
- double t = 0;
- CElementChemistriesList listElementChemistryG1;
- for (auto pElementChemistry : listElementChemistryNew)
- {
- t += pElementChemistry->GetPercentage();
- }
- if (t == 0)
- {
- continue;
- }
- for (auto pElementChemistry : listElementChemistryNew)
- {
- double dPecent = 100.0 *pElementChemistry->GetPercentage() / t;
- CElementChemistryPtr pElementNew = CElementChemistryPtr(new CElementChemistry(*pElementChemistry.get()));
- pElementNew->SetPercentage(dPecent);
- listElementChemistryG1.push_back(pElementNew);
- }
- CElementAreaPtr pElementArea = CElementAreaPtr(new CElementArea());
- double dArea = pParticle->GetActualArea();
- pElementArea->SetArea(dArea);
- pElementArea->SetElementList(listElementChemistryG1);
- listElementArea.push_back(pElementArea);
- dTotalArea += dArea;
- }
- for (auto pElementArea : listElementArea)
- {
- CElementChemistriesList listElementChemistryCurrent = pElementArea->GetElementList();
- for (auto pElement : listElementChemistryCurrent)
- {
- CString strName = pElement->GetName();
- double dPercentNorm = 1.0;
- auto itr = std::find_if(listElementChemistry.begin(), listElementChemistry.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
- if (itr == listElementChemistry.end())
- {
- double dArea = pElementArea->GetArea();
- double dPercent = pElement->GetPercentage();
- dPercentNorm = dArea * dPercent / dTotalArea;
- }
- else
- {
- CElementChemistryPtr pElementChemistry = *itr;
- double dAreaOld = pElementChemistry->GetPercentage() * dTotalArea * 0.01;
- double dArea = pElementArea->GetArea();
- double dPercent = pElement->GetPercentage();
- dPercentNorm = 100 * (0.01 * dArea * dPercent + dAreaOld) / dTotalArea;
- listElementChemistry.erase(itr);
- }
- CElementChemistryPtr pElement = CElementChemistryPtr(new CElementChemistry());
- pElement->SetName(strName);
- pElement->SetPercentage(dPercentNorm);
- listElementChemistry.push_back(pElement);
- }
- }
- return listElementChemistry;
- }
-
-
- }
|