236 lines
4.6 KiB
C++
236 lines
4.6 KiB
C++
#include "stdafx.h"
|
|
#include "TThunderInsertPreviewJig.h"
|
|
#include "LayPinDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
TThunderInsertPreviewJig::TThunderInsertPreviewJig(AcDbBlockReference* pRef)
|
|
{
|
|
m_pLayPinDlg = NULL;
|
|
m_pVirEnt = new TVirtualEntity(pRef);
|
|
}
|
|
|
|
TThunderInsertPreviewJig::~TThunderInsertPreviewJig()
|
|
{
|
|
if (m_pVirEnt != NULL)
|
|
{
|
|
delete m_pVirEnt;
|
|
m_pVirEnt = NULL;
|
|
}
|
|
}
|
|
|
|
void TThunderInsertPreviewJig::SetLayPinDlgPtr(CLayPinDlg* pLayPtr)
|
|
{
|
|
m_pLayPinDlg = pLayPtr;
|
|
}
|
|
|
|
AcEdJig::DragStatus TThunderInsertPreviewJig::GetPoint(XPoint &pt)
|
|
{
|
|
AcEdJig::DragStatus drg = acquirePoint(pt);
|
|
m_ptPos = pt;
|
|
|
|
return drg;
|
|
}
|
|
|
|
Adesk::Boolean TThunderInsertPreviewJig::update()
|
|
{
|
|
if (m_pVirEnt != NULL)
|
|
{
|
|
m_pVirEnt->SetCurrentPos(m_ptPos);
|
|
|
|
if (m_pLayPinDlg != NULL)
|
|
{
|
|
AcGeDoubleArray arProH;
|
|
CStringArray arXData;
|
|
m_pLayPinDlg->GetCurrentData(arXData);
|
|
m_pLayPinDlg->GetThunderProHeight(arProH);
|
|
m_pVirEnt->SetProCircleRadius(arProH);
|
|
m_pVirEnt->SetThunderData(arXData);
|
|
}
|
|
}
|
|
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcDbEntity* TThunderInsertPreviewJig::entity() const
|
|
{
|
|
return (AcDbEntity*)m_pVirEnt;
|
|
}
|
|
|
|
AcGePoint3d TThunderInsertPreviewJig::GetLastPoint() const
|
|
{
|
|
return m_ptPos;
|
|
}
|
|
|
|
//TVirtualEntity
|
|
//////////////////////////////////////////////////////////////////////////
|
|
TVirtualEntity::TVirtualEntity(AcDbBlockReference* pRef)
|
|
{
|
|
m_pRef = pRef;
|
|
}
|
|
|
|
TVirtualEntity::~TVirtualEntity()
|
|
{
|
|
|
|
}
|
|
|
|
void TVirtualEntity::SetCurrentPos(const AcGePoint3d& ptPos)
|
|
{
|
|
m_ptPos = ptPos;
|
|
}
|
|
|
|
void TVirtualEntity::SetProCircleRadius(AcGeDoubleArray& arData)
|
|
{
|
|
m_arCirData = arData;
|
|
}
|
|
|
|
void TVirtualEntity::SetThunderData(CStringArray& arXData)
|
|
{
|
|
m_arXData.RemoveAll();
|
|
m_arXData.Append(arXData);
|
|
}
|
|
|
|
Adesk::Boolean TVirtualEntity::subWorldDraw(AcGiWorldDraw* mode)
|
|
{
|
|
subWorldDrawBlk(mode);
|
|
subWorldDrawCir(mode);
|
|
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
bool TVirtualEntity::DocGetMeterUnitDraw()
|
|
{
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"),&rb);
|
|
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
Adesk::Boolean TVirtualEntity::subWorldDrawCir(AcGiWorldDraw* mode)
|
|
{
|
|
if (mode != NULL)
|
|
{
|
|
if (m_arXData.GetSize() != 6)
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
double dScale = 1.0;
|
|
if (!DocGetMeterUnitDraw())
|
|
dScale = 1000.0;
|
|
|
|
double dPinH = _tstof(m_arXData.GetAt(CThunderXData::eXDataPinHeight));
|
|
double dProR = _tstof(m_arXData.GetAt(CThunderXData::eXDataPinRadius));
|
|
double dRadius = 0.0;
|
|
|
|
for (int i = 0;i < m_arCirData.length();++i)
|
|
{
|
|
dRadius = pow(dPinH *(2 * dProR -dPinH), 0.5) -pow(m_arCirData[i] *(2 * dProR - m_arCirData[i]), 0.5);
|
|
mode->geometry().circle(m_ptPos,dRadius*dScale,AcGeVector3d::kZAxis);
|
|
}
|
|
}
|
|
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
Adesk::Boolean TVirtualEntity::subWorldDrawBlk(AcGiWorldDraw* mode)
|
|
{
|
|
if (mode != NULL && m_pRef != NULL)
|
|
{
|
|
if (m_arXData.GetSize() != 6)
|
|
{
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
m_pRef->setPosition(m_ptPos);
|
|
|
|
CString strText = m_arXData.GetAt(CThunderXData::eXDataPinNum);
|
|
strText += _T("#,h=");
|
|
CString sPinHeight = m_arXData.GetAt(CThunderXData::eXDataPinHeight);
|
|
strText += sPinHeight;
|
|
strText += _T("m");
|
|
double dTestHeight = _tstof(m_arXData.GetAt(CThunderXData::eXDataBlockScale));
|
|
|
|
AcGeScale3d scal(dTestHeight*10*DocGetPScale(),dTestHeight*10*DocGetPScale(),dTestHeight*10*DocGetPScale());
|
|
m_pRef->setScaleFactors(scal);
|
|
|
|
m_pRef->worldDraw(mode);
|
|
}
|
|
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
//TThunderLinePreviewJig
|
|
//////////////////////////////////////////////////////////////////////////
|
|
TThunderLinePreviewJig::TThunderLinePreviewJig(AcDbPolyline* pLine)
|
|
{
|
|
m_pLine = pLine;
|
|
m_bFix = FALSE;
|
|
m_dFixAngle = 0.0;
|
|
}
|
|
|
|
TThunderLinePreviewJig::~TThunderLinePreviewJig()
|
|
{
|
|
|
|
}
|
|
|
|
AcEdJig::DragStatus TThunderLinePreviewJig::GetPoint(XPoint &pt)
|
|
{
|
|
AcGePoint3d ptTemp;
|
|
if (m_pLine != NULL)
|
|
{
|
|
m_pLine->getStartPoint(ptTemp);
|
|
}
|
|
|
|
AcEdJig::DragStatus drg = acquirePoint(pt, ptTemp);
|
|
if (m_bFix) // ¹Ì¶¨½Ç¶È
|
|
{
|
|
AcGeVector3d vtT = AcGeVector3d::kXAxis;
|
|
vtT.rotateBy(m_dFixAngle, AcGeVector3d::kZAxis);
|
|
AcDbLine ln(ptTemp, ptTemp + vtT);
|
|
ln.getClosestPointTo(pt,pt,Adesk::kTrue);
|
|
}
|
|
|
|
m_ptPos = pt;
|
|
|
|
return drg;
|
|
}
|
|
|
|
Adesk::Boolean TThunderLinePreviewJig::update()
|
|
{
|
|
if (m_pLine != NULL)
|
|
{
|
|
m_pLine->setPointAt(1, m_ptPos.convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
AcDbEntity* TThunderLinePreviewJig::entity() const
|
|
{
|
|
return m_pLine;
|
|
}
|
|
|
|
void TThunderLinePreviewJig::SetFixAngleState(BOOL bFix)
|
|
{
|
|
m_bFix = bFix;
|
|
}
|
|
|
|
void TThunderLinePreviewJig::SetFixAngleValue(double dFixAngle)
|
|
{
|
|
m_dFixAngle = dFixAngle;
|
|
}
|
|
|
|
AcGePoint3d TThunderLinePreviewJig::GetLastPoint()
|
|
{
|
|
return m_ptPos;
|
|
}
|