You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
3.7 KiB
C++

#include "StdAfx.h"
#include "ParMappingTab.h"
#include "Propertie.h"
#include "PropertieMgr.h"
CParMappingTab::CParMappingTab(void)
{
//初始化参数容器
for(int i=0;i<VAR_PAR_CNT;i++)
{
m_CurCtrlParVec.push_back("NULL");
}
}
CParMappingTab::~CParMappingTab(void)
{
}
void CParMappingTab::CreatGridProperty(CMFCPropertyGridProperty* pGroup,CString Path,CModule *pModule)
{
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("参数映射表"));
{
for(int i=0;i<VAR_PAR_CNT;i++)
{
CString str;
str.Format("%ld",i+1);
//添加属性变量映射
CString Name = "m_CurCtrlParVec" + str;//变量名字
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&(m_CurCtrlParVec[i]));
pPropertie->SetType(_PROP_TYPE_STRING);
pPropertie->SetpModule(pModule);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//读取保存的属性
//添加属性显示
str.Format("参数%ld",i+1);
CString PropertyName = str;
str += "对应的含义(修改需要重启软件才能生效)";
CString Description = str;
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CurCtrlParVec[i], Description);
//插入参数内容
InsertPenParName(p1);
p1->AllowEdit(FALSE);//不可修改
pGroup1->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
}
}
//调整参数的顺序(使用的参数都靠前排列),并且去掉不存在的参数
void CParMappingTab::AdjustParOrder()
{
vector<CString> Vec;
for(int i=0;i<VAR_PAR_CNT;i++)
{
if(m_CurCtrlParVec[i]!="NULL")
{
bool flg = false;
int size = m_AllCtrlParList.size();
for(int k=0;k<size;k++)
{
if(m_CurCtrlParVec[i] == m_AllCtrlParList[k])//存在
{
flg = true;
break;
}
}
if(flg)//只保留存在的参数名
{
Vec.push_back(m_CurCtrlParVec[i]);
}
m_CurCtrlParVec[i] = "NULL";
}
}
int size = Vec.size();
for(int k=0;k<size;k++)
{
m_CurCtrlParVec[k] = Vec[k];
}
}
//插入参数内容
void CParMappingTab::InsertPenParName(CMFCPropertyGridProperty* p)
{
vector<CString>::iterator iter = m_AllCtrlParList.begin();
vector<CString>::iterator iter_end = m_AllCtrlParList.end();
for(int i=0;iter!=iter_end;iter++,i++)
{
p->AddOption(*iter);
}
}
//通过(模块自定义的par 类型枚举值)来查询在映射表中的索引值idx
//模块得到idx 后,再到自己的数据容器中去查找对应的数据
bool CParMappingTab::GetMappingTabParIdx(int EnumParType,int &ParIdx)
{
int size = m_AllCtrlParList.size();
if(EnumParType<size)
{
CString ParName = m_AllCtrlParList[EnumParType];//查询参数的名字
size = m_CurCtrlParVec.size();
for(int k=0;k<size;k++)
{
if(ParName == m_CurCtrlParVec[k])//发现匹配项(多个一样的以第一个为准)
{
ParIdx = k;
return true;
}
}
}
ParIdx = -1;
return false;//没有匹配项
}