COTSMsrPrjResultData.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597
  1. using OTSDataType;
  2. using OTSModelSharp.ServiceInterface;
  3. using OTSModelSharp.DTLBase;
  4. using OTSModelSharp.ImageProcess;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Forms;
  14. using static OTSDataType.otsdataconst;
  15. using System.Xml;
  16. using OTSCOMMONCLR;
  17. using OTSModelSharp.ServiceCenter;
  18. namespace OTSModelSharp
  19. {
  20. public class COTSMsrPrjResultData
  21. {
  22. // SEM stage data
  23. CSEMStageData m_pSEMStageData;
  24. //// stage
  25. CStage m_pStage;
  26. // general parameter
  27. COTSGeneralParam m_GenParam;
  28. // sample list
  29. List<COTSSample> m_listSamples = new List<COTSSample>();
  30. List<CHoleBSEImg> m_listHoleBSEImg = new List<CHoleBSEImg>();
  31. bool m_bModify;
  32. // path name
  33. String m_strPathName;
  34. // working sample index
  35. int m_nWorkingSampeIndex;
  36. const String UNTITLED_FILE_NAME = "Untitled";
  37. //以下这两个原来在SmplMsrResultFile中
  38. // fields file sub-directory string
  39. const String SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER = "FIELD_FILES";
  40. // Inclusion file name
  41. const String SMPL_MSR_RESULT_INCLUSION_FILE = "Inclusion.db";//put all the table in one db file so that report can make join query.
  42. public COTSMsrPrjResultData()
  43. {
  44. Init();
  45. }
  46. // initialization
  47. public void Init()
  48. {
  49. m_listSamples.Clear();
  50. m_listHoleBSEImg.Clear();
  51. m_bModify = false;
  52. m_strPathName = "";
  53. m_nWorkingSampeIndex = -1;
  54. }
  55. // duplication
  56. public void Duplicate(COTSMsrPrjResultData a_oSource)
  57. {
  58. // initialization
  59. Init();
  60. // copy data over
  61. m_pSEMStageData = new CSEMStageData(a_oSource.m_pSEMStageData);
  62. m_pStage = new CStage(a_oSource.m_pStage);
  63. foreach (var pHoleBSEImg in a_oSource.m_listHoleBSEImg)
  64. {
  65. CHoleBSEImg pHoleBSEImgNew = (new CHoleBSEImg(pHoleBSEImg));
  66. m_listHoleBSEImg.Add(pHoleBSEImgNew);
  67. }
  68. foreach (var pSample in a_oSource.m_listSamples)
  69. {
  70. COTSSample pSampleNew = new COTSSample();
  71. m_listSamples.Add(pSampleNew);
  72. }
  73. m_bModify = a_oSource.m_bModify;
  74. m_strPathName = a_oSource.m_strPathName;
  75. m_nWorkingSampeIndex = a_oSource.m_nWorkingSampeIndex;
  76. }
  77. // file
  78. public void SetPathName(String a_strPathName) { m_strPathName = a_strPathName; }
  79. public bool Load()
  80. {
  81. String strPathName = "";
  82. strPathName.Trim();
  83. if (strPathName == "")
  84. {
  85. // file open dialog
  86. OpenFileDialog openFileDialog = new OpenFileDialog();
  87. if (openFileDialog.ShowDialog() != DialogResult.OK)
  88. {
  89. return false;
  90. }
  91. strPathName = openFileDialog.FileName;
  92. }
  93. //Init data
  94. Cleanup();
  95. // check if the file exist
  96. if (!FileExists(strPathName))
  97. {
  98. // shouldn't happen, file does not exist
  99. return false;
  100. }
  101. //获取测量项目文件
  102. XmlDocument doc = new XmlDocument();
  103. //载入xml文件
  104. doc.Load(strPathName);
  105. XmlNode root = doc.SelectSingleNode("XMLData");
  106. Serialize(false, doc, root);
  107. //设置测量项目文件路径
  108. m_strPathName = strPathName;
  109. //-------------
  110. foreach (var smpl in m_listSamples)
  111. {
  112. // get path of the pathname
  113. String strFilePath = GetFolderName(strPathName);
  114. if (strFilePath == "")
  115. {
  116. // file path string is an empty string
  117. return false;
  118. }
  119. // field file sub folder string
  120. String strFieldFileSubFolder = strFilePath + "\\" + smpl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
  121. // check if the field file sub folder exists
  122. if (!DirectoryExists(strFieldFileSubFolder))
  123. {// field files folder doesn't exist
  124. continue;
  125. }
  126. String strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
  127. CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
  128. List<COTSFieldData> allFlds = new List<COTSFieldData>();
  129. CMsrSampleStatus poMsrStatus = new CMsrSampleStatus();
  130. poMsrStatus.GetStatus();
  131. CMsrDisplayResults poMsrResults = smpl.GetMsrResults();
  132. double aFldArea = smpl.CalculateAFieldArea();
  133. SetPathName(strIncAFilename);
  134. if (GetAllFieldsFromDB(ref allFlds, poMsrStatus, poMsrResults, aFldArea))
  135. {
  136. smpl.SetFieldsData(allFlds);
  137. // file validation
  138. smpl.SetMsrStatus(poMsrStatus);
  139. smpl.SetMsrResults(poMsrResults);
  140. // set modify flag
  141. //SetModify(false);
  142. // set pathname
  143. SetPathName(strPathName);
  144. // set working sample
  145. if (m_listSamples.Count > 0)
  146. {
  147. m_nWorkingSampeIndex = 0;
  148. }
  149. else
  150. {
  151. m_nWorkingSampeIndex = -1;
  152. }
  153. }
  154. else
  155. {
  156. return false;
  157. }
  158. }
  159. if (m_listSamples != null)
  160. {
  161. if (m_listSamples.Count > 0)
  162. {
  163. m_nWorkingSampeIndex = 0;
  164. }
  165. }
  166. //-----------------------------------------
  167. return true;
  168. }
  169. // gets the name of the folder
  170. public String GetFolderName(String a_strPathName)
  171. {
  172. string str = "";
  173. str = Path.GetDirectoryName(a_strPathName);
  174. return str.ToString();
  175. }
  176. public bool FileExists(string a_sPath)
  177. {
  178. bool b_IsExists = File.Exists(a_sPath);
  179. return b_IsExists;
  180. }
  181. public bool DirectoryExists(string a_sPath)
  182. {
  183. bool b_IsExists = Directory.Exists(a_sPath);
  184. return b_IsExists;
  185. }
  186. // cleanup
  187. public void Cleanup()
  188. {
  189. m_listHoleBSEImg.Clear();
  190. m_listSamples.Clear();
  191. m_bModify = false;
  192. m_strPathName = "";
  193. m_nWorkingSampeIndex = -1;
  194. }
  195. // set modify flag
  196. public void SetModify(bool a_bModify = true) { m_bModify = a_bModify; }
  197. // file pathname
  198. public String GetPathName() { return m_strPathName; }
  199. public bool GetAllFieldsFromDB(ref List<COTSFieldData> allFlds, CMsrSampleStatus status, CMsrDisplayResults rst, double aFieldArea)
  200. {
  201. String sDatabaseName = m_strPathName;
  202. if (!FileExists(sDatabaseName))
  203. {
  204. return false;
  205. }
  206. List<System.Drawing.Point> completedflds = new List<System.Drawing.Point>();
  207. CIncAFileMgr incAFileMgr = new CIncAFileMgr(sDatabaseName);
  208. var m_IncADataDB = incAFileMgr.GetIncADB();
  209. m_IncADataDB.GetAllFieldsRecord(ref allFlds);
  210. var eleChemistryDB = incAFileMgr.GetPosXrayDBMgr().GetElementChemistryDB();
  211. Dictionary<List<int>, CPosXrayClr> mapXrayInfo=new Dictionary<List<int>, CPosXrayClr>();
  212. eleChemistryDB.GetAllMapedXrayInfo(ref mapXrayInfo);
  213. foreach (var f in allFlds)
  214. {
  215. foreach (var p in f.ListAnalysisParticles)
  216. {
  217. int curFldId = f.GetId();
  218. int xrayId = p.GetAnalysisId();
  219. List<int> fldvec=new List<int>();
  220. fldvec.Add(curFldId);
  221. fldvec.Add(xrayId);
  222. //auto cXray = mapXrayInfo.find(fldvec);
  223. if (mapXrayInfo.ContainsKey(fldvec))
  224. {
  225. var xray = mapXrayInfo[fldvec];
  226. p.SetXray(xray);
  227. }
  228. }
  229. }
  230. var xrayDataDBDB = incAFileMgr.GetPosXrayDBMgr().GetXrayDataDB();
  231. Dictionary<List<int>, CPosXrayClr> mapXrayData=new Dictionary<List<int>, CPosXrayClr>();// map structure:[(fieldId,xrayId),CPosXrayPtr],every element of this map represent one unique xraydata.
  232. xrayDataDBDB.GetAllMapedXrayData(ref mapXrayData);
  233. foreach (var f in allFlds)
  234. {
  235. foreach (var p in f.ListAnalysisParticles)
  236. {
  237. int curFldId = f.GetId();
  238. int xrayId = p.GetAnalysisId();
  239. List<int> fldvec=new List<int>();
  240. fldvec.Add (curFldId);
  241. fldvec.Add (xrayId);
  242. //auto cXray = mapXrayData.find(fldvec);
  243. if (mapXrayData.ContainsKey(fldvec))
  244. {
  245. var xray = mapXrayData[fldvec];
  246. CPosXrayClr t2 = p.GetXray();
  247. if (t2 == null)
  248. {
  249. t2 =new CPosXrayClr();
  250. p.SetXray(t2);
  251. }
  252. t2.SetXrayData(xray.GetXrayData());
  253. }
  254. }
  255. }
  256. CSegmentDB SegmentDB = incAFileMgr.GetSegmentDB();
  257. double msrFldsArea = 0;
  258. Dictionary<int, List<COTSParticleClr>> mapTypeParticles = new Dictionary<int,List<COTSParticleClr>>();//record typeId relevants particlelist;
  259. List<COTSSegmentClr> AllSegments = new List<COTSSegmentClr>();
  260. Dictionary<List<int>, List<COTSSegmentClr>> mapSegments = new Dictionary<List<int>, List<COTSSegmentClr>>();
  261. if (SegmentDB.GetAllSegmentsRecord(mapSegments))
  262. {
  263. foreach (var fld in allFlds)
  264. {
  265. int fldId = fld.GetId();
  266. List<COTSParticleClr> parts = fld.ListAnalysisParticles;
  267. foreach (var part in parts)
  268. {
  269. List<int> fldvec = new List<int>();
  270. fldvec.Add(fldId);
  271. fldvec.Add(part.GetTagId());
  272. if (mapSegments.ContainsKey(fldvec))
  273. {
  274. COTSFeatureClr f = new COTSFeatureClr();
  275. AllSegments = mapSegments[fldvec];
  276. f.SetSegmentsList(AllSegments, true);
  277. part.SetFeature(f);
  278. if (mapTypeParticles.ContainsKey(part.GetType()))
  279. {
  280. mapTypeParticles[part.GetType()].Add(part);
  281. }
  282. else
  283. {
  284. List<COTSParticleClr> ps = new List<COTSParticleClr>();
  285. ps.Add(part);
  286. mapTypeParticles.Add(part.GetType(), ps);
  287. }
  288. }
  289. completedflds.Add(fld.GetPosition());
  290. msrFldsArea += aFieldArea;
  291. }
  292. }
  293. // get MsrStatus info from DB.
  294. var m_GenInfoDB = incAFileMgr.GetGeneralInfoDB();//DBStoreFile类
  295. String strTimeStart = "";
  296. String strTimeEnd = "";
  297. String strRstStatus = "";
  298. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
  299. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(), ref strTimeEnd);
  300. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(), ref strRstStatus);
  301. status.SetCompletedFieldsCenter(completedflds);
  302. status.SetCompletedFields(completedflds.Count);
  303. DateTime timeStart, timeEnd;
  304. timeStart = Convert.ToDateTime(strTimeStart);
  305. timeEnd = Convert.ToDateTime(strTimeEnd);
  306. status.SetStartTime(timeStart);
  307. status.SetEndTime(timeEnd);
  308. status.SetUsedTime(timeEnd - timeStart);
  309. status.SetStatus((OTS_MSR_SAMPLE_STATUS)Convert.ToInt32(strRstStatus));
  310. //get MsrResults data from map.
  311. List<CMsrResultItem> rstItms = new List<CMsrResultItem>();
  312. double allPartArea = 0;
  313. int typeNum = 0;
  314. double typeArea = 0;
  315. foreach (var typeParticles in mapTypeParticles)
  316. {
  317. CMsrResultItem rstItm = new CMsrResultItem();
  318. foreach (var p in typeParticles.Value)
  319. {
  320. typeNum += 1;
  321. typeArea +=p.GetArea();
  322. }
  323. rstItm.SetTypeId(typeParticles.Key);
  324. rstItm.SetNumber((uint)typeNum);
  325. rstItm.SetArea((uint)typeArea);
  326. rstItms.Add(rstItm);
  327. allPartArea += typeArea;
  328. }
  329. rst.SetResultItems(rstItms);
  330. rst.SetMeasuredArea(Convert.ToUInt32(msrFldsArea * 1000000));
  331. rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
  332. return true;
  333. }
  334. return false;
  335. }
  336. public bool Save()
  337. {
  338. // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
  339. String strPathName = GetPathName();
  340. // is this a new file?
  341. strPathName.Trim();
  342. if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
  343. {
  344. // this is a new file
  345. // return save as result
  346. return SaveAs();
  347. }
  348. //保存测量项目文件 .prj
  349. XmlDocument doc = new XmlDocument();
  350. doc.Load(strPathName);
  351. doc.RemoveAll();
  352. //添加xml文件头申明
  353. XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
  354. doc.AppendChild(xmldecl);
  355. XmlElement rootNode = doc.CreateElement("XMLData");
  356. doc.AppendChild(rootNode);
  357. Serialize(true, doc, rootNode);
  358. try
  359. {
  360. doc.Save(strPathName);
  361. }
  362. catch
  363. {
  364. return false;
  365. }
  366. // set file modify flag
  367. SetModify(false);
  368. // Ok, return TRUE
  369. return true;
  370. }
  371. public bool SaveAs()
  372. {
  373. // get file name
  374. String strPathName = "";
  375. // file open dialog
  376. SaveFileDialog saveFileDialog = new SaveFileDialog();
  377. saveFileDialog.FileName = m_strPathName;
  378. saveFileDialog.Filter = "Probject Files (*.prj)|*.prj|All files (*.*)|*.*";
  379. if (saveFileDialog.ShowDialog() != DialogResult.OK)
  380. {
  381. return false;
  382. }
  383. // get file pathname
  384. strPathName = saveFileDialog.FileName;
  385. //保存测量项目文件 .prj
  386. XmlDocument doc = new XmlDocument();
  387. //添加xml文件头申明
  388. XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
  389. doc.AppendChild(xmldecl);
  390. XmlElement rootNode = doc.CreateElement("XMLData");
  391. doc.AppendChild(rootNode);
  392. Serialize(true, doc, rootNode);
  393. try
  394. {
  395. doc.Save(strPathName);
  396. }
  397. catch
  398. {
  399. return false;
  400. }
  401. // set file modify flag
  402. m_bModify = false;
  403. // Set project Path
  404. SetPathName(strPathName);
  405. // Ok, return TRUE
  406. return true;
  407. }
  408. // SEM stage data
  409. public CSEMStageData GetSEMStageData() { return m_pSEMStageData; }
  410. // SEM stage data
  411. public void SetSEMStageData(CSEMStageData a_pCSEMStageData)
  412. {
  413. m_pSEMStageData = a_pCSEMStageData;
  414. }
  415. // stage
  416. public CStage GetStage() { return m_pStage; }
  417. public void SetStage(CStage a_pStage)
  418. {
  419. m_pStage = new CStage(a_pStage);
  420. }
  421. // samples list
  422. public List<COTSSample> GetSampleList() { return m_listSamples; }
  423. // samples list
  424. public bool SetSampleList(List<COTSSample> a_listSample, bool a_bClear/* = TRUE*/)
  425. {
  426. // clear samples list if necessary
  427. if (a_bClear)
  428. {
  429. m_listSamples.Clear();
  430. }
  431. // go through the sample list of the source
  432. foreach (var pSample in a_listSample)
  433. {
  434. // add the new sample into sample list
  435. m_listSamples.Add(pSample);
  436. }
  437. return true;
  438. }
  439. public COTSSample GetSampleByIndex(int a_nIndex)
  440. {
  441. // safe check
  442. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  443. {
  444. // invalid sample id
  445. return null;
  446. }
  447. // get the matching sample
  448. COTSSample pSample = m_listSamples[a_nIndex];
  449. // return the sample
  450. return pSample;
  451. }
  452. public COTSSample GetSampleByName(String a_strSampleName)
  453. {
  454. bool IsChanged = false;
  455. COTSSample pOTSSample = null;
  456. for (int itr = 0; itr < m_listSamples.Count; itr++)
  457. {
  458. if (m_listSamples[itr].GetName() == a_strSampleName)
  459. {
  460. pOTSSample = m_listSamples[itr];
  461. //m_listSamples.RemoveAt(itr);
  462. IsChanged = true;
  463. }
  464. }
  465. if (IsChanged)
  466. {
  467. return pOTSSample;
  468. }
  469. return m_listSamples[0];
  470. }
  471. public void AddSample(COTSSample pSample)
  472. {
  473. // add the new sample into the samples list
  474. m_listSamples.Add(pSample);
  475. // set the project file modified.
  476. SetModify();
  477. // set the new as working sample
  478. m_nWorkingSampeIndex = (int)m_listSamples.Count - 1;
  479. // return the new sample
  480. }
  481. // get new sample name
  482. public bool DeleteSampleByIndex(int a_nIndex)
  483. {
  484. // check the index
  485. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  486. {
  487. // invalid input sample index
  488. return true;
  489. }
  490. // calculate new working sample index
  491. int nNewWorkingSampeIndex;
  492. if (a_nIndex < m_nWorkingSampeIndex)
  493. {
  494. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  495. }
  496. else if (a_nIndex > m_nWorkingSampeIndex)
  497. {
  498. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  499. }
  500. else
  501. {
  502. // deleting working sample.
  503. if (a_nIndex == (int)m_listSamples.Count - 1)
  504. {
  505. // this is the last sample, select the above sample as working sample
  506. // if this is only sample in the list working sample index will be -1;
  507. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  508. }
  509. else
  510. {
  511. // select next sample as working sample
  512. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  513. }
  514. }
  515. // delete the sample
  516. for (int i = m_listSamples.Count - 1; i >= 0; i--)
  517. {
  518. if (i == a_nIndex)
  519. {
  520. m_listSamples.Remove(m_listSamples[i]);
  521. break;
  522. }
  523. }
  524. // the file is modified.
  525. SetModify();
  526. // reset working sample index
  527. m_nWorkingSampeIndex = nNewWorkingSampeIndex;
  528. // ok, return TRUE
  529. return true;
  530. }
  531. public bool ChangeParamFromList(int iNamePos)
  532. {
  533. throw new NotImplementedException();
  534. }
  535. public bool GetParamFileList(ref int iNamePos, ref List<string> mParamFileNameList)
  536. {
  537. throw new NotImplementedException();
  538. }
  539. public bool DeleteSampleByName(String a_strSampleName)
  540. {
  541. // check input sample name
  542. a_strSampleName.Trim();
  543. if (a_strSampleName == "")
  544. {
  545. // input sample name is empty
  546. return false;
  547. }
  548. // go through sample list
  549. int nIndex = 0;
  550. foreach (var pSample in m_listSamples)
  551. {
  552. // return TRUE if this is not an exclude sample and its name is same with input
  553. String strSampleName = pSample.GetName();
  554. if (strSampleName.CompareTo(a_strSampleName) == 0)
  555. {
  556. // find the sample, return deleting result
  557. return DeleteSampleByIndex(nIndex);
  558. }
  559. ++nIndex;
  560. }
  561. // can't find the sample in the samples list, return FALSE
  562. return false;
  563. }
  564. public bool ResetSamplesListOrder(List<String> a_listSampleNames)
  565. {
  566. // no sample in the samples list; shouldn't be here
  567. if (m_listSamples.Count == 0)
  568. {
  569. return false;
  570. }
  571. // make sure that input sample names list size is same with the samples list
  572. if (m_listSamples.Count != a_listSampleNames.Count)
  573. {
  574. return false;
  575. }
  576. // new sample list
  577. List<COTSSample> listSamples = new List<COTSSample>();
  578. // go through the sample names list
  579. foreach (var strSampleName in a_listSampleNames)
  580. {
  581. bool IsChanged = false;
  582. for (int itr = 0; itr < m_listSamples.Count; itr++)
  583. {
  584. if (m_listSamples[itr].GetName() == strSampleName)
  585. {
  586. COTSSample pElementChemistry = m_listSamples[itr];
  587. IsChanged = true;
  588. }
  589. }
  590. if (!IsChanged)
  591. {
  592. return false;
  593. }
  594. }
  595. // reset the samples list
  596. m_listSamples.Clear();
  597. foreach (var pSample in listSamples)
  598. {
  599. m_listSamples.Add(pSample);
  600. }
  601. // set modify flag
  602. SetModify();
  603. // Ok, return TRUE
  604. return true;
  605. }
  606. public bool InsrtSample(COTSSample a_pSample, int a_nIndex)
  607. {
  608. // input check
  609. if (a_pSample != null)
  610. {
  611. // invalid input sample pointer
  612. return false;
  613. }
  614. if (m_listSamples.Count == 0 || a_nIndex >= (int)m_listSamples.Count)
  615. {
  616. m_listSamples.Add(a_pSample);
  617. }
  618. else if (a_nIndex <= 0)
  619. {
  620. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]), a_pSample);
  621. }
  622. else
  623. {
  624. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]) + a_nIndex, a_pSample);
  625. }
  626. // Ok, return TRUE
  627. return true;
  628. }
  629. public bool ChangeSamplePosition(int a_nIndexFrom, int a_nIndexTo)
  630. {
  631. // make sure both index are valid
  632. if (a_nIndexFrom < 0 || a_nIndexFrom >= (int)m_listSamples.Count)
  633. {
  634. // invalid from index
  635. return false;
  636. }
  637. if (a_nIndexTo < 0 || a_nIndexTo >= (int)m_listSamples.Count)
  638. {
  639. // invalid to index
  640. return false;
  641. }
  642. // need to do nothing if the two indexes are the same
  643. if (a_nIndexFrom != a_nIndexTo)
  644. {
  645. // move to last?
  646. bool bLast = (a_nIndexTo == ((int)m_listSamples.Count - 1));
  647. // get the sample
  648. COTSSample pSample = m_listSamples[a_nIndexFrom];
  649. // remove it from the samples list
  650. m_listSamples.Remove(pSample);
  651. // put the sample back in
  652. if (bLast)
  653. {
  654. m_listSamples.Add(pSample);
  655. }
  656. else
  657. {
  658. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndexTo]) + a_nIndexTo, pSample);
  659. }
  660. }
  661. // Ok, return TRUE
  662. return true;
  663. }
  664. public bool MoveSamplePosition(COTSSample a_pTargetSample, COTSSample a_RefpSample, bool a_bBefore /*= TRUE*/)
  665. {
  666. // check input
  667. if (a_pTargetSample != null)
  668. {
  669. // invalid input target sample pointer
  670. return false;
  671. }
  672. if (a_RefpSample != null)
  673. {
  674. // invalid input ref sample pointer
  675. return false;
  676. }
  677. bool IsChanged = false;
  678. for (int itr = 0; itr < m_listSamples.Count; itr++)
  679. {
  680. if (m_listSamples[itr].GetName() == a_pTargetSample.GetName())
  681. {
  682. COTSSample pElementChemistry = m_listSamples[itr];
  683. // m_listSamples.RemoveAt(itr);
  684. IsChanged = true;
  685. }
  686. }
  687. if (!IsChanged)
  688. {
  689. return false;
  690. }
  691. for (int itr = 0; itr < m_listSamples.Count; itr++)
  692. {
  693. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  694. {
  695. COTSSample pElementChemistry = m_listSamples[itr];
  696. //m_listSamples.RemoveAt(itr);
  697. IsChanged = true;
  698. }
  699. }
  700. if (!IsChanged)
  701. {
  702. return false;
  703. }
  704. // remove the sample from the samples list
  705. for (int itr = 0; itr < m_listSamples.Count; itr++)
  706. {
  707. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  708. {
  709. COTSSample pElementChemistry = m_listSamples[itr];
  710. //m_listSamples.RemoveAt(itr);
  711. IsChanged = true;
  712. }
  713. }
  714. if (!IsChanged)
  715. {
  716. return false;
  717. }
  718. // put the sample back in
  719. if (a_bBefore)
  720. {
  721. m_listSamples.Insert(0, a_pTargetSample);
  722. }
  723. else
  724. {
  725. m_listSamples.Insert(1, a_pTargetSample);
  726. }
  727. // Ok, return TRUE
  728. return true;
  729. }
  730. public bool MoveSamplePosition(String a_strTargetSampleName, String a_strRefSampleName, bool a_bBefore /*= TRUE*/)
  731. {
  732. // input check
  733. a_strTargetSampleName.Trim();
  734. if (a_strTargetSampleName == "")
  735. {
  736. // input target sample is an empty string
  737. return false;
  738. }
  739. a_strRefSampleName.Trim();
  740. if (a_strRefSampleName == "")
  741. {
  742. // input ref sample is an empty string
  743. return false;
  744. }
  745. bool IsChanged = false;
  746. for (int itr = 0; itr < m_listSamples.Count; itr++)
  747. {
  748. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  749. {
  750. COTSSample pElementChemistry = m_listSamples[itr];
  751. IsChanged = true;
  752. }
  753. }
  754. if (!IsChanged)
  755. {
  756. return false;
  757. }
  758. COTSSample pTargetSample = m_listSamples[0];
  759. for (int itr = 0; itr < m_listSamples.Count; itr++)
  760. {
  761. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  762. {
  763. COTSSample pElementChemistry = m_listSamples[itr];
  764. IsChanged = true;
  765. }
  766. }
  767. if (!IsChanged)
  768. {
  769. return false;
  770. }
  771. COTSSample pRefSample = pTargetSample;
  772. // need to do nothing if the two name are same
  773. if (a_strTargetSampleName.CompareTo(a_strRefSampleName) != 0)
  774. {
  775. return MoveSamplePosition(pTargetSample, pRefSample, a_bBefore);
  776. }
  777. // Ok, return TRUE
  778. return true;
  779. }
  780. public COTSSample GetWorkingSample()
  781. {
  782. // check if the working sample index
  783. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSamples.Count)
  784. {
  785. // invalid working sample index
  786. return null;
  787. }
  788. return GetSampleByIndex(m_nWorkingSampeIndex);
  789. }
  790. int GetWorkingSampleIndex() { return m_nWorkingSampeIndex; }
  791. void SetWorkingSampleIndex(int a_nWorkingSampleIndex) { m_nWorkingSampeIndex = a_nWorkingSampleIndex; }
  792. public bool SetWorkingSampleByIndex(int a_nIndex)
  793. {
  794. // special treatment
  795. if (a_nIndex == -1 && m_listSamples.Count == 0)
  796. {
  797. m_nWorkingSampeIndex = -1;
  798. return true;
  799. }
  800. // check if the working sample index
  801. if (0 > a_nIndex || a_nIndex >= (int)m_listSamples.Count)
  802. {
  803. // invalid sample index
  804. return false;
  805. }
  806. m_nWorkingSampeIndex = a_nIndex;
  807. return true;
  808. }
  809. public bool SetWorkingSampleByName(String a_pSampleName)
  810. {
  811. // check input sample name
  812. a_pSampleName.Trim();
  813. if (a_pSampleName == "")
  814. {
  815. // input sample name is empty
  816. return false;
  817. }
  818. // go through sample list
  819. int nIndex = 0;
  820. foreach (var pSample in m_listSamples)
  821. {
  822. // return TRUE if this is not an exclude sample and its name is same with input
  823. String strSampleName = pSample.GetName();
  824. if (strSampleName.CompareTo(a_pSampleName) == 0)
  825. {
  826. // find the sample, return deleting result
  827. return SetWorkingSampleByIndex(nIndex);
  828. }
  829. ++nIndex;
  830. }
  831. // failed to find the named sample
  832. // failed to find the named sample return FALSE
  833. return false;
  834. }
  835. public bool DeleteWorkingSample()
  836. {
  837. // check if the working sample index
  838. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSamples.Count)
  839. {
  840. // invalid working sample index
  841. return false;
  842. }
  843. // return the result of DeleteSampleByIndex
  844. return DeleteSampleByIndex(m_nWorkingSampeIndex);
  845. }
  846. // Sample hole BSE image list
  847. public List<CHoleBSEImg> GetHoleBESImgList() { return m_listHoleBSEImg; }
  848. // hole BSE images list
  849. public void SetHoleBESImgList(List<CHoleBSEImg> a_listHoleBSEImg, bool a_bClear/* = TRUE*/)
  850. {
  851. // clear the hole BSE image list if necessary
  852. if (a_bClear)
  853. {
  854. m_listHoleBSEImg.Clear();
  855. }
  856. m_listHoleBSEImg = a_listHoleBSEImg;
  857. if (m_nWorkingSampeIndex != -1)
  858. {
  859. COTSSample pSample = GetWorkingSample();
  860. }
  861. }
  862. // get modify flag
  863. public bool IsModified() { return m_bModify; }
  864. // file name
  865. public String GetFileName()
  866. {
  867. // make a copy of file path name
  868. String strPathName = m_strPathName;
  869. // is this a new file?
  870. if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
  871. {
  872. return strPathName;
  873. }
  874. // get file name
  875. String strFileName = GetFileNameWithoutExtension(strPathName);
  876. // return file name
  877. return strFileName;
  878. }
  879. // get file name without extension
  880. public String GetFileNameWithoutExtension(String a_strPathName)
  881. {
  882. string str = "";
  883. str = Path.GetFileNameWithoutExtension(a_strPathName);
  884. return str;
  885. }
  886. // if the new sample name can be used.
  887. public bool IsValidSampleName(String a_sName)
  888. {
  889. int nindex = -1;
  890. foreach (var pSample in m_listSamples)
  891. {
  892. nindex++;
  893. String sSampleName = pSample.GetName();
  894. if (a_sName.CompareTo(sSampleName) != 0)
  895. {
  896. if (nindex != m_nWorkingSampeIndex)
  897. {
  898. return false;
  899. }
  900. }
  901. }
  902. return true;
  903. }
  904. // get std file list, a_nPos = -1, current do not use any STD lib, a_nPos = 0, current use STD lib.
  905. public bool GetSTDFileList(ref int a_nPos, ref List<String> a_listSTDLibName)
  906. {
  907. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  908. if (a_strFolderName == "")
  909. {
  910. return false;
  911. }
  912. // lib name list
  913. a_listSTDLibName.Clear();
  914. // file list
  915. List<String> listSTDFile = new List<string>();
  916. listSTDFile.Clear();
  917. const String STD_LIB_EXT = ".db";
  918. // get file list
  919. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  920. {
  921. return false;
  922. }
  923. foreach (var file in listSTDFile)
  924. {
  925. //string fileName = file.Left(file.GetLength() - 3);
  926. String fileName = file;
  927. a_listSTDLibName.Add(fileName);
  928. }
  929. if (a_listSTDLibName.Count > -1)
  930. {
  931. string m_NoSTDDB = "NoSTDDB";
  932. a_listSTDLibName.Add(m_NoSTDDB);
  933. }
  934. //before the use choose one STD, always should be null.
  935. a_nPos = -1;
  936. String sCurrentSTD;
  937. CSampleParam pCurrentParam;
  938. COTSSample pSample = GetWorkingSample();
  939. if (pSample == null)
  940. {
  941. }
  942. else
  943. {
  944. pCurrentParam = pSample.GetMsrParams();
  945. if (pCurrentParam == null)
  946. {
  947. }
  948. //将当前使用的数据库的名字与下拉菜单的名字对应起来
  949. sCurrentSTD = pCurrentParam.GetSTDName();
  950. for (int i = 0; i < (int)a_listSTDLibName.Count; i++)
  951. {
  952. a_nPos++;
  953. if (a_listSTDLibName[i].CompareTo(sCurrentSTD) == 0)
  954. break;
  955. }
  956. }
  957. return true;
  958. }
  959. // get file name list in a folder
  960. public bool GetFileNameList(String a_strFolderName, String a_strFileType, List<String> a_listFileName)
  961. {
  962. try
  963. {
  964. //find first file
  965. //int FindFileData = 0;
  966. // int file = FindFirstFile(a_strFolderName, FindFileData);
  967. string path = a_strFolderName;
  968. List<string> lineStringList = new List<string>();//存储所有读取到的文件
  969. DirectoryInfo[] dateDirArr = new DirectoryInfo(path).GetDirectories(); //取指定路径下的所有目录
  970. string[] dir = Directory.GetDirectories(path); //文件夹列表   
  971.                 DirectoryInfo fdir = new DirectoryInfo(path);
  972. FileInfo[] files = fdir.GetFiles();
  973. foreach (FileInfo file in files)
  974. {
  975. string extensionName = Path.GetExtension(file.FullName);
  976. if (extensionName == a_strFileType)
  977. {
  978. string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
  979. a_listFileName.Add(FileNameWithoutExtension);
  980. }
  981. }
  982. #region 原方法
  983. //foreach (DirectoryInfo directoryInfo in dateDirArr)
  984. //{
  985. // string fullName = directoryInfo.FullName + a_strFileType;
  986. // if (!File.Exists(fullName))
  987. // {
  988. // continue;//目录下不存在此文件,返回。
  989. // }
  990. // FileInfo file = new FileInfo(fullName);
  991. // StreamReader reader = new StreamReader(file.FullName);
  992. // while (!reader.EndOfStream)//判断是否读取完成
  993. // {
  994. // lineStringList.Add(reader.ReadLine());
  995. // }
  996. // reader.Close();
  997. //}
  998. //int INVALID_HANDLE_VALUE = 0;
  999. ////find other file
  1000. //if (FindFileData != INVALID_HANDLE_VALUE)
  1001. //{
  1002. // a_listFileName.Add(FindFileData.ToString());
  1003. // bool bState = false;
  1004. // FindFile(a_strFolderName, FindFileData.ToString());
  1005. // while (bState)
  1006. // {
  1007. // a_listFileName.Add(FindFileData.ToString());
  1008. // FindFile(a_strFolderName, FindFileData.ToString());
  1009. // }
  1010. //}
  1011. #endregion
  1012. }
  1013. catch (Exception pe)
  1014. {
  1015. return false;
  1016. }
  1017. return true;
  1018. }
  1019. static String FindFile(String filename, String path)
  1020. {
  1021. if (Directory.Exists(path))
  1022. {
  1023. if (File.Exists(path + filename))
  1024. return path + filename;
  1025. String[] directorys = Directory.GetDirectories(path);
  1026. foreach (String d in directorys)
  1027. {
  1028. String p = FindFile(filename, d);
  1029. if (p != null)
  1030. return p;
  1031. }
  1032. }
  1033. return null;
  1034. }
  1035. //// change STD
  1036. public bool ChangeSTDFromList(int a_nPos)
  1037. {
  1038. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  1039. if (a_strFolderName == "")
  1040. {
  1041. return false;
  1042. }
  1043. // file list
  1044. List<String> listSTDFile = new List<string>();
  1045. listSTDFile.Clear();
  1046. const String STD_LIB_EXT = ".db";
  1047. // get file list
  1048. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  1049. {
  1050. return false;
  1051. }
  1052. List<String> listSTDLibName = new List<string>();
  1053. listSTDLibName.Clear();
  1054. foreach (var file in listSTDFile)
  1055. {
  1056. //string fileName = file.Left(file.GetLength() - 3);
  1057. String fileName = file;
  1058. listSTDLibName.Add(fileName);
  1059. }
  1060. if (listSTDLibName.Count > 0)
  1061. {
  1062. listSTDLibName.Add("NoSTDDB");
  1063. }
  1064. if (a_nPos > (int)listSTDLibName.Count)
  1065. {
  1066. return false;
  1067. }
  1068. String STDName = listSTDLibName[a_nPos];
  1069. // updata STD to working sample
  1070. COTSSample pSample = GetWorkingSample();
  1071. CSampleParam pParam = pSample.GetMsrParams();
  1072. pParam.SetSTDName(STDName);
  1073. pSample.SetMsrParams(pParam);
  1074. return true;
  1075. }
  1076. // get measured sample list
  1077. public bool GetMsredSampleList(ref List<COTSSample> a_listMsredSample)
  1078. {
  1079. a_listMsredSample.Clear();
  1080. foreach (var pSample in m_listSamples)
  1081. {
  1082. if (pSample.GetMsrResults() == new CMsrDisplayResults())
  1083. {
  1084. continue;
  1085. }
  1086. else
  1087. {
  1088. a_listMsredSample.Add(pSample);//the reference count will increament automatically.
  1089. }
  1090. }
  1091. return true;
  1092. }
  1093. // calculate measurement area
  1094. public CDomain CalculateMsrArea(CHole a_pHole)
  1095. {
  1096. CDomain pMsrArea = new CDomain(a_pHole.GetShape(), a_pHole.GetDomainRect());
  1097. // create measurement area
  1098. // reset measurement area
  1099. // measurement area should smaller than the sample hole
  1100. Rectangle rectMsrArea = pMsrArea.GetDomainRect();
  1101. int nWidth = rectMsrArea.Width;
  1102. int nHeight = rectMsrArea.Height;
  1103. int nDeflateX = CalculateDeflateValue(nWidth);
  1104. int nDeflateY = CalculateDeflateValue(nHeight);
  1105. rectMsrArea.Offset(nDeflateX, nDeflateY);
  1106. pMsrArea.SetDomainRect(rectMsrArea);
  1107. // return measurement area
  1108. return pMsrArea;
  1109. }
  1110. // calculate deflate value
  1111. public int CalculateDeflateValue(int a_nWitchOrHeight)
  1112. {
  1113. const long LENGTH_THRESHOLD = 150000;
  1114. const long LENGTH_THRESHOLD_MIN = 10000;
  1115. const int EDGE = 1000;
  1116. const int EDGE_MIN = 500;
  1117. // deflate 1000 if width or height is greater than 15000
  1118. if (a_nWitchOrHeight >= LENGTH_THRESHOLD)
  1119. {
  1120. return EDGE;
  1121. }
  1122. // deflate 500 if width or height is greater than 15000
  1123. else if (a_nWitchOrHeight >= LENGTH_THRESHOLD_MIN)
  1124. {
  1125. return EDGE_MIN;
  1126. }
  1127. // otherwise, no deflate
  1128. return 0;
  1129. }
  1130. //合并后新添加的需要的方法
  1131. public void SetGenParam(COTSGeneralParam GenParam) { m_GenParam = GenParam; }
  1132. public bool Reclassify()
  1133. {
  1134. string strFilePath = FileHelper.GetFolderName(m_strPathName);
  1135. foreach (var spl in m_listSamples)
  1136. {
  1137. //get the parameter MsrParam object
  1138. CSampleParam pMsrParam = spl.GetMsrParams();
  1139. string stdFileName = pMsrParam.GetSTDName();
  1140. if (!stdFileName.Contains(".db"))
  1141. {
  1142. stdFileName += ".db";
  1143. }
  1144. string filename = strFilePath + "\\" + spl.GetName() + "\\" + spl.GetName() + ".rst";
  1145. //获取测量项目文件
  1146. XmlDocument doc = new XmlDocument();
  1147. //载入xml文件
  1148. doc.Load(filename);
  1149. pMsrParam.SetSTDName(stdFileName);
  1150. XmlNode root = doc.SelectSingleNode("XMLData");
  1151. Serialize(true, doc, root);
  1152. //string imgpath = filename.GetBuffer(0);
  1153. //const char* file = imgpath.c_str();
  1154. //tinyxml2::XMLDocument doc;
  1155. //if (doc.LoadFile(file) != 0)
  1156. //{
  1157. // return NULL;
  1158. //}
  1159. //tinyxml2::XMLElement* root = doc.RootElement();
  1160. //std::string sem = "Sample";
  1161. //tinyxml2::XMLElement* member = queryUserNodeByName(root, sem);
  1162. //tinyxml2::XMLElement* member1 = queryUserNodeByName(member, "MsrParams");
  1163. //member1->SetAttribute("STDName", stdFileName);
  1164. doc.Save(filename);
  1165. //get the steel technology parameter
  1166. STEEL_TECHNOLOGY steelTech = pMsrParam.GetSteelTechnology();
  1167. foreach (var fld in spl.GetFieldsData())
  1168. {
  1169. foreach (var part in fld.ListAnalysisParticles)
  1170. {
  1171. if (spl.IfUsingSysSTD())
  1172. {
  1173. if (stdFileName != "NoSTDDB")
  1174. {
  1175. var m_classifyEngine = new CClassifyEngine();
  1176. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1177. if (!engine.Classify(part))
  1178. {
  1179. return false;
  1180. }
  1181. }
  1182. if (part.GetType() == (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
  1183. {
  1184. var m_classifyEngine = new CClassifyEngine();
  1185. IClassifyEngine engine = m_classifyEngine.GetIncClassifyEngine();
  1186. if (!engine.ClassifyIncA(part, (int)steelTech))
  1187. {
  1188. return false;
  1189. }
  1190. }
  1191. }
  1192. else
  1193. {
  1194. if (stdFileName != "NoSTDDB")
  1195. {
  1196. var m_classifyEngine = new CClassifyEngine();
  1197. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1198. if (!engine.Classify(part))
  1199. {
  1200. return false;
  1201. }
  1202. }
  1203. }
  1204. }
  1205. string strFieldFileSubFolder = strFilePath + "\\" + spl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER;
  1206. string strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
  1207. CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
  1208. pIncAFileMgr.UpdateIncAList(fld.ListAnalysisParticles);
  1209. }
  1210. }
  1211. return true;
  1212. }
  1213. /// <summary>
  1214. /// 设置样品中对象属性 赋值
  1215. /// </summary>
  1216. /// <param name="pSample"></param>
  1217. /// <param name="poMsrParams"></param>
  1218. /// <returns></returns>
  1219. void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  1220. {
  1221. // copy data over
  1222. if (m_pSEMStageData == null)
  1223. {
  1224. m_pSEMStageData = new CSEMStageData();
  1225. }
  1226. if (m_pStage == null)
  1227. {
  1228. m_pStage = new CStage();
  1229. }
  1230. xInt xProjMgrFileMark = new xInt();
  1231. xString xProjMgrFileVersion = new xString();
  1232. xString xstrPathName = new xString();
  1233. Collection<CHoleBSEImg> xholeBSEImgs = new Collection<CHoleBSEImg>();
  1234. Collection<COTSSample> xsamples = new Collection<COTSSample>();
  1235. Slo slo = new Slo();
  1236. slo.Register("ProjMgrFileMark", xProjMgrFileMark);
  1237. slo.Register("ProjMgrFileVersion", xProjMgrFileVersion);
  1238. slo.Register("strPathName", xstrPathName);
  1239. slo.Register("SEMStageData", m_pSEMStageData);
  1240. slo.Register("Stage", m_pStage);
  1241. slo.Register("HoleBSEImg", xholeBSEImgs);
  1242. slo.Register("Samples", xsamples);
  1243. if (isStoring)
  1244. {
  1245. xProjMgrFileMark.AssignValue(0);
  1246. xProjMgrFileVersion.AssignValue("");
  1247. xstrPathName.AssignValue(m_strPathName);
  1248. xholeBSEImgs.Clear();
  1249. foreach (var hole in m_listHoleBSEImg)
  1250. {
  1251. xholeBSEImgs.addItem(hole);
  1252. }
  1253. xsamples.Clear();
  1254. foreach (var sample in m_listSamples)
  1255. {
  1256. xsamples.addItem(sample);
  1257. }
  1258. slo.Serialize(true, classDoc, rootNode);
  1259. }
  1260. else
  1261. {
  1262. slo.Serialize(false, classDoc, rootNode);
  1263. m_strPathName = xstrPathName.value();
  1264. m_listHoleBSEImg.Clear();
  1265. for (int i = 0; i < xholeBSEImgs.size(); i++)
  1266. {
  1267. m_listHoleBSEImg.Add(xholeBSEImgs.getItem(i));
  1268. }
  1269. m_listSamples.Clear();
  1270. for (int i = 0; i < (int)xsamples.size(); i++)
  1271. {
  1272. m_listSamples.Add(xsamples.getItem(i));
  1273. }
  1274. }
  1275. }
  1276. }
  1277. }