OTSParticleClr.h 6.2 KB

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