#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())); } }