2038 lines
46 KiB
C++
2038 lines
46 KiB
C++
#include "stdafx.h"
|
|
#include "AcPolylineJig.h"
|
|
#include "AecAngleWatch.h"
|
|
#include "AECStatusRecord.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "KTCadUtility.h"
|
|
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d &pt1, const AcGePoint3d &pt2);
|
|
|
|
extern DLLIMPEXP AcDbArc* FormatArc(const AcGePoint3d& ptGe1,const AcGePoint3d& ptGe2,const AcGePoint3d& ptGe3);
|
|
|
|
AcPolyline::AcPolyline()
|
|
{
|
|
m_pCurve = NULL;
|
|
m_pAngleWatch = NULL;
|
|
m_bDblLine = false;
|
|
m_dW = 0.0;
|
|
m_dLW = 0.5 * m_dW;
|
|
m_pCurve1 = NULL;
|
|
m_pCurve2 = NULL;
|
|
m_bAngleWatchDraw = false;
|
|
m_eAlign = kMid;
|
|
}
|
|
|
|
AcPolyline::~AcPolyline()
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus AcPolyline::Draw2d(AcGiDraw &mode) const
|
|
{
|
|
if (m_pCurve != NULL)
|
|
{
|
|
if (m_bDblLine)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(m_pCurve);
|
|
if (pLn != NULL)
|
|
{
|
|
AcGeVector3d vtL = pLn->endPoint() - pLn->startPoint();
|
|
vtL.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
vtL.normalize();
|
|
|
|
AcGeVector3d vtR = vtL;
|
|
vtR.negate();
|
|
|
|
switch (m_eAlign)
|
|
{
|
|
case kMid:
|
|
{
|
|
//vtL *= 0.5 * m_dW;
|
|
//vtR *= 0.5 * m_dW;
|
|
|
|
//有左宽要求
|
|
vtL *= m_dLW;
|
|
vtR *= m_dW - m_dLW;
|
|
|
|
break;
|
|
}
|
|
case kLeft:
|
|
{
|
|
vtL *= m_dW;
|
|
break;
|
|
}
|
|
case kRight:
|
|
{
|
|
vtR *= m_dW;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (m_pCurve1 == NULL)
|
|
m_pCurve1 = new AcDbLine;
|
|
|
|
AcDbLine* pLn1 = AcDbLine::cast(m_pCurve1);
|
|
if (pLn1 == NULL)
|
|
{
|
|
delete m_pCurve1;
|
|
m_pCurve1 = new AcDbLine;
|
|
}
|
|
|
|
//Left
|
|
AcGePoint3d ptSta = pLn->startPoint();
|
|
AcGePoint3d ptEnd = pLn->endPoint();
|
|
|
|
pLn1 = AcDbLine::cast(m_pCurve1);
|
|
if (pLn1 != NULL)
|
|
{
|
|
ptSta += vtL;
|
|
ptEnd += vtL;
|
|
pLn1->setStartPoint( ptSta );
|
|
pLn1->setEndPoint( ptEnd );
|
|
}
|
|
|
|
if (m_pCurve2 == NULL)
|
|
m_pCurve2 = new AcDbLine;
|
|
|
|
AcDbLine* pLn2 = AcDbLine::cast(m_pCurve2);
|
|
if (pLn2 == NULL)
|
|
{
|
|
delete m_pCurve2;
|
|
m_pCurve2 = new AcDbLine;
|
|
}
|
|
|
|
//Right
|
|
ptSta = pLn->startPoint();
|
|
ptEnd = pLn->endPoint();
|
|
pLn2 = AcDbLine::cast(m_pCurve2);
|
|
if (pLn2 != NULL)
|
|
{
|
|
ptSta += vtR;
|
|
ptEnd += vtR;
|
|
pLn2->setStartPoint( ptSta );
|
|
pLn2->setEndPoint( ptEnd );
|
|
}
|
|
|
|
mode.DrawEntity((AcDbEntity*)m_pCurve1);
|
|
mode.DrawEntity((AcDbEntity*)m_pCurve2);
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(m_pCurve);
|
|
if (pArc != NULL)
|
|
{
|
|
if (m_pCurve1 == NULL)
|
|
m_pCurve1 = new AcDbArc;
|
|
|
|
AcDbArc* pArc1 = AcDbArc::cast(m_pCurve1);
|
|
if (pArc1 == NULL)
|
|
{
|
|
delete m_pCurve1;
|
|
pArc1 = new AcDbArc;
|
|
m_pCurve1 = pArc1;
|
|
}
|
|
|
|
if (m_pCurve2 == NULL)
|
|
m_pCurve2 = new AcDbArc;
|
|
|
|
AcDbArc* pArc2 = AcDbArc::cast(m_pCurve2);
|
|
if (pArc2 == NULL)
|
|
{
|
|
delete m_pCurve2;
|
|
pArc2 = new AcDbArc;
|
|
m_pCurve2 = pArc2;
|
|
}
|
|
|
|
double dR = pArc->radius();
|
|
AcGePoint3d ptCen = pArc->center();
|
|
double dSta = pArc->startAngle();
|
|
double dEnd = pArc->endAngle();
|
|
|
|
double dLr = 0.0, dRr = 0.0;
|
|
switch (m_eAlign)
|
|
{
|
|
case kMid:
|
|
{
|
|
//dLr = 0.5 * m_dW;
|
|
//dRr = -0.5 * m_dW;
|
|
|
|
dLr = m_dLW;
|
|
dRr = -(m_dW - m_dLW);
|
|
|
|
break;
|
|
}
|
|
case kLeft:
|
|
{
|
|
dLr = 0.0;
|
|
dRr = -m_dW;
|
|
|
|
break;
|
|
}
|
|
case kRight:
|
|
{
|
|
dLr = m_dW;
|
|
dRr = 0.0;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//Left
|
|
pArc1->setRadius(dR + dLr);
|
|
|
|
pArc1->setStartAngle(dSta);
|
|
pArc1->setEndAngle(dEnd);
|
|
pArc1->setCenter(ptCen);
|
|
pArc1->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
//Right
|
|
pArc2->setRadius(dR + dRr);
|
|
pArc2->setStartAngle(dSta);
|
|
pArc2->setEndAngle(dEnd);
|
|
pArc2->setCenter(ptCen);
|
|
pArc2->setNormal(AcGeVector3d::kZAxis);
|
|
|
|
mode.DrawEntity((AcDbEntity*)m_pCurve1);
|
|
mode.DrawEntity((AcDbEntity*)m_pCurve2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mode.DrawEntity((AcDbEntity*)m_pCurve);
|
|
}
|
|
}
|
|
|
|
if (m_pAngleWatch != NULL && m_bAngleWatchDraw)
|
|
{
|
|
m_pAngleWatch->Draw2d(mode);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
AcPolylineJig::AcPolylineJig(void)
|
|
{
|
|
m_pCurStaRec = NULL;
|
|
m_pLine = new AcDbLine;
|
|
m_pArc = new AcDbArc;
|
|
m_pCurve = m_pLine;
|
|
|
|
m_nUndoGoupid = 0;
|
|
m_pRoadAxisLine = new AecDb3dRoadAxisLine;
|
|
m_pAngleWatch = new AecAngleWatch;
|
|
InitStatusRecsForPolyline();
|
|
m_pPolylineProxy = new AcPolyline();
|
|
m_pPolylineProxy->m_pAngleWatch = m_pAngleWatch;
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
m_pPolylineProxy->setColorIndex(kMagenta);//默认红色
|
|
}
|
|
|
|
AcPolylineJig::~AcPolylineJig(void)
|
|
{
|
|
if (m_pLine != NULL)
|
|
delete m_pLine;
|
|
|
|
if (m_pArc != NULL)
|
|
delete m_pArc;
|
|
|
|
if ( m_pAngleWatch != NULL)
|
|
delete m_pAngleWatch;
|
|
}
|
|
|
|
void AcPolylineJig::PushBackStatusRec(AECStatusRecord* pRec)
|
|
{
|
|
pRec->SetUndoGroupId(m_nUndoGoupid);
|
|
m_lstStaPtrsBack.AddTail(pRec);
|
|
}
|
|
|
|
void AcPolylineJig::SetUndoGroupBegin()
|
|
{
|
|
m_nUndoGoupid += 1;
|
|
}
|
|
|
|
void AcPolylineJig::SetUndoGroupEnd()
|
|
{
|
|
|
|
}
|
|
|
|
void AcPolylineJig::PopUpStatusRec()
|
|
{
|
|
//按 id 回退一次,调整当前状态
|
|
if (m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
AECStatusRecord* pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
int nID = pLast->GetUndoGroupId();
|
|
|
|
while(m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
m_lstStaPtrsBack.RemoveTail();
|
|
|
|
DELETE_PTR(pLast);
|
|
pLast = NULL;
|
|
if (m_lstStaPtrsBack.GetCount() == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
if (nID != pLast->GetUndoGroupId())
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//roadline 回退一次,调整接口记录
|
|
if (m_pRoadAxisLine != NULL)
|
|
{
|
|
m_pRoadAxisLine->RemoveLast();
|
|
}
|
|
MoveAngWatchPosition();
|
|
}
|
|
}
|
|
|
|
void AcPolylineJig::FreeBuffer()
|
|
{
|
|
AECStatusRecord* pRec = NULL;
|
|
while(!m_arStaPtrs.IsEmpty())
|
|
{
|
|
pRec = (AECStatusRecord* )m_arStaPtrs.GetAt(0);
|
|
m_arStaPtrs.RemoveAt(0);
|
|
delete pRec;
|
|
}
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsForPolyline()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点或[宽度(W)]<退出>:"));
|
|
pRec1->SetKeywordList(_T("W"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点或 [圆弧(A)/放弃(U)/表盘精度(J)/宽度(W)]:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J W"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2,1);
|
|
m_pCurStaRec = pRec1;
|
|
|
|
//分支状态
|
|
AECStatusRecord* pRec3 = NULL;
|
|
pRec3 = new AECStatusRecord;
|
|
pRec3->SetPrompt(_T("\n指定下一个点或 [圆弧设置(A)/宽度(W)]:"));
|
|
pRec3->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec3->SetKeywordList(_T("A W"));
|
|
pRec2->SetKeyStatus(_T("A"),pRec3);
|
|
pRec3->SetPlanPosition(2);
|
|
pRec3->SetNextStatus(pRec2);
|
|
m_arStaPtrs.Add(pRec3);
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsForWall(double dWallW, double dLW, EAlign eAlign)
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点或 [圆弧(A)/放弃(U)/表盘精度(J)]:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2,1);
|
|
m_pCurStaRec = pRec1;
|
|
|
|
//分支状态
|
|
AECStatusRecord* pRec3 = NULL;
|
|
pRec3 = new AECStatusRecord;
|
|
pRec3->SetPrompt(_T("\n指定下一个点或 [圆弧设置(A)]:"));
|
|
pRec3->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec3->SetKeywordList(_T("A"));
|
|
pRec2->SetKeyStatus(_T("A"),pRec3);
|
|
pRec3->SetPlanPosition(2);
|
|
pRec3->SetNextStatus(pRec2);
|
|
m_arStaPtrs.Add(pRec3);
|
|
|
|
m_pPolylineProxy->SetDoubleLineDraw(true,dWallW,dLW, eAlign);
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsForArcWall(double dWallW,double dLW, EAlign eAlign)
|
|
{
|
|
//起点或 [参考点(R)]<退出>:
|
|
//弧墙终点<取消>:
|
|
//点取弧上任意点或[半径(R)]<取消>:
|
|
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
m_pCurStaRec = pRec1;
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n弧墙终点<取消>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
//分支状态
|
|
AECStatusRecord* pRec3 = NULL;
|
|
pRec3 = new AECStatusRecord;
|
|
pRec3->SetPrompt(_T("\n点取弧上任意点或[半径(R)]<取消>:"));
|
|
pRec3->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec3->SetKeywordList(_T("R"));
|
|
pRec3->SetPlanPosition(1394);
|
|
pRec2->SetNextStatus(pRec3);
|
|
|
|
m_pPolylineProxy->SetDoubleLineDraw(true,dWallW, dLW,eAlign);
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsForOnLine()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定终点<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
pRec2->SetCommandStop(TRUE);
|
|
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsForLineSegs()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点[标高(E)]<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点 [标高(E)/放弃(U)/表盘精度(J)/坡度(P)]:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J W P"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2,1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsFor3dRoadAxisLine()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord *pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord *pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点 [圆弧(A)/标高(E)/放弃(U)/表盘精度(J)/坡度(P)]:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J W P"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2, 1);
|
|
m_pCurStaRec = pRec1;
|
|
|
|
//分支状态
|
|
AECStatusRecord *pRec3 = NULL;
|
|
pRec3 = new AECStatusRecord;
|
|
pRec3->SetPrompt(_T("\n指定下一个点或 [圆弧设置(A)/宽度(W)]:"));
|
|
pRec3->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec3->SetKeywordList(_T("A W"));
|
|
pRec2->SetKeyStatus(_T("A"), pRec3);
|
|
pRec3->SetPlanPosition(2);
|
|
pRec3->SetNextStatus(pRec2);
|
|
m_arStaPtrs.Add(pRec3);
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsFor2DLineSegs()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord *pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord *pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点 [放弃(U)/表盘精度(J)]:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2, 1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void AcPolylineJig::InitStatusRecsFor2DISOLineSegs()
|
|
{
|
|
FreeBuffer();
|
|
|
|
AECStatusRecord *pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
pRec1->SetPos(0);
|
|
m_arStaPtrs.Add(pRec1);
|
|
|
|
AECStatusRecord *pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
pRec2->SetPrompt(_T("\n指定下一个点<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("A E U J"));
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
|
|
pRec2->SetNextStatus(pRec2, 1);
|
|
pRec2->SetPos(1);
|
|
m_pCurStaRec = pRec1;
|
|
|
|
SetAngleWatchDraw(true);
|
|
}
|
|
|
|
void AcPolylineJig::SetAngleWatchDraw(bool bAngleWatchDraw)
|
|
{
|
|
m_pPolylineProxy->m_bAngleWatchDraw = bAngleWatchDraw;
|
|
}
|
|
|
|
void AcPolylineJig::SetElevation(double dStEl)
|
|
{
|
|
AcGePoint3d ptGe;
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
ptGe.z = dStEl;
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
}
|
|
|
|
void AcPolylineJig::CalReferencePoint()
|
|
{
|
|
AcGePoint3d ptWcs;
|
|
ads_point ptBase,pt22,pt33;
|
|
|
|
acedInitGet(RSG_NONULL,_T("R"));
|
|
int nRes = acedGetPoint(NULL,_T("\n指定起点或[参考点(R)]<退出>:"),ptBase);
|
|
switch(nRes)
|
|
{
|
|
case RTNORM:
|
|
{
|
|
acdbUcs2Wcs(ptBase,pt22,false);
|
|
ptWcs = asPnt3d(pt22);
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
break;
|
|
}
|
|
case RTKWORD:
|
|
{
|
|
TCHAR szKey[2];
|
|
szKey[0] = '0';
|
|
acedGetInput(szKey);
|
|
|
|
switch(szKey[0])
|
|
{
|
|
case _T('R'):
|
|
case _T('r'):
|
|
{
|
|
//参考点<退出>:
|
|
nRes = acedGetPoint(NULL,_T("\n参考点<退出>:"),ptBase);
|
|
if (nRes == RTNORM)
|
|
{
|
|
//起点<退出>:
|
|
nRes = acedGetPoint(ptBase,_T("\n指定起点<退出>:"),pt22);
|
|
if (nRes == RTNORM)
|
|
{
|
|
acdbUcs2Wcs(pt22,pt33,false);
|
|
ptWcs = asPnt3d(pt33);
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AcPolylineJig::DoIt()
|
|
{
|
|
AcEdJig::DragStatus eStat;
|
|
int nPlanPos = 0;
|
|
CString sPrompt = _T("");
|
|
AcGePoint3d ptGe;
|
|
|
|
//参考
|
|
CalReferencePoint();
|
|
|
|
while(TRUE)
|
|
{
|
|
sPrompt = m_pCurStaRec->Prompt();
|
|
SetDispPromptWithEleTip(sPrompt);
|
|
setDispPrompt(sPrompt);
|
|
|
|
eStat = drag();
|
|
|
|
if (m_pCurStaRec == NULL)
|
|
return false;
|
|
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
switch(eStat)
|
|
{
|
|
case AcEdJig::kNormal:
|
|
{
|
|
if (nPlanPos == 1 || nPlanPos == 2) //Create line,Arc
|
|
{
|
|
if ( AddRoadNode(WPipe::eToCreate) )
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
m_pCurStaRec->SetRefDblValue(0);//归0
|
|
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
}
|
|
m_pCurve = m_pLine;//回归直线
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kCancel:
|
|
case AcEdJig::kNull:// 退出
|
|
{
|
|
acutPrintf(_T("\n"));
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
case AcEdJig::kKW1://圆弧 A 或 W 或 R
|
|
{
|
|
//指定下一个点或 [圆弧设置(S)]
|
|
if (m_pCurStaRec->GetPlanPosition() == 1)//A
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() == 1)//第一个点历史记录,开始绘制圆弧
|
|
{
|
|
AECStatusRecord* pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
ads_point ptLast;
|
|
acdbWcs2Ucs(asDblArray(pLast->GetAcquirePoint()),ptLast,false);
|
|
|
|
ads_point pt2,pt22;
|
|
int nRes = acedGetPoint(ptLast,_T("\n定圆弧上的中间一点:"),pt2);
|
|
if (nRes == RTNORM)
|
|
{
|
|
ads_point pt3,pt33;
|
|
nRes = acedGetPoint(pt2,_T("\n指定圆弧的端点:"),pt3);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcGePoint3d ptMid;
|
|
acdbUcs2Wcs(pt2,pt22,false);
|
|
ptMid = asPnt3d(pt22);
|
|
|
|
acdbUcs2Wcs(pt3,pt33,false);
|
|
|
|
AcDbArc* pArc = FormatArc(pLast->GetAcquirePoint(),ptMid,asPnt3d(pt33));
|
|
if (pArc != NULL)
|
|
{
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
AddRoadNode(WPipe::eToCreate);
|
|
delete pArc;
|
|
}
|
|
|
|
m_pCurStaRec->SetAcquirePoint(asPnt3d(pt33));
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetAcquirePoint(asPnt3d(pt33));
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
AECStatusRecord* pRec = m_pCurStaRec->GetKeyStatus(_T("A"));
|
|
m_pCurStaRec = pRec;
|
|
}
|
|
continue;
|
|
}
|
|
else if(m_pCurStaRec->GetPlanPosition() == 0)//W
|
|
{
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dAngle(.0), dR(.0);
|
|
//圆弧设置 R,ANGLE
|
|
if (acedGetReal(_T("\n请输入圆心角(负值时顺时针绘制):"), &dAngle) == RTNORM)
|
|
{
|
|
if (acedGetReal(_T("\n请输入半径:"), &dR) == RTNORM)
|
|
{
|
|
if (AddRoadNode(dAngle * PI / 180.0, dR))
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
AcGePoint3d ptSta, ptEnd;
|
|
m_pLine->getStartPoint(ptSta);
|
|
m_pLine->getEndPoint(ptEnd);
|
|
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
if (!m_lstStaPtrsBack.IsEmpty())
|
|
{
|
|
//根据R,Angle 转为 模拟去点动作保存缓存
|
|
AECStatusRecord* pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
if (ptSta.distanceTo(pLast->GetAcquirePoint()) < 1.e-3)
|
|
pRec->SetAcquirePoint(ptEnd);
|
|
|
|
if (ptEnd.distanceTo(pLast->GetAcquirePoint()) < 1.e-3)
|
|
pRec->SetAcquirePoint(ptSta);
|
|
}
|
|
PushBackStatusRec(pRec);
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW2://标高 E 或 W
|
|
{
|
|
//对话框
|
|
if (m_pCurStaRec->GetPlanPosition() == 1)//
|
|
{
|
|
double dH(.0);
|
|
if (acedGetReal(_T("\n请输入标高增量:"), &dH) == RTNORM)
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() == 1)
|
|
{
|
|
AECStatusRecord *pRecLast = (AECStatusRecord *)m_lstStaPtrsBack.GetTail();
|
|
|
|
AcGePoint3d ptFr;
|
|
ptFr = pRecLast->GetAcquirePoint();
|
|
ptFr.z += dH;
|
|
pRecLast->SetAcquirePoint(ptFr);
|
|
|
|
continue;
|
|
}
|
|
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
GetLastStatusAquire(ptGe);
|
|
|
|
AcGePoint3d ptTo = ptGe;
|
|
|
|
ptTo.z += dH;
|
|
m_pCurStaRec->SetAcquirePoint(ptTo);
|
|
|
|
MakeLine();
|
|
|
|
AddRoadNode(WPipe::eToCreate);
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
}
|
|
}
|
|
else if(m_pCurStaRec->GetPlanPosition() == 2)//W 宽度
|
|
{
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case AcEdJig::kKW3://放弃 U
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() > 1)
|
|
{
|
|
SHacedCommand(RTSTR,_T("u"),RTNONE);
|
|
PopUpStatusRec();
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW4://精度 J
|
|
{
|
|
int iAngle(0);
|
|
CString str(_T(""));
|
|
str.Format(_T("\n请输入表盘精度<%d>:"), m_pPolylineProxy->m_pAngleWatch->m_nWatchStep);
|
|
if (acedGetInt(str, &iAngle) == RTNORM && iAngle <= 90)
|
|
m_pPolylineProxy->m_pAngleWatch->m_nWatchStep = iAngle;
|
|
}
|
|
case AcEdJig::kKW5://宽度 W
|
|
{
|
|
//
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW6://坡度 P
|
|
{
|
|
double dP = 0.0;
|
|
if (acedGetReal(_T("\n请输入坡度%:"), &dP) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetRefDblValue(dP);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcGePoint3d ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
//获取下个状态,plane判断是?
|
|
if (m_pCurStaRec->GetPlanPosition() == 0 ||
|
|
m_pCurStaRec->GetPlanPosition() == 2)
|
|
{
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
}
|
|
}
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
|
|
bool AcPolylineJig::DoItISO(int nAngMode, int nAngle)
|
|
{
|
|
m_pAngleWatch->SetISOMode(nAngMode,nAngle);
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
int nPlanPos = 0;
|
|
CString sPrompt = _T("");
|
|
AcGePoint3d ptGe;
|
|
|
|
//参考
|
|
CalReferencePoint();
|
|
|
|
while (TRUE)
|
|
{
|
|
sPrompt = m_pCurStaRec->Prompt();
|
|
SetDispPromptWithEleTip(sPrompt);
|
|
setDispPrompt(sPrompt);
|
|
|
|
eStat = drag();
|
|
|
|
if (m_pCurStaRec == NULL)
|
|
return false;
|
|
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
switch (eStat)
|
|
{
|
|
case AcEdJig::kNormal:
|
|
{
|
|
if (nPlanPos == 1 || nPlanPos == 2) //Create line,Arc
|
|
{
|
|
if (AddRoadNode(WPipe::eToCreate))
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
m_pCurStaRec->SetRefDblValue(0);//归0
|
|
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
}
|
|
m_pCurve = m_pLine;//回归直线
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kCancel:
|
|
case AcEdJig::kNull:// 退出
|
|
{
|
|
acutPrintf(_T("\n"));
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
case AcEdJig::kKW1://圆弧 A 或 W 或 R
|
|
{
|
|
//指定下一个点或 [圆弧设置(S)]
|
|
if (m_pCurStaRec->GetPlanPosition() == 1)//A
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() == 1)//第一个点历史记录,开始绘制圆弧
|
|
{
|
|
AECStatusRecord *pLast = (AECStatusRecord *)m_lstStaPtrsBack.GetTail();
|
|
ads_point ptLast;
|
|
acdbWcs2Ucs(asDblArray(pLast->GetAcquirePoint()), ptLast, false);
|
|
|
|
ads_point pt2, pt22;
|
|
int nRes = acedGetPoint(ptLast, _T("\n定圆弧上的中间一点:"), pt2);
|
|
if (nRes == RTNORM)
|
|
{
|
|
ads_point pt3, pt33;
|
|
nRes = acedGetPoint(pt2, _T("\n指定圆弧的端点:"), pt3);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcGePoint3d ptMid;
|
|
acdbUcs2Wcs(pt2, pt22, false);
|
|
ptMid = asPnt3d(pt22);
|
|
|
|
acdbUcs2Wcs(pt3, pt33, false);
|
|
|
|
AcDbArc *pArc = FormatArc(pLast->GetAcquirePoint(), ptMid, asPnt3d(pt33));
|
|
if (pArc != NULL)
|
|
{
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
AddRoadNode(WPipe::eToCreate);
|
|
delete pArc;
|
|
}
|
|
|
|
m_pCurStaRec->SetAcquirePoint(asPnt3d(pt33));
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetAcquirePoint(asPnt3d(pt33));
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
AECStatusRecord *pRec = m_pCurStaRec->GetKeyStatus(_T("A"));
|
|
m_pCurStaRec = pRec;
|
|
}
|
|
continue;
|
|
}
|
|
else if (m_pCurStaRec->GetPlanPosition() == 0)//W
|
|
{
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dAngle(.0), dR(.0);
|
|
//圆弧设置 R,ANGLE
|
|
if (acedGetReal(_T("\n请输入圆心角(负值时顺时针绘制):"), &dAngle) == RTNORM)
|
|
{
|
|
if (acedGetReal(_T("\n请输入半径:"), &dR) == RTNORM)
|
|
{
|
|
if (AddRoadNode(dAngle * PI / 180.0, dR))
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
AcGePoint3d ptSta, ptEnd;
|
|
m_pLine->getStartPoint(ptSta);
|
|
m_pLine->getEndPoint(ptEnd);
|
|
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
if (!m_lstStaPtrsBack.IsEmpty())
|
|
{
|
|
//根据R,Angle 转为 模拟去点动作保存缓存
|
|
AECStatusRecord *pLast = (AECStatusRecord *)m_lstStaPtrsBack.GetTail();
|
|
if (ptSta.distanceTo(pLast->GetAcquirePoint()) < 1.e-3)
|
|
pRec->SetAcquirePoint(ptEnd);
|
|
|
|
if (ptEnd.distanceTo(pLast->GetAcquirePoint()) < 1.e-3)
|
|
pRec->SetAcquirePoint(ptSta);
|
|
}
|
|
PushBackStatusRec(pRec);
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW2://标高 E 或 W
|
|
{
|
|
//对话框
|
|
if (m_pCurStaRec->GetPlanPosition() == 1)//
|
|
{
|
|
double dH(.0);
|
|
if (acedGetReal(_T("\n请输入标高增量:"), &dH) == RTNORM)
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() == 1)
|
|
{
|
|
AECStatusRecord *pRecLast = (AECStatusRecord *)m_lstStaPtrsBack.GetTail();
|
|
|
|
AcGePoint3d ptFr;
|
|
ptFr = pRecLast->GetAcquirePoint();
|
|
ptFr.z += dH;
|
|
pRecLast->SetAcquirePoint(ptFr);
|
|
|
|
continue;
|
|
}
|
|
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
GetLastStatusAquire(ptGe);
|
|
|
|
AcGePoint3d ptTo = ptGe;
|
|
|
|
ptTo.z += dH;
|
|
m_pCurStaRec->SetAcquirePoint(ptTo);
|
|
|
|
MakeLine();
|
|
|
|
AddRoadNode(WPipe::eToCreate);
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
}
|
|
}
|
|
else if (m_pCurStaRec->GetPlanPosition() == 2)//W 宽度
|
|
{
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case AcEdJig::kKW3://放弃 U
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() > 1)
|
|
{
|
|
SHacedCommand(RTSTR, _T("u"), RTNONE);
|
|
PopUpStatusRec();
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW4://精度 J
|
|
{
|
|
int iAngle(0);
|
|
CString str(_T(""));
|
|
str.Format(_T("\n请输入表盘精度<%d>:"), m_pPolylineProxy->m_pAngleWatch->m_nWatchStep);
|
|
if (acedGetInt(str, &iAngle) == RTNORM && iAngle <= 90)
|
|
m_pPolylineProxy->m_pAngleWatch->m_nWatchStep = iAngle;
|
|
}
|
|
case AcEdJig::kKW5://宽度 W
|
|
{
|
|
//
|
|
double dW = 0.0;
|
|
if (acedGetReal(_T("\n请输入宽度:"), &dW) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetAcquireDouble(dW);
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW6://坡度 P
|
|
{
|
|
double dP = 0.0;
|
|
if (acedGetReal(_T("\n请输入坡度%:"), &dP) == RTNORM)
|
|
{
|
|
m_pCurStaRec->SetRefDblValue(dP);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcGePoint3d ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
//获取下个状态,plane判断是?
|
|
if (m_pCurStaRec->GetPlanPosition() == 0 ||
|
|
m_pCurStaRec->GetPlanPosition() == 1 ||
|
|
m_pCurStaRec->GetPlanPosition() == 2)
|
|
{
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
}
|
|
}
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
|
|
bool AcPolylineJig::DoArcIt()
|
|
{
|
|
AcEdJig::DragStatus eStat;
|
|
int nPlanPos = 0;
|
|
CString sPrompt = _T("");
|
|
AcGePoint3d ptGe;
|
|
|
|
//参考
|
|
CalReferencePoint();
|
|
|
|
while(TRUE)
|
|
{
|
|
sPrompt = m_pCurStaRec->Prompt();
|
|
SetDispPromptWithEleTip(sPrompt);
|
|
setDispPrompt(sPrompt);
|
|
|
|
eStat = drag();
|
|
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
switch(eStat)
|
|
{
|
|
case AcEdJig::kNormal:
|
|
{
|
|
if ( nPlanPos == 1394) //Create Arc
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
if ( AddArcRoadNode(WPipe::eToCreate) )
|
|
{
|
|
m_pCurve = m_pArc;//回归直线
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
return true;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kCancel:
|
|
case AcEdJig::kNull:// 退出
|
|
{
|
|
acutPrintf(_T("\n"));
|
|
return m_idRoadLine.isValid();
|
|
}
|
|
case AcEdJig::kKW1://圆弧 R
|
|
{
|
|
if (m_pCurStaRec->GetPlanPosition() == 1394)//R
|
|
{
|
|
ads_point ptR,ptm;
|
|
|
|
if (m_lstStaPtrsBack.GetSize() >= 2)
|
|
{
|
|
POSITION ps0 = m_lstStaPtrsBack.GetHeadPosition();
|
|
AECStatusRecord* pRec0 = (AECStatusRecord*)m_lstStaPtrsBack.GetNext(ps0);
|
|
AECStatusRecord* pRec1 = (AECStatusRecord*)m_lstStaPtrsBack.GetNext(ps0);
|
|
|
|
AcGePoint3d pt1 = pRec0->GetAcquirePoint();
|
|
AcGePoint3d pt2 = pRec1->GetAcquirePoint();
|
|
AcGePoint3d ptM = MidPoint(pt1,pt2);
|
|
|
|
acdbWcs2Ucs(asDblArray(ptM),ptm,false);
|
|
|
|
if ( acedGetPoint(ptm,_T("\n请输入半径:"), ptR) == RTNORM)
|
|
{
|
|
ads_point ptwr;
|
|
acdbUcs2Wcs(ptR,ptwr,false);
|
|
|
|
AcGeVector3d vtDir = asPnt3d(ptwr) - ptM;
|
|
AcGePoint3d ptRW(vtDir.x,vtDir.y,vtDir.z);
|
|
m_pCurStaRec->SetAcquirePoint(ptRW);
|
|
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetPlanPosition(1395);
|
|
PushBackStatusRec(pRec);
|
|
|
|
if ( AddArcRoadNode(WPipe::eToCreate) )
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcGePoint3d ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
//获取下个状态,plane判断是?
|
|
if ( m_pCurStaRec->GetPlanPosition() <= 1)
|
|
{
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
}
|
|
}
|
|
return m_idRoadLine.isValid();
|
|
|
|
}
|
|
|
|
AcDbObjectId AcPolylineJig::GetRoadAxisLineId() const
|
|
{
|
|
return m_idRoadLine;
|
|
}
|
|
|
|
void AcPolylineJig::SetDispPromptWithEleTip(CString& sPrompt)
|
|
{
|
|
CString sEl;
|
|
if (m_pCurStaRec != NULL)
|
|
{
|
|
sEl.Format(_T("(当前标高:%g)"),m_pCurStaRec->GetAcquirePoint().z);
|
|
|
|
int nIndex = sPrompt.ReverseFind(_T(':'));
|
|
if (nIndex != -1)
|
|
{
|
|
sPrompt.Insert(nIndex,sEl);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcEdJig::DragStatus AcPolylineJig::sampler()
|
|
{
|
|
setUserInputControls( ( UserInputControls)
|
|
( AcEdJig::kAccept3dCoordinates |
|
|
AcEdJig::kNullResponseAccepted ) );
|
|
|
|
if (m_pCurStaRec == NULL)
|
|
return AcEdJig::kCancel;
|
|
|
|
CString sKeywordsList;
|
|
sKeywordsList = m_pCurStaRec->KeywordList();
|
|
if (!sKeywordsList.IsEmpty())
|
|
{
|
|
setKeywordList(sKeywordsList);
|
|
}
|
|
|
|
AcEdJig::DragStatus eStat = AcEdJig::kNormal;
|
|
AcGePoint3d ptGe,ptGeBase,ptGe2;
|
|
ptGeBase = AcGePoint3d::kOrigin;
|
|
|
|
AECStatusRecord::EAcquire eAcquire = m_pCurStaRec->GetStatusType();
|
|
switch(eAcquire)
|
|
{
|
|
case AECStatusRecord::kPoint:
|
|
{
|
|
int nPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
if (nPos == 0)//指定起点
|
|
{
|
|
eStat = acquirePoint(ptGe);
|
|
}
|
|
else
|
|
{
|
|
GetLastStatusAquire(ptGeBase);
|
|
eStat = acquirePoint(ptGe,ptGeBase);
|
|
|
|
ptGe.z = ptGeBase.z;
|
|
double dDist = ptGeBase.distanceTo(ptGe);
|
|
if ( dDist < 1.e-6)
|
|
{
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
else
|
|
{
|
|
|
|
ptGe2 = m_pCurStaRec->GetAcquirePoint();
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
}
|
|
}
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
if (m_pCurStaRec->IsValSeted())
|
|
{
|
|
double dDis = ptGe2.distanceTo(ptGe);
|
|
if (dDis < 1.e-6)
|
|
{
|
|
//鼠标原地不动
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
}
|
|
|
|
ptGe2 = m_pCurStaRec->GetAcquirePoint();
|
|
ptGe.z = ptGeBase.z;
|
|
|
|
//m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
//acutPrintf(_T("\nGetPt: Y= %.3f"), ptGe.y);
|
|
|
|
if (m_pCurStaRec->GetPlanPosition() > 0 && m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
if (m_pCurStaRec->GetPlanPosition() == 1394 ||
|
|
m_pCurStaRec->GetPlanPosition() == 1395)
|
|
{
|
|
AddArcRoadNode(WPipe::eToPreView);
|
|
}
|
|
else
|
|
{
|
|
AddRoadNode(WPipe::eToPreView);
|
|
}
|
|
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
if (ptGe.distanceTo(ptGe2) < 1.e-6)
|
|
{
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
return AcEdJig::kNormal;
|
|
}
|
|
}
|
|
else if (eStat == AcEdJig::kOther)
|
|
{
|
|
int nn = 0;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return eStat;
|
|
}
|
|
|
|
double AcPolylineJig::GetEndElevation() const
|
|
{
|
|
AcGePoint3d ptEnd(0,0,0);
|
|
if ( !m_lstStaPtrsBack.IsEmpty() )
|
|
{
|
|
AECStatusRecord* pRec = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
ptEnd = pRec->GetAcquirePoint();
|
|
}
|
|
return ptEnd.z;
|
|
}
|
|
|
|
BOOL AcPolylineJig::MakeLine()
|
|
{
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return FALSE;
|
|
|
|
AECStatusRecord* pRecLast = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
|
|
AcGePoint3d ptFr;
|
|
ptFr = pRecLast->GetAcquirePoint();
|
|
m_pLine->setStartPoint(ptFr);
|
|
|
|
AcGePoint3d ptCur;
|
|
ptCur = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
//如果上次是圆弧,则计算切线
|
|
if (pRecLast->GetPlanPosition() == 2)
|
|
{
|
|
AcGeVector3d vtLast(0,0,0);
|
|
m_pArc->getFirstDeriv(ptFr,vtLast);
|
|
if (vtLast.isZeroLength())
|
|
{
|
|
AcGePoint3d ptFr2;
|
|
m_pArc->getClosestPointTo(ptFr, ptFr2);
|
|
|
|
m_pArc->getFirstDeriv(ptFr2, vtLast);
|
|
ptFr = ptFr2;
|
|
}
|
|
AcDbXline xLn;
|
|
xLn.setBasePoint(ptFr);
|
|
xLn.setUnitDir(vtLast);
|
|
|
|
AcGePoint3d ptEnd;
|
|
xLn.getClosestPointTo(ptCur,ptEnd);
|
|
ptCur = ptEnd;
|
|
}
|
|
|
|
//坡度
|
|
double dP = m_pCurStaRec->GetRefDblValue();
|
|
double dZBk = ptCur.z;
|
|
AcGeVector3d vt = ptCur - ptFr;
|
|
if (vt.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
}
|
|
else
|
|
{
|
|
if (fabs(dP) > 1.e-3)
|
|
{
|
|
double dDist = ptCur.distanceTo(ptFr);
|
|
//dP = 100.0 * (pt2.z - pt1.z) / dDist;//计算坡度
|
|
ptCur.z = ptFr.z + dP * 0.01 * dDist;
|
|
}
|
|
}
|
|
|
|
//投影校正
|
|
m_pLine->setEndPoint(ptCur);
|
|
|
|
m_pCurStaRec->SetAcquirePoint(ptCur);
|
|
m_pCurve = m_pLine;
|
|
m_pCurve->setColorIndex(1);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//切线弧
|
|
BOOL AcPolylineJig::MakeArc()
|
|
{
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return FALSE;
|
|
|
|
if (m_pRoadAxisLine->GetCurveSegCount() > 0)
|
|
{
|
|
AECStatusRecord* pRecLast = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
AcDbCurve* pLast = m_pRoadAxisLine->GetCurveSeg(m_pRoadAxisLine->GetCurveSegCount() - 1);
|
|
|
|
AcGePoint3d ptLast = pRecLast->GetAcquirePoint();
|
|
AcGePoint3d ptThis = m_pCurStaRec->GetAcquirePoint();
|
|
AcGeVector3d vtLast,vtLastBk;
|
|
pLast->getFirstDeriv(ptLast,vtLast);
|
|
vtLastBk = vtLast;
|
|
vtLastBk.normalize();
|
|
vtLast.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtThis = ptThis - ptLast;
|
|
AcGePoint3d ptMid = MidPoint(ptLast,ptThis);
|
|
|
|
vtThis.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeLine3d ln1(ptLast,vtLast);
|
|
AcGeLine3d ln2(ptMid,vtThis);
|
|
AcGePoint3d ptCen;
|
|
if (vtLast.isParallelTo(vtThis))
|
|
{
|
|
vtLast.normalize();
|
|
ptCen = ptMid;
|
|
ptMid = ptCen + 0.5 * ptLast.distanceTo(ptThis) * vtLast;
|
|
}
|
|
else
|
|
{
|
|
ln1.intersectWith(ln2, ptCen);
|
|
}
|
|
|
|
double dR = ptCen.distanceTo(ptLast);
|
|
vtThis = ptMid - ptCen;
|
|
vtThis.normalize();
|
|
if (vtThis.isZeroLength())
|
|
{
|
|
ptMid = ptCen + 0.5 * ptLast.distanceTo(ptThis) * vtLastBk;
|
|
vtThis = ptMid - ptCen;
|
|
}
|
|
else
|
|
{
|
|
ptMid = ptCen + dR * vtThis;
|
|
}
|
|
|
|
AcDbArc* pArc = FormatArc(ptLast,ptMid,ptThis);
|
|
if (pArc != NULL)
|
|
{
|
|
double dSta = pArc->startAngle();
|
|
double dEnd = pArc->endAngle();
|
|
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
|
|
//acutPrintf(_T("\nsta,end = %g,%g"),pArc->startAngle(),pArc->endAngle());
|
|
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(1);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
delete pArc;
|
|
m_pCurStaRec->SetAcquirePoint(ptThis);
|
|
//TEST
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AcPolylineJig::AddRoadNode(WPipe::PipeDraw ePipe)
|
|
{
|
|
switch(ePipe)
|
|
{
|
|
case WPipe::eToPreView:
|
|
{
|
|
AcGePoint3d ptEnd = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
if ( !m_lstStaPtrsBack.IsEmpty() )
|
|
{
|
|
if (m_pCurStaRec->GetPlanPosition() <= 1)
|
|
{
|
|
//前后标高一致
|
|
MakeLine();
|
|
}
|
|
else
|
|
{
|
|
MakeArc();
|
|
}
|
|
|
|
AcGePoint3d ptGe,ptGe1;
|
|
ptGe1 = GetTailStatusRec()->GetAcquirePoint();
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
AcGeVector3d vtDir = m_pAngleWatch->m_vtDir;
|
|
|
|
m_pPolylineProxy->m_pAngleWatch->m_bFallInSnap = FALSE;
|
|
if (m_pPolylineProxy->m_bAngleWatchDraw && m_pPolylineProxy->m_pAngleWatch->snapWatch(ptGe1,ptGe,vtDir))
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);//???2024-11-25
|
|
m_pPolylineProxy->m_pAngleWatch->m_bFallInSnap = TRUE;
|
|
|
|
return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
case WPipe::eToCreate:
|
|
{
|
|
if (m_pCurve != NULL)
|
|
{
|
|
AecDb3dRoadAxisLine* pAxisLine = NULL;
|
|
if (m_idRoadLine.isValid())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_idRoadLine,AcDb::kForWrite))
|
|
{
|
|
pAxisLine = AecDb3dRoadAxisLine::cast(pEnt);
|
|
if (pAxisLine != NULL)
|
|
{
|
|
pAxisLine->setColorIndex(kMagenta);
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pAxisLine = new AecDb3dRoadAxisLine;
|
|
pAxisLine->setColorIndex(kMagenta);
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
|
|
CKTCadUtility::AddToBlockTableRecord(pAxisLine);
|
|
m_idRoadLine = pAxisLine->objectId();
|
|
pAxisLine->close();
|
|
}
|
|
|
|
//缓存添加本段
|
|
m_pRoadAxisLine->setColorIndex(kMagenta);
|
|
m_pRoadAxisLine->AppendCurveSeg(m_pCurve);
|
|
MoveAngWatchPosition();
|
|
|
|
AcGePoint3d ptGe,ptGe1;
|
|
ptGe1 = GetTailStatusRec()->GetAcquirePoint();
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
AcGeVector3d vtDir = m_pAngleWatch->m_vtDir;
|
|
|
|
m_pPolylineProxy->m_pAngleWatch->m_bFallInSnap = FALSE;
|
|
if (m_pPolylineProxy->m_bAngleWatchDraw && m_pPolylineProxy->m_pAngleWatch->snapWatch(ptGe1,ptGe,vtDir))
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
m_pPolylineProxy->m_pAngleWatch->m_bFallInSnap = TRUE;
|
|
|
|
return TRUE;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AcPolylineJig::AddArcRoadNode(WPipe::PipeDraw ePipe)
|
|
{
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return FALSE;
|
|
|
|
CPtrList listPtrs;
|
|
listPtrs.AddTail(&m_lstStaPtrsBack);
|
|
//
|
|
|
|
BOOL bSuccess = FALSE;
|
|
if (ePipe == WPipe::eToPreView)
|
|
{
|
|
listPtrs.AddTail(m_pCurStaRec);
|
|
}
|
|
|
|
AcGePoint3dArray arPts;
|
|
if (listPtrs.GetSize() == 3)
|
|
{
|
|
POSITION ps = listPtrs.GetHeadPosition();
|
|
|
|
AECStatusRecord* pRec0 = (AECStatusRecord*)listPtrs.GetNext(ps);
|
|
AECStatusRecord* pRec1 = (AECStatusRecord*)listPtrs.GetNext(ps);
|
|
AECStatusRecord* pRec2 = (AECStatusRecord*)listPtrs.GetNext(ps);
|
|
|
|
if (pRec2->GetPlanPosition() == 1394)//三点圆弧
|
|
{
|
|
AcDbArc* pArc = FormatArc(pRec0->GetAcquirePoint(),pRec2->GetAcquirePoint(),pRec1->GetAcquirePoint());
|
|
if (pArc != NULL)
|
|
{
|
|
double dSta = pArc->startAngle();
|
|
double dEnd = pArc->endAngle();
|
|
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
|
|
//acutPrintf(_T("\nsta,end = %g,%g"),pArc->startAngle(),pArc->endAngle());
|
|
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(kMagenta);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
delete pArc;
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
else//两点,方向半径
|
|
{
|
|
AcGePoint3d ptS = pRec0->GetAcquirePoint();
|
|
AcGePoint3d ptE = pRec1->GetAcquirePoint();
|
|
|
|
AcGePoint3d ptV = pRec2->GetAcquirePoint();
|
|
|
|
AcGeVector3d vtDir(ptV.x,ptV.y,ptV.z);
|
|
|
|
AcGePoint3d ptM = MidPoint(ptS,ptE);
|
|
double dR = vtDir.length();
|
|
|
|
double dL = ptS.distanceTo(ptE);
|
|
double dhh = dR * dR - 0.25 * dL * dL;
|
|
if (dhh < 1.e-3)
|
|
{
|
|
acutPrintf(_T("\n输入的半径国小!创建圆弧失败!"));
|
|
return FALSE;
|
|
}
|
|
double dh = sqrt(dhh);
|
|
|
|
AcGeVector3d vtN = ptE - ptS;
|
|
AcGeVector3d vtDir2 = vtDir.orthoProject(vtN);
|
|
vtDir2.normalize();
|
|
|
|
vtDir2.negate();
|
|
vtDir2 *= dh;
|
|
|
|
AcGePoint3d ptCen = ptM + vtDir2;
|
|
vtDir2.normalize();
|
|
ptM = ptCen - vtDir2 * dR;
|
|
|
|
AcDbArc* pArc = FormatArc(ptS,ptM,ptE);
|
|
if (pArc != NULL)
|
|
{
|
|
double dSta = pArc->startAngle();
|
|
double dEnd = pArc->endAngle();
|
|
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
|
|
//acutPrintf(_T("\nsta,end = %g,%g"),pArc->startAngle(),pArc->endAngle());
|
|
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(kMagenta);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
delete pArc;
|
|
//TEST
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
//缓存添加本段
|
|
if (ePipe == WPipe::eToCreate)
|
|
{
|
|
AecDb3dRoadAxisLine* pAxisLine = NULL;
|
|
if (m_idRoadLine.isValid())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_idRoadLine,AcDb::kForWrite))
|
|
{
|
|
pAxisLine = AecDb3dRoadAxisLine::cast(pEnt);
|
|
if (pAxisLine != NULL)
|
|
{
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pAxisLine = new AecDb3dRoadAxisLine;
|
|
pAxisLine->setColorIndex(kMagenta);
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
|
|
CKTCadUtility::AddToBlockTableRecord(pAxisLine);
|
|
m_idRoadLine = pAxisLine->objectId();
|
|
pAxisLine->close();
|
|
}
|
|
m_pRoadAxisLine->AppendCurveSeg(m_pCurve);
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
AECStatusRecord* AcPolylineJig::GetTailStatusRec() const
|
|
{
|
|
if (!m_lstStaPtrsBack.IsEmpty())
|
|
{
|
|
return (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
}
|
|
return m_pCurStaRec;
|
|
}
|
|
|
|
AcGeVector3d AcPolylineJig::GetLastInterface() const
|
|
{
|
|
if (m_pRoadAxisLine->GetCurveSegCount() > 0)
|
|
{
|
|
AECStatusRecord* pRecLast = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
AcDbCurve* pLast = m_pRoadAxisLine->GetCurveSeg(m_pRoadAxisLine->GetCurveSegCount() - 1);
|
|
|
|
AcGePoint3d ptLast = pRecLast->GetAcquirePoint();
|
|
|
|
pLast->getClosestPointTo(ptLast, ptLast);
|
|
|
|
AcGeVector3d vtLast;
|
|
pLast->getFirstDeriv(ptLast,vtLast);
|
|
|
|
return vtLast;
|
|
}
|
|
return AcGeVector3d::kXAxis;
|
|
}
|
|
|
|
void AcPolylineJig::MoveAngWatchPosition()
|
|
{
|
|
AECStatusRecord* pRec = NULL;
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return;
|
|
|
|
pRec = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
|
|
//导航表盘
|
|
if (pRec->GetStatusType() >= AECStatusRecord::kAngle &&
|
|
pRec->GetStatusType() <= AECStatusRecord::kPoint)
|
|
{
|
|
AcGePoint3d ptGe,ptGe1;
|
|
ptGe = pRec->GetAcquirePoint();
|
|
ptGe1 = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
AcGeVector3d vtDir;
|
|
vtDir = m_pAngleWatch->m_vtDir;
|
|
|
|
vtDir = GetLastInterface();
|
|
|
|
m_pAngleWatch->SetAngleWath(ptGe1,ptGe,vtDir);
|
|
}
|
|
}
|
|
|
|
BOOL AcPolylineJig::AddRoadNode(double dAngle,double dR)
|
|
{
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return FALSE;
|
|
|
|
if (m_pRoadAxisLine->GetCurveSegCount() > 0)
|
|
{
|
|
AECStatusRecord* pRecLast = (AECStatusRecord* )m_lstStaPtrsBack.GetTail();
|
|
AcDbCurve* pLast = m_pRoadAxisLine->GetCurveSeg(m_pRoadAxisLine->GetCurveSegCount() - 1);
|
|
AcGePoint3d ptLast = pRecLast->GetAcquirePoint();
|
|
|
|
double dB = 0.5 * dAngle;
|
|
|
|
AcGePoint3d ptSta,ptEnd;
|
|
pLast->getStartPoint(ptSta);
|
|
pLast->getEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptMid = MidPoint(ptSta,ptEnd);
|
|
AcGeVector3d vtLast = ptLast - ptMid;
|
|
|
|
AcGeVector3d vtLast2;
|
|
pLast->getFirstDeriv(ptLast,vtLast2);
|
|
|
|
if (vtLast2.dotProduct(vtLast) < 1.e-10)//反向
|
|
vtLast.negate();
|
|
|
|
AcGeVector3d vtThis = vtLast;
|
|
vtThis.rotateBy(dB,AcGeVector3d::kZAxis);
|
|
vtThis.normalize();
|
|
|
|
double dL = 2 * dR * fabs(sin(dB));
|
|
AcGePoint3d ptThis = ptLast + vtThis * dL;
|
|
|
|
if (dB < 1.e-10)
|
|
{vtThis.rotateBy(-PI / 2.0 - dB,AcGeVector3d::kZAxis);}
|
|
else
|
|
{vtThis.rotateBy(PI / 2.0 - dB,AcGeVector3d::kZAxis);}
|
|
|
|
AcGePoint3d ptCen = ptLast + vtThis * dR;
|
|
ptMid = MidPoint(ptLast,ptThis);
|
|
|
|
AcGeVector3d vtMid = ptMid - ptCen;
|
|
vtMid.normalize();
|
|
ptMid = ptCen + vtMid * dR;
|
|
|
|
AcDbArc* pArc = FormatArc(ptLast,ptMid,ptThis);
|
|
if (pArc != NULL)
|
|
{
|
|
m_pArc->setCenter(pArc->center());
|
|
m_pArc->setStartAngle(pArc->startAngle());
|
|
m_pArc->setEndAngle(pArc->endAngle());
|
|
m_pArc->setRadius(pArc->radius());
|
|
m_pArc->setNormal(pArc->normal());
|
|
m_pCurve = m_pArc;
|
|
m_pCurve->setColorIndex(kMagenta);
|
|
m_pPolylineProxy->m_pCurve = m_pCurve;
|
|
delete pArc;
|
|
|
|
AecDb3dRoadAxisLine* pAxisLine = NULL;
|
|
if (m_idRoadLine.isValid())
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,m_idRoadLine,AcDb::kForWrite))
|
|
{
|
|
pAxisLine = AecDb3dRoadAxisLine::cast(pEnt);
|
|
if (pAxisLine != NULL)
|
|
{
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pAxisLine = new AecDb3dRoadAxisLine;
|
|
pAxisLine->AppendCurveSeg(m_pCurve);
|
|
|
|
CKTCadUtility::AddToBlockTableRecord(pAxisLine);
|
|
m_idRoadLine = pAxisLine->objectId();
|
|
pAxisLine->close();
|
|
}
|
|
|
|
//缓存添加本段
|
|
m_pRoadAxisLine->AppendCurveSeg(m_pCurve);
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool AcPolylineJig::GetLastStatusAquire(AcGePoint3d& ptGe)
|
|
{
|
|
int nSize = (int)m_lstStaPtrsBack.GetCount();
|
|
if (nSize > 0)
|
|
{
|
|
AECStatusRecord* pRecLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
if (pRecLast != NULL)
|
|
ptGe = pRecLast->GetAcquirePoint();
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AcDbEntity* AcPolylineJig::entity() const
|
|
{
|
|
if (m_lstStaPtrsBack.IsEmpty())
|
|
return m_pCurve;
|
|
|
|
return m_pPolylineProxy;
|
|
}
|
|
|
|
Adesk::Boolean AcPolylineJig::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AcPolyline::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapSpecXData;
|
|
}
|
|
AecDbObjXDataMap* AcPolyline::GetSpecialtyData(AcDb::OpenMode bMode)
|
|
{
|
|
switch (bMode)
|
|
{
|
|
case AcDb::kForRead:
|
|
{
|
|
assertReadEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForWrite:
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
AssertWriteEnabled();
|
|
break;
|
|
}
|
|
case AcDb::kForNotify:
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return &m_mapSpecXData;
|
|
} |