OTSParticleClr.h 6.1 KB

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