#include "stdafx.h" #include "AecRoutingJig.h" #include "CoreTools.h" #include "CCableRouting.h" AecRoutingJig::AecRoutingJig() { m_nIndexPos = 0; m_pEntYellow = NULL; } AecRoutingJig::~AecRoutingJig() { if (m_pEntYellow != NULL) delete m_pEntYellow; AcDbEntity *pEnt = NULL; CableRoutePath *pPath = NULL; while(!m_ar3dRdAxLines.isEmpty()) { pPath = (CableRoutePath *)m_ar3dRdAxLines.last(); pEnt = NULL; m_mapPath2RoadAxLn.Lookup(pPath, (void *&)pEnt); if (pEnt != NULL) delete pEnt; m_mapPath2RoadAxLn.RemoveKey(pPath); delete pPath; m_ar3dRdAxLines.removeLast(); } } void AecRoutingJig::SetRoutingResult(AcArray &ar3dRdAxLines, AcDbEntity *pEntYellow) { m_ar3dRdAxLines.append(ar3dRdAxLines); m_pEntYellow = pEntYellow; } bool AecRoutingJig::doIt(AcDbObjectId &idPath, CableRoutePath*& pPath) { AcEdJig::DragStatus eStat; int nRes = 0; CString sPrompt = _T("\n鼠标点一下显示下一路径[选择该路径(S)/上一路径(L)]<退出>:"); pPath = NULL; AcDbEntity *pEnt = NULL; while (true) { setDispPrompt(sPrompt); pPath = NULL; eStat = drag(); switch (eStat) { case AcEdJig::kNormal: { m_nIndexPos += 1; if (m_nIndexPos >= m_ar3dRdAxLines.length()) m_nIndexPos = 0; break; } case AcEdJig::kCancel: case AcEdJig::kNull:// 退出 { acutPrintf(_T("\n")); return false; } case AcEdJig::kKW1://选择该路径(S) { if (m_nIndexPos > -1 && m_nIndexPos < m_ar3dRdAxLines.length()) { pPath = (CableRoutePath *)m_ar3dRdAxLines.at(m_nIndexPos); if (!m_mapPath2RoadAxLn.Lookup(pPath, (void *&)pEnt)) { pEnt = (AcDbEntity *)pPath->GetPathRoadAxLine(); } idPath = CoreTools::AddToModelSpace(pEnt); m_mapPath2RoadAxLn.RemoveKey(pPath); m_ar3dRdAxLines.removeAt(m_nIndexPos); } return true; break; } case AcEdJig::kKW2://上一路径(L) { m_nIndexPos -= 1; if (m_nIndexPos < 0) m_nIndexPos = 0; break; } default: break; } } return false; } AcEdJig::DragStatus AecRoutingJig::sampler() { setUserInputControls((UserInputControls) (AcEdJig::kAcceptOtherInputString | AcEdJig::kInitialBlankTerminatesInput| AcEdJig::kNullResponseAccepted)); CString sKeywordsList = _T("S L"); setKeywordList(sKeywordsList); AcEdJig::DragStatus eStat; AcGePoint3d ptGe, ptGeBase, ptGe2; ptGeBase = AcGePoint3d::kOrigin; AcGePoint3d pt; eStat = acquirePoint(pt); return eStat; } AcDbEntity *AecRoutingJig::entity() const { AcDbEntity *pEnt = NULL; CableRoutePath *pPath = NULL; if (m_nIndexPos > -1 && m_nIndexPos < m_ar3dRdAxLines.length()) { pPath = (CableRoutePath *)m_ar3dRdAxLines.at(m_nIndexPos); if (!m_mapPath2RoadAxLn.Lookup(pPath, (void *&)pEnt)) { pEnt = (AcDbEntity *)pPath->GetPathRoadAxLine(); m_mapPath2RoadAxLn.SetAt(pPath, (void *)pEnt); } return pEnt; } return m_pEntYellow; } Adesk::Boolean AecRoutingJig::update() { return Adesk::kTrue; }