PosXrayInfoClr.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #include "stdafx.h"
  2. #include "PosXrayInfoClr.h"
  3. namespace OTSINTERFACE {
  4. CPosXrayInfoClr::CPosXrayInfoClr() // constructor
  5. {
  6. m_PosXrayInfo = new CPosXrayInfoPtr(new CPosXrayInfo());
  7. }
  8. CPosXrayInfoClr::CPosXrayInfoClr(CPosXrayInfoPtr a_pPosXrayInfo) // copy constructor
  9. {
  10. ASSERT(a_pPosXrayInfo);
  11. if (!a_pPosXrayInfo)
  12. {
  13. LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayInfoClr: Generate CPosXrayInfoClr pointer failed."));
  14. return;
  15. }
  16. m_PosXrayInfo = new CPosXrayInfoPtr(a_pPosXrayInfo);
  17. }
  18. CPosXrayInfoPtr CPosXrayInfoClr::GetPosXrayInfoPtr()
  19. {
  20. return *m_PosXrayInfo;
  21. }
  22. CPosXrayInfoClr::CPosXrayInfoClr(CPosXrayInfo* a_pSource) // copy constructor
  23. {
  24. ASSERT(a_pSource);
  25. if (!a_pSource)
  26. {
  27. LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed."));
  28. return;
  29. }
  30. m_PosXrayInfo = new CPosXrayInfoPtr(a_pSource);
  31. }
  32. CPosXrayInfoClr::~CPosXrayInfoClr()
  33. {
  34. if (m_PosXrayInfo != nullptr)
  35. {
  36. delete m_PosXrayInfo;
  37. m_PosXrayInfo = nullptr;
  38. }
  39. }
  40. CPosXrayInfoClr::!CPosXrayInfoClr()
  41. {
  42. if (m_PosXrayInfo != nullptr)
  43. {
  44. delete m_PosXrayInfo;
  45. m_PosXrayInfo = nullptr;
  46. }
  47. }
  48. System::Drawing::Point^CPosXrayInfoClr::GetPosition()
  49. {
  50. auto p= m_PosXrayInfo->get()->GetPosition();
  51. System::Drawing::Point^ pnt = gcnew System::Drawing::Point(p.x, p.y);
  52. return pnt;
  53. }
  54. void CPosXrayInfoClr::SetPosition(System::Drawing::Point^ a_pRect)
  55. {
  56. m_PosXrayInfo->get()->SetPosition(CPoint(a_pRect->X, a_pRect->Y));
  57. }
  58. long CPosXrayInfoClr::GetIndex()
  59. {
  60. int nIndex = -1;
  61. if (m_PosXrayInfo != nullptr)
  62. {
  63. nIndex = (int)m_PosXrayInfo->get()->GetIndex();
  64. }
  65. return nIndex;
  66. }
  67. void CPosXrayInfoClr::SetIndex(long a_nIndex)
  68. {
  69. if (m_PosXrayInfo != nullptr)
  70. {
  71. m_PosXrayInfo->get()->SetIndex(a_nIndex);
  72. }
  73. }
  74. long CPosXrayInfoClr::GetScanFieldId()
  75. {
  76. int nScanFieldId = -1;
  77. if (m_PosXrayInfo != nullptr)
  78. {
  79. nScanFieldId = (int)m_PosXrayInfo->get()->GetScanFieldId();
  80. }
  81. return nScanFieldId;
  82. }
  83. void CPosXrayInfoClr::SetScanFieldId(long a_nScanfieldId)
  84. {
  85. if (m_PosXrayInfo != nullptr)
  86. {
  87. m_PosXrayInfo->get()->SetScanFieldId(a_nScanfieldId);
  88. }
  89. }
  90. long CPosXrayInfoClr::GetPartTagId()
  91. {
  92. int nPartTagId = -1;
  93. if (m_PosXrayInfo != nullptr)
  94. {
  95. nPartTagId = (int)m_PosXrayInfo->get()->GetPartTagId();
  96. }
  97. return nPartTagId;
  98. }
  99. void CPosXrayInfoClr::SetPartTagId(long a_nPartTagId)
  100. {
  101. if (m_PosXrayInfo != nullptr)
  102. {
  103. m_PosXrayInfo->get()->SetScanFieldId(a_nPartTagId);
  104. }
  105. }
  106. long CPosXrayInfoClr::GetFeatureId()
  107. {
  108. int nFeatureId = -1;
  109. if (m_PosXrayInfo != nullptr)
  110. {
  111. nFeatureId = (int)m_PosXrayInfo->get()->GetFeatureId();
  112. }
  113. return nFeatureId;
  114. }
  115. void CPosXrayInfoClr::SetFeatureId(long a_nFeatureId)
  116. {
  117. if (m_PosXrayInfo != nullptr)
  118. {
  119. m_PosXrayInfo->get()->SetScanFieldId(a_nFeatureId);
  120. }
  121. }
  122. CElementChemistryListClr^ CPosXrayInfoClr::GetElementQuantifyData()
  123. {
  124. CElementChemistryListClr^ ElementChemistryListClr=gcnew CElementChemistryListClr();
  125. auto eleQtyData = m_PosXrayInfo->get()->GetElementQuantifyData();
  126. if (m_PosXrayInfo != nullptr)
  127. {
  128. for (auto i = 0; i < eleQtyData.size(); i++)
  129. {
  130. ElementChemistryListClr->Add(gcnew CElementChemistryClr(eleQtyData[i]));
  131. }
  132. }
  133. return ElementChemistryListClr;
  134. }
  135. // element quantify data
  136. void CPosXrayInfoClr::SetElementQuantifyData(CElementChemistryListClr^ a_listElementQuantifyData)
  137. {
  138. ASSERT(a_listElementQuantifyData);
  139. if (!a_listElementQuantifyData)
  140. {
  141. LogErrorTrace(__FILE__, __LINE__, _T("SetElementQuantifyData: invalid feature pointer."));
  142. return;
  143. }
  144. CElementChemistriesList chemiList;
  145. for (int i = 0; i < a_listElementQuantifyData->Count; i++)
  146. {
  147. chemiList[i] = a_listElementQuantifyData[i]->GetElementChemistryPtr();
  148. }
  149. m_PosXrayInfo->get()->SetElementQuantifyData(chemiList);
  150. }
  151. void CPosXrayInfoClr::NormalizeXrayQuantifyData()
  152. {
  153. CPosXrayInfoPtr pPosXrayInfo = GetPosXrayInfoPtr();
  154. ASSERT(pPosXrayInfo);
  155. if (!pPosXrayInfo)
  156. {
  157. LogErrorTrace(__FILE__, __LINE__, _T("NormalizeXrayQuantifyData: Can't get pointer."));
  158. return;
  159. }
  160. pPosXrayInfo->NormalizeXrayQuantifyData();
  161. }
  162. }