302 lines
5.6 KiB
C++
302 lines
5.6 KiB
C++
#include "StdAfx.h"
|
|
#include "aecSectionDirJig.h"
|
|
#include "EarThwormDef.h"
|
|
|
|
extern AcGePoint3d MidPoint(AcGePoint3d& pt1,AcGePoint3d& pt2);
|
|
|
|
AecSectionDirEntity::AecSectionDirEntity()
|
|
{
|
|
m_vtNorm.set(0,0,0);
|
|
}
|
|
|
|
AecSectionDirEntity::~AecSectionDirEntity()
|
|
{}
|
|
|
|
void AecSectionDirEntity::SetDirToPoint(AcGePoint3d& ptTo2)
|
|
{
|
|
m_ptTo2 = ptTo2;
|
|
}
|
|
|
|
void AecSectionDirEntity::SetBasePoint(AcGePoint3d& ptFr,AcGePoint3d& ptTo)
|
|
{
|
|
m_ptFr = ptFr;
|
|
m_ptTo = ptTo;
|
|
}
|
|
|
|
void AecSectionDirEntity::SetBasePoint(AcGePoint3d& ptFr,AcGePoint3d& ptTo,AcGeVector3d& vtNorm)
|
|
{
|
|
m_ptFr = ptFr;
|
|
m_ptTo = ptTo;
|
|
m_vtNorm = vtNorm;
|
|
m_vtDirSel = m_vtNorm;
|
|
}
|
|
|
|
#if ARX < 18
|
|
Adesk::Boolean AecSectionDirEntity::worldDraw (AcGiWorldDraw *mode)
|
|
{
|
|
return worldDraw2d(mode);
|
|
}
|
|
#else
|
|
Adesk::Boolean AecSectionDirEntity::subWorldDraw (AcGiWorldDraw *mode)
|
|
{
|
|
return worldDraw2d(mode);
|
|
}
|
|
#endif
|
|
|
|
Adesk::Boolean AecSectionDirEntity::worldDraw2d(AcGiWorldDraw *mode)
|
|
{
|
|
AcGePoint3d ptGe[5];
|
|
ptGe[0] = m_ptFr;
|
|
ptGe[1] = m_ptTo;
|
|
|
|
if ( !m_vtNorm.isZeroLength())
|
|
{
|
|
AcGeVector3d vtX = m_vtNorm;
|
|
vtX.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGePoint3d ptMid = MidPoint(m_ptFr,m_ptTo);
|
|
AcGeVector3d vtLn = m_ptTo - m_ptFr;
|
|
|
|
AcGeVector3d vtTest = m_ptTo2 - ptMid;
|
|
|
|
double dAngN = vtTest.angleTo(vtLn);
|
|
|
|
if (dAngN > PI / 4.0 )//靠经m_vtNorm > 45度
|
|
{
|
|
AcGePlane plan;
|
|
plan.set(m_ptTo2,m_vtNorm);
|
|
|
|
AcGePoint3d ptFr2 = plan.closestPointTo(m_ptFr);
|
|
AcGePoint3d ptTo2 = plan.closestPointTo(m_ptTo);
|
|
|
|
ptGe[2] = ptTo2;
|
|
ptGe[3] = ptFr2;
|
|
ptGe[4] = ptGe[0];
|
|
mode->geometry().polyline(5,ptGe);
|
|
|
|
m_vtDirSel = ptFr2 - m_ptFr;
|
|
}
|
|
else//靠经X
|
|
{
|
|
AcGePlane plan;
|
|
plan.set(m_ptTo2,vtX);
|
|
|
|
AcGePoint3d ptFr2 = plan.closestPointTo(m_ptFr);
|
|
AcGePoint3d ptTo2 = plan.closestPointTo(m_ptTo);
|
|
|
|
ptGe[2] = ptTo2;
|
|
ptGe[3] = ptFr2;
|
|
ptGe[4] = ptGe[0];
|
|
mode->geometry().polyline(5,ptGe);
|
|
|
|
m_vtDirSel = ptFr2 - m_ptFr;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGeLine3d ln(m_ptFr,m_ptTo);
|
|
AcGePoint3d ptTo2 = ln.closestPointTo(m_ptTo2);
|
|
|
|
AcGeVector3d vt = m_ptTo2 - ptTo2;
|
|
ptGe[2] = m_ptTo + vt;
|
|
ptGe[3] = m_ptFr + vt;
|
|
ptGe[4] = ptGe[0];
|
|
mode->geometry().polyline(5,ptGe);
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AecSectionDirJig::AecSectionDirJig(void)
|
|
{
|
|
m_pEnt = NULL;
|
|
m_vtNorm.set(0,0,0);
|
|
m_bSlice = false;
|
|
}
|
|
|
|
AecSectionDirJig::~AecSectionDirJig(void)
|
|
{
|
|
if (m_pEnt != NULL)
|
|
DELETE_PTR(m_pEnt);
|
|
}
|
|
|
|
void AecSectionDirJig::SetSectionLine(ads_point ptFr,ads_point ptTo)
|
|
{
|
|
ads_point ptFr1,ptTo1;
|
|
acdbUcs2Wcs(ptFr,ptFr1,false);
|
|
acdbUcs2Wcs(ptTo,ptTo1,false);
|
|
m_ptFr = asPnt3d(ptFr1);
|
|
m_ptTo = asPnt3d(ptTo1);
|
|
m_vtNorm.set(0,0,0);
|
|
}
|
|
|
|
void AecSectionDirJig::SetSectionLine(ads_point ptFr,ads_point ptTo,const AcGeVector3d& vtNorm)
|
|
{
|
|
ads_point ptFr1,ptTo1;
|
|
acdbUcs2Wcs(ptFr,ptFr1,false);
|
|
acdbUcs2Wcs(ptTo,ptTo1,false);
|
|
m_ptFr = asPnt3d(ptFr1);
|
|
m_ptTo = asPnt3d(ptTo1);
|
|
m_vtNorm = vtNorm;
|
|
}
|
|
|
|
BOOL AecSectionDirJig::DoIt(LPCTSTR pszPrompt)
|
|
{
|
|
if (m_pEnt != NULL)
|
|
DELETE_PTR(m_pEnt);
|
|
m_pEnt = new AecSectionDirEntity;
|
|
m_pEnt->SetBasePoint(m_ptFr,m_ptTo,m_vtNorm);
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
|
|
if (pszPrompt == NULL)
|
|
setDispPrompt(_T("\n请指定剖面的范围方向[不选范围仅仅切面(S)]:"));
|
|
else
|
|
setDispPrompt(pszPrompt);
|
|
|
|
eStat = drag();
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
return TRUE;
|
|
}
|
|
else if (eStat == AcEdJig::kKW1)
|
|
{
|
|
m_ptTo2 = MidPoint(m_ptFr,m_ptTo);
|
|
m_bSlice = true;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
AcEdJig::DragStatus AecSectionDirJig::sampler()
|
|
{
|
|
setUserInputControls( ( UserInputControls)
|
|
( AcEdJig::kAccept3dCoordinates |
|
|
AcEdJig::kNullResponseAccepted ) );
|
|
|
|
setKeywordList(_T("S"));
|
|
|
|
static AcGePoint3d ptMid,ptTo2;
|
|
ptMid.set( (m_ptFr.x + m_ptTo.x ) / 2.0,(m_ptFr.y + m_ptTo.y ) / 2.0,(m_ptFr.z + m_ptTo.z ) / 2.0);
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
eStat = acquirePoint(m_ptTo2,ptMid);
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
if ( ptTo2.isEqualTo(m_ptTo2))
|
|
{
|
|
//鼠标原地不动
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
ptTo2 = m_ptTo2;
|
|
m_pEnt->SetDirToPoint(ptTo2);
|
|
}
|
|
return eStat;
|
|
}
|
|
|
|
AcDbEntity* AecSectionDirJig::entity() const
|
|
{
|
|
return m_pEnt;
|
|
}
|
|
|
|
Adesk::Boolean AecSectionDirJig::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
void AecSectionDirJig::GetDirPoint(AcGePoint3d& ptDirTo) const
|
|
{
|
|
ptDirTo = m_ptTo2;
|
|
}
|
|
|
|
bool AecSectionDirJig::GetDir(AcGeVector3d& vtDir) const
|
|
{
|
|
if (m_pEnt != NULL)
|
|
{
|
|
vtDir = m_pEnt->m_vtDirSel;
|
|
}
|
|
return m_bSlice;
|
|
}
|
|
|
|
AecSectionPosJig::AecSectionPosJig(void)
|
|
{
|
|
m_pEnt = NULL;
|
|
m_ptTo.set(0.0,0.0,0.0);
|
|
}
|
|
|
|
AecSectionPosJig::~AecSectionPosJig(void)
|
|
{
|
|
}
|
|
|
|
BOOL AecSectionPosJig::DoIt()
|
|
{
|
|
if (m_pEnt != NULL)
|
|
DELETE_PTR(m_pEnt);
|
|
m_pEnt = new AecSectionDirEntity;
|
|
//m_pEnt->SetDirToPoint(m_ptTo);
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
setDispPrompt(_T("\n请指定视图的放置位置:"));
|
|
eStat = drag();
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void AecSectionPosJig::GetPosPoint(AcGePoint3d& ptTo)
|
|
{
|
|
ptTo = m_ptTo;
|
|
}
|
|
|
|
AcEdJig::DragStatus AecSectionPosJig::sampler()
|
|
{
|
|
setUserInputControls( ( UserInputControls)
|
|
( AcEdJig::kAccept3dCoordinates |
|
|
AcEdJig::kNullResponseAccepted ) );
|
|
|
|
static AcGePoint3d ptTo;
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
eStat = acquirePoint(m_ptTo);
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
if ( ptTo.isEqualTo(m_ptTo))
|
|
{
|
|
//鼠标原地不动
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
ptTo = m_ptTo;
|
|
|
|
AcGePoint3d ptFr1,ptTo1;
|
|
ptFr1 = ptTo;
|
|
ptFr1.x -= m_dW / 2.0;
|
|
ptFr1.y -= m_dH / 2.0;
|
|
|
|
ptTo1 = ptTo;
|
|
ptTo1.x -= m_dW / 2.0;
|
|
ptTo1.y += m_dH / 2.0;
|
|
|
|
m_pEnt->SetBasePoint(ptFr1,ptTo1);
|
|
|
|
ptTo1 = ptTo;
|
|
ptTo1.x += m_dW / 2.0;
|
|
m_pEnt->SetDirToPoint(ptTo1);
|
|
}
|
|
return eStat;
|
|
}
|
|
|
|
AcDbEntity* AecSectionPosJig::entity() const
|
|
{
|
|
return m_pEnt;
|
|
}
|
|
|
|
Adesk::Boolean AecSectionPosJig::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|