|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "PltReader.h"
|
|
|
|
|
#include "ObjComposite.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "AuthorityMgr.h"
|
|
|
|
|
#include "MarkObjPropertieMgr.h"
|
|
|
|
|
#include "Layer.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
CPltReader* gPltReader = new CPltReader;//plt <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
CPltReader::CPltReader(void)
|
|
|
|
|
{
|
|
|
|
|
m_ScaleX = 0.024888;
|
|
|
|
|
m_ScaleY = 0.024875;
|
|
|
|
|
}
|
|
|
|
|
CPltReader::~CPltReader(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
|
|
|
|
|
CMFCPropertyGridProperty *CPltReader::CreatGridProperty()
|
|
|
|
|
{
|
|
|
|
|
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString Description;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
CString Path = _T("PltSet");;//<2F>洢·<E6B4A2><C2B7>
|
|
|
|
|
CString Name;
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("plt <20><>ȡ");
|
|
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_Authority_Factory))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_ScaleX");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_ScaleX);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("plt <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>X");
|
|
|
|
|
Description = _T("<EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>plt <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ŵ<EFBFBD>cad <20><>Ӧ<EFBFBD><D3A6>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_ScaleX, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_Authority_Factory))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_ScaleY");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_ScaleY);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("plt <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Y");
|
|
|
|
|
Description = _T("<EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>plt <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ŵ<EFBFBD>cad <20><>Ӧ<EFBFBD><D3A6>С<EFBFBD>ı<EFBFBD><C4B1><EFBFBD>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_ScaleY, Description);
|
|
|
|
|
pGroup->AddSubItem(p1);
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
return pGroup;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
void CPltReader::OpenFile()
|
|
|
|
|
{
|
|
|
|
|
CLayer &layer = gLayer;
|
|
|
|
|
CFileDialog FileOpen(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "plt <20>ļ<EFBFBD> (*.plt)|*.plt;");
|
|
|
|
|
if(IDOK == FileOpen.DoModal())
|
|
|
|
|
{
|
|
|
|
|
CString FilePath=FileOpen.GetPathName();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>plt <20>ļ<EFBFBD>
|
|
|
|
|
if(AnalysePltFlie(FilePath))
|
|
|
|
|
{
|
|
|
|
|
//<2F><>vec <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ϳɶ<CFB3><C9B6><EFBFBD>
|
|
|
|
|
TranslatorToComposite(m_PtVec,layer.GetObjContainer());
|
|
|
|
|
GetCurViewPtr()->RefreshView();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
gMarkObjPropertieMgr->UpdateSelMarkObjPropertie();
|
|
|
|
|
gLogMgr->WriteDebugLog("func :Open Plt File---->"+FilePath);
|
|
|
|
|
}
|
|
|
|
|
gLogMgr->WriteDebugLog("func :AnalysePltFlie---->Error");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>vec <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ϳɶ<CFB3><C9B6><EFBFBD>
|
|
|
|
|
void CPltReader::TranslatorToComposite(vector<PointType> &vec,CObjContainer &ObjContainer)
|
|
|
|
|
{
|
|
|
|
|
if(vec.empty())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϳɶ<CFB3><C9B6><EFBFBD>
|
|
|
|
|
CObjComposite *pObj = new CObjComposite;
|
|
|
|
|
|
|
|
|
|
vector<PointType>::iterator iter = vec.begin();
|
|
|
|
|
vector<PointType>::iterator iter_end = vec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
Dbxy DbPt((*iter).first.x,(*iter).first.y);
|
|
|
|
|
CDataPoint pt(DbPt);
|
|
|
|
|
pObj->AddPt(pt,(*iter).second);
|
|
|
|
|
}
|
|
|
|
|
//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>м<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
DbRect rect = pObj->GetRect();
|
|
|
|
|
Dbxy pt = rect.GetCenterPt();
|
|
|
|
|
|
|
|
|
|
SObjOperatePar par;
|
|
|
|
|
par.OpType = _OP_MOVE;
|
|
|
|
|
par.MoveX = -pt.x;
|
|
|
|
|
par.MoveY = -pt.y;
|
|
|
|
|
pObj->Operate(par);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ŵ<EFBFBD>cad <20><><EFBFBD>óߴ<C3B3>X
|
|
|
|
|
{
|
|
|
|
|
SObjOperatePar par;
|
|
|
|
|
par.Scale = m_ScaleX;
|
|
|
|
|
|
|
|
|
|
par.OpType = _OP_STRETCH;
|
|
|
|
|
DbRect rect = pObj->GetRect();
|
|
|
|
|
Dbxy pt = rect.GetCenterPt();
|
|
|
|
|
|
|
|
|
|
par.OldSize = rect.R - rect.L;
|
|
|
|
|
par.NewSize = par.OldSize*par.Scale;
|
|
|
|
|
par.Diff = par.NewSize-par.OldSize;
|
|
|
|
|
par.xy = _X;
|
|
|
|
|
pObj->Operate(par);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ŵ<EFBFBD>cad <20><><EFBFBD>óߴ<C3B3>Y
|
|
|
|
|
{
|
|
|
|
|
SObjOperatePar par;
|
|
|
|
|
par.Scale = m_ScaleY;
|
|
|
|
|
|
|
|
|
|
par.OpType = _OP_STRETCH;
|
|
|
|
|
DbRect rect = pObj->GetRect();
|
|
|
|
|
Dbxy pt = rect.GetCenterPt();
|
|
|
|
|
|
|
|
|
|
par.OldSize = rect.T - rect.B;
|
|
|
|
|
par.NewSize = par.OldSize*par.Scale;
|
|
|
|
|
par.Diff = par.NewSize-par.OldSize;
|
|
|
|
|
par.xy = _Y;
|
|
|
|
|
pObj->Operate(par);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjContainer.AddObject(pObj);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>plt <20>ļ<EFBFBD>
|
|
|
|
|
bool CPltReader::AnalysePltFlie(CString FilePath)
|
|
|
|
|
{
|
|
|
|
|
m_PtVec.clear();
|
|
|
|
|
|
|
|
|
|
CStdioFile file;
|
|
|
|
|
if(file.Open(FilePath,CFile::modeRead,NULL)==0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CString str;
|
|
|
|
|
bool flg = true;
|
|
|
|
|
int pos = 0;
|
|
|
|
|
while(file.ReadString(str))//<2F><>ȡһ<C8A1><D2BB>
|
|
|
|
|
{
|
|
|
|
|
int len = str.GetLength();
|
|
|
|
|
while(pos<len)
|
|
|
|
|
{
|
|
|
|
|
CString TypeStr = FindNextP(str,pos);
|
|
|
|
|
if(TypeStr == "PU")
|
|
|
|
|
{
|
|
|
|
|
flg = true;
|
|
|
|
|
}
|
|
|
|
|
else if(TypeStr == "PD")
|
|
|
|
|
{
|
|
|
|
|
flg = false;
|
|
|
|
|
}
|
|
|
|
|
else if(TypeStr == "PA")//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
{
|
|
|
|
|
int idx1 = str.Find(',',pos);//<2F><><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
int idx2 = str.Find(';',pos);//<2F>ֺŵ<D6BA>λ<EFBFBD><CEBB>
|
|
|
|
|
if(idx1<idx2 && idx1 != -1 && idx2 != -1)
|
|
|
|
|
{
|
|
|
|
|
CString strNum1 = str.Mid(pos+1,idx1 - (pos+1));
|
|
|
|
|
CString strNum2 = str.Mid(idx1+1,idx2 - (idx1+1));
|
|
|
|
|
int x = atoi(strNum1);
|
|
|
|
|
int y = atoi(strNum2);
|
|
|
|
|
//<2F><><EFBFBD>浱ǰ<E6B5B1><C7B0>
|
|
|
|
|
if(!(x == 0 && y == 0))//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>0<EFBFBD><30>
|
|
|
|
|
{
|
|
|
|
|
CPoint point(x,y);
|
|
|
|
|
m_PtVec.push_back(make_pair(point,flg));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(TypeStr == "END")
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
//<2F>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB>P ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString CPltReader::FindNextP(CString str,int &pos)
|
|
|
|
|
{
|
|
|
|
|
CString TypeStr;
|
|
|
|
|
int len = str.GetLength();
|
|
|
|
|
pos = str.Find('P',pos);
|
|
|
|
|
if(pos == -1)
|
|
|
|
|
{
|
|
|
|
|
TypeStr = "END";
|
|
|
|
|
}
|
|
|
|
|
else if(pos<len)
|
|
|
|
|
{
|
|
|
|
|
pos++;
|
|
|
|
|
if(str[pos]=='U')
|
|
|
|
|
{
|
|
|
|
|
TypeStr = "PU";
|
|
|
|
|
}
|
|
|
|
|
else if(str[pos]=='D')
|
|
|
|
|
{
|
|
|
|
|
TypeStr = "PD";
|
|
|
|
|
}
|
|
|
|
|
else if(str[pos]=='A')
|
|
|
|
|
{
|
|
|
|
|
TypeStr = "PA";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TypeStr;
|
|
|
|
|
}
|
|
|
|
|
#endif
|