SEMStageData.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // SEMStageData.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "SEMStageData.h"
  5. // CSEMStageData
  6. namespace OTSDATA
  7. {
  8. CSEMStageData::CSEMStageData()
  9. {
  10. Init();
  11. }
  12. // copy constructor
  13. CSEMStageData::CSEMStageData(const CSEMStageData& a_oSource)
  14. {
  15. // can't copy itself
  16. if (&a_oSource == this)
  17. {
  18. return;
  19. }
  20. // copy data over
  21. Duplicate(a_oSource);
  22. }
  23. // copy constructor
  24. CSEMStageData::CSEMStageData(CSEMStageData* a_poSource)
  25. {
  26. // input check
  27. ASSERT(a_poSource);
  28. if (!a_poSource)
  29. {
  30. return;
  31. }
  32. // can't copy itself
  33. if (a_poSource == this)
  34. {
  35. return;
  36. }
  37. // copy data over
  38. Duplicate(*a_poSource);
  39. }
  40. // =operator
  41. CSEMStageData& CSEMStageData::operator=(const CSEMStageData& a_oSource)
  42. {
  43. // cleanup
  44. Cleanup();
  45. // copy the class data over
  46. Duplicate(a_oSource);
  47. // return class
  48. return *this;
  49. }
  50. // ==operator
  51. BOOL CSEMStageData::operator==(const CSEMStageData& a_oSource)
  52. {
  53. // return test result
  54. return m_nScanFieldSize100 == a_oSource.m_nScanFieldSize100 &&
  55. *(m_oXAxis.get()) == *(a_oSource.m_oXAxis.get()) &&
  56. *(m_oYAxis.get()) == *(a_oSource.m_oYAxis.get()) &&
  57. m_bXAxisDir == a_oSource.m_bXAxisDir &&
  58. m_bYAxisDir == a_oSource.m_bYAxisDir &&
  59. m_dMinMag == a_oSource.m_dMinMag;
  60. }
  61. // detractor
  62. CSEMStageData::~CSEMStageData()
  63. {
  64. Cleanup();
  65. }
  66. // CSEMStageData member functions
  67. // serialization
  68. void CSEMStageData::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
  69. {
  70. xmls::xInt xscanFieldSize100;
  71. xmls::xInt xbXAxisDir;
  72. xmls::xInt xbYAxisDir;
  73. xmls::xDouble xMinMag;
  74. xmls::Slo slo;
  75. //Slo::Clear();
  76. slo.Register("scanFieldSize", &xscanFieldSize100);
  77. slo.Register("xAxisDir", &xbXAxisDir);
  78. slo.Register("yAxisDir", &xbYAxisDir);
  79. slo.Register("MinMag", &xMinMag);
  80. slo.Register("XAxis", m_oXAxis.get());
  81. slo.Register("YAxis", m_oYAxis.get());
  82. if (isStoring)
  83. {
  84. xscanFieldSize100 = m_nScanFieldSize100;
  85. xbXAxisDir = (int)m_bXAxisDir;
  86. xbYAxisDir = (int)m_bYAxisDir;
  87. xMinMag = m_dMinMag;
  88. slo.Serialize(true, classDoc, rootNode);
  89. }
  90. else
  91. {
  92. slo.Serialize(false, classDoc, rootNode);
  93. m_nScanFieldSize100 = xscanFieldSize100.value();
  94. m_bXAxisDir = (OTS_X_AXIS_DIRECTION)xbXAxisDir.value();
  95. m_bYAxisDir = (OTS_Y_AXIS_DIRECTION)xbYAxisDir.value();
  96. m_dMinMag = xMinMag.value();
  97. }
  98. }
  99. // cleanup
  100. void CSEMStageData::Cleanup()
  101. {
  102. // nothing needs to be done at the moment
  103. }
  104. // initialization
  105. void CSEMStageData::Init()
  106. {
  107. m_nScanFieldSize100 = 0;
  108. m_bXAxisDir = OTS_X_AXIS_DIRECTION::LEFT_TOWARD;
  109. m_bYAxisDir = OTS_Y_AXIS_DIRECTION::UP_TOWARD;
  110. m_oXAxis = CIntRangePtr(new CIntRange(0, 0));
  111. m_oYAxis = CIntRangePtr(new CIntRange(0, 0));
  112. m_dMinMag = MAGNIFICATION_MIN;
  113. }
  114. // duplication
  115. void CSEMStageData::Duplicate(const CSEMStageData& a_oSource)
  116. {
  117. // initialization
  118. Init();
  119. // copy data over
  120. m_nScanFieldSize100 = a_oSource.m_nScanFieldSize100;
  121. m_bXAxisDir = a_oSource.m_bXAxisDir;
  122. m_bYAxisDir = a_oSource.m_bYAxisDir;
  123. m_oXAxis = a_oSource.m_oXAxis;
  124. m_oYAxis = a_oSource.m_oYAxis;
  125. m_dMinMag = a_oSource.m_dMinMag;
  126. }
  127. }