#pragma once #include "stdafx.h" #include "OTSParticleClr.h" #include "../OTSLog/COTSUtilityDllFunExport.h" namespace OTSCLRINTERFACE { COTSParticleClr::COTSParticleClr() { m_Particle = new COTSParticlePtr(new COTSParticle()); } COTSParticleClr::COTSParticleClr(COTSParticlePtr pParticle) // copy constructor { ASSERT(pParticle); if (!pParticle) { LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed.")); return; } m_Particle = new COTSParticlePtr(pParticle); } COTSParticleClr::COTSParticleClr(COTSParticleClr^ a_pSource) { auto src = a_pSource->GetOTSParticlePtr(); m_Particle = new COTSParticlePtr(new COTSParticle(src.get())); } COTSParticleClr::COTSParticleClr(COTSParticle* a_pSource) // copy constructor { ASSERT(a_pSource); if (!a_pSource) { LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed.")); return; } m_Particle = new COTSParticlePtr(new COTSParticle(a_pSource)); } COTSParticleClr::~COTSParticleClr() { if (m_Particle != nullptr) { delete m_Particle; m_Particle = nullptr; } } COTSParticleClr::!COTSParticleClr() { if (m_Particle != nullptr) { delete m_Particle; m_Particle = nullptr; } } COTSParticlePtr COTSParticleClr::GetOTSParticlePtr() { return *m_Particle; } System::Drawing::Rectangle^ COTSParticleClr::GetParticleRect() { COTSParticlePtr prt = *m_Particle; CRect Crec = prt->GetParticleRect(); System::Drawing::Rectangle^ r = gcnew System::Drawing::Rectangle((int)Crec.left, (int)Crec.top, (int)Crec.Width(), (int)Crec.Height()); return r; } void COTSParticleClr::SetParticleRect(System::Drawing::Rectangle^ a_rectParticle) { CRect r(a_rectParticle->Left, a_rectParticle->Top, a_rectParticle->Right, a_rectParticle->Bottom); m_Particle->get()->SetParticleRect(r); } int COTSParticleClr::GetType() { int nType = -1; if (m_Particle != nullptr) { nType =(int) m_Particle->get()->GetType(); } return nType; } void COTSParticleClr::SetType(int a_nType) { if (m_Particle != nullptr) { m_Particle->get()->SetType((OTS_PARTICLE_TYPE)a_nType); } } int COTSParticleClr::GetClassifyId() { int nType = -1; if (m_Particle != nullptr) { nType = m_Particle->get()->GetClassifyId(); } return nType; } void COTSParticleClr::SetClassifyId(int a_nType) { if (m_Particle != nullptr) { m_Particle->get()->SetClassifyId(a_nType); } } double COTSParticleClr::GetActualArea() { double nArea = -1; if (m_Particle != nullptr) { nArea = m_Particle->get()->GetActualArea(); } return nArea; } void COTSParticleClr::SetArea(double a_dArea) { if (m_Particle != nullptr) { m_Particle->get()->SetActualArea(a_dArea); } } BYTE COTSParticleClr::GetAveGray() { BYTE nAveGray = -1; if (m_Particle != nullptr) { nAveGray = m_Particle->get()->GetAveGray(); } return nAveGray; } void COTSParticleClr::SetAveGray(BYTE a_cAveGray) { if (m_Particle != nullptr) { m_Particle->get()->SetAveGray(a_cAveGray); } } Point^ COTSParticleClr::GetXRayPos() { Point^ XRayPosClr; if (m_Particle != nullptr) { CPoint P = m_Particle->get()->GetXRayPos(); XRayPosClr = gcnew Point(P.x, P.y); } return XRayPosClr; } void COTSParticleClr::SetXRayPos(Point^ a_pXRayPos) { ASSERT(a_pXRayPos); if (!a_pXRayPos) { LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version.")); } if (m_Particle != nullptr) { CPoint P = CPoint(a_pXRayPos->X, a_pXRayPos->Y); m_Particle->get()->SetXRayPos(P); } } void COTSParticleClr::SetAbsolutPos(System::Drawing::Point^ a_pAbsPos) { m_Particle->get()->SetAbsolutePos(CPoint(a_pAbsPos->X, a_pAbsPos->Y)); } COTSFeatureClr^ COTSParticleClr::GetFeature() { COTSFeatureClr^ FeatureClr; if (m_Particle != nullptr) { COTSFeaturePtr Feature = m_Particle->get()->GetFeature(); FeatureClr = gcnew COTSFeatureClr(Feature); } return FeatureClr; } void COTSParticleClr::SetFeature(COTSFeatureClr^ a_pFeautre) { ASSERT(a_pFeautre); if (!a_pFeautre) { LogErrorTrace(__FILE__, __LINE__, _T("SetFeature: invalid feature pointer.")); return; } if (m_Particle != nullptr) { COTSFeaturePtr pSetElement = a_pFeautre->GetOTSFeaturePtr(); ASSERT(pSetElement); if (!pSetElement) { LogErrorTrace(__FILE__, __LINE__, _T("SetElement: invalid part Element pointer.")); return; } m_Particle->get()->SetFeature(pSetElement); } } void COTSParticleClr::SetXray(CPosXrayClr^ xray) { m_Particle->get()->SetXrayInfo(xray->GetPosXrayPtr()); } CPosXrayClr^ COTSParticleClr::GetXray() { auto xray = m_Particle->get()->GetXrayInfo(); if (xray != nullptr) { return gcnew CPosXrayClr(m_Particle->get()->GetXrayInfo()); } else { return gcnew CPosXrayClr(); } } int COTSParticleClr::GetTagId() { int nTagId = -1; if (m_Particle != nullptr) { nTagId = m_Particle->get()->GetTagId(); } return nTagId; } void COTSParticleClr::SetTagId(int a_nTagId) { if (m_Particle != nullptr) { m_Particle->get()->SetTagId(a_nTagId); } } int COTSParticleClr::GetSearchId() { int SearchId = -1; if (m_Particle != nullptr) { SearchId = m_Particle->get()->GetSearchId(); } return SearchId; } void COTSParticleClr::SetSearchId(int a_nSearchId) { if (m_Particle != nullptr) { m_Particle->get()->SetSearchtId(a_nSearchId); } } int COTSParticleClr::GetAnalysisId() { int AnalysisId = -1; if (m_Particle != nullptr) { AnalysisId = m_Particle->get()->GetAnalysisId(); } return AnalysisId; } void COTSParticleClr::SetAnalysisId(int a_nAnalysisId) { if (m_Particle != nullptr) { m_Particle->get()->SetAnalysisId(a_nAnalysisId); } } int COTSParticleClr::GetFieldId() { int FieldId = -1; if (m_Particle != nullptr) { FieldId = m_Particle->get()->GetFieldId(); } return FieldId; } void COTSParticleClr::SetFieldId(int a_nFieldId) { if (m_Particle != nullptr) { m_Particle->get()->SetFieldId(a_nFieldId); } } }