// SEMDtaMsr.cpp : implementation file // #include "stdafx.h" //#include "OTSData.h" #include "SEMDataMsr.h" namespace OTSDATA { // constructor CSEMDataMsr::CSEMDataMsr() { // initialization Init(); } // copy constructor CSEMDataMsr::CSEMDataMsr(const CSEMDataMsr& a_oSource) { // can't copy itself if (&a_oSource == this) { return; } // copy data over Duplicate(a_oSource); } // copy constructor CSEMDataMsr::CSEMDataMsr(CSEMDataMsr* a_poSource) { // can't copy itself if (a_poSource == this) { return; } // copy data over Duplicate(*a_poSource); } // =operator CSEMDataMsr& CSEMDataMsr::operator=(const CSEMDataMsr& a_oSource) { // cleanup Cleanup(); // copy the class data over Duplicate(a_oSource); // return class return *this; } // destructor CSEMDataMsr::~CSEMDataMsr() { // cleanup Cleanup(); } // ==operator BOOL CSEMDataMsr::operator==(const CSEMDataMsr& a_oSource) { return m_nScanFieldSize == a_oSource.m_nScanFieldSize && m_nScanFieldSize100 == a_oSource.m_nScanFieldSize100 && abs(m_dWorkingDistance - a_oSource.m_dWorkingDistance) < MIN_DOUBLE_VALUE /*&& m_nTotalFields == a_oSource.m_nTotalFields*/; } // CSEMDataMsr member functions // public // serialization void CSEMDataMsr::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode) { xmls::xInt xnScanFieldSize; xmls::xInt xnScanFieldSize100; xmls::xDouble xdWorkingDistance; xmls::xInt xnTotalFields; xmls::Slo slo; slo.Register("ScanFieldSize", &xnScanFieldSize); slo.Register("ScanFieldSize100", &xnScanFieldSize100); slo.Register("WorkingDistance", &xdWorkingDistance); slo.Register("TotalFields", &xnTotalFields); if (isStoring) { xnScanFieldSize = m_nScanFieldSize; xnScanFieldSize100 = m_nScanFieldSize100; xdWorkingDistance = m_dWorkingDistance; xnTotalFields = m_nTotalFields; slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); m_nScanFieldSize = xnScanFieldSize.value(); m_nScanFieldSize100 = xnScanFieldSize100.value(); m_dWorkingDistance = xdWorkingDistance.value(); m_nTotalFields = xnTotalFields.value(); } } // get magnification double CSEMDataMsr::GetMagnification() { // magnification double dMag = 0.0; // convert scan field size to magnification if (m_nScanFieldSize > 0) { dMag = (double)m_nScanFieldSize100 * 100.0 / (double)m_nScanFieldSize; } // return magnification return dMag; } void CSEMDataMsr::SetMagnification(double a_dMag) { if (a_dMag < MAGNIFICATION_MIN) { return; } m_nScanFieldSize = (int)(100.0 * (double)m_nScanFieldSize100 / a_dMag + 0.5); } // protected // cleanup void CSEMDataMsr::Cleanup() { // need to do nothing at the moment } // initialization void CSEMDataMsr::Init() { m_nScanFieldSize = 0; m_nScanFieldSize100 = 0; m_dWorkingDistance = 0; m_nTotalFields = 0; } // duplication void CSEMDataMsr::Duplicate(const CSEMDataMsr& a_oSource) { // initialization Init(); // copy data over m_nScanFieldSize = a_oSource.m_nScanFieldSize; m_nScanFieldSize100 = a_oSource.m_nScanFieldSize100; m_dWorkingDistance = a_oSource.m_dWorkingDistance; m_nTotalFields = a_oSource.m_nTotalFields; } }