ReportMgr.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "resource.h"
  4. #include "ReportMgr.h"
  5. #include "BSEImgFileMgr.h"
  6. #include "PosXrayFileMgr.h"
  7. #include "CGBCalculate.h"
  8. #include "GBFieldData.h"
  9. #include "OTSHelper.h"
  10. #include "OTSFileSys.h"
  11. #include "RptParamFileMgr.h"
  12. #include "GBImgPropCal.h"
  13. using namespace OTSGBCalculate;
  14. namespace OTSMODEL {
  15. using namespace std;
  16. // constructor
  17. CReportMgr::CReportMgr()
  18. {
  19. m_listPropParams.clear();
  20. m_listSmplMgrs.clear();
  21. m_nWorkingSampeIndex = -1;
  22. //load param file
  23. CRptParamFileMgr paramFleMgr;
  24. paramFleMgr.Load(OTSMODEL::OTS_SOFT_PACKAGE_ID::OTSIncA);
  25. m_rptparamfile = paramFleMgr.GetRptParamFile();
  26. double dScale = m_rptparamfile->GetScale();
  27. }
  28. // destructor
  29. CReportMgr::~CReportMgr()
  30. {
  31. }
  32. CRptParamFilePtr CReportMgr::GetRptParamFilePtr()
  33. {
  34. return m_rptparamfile;
  35. }
  36. // class methods
  37. // public
  38. // property parameters
  39. CPropParamPtr CReportMgr::GetPropertyParamImage()
  40. {
  41. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::IMAGE];
  42. }
  43. CPropParamPtr CReportMgr::GetPropertyParamGrid()
  44. {
  45. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::TABLE];
  46. }
  47. CPropParamPtr CReportMgr::GetPropertyParamChart()
  48. {
  49. return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::CHART];
  50. }
  51. // reset property parameters
  52. BOOL CReportMgr::ResetPropertyParams(BOOL a_bClear /*= FALSE*/)
  53. {
  54. // clear property parameters list
  55. if (a_bClear)
  56. {
  57. m_listPropParams.clear();
  58. }
  59. // get data source names list
  60. std::vector<CString> listDataSourceNames = GetDataSourceNamesList();
  61. // data source names list can't be empty
  62. if (listDataSourceNames.empty())
  63. {
  64. LogErrorTrace(__FILE__, __LINE__, _T("ResetPropertyParams: empty data source name list."));
  65. return FALSE;
  66. }
  67. // add property parameters into the list
  68. if (m_listPropParams.empty())
  69. {
  70. //Image display picture's property
  71. CPropParamPtr pPropParam = CPropParamPtr(new CPropParamImage());
  72. pPropParam->SetDataSourceList(listDataSourceNames);
  73. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  74. pPropParam->SetType(DISPLAY_PICTURE_TYPE::IMAGE);
  75. m_listPropParams.push_back(pPropParam);
  76. //grid table display picture's property
  77. pPropParam = CPropParamPtr(new CPropParamGrid());
  78. pPropParam->SetDataSourceList(listDataSourceNames);
  79. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  80. pPropParam->SetType(DISPLAY_PICTURE_TYPE::TABLE);
  81. m_listPropParams.push_back(pPropParam);
  82. //chart display picture's property object
  83. pPropParam = CPropParamPtr(new CPropParamChart());
  84. pPropParam->SetDataSourceList(listDataSourceNames);
  85. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  86. pPropParam->SetType(DISPLAY_PICTURE_TYPE::CHART);
  87. m_listPropParams.push_back(pPropParam);
  88. }
  89. else
  90. {
  91. for (auto pPropParam : m_listPropParams)
  92. {
  93. pPropParam->SetDataSourceList(listDataSourceNames);
  94. pPropParam->SetDataSourceId(m_nWorkingSampeIndex);
  95. }
  96. }
  97. // ok, return TRUE
  98. return TRUE;
  99. }
  100. // sample measure result files
  101. BOOL CReportMgr::AddASmplMsrResultMgr(CString a_strPathName /*= _T("")*/)
  102. {
  103. /*int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
  104. tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
  105. _CrtSetDbgFlag(tmpFlag);*/
  106. //_CrtSetBreakAlloc(351380);
  107. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgrPtr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(a_strPathName));
  108. // load sample result file
  109. if (!pSmplMsrResultFileMgrPtr->Load(a_strPathName))
  110. {
  111. return FALSE;
  112. }
  113. //判断新打开的测量结果文件名,是否已经在打开的测量结果列表名中,是的话,不打开,防止同名
  114. CString strSampleNameNew = pSmplMsrResultFileMgrPtr->GetSmplMsrResultFile()->GetSample()->GetName();
  115. for (int i = 0; i < m_listSmplMgrs.size(); i++)
  116. {
  117. if (m_listSmplMgrs[i]->GetSmplMsrResultFile()->GetSample()->GetName() == strSampleNameNew)
  118. {
  119. LogErrorTrace(__FILE__, __LINE__, _T("AddASmplMsrResultMgr: The measurement result name is already included."));
  120. return FALSE;
  121. }
  122. }
  123. // add the file path name into file path names list
  124. // add the sample result file into sample measure result files list
  125. m_listSmplMgrs.push_back(pSmplMsrResultFileMgrPtr);
  126. // set working sample
  127. m_nWorkingSampeIndex = (int)m_listSmplMgrs.size() - 1;
  128. // reset property parameters
  129. ResetPropertyParams();
  130. // ok, return TRUE
  131. return TRUE;
  132. }
  133. void CReportMgr::SetSmplMsrResultMgrs(CSmplMsrResultFileMgrList a_listSmplMsrResultFileMgr)
  134. {
  135. for (auto pSmplMsrResultMgr : a_listSmplMsrResultFileMgr)
  136. {
  137. CString strWorkingFolder = pSmplMsrResultMgr->GetWorkingFolderStr();
  138. CSmplMsrResultFileMgrPtr pSmplMsrResultMgrNew = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(strWorkingFolder));
  139. CString strPathname = pSmplMsrResultMgr->GetPathName();
  140. pSmplMsrResultMgrNew->SetPathName(strPathname);
  141. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultMgr->GetSmplMsrResultFile();
  142. CSmplMsrResultFilePtr pSmplMsrResultFileNew = CSmplMsrResultFilePtr(new CSmplMsrResultFile(pSmplMsrResultFile.get()));
  143. pSmplMsrResultMgrNew->SetSmplMsrResultFile(pSmplMsrResultFileNew);
  144. m_listSmplMgrs.push_back(pSmplMsrResultMgrNew);
  145. }
  146. }
  147. CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrById(int a_nIndex)
  148. {
  149. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  150. {
  151. return nullptr;
  152. }
  153. return m_listSmplMgrs[a_nIndex];
  154. }
  155. CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrByPathName(CString a_strPathName)
  156. {
  157. a_strPathName.Trim();
  158. if (a_strPathName.IsEmpty())
  159. {
  160. return nullptr;
  161. }
  162. auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
  163. if (itr == m_listSmplMgrs.end())
  164. {
  165. return nullptr;
  166. }
  167. return *itr;
  168. }
  169. CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrByFileName(CString a_strFileName)
  170. {
  171. a_strFileName.Trim();
  172. if (a_strFileName.IsEmpty())
  173. {
  174. return nullptr;
  175. }
  176. auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strFileName](CSmplMsrResultFileMgrPtr p)
  177. {
  178. CString strDataSource = COTSHelper::GetFileName(p->GetPathName());
  179. return strDataSource.CompareNoCase(a_strFileName) == 0;
  180. });
  181. if (itr == m_listSmplMgrs.end())
  182. {
  183. return nullptr;
  184. }
  185. return *itr;
  186. }
  187. BOOL CReportMgr::DeleteASmplMsrResultMgrById(int a_nIndex)
  188. {
  189. // check the index
  190. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  191. {
  192. // invalid input sample index
  193. LogErrorTrace(__FILE__, __LINE__, _T("DeleteSampleByIndex::input sample index"));
  194. return a_nIndex;
  195. }
  196. // calculate new working sample index
  197. int nNewWorkingSampeIndex;
  198. if (a_nIndex < m_nWorkingSampeIndex)
  199. {
  200. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  201. }
  202. else if (a_nIndex > m_nWorkingSampeIndex)
  203. {
  204. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  205. }
  206. else
  207. {
  208. // deleting working sample.
  209. if (a_nIndex == (int)m_listSmplMgrs.size() - 1)
  210. {
  211. // this is the last sample, select the above sample as working sample
  212. // if this is only sample in the list working sample index will be -1;
  213. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  214. }
  215. else
  216. {
  217. // select next sample as working sample
  218. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  219. }
  220. }
  221. // delete the sample
  222. m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
  223. // reset working sample index
  224. m_nWorkingSampeIndex = nNewWorkingSampeIndex;
  225. // reset property parameters
  226. ResetPropertyParams();
  227. // ok, return TRUE
  228. return TRUE;
  229. }
  230. BOOL CReportMgr::DeleteASmplMsrResultMgrByPathName(CString a_strPathName)
  231. {
  232. // check report project file pointer
  233. a_strPathName.Trim();
  234. if (a_strPathName.IsEmpty())
  235. {
  236. return FALSE;
  237. }
  238. auto itrObj = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strPathName](CSmplMsrResultFileMgrPtr p) { return p->GetPathName().CompareNoCase(a_strPathName) == 0; });
  239. if (itrObj == m_listSmplMgrs.end())
  240. {
  241. // failed to find sample measure result file
  242. LogErrorTrace(__FILE__, __LINE__, _T("DeleteASmplMsrResultMgrByPathName: failed to find sample measure result file."));
  243. return FALSE;
  244. }
  245. m_listSmplMgrs.erase(itrObj);
  246. // reset property parameters
  247. ResetPropertyParams();
  248. // ok, return TRUE
  249. return TRUE;
  250. }
  251. BOOL CReportMgr::EditASmplMsrResultMgrById(int a_nIndex, CSmplMsrResultFileMgrPtr a_pSmpFileMgr)
  252. {
  253. ASSERT(a_pSmpFileMgr);
  254. if (!a_pSmpFileMgr)
  255. {
  256. LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById:invalid sample measure result manager pointer."));
  257. return FALSE;
  258. }
  259. // check if the working sample index
  260. if (a_nIndex < 0 || a_nIndex >= (int)m_listSmplMgrs.size())
  261. {
  262. LogErrorTrace(__FILE__, __LINE__, _T("EditASmplMsrResultMgrById: invalid sample measure result manager index."));
  263. // invalid working sample index
  264. return FALSE;
  265. }
  266. m_listSmplMgrs.erase(m_listSmplMgrs.begin() + a_nIndex);
  267. m_listSmplMgrs.insert(m_listSmplMgrs.begin() + a_nIndex, a_pSmpFileMgr);
  268. return TRUE;
  269. }
  270. CSmplMsrResultFileMgrPtr CReportMgr::GetWorkingSmplMsrReslMgr()
  271. {
  272. // check if the working sample index
  273. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSmplMgrs.size())
  274. {
  275. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSmplMsrReslMgr: invalid working sample measure result manager index."));
  276. // invalid working sample index
  277. return FALSE;
  278. }
  279. return GetASmplMsrResultMgrById(m_nWorkingSampeIndex);
  280. }
  281. CString CReportMgr::GetWorkingSampleName()
  282. {
  283. CString strRet = _T("");
  284. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = GetWorkingSmplMsrReslMgr();
  285. ASSERT(pSmplMsrResultFileMgr);
  286. if (!pSmplMsrResultFileMgr)
  287. {
  288. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result manager."));
  289. return _T("");
  290. }
  291. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  292. ASSERT(pSmplMsrResultFile);
  293. if (!pSmplMsrResultFile)
  294. {
  295. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample measure result file."));
  296. return _T("");
  297. }
  298. COTSSamplePtr pSample = pSmplMsrResultFile->GetSample();
  299. ASSERT(pSample);
  300. if (!pSample)
  301. {
  302. LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingSampleName: invalid working sample."));
  303. return _T("");
  304. }
  305. strRet = pSample->GetName();
  306. return strRet;
  307. }
  308. BOOL CReportMgr::SetWorkingSmplMsrReslMgr(CSmplMsrResultFileMgrPtr a_pSmplMsrResultMgr)
  309. {
  310. ASSERT(a_pSmplMsrResultMgr);
  311. if (!a_pSmplMsrResultMgr)
  312. {
  313. LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: invalid sample measure result manager pointer."));
  314. return FALSE;
  315. }
  316. if (!EditASmplMsrResultMgrById(m_nWorkingSampeIndex, a_pSmplMsrResultMgr))
  317. {
  318. LogErrorTrace(__FILE__, __LINE__, _T("SetWorkingSmplMsrReslMgr: can't edit working sample measure result file."));
  319. return FALSE;
  320. }
  321. return TRUE;
  322. }
  323. // grid computing
  324. CGridDatasList CReportMgr::GridDataTransfer(CPropParamPtr thePropParam)
  325. {
  326. CGridDatasList listGridData;
  327. listGridData.clear();
  328. CGBCalculate GBCal(this);
  329. CALCULATE_TABLE_TYPE nCalTableType = thePropParam->GetCalTableType();
  330. switch (nCalTableType)
  331. {
  332. case CALCULATE_TABLE_TYPE::GB_Method1:
  333. listGridData = GBCal.GetGBInclusion();
  334. break;
  335. case CALCULATE_TABLE_TYPE::GB_Method2:
  336. listGridData = GBCal.GetGBInclusion();
  337. break;
  338. case CALCULATE_TABLE_TYPE::ASTM:
  339. listGridData = GBCal.GetGBInclusion();
  340. break;
  341. case CALCULATE_TABLE_TYPE::DIN:
  342. listGridData = GBCal.GetGBInclusion();
  343. break;
  344. default:
  345. break;
  346. }
  347. return listGridData;
  348. }
  349. // protected
  350. // get data source name list
  351. std::vector<CString> CReportMgr::GetDataSourceNamesList()
  352. {
  353. std::vector<CString> listDataSourceNames;
  354. CString strComSourceName = _T("");
  355. int nComNum = 0;
  356. for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
  357. {
  358. // sample measure result file
  359. CString strFilePathName = pSmplMsrResultFileMgr->GetPathName();
  360. // get data source name
  361. CString strDataSource = COTSHelper::GetFileName(strFilePathName);
  362. // get compound source name
  363. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  364. ASSERT(pSmplMsrResultFile);
  365. if (!pSmplMsrResultFile)
  366. {
  367. LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
  368. break;
  369. }
  370. BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
  371. if (bSwitch)
  372. {
  373. strComSourceName += strDataSource + _T("+");
  374. nComNum++;
  375. }
  376. // add data source name into the list
  377. listDataSourceNames.push_back(strDataSource);
  378. }
  379. if (nComNum > 1)
  380. {
  381. //listDataSourceNames.push_back(strComSourceName);
  382. strComSourceName.TrimRight(_T("+"));//去掉最后的+号
  383. listDataSourceNames.insert(listDataSourceNames.begin(), strComSourceName);
  384. }
  385. return listDataSourceNames;
  386. }
  387. std::vector<int> CReportMgr::GetDataSourcePosList()
  388. {
  389. std::vector<int> listDataSourcePos;
  390. if (!IsHaveMultiDataSource())
  391. {
  392. return listDataSourcePos;
  393. }
  394. int nPos = -1;
  395. for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
  396. {
  397. nPos++;
  398. // get compound source name
  399. CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
  400. ASSERT(pSmplMsrResultFile);
  401. if (!pSmplMsrResultFile)
  402. {
  403. LogErrorTrace(__FILE__, __LINE__, _T("GetDataSourceNamesList: Can't get sample result file pointer."));
  404. break;
  405. }
  406. BOOL bSwitch = pSmplMsrResultFile->GetSwitch();
  407. if (bSwitch)
  408. {
  409. listDataSourcePos.push_back(nPos);
  410. }
  411. }
  412. return listDataSourcePos;
  413. }
  414. // get property parameter
  415. COTSParticleList CReportMgr::GetAnalysisParticleList(CString a_DataSourceName)
  416. {
  417. COTSParticleList listParticleAll;
  418. // compound sample measure result files
  419. CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
  420. if (!pSmplMsrResultFileMgr->ComputeParticleList())
  421. {
  422. LogErrorTrace(__FILE__, __LINE__, _T("GetAnalysisParticleList: can't get particle list."));
  423. return listParticleAll;
  424. }
  425. listParticleAll = pSmplMsrResultFileMgr->GetParticleList();
  426. return listParticleAll;
  427. }
  428. //CPosXraysList CReportMgr::GetAnalysisXrayList(CString a_DataSourceName)
  429. //{
  430. // CPosXraysList listAnalysisXray;
  431. // CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgr = this->GetASmplMsrResultMgrByFileName(a_DataSourceName);
  432. // pSmplMsrResultFileMgr->GetOTSFldMgrListAndAnalysisXrayList();
  433. // // should first read x ray data from data base.
  434. // listAnalysisXray = pSmplMsrResultFileMgr->GetAnalysisXray();
  435. // return listAnalysisXray;
  436. //}
  437. //判断该列是否要显示
  438. BOOL CReportMgr::EstimateShowColumn(CString a_strColName)
  439. {
  440. CString str_Area_Enum = "Area";
  441. CString str_MaxDiameter_Enum = "MaxDiameter";
  442. CString str_MinDiameter_Enum = "MinDiameter";
  443. CString str_DiameterRatio_Enum = "DiameterRatio";
  444. CString str_EquivalentCircleDiameter_Enum = "EquivalentCircleDiameter";
  445. CString str_FerretDiameter_Enum = "FerretDiameter";
  446. CString str_Area_CN = "颗粒面积";
  447. CString str_MaxDiameter_CN = "最长直径";
  448. CString str_MinDiameter_CN = "最短直径";
  449. CString str_DiameterRatio_CN = "长短直径比";
  450. CString str_EquivalentCircleDiameter_CN = "等效圆直径";
  451. CString str_FerretDiameter_CN = "费雷特直径";
  452. //最后再根据设置默认显示列名,对不需要显示的列进行屏蔽
  453. CString s_DefaultComputedColName = m_rptparamfile->GetDefaultComputedColName();
  454. if (a_strColName.Find(str_Area_CN, 0) > -1 || a_strColName.Find(str_MaxDiameter_CN, 0) > -1 ||
  455. a_strColName.Find(str_MinDiameter_CN, 0) > -1 || a_strColName.Find(str_DiameterRatio_CN, 0) > -1 ||
  456. a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1 || a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
  457. {
  458. //面积
  459. if (s_DefaultComputedColName.Find(str_Area_Enum) > -1 && a_strColName.Find(str_Area_CN, 0) > -1)
  460. {
  461. return true;
  462. }
  463. //最长直径
  464. if (s_DefaultComputedColName.Find(str_MaxDiameter_Enum) > -1 && a_strColName.Find(str_MaxDiameter_CN, 0) > -1)
  465. {
  466. return true;
  467. }
  468. //最短直径
  469. if (s_DefaultComputedColName.Find(str_MinDiameter_Enum) > -1 && a_strColName.Find(str_MinDiameter_CN, 0) > -1)
  470. {
  471. return true;
  472. }
  473. //长短直径比
  474. if (s_DefaultComputedColName.Find(str_DiameterRatio_Enum) > -1 && a_strColName.Find(str_DiameterRatio_CN, 0) > -1)
  475. {
  476. return true;
  477. }
  478. //等效圆直径
  479. if (s_DefaultComputedColName.Find(str_EquivalentCircleDiameter_Enum) > -1 && a_strColName.Find(str_EquivalentCircleDiameter_CN, 0) > -1)
  480. {
  481. return true;
  482. }
  483. //费雷特直径
  484. if (s_DefaultComputedColName.Find(str_FerretDiameter_Enum) > -1 && a_strColName.Find(str_FerretDiameter_CN, 0) > -1)
  485. {
  486. return true;
  487. }
  488. return false;
  489. }
  490. return true;
  491. }
  492. BOOL CReportMgr::IsHaveMultiDataSource()
  493. {
  494. int nMultiCount = 0;
  495. for (auto SmplMgr : m_listSmplMgrs)
  496. {
  497. CSmplMsrResultFilePtr pSmpl = SmplMgr->GetSmplMsrResultFile();
  498. if (pSmpl->GetSwitch())
  499. {
  500. nMultiCount++;
  501. }
  502. }
  503. if (nMultiCount > 1)
  504. {
  505. return TRUE;
  506. }
  507. return FALSE;
  508. }
  509. // get undefined element list from particle list
  510. CElementChemistriesList CReportMgr::GetUndefinedElementList(COTSParticleList a_listParticle, CPosXraysList a_listXray)
  511. {
  512. CElementChemistriesList listElementChemistry;
  513. // safety check to get xray data and element number
  514. int nXraySize = (int)a_listXray.size();
  515. int nParticleSize = (int)a_listParticle.size();
  516. if (nParticleSize > nXraySize)
  517. {
  518. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get xray number is not enough."));
  519. return listElementChemistry;
  520. }
  521. CElementAreaList listElementArea;
  522. // get element area
  523. double dTotalArea = 0;
  524. for (auto pParticle : a_listParticle)
  525. {
  526. int nXrayId = pParticle->GetAnalysisId();
  527. if (nXrayId < 0 || nXrayId >(int) a_listXray.size())
  528. {
  529. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: get wrong xray id."));
  530. return listElementChemistry;
  531. }
  532. int nFieldId = pParticle->GetFieldId();
  533. auto itr = std::find_if(a_listXray.begin(), a_listXray.end(), [nXrayId, nFieldId](CPosXrayPtr p) { return ((p->GetScanFieldId() == nFieldId) && (p->GetIndex() == nXrayId)); });
  534. if (itr == a_listXray.end())
  535. {
  536. LogErrorTrace(__FILE__, __LINE__, _T("GetUndefinedElementList: can't find x-ray."));
  537. return listElementChemistry;
  538. }
  539. CPosXrayPtr pXray = *itr;
  540. // remove Fe
  541. CElementChemistriesList listElementChemistryCurrent = pXray->GetElementQuantifyData();
  542. CElementChemistriesList listElementChemistryNew1 = CPosXray::RemoveFe(listElementChemistryCurrent);
  543. CElementChemistriesList listElementChemistryNew = CPosXray::RemoveC(listElementChemistryNew1);
  544. double t = 0;
  545. CElementChemistriesList listElementChemistryG1;
  546. for (auto pElementChemistry : listElementChemistryNew)
  547. {
  548. t += pElementChemistry->GetPercentage();
  549. }
  550. if (t == 0)
  551. {
  552. continue;
  553. }
  554. for (auto pElementChemistry : listElementChemistryNew)
  555. {
  556. double dPecent = 100.0 *pElementChemistry->GetPercentage() / t;
  557. CElementChemistryPtr pElementNew = CElementChemistryPtr(new CElementChemistry(*pElementChemistry.get()));
  558. pElementNew->SetPercentage(dPecent);
  559. listElementChemistryG1.push_back(pElementNew);
  560. }
  561. CElementAreaPtr pElementArea = CElementAreaPtr(new CElementArea());
  562. double dArea = pParticle->GetActualArea();
  563. pElementArea->SetArea(dArea);
  564. pElementArea->SetElementList(listElementChemistryG1);
  565. listElementArea.push_back(pElementArea);
  566. dTotalArea += dArea;
  567. }
  568. for (auto pElementArea : listElementArea)
  569. {
  570. CElementChemistriesList listElementChemistryCurrent = pElementArea->GetElementList();
  571. for (auto pElement : listElementChemistryCurrent)
  572. {
  573. CString strName = pElement->GetName();
  574. double dPercentNorm = 1.0;
  575. auto itr = std::find_if(listElementChemistry.begin(), listElementChemistry.end(), [strName](CElementChemistryPtr p) { return p->GetName().CompareNoCase(strName) == 0; });
  576. if (itr == listElementChemistry.end())
  577. {
  578. double dArea = pElementArea->GetArea();
  579. double dPercent = pElement->GetPercentage();
  580. dPercentNorm = dArea * dPercent / dTotalArea;
  581. }
  582. else
  583. {
  584. CElementChemistryPtr pElementChemistry = *itr;
  585. double dAreaOld = pElementChemistry->GetPercentage() * dTotalArea * 0.01;
  586. double dArea = pElementArea->GetArea();
  587. double dPercent = pElement->GetPercentage();
  588. dPercentNorm = 100 * (0.01 * dArea * dPercent + dAreaOld) / dTotalArea;
  589. listElementChemistry.erase(itr);
  590. }
  591. CElementChemistryPtr pElement = CElementChemistryPtr(new CElementChemistry());
  592. pElement->SetName(strName);
  593. pElement->SetPercentage(dPercentNorm);
  594. listElementChemistry.push_back(pElement);
  595. }
  596. }
  597. return listElementChemistry;
  598. }
  599. }