123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- #include "stdafx.h"
- #include "DomainClr.h"
- #include "COTSUtilityDllFunExport.h"
- namespace OTSCLRINTERFACE {
- CDomainClr::CDomainClr()
- {
-
- m_LpDomain = new CDomainPtr(new CDomain());
- }
- CDomainClr::CDomainClr(CDomainPtr a_pDomain) // constructor
- {
-
- ASSERT(a_pDomain);
- if (!a_pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgClr: Generate CDomainClr pointer failed."));
- return;
- }
-
- m_LpDomain = new CDomainPtr(a_pDomain);
-
- }
- CDomainClr::CDomainClr(int a_nShape, System::Drawing::Rectangle^ a_rectDomain) // constructor
- {
- m_LpDomain = new CDomainPtr(new CDomain());
- CDomainPtr d = *m_LpDomain;
- if (a_rectDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CDomainClr: invalide rectangle."));
- return;
- }
- d->SetShape((DOMAIN_SHAPE)a_nShape);
- CRect r = CRect(a_rectDomain->Left, a_rectDomain->Top, a_rectDomain->Right, a_rectDomain->Bottom);
- d->SetDomainRect(r);
-
- }
-
-
- CDomainClr::~CDomainClr()
- {
- if (m_LpDomain != nullptr)
- {
- delete m_LpDomain;
- m_LpDomain = NULL;
- }
- }
- /*CDomainClr::!CDomainClr()
- {
- if (m_LpDomain != nullptr)
- {
- delete m_LpDomain;
- m_LpDomain = NULL;
- }
- }*/
- CDomainClr::CDomainClr(CDomain* a_pSource) // copy constructor
- {
- ASSERT(a_pSource);
- if (!a_pSource)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgClr: Generate CDomainClr pointer failed."));
- return;
- }
- m_LpDomain = new CDomainPtr(a_pSource);
- }
- void CDomainClr::MyDispose()
- {
- if (m_LpDomain != nullptr)
- {
- delete m_LpDomain;
- m_LpDomain = NULL;
- }
- }
- bool CDomainClr::IsEmpty()
- {
- if (m_LpDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName: current CLR point is IsEmpty."));
- return false;
- }
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName:IsEmpty pointer."));
- return false;
- }
- return pDomain->IsEmpty();
- }
- bool CDomainClr::IsRound()
- {
- if (m_LpDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName: current CLR point is IsRound."));
- return false;
- }
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName:invalid pointer."));
- return false;
- }
- return pDomain->IsRound();
- }
- bool CDomainClr::IsRect()
- {
- if (m_LpDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName: current CLR point is IsRect."));
- return false;
- }
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetName:invalid pointer."));
- return false;
- }
- return pDomain->IsRect();
- }
- bool CDomainClr::IsInvalid()
- {
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CDomainClr::IsInvalid: invalid pointer."));
- return false;
- }
- bool bRet = false;
- bRet = pDomain->IsInvalid();
- return bRet;
- }
- // domain center
- Point CDomainClr::GetDomainCenter()
- {
- Point oRet;
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDomainCenter::IsInvalid: invalid pointer."));
- return oRet;
- }
-
- CPoint oPoint = pDomain->GetDomainCenter();
-
-
-
- oRet.X = oPoint.x;
- oRet.Y = oPoint.y;
- return oRet;
- }
- void CDomainClr::OffsetDomain(Point a_poiMove)
- {
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetDomainCenter::IsInvalid: invalid pointer."));
- return;
- }
- CPoint oPoint;
- oPoint.x = a_poiMove.X;
- oPoint.y = a_poiMove.Y;
- pDomain->OffsetDomain(oPoint);
- }
- long CDomainClr::GetDiameter()
- {
- int nDiameter = -1;
- if (m_LpDomain != nullptr)
- {
- nDiameter = (int)m_LpDomain->get()->GetDiameter();
- }
- return nDiameter;
- }
- // check if have common area with the given domain
- bool CDomainClr::IntersectDomain(CDomainClr^ a_oDomain)
- {
-
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IntersectDomain::IsInvalid: invalid pointer."));
- return false;
- }
- if (a_oDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IntersectDomain::IsInvalid: invalid pointer."));
- return false;
- }
- const CDomainPtr pInsertDomain = a_oDomain->GetDomainPtr();
- ASSERT(pInsertDomain);
- if (!pInsertDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("IntersectDomain::IsInvalid: invalid pointer."));
- return false;
- }
- bool bRet = false;
- bRet = pDomain->IntersectDomain(pInsertDomain.get());
- return bRet;
-
- }
- // check if the point in the domain
- bool CDomainClr::PtInDomain(Point^ a_poiCheck)
- {
- CDomainPtr pDomain = GetDomainPtr();
- ASSERT(pDomain);
- if (!pDomain)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("PtInDomain::IsInvalid: invalid pointer."));
- return false;
- }
- ASSERT(a_poiCheck);
- if (!a_poiCheck)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("PtInDomain::IsInvalid: invalid pointer."));
- return false;
- }
- CPoint poiCheck;
- poiCheck.x = a_poiCheck->X;
- poiCheck.y = a_poiCheck->Y;
- bool bRet = false;
- bRet = pDomain->PtInDomain(poiCheck);
- return bRet;
- }
- void CDomainClr::SetShape(int a_nShape)
- {
- if (m_LpDomain != nullptr)
- {
- m_LpDomain->get()->SetShape(( OTSDATA::DOMAIN_SHAPE)a_nShape);
- }
- }
- int CDomainClr::GetShape()
- {
- int nGetShape = -1;
- if (m_LpDomain != nullptr)
- {
- nGetShape = (int)m_LpDomain->get()->GetShape();
- }
- return nGetShape;
- }
- void CDomainClr::SetRectDomain(System::Drawing::Rectangle a_oRect)
- {
- CDomainPtr d = GetDomainPtr();
-
- CRect r = CRect(a_oRect.Left, a_oRect.Top, a_oRect.Right, a_oRect.Bottom);
- d->SetDomainRect(r);
- }
- System::Drawing::Rectangle CDomainClr::GetRectDomain()
- {
- CDomainPtr d = GetDomainPtr();
- CRect cr = d->GetDomainRect();
- System::Drawing::Rectangle r(cr.left ,cr.top ,cr.Width() ,cr.Height() );
- return r;
- }
- bool CDomainClr::DomainInDomain(CDomainClr^ a_oDomain)
- {
-
- if (a_oDomain == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DomainInDomain : invalide domain."));
- return false;
- }
- bool bRet = false;
- CDomainPtr pDomainThis = GetDomainPtr();
- if (pDomainThis == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DomainInDomain : invalide domain."));
- return false;
- }
- const CDomainPtr pDomainParam = a_oDomain->GetDomainPtr();
-
- if (pDomainParam == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("DomainInDomain : invalide domain."));
- return false;
- }
- bRet = pDomainThis->DomainInDomain(*pDomainParam.get());
- return bRet;
- }
- CDomainPtr CDomainClr::GetDomainPtr()
- {
- return *m_LpDomain;
- }
- void CDomainClr::SetPolygonPoint(System::Collections::Generic::List<System::Drawing::Point>^ a_PolygonPoint)
- {
- CDomainPtr domainPtr = GetDomainPtr();
- std::vector<CPoint> listPolygonPoint;
- listPolygonPoint.clear();
-
- for (int i = 0; i < (int)a_PolygonPoint->Count; i++)
- {
- CPoint pt(a_PolygonPoint[i].X, a_PolygonPoint[i].Y);
- listPolygonPoint.push_back(pt);
- }
- if (domainPtr != nullptr)
- {
- domainPtr->SetPolygonPoint(listPolygonPoint);
- }
- }
- System::Collections::Generic::List<System::Drawing::Point>^ CDomainClr::GetPolygonPoint()
- {
- CDomainPtr domainPtr = GetDomainPtr();
- std::vector<CPoint> vectorCPoint=domainPtr->GetPolygonPoint();
- System::Collections::Generic::List<System::Drawing::Point>^ listPolygonPoint = gcnew System::Collections::Generic::List < System::Drawing::Point >();
- for (int i = 0; i < (int)vectorCPoint.size(); i++)
- {
- System::Drawing::Point pt(vectorCPoint[i].x, vectorCPoint[i].y);
- listPolygonPoint->Add(pt);
- }
- return listPolygonPoint;
- }
- }
|