2026-10-04 00:04:20 +08:00
|
|
|
#include "StdAfx.h"
|
2026-09-28 15:28:50 +08:00
|
|
|
#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;
|
2026-10-04 00:04:20 +08:00
|
|
|
setDispPrompt(_T("\n指定设备元件插入的角度方向:"));
|
2026-09-28 15:28:50 +08:00
|
|
|
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)
|
|
|
|
|
{
|
2026-10-04 00:04:20 +08:00
|
|
|
//鼠标原地不动
|
2026-09-28 15:28:50 +08:00
|
|
|
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;
|
|
|
|
|
}
|