Browse Source

fix a bug when operating visual stage(readSEMData first then locate to currentSem point will result to state display yellow or green rect problem)

gsp 2 years ago
parent
commit
4b42c01102

+ 110 - 108
OTSCPP/OTSClassifyEngine/InclutionClassifyEngine.cpp

@@ -6,147 +6,149 @@
 #include "InclutionEngine/OTSClassifyEng.h"
 namespace OTSClassifyEngine
 { 
-bool InclutionClassifyEngine::Init()
-{
-	CSTDFileMgrPtr stdfile = CSTDFileMgrPtr(new CSTDFileMgr());
-	if (!stdfile->Load())
+	bool InclutionClassifyEngine::Init()
 	{
-		return false;
-	}
-	myStd = stdfile-> GenerateSTDLib(IDENTIFY_KIND::ALL);
-	if (myStd!=nullptr) 
-	{
-		return true;
-	}
-	else
-	{
-		return false;
-	}
+		CSTDFileMgrPtr stdfile = CSTDFileMgrPtr(new CSTDFileMgr());
+		if (!stdfile->Load())
+		{
+			return false;
+		}
+		myStd = stdfile-> GenerateSTDLib(IDENTIFY_KIND::ALL);
+		if (myStd!=nullptr) 
+		{
+			m_Engine = new COTSClassifyEng(myStd);
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+		
 	
-}
-
-
-
-bool InclutionClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray)
-{
-	return false;
-}
-
-
+	}
 
