123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- // 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 xnScanFieldHeight;
- xmls::xInt xnScanFieldSize100;
- xmls::xDouble xdWorkingDistance;
- xmls::xInt xnTotalFields;
- xmls::Slo slo;
- slo.Register("ScanFieldSize", &xnScanFieldSize);
- slo.Register("ScanFieldHeight", &xnScanFieldHeight);
- slo.Register("ScanFieldSize100", &xnScanFieldSize100);
- slo.Register("WorkingDistance", &xdWorkingDistance);
- slo.Register("TotalFields", &xnTotalFields);
- if (isStoring)
- {
- xnScanFieldSize = m_nScanFieldSize;
- xnScanFieldHeight = m_nScanFieldHeight;
- 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_nScanFieldHeight = xnScanFieldHeight.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;
- }
- }
|