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
2.9 KiB
C++
117 lines
2.9 KiB
C++
#include "StdAfx.h"
|
|
#include "ObjChar.h"
|
|
#include "ObjPline.h"
|
|
#include "DataPoint.h"
|
|
#include "FontTypeMgr.h"
|
|
#include "LogMgr.h"
|
|
#include "GlobalFunction.h"
|
|
|
|
|
|
CObjChar::CObjChar(char *p)
|
|
{
|
|
m_pChar = p;
|
|
}
|
|
CObjChar::~CObjChar(void)
|
|
{
|
|
|
|
}
|
|
CString CObjChar::GetStr()
|
|
{
|
|
CString str = "字符";
|
|
return str;
|
|
}
|
|
void CObjChar::Creat()
|
|
{
|
|
CFontTypeMgr &pFontTypeMgr = CFontTypeMgr::Instance();
|
|
//先读取到m_PonitVec 中
|
|
vector<PointType> m_PonitVec;
|
|
//用当前字体来创建字符数据
|
|
pFontTypeMgr.CreatCharVec(m_pChar,m_PonitVec);
|
|
//再转换为obj
|
|
CreatObjData(m_PonitVec);
|
|
}
|
|
|
|
//获取obj 的数据
|
|
void CObjChar::CreatObjData(vector<PointType> &m_PonitVec)
|
|
{
|
|
if(m_PonitVec.size() <= 1)//没有取到数据则创建一个矩形
|
|
{
|
|
CObjPline *pPline = new CObjPline;
|
|
|
|
DbRect rect(0,100,100,0);
|
|
pPline->CreatRect(rect);
|
|
m_ObjContainer.AddObject(pPline);
|
|
}
|
|
else
|
|
{
|
|
int size = m_PonitVec.size();
|
|
|
|
//去掉末尾不要的偏移-----------------------------------
|
|
if(m_PonitVec[size-1].second == TRUE)
|
|
{
|
|
m_PonitVec.pop_back();
|
|
size--;
|
|
}
|
|
//用m_PonitVec 的数据来创建obj
|
|
CObjPline *pPline = NULL;
|
|
for(int i=0;i<size;i++)
|
|
{
|
|
if(m_PonitVec[i].second == true)
|
|
{
|
|
pPline = new CObjPline;
|
|
m_ObjContainer.AddObject(pPline);
|
|
}
|
|
if(pPline)
|
|
{
|
|
Dbxy pt;
|
|
pt.x = m_PonitVec[i].first.x;
|
|
pt.y = m_PonitVec[i].first.y;
|
|
CDataPoint DataPoint(pt);
|
|
//DataPoint.SetIsNode(true);//是否为节点
|
|
pPline->AddDataPoint(DataPoint);
|
|
}
|
|
}
|
|
}
|
|
//删除空线段
|
|
m_ObjContainer.DelNullLine();
|
|
}
|
|
void CObjChar::Operate(SObjOperatePar &par)
|
|
{
|
|
if(par.OpType == _OP_SCALE)
|
|
{
|
|
DbRect rect = m_ObjContainer.GetObjRect(false);
|
|
DbSize s = rect.GetSize();
|
|
|
|
SObjOperatePar parX;
|
|
{
|
|
parX.OpType = _OP_STRETCH;
|
|
parX.BasePt = rect.GetCenterPt();
|
|
|
|
parX.OldSize = s.w;
|
|
parX.NewSize = s.w*par.Scale;
|
|
parX.Diff = parX.NewSize-parX.OldSize;
|
|
parX.xy = _X;
|
|
}
|
|
SObjOperatePar parY;
|
|
{
|
|
parY.OpType = _OP_STRETCH;
|
|
parX.BasePt = rect.GetCenterPt();
|
|
|
|
parY.OldSize = s.h;
|
|
parY.NewSize = s.h*par.Scale;
|
|
parY.Diff = parY.NewSize-parY.OldSize;
|
|
parY.xy = _Y;
|
|
}
|
|
|
|
int size = m_ObjContainer.GetSize();
|
|
for(int i=0;i<size;i++)
|
|
{
|
|
m_ObjContainer.Operate(parX,i);
|
|
m_ObjContainer.Operate(parY,i);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CObjComposite::Operate(par);
|
|
}
|
|
} |