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

110 lines
2.4 KiB
C++

#include "StdAfx.h"
#include "EquInsDirJig.h"
CEquInsDirJig::CEquInsDirJig()
{
m_dAngle = 0.0;
m_pPolyline = new AcDbPolyline();
m_pPolyline->reset(false, 0);
}
CEquInsDirJig::~CEquInsDirJig ()
{
delete m_pPolyline;
}
void CEquInsDirJig::SetEqu(AcDbEntity* pEqu, const AcGePoint3d &ptBase)
{
m_ptBase = ptBase;
double w(1000), h(500);
if (pEqu)
{
AcDbExtents ext;
pEqu->getGeomExtents(ext);
AcGePoint3d ptMax(ext.maxPoint()), ptMin(ext.minPoint());
w = (ext.maxPoint().x - ext.minPoint().x) * .5;
h = (ext.maxPoint().y - ext.minPoint().y) * .5;
}
AcGePoint2d pt0(-w, -h), pt1(-w, h), pt2(w, h), pt3(w, -h);
m_pPolyline->addVertexAt(0, pt0);
m_pPolyline->addVertexAt(1, pt1);
m_pPolyline->addVertexAt(2, pt2);
m_pPolyline->addVertexAt(3, pt3);
m_pPolyline->setClosed(true);
AcGeMatrix3d mat;
mat.setToTranslation(ptBase - AcGePoint3d::kOrigin);
m_pPolyline->transformBy(mat);
}
BOOL CEquInsDirJig::DoIt()
{
AcEdJig::DragStatus eStat;
setDispPrompt(_T("\n指定设备元件插入的角度方向:"));
eStat = drag();
if (eStat == AcEdJig::kNormal)
{
return TRUE;
}
return FALSE;
}
AcEdJig::DragStatus CEquInsDirJig::sampler()
{
setUserInputControls( ( UserInputControls)
( AcEdJig::kAccept3dCoordinates |
AcEdJig::kNullResponseAccepted ) );
static double dAngle2 = 0.0;
AcEdJig::DragStatus eStat;
eStat = acquireAngle(m_dAngle,m_ptBase);
if (eStat == AcEdJig::kNormal)
{
if ( fabs(dAngle2 - m_dAngle) < 1.e-3)
{
//鼠标原地不动
return AcEdJig::kNoChange;
}
dAngle2 = m_dAngle;
AcGeVector3d vtX = AcGeVector3d::kXAxis;
vtX.rotateBy(m_dAngle,AcGeVector3d::kZAxis);
AcGeVector3d vtY = vtX;
vtY.rotateBy(PI * .5, AcGeVector3d::kZAxis);
m_pPolyline->reset(false, 0);
double w(1000), h(500);
AcGePoint3d pt0(m_ptBase);
pt0 -= vtX * .5 * w;
pt0 -= vtY * .5 * h;
AcGePoint3d pt1 = pt0 + vtY * h
, pt2 = pt1 + vtX * w
, pt3 = pt2 - vtY * h;
m_pPolyline->addVertexAt(0, pt0.convert2d(AcGePlane::kXYPlane));
m_pPolyline->addVertexAt(1, pt1.convert2d(AcGePlane::kXYPlane));
m_pPolyline->addVertexAt(2, pt2.convert2d(AcGePlane::kXYPlane));
m_pPolyline->addVertexAt(3, pt3.convert2d(AcGePlane::kXYPlane));
m_pPolyline->setClosed(true);
return AcEdJig::kNormal;
}
return eStat;
}
AcDbEntity* CEquInsDirJig::entity() const
{
return m_pPolyline;
//return m_pEqu;
}
Adesk::Boolean CEquInsDirJig::update()
{
return Adesk::kTrue;
}