OTSParticleClr.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. void COTSParticleClr::SetArea(double a_dArea)
  109. {
  110. if (m_Particle != nullptr)
  111. {
  112. m_Particle->get()->SetActualArea(a_dArea);
  113. }
  114. }
  115. BYTE COTSParticleClr::GetAveGray()
  116. {
  117. BYTE nAveGray = -1;
  118. if (m_Particle != nullptr)
  119. {
  120. nAveGray = m_Particle->get()->GetAveGray();
  121. }
  122. return nAveGray;
  123. }
  124. void COTSParticleClr::SetAveGray(BYTE a_cAveGray)
  125. {
  126. if (m_Particle != nullptr)
  127. {
  128. m_Particle->get()->SetAveGray(a_cAveGray);
  129. }
  130. }
  131. Point^ COTSParticleClr::GetXRayPos()
  132. {
  133. Point^ XRayPosClr;
  134. if (m_Particle != nullptr)
  135. {
  136. CPoint P = m_Particle->get()->GetXRayPos();
  137. XRayPosClr = gcnew Point(P.x, P.y);
  138. }
  139. return XRayPosClr;
  140. }
  141. void COTSParticleClr::SetXRayPos(Point^ a_pXRayPos)
  142. {
  143. ASSERT(a_pXRayPos);
  144. if (!a_pXRayPos)
  145. {
  146. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  147. }
  148. if (m_Particle != nullptr)
  149. {
  150. CPoint P = CPoint(a_pXRayPos->X, a_pXRayPos->Y);
  151. m_Particle->get()->SetXRayPos(P);
  152. }
  153. }
  154. void COTSParticleClr::SetAbsolutPos(System::Drawing::Point^ a_pAbsPos)
  155. {
  156. m_Particle->get()->SetAbsolutePos(CPoint(a_pAbsPos->X, a_pAbsPos->Y));
  157. }
  158. COTSFeatureClr^ COTSParticleClr::GetFeature()
  159. {
  160. COTSFeatureClr^ FeatureClr;
  161. if (m_Particle != nullptr)
  162. {
  163. COTSFeaturePtr Feature = m_Particle->get()->GetFeature();
  164. FeatureClr = gcnew COTSFeatureClr(Feature);
  165. }
  166. return FeatureClr;
  167. }
  168. void COTSParticleClr::SetFeature(COTSFeatureClr^ a_pFeautre)
  169. {
  170. ASSERT(a_pFeautre);
  171. if (!a_pFeautre)
  172. {
  173. LogErrorTrace(__FILE__, __LINE__, _T("SetFeature: invalid feature pointer."));
  174. return;
  175. }
  176. if (m_Particle != nullptr)
  177. {
  178. COTSFeaturePtr pSetElement = a_pFeautre->GetOTSFeaturePtr();
  179. ASSERT(pSetElement);
  180. if (!pSetElement)
  181. {
  182. LogErrorTrace(__FILE__, __LINE__, _T("SetElement: invalid part Element pointer."));
  183. return;
  184. }
  185. m_Particle->get()->SetFeature(pSetElement);
  186. }
  187. }
  188. void COTSParticleClr::SetXray(CPosXrayClr^ xray)
  189. {
  190. m_Particle->get()->SetXrayInfo(xray->GetPosXrayPtr());
  191. }
  192. CPosXrayClr^ COTSParticleClr::GetXray()
  193. {
  194. auto xray = m_Particle->get()->GetXrayInfo();
  195. if (xray != nullptr)
  196. {
  197. return gcnew CPosXrayClr(m_Particle->get()->GetXrayInfo());
  198. }
  199. else
  200. {
  201. return gcnew CPosXrayClr();
  202. }
  203. }
  204. int COTSParticleClr::GetTagId()
  205. {
  206. int nTagId = -1;
  207. if (m_Particle != nullptr)
  208. {
  209. nTagId = m_Particle->get()->GetTagId();
  210. }
  211. return nTagId;
  212. }
  213. void COTSParticleClr::SetTagId(int a_nTagId)
  214. {
  215. if (m_Particle != nullptr)
  216. {
  217. m_Particle->get()->SetTagId(a_nTagId);
  218. }
  219. }
  220. int COTSParticleClr::GetSearchId()
  221. {
  222. int SearchId = -1;
  223. if (m_Particle != nullptr)
  224. {
  225. SearchId = m_Particle->get()->GetSearchId();
  226. }
  227. return SearchId;
  228. }
  229. void COTSParticleClr::SetSearchId(int a_nSearchId)
  230. {
  231. if (m_Particle != nullptr)
  232. {
  233. m_Particle->get()->SetSearchtId(a_nSearchId);
  234. }
  235. }
  236. int COTSParticleClr::GetAnalysisId()
  237. {
  238. int AnalysisId = -1;
  239. if (m_Particle != nullptr)
  240. {
  241. AnalysisId = m_Particle->get()->GetAnalysisId();
  242. }
  243. return AnalysisId;
  244. }
  245. void COTSParticleClr::SetAnalysisId(int a_nAnalysisId)
  246. {
  247. if (m_Particle != nullptr)
  248. {
  249. m_Particle->get()->SetAnalysisId(a_nAnalysisId);
  250. }
  251. }
  252. int COTSParticleClr::GetFieldId()
  253. {
  254. int FieldId = -1;
  255. if (m_Particle != nullptr)
  256. {
  257. FieldId = m_Particle->get()->GetFieldId();
  258. }
  259. return FieldId;
  260. }
  261. void COTSParticleClr::SetFieldId(int a_nFieldId)
  262. {
  263. if (m_Particle != nullptr)
  264. {
  265. m_Particle->get()->SetFieldId(a_nFieldId);
  266. }
  267. }
  268. }