#include "stdafx.h" #include "PosXrayClr.h" namespace OTSINTERFACE { CPosXrayClr::CPosXrayClr() // constructor { m_PosXray = new CPosXrayPtr(new CPosXray()); } CPosXrayClr::CPosXrayClr(CPosXrayPtr a_pPosXray) // copy constructor { ASSERT(a_pPosXray); if (!a_pPosXray) { LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed.")); return; } m_PosXray = new CPosXrayPtr(a_pPosXray); } CPosXrayPtr CPosXrayClr::GetPosXrayPtr() { return *m_PosXray; } CPosXrayClr::CPosXrayClr(CPosXray* a_pSource) // copy constructor { ASSERT(a_pSource); if (!a_pSource) { LogErrorTrace(__FILE__, __LINE__, _T("CPosXrayClr: Generate CPosXrayClr pointer failed.")); return; } m_PosXray = new CPosXrayPtr(new CPosXray(a_pSource)); } CPosXrayClr::~CPosXrayClr() { if (m_PosXray != nullptr) { delete m_PosXray; m_PosXray = nullptr; } } CPosXrayClr::!CPosXrayClr() { if (m_PosXray != nullptr) { delete m_PosXray; m_PosXray = nullptr; } } array^ CPosXrayClr::GetXrayData() { array^ XrayData; if (m_PosXray != nullptr) { DWORD* XData = m_PosXray->get()->GetXrayData(); XrayData = gcnew array(m_PosXray->get()->GetChannelsNo ()); for (int i = 0; i < m_PosXray->get()->GetChannelsNo(); i++) { XrayData[i] = XData[i]; } } return XrayData; } long CPosXrayClr::GetIndex() { return m_PosXray->get()->GetIndex(); } CElementChemistryListClr^ CPosXrayClr::GetElementQuantifyData() { CElementChemistryListClr^ ElementChemistryListClr = gcnew CElementChemistryListClr(); auto eleQtyData = m_PosXray->get()->GetElementQuantifyData(); if (m_PosXray != nullptr) { for (auto i = 0; i < eleQtyData.size(); i++) { ElementChemistryListClr->Add(gcnew CElementChemistryClr(eleQtyData[i])); } } return ElementChemistryListClr; } void CPosXrayClr::SetXrayData(cli::array^ a_pnXrayData) { ASSERT(a_pnXrayData); if (!a_pnXrayData) { LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version.")); } DWORD* XData=new DWORD[a_pnXrayData->GetLength(0)]; for (auto i = 0; i < a_pnXrayData->GetLength(0);i++) { XData[i] = a_pnXrayData[i]; } if (m_PosXray != nullptr) { m_PosXray->get()->SetXrayData(XData); } } DWORD CPosXrayClr::GetTotalCount() { CPosXrayPtr pPosXray = GetPosXrayPtr(); return pPosXray->GetTotalCount(); } void CPosXrayClr::GetMaxHeightPosition(long % a_nMaxHeight, long % a_nPosition) { CPosXrayPtr pPosXray = GetPosXrayPtr(); long nMaxHeight, nPosition; pPosXray->GetMaxHeightPosition(nMaxHeight, nPosition); a_nMaxHeight = nMaxHeight; a_nPosition = nPosition; } // clear the x-ray data // if start position is [0, GENERALXRAYCHANNELS - 1], will do the clear void CPosXrayClr::ClearXrayData(long a_nStartPos) { CPosXrayPtr pPosXray = GetPosXrayPtr(); pPosXray->ClearXrayData(a_nStartPos); } // set x-ray data at channel void CPosXrayClr::SetXrayDataAtChannel(DWORD a_nXray, long a_nChannel) { if (this == nullptr) { LogErrorTrace(__FILE__, __LINE__, _T("GetTotalCount: empty pointer.")); } CPosXrayPtr pPosXray = GetPosXrayPtr(); pPosXray->SetXrayDataAtChannel(a_nXray, a_nChannel); } }