PosXrayClr.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. array<DWORD>^ CPosXrayClr::GetXrayData()
  55. {
  56. array<DWORD>^ XrayData;
  57. if (m_PosXray != nullptr)
  58. {
  59. DWORD* XData = m_PosXray->get()->GetXrayData();
  60. XrayData = gcnew array<DWORD>(m_PosXray->get()->GetChannelsNo ());
  61. for (int i = 0; i < m_PosXray->get()->GetChannelsNo(); i++)
  62. {
  63. XrayData[i] = XData[i];
  64. }
  65. }
  66. return XrayData;
  67. }
  68. void CPosXrayClr::SetXrayData(cli::array<DWORD>^ a_pnXrayData)
  69. {
  70. ASSERT(a_pnXrayData);
  71. if (!a_pnXrayData)
  72. {
  73. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  74. }
  75. DWORD* XData=new DWORD[a_pnXrayData->GetLength(0)];
  76. for (auto i = 0; i < a_pnXrayData->GetLength(0);i++)
  77. {
  78. XData[i] = a_pnXrayData[i];
  79. }
  80. if (m_PosXray != nullptr)
  81. {
  82. m_PosXray->get()->SetXrayData(XData);
  83. }
  84. }
  85. DWORD CPosXrayClr::GetTotalCount()
  86. {
  87. CPosXrayPtr pPosXray = GetPosXrayPtr();
  88. return pPosXray->GetTotalCount();
  89. }
  90. void CPosXrayClr::GetMaxHeightPosition(long % a_nMaxHeight, long % a_nPosition)
  91. {
  92. CPosXrayPtr pPosXray = GetPosXrayPtr();
  93. long nMaxHeight, nPosition;
  94. pPosXray->GetMaxHeightPosition(nMaxHeight, nPosition);
  95. a_nMaxHeight = nMaxHeight;
  96. a_nPosition = nPosition;
  97. }
  98. // clear the x-ray data
  99. // if start position is [0, GENERALXRAYCHANNELS - 1], will do the clear
  100. void CPosXrayClr::ClearXrayData(long a_nStartPos)
  101. {
  102. CPosXrayPtr pPosXray = GetPosXrayPtr();
  103. pPosXray->ClearXrayData(a_nStartPos);
  104. }
  105. // set x-ray data at channel
  106. void CPosXrayClr::SetXrayDataAtChannel(DWORD a_nXray, long a_nChannel)
  107. {
  108. if (this == nullptr)
  109. {
  110. LogErrorTrace(__FILE__, __LINE__, _T("GetTotalCount: empty pointer."));
  111. }
  112. CPosXrayPtr pPosXray = GetPosXrayPtr();
  113. pPosXray->SetXrayDataAtChannel(a_nXray, a_nChannel);
  114. }
  115. System::Drawing::Point^ CPosXrayClr::GetPosition()
  116. {
  117. auto p = m_PosXray->get()->GetPosition();
  118. System::Drawing::Point^ pnt = gcnew System::Drawing::Point(p.x, p.y);
  119. return pnt;
  120. }
  121. void CPosXrayClr::SetPosition(System::Drawing::Point^ a_pRect)
  122. {
  123. m_PosXray->get()->SetPosition(CPoint(a_pRect->X, a_pRect->Y));
  124. }
  125. long CPosXrayClr::GetIndex()
  126. {
  127. int nIndex = -1;
  128. if (m_PosXray != nullptr)
  129. {
  130. nIndex = (int)m_PosXray->get()->GetIndex();
  131. }
  132. return nIndex;
  133. }
  134. void CPosXrayClr::SetIndex(long a_nIndex)
  135. {
  136. if (m_PosXray != nullptr)
  137. {
  138. m_PosXray->get()->SetIndex(a_nIndex);
  139. }
  140. }
  141. long CPosXrayClr::GetScanFieldId()
  142. {
  143. int nScanFieldId = -1;
  144. if (m_PosXray != nullptr)
  145. {
  146. nScanFieldId = (int)m_PosXray->get()->GetScanFieldId();
  147. }
  148. return nScanFieldId;
  149. }
  150. void CPosXrayClr::SetScanFieldId(long a_nScanfieldId)
  151. {
  152. if (m_PosXray != nullptr)
  153. {
  154. m_PosXray->get()->SetScanFieldId(a_nScanfieldId);
  155. }
  156. }
  157. long CPosXrayClr::GetPartTagId()
  158. {
  159. int nPartTagId = -1;
  160. if (m_PosXray != nullptr)
  161. {
  162. nPartTagId = m_PosXray->get()->GetPartTagId();
  163. }
  164. return nPartTagId;
  165. }
  166. void CPosXrayClr::SetPartTagId(long a_nPartTagId)
  167. {
  168. if (m_PosXray != nullptr)
  169. {
  170. m_PosXray->get()->SetScanFieldId(a_nPartTagId);
  171. }
  172. }
  173. long CPosXrayClr::GetFeatureId()
  174. {
  175. int nFeatureId = -1;
  176. if (m_PosXray != nullptr)
  177. {
  178. nFeatureId = (int)m_PosXray->get()->GetFeatureId();
  179. }
  180. return nFeatureId;
  181. }
  182. void CPosXrayClr::SetFeatureId(long a_nFeatureId)
  183. {
  184. if (m_PosXray != nullptr)
  185. {
  186. m_PosXray->get()->SetScanFieldId(a_nFeatureId);
  187. }
  188. }
  189. CElementChemistryListClr^ CPosXrayClr::GetElementQuantifyData()
  190. {
  191. CElementChemistryListClr^ ElementChemistryListClr = gcnew CElementChemistryListClr();
  192. auto eleQtyData = m_PosXray->get()->GetElementQuantifyData();
  193. if (m_PosXray != nullptr)
  194. {
  195. for (auto i = 0; i < eleQtyData.size(); i++)
  196. {
  197. ElementChemistryListClr->Add(gcnew CElementChemistryClr(eleQtyData[i]));
  198. }
  199. }
  200. return ElementChemistryListClr;
  201. }
  202. // element quantify data
  203. void CPosXrayClr::SetElementQuantifyData(CElementChemistryListClr^ a_listElementQuantifyData)
  204. {
  205. ASSERT(a_listElementQuantifyData);
  206. if (!a_listElementQuantifyData)
  207. {
  208. LogErrorTrace(__FILE__, __LINE__, _T("SetElementQuantifyData: invalid feature pointer."));
  209. return;
  210. }
  211. CElementChemistriesList chemiList;
  212. for (int i = 0; i < a_listElementQuantifyData->Count; i++)
  213. {
  214. chemiList.push_back(a_listElementQuantifyData[i]->GetElementChemistryPtr());
  215. }
  216. m_PosXray->get()->SetElementQuantifyData(chemiList);
  217. }
  218. void CPosXrayClr::AddQuantifyElement(CElementChemistryClr^ che)
  219. {
  220. m_PosXray->get()->AddQuantifyElement(che->GetElementChemistryPtr());
  221. }
  222. void CPosXrayClr::NormalizeXrayQuantifyData()
  223. {
  224. CPosXrayPtr pPosXray = GetPosXrayPtr();
  225. ASSERT(pPosXray);
  226. if (!pPosXray)
  227. {
  228. LogErrorTrace(__FILE__, __LINE__, _T("NormalizeXrayQuantifyData: Can't get pointer."));
  229. return;
  230. }
  231. pPosXray->NormalizeXrayQuantifyData();
  232. }
  233. void CPosXrayClr::SetElementNum(int num)
  234. {
  235. m_PosXray->get()->SetElementNum(num);
  236. }
  237. int CPosXrayClr::GetElementNum()
  238. {
  239. return m_PosXray->get()->GetElementNum();
  240. }
  241. }