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.

1415 lines
38 KiB
C++

#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"
#include "FileMgr.h"
#define OBJ_TXT_START "START"
#define OBJ_TXT_END "END"
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)
{
//<2F><><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD>---------------------------------------------------
vector<CLabVecRang> LabVecRangVec;
CWorkFileMgr WorkFileMgr;
WorkFileMgr.SeparateStrVec(LabVecRang,LabVecRangVec,LAB_OBJ_START,LAB_OBJ_END);
//<2F><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>obj ---------------------------------------------------
if(gTemplateMgr->IsbClearOldObj())
{
Clear();//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>obj
}
if(!LabVecRangVec.empty())
{
vector<CLabVecRang>::iterator iter = LabVecRangVec.begin();
vector<CLabVecRang>::iterator iter_end = LabVecRangVec.end();
for(;iter!=iter_end;iter++)
{
//<2F><>ȡobj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F>ָ<EFBFBD>obj <20><>ʵ<EFBFBD><CAB5>
if(p)
{
p->ReadWorkFile(*iter);//<2F>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>
AddObject(p);
}
}
}
}
}
}
#endif
#if 1
//<2F><><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Txt <20>ļ<EFBFBD>
void CObjContainer::SaveObjToTxt(CString FilePath)
{
ofstream FileStream;
FileStream.open(FilePath);
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
for(;iter!=iter_end;iter++)
{
OBJ_TYPE Type = (*iter)->GetType();
if(!(Type==_TYPE_PLINE||Type==_TYPE_CIRCLE))//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶κ<DFB6>Բ
continue;
vector<CDataPoint>&PtVec = (*iter)->GetPtContainer();
int size = PtVec.size();
if(size<4)//<2F><><EFBFBD><EFBFBD>4<EFBFBD><34><EFBFBD><EFBFBD>
continue;
FileStream<<"OBJ"<<","<<OBJ_TXT_START<<"\n";//<2F><><EFBFBD>ݿ<EFBFBD>ʼ
for(int k=0;k<size;k++)
{
Dbxy pt = PtVec[k].GetPt();
FileStream<<Db2CString(pt.x)<<","<<Db2CString(pt.y)<<"\n";
}
FileStream<<"OBJ"<<","<<OBJ_TXT_END<<endl;//<2F><><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD>
}
}
//<2F><>txt <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
void CObjContainer::ReadObjFromTxt(CString FilePath)
{
CMsgBox MsgBox;
CString s;
bool bObjStart = true;
CFileMgr FileMgr;
vector<vector<CString>> StrVec;
int EmptyLine = FileMgr.ReadFileToStrVec(FilePath,StrVec);
if(EmptyLine>0)
{
s.Format("<EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>line = %d",EmptyLine);
MsgBox.Show(s);
return;
}
int size = StrVec.size();
vector<Dbxy> ObjPtVec;
for(int k=0;k<size;k++)
{
if(StrVec[k].size()!=2)
{
continue;
}
if(bObjStart)
{
if((StrVec[k][1]).Find(OBJ_TXT_START)!=-1)//obj <20><>ʼ
{
ObjPtVec.clear();
bObjStart = false;
}
}
else
{
if((StrVec[k][1]).Find(OBJ_TXT_END)!=-1)//obj<62><6A><EFBFBD><EFBFBD>
{
bObjStart = true;//<2F><><EFBFBD>¿<EFBFBD>ʼ
int PtCnt = ObjPtVec.size();
if(PtCnt<4)
{
s.Format("<EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,line = %d",k+1);
MsgBox.Show(s);
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD>
double eps =0.001;//<2F>ȽϾ<C8BD><CFBE><EFBFBD>
if(!IsTwoPtEqual(ObjPtVec[0],ObjPtVec[PtCnt-1],eps))
{
ObjPtVec.push_back(ObjPtVec[0]);
}
CObjPline *pLine = new CObjPline;
pLine->Creat(ObjPtVec[0],ObjPtVec[1]);
PtCnt = ObjPtVec.size();
for(int i=2;i<PtCnt;i++)
{
CDataPoint DataPoint(ObjPtVec[i]);
DataPoint.SetIsNode(true);
pLine->AddDataPoint(DataPoint);
}
AddObject(pLine);
}
else
{
Dbxy pt;
pt.x = CStringToDouble(StrVec[k][0]);
pt.y = CStringToDouble(StrVec[k][1]);
ObjPtVec.push_back(pt);
}
}
}
}
#endif
#if 1
void CObjContainer::AddObject(CObjBase *pMarkObject)
{
//<2F><><EFBFBD><EFBFBD><E6B5BD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
Sptr<CObjBase> sPtr(pMarkObject);
AddObject(sPtr);
}
void CObjContainer::AddObject(Sptr<CObjBase> p)
{
m_ObjVec.push_back(p);
}
//<2F><><EFBFBD>ӵ㵽ĩβ<C4A9><CEB2>obj
void CObjContainer::AddPtToLastObj(CDataPoint pt)
{
if(!m_ObjVec.empty())
{
m_ObjVec[m_ObjVec.size()-1]->AddDataPoint(pt);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Բ)
CMFCPropertyGridProperty *CObjContainer::CreatSpecialGridProperty(CModule *pModule)
{
if(GetSelObjCnt() == 1)//ֻ<><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
return GetFirstSelObj()->CreatSpecialGridProperty(pModule);
}
else
return NULL;
}
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եı
void CObjContainer::OnSpecialPropertyChanged()
{
if(GetSelObjCnt() == 1)//ֻ<><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
GetFirstSelObj()->OnSpecialPropertyChanged();
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
void CObjContainer::InsertList(CListCtrl &List)
{
int size = m_ObjVec.size();
for(int i=0;i<size;i++)
{
int idx = 0;
List.InsertItem(i," ");//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
List.SetItemText(i,idx++,Int2CString(i+1));//<2F><><EFBFBD><EFBFBD>
List.SetItemText(i,idx++,m_ObjVec[i]->GetStr());//<2F><><EFBFBD><EFBFBD>
}
}
#endif
#if 1//<2F><><EFBFBD><EFBFBD>
void CObjContainer::DrawAllObj(CDC* pDC)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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++)
{
//<2F>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(!gLayer.IsbDrawObj() && (*iter)->IsbFillObj())
{
continue;
}
if((*iter)->IsbScaned())//<2F><>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>
{
(*iter)->Draw(pDC,gDraw->GetScanLine());
continue;
}
if((*iter)->IsSelected())
{
(*iter)->Draw(pDC,gDraw->GetSelObjectPen());
}
else
{
(*iter)->Draw(pDC);
}
}
}
//<2F><><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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());
}
}
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD>εĽڵ<C4BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
void CObjContainer::DrawObjPtCoord(CDC* pDC)
{
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())//ֻ<><D6BB><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ͼ<EFBFBD><CDBC>
{
(*iter)->DrawPtCoord(pDC);
}
}
}
//<2F><><EFBFBD><EFBFBD>mark <20><><EFBFBD>ַ<EFBFBD>
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);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>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;
}
//<2F><>ȡѡ<C8A1><D1A1>obj <20>ĸ<EFBFBD><C4B8><EFBFBD>
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;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
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;
}
//<2F><>ȡɨ<C8A1><C9A8><EFBFBD>߶ε<DFB6><CEB5><EFBFBD><EFBFBD><EFBFBD>
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;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rect <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ľڵ<C4BD>
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;
}
//<2F><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>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);
}
}
//<2F><><EFBFBD><EFBFBD>
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;
}
}
//<2F><><EFBFBD><EFBFBD>
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;
}
}
//<2F><><EFBFBD><EFBFBD>
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;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Obj <20>ķ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>
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;
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>obj <20>ľ<EFBFBD><C4BE>η<EFBFBD>Χ
DbRect CObjContainer::GetObjRect(int idx)
{
DbRect ObjRect;
int size = m_ObjVec.size();
if(CorrectIdx(idx))
{
ObjRect = m_ObjVec[idx]->GetRect();
}
return ObjRect;
}
//ѡ<><D1A1>rect <20>ڵ<EFBFBD>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);
gLogMgr->WriteDebugLog(LogStr);
}
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);
}
}
//<2F><>ѡ
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);
}
}
}
//ɾ<><C9BE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
void CObjContainer::DelSelObj()
{
vector<Sptr<CObjBase>> vec;
//<2F>ȱ<EFBFBD><C8B1>ݷ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
{
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);
}
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj
m_ObjVec.clear();
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD><EFBFBD>
{
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);
}
}
}
//ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>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;
}
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
void CObjContainer::DeleteLastObj()
{
if(Empty()==false)
{
m_ObjVec.pop_back();
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
void CObjContainer::DelNullLine()
{
vector<Sptr<CObjBase>> vec;
//<2F>ȱ<EFBFBD><C8B1>ݷ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
{
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);
}
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj
m_ObjVec.clear();
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD><EFBFBD>
{
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);
}
}
}
//<2F>ϲ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
CObjBase* CObjContainer::JoinSelObj()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD>ʺϷ<CABA><CFB7>ڵ<EFBFBD>һλ<D2BB><CEBB>obj ---------------------------------------------------
int size = m_ObjVec.size();
int cnt = 0;
bool flg1;
bool flg2;
double eps =0.01;//<2F>ȽϾ<C8BD><CFBE><EFBFBD>
int idx=0;
int firstSelIdx = -1;//<2F><>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>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();
//<2F><><EFBFBD><EFBFBD>
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)//<2F>ҵ<EFBFBD>
{
break;
}
}
}
if(flg1 && flg2)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>û<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD>obj<62><6A><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܺϲ<DCBA>
return NULL;
if(firstSelIdx==-1)
return NULL;
if(!flg1 && !flg2)//ѡ<><D1A1><EFBFBD><EFBFBD>obj Ϊ<>պ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><>ʼ
{
idx= flg1;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>obj ------------------------------------------
bool bReverse = false;
if(flg2)
{
bReverse = true;
}
CObjPline *p = new CObjPline;
p->AddObj(m_ObjVec[idx],bReverse);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
set<int> Set;//<2F><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>Щ<EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
Set.insert(idx);
Dbxy ConectPt = p->GetLastPt();//<2F><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>
for(int i=0;i<size;i++)
{
for(int j=0;j<size;j++)
{
if(m_ObjVec[j]->IsSelected()&&Set.count(j)==false)//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj
{
if(IsTwoPtEqual(ConectPt,m_ObjVec[j]->GetFirstPt(),eps))//<2F><><EFBFBD><EFBFBD>
{
p->AddObj(m_ObjVec[j],false);
Set.insert(j);//<2F><><EFBFBD><EFBFBD>
ConectPt = m_ObjVec[j]->GetLastPt();
}
else if(IsTwoPtEqual(ConectPt,m_ObjVec[j]->GetLastPt(),eps))//<2F><><EFBFBD><EFBFBD>
{
p->AddObj(m_ObjVec[j],true);
Set.insert(j);//<2F><><EFBFBD><EFBFBD>
ConectPt = m_ObjVec[j]->GetFirstPt();
}
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj û<>б<EFBFBD><D0B1>ϲ<EFBFBD>
bool flg = false;
for(int i=0;i<size;i++)
{
if(m_ObjVec[i]->IsSelected()&&Set.count(i)==false)
{
flg = true;
break;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ܺϲ<DCBA>
if(flg)
{
delete p;
p = NULL;
}
return p;
}
//<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>idx <20>ڵ<EFBFBD><DAB5><EFBFBD>ֵΪpt
void CObjContainer::SetNodePtByIdx(int idx,Dbxy pt)
{
if(Empty())
return;
m_ObjVec[0]->SetNodePtByIdx(idx,pt);
}
#endif
#if 1
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj
//bNeedSel <20><>ʾ<EFBFBD><CABE>ҪΪѡ<CEAA><D1A1>״̬<D7B4>Ų<EFBFBD><C5B2><EFBFBD>
//bTmpOp <20><>ʾ<EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
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);
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
void CObjContainer::OperateLastObj(SObjOperatePar &par)
{
if(m_ObjVec.empty()==false)
{
m_ObjVec[m_ObjVec.size()-1]->Operate(par);
}
}
#endif
#if 1//<2F><><EFBFBD><EFBFBD>
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++)
{
//<2F><>Ҫ<EFBFBD><D2AA>׽<EFBFBD><D7BD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>Ϊѡ<CEAA><D1A1><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
if(bCatchTemp==false&&(*iter)->IsSelected())
continue;
(*iter)->GetLineInRect(rect,DataPtLineVec);
}
}
//<2F><><EFBFBD><EFBFBD>m_ObjVec <20><>obj <20><>rhs <20><><EFBFBD><EFBFBD>
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);
}
}
}
//<2F><>ȡ<EFBFBD><C8A1>line <20><EFBFBD><E0BDBB><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD>㵽PointVec <20><>
void CObjContainer::GetIntersectPoint(DbLine &line,vector<Dbxy> &PointVec)
{
}
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>obj <20><>line <20>
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
//<2F><><EFBFBD><EFBFBD>obj <20><>ָ<EFBFBD><D6B8>
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));
}
}
}
//<2F><>obj <20><><EFBFBD>뵱ǰ<EBB5B1><C7B0>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);
}
}
//<2F><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>е<EFBFBD>obj <20><><EFBFBD><EFBFBD>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);
}
}
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj <20><>ָ<EFBFBD><D6B8>(<28>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tool ʹ<><CAB9>)
CObjBase *CObjContainer::GetCurOpObj()
{
if(m_ObjVec.empty())
return NULL;
else
return m_ObjVec[m_ObjVec.size()-1].GetPtr();
}
#endif
#if 1//group <20><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>
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 ʱ<><CAB1><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
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;
}
//<2F>󶨲<EFBFBD><F3B6A8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
void CObjContainer::BindingDlg()
{
int cnt = GetSelObjCnt();
if(cnt ==1)//ֻѡ<D6BB><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
{
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
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><>vec <20><>(<28>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>)
void CObjContainer::GetObjPtData(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((*iter)->IsbScaned())//<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>line
continue;
if(!bNeedSel || (bNeedSel && (*iter)->IsSelected()))
{
(*iter)->GetPtData(vec);
}
}
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>vec <20><>
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);
}
}
}
//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>󣬲<EFBFBD><F3A3ACB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>굽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
//<2F><><EFBFBD><EFBFBD>
void CObjContainer::FillObj(SFillPar &FillPar,bool bNeedSel)
{
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;
CRecipeParameter RecipePar;
if(gLaser->IsbScanByDirX())
RecipePar = gRecipeMgr->GetCurRecipePar(RECIPE_PAR_NAME_OVERLAP_RATIO_Y);
else
RecipePar = gRecipeMgr->GetCurRecipePar(RECIPE_PAR_NAME_OVERLAP_RATIO_X);
double ScanOverlapRatio = RecipePar.m_ParDoubleVal;//Y <20><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>
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;
}
//ͨ<><CDA8><EFBFBD>ص<EFBFBD><D8B5>ʺ͹<CABA><CDB9><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mm (bhorizontal <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>)
FillPar.m_FillGap = gLaser->GetScanIntervals(ScanOverlapRatio,bhorizontal);
(*iter)->CreatFillData(FillPar);
}
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
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());
}
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj <20>ıʺ<C4B1>
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))//<2F><><EFBFBD>ܸı<DCB8><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʺŵĶ<C5B5><C4B6><EFBFBD>
(*iter)->SetPenNum(num);
}
}
}
//ͨ<><CDA8><EFBFBD>ʺ<EFBFBD>ѡ<EFBFBD><D1A1>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
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>obj (bNext == true <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>)
void CObjContainer::SelborderObj(bool bNext)
{
if(GetSelObjCnt()!=1)
{
CMsgBox MsgBox;
MsgBox.Show("ֻ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD>!");
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;
}
}
}
//ѡ<><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD>뵽idx ָ<><D6B8><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
void CObjContainer::SelectedObjInsertToIdx(int idx)
{
int size = m_ObjVec.size();
if(idx<1 || idx>size)
{
return;
}
vector<Sptr<CObjBase>> ObjVecTmp;//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
int k = 1;
//<2F>ҵ<EFBFBD>idx-1 <20><>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
for(int i=0;i<size;i++)
{
if(!m_ObjVec[i]->IsSelected())
{
if(k>=idx)
{
k = i;//<2F><>ס<EFBFBD><D7A1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
break;
}
k++;
ObjVecTmp.push_back(m_ObjVec[i]);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD>
for(int i=0;i<size;i++)
{
if(m_ObjVec[i]->IsSelected())
{
ObjVecTmp.push_back(m_ObjVec[i]);
}
}
//<2F><>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD>η<EFBFBD><CEB7>ں<EFBFBD><DABA><EFBFBD>
for(int i=k;i<size;i++)
{
if(!m_ObjVec[i]->IsSelected())
{
ObjVecTmp.push_back(m_ObjVec[i]);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_ObjVec = ObjVecTmp;
}
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>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);
}
}
//<2F><>ȡѡ<C8A1><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
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
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB>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);
}
}
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);
}
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
void CObjContainer::DelAllFillObj()
{
//<2F><>ȫ<EFBFBD><C8AB>ѡ
NotSelAllObj();
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SelAllFillObj();
//ɾ<><C9BE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
DelSelObj();
}
//ͨ<><CDA8>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>Check Vec <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20><>ѡ<EFBFBD><D1A1>״̬
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);
}
}
}
//<2F>ӹ<EFBFBD><D3B9><EFBFBD>ʼǰ<CABC><C7B0><EFBFBD><EFBFBD>obj <20><>ɨ<EFBFBD><C9A8>״̬
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++;
}
}
}
}
//<2F>Ƿ<EFBFBD><C7B7>б<EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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;
}
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool CObjContainer::HasScanLine()
{
int size1 = m_ObjVec.size();
for(int k=0;k<size1;k++)
{
if(m_ObjVec[k]->IsbFillObj())
return true;
}
return false;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ڰ뾶R <20>ķ<EFBFBD>Χ<EFBFBD><CEA7>
bool CObjContainer::CheckPtRadius(double R)
{
vector<Sptr<CObjBase>>::iterator iter = m_ObjVec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjVec.end();
for(;iter!=iter_end;iter++)
{
OBJ_TYPE Type = (*iter)->GetType();
if(!(Type==_TYPE_PLINE||Type==_TYPE_CIRCLE))//ֻ<><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶κ<DFB6>Բ
return false;
vector<CDataPoint>&PtVec = (*iter)->GetPtContainer();
int size = PtVec.size();
for(int k=0;k<size;k++)
{
Dbxy pt = PtVec[k].GetPt();
Dbxy ZeroPt;
if(CalDistance(ZeroPt,pt)>R)
return false;
}
}
return true;
}