| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030 |
- using OTSCLRINTERFACE;
- using OTSDataType;
- using OTSModelSharp.DTLBase;
- using OTSModelSharp.ServiceInterface;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
- namespace OTSModelSharp
- {
- class CSmplMsrResult
- {
- //----------------定义----------------------
- protected static NLog.Logger logger = null;
- // working folder string
- string m_strWorkingFolder;
- string m_strSampleWorkingFolder;
- string m_strFieldFileSubFolder;
- private string m_strBSEImageFileFolder;
- private string m_strDBFileFolder;
- // pathname
- string m_strRstFileName;
- string m_strdbPathName;
- CIncAFileMgr m_DBFileMgr ;
-
- public string SMPL_MSR_RESULT_FILE_EXT = ".rst";
- // fields file sub-directory string
- public string SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER = "FIELD_FILES";
- public string DBFILE_NAME = "Inclusion.db";
-
- public string SMPL_MSR_RESULT_FILE_FILTER = ("Sample Measure Result Files (*.rst)|*.rst||");
- // BSE file name
- public string SMPL_MSR_RESULT_FIELDS_BSE = ("Field");
- // search x-ray file name
- public string SMPL_MSR_RESULT_SEARCH_X_RAY_FILE = ("SearchXray.db");
- //----------全局定义------------------
- // sample measure result file mark
- public int SMPL_MSR_RESULT_FILE_MARK = 'S' + 'M' + 'P' + 'L' + 'M' + 'S' + 'R' + 'R' + 'E' + 'S' + 'U' + 'L' + 'T';
- // sample measure result file version
- public string SMPL_MSR_RESULT_FILE_VERSION = ("2.0.0");
- // sample measure result file extension
- //----------定义----------------------
- // file version string
- string m_strFileVersion;
- // SEM sample stage
- CSEMStageData m_pSEMStageData;
- // sample stage
- CStage m_pStage;
- //CSEMStageDataPtr m_pSEMData;
- CSEMDataGnr m_pSEMData;
- // sample setting
- COTSSample m_pSample;
- // switch
- bool m_bSwitch;
-
- public CIncAFileMgr DBFileMgr { get => m_DBFileMgr; set => m_DBFileMgr = value; }
- //----------------public-----------------
- public CSmplMsrResult()
- {
- Init();
- m_pSample = new COTSSample();
-
- }
- protected void Duplicate(CSmplMsrResult a_oSource)
- {
- // initialization
- Init();
- m_pSample = new COTSSample();
- // copy data over
- // file version string
- m_strFileVersion = a_oSource.m_strFileVersion;
- // SEM sample stage
- m_pSEMStageData = a_oSource.m_pSEMStageData;
- // sample stage
- m_pStage = a_oSource.m_pStage;
- // SEM condition??
- //CSEMStageDataPtr m_pSEMData;
- m_pSEMData = a_oSource.m_pSEMData;
- // sample setting
- m_pSample = a_oSource.m_pSample;
- // switch
- m_bSwitch = a_oSource.m_bSwitch;
- // fields
- m_pSample.GetFieldsData().Clear();
- foreach (COTSFieldData pFieldData in a_oSource.m_pSample.GetFieldsData())
- {
- COTSFieldData pFieldDataNew = pFieldData;
- m_pSample.GetFieldsData().Add(pFieldDataNew);
- }
- }
- public List<COTSFieldData> GetFieldData()
- {
- return m_pSample.GetFieldsData();
- //m_pSample.GetFieldsData()
- }
- public CSmplMsrResult(string measureWorkingFolder,COTSSample a_pSample)
- {
- Init();
- logger = NLog.LogManager.GetCurrentClassLogger();
-
- m_pSample = a_pSample;
-
- m_strWorkingFolder = measureWorkingFolder;
- m_strSampleWorkingFolder = measureWorkingFolder + "\\" + a_pSample.GetName();
- m_strFieldFileSubFolder = m_strSampleWorkingFolder + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER;
- m_strBSEImageFileFolder = m_strFieldFileSubFolder;
- m_strDBFileFolder = m_strFieldFileSubFolder;
- m_strRstFileName = m_strSampleWorkingFolder + "\\" + a_pSample.GetName() + SMPL_MSR_RESULT_FILE_EXT;
- m_strdbPathName = m_strFieldFileSubFolder + "\\" + DBFILE_NAME;
-
- m_DBFileMgr = new CIncAFileMgr(m_strdbPathName);
- }
- protected void Init()
- {
-
- m_strFileVersion = ("");
-
- m_pSEMStageData = new CSEMStageData();
-
- m_pStage = new CStage();
-
- m_pSEMData = new CSEMDataGnr();
-
- m_bSwitch = false;
-
- }
- protected void Cleanup()
- {
- m_pSample.GetFieldsData().Clear();
- }
- public string GetFileVersion()
- {
- return m_strFileVersion;
- }
- public void SetFileVersion(string a_strFileVersion)
- {
- m_strFileVersion = a_strFileVersion;
- }
- public COTSSample GetSample()
- {
- return m_pSample;
- }
- public void SetSample(COTSSample a_pSample)
- {
- if (a_pSample != null)
- {
- return;
- }
- m_pSample = a_pSample;
- }
- public CSEMStageData GetSEMStageData()
- {
- return m_pSEMStageData;
- }
- public void SetSEMStageData(CSEMStageData a_pSEMStageData)
- {
-
- m_pSEMStageData = a_pSEMStageData;
- }
- // sample stage
- public CStage GetStage()
- {
- return m_pStage;
- }
- public void SetStage(CStage a_pStage)
- {
- if (a_pStage != null)
- {
- return;
- }
- m_pStage = a_pStage;
- }
- // SEM condition
- public CSEMDataGnr GetSEMStage()
- {
- return m_pSEMData;
- }
- public void SetSEMStage(CSEMDataGnr a_pSEMData)
- {
- if (a_pSEMData != null)
- {
- return;
- }
- m_pSEMData = a_pSEMData;
- }
- public bool GetSwitch()
- {
- return m_bSwitch;
- }
- public void SetSwitch(bool a_bSwitch)
- {
- m_bSwitch = a_bSwitch;
- }
- public void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- xInt xnFileMark = new xInt();
- xString xnVersion = new xString();
- xBool xbSwitch = new xBool();
- Collection<Slo> xfields = new Collection<Slo>();
- Slo slo = new Slo();
- slo.Register("FileMark", xnFileMark);
- slo.Register("Version", xnVersion);
- slo.Register("Switch", xbSwitch);
- slo.Register("SEMStageData", m_pSEMStageData);
- slo.Register("Stage", m_pStage);
- slo.Register("SEMData", m_pSEMData);
- slo.Register("Sample", m_pSample);
- slo.Register("Fields", xfields);
- if (isStoring)
- {
- xnFileMark.AssignValue(SMPL_MSR_RESULT_FILE_MARK);
- xnVersion.AssignValue(SMPL_MSR_RESULT_FILE_VERSION);
- xbSwitch.AssignValue(m_bSwitch);
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_bSwitch = xbSwitch.value();
- m_strFileVersion = xnVersion.value();
-
- }
- }
- private bool InitFolders()
- {
-
- if (!Exists(m_strSampleWorkingFolder))
- {
- // the working directory is not exit, create it
- if (!CreateFolder(m_strSampleWorkingFolder))
- {
- return false;
- }
-
- }
-
- // check if the field files directory exists
- if (!Exists(m_strFieldFileSubFolder))
- {
- // field files directory exists not exists, creates it
- if (!CreateFolder(m_strFieldFileSubFolder))
- {
- // failed to create the field files directory
- return false;
- }
- }
-
- return true;
- }
-
- // creates a folder.
- private bool CreateFolder(string a_strFolder)
- {
- // make sure the folder name string are not empty
- string strFolder = a_strFolder;
- strFolder.Trim();
- if (strFolder=="")
- {
- return false;
- }
- // if the folder exist?
- if (Exists(strFolder))
- {
- return true;
- }
-
- Directory.CreateDirectory(strFolder);
- bool bRet = true;
- // return folder create result
- return bRet;
- }
- // check if the file exists or not
- private bool Exists(string a_sPath)
- {
- return Directory.Exists(a_sPath);
-
- }
-
- // Load
- public bool Load(String a_strPathname /*= _T("")*/)
- {
- a_strPathname.Trim();
- if (a_strPathname == "")
- {
-
- FolderBrowserDialog FileDialog = new FolderBrowserDialog();//创建一个文件对话框
- if (FileDialog.ShowDialog() != DialogResult.OK)
- {
- // user canceled loading
- logger.Info("Load: user canceled loading.");
- return false;
- }
- a_strPathname = FileDialog.SelectedPath;
- }
- // get path of the pathname
- String strFilePath =a_strPathname;
-
- // field file sub folder string
- m_strFieldFileSubFolder = strFilePath + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
-
- // check if the field file sub folder exists
- if (!Exists(m_strFieldFileSubFolder))
- {
- // field files folder doesn't exist
- return false;
- }
- // file version
- String strFileVersion = m_strFileVersion;
- uint nFileVersion = GetVersionFromString(strFileVersion);
- if (nFileVersion == 0)
- {// invalid file
- return false;
- }
- // sample measure result file
-
- SetPathFileName(a_strPathname);
- this.LoadFieldDataFromDB(a_strPathname);
- // ok, return TRUE
- return true;
- }
- // Get file versio
- // File Version should be format <Major version>.<Minor version>.<Build version>, like 1.2.3
- public uint GetVersionFromString(string a_sVersion)
- {
- int nMajorVersion = 0;
- int nMinorVersion = 0;
- int nBuildVersion = 0;
- uint nVersion = 0;
- if (GetMajorVersionFromString(a_sVersion, nMajorVersion) &&
- GetMinorVersionFromString(a_sVersion, nMinorVersion) &&
- GetBuildVersionFromString(a_sVersion, nBuildVersion))
- {
- nVersion = (uint)nMajorVersion * 10000 + (uint)nMinorVersion * 100 + (uint)nBuildVersion;
- }
- return nVersion;
- }
- public bool GetMinorVersionFromString(string a_sVersion, int a_nVersion)
- {
- // version string
- String strVersion = a_sVersion;
- // get major file version string position first
- int nPosFirst = strVersion.IndexOf('.');
- if (nPosFirst < 0)
- {
- // failed to find major file version string
- return false;
- }
- // get minor file version string position
- int nPosSecond = strVersion.IndexOf('.', nPosFirst + 1);
- int nStrLength = nPosSecond - nPosFirst - 1;
- if (nStrLength <= 0)
- {
- // failed to find minor file version string
- return false;
- }
- // get minor file version string
- String strMinorVersion = strVersion.Remove(nPosFirst + 1, nStrLength);
- // the minor file version string can't be empty
- strMinorVersion.Trim();
- if (strMinorVersion == "")
- {
- // failed to find minor file version string
- return false;
- }
- // convert the minor version string to minor version number
- if (!StringToInt(strMinorVersion, a_nVersion))
- {
- // failed to convert the major file version string to number
- return false;
- }
- // ok, return TRUE
- return true;
- }
- public bool GetMajorVersionFromString(string a_sVersion, int a_nVersion)
- {
- // version string
- String strVersion = a_sVersion;
- // get major file version string position
- int nPosFirst = strVersion.IndexOf('.');
- if (nPosFirst <= 0)
- {
- // failed to find major file version
- return false;
- }
- // get major file version string
- String strMajorVersion = strVersion.PadLeft(nPosFirst);
- // the major file version string can't be empty
- strMajorVersion.Trim();
- if (strMajorVersion == "")
- {
- // failed to find major file version
- return false;
- }
- // convert the major version string to major version number
- if (!StringToInt(strMajorVersion, a_nVersion))
- {
- // failed to convert the major file version string to number
- return false;
- }
- // ok, return TRUE
- return true;
- }
- public bool GetBuildVersionFromString(string a_sVersion, int a_nBuild)
- {
- // version string
- String strVersion = a_sVersion;
- // get major file version string position first
- int nPosFirst = strVersion.IndexOf('.');
- if (nPosFirst < 0)
- {
- // failed to find major file version string
- return false;
- }
- // get minor file version string position
- int nPosSecond = strVersion.IndexOf('.', nPosFirst + 1);
- if (nPosSecond < 0)
- {
- // failed to find minor file version string
- return false;
- }
- // get build string position
- int nStrLength = strVersion.Length - nPosSecond - 1;
- if (nStrLength <= 0)
- {
- // failed to find build string
- return false;
- }
- // get build string
- String strBuild = strVersion.PadRight(nStrLength);
- // build string can't be empty
- strBuild.Trim();
- if (strBuild == "")
- {
- // failed to convert the build string to number
- return false;
- }
- // convert the build string to build number
- if (!StringToInt(strBuild, a_nBuild))
- {
- // failed to convert the build string to number
- return false;
- }
- // ok, return TRUE
- return true;
- }
- // Strings to int.
- public bool StringToInt(string a_sValue, int a_nValue)
- {
- if (!IsDigitString(a_sValue))
- {
- return false;
- }
- a_nValue = Convert.ToInt32(a_sValue);
- return true;
- }
- // Determines whether is digit string.
- public bool IsDigitString(string a_sValue)
- {
- String strInt = a_sValue;
- strInt.Trim();
- if (strInt == "")
- {
- return false;
- }
- int nStart = 0;
- if (strInt[nStart] == '-')
- {
- ++nStart;
- }
- // cycle through string and check each character if it is a digit
- for (; nStart < strInt.Length; ++nStart)
- {
- if (strInt[nStart] != '-')
- {
- return false;
- }
- }
- return true;
- }
- // gets the name of the folder
- static String GetFolderName(String a_strPathName)
- {
-
- string str= FileHelper.GetFolderName(a_strPathName);
- return str.ToString();
- }
- private bool LoadFieldDataFromDB(string a_strPathname)
- {
- // check the pathname string
- a_strPathname.Trim();
- if (a_strPathname == null)
- {
- // open
- FolderBrowserDialog FileDialog = new FolderBrowserDialog();//创建一个文件对话框
- if (FileDialog.ShowDialog() != DialogResult.OK)
- {
- // user canceled loading
- logger.Info("Load: user canceled loading.");
- return false;
- }
- a_strPathname = FileDialog.SelectedPath;
- }
- // get path of the pathname
-
- string strFilePath = GetFolderName(a_strPathname);
- if (strFilePath == null)
- {
- // file path string is an empty string
- logger.Info("Load: file path string is an empty string.");
- return false;
- }
- // field file sub folder string
-
- string strFieldFileSubFolder = strFilePath + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
- // check if the field file sub folder exists
-
- if (!Exists(strFieldFileSubFolder))
- {// field files folder doesn't exist
- logger.Info("Load: field files folder doesn't exist (%s).");
- return false;
- }
- string strIncAFilename = strFieldFileSubFolder + "\\" +DBFILE_NAME;
- CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
- List<COTSFieldData> allFlds;
- allFlds = null;
- CMsrSampleStatus poMsrStatus = m_pSample.GetMsrStatus();
- CMsrDisplayResults poMsrResults = m_pSample.GetMsrResults();
- double aFldArea = m_pSample.CalculateAFieldArea();
- if (GetAllFieldsFromDB(allFlds, poMsrStatus, poMsrResults, aFldArea))
- {
- SetFieldData(allFlds);
-
- return true;
- }
- else
- {
- return false;
- }
- }
- public bool GetAllFieldsFromDB(List<COTSFieldData> allFlds, CMsrSampleStatus status, CMsrDisplayResults rst, double aFieldArea)
- {
-
- List<System.Drawing.Point> completedfld = new List<System.Drawing.Point>();
-
- m_DBFileMgr.GetIncADB().GetAllFieldsRecord(ref allFlds);
- var SegmentDB = m_DBFileMgr.GetSegmentDB();
- double msrFldsArea = 0;
-
- Dictionary<int, List<COTSParticleClr>> mapTypeParticles = new Dictionary<int, List<COTSParticleClr>>();
-
- Dictionary<string, List<COTSSegmentClr>> AllSegments = new Dictionary<string, List<COTSSegmentClr>>();
- if (SegmentDB.GetAllSegmentsRecord(AllSegments))
- {
- int nCol;
- foreach (var fld in allFlds)
- {
- int fldId = fld.GetId();
- List<COTSParticleClr> parts = fld.GetListAnalysisParticles();
- List<COTSSegmentClr> cOTSSegment = new List<COTSSegmentClr>();
- foreach (var part in parts)
- {
-
- var itr = AllSegments.Values;
- if (itr != AllSegments.Values)
- {
- COTSFeatureClr f = new COTSFeatureClr();
- f.SetSegmentsList(cOTSSegment, true);
- part.SetFeature(f);
- }
- mapTypeParticles[part.GetClassifyId()].Add(part);
- }
- completedfld.Add(fld.GetOTSPosition());
- msrFldsArea += aFieldArea;
- }
- }
- // get MsrStatus info from DB.
-
- String strTimeStart = "";
- String strTimeEnd = "";
- String strRstStatus = "";
- var m_GenInfoDB = m_DBFileMgr.GetGeneralInfoDB();
- m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
- m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(),ref strTimeEnd);
- m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(),ref strRstStatus);
- status.SetCompletedFieldsCenter(completedfld);
- status.SetCompletedFields(completedfld.Count);
- DateTime timeStart, timeEnd;
-
- timeStart = Convert.ToDateTime(strTimeStart);
- timeEnd = Convert.ToDateTime(strTimeEnd);
- status.SetStartTime(timeStart);
- status.SetEndTime(timeEnd);
- status.SetUsedTime(timeEnd - timeStart);
- status.SetStatus((OTS_MSR_SAMPLE_STATUS)Convert.ToInt32(strRstStatus));
- //get MsrResults data from map.
- List<CMsrResultItem> rstItms = new List<CMsrResultItem>();
- double allPartArea = 0;
- foreach (var typeParticles in mapTypeParticles)
- {
- CMsrResultItem rstItm = new CMsrResultItem();
- int typeNum = 0;
- double typeArea = 0;
- foreach (var p in mapTypeParticles)
- {
- typeNum += 1;
- typeArea += Convert.ToInt32(p);
- }
- rstItm.SetTypeId(Convert.ToInt32(typeParticles));
- rstItm.SetNumber((uint)typeNum);
- rstItm.SetArea((uint)typeArea);
- rstItms.Add(rstItm);
- allPartArea += typeArea;
- }
- rst.SetResultItems(rstItms);
- rst.SetMeasuredArea((uint)msrFldsArea * 1000000);
- rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
- return true;
- }
- // Save
- public bool CreateResultFiles()
- {
- InitFolders();
- XmlDocument xmlDoc = new XmlDocument();
- XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
- xmlDoc.AppendChild(xmlDeclaration);
- XmlElement rootNode = xmlDoc.CreateElement("XMLData");
- xmlDoc.AppendChild(rootNode);
-
- XmlNode root = xmlDoc.SelectSingleNode("XMLData");
-
- Serialize(true, xmlDoc, root);
- xmlDoc.Save(m_strRstFileName);
-
-
- m_DBFileMgr.InitFile();
- m_DBFileMgr.InitDataTable();
- return true;
- }
-
- public string GetFieldFileSubFolderStr()
- {
-
-
- // return field file sub folder string
- return m_strFieldFileSubFolder;
- }
- // sample measure result file
-
- // save a BSE file for a field
- public bool SaveBSEFileForAField(COTSFieldData a_pField)
- {
- if (a_pField == null)
- {
- logger.Info("SaveBSEFileForAField: invalid field data pointer.");
- return false;
- }
-
- string strBSEFilePathname = m_strSampleWorkingFolder + "\\" +SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
- // save BSE file for the field
- CBSEImgClr pBSEImage = a_pField.GetBSEImage();
- CBSEImageFileMgr pBSEImgFileMgr = new CBSEImageFileMgr();
- pBSEImgFileMgr.SetBSEImg(pBSEImage);
- pBSEImgFileMgr.SaveIntoBitmap(strBSEFilePathname);
- // ok, return TRUE
- return true;
- }
- // save a x-ray file for a field
- public bool SaveXRayFileForAField(List<CPosXrayClr> a_pFieldXray)
- {
-
- string strIncAFilename = m_strDBFileFolder + "\\" + DBFILE_NAME;
- // save x-ray file for the field
- CPosXrayDBMgr pPosXrayDBMgr = new CIncAFileMgr(strIncAFilename).GetPosXrayDBMgr();
-
- List<CPosXrayClr> listAnalysisXray = a_pFieldXray;
-
- if (!pPosXrayDBMgr.SaveXray(listAnalysisXray,true))
- {
- logger.Info("SaveXRayFileForAField: save analysis x-ray failed.");
- return false;
- }
- // ok, return TRUE
- return true;
- }
- // fields
- public COTSFieldData GetFieldById(int a_nID)
- {
- List<COTSFieldData> listFieldData = GetFieldData();
- if (a_nID < 0 || a_nID > (int)listFieldData.Count)
- {
- return null;
- }
- COTSFieldData pFieldData = listFieldData[a_nID];
- return pFieldData;
- }
- public void AddAField(COTSFieldData a_pFieldData)
- {
- m_pSample.AddFieldData(a_pFieldData);
- return ;
- }
- public void SetFieldData(List<COTSFieldData> a_listFieldData)
- {
- m_pSample.SetFieldsData(a_listFieldData);
- }
-
- public bool DeleteAFieldById(int a_nID)
- {
- List<COTSFieldData> listFieldData = GetFieldData();
- if (a_nID < 0 || a_nID > (int)listFieldData.Count)
- {
- return false;
- }
- //listFieldData.erase(listFieldData.begin() + a_nID);
- for (int i = 0; i < a_nID; i++)
- {
- listFieldData.RemoveAt(0);
- }
- return true;
- }
- // pathname
- public string GetPathFileName()
- {
- return m_strRstFileName;
- }
- public string GetDBPathName()
- {
- return m_strdbPathName;
- }
- public void SetPathFileName(string PathName)
- {
- m_strRstFileName = PathName;
- }
- // set sample
-
- // set SEM general data
- public void SetSEMGnr(CSEMDataGnr a_pSEMGnr)
- {
- //ASSERT(a_pSEMGnr);
- if (a_pSEMGnr == null)
- {
- logger.Info("input a invalid SEM general data pointer.");
- return;
- }
- m_pSEMData= a_pSEMGnr;
- }
- // get id for a new field
- public int GetIdForANewField()
- {
- List<COTSFieldData> listFieldData = GetFieldData();
- // new field id
- int nNewFieldId= listFieldData.Count;
-
-
- bool bUnit = false;
- do
- {
- bool iffound = false;
- COTSFieldData cOTSFieldData;
- for (int i = 0; i < listFieldData.Count; i++)
- {
- cOTSFieldData = listFieldData[i];
- if (cOTSFieldData.GetId() == nNewFieldId)
- {
- iffound = true;
- }
- }
- if (iffound == true)
- {
- ++nNewFieldId;
- }
- else
- {
- break;
- }
- } while (true);
-
-
- return nNewFieldId;
- }
- // set SEMStageData
- // set SEMStage
- public void SetSEMStage(CStage a_pStage)
- {
- //ASSERT(a_pStage);
- if (a_pStage == null)
- {
- logger.Info("input a invalid stage pointer.");
- return;
- }
-
- m_pStage= a_pStage;
- }
- // according to a sample result file get a list of OTSFieldMgr
- //public List<COTSFieldData> GetOTSFldMgrListAndAnalysisXrayList()
- //{
-
-
- // //Get FieldDataList
- // List<COTSFieldData> listFieldData =GetFieldData();
- // int nFieldNum = (int)listFieldData.Count;
-
- // // get field number
- // foreach (COTSFieldData pFieldData in listFieldData)
- // {
-
- // string strIncAFilename = m_strDBFileFolder + "\\" + DBFILE_NAME;
- // CIncAFileMgr DBFile = new CIncAFileMgr(strIncAFilename);
- // COTSFieldData pFieldMgr = new COTSFieldData();
-
- // // get FieldData
-
- // //pFieldMgr.SetOTSFieldData(pFieldData);
- // List<COTSParticleClr> listParticle = pFieldData.ListAnalysisParticles;
- // if (listParticle == null)
- // {
- // logger.Info("GetOTSFieldMgrList: there is no particle in this field.");
- // continue;
- // }
- // // get BSE
- // string strFieldFileFolder = m_strFieldFileSubFolder;
- // int nId = pFieldData.GetId();
- // string sFieldId;
- // sFieldId = nId.ToString();
- // CBSEImageFileMgr cBSEImgFileMgr = new CBSEImageFileMgr();
- // string strBSEFilePathname = strFieldFileFolder + SMPL_MSR_RESULT_FIELDS_BSE + sFieldId + cBSEImgFileMgr.BMP_IMG_FILE_EXT;
- // CBSEImageFileMgr pBSEImgFile = new CBSEImageFileMgr();
- // if (!pBSEImgFile.LoadFromBitmap(strBSEFilePathname, true) == true)
- // {
- // logger.Error("GetOTSFieldMgrList: can't load BSE File.");
-
- // AddAField(pFieldMgr);
- // continue;
- // }
- // CBSEImgClr pBSEImg = pBSEImgFile.GetBSEImg();
- // pFieldMgr.SetBSEImage(pBSEImg);
- // // get analysis X-ray list
- // CPosXrayDBMgr pPosAnalysisXrayFileMgr = DBFile.GetPosXrayDBMgr();
- // pPosAnalysisXrayFileMgr.SetHasElement(true);
- // if (!pPosAnalysisXrayFileMgr.Load(pFieldData.GetId(), true))
- // {
- // AddAField(pFieldMgr);
- // continue;
- // }
- // List<CPosXrayClr> listAnalysisXray = pPosAnalysisXrayFileMgr.GetPosXrayList();
-
- // AddAField(pFieldMgr);
- // }
- // var flddata = GetFieldData();
- // return flddata;
- //}
-
-
-
- //----------------protected-----------------
- //protected bool GetID(COTSFieldData cOTSFieldData, int a_TypeId)
- //{
- // if (cOTSFieldData.GetId() == a_TypeId)
- // {
- // return true;
- // }
- // else
- // {
- // return false;
- // }
- //}
-
- }
- }
|