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.
193 lines
5.2 KiB
C++
193 lines
5.2 KiB
C++
#include "StdAfx.h"
|
|
#include "TemplateMgr.h"
|
|
#include "Layer.h"
|
|
#include "Propertie.h"
|
|
#include "PropertieMgr.h"
|
|
#include "AuthorityMgr.h"
|
|
#include "WorkFileLable.h"
|
|
#include "WorkFileMgr.h"
|
|
#include "LogMgr.h"
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
#define MaxTempCnt 200 //可编辑模板的数量
|
|
#define NULL_IDX -1//判断无绑定模板的索引值
|
|
CTemplateMgr *gTemplateMgr = new CTemplateMgr;
|
|
CTemplateMgr::CTemplateMgr(void)
|
|
{
|
|
m_bUseObjList = false;//是否使用对象列表
|
|
m_bClearOldObj = true;//读取文件时是否清除旧的obj 对象
|
|
}
|
|
CTemplateMgr::~CTemplateMgr(void)
|
|
{
|
|
}
|
|
#if 1//复写module 的函数
|
|
CMFCPropertyGridProperty *CTemplateMgr::CreatGridProperty()
|
|
{
|
|
CPropertieMgr &PropertieMgr = gDevicePropertieMgr;
|
|
|
|
CString PropertyName;//属性名称
|
|
CString Description;//描述
|
|
CString Path = _T("Template");//存储路径
|
|
CString Name;
|
|
//-------------------------------------------------------------------------------//
|
|
PropertyName = _T("模板设定");
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
PropertyName = _T("对象列表");
|
|
if(gAuthorityMgr->CheckAuthority(_Authority_Operator))
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_bUseObjList");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_bUseObjList);
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
//添加属性显示
|
|
PropertyName = _T("对象列表");
|
|
Description = _T("是否使用对象列表,使用后会影响刷新速度");
|
|
CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bUseObjList, Description);
|
|
pGroup->AddSubItem(p);
|
|
|
|
PropertieMgr.Insert(p, pPropertie);
|
|
}
|
|
}
|
|
return pGroup;
|
|
}
|
|
void CTemplateMgr::OnAppInitialize()
|
|
{
|
|
//清空容器
|
|
m_TempVec.clear();
|
|
//初始化模板容器
|
|
for(int i=0;i<MaxTempCnt;i++)
|
|
{
|
|
CTemplate Temp;
|
|
m_TempVec.push_back(Temp);
|
|
}
|
|
|
|
//不要绑定任何模板到layer
|
|
ClearTempNull();
|
|
BindNullTemp();
|
|
}
|
|
#endif
|
|
#if 1
|
|
void CTemplateMgr::WriteWorkFileExt(vector<CLab> &LabVec)
|
|
{
|
|
for(int i=0;i<MaxTempCnt;i++)
|
|
{
|
|
LabVec.push_back(CLab(LAB_TEMPLATE_START));
|
|
m_TempVec[i].WriteWorkFile(LabVec);
|
|
LabVec.push_back(CLab(LAB_TEMPLATE_END));
|
|
}
|
|
//写入空模板
|
|
LabVec.push_back(CLab(LAB_TEMPLATE_START));
|
|
m_TempNull.WriteWorkFile(LabVec);
|
|
LabVec.push_back(CLab(LAB_TEMPLATE_END));
|
|
}
|
|
void CTemplateMgr::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
{
|
|
if(IsbClearOldObj())
|
|
{
|
|
ClearTempNull();
|
|
}
|
|
//分离模板---------------------------------------------------
|
|
vector<CLabVecRang> LabVecRangVec;
|
|
CWorkFileMgr WorkFileMgr;
|
|
WorkFileMgr.SeparateStrVec(LabVecRang,LabVecRangVec,LAB_TEMPLATE_START,LAB_TEMPLATE_END);
|
|
|
|
//处理每个模板
|
|
if(!LabVecRangVec.empty())
|
|
{
|
|
size_t size = LabVecRangVec.size();
|
|
for(size_t i=0;i<size;i++)
|
|
{
|
|
if(i==size-1)
|
|
{
|
|
m_TempNull.ReadWorkFile(LabVecRangVec[i]);
|
|
}
|
|
else
|
|
{
|
|
m_TempVec[i].ReadWorkFile(LabVecRangVec[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//绑定模板
|
|
BindNullTemp();
|
|
}
|
|
#endif
|
|
|
|
void CTemplateMgr::ClearTempNull()
|
|
{
|
|
m_TempNull.ClearObj();
|
|
}
|
|
|
|
//不要绑定任何模板到layer
|
|
void CTemplateMgr::BindNullTemp()
|
|
{
|
|
m_CurTempIdx = NULL_IDX;
|
|
//绑定模板
|
|
BindCurTemp();
|
|
}
|
|
|
|
//绑定当前选择的模板
|
|
void CTemplateMgr::BindCurTemp()
|
|
{
|
|
//当前模板设置为layer 编辑模板
|
|
CLayer &Layer = gLayer;
|
|
|
|
//没有要编辑的模板时绑定一个空模板到layer
|
|
//可以向空模板加入对象,但是不会使用这些对象
|
|
if(m_CurTempIdx==NULL_IDX)
|
|
{
|
|
Layer.BindObjContainer(m_TempNull.GetObjContainer());
|
|
}
|
|
else
|
|
{
|
|
Layer.BindObjContainer(m_TempVec[m_CurTempIdx].GetObjContainer());
|
|
}
|
|
}
|
|
//指定要编辑的模板
|
|
void CTemplateMgr::EditTemp(int idx)
|
|
{
|
|
if(idx>=0&&idx<MaxTempCnt)
|
|
{
|
|
m_CurTempIdx = idx;
|
|
ClearTempNull();
|
|
BindCurTemp();
|
|
}
|
|
}
|
|
|
|
void CTemplateMgr::Draw(CDC* pDC)
|
|
{
|
|
if(m_CurTempIdx != NULL_IDX)
|
|
m_TempVec[m_CurTempIdx].Draw(pDC,gDraw->GetTempRectPen());
|
|
}
|
|
|
|
//设置指定模板的范围(bCircle 表示是否为圆形)
|
|
void CTemplateMgr::SetTempRect(int idx,DbRect &rect,bool bCircle)
|
|
{
|
|
if(idx>=0&&idx<MaxTempCnt)
|
|
{
|
|
m_TempVec[idx].SetRect(rect,bCircle);
|
|
}
|
|
}
|
|
|
|
//收集指定模板的数据BasePt 是转换的基准点
|
|
void CTemplateMgr::CollectWorkData(int idx,vector<vector<Dbxy>> &vec)
|
|
{
|
|
if(idx>=0&&idx<MaxTempCnt)
|
|
{
|
|
m_TempVec[idx].CollectWorkData(vec);
|
|
}
|
|
}
|
|
//获取0 号模板的ObjContainer
|
|
CObjContainer &CTemplateMgr::GetTemplateZeroObjContainer()
|
|
{
|
|
return m_TempVec[0].GetObjContainer();
|
|
}
|