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.

376 lines
9.0 KiB
C++

#include "StdAfx.h"
#include "ObjBase.h"
#include "LogMgr.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
#include "PenParMgr.h"
#include "WorkFileLable.h"
#include "WorkFileMgr.h"
#include "CommonFlowMgr.h"
#include "DrawSimpleShape.h"
#include "ProgramLaserTuiHuo.h"
#include "WaferRecipeDataMgr.h"
#include "CStringFuc.h"
CObjBase::CObjBase(void)
{
SetSelected(false);//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1>
SetLock(false);//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
m_bDraw = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
m_bMarkPt = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊmark <20><>λ<EFBFBD><CEBB>
m_bCollected = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ռ<EFBFBD>
m_bFillObj = false;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>obj
m_bScaned = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>
OnCreat();
}
CObjBase::~CObjBase(void)
{
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
void CObjBase::OnCreat()
{
SetPenNum(gPenParMgr->GetCurPenNum());
}
void CObjBase::SetPenNum(int n)
{
m_PenNum = n;
}
#if 1
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBAAF>
CObjBase::CObjBase(CObjBase &rhs)
{
m_bSelected = rhs.m_bSelected;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1>
m_PtContainer.Load(rhs.m_PtContainer);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>
m_NodePtContainer.Load(rhs.m_NodePtContainer);
m_PenNum = rhs.m_PenNum;
m_bLocked = rhs.m_bLocked;
m_bDraw = rhs.m_bDraw;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
m_bMarkPt = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊmark <20><>λ<EFBFBD><CEBB>
m_bFillObj = rhs.m_bFillObj;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>obj
m_bScaned = rhs.m_bScaned;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>
}
//<2F><><EFBFBD><EFBFBD>rhs <20><><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>
void CObjBase::CopyPt(CObjBase &rhs)
{
m_PtContainer.Load(rhs.m_PtContainer);
}
#endif
#if 1
void CObjBase::WriteWorkFileBase(vector<CLab> &LabVec)
{
LabVec.push_back(CLab(LAB_OBJ_TYPE,(int)GetType()));//obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LabVec.push_back(CLab(LAB_PEN_NUM,m_PenNum));//obj <20><><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
LabVec.push_back(CLab(LAB_OBJ_IS_MARK,m_bMarkPt));//<2F>Ƿ<EFBFBD>Ϊmark <20><>
}
void CObjBase::ReadWorkFileBase(CLabVecRang &LabVecRang)
{
CWorkFileMgr WorkFileMgr;
//<2F><>ȡ<EFBFBD>ʺ<EFBFBD>------------------------------------------------
{
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_PEN_NUM);
if(Lab.m_ValType != _TYPE_NULL)
{
m_PenNum = Lab.m_Int;
}
}
{
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_OBJ_IS_MARK);
if(Lab.m_ValType != _TYPE_NULL)
{
m_bMarkPt = Lab.m_Bool;
}
}
}
void CObjBase::WriteWorkFile(vector<CLab> &LabVec)
{
//д<><EFBFBD><EBB9AB><EFBFBD><EFBFBD>Ϣ
WriteWorkFileBase(LabVec);
WriteWorkFileExt(LabVec);
}
void CObjBase::ReadWorkFile(CLabVecRang &LabVecRang)
{
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
ReadWorkFileBase(LabVecRang);
ReadWorkFileExt(LabVecRang);
}
void CObjBase::WriteWorkFileExt(vector<CLab> &LabVec)
{
m_PtContainer.WriteWorkFile(LabVec);
}
void CObjBase::ReadWorkFileExt(CLabVecRang &LabVecRang)
{
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ݵ<EFBFBD>--------------------------------------------
m_PtContainer.ReadWorkFile(LabVecRang);
}
#endif
#if 1
void CObjBase::Draw(CDC* pDC,CPen &Pen)
{
if(!m_bDraw)
return;
//ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_PtContainer.Draw(pDC,Pen);
//<2F>ڵ<EFBFBD>
if(gDraw->IsbShowObjNode() && IsSelected())
{
m_PtContainer.DrawNode(pDC);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DrawFill(pDC,Pen);
}
void CObjBase::Draw(CDC* pDC)
{
if(!m_bDraw)
return;
CPen Pen;
COLORREF color = gPenParMgr->GetPenColor(m_PenNum);
if(IsbFillObj())//ɨ<><C9A8><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ɫ
{
if(gWaferRecipeDataMgr->IsbScanEnd())
color = RGB_RED;
else
color = RGB_BLUE1;
if(gPenParMgr->IsSpecialPen(m_PenNum))
return;
}
Pen.CreatePen(PS_INSIDEFRAME,0.5,color);
Draw(pDC,Pen);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>߶<EFBFBD>
void CObjBase::DrawLastLine(CDC* pDC,CPen &Pen)
{
if(!m_bDraw)
return;
m_PtContainer.DrawLastLine(pDC,Pen);
}
#endif
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>
void CObjBase::AddDataPoint(CDataPoint pt)
{
m_PtContainer.AddDataPoint(pt);
}
//<2F><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>ĵ<EFBFBD>
void CObjBase::AddNodePt(CDataPoint pt)
{
m_NodePtContainer.AddDataPoint(pt);
}
bool CObjBase::Empty()
{
return (m_PtContainer.GetPtCnt()<2) ;
}
void CObjBase::DelAllPt()//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>
{
m_PtContainer.DelAllPt();
m_NodePtContainer.DelAllPt();
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
int CObjBase::GetPtCnt()
{
return m_PtContainer.GetPtCnt();
}
void CObjBase::DelLastDataPoint()//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڵ<EFBFBD>
{
m_PtContainer.DelLastDataPoint();
}
int CObjBase::GetNodePtIdx(Dbxy pt)
{
return m_PtContainer.GetNodePtIdx(pt);
}
void CObjBase::DelNodePtByIdx(int idx)
{
m_PtContainer.DelNodePtByIdx(idx);
}
void CObjBase::SetNodePtByIdx(int idx,Dbxy pt)
{
m_PtContainer.SetNodePtByIdx(idx,pt);
}
void CObjBase::InsertNode(int idx,Dbxy pt)
{
m_PtContainer.InsertNode(idx,pt);
}
void CObjBase::SetLastPoint(CDataPoint &pt)
{
m_PtContainer.SetLastPoint(pt);
}
bool CObjBase::IsSelected()
{
return m_bSelected;
}
void CObjBase::SetSelected(bool bSelected)
{
if(m_bLocked)//<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD>ܱ<EFBFBD>ѡ<EFBFBD><D1A1>
return;
m_bSelected = bSelected;
}
DbRect CObjBase::GetRect()
{
return m_PtContainer.GetRect();
}
Dbxy CObjBase::GetFirstPt()
{
return m_PtContainer.GetFirstPt();
}
Dbxy CObjBase::GetLastPt()
{
return m_PtContainer.GetLastPt();
}
//<2F>Ƿ<EFBFBD><C7B7>нڵ<D0BD><DAB5><EFBFBD>rect <20><>
bool CObjBase::HasNodeInRect(DbRect rect)
{
return m_PtContainer.HasNodeInRect(rect);
}
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>line <20>
bool CObjBase::IntersectWithLine(DbLine &line)
{
return m_PtContainer.IntersectWithLine(line);
}
#if 1
void CObjBase::Operate(SObjOperatePar &par)
{
m_GeometryPorp.Operate(par);//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_PtContainer.Operate(par);//<2F><><EFBFBD>ݵ<EFBFBD>
m_NodePtContainer.Operate(par);//<2F>ڵ<EFBFBD>
OperateFill(par);//<2F><><EFBFBD><EFBFBD>
}
#endif
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>
//<2F><>ȡobj <20><>rect <20><EFBFBD><E0BDBB><EFBFBD>߶<EFBFBD>(bGetCatchNode <20><>ʾ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD>IJ<EFBFBD>׽<EFBFBD><D7BD>)
void CObjBase::GetLineInRect(DbRect &rect,vector<DbLine> &DataPtLineVec,bool bGetCatchNode)
{
m_PtContainer.GetLineInRect(rect,DataPtLineVec);
if(bGetCatchNode)
{
m_NodePtContainer.GetNodePtLineInRect(rect,DataPtLineVec);
}
}
#endif
#if 1
//<2F>Ѽ<EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>vec <20><>
void CObjBase::GetPtData(vector<vector<Dbxy>> &vec)
{
if(m_bMarkPt)//<2F><>Ҫ<EFBFBD>ռ<EFBFBD>mark <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return;
m_PtContainer.GetPtData(vec,m_PenNum);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--------------------------------------------------
vector<CSequentialPoint>::iterator iter = m_FillDataVec.begin();
vector<CSequentialPoint>::iterator iter_end = m_FillDataVec.end();
for(;iter!=iter_end;iter++)
{
(*iter).GetPtData(vec,m_PenNum);
}
}
#endif
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CObjBase::CreatFillData(SFillPar FillPar)
{
m_FillDataVec.clear();
if(!FillPar.bFill)
return;
//<2F>Ѽ<EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>vec <20><>
vector<vector<Dbxy>> vec;
GetPtData(vec);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CObjFill Fill(m_FillDataVec);
Fill.SetPar(FillPar);
Fill.CreatFill(vec,GetRect());
}
void CObjBase::DrawFill(CDC* pDC,CPen &Pen)
{
vector<CSequentialPoint>::iterator iter = m_FillDataVec.begin();
vector<CSequentialPoint>::iterator iter_end = m_FillDataVec.end();
for(;iter!=iter_end;iter++)
{
(*iter).Draw(pDC,Pen);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CObjBase::OperateFill(SObjOperatePar &par)
{
vector<CSequentialPoint>::iterator iter = m_FillDataVec.begin();
vector<CSequentialPoint>::iterator iter_end = m_FillDataVec.end();
for(;iter!=iter_end;iter++)
{
(*iter).Operate(par);
}
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CObjBase::GetFillData(vector<vector<Dbxy>> &vec)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vector<CSequentialPoint>::iterator iter = m_FillDataVec.begin();
vector<CSequentialPoint>::iterator iter_end = m_FillDataVec.end();
for(;iter!=iter_end;iter++)
{
(*iter).GetPtData(vec);
}
}
#endif
#if 1
void CObjBase::AddDataPointVec(vector<CDataPoint> &Vec)
{
vector<CDataPoint> &DataPointVec = GetPtContainer();
vector<CDataPoint>::iterator iter = Vec.begin();
vector<CDataPoint>::iterator iter_end = Vec.end();
for(;iter!=iter_end;iter++)
{
DataPointVec.push_back(*iter);
}
}
//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>txt
void CObjBase::DrawPtCoord(CDC* pDC)
{
if(m_bFillObj)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
return;
vector<CDataPoint> &DataPointVec = GetPtContainer();
bool bShowPerPt = false;//ǰһ<C7B0><D2BB><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ
int size = DataPointVec.size();
for(int k=0;k<size;k++)
{
Dbxy pt = DataPointVec[k].GetPt();
bool bShow = false;
if(k==0||k==size-1)//<2F>˵<EFBFBD>
{
bShow = true;
}
if(k>0)
{
Dbxy PerPt = DataPointVec[k-1].GetPt();//ǰһ<C7B0><D2BB><EFBFBD><EFBFBD>
//<2F><>ǰһ<C7B0><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ֵʱ<D6B5><CAB1>ʾ
if(CalDistance(PerPt,pt)>30)
{
bShow = true;
if(!bShowPerPt)//ǰһ<C7B0><D2BB><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
DrawPtCoordExt(pDC,PerPt);
}
}
}
if(bShow)
{
DrawPtCoordExt(pDC,pt);
}
//<2F><>¼<EFBFBD><C2BC>ǰ<EFBFBD><C7B0><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ
bShowPerPt = bShow;
}
}
void CObjBase::DrawPtCoordExt(CDC* pDC,Dbxy &pt)
{
CString str= "X"+Db2CString(pt.x,3)+"Y"+Db2CString(pt.y,3);
gDraw->DrawTxt(pDC,str,pt);
}
#endif