123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- #include "stdafx.h"
- #include "PosXrayClr.h"
- #include <COTSUtilityDllFunExport.h>
- namespace OTSCLRINTERFACE {
- 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(CPosXrayClr^ a_pSource)
- {
- auto src = a_pSource->GetPosXrayPtr();
- m_PosXray = new CPosXrayPtr(new CPosXray(src.get()));
- }
- 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<DWORD>^ CPosXrayClr::GetXrayData()
- {
- array<DWORD>^ XrayData;
- if (m_PosXray != nullptr)
- {
- DWORD* XData = m_PosXray->get()->GetXrayData();
- XrayData = gcnew array<DWORD>(m_PosXray->get()->GetChannelsNum ());
- for (int i = 0; i < m_PosXray->get()->GetChannelsNum(); i++)
- {
- XrayData[i] = XData[i];
- }
- }
- return XrayData;
- }
- void CPosXrayClr::SetXrayData(cli::array<DWORD>^ 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);
- }
- System::Drawing::Point^ CPosXrayClr::GetPosition()
- {
- auto p = m_PosXray->get()->GetPosition();
- System::Drawing::Point^ pnt = gcnew System::Drawing::Point(p.x, p.y);
- return pnt;
- }
- void CPosXrayClr::SetPosition(System::Drawing::Point^ a_pRect)
- {
- m_PosXray->get()->SetPosition(CPoint(a_pRect->X, a_pRect->Y));
- }
- long CPosXrayClr::GetIndex()
- {
- int nIndex = -1;
- if (m_PosXray != nullptr)
- {
- nIndex = (int)m_PosXray->get()->GetIndex();
- }
- return nIndex;
- }
- void CPosXrayClr::SetIndex(long a_nIndex)
- {
- if (m_PosXray != nullptr)
- {
- m_PosXray->get()->SetIndex(a_nIndex);
- }
- }
- long CPosXrayClr::GetScanFieldId()
- {
- int nScanFieldId = -1;
- if (m_PosXray != nullptr)
- {
- nScanFieldId = (int)m_PosXray->get()->GetScanFieldId();
- }
- return nScanFieldId;
- }
- void CPosXrayClr::SetScanFieldId(long a_nScanfieldId)
- {
- if (m_PosXray != nullptr)
- {
- m_PosXray->get()->SetScanFieldId(a_nScanfieldId);
- }
- }
- long CPosXrayClr::GetPartTagId()
- {
- int nPartTagId = -1;
- if (m_PosXray != nullptr)
- {
- nPartTagId = m_PosXray->get()->GetPartTagId();
- }
- return nPartTagId;
- }
- void CPosXrayClr::SetPartTagId(long a_nPartTagId)
- {
- if (m_PosXray != nullptr)
- {
- m_PosXray->get()->SetScanFieldId(a_nPartTagId);
- }
- }
- long CPosXrayClr::GetFeatureId()
- {
- int nFeatureId = -1;
- if (m_PosXray != nullptr)
- {
- nFeatureId = (int)m_PosXray->get()->GetFeatureId();
- }
- return nFeatureId;
- }
- void CPosXrayClr::SetFeatureId(long a_nFeatureId)
- {
- if (m_PosXray != nullptr)
- {
- m_PosXray->get()->SetScanFieldId(a_nFeatureId);
- }
- }
- 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;
- }
- String^ CPosXrayClr::GetQuantifiedElementsStr()
- {
- return gcnew String(m_PosXray->get()->GetQuantifiedElementsStr());
- }
- // element quantify data
- void CPosXrayClr::SetElementQuantifyData(CElementChemistryListClr^ a_listElementQuantifyData)
- {
- ASSERT(a_listElementQuantifyData);
- if (!a_listElementQuantifyData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetElementQuantifyData: invalid feature pointer."));
- return;
- }
- CElementChemistriesList chemiList;
- for (int i = 0; i < a_listElementQuantifyData->Count; i++)
- {
- chemiList.push_back(a_listElementQuantifyData[i]->GetElementChemistryPtr());
- }
- m_PosXray->get()->SetElementQuantifyData(chemiList);
- }
- void CPosXrayClr::AddQuantifyElement(CElementChemistryClr^ che)
- {
- m_PosXray->get()->AddQuantifyElement(che->GetElementChemistryPtr());
- }
- void CPosXrayClr::NormalizeXrayQuantifyData()
- {
- CPosXrayPtr pPosXray = GetPosXrayPtr();
- ASSERT(pPosXray);
- if (!pPosXray)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("NormalizeXrayQuantifyData: Can't get pointer."));
- return;
- }
- pPosXray->NormalizeXrayQuantifyData();
- }
- void CPosXrayClr::SetElementNum(int num)
- {
- m_PosXray->get()->SetElementNum(num);
- }
- int CPosXrayClr::GetElementNum()
- {
- return m_PosXray->get()->GetElementNum();
- }
- }
|