114 lines
2.3 KiB
C++
114 lines
2.3 KiB
C++
#include "stdafx.h"
|
|
#include "TParallelDimJig.h"
|
|
|
|
|
|
CTParallelDimJig::~CTParallelDimJig(void)
|
|
{
|
|
}
|
|
|
|
CTParallelDimJig::CTParallelDimJig(TDbDimension2 *pDim, const TADSGePointList& lstPts)
|
|
{
|
|
m_pDim = pDim;
|
|
m_bFlag = 1;
|
|
m_bAppend = FALSE;
|
|
m_lstPts.copyFrom(lstPts);
|
|
int nLen = m_lstPts.Length();
|
|
for(int n = 0; n < nLen; n++)
|
|
{
|
|
m_pDim->AddSegment(*m_lstPts[n]);
|
|
}
|
|
m_pDim->SetFixLinePos(*m_lstPts[0]);
|
|
}
|
|
|
|
AcEdJig::DragStatus CTParallelDimJig::doIt()
|
|
{
|
|
setDispPrompt(_T("\n请点取尺寸线位置<退出>:"));
|
|
DragStatus stat = drag();
|
|
return stat;
|
|
}
|
|
|
|
AcEdJig::DragStatus CTParallelDimJig::sampler()
|
|
{
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
|
|
|
XPoint ptCursor;
|
|
DragStatus stat = acquirePoint(ptCursor);
|
|
if(stat == AcEdJig::kNormal)
|
|
{
|
|
if (ptCursor.Distance2d(m_ptDim) > _DIST_SNAP)
|
|
m_ptDim = ptCursor;
|
|
else
|
|
stat = AcEdJig::kNoChange;
|
|
}
|
|
return stat;
|
|
}
|
|
|
|
Adesk::Boolean CTParallelDimJig::update()
|
|
{
|
|
int nLen = 0, n = 0;
|
|
if (m_bAppend)
|
|
{
|
|
m_bAppend = FALSE;
|
|
int ncount = m_pDim->GetSegmentNum();
|
|
while(m_pDim->GetSegmentNum() > 0)
|
|
m_pDim->RemoveSegment(0);
|
|
|
|
m_pDim->SetLocation(*m_lstPts[0]);
|
|
|
|
nLen = m_lstPts.Length();
|
|
for(n = 0; n < nLen; n++)
|
|
{
|
|
m_pDim->AddSegment(*m_lstPts[n]);
|
|
}
|
|
TADSGePoint3d ptEnd=*m_lstPts[m_lstPts.Length()-1],ptStart=*m_lstPts[0];
|
|
XVector3D vt=ptEnd-ptStart;
|
|
m_pDim->getStartPoint(ptStart);
|
|
m_pDim->getEndPoint(ptEnd);
|
|
|
|
}
|
|
|
|
XPoint ptOnSeg;
|
|
TGGeCurveSegment seg;
|
|
seg = m_pDim->GetDimCurve();
|
|
if(seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
|
{
|
|
double nDistMove = ptOnSeg.Distance2d(m_ptDim);
|
|
int nSideLoc = seg.OnWhichSide(m_pDim->GetLocation());
|
|
int nSide = seg.OnWhichSide(m_ptDim);
|
|
double nDist2Dim = m_pDim->GetDist2DimLine(FALSE);
|
|
double nFactor = nDist2Dim/fabs(nDist2Dim);
|
|
if(fabs(nDist2Dim) > 1.0E-6)
|
|
{
|
|
if(nSide != nSideLoc)
|
|
{
|
|
nDistMove *= nFactor;
|
|
}
|
|
else
|
|
{
|
|
nDistMove *= -nFactor;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(nSideLoc == OFFSET_LEFT)
|
|
nDistMove *= -1;
|
|
}
|
|
nDist2Dim += nDistMove;
|
|
m_pDim->SetDist2DimLine(nDist2Dim, FALSE);
|
|
double ddis = m_pDim->GetPScale() * 8;
|
|
if(nDist2Dim >= 0)
|
|
nDist2Dim += ddis;
|
|
else
|
|
nDist2Dim -= ddis;
|
|
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcDbEntity* CTParallelDimJig::entity() const
|
|
{
|
|
return (AcDbEntity*)m_pDim;
|
|
}
|
|
|