|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "ObjComponent.h"
|
|
|
|
|
#include "DrawSimpleShape.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
#include "TemplateMgr.h"
|
|
|
|
|
#include "ProductMgr.h"
|
|
|
|
|
#include "ObjComponentMgr.h"
|
|
|
|
|
#include "CommonFlowMgr.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CObjComponent::CObjComponent()
|
|
|
|
|
{
|
|
|
|
|
m_Size.w = 5;
|
|
|
|
|
m_Size.h = 4.2;
|
|
|
|
|
m_bMark1Obj = false;//<2F><>һ<EFBFBD><D2BB>mark
|
|
|
|
|
Ini();
|
|
|
|
|
}
|
|
|
|
|
CObjComponent::CObjComponent(Dbxy pt,DbSize size)
|
|
|
|
|
{
|
|
|
|
|
m_BasePt = pt;//Ԫ<><D4AA><EFBFBD>Ļ<EFBFBD><EFBFBD><D7BC>
|
|
|
|
|
m_Size = size;//Ԫ<><D4AA><EFBFBD>ijߴ<C4B3>
|
|
|
|
|
Ini();
|
|
|
|
|
}
|
|
|
|
|
void CObjComponent::Ini()
|
|
|
|
|
{
|
|
|
|
|
m_bBase = false;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA>Ԫ<D7BC><D4AA>
|
|
|
|
|
m_bSel = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ѡ<EFBFBD><D1A1>
|
|
|
|
|
m_TempIdx = 0;//ʹ<>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_bMarked = false;//<2F>Ƿӹ<F1B1BBBC><D3B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
m_bCollected = false;
|
|
|
|
|
m_bCircle = false;//<2F>Ƿ<EFBFBD>ΪԲ<CEAA><D4B2>
|
|
|
|
|
m_bMarkObj = false;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ǵ<EFBFBD>obj
|
|
|
|
|
m_bMarkSidewardObj = false;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>obj <20>Աߵ<D4B1>obj
|
|
|
|
|
m_ColorIdx = -1;//<2F><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
m_ObjMarkIdx = -1;//obj <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<C7B7>
|
|
|
|
|
m_bAutoCreatObj = false;//<2F>Ƿ<EFBFBD>Ϊ<EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>obj
|
|
|
|
|
m_ObjLineIdx = 0;//obj <20><>line <20>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ֵ,<2C><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>line <20><>obj <20>Ĺ<EFBFBD>ϵ
|
|
|
|
|
m_bView = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڹ۲<DAB9>
|
|
|
|
|
m_bViewed = false;//<2F>Ƿ۲<F1B1BBB9><DBB2><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_bCollecteData = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD>ռ<EFBFBD><D5BC>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>(false <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
|
|
|
|
m_bHide = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
m_bMark3Obj = false;//<2F>Ƿ<EFBFBD>Ϊmark3
|
|
|
|
|
}
|
|
|
|
|
CObjComponent::~CObjComponent(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
DbRect CObjComponent::GetRect()
|
|
|
|
|
{
|
|
|
|
|
DbRect rect(m_BasePt,m_Size);
|
|
|
|
|
return rect;
|
|
|
|
|
}
|
|
|
|
|
void CObjComponent::Draw(CDC* pDC)
|
|
|
|
|
{
|
|
|
|
|
if(m_bHide)
|
|
|
|
|
return;
|
|
|
|
|
//<2F><>ɫ-----------------------------------------------
|
|
|
|
|
COLORREF c;
|
|
|
|
|
if(m_bSel)//ѡ<><D1A1>״̬
|
|
|
|
|
{
|
|
|
|
|
c = gObjComponentMgr->GetSelColor();
|
|
|
|
|
}
|
|
|
|
|
else if(!m_bCollecteData)//<2F><><EFBFBD>ӹ<EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
c = RGB_GRAY1;
|
|
|
|
|
}
|
|
|
|
|
else if(m_bMarked)//<2F><><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
c = gObjComponentMgr->GetViewedObjColor();
|
|
|
|
|
}
|
|
|
|
|
else//<2F><>ͨ״̬
|
|
|
|
|
{
|
|
|
|
|
if(IsbSpecialObj())//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
c = RGB_BLUE1;
|
|
|
|
|
else
|
|
|
|
|
c = gObjComponentMgr->GetNoSelColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>-------------------------------------------------
|
|
|
|
|
Dbxy pt = m_BasePt;
|
|
|
|
|
DbSize size = m_Size;
|
|
|
|
|
DbRect rect = GetRect();
|
|
|
|
|
double Gap = 0.5;
|
|
|
|
|
rect.L -= Gap;
|
|
|
|
|
rect.R += Gap;
|
|
|
|
|
rect.T += Gap;
|
|
|
|
|
rect.B -= Gap;
|
|
|
|
|
|
|
|
|
|
if(gObjComponentMgr->IsbShowRealObj())
|
|
|
|
|
{
|
|
|
|
|
pt = m_RealBasePt;
|
|
|
|
|
size.w = size.h = 1;
|
|
|
|
|
DbRect RealRect(pt,size);
|
|
|
|
|
rect = RealRect;
|
|
|
|
|
}
|
|
|
|
|
if(gObjComponentMgr->IsDrawFillColor())
|
|
|
|
|
{
|
|
|
|
|
if(m_bCircle)
|
|
|
|
|
{
|
|
|
|
|
DrawSolidCircle(pDC,c,pt,(size.w+Gap)/2);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawSolidRect(pDC,c,rect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CPen pen;
|
|
|
|
|
pen.CreatePen(PS_INSIDEFRAME,1,c);
|
|
|
|
|
if(m_bCircle)
|
|
|
|
|
{
|
|
|
|
|
DrawCircle(pDC,pen,pt,(size.w+Gap)/2,50);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DrawRect(pDC,pen,rect,false);
|
|
|
|
|
}
|
|
|
|
|
pen.DeleteObject();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(m_bMarkObj || m_bMark3Obj)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mark obj <20><><EFBFBD>м仭һ<E4BBAD><D2BB>ʮ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
{
|
|
|
|
|
CPen pen;
|
|
|
|
|
pen.CreatePen(PS_INSIDEFRAME,1,RGB_RED);
|
|
|
|
|
XorDrawCross(pDC,false,pen,pt,size.w*4);
|
|
|
|
|
pen.DeleteObject();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
COLORREF CObjComponent::GetObjColorByIdx(int Idx)
|
|
|
|
|
{
|
|
|
|
|
COLORREF c = RGB_GREEN;
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
int r = GetRValue(c)+30*Idx;
|
|
|
|
|
int g = GetGValue(c)+30*Idx;
|
|
|
|
|
int b = GetBValue(c)+30*Idx;
|
|
|
|
|
COLORREF Color = RGB(r,g,b);
|
|
|
|
|
return Color;
|
|
|
|
|
}
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Χ(bCenterIn <20><>ʾ<EFBFBD><CABE><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>rect <20><>Χ<EFBFBD><CEA7>)
|
|
|
|
|
bool CObjComponent::IsInRect(DbRect rect,bool bCenterIn)
|
|
|
|
|
{
|
|
|
|
|
if(bCenterIn && !m_bCollecteData)//<2F>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
DbRect ObjRect = GetRect();
|
|
|
|
|
bool ret;
|
|
|
|
|
if(bCenterIn)
|
|
|
|
|
ret = IsPointInRect(ObjRect.GetCenterPt(),rect);//obj <20><><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rect <20><>
|
|
|
|
|
else
|
|
|
|
|
ret = IsTwoRectIntersect(ObjRect,rect)||IsTwoRectIntersect(rect,ObjRect);//<2F>ҵ<EFBFBD>obj <20>ı߾<C4B1><DFBE><EFBFBD>
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
//<2F>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(Ŀǰ<C4BF><C7B0><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD>)
|
|
|
|
|
void CObjComponent::CollectWorkData(DbRect &rect,vector<vector<Dbxy>> &vec)
|
|
|
|
|
{
|
|
|
|
|
if(!m_bCollecteData)
|
|
|
|
|
return;
|
|
|
|
|
if(m_bCollected)//<2F><>Ҫ<EFBFBD>ظ<EFBFBD><D8B8>ռ<EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>Χ
|
|
|
|
|
if(!IsInRect(rect,true))//<2F>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD>ݵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD>ж<EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//<2F>Ż<EFBFBD><C5BB>ٶ<EFBFBD>
|
|
|
|
|
int MarkCnt = 0;
|
|
|
|
|
if(gCommonFlowMgr->IsbCollectSpecialObj())//<2F>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(!IsbSpecialObj())//<2F><><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
MarkCnt = gCommonFlowMgr->GetSpecialOneObjMarkCnt();
|
|
|
|
|
}
|
|
|
|
|
else//<2F><>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
MarkCnt = gCommonFlowMgr->GetOneObjMarkCnt();//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjShapeVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjShapeVec.end();
|
|
|
|
|
{
|
|
|
|
|
for(int k=0;k<MarkCnt;k++)
|
|
|
|
|
{
|
|
|
|
|
(*iter)->GetPtData(vec);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!IsbSpecialObj())//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
|
|
|
|
m_bCollected = true;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>mark <20><><EFBFBD><EFBFBD>
|
|
|
|
|
void CObjComponent::SetObjMarkIdx(bool b)
|
|
|
|
|
{
|
|
|
|
|
m_ObjMarkIdx = b?1:2;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>Ӱ<D3B0>layer obj
|
|
|
|
|
void CObjComponent::AddObjShape(Sptr<CObjBase> p)
|
|
|
|
|
{
|
|
|
|
|
m_ObjShapeVec.push_back(p);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>״̬
|
|
|
|
|
void CObjComponent::SetSelected(bool b)
|
|
|
|
|
{
|
|
|
|
|
m_bSel = b;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD>ð<EFBFBD><C3B0><EFBFBD>layer obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
void CObjComponent::SetShapeLockState(bool b)
|
|
|
|
|
{
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjShapeVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjShapeVec.end();
|
|
|
|
|
{
|
|
|
|
|
(*iter)->SetLock(b);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//bMoveObjShape<70>Ƿ<EFBFBD><C7B7>ƶ<EFBFBD><C6B6><EFBFBD>ͼ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD>
|
|
|
|
|
void CObjComponent::OnMove(Dbxy Offset,bool bMoveObjShape)
|
|
|
|
|
{
|
|
|
|
|
m_BasePt.x += Offset.x;
|
|
|
|
|
m_BasePt.y += Offset.y;
|
|
|
|
|
if(bMoveObjShape)
|
|
|
|
|
{
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjShapeVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjShapeVec.end();
|
|
|
|
|
{
|
|
|
|
|
SObjOperatePar par;
|
|
|
|
|
par.OpType = _OP_MOVE;
|
|
|
|
|
par.MoveX = Offset.x;
|
|
|
|
|
par.MoveY = Offset.y;
|
|
|
|
|
(*iter)->Operate(par);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ıʺ<C4B1>
|
|
|
|
|
void CObjComponent::SetSelObjPenNum()
|
|
|
|
|
{
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjShapeVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjShapeVec.end();
|
|
|
|
|
{
|
|
|
|
|
if((*iter)->GetPenNum() == 0)
|
|
|
|
|
(*iter)->SetPenNum(1);
|
|
|
|
|
else
|
|
|
|
|
(*iter)->SetPenNum(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//obj <20>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool CObjComponent::IsbSpecialObj()
|
|
|
|
|
{
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter = m_ObjShapeVec.begin();
|
|
|
|
|
vector<Sptr<CObjBase>>::iterator iter_end = m_ObjShapeVec.end();
|
|
|
|
|
{
|
|
|
|
|
if((*iter)->GetPenNum() == 0)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|