OTSParticleClr.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 GetType();
  31. void SetType(int a_nType);
  32. //Type
  33. int GetClassifyId();
  34. void SetClassifyId(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()->GetSEMPos().x, m_Particle->get()->GetSEMPos().y);
  59. }
  60. // feature
  61. COTSFeatureClr^ GetFeature();
  62. void SetFeature(COTSFeatureClr^ a_pFeautre);
  63. void SetXray(CPosXrayClr^ xray);
  64. CPosXrayClr^ GetXray();
  65. // tag id
  66. int GetParticleId();
  67. void SetParticleId(int a_nTagId);
  68. // analysis id
  69. int GetAnalysisId();
  70. void SetAnalysisId(int a_nAnalysisId);
  71. // field id
  72. int GetFieldId();
  73. void SetFieldId(int a_nFieldId);
  74. double GetDMAX()
  75. {
  76. return m_Particle->get()->GetDMax();
  77. }
  78. void SetDMAX(double val)
  79. {
  80. return m_Particle->get()->SetDMax(val);
  81. }
  82. double GetDMIN()
  83. {
  84. return m_Particle->get()->GetDMin();
  85. }
  86. void SetDMIN(double val)
  87. {
  88. return m_Particle->get()->SetDMin(val);
  89. }
  90. double GetDMPERP()
  91. {
  92. return m_Particle->get()->GetDPerp();
  93. }
  94. void SetDMPERP(double val)
  95. {
  96. return m_Particle->get()->SetDPerp(val);
  97. }
  98. double GetDINSCR()
  99. {
  100. return m_Particle->get()->GetDInscr ();
  101. }
  102. void SetDINSCR(double val)
  103. {
  104. return m_Particle->get()->SetDInscr(val);
  105. }
  106. double GetDMEAN()
  107. {
  108. return m_Particle->get()->GetDMean();
  109. }
  110. void SetDMEAN(double val)
  111. {
  112. return m_Particle->get()->SetDMean(val);
  113. }
  114. double GetDELONG()
  115. {
  116. return m_Particle->get()->GetDElong();
  117. }
  118. void SetDELONG(double val)
  119. {
  120. return m_Particle->get()->SetDElong(val);
  121. }
  122. double GetDPRIMETER()
  123. {
  124. return m_Particle->get()->GetPerimeter();
  125. }
  126. void SetDPRIMETER(double val)
  127. {
  128. return m_Particle->get()->SetPerimeter(val);
  129. }
  130. double GetORIENTATION()
  131. {
  132. return m_Particle->get()->GetOrientation();
  133. }
  134. void SetORIENTATION(double val)
  135. {
  136. return m_Particle->get()->SetOrientation(val);
  137. }
  138. double GetEqualCircleDiameter()
  139. {
  140. return m_Particle->get()->GetEqualCircleDiameter();
  141. }
  142. double GetFeretDiameter()
  143. {
  144. return m_Particle->get()->GetFeretDiameter();
  145. }
  146. void SetFeretDiameter(double val)
  147. {
  148. return m_Particle->get()->SetFeretDiameter(val);
  149. }
  150. double CalculateSimilarity(COTSParticleClr^ part);
  151. String^ GetImgPortraitString()
  152. {
  153. return gcnew String(m_Particle->get()->GetImgPortraitString().c_str());
  154. }
  155. String^ GetTypeName()
  156. {
  157. return gcnew String(m_Particle->get()->GetClassifyName().c_str());
  158. }
  159. void SetTypeName(String^ val)
  160. {
  161. std::string val1 = marshal_as<std::string>(val);
  162. return m_Particle->get()->SetClassifyName(val1);
  163. }
  164. String^ GetTypeColor()
  165. {
  166. return gcnew String(m_Particle->get()->GetColor().c_str());
  167. }
  168. void SetTypeColor(String^ val)
  169. {
  170. std::string val1 = marshal_as<std::string>(val);
  171. return m_Particle->get()->SetColor(val1);
  172. }
  173. String^ GetConnectedParticlesName()
  174. {
  175. return gcnew String(m_Particle->get()->GetConnectedParticlesSequentialString().c_str());
  176. }
  177. void SetConnectedParticlesName(String^ val)
  178. {
  179. std::string val1 = marshal_as<std::string>(val);
  180. return m_Particle->get()->SetConnectedParticlesSequentialString(val1);
  181. }
  182. String^ GetGrpName()
  183. {
  184. return gcnew String(m_Particle->get()->GetGroupName().c_str());
  185. }
  186. void SetGrpName(String^ val)
  187. {
  188. std::string val1 = marshal_as<std::string>(val);
  189. return m_Particle->get()->SetGroupName(val1);
  190. }
  191. String^ GetGrpColor()
  192. {
  193. return gcnew String(m_Particle->get()->GetGroupColor().c_str());
  194. }
  195. void SetGrpColor(String^ val)
  196. {
  197. std::string val1 = marshal_as<std::string>(val);
  198. return m_Particle->get()->SetGroupColor(val1);
  199. }
  200. int GetGrpId()
  201. {
  202. return m_Particle->get()->GetGroupId();
  203. }
  204. void SetGrpId(int grpid)
  205. {
  206. m_Particle->get()->SetGroupId(grpid);
  207. }
  208. bool IsXrayParticle()
  209. {
  210. return m_Particle->get()->IsXrayParticle();
  211. }
  212. void SetIsXrayParticle(bool value)
  213. {
  214. m_Particle->get()->SetIsXrayParticle(value);
  215. }
  216. System::Collections::Generic::List<COTSParticleClr^>^ GetSubParticles()
  217. {
  218. System::Collections::Generic::List<COTSParticleClr^>^ clrparts = gcnew System::Collections::Generic::List<COTSParticleClr^>();
  219. auto parts = m_Particle->get()->GetSubParticles();
  220. for (auto p : parts)
  221. {
  222. auto clrPart = gcnew COTSParticleClr(p);
  223. clrparts->Add(clrPart);
  224. }
  225. return clrparts;
  226. }
  227. void SetSubParticles(System::Collections::Generic::List<COTSParticleClr^>^ clrParts)
  228. {
  229. m_Particle->get()->ClearSubParticles();
  230. for (int i=0;i<clrParts->Count;i++)
  231. {
  232. m_Particle->get()->AddSubParticle(clrParts[i]->GetOTSParticlePtr());
  233. }
  234. }
  235. void ClearSubParticles() { m_Particle->get()->ClearSubParticles(); }
  236. void AddSubParticle(COTSParticleClr^ particle) { m_Particle->get()->AddSubParticle(particle->GetOTSParticlePtr()); }
  237. protected:
  238. COTSParticlePtr* m_Particle;
  239. };
  240. typedef System::Collections::Generic::List<COTSParticleClr^> COTSParticleListClr;
  241. }