|
|
#include "StdAfx.h"
|
|
|
#include "ObjContainer.h"
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
#include "GlobalFunction.h"
|
|
|
#include "ObjPLine.h"
|
|
|
#include "ObjFactory.h"
|
|
|
#include "CommandBase.h"
|
|
|
#include "CStringFuc.h"
|
|
|
#include "WorkFileLable.h"
|
|
|
#include "WorkFileMgr.h"
|
|
|
#include "LogMgr.h"
|
|
|
#include "MsgBox.h"
|
|
|
#include "TemplateMgr.h"
|
|
|
#include "PenParMgr.h"
|
|
|
#include "Laser.h"
|
|
|
#include "ObjFillMgr.h"
|
|
|
#include "ProgramLaserTuiHuo.h"
|
|
|
#include "Layer.h"
|
|
|
#include "WaferRecipeDataMgr.h"
|
|
|
#include "RecipeMgr.h"
|
|
|
|
|
|
|
|
|
CObjContainer::CObjContainer(void)
|
|
|
{
|
|
|
}
|
|
|
CObjContainer::~CObjContainer(void)
|
|
|
{
|
|
|
}
|
|
|
#if 1
|
|
|
void CObjContainer::WriteWorkFile(vector<CLab> &LabVec)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsbFillObj())
|
|
|
continue;
|
|
|
LabVec.push_back(CLab(LAB_OBJ_START));
|
|
|
(*iter)->WriteWorkFile(LabVec);
|
|
|
LabVec.push_back(CLab(LAB_OBJ_END));
|
|
|
}
|
|
|
}
|
|
|
void CObjContainer::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
|
{
|
|
|
//分离obj 对象---------------------------------------------------
|
|
|
vector<CLabVecRang> LabVecRangVec;
|
|
|
CWorkFileMgr WorkFileMgr;
|
|
|
WorkFileMgr.SeparateStrVec(LabVecRang,LabVecRangVec,LAB_OBJ_START,LAB_OBJ_END);
|
|
|
//处理每个obj ---------------------------------------------------
|
|
|
if(gTemplateMgr->IsbClearOldObj())
|
|
|
{
|
|
|
Clear();//清空原来的obj
|
|
|
}
|
|
|
if(!LabVecRangVec.empty())
|
|
|
{
|
|
|
vector<CLabVecRang>::iterator iter = LabVecRangVec.begin();
|
|
|
vector<CLabVecRang>::iterator iter_end = LabVecRangVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
//获取obj 的类型
|
|
|
CLab ObjType= WorkFileMgr.FindLab((*iter),LAB_OBJ_TYPE);
|
|
|
if(ObjType.m_ValType != _TYPE_NULL)
|
|
|
{
|
|
|
OBJ_TYPE type = (OBJ_TYPE)(ObjType.m_Int);
|
|
|
if(type != _TYPE_BASE)
|
|
|
{
|
|
|
CObjFactory ObjFactory;
|
|
|
CObjBase *p = ObjFactory.CreatObj(type);//恢复obj 的实例
|
|
|
if(p)
|
|
|
{
|
|
|
p->ReadWorkFile(*iter);//恢复数据
|
|
|
AddObject(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
void CObjContainer::AddObject(CObjBase *pMarkObject)
|
|
|
{
|
|
|
//保存到智能指针
|
|
|
Sptr<CObjBase> sPtr(pMarkObject);
|
|
|
AddObject(sPtr);
|
|
|
}
|
|
|
void CObjContainer::AddObject(Sptr<CObjBase> p)
|
|
|
{
|
|
|
m_ObjVec.push_back(p);
|
|
|
}
|
|
|
//添加点到末尾的obj
|
|
|
void CObjContainer::AddPtToLastObj(CDataPoint pt)
|
|
|
{
|
|
|
if(!m_ObjVec.empty())
|
|
|
{
|
|
|
m_ObjVec[m_ObjVec.size()-1]->AddDataPoint(pt);
|
|
|
}
|
|
|
}
|
|
|
//创建特殊对象属性(比如圆)
|
|
|
CMFCPropertyGridProperty *CObjContainer::CreatSpecialGridProperty(CModule *pModule)
|
|
|
{
|
|
|
if(GetSelObjCnt() == 1)//只有一个对象时才设置
|
|
|
{
|
|
|
return GetFirstSelObj()->CreatSpecialGridProperty(pModule);
|
|
|
}
|
|
|
else
|
|
|
return NULL;
|
|
|
}
|
|
|
//相应特殊属性的变化
|
|
|
void CObjContainer::OnSpecialPropertyChanged()
|
|
|
{
|
|
|
if(GetSelObjCnt() == 1)//只有一个对象时才设置
|
|
|
{
|
|
|
GetFirstSelObj()->OnSpecialPropertyChanged();
|
|
|
}
|
|
|
}
|
|
|
//插入对象列表
|
|
|
void CObjContainer::InsertList(CListCtrl &List)
|
|
|
{
|
|
|
int size = m_ObjVec.size();
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
int idx = 0;
|
|
|
List.InsertItem(i," ");//插入一行
|
|
|
List.SetItemText(i,idx++,Int2CString(i+1));//序号
|
|
|
List.SetItemText(i,idx++,m_ObjVec[i]->GetStr());//类型
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1//绘制
|
|
|
void CObjContainer::DrawAllObj(CDC* pDC)
|
|
|
{
|
|
|
//绘制所有obj
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
int k = 1;
|
|
|
for(;iter!=iter_end;iter++,k++)
|
|
|
{
|
|
|
//退火过程中不要绘制填充对象
|
|
|
if(!gLayer.IsbDrawObj() && (*iter)->IsbFillObj())
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
if((*iter)->IsbScaned())//被扫描过
|
|
|
{
|
|
|
(*iter)->Draw(pDC,gDraw->GetScanLine());
|
|
|
continue;
|
|
|
}
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
(*iter)->Draw(pDC,gDraw->GetSelObjectPen());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
(*iter)->Draw(pDC);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//绘制obj 对象的索引idx
|
|
|
void CObjContainer::DrawObjIdx(CDC* pDC)
|
|
|
{
|
|
|
if(GetScanAreaCnt()<=1)
|
|
|
return;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
int k = 1;
|
|
|
int MarkIdx = 1;
|
|
|
for(;iter!=iter_end;iter++,k++)
|
|
|
{
|
|
|
if(!(*iter)->IsbFillObj())
|
|
|
{
|
|
|
CString str;
|
|
|
str.Format(_T("%d"),k);
|
|
|
if(gDraw->IsbDrawObjIdxCenter())
|
|
|
gDraw->DrawTxt(pDC,str,(*iter)->GetCenterPt());
|
|
|
else
|
|
|
gDraw->DrawTxt(pDC,str,(*iter)->GetFirstPt());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//绘制mark 点字符
|
|
|
void CObjContainer::DrawMarkIdx(CDC* pDC)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
int k = 1;
|
|
|
int MarkIdx = 1;
|
|
|
for(;iter!=iter_end;iter++,k++)
|
|
|
{
|
|
|
if((*iter)->IsbMarkPt())
|
|
|
{
|
|
|
CString str;
|
|
|
str.Format(_T("Mark%d"),MarkIdx++);
|
|
|
gDraw->DrawTxt(pDC,str,(*iter)->GetFirstPt());
|
|
|
}
|
|
|
if(MarkIdx>2)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CObjContainer::DrawAllObj(CDC* pDC,CPen &Pen)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->Draw(pDC,Pen);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CObjContainer::XorRedrawObj(CDC* pDC,bool bNeedSel)
|
|
|
{
|
|
|
int old_rop = pDC->SetROP2(R2_XORPEN);
|
|
|
//绘制所有obj
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(bNeedSel)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
(*iter)->Draw(pDC,gDraw->GetSelObjectPen());
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
(*iter)->Draw(pDC,gDraw->GetObjectPen());
|
|
|
}
|
|
|
}
|
|
|
pDC->SetROP2(old_rop);
|
|
|
}
|
|
|
void CObjContainer::XorDrawLastObj(CDC* pDC)
|
|
|
{
|
|
|
if(m_ObjVec.empty()==false)
|
|
|
{
|
|
|
int old_rop = pDC->SetROP2(R2_XORPEN);
|
|
|
m_ObjVec[m_ObjVec.size()-1]->Draw(pDC,gDraw->GetObjectPen());
|
|
|
pDC->SetROP2(old_rop);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//是否有选择的obj
|
|
|
bool CObjContainer::HasObjSel()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//获取选中obj 的个数
|
|
|
int CObjContainer::GetSelObjCnt()
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
cnt++;
|
|
|
}
|
|
|
return cnt;
|
|
|
}
|
|
|
//获取轮廓obj 的数量(非填充对象)
|
|
|
int CObjContainer::GetScanAreaCnt()
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(!(*iter)->IsbFillObj())
|
|
|
{
|
|
|
cnt++;
|
|
|
}
|
|
|
}
|
|
|
return cnt;
|
|
|
}
|
|
|
//获取扫描线段的数量
|
|
|
int CObjContainer::GetScanLineCnt()
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsbFillObj())
|
|
|
{
|
|
|
cnt++;
|
|
|
}
|
|
|
}
|
|
|
return cnt;
|
|
|
}
|
|
|
bool CObjContainer::HasSelObjectInRect(DbRect rect)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected() && (*iter)->IsInRect(rect,false))
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//在鼠标的rect 中是否有选择的节点
|
|
|
bool CObjContainer::HasSelNodeInRect(DbRect rect)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected()&&(*iter)->HasNodeInRect(rect))
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
bool CObjContainer::HasObjectInRect(DbRect rect)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsInRect(rect,false))
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//获取第一个选择的obj
|
|
|
Sptr<CObjBase> CObjContainer::GetFirstSelObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
return (*iter);
|
|
|
}
|
|
|
}
|
|
|
//错误
|
|
|
Sptr<CObjBase> sp(NULL);
|
|
|
return sp;
|
|
|
}
|
|
|
Sptr<CObjBase> CObjContainer::GetFirstObjInRect(DbRect &rect)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsInRect(rect,false))
|
|
|
{
|
|
|
Sptr<CObjBase> sp(*iter);
|
|
|
return sp;
|
|
|
}
|
|
|
}
|
|
|
//错误
|
|
|
Sptr<CObjBase> sp(NULL);
|
|
|
return sp;
|
|
|
}
|
|
|
Sptr<CObjBase> CObjContainer::GetFirstNodeObjInRect(DbRect &rect)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->HasNodeInRect(rect))
|
|
|
{
|
|
|
Sptr<CObjBase> sp(*iter);
|
|
|
return sp;
|
|
|
}
|
|
|
}
|
|
|
//错误
|
|
|
Sptr<CObjBase> sp(NULL);
|
|
|
return sp;
|
|
|
}
|
|
|
DbRect CObjContainer::GetSelObjRect()
|
|
|
{
|
|
|
DbRect SelObjRect;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected()==false)
|
|
|
continue;
|
|
|
DbRect rect = (*iter)->GetRect();
|
|
|
if(SelObjRect.IsZero())
|
|
|
{
|
|
|
SelObjRect = rect;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AdjustRectByRect(SelObjRect,rect);
|
|
|
}
|
|
|
}
|
|
|
return SelObjRect;
|
|
|
}
|
|
|
//获取所有Obj 的范围矩形
|
|
|
DbRect CObjContainer::GetObjRect(bool bNeedSel)
|
|
|
{
|
|
|
DbRect ObjRect;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(bNeedSel && (*iter)->IsSelected()==false)
|
|
|
continue;
|
|
|
DbRect rect = (*iter)->GetRect();
|
|
|
if(ObjRect.IsZero())
|
|
|
{
|
|
|
ObjRect = rect;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AdjustRectByRect(ObjRect,rect);
|
|
|
}
|
|
|
}
|
|
|
return ObjRect;
|
|
|
}
|
|
|
//获取单个obj 的矩形范围
|
|
|
DbRect CObjContainer::GetObjRect(int idx)
|
|
|
{
|
|
|
DbRect ObjRect;
|
|
|
int size = m_ObjVec.size();
|
|
|
if(CorrectIdx(idx))
|
|
|
{
|
|
|
ObjRect = m_ObjVec[idx]->GetRect();
|
|
|
}
|
|
|
return ObjRect;
|
|
|
}
|
|
|
//选择rect 内的obj
|
|
|
bool CObjContainer::SelObjectInRect(DbRect rect,bool bNeedAllIn)
|
|
|
{
|
|
|
bool ret = false;
|
|
|
int cnt = 0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
Sptr<CObjBase> p = (*iter);
|
|
|
if(p->IsInRect(rect,bNeedAllIn))
|
|
|
{
|
|
|
p->SetSelected(true);
|
|
|
ret = true;
|
|
|
cnt++;
|
|
|
}
|
|
|
}
|
|
|
if(cnt>0)
|
|
|
{
|
|
|
CString LogStr;
|
|
|
LogStr.Format(_T("[Sel Obj Count] = [%d]"),cnt);
|
|
|
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CObjContainer";
|
|
|
LogInfo.m_FuncName = "SelObjectInRect";
|
|
|
LogInfo.m_LogMsg = LogStr;
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
}
|
|
|
return ret;
|
|
|
}
|
|
|
//全选
|
|
|
void CObjContainer::SelAllObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->SetSelected(true);
|
|
|
}
|
|
|
}
|
|
|
void CObjContainer::NotSelAllObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->SetSelected(false);
|
|
|
}
|
|
|
}
|
|
|
//反选
|
|
|
void CObjContainer::RevSelAllObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
(*iter)->SetSelected(false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
(*iter)->SetSelected(true);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除选择项
|
|
|
void CObjContainer::DelSelObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>> vec;
|
|
|
//先备份非选择项
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected() == false)
|
|
|
{
|
|
|
vec.push_back(*iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除所有obj
|
|
|
m_ObjVec.clear();
|
|
|
//将非选择obj 倒回
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
m_ObjVec.push_back(*iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除指定的obj
|
|
|
void CObjContainer::DelObj(Sptr<CObjBase> p)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter).GetPtr() == p.GetPtr())
|
|
|
{
|
|
|
m_ObjVec.erase(iter);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除最后一个obj
|
|
|
void CObjContainer::DeleteLastObj()
|
|
|
{
|
|
|
if(Empty()==false)
|
|
|
{
|
|
|
m_ObjVec.pop_back();
|
|
|
}
|
|
|
}
|
|
|
//删除空线段
|
|
|
void CObjContainer::DelNullLine()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>> vec;
|
|
|
//先备份非选择项
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->Empty() == false)
|
|
|
{
|
|
|
vec.push_back(*iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//删除所有obj
|
|
|
m_ObjVec.clear();
|
|
|
//将非选择obj 倒回
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
m_ObjVec.push_back(*iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//合并选择的图形
|
|
|
CObjBase* CObjContainer::JoinSelObj()
|
|
|
{
|
|
|
//查找适合放在第一位的obj ---------------------------------------------------
|
|
|
int size = m_ObjVec.size();
|
|
|
int cnt = 0;
|
|
|
bool flg1;
|
|
|
bool flg2;
|
|
|
double eps =0.01;//比较精度
|
|
|
int idx=0;
|
|
|
int firstSelIdx = -1;//第一个选择的obj
|
|
|
for(;idx<size;idx++)
|
|
|
{
|
|
|
if(m_ObjVec[idx]->IsSelected())
|
|
|
{
|
|
|
if(firstSelIdx==-1)
|
|
|
{
|
|
|
firstSelIdx = idx;
|
|
|
}
|
|
|
flg1 = true;
|
|
|
flg2 = true;
|
|
|
for(int j=0;j<size;j++)
|
|
|
{
|
|
|
if(m_ObjVec[j]->IsSelected()&&j!=idx)
|
|
|
{
|
|
|
Dbxy FirstPt1 = m_ObjVec[idx]->GetFirstPt();
|
|
|
Dbxy FirstPt2 = m_ObjVec[j]->GetFirstPt();
|
|
|
Dbxy LastPt1 = m_ObjVec[idx]->GetLastPt();
|
|
|
Dbxy LastPt2 = m_ObjVec[j]->GetLastPt();
|
|
|
//相连
|
|
|
if(IsTwoPtEqual(FirstPt1,FirstPt2,eps) || IsTwoPtEqual(FirstPt1,LastPt2,eps))
|
|
|
{
|
|
|
flg1 = false;
|
|
|
}
|
|
|
if(IsTwoPtEqual(LastPt1,FirstPt2,eps) || IsTwoPtEqual(LastPt1,LastPt2,eps))
|
|
|
{
|
|
|
flg2 = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(flg1 || flg2)//找到
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(flg1 && flg2)//如果两端都没有和其他obj连接,则不能合并
|
|
|
return NULL;
|
|
|
if(firstSelIdx==-1)
|
|
|
return NULL;
|
|
|
if(!flg1 && !flg2)//选择的obj 为闭合状态,则以第一个选择的obj 开始
|
|
|
{
|
|
|
idx= flg1;
|
|
|
}
|
|
|
//创建合并的obj ------------------------------------------
|
|
|
bool bReverse = false;
|
|
|
if(flg2)
|
|
|
{
|
|
|
bReverse = true;
|
|
|
}
|
|
|
CObjPline *p = new CObjPline;
|
|
|
p->AddObj(m_ObjVec[idx],bReverse);//加入第一个obj
|
|
|
set<int> Set;//用来判断哪些已经处理过
|
|
|
Set.insert(idx);
|
|
|
|
|
|
Dbxy ConectPt = p->GetLastPt();//当前的连接点
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
for(int j=0;j<size;j++)
|
|
|
{
|
|
|
if(m_ObjVec[j]->IsSelected()&&Set.count(j)==false)//加入没处理过的选择obj
|
|
|
{
|
|
|
if(IsTwoPtEqual(ConectPt,m_ObjVec[j]->GetFirstPt(),eps))//正向
|
|
|
{
|
|
|
p->AddObj(m_ObjVec[j],false);
|
|
|
Set.insert(j);//标记
|
|
|
ConectPt = m_ObjVec[j]->GetLastPt();
|
|
|
}
|
|
|
else if(IsTwoPtEqual(ConectPt,m_ObjVec[j]->GetLastPt(),eps))//逆向
|
|
|
{
|
|
|
p->AddObj(m_ObjVec[j],true);
|
|
|
Set.insert(j);//标记
|
|
|
ConectPt = m_ObjVec[j]->GetFirstPt();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//检查是否还有选择的obj 没有被合并
|
|
|
bool flg = false;
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
if(m_ObjVec[i]->IsSelected()&&Set.count(i)==false)
|
|
|
{
|
|
|
flg = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//如果有,则表示不能合并
|
|
|
if(flg)
|
|
|
{
|
|
|
delete p;
|
|
|
p = NULL;
|
|
|
}
|
|
|
return p;
|
|
|
}
|
|
|
//设置当前操作对象idx 节点的值为pt
|
|
|
void CObjContainer::SetNodePtByIdx(int idx,Dbxy pt)
|
|
|
{
|
|
|
if(Empty())
|
|
|
return;
|
|
|
m_ObjVec[0]->SetNodePtByIdx(idx,pt);
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
#if 1
|
|
|
//操作选择的obj
|
|
|
//bNeedSel 表示需要为选择状态才操作
|
|
|
//bTmpOp 表示是否为临时操作
|
|
|
void CObjContainer::OperateObj(SObjOperatePar &par,bool bNeedSel)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(bNeedSel==false || (bNeedSel && (*iter)->IsSelected()))
|
|
|
{
|
|
|
(*iter)->Operate(par);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//操作最后一个obj
|
|
|
void CObjContainer::OperateLastObj(SObjOperatePar &par)
|
|
|
{
|
|
|
if(m_ObjVec.empty()==false)
|
|
|
{
|
|
|
m_ObjVec[m_ObjVec.size()-1]->Operate(par);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1//捕获
|
|
|
void CObjContainer::GetLineInRect(DbRect &rect,vector<DbLine> &DataPtLineVec,bool bCatchTemp)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
//不要捕捉临时对象的工具认为选择的对象也是临时对象
|
|
|
if(bCatchTemp==false&&(*iter)->IsSelected())
|
|
|
continue;
|
|
|
(*iter)->GetLineInRect(rect,DataPtLineVec);
|
|
|
}
|
|
|
}
|
|
|
//复制m_ObjVec 的obj 到rhs 容器
|
|
|
void CObjContainer::CloneObj(CObjContainer &rhs,bool bNeedSel)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(!bNeedSel ||(bNeedSel && (*iter)->IsSelected()))
|
|
|
{
|
|
|
CObjBase *p = (*iter)->Clone();
|
|
|
rhs.AddObject(p);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//获取和line 相交的所有交点到PointVec 中
|
|
|
void CObjContainer::GetIntersectPoint(DbLine &line,vector<Dbxy> &PointVec)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
//是否有obj 和line 相交
|
|
|
bool CObjContainer::HasObjIntersectWithLine(DbLine &line)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IntersectWithLine(line))
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//添加obj 到指令
|
|
|
void CObjContainer::AddObjToCmd(CCommandBase *p,bool bNeedSel)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(bNeedSel)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
p->AddOpObj((*iter));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
p->AddOpObj((*iter));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//将obj 导入当前的layer
|
|
|
void CObjContainer::AllObjAddToLayer()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
gLayer.AddObject(*iter);
|
|
|
}
|
|
|
}
|
|
|
//把自己所有的obj 导入rhs
|
|
|
void CObjContainer::AllObjAddToContainer(CObjContainer &rhs,bool bNeedSel)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(bNeedSel)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
rhs.AddObject(*iter);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
rhs.AddObject(*iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
void CObjContainer::AllObjAddToLayerTmp()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
gLayer.AddTmpObject(*iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取当前操作的一个obj 的指针(由创建对象的tool 使用)
|
|
|
CObjBase *CObjContainer::GetCurOpObj()
|
|
|
{
|
|
|
if(m_ObjVec.empty())
|
|
|
return NULL;
|
|
|
else
|
|
|
return m_ObjVec[m_ObjVec.size()-1].GetPtr();
|
|
|
}
|
|
|
#endif
|
|
|
#if 1//group 相关函数
|
|
|
bool CObjContainer::IsInRect(DbRect rect,bool bNeedAllIn)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsInRect(rect,bNeedAllIn))
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
void CObjContainer::SetSelected(bool bSelected)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->SetSelected(bSelected);
|
|
|
}
|
|
|
}
|
|
|
//idx 为-1 时操作全部
|
|
|
void CObjContainer::Operate(SObjOperatePar &par,int idx)
|
|
|
{
|
|
|
if(idx==-1)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->Operate(par);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if(CorrectIdx(idx))
|
|
|
{
|
|
|
m_ObjVec[idx]->Operate(par);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
bool CObjContainer::CorrectIdx(int idx)
|
|
|
{
|
|
|
int size = m_ObjVec.size();
|
|
|
if(0<=idx && idx<size)
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
//绑定参数到对话框
|
|
|
void CObjContainer::BindingDlg()
|
|
|
{
|
|
|
int cnt = GetSelObjCnt();
|
|
|
if(cnt ==1)//只选择一个对象时
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
(*iter)->BindingDlg();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
#if 1
|
|
|
//提取所有obj 的数据(包括填充数据)到vec 中(合并相连的线段)
|
|
|
void CObjContainer::GetObjPtData(vector<vector<Dbxy>> &vec,bool bNeedSel,bool bXYTest)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
int size = m_ObjVec.size();
|
|
|
double MinScanLineLength = gProgramLaserTuiHuo->GetMinScanLineLength();
|
|
|
for(int k=0;k<(size);k++)
|
|
|
{
|
|
|
if(m_ObjVec[k]->IsbScaned())//过滤掉被扫描过line
|
|
|
continue;
|
|
|
if(!bNeedSel || (bNeedSel && m_ObjVec[k]->IsSelected()))
|
|
|
{
|
|
|
vector<vector<Dbxy>> VecTemp;
|
|
|
m_ObjVec[k]->GetPtData(VecTemp);
|
|
|
if(!VecTemp.empty())
|
|
|
{
|
|
|
vector<Dbxy> &VecTemp1 = VecTemp[0];
|
|
|
if(VecTemp1.size()==2||(bXYTest&&VecTemp1.size()>=2))
|
|
|
{
|
|
|
//过滤线段长度小于指定长度的线段
|
|
|
double LineLen = CalDistance(VecTemp1[0],VecTemp1[1]);
|
|
|
if(LineLen<MinScanLineLength)
|
|
|
{
|
|
|
CString log;
|
|
|
log.Format("FilterLine : Idx[%d] Len[%f]MinScanLen[%f]",k,LineLen,MinScanLineLength);
|
|
|
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CObjContainer";
|
|
|
LogInfo.m_FuncName = "GetObjPtData";
|
|
|
LogInfo.m_LogMsg = log;
|
|
|
gLogMgr->WriteLogInfo(LogInfo);
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
m_ObjVec[k]->GetPtData(vec);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//提取所有obj 的填充数据到vec 中
|
|
|
void CObjContainer::GetObjFillData(vector<vector<Dbxy>> &vec,bool bNeedSel)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if(!bNeedSel || (bNeedSel && (*iter)->IsSelected()))
|
|
|
{
|
|
|
(*iter)->GetFillData(vec);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//找到所有点对象,并保存坐标到vec
|
|
|
void CObjContainer::GetOnePoint(vector<Dbxy> &vec)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->GetType()==_TYPE_POINT)
|
|
|
{
|
|
|
Dbxy pt = (*iter)->GetFirstPt();
|
|
|
vec.push_back(pt);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
//填充
|
|
|
void CObjContainer::FillObj(SFillPar &FillPar,bool bNeedSel)
|
|
|
{
|
|
|
CLogInfo LogInfo;
|
|
|
LogInfo.m_ClassName = "CObjContainer";
|
|
|
LogInfo.m_FuncName = "FillObj";
|
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
int idx = 0;
|
|
|
for(;iter!=iter_end;iter++,idx++)
|
|
|
{
|
|
|
if(bNeedSel && (*iter)->IsSelected()==false)
|
|
|
continue;
|
|
|
double ScanOverlapRatio = gWaferRecipeDataMgr->GetCurAnnealOverlap();//Y 方向重叠率
|
|
|
double FixScanLineGap = gWaferRecipeDataMgr->GetCurFixScanLineGap();//固定扫描间隔
|
|
|
|
|
|
SCAN_TRACK_E ScanTrack = gObjFillMgr.GetCurScanType();
|
|
|
bool bhorizontal = false;
|
|
|
if(ScanTrack == _SCAN_TRACK_S_U_D || ScanTrack == _SCAN_TRACK_S_D_U|| ScanTrack == _SCAN_TRACK_L_R|| ScanTrack == _SCAN_TRACK_R_L)
|
|
|
{
|
|
|
bhorizontal = true;
|
|
|
FillPar.m_FillAngle = 0;
|
|
|
}
|
|
|
else if(ScanTrack == _SCAN_TRACK_S_L_R || ScanTrack == _SCAN_TRACK_S_R_L|| ScanTrack == _SCAN_TRACK_U_D|| ScanTrack == _SCAN_TRACK_D_U)
|
|
|
{
|
|
|
FillPar.m_FillAngle = 90;
|
|
|
}
|
|
|
if(FixScanLineGap>0)//rcp 设置了固定扫描间隔
|
|
|
{
|
|
|
FillPar.m_FillGap = FixScanLineGap;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//通过重叠率和光斑直径来计算扫描间隔mm (bhorizontal 是否横向)
|
|
|
FillPar.m_FillGap = gLaser->GetScanIntervals(ScanOverlapRatio,bhorizontal);
|
|
|
}
|
|
|
(*iter)->CreatFillData(FillPar);
|
|
|
}
|
|
|
}
|
|
|
//提取所有点对象的中心点
|
|
|
void CObjContainer::GetAllPointObjPt(vector<Dbxy> &PtVec)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->GetType()==_TYPE_POINT)
|
|
|
{
|
|
|
PtVec.push_back(((*iter)->GetRect()).GetCenterPt());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//设置所有选择obj 的笔号
|
|
|
void CObjContainer::SetSelObjPenNum(int num)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
int CurPenNum = (*iter)->GetPenNum();
|
|
|
if(!gPenParMgr->IsSpecialPen(CurPenNum))//不能改变特殊笔号的对象
|
|
|
(*iter)->SetPenNum(num);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//通过笔号选择obj
|
|
|
void CObjContainer::SelObjByPenNum(int num)
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
int CurPenNum = (*iter)->GetPenNum();
|
|
|
if(CurPenNum == num)
|
|
|
{
|
|
|
(*iter)->SetSelected(true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
(*iter)->SetSelected(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#if 1
|
|
|
//选择相邻的obj (bNext == true 后面一个)
|
|
|
void CObjContainer::SelborderObj(bool bNext)
|
|
|
{
|
|
|
if(GetSelObjCnt()!=1)
|
|
|
{
|
|
|
CMsgBox MsgBox;
|
|
|
MsgBox.Show("只能选择一个obj 对象!");
|
|
|
return;
|
|
|
}
|
|
|
int size = m_ObjVec.size();
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
if(m_ObjVec[i]->IsSelected())
|
|
|
{
|
|
|
if(bNext && i+1<size)
|
|
|
{
|
|
|
m_ObjVec[i]->SetSelected(false);
|
|
|
m_ObjVec[i+1]->SetSelected(true);
|
|
|
}
|
|
|
if(!bNext && i-1>=0)
|
|
|
{
|
|
|
m_ObjVec[i]->SetSelected(false);
|
|
|
m_ObjVec[i-1]->SetSelected(true);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//选择的obj 插入到idx 指定的位置上
|
|
|
void CObjContainer::SelectedObjInsertToIdx(int idx)
|
|
|
{
|
|
|
int size = m_ObjVec.size();
|
|
|
if(idx<1 || idx>size)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
vector<Sptr<CObjBase>> ObjVecTmp;//临时容器
|
|
|
int k = 1;
|
|
|
//找到idx-1 个没有选择的obj 加入临时容器
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
if(!m_ObjVec[i]->IsSelected())
|
|
|
{
|
|
|
if(k>=idx)
|
|
|
{
|
|
|
k = i;//记住这个位置
|
|
|
break;
|
|
|
}
|
|
|
k++;
|
|
|
ObjVecTmp.push_back(m_ObjVec[i]);
|
|
|
}
|
|
|
}
|
|
|
//把所有选择的obj 依次加入
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
if(m_ObjVec[i]->IsSelected())
|
|
|
{
|
|
|
ObjVecTmp.push_back(m_ObjVec[i]);
|
|
|
}
|
|
|
}
|
|
|
//把剩余的没有选择的obj 依次放在后面
|
|
|
for(int i=k;i<size;i++)
|
|
|
{
|
|
|
if(!m_ObjVec[i]->IsSelected())
|
|
|
{
|
|
|
ObjVecTmp.push_back(m_ObjVec[i]);
|
|
|
}
|
|
|
}
|
|
|
//拷贝回原来的容器
|
|
|
m_ObjVec = ObjVecTmp;
|
|
|
}
|
|
|
//逆序选择的obj
|
|
|
void CObjContainer::ReverseSelObj()
|
|
|
{
|
|
|
int size = m_ObjVec.size();
|
|
|
int L = 0;
|
|
|
int R = size-1;
|
|
|
while(L<R)
|
|
|
{
|
|
|
while(L<R)
|
|
|
{
|
|
|
if(m_ObjVec[L]->IsSelected())
|
|
|
break;
|
|
|
L++;
|
|
|
}
|
|
|
while(L<R)
|
|
|
{
|
|
|
if(m_ObjVec[R]->IsSelected())
|
|
|
break;
|
|
|
R--;
|
|
|
}
|
|
|
if(L<R)
|
|
|
{
|
|
|
swap(m_ObjVec[L++],m_ObjVec[R--]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
void CObjContainer::SelFirstObj()
|
|
|
{
|
|
|
int size = m_ObjVec.size();
|
|
|
for(int i=0;i<size;i++)
|
|
|
{
|
|
|
if(i==0)
|
|
|
{
|
|
|
m_ObjVec[i]->SetSelected(true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
m_ObjVec[i]->SetSelected(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
int CObjContainer::GetMarkObjCnt()
|
|
|
{
|
|
|
int cnt = 0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsbMarkPt())
|
|
|
cnt++;
|
|
|
}
|
|
|
return cnt;
|
|
|
}
|
|
|
void CObjContainer::ResetAllMarkObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->SetbMarkPt(false);
|
|
|
}
|
|
|
}
|
|
|
void CObjContainer::ResetAllCollectedState()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
(*iter)->SetbCollected(false);
|
|
|
}
|
|
|
}
|
|
|
//获取选择对象的笔号
|
|
|
int CObjContainer::GetSelObjPenNum()
|
|
|
{
|
|
|
if(GetSelObjCnt()!=1)
|
|
|
{
|
|
|
return -1;
|
|
|
}
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsSelected())
|
|
|
{
|
|
|
return (*iter)->GetPenNum();
|
|
|
}
|
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
#endif
|
|
|
//按照索引顺序来选择一个obj
|
|
|
void CObjContainer::SelObjByIdx(int idx)
|
|
|
{
|
|
|
int k=0;
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++,k++)
|
|
|
{
|
|
|
(*iter)->SetSelected(false);
|
|
|
if(k==idx)
|
|
|
(*iter)->SetSelected(true);
|
|
|
}
|
|
|
}
|
|
|
//选择所有填充对象
|
|
|
void CObjContainer::SelAllFillObj()
|
|
|
{
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
{
|
|
|
if((*iter)->IsbFillObj())
|
|
|
(*iter)->SetSelected(true);
|
|
|
}
|
|
|
}
|
|
|
//删除所有填充的对象
|
|
|
void CObjContainer::DelAllFillObj()
|
|
|
{
|
|
|
//先全不选
|
|
|
NotSelAllObj();
|
|
|
//选择所有填充对象
|
|
|
SelAllFillObj();
|
|
|
//删除选择项
|
|
|
DelSelObj();
|
|
|
}
|
|
|
//通过一个对应的Check Vec 来设置obj 的选择状态
|
|
|
void CObjContainer::SelObjByIdxVec(vector<bool> &vec)
|
|
|
{
|
|
|
int size1 = m_ObjVec.size();
|
|
|
int size2 = vec.size();
|
|
|
for(int k=0;k<size1;k++)
|
|
|
{
|
|
|
if(k<size2)
|
|
|
{
|
|
|
m_ObjVec[k]->SetSelected(vec[k]);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
m_ObjVec[k]->SetSelected(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//加工开始前设置obj 的扫描状态
|
|
|
void CObjContainer::SetObjScanState(int ScanedLineCnt)
|
|
|
{
|
|
|
int FillObjCnt = 0;
|
|
|
int size1 = m_ObjVec.size();
|
|
|
for(int k=0;k<size1;k++)
|
|
|
{
|
|
|
m_ObjVec[k]->SetbScaned(false);
|
|
|
if(ScanedLineCnt>0)
|
|
|
{
|
|
|
if(m_ObjVec[k]->IsbFillObj() && FillObjCnt<ScanedLineCnt)
|
|
|
{
|
|
|
m_ObjVec[k]->SetbScaned(true);
|
|
|
FillObjCnt++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//是否有被扫描过的line
|
|
|
bool CObjContainer::HasScanedLine()
|
|
|
{
|
|
|
int size1 = m_ObjVec.size();
|
|
|
for(int k=0;k<size1;k++)
|
|
|
{
|
|
|
if(m_ObjVec[k]->IsbScaned())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
//是否有扫描对象
|
|
|
bool CObjContainer::HasScanLine()
|
|
|
{
|
|
|
int size1 = m_ObjVec.size();
|
|
|
for(int k=0;k<size1;k++)
|
|
|
{
|
|
|
if(m_ObjVec[k]->IsbFillObj())
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|