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.

120 lines
2.8 KiB
C++

#include "StdAfx.h"
#include "ObjComposite.h"
#include "ObjPline.h"
#include "GlobalFunction.h"
CObjComposite::CObjComposite(void)
{
m_Distance = 10;//两个基准点的距离
}
CObjComposite::~CObjComposite(void)
{
}
CObjComposite::CObjComposite(CObjComposite &rhs)
:CObjBase(rhs)
{
m_BasePt1 = rhs.m_BasePt1;//保存object 当前的位置
m_BasePt2 = rhs.m_BasePt2;//保存object 当前的位置(用于记录旋转)
m_Distance = rhs.m_Distance;//两个点的距离
rhs.m_ObjContainer.CloneObj(m_ObjContainer,false);
}
#if 1
void CObjComposite::WriteWorkFileExt(vector<CLab> &LabVec)
{
//写入obj 信息
m_ObjContainer.WriteWorkFile(LabVec);
}
void CObjComposite::ReadWorkFileExt(CLabVecRang &LabVecRang)
{
//读取obj 信息
m_ObjContainer.ReadWorkFile(LabVecRang);
}
#endif
//bNewLine 表示是否要新建一段线段
void CObjComposite::AddPt(CDataPoint pt,bool bNewLine)
{
if(bNewLine)
{
CObjPline *p = new CObjPline;
p->AddDataPoint(pt);
m_ObjContainer.AddObject(p);
}
else
{
m_ObjContainer.AddPtToLastObj(pt);
}
}
void CObjComposite::Creat()
{
CreatExt();
UpdateSelState();
}
//更新组obj 的选择状态
void CObjComposite::UpdateSelState()
{
if(m_bSelected)
{
m_ObjContainer.SelAllObj();
}
else
{
m_ObjContainer.NotSelAllObj();
}
}
void CObjComposite::Draw(CDC* pDC,CPen &Pen)
{
m_ObjContainer.DrawAllObj(pDC);
}
bool CObjComposite::IsInRect(DbRect rect,bool bNeedAllIn)
{
return m_ObjContainer.IsInRect(rect,bNeedAllIn);
}
void CObjComposite::SetSelected(bool bSelected)
{
CObjBase::SetSelected(bSelected);//全部的选择状态
m_ObjContainer.SetSelected(bSelected);//每个成员的选择状态
}
void CObjComposite::Operate(SObjOperatePar &par)
{
//记录操作参数
SavePar(par);
m_ObjContainer.Operate(par);
}
//记录操作参数, 用来从新生成的是否定位
void CObjComposite::SavePar(SObjOperatePar &par)
{
if(par.OpType == _OP_MOVE)
{
m_BasePt1.x += par.MoveX;
m_BasePt1.y += par.MoveY;
m_BasePt2.x += par.MoveX;
m_BasePt2.y += par.MoveY;
}
if(par.OpType == _OP_ROTATO)
{
m_BasePt1 = RotatoPt(m_BasePt1,_360ToAngle(par.Angle),par.BasePt);
m_BasePt2 = RotatoPt(m_BasePt2,_360ToAngle(par.Angle),par.BasePt);
}
}
DbRect CObjComposite::GetRect()
{
return m_ObjContainer.GetObjRect(false);
}
void CObjComposite::SetPosition(Dbxy pt)
{
m_BasePt1 = m_BasePt2= pt;
m_BasePt2.x += m_Distance;
};
//委托给组成员去搜集
void CObjComposite::GetPtData(vector<vector<Dbxy>> &vec)
{
m_ObjContainer.GetObjPtData(vec,false);
}
//获取rect 范围内所有的线段
void CObjComposite::GetLineInRect(DbRect &rect,vector<DbLine> &DataPtLineVec,bool bGetCatchNode)
{
m_ObjContainer.GetLineInRect(rect,DataPtLineVec,true);
}