OTSParticleClr.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. #pragma once
  2. #include "OTSParticle.h"
  3. #include "OTSFeatureClr.h"
  4. #include <PosXrayClr.h>
  5. #include <msclr\marshal.h>
  6. #include <msclr\marshal_cppstd.h>
  7. namespace OTSCLRINTERFACE {
  8. using namespace System;
  9. using namespace System::Drawing;
  10. using namespace OTSDATA;
  11. using namespace msclr::interop;
  12. using namespace System::Runtime::InteropServices;
  13. public ref class COTSParticleClr
  14. {
  15. public:
  16. // constructor
  17. COTSParticleClr(); // constructor
  18. COTSParticleClr(COTSParticlePtr); // copy constructor
  19. COTSParticleClr(COTSParticleClr^);
  20. COTSParticleClr(COTSParticle*);
  21. ~COTSParticleClr();
  22. !COTSParticleClr();
  23. COTSParticlePtr GetOTSParticlePtr(); //can only be used in C++, because the original C++ type.
  24. // rectangle
  25. System::Drawing::Rectangle^ GetParticleRect();
  26. void SetParticleRect(System::Drawing::Rectangle^ a_rectParticle);
  27. void SetOTSRect(int left, int top, int right, int bottom);
  28. bool GetOTSRect(int% left, int% top, int% right, int% bottom);
  29. //Type
  30. int GetBasicClassifyId();
  31. void SetBasicClassifyId(int a_nType);
  32. //Type
  33. int GetTypeId();
  34. void SetTypeId(int a_nType);
  35. //area
  36. double GetActualArea();
  37. void SetActualArea(double a_dArea);
  38. double GetPixelArea();
  39. // gray
  40. BYTE GetAveGray();
  41. void SetAveGray(BYTE a_cAveGray);
  42. // x-ray position
  43. System::Drawing::Point^ GetXRayPos();
  44. void SetXRayPos(System::Drawing::Point^ a_pXRayPos);
  45. cli::array<System::Drawing::Point^>^ GetXrayMatrixPoints();
  46. void SetXrayMatrixPoints(cli::array<System::Drawing::Point^>^ points);
  47. void CalXrayPos()
  48. {
  49. m_Particle->get()->CalXRayPos();
  50. }
  51. void CalCoverRectFromSegment()
  52. {
  53. m_Particle->get()->CalCoverRectFromSegment();
  54. }
  55. void SetSEMPos(System::Drawing::Point^ a_pAbsPos);
  56. System::Drawing::Point^ GetSEMPos()
  57. {
  58. return gcnew System::Drawing::Point(m_Particle->get()->GetFieldSEMPos().x, m_Particle->get()->GetFieldSEMPos().y);
  59. }
  60. void SetFieldOTSPos(System::Drawing::Point^ a_pAbsPos);
  61. System::Drawing::Point^ GetFieldOTSPos()
  62. {
  63. return gcnew System::Drawing::Point(m_Particle->get()->GetOTSScanFieldPos().x, m_Particle->get()->GetOTSScanFieldPos().y);
  64. }
  65. // feature
  66. COTSFeatureClr^ GetFeature();
  67. void SetFeature(COTSFeatureClr^ a_pFeautre);
  68. void SetXray(CPosXrayClr^ xray);
  69. CPosXrayClr^ GetXray();
  70. // tag id
  71. int GetParticleId();
  72. void SetParticleId(int a_nTagId);
  73. // analysis id
  74. int GetAnalysisId();
  75. void SetAnalysisId(int a_nAnalysisId);
  76. // field id
  77. int GetFieldId();
  78. void SetFieldId(int a_nFieldId);
  79. double GetDMAX()
  80. {
  81. return m_Particle->get()->GetDMax();
  82. }
  83. void SetDMAX(double val)
  84. {
  85. return m_Particle->get()->SetDMax(val);
  86. }
  87. double GetDMIN()
  88. {
  89. return m_Particle->get()->GetDMin();
  90. }
  91. void SetDMIN(double val)
  92. {
  93. return m_Particle->get()->SetDMin(val);
  94. }
  95. double GetDMPERP()
  96. {
  97. return m_Particle->get()->GetDPerp();
  98. }
  99. void SetDMPERP(double val)
  100. {
  101. return m_Particle->get()->SetDPerp(val);
  102. }
  103. double GetDINSCR()
  104. {
  105. return m_Particle->get()->GetDInscr ();
  106. }
  107. void SetDINSCR(double val)
  108. {
  109. return m_Particle->get()->SetDInscr(val);
  110. }
  111. double GetDMEAN()
  112. {
  113. return m_Particle->get()->GetDMean();
  114. }
  115. void SetDMEAN(double val)
  116. {
  117. return m_Particle->get()->SetDMean(val);
  118. }
  119. double GetDELONG()
  120. {
  121. return m_Particle->get()->GetDElong();
  122. }
  123. void SetDELONG(double val)
  124. {
  125. return m_Particle->get()->SetDElong(val);
  126. }
  127. double GetDPRIMETER()
  128. {
  129. return m_Particle->get()->GetPerimeter();
  130. }
  131. void SetDPRIMETER(double val)
  132. {
  133. return m_Particle->get()->SetPerimeter(val);
  134. }
  135. double GetORIENTATION()
  136. {
  137. return m_Particle->get()->GetOrientation();
  138. }
  139. void SetORIENTATION(double val)
  140. {
  141. return m_Particle->get()->SetOrientation(val);
  142. }
  143. double GetEqualCircleDiameter()
  144. {
  145. return m_Particle->get()->GetEqualCircleDiameter();
  146. }
  147. double GetFeretDiameter()
  148. {
  149. return m_Particle->get()->GetFeretDiameter();
  150. }
  151. void SetFeretDiameter(double val)
  152. {
  153. return m_Particle->get()->SetFeretDiameter(val);
  154. }
  155. double CalculateSimilarity(COTSParticleClr^ part);
  156. String^ GetImgPortraitString()
  157. {
  158. return gcnew String(m_Particle->get()->GetImgPortraitString().c_str());
  159. }
  160. String^ GetTypeName()
  161. {
  162. return gcnew String(m_Particle->get()->GetTypeName().c_str());
  163. }
  164. void SetTypeName(String^ val)
  165. {
  166. std::string val1 = marshal_as<std::string>(val);
  167. return m_Particle->get()->SetTypeName(val1);
  168. }
  169. String^ GetTypeColor()
  170. {
  171. return gcnew String(m_Particle->get()->GetColor().c_str());
  172. }
  173. void SetTypeColor(String^ val)
  174. {
  175. std::string val1 = marshal_as<std::string>(val);
  176. return m_Particle->get()->SetColor(val1);
  177. }
  178. String^ GetConnectedParticlesName()
  179. {
  180. return gcnew String(m_Particle->get()->GetConnectedParticlesSequentialString().c_str());
  181. }
  182. void SetConnectedParticlesName(String^ val)
  183. {
  184. std::string val1 = marshal_as<std::string>(val);
  185. return m_Particle->get()->SetConnectedParticlesSequentialString(val1);
  186. }
  187. String^ GetGrpName()
  188. {
  189. return gcnew String(m_Particle->get()->GetGroupName().c_str());
  190. }
  191. void SetGrpName(String^ val)
  192. {
  193. std::string val1 = marshal_as<std::string>(val);
  194. return m_Particle->get()->SetGroupName(val1);
  195. }
  196. String^ GetGrpColor()
  197. {
  198. return gcnew String(m_Particle->get()->GetGroupColor().c_str());
  199. }
  200. void SetGrpColor(String^ val)
  201. {
  202. std::string val1 = marshal_as<std::string>(val);
  203. return m_Particle->get()->SetGroupColor(val1);
  204. }
  205. int GetGrpId()
  206. {
  207. return m_Particle->get()->GetGroupId();
  208. }
  209. void SetGrpId(int grpid)
  210. {
  211. m_Particle->get()->SetGroupId(grpid);
  212. }
  213. bool IsXrayParticle()
  214. {
  215. return m_Particle->get()->IsXrayParticle();
  216. }
  217. void SetIsXrayParticle(bool value)
  218. {
  219. m_Particle->get()->SetIsXrayParticle(value);
  220. }
  221. System::Collections::Generic::List<COTSParticleClr^>^ GetSubParticles()
  222. {
  223. System::Collections::Generic::List<COTSParticleClr^>^ clrparts = gcnew System::Collections::Generic::List<COTSParticleClr^>();
  224. auto parts = m_Particle->get()->GetSubParticles();
  225. for (auto p : parts)
  226. {
  227. auto clrPart = gcnew COTSParticleClr(p);
  228. clrparts->Add(clrPart);
  229. }
  230. return clrparts;
  231. }
  232. void SetSubParticles(System::Collections::Generic::List<COTSParticleClr^>^ clrParts)
  233. {
  234. m_Particle->get()->ClearSubParticles();
  235. for (int i=0;i<clrParts->Count;i++)
  236. {
  237. m_Particle->get()->AddSubParticle(clrParts[i]->GetOTSParticlePtr());
  238. }
  239. }
  240. void ClearSubParticles() { m_Particle->get()->ClearSubParticles(); }
  241. void AddSubParticle(COTSParticleClr^ particle) { m_Particle->get()->AddSubParticle(particle->GetOTSParticlePtr()); }
  242. bool IsConnected(COTSParticleClr^ a_p, int fldwidth, int fldheight, int direction)
  243. {
  244. return m_Particle->get()->IsConnected(a_p->GetOTSParticlePtr().get(), fldwidth, fldheight, direction);
  245. }
  246. protected:
  247. COTSParticlePtr* m_Particle;
  248. };
  249. typedef System::Collections::Generic::List<COTSParticleClr^> COTSParticleListClr;
  250. }