OTSParticleClr.cpp 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. #pragma once
  2. #include "stdafx.h"
  3. #include "OTSParticleClr.h"
  4. #include "../OTSLog/COTSUtilityDllFunExport.h"
  5. namespace OTSCLRINTERFACE {
  6. COTSParticleClr::COTSParticleClr()
  7. {
  8. m_Particle = new COTSParticlePtr(new COTSParticle());
  9. }
  10. COTSParticleClr::COTSParticleClr(COTSParticlePtr pParticle) // copy constructor
  11. {
  12. ASSERT(pParticle);
  13. if (!pParticle)
  14. {
  15. LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed."));
  16. return;
  17. }
  18. m_Particle = new COTSParticlePtr(pParticle);
  19. }
  20. COTSParticleClr::COTSParticleClr(COTSParticleClr^ a_pSource)
  21. {
  22. auto src = a_pSource->GetOTSParticlePtr();
  23. m_Particle = new COTSParticlePtr(new COTSParticle(src.get()));
  24. }
  25. COTSParticleClr::COTSParticleClr(COTSParticle* a_pSource) // copy constructor
  26. {
  27. ASSERT(a_pSource);
  28. if (!a_pSource)
  29. {
  30. LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed."));
  31. return;
  32. }
  33. m_Particle = new COTSParticlePtr(new COTSParticle(a_pSource));
  34. }
  35. COTSParticleClr::~COTSParticleClr()
  36. {
  37. if (m_Particle != nullptr)
  38. {
  39. delete m_Particle;
  40. m_Particle = nullptr;
  41. }
  42. }
  43. COTSParticleClr::!COTSParticleClr()
  44. {
  45. if (m_Particle != nullptr)
  46. {
  47. delete m_Particle;
  48. m_Particle = nullptr;
  49. }
  50. }
  51. COTSParticlePtr COTSParticleClr::GetOTSParticlePtr()
  52. {
  53. return *m_Particle;
  54. }
  55. System::Drawing::Rectangle^ COTSParticleClr::GetParticleRect()
  56. {
  57. COTSParticlePtr prt = *m_Particle;
  58. CRect Crec = prt->GetParticleRect();
  59. System::Drawing::Rectangle^ r = gcnew System::Drawing::Rectangle((int)Crec.left, (int)Crec.top, (int)Crec.Width(), (int)Crec.Height());
  60. return r;
  61. }
  62. void COTSParticleClr::SetParticleRect(System::Drawing::Rectangle^ a_rectParticle)
  63. {
  64. CRect r(a_rectParticle->Left, a_rectParticle->Top, a_rectParticle->Right, a_rectParticle->Bottom);
  65. m_Particle->get()->SetParticleRect(r);
  66. }
  67. int COTSParticleClr::GetType()
  68. {
  69. int nType = -1;
  70. if (m_Particle != nullptr)
  71. {
  72. nType =(int) m_Particle->get()->GetType();
  73. }
  74. return nType;
  75. }
  76. void COTSParticleClr::SetType(int a_nType)
  77. {
  78. if (m_Particle != nullptr)
  79. {
  80. m_Particle->get()->SetType((OTS_PARTICLE_TYPE)a_nType);
  81. }
  82. }
  83. int COTSParticleClr::GetClassifyId()
  84. {
  85. int nType = -1;
  86. if (m_Particle != nullptr)
  87. {
  88. nType = m_Particle->get()->GetClassifyId();
  89. }
  90. return nType;
  91. }
  92. void COTSParticleClr::SetClassifyId(int a_nType)
  93. {
  94. if (m_Particle != nullptr)
  95. {
  96. m_Particle->get()->SetClassifyId(a_nType);
  97. }
  98. }
  99. double COTSParticleClr::GetActualArea()
  100. {
  101. double nArea = -1;
  102. if (m_Particle != nullptr)
  103. {
  104. nArea = m_Particle->get()->GetActualArea();
  105. }
  106. return nArea;
  107. }
  108. double COTSParticleClr::GetPixelArea()
  109. {
  110. double nArea = -1;
  111. if (m_Particle != nullptr)
  112. {
  113. nArea = m_Particle->get()->GetPixelArea();
  114. }
  115. return nArea;
  116. }
  117. void COTSParticleClr::SetActualArea(double a_dArea)
  118. {
  119. if (m_Particle != nullptr)
  120. {
  121. m_Particle->get()->SetActualArea(a_dArea);
  122. }
  123. }
  124. BYTE COTSParticleClr::GetAveGray()
  125. {
  126. BYTE nAveGray = -1;
  127. if (m_Particle != nullptr)
  128. {
  129. nAveGray = m_Particle->get()->GetAveGray();
  130. }
  131. return nAveGray;
  132. }
  133. void COTSParticleClr::SetAveGray(BYTE a_cAveGray)
  134. {
  135. if (m_Particle != nullptr)
  136. {
  137. m_Particle->get()->SetAveGray(a_cAveGray);
  138. }
  139. }
  140. Point^ COTSParticleClr::GetXRayPos()
  141. {
  142. Point^ XRayPosClr;
  143. if (m_Particle != nullptr)
  144. {
  145. CPoint P = m_Particle->get()->GetXRayPos();
  146. XRayPosClr = gcnew Point(P.x, P.y);
  147. }
  148. return XRayPosClr;
  149. }
  150. void COTSParticleClr::SetXRayPos(Point^ a_pXRayPos)
  151. {
  152. ASSERT(a_pXRayPos);
  153. if (!a_pXRayPos)
  154. {
  155. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  156. }
  157. if (m_Particle != nullptr)
  158. {
  159. CPoint P = CPoint(a_pXRayPos->X, a_pXRayPos->Y);
  160. m_Particle->get()->SetXRayPos(P);
  161. }
  162. }
  163. cli::array<System::Drawing::Point^>^ COTSParticleClr::GetXrayMatrixPoints()
  164. {
  165. auto ps = m_Particle->get()->GetXrayMatrixPoints();
  166. cli::array<System::Drawing::Point^>^ matrixPs = gcnew cli::array<System::Drawing::Point^>(ps.size());
  167. int i=0;
  168. for (auto p : ps)
  169. {
  170. System::Drawing::Point^ p1 = gcnew System::Drawing::Point(p.x, p.y);
  171. matrixPs[i] = p1;
  172. i++;
  173. }
  174. return matrixPs;
  175. }
  176. void COTSParticleClr::SetXrayMatrixPoints(cli::array<System::Drawing::Point^>^ points)
  177. {
  178. std::vector<CPoint> matrixPs;
  179. int L = points->Length;
  180. for (int i = 0; i < L; i++)
  181. {
  182. CPoint p = CPoint(points[i]->X, points[i]->Y);
  183. matrixPs.push_back(p);
  184. }
  185. m_Particle->get()->SetXrayMatrixPoints(matrixPs);
  186. }
  187. /*cli::array<CPosXrayClr^>^ COTSParticleClr::GetXrayMatrixInfo()
  188. {
  189. auto xrayInfos = m_Particle->get()->GetMatrixXrayInfo();
  190. cli::array<CPosXrayClr^>^ xrayClrs = gcnew cli::array<CPosXrayClr^>(xrayInfos.size());
  191. int i = 0;
  192. for (auto p : xrayInfos)
  193. {
  194. CPosXrayClr^ xrayInfo = gcnew CPosXrayClr(p);
  195. xrayClrs[i] = xrayInfo;
  196. }
  197. return xrayClrs;
  198. }*/
  199. /*void COTSParticleClr::SetXrayMatrixInfo(cli::array<CPosXrayClr^>^ xrayInfos)
  200. {
  201. std::vector<CPosXrayPtr> matrixXray;
  202. int L = xrayInfos->Length;
  203. for (int i = 0; i < L; i++)
  204. {
  205. CPosXrayPtr p = xrayInfos[i]->GetPosXrayPtr();
  206. matrixXray.push_back(p);
  207. }
  208. m_Particle->get()->SetMatrixXrayInfo(matrixXray);
  209. }*/
  210. void COTSParticleClr::SetAbsolutPos(System::Drawing::Point^ a_pAbsPos)
  211. {
  212. m_Particle->get()->SetAbsolutePos(CPoint(a_pAbsPos->X, a_pAbsPos->Y));
  213. }
  214. COTSFeatureClr^ COTSParticleClr::GetFeature()
  215. {
  216. COTSFeatureClr^ FeatureClr;
  217. if (m_Particle != nullptr)
  218. {
  219. COTSFeaturePtr Feature = m_Particle->get()->GetFeature();
  220. FeatureClr = gcnew COTSFeatureClr(Feature);
  221. }
  222. return FeatureClr;
  223. }
  224. void COTSParticleClr::SetFeature(COTSFeatureClr^ a_pFeautre)
  225. {
  226. ASSERT(a_pFeautre);
  227. if (!a_pFeautre)
  228. {
  229. LogErrorTrace(__FILE__, __LINE__, _T("SetFeature: invalid feature pointer."));
  230. return;
  231. }
  232. if (m_Particle != nullptr)
  233. {
  234. COTSFeaturePtr pSetElement = a_pFeautre->GetOTSFeaturePtr();
  235. ASSERT(pSetElement);
  236. if (!pSetElement)
  237. {
  238. LogErrorTrace(__FILE__, __LINE__, _T("SetElement: invalid part Element pointer."));
  239. return;
  240. }
  241. m_Particle->get()->SetFeature(pSetElement);
  242. }
  243. }
  244. void COTSParticleClr::SetXray(CPosXrayClr^ xray)
  245. {
  246. m_Particle->get()->SetXrayInfo(xray->GetPosXrayPtr());
  247. }
  248. CPosXrayClr^ COTSParticleClr::GetXray()
  249. {
  250. auto xray = m_Particle->get()->GetXrayInfo();
  251. if (xray != nullptr)
  252. {
  253. return gcnew CPosXrayClr(m_Particle->get()->GetXrayInfo());
  254. }
  255. else
  256. {
  257. return gcnew CPosXrayClr();
  258. }
  259. }
  260. int COTSParticleClr::GetParticleId()
  261. {
  262. int nTagId = -1;
  263. if (m_Particle != nullptr)
  264. {
  265. nTagId = m_Particle->get()->GetParticleId();
  266. }
  267. return nTagId;
  268. }
  269. void COTSParticleClr::SetParticleId(int a_nTagId)
  270. {
  271. if (m_Particle != nullptr)
  272. {
  273. m_Particle->get()->SetParticleId(a_nTagId);
  274. }
  275. }
  276. int COTSParticleClr::GetSearchId()
  277. {
  278. int SearchId = -1;
  279. if (m_Particle != nullptr)
  280. {
  281. SearchId = m_Particle->get()->GetSearchId();
  282. }
  283. return SearchId;
  284. }
  285. void COTSParticleClr::SetSearchId(int a_nSearchId)
  286. {
  287. if (m_Particle != nullptr)
  288. {
  289. m_Particle->get()->SetSearchtId(a_nSearchId);
  290. }
  291. }
  292. int COTSParticleClr::GetAnalysisId()
  293. {
  294. int AnalysisId = -1;
  295. if (m_Particle != nullptr)
  296. {
  297. AnalysisId = m_Particle->get()->GetAnalysisId();
  298. }
  299. return AnalysisId;
  300. }
  301. void COTSParticleClr::SetAnalysisId(int a_nAnalysisId)
  302. {
  303. if (m_Particle != nullptr)
  304. {
  305. m_Particle->get()->SetAnalysisId(a_nAnalysisId);
  306. }
  307. }
  308. int COTSParticleClr::GetFieldId()
  309. {
  310. int FieldId = -1;
  311. if (m_Particle != nullptr)
  312. {
  313. FieldId = m_Particle->get()->GetFieldId();
  314. }
  315. return FieldId;
  316. }
  317. void COTSParticleClr::SetFieldId(int a_nFieldId)
  318. {
  319. if (m_Particle != nullptr)
  320. {
  321. m_Particle->get()->SetFieldId(a_nFieldId);
  322. }
  323. }
  324. }