PosXrayClr.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #include "stdafx.h"
  2. #include "PosXrayClr.h"
  3. namespace OTSINTERFACE {
  4. CPosXrayClr::CPosXrayClr() // constructor
  5. {
  6. m_PosXray = new CPosXrayPtr(new CPosXray());
  7. }
  8. CPosXrayClr::CPosXrayClr(CPosXrayPtr a_pPosXray) // copy constructor
  9. {
  10. ASSERT(a_pPosXray);
  11. if (!a_pPosXray)
  12. {
  13. LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed."));
  14. return;
  15. }
  16. m_PosXray = new CPosXrayPtr(a_pPosXray);
  17. }
  18. CPosXrayPtr CPosXrayClr::GetPosXrayPtr()
  19. {
  20. return *m_PosXray;
  21. }
  22. CPosXrayClr::CPosXrayClr(CPosXray* 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_PosXray = new CPosXrayPtr(new CPosXray(a_pSource));
  31. }
  32. CPosXrayClr::~CPosXrayClr()
  33. {
  34. if (m_PosXray != nullptr)
  35. {
  36. delete m_PosXray;
  37. m_PosXray = nullptr;
  38. }
  39. }
  40. CPosXrayClr::!CPosXrayClr()
  41. {
  42. if (m_PosXray != nullptr)
  43. {
  44. delete m_PosXray;
  45. m_PosXray = nullptr;
  46. }
  47. }
  48. array<DWORD>^ CPosXrayClr::GetXrayData()
  49. {
  50. array<DWORD>^ XrayData;
  51. if (m_PosXray != nullptr)
  52. {
  53. DWORD* XData = m_PosXray->get()->GetXrayData();
  54. XrayData = gcnew array<DWORD>(m_PosXray->get()->GetChannelsNo ());
  55. for (int i = 0; i < m_PosXray->get()->GetChannelsNo(); i++)
  56. {
  57. XrayData[i] = XData[i];
  58. }
  59. }
  60. return XrayData;
  61. }
  62. long CPosXrayClr::GetIndex()
  63. {
  64. return m_PosXray->get()->GetIndex();
  65. }
  66. CElementChemistryListClr^ CPosXrayClr::GetElementQuantifyData()
  67. {
  68. CElementChemistryListClr^ ElementChemistryListClr = gcnew CElementChemistryListClr();
  69. auto eleQtyData = m_PosXray->get()->GetElementQuantifyData();
  70. if (m_PosXray != nullptr)
  71. {
  72. for (auto i = 0; i < eleQtyData.size(); i++)
  73. {
  74. ElementChemistryListClr->Add(gcnew CElementChemistryClr(eleQtyData[i]));
  75. }
  76. }
  77. return ElementChemistryListClr;
  78. }
  79. void CPosXrayClr::SetXrayData(cli::array<DWORD>^ a_pnXrayData)
  80. {
  81. ASSERT(a_pnXrayData);
  82. if (!a_pnXrayData)
  83. {
  84. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  85. }
  86. DWORD* XData=new DWORD[a_pnXrayData->GetLength(0)];
  87. for (auto i = 0; i < a_pnXrayData->GetLength(0);i++)
  88. {
  89. XData[i] = a_pnXrayData[i];
  90. }
  91. if (m_PosXray != nullptr)
  92. {
  93. m_PosXray->get()->SetXrayData(XData);
  94. }
  95. }
  96. DWORD CPosXrayClr::GetTotalCount()
  97. {
  98. CPosXrayPtr pPosXray = GetPosXrayPtr();
  99. return pPosXray->GetTotalCount();
  100. }
  101. void CPosXrayClr::GetMaxHeightPosition(long % a_nMaxHeight, long % a_nPosition)
  102. {
  103. CPosXrayPtr pPosXray = GetPosXrayPtr();
  104. long nMaxHeight, nPosition;
  105. pPosXray->GetMaxHeightPosition(nMaxHeight, nPosition);
  106. a_nMaxHeight = nMaxHeight;
  107. a_nPosition = nPosition;
  108. }
  109. // clear the x-ray data
  110. // if start position is [0, GENERALXRAYCHANNELS - 1], will do the clear
  111. void CPosXrayClr::ClearXrayData(long a_nStartPos)
  112. {
  113. CPosXrayPtr pPosXray = GetPosXrayPtr();
  114. pPosXray->ClearXrayData(a_nStartPos);
  115. }
  116. // set x-ray data at channel
  117. void CPosXrayClr::SetXrayDataAtChannel(DWORD a_nXray, long a_nChannel)
  118. {
  119. if (this == nullptr)
  120. {
  121. LogErrorTrace(__FILE__, __LINE__, _T("GetTotalCount: empty pointer."));
  122. }
  123. CPosXrayPtr pPosXray = GetPosXrayPtr();
  124. pPosXray->SetXrayDataAtChannel(a_nXray, a_nChannel);
  125. }
  126. }