#include "stdafx.h" #include "DrawRoadDlg.h" // 引入绘制道路对话框头文件 #include "TRoadDragJig.h" #include "RoadFillterMgr.h" ////////////////////////////////////////////////////////////// // // 命令函数:道路绘制 // ////////////////////////////////////////////////////////////// using namespace RoadDrag; CStateData* ConRoadStateClass(TRoadDragContext::ESequence eSequence, TRoadDragJig *pJig, TRoadDragContext *pContex) { switch (eSequence) { case TRoadDragContext::eFirstIn: return new CFirstInState(pJig, pContex); break; case TRoadDragContext::eLineRoad: return new CLineRoadState(pJig, pContex); break; case TRoadDragContext::eNextLineRoad: return new CNextLineRoadState(pJig, pContex); break; case TRoadDragContext::eThirdLineRoad: return new CThirdLineRoadState(pJig, pContex); break; case TRoadDragContext::eArcRoad: return new CArcRoadState(pJig, pContex); break; case TRoadDragContext::eNextArcRoad: return new CNextArcRoadState(pJig, pContex); break; case TRoadDragContext::eArcMidRoad: return new CMidArcRoadState(pJig, pContex); break; default: return NULL; break; } } void DrawRoadCmd() { CDrawRoadDlg dlg(acedGetAcadFrame()); { CAcModuleResourceOverride vTemp; if ( !dlg.Create(dlg.IDD, acedGetAcadFrame()) ) return; } dlg.ShowWindow(SW_SHOW); acedGetAcadDwgView()->SetFocus(); // jig负责控制实时显示 TRoadDragJig jig(&dlg); // 道路手工绘制时,保存的上下文,以及一些相关数据 TRoadDragContext context(&dlg); // 道路绘制状态类,供jig调用 CStateData *pState = NULL; while (context.GetSequenceState() != TRoadDragContext::eSequenceCancel && context.GetSequenceState() != TRoadDragContext::eSequenceOk) { ASSERT(pState == NULL); pState = ConRoadStateClass(context.GetSequenceState(), &jig, &context); jig.SetState(pState); jig.DoIt(); delete pState; pState = NULL; } dlg.SetCmdNum(0); if (IsWindow(dlg.m_hWnd)) dlg.DestroyWindow(); } ////////////////////////////////////////////////////////////// // // 命令函数:道路圆角 // ////////////////////////////////////////////////////////////// void FilletRoadCmd() { CRoadFillterMgr mgrFillt; BOOL ret = FALSE; // 选择道路边线 while(TRUE) { if (!mgrFillt.SelectRoad()) { return; } mgrFillt.MakeFilroadConnect(); if (mgrFillt.IsSameCenter()) {// 如果是同圆心的,需要对道路两两进行一次分组(道路的两边)(识别出来道路) mgrFillt.GroupConnect(); } // 执行倒角 if (!mgrFillt.FilltRoad()) acedPrompt(_T("\nz,无法正确倒角!")); mgrFillt.Draw(); mgrFillt.ReleaseMem(); } }