-bool InclutionClassifyEngine::Classify(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray)
-{
-	if (particle == nullptr || xray == nullptr) return false;
-	int Id;
-	int grpId;
-	auto result = COTSClassifyEng::ClassifyXray(myStd, (OTSDATA::STEEL_TECHNOLOGY)SteelTech, xray->GetElementQuantifyData(), Id, grpId);
 
 
-	if (grpId == (int)OTS_PARTICLE_TYPE::INVALID)
+	bool InclutionClassifyEngine::Classify(COTSParticlePtr particle, CPosXrayPtr xray)
 	{
-		particle->SetType(OTS_PARTICLE_TYPE::INVALID);
-		particle->TypeName("Invalid");
-		particle->TypeColor("#000000");
-		particle->SetClassifyId(Id);
-		particle->SetGroupId(grpId);
-		std::string grpName;
-		std::string grpColor;
-		COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
-		particle->SetGroupName(grpName);
-		particle->SetGroupColor(grpColor);
-
+		return false;
 	}
-	else if (grpId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
-	{
-		particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
-		particle->TypeName("Not Identified");
-		particle->TypeColor("#000000");
-		particle->SetClassifyId((int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
-		particle->SetGroupId(grpId);
-		std::string grpName;
-		std::string grpColor;
-		COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
-		particle->SetGroupName(grpName);
-		particle->SetGroupColor(grpColor);
 
-	}
-	else if (grpId == (int)OTS_PARTICLE_TYPE::ISNOT_INCLUTION)
-	{
-		if (Id == (int)NOT_INCLUTION_ID::SiC)
-		{
-			particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
-			particle->TypeName("SiC");
-			particle->SetClassifyId((int)NOT_INCLUTION_ID::SiC);
-			particle->TypeColor("#7B68EE");
 
-		}
-		else if (Id == (int)NOT_INCLUTION_ID::FeO)
-		{
-			particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
-			particle->TypeName("FeO");
-			particle->SetClassifyId((int)NOT_INCLUTION_ID::FeO);
-			particle->TypeColor("#FF6347");
-		}
-		std::string grpName;
-		std::string grpColor;
-		COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
-		particle->SetGroupId(grpId);
-		particle->SetGroupName(grpName);
-		particle->SetGroupColor(grpColor);
 
-	}
-	else
+	bool InclutionClassifyEngine::Classify(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray)
 	{
-		auto stditm = myStd->GetSTDItemById(Id);
-		if (stditm != nullptr)
+		if (particle == nullptr || xray == nullptr) return false;
+		int Id;
+		int grpId;
+		auto result = m_Engine->ClassifyXray((OTSDATA::STEEL_TECHNOLOGY)SteelTech, xray->GetElementQuantifyData(), Id, grpId);
+
+
+		if (grpId == (int)OTS_PARTICLE_TYPE::INVALID)
 		{
-			particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
+			particle->SetType(OTS_PARTICLE_TYPE::INVALID);
+			particle->TypeName("Invalid");
+			particle->TypeColor("#000000");
 			particle->SetClassifyId(Id);
-			particle->TypeColor(stditm->GetColor().GetBuffer());
-			particle->TypeName(stditm->GetName().GetBuffer());
 			particle->SetGroupId(grpId);
 			std::string grpName;
 			std::string grpColor;
-			COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
+			m_Engine->GetGroupNameAndColorById(grpId, grpName, grpColor);
 			particle->SetGroupName(grpName);
 			particle->SetGroupColor(grpColor);
 
 		}
-		else
+		else if (grpId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
 		{
 			particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
 			particle->TypeName("Not Identified");
 			particle->TypeColor("#000000");
+			particle->SetClassifyId((int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
 			particle->SetGroupId(grpId);
 			std::string grpName;
 			std::string grpColor;
-			COTSClassifyEng::GetGroupNameAndColorById(grpId, grpName, grpColor);
+			m_Engine->GetGroupNameAndColorById(grpId, grpName, grpColor);
+			particle->SetGroupName(grpName);
+			particle->SetGroupColor(grpColor);
+
+		}
+		else if (grpId == (int)OTS_PARTICLE_TYPE::ISNOT_INCLUTION)
+		{
+			if (Id == (int)NOT_INCLUTION_ID::SiC)
+			{
+				particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
+				particle->TypeName("SiC");
+				particle->SetClassifyId((int)NOT_INCLUTION_ID::SiC);
+				particle->TypeColor("#7B68EE");
+
+			}
+			else if (Id == (int)NOT_INCLUTION_ID::FeO)
+			{
+				particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
+				particle->TypeName("FeO");
+				particle->SetClassifyId((int)NOT_INCLUTION_ID::FeO);
+				particle->TypeColor("#FF6347");
+			}
+			std::string grpName;
+			std::string grpColor;
+			m_Engine->GetGroupNameAndColorById(grpId, grpName, grpColor);
+			particle->SetGroupId(grpId);
 			particle->SetGroupName(grpName);
 			particle->SetGroupColor(grpColor);
+
 		}
+		else
+		{
+			auto stditm = myStd->GetSTDItemById(Id);
+			if (stditm != nullptr)
+			{
+				particle->SetType(OTS_PARTICLE_TYPE::IDENTIFIED);
+				particle->SetClassifyId(Id);
+				particle->TypeColor(stditm->GetColor().GetBuffer());
+				particle->TypeName(stditm->GetName().GetBuffer());
+				particle->SetGroupId(grpId);
+				std::string grpName;
+				std::string grpColor;
+				m_Engine->GetGroupNameAndColorById(grpId, grpName, grpColor);
+				particle->SetGroupName(grpName);
+				particle->SetGroupColor(grpColor);
+
+			}
+			else
+			{
+				particle->SetType(OTS_PARTICLE_TYPE::NOT_IDENTIFIED);
+				particle->TypeName("Not Identified");
+				particle->TypeColor("#000000");
+				particle->SetGroupId(grpId);
+				std::string grpName;
+				std::string grpColor;
+				m_Engine->GetGroupNameAndColorById(grpId, grpName, grpColor);
+				particle->SetGroupName(grpName);
+				particle->SetGroupColor(grpColor);
+			}
 
+		}
+
+			return result;
+	}
+
+	bool InclutionClassifyEngine::IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime)
+	{
+		throw std::logic_error("The method or operation is not implemented.");
 	}
 
-		return result;
-}
-
-bool InclutionClassifyEngine::IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime)
-{
-	throw std::logic_error("The method or operation is not implemented.");
-}
-
-OTSClassifyEngine::CLEEnginePtr CreateInclutionEngine()
-{
-	return CLEEnginePtr(new InclutionClassifyEngine());
-}
- OTSClassifyEngine::CLEEnginePtr GetInclutionEngine()
- {
-	 static CLEEnginePtr engine;
-	 if (engine == NULL)
+	OTSClassifyEngine::CLEEnginePtr CreateInclutionEngine()
+	{
+		return CLEEnginePtr(new InclutionClassifyEngine());
+	}
+	 OTSClassifyEngine::CLEEnginePtr GetInclutionEngine()
 	 {
-		 engine = CLEEnginePtr( new InclutionClassifyEngine());
-		 engine->Init();
+		 static CLEEnginePtr engine;
+		 if (engine == NULL)
+		 {
+			 engine = CLEEnginePtr( new InclutionClassifyEngine());
+			 engine->Init();
+		 }
+		 return engine;
 	 }
-	 return engine;
- }
 }

+ 16 - 14
OTSCPP/OTSClassifyEngine/InclutionClassifyEngine.h

@@ -1,26 +1,28 @@
 #pragma once
 #include "InclutionEngine\InclutionSTDData.h"
 #include "IClassifyEngine.h"
+#include "InclutionEngine\OTSClassifyEng.h"
 namespace OTSClassifyEngine
 {
 
-class InclutionClassifyEngine:public IClassifyEngine
-{
-public:
-	//InclutionClassifyEngine() :m_StrName("###") {}; //成员列表初始化参数
+	class InclutionClassifyEngine:public IClassifyEngine
+	{
+		public:
+			InclutionClassifyEngine() :m_StrName("###") {}; //成员列表初始化参数
 	
-	virtual ~InclutionClassifyEngine() {};
-	bool Init() override;
-	 //bool ClassifyByXrayInfo(COTSParticlePtr particle, CPosXrayInfoPtr xrayInfo) override;//
-	 bool Classify(COTSParticlePtr particle, CPosXrayPtr xray) override;//
+			 virtual ~InclutionClassifyEngine() {};
+			 bool Init() override;
+			 //bool ClassifyByXrayInfo(COTSParticlePtr particle, CPosXrayInfoPtr xrayInfo) override;//
+			 bool Classify(COTSParticlePtr particle, CPosXrayPtr xray) override;//
 
-	 virtual bool Classify(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray) override;
+			 virtual bool Classify(COTSParticlePtr particle, int SteelTech, CPosXrayPtr xray) override;
 
 
-	 virtual bool IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime) override;
+			 virtual bool IfNeedMaxEDS(COTSParticlePtr particle, CPosXrayPtr xray, double& MaxEDSTime) override;
 
-private:
-	CInclutionSTDDataPtr myStd;
-	string m_StrName;
-};
+		private:
+			CInclutionSTDDataPtr myStd;
+			string m_StrName;
+			COTSClassifyEng* m_Engine;
+	};
 }

+ 93 - 128
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.cpp

@@ -10,8 +10,47 @@ namespace OTSClassifyEngine
 
 	using namespace OTSClassifyEngine;
 
-	COTSClassifyEng::COTSClassifyEng()						// constructor
+	COTSClassifyEng::COTSClassifyEng(CInclutionSTDDataPtr a_pPartSTDData)						// constructor
 	{
+		ASSERT(a_pPartSTDData);
+		// get all sulfides STD items
+		pPartSTDData = a_pPartSTDData;
+		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::SUL, listSulfideSTD))
+		{
+			// something is wrong
+			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::SulClassify: failed to call GetClassifySTDItem method."));
+		}
+
+		// get all oxides STD items
+	
+		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::OXIDE, listOxideSTD))
+		{
+			// something wrong
+			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::OxideClassify: failed to call GetClassifySTDItem method."));
+		}
+		// get all nitride STD items
+		
+		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::NITR, listNitrideSTD))
+		{
+			// something wrong
+			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
+		}
+		// get all nitride STD items
+		
+		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::CARBON, listCarbonSTD))
+		{
+			// something wrong
+			LogErrorTrace(__FILE__, __LINE__, _T("CClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
+		}
+		// get user STD items
+		
+		//if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::USER, listUserSTD))
+		//{
+		//	// something wrong
+		//	LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::OxideClassify: failed to call GetClassifySTDItem method."));
+		//	
+		//}
+
 	}
 
 	COTSClassifyEng::~COTSClassifyEng()						// detractor
@@ -19,17 +58,10 @@ namespace OTSClassifyEngine
 	}
 
 	//Dispose ClassifyXray
