101 lines
2.3 KiB
C++
101 lines
2.3 KiB
C++
// LeaderEdjig.cpp: implementation of the CLeaderEdjig class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "stdafx.h"
|
|
#include "LeaderEdjig.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
TLeaderEdJig::TLeaderEdJig(TDbSymbMultiLeader *pElev)
|
|
{
|
|
m_nOperCode = TLeaderEdJig::kNone;
|
|
m_pDrawEnt = pElev;
|
|
}
|
|
|
|
XPoint TLeaderEdJig::GetDragPoint() const
|
|
{
|
|
XPoint ptDrag = m_ptResult;
|
|
if(m_nOperCode == TLeaderEdJig::kLeader)
|
|
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
|
else if(m_nOperCode == TLeaderEdJig::kTextLine)
|
|
ptDrag = m_pDrawEnt->GetTextBasePoint();
|
|
return ptDrag;
|
|
}
|
|
|
|
XPoint TLeaderEdJig::GetBasePoint() const
|
|
{
|
|
XPoint ptDrag = m_ptResult;
|
|
if(m_nOperCode == TLeaderEdJig::kLeader) {
|
|
XPointList pts;
|
|
m_pDrawEnt->GetLeaderVertexes(pts);
|
|
if(pts.Length())
|
|
ptDrag = *pts[0];
|
|
} else {
|
|
ptDrag = m_pDrawEnt->GetLeaderPoint();
|
|
}
|
|
return ptDrag;
|
|
}
|
|
|
|
|
|
// 开始执行拖动
|
|
int TLeaderEdJig::DoIt(int *keyIndex)
|
|
{
|
|
m_ptResult=GetDragPoint();
|
|
|
|
XPushVar<int> osmode(_T("OSMODE"), 0);
|
|
return TSymbEdJig::DoIt(keyIndex);
|
|
}
|
|
|
|
// 反馈
|
|
AcEdJig::DragStatus
|
|
TLeaderEdJig::GetPoint(XPoint &pt)
|
|
{
|
|
DragStatus stat;
|
|
if(m_nOperCode == kTextLine)
|
|
{
|
|
stat = acquirePoint(pt);
|
|
}
|
|
else
|
|
{
|
|
stat = acquirePoint(pt, GetBasePoint().AsAcGePoint3d());
|
|
}
|
|
return stat;
|
|
}
|
|
|
|
|
|
// 更新实体数据
|
|
Adesk::Boolean TLeaderEdJig::update()
|
|
{
|
|
Adesk::Boolean bRet = Adesk::kTrue;
|
|
if(m_nOperCode == TLeaderEdJig::kLeader)
|
|
{
|
|
XVector3D vtOffset = m_ptResult - GetBasePoint();
|
|
m_pDrawEnt->SetLeaderPoint(m_ptResult);
|
|
if(vtOffset.x < 0.0)
|
|
m_pDrawEnt->SetTextBaseLen(-fabs(m_pDrawEnt->GetTextBaseLen()));
|
|
else
|
|
m_pDrawEnt->SetTextBaseLen(fabs(m_pDrawEnt->GetTextBaseLen()));
|
|
}
|
|
else if(m_nOperCode == TLeaderEdJig::kVertex)
|
|
{
|
|
}
|
|
else if(m_nOperCode == TLeaderEdJig::kTextLine)
|
|
{
|
|
XPoint ptLeader = m_pDrawEnt->GetLeaderPoint();
|
|
m_pDrawEnt->SetTextBaseLen(m_ptResult.x - ptLeader.x, FALSE);
|
|
}
|
|
//m_pDrawEnt->SetText2BaseRatio(m_pDrawEnt->GetText2BaseRatio());//ZXL 2012.08.28 ADD
|
|
return bRet;
|
|
}
|
|
|
|
AcDbEntity* TLeaderEdJig::entity() const
|
|
{
|
|
return (AcDbEntity *)m_pDrawEnt;
|
|
}
|
|
|