|
@@ -21,7 +21,7 @@ namespace OTSMODEL {
|
|
|
{
|
|
|
|
|
|
m_listPropParams.clear();
|
|
|
- m_listSmplMgrs.clear();
|
|
|
+ m_mapSmplMgrs.clear();
|
|
|
|
|
|
m_nWorkingSampeIndex = -1;
|
|
|
|
|
@@ -52,7 +52,7 @@ namespace OTSMODEL {
|
|
|
{
|
|
|
return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::IMAGE];
|
|
|
}
|
|
|
- CPropParamPtr CReportMgr::GetPropertyParamGrid()
|
|
|
+ CPropParamPtr CReportMgr::GetPropertyParamForGrid()
|
|
|
{
|
|
|
return m_listPropParams[(int)DISPLAY_PICTURE_TYPE::TABLE];
|
|
|
}
|
|
@@ -139,36 +139,38 @@ namespace OTSMODEL {
|
|
|
_CrtSetDbgFlag(tmpFlag);*/
|
|
|
|
|
|
//_CrtSetBreakAlloc(351380);
|
|
|
-
|
|
|
+ if (m_mapSmplMgrs.find(a_strPathName) != m_mapSmplMgrs.end())//already exist;
|
|
|
+ {
|
|
|
+ //m_mapSmplMgrs[a_strPathName].
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
CSmplMsrResultFileMgrPtr pSmplMsrResultFileMgrPtr = CSmplMsrResultFileMgrPtr(new CSmplMsrResultFileMgr(a_strPathName));
|
|
|
|
|
|
+ if (!COTSFileSys::Exists(a_strPathName))
|
|
|
+ {
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, "result file not exist!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// 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);
|
|
|
-
|
|
|
+ m_mapSmplMgrs[a_strPathName]=pSmplMsrResultFileMgrPtr;
|
|
|
+
|
|
|
|
|
|
// set working sample
|
|
|
- m_nWorkingSampeIndex = (int)m_listSmplMgrs.size() - 1;
|
|
|
+ m_nWorkingSampeIndex = m_mapSmplMgrs.size();
|
|
|
|
|
|
// reset property parameters
|
|
|
ResetPropertyParams();
|
|
@@ -191,19 +193,11 @@ namespace OTSMODEL {
|
|
|
CSmplMsrResultFilePtr pSmplMsrResultFileNew = CSmplMsrResultFilePtr(new CSmplMsrResultFile(pSmplMsrResultFile.get()));
|
|
|
pSmplMsrResultMgrNew->SetSmplMsrResultFile(pSmplMsrResultFileNew);
|
|
|
|
|
|
- m_listSmplMgrs.push_back(pSmplMsrResultMgrNew);
|
|
|
+ m_mapSmplMgrs[strPathname]=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();
|
|
@@ -211,12 +205,12 @@ namespace OTSMODEL {
|
|
|
{
|
|
|
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())
|
|
|
+ auto itr = m_mapSmplMgrs.find(a_strPathName);
|
|
|
+ if (itr == m_mapSmplMgrs.end())
|
|
|
{
|
|
|
return nullptr;
|
|
|
}
|
|
|
- return *itr;
|
|
|
+ return itr->second;
|
|
|
}
|
|
|
CSmplMsrResultFileMgrPtr CReportMgr::GetASmplMsrResultMgrByFileName(CString a_strFileName)
|
|
|
{
|
|
@@ -226,184 +220,22 @@ namespace OTSMODEL {
|
|
|
return nullptr;
|
|
|
}
|
|
|
|
|
|
- auto itr = std::find_if(m_listSmplMgrs.begin(), m_listSmplMgrs.end(), [a_strFileName](CSmplMsrResultFileMgrPtr p)
|
|
|
+ auto itr = std::find_if(m_mapSmplMgrs.begin(), m_mapSmplMgrs.end(), [a_strFileName](std::pair<CString, CSmplMsrResultFileMgrPtr> p)
|
|
|
{
|
|
|
- CString strDataSource = COTSHelper::GetFileName(p->GetPathName());
|
|
|
+ // lambda predicate
|
|
|
+ CString strDataSource = COTSHelper::GetFileName(p.second->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)
|
|
|
+ if (itr == m_mapSmplMgrs.end())
|
|
|
{
|
|
|
- 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("");
|
|
|
+ return nullptr;
|
|
|
}
|
|
|
-
|
|
|
- strRet = pSample->GetName();
|
|
|
-
|
|
|
- return strRet;
|
|
|
+ return itr->second;
|
|
|
}
|
|
|
|
|
|
- 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
|
|
@@ -458,16 +290,16 @@ namespace OTSMODEL {
|
|
|
CString strComSourceName = _T("");
|
|
|
int nComNum = 0;
|
|
|
|
|
|
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
|
|
|
+ for (auto pSmplMsrResultFileMgr : m_mapSmplMgrs)
|
|
|
{
|
|
|
// sample measure result file
|
|
|
- CString strFilePathName = pSmplMsrResultFileMgr->GetPathName();
|
|
|
+ CString strFilePathName = pSmplMsrResultFileMgr.second->GetPathName();
|
|
|
|
|
|
// get data source name
|
|
|
CString strDataSource = COTSHelper::GetFileName(strFilePathName);
|
|
|
|
|
|
// get compound source name
|
|
|
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
|
|
|
+ CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr.second->GetSmplMsrResultFile();
|
|
|
ASSERT(pSmplMsrResultFile);
|
|
|
if (!pSmplMsrResultFile)
|
|
|
{
|
|
@@ -507,12 +339,12 @@ namespace OTSMODEL {
|
|
|
|
|
|
int nPos = -1;
|
|
|
|
|
|
- for (auto pSmplMsrResultFileMgr : m_listSmplMgrs)
|
|
|
+ for (auto pSmplMsrResultFileMgr : m_mapSmplMgrs)
|
|
|
{
|
|
|
nPos++;
|
|
|
|
|
|
// get compound source name
|
|
|
- CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr->GetSmplMsrResultFile();
|
|
|
+ CSmplMsrResultFilePtr pSmplMsrResultFile = pSmplMsrResultFileMgr.second->GetSmplMsrResultFile();
|
|
|
ASSERT(pSmplMsrResultFile);
|
|
|
if (!pSmplMsrResultFile)
|
|
|
{
|
|
@@ -552,17 +384,7 @@ namespace OTSMODEL {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //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;
|
|
|
|
|
|
- //}
|
|
|
|
|
|
|
|
|
//判断该列是否要显示
|
|
@@ -634,9 +456,9 @@ namespace OTSMODEL {
|
|
|
BOOL CReportMgr::IsHaveMultiDataSource()
|
|
|
{
|
|
|
int nMultiCount = 0;
|
|
|
- for (auto SmplMgr : m_listSmplMgrs)
|
|
|
+ for (auto SmplMgr : m_mapSmplMgrs)
|
|
|
{
|
|
|
- CSmplMsrResultFilePtr pSmpl = SmplMgr->GetSmplMsrResultFile();
|
|
|
+ CSmplMsrResultFilePtr pSmpl = SmplMgr.second->GetSmplMsrResultFile();
|
|
|
if (pSmpl->GetSwitch())
|
|
|
{
|
|
|
nMultiCount++;
|