| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628 | #include "stdafx.h"#include "OTSSampleClr.h"#include <COTSUtilityDllFunExport.h>namespace OTSCLRINTERFACE {	using namespace Newtonsoft::Json ::Linq;	COTSSampleClr::COTSSampleClr()	{		theSample = new COTSSamplePtr(new COTSSample());	}	COTSSampleClr::COTSSampleClr(COTSSamplePtr pSample)							// copy constructor	{			ASSERT(pSample);			//theSample= new COTSSamplePtr(new COTSSample(pSample.get()));							theSample = new COTSSamplePtr(pSample);				//*theSample = pSample;			}	COTSSampleClr::~COTSSampleClr()	{		if (theSample != nullptr)		{			delete theSample;			theSample = nullptr;		}	}	COTSSampleClr::!COTSSampleClr()	{		if (theSample != nullptr)		{			delete theSample;			theSample = nullptr;		}	}	//JObject^ COTSSampleClr:: GetJSONProperty()	//{	//		//	JObject^ SMeasureInfo= gcnew JObject();	//	//the propItem list will change according to the value which is selected in the property grid.	//	//So we have to call setpropItemGrps function every time when we want to update the property grid display.	//	theSample->get()->SetPropItemGrps();	//	//获得 样品属性值	//	auto PropItemGrpsList = theSample->get()->GetPropItemGrps();	//		//		//	int iItemGrpCount = PropItemGrpsList.size();	//	if (0 == iItemGrpCount)	//	{	//		return SMeasureInfo;	//	}		//	SMeasureInfo->Add("bSwitch", theSample->get()->GetSwitch());	//	SMeasureInfo->Add("ParamLock", theSample->get()->GetParamLock());	//	JObject^ SMeasurePara = gcnew JObject();	//	//获取样品的测量区域信息 	//	//获取样品名称	//		//	CString sSName = theSample->get()->GetName();	//	SMeasurePara->Add("sNewSampleName", gcnew String(theSample->get()->GetName()));	//	// 获取测量区域形状	//	auto area = theSample->get()->GetMsrArea();	//	SMeasurePara->Add("iShape", (int)area->GetShape());	//	//获取样品孔名称	//	SMeasurePara->Add("sHoleName" ,gcnew String(theSample->get()->GetSampleHoleName()));	//	//样品测量区域	//	JObject^ rectangleObject = gcnew JObject();	//	auto rec = area->GetDomainRect();	//	rectangleObject->Add("x", rec.left);	//	rectangleObject->Add("y", rec.top );	//	rectangleObject->Add("width", rec.Width());	//	rectangleObject->Add("height", rec.Height());	//	SMeasurePara->Add("MeasureRect",  rectangleObject);	//	SMeasureInfo->Add("SMeasurePara", SMeasurePara);	//	JObject^ TSampleParam = gcnew JObject();	//	TSampleParam->Add("sWorkSampleName", gcnew String(theSample->get()->GetName()));	//	TSampleParam->Add("bSwitch", theSample->get()->GetSwitch());	//	SMeasureInfo->Add("TSampleParam", TSampleParam);	//	JArray^ groupArray = gcnew JArray();	//	for (int i = 0; i < iItemGrpCount; i++)	//	{	//		JObject^ groupObject = gcnew JObject();	//		//获取GROUP ID和Grid的显示组的标题名	//		groupObject->Add ("GroupId" ,(int)PropItemGrpsList[i]->GetGroupId());	//		groupObject->Add ("Title", gcnew String( PropItemGrpsList[i]->GetName()));	//			//获取样品属性ID和值	//			std::vector <CPropItemPtr> PropItemList = PropItemGrpsList[i]->GetItemsList();	//				//			int iItemCount = PropItemList.size();	//			JArray^ itemArray = gcnew JArray();	//			for (int k = 0; k < iItemCount; k++)	//			{	//				JObject^ SData = gcnew JObject();	//				SData->Add("SampleId" ,(int)PropItemList[k]->GetSmplItemId());						//				SData->Add("CaptionName", gcnew String( PropItemList[k]->GetName()));	//				SData->Add("IsReadOnly" , PropItemList[k]->IsReadOnly());	//				SData->Add("SampleValType", (int)PropItemList[k]->GetTypeId());	//				SData->Add("DescriptionInfo",gcnew String(PropItemList[k]->GetDescription()));	//					//				String^ val = gcnew String(theSample->get()->GetItemValueStr(PropItemList[k]->GetSmplItemId()));	//				SData->Add("valStr", val);	//				std::vector<CString> comboDownList;	//				if (PropItemList[k]->GetTypeId() == OTS_ITEM_TYPES::COMBO)	//				{	//					comboDownList = theSample->get()->GetItemComboDownList(PropItemList[k]->GetSmplItemId());	//				}	//					//				JArray^ jarr = gcnew JArray();	//				if (comboDownList.size() > 0)	//				{	//					for (int i=0; i < (int)comboDownList.size(); i++)	//					{	//						jarr->Add(gcnew String(comboDownList[i]));	//					}	//				}	//				SData->Add("comboDownList", jarr);	//				itemArray->Add(SData);	//			}	//			groupObject->Add("SData", itemArray);	//			groupArray->Add(groupObject);	//				//	}	//	SMeasureInfo->Add("ItemGrp", groupArray);	//	return SMeasureInfo;	//}	COTSSamplePtr COTSSampleClr::GetSamplePtr()	{		return *theSample;	}	// has measure results test	bool COTSSampleClr::HasMeasureResult()	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("HasMeasureResult: invalide pointer."));			return false;		}		return pSample->HasMeasureResult();	}		// property item groups list	/*bool COTSSampleClr::SetPropItemGrps()	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropItemGrps: invalide pointer."));			return FALSE;		}				pSample->SetPropItemGrps();		return TRUE;	}*/	/*CPropItemGrpClr^ COTSSampleClr::GetPropItemGrpByIndex(int a_nIndex)	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropItemGrps: invalide pointer."));			return nullptr;		}		CPropItemGrpPtr pPropItemGrp = pSample->GetPropItemGrpByIndex(a_nIndex);		if (pPropItemGrp == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropItemGrps: invalide pointer."));			return nullptr;		}		CPropItemGrpClr^ pPropItemGrpClr = gcnew CPropItemGrpClr(pPropItemGrp);		return pPropItemGrpClr;	}*/	/*CPropItemGrpClr^ COTSSampleClr::GetPropItemGrpById(int a_nId)	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropItemGrpById: invalide pointer."));			return nullptr;		}		CPropItemGrpPtr pPropItemGrp = pSample->GetPropItemGrpById((OTS_SAMPLE_PROP_GRID_ITEM_GROUPS)a_nId);		if (pPropItemGrp == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropItemGrpById: invalide pointer."));			return nullptr;		}		CPropItemGrpClr^ pPropItemGrpClr = gcnew CPropItemGrpClr(pPropItemGrp);		return pPropItemGrpClr;	}*/	/*CPropItemGrpClr^ COTSSampleClr::UpdatePropItemGrp(int a_nId)	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("UpdatePropItemGrp: invalide pointer."));			return nullptr;		}		CPropItemGrpPtr pPropItemGrp = pSample->UpdatePropItemGrp((OTS_SAMPLE_PROP_GRID_ITEM_GROUPS)a_nId);		if (pPropItemGrp == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("UpdatePropItemGrp: invalide pointer."));			return nullptr;		}		CPropItemGrpClr^ pPropItemGrpClr = gcnew CPropItemGrpClr(pPropItemGrp);		return pPropItemGrpClr;	}*/	/*CPropItemClr^ COTSSampleClr::GetPropItemById(int a_nId)	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropItemById: invalide pointer."));			return nullptr;		}		CPropItemPtr pPropItem = pSample->GetPropItemById((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId);		if (pPropItem == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropItemById: invalide pointer."));			return nullptr;		}		CPropItemClr^ pPropItemClr = gcnew CPropItemClr(pPropItem);		return pPropItemClr;	}*/	// BOOL data (1)	/*bool COTSSampleClr::GetPropBOOLData(int a_nId, bool% a_bValue)	{		bool bRet;		BOOL bResult;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropBOOLData: invalide pointer."));			return false;		}		bRet = pSample->GetPropBOOLData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);		a_bValue = bResult;		return bRet;	}*/	/*bool COTSSampleClr::SetPropBOOLData(int a_nId, bool a_bValue)	{		bool bResult = FALSE;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropBOOLData: invalide pointer."));			return false;		}		BOOL bValue = a_bValue;		bResult = pSample->SetPropBOOLData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bValue);		return bResult;	}*/	// int data (16)	/*bool COTSSampleClr::GetPropIntData(int a_nId, int% a_nValue)	{		bool bRet;		int bResult;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropIntData: invalide pointer."));			return false;		}		bRet = pSample->GetPropIntData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);		a_nValue = bResult;		return bRet;	}*/	/*bool COTSSampleClr::SetPropIntData(int a_nId, int a_nValue)	{		bool bRet = FALSE;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropIntData: invalide pointer."));			return false;		}		bRet = pSample->SetPropIntData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, a_nValue);		return bRet;			}*/	// double data (4)	/*bool COTSSampleClr::GetPropDoubleData(int a_nId, double% a_dValue)	{		bool bRet;		double bResult;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropDoubleData: invalide pointer."));			return false;		}				bRet = pSample->GetPropDoubleData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);				a_dValue = bResult;				return bRet;	}*/	/*bool COTSSampleClr::SetPropDoubleData(int a_nId, double a_dValue)	{		bool bRet = FALSE;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropDoubleData: invalide pointer."));			return false;		}		bRet = pSample->SetPropDoubleData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, a_dValue);		return bRet;	}*/	// string data (7)	/*bool COTSSampleClr::GetPropStringData(int a_nId, String^% a_strValue)	{		bool bRet;		CString bResult;		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetPropStringData: invalide pointer."));			return false;		}		bRet = pSample->GetPropStringData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);		a_strValue = gcnew String(bResult);		return bRet;	}*/	/*bool COTSSampleClr::SetPropStringData(int a_nId, String^ a_strValue)	{		bool bRet = false;		if (a_strValue == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropStringData: invalide pointer."));			return false;		}		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("SetPropStringData: invalide pointer."));			return false;		}		CString str = a_strValue;		bRet = pSample->SetPropStringData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, str);		return bRet;	}*/	// combo data (7)	//bool COTSSampleClr::GetPropComboData(int a_nId, int% a_nValue)	//{	//	bool bRet;	//	int bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetPropComboData: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetPropComboData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	a_nValue = bResult;	//	return bRet;	//}	//bool COTSSampleClr::SetPropComboData(int a_nId, int a_nValue)	//{	//	bool bRet = false;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropComboData: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->SetPropComboData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, a_nValue);	//	return bRet;	//}	//bool COTSSampleClr::GetPropComboStrings(int a_nId, CStringListClr^% a_listComboStrings)	//{	//	bool bRet;			//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetPropComboStrings: invalide pointer."));	//		return false;	//	}	//	std::vector<CString> bResult;	//	bRet = pSample->GetPropComboStrings((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	for (auto pString : bResult)	//	{	//		String^ str = gcnew String(pString);	//		a_listComboStrings->Add(str);	//	}	//	return bRet;	//}	//// time data (2)	//bool COTSSampleClr::GetPropTimeData(int a_nId, DateTime^% a_oValue)	//{	//	bool bRet;	//	COleDateTime bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetPropTimeData: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetPropTimeData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	a_oValue = gcnew DateTime(bResult.GetYear(), bResult.GetMonth(), bResult.GetDay(), bResult.GetHour(), bResult.GetMinute(), bResult.GetSecond());	//	return bRet;	//}	//bool COTSSampleClr::SetPropTimeData(int a_nId, DateTime^ a_oValue)	//{	//	bool bRet;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeData: invalide pointer."));	//		return false;	//	}	//	ASSERT(a_oValue);	//	if (!a_oValue)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeData: invalide pointer."));	//		return false;	//	}	//	COleDateTime oVaule(a_oValue->Year, a_oValue->Month, a_oValue->Day, a_oValue->Hour, a_oValue->Minute, a_oValue->Second);	//		//	bRet = pSample->SetPropTimeData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, oVaule);	//	return bRet;	//}	//// time span data (1)	//bool COTSSampleClr::GetPropTimeSpanData(int a_nId, TimeSpan^% a_oValue)	//{	//	bool bRet;	//	COleDateTimeSpan bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetPropTimeSpanData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	#pragma warning(disable : 4244)	//	a_oValue = gcnew TimeSpan(bResult.GetTotalDays(), bResult.GetTotalHours(), bResult.GetTotalMinutes(), bResult.GetTotalSeconds());	//	#pragma warning(default : 4244)	//	return bRet;	//}	//bool COTSSampleClr::SetPropTimeSpanData(int a_nId, TimeSpan^ a_oValue)	//{	//	bool bRet = false;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	ASSERT(a_oValue);	//	if(!a_oValue)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	COleDateTimeSpan oVaule(a_oValue->Days, a_oValue->Hours, a_oValue->Minutes, a_oValue->Seconds);	//		//	bRet = pSample->SetPropTimeSpanData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, oVaule);	//	return bRet;	//}	//// file list data (2)	//bool COTSSampleClr::GetPropFileListData(int a_nId, String^% a_strFileName)	//{	//	bool bRet;	//	CString bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetPropFileListData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	a_strFileName = gcnew String(bResult);	//	return bRet;	//}	//bool COTSSampleClr::SetPropFileListData(int a_nId, String^ a_strFileName)	//{	//	bool bRet = false;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	ASSERT(a_strFileName);	//	if(!a_strFileName)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("SetPropTimeSpanData: invalide pointer."));	//		return false;	//	}	//	CString str = a_strFileName;	//	bRet = pSample->SetPropFileListData((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, str);	//	return bRet;	//}	//// get related property item	//bool COTSSampleClr::GetRelatedPropItem(int a_nId, int% a_nRelatedPropId)	//{	//	bool bRet;	//	OTS_SAMPLE_PROP_GRID_ITEMS bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetRelatedPropItem: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetRelatedPropItem((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	a_nRelatedPropId = (int)bResult;	//	return bRet;	//}	//// get related property item group 	//bool COTSSampleClr::GetRelatedPropItemGrp(int a_nId, int% a_nRelatedPropGrpId)	//{	//	bool bRet;	//	OTS_SAMPLE_PROP_GRID_ITEM_GROUPS bResult;	//	COTSSamplePtr pSample = GetSamplePtr();	//	if (pSample == nullptr)	//	{	//		LogErrorTrace(__FILE__, __LINE__, _T("GetRelatedPropItem: invalide pointer."));	//		return false;	//	}	//	bRet = pSample->GetRelatedPropItemGrp((OTS_SAMPLE_PROP_GRID_ITEMS)a_nId, bResult);	//	a_nRelatedPropGrpId = (int)bResult;	//	//	return bRet;	//}	bool COTSSampleClr::GetBSESize(int% a_nWidth, int% a_nHeight)	{		COTSSamplePtr pSample = GetSamplePtr();		if (pSample == nullptr)		{			LogErrorTrace(__FILE__, __LINE__, _T("GetBSESize: invalide pointer."));			return false;		}		int nWidth = 0;		int nHeight = 0;		bool bRet = pSample->GetBSESize(nWidth, nHeight);		a_nWidth = nWidth;		a_nHeight = nHeight;		return bRet;	}}
 |