PosXrayClr.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. #include "stdafx.h"
  2. #include "PosXrayClr.h"
  3. #include <COTSUtilityDllFunExport.h>
  4. namespace OTSCLRINTERFACE {
  5. CPosXrayClr::CPosXrayClr() // constructor
  6. {
  7. m_PosXray = new CPosXrayPtr(new CPosXray());
  8. }
  9. CPosXrayClr::CPosXrayClr(CPosXrayPtr a_pPosXray) // copy constructor
  10. {
  11. ASSERT(a_pPosXray);
  12. if (!a_pPosXray)
  13. {
  14. LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed."));
  15. return;
  16. }
  17. m_PosXray = new CPosXrayPtr(a_pPosXray);
  18. }
  19. CPosXrayPtr CPosXrayClr::GetPosXrayPtr()
  20. {
  21. return *m_PosXray;
  22. }
  23. CPosXrayClr::CPosXrayClr(CPosXray* a_pSource) // copy constructor
  24. {
  25. ASSERT(a_pSource);
  26. if (!a_pSource)
  27. {
  28. LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed."));
  29. return;
  30. }
  31. m_PosXray = new CPosXrayPtr(new CPosXray(a_pSource));
  32. }
  33. CPosXrayClr::CPosXrayClr(CPosXrayClr^ a_pSource)
  34. {
  35. auto src = a_pSource->GetPosXrayPtr();
  36. m_PosXray = new CPosXrayPtr(new CPosXray(src.get()));
  37. }
  38. CPosXrayClr::~CPosXrayClr()
  39. {
  40. if (m_PosXray != nullptr)
  41. {
  42. delete m_PosXray;
  43. m_PosXray = nullptr;
  44. }
  45. }
  46. CPosXrayClr::!CPosXrayClr()
  47. {
  48. if (m_PosXray != nullptr)
  49. {
  50. delete m_PosXray;
  51. m_PosXray = nullptr;
  52. }
  53. }
  54. double CPosXrayClr::GetXrayDataVectorNorm()
  55. {
  56. return m_PosXray->get()->GetXrayDataVectorNorm();
  57. }
  58. array<DWORD>^ CPosXrayClr::GetXrayData()
  59. {
  60. array<DWORD>^ XrayData;
  61. if (m_PosXray != nullptr)
  62. {
  63. DWORD* XData = m_PosXray->get()->GetXrayData();
  64. XrayData = gcnew array<DWORD>(m_PosXray->get()->GetChannelsNum ());
  65. for (int i = 0; i < m_PosXray->get()->GetChannelsNum(); i++)
  66. {
  67. XrayData[i] = XData[i];
  68. }
  69. }
  70. return XrayData;
  71. }
  72. void CPosXrayClr::SetXrayData(cli::array<DWORD>^ a_pnXrayData)
  73. {
  74. ASSERT(a_pnXrayData);
  75. if (!a_pnXrayData)
  76. {
  77. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  78. }
  79. DWORD* XData=new DWORD[a_pnXrayData->GetLength(0)];
  80. for (auto i = 0; i < a_pnXrayData->GetLength(0);i++)
  81. {
  82. XData[i] = a_pnXrayData[i];
  83. }
  84. if (m_PosXray != nullptr)
  85. {
  86. m_PosXray->get()->SetXrayData(XData);
  87. }
  88. }
  89. DWORD CPosXrayClr::GetTotalCount()
  90. {
  91. CPosXrayPtr pPosXray = GetPosXrayPtr();
  92. return pPosXray->GetTotalCount();
  93. }
  94. void CPosXrayClr::GetMaxHeightPosition(long % a_nMaxHeight, long % a_nPosition)
  95. {
  96. CPosXrayPtr pPosXray = GetPosXrayPtr();
  97. long nMaxHeight, nPosition;
  98. pPosXray->GetMaxHeightPosition(nMaxHeight, nPosition);
  99. a_nMaxHeight = nMaxHeight;
  100. a_nPosition = nPosition;
  101. }
  102. // clear the x-ray data
  103. // if start position is [0, GENERALXRAYCHANNELS - 1], will do the clear
  104. void CPosXrayClr::ClearXrayData(long a_nStartPos)
  105. {
  106. CPosXrayPtr pPosXray = GetPosXrayPtr();
  107. pPosXray->ClearXrayData(a_nStartPos);
  108. }
  109. // set x-ray data at channel
  110. void CPosXrayClr::SetXrayDataAtChannel(DWORD a_nXray, long a_nChannel)
  111. {
  112. if (this == nullptr)
  113. {
  114. LogErrorTrace(__FILE__, __LINE__, _T("GetTotalCount: empty pointer."));
  115. }
  116. CPosXrayPtr pPosXray = GetPosXrayPtr();
  117. pPosXray->SetXrayDataAtChannel(a_nXray, a_nChannel);
  118. }
  119. System::Drawing::Point^ CPosXrayClr::GetPosition()
  120. {
  121. auto p = m_PosXray->get()->GetPosition();
  122. System::Drawing::Point^ pnt = gcnew System::Drawing::Point(p.x, p.y);
  123. return pnt;
  124. }
  125. void CPosXrayClr::SetPosition(System::Drawing::Point^ a_pRect)
  126. {
  127. m_PosXray->get()->SetPosition(CPoint(a_pRect->X, a_pRect->Y));
  128. }
  129. long CPosXrayClr::GetIndex()
  130. {
  131. int nIndex = -1;
  132. if (m_PosXray != nullptr)
  133. {
  134. nIndex = (int)m_PosXray->get()->GetIndex();
  135. }
  136. return nIndex;
  137. }
  138. void CPosXrayClr::SetIndex(long a_nIndex)
  139. {
  140. if (m_PosXray != nullptr)
  141. {
  142. m_PosXray->get()->SetIndex(a_nIndex);
  143. }
  144. }
  145. long CPosXrayClr::GetScanFieldId()
  146. {
  147. int nScanFieldId = -1;
  148. if (m_PosXray != nullptr)
  149. {
  150. nScanFieldId = (int)m_PosXray->get()->GetScanFieldId();
  151. }
  152. return nScanFieldId;
  153. }
  154. void CPosXrayClr::SetScanFieldId(long a_nScanfieldId)
  155. {
  156. if (m_PosXray != nullptr)
  157. {
  158. m_PosXray->get()->SetScanFieldId(a_nScanfieldId);
  159. }
  160. }
  161. long CPosXrayClr::GetPartTagId()
  162. {
  163. int nPartTagId = -1;
  164. if (m_PosXray != nullptr)
  165. {
  166. nPartTagId = m_PosXray->get()->GetPartTagId();
  167. }
  168. return nPartTagId;
  169. }
  170. void CPosXrayClr::SetPartTagId(long a_nPartTagId)
  171. {
  172. if (m_PosXray != nullptr)
  173. {
  174. m_PosXray->get()->SetScanFieldId(a_nPartTagId);
  175. }
  176. }
  177. long CPosXrayClr::GetFeatureId()
  178. {
  179. int nFeatureId = -1;
  180. if (m_PosXray != nullptr)
  181. {
  182. nFeatureId = (int)m_PosXray->get()->GetFeatureId();
  183. }
  184. return nFeatureId;
  185. }
  186. void CPosXrayClr::SetFeatureId(long a_nFeatureId)
  187. {
  188. if (m_PosXray != nullptr)
  189. {
  190. m_PosXray->get()->SetScanFieldId(a_nFeatureId);
  191. }
  192. }
  193. CElementChemistryListClr^ CPosXrayClr::GetElementQuantifyData()
  194. {
  195. CElementChemistryListClr^ ElementChemistryListClr = gcnew CElementChemistryListClr();
  196. auto eleQtyData = m_PosXray->get()->GetElementQuantifyData();
  197. if (m_PosXray != nullptr)
  198. {
  199. for (auto i = 0; i < eleQtyData.size(); i++)
  200. {
  201. ElementChemistryListClr->Add(gcnew CElementChemistryClr(eleQtyData[i]));
  202. }
  203. }
  204. return ElementChemistryListClr;
  205. }
  206. String^ CPosXrayClr::GetQuantifiedElementsStr()
  207. {
  208. return gcnew String(m_PosXray->get()->GetQuantifiedElementsStr());
  209. }
  210. // element quantify data
  211. void CPosXrayClr::SetElementQuantifyData(CElementChemistryListClr^ a_listElementQuantifyData)
  212. {
  213. ASSERT(a_listElementQuantifyData);
  214. if (!a_listElementQuantifyData)
  215. {
  216. LogErrorTrace(__FILE__, __LINE__, _T("SetElementQuantifyData: invalid feature pointer."));
  217. return;
  218. }
  219. CElementChemistriesList chemiList;
  220. for (int i = 0; i < a_listElementQuantifyData->Count; i++)
  221. {
  222. chemiList.push_back(a_listElementQuantifyData[i]->GetElementChemistryPtr());
  223. }
  224. m_PosXray->get()->SetElementQuantifyData(chemiList);
  225. }
  226. void CPosXrayClr::AddQuantifyElement(CElementChemistryClr^ che)
  227. {
  228. m_PosXray->get()->AddQuantifyElement(che->GetElementChemistryPtr());
  229. }
  230. void CPosXrayClr::NormalizeXrayQuantifyData()
  231. {
  232. CPosXrayPtr pPosXray = GetPosXrayPtr();
  233. ASSERT(pPosXray);
  234. if (!pPosXray)
  235. {
  236. LogErrorTrace(__FILE__, __LINE__, _T("NormalizeXrayQuantifyData: Can't get pointer."));
  237. return;
  238. }
  239. pPosXray->NormalizeXrayQuantifyData();
  240. }
  241. void CPosXrayClr::SetElementNum(int num)
  242. {
  243. m_PosXray->get()->SetElementNum(num);
  244. }
  245. int CPosXrayClr::GetElementNum()
  246. {
  247. return m_PosXray->get()->GetElementNum();
  248. }
  249. }