118 lines
2.7 KiB
C++
118 lines
2.7 KiB
C++
#include "stdafx.h"
|
|
#include "KTJigSkirt.h"
|
|
#include "KTObjLifeMgr.h"
|
|
|
|
KTJigSkirt::KTJigSkirt()
|
|
: m_pEdge1(NULL), m_pEdge2(NULL), m_pBase(NULL)
|
|
{
|
|
}
|
|
|
|
KTJigSkirt::~KTJigSkirt()
|
|
{
|
|
}
|
|
|
|
BOOL KTJigSkirt::DragCreate(const AcGePoint3d& ptBase, const AcGeVector3d& vtEdge, const AcGeVector3d& vtNormal,
|
|
LPCTSTR pszPrompt, const AcDbObjectId& idLayer, AcDbVoidPtrArray& arpEnt)
|
|
{
|
|
ASSERT(!vtEdge.isZeroLength() && !vtNormal.isZeroLength() && !vtEdge.isCodirectionalTo(vtNormal));
|
|
|
|
AcGeVector3d vtPerp(vtNormal.crossProduct(vtEdge));
|
|
m_ptLast = ptBase + vtEdge;
|
|
|
|
AcGePoint3d pt1 = ptBase + vtPerp;
|
|
AcDbLine* pEdge1 = new AcDbLine(ptBase, pt1);
|
|
if (NULL == pEdge1)
|
|
return FALSE;
|
|
|
|
CKTObjLifeMgr entMgr;
|
|
entMgr.Add(pEdge1);
|
|
pEdge1->setLayer(idLayer);
|
|
m_cDumbEntity.m_arpEntity.append(pEdge1);
|
|
|
|
AcGePoint3d pt2 = m_ptLast + vtPerp;
|
|
AcDbLine* pEdge2 = new AcDbLine(m_ptLast, pt2);
|
|
if (NULL == pEdge2)
|
|
return FALSE;
|
|
|
|
entMgr.Add(pEdge2);
|
|
pEdge2->setLayer(idLayer);
|
|
m_cDumbEntity.m_arpEntity.append(pEdge2);
|
|
|
|
AcGeVector3d vt(vtEdge.normal() * 0.25);
|
|
AcDbLine* pBase = new AcDbLine(pt1 - vt, pt2 + vt);
|
|
if (NULL == pBase)
|
|
return FALSE;
|
|
|
|
entMgr.Add(pBase);
|
|
pBase->setLayer(idLayer);
|
|
m_cDumbEntity.m_arpEntity.append(pBase);
|
|
|
|
if (NULL != pszPrompt)
|
|
setDispPrompt(pszPrompt);
|
|
|
|
ASSERT(NULL == m_pEdge1 && NULL == m_pEdge2 && NULL == m_pBase);
|
|
m_pEdge1 = pEdge1;
|
|
m_pEdge2 = pEdge2;
|
|
m_pBase = pBase;
|
|
BOOL bError = (AcEdJig::kNormal != drag());
|
|
m_pEdge1 = NULL;
|
|
m_pEdge2 = NULL;
|
|
m_pBase = NULL;
|
|
|
|
if (bError)
|
|
return FALSE;
|
|
|
|
arpEnt.append(pEdge1);
|
|
arpEnt.append(pEdge2);
|
|
arpEnt.append(pBase);
|
|
|
|
entMgr.Remove();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
AcEdJig::DragStatus KTJigSkirt::sampler()
|
|
{
|
|
setUserInputControls((UserInputControls)(kAccept3dCoordinates | kNullResponseAccepted | kDontUpdateLastPoint));
|
|
|
|
AcGePoint3d ptDynamic;
|
|
AcEdJig::DragStatus eStatus = acquirePoint(ptDynamic);
|
|
if (AcEdJig::kNormal != eStatus)
|
|
return eStatus;
|
|
|
|
if (m_ptLast == ptDynamic)
|
|
return AcEdJig::kNoChange;
|
|
|
|
m_ptLast = ptDynamic;
|
|
|
|
AcGePoint3d pt1(m_pEdge1->startPoint()), pt2(m_pEdge1->endPoint()),
|
|
pt3(m_pEdge2->startPoint()), pt4(m_pEdge2->endPoint());
|
|
|
|
AcGeLine3d line1(pt1, pt2);
|
|
AcGeLine3d line2(ptDynamic, pt3 - pt1);
|
|
|
|
AcGePoint3d ptInt;
|
|
if (!line1.intersectWith(line2, ptInt) || ptInt == pt2 || pt1 == ptInt)
|
|
return AcEdJig::kNoChange;
|
|
|
|
AcGeVector3d vtOff(ptInt - pt2);
|
|
|
|
m_pEdge1->setEndPoint(ptInt);
|
|
m_pEdge2->setEndPoint(pt4 + vtOff);
|
|
|
|
m_pBase->setStartPoint(m_pBase->startPoint() + vtOff);
|
|
m_pBase->setEndPoint(m_pBase->endPoint() + vtOff);
|
|
|
|
return eStatus;
|
|
}
|
|
|
|
Adesk::Boolean KTJigSkirt::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcDbEntity* KTJigSkirt::entity() const
|
|
{
|
|
return (AcDbEntity*)&m_cDumbEntity;
|
|
}
|