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.

707 lines
18 KiB
C++

#include "StdAfx.h"
#include "Layer.h"
#include "LogMgr.h"
#include "GlobalDrawMgr.h"
#include "LaiPuLaserView.h"
#include "GlobalFunction.h"
#include "CommandRotato.h"
#include "CommandMirror.h"
#include "CommandMove.h"
#include "CommandReverse.h"
#include "CommandJion.h"
#include "CommandMgr.h"
#include "EasyOperationMgr.h"
#include "ObjComponentMgr.h"
#include "ObjCircle.h"
#include "ObjPline.h"
#include "Laser.h"
#include "CStringFuc.h"
#include "MsgBox.h"
CLayer gLayer;
CLayer::CLayer(void)
{
m_ObjContainer = &m_TmpObjContainer;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD>򱨴<EFBFBD>
m_bShowObjIdx = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ʾobj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>idx
m_bShowObjPtCoord = true;
m_bDrawObj = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>obj
m_AreaCrossPtRange = 10;//<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD>Χ
}
CLayer::~CLayer(void)
{
}
#if 1
void CLayer::Serialize(CArchive& ar)
{
// m_ObjContainer->Serialize(ar);
}
//<2F>󶨵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ObjContainer
void CLayer::BindObjContainer(CObjContainer &Container)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ༭״̬
gCommandMgr.Reset();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ClearTmpObj();
//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
m_ObjContainer = &Container;
}
#endif
#if 1
void CLayer::Draw(CDC* pDC)
{
//if(m_bDrawObj)
{
DrawAllObj(pDC);
}
}
void CLayer::DrawAllObj(CDC* pDC)
{
m_ObjContainer->DrawAllObj(pDC);
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ҲҪ<D2B2><D2AA><EFBFBD><EFBFBD>
m_TmpObjContainer.DrawAllObj(pDC);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
if(m_bShowObjIdx)
{
m_ObjContainer->DrawObjIdx(pDC);
}
//ֻ<>ڱ༭ģʽ<C4A3><CABD>ʾ
if(m_bShowObjPtCoord)
{
m_ObjContainer->DrawObjPtCoord(pDC);
}
}
//<2F>ػ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
void CLayer::XorRedrawObj(CDC* pDC,bool bNeedSel)
{
m_ObjContainer->XorRedrawObj(pDC,bNeedSel);
}
#endif
#if 1
void CLayer::AddObject(CObjBase *pMarkObject)
{
m_ObjContainer->AddObject(pMarkObject);
}
void CLayer::AddObject(Sptr<CObjBase> p)
{
m_ObjContainer->AddObject(p);
}
void CLayer::AddObject(CObjContainer &ObjContainer)
{
vector<Sptr<CObjBase>> &vec = ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
(*iter)->SetSelected(false);
AddObject((*iter));
}
}
}
//ɾ<><C9BE>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
void CLayer::DelSelObj()
{
m_ObjContainer->DelSelObj();
}
//ɾ<><C9BE>ObjContainer <20><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj
void CLayer::DelObj(CObjContainer &ObjContainer)
{
vector<Sptr<CObjBase>> &vec = ObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter).IsNull()==false)
{
DelObj((*iter));
}
}
}
//ɾ<><C9BE>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>obj
void CLayer::DelObj(Sptr<CObjBase> p)
{
m_ObjContainer->DelObj(p);
}
#endif
#if 1
bool CLayer::HasSelObjectInRect(DbRect rect)
{
return m_ObjContainer->HasSelObjectInRect(rect);
}
bool CLayer::HasSelNodeInRect(DbRect rect)
{
return m_ObjContainer->HasSelNodeInRect(rect);
}
bool CLayer::HasObjectInRect(DbRect rect)
{
return m_ObjContainer->HasObjectInRect(rect);
}
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĶ<DAB5><C4B6><EFBFBD>(bNeedAllIn <20><>ʾ<EFBFBD><CABE>Ҫ<EFBFBD><D2AA>rect <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
bool CLayer::SelObjectInRect(DbRect rect,bool bNeedAllIn)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>֮ǰ<D6AE><C7B0>ѡ<EFBFBD><D1A1>
if(!gDraw->IsbMultipleSel())
{
SelAllObj();
RevSelAllObj();
}
if(gDraw->IsEditLayerObj())
{
if(m_ObjContainer->SelObjectInRect(rect,bNeedAllIn))
{
gEasyOperationMgr->Refresh();
return true;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<CDAC><CAB1><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
if(gObjComponentMgr->SelObjectInRect(rect))
{
return true;
}
return false;
}
//<2F><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>rect <20><>obj
Sptr<CObjBase> CLayer::GetFirstObjInRect(DbRect &rect)
{
return m_ObjContainer->GetFirstObjInRect(rect);
}
Sptr<CObjBase> CLayer::GetFirstNodeObjInRect(DbRect &rect)
{
return m_ObjContainer->GetFirstNodeObjInRect(rect);
}
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj
bool CLayer::HasObjSel()
{
return m_ObjContainer->HasObjSel();
}
//ȫѡ
void CLayer::SelAllObj()
{
m_ObjContainer->SelAllObj();
gEasyOperationMgr->Refresh();
//Ԫ<><D4AA>
gObjComponentMgr->SelAllObj();
}
//ȫ<><C8AB>ѡ
void CLayer::NotSelAllObj()
{
m_ObjContainer->NotSelAllObj();
//Ԫ<><D4AA>
gObjComponentMgr->NotSelAllObj();
gEasyOperationMgr->Refresh();
}
//<2F><>ѡ
void CLayer::RevSelAllObj()
{
m_ObjContainer->RevSelAllObj();
gEasyOperationMgr->Refresh();
//Ԫ<><D4AA>
gObjComponentMgr->RevSelAllObj();
}
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>obj
void CLayer::DelAllObj()
{
SelAllObj();
DelSelObj();
}
//<2F>жϵ<D0B6>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD>
MOUSE_TOOL CLayer::JudgeMouseToolType(Dbxy pt)
{
MOUSE_TOOL type = _TOOL_POINT;
DbRect rect = gDraw->GetCurPointRect(pt);
if(HasSelNodeInRect(rect))
{
type = _TOOL_MOVE_NODE;
}
else if(HasSelObjectInRect(rect))
{
type = _TOOL_MOVE;
}
return type;
}
DbRect CLayer::GetSelObjRect()
{
return m_ObjContainer->GetSelObjRect();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Բ)
CMFCPropertyGridProperty *CLayer::CreatSpecialGridProperty(CModule *pModule)
{
return m_ObjContainer->CreatSpecialGridProperty(pModule);
}
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եı
void CLayer::OnSpecialPropertyChanged()
{
m_ObjContainer->OnSpecialPropertyChanged();
}
#endif
#if 1
//<2F><><EFBFBD><EFBFBD>obj
void CLayer::OperateObj(SObjOperatePar &par,bool bAll)
{
m_ObjContainer->OperateObj(par,bAll);
}
//<2F>ƶ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj (bAddUndoΪ<6F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EBB3B7>ָ<EFBFBD><D6B8>)
void CLayer::OnMove(double MoveX,double MoveY,bool bAddUndo)
{
if(HasObjSel())
{
//<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
CCommandMove *p = new CCommandMove;
SObjOperatePar par;
par.OpType = _OP_MOVE;
par.MoveX = MoveX;
par.MoveY = MoveY;
p->SetOperatePar(par);
//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
if(bAddUndo)
gCommandMgr.AddUndoCommand(p);
//ִ<><D6B4>ָ<EFBFBD><D6B8>
p->Excute();
}
}
//<2F><>Ӧָ<D3A6><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Angle 360<36>Ƚ<EFBFBD>
void CLayer::OnRotato(double Angle)
{
Dbxy pt = GetSelObjRect().GetCenterPt();
//obj <20><><EFBFBD><EFBFBD>----------------------------
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = pt;
par.Angle = Angle;
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
CCommandRotato *p = new CCommandRotato;
p->SetOperatePar(par);
gCommandMgr.AddUndoCommand(p);
p->Excute();
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----end
}
//ֱ<><D6B1><EFBFBD><EFBFBD>תAngle (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>UndoCommand ָ<><D6B8>)Angle 360<36>Ƚ<EFBFBD>
void CLayer::Rotato(double Angle)
{
Dbxy pt = GetSelObjRect().GetCenterPt();
//obj <20><><EFBFBD><EFBFBD>----------------------------
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = pt;
par.Angle = Angle;
m_ObjContainer->OperateObj(par,false);
}
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CLayer::OnMirror(X_OR_Y xy)
{
Dbxy pt = GetSelObjRect().GetCenterPt();
//obj <20><><EFBFBD><EFBFBD>
SObjOperatePar par;
par.OpType = _OP_MIRROR;
par.BasePt = pt;
par.xy = xy;
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
CCommandMirror *p = new CCommandMirror;
p->SetOperatePar(par);
gCommandMgr.AddUndoCommand(p);
p->Excute();
}
//<2F><>ת<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>˳<EFBFBD><CBB3>
void CLayer::OnReverseSelObj()
{
//obj <20><><EFBFBD><EFBFBD>
SObjOperatePar par;
par.OpType = _OP_REVERSE;
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
CCommandReverse *p = new CCommandReverse;
p->SetOperatePar(par);
gCommandMgr.AddUndoCommand(p);
p->Excute();
}
//<2F>ϲ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
bool CLayer::OnJoin()
{
CObjBase *p = m_ObjContainer->JoinSelObj();
if(p)//<2F>ϲ<EFBFBD><CFB2>ɹ<EFBFBD>
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>-----------------------------
CCommandJion *pCmd = new CCommandJion;
gCommandMgr.AddUndoCommand(pCmd);
Sptr<CObjBase> pObj(p);
pCmd->AddOpObj(pObj);
pObj->SetSelected(true);//<2F>ϲ<EFBFBD><CFB2><EFBFBD>Ĭ<EFBFBD><C4AC>Ϊѡ<CEAA><D1A1>״̬
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>obj
DelSelObj();
//<2F><><EFBFBD>Ӻϲ<D3BA><CFB2><EFBFBD><EFBFBD><EFBFBD>obj
AddObject(pObj);
return true;
}
return false;
}
//<2F>ֽ<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
void CLayer::OnExplode()
{
}
#endif
#if 1//<2F><>׽
void CLayer::AddTmpObject(Sptr<CObjBase> p)
{
m_TmpObjContainer.AddObject(p);
}
void CLayer::ClearTmpObj()
{
m_TmpObjContainer.Clear();
}
//<2F><>ȡrect <20><>Χ<EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶α<DFB6><CEB1>浽DataPtLineVec <20><>
void CLayer::GetLineInRect(DbRect &rect,vector<DbLine> &DataPtLineVec,bool bCatchTemp)
{
m_ObjContainer->GetLineInRect(rect,DataPtLineVec,bCatchTemp);
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
if(bCatchTemp)
{
vector<Sptr<CObjBase>> &vec = m_TmpObjContainer.GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((iter+1)!=vec.end())//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
{
(*iter)->GetLineInRect(rect,DataPtLineVec);
}
}
}
}
//<2F><>ȡ<EFBFBD><C8A1>line <20><EFBFBD><E0BDBB><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD>㵽PointVec <20><>
void CLayer::GetIntersectPoint(DbLine &line,vector<Dbxy> &PointVec)
{
m_ObjContainer->GetIntersectPoint(line,PointVec);
}
bool CLayer::HasObjIntersectWithLine(DbLine &line)
{
return m_ObjContainer->HasObjIntersectWithLine(line);
}
//<2F><>¡<EFBFBD><C2A1>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Vec <20><>
void CLayer::CloneObj(CObjContainer &ObjContainer,bool bNeedSel)
{
m_ObjContainer->CloneObj(ObjContainer,bNeedSel);
}
#endif
#if 1//group <20><><EFBFBD><EFBFBD>
//<2F><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>group <20><><EFBFBD><EFBFBD><EFBFBD>󶨵<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ĶԻ<C4B6><D4BB><EFBFBD><EFBFBD><EFBFBD>
void CLayer::BindingSelObjToDlg()
{
//<2F>ȳ<EFBFBD><C8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><D0B0><EFBFBD>
GetFrame()->UnBindingDlg();
m_ObjContainer->BindingDlg();
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
void CLayer::FillObj(SFillPar FillPar,bool bNeedSel)
{
m_ObjContainer->FillObj(FillPar,bNeedSel);
}
#endif
#if 1
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
void CLayer::GetAllPointObjPt(vector<Dbxy> &PtVec)
{
m_ObjContainer->GetAllPointObjPt(PtVec);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj <20>ıʺ<C4B1>
void CLayer::SetSelObjPenNum(int num)
{
if(!gPenParMgr->IsSpecialPen(num))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD>
{
m_ObjContainer->SetSelObjPenNum(num);
NotSelAllObj();//ȫ<><C8AB>ѡ
}
}
void CLayer::SelborderObj(bool bNext)
{
m_ObjContainer->SelborderObj(bNext);
GetCurViewPtr()->RefreshView();
}
//ѡ<><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD>뵽idx <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD>)
void CLayer::SelectedObjInsertToIdx(int idx)
{
m_ObjContainer->SelectedObjInsertToIdx(idx);
GetCurViewPtr()->RefreshView();
}
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj
void CLayer::ReverseSelObj()
{
m_ObjContainer->ReverseSelObj();
GetCurViewPtr()->RefreshView();
}
//ѡ<><D1A1><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj
void CLayer::SelFirstObj()
{
m_ObjContainer->SelFirstObj();
GetCurViewPtr()->RefreshView();
}
#endif
#if 1
void CLayer::ResetAllMarkObj()
{
m_ObjContainer->ResetAllMarkObj();
}
void CLayer::CreatCircleByThreePt()
{
vector<Dbxy> PtVec;
vector<Sptr<CObjBase>> &vec = m_ObjContainer->GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
PtVec.push_back((*iter)->GetCenterPt());
}
int size = PtVec.size();
if(size>=3)
{
CCirclePar CirclePar = CalCircleByThreePt(PtVec[0],PtVec[1],PtVec[2]);
CirclePar.DEdgeCnt = 100;
CObjCircle *pCircle = new CObjCircle;
pCircle->Creat(CirclePar);
AddObject(pCircle);
GetCurViewPtr()->RefreshView();
}
}
//<2F><>תƫ<D7AA><C6AB>obj (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>Ϊ<EFBFBD><CEAA>׼)
void CLayer::OffsetRotatoObj(COffsetRotatoPar OffsetRotatoPar)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ת
Dbxy pt;
SObjOperatePar par;
par.OpType = _OP_ROTATO;
par.BasePt = pt;
par.Angle = OffsetRotatoPar.m_RotatoAng;
m_ObjContainer->OperateObj(par,false);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ת
par.OpType = _OP_MOVE;
par.MoveX = OffsetRotatoPar.m_Offset.x;
par.MoveY = OffsetRotatoPar.m_Offset.y;
m_ObjContainer->OperateObj(par,false);
}
#endif
#if 1
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>
void CLayer::CreatOneLineObj(double Len)
{
Dbxy Pt1;
Dbxy Pt2;
CObjContainer &ObjContainer = GetObjContainer();
//<2F><>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>
if(ObjContainer.GetObjCnt()==1)
{
DbRect Rect = ObjContainer.GetObjRect(false);
Pt1 = Rect.GetCenterPt();
Pt2 = Rect.GetCenterPt();
}
if(gLaser->IsbScanByDirX())
{
Pt1.x -= Len/2;
Pt2.x += Len/2;
}
else
{
Pt1.y -= Len/2;
Pt2.y += Len/2;
}
DelAllObj();
CObjPline * pObjPline = new CObjPline;
pObjPline->Creat(Pt1,Pt2);
AddObject(pObjPline);
NotSelAllObj();
m_pView->RefreshView();
}
//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
void CLayer::MoveScanObj(DIRECTION dir,double Dis)
{
CObjContainer &ObjContainer = GetObjContainer();
SelAllObj();
m_pView->MoveObjToPtByDir(dir,Dis);
NotSelAllObj();
m_pView->RefreshView();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8>״̬
void CLayer::ResetAllObjScaned()
{
vector<Sptr<CObjBase>> &vec = m_ObjContainer->GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
(*iter)->SetbScaned(false);
}
}
#endif
#if 1
bool CompareLineY(double y1,double y2)
{
return y1>y2;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,һ<><D2BB>Բ<EFBFBD><D4B2>ֱ<EFBFBD><D6B1>
void CLayer::QuickCreatScanArea(double AreaGap)
{
vector<double> LineCoordyVec;
vector<Dbxy> PointObjVec;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CObjBase *pCircle = NULL;
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
vector<Sptr<CObjBase>> &vec = m_ObjContainer->GetObjVec();
vector<Sptr<CObjBase>>::iterator iter = vec.begin();
vector<Sptr<CObjBase>>::iterator iter_end = vec.end();
for(;iter!=iter_end;iter++)
{
if((*iter)->GetType()==_TYPE_PLINE)
{
Dbxy pt = (*iter)->GetCenterPt();
LineCoordyVec.push_back(pt.y);
}
if((*iter)->GetType()==_TYPE_POINT)
{
Dbxy pt = (*iter)->GetCenterPt();
PointObjVec.push_back(pt);
}
//<2F>ҵ<EFBFBD>Բ
if((*iter)->GetType()==_TYPE_CIRCLE)
{
pCircle = (*iter).GetPtr();
}
}
if(pCircle == NULL)
{
CMsgBox MsgBox;
MsgBox.Show("û<EFBFBD><EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
DbRect rect = pCircle->GetRect();
if(pCircle)//<2F><><EFBFBD>¸<EFBFBD><C2B8><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
{
LineCoordyVec.push_back(rect.T+0.01);
LineCoordyVec.push_back(rect.B-0.01);
}
CObjCircle CircleTem;//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
CCirclePar ObjCirclePar;
Dbxy CenterPt = rect.GetCenterPt();
double Radius =rect.GetSize().w /2;
int EdgeCnt = 300;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ
CircleTem.CreatByRadius(Radius,CenterPt,EdgeCnt);
//<2F><><EFBFBD><EFBFBD>
sort(LineCoordyVec.begin(),LineCoordyVec.end(),CompareLineY);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vector<CObjBase *> AreaObjVec;
int size = LineCoordyVec.size();
for(int k=1;k<size;k++)
{
DIRECTION Dir = _DIR_M;
double ChangeSizeY = AreaGap;
if(k==1||k==(size-1))
{
ChangeSizeY /=2;
}
if(k==1)//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
Dir = _DIR_U;
}
if(k==(size-1))//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
Dir = _DIR_D;
}
CObjBase *pAreaObj = CreatScanAreaObj(&CircleTem,PointObjVec,LineCoordyVec[k-1],LineCoordyVec[k],ChangeSizeY,Dir);
if(pAreaObj)
{
AreaObjVec.push_back(pAreaObj);
}
}
//ɾ<><C9BE>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
DelAllObj();
//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>obj
size = AreaObjVec.size();
for(int k=0;k<size;k++)
{
if(AreaObjVec[k])
{
AddObject(AreaObjVec[k]);
}
}
SelAllObj();
m_pView->RefreshView();
}
CObjBase * CLayer::CreatScanAreaObj(CObjBase *pCircle,vector<Dbxy> PointObjVec,double Coordy1,double Coordy2,double ChangeSizeY,DIRECTION Dir)
{
if(!pCircle)
return NULL;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CObjPline *pPline = new CObjPline;
vector<CDataPoint>&PtContainer = pCircle->GetPtContainer();
int size = PtContainer.size();
CDataPoint FirstDataPoint;
bool bFirstPt = true;
for(int k=0;k<size;k++)
{
CDataPoint &DataPoint = PtContainer[k];
Dbxy Pt = DataPoint.GetPt();
if(Pt.y>=Coordy2 && Pt.y<=Coordy1)
{
int PointObjCnt = PointObjVec.size();
for(int i=0;i<PointObjCnt;i++)
{
if(CalDistance(Pt,PointObjVec[i])<m_AreaCrossPtRange)
{
DataPoint.SetPt(PointObjVec[i]);
break;
}
}
if(bFirstPt)//<2F><>¼<EFBFBD><C2BC>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
{
FirstDataPoint = DataPoint;
bFirstPt = false;
}
pPline->AddDataPoint(DataPoint);
}
}
//<2F>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD>
pPline->AddDataPoint(FirstDataPoint);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Y<EFBFBD><59><EFBFBD><EFBFBD>
{
SObjOperatePar par;
par.OpType = _OP_STRETCH;
DbRect rect = pPline->GetRect();
par.OldSize = rect.T - rect.B;
par.NewSize = (Coordy1-Coordy2)-ChangeSizeY;
par.Diff = par.NewSize-par.OldSize;
par.xy = _Y;
pPline->Operate(par);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD>λ<EFBFBD><CEBB>
{
SObjOperatePar par;
DbRect rect = pPline->GetRect();
par.OpType = _OP_MOVE;
par.MoveX = 0;
if(Dir==_DIR_U)
{
par.MoveY = Coordy1-rect.T;
}
else if(Dir==_DIR_D)
{
par.MoveY = Coordy2-rect.B;
}
else
{
par.MoveY = ((Coordy1+Coordy2)/2)-(rect.GetCenterPt().y);
}
pPline->Operate(par);
}
return pPline;
}
#endif