2026-10-04 00:04:20 +08:00
|
|
|
// TRoadJig.cpp: implementation of the TRoadJig class.
|
2026-09-28 15:28:50 +08:00
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
#include "TRoadJig.h"
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Construction/Destruction
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CRoadPreview::CRoadPreview(XPoint ptStart, XPoint ptEnd, double nRoadWidth)
|
|
|
|
|
{
|
|
|
|
|
m_ptStart = ptStart;
|
|
|
|
|
m_ptEnd = ptEnd;
|
|
|
|
|
m_nRoadWidth = nRoadWidth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CRoadPreview::~CRoadPreview()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Adesk::Boolean CRoadPreview::subWorldDraw(AcGiWorldDraw *pWd)
|
|
|
|
|
{
|
|
|
|
|
double nAng = ads_angle(m_ptStart, m_ptEnd);
|
|
|
|
|
XPoint ptS1, ptS2, ptE1, ptE2;
|
|
|
|
|
ads_polar(m_ptStart, nAng + PI/2, m_nRoadWidth/2, ptS1);
|
|
|
|
|
ads_polar(m_ptStart, nAng - PI/2, m_nRoadWidth/2, ptS2);
|
|
|
|
|
ads_polar(m_ptEnd, nAng + PI/2, m_nRoadWidth/2, ptE1);
|
|
|
|
|
ads_polar(m_ptEnd, nAng - PI/2, m_nRoadWidth/2, ptE2);
|
|
|
|
|
|
|
|
|
|
AcDbLine line1(m_ptStart, m_ptEnd);
|
|
|
|
|
line1.worldDraw(pWd);
|
|
|
|
|
|
|
|
|
|
AcDbLine line2(ptS1, ptE1);
|
|
|
|
|
line2.worldDraw(pWd);
|
|
|
|
|
|
|
|
|
|
AcDbLine line3(ptS2, ptE2);
|
|
|
|
|
line3.worldDraw(pWd);
|
|
|
|
|
|
|
|
|
|
double nDist = ads_distance(m_ptStart, m_ptEnd);
|
|
|
|
|
|
|
|
|
|
XPoint ptText;
|
|
|
|
|
if (nAng > PI/2 && nAng <= PI+PI/2)
|
|
|
|
|
ads_polar(m_ptStart, nAng, nDist/2+300, ptText);
|
|
|
|
|
else
|
|
|
|
|
ads_polar(m_ptStart, nAng, nDist/2-300, ptText);
|
|
|
|
|
ads_polar(ptText, nAng+PI/2, 100, ptText);
|
|
|
|
|
if (nAng > PI/2 && nAng <= PI+PI/2) {
|
|
|
|
|
ads_polar(ptText, nAng-PI/2, 100*2, ptText);
|
|
|
|
|
nAng += PI;
|
|
|
|
|
}
|
|
|
|
|
CString csDist;
|
|
|
|
|
csDist.Format(_T("%.0f"), nDist);
|
|
|
|
|
AcDbText text;
|
|
|
|
|
text.setRotation(nAng);
|
|
|
|
|
text.setHeight(m_nRoadWidth/2);
|
|
|
|
|
text.setTextString(csDist);
|
|
|
|
|
text.setTextStyle(GetTextStyleId(_T("STANDARD")));
|
|
|
|
|
text.setPosition(ptText);
|
|
|
|
|
text.setAlignmentPoint(ptText);
|
|
|
|
|
text.worldDraw(pWd);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Adesk::kTrue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TRoadJig::TRoadJig(XPoint pt1, double nRoadWidth)
|
|
|
|
|
{
|
|
|
|
|
m_ptStart = pt1;
|
|
|
|
|
m_ptEnd = pt1;
|
|
|
|
|
m_nDist = 0;
|
|
|
|
|
m_nRoadWidth = nRoadWidth;
|
|
|
|
|
m_pDrawEnt = new CRoadPreview(m_ptStart, m_ptEnd, m_nRoadWidth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TRoadJig::~TRoadJig()
|
|
|
|
|
{
|
|
|
|
|
if(m_pDrawEnt)
|
|
|
|
|
delete m_pDrawEnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TRoadJig::SetStartPoint(XPoint pt)
|
|
|
|
|
{
|
|
|
|
|
m_ptStart = pt;
|
|
|
|
|
m_pDrawEnt->m_ptStart = m_ptStart;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AcEdJig::DragStatus
|
|
|
|
|
TRoadJig::GetPoint(XPoint &pt)
|
|
|
|
|
{
|
|
|
|
|
return acquirePoint(pt, m_ptStart.AsAcGePoint3d());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TRoadJig::DoIt(int *keyIndex)
|
|
|
|
|
{
|
|
|
|
|
int nRet = TSymbEdJig::DoIt(keyIndex);
|
|
|
|
|
return nRet;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-04 00:04:20 +08:00
|
|
|
// 更新实体数据
|
2026-09-28 15:28:50 +08:00
|
|
|
Adesk::Boolean TRoadJig::update()
|
|
|
|
|
{
|
|
|
|
|
Adesk::Boolean bRet=Adesk::kTrue;
|
|
|
|
|
// if(m_nDist > g_nSprinklerRadius){
|
|
|
|
|
// double nAng = ads_angle(m_ptStart, m_ptResult);
|
|
|
|
|
// ads_polar(m_ptStart, nAng, m_nDist, m_ptResult);
|
|
|
|
|
// }
|
|
|
|
|
// if(g_nDoubleDist > 0)
|
|
|
|
|
// m_nRoadWidth = g_nDoubleDist;
|
|
|
|
|
m_pDrawEnt->m_nRoadWidth = m_nRoadWidth;
|
|
|
|
|
m_pDrawEnt->m_ptEnd = m_ptResult;
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AcDbEntity* TRoadJig::entity() const
|
|
|
|
|
{
|
|
|
|
|
return (AcDbEntity *)m_pDrawEnt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|