BSEImgFileMgrClr.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #include "stdafx.h"
  2. #include "BSEImgFileMgrClr.h"
  3. namespace OTSINTERFACE {
  4. //CMsrParamFileMrgClr
  5. CBSEImgFileMgrClr::CBSEImgFileMgrClr() // constructor
  6. {
  7. //Init();
  8. m_BSEImgFileMgr = new CBSEImgFileMgrPtr(new CBSEImgFileMgr());
  9. }
  10. CBSEImgFileMgrClr::CBSEImgFileMgrClr(CBSEImgFileMgrPtr a_pBSEFileMgr)
  11. {
  12. ASSERT(a_pBSEFileMgr);
  13. if (!a_pBSEFileMgr)
  14. {
  15. LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgFileMgrClr::invalid pointer."));
  16. return;
  17. }
  18. m_BSEImgFileMgr = new CBSEImgFileMgrPtr(a_pBSEFileMgr);
  19. }
  20. CBSEImgFileMgrClr::CBSEImgFileMgrClr(CBSEImgFileMgr* a_pSource) // copy constructor
  21. {
  22. ASSERT(a_pSource);
  23. if (!a_pSource)
  24. {
  25. LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgClr: Generate CBSEImgFileMgrClr pointer failed."));
  26. return;
  27. }
  28. m_BSEImgFileMgr = new CBSEImgFileMgrPtr(a_pSource);
  29. }
  30. CBSEImgFileMgrPtr CBSEImgFileMgrClr::GetBSEImgFileMgrPtr()
  31. {
  32. return *m_BSEImgFileMgr;
  33. }
  34. CBSEImgFileMgrClr::~CBSEImgFileMgrClr()
  35. {
  36. if (m_BSEImgFileMgr != nullptr)
  37. {
  38. delete m_BSEImgFileMgr;
  39. }
  40. }
  41. CBSEImgFileMgrClr::!CBSEImgFileMgrClr()
  42. {
  43. if (m_BSEImgFileMgr != nullptr)
  44. {
  45. delete m_BSEImgFileMgr;
  46. }
  47. }
  48. // Load/Save
  49. bool CBSEImgFileMgrClr::Load(String^ a_strPathName, bool a_bClear)
  50. {
  51. bool bRet = false;
  52. CBSEImgFileMgrPtr pBSEImgFileMgr = GetBSEImgFileMgrPtr();
  53. ASSERT(a_strPathName);
  54. if (!a_strPathName)
  55. {
  56. LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgFileMgrClr::Load:: invalid pointer."));
  57. return false;
  58. }
  59. bRet = pBSEImgFileMgr->Load(a_strPathName, a_bClear);
  60. return bRet;
  61. }
  62. bool CBSEImgFileMgrClr::Save(String^ a_strPathName)
  63. {
  64. bool bRet = false;
  65. CBSEImgFileMgrPtr pBSEImgFileMgr = GetBSEImgFileMgrPtr();
  66. ASSERT(a_strPathName);
  67. if (!a_strPathName)
  68. {
  69. LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgFileMgrClr::Save:: invalid pointer."));
  70. }
  71. bRet = pBSEImgFileMgr->Save(a_strPathName);
  72. return bRet;
  73. }
  74. // LoadFromBitmap
  75. bool CBSEImgFileMgrClr::LoadFromBitmap(String^ a_strPathName, bool a_bClear)
  76. {
  77. bool bRet = false;
  78. CBSEImgFileMgrPtr pBSEImgFileMgr = GetBSEImgFileMgrPtr();
  79. ASSERT(a_strPathName);
  80. if (!a_strPathName)
  81. {
  82. LogErrorTrace(__FILE__, __LINE__, _T("LoadFromBitmap:: invalid pointer."));
  83. return false;
  84. }
  85. bRet = pBSEImgFileMgr->LoadFromBitmap(a_strPathName, a_bClear);
  86. return bRet;
  87. }
  88. // SaveIntoBitmap
  89. bool CBSEImgFileMgrClr::SaveIntoBitmap(String^ a_strPathName)
  90. {
  91. bool bRet = false;
  92. CBSEImgFileMgrPtr pBSEImgFileMgr = GetBSEImgFileMgrPtr();
  93. ASSERT(a_strPathName);
  94. if (!a_strPathName)
  95. {
  96. LogErrorTrace(__FILE__, __LINE__, _T("SaveIntoBitmap:: invalid pointer."));
  97. return false;
  98. }
  99. bRet = pBSEImgFileMgr->SaveIntoBitmap(a_strPathName);
  100. return bRet;
  101. }
  102. // measurement parameters file
  103. bool CBSEImgFileMgrClr::SetBSEImg(CBSEImgClr^ a_poBSE)
  104. {
  105. if (this == nullptr)
  106. {
  107. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImg::empty object!"));
  108. return false;
  109. }
  110. CBSEImgFileMgrPtr pBSEImgFileMgr = GetBSEImgFileMgrPtr();
  111. ASSERT(a_poBSE);
  112. if (!a_poBSE)
  113. {
  114. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImg::invalide param pointer."));
  115. return false;
  116. }
  117. CBSEImgPtr poBSEImg = a_poBSE->GetBSEImgPtr();
  118. ASSERT(poBSEImg);
  119. if (!poBSEImg)
  120. {
  121. LogErrorTrace(__FILE__, __LINE__, _T("SetBSEImg::invalide param pointer."));
  122. return false;
  123. }
  124. pBSEImgFileMgr->SetBSEImg(poBSEImg);
  125. return true;
  126. }
  127. // file pathname
  128. String^ CBSEImgFileMgrClr::GetPathName()
  129. {
  130. String^ FilePathNameClr;
  131. if (m_BSEImgFileMgr != nullptr)
  132. {
  133. CBSEImgFileMgrPtr filePtr = *m_BSEImgFileMgr;
  134. CString sPathName = filePtr->GetPathName();
  135. FilePathNameClr = gcnew String(sPathName);
  136. }
  137. return FilePathNameClr;
  138. }
  139. void CBSEImgFileMgrClr::SetPathName(String^ strPathName)
  140. {
  141. ASSERT(strPathName);
  142. if (!strPathName)
  143. {
  144. LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version."));
  145. }
  146. if (m_BSEImgFileMgr != nullptr)
  147. {
  148. CBSEImgFileMgrPtr filePtr= *m_BSEImgFileMgr;
  149. filePtr->SetPathName(strPathName);
  150. }
  151. }
  152. CBSEImgClr^ CBSEImgFileMgrClr::GetBSEImg()
  153. {
  154. CBSEImgClr^ BSEImgClr;
  155. if (m_BSEImgFileMgr != nullptr)
  156. {
  157. CBSEImgFileMgrPtr filePtr = *m_BSEImgFileMgr;
  158. CBSEImgPtr pBSEImg = filePtr->GetBSEImg();
  159. ASSERT(pBSEImg);
  160. if (!pBSEImg)
  161. {
  162. LogErrorTrace(__FILE__, __LINE__, _T("COTSReportProjFileClr: invalid partSTDData pointer."));
  163. return BSEImgClr;
  164. }
  165. BSEImgClr = gcnew CBSEImgClr(pBSEImg);
  166. }
  167. return BSEImgClr;
  168. }
  169. }