-	BOOL COTSClassifyEng::ClassifyXray(CInclutionSTDDataPtr a_pPartSTDData, STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElementChemistries, int& a_nIncId, int& a_GrpId)
+	BOOL COTSClassifyEng::ClassifyXray( STEEL_TECHNOLOGY steelTech, CElementChemistriesList& a_listElementChemistries, int& a_nIncId, int& a_GrpId)
 	{
 		
-		// safety check
-		ASSERT(a_pPartSTDData);
-		if (!a_pPartSTDData)
-		{
-			/*SendLogMessageToNlog("begin to classify particles", (int)PostLogLevel::warn);*/
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: invalid CPartSTDDataPtr."));
-			return FALSE;
-		}
+		
 
 		// the element chemistries list is an inclusion 
 		CElementChemistriesList listElChemsInc;
@@ -63,7 +95,7 @@ namespace OTSClassifyEngine
 
 		// system STD classification
 		int nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		if (!SystemClassify(a_pPartSTDData, steelTech, listElChemsIncNoFe, dMolarSumNoFe, nIncId))
+		if (!SystemClassify( steelTech, listElChemsIncNoFe, dMolarSumNoFe, nIncId))
 		{
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call SystemClassify method."));
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
@@ -75,18 +107,18 @@ namespace OTSClassifyEngine
 		{// identified, return TRUE
 			a_nIncId = nIncId;
 			IDENTIFIED_INC_GRP_ID grpid;
-			GroupClassify(a_pPartSTDData,listElChemsIncNoFe,nIncId, grpid);
+			GroupClassify(listElChemsIncNoFe,nIncId, grpid);
 			a_GrpId = (int)grpid;
 			return TRUE;
 		}
 
 		// user STD classification
-		if (!UserClassify(a_pPartSTDData, listElChemsInc, dMolarSum, nIncId))
+		/*if (!UserClassify(a_pPartSTDData, listElChemsInc, dMolarSum, nIncId))
 		{
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call UserClassify method."));
 			a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 			return FALSE;
-		}
+		}*/
 
 		// identified?
 		if (nIncId > (int)OTS_PARTICLE_TYPE::IDENTIFIED)
@@ -94,7 +126,7 @@ namespace OTSClassifyEngine
 			// identified, return TRUE
 			a_nIncId = nIncId;
 			IDENTIFIED_INC_GRP_ID grpid;
-			GroupClassify(a_pPartSTDData,listElChemsIncNoFe,nIncId, grpid);
+			GroupClassify(listElChemsIncNoFe,nIncId, grpid);
 			a_GrpId = (int)grpid;
 			return TRUE;
 		}
@@ -102,7 +134,7 @@ namespace OTSClassifyEngine
 		// can't identify this inclusion
 		a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
 		IDENTIFIED_INC_GRP_ID grpid;
-		GroupClassify(a_pPartSTDData,listElChemsIncNoFe,nIncId, grpid);
+		GroupClassify(listElChemsIncNoFe,nIncId, grpid);
 		a_GrpId = (int)grpid;
 		return TRUE;
 	}
@@ -268,20 +300,17 @@ namespace OTSClassifyEngine
 	}
 
 	// system classification
-	BOOL COTSClassifyEng::SystemClassify(CInclutionSTDDataPtr a_pPartSTDData,
+	BOOL COTSClassifyEng::SystemClassify(
 		STEEL_TECHNOLOGY steelTech,
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
 	{
-		// safety check
-		ASSERT(a_pPartSTDData);
-		
 		
 
 		// try sulfide classification
 		int nIncId = (int)OTS_PARTICLE_TYPE::INVALID;
-		if (!SulClassify(a_pPartSTDData, steelTech, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!SulClassify(steelTech, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call SulClassify method."));
@@ -299,7 +328,7 @@ namespace OTSClassifyEngine
 		}
 
 		// nitride classification
-		if (!NitrideClassify(a_pPartSTDData, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!NitrideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call NitrideClassify method."));
@@ -315,7 +344,7 @@ namespace OTSClassifyEngine
 		}
 
 		// oxide classification
-		if (!OxideClassify(a_pPartSTDData, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call OxideClassify method."));
@@ -331,7 +360,7 @@ namespace OTSClassifyEngine
 		}
 
 		// CarbonClassify classification
-		if (!CarbonClassify(a_pPartSTDData, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!CarbonClassify(a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::ClassifyXray: failed to call CarbonClassify method."));
@@ -351,7 +380,7 @@ namespace OTSClassifyEngine
 		return TRUE;
 	}
 
-	BOOL COTSClassifyEng::GroupClassify(CInclutionSTDDataPtr a_pPartSTDData,CElementChemistriesList& a_listElChemsIncNoFe,int incId, IDENTIFIED_INC_GRP_ID& a_GrpId)
+	BOOL COTSClassifyEng::GroupClassify(CElementChemistriesList& a_listElChemsIncNoFe,int incId, IDENTIFIED_INC_GRP_ID& a_GrpId)
 	{
 	
 		double dOWeight = 0;
@@ -364,7 +393,7 @@ namespace OTSClassifyEngine
 
 		}*/
 
-		auto stdItm =a_pPartSTDData->GetSTDItemById( incId);
+		auto stdItm =pPartSTDData->GetSTDItemById( incId);
 		if (incId == (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED)
 		{
 			a_GrpId = IDENTIFIED_INC_GRP_ID::Others;
@@ -551,25 +580,14 @@ namespace OTSClassifyEngine
 
 
 	// sulfides classification 
-	BOOL COTSClassifyEng::SulClassify(CInclutionSTDDataPtr a_pPartSTDData,
+	BOOL COTSClassifyEng::SulClassify(
 		STEEL_TECHNOLOGY steelTech,
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
 	{
-		// safety check
-		ASSERT(a_pPartSTDData);
 		
-
-		// get all sulfides STD items
-		CSTDItemsList listSulfideSTD;
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::SUL, listSulfideSTD))
-		{
-			// something is wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::SulClassify: failed to call GetClassifySTDItem method."));
-			return FALSE;
-		}
-		//GetSTDItemNameById
+		
 		// check if element chemistries list contain any sulfur
 		CElementChemistryPtr pSulElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_SUL);
 		if (!pSulElChem)
@@ -815,7 +833,7 @@ namespace OTSClassifyEngine
 
 		// check if the rest element chemistries map an oxide
 		int nIncId = (int)OTS_PARTICLE_TYPE::INVALID;
-		if (!OxideClassify(a_pPartSTDData, listChemistriesToAnalysis, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify(listChemistriesToAnalysis, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::SulClassify: failed to call OxideClassify method."));
@@ -830,7 +848,7 @@ namespace OTSClassifyEngine
 			// confirm the oxide sulfide id
 
 			// get the STD item of the mapped oxide
-			CSTDItemPtr pOxideSTDItem = a_pPartSTDData->GetSTDItemById(nIncId);
+			CSTDItemPtr pOxideSTDItem = pPartSTDData->GetSTDItemById(nIncId);
 			if (pOxideSTDItem)
 			{
 				// get mapped oxide name
@@ -934,24 +952,12 @@ namespace OTSClassifyEngine
 	}
 
 	// oxides classification
-	BOOL COTSClassifyEng::OxideClassify(CInclutionSTDDataPtr a_pPartSTDData,
+	BOOL COTSClassifyEng::OxideClassify(
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
 	{
-		// safety check
-		ASSERT(a_pPartSTDData);
-
-
-		// get all oxides STD items
-		CSTDItemsList listOxideSTD;
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::OXIDE, listOxideSTD))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::OxideClassify: failed to call GetClassifySTDItem method."));
-			return FALSE;
-		}
-
+		
 		// check if element chemistries list contain any oxygen 
 		CElementChemistryPtr pOElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_OXIDE);
 		if (!pOElChem)
@@ -1119,24 +1125,12 @@ namespace OTSClassifyEngine
 	}
 
 	// nitrides classification
-	BOOL COTSClassifyEng::NitrideClassify(CInclutionSTDDataPtr a_pPartSTDData,
+	BOOL COTSClassifyEng::NitrideClassify(
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
 	{
-		// safety check
-		ASSERT(a_pPartSTDData);
-	
-
-		// get all nitride STD items
-		CSTDItemsList listNitrideSTD;
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::NITR, listNitrideSTD))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
-			return FALSE;
-		}
-
+		
 		// check if element chemistries list contain any nitrogen
 		CElementChemistryPtr pNitrElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_NITR);
 		if (!pNitrElChem)
@@ -1272,7 +1266,7 @@ namespace OTSClassifyEngine
 
 		// check if the rest element chemistries map an oxide
 		int nIncId = (int)OTS_PARTICLE_TYPE::INVALID;
-		if (!OxideClassify(a_pPartSTDData, a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
+		if (!OxideClassify( a_listElChemsIncNoFe, a_dMolarSumNoFe, nIncId))
 		{
 			// something wrong
 			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::NitrideClassify: failed to call OxideClassify method."));
@@ -1287,7 +1281,7 @@ namespace OTSClassifyEngine
 			// confirm the oxide nitride id
 
 			// get the STD item of the mapped oxide
-			CSTDItemPtr pOxideSTDItem = a_pPartSTDData->GetSTDItemById(nIncId);
+			CSTDItemPtr pOxideSTDItem = pPartSTDData->GetSTDItemById(nIncId);
 			if (pOxideSTDItem)
 			{
 				// get mapped oxide name
@@ -1391,23 +1385,12 @@ namespace OTSClassifyEngine
 	}
 
 	// nitrides classification
-	BOOL COTSClassifyEng::CarbonClassify(CInclutionSTDDataPtr a_pPartSTDData,
+	BOOL COTSClassifyEng::CarbonClassify(
 		CElementChemistriesList& a_listElChemsIncNoFe,
 		double a_dMolarSumNoFe,
 		int& a_nIncId)
 	{
-		// safety check
-		ASSERT(a_pPartSTDData);
-
-
-		// get all nitride STD items
-		CSTDItemsList listCarbonSTD;
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::CARBON, listCarbonSTD))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("CClassifyEng::NitrideClassify: failed to call GetClassifySTDItem method."));
-			return FALSE;
-		}
+		
 
 		// check if element chemistries list contain any nitrogen
 		CElementChemistryPtr pCarElChem = GetNamedElementChemistry(a_listElChemsIncNoFe, STR_CAR);
@@ -1547,41 +1530,31 @@ namespace OTSClassifyEngine
 	}
 
 
-	// user STD items classification
-	BOOL COTSClassifyEng::UserClassify(CInclutionSTDDataPtr a_pPartSTDData,
-		CElementChemistriesList& a_listEltChemsInc,
-		double dSum,
-		int& a_nIncId)
-	{
-		// safety check
-		ASSERT(a_pPartSTDData);
-	
-
-		// get user STD items
-		CSTDItemsList listUserSTD;
-		if (!GetClassifySTDItem(a_pPartSTDData, INC_CLASSIFY_TYPE::USER, listUserSTD))
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::OxideClassify: failed to call GetClassifySTDItem method."));
-			return FALSE;
-		}
-
-		// try to identify the oxide
-		for (auto pUserSTD : listUserSTD)
-		{
-			// matching STD?
-			if (MatchingSTD(a_listEltChemsInc, pUserSTD, dSum))
-			{
-				// found matching STD
-				a_nIncId = pUserSTD->GetSTDId();
-				return TRUE;
-			}
-		}
-
-		// can't identify this inclusion
-		a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
-		return TRUE;
-	}	
+	//// user STD items classification
+	//BOOL COTSClassifyEng::UserClassify(
+	//	CElementChemistriesList& a_listEltChemsInc,
+	//	double dSum,
+	//	int& a_nIncId)
+	//{
+	//	
+	//	
+
+	//	// try to identify the oxide
+	//	for (auto pUserSTD : listUserSTD)
+	//	{
+	//		// matching STD?
+	//		if (MatchingSTD(a_listEltChemsInc, pUserSTD, dSum))
+	//		{
+	//			// found matching STD
+	//			a_nIncId = pUserSTD->GetSTDId();
+	//			return TRUE;
+	//		}
+	//	}
+
+	//	// can't identify this inclusion
+	//	a_nIncId = (int)OTS_PARTICLE_TYPE::NOT_IDENTIFIED;
+	//	return TRUE;
+	//}	
 
 	// nominate element chemistries list 
 	BOOL COTSClassifyEng::NomiNateElChemsList( CElementChemistriesList& a_listElChemsInc, 
@@ -1740,15 +1713,7 @@ namespace OTSClassifyEngine
 	// get classify STD items
 	BOOL COTSClassifyEng::GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems)
 	{
-		// safety check
-		ASSERT(a_pPartSTDDataPtr);
-		if (!a_pPartSTDDataPtr)
-		{
-			// something wrong
-			LogErrorTrace(__FILE__, __LINE__, _T("COTSClassifyEng::GetClassifySTDItem: invalid CPartSTDDataPtr."));
-			return FALSE;
-		}
-
+	
 		// cal STD item id value range
 		OTS_STD_ITEM_VALUE nSTDIdRangeMin = OTS_STD_ITEM_VALUE::INVALID;
 		OTS_STD_ITEM_VALUE nSTDIdRangeMax = OTS_STD_ITEM_VALUE::INVALID;

+ 37 - 31
OTSCPP/OTSClassifyEngine/InclutionEngine/OTSClassifyEng.h

@@ -192,14 +192,14 @@ namespace OTSClassifyEngine
 	{
 	public:
 	
-		COTSClassifyEng();					// constructor
+		COTSClassifyEng(CInclutionSTDDataPtr a_pPartSTDData);					// constructor
 		virtual ~COTSClassifyEng();			// detractor
 
-		static BOOL ClassifyXray(CInclutionSTDDataPtr a_pPartSTDData, STEEL_TECHNOLOGY steelTech, CElementChemistriesList & a_listElementChemistries, int & a_nIncId, int& a_GrpId);
+		 BOOL ClassifyXray(STEEL_TECHNOLOGY steelTech, CElementChemistriesList & a_listElementChemistries, int & a_nIncId, int& a_GrpId);
 
 		
 		// check if the x-ray is an inc x-ray
-		static BOOL IsAnValidIncXRay( CElementChemistriesList& a_listElementChemistries, 
+		 BOOL IsAnValidIncXRay( CElementChemistriesList& a_listElementChemistries, 
 								 CElementChemistriesList& a_listElChemsInc, 
 								 CElementChemistriesList& a_listElChemsIncNoFe, 
 								 double& a_dMolarSum,
@@ -207,98 +207,104 @@ namespace OTSClassifyEngine
 			OTS_PARTICLE_TYPE& a_nIncId,NOT_INCLUTION_ID& notIncId);
 
 		// system STD classification
-		static BOOL SystemClassify( CInclutionSTDDataPtr a_pPartSTDData,
-									STEEL_TECHNOLOGY steelTech,
+		 BOOL SystemClassify(STEEL_TECHNOLOGY steelTech,
 									CElementChemistriesList& a_listElChemsIncNoFe,
 									double a_dMolarSumNoFe,
 									int& a_nIncId);
 
-		static BOOL GroupClassify(CInclutionSTDDataPtr a_pPartSTDData,CElementChemistriesList& a_listElChemsIncNoFe,int incId, IDENTIFIED_INC_GRP_ID& a_GrpId);
+		 BOOL GroupClassify(CElementChemistriesList& a_listElChemsIncNoFe,int incId, IDENTIFIED_INC_GRP_ID& a_GrpId);
 
-		static BOOL GetGroupNameAndColorById(int grpId, std::string& grpName, std::string& grpColor);
+		 BOOL GetGroupNameAndColorById(int grpId, std::string& grpName, std::string& grpColor);
 
 		// sulfides classification 
-		static BOOL SulClassify( CInclutionSTDDataPtr a_pPartSTDData,
+		 BOOL SulClassify(
 								 STEEL_TECHNOLOGY steelTech, 
 								 CElementChemistriesList& a_listElChemsIncNoFe,
 								 double a_dMolarSumNoFe,
 								 int& a_nIncId);
 
 		// oxides classification
-		static BOOL OxideClassify( CInclutionSTDDataPtr a_pPartSTDData,
+		 BOOL OxideClassify(
 								   CElementChemistriesList& a_listElChemsIncNoFe,
 								   double a_dSumNoFe,
 								   int& a_nIncId);
 
 		// nitrides classification
-		static BOOL NitrideClassify( CInclutionSTDDataPtr a_pPartSTDData,
+		 BOOL NitrideClassify(
 									 CElementChemistriesList& a_listElChemsIncNoFe,
 									 double a_dMolarSumNoFe,
 									 int& a_nIncId);
 
 		// carbon classification
-		static BOOL CarbonClassify(CInclutionSTDDataPtr a_pPartSTDData,
+		 BOOL CarbonClassify(
 			CElementChemistriesList& a_listElChemsIncNoFe,
 			double a_dMolarSumNoFe,
 			int& a_nIncId);
 
 
 		// user STD items classification
-		static BOOL UserClassify( CInclutionSTDDataPtr a_pPartSTDData,
+		/* BOOL UserClassify(
 								  CElementChemistriesList& a_listEltChemsInc,
 								  double a_dSum,
-								  int& a_nIncId);
+								  int& a_nIncId);*/
 
 		// nominate element chemistries list 
-		static BOOL NomiNateElChemsList( CElementChemistriesList& a_listElChemsInc, 
+		 BOOL NomiNateElChemsList( CElementChemistriesList& a_listElChemsInc, 
 										 CElementChemistriesList& a_listNomiElChemsInc);
 	
 	protected:
 		
 		// check if this is a key element
-		static BOOL IsKeyElement(CElementChemistryPtr a_pElChem);
+		 BOOL IsKeyElement(CElementChemistryPtr a_pElChem);
 
 		// check if this is a sub element
-		static BOOL IsSubElement(CElementChemistryPtr a_pElChem);
+		 BOOL IsSubElement(CElementChemistryPtr a_pElChem);
 
 		// get named element chemistry
-		static CElementChemistryPtr GetNamedElementChemistry(CElementChemistriesList& a_listChemistriesElements, const CString a_strElementName);
+		 CElementChemistryPtr GetNamedElementChemistry(CElementChemistriesList& a_listChemistriesElements, const CString a_strElementName);
 
-		// get classify STD items
-		static BOOL GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems);
+		
 
 		// get STD item by name
-		static CSTDItemPtr GetSTDItemByName(CSTDItemsList& a_listSTDItems, CString a_strName);
+		 CSTDItemPtr GetSTDItemByName(CSTDItemsList& a_listSTDItems, CString a_strName);
 
 		// get STD item name by id
-		static CString GetSTDItemNameById(CSTDItemsList& a_listSTDItems, int a_nItemId);
+		 CString GetSTDItemNameById(CSTDItemsList& a_listSTDItems, int a_nItemId);
 
 		// elements mapping
-		static BOOL ElementsMapping(double a_dMolarSumNoFe, double a_dMappingRadio, CElementChemistryPtr a_pFirstElChem, CElementChemistryPtr a_pSecondElChem, BOOL& a_bMapped);
+		 BOOL ElementsMapping(double a_dMolarSumNoFe, double a_dMappingRadio, CElementChemistryPtr a_pFirstElChem, CElementChemistryPtr a_pSecondElChem, BOOL& a_bMapped);
 
 		// check if is a simple
-		static BOOL IsASimpleOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& a_strSimOxName);
+		 BOOL IsASimpleOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& a_strSimOxName);
 
 		// check if is a REOxide
-		static BOOL IsAREOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum);
+		 BOOL IsAREOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum);
 
 		// check if is a REAlOxide
-		static BOOL IsAnREAlOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum);
+		 BOOL IsAnREAlOxide(CElementChemistriesList& a_listElChems, double a_dMolarSum);
 
 		// check if is a Spinel
-		static BOOL IsASpinel(CElementChemistriesList& a_listElChems, double a_dMolarSum);
+		 BOOL IsASpinel(CElementChemistriesList& a_listElChems, double a_dMolarSum);
 
 		// check if is a Silicate
-		static BOOL IsASilicate(CElementChemistriesList& a_listElChems, double a_dMolarSum);
+		 BOOL IsASilicate(CElementChemistriesList& a_listElChems, double a_dMolarSum);
 
 		// check if is a Aluminate
-		static BOOL IsAnCa_Aluminate(CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& strName);
+		 BOOL IsAnCa_Aluminate(CElementChemistriesList& a_listElChems, double a_dMolarSum, CString& strName);
 
 		// check if the element chemistries list matching the STD
-		static BOOL MatchingSTD(CElementChemistriesList& a_listElChems, CSTDItemPtr a_pSTDItem, double a_dMolarSum);
+		 BOOL MatchingSTD(CElementChemistriesList& a_listElChems, CSTDItemPtr a_pSTDItem, double a_dMolarSum);
 
 		// calculate 100% value
-		static double Cal100NorValue(double a_dValue, double a_dSumValue);
-
+		 double Cal100NorValue(double a_dValue, double a_dSumValue);
+	private:
+		CInclutionSTDDataPtr pPartSTDData;
+		CSTDItemsList listSulfideSTD;
+		CSTDItemsList listOxideSTD;
+		CSTDItemsList listNitrideSTD;
+		CSTDItemsList listCarbonSTD;
+		//CSTDItemsList listUserSTD;
+		// get classify STD items
+		BOOL GetClassifySTDItem(CInclutionSTDDataPtr a_pPartSTDDataPtr, INC_CLASSIFY_TYPE a_nClassifyType, CSTDItemsList& a_listSTDItems);
 	};
 }   

+ 6 - 1
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/OTSSamplespaceWindow.cs

@@ -242,15 +242,20 @@ namespace OTSMeasureApp
                 case "DriveSEMToCenterLocation":
                     //驱动SEM到中心位置
                     SetSEMToCenterPoint();
+                    ReadSEMDataAndSetToCurrentSample();
+                    PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
                     break;
                 case "DriveSEMToCurrentLocation":
                     //驱动SEM到当前位置
                     SetSEMCurrentLocation();
+                    ReadSEMDataAndSetToCurrentSample();
+                    PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
                     break;
                 case "SetSEMCenterLocation":
                     //将测量区域移到SEM当前位置
                     SetMeasureToSEMLocation();
-
+                    ReadSEMDataAndSetToCurrentSample();
+                    PrepareMeasureField(GetWorkingVisualSample(), MSR_RUN_TYPE.RUNMEASURE);
                     break;
                 case "ReadSEMData":
                     m_MeasureAppForm.SetRunType(MSR_RUN_TYPE.RUNMEASURE);

+ 16 - 30
OTSIncAMeasureApp/4-OTSSamplespaceGraphicsPanel/sampleSpaceObject.cd

@@ -1,68 +1,54 @@
 <?xml version="1.0" encoding="utf-8"?>
 <ClassDiagram MajorVersion="1" MinorVersion="1">
-  <Class Name="OTSMeasureApp.CRectangleGDIObject">
-    <Position X="1.25" Y="0.5" Width="2.75" />
+  <Class Name="OTSMeasureApp.CRectangleGDIObject" Collapsed="true">
+    <Position X="3.75" Y="3.25" Width="2.75" />
     <TypeIdentifier>
-      <HashCode>AWCFBAAAwIho4YAAACAgA0cgAABAIBAAAAgAAgAAAAg=</HashCode>
-      <FileName>4-OTSSamplespaceGraphicsPanel\CreateRectangle.cs</FileName>
-    </TypeIdentifier>
-  </Class>
-  <Class Name="OTSMeasureApp.CreateRectangle">
-    <Position X="1" Y="10" Width="2.75" />
-    <TypeIdentifier>
-      <HashCode>AeCFDAICwIt54cAAAGAgA0cgMBBGJBAQAggAAgEJBgg=</HashCode>
+      <HashCode>oeCGDKMgQIMho8CYMHEAA8MiSDDCJJEQiAgiAAMJBhA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\CreateRectangle.cs</FileName>
     </TypeIdentifier>
   </Class>
   <Class Name="OTSMeasureApp.OTSSamplespaceWindow">
     <Position X="8.75" Y="0.5" Width="2.75" />
     <TypeIdentifier>
-      <HashCode>Jb6d/TvUAqHzzwHlJTniOrr7ZH7TkJnR/26MGCR6UCA=</HashCode>
+      <HashCode>A7TZ6hkUBKXhzgHlBCiieIv3QH4DgJnV80iECQATUAA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\OTSSamplespaceWindow.cs</FileName>
     </TypeIdentifier>
     <ShowAsAssociation>
-      <Field Name="selectSampleGDIObjects" />
       <Field Name="m_visualStage" />
     </ShowAsAssociation>
     <ShowAsCollectionAssociation>
-      <Field Name="m_SampleGDIObjects" />
-      <Field Name="m_MeasureGDIObjects" />
-      <Field Name="m_MeasurePathGDIObjects" />
-      <Field Name="m_MeasureFieldGDIObjects" />
-      <Field Name="m_AllFieldGDIObjects" />
       <Field Name="m_ImageGDIObjects" />
       <Field Name="m_ImageOfFieldGDIObjects" />
-      <Field Name="m_DrawMeasureGDIObjects" />
-      <Field Name="m_DrawPolygonFinishGDIObjects" />
+      <Field Name="m_visualSamples" />
     </ShowAsCollectionAssociation>
   </Class>
   <Class Name="OTSMeasureApp.OTSSamplespaceGraphicsPanelFun">
     <Position X="17.25" Y="0.75" Width="2.75" />
-    <NestedTypes>
-      <Enum Name="OTSMeasureApp.OTSSamplespaceGraphicsPanelFun.EnumMousePointPosition" Collapsed="true">
-        <TypeIdentifier>
-          <NewMemberFileName>4-OTSSamplespaceGraphicsPanel\OTSSamplespaceGraphicsPanelFun.cs</NewMemberFileName>
-        </TypeIdentifier>
-      </Enum>
-    </NestedTypes>
     <TypeIdentifier>
-      <HashCode>ABhEQABEAAAAIQAAAAAAQQAIAIAAAABEIEAEwAIBwCA=</HashCode>
+      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAA=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\OTSSamplespaceGraphicsPanelFun.cs</FileName>
     </TypeIdentifier>
   </Class>
   <Class Name="OTSMeasureApp.SEMDATAFieldManage">
     <Position X="19" Y="8.25" Width="2" />
     <TypeIdentifier>
-      <HashCode>QIAAAAgAJAAAACAggAAIKgGAACAAAAABQAAAAEAAAAM=</HashCode>
+      <HashCode>AAAAAAgAJAAAAAAAAAAIKgGAACAAAAAAQAAAAEAAAAM=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\SEMDATAFieldManage.cs</FileName>
     </TypeIdentifier>
   </Class>
-  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualStage">
+  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualStage" Collapsed="true">
     <Position X="13.5" Y="0.5" Width="3" />
     <TypeIdentifier>
-      <HashCode>kWIacgCACJgKEAESAAYEKSgAABMwMpIAhAAIUAQAAAg=</HashCode>
+      <HashCode>iWAKYhCAAIgCEAAWAAQECSAAIJMwApJAhBAIUASAARg=</HashCode>
       <FileName>4-OTSSamplespaceGraphicsPanel\VisualStage.cs</FileName>
     </TypeIdentifier>
   </Class>
+  <Class Name="OTSMeasureApp._4_OTSSamplespaceGraphicsPanel.CVisualSampleArea" Collapsed="true">
+    <Position X="0.5" Y="1.5" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>CCECAABAAACAAAAAAAAAIAEgAgBAAACEAAgAAQAAEAA=</HashCode>
+      <FileName>4-OTSSamplespaceGraphicsPanel\CVisualSampleArea.cs</FileName>
+    </TypeIdentifier>
+  </Class>
   <Font Name="Microsoft YaHei UI" Size="9" />
 </ClassDiagram>