|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "ObjComponentMgr.h"
|
|
|
|
|
#include "CStringFuc.h"
|
|
|
|
|
#include "GlobalDrawMgr.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "DrawSimpleShape.h"
|
|
|
|
|
#include "ObjCircle.h"
|
|
|
|
|
#include "WorkFileMgr.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "AuthorityMgr.h"
|
|
|
|
|
#include "MeasureMgr.h"
|
|
|
|
|
#include "MsgBox.h"
|
|
|
|
|
#include "WorkCmdInvoker.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "Layer.h"
|
|
|
|
|
#include "ObjContainer.h"
|
|
|
|
|
#include "CommonFlowMgr.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define GENG_3 (1.7320508075689)//<2F><><EFBFBD><EFBFBD>3
|
|
|
|
|
|
|
|
|
|
CObjComponentMgr *gObjComponentMgr = new CObjComponentMgr;
|
|
|
|
|
CObjComponentMgr::CObjComponentMgr(void)
|
|
|
|
|
{
|
|
|
|
|
m_CurSelIdx = -1;//<2F><>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
m_bDrawBase = false;//<2F>Ƿ<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>ƻ<EFBFBD>Ԫ<D7BC><D4AA>
|
|
|
|
|
|
|
|
|
|
m_ArrayXcntZ = 35;//X <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_ArrayXcntF = 0;//X <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_ArrayYcntZ = 3;//Y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_ArrayYcntF = 0;//Y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_OffsetX = 5;//X <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_OffsetY = 4.2;//Y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
m_RealOffsetX = m_OffsetX;//ʵ<>ʵ<EFBFBD>X <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mm
|
|
|
|
|
m_RealOffsetY = m_OffsetY;//ʵ<>ʵ<EFBFBD>Y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mm
|
|
|
|
|
|
|
|
|
|
//<2F><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ķ<EFBFBD>Χ
|
|
|
|
|
m_bUseArea = false;//<2F>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><DEB6><EFBFBD>Χ
|
|
|
|
|
|
|
|
|
|
m_bRectArea = false;//true Ϊ<><CEAA><EFBFBD>η<EFBFBD>Χ,false ΪԲ<CEAA>η<EFBFBD>Χ
|
|
|
|
|
m_AreaSize.w = 50;//<2F><><EFBFBD>η<EFBFBD>Χ<EFBFBD>ijߴ<C4B3>
|
|
|
|
|
m_AreaSize.h = 50;//<2F><><EFBFBD>η<EFBFBD>Χ<EFBFBD>ijߴ<C4B3>
|
|
|
|
|
m_AreaRadius = 150;//Բ<>η<EFBFBD>Χ<EFBFBD><CEA7>ֱ<EFBFBD><D6B1>
|
|
|
|
|
m_bDrawAllObj = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_bDrawFillColor = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_NoSelColor = RGB_GREEN;
|
|
|
|
|
m_SelColor = RGB_RED;
|
|
|
|
|
m_ViewObjColor = RGB_YELLOW;
|
|
|
|
|
m_ViewedObjColor = RGB_GREEN;//<2F>۲<EFBFBD><DBB2><EFBFBD><EFBFBD><EFBFBD>obj <20><>ɫ
|
|
|
|
|
|
|
|
|
|
m_bNeedAllIn = true;//Ԫ<><D4AA><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫȫ<D2AA><C8AB><EFBFBD>ڷ<EFBFBD>Χ<EFBFBD><CEA7>
|
|
|
|
|
m_bAutoArray = false;//<2F>Ƿ<EFBFBD><C7B7>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_AutoArrayGap = 0.5;//<2F>Զ<EFBFBD><D4B6>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_DefaultAng = 0;//Ĭ<>ϽǶ<CFBD>
|
|
|
|
|
|
|
|
|
|
m_CurSelObjIdx.x = 1;
|
|
|
|
|
m_CurSelObjIdx.y = 1;
|
|
|
|
|
|
|
|
|
|
m_bMoveTrackSDir = true;//S<>ι켣<CEB9>ƶ<EFBFBD><C6B6>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>־
|
|
|
|
|
m_bShowRealObj = false;//<2F><>ʾobj <20><>ʵ<EFBFBD><CAB5>λ<EFBFBD><CEBB>
|
|
|
|
|
|
|
|
|
|
m_bObjToCcdMode = false;//true <20><>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>CCD <20>۲<EFBFBD>
|
|
|
|
|
|
|
|
|
|
m_bDrawBindingObj = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ư<C6B0>layer obj
|
|
|
|
|
}
|
|
|
|
|
CObjComponentMgr::~CObjComponentMgr(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
void CObjComponentMgr::WriteWorkFileExt(vector<CLab> &LabVec)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡҲҪ<D2B2><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_ArrayXcntZ));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_ArrayXcntF));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_ArrayYcntZ));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_ArrayYcntF));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_OffsetX));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_OffsetY));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_bUseArea));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_bRectArea));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AreaBasePt.x));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AreaBasePt.y));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AreaSize.w));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AreaSize.h));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AreaRadius));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_bAutoArray));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_AutoArrayGap));
|
|
|
|
|
LabVec.push_back(CLab(LAB_NULL,m_DefaultAng));
|
|
|
|
|
//<2F>洢<EFBFBD><E6B4A2><EFBFBD><D7BC><EFBFBD><EFBFBD>--------------------------------------------------------
|
|
|
|
|
SaveBaseObj(LabVec);
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::ReadWorkFile(CLabVecRang &LabVecRang)
|
|
|
|
|
{
|
|
|
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DelAll();
|
|
|
|
|
|
|
|
|
|
//<2F><>ȡ˳<C8A1><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ͬ
|
|
|
|
|
int idx = LabVecRang.GetStart()+1;
|
|
|
|
|
m_ArrayXcntZ = LabVecRang.GetInt(idx++);
|
|
|
|
|
m_ArrayXcntF = LabVecRang.GetInt(idx++);
|
|
|
|
|
m_ArrayYcntZ = LabVecRang.GetInt(idx++);
|
|
|
|
|
m_ArrayYcntF = LabVecRang.GetInt(idx++);
|
|
|
|
|
m_OffsetX = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_OffsetY = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_bUseArea = LabVecRang.GetBool(idx++);
|
|
|
|
|
m_bRectArea = LabVecRang.GetBool(idx++);
|
|
|
|
|
m_AreaBasePt.x = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_AreaBasePt.y = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_AreaSize.w = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_AreaSize.h = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_AreaRadius = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_bAutoArray = LabVecRang.GetBool(idx++);
|
|
|
|
|
m_AutoArrayGap = LabVecRang.GetDouble(idx++);
|
|
|
|
|
m_DefaultAng = LabVecRang.GetDouble(idx++);
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
|
|
|
|
ReadBaseObj(LabVecRang);
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Array();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::SaveBaseObj(vector<CLab> &LabVec)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_BaseComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_BaseComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
LabVec.push_back(CLab(LAB_OBJ_START));//<2F><><EFBFBD>ݵ㿪ʼ
|
|
|
|
|
|
|
|
|
|
Dbxy BasePt = (*iter).GetBasePt();
|
|
|
|
|
DbSize size = (*iter).GetSize();
|
|
|
|
|
LabVec.push_back(CLab(LAB_POINT_X,BasePt.x));
|
|
|
|
|
LabVec.push_back(CLab(LAB_POINT_Y,BasePt.y));
|
|
|
|
|
LabVec.push_back(CLab(LAB_SIZE_W,size.w));
|
|
|
|
|
LabVec.push_back(CLab(LAB_SIZE_H,size.h));
|
|
|
|
|
LabVec.push_back(CLab(LAB_OBJ_IS_CIRCLE,(*iter).IsCircle()));
|
|
|
|
|
|
|
|
|
|
LabVec.push_back(CLab(LAB_OBJ_END));//<2F><><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::ReadBaseObj(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(!LabVecRangVec.empty())
|
|
|
|
|
{
|
|
|
|
|
vector<CLabVecRang>::iterator iter = LabVecRangVec.begin();
|
|
|
|
|
vector<CLabVecRang>::iterator iter_end = LabVecRangVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
Dbxy BasePt;
|
|
|
|
|
DbSize size;
|
|
|
|
|
{//BasePt X <20><><EFBFBD><EFBFBD>
|
|
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_POINT_X);
|
|
|
|
|
if(Lab.m_ValType != _TYPE_NULL)
|
|
|
|
|
{
|
|
|
|
|
BasePt.x = Lab.m_Double;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{//BasePt Y <20><><EFBFBD><EFBFBD>
|
|
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_POINT_Y);
|
|
|
|
|
if(Lab.m_ValType != _TYPE_NULL)
|
|
|
|
|
{
|
|
|
|
|
BasePt.y = Lab.m_Double;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{//size w
|
|
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_SIZE_W);
|
|
|
|
|
if(Lab.m_ValType != _TYPE_NULL)
|
|
|
|
|
{
|
|
|
|
|
size.w = Lab.m_Double;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{//size h
|
|
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_SIZE_H);
|
|
|
|
|
if(Lab.m_ValType != _TYPE_NULL)
|
|
|
|
|
{
|
|
|
|
|
size.h = Lab.m_Double;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool bIsCircle = true;
|
|
|
|
|
{//size h
|
|
|
|
|
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_OBJ_IS_CIRCLE);
|
|
|
|
|
if(Lab.m_ValType != _TYPE_NULL)
|
|
|
|
|
{
|
|
|
|
|
bIsCircle = Lab.m_Bool;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CObjComponent Obj(BasePt,size);
|
|
|
|
|
Obj.SetIsCircle(bIsCircle);
|
|
|
|
|
m_BaseComponentVec.push_back(Obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
void CObjComponentMgr::Draw(CDC* pDC)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bDrawAllObj)
|
|
|
|
|
return;
|
|
|
|
|
{
|
|
|
|
|
//Ԫ<><D4AA>
|
|
|
|
|
int size = m_ComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[i].Draw(pDC);
|
|
|
|
|
}
|
|
|
|
|
Dbxy Offset;
|
|
|
|
|
DrawArea(pDC,Offset);//<2F><EFBFBD><DEB6><EFBFBD>Χ
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_bDrawBase)//<2F><>Ԫ<D7BC><D4AA>
|
|
|
|
|
{
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
if(m_CurSelIdx==i)
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec[i].SetSelected(true);
|
|
|
|
|
m_BaseComponentVec[i].Draw(pDC);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec[i].SetSelected(false);
|
|
|
|
|
m_BaseComponentVec[i].Draw(pDC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#if 0
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD>obj <20><><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD>һ<EFBFBD><D2BB>ʮ<EFBFBD><CAAE>
|
|
|
|
|
DbRect Rect(m_AllObjCenterPt,2);
|
|
|
|
|
DrawCrossX(pDC,gDraw->GetMarkPointPen(),Rect);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ƫ<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><DEB6><EFBFBD>Χ
|
|
|
|
|
void CObjComponentMgr::DrawArea(CDC* pDC,Dbxy Offset)
|
|
|
|
|
{
|
|
|
|
|
if(m_bUseArea && !m_ComponentVec.empty())
|
|
|
|
|
{
|
|
|
|
|
Dbxy BasePt;
|
|
|
|
|
BasePt.x += Offset.x;
|
|
|
|
|
BasePt.y += Offset.y;
|
|
|
|
|
if(m_bRectArea)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
DbRect rect(BasePt,m_AreaSize);
|
|
|
|
|
DrawRect(pDC,gDraw->GetObjComponentAreaPen(),rect,false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CObjCircle Circle;
|
|
|
|
|
CCirclePar par;
|
|
|
|
|
par.CenterPt = m_AreaBasePt;
|
|
|
|
|
par.Radius = m_AreaRadius;
|
|
|
|
|
par.DEdgeCnt = 200;
|
|
|
|
|
Circle.Creat(par);
|
|
|
|
|
Circle.Draw(pDC,gDraw->GetObjComponentAreaPen());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ѡ<><D1A1>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
bool CObjComponentMgr::SelObjectInRect(DbRect rect)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bDrawAllObj)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
bool flg = false;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsInRect(rect))
|
|
|
|
|
{
|
|
|
|
|
//<2F><>תѡ<D7AA><D1A1>
|
|
|
|
|
bool b = !((*iter).IsSelected());
|
|
|
|
|
(*iter).SetSelected(b);
|
|
|
|
|
flg = true;
|
|
|
|
|
|
|
|
|
|
if(!gDraw->IsbMultipleSel())//<2F><><EFBFBD><EFBFBD>ѡ
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt = (*iter).GetBasePt();
|
|
|
|
|
gLogMgr->WriteDebugLog("Sel Obj ViewCoord :","x","y",pt.x,pt.y);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Թ۲<D4B9>ѡ<EFBFBD><D1A1>obj <20><>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
Dbxy RealBasePt = (*iter).GetRealBasePt();
|
|
|
|
|
gLogMgr->WriteDebugLog("Sel Obj RealCoord :","x","y",RealBasePt.x,RealBasePt.y);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ӧobj ѡ<><D1A1>״̬<D7B4>ĸı<C4B8>
|
|
|
|
|
OnObjSelStateChange();
|
|
|
|
|
return flg;
|
|
|
|
|
}
|
|
|
|
|
//ȫѡ
|
|
|
|
|
void CObjComponentMgr::SelAllObj()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetSelected(true);
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ӧobj ѡ<><D1A1>״̬<D7B4>ĸı<C4B8>
|
|
|
|
|
OnObjSelStateChange();
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::NotSelAllObj()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetSelected(false);
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ӧobj ѡ<><D1A1>״̬<D7B4>ĸı<C4B8>
|
|
|
|
|
OnObjSelStateChange();
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ѡ
|
|
|
|
|
void CObjComponentMgr::RevSelAllObj()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetSelected(!((*iter).IsSelected()));
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ӧobj ѡ<><D1A1>״̬<D7B4>ĸı<C4B8>
|
|
|
|
|
OnObjSelStateChange();
|
|
|
|
|
}
|
|
|
|
|
//<2F><>Ӧobj ѡ<><D1A1>״̬<D7B4>ĸı<C4B8>
|
|
|
|
|
void CObjComponentMgr::OnObjSelStateChange()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>vec
|
|
|
|
|
void CObjComponentMgr::GetSelObjIdx(vector<bool> &SelObjIdxVec)
|
|
|
|
|
{
|
|
|
|
|
SelObjIdxVec.clear();
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
int idx = 0;
|
|
|
|
|
for(;iter!=iter_end;iter++,idx++)
|
|
|
|
|
{
|
|
|
|
|
SelObjIdxVec.push_back((*iter).IsSelected());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20><>ѡ<EFBFBD><D1A1>״̬
|
|
|
|
|
void CObjComponentMgr::SetSelectedByIdx(int idx,bool b)
|
|
|
|
|
{
|
|
|
|
|
int size = m_ComponentVec.size();
|
|
|
|
|
if(idx<size)
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[idx].SetSelected(b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
void CObjComponentMgr::CalAllObjCenterPt()
|
|
|
|
|
{
|
|
|
|
|
DbRect Rect;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
int idx = 0;
|
|
|
|
|
for(;iter!=iter_end;iter++,idx++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsbCollecteData())
|
|
|
|
|
{
|
|
|
|
|
AdjustRectByPoint(Rect,(*iter).GetBasePt());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_AllObjCenterPt = Rect.GetCenterPt();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ǰѡ<C7B0><D1A1>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int CObjComponentMgr::GetSelObjCnt()
|
|
|
|
|
{
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsSelected())
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD>趨<EFBFBD><E8B6A8>mark <20><><EFBFBD><EFBFBD>
|
|
|
|
|
int CObjComponentMgr::GetMarkObjCnt()
|
|
|
|
|
{
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsMarkObj())
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::ResetAllMarkObj()
|
|
|
|
|
{
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbMarkObj(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj Ϊmark
|
|
|
|
|
void CObjComponentMgr::SetSelObjMark(int CurMarkCnt)
|
|
|
|
|
{
|
|
|
|
|
int idx = CurMarkCnt+1;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsSelected())
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbMarkObj(true);
|
|
|
|
|
CString LogStr;
|
|
|
|
|
LogStr.Format(("Set Mark Pt [%d]"),idx++);
|
|
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
|
|
Dbxy pt = (*iter).GetBasePt();
|
|
|
|
|
LogStr.Format(("[pt.x] = [%f] ,[pt.y] = [%f]"),pt.x,pt.y);
|
|
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj Ϊmark obj
|
|
|
|
|
bool CObjComponentMgr::SetMarkObj()
|
|
|
|
|
{
|
|
|
|
|
int SelObjCnt = GetSelObjCnt();//ѡ<><D1A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
if(SelObjCnt>2)
|
|
|
|
|
{
|
|
|
|
|
//gLogMgr->WriteDebugLog("<22><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj Ϊmark");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(SelObjCnt==0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
int MarkObjCnt = GetMarkObjCnt();//<2F><><EFBFBD><EFBFBD>mark obj <20>ĸ<EFBFBD><C4B8><EFBFBD>
|
|
|
|
|
if(MarkObjCnt>=2)
|
|
|
|
|
{
|
|
|
|
|
ResetAllMarkObj();
|
|
|
|
|
MarkObjCnt = 0;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj Ϊmark
|
|
|
|
|
SetSelObjMark(MarkObjCnt);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ԫ<D7BC><D4AA>
|
|
|
|
|
void CObjComponentMgr::AddBaseComponent()
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt;
|
|
|
|
|
DbSize size(2,2);
|
|
|
|
|
AddBaseComponent(pt,size);
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::AddBaseComponent(Dbxy pt,DbSize size)
|
|
|
|
|
{
|
|
|
|
|
CObjComponent Component(pt,size);
|
|
|
|
|
Component.SetBase(true);
|
|
|
|
|
m_BaseComponentVec.push_back(Component);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ͨԭ<CDA8><D4AD>
|
|
|
|
|
void CObjComponentMgr::AddComponent(CObjComponent Component)
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec.push_back(Component);
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::InsertList(CListCtrl &List)
|
|
|
|
|
{
|
|
|
|
|
int size = m_BaseComponentVec.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>
|
|
|
|
|
Dbxy pt = m_BaseComponentVec[i].GetBasePt();//<2F><><EFBFBD><D7BC>
|
|
|
|
|
List.SetItemText(i,idx++,Db2CString(pt.x));
|
|
|
|
|
List.SetItemText(i,idx++,Db2CString(pt.y));
|
|
|
|
|
DbSize size = m_BaseComponentVec[i].GetSize();//<2F>ߴ<EFBFBD>
|
|
|
|
|
List.SetItemText(i,idx++,Db2CString(size.w));
|
|
|
|
|
List.SetItemText(i,idx++,Db2CString(size.h));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>idx <20>Ƿ<EFBFBD><C7B7><EFBFBD>Ч
|
|
|
|
|
bool CObjComponentMgr::IdxValid(int idx)
|
|
|
|
|
{
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
if(idx<0 || idx>= size)
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
void CObjComponentMgr::DelSel(int &idx)
|
|
|
|
|
{
|
|
|
|
|
if(!IdxValid(idx))
|
|
|
|
|
return;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_BaseComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_BaseComponentVec.end();
|
|
|
|
|
int i=0;
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if(i==idx)
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec.erase(iter);
|
|
|
|
|
idx = -1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::DelAll()
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec.clear();
|
|
|
|
|
m_ComponentVec.clear();
|
|
|
|
|
m_CatchPtVec.clear();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>idx <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::OpArea(int idx,CObjComponent &Area,bool bRead)
|
|
|
|
|
{
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
if(idx == i)
|
|
|
|
|
{
|
|
|
|
|
if(bRead)
|
|
|
|
|
{
|
|
|
|
|
Area = m_BaseComponentVec[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec[i] = Area;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><DEB6><EFBFBD>Χ<EFBFBD><CEA7>(Size <20><><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>ҵ<EFBFBD><D2B5>ߵ<EFBFBD>obj)
|
|
|
|
|
bool CObjComponentMgr::IsInArea(Dbxy pt,DbSize Size)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bUseArea)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if(!m_bNeedAllIn)
|
|
|
|
|
Size.w = Size.h = 0;
|
|
|
|
|
if(m_bRectArea)//<2F><><EFBFBD>η<EFBFBD>Χ
|
|
|
|
|
{
|
|
|
|
|
DbRect rect(m_AreaBasePt,DbSize(m_AreaSize.w-Size.w,m_AreaSize.h-Size.h));
|
|
|
|
|
return IsPointInRect(pt,rect);
|
|
|
|
|
}
|
|
|
|
|
else//Բ<><D4B2>
|
|
|
|
|
{
|
|
|
|
|
return CalDistance(m_AreaBasePt,pt)<(m_AreaRadius-Size.w/2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
void CObjComponentMgr::Array()
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec.clear();
|
|
|
|
|
m_CatchPtVec.clear();
|
|
|
|
|
|
|
|
|
|
if(m_bAutoArray)//<2F>Զ<EFBFBD><D4B6>Ų<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
AutoArray();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ArrayExt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>Զ<EFBFBD><D4B6>Ų<EFBFBD>
|
|
|
|
|
void CObjComponentMgr::AutoArray()
|
|
|
|
|
{
|
|
|
|
|
if(m_BaseComponentVec.empty())
|
|
|
|
|
return;
|
|
|
|
|
if(!m_bUseArea)
|
|
|
|
|
return;
|
|
|
|
|
//<2F>Զ<EFBFBD><D4B6>Ų<EFBFBD>ֻȡ<D6BB><C8A1>һ<EFBFBD><D2BB>
|
|
|
|
|
Dbxy BasePt = m_BaseComponentVec[0].GetBasePt();
|
|
|
|
|
DbSize Size = m_BaseComponentVec[0].GetSize();
|
|
|
|
|
bool bIsCircle = m_BaseComponentVec[0].IsCircle();
|
|
|
|
|
|
|
|
|
|
double OffsetX = (Size.w + m_AutoArrayGap)/2;
|
|
|
|
|
double OffsetY = GENG_3*OffsetX;
|
|
|
|
|
|
|
|
|
|
Dbxy Pt = BasePt;
|
|
|
|
|
while(1)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(AutoArrayExt(Pt,Size,OffsetX,OffsetY,bIsCircle)==false)
|
|
|
|
|
break;
|
|
|
|
|
Pt.x += (Size.w + m_AutoArrayGap);
|
|
|
|
|
}
|
|
|
|
|
Pt = BasePt;
|
|
|
|
|
Pt.x -= (Size.w + m_AutoArrayGap);
|
|
|
|
|
while(1)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(AutoArrayExt(Pt,Size,OffsetX,OffsetY,bIsCircle)==false)
|
|
|
|
|
break;
|
|
|
|
|
Pt.x -= (Size.w + m_AutoArrayGap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool CObjComponentMgr::AutoArrayExt(Dbxy BasePt,DbSize Size,double OffsetX,double OffsetY,bool bIsCircle)
|
|
|
|
|
{
|
|
|
|
|
bool ret = false;//<2F>Ƿ<EFBFBD><C7B7>з<EFBFBD>Χ<EFBFBD>ڵ<EFBFBD>obj
|
|
|
|
|
Dbxy Pt = BasePt;
|
|
|
|
|
for(int i=0;i<m_ArrayYcntZ;i++)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(IsInArea(Pt,Size))
|
|
|
|
|
{
|
|
|
|
|
CObjComponent Obj(Pt,Size);
|
|
|
|
|
Obj.SetIsCircle(bIsCircle);
|
|
|
|
|
m_ComponentVec.push_back(Obj);
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
Pt.x += OffsetX;
|
|
|
|
|
Pt.y += OffsetY;
|
|
|
|
|
}
|
|
|
|
|
Pt = BasePt;
|
|
|
|
|
Pt.x -= OffsetX;
|
|
|
|
|
Pt.y -= OffsetY;
|
|
|
|
|
for(int i=0;i<m_ArrayYcntF;i++)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(IsInArea(Pt,Size))
|
|
|
|
|
{
|
|
|
|
|
CObjComponent Obj(Pt,Size);
|
|
|
|
|
Obj.SetIsCircle(bIsCircle);
|
|
|
|
|
m_ComponentVec.push_back(Obj);
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
Pt.x -= OffsetX;
|
|
|
|
|
Pt.y -= OffsetY;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
//XY<58><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::ArrayExt()
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ͻǿ<CFBD>ʼ
|
|
|
|
|
int startX = m_ArrayXcntZ;
|
|
|
|
|
int endX = m_ArrayXcntF*(-1);
|
|
|
|
|
int startY = m_ArrayYcntZ;
|
|
|
|
|
int endY = m_ArrayYcntF*(-1);
|
|
|
|
|
|
|
|
|
|
Dbxy Offset;//<2F><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
Offset.x = (endX*m_OffsetX-startX*m_OffsetX)/2;
|
|
|
|
|
Offset.y = (endY*m_OffsetY-startY*m_OffsetY)/2;
|
|
|
|
|
|
|
|
|
|
Dbxy RealOffset;//<2F><><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>
|
|
|
|
|
RealOffset.x = (endX*m_RealOffsetX-startX*m_RealOffsetX)/2;
|
|
|
|
|
RealOffset.y = (endY*m_RealOffsetY-startY*m_RealOffsetY)/2;
|
|
|
|
|
|
|
|
|
|
for(int i = startX;i>=endX;i--)
|
|
|
|
|
{
|
|
|
|
|
for(int j = startY;j>=endY;j--)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
IntXY idx;
|
|
|
|
|
idx.x = (i-startX-1)*(-1);
|
|
|
|
|
idx.y = (j-startY-1)*(-1);
|
|
|
|
|
Arrayij(i,j,idx,Offset,RealOffset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><>i <20>е<EFBFBD>j <20><>(Offset <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>,RealOffset ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƫ<EFBFBD><C6AB>)
|
|
|
|
|
void CObjComponentMgr::Arrayij(int i,int j,IntXY idx,Dbxy Offset,Dbxy RealOffset)
|
|
|
|
|
{
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
for(int k=0;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
Dbxy BasePt = m_BaseComponentVec[k].GetBasePt();
|
|
|
|
|
DbSize Size = m_BaseComponentVec[k].GetSize();
|
|
|
|
|
bool bIsCircle = m_BaseComponentVec[k].IsCircle();
|
|
|
|
|
|
|
|
|
|
Dbxy RealBasePt = BasePt;//ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
BasePt.x += m_OffsetX*i + Offset.x;
|
|
|
|
|
BasePt.y += m_OffsetY*j + Offset.y;
|
|
|
|
|
|
|
|
|
|
RealBasePt.x += m_RealOffsetX*i + RealOffset.x;
|
|
|
|
|
RealBasePt.y += m_RealOffsetY*j + RealOffset.y;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><DEB6><EFBFBD>Χ<EFBFBD><CEA7>
|
|
|
|
|
if(!IsInArea(BasePt,Size))
|
|
|
|
|
continue;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>obj
|
|
|
|
|
CObjComponent Obj(BasePt,Size);
|
|
|
|
|
Obj.SetRealBasePt(RealBasePt);
|
|
|
|
|
Obj.SetIsCircle(bIsCircle);
|
|
|
|
|
if(i==0 && j==0)//<2F><><EFBFBD>ǻ<EFBFBD>Ԫ<D7BC><D4AA>
|
|
|
|
|
{
|
|
|
|
|
Obj.SetBase(true);
|
|
|
|
|
}
|
|
|
|
|
Obj.SetIndex(idx);
|
|
|
|
|
|
|
|
|
|
m_ComponentVec.push_back(Obj);
|
|
|
|
|
|
|
|
|
|
if(k==0)//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5>õĽ<C3B5><C4BD><EFBFBD>,ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt(BasePt.x-m_OffsetX/2,BasePt.y-m_OffsetY/2);
|
|
|
|
|
m_CatchPtVec.push_back(pt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>û<EFBFBD>obj <20><>ƫ<EFBFBD><C6AB>
|
|
|
|
|
void CObjComponentMgr::SetBaseObjOffset(Dbxy Offset)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_BaseComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_BaseComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetBasePt(Offset);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>pt <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
Dbxy CObjComponentMgr::FindNearestPt(Dbxy pt)
|
|
|
|
|
{
|
|
|
|
|
Dbxy NearestPt = pt;
|
|
|
|
|
double MinDis = -1;
|
|
|
|
|
vector<Dbxy>::iterator iter = m_CatchPtVec.begin();
|
|
|
|
|
vector<Dbxy>::iterator iter_end = m_CatchPtVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
double dis = CalDistance(pt,(*iter));
|
|
|
|
|
if(MinDis == -1 || dis < MinDis)
|
|
|
|
|
{
|
|
|
|
|
MinDis = dis;
|
|
|
|
|
NearestPt = (*iter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return NearestPt;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//ͨ<><CDA8>layer <20>е<EFBFBD>ͼ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::CreatObjByLayerObj()
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec.clear();
|
|
|
|
|
|
|
|
|
|
CLayer &Layer = gLayer;
|
|
|
|
|
CObjContainer &ObjContainer = Layer.GetObjContainer();
|
|
|
|
|
vector<Sptr<CObjBase>> &ObjVec = ObjContainer.GetObjVec();
|
|
|
|
|
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = ObjVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = ObjVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
DbRect rect = (*iter)->GetRect();
|
|
|
|
|
if(!m_bDrawBindingObj)//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD>obj
|
|
|
|
|
{
|
|
|
|
|
(*iter)->SetbDraw(false);
|
|
|
|
|
}
|
|
|
|
|
(*iter)->SetSelected(false);
|
|
|
|
|
Dbxy pt = rect.GetCenterPt();
|
|
|
|
|
DbSize size = rect.GetSize();
|
|
|
|
|
double MinSize = 2;
|
|
|
|
|
if(size.w<MinSize)
|
|
|
|
|
size.w=MinSize;
|
|
|
|
|
if(size.h<MinSize)
|
|
|
|
|
size.h=MinSize;
|
|
|
|
|
|
|
|
|
|
double gap = 0.1;//<2F><>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
size.w += gap;
|
|
|
|
|
size.h += gap;
|
|
|
|
|
CObjComponent Obj(pt,size);
|
|
|
|
|
Obj.SetIsCircle(false);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
Obj.AddObjShape(*iter);//<2F><><EFBFBD><EFBFBD>layer obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_ComponentVec.push_back(Obj);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>layer obj (<28><>ֹ<EFBFBD>༭)
|
|
|
|
|
SetShapeLockState(true);
|
|
|
|
|
}
|
|
|
|
|
//<2F><>obj <20>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λmark <20><>λ<EFBFBD><CEBB>(<28><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>Բ)
|
|
|
|
|
//ֱ<><D6B1>С<EFBFBD><D0A1>R <20><>obj <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ܵ<EFBFBD>mark <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::AnalyseMarkPt(double R)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent*> MarkVec;
|
|
|
|
|
//<2F><><EFBFBD>ҳ<EFBFBD><D2B3>뾶С<EBBEB6><D0A1>R <20>Ķ<EFBFBD><C4B6><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
DbSize Size = (*iter).GetSize();
|
|
|
|
|
if(Size.w<R && Size.h<R)
|
|
|
|
|
{
|
|
|
|
|
(*iter).NotCollect();//<2F><>Ҫ<EFBFBD>ռ<EFBFBD><D5BC>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
MarkVec.push_back(&(*iter));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>mark
|
|
|
|
|
int MarkCnt = 0;//<2F>ҵ<EFBFBD>mark <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int size = MarkVec.size();
|
|
|
|
|
for(int i=0;i<size-1;i++)
|
|
|
|
|
{
|
|
|
|
|
if(MarkVec[i]->IsCollected())//<2F><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
|
|
|
|
continue;
|
|
|
|
|
Dbxy pt1 = MarkVec[i]->GetBasePt();
|
|
|
|
|
for(int k=i+1;k<size;k++)
|
|
|
|
|
{
|
|
|
|
|
if(MarkVec[k]->IsCollected())//<2F><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD>
|
|
|
|
|
continue;
|
|
|
|
|
Dbxy pt2 = MarkVec[k]->GetBasePt();
|
|
|
|
|
double dis = CalDistance(pt1,pt2);
|
|
|
|
|
if(dis<0.5)//ƥ<><C6A5>
|
|
|
|
|
{
|
|
|
|
|
MarkVec[k]->SetbMarkObj(true);//<2F><><EFBFBD><EFBFBD>Ϊmark
|
|
|
|
|
MarkVec[k]->SetbCollected(true);
|
|
|
|
|
MarkCnt++;//<2F><>¼<EFBFBD>ҵ<EFBFBD>mark <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MarkVec[i]->SetbCollected(true);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CString LogStr;
|
|
|
|
|
LogStr.Format(_T("func: AnalyseMarkPt---->[MarkCnt] = [%d]"),MarkCnt);
|
|
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>û<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
DbSize CObjComponentMgr::GetBaseSize(int idx)
|
|
|
|
|
{
|
|
|
|
|
DbSize BaseSize;
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
if(idx>=0 && idx<size)
|
|
|
|
|
{
|
|
|
|
|
BaseSize = m_BaseComponentVec[idx].GetSize();
|
|
|
|
|
}
|
|
|
|
|
return BaseSize;
|
|
|
|
|
}
|
|
|
|
|
bool CObjComponentMgr::IsBaseCircle(int idx)
|
|
|
|
|
{
|
|
|
|
|
bool ret = false;
|
|
|
|
|
int size = m_BaseComponentVec.size();
|
|
|
|
|
if(idx>=0 && idx<size)
|
|
|
|
|
{
|
|
|
|
|
ret = m_BaseComponentVec[idx].IsCircle();
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>״̬NeedSel Ϊtrue <20><>ʾѡ<CABE><D1A1><EFBFBD>IJ<EFBFBD><C4B2>ռ<EFBFBD>
|
|
|
|
|
void CObjComponentMgr::ResetObjCollectState(bool NeedSel)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbCollected(false);
|
|
|
|
|
if(NeedSel && (*iter).IsSelected()==false)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbCollected(true);//δѡ<CEB4><D1A1><EFBFBD>IJ<EFBFBD>Ҫ<EFBFBD>ռ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>ռ<EFBFBD>rect <20><>Χ<EFBFBD><CEA7>Ԫ<EFBFBD><D4AA><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::CollectWorkData(DbRect &rect,vector<vector<Dbxy>> &vec,bool bNeedSel)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if(!bNeedSel || (bNeedSel && (*iter).IsSelected()))
|
|
|
|
|
{
|
|
|
|
|
(*iter).CollectWorkData(rect,vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ص<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>obj <20>Ƿ<EFBFBD><C7B7><EFBFBD>Բ<EFBFBD><D4B2>
|
|
|
|
|
bool CObjComponentMgr::IsCircle()
|
|
|
|
|
{
|
|
|
|
|
if(m_BaseComponentVec.empty())
|
|
|
|
|
return true;
|
|
|
|
|
return m_BaseComponentVec[0].IsCircle();
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>obj <20>Ƿ<EFBFBD>ΪԲ<CEAA><D4B2>
|
|
|
|
|
void CObjComponentMgr::SetIsCircle(bool b)
|
|
|
|
|
{
|
|
|
|
|
if(!m_BaseComponentVec.empty())
|
|
|
|
|
{
|
|
|
|
|
m_BaseComponentVec[0].SetIsCircle(b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ͨ<><CDA8>obj <20><><EFBFBD><EFBFBD>markarea
|
|
|
|
|
void CObjComponentMgr::CreatAreaByObj(CMarkAreaMgr &AreaMgr)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
CMarkArea Area((*iter).GetBasePt(),(*iter).GetSize());
|
|
|
|
|
AreaMgr.AddArea(Area);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
IntXY CObjComponentMgr::GetFristSelectedObjIdx()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsSelected())
|
|
|
|
|
{
|
|
|
|
|
return (*iter).GetIndex();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IntXY idx(-1,-1);
|
|
|
|
|
return idx;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊvector <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(û<><C3BB>ƥ<EFBFBD>䷵<EFBFBD><E4B7B5>-1)
|
|
|
|
|
int CObjComponentMgr::ConvertIdx(IntXY Idx)
|
|
|
|
|
{
|
|
|
|
|
int size = m_ComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
if(m_ComponentVec[i].GetIndex() == Idx)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
//<2F>ƶ<EFBFBD><C6B6><EFBFBD>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>TargetPt
|
|
|
|
|
void CObjComponentMgr::MoveFristSelObjToPt(Dbxy TargetPt)
|
|
|
|
|
{
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
IntXY IdxXY = GetFristSelectedObjIdx();
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
MoveObjToPtByIdx(IdxXY,TargetPt);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD>۲<EFBFBD><DBB2><EFBFBD>obj
|
|
|
|
|
void CObjComponentMgr::SetCurViewObjIdx(IntXY Idx)
|
|
|
|
|
{
|
|
|
|
|
m_CurSelObjIdx = Idx;
|
|
|
|
|
int size = m_ComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
if(m_ComponentVec[i].GetIndex() == Idx)
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[i].SetbView(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[i].SetbView(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>õ<EFBFBD>ǰѡ<C7B0><D1A1><EFBFBD><EFBFBD>obj
|
|
|
|
|
void CObjComponentMgr::SetCurSelObjIdx(IntXY Idx)
|
|
|
|
|
{
|
|
|
|
|
m_CurSelObjIdx = Idx;
|
|
|
|
|
int size = m_ComponentVec.size();
|
|
|
|
|
for(int i=0;i<size;i++)
|
|
|
|
|
{
|
|
|
|
|
if(m_ComponentVec[i].GetIndex() == Idx)
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[i].SetSelected(true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_ComponentVec[i].SetSelected(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ƶ<EFBFBD>obj (<28><><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>۲<EFBFBD>obj )
|
|
|
|
|
bool CObjComponentMgr::MoveObjToPtByIdx(IntXY IdxXY,Dbxy TargetPt)
|
|
|
|
|
{
|
|
|
|
|
//ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int idx = ConvertIdx(IdxXY);
|
|
|
|
|
if(idx>=0)
|
|
|
|
|
{
|
|
|
|
|
CString LogStr;
|
|
|
|
|
LogStr.Format(_T("Fuc:MoveSelObjToPt : Idx[X] = [%d] ,Idx[Y] = [%d]"),IdxXY.x,IdxXY.y);
|
|
|
|
|
gLogMgr->WriteDebugLog(LogStr);
|
|
|
|
|
//<2F><>¼<EFBFBD><C2BC>ǰ<EFBFBD>۲<EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
SetCurViewObjIdx(IdxXY);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD>ѹ۲<D1B9>
|
|
|
|
|
m_ComponentVec[idx].SetbViewed(true);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>obj <20><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponentMgr::MoveObjToCameraByDir(DIRECTION dir,Dbxy TargetPt)
|
|
|
|
|
{
|
|
|
|
|
IntXY IdxXY = GetCurViewObjIdx();
|
|
|
|
|
if(dir == _DIR_R)
|
|
|
|
|
IdxXY.x--;
|
|
|
|
|
else if(dir == _DIR_L)
|
|
|
|
|
IdxXY.x++;
|
|
|
|
|
else if(dir == _DIR_U)
|
|
|
|
|
IdxXY.y--;
|
|
|
|
|
else if(dir == _DIR_D)
|
|
|
|
|
IdxXY.y++;
|
|
|
|
|
else if(dir == _DIR_M)
|
|
|
|
|
{
|
|
|
|
|
IdxXY.x = 1;
|
|
|
|
|
IdxXY.y = 1;
|
|
|
|
|
}
|
|
|
|
|
MoveObjToPtByIdx(IdxXY,TargetPt);
|
|
|
|
|
}
|
|
|
|
|
//<2F><>S <20>ι켣<CEB9><ECBCA3><EFBFBD>ƶ<EFBFBD>obj (bDir <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>)
|
|
|
|
|
void CObjComponentMgr::MoveTrackS(Dbxy TargetPt,IntXY Gap,bool bDir)
|
|
|
|
|
{
|
|
|
|
|
IntXY IdxXY = GetCurViewObjIdx();
|
|
|
|
|
IntXY NewIdxXY = IdxXY;
|
|
|
|
|
|
|
|
|
|
if(m_bMoveTrackSDir)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
NewIdxXY.y += Gap.y;
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
NewIdxXY.y -= Gap.y;
|
|
|
|
|
|
|
|
|
|
if(MoveObjToPtByIdx(NewIdxXY,TargetPt)==false)//<2F><>ͷ<EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
NewIdxXY.y = IdxXY.y;
|
|
|
|
|
if(bDir)//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
NewIdxXY.x += Gap.x;
|
|
|
|
|
else//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
NewIdxXY.x -= Gap.x;
|
|
|
|
|
|
|
|
|
|
if(MoveObjToPtByIdx(NewIdxXY,TargetPt))//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
m_bMoveTrackSDir = !m_bMoveTrackSDir;//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>Y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//LPS ISP3000 ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>die <20>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>obj <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD>(bDivideX <20>Ƿ<EFBFBD><C7B7>뷽<EFBFBD><EBB7BD>)
|
|
|
|
|
void CObjComponentMgr::DivideBySpacingDis(double dis,bool bDivideX)
|
|
|
|
|
{
|
|
|
|
|
if(dis<0.001)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
vector<CObjComponent> ComponentVecTmp;//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
ComponentVecTmp.push_back(CopyObj((*iter),-1,dis,bDivideX));
|
|
|
|
|
ComponentVecTmp.push_back(CopyObj((*iter),1,dis,bDivideX));
|
|
|
|
|
}
|
|
|
|
|
m_ComponentVec = ComponentVecTmp;
|
|
|
|
|
}
|
|
|
|
|
CObjComponent CObjComponentMgr::CopyObj(CObjComponent &Obj,int sign,double dis,bool bDivideX)
|
|
|
|
|
{
|
|
|
|
|
Dbxy BasePt = Obj.GetBasePt();//<2F><>ʾ<EFBFBD><CABE>
|
|
|
|
|
Dbxy RealBasePt = Obj.GetRealBasePt();//ʵ<>ʵ<EFBFBD>
|
|
|
|
|
DbSize size = Obj.GetSize();//<2F><>ʾ<EFBFBD>ߴ<EFBFBD>
|
|
|
|
|
IntXY Idx = Obj.GetIndex();
|
|
|
|
|
CObjComponent NewObj = Obj;
|
|
|
|
|
BasePt.x += (size.w/4)*(sign);
|
|
|
|
|
NewObj.SetBasePt(BasePt);
|
|
|
|
|
RealBasePt.x += (dis/2)*(sign);
|
|
|
|
|
NewObj.SetRealBasePt(RealBasePt);
|
|
|
|
|
size.w /= 2;
|
|
|
|
|
NewObj.SetSize(size);
|
|
|
|
|
Idx.x *=2;
|
|
|
|
|
if(sign==1)
|
|
|
|
|
Idx.x -= 1;
|
|
|
|
|
NewObj.SetIndex(Idx);
|
|
|
|
|
return NewObj;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ǰ<EFBFBD>۲<EFBFBD><DBB2><EFBFBD><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int CObjComponentMgr::GetCurViewedObj()
|
|
|
|
|
{
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsbViewed())
|
|
|
|
|
cnt++;
|
|
|
|
|
}
|
|
|
|
|
return cnt;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F>л<EFBFBD><D0BB>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD><C6B6><EFBFBD>ccd <20><>ģʽ
|
|
|
|
|
bool CObjComponentMgr::SwithObjToCcdMode()
|
|
|
|
|
{
|
|
|
|
|
m_bObjToCcdMode = !m_bObjToCcdMode;
|
|
|
|
|
return m_bObjToCcdMode;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>
|
|
|
|
|
Dbxy CObjComponentMgr::GetFristSelObjCenter()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if((*iter).IsSelected())
|
|
|
|
|
return (*iter).GetRealBasePt();
|
|
|
|
|
}
|
|
|
|
|
Dbxy pt;
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>rect <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20><>mark ״̬(bSel <20><>ʾ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫѡ<D2AA><D1A1>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>)
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>Χ(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>markarea)
|
|
|
|
|
DbRect CObjComponentMgr::SetMarkedStateRect(DbRect AreaRect,bool bSel)
|
|
|
|
|
{
|
|
|
|
|
DbRect DataRect;//<2F><><EFBFBD>ݷ<EFBFBD>Χ
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
if(bSel && !(*iter).IsSelected())
|
|
|
|
|
continue;
|
|
|
|
|
if(!(*iter).IsbMarked() && (*iter).IsInRect(AreaRect,true))
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbMarked(true);
|
|
|
|
|
AdjustRectByRect(DataRect,(*iter).GetRect());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return DataRect;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj <20>ļӹ<C4BC>״̬
|
|
|
|
|
void CObjComponentMgr::ResetAllMarkedState()
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetbMarked(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>layer obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬(<28><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>)
|
|
|
|
|
void CObjComponentMgr::SetShapeLockState(bool b)
|
|
|
|
|
{
|
|
|
|
|
vector<CObjComponent>::iterator iter = m_ComponentVec.begin();
|
|
|
|
|
vector<CObjComponent>::iterator iter_end = m_ComponentVec.end();
|
|
|
|
|
for(;iter!=iter_end;iter++)
|
|
|
|
|
{
|
|
|
|
|
(*iter).SetShapeLockState(b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|