多段线类型
class McDbPolyline : public McDbCurve;
McDbPolyline.h
例如:MxDrawX.ocx中绘PL线的代码
McDbPolyline* MxDrawXDrawPath::MakePolyline(double dW) { if(m_vecData.size() < 2) return NULL; McDbPolyline* pPL = new McDbPolyline; bool isHaveWidth = false; for(unsigned int i = 0; i < m_vecData.size();i++) { pPL->addVertexAt(m_vecData[i].pt, m_vecData[i].dBulge, m_vecData[i].dStartWidth, m_vecData[i].dEndWidth ); if((m_vecData[i].dStartWidth > 0 ) || (m_vecData[i].dEndWidth > 0) ) { isHaveWidth = true; } } if(m_isClosed) pPL->setClosed(Mdesk::kTrue); if((!isHaveWidth) && (!MxT::IsZero(dW)) ) { pPL->setConstantWidth(dW); } ClaerData(); return pPL; } LONG CMxDrawXCtrl::DrawPathToPolyline(void) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: 在此添加调度处理程序代码 McDbPolyline* pPolyline = m_pDrawPath->MakePolyline(m_dLineWidth); if(pPolyline == NULL) return 0; std::auto_ptr<MxDrawXDrawFun> spDrawFun(DrawFun() ); return spDrawFun->AddToCurrentSpace(pPolyline); }
创建Pl线代码
AcDbPolyline* pPL = new AcDbPolyline; pPL->setConstantWidth(dLineWidth); pPL->addVertexAt(0,pt1.convert2d(AcGePlane::kXYPlane)); pPL->addVertexAt(1,pt2.convert2d(AcGePlane::kXYPlane)); return AddToModelSpace(pPL,pDatabase);