Files
envi-code/SourceCode/Code2026/PIDLineCmd/KTSideJig.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

118 lines
2.3 KiB
C++

#include "stdafx.h"
#include "KTSideJig.h"
#include "KTObjLifeMgr.h"
KTSideJig::KTSideJig()
{
}
KTSideJig::~KTSideJig()
{
}
BOOL KTSideJig::DragCreate(AcGePoint3dArray& pts, double dTextH,double dTextW,CStringArray &stexts,
int ntype,LPCTSTR pszPrompt,AcDbObjectId idSt,AcDbObjectId idLayer, AcDbVoidPtrArray& arpEnt)
{
m_ntype=ntype;
m_pts.append(pts);
m_idTextS=idSt;
m_idTextL=idLayer;
m_sTexts.Append(stexts);
m_ptFirst=pts.at(0);
m_dTextH=dTextH;
m_dTextW=dTextW;
CKTObjLifeMgr entMgr;
if (NULL != pszPrompt)
setDispPrompt(pszPrompt);
BOOL bError = (AcEdJig::kNormal != drag());
entMgr.Add(m_pTexts);
if (bError)
return FALSE;
arpEnt.append(m_pTexts);
entMgr.Remove();
m_pts.setLogicalLength(0);
return TRUE;
}
AcEdJig::DragStatus KTSideJig::sampler()
{
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates
| AcEdJig::kNoNegativeResponseAccepted | AcEdJig::kNoZeroResponseAccepted));
AcEdJig::DragStatus eStatus = acquirePoint(m_ptDynamic);
if (AcEdJig::kNormal != eStatus)
return eStatus;
if (m_ptLast == m_ptDynamic)
return kNoChange;
return eStatus;
}
Adesk::Boolean KTSideJig::update()
{
if (m_ptLast == m_ptDynamic)
return Adesk::kTrue;
//移除上次的数据
m_cDumbEntity.m_arpEntity.setLogicalLength(0);
int i=0;
i = m_pTexts.length();
while ((--i) >= 0)
delete ((AcDbEntity*)m_pTexts[i]);
m_pTexts.setLogicalLength(0);
int nl=m_pts.logicalLength();
AcGePoint3d pttemp;
AcGeVector3d vtemp,vNormal;
vtemp=AcGeVector3d::kXAxis;
if (1 == m_ntype)
{
vtemp=AcGeVector3d::kYAxis;
}
AcGePlane plane;
for (int j=0;j<nl;j++)
{
vNormal= vtemp.crossProduct(AcGeVector3d::kZAxis);
plane.set(m_pts.at(j),vNormal);
pttemp = m_ptDynamic.orthoProject(plane);
AcDbMText * ptextu= new AcDbMText();
ptextu->setTextStyle(m_idTextS);
ptextu->setTextHeight(m_dTextH);
ptextu->setLayer(m_idTextL);
ptextu->setContents(m_sTexts.GetAt(j));
ptextu->setAttachment(AcDbMText::kBottomCenter);
if (1 == m_ntype)
{
ptextu->setRotation(PI_2);
}
else
{
ptextu->setRotation(0);
}
ptextu->setLocation(pttemp);
m_cDumbEntity.m_arpEntity.append(ptextu);
m_pTexts.append(ptextu);
}
m_ptLast = m_ptDynamic;
return Adesk::kTrue;
}
AcDbEntity* KTSideJig::entity() const
{
return (AcDbEntity*)&m_cDumbEntity;
}