| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- #include "stdafx.h"
- #include "StageFileClr.h"
- #include "DlgStageMgr.h"
- namespace OTSINTERFACE {
- CStageFileClr::CStageFileClr()// constructor
- {
- mStageFile =new CStageFilePtr( new CStageFile());
- }
-
- CStageFileClr::CStageFileClr(CStageFileClr^ a_pSource) // copy constructor
- {
- if (a_pSource == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgClr: empty BSE image."));
- return;
- }
- // can't copy itself
- if (a_pSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_pSource);
- }
- CStageFileClr::CStageFileClr(CStageFilePtr a_pStageFile) // copy constructor
- {
-
- mStageFile = new CStageFilePtr(a_pStageFile);
-
-
- }
- CStageFileClr^ CStageFileClr::operator=(CStageFileClr^ a_pSource) // =operator
- {
- if (a_pSource == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("CBSEImgClr =: empty BSE image."));
- return nullptr;
- }
-
- // copy the class data over
- Duplicate(a_pSource);
- // return class
- return this;
- }
- CStageFileClr::~CStageFileClr()
- {
- if (mStageFile != nullptr)
- {
- delete mStageFile;
- mStageFile = nullptr;
- }
- }
- CStageFileClr::!CStageFileClr()
- {
- if (mStageFile != nullptr)
- {
- delete mStageFile;
- mStageFile = nullptr;
- }
- }
- CStageFilePtr CStageFileClr::GetStageFilePtr()
- {
-
- return *mStageFile;
- }
-
- // load/save a stage from a text file
- bool CStageFileClr::LoadStageFromTextFile(String^ a_strFilePathName)
- {
- bool bRet = false;
-
- bRet = mStageFile->get()->LoadStageFromTextFile(a_strFilePathName);
-
-
- return bRet;
- }
- bool CStageFileClr::SaveStageIntoTextFile(int a_nIndex, String^ a_strFilePathName)
- {
- bool bRet = false;
-
- bRet = mStageFile->get()->SaveStageIntoTextFile(a_nIndex, a_strFilePathName);
- return bRet;
- }
- // Load/Save
- bool CStageFileClr::Load(int a_nPackId, bool a_bClear, bool a_bGetFromText)
- {
- bool bRet = false;
-
- bRet = mStageFile->get()->Load((OTS_SOFT_PACKAGE_ID)a_nPackId, a_bClear, a_bGetFromText);
- return bRet;
- }
- bool CStageFileClr::Save(int a_nPackId)
- {
- bool bRet = false;
- bRet = mStageFile->get()->Save((OTS_SOFT_PACKAGE_ID)a_nPackId);
-
- return bRet;
- }
-
- CStagesListClr ^ CStageFileClr::GetStagesList()
- {
- auto lstStage = mStageFile->get()->GetStagesList();
- auto stages = gcnew CStagesListClr();
- for (auto s : lstStage)
- {
- auto stage = gcnew CStageClr(s);
- stages->Add(stage);
- }
- return stages;
- }
- bool CStageFileClr::SetStagesList(CStagesListClr^ a_listStages, bool a_bClear)
- {
- ASSERT(a_listStages);
- if (!a_listStages)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetStagesList:invalid stage list."));
- return false;
- }
- // stages list
- CStagesList listStage;
- for (int i = 0; i < a_listStages->Count; i++)
- {
- CStageClr^ pStageClr = a_listStages[i];
- ASSERT(pStageClr);
- if (!pStageClr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetStageFilePtr:invalid stage file pointer."));
- return false;
- }
- CStagePtr pStage = pStageClr->GetStagePtr();
- ASSERT(pStage);
- if (!pStage)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetStageFilePtr:invalid stage file pointer."));
- return false;
- }
- listStage.push_back(pStage);
- }
-
- mStageFile->get()->SetStagesList(listStage, a_bClear);
- return true;
- }
-
- bool CStageFileClr::SetStageData(CSEMStageDataClr^ a_pStageData)
- {
- ASSERT(a_pStageData);
- if (!a_pStageData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("SetStageData:invalid stage pointer."));
- return false;
- }
- CSEMStageDataPtr pSEMStageData = a_pStageData->GetCSEMStageData();
- ASSERT(pSEMStageData);
- if (!pSEMStageData)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("Save::invalide stage file pointer"));
- return false;
- }
- mStageFile->get()->SetStageData(pSEMStageData);
- return true;
- }
- // conver SEM cordination to OTS cordination
- bool CStageFileClr::ConverSEMToOTSSystem(CDomainClr^ a_pBoundary, CDomainClr^ a_pSTD, CHoleListClr^ a_listStageHoles)
- {
- if (this == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid pointer."));
- return false;
- }
- ASSERT(a_pBoundary);
- if (!a_pBoundary)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid boundary pointer."));
- return false;
- }
- CDomainPtr pBoundary = a_pBoundary->GetDomainPtr();
- ASSERT(pBoundary);
- if (!pBoundary)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid boundary pointer."));
- return false;
- }
- ASSERT(a_pSTD);
- if (!a_pSTD)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid STD pointer."));
- return false;
- }
- CDomainPtr pSTD = a_pBoundary->GetDomainPtr();
- ASSERT(pSTD);
- if (!pSTD)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid STD pointer."));
- return false;
- }
- ASSERT(a_listStageHoles);
- if (!a_listStageHoles)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid stage hole pointer."));
- return false;
- }
- CHolesList listHole;
- for (int i = 0; i < a_listStageHoles->Count; i++)
- {
- CHoleClr^ pHoleClr = a_listStageHoles[i];
- ASSERT(pHoleClr);
- if (!pHoleClr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid hole pointer."));
- return false;
- }
- CHolePtr pHole = pHoleClr->GetHolePtr();
- ASSERT(pHole);
- if (!pHole)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSSystem: invalid hole pointer"));
- return false;
- }
- listHole.push_back(pHole);
- }
- bool bRet = false;
-
- bRet =mStageFile->get()->ConverSEMToOTSSystem(pBoundary, pSTD, listHole);
- return bRet;
- }
- // conver OTS point to SEM point
- bool CStageFileClr::ConverOTSToSEMPoint(Point^ a_OTSpt, Point^ % a_SEMpt)
- {
- if (this == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverOTSToSEMPoint: invalid pointer."));
- return false;
- }
- CPoint ptOTS;
- ptOTS.x = a_OTSpt->X;
- ptOTS.y = a_OTSpt->Y;
- CPoint ptSEM;
-
- bool bRet = mStageFile->get()->ConverOTSToSEMPoint(ptOTS, ptSEM);
- if (!bRet)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverOTSToSEMPoint::can't change the point to SEM."));
- return false;
- }
- a_SEMpt->X = ptSEM.x;
- a_SEMpt->Y = ptSEM.y;
- return bRet;
- }
- // conver SEM point to OTS point
- bool CStageFileClr::ConverSEMToOTSPoint(Point^ a_SEMpt, Point^% a_OTSpt)
- {
- if (this == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ConverSEMToOTSPoint: invalid pointer."));
- return false;
- }
- CPoint ptSEM;
- ptSEM.x = a_SEMpt->X;
- ptSEM.y = a_SEMpt->Y;
-
- CPoint ptOTS;
- bool bRet = mStageFile->get()->ConverSEMToOTSPoint(ptSEM, ptOTS);
- a_OTSpt->X = ptOTS.x;
- a_OTSpt->Y = ptOTS.y;
- return bRet;
-
- }
- //show stage dialog
- CStageFileClr^ CStageFileClr::ShowStageDialogExport(int a_nPackId, CStageFileClr^ a_pStageFile)
- {
- ASSERT(a_pStageFile);
- if (!a_pStageFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ShowStageDialogExport:invalid stage file pointer."));
- return nullptr;
- }
- CStageFilePtr pStageFile = a_pStageFile->GetStageFilePtr();
- ASSERT(pStageFile);
- if (!pStageFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ShowStageDialogExport:invalid stage file pointer."));
- return nullptr;
- }
- CStageFilePtr pNewStageFile = ShowStageMgrDialog((OTS_SOFT_PACKAGE_ID)a_nPackId, pStageFile);
- ASSERT(pNewStageFile);
- if (!pNewStageFile)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("ShowStageDialogExport:invalid new stage file pointer."));
- return nullptr;
- }
- CStageFileClr^ pNewStageFileClr = gcnew CStageFileClr(pNewStageFile);
- return pNewStageFileClr;
-
- }
-
- CStageClr^ CStageFileClr::GetWorkingStage()
- {
- if (this == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingStage: invalid pointer."));
- return nullptr;
- }
- CStagePtr pStage = mStageFile->get()->GetWorkingStage();
- if (pStage == nullptr)
- {
- LogErrorTrace(__FILE__, __LINE__, _T("GetWorkingStage::invalide stage pointer"));
- return nullptr;
- }
- CStageClr^ pStageClr = gcnew CStageClr(pStage);
- return pStageClr;
- }
- // duplication
- void CStageFileClr::Duplicate(CStageFileClr^ a_oSource)
- {
- mStageFile=new CStageFilePtr(new CStageFile(a_oSource->GetStageFilePtr().get()));
-
- }
- }
|