#include "stdafx.h" #include "AecSectionPathJig.h" #include "AECStatusRecord.h" #include "AecDb3dRoadAxisLine.h" AecSectionPathJig::AecSectionPathJig(void) { } AecSectionPathJig::~AecSectionPathJig(void) { } void AecSectionPathJig::InitStatusRecsForVerLineSegs() { 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)]:")); pRec2->SetStatusType(AECStatusRecord::kPoint); pRec2->SetKeywordList(_T("A E U X")); m_arStaPtrs.Add(pRec2); pRec1->SetNextStatus(pRec2); pRec2->SetPlanPosition(1); pRec2->SetNextStatus(pRec2,1); m_pCurStaRec = pRec1; if (m_pAngleWatch != NULL) { m_pPolylineProxy->m_bAngleWatchDraw = false; } } AcEdJig::DragStatus AecSectionPathJig::sampler() { setUserInputControls( ( UserInputControls) ( AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted ) ); 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); AcGePoint3d ptAq = m_pCurStaRec->GetAcquirePoint(); ads_point pptGe,pptAq; acdbWcs2Ucs(asDblArray(ptAq),pptAq,false); acdbWcs2Ucs(asDblArray(ptGe),pptGe,false); pptGe[Z] = pptAq[Z]; ads_point pptGe2; acdbUcs2Wcs(pptGe,pptGe2,false); //当前标高 ptGe = asPnt3d(pptGe2); //取和上次垂直,投影 AcGeVector3d vtDir; if ( GetLastLineSegDir(vtDir) ) { AcGePlane pln; pln.set(ptGeBase,vtDir); ptGe = ptGe.orthoProject(pln); } double dDist = ptGeBase.distanceTo(ptGe); if ( dDist < 1.e-6) { return AcEdJig::kNoChange; } } if (eStat == AcEdJig::kNormal) { if (m_pCurStaRec->IsValSeted()) { ptGe2 = m_pCurStaRec->GetAcquirePoint(); double dDis = ptGe2.distanceTo(ptGe); if (dDis < 1.e-6) { //鼠标原地不动 return AcEdJig::kNoChange; } } ptGe2 = m_pCurStaRec->GetAcquirePoint(); AcGePoint3d ptAq = ptGe2; ads_point pptGe,pptAq; acdbWcs2Ucs(asDblArray(ptAq),pptAq,false); acdbWcs2Ucs(asDblArray(ptGe),pptGe,false); pptGe[Z] = pptAq[Z]; ads_point pptGe2; acdbUcs2Wcs(pptGe,pptGe2,false); //当前标高 ptGe = asPnt3d(pptGe2); //取和上次垂直,投影 AcGeVector3d vtDir; if ( GetLastLineSegDir(vtDir) ) { AcGePlane pln; pln.set(ptGeBase,vtDir); ptGe = ptGe.orthoProject(pln); } m_pCurStaRec->SetAcquirePoint(ptGe); 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; } bool AecSectionPathJig::GetLastLineSegDir(AcGeVector3d& vtDir) { if ( m_lstStaPtrsBack.GetCount() >= 2) { POSITION ps = m_lstStaPtrsBack.GetTailPosition(); AECStatusRecord* pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetPrev(ps); if (pLast != NULL) { AECStatusRecord* pLLast = (AECStatusRecord*)m_lstStaPtrsBack.GetPrev(ps); if (pLLast != NULL) { vtDir = pLast->GetAcquirePoint() - pLLast->GetAcquirePoint(); return true; } } } return false; } bool AecSectionPathJig::GetSectionPath(AcGePoint3dArray& arPts) { AcDbObjectId idRoadLn = GetRoadAxisLineId(); AcDbPolyline* pPl = NULL; AcDbEntity* pEnt = NULL; if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,idRoadLn,AcDb::kForWrite)) { AecDb3dRoadAxisLine* pRoad = AecDb3dRoadAxisLine::cast(pEnt); if (pRoad != NULL) { pPl = pRoad->ConvertTo2dPline(); } pEnt->erase(); pEnt->close(); } if (pPl != NULL) { AcGePoint3d ptGe; for (int i = 0;i < pPl->numVerts();i++) { pPl->getPointAt(i,ptGe); arPts.append(ptGe); } delete pPl; return arPts.isEmpty() ? false : true; } return false; }