#include "stdafx.h" #include "dbobjptr.h" #include "SHAcDbBlockTableRecPtr.h" #include "AcDbObjectPtr.h" #include "DbVerticalSectionFeed.h" #include "AecDbSymbWithText.h" #include "AecDbSymbElevation.h" #include "AecDbSymbArrow.h" #include "DbWell.h" #include "DbPipe.h" #include "dbgridsheet.h" #include #include extern BOOL IsNodeWell(AcDbObjectId id); extern AcDbObjectId InitTextStyle(const TCHAR *pszStyle, AcDbDatabase *pDb = NULL); extern AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL); extern bool GetCrossInfo(const std::vector &vecCross, CrossPoint &cr); extern CString I2Str(double i); extern void CalcCrossPipes(DList &lstPipe, DList &lstOtherPipe, std::vector &vecCross, bool bShowPipeEndNotLinkedPipe); namespace { int GetPipeLenPrecision() { return 3; } int GetWellDeepPrecision() { return 3; } } ACRX_DXF_DEFINE_MEMBERS(CDbVerticalSectionFeed, AecXDbEntityBaseEx, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, AEC_ZT_VERTICALSECTION_FEED, "AEC_VERTICALSECTION_FEED图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"); const Adesk::UInt8 CDbVerticalSectionFeed::g_nVersion = 2; // cet 2016.5.11 modify 添加新成员变量 CDbVerticalSectionFeed::CDbVerticalSectionFeed() { m_iScaleX = 100; m_iScaleY = 50; m_iCalcMode = 0; m_nStartDeep = 0; m_nMaxDeep = 0; m_nMinDeep = 0; m_nSpare = 0; m_nGridScale = 1; m_idTextLayer = NULL; m_idGridLayer = NULL; m_idSectLayer = NULL; m_idDoteLayer = NULL; m_sSheetHead = _T("井编号 井径(mm) 设计地面标高(m) 自然地面标高(m) 埋设深度(m) 覆土厚度(m) 管标高(m)管径(mm) 备注"); m_nCalcType = 1; // cet 2015.5.11 add 默认按已知覆土厚度计算 } void CDbVerticalSectionFeed::CopyPropertiesFrom(AcDbEntity *pSrc, unsigned gMatchFlag) { assertWriteEnabled(); CDbVerticalSectionFeed *pSect = CDbVerticalSectionFeed::cast(pSrc); if (pSect) { m_iScaleX = pSect->m_iScaleX; m_iScaleY = pSect->m_iScaleY; m_iCalcMode = pSect->m_iCalcMode; } AecXDbEntityBaseEx::CopyPropertiesFrom(pSrc, gMatchFlag); } //Acad::ErrorStatus CDbVerticalSectionFeed::subGetClassID(CLSID* pClsid) const //{ // return Acad::eOk; //} Acad::ErrorStatus CDbVerticalSectionFeed::subGetOsnapPoints(AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& ptPick, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds) const { Acad::ErrorStatus es = AecXDbEntityBaseEx::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); AcDbLine line1(m_ptTopLeft, m_ptBottomLeft); line1.getOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); AcDbLine line2(m_ptBottomLeft, m_ptBottomRight); line2.getOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); AcDbLine line3(m_ptTolRight, m_ptBottomRight); line3.getOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); return es; } // 取得所有的夹点 Acad::ErrorStatus CDbVerticalSectionFeed::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { assertReadEnabled(); XPoint pt = m_ptIns; ads_polar(pt, m_nLayoutRotation + PI, 10 * GetPScale(), pt); gripPoints.append(pt); for (int i = 0; i < m_lstPt.Length(); i++) { gripPoints.append(m_lstPt[i]); } // cet 2017.9.6 add 添加表格夹点,便于用户拖动对齐纵断面图 gripPoints.append(m_ptTopLeft); gripPoints.append(m_ptTolRight); gripPoints.append(m_ptBottomLeft); gripPoints.append(m_ptBottomRight); return Acad::eOk; } // 功能: 夹点操作 Acad::ErrorStatus CDbVerticalSectionFeed::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); AcGeMatrix3d mat; AcGeVector3d vtOffset = offset; vtOffset.z = 0; mat.setToTranslation(vtOffset); int idx = 0; for (int i = 0; i < indices.length(); i++) { idx = indices[i]; if (idx == 0 || idx > m_lstPt.Length()) // cet 2017.9.6 modify 拖动底部两个夹点之一时,移动纵断面图 { m_ptIns.TransformBy(mat); ads_matrix mat2; GlobalFunc::AsAdsMatrix(mat, mat2); m_lstPt.TransUCS(mat2); // cet 2017.9.6 add 更新表格夹点 m_ptTopLeft.TransformBy(mat); m_ptTolRight.TransformBy(mat); m_ptBottomLeft.TransformBy(mat); m_ptBottomRight.TransformBy(mat); } else { XPoint ptOffset = *m_lstPt[idx - 1]; XPoint ptOld = ptOffset; ptOffset.TransformBy(mat); double dScaleY = m_iScaleY; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 double nDist = (ptOffset.y - ptOld.y) / dScaleY; m_lstFeedWell[(idx - 1) * 2]->m_nUpEle += nDist; for (int j = 0; j < m_lstFeedWell.Length(); j++) { if (m_lstFeedWell[j]->m_csName == m_lstFeedWell[(idx - 1) * 2]->m_csName) { m_lstFeedWell[j]->m_nUpEle = m_lstFeedWell[(idx - 1) * 2]->m_nUpEle; break; } } Calc(); } } Acad::ErrorStatus es = Acad::eOk; return es; } Acad::ErrorStatus CDbVerticalSectionFeed::GetGripText(int idx, CString &cs) const { Acad::ErrorStatus es = Acad::eOk; // cet 2017.9.6 add 底部添加的两个夹点提示 if (idx > m_lstPt.Length()) { cs = _T("移动"); return es; } switch (idx) { case 0: cs = _T("移动"); break; default: cs = _T("修改井面标高"); } return es; } // 从DWG读入数据: Acad::ErrorStatus CDbVerticalSectionFeed::dwgInFields(AcDbDwgFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = AecXDbEntityBaseEx::dwgInFields(pFiler); if (es != Acad::eOk) return es; es = CLabelStyle::dwgInFields(pFiler); if (es != Acad::eOk) return es; Adesk::UInt8 nVer; pFiler->readItem(&nVer); if (nVer > g_nVersion) {// Version is too new return Acad::eMakeMeProxy; } pFiler->readItem((AcGePoint3d *)&m_ptIns); pFiler->readItem(&m_iScaleX); pFiler->readItem(&m_iScaleY); pFiler->readItem(&m_iCalcMode); pFiler->readItem(&m_nStartDeep); pFiler->readItem(&m_nSpare); pFiler->readItem(&m_nMaxDeep); pFiler->readItem(&m_nMinDeep); pFiler->readItem(&m_idTextLayer); pFiler->readItem(&m_idGridLayer); pFiler->readItem(&m_idSectLayer); pFiler->readItem(&m_idDoteLayer); GlobalFunc::ReadString(pFiler, m_sSheetHead); // GlobalFunc::ReadString(pFiler, m_sSheetRow); Adesk::UInt16 nNum = 0; pFiler->readItem(&nNum); m_lstFeedWell.Reset(); for (Adesk::UInt16 i = 0; i < nNum; i++) { TFeedWellData *pData = new TFeedWellData; pData->dwgInFields(pFiler); m_lstFeedWell.Append(pData); } m_lstPt.Reset(); pFiler->readItem(&nNum); for (i = 0; i < nNum; i++) { XPoint PtTemp; pFiler->readItem((AcGePoint3d *)&PtTemp); m_lstPt.NewAppend(PtTemp); } m_nGridScale = GetGridScale(); // cet 2016.5.11 add 添加计算方式 if (nVer > 1) { pFiler->readItem(&m_nCalcType); } return pFiler->filerStatus(); } Acad::ErrorStatus CDbVerticalSectionFeed::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = AecXDbEntityBaseEx::dwgOutFields(pFiler); if (es != Acad::eOk) return es; es = CLabelStyle::dwgOutFields(pFiler); if (es != Acad::eOk) return es; pFiler->writeItem(g_nVersion); pFiler->writeItem((const AcGePoint3d &)m_ptIns); pFiler->writeItem(m_iScaleX); pFiler->writeItem(m_iScaleY); pFiler->writeItem(m_iCalcMode); pFiler->writeItem(m_nStartDeep); pFiler->writeItem(m_nSpare); pFiler->writeItem(m_nMaxDeep); pFiler->writeItem(m_nMinDeep); pFiler->writeItem(m_idTextLayer); pFiler->writeItem(m_idGridLayer); pFiler->writeItem(m_idSectLayer); pFiler->writeItem(m_idDoteLayer); pFiler->writeItem((const TCHAR *)m_sSheetHead); // pFiler->writeItem((const TCHAR *)m_sSheetRow); //8.0数据 Adesk::UInt16 nCount = (Adesk::UInt16)m_lstFeedWell.Length(); pFiler->writeItem(nCount); for (Adesk::UInt16 i = 0; i < nCount; i++) { m_lstFeedWell[i].dwgOutFields(pFiler); } nCount = (Adesk::UInt16)m_lstPt.Length(); pFiler->writeItem(nCount); for (i = 0; i < nCount; i++) { pFiler->writeItem((AcGePoint3d &)m_lstPt[i]); } // cet 2016.5.11 add 添加计算方式 Adesk::UInt8 nVer; //if (g_nSaveTArchVer <= 10) //{ // nVer = 1; //} //else { nVer = g_nVersion; } if (nVer > 1) { pFiler->writeItem(m_nCalcType); } return pFiler->filerStatus(); } Acad::ErrorStatus CDbVerticalSectionFeed::dxfInFields(AcDbDxfFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = Acad::eOk; es = AecXDbEntityBaseEx::dxfInFields(pFiler); return es; } Acad::ErrorStatus CDbVerticalSectionFeed::dxfOutFields(AcDbDxfFiler* pFiler) const { Acad::ErrorStatus es = Acad::eOk; es = AecXDbEntityBaseEx::dxfOutFields(pFiler); return es; } // Active when being rotated, scaled, moved, etc. Acad::ErrorStatus CDbVerticalSectionFeed::subTransformBy(const AcGeMatrix3d& xform) { assertWriteEnabled(); m_ptIns.TransformBy(xform); ads_matrix mat; GlobalFunc::AsAdsMatrix(xform, mat); m_lstPt.TransUCS(mat); Acad::ErrorStatus es = Acad::eOk; return es; } Acad::ErrorStatus CDbVerticalSectionFeed::subIntersectWith(const AcDbEntity* ent, AcDb::Intersect intType, AcGePoint3dArray& points, int thisGsMarker, int otherGsMarker) const { return Acad::eOk; } Acad::ErrorStatus CDbVerticalSectionFeed::subIntersectWith(const AcDbEntity* ent, AcDb::Intersect intType, const AcGePlane& projPlane, AcGePoint3dArray& points, int thisGsMarker, int otherGsMarker) const { return Acad::eOk; } //const TCHAR* CDbVerticalSectionFeed::GetSheetRowHeight() const //{ // const EntityFields &fd = GetFields(); // CString sData; // fd.GFD(_T("ROW_HEIGHT"), sData); // return (const TCHAR*)sData; //} // //void CDbVerticalSectionFeed::SetSheetRowHeight(const TCHAR* szSheetRowHeight) //{ // assertWriteEnabled(); // EntityFields &fd = Fields(); // fd.SFD(_T("ROW_HEIGHT"), szSheetRowHeight); //} void CDbVerticalSectionFeed::DrawBreakPipe(XPoint ptStart, XPoint ptEnd, AcGiDraw &dc) const { AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idSectLayer); XPoint ptMid, ptTmp1, ptTmp2; XLine l1(ptStart, ptEnd); ptMid = l1.MidPoint(); XLine l2(ptStart, ptMid); ptTmp1 = l2.MidPoint(); ads_polar(ptTmp1, m_nLayoutRotation + PI, l2.GetLength() / 4, ptTmp1); XArc arc(ptStart, ptTmp1, ptMid); //dc.DrawArc(arc, 0); DrawArc(dc, arc); XLine l3(ptEnd, ptMid); ptTmp2 = l3.MidPoint(); ads_polar(ptTmp2, m_nLayoutRotation, l3.GetLength() / 4, ptTmp2); XArc arc2(ptMid, ptTmp2, ptEnd); //dc.DrawArc(arc2, 0); DrawArc(dc, arc2); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawGridLine(XPoint ptStart, XPoint ptEnd, AcGiDraw &dc) const { if (m_nGridScale < 0.01) return; AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idGridLayer); XLine pLine(ptStart, ptEnd, 1); //dc.DrawLine(pLine, 0); BaseEx::DrawLine(dc, pLine); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawDoteLine(XPoint ptStart, XPoint ptEnd, AcGiDraw &dc) const { AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idDoteLayer); XLine pLine(ptStart, ptEnd, 1); //dc.DrawLine(pLine, 0); BaseEx::DrawLine(dc, pLine); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawLine(XPoint ptStart, XPoint ptEnd, AcGiDraw &dc) const { AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idSectLayer); XLine pLine(ptStart, ptEnd, 1); //dc.DrawLine(pLine, 0); BaseEx::DrawLine(dc, pLine); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawPLine(XPoint ptStart, XPoint ptEnd, AcGiDraw &dc, double nWeight) const { AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idSectLayer); XLine pLine(ptStart, ptEnd, 1); XCurveSegment seg; seg = pLine; XPoly2D poly; seg.AsPoly2D(poly); AcDbPolyline pline; GlobalFunc::PolyConvert(poly, pline); //XAcGiViewDraw &viewDraw = (XAcGiViewDraw &)dc; //int nNum = pline.numVerts(); //if (nNum > 0) { // for (int k = 0; k < nNum; k++) { // pline.setWidthsAt(k, nWeight, nWeight); // } // viewDraw.Polyline(pline); //} DrawPline(dc, pline); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawText(XPoint ptText, const TCHAR*szText, AcGiDraw::TextAlignment Align, AcGiDraw &dc, double nRotation) const { nRotation = m_nLayoutRotation + nRotation; AcDbObjectId idTextStyle = m_idTextStyle; if (!idTextStyle) idTextStyle = InitTextStyle(_T("Standard")); AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idTextLayer); AecXDbText text; text.SetPScale(GetPScale()); text.setLayer(m_idTextLayer); text.SetStyleId(idTextStyle); text.SetText(szText); text.SetRotation(nRotation); text.SetLocation(ptText); text.SetHeight(m_dTextHeight); text.SetAlignment(Align); //text.ExplodeOrDraw2d(dc); DrawBaseEx(dc, text); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawScaleArrow(XPoint ptStart, XPoint ptEnd, const TCHAR*szText, AcGiDraw &dc) const { AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idTextLayer); AcDbObjectId idTextStyle = m_idTextStyle; if (!idTextStyle) idTextStyle = InitTextStyle(_T("Standard")); AecXDbSymbArrow pArrow; pArrow.setPropertiesFrom(this); XPoly2D poly; poly.AppendNode(ptStart); poly.AppendNode(ptEnd); pArrow.SetPoly2D(poly); pArrow.setLayer(m_idTextLayer); pArrow.SetTextLayerId(m_idTextLayer); pArrow.SetTextStyleId(idTextStyle); pArrow.SetTextHeight(m_dTextHeight); pArrow.SetTextAlign(AecXDbSymbArrow::kAlignMid); pArrow.SetArrowSize(2); pArrow.SetText(szText); XPoint ptText = pArrow.GetDefaultTextLocation(); pArrow.SetTextLocation(ptText); //pArrow.ExplodeOrDraw2d(dc); DrawBaseEx(dc, pArrow); dc.SetLayer(idLayerOld); } void CDbVerticalSectionFeed::DrawEllipse(XPoint ptCen, double nRadiusLong, double nRadiusShort, AcGiDraw &dc, const AcDbObjectId idLay, bool *pRet) const { if (pRet != NULL) { *pRet = false; } // cet 2016.7.5 add 超出管井显示区域 AcGeVector3d vtDir = AcGeVector3d::kXAxis; vtDir.rotateBy(m_nLayoutRotation + PI * 0.5, AcGeVector3d::kZAxis); XLine line(ptCen, ptCen + vtDir * 10, INFINITE); XPoint pt1, pt2; m_ptTop.Project(&line, pt1); m_ptBottom.Project(&line, pt2); if (pt1.Distance(ptCen) + pt2.Distance(ptCen) > pt1.Distance(pt2) + 0.001 && (pt1.Distance(ptCen) > pt2.Distance(ptCen) && ptCen.Distance(pt2) > nRadiusLong + 0.0001 || pt1.Distance(ptCen) < pt2.Distance(ptCen) && ptCen.Distance(pt1) > nRadiusLong + 0.0001)) { return; } AcDbEllipse ellipse; double ratio = nRadiusShort / nRadiusLong; XPoint ptTem; ads_polar(ptCen, m_nLayoutRotation + PI / 2, nRadiusLong, ptTem); AcGeVector3d majorAxis = ptTem.AsAcGePoint3d() - ptCen.AsAcGePoint3d(); // cet 2016.7.5 add 长轴小于短轴 if (nRadiusLong + 0.001 < nRadiusShort) { ads_polar(ptCen, m_nLayoutRotation, nRadiusShort, ptTem); majorAxis = ptTem.AsAcGePoint3d() - ptCen.AsAcGePoint3d(); ratio = nRadiusLong / nRadiusShort; } ellipse.set(ptCen, AcGeVector3d::kZAxis, majorAxis, ratio); int iColorIdx(7); OPENOBJ_BEGIN(idLay, AcDb::kForRead, AcDbLayerTableRecord, pRec); if (pRec) { AcCmColor color = pRec->color(); iColorIdx = color.colorIndex(); } OPENOBJ_END(); ellipse.setColorIndex(iColorIdx); ellipse.setLayer(m_idGridLayer); // cet 2018.2.8 add dc.DrawEntity(ellipse); if (pRet != NULL) { *pRet = true; } } Acad::ErrorStatus CDbVerticalSectionFeed::DrawScale(AcGiDraw &dc, XPoint &ptEnd) const { double dScaleY = m_iScaleY; double dScaleX = m_iScaleX; dScaleX = GetPScale() / dScaleX * 1000; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 XPoint ptStart; XPoint ptIns = m_ptIns; double nHighEle = m_nMaxDeep; double nLowEle = m_nMinDeep; double nEleStart = 0.0; nEleStart = m_lstFeedWell[0].m_nUpEle; //绘制比例尺 int iHighEle = (int)(nHighEle + 1); int iLowEle = (int)nLowEle; if (fabs(nLowEle) > iLowEle && nLowEle < 0) iLowEle--; int iAllMeter = iHighEle - iLowEle; nHighEle = (double)iHighEle - nEleStart; ads_polar(ptIns, m_nLayoutRotation + PI, 20 * GetPScale(), ptStart); ads_polar(ptStart, m_nLayoutRotation + PI / 2, nHighEle * dScaleY, ptStart); //第一行比例尺 XPoint ptText, ptFisrtStart, ptStart2, ptEnd2, pt1; ptFisrtStart = ptStart; CString csText; csText.Format(_T("%.2f"), (double)iHighEle); ads_polar(ptStart, m_nLayoutRotation + PI, 3 * GetPScale(), ptText); DrawText(ptText, csText, AcGiDraw::kBottomRight, dc); ads_polar(ptStart, m_nLayoutRotation, GetAllPipeLen() + 20 * GetPScale(), pt1); DrawGridLine(pt1, ptStart, dc); double nHighEleTmp = (double)iHighEle; ads_polar(ptStart, m_nLayoutRotation + PI, 2 * GetPScale(), ptStart2); DrawGridLine(ptStart, ptStart2, dc); double nNum = 1 / m_nGridScale; double nGridScale = m_nGridScale; if (m_nGridScale < 0.01) { nNum = 1; nGridScale = 1; } for (int i = 0; i < iAllMeter * nNum; i++) { ads_polar(ptStart, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd); if (i % 2 == 0) ads_polar(ptStart, m_nLayoutRotation + PI, 1.5 * GetPScale(), ptStart2); else ads_polar(ptStart, m_nLayoutRotation + PI, 0.5 * GetPScale(), ptStart2); ads_polar(ptStart2, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd2); DrawPLine(ptStart2, ptEnd2, dc, 1 * GetPScale()); ads_polar(ptStart, m_nLayoutRotation + PI, 2 * GetPScale(), ptStart2); ads_polar(ptStart2, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd2); DrawLine(ptStart, ptEnd, dc); DrawLine(ptStart2, ptEnd2, dc); ads_polar(ptEnd, m_nLayoutRotation + PI, 3 * GetPScale(), ptText); nHighEleTmp = nHighEleTmp - nGridScale; csText.Format(_T("%.2f"), nHighEleTmp); DrawText(ptText, csText, AcGiDraw::kBottomRight, dc); ptStart = ptEnd; //绘制横网格 if (m_nGridScale > 0.01) { ads_polar(ptEnd, m_nLayoutRotation, GetAllPipeLen() + 20 * GetPScale(), pt1); DrawGridLine(pt1, ptEnd, dc); } } ads_polar(ptEnd, m_nLayoutRotation + PI, 2 * GetPScale(), ptEnd2); DrawGridLine(ptEnd, ptEnd2, dc); // cet 2016.7.5 add 管井Y值方向显示区域 const_cast(m_ptTop) = ptFisrtStart; const_cast(m_ptBottom) = ptEnd; //绘制比例 ads_polar(ptStart, m_nLayoutRotation + PI, 30 * GetPScale(), ptEnd); ads_polar(ptEnd, m_nLayoutRotation, 15 * GetPScale(), pt1); DrawScaleArrow(ptEnd, pt1, XString(_T("1:%d"), m_iScaleX), dc); ads_polar(ptEnd, m_nLayoutRotation + PI / 2, 15 * GetPScale(), pt1); DrawScaleArrow(ptEnd, pt1, XString(_T("1:%d"), m_iScaleY), dc); //绘制竖网格 ptStart当前是比例尺最下端 if (m_nGridScale > 0.01) { double nCount = (GetAllPipeLen() + 20 * GetPScale()) / (dScaleY / nNum); for (i = 1; i <= nCount; i++) { XPoint ptTmp1, ptTmp2; ads_polar(ptStart, m_nLayoutRotation, i * dScaleY / nNum, ptTmp1); ads_polar(ptTmp1, m_nLayoutRotation + PI / 2, iAllMeter * dScaleY, ptTmp2); DrawGridLine(ptTmp1, ptTmp2, dc); } } // //绘制井中心线 // ads_polar(ptStart, m_nLayoutRotation-PI/2, 10*GetPScale(), ptEnd); // //ads_polar(ptEnd, m_nLayoutRotation+PI, 10*GetPScale(), ptEnd); // for(i=0;i lstAllPipe;//本图所有管线 // if(!!objectId()) // GetAllPipes(lstAllPipe); XPoint ptIns = m_ptIns; double dScaleY = m_iScaleY; double dScaleX = m_iScaleX; dScaleX = GetPScale() / dScaleX * 1000; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 double iDn = OuterDn(m_lstFeedWell[1].m_ID); iDn = iDn * dScaleY / 1000; double iDn2(0); double nEleStart = m_lstFeedWell[0].m_nUpEle; XPoint ptStart, ptEnd, pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, ptTmp, ptStartG, ptEndG; XPoint ptFrontUp, ptFrontLow; ptStart = ptIns; ads_polar(ptStart, m_nLayoutRotation + PI / 2, (m_lstFeedWell[0].m_nGroundEle - nEleStart) * dScaleY, ptStartG); double dPipeLen = 0; BOOL bDrawGround = FALSE; for (int i = 0; i < m_lstFeedWell.Length(); i++) { if (m_lstFeedWell[i].m_bIsWell) { //井 if (fabs(m_lstFeedWell[i].m_nGroundEle) > 0.0001) { bDrawGround = TRUE; break; } } } // // cet 2017.8.28 add 获取所有交叉信息 // DList lstPipe; // for(int i = 0; i < m_lstFeedWell.Length(); ++i) // { // if(!m_lstFeedWell[i].m_bIsWell) // { // lstPipe.Append(new AcDbObjectId(m_lstFeedWell[i].m_ID)); // } // } // std::vector vecCrossPoint; // CalcCrossPipes(lstPipe, lstAllPipe, vecCrossPoint, IsShowPipeEndNotLinkedPipe()); std::vector vecCrossPoint; GetCrossPointInfo(vecCrossPoint); for (i = 0; i < m_lstFeedWell.Length(); i++) { double nEle = m_lstFeedWell[i].m_nUpEle - nEleStart; //井面标高 double nEleG = m_lstFeedWell[i].m_nGroundEle - nEleStart;//地面标高 if (m_lstFeedWell[i].m_bIsWell) { //井 if (m_lstFeedWell[i].m_csName == _T("断管") && dPipeLen > 0) { double nI = m_lstFeedWell[i - 1].m_nI; double nLow = nI * dPipeLen / 2; ads_polar(pt7, m_nLayoutRotation, dPipeLen / 2, pt3); ads_polar(pt8, m_nLayoutRotation, dPipeLen / 2, pt4); ads_polar(pt3, m_nLayoutRotation + PI / 2, -nLow, pt3); ads_polar(pt4, m_nLayoutRotation + PI / 2, -nLow, pt4); DrawPLine(pt7, pt3, dc, 0.35 * GetPScale());//井底边线 DrawPLine(pt8, pt4, dc, 0.35 * GetPScale());//井底边线 DrawBreakPipe(pt3, pt4, dc); ads_polar(ptStart, m_nLayoutRotation, dPipeLen, ptEnd); continue; } else if (m_lstFeedWell[i].m_csName == _T("断管") && dPipeLen < 0.0001) { continue; } double nWellDia = fabs(m_lstFeedWell[i].m_nWellRadius * dScaleX * 0.002);//支持米单位 BOOL bIsNode = IsNodeWell(m_lstFeedWell[i].m_ID); if (i != m_lstFeedWell.Length() - 1) iDn = OuterDn(m_lstFeedWell[i + 1].m_ID) * dScaleY / 1000; if (i != 0) iDn2 = OuterDn(m_lstFeedWell[i - 1].m_ID) * dScaleY / 1000; //把井盖填平 if (dPipeLen < 0.001) { ads_polar(ptStart, m_nLayoutRotation + PI / 2, nEle * dScaleY, ptStart); ads_polar(ptStart, m_nLayoutRotation + PI, nWellDia / 2, pt1); ads_polar(ptStart, m_nLayoutRotation, nWellDia / 2, pt2); DrawLine(pt1, pt2, dc); } if (dPipeLen > 0) { BOOL bIsNode2 = IsNodeWell(m_lstFeedWell[i - 2].m_ID); //看前1井是否是节点 ads_polar(ptStart, m_nLayoutRotation, dPipeLen, ptEnd); //ptEnd.y = ptIns.y; nEle = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i - 2].m_nUpEle; //井面标高 ads_polar(ptEnd, m_nLayoutRotation + PI / 2, nEleG * dScaleY, ptEndG); ads_polar(ptEnd, m_nLayoutRotation + PI / 2, nEle * dScaleY, ptEnd); if (bDrawGround) DrawDoteLine(ptStartG, ptEndG, dc); ads_polar(ptEnd, m_nLayoutRotation + PI, nWellDia / 2, pt1); ads_polar(ptEnd, m_nLayoutRotation, nWellDia / 2, pt2); DrawLine(pt1, pt2, dc);//把井盖填平 // cet 2016.12.8 modify 使用管道首端井的宽度 // ads_polar(ptStart, m_nLayoutRotation, nWellDia/2, pt3); ads_polar(ptStart, m_nLayoutRotation, i >= 2 ? fabs(m_lstFeedWell[i - 2].m_nWellRadius * dScaleX * 0.002) / 2 : nWellDia / 2, pt3); DrawLine(pt3, pt1, dc);//绘制地面线 // cet 2016.12.8 modify 使用管道首端井的宽度 // ads_polar(ptStart, m_nLayoutRotation, nWellDia/2, pt1); ads_polar(ptStart, m_nLayoutRotation, i >= 2 ? fabs(m_lstFeedWell[i - 2].m_nWellRadius * dScaleX * 0.002) / 2 : nWellDia / 2, pt1); ads_polar(ptEnd, m_nLayoutRotation + PI, nWellDia / 2, pt2); //如果是节点井,就不绘制井道,地面填充也填满 if (bIsNode) pt2 = ptEnd; if (bIsNode2) pt1 = ptStart; ads_polar(pt1, m_nLayoutRotation - PI / 2, 3 * GetPScale(), pt3); ads_polar(pt2, m_nLayoutRotation - PI / 2, 3 * GetPScale(), pt4); XPoly2D poly2d; poly2d.AppendNode(pt1); poly2d.AppendNode(pt3); poly2d.AppendNode(pt4); poly2d.AppendNode(pt2); // cet 2018.2.8 modify 填充 // if(!!objectId()) // dc.DrawHatch(poly2d, _T("AR-HBONE"), 0.5*GetPScale());//动态拖动速度极慢 DrawHatch(dc, poly2d); ptStart = ptEnd; ptStartG = ptEndG; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 绘制表示本井其它管标高的管,用椭圆表示 OPENOBJ_BEGIN(m_lstFeedWell[i].m_ID, AcDb::kForRead, CDbEquipment, pEquip); if (pEquip) { int num = pEquip->GetInterfaceNum(); if (num > 1) { // cet 2016.9.6 modify 未考虑起始端井连接的管道 for (int j = 0; j < num; j++) { CPipeInterface face; pEquip->GetInterface(j, face); if (i > 0 && face.m_idPipe == m_lstFeedWell[i - 1].m_ID) continue; if (i < m_lstFeedWell.Length() - 1 && face.m_idPipe == m_lstFeedWell[i + 1].m_ID) continue; double nPipeDownEle = 0.0; // cet 2016.7.6 add 管底标高 double dOuterDn = 0.0; // cet 2016.7.6 add 外径 double nThirdDn(0); double dDn = 0.0; AcDbObjectId idLay = NULL; bool bBranch = true; // cet 2016.9.8 add 是否为支路 OPENOBJ_BEGIN(face.m_idPipe, AcDb::kForRead, CDbPipe, pPipe); if (pPipe) { nThirdDn = (pPipe->OuterDn() - pPipe->GetPipeThick() * 2) * dScaleY / 1000; idLay = pPipe->layerId(); // cet 2016.7.6 add 计算管内底标高 dDn = (pPipe->OuterDn() - pPipe->GetPipeThick() * 2) / 2000; if (pPipe->StartPoint().Distance2d(face.m_ptLocation) < 0.001) { nPipeDownEle = pPipe->StartPoint().z / dUnitMeter - dDn; } else { nPipeDownEle = pPipe->EndPoint().z / dUnitMeter - dDn; } dOuterDn = pPipe->OuterDn(); bBranch = IsBrach(pPipe, m_lstFeedWell[i].m_ID); // cet 2016.9.8 add 是否为支路 } OPENOBJ_END(); // cet 2016.7.6 del 直接获取管底标高 // CString csPipeDownEle = pEquip->GetISysLabel(j); // if(csPipeDownEle == _T("")) // continue; // double nPipeDownEle = _tstof(csPipeDownEle); // cet 2016.9.8 modify 细化显示控制 // if(fabs(nPipeDownEle - m_lstFeedWell[i].m_nDownEle) > 0.001) // cet 2016.9.6 modify 不绘制管内底标高与井底标高一致的管道 if ((IsOnlyShowBranch() && bBranch || !IsOnlyShowBranch()) && // 控制是否只显示支路 ((fabs(nPipeDownEle + dDn - m_lstFeedWell[i].m_nDownEle) > 0.001) && !IsShowEqualEleBranch() || IsShowEqualEleBranch())) // 是否只显示等高支路 { XPoint ptEllipse; double nThirdPipeDeep = m_lstFeedWell[i].m_nUpEle - nPipeDownEle; ads_polar(ptStart, m_nLayoutRotation - PI / 2, nThirdPipeDeep * dScaleY - nThirdDn / 2, ptEllipse); bool bRet = false; DrawEllipse(ptEllipse, dOuterDn * dScaleY * 0.0005, dOuterDn * dScaleX * 0.0005, dc, idLay, &bRet); // cet 2011.6.2 add 标注碰撞管内底标高 if (bRet && IsDimEle()) { ads_polar(ptEllipse, m_nLayoutRotation + PI / 2, dOuterDn * dScaleY * 0.0005, ptEllipse); CString s; DimEle(ptEllipse, dOuterDn * dScaleY * 0.0005, dOuterDn * dScaleX * 0.0005, nPipeDownEle + dDn, s, true, dc); } } } } } OPENOBJ_END(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// XPoint ptUpLeft2; ads_polar(ptStart, m_nLayoutRotation, nWellDia / 2, pt1); ads_polar(ptStart, m_nLayoutRotation + PI, nWellDia / 2, pt2); double nDeep = (m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle) * dScaleY; XPoint ptFrontWellTop, ptFrontWellBottom, ptBackWellTop, ptBackWellBottom; ptFrontWellTop = pt7;// 前井 pt7井管顶右边点 pt8井管底右边点 ptFrontWellBottom = pt8; if (i != 0) { double nDropDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle; ads_polar(pt2, m_nLayoutRotation - PI / 2.0, nDropDeep * dScaleY, pt6); ads_polar(pt6, m_nLayoutRotation - PI / 2.0, iDn2 / 2.0, ptBackWellBottom); ads_polar(pt6, m_nLayoutRotation + PI / 2.0, iDn2 / 2.0, ptBackWellTop); } else { ads_polar(pt2, m_nLayoutRotation - PI / 2.0, nDeep, pt6); ads_polar(pt6, m_nLayoutRotation - PI / 2.0, iDn / 2.0, ptBackWellTop); ptBackWellBottom = ptBackWellTop; } if (dPipeLen > 0) { DrawPLine(ptFrontWellTop, ptBackWellTop, dc, 0.35 * GetPScale()); //横管上线 DrawPLine(ptFrontWellBottom, ptBackWellBottom, dc, 0.35 * GetPScale()); //横管下线 } XPoint ptBottomRight, ptUpRight, ptBottomLeft(ptTmp); // ads_polar(pt1, m_nLayoutRotation-PI/2, nDeep+iDn/2, ptBottomRight); // cet 2010.7.14 del iDn / 2 结果应为double型 ads_polar(pt1, m_nLayoutRotation - PI / 2, nDeep + iDn / 2.0, ptBottomRight); // cet 2010.7.14 add if (i == m_lstFeedWell.Length() - 1) ptUpRight = ptBottomRight; //最后一个井 else // ads_polar(pt1, m_nLayoutRotation-PI/2, nDeep-iDn/2, ptUpRight); // cet 2010.7.14 del iDn / 2 结果应为double型 ads_polar(pt1, m_nLayoutRotation - PI / 2, nDeep - iDn / 2.0, ptUpRight); // cet 2010.7.14 add double nDropDeep = m_lstFeedWell[i].m_nFrondDownEle - m_lstFeedWell[i].m_nDownEle; if (nDropDeep > 0.001 && i != 0 && i != m_lstFeedWell.Length() - 1) {//下跌水 XPoint ptBackWellTopRight, ptBackWellBottomLeft; ads_polar(ptBackWellTop, m_nLayoutRotation, nWellDia, ptBackWellTopRight); DrawPLine(ptBackWellTop, ptBackWellTopRight, dc, 0.35 * GetPScale()); ads_polar(ptBottomRight, m_nLayoutRotation + PI, nWellDia, ptBackWellBottomLeft); DrawPLine(ptBottomRight, ptBackWellBottomLeft, dc, 0.35 * GetPScale()); DrawPLine(ptBackWellBottomLeft, ptBackWellBottom, dc, 0.35 * GetPScale()); DrawPLine(ptBackWellTopRight, ptUpRight, dc, 0.35 * GetPScale()); } else if (nDropDeep < -0.001 && i != 0 && i != m_lstFeedWell.Length() - 1) {//上跌水 XPoint ptBackWellBottomRight, ptBackWellTopLeft; ads_polar(ptBackWellBottom, m_nLayoutRotation, nWellDia, ptBackWellBottomRight); DrawPLine(ptBackWellBottom, ptBackWellBottomRight, dc, 0.35 * GetPScale()); ads_polar(ptUpRight, m_nLayoutRotation + PI, nWellDia, ptBackWellTopLeft); DrawPLine(ptUpRight, ptBackWellTopLeft, dc, 0.35 * GetPScale()); DrawPLine(ptBackWellTopLeft, ptBackWellTop, dc, 0.35 * GetPScale()); DrawPLine(ptBackWellBottomRight, ptBottomRight, dc, 0.35 * GetPScale()); } else { //绘制2管的连接部分 if (i != 0 && i != m_lstFeedWell.Length() - 1) { DrawPLine(ptBackWellTop, ptUpRight, dc, 0.35 * GetPScale()); DrawPLine(ptBackWellBottom, ptBottomRight, dc, 0.35 * GetPScale()); } } //绘制井 if (!bIsNode) { //如果是节点或者就不画井了 double nDeepSand = m_lstFeedWell[i].m_nSpare / 1000 * dScaleY; XPoint ptWellDownRight, ptWellDownLeft; double nDeep2 = (m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle) * dScaleY; if (nDeep < nDeep2 && i != 0) //如果前管的深度大于本井的深度 nDeep = nDeep2; ads_polar(pt1, m_nLayoutRotation - PI / 2, nDeep + iDn / 2 + nDeepSand, ptWellDownRight); ads_polar(pt2, m_nLayoutRotation - PI / 2, nDeep + iDn / 2 + nDeepSand, ptWellDownLeft); DrawLine(pt2, ptWellDownLeft, dc); //井左边线 DrawLine(pt1, ptWellDownRight, dc); //井右边线 DrawLine(ptWellDownLeft, ptWellDownRight, dc); //井底边线 } pt7 = ptUpRight; // PT7井管顶右边点 pt8 = ptBottomRight; // PT8井管底右边点 //前断管 if (dPipeLen < 0.001 && i != 0) { double nI = m_lstFeedWell[i - 1].m_nI; dPipeLen = 10 * GetPScale(); ads_polar(ptBackWellTop, m_nLayoutRotation + PI, dPipeLen / 2, pt3); ads_polar(ptBackWellBottom, m_nLayoutRotation + PI, dPipeLen / 2, pt4); DrawPLine(ptBackWellTop, pt3, dc, 0.35 * GetPScale()); //井底边线 DrawPLine(ptBackWellBottom, pt4, dc, 0.35 * GetPScale());//井底边线 DrawBreakPipe(pt3, pt4, dc); } dPipeLen = 0; } else if (!m_lstFeedWell[i].m_bIsWell) { //管 dPipeLen = m_lstFeedWell[i].m_nLength * dScaleX; if (m_lstFeedWell[i - 1].m_csName == _T("断管")) dPipeLen = 0; AcDbObjectId idPipe = m_lstFeedWell[i].m_ID; OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipe, pPipe); if (pPipe) { // ZXL 2013.12.06 ADD DList lstCrossPipes; CrossPoint cr(pPipe->objectId()); GetCrossInfo(vecCrossPoint, cr); cr.GetAllCrossPipes(lstCrossPipes); int nPipeNum = lstCrossPipes.Length(); XPoint ptEllipse, ptInt; int nIndex = 0; for (int j = 0; j < nPipeNum; j++) { AcDbObjectId idOther = *lstCrossPipes[j]; OPENOBJ_BEGIN(idOther, AcDb::kForRead, CDbPipe, pPipe2); if (pPipe2) { AcDbObjectId idLay = NULL; idLay = pPipe2->layerId(); if (!IsShowCrossPipe(pPipe2->objectId())) { continue; } double dDn = pPipe2->OuterDn() - pPipe2->GetPipeThick() * 2; double dI = pPipe2->GetPipeGradient(); double dPipeStartEle(0); dDn = dDn / 2000; //转换为米单位 if (pPipe2->GetFlowDir() == TPipeSys::kFromStart) dPipeStartEle = pPipe2->StartPoint().z / dUnitMeter - dDn; else dPipeStartEle = pPipe2->EndPoint().z / dUnitMeter - dDn; double nDist2Well1(0), nDist2Well2(0); cr.GetCrossInfo(idOther, ptInt, nDist2Well1, nDist2Well2); if (fabs(nDist2Well1) > 0.001 && fabs(nDist2Well2) > 0.001 || IsShowPipeEndNotLinkedPipe() && (fabs(nDist2Well1) > 0.001 || fabs(nDist2Well2) > 0.001)) { AcDbObjectId idLay = pPipe2->layerId(); //int iDnTmp = int(dDn*dScaleY/1000); double dDnTmp = dDn * dScaleY; double nPipeIntEle = dPipeStartEle - nDist2Well2 * dI; //根据相交管线起点标高计算交点标高 double nThirdPipeDeep = m_lstFeedWell[i - 1].m_nUpEle - nPipeIntEle;//转换为埋深 ads_polar(ptStart, m_nLayoutRotation - PI / 2, nThirdPipeDeep * dScaleY - dDnTmp, ptEllipse); ads_polar(ptEllipse, m_nLayoutRotation, nDist2Well1 * dScaleX, ptEllipse); double dOuterDn = pPipe2->OuterDn(); bool bRet = false; DrawEllipse(ptEllipse, dOuterDn * dScaleY * 0.0005, dOuterDn * dScaleX * 0.0005, dc, idLay, &bRet); // cet 2011.6.3 add 标注碰撞管中标高 if (bRet && IsDimEle()) { CString sPipeName = pPipe2->GetPipeSystemName(); sPipeName += _T("管"); CString sLabel = pPipe2->GetLabel(); sPipeName += sLabel; sLabel.Format(_T("%.f"), pPipe2->GetDnDiameter()); sPipeName += sLabel; XPoint ptTemp; ads_polar(ptEllipse, m_nLayoutRotation + PI / 2, dOuterDn * dScaleY * 0.0005, ptTemp); DimEle(ptTemp, dOuterDn * dScaleY * 0.0005, dOuterDn * dScaleX * 0.0005, nPipeIntEle + dDn, sPipeName, false, dc); } // zxl 2013.12.10 add if (bRet && IsDimDist()) { CString sDim; sDim.Format(_T("%.2f"), nDist2Well1 * dUnitMeter); if (dUnitMeter > 1.0) { sDim.Format(_T("%.f"), nDist2Well1 * dUnitMeter); } DimDist(sDim, ptStart, ptEllipse, dc, nIndex, nThirdPipeDeep, dDnTmp); } } } OPENOBJ_END(); } } OPENOBJ_END(); } } return Acad::eOk; } void CDbVerticalSectionFeed::GetLine(XLine &line) const { XPoint ptEnd; double dScaleY = m_iScaleY; double dScaleX = m_iScaleX; dScaleX = GetPScale() / dScaleX * 1000; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 XPoint ptStart; XPoint ptIns = m_ptIns; double nHighEle = m_nMaxDeep; double nLowEle = m_nMinDeep; double nEleStart = 0.0; if (m_iCalcMode < 100) // 从左往右 原代码 nEleStart = m_lstFeedWell[0].m_nUpEle; else // add by 王辉 08-05-05 nEleStart = m_lstFeedWell[m_lstFeedWell.Length() - 1].m_nUpEle; //绘制比例尺 int iHighEle = (int)(nHighEle + 1); int iLowEle = (int)nLowEle; if (fabs(nLowEle) > iLowEle && nLowEle < 0) iLowEle--; //2009-6-24 增加以下2句, if (fabs(nLowEle - iLowEle) < 0.2) //如果最低标尺值距实际最低标高就差0.2米,最低标尺再降低1米 iLowEle--; if (fabs(nHighEle - iHighEle) < 0.2) //如果最高标尺值距实际最高标高就差0.2米,最高标尺再提高1米 iHighEle++; int iAllMeter = iHighEle - iLowEle; nHighEle = (double)iHighEle - nEleStart; ads_polar(ptIns, m_nLayoutRotation + PI, 20 * GetPScale(), ptStart); ads_polar(ptStart, m_nLayoutRotation + PI / 2, nHighEle * dScaleY, ptStart); //第一行比例尺 XPoint ptText, ptFisrtStart, ptStart2, ptEnd2, pt1; ptFisrtStart = ptStart; ads_polar(ptStart, m_nLayoutRotation + PI, 3 * GetPScale(), ptText); ads_polar(ptStart, m_nLayoutRotation, GetAllPipeLen() + 20 * GetPScale(), pt1); double nHighEleTmp = (double)iHighEle; ads_polar(ptStart, m_nLayoutRotation + PI, 2 * GetPScale(), ptStart2); double nNum = 1 / m_nGridScale; double nGridScale = m_nGridScale; if (m_nGridScale < 0.01) { nNum = 1; nGridScale = 1; } for (int i = 0; i < iAllMeter * nNum; i++) { ads_polar(ptStart, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd); if (i % 2 == 0) ads_polar(ptStart, m_nLayoutRotation + PI, 1.5 * GetPScale(), ptStart2); else ads_polar(ptStart, m_nLayoutRotation + PI, 0.5 * GetPScale(), ptStart2); ads_polar(ptStart2, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd2); ads_polar(ptStart, m_nLayoutRotation + PI, 2 * GetPScale(), ptStart2); ads_polar(ptStart2, m_nLayoutRotation - PI / 2, dScaleY / nNum, ptEnd2); ads_polar(ptEnd, m_nLayoutRotation + PI, 3 * GetPScale(), ptText); nHighEleTmp = nHighEleTmp - nGridScale; ptStart = ptEnd; //绘制横网格 if (m_nGridScale > 0.01) { ads_polar(ptEnd, m_nLayoutRotation, GetAllPipeLen() + 20 * GetPScale(), pt1); } } //绘制井中心线 ads_polar(ptStart, m_nLayoutRotation - PI / 2, 10 * GetPScale(), ptStart); ads_polar(ptStart, m_nLayoutRotation, 10 * GetPScale(), ptEnd2); XLine lineButton(ptStart, ptEnd2); //底线 line = lineButton; } void CDbVerticalSectionFeed::DimEle(const XPoint &ptCen, double dRadiusLong, double dRadiusShort, double dEle, CString &sText, bool bOnlyDimEle, AcGiDraw &dc) const { XLine line; GetLine(line); XPoint pt; ptCen.Project(&line, pt); AcDbLine line2(ptCen, pt); AcDbEllipse ellipse; double ratio = dRadiusShort / dRadiusLong; XPoint ptTem; ads_polar(ptCen, m_nLayoutRotation + PI / 2, dRadiusLong, ptTem); AcGeVector3d majorAxis = ptTem.AsAcGePoint3d() - ptCen.AsAcGePoint3d(); ellipse.set(ptCen, AcGeVector3d::kZAxis, majorAxis, ratio); AcGePoint3dArray ptArr; line2.intersectWith(&ellipse, AcDb::kOnBothOperands, ptArr); if (ptArr.length() == 1) { // cet 2014.7.7 add 当标高处于line之下时标注位置不对,现加以调整 int nFactor = 1; AcGeVector3d vtTemp = ptArr[0] - pt.AsAcGePoint3d(); vtTemp.z = 0.0; vtTemp.normalize(); AcGeTol tol; tol.setEqualVector(0.001); vtTemp = GlobalFunc::Wcs2Ucs(vtTemp, TRUE); if (vtTemp.isCodirectionalTo(-AcGeVector3d::kYAxis, tol)) { nFactor = -1; ptArr[0] += vtTemp * dRadiusLong * 2; } if (!bOnlyDimEle) { // 管线名称管径标注 XPoint ptMid; Midpoint(pt, asDblArray(ptArr[0]), ptMid); AecXDbText text1; text1.SetPScale(GetPScale()); text1.setLayer(m_idTextLayer); text1.SetStyleId(m_idTextStyle); text1.SetText(sText); // text1.SetRotation(PI / 2); cet 2011.6.30 midofy text1.SetRotation(GlobalFunc::Ucs2Wcs(PI / 2)); text1.SetLocation(ptMid); text1.SetHeight(m_dTextHeight); text1.SetAlignment(AcGiDraw::kMiddle); double dWidth = 0.0; text1.GetExtents(&dWidth, NULL); //if (dc.IsFullExplode()) //{ // text1.ExplodeOrDraw2d(dc); //} //else //{ // dc.DrawEntity(text1); //} DrawBaseEx(dc, text1); // 直线 double dLen = pt.Distance2d(ptArr[0]); AcGeVector3d vt = ptArr[0] - asPnt3d(pt); vt.normalize(); XPoint pt2; pt2 = pt + vt * (dLen - dWidth) * 0.5; // cet 2018.2.8 modify 调整直线图层 // dc << TGGeLine(pt, pt2); DrawGridLine(pt, pt2, dc); pt2 = ptArr[0] - vt * (dLen - dWidth) * 0.5; // cet 2018.2.8 modify 调整直线图层 // dc << TGGeLine(asDblArray(ptArr[0]), pt2); DrawGridLine(ptArr[0], pt2, dc); } // 标高 AcGeVector3d vt = ptArr[0] - asPnt3d(pt); vt.normalize(); vt.rotateBy(-PI / 2 * nFactor, AcGeVector3d::kZAxis); // cet 2014.7.7 add 当标高处于line之下时标注位置不对,现加以调整 XPoint pt3; pt3 = ptArr[0] + vt * 1000; if (GlobalFunc::DocGetMeterUnitDraw()) // cet 2011.6.30 add { pt3 = ptArr[0] + vt * 10; } // cet 2018.2.8 modify 调整直线图层 // dc << TGGeLine(pt3, asDblArray(ptArr[0])); DrawGridLine(pt3, ptArr[0], dc); CString sEle; sEle.Format(_T("%.3f"), dEle); AecXDbSymbElevation text; pt3 = ptArr[0] + vt * 500; if (GlobalFunc::DocGetMeterUnitDraw()) // cet 2011.6.30 add { pt3 = ptArr[0] + vt * 5; } text.setLayer(m_idTextLayer); // cet 2018.2.8 add 标注图层 text.SetLocation(pt3); text.SetText(sEle); text.SetBaseLine(FALSE); text.SetLeader(FALSE); text.SetTextHeight(m_dTextHeight); text.SetTextStyleId(m_idTextStyle); text.SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); AcDbIntArray indices; indices.append(1); AcGeVector3d vtOffset(0, -1, 0); vtOffset = GlobalFunc::Ucs2Wcs(vtOffset, TRUE); // cet 2011.6.30 add if (vtOffset.length() > g_Option::instance()._DIST_SNAP * 10) { vtOffset.normalize(); double dScale = (2 * GlobalFunc::DocGetEleTriangleSize() + 0.5) * GlobalFunc::DocGetPScale(); vtOffset *= dScale; text.moveGripPointsAt(indices, vtOffset); } text.SetLayoutRotation(m_nLayoutRotation); int nColor = dc.GetColor(); dc.SetColor(3); text.SetPScale(this->GetPScale()); // cet 2016.11.3 add 缺少比例设置,导致图纸空间中实体大小发生变化 //if (dc.IsFullExplode()) //{ // text.ExplodeOrDraw2d(dc); //} //else //{ // dc.DrawEntity(text); //} DrawBaseEx(dc, text); dc.SetColor(nColor); } } void CDbVerticalSectionFeed::DimDist(const CString &sDim, const XPoint &ptStart, const XPoint &ptEnd, AcGiDraw &dc, int &nDist, const double dDeep, const double dLong) const { // cet 2017.8.29 add 长度为0不标注 if (fabs(_tstof(sDim)) < 0.0001) { return; } double d = m_iScaleY; double dScale = (50 / d); double dDist2Line = 1.3; if (m_nGridScale == 2.0) { dDist2Line = 3.3; } XLine line; GetLine(line); XPoint pt1, pt2; pt1 = line.GetStartPoint(); pt2 = line.GetEndPoint(); ads_polar(pt1, m_nLayoutRotation + PI / 2, (1 + (dDist2Line * dScale)) * (GlobalFunc::DocGetMeterUnitDraw() ? 10 : 1000), pt1); ads_polar(pt2, m_nLayoutRotation + PI / 2, (1 + (dDist2Line * dScale)) * (GlobalFunc::DocGetMeterUnitDraw() ? 10 : 1000), pt2); line.SetStartPoint(pt1); line.SetEndPoint(pt2); ptStart.Project(&line, pt1); ptEnd.Project(&line, pt2); AcGeVector3d vt = pt2 - pt1; double dFact = 0.0; if (dDeep < 0.001 || dDeep > 3.0)// 埋深与管线的距离不在合适的范围时,长度标注位置随管线 { pt2 = ptEnd; if (dDeep < 0.001) { dFact = 0.8; } else { dFact = -0.8; } pt1 = pt2 - vt; } else { nDist++; dFact = nDist; } // cet 2016.7.25 modify 转T3 T5 T6时,提示错误,更改标注方法 // TDbDimension2 entDim; // entDim.setLayer(m_idTextLayer); // entDim.SetLocation(pt1); // entDim.SetStyleId(InitDimStyle(DS_LINEAR)); // entDim.SetRotation(GlobalFunc::Ucs2Wcs(0.0)); // entDim.AddSegment(pt2); // entDim.SetTextContent(0, sDim); // entDim.SetDist2DimLine(-0.6 * dFact * (GlobalFunc::DocGetMeterUnitDraw() ? 10 : 1000), FALSE); // // int nIndex = dc.GetColor(); // dc.SetColor(3); // if(dc.IsFullExplode()) // { // entDim.ExplodeOrDraw2d(dc); // } // else // { // dc.DrawEntity(entDim); // } // dc.SetColor(nIndex); XPoint ptMid; Midpoint(pt1, pt2, ptMid); AecXDbText text; text.SetPScale(GetPScale()); text.setLayer(m_idTextLayer); text.SetStyleId(m_idTextStyle); text.SetText(sDim); text.SetRotation(m_nLayoutRotation); text.SetHeight(m_dTextHeight); text.SetAlignment(AcGiDraw::kBottomCenter); double dWidth = 0.0, dHeight = 0.0; text.GetExtents(&dWidth, &dHeight); AcGeVector3d vtDir = AcGeVector3d::kXAxis; vtDir.rotateBy(m_nLayoutRotation + PI * 0.5, AcGeVector3d::kZAxis); double dOffset = dHeight * 0.3; text.SetLocation(ptMid + vtDir * dOffset); //if (dc.IsFullExplode()) //{ // text.ExplodeOrDraw2d(dc); //} //else //{ // dc.DrawEntity(text); //} DrawBaseEx(dc, text); AcDbObjectId idLayerOld = dc.GetLayerId(); dc.SetLayer(m_idSectLayer); int nIndex = dc.GetColor(); int nNewColor = 3; dc.SetColor(nNewColor); // cet 2018.2.8 modify 调整直线图层 // dc << XLine(pt1, pt2); // dc << XLine(pt1 + vtDir * dHeight, pt1 - vtDir * dHeight); // dc << XLine(pt2 + vtDir * dHeight, pt2 - vtDir * dHeight); DrawGridLine(pt1, pt2, dc); DrawGridLine(pt1 + vtDir * dHeight, pt1 - vtDir * dHeight, dc); DrawGridLine(pt2 + vtDir * dHeight, pt2 - vtDir * dHeight, dc); double dLineWidth = 0.05 * GetPScale(); vtDir.rotateBy(-PI * 0.25, AcGeVector3d::kZAxis); AcDbPolyline polyLine1, polyLine2; polyLine1.addVertexAt(0, (pt1 + vtDir * dHeight * 0.25).AsAcGePoint2d()); polyLine1.addVertexAt(1, (pt1 - vtDir * dHeight * 0.25).AsAcGePoint2d()); polyLine2.addVertexAt(0, (pt2 + vtDir * dHeight * 0.25).AsAcGePoint2d()); polyLine2.addVertexAt(1, (pt2 - vtDir * dHeight * 0.25).AsAcGePoint2d()); polyLine1.setConstantWidth(dLineWidth); polyLine2.setConstantWidth(dLineWidth); polyLine1.setLayer(m_idSectLayer); polyLine2.setLayer(m_idSectLayer); polyLine1.setColorIndex(nNewColor); polyLine2.setColorIndex(nNewColor); dc.DrawEntity(polyLine1); dc.DrawEntity(polyLine2); dc.SetColor(nIndex); dc.SetLayer(idLayerOld); } bool CDbVerticalSectionFeed::IsDimDist() const { const EntityFields &fd = GetFields(); Adesk::Boolean bVal = Adesk::kFalse; fd.GFD(_T("DIM_DIST"), bVal); return bVal == Adesk::kTrue ? true : false; } void CDbVerticalSectionFeed::SetDimDist(bool bDim) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("DIM_DIST"), bDim ? Adesk::kTrue : Adesk::kFalse); } bool CDbVerticalSectionFeed::IsDimEle() const { const EntityFields &fd = GetFields(); Adesk::Boolean bVal = Adesk::kFalse; fd.GFD(_T("DIM_ELE"), bVal); return bVal == Adesk::kTrue ? true : false; } void CDbVerticalSectionFeed::SetDimEle(bool bDim) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("DIM_ELE"), bDim ? Adesk::kTrue : Adesk::kFalse); } bool CDbVerticalSectionFeed::IsShowCrossPipe(TPipeSys::SysType sys) const { int nDx = GetPipeIndex(sys); if (nDx == -1) { return false; } Adesk::UInt32 nCrossPipe = 0xffff; const EntityFields &fd = GetFields(); fd.GFD(_T("ShowCrossPipe"), nCrossPipe); Adesk::UInt32 nTemp = 0x01; nTemp <<= nDx; return ((nCrossPipe & nTemp) > 0); } bool CDbVerticalSectionFeed::IsShowCrossPipe(const CString &sSysName) const { const EntityFields &fd = GetFields(); Adesk::Boolean bShow = Adesk::kFalse; fd.GFD(sSysName, bShow); return bShow == Adesk::kTrue ? true : false; } bool CDbVerticalSectionFeed::IsShowCrossPipe(const AcDbObjectId &idPipe) const { bool bShow = false; CDbPipe *pPipe = NULL; acdbOpenObject(pPipe, idPipe, AcDb::kForRead); if (pPipe != NULL) { if (pPipe->HavePipeSystemName()) // 新版管道系统 { bShow = IsShowCrossPipe(pPipe->GetPipeSystemName()); } else // 旧版管道系统 { bShow = IsShowCrossPipe(pPipe->GetSysType()); } pPipe->close(); } return bShow; } void CDbVerticalSectionFeed::SetShowCrossPipe(TPipeSys::SysType sys, bool bShow) { int nDx = GetPipeIndex(sys); if (nDx == -1) { return; } Adesk::UInt32 nCrossPipe = 0; EntityFields &fd = Fields(); fd.GFD(_T("ShowCrossPipe"), nCrossPipe); Adesk::UInt32 nTemp = 0x01; nTemp <<= nDx; if (bShow) { nCrossPipe |= nTemp; } else { nCrossPipe &= ~nTemp; } fd.SFD(_T("ShowCrossPipe"), nCrossPipe); } void CDbVerticalSectionFeed::SetShowCrossPipe(const CString &sSysName, bool bShow) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(sSysName, bShow ? Adesk::kTrue : Adesk::kFalse); } int CDbVerticalSectionFeed::GetPipeIndex(TPipeSys::SysType sys) const { int nRet = -1; switch (sys) { case TPipeSys::kFeedWater: case TPipeSys::kFeedWater2: case TPipeSys::kFeedWater3: { nRet = 0; break; } case TPipeSys::kDirtWater: { nRet = 1; break; } case TPipeSys::kUselessWater: { nRet = 2; break; } case TPipeSys::kRainWater: { nRet = 3; break; } case TPipeSys::kUsedWater: case TPipeSys::kUsedWater2: case TPipeSys::kUsedWater3: { nRet = 4; break; } case TPipeSys::kFireFighting: case TPipeSys::kFireFighting2: case TPipeSys::kFireFighting3: { nRet = 5; break; } case TPipeSys::kOther: { nRet = 6; break; } } return nRet; } //绘制给水的支管, 要求必须是TDbPipeFitting,且连接水管在2根以上 //往AcDbObjectIdArray中添加一个对象, 如何已经存在就不添加 BOOL CDbVerticalSectionFeed::AppendIdArray(AcDbObjectIdArray &idArray, AcDbObjectId id) const { BOOL bFlag = FALSE; //OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipeFitting, pNode); //if (pNode) { // if (pNode->GetInterfaceNum() > 2) // bFlag = TRUE; //} //OPENOBJ_END(); //if (!bFlag) // return FALSE; int len = idArray.length(); for (int i = 0; i < len; i++) { AcDbObjectId idTmp = idArray[i]; if (idTmp == id) return FALSE; } idArray.append(id); return TRUE; } Acad::ErrorStatus CDbVerticalSectionFeed::DrawCivilSheetFeed(AcGiDraw &dc, XPoint ptEnd) const { double nSheetHeight = m_dTextHeight + 3; XStringList lstHead; int idx2(1); double nWellNameRow(0), nWellRaiusRow(0), nDeepRow(0), nGroundEleRow(0), nUpEleRow(0), nThicknessRow(0), nDownEleRow(0), nTmpHeight(0); double dStakeRow(0); while (1) { TCHAR sBuf[256] = _T(""); GlobalFunc::GetStringAtIndex(m_sSheetHead, idx2, sBuf); if (_tcsicmp(sBuf, _T("")) == 0) break; lstHead.Append(tstrnew(sBuf)); idx2++; if (_tcsicmp(sBuf, _T("井编号")) == 0) { nWellNameRow = nTmpHeight; nTmpHeight += nSheetHeight; } else if (_tcsicmp(sBuf, _T("桩号")) == 0) // cet 2012.8.20 add { dStakeRow = nTmpHeight; nTmpHeight += nSheetHeight; } else if (_tcsicmp(sBuf, _T("井径(mm)")) == 0) { nWellRaiusRow = nTmpHeight; nTmpHeight += nSheetHeight; } else if (_tcsicmp(sBuf, _T("设计地面标高(m)")) == 0) { nUpEleRow = nTmpHeight; nTmpHeight += nSheetHeight * 2.5; } else if (_tcsicmp(sBuf, _T("自然地面标高(m)")) == 0) { nGroundEleRow = nTmpHeight; nTmpHeight += nSheetHeight * 2.5; } else if (_tcsicmp(sBuf, _T("埋设深度(m)")) == 0) { nDeepRow = nTmpHeight; nTmpHeight += nSheetHeight * 2; } else if (_tcsicmp(sBuf, _T("覆土厚度(m)")) == 0) { nThicknessRow = nTmpHeight; nTmpHeight += nSheetHeight * 2; } else if (_tcsicmp(sBuf, _T("管标高(m)")) == 0) { nDownEleRow = nTmpHeight; nTmpHeight += nSheetHeight * 2.5; } else nTmpHeight += nSheetHeight; } int iDemoRow = lstHead.Index(_T("备注")); int iPipeLenRow = lstHead.Index(_T("管道长度(m)")); int iGradientRow = lstHead.Index(_T("管道坡度")); int iDnRow = lstHead.Index(_T("管径(mm)")); int iWellNameRow = lstHead.Index(_T("井编号")); int iUpEleRow = lstHead.Index(_T("设计地面标高(m)")); int iDeepRow = lstHead.Index(_T("埋设深度(m)")); int iThicknessRow = lstHead.Index(_T("覆土厚度(m)")); int iGroundEleRow = lstHead.Index(_T("自然地面标高(m)")); int iWellRadiusRow = lstHead.Index(_T("井径(mm)")); int iDownEleRow = lstHead.Index(_T("管标高(m)")); int iPipePlanRow = lstHead.Index(_T("管线平面")); int iStakeRow = lstHead.Index(_T("桩号")); // cet 2012.8.20 add BOOL bBreak1 = FALSE; BOOL bBreak2 = FALSE; if (m_lstFeedWell[0].m_csName == _T("断管")) bBreak1 = TRUE; if (m_lstFeedWell[m_lstFeedWell.Length() - 1].m_csName == _T("断管")) bBreak2 = TRUE; double dScaleY = m_iScaleY; double dScaleX = m_iScaleX; dScaleX = GetPScale() / dScaleX * 1000; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 // XPoint ptIns = m_ptIns; // XPoint ptCivilIns = ptIns; // ptCivilIns.y = ptEnd.y; // ptIns = ptCivilIns; // ads_polar(ptCivilIns, m_nLayoutRotation+PI, 45*GetPScale(), ptCivilIns); XPoint ptCivilIns = ptEnd; XPoint ptIns = ptCivilIns; ads_polar(ptCivilIns, m_nLayoutRotation + PI, 45 * GetPScale(), ptCivilIns); //绘制表格 AcDbObjectId idTextStyle = m_idTextStyle; CDbSheet pSheet; // cet 2018.2.7 modify 表格图层与网格一致 // pSheet.setLayer(this->layerId()); pSheet.setLayer(this->GetGridLayer()); pSheet.SetPScale(GetPScale()); pSheet.SetRotation(m_nLayoutRotation); GridStyle gridStyle; gridStyle.SetOverrideAll(TRUE); gridStyle.SetTextHeight(m_dTextHeight); gridStyle.SetTextStyleId(idTextStyle); SheetTitle &title = pSheet.GetTitle(); title.SetHeight(nSheetHeight); title.SetVisible(FALSE); gridStyle.SetHorMode(AcDb::kTextCenter); gridStyle.SetVerMode(AcDb::kTextVertMid); gridStyle.SetLineSpaceFactor(0.2); gridStyle.SetTextWrap(FALSE); pSheet.SetGridStyle(gridStyle); pSheet.SetRowHeight(m_dTextHeight + 2); if (bBreak2 || bBreak1) pSheet.InitSheet(lstHead.Length(), m_lstFeedWell.Length() / 2 + 2, nSheetHeight, 50); else pSheet.InitSheet(lstHead.Length(), m_lstFeedWell.Length() / 2 + 3, nSheetHeight, 50); SheetColumn column; column.SetWidth(25); //表头 pSheet.SetColumnAt(0, column); SheetColumn column2; if (!bBreak2 && !bBreak1) { column2.SetWidth(5); //表尾 pSheet.SetColumnAt(m_lstFeedWell.Length() / 2 + 2, column2); } if (bBreak1) { column2.SetWidth(5); //表尾 pSheet.SetColumnAt(m_lstFeedWell.Length() / 2 + 1, column2); } double nWidth = 20 * GetPScale(); XPoint ptCellS, ptCellE, ptText, ptWell; ptCellS = ptIns; double dPipeLen(0); int idx = 1; int iDn(0); int nGsMarker = 1; pSheet.SetLocation(ptCivilIns); for (int i = 0; i < m_lstFeedWell.Length(); i++) { AcDbObjectId id = m_lstFeedWell[i].m_ID; if (m_lstFeedWell[i].m_bIsWell) { //井 if (m_lstFeedWell[i].m_csName == _T("断管") && dPipeLen > 0) { SheetColumn column3; column3.SetWidth(dPipeLen / GetPScale()); //表尾 pSheet.SetColumnAt(m_lstFeedWell.Length() / 2 + 1, column3); continue; } if (m_lstFeedWell[i].m_csName == _T("断管") && dPipeLen < 0.001) { continue; } double nEle = m_lstFeedWell[i].m_nUpEle; double nDeep = m_lstFeedWell[i].m_nDeep; double nDownEle = m_lstFeedWell[i].m_nDownEle; double nGroundDeep = m_lstFeedWell[i].m_nDeep; double nFrondEle = m_lstFeedWell[i].m_nFrondDownEle; double nGroundEle = m_lstFeedWell[i].m_nGroundEle; double dWellRadius = m_lstFeedWell[i].m_nWellRadius; if (i == m_lstFeedWell.Length() - 1) nGroundDeep -= (double)m_lstFeedWell[i - 1].m_iDn / 1000; else nGroundDeep -= (double)m_lstFeedWell[i + 1].m_iDn / 1000; int iPre = GetWellDeepPrecision(); CString sHead, sFormat; sHead.Format(_T("%d"), iPre); sFormat = _T("%.") + sHead + _T("f"); CString csWellUpEle, csDeep, csDownEle, csGroundDeep, csFrontEle, csGroundEle, csWellRaius; csDeep.Format(sFormat, nDeep); csGroundEle.Format(sFormat, nGroundEle); csDownEle.Format(sFormat, nDownEle); csWellUpEle.Format(sFormat, nEle); csGroundDeep.Format(sFormat, nGroundDeep); csFrontEle.Format(sFormat, nFrondEle); CString csWellName = m_lstFeedWell[i].m_csName; csWellRaius.Format(_T("D%.0f"), dWellRadius * 2.0); ads_polar(ptCellS, m_nLayoutRotation, dPipeLen, ptCellS); if (iWellNameRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nWellNameRow + nSheetHeight / 2) * GetPScale(), ptText); DrawText(ptText, csWellName, AcGiDraw::kMiddleCenter, dc); } if (iWellRadiusRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nWellRaiusRow + nSheetHeight / 2) * GetPScale(), ptText); DrawText(ptText, csWellRaius, AcGiDraw::kMiddleCenter, dc); } if (iUpEleRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nUpEleRow + nSheetHeight / 3) * GetPScale(), ptText); DrawText(ptText, csWellUpEle, AcGiDraw::kMiddleRight, dc, PI / 2); } if (iGroundEleRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nGroundEleRow + nSheetHeight / 3) * GetPScale(), ptText); DrawText(ptText, csGroundEle, AcGiDraw::kMiddleRight, dc, PI / 2); } // cet 2012.820 增加桩号 if (iStakeRow > -1) //桩号 { AcDbObjectId id = m_lstFeedWell[i].m_ID; ads_name entWell; acdbGetAdsName(entWell, id); CString csStake = GlobalFunc::ReadXdata(entWell, _T("TWT-STAKEVALUE")); ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (dStakeRow + nSheetHeight / 2) * GetPScale(), ptText); DrawText(ptText, csStake, AcGiDraw::kMiddleCenter, dc); } #if ARX < 18 double dTol = 0.1; for (int j = 0; j < iPre; ++j) { dTol *= 0.1; } #else double dTol =pow(0.1, iPre + 1); #endif bool bFlag = (i != 0) && (i != m_lstFeedWell.Length() - 1) && (fabs(m_lstFeedWell[i].m_nFrondDownEle - m_lstFeedWell[i].m_nDownEle) > dTol || fabs((double)(m_lstFeedWell[i - 1].m_iDn - m_lstFeedWell[i + 1].m_iDn)) > dTol); // 埋设深度或覆土厚度是否不相同 if (m_nCalcType == 0) // 已知管中标高 { // 埋深 if (iDeepRow > -1 && m_iCalcMode != 3) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nDeepRow + nSheetHeight / 3) * GetPScale(), ptText); // 埋设深度=设计地面标高-管中标高 if (i != 0) // 前管埋设深度 { double nDeep2 = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle; CString csDeep2; csDeep2.Format(sFormat, fabs(nDeep2)); XPoint ptTmpText = ptText; if (i != m_lstFeedWell.Length() - 1 && bFlag) { ads_polar(ptText, m_nLayoutRotation + PI, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csDeep2, AcGiDraw::kMiddleRight, dc, PI / 2); } if (i != m_lstFeedWell.Length() - 1) // 后管埋设深度 { double nDeep2 = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle; CString csDeep2; csDeep2.Format(sFormat, fabs(nDeep2)); XPoint ptTmpText = ptText; if (i != 0 && bFlag) { ads_polar(ptText, m_nLayoutRotation, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csDeep2, AcGiDraw::kMiddleRight, dc, PI / 2); } } // 覆土厚度 if (iThicknessRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nThicknessRow + nSheetHeight / 3) * GetPScale(), ptText); // 覆土厚度=埋设深度-管外径的一半 if (i != 0) // 前管覆土厚度 { double dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle - m_lstFeedWell[i - 1].m_iDn * 0.0005; OPENOBJ_BEGIN(m_lstFeedWell[i - 1].m_ID, AcDb::kForRead, CDbPipe, pPipe); if (pPipe != NULL) { double dOuterDn = pPipe->OuterDn(); if (pPipe->OuterDn() > 0.001) { dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle - dOuterDn * 0.0005; } } OPENOBJ_END(); CString csFeedDeep; csFeedDeep.Format(sFormat, dFeedDeep); XPoint ptTmpText = ptText; if (i != m_lstFeedWell.Length() - 1 && bFlag) { ads_polar(ptText, m_nLayoutRotation + PI, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csFeedDeep, AcGiDraw::kMiddleRight, dc, PI / 2); } if (i != m_lstFeedWell.Length() - 1) // 后管覆土厚度 { double dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle - m_lstFeedWell[i + 1].m_iDn * 0.0005; OPENOBJ_BEGIN(m_lstFeedWell[i + 1].m_ID, AcDb::kForRead, CDbPipe, pPipe); if (pPipe != NULL) { double dOuterDn = pPipe->OuterDn(); if (pPipe->OuterDn() > 0.001) { dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle - dOuterDn * 0.0005; } } OPENOBJ_END(); CString csFeedDeep; csFeedDeep.Format(sFormat, dFeedDeep); XPoint ptTmpText = ptText; if (i != 0 && bFlag) { ads_polar(ptText, m_nLayoutRotation, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csFeedDeep, AcGiDraw::kMiddleRight, dc, PI / 2); } } } else // 已知覆土厚度 { // 埋深 if (iDeepRow > -1 && m_iCalcMode != 3) { // 埋设深度=覆土厚度+管外径的一半(管中标高=设计地面标高-埋设深度) ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nDeepRow + nSheetHeight / 3) * GetPScale(), ptText); if (i != 0) // 前管埋设深度 { double nDeep2 = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle; CString csDeep2; csDeep2.Format(sFormat, fabs(nDeep2)); XPoint ptTmpText = ptText; if (i != m_lstFeedWell.Length() - 1 && bFlag) { ads_polar(ptText, m_nLayoutRotation + PI, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csDeep2, AcGiDraw::kMiddleRight, dc, PI / 2); } if (i != m_lstFeedWell.Length() - 1) // 后管埋设深度 { double nDeep2 = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle; CString csDeep2; csDeep2.Format(sFormat, fabs(nDeep2)); XPoint ptTmpText = ptText; if (i != 0 && bFlag) { ads_polar(ptText, m_nLayoutRotation, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csDeep2, AcGiDraw::kMiddleRight, dc, PI / 2); } } // 覆土厚度 if (iThicknessRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nThicknessRow + nSheetHeight / 3) * GetPScale(), ptText); if (i != 0) // 前管覆土厚度 { double dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle - m_lstFeedWell[i - 1].m_iDn * 0.0005; OPENOBJ_BEGIN(m_lstFeedWell[i - 1].m_ID, AcDb::kForRead, CDbPipe, pPipe); if (pPipe != NULL) { double dOuterDn = pPipe->OuterDn(); if (pPipe->OuterDn() > 0.001) { dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nFrondDownEle - dOuterDn * 0.0005; } } OPENOBJ_END(); CString csFeedDeep; csFeedDeep.Format(sFormat, dFeedDeep); XPoint ptTmpText = ptText; if (i != m_lstFeedWell.Length() - 1 && bFlag) { ads_polar(ptText, m_nLayoutRotation + PI, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csFeedDeep, AcGiDraw::kMiddleRight, dc, PI / 2); } if (i != m_lstFeedWell.Length() - 1) // 后管覆土厚度 { double dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle - m_lstFeedWell[i + 1].m_iDn * 0.0005; OPENOBJ_BEGIN(m_lstFeedWell[i + 1].m_ID, AcDb::kForRead, CDbPipe, pPipe); if (pPipe != NULL) { double dOuterDn = pPipe->OuterDn(); if (pPipe->OuterDn() > 0.001) { dFeedDeep = dFeedDeep = m_lstFeedWell[i].m_nUpEle - m_lstFeedWell[i].m_nDownEle - dOuterDn * 0.0005; } } OPENOBJ_END(); CString csFeedDeep; csFeedDeep.Format(sFormat, dFeedDeep); XPoint ptTmpText = ptText; if (i != 0 && bFlag) { ads_polar(ptText, m_nLayoutRotation, GetPScale() * 2, ptTmpText); } DrawText(ptTmpText, csFeedDeep, AcGiDraw::kMiddleRight, dc, PI / 2); } } } //管内底标高, 或给水的管中标高 if (iDownEleRow > -1) { ads_polar(ptCellS, m_nLayoutRotation - PI / 2, (nDownEleRow + nSheetHeight / 3) * GetPScale(), ptText); if (csFrontEle == csDownEle || i == 0 || i == m_lstFeedWell.Length() - 1) { DrawText(ptText, i != 0 ? csFrontEle : csDownEle, AcGiDraw::kMiddleRight, dc, PI / 2); } else { XPoint ptTmpText = ptText; ads_polar(ptText, m_nLayoutRotation + PI, GetPScale() * 2, ptTmpText); DrawText(ptTmpText, csFrontEle, AcGiDraw::kMiddleRight, dc, PI / 2); ads_polar(ptText, m_nLayoutRotation, GetPScale() * 2, ptTmpText); DrawText(ptTmpText, csDownEle, AcGiDraw::kMiddleRight, dc, PI / 2); } } ads_polar(ptCellS, m_nLayoutRotation - PI / 2, nSheetHeight * 12 * GetPScale(), ptText); int num(0); ptWell = ptText; SheetColumn column4; column4.SetWidth(nWidth / GetPScale()); //序号 pSheet.SetColumnAt(idx, column4); idx++; } else if (!m_lstFeedWell[i].m_bIsWell) { //管 // double dLenPipe = m_lstWell[i].m_nLength; // if(dLenPipe > 1000)// 7.0 管长用mm // dLenPipe = dLenPipe/1000.0; dPipeLen = m_lstFeedWell[i].m_nLength * dScaleX; nWidth = dPipeLen; if (m_lstFeedWell[i - 1].m_csName == _T("断管")) { nWidth = 20 * GetPScale(); dPipeLen = 0; } iDn = m_lstFeedWell[i].m_iDn; CString csDn, csPipeLen, csI; csDn.Format(_T("%d"), iDn); csI = I2Str(m_lstFeedWell[i].m_nI * 1000); csPipeLen.Format(_T("%.2f"), m_lstFeedWell[i].m_nLength); if (iDnRow > -1) { GridCell &cell21 = *(pSheet)(iDnRow, idx); cell21.SetText(csDn); } if (iPipeLenRow > -1) { GridCell &cell22 = *(pSheet)(iPipeLenRow, idx); cell22.SetText(csPipeLen); } if (iGradientRow > -1) { GridCell &cell23 = *(pSheet)(iGradientRow, idx); cell23.SetText(csI); } if (iDemoRow > -1 && i > 1 && m_lstFeedWell[i - 1].m_bIsDropWell && m_iCalcMode != 3) { GridCell &cell24 = *(pSheet)(iDemoRow, idx); double nDrop = m_lstFeedWell[i - 1].m_nDownEle - m_lstFeedWell[i - 1].m_nFrondDownEle; cell24.SetText(XString(_T("跌落%.2f米"), fabs(nDrop))); GridStyle gridStyle2; gridStyle2.SetOverrideAll(TRUE); gridStyle2.SetHorMode(AcDb::kTextLeft); gridStyle2.SetTextHeight(m_dTextHeight); cell24.SetGridStyle(gridStyle2); } } } for (int j = 0; j < lstHead.Length(); j++) { GridCell &cell = *(pSheet)(j, 0); CString csHead = lstHead[j]; if (csHead == _T("管标高(m)")) { cell.SetText(_T("管中标高(m)")); } else cell.SetText(csHead); if (csHead.Find(_T("埋设深度")) > -1 || csHead.Find(_T("覆土厚度")) > -1 || csHead.Find(_T("管线平面")) > -1) { SheetRow *row = pSheet.GetRow(j); row->SetRowHeightStyle(SheetRow::kFree); row->SetHeight(nSheetHeight * 2); } else if (csHead.Find(_T("设计地面标高")) > -1 || csHead.Find(_T("自然地面标高")) > -1 || csHead.Find(_T("管标高(m)")) > -1) {//这几个标高的行,很容易出界 SheetRow *row = pSheet.GetRow(j); row->SetRowHeightStyle(SheetRow::kFree); row->SetHeight(nSheetHeight * 2.5); } if (csHead.Find(_T("设计地面标高")) > -1 || csHead.Find(_T("埋设深度")) > -1 || csHead.Find(_T("桩号")) > -1 || csHead.Find(_T("管道基础")) > -1 || csHead.Find(_T("自然地面标高")) > -1 || csHead.Find(_T("管材")) > -1 || csHead.Find(_T("管线平面")) > -1 || csHead.Find(_T("井径(mm)")) > -1 || csHead.Find(_T("覆土厚度")) > -1 || csHead.Find(_T("井编号")) > -1 || csHead.Find(_T("管标高")) > -1) { if (bBreak2 || bBreak1) { pSheet.MergeCells(j, 1, j, m_lstFeedWell.Length() / 2 + 1); } else { pSheet.MergeCells(j, 1, j, m_lstFeedWell.Length() / 2 + 2); } } } //绘制管线平面 sr add 2007-8-17 if (iPipePlanRow > -1) { XPoint ptS; ptS = pSheet.GetCellPoint(iPipePlanRow, 1); ads_polar(ptS, m_nLayoutRotation + PI / 2, -nSheetHeight * GetPScale(), ptS); ads_polar(ptS, m_nLayoutRotation, 20 * GetPScale(), ptS); for (int i = 0; i < m_lstFeedWell.Length(); i++) { AcDbObjectId id = m_lstFeedWell[i].m_ID; if (m_lstFeedWell[i].m_bIsWell) { //井 OPENOBJ_BEGIN(id, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { AcDbObjectId eqId = pEquip->GetBlock2d(); CString csBlkName = GlobalFunc::GetSymbolName(eqId); OPENOBJ_BEGIN(eqId, AcDb::kForRead, AcDbBlockTableRecord, pBlock); if (pBlock) { AcGeScale3d scale(pEquip->GetScale() * GetPScale(), pEquip->GetScale() * GetPScale(), pEquip->GetScale() * GetPScale()); dc.DrawBlock(*pBlock, ptS, scale, 0, TRUE); } OPENOBJ_END(); } OPENOBJ_END(); // idx++; } else if (!m_lstFeedWell[i].m_bIsWell) {//管 XPoint ptTmp1, ptTmp2; dPipeLen = m_lstFeedWell[i].m_nLength * dScaleX; ptTmp1 = ptS; ads_polar(ptS, m_nLayoutRotation, dPipeLen, ptS); ptTmp2 = ptS; AcDbObjectId id2 = m_lstFeedWell[i - 1].m_ID; OPENOBJ_BEGIN(id2, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { if (pEquip->IsHidePipe()) { double dScale = pEquip->GetScale() * GetPScale(); ads_polar(ptTmp1, m_nLayoutRotation, dScale / 2, ptTmp1); } } OPENOBJ_END(); AcDbObjectId id3 = m_lstFeedWell[i + 1].m_ID; OPENOBJ_BEGIN(id3, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { if (pEquip->IsHidePipe()) { double dScale = pEquip->GetScale() * GetPScale(); ads_polar(ptTmp2, m_nLayoutRotation, -dScale / 2, ptTmp2); } } OPENOBJ_END(); DrawLine(ptTmp1, ptTmp2, dc); // 绘制给水管道中间的支路 sr add 2008-7-8 int iPipeLen = m_lstFeedWell[i].m_lstID.Length(); XPoly2D poly; AcDbObjectIdArray idArray; for (int j = 0; j < iPipeLen; j++) { AcDbObjectId idPipe = m_lstFeedWell[i].m_lstID[j]; OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipe, pPipe); if (pPipe) { AcDbObjectId idNode1 = pPipe->GetNode(0); AcDbObjectId idNode2 = pPipe->GetNode(1); AppendIdArray(idArray, idNode1); AppendIdArray(idArray, idNode2); XCurveSegment seg = *pPipe; seg.SetElevation(0); if (j == iPipeLen - 1) poly.AppendSegment(seg, 0, 1); else poly.AppendSegment(seg); } OPENOBJ_END(); } AcDbPolyline pline; GlobalFunc::PolyConvert(poly, pline); int iNodeLen = idArray.length(); for (j = 0; j < iNodeLen; j++) { AcDbObjectId idNode = idArray[j]; double dDist2Well(0); //OPENOBJ_BEGIN(idNode, AcDb::kForRead, TDbPipeFitting, pNode); //if (pNode) { // XPoint ptLoc = pNode->GetLocation(); // ptLoc.z = 0;//仅算投影距离 // pline.getDistAtPoint(ptLoc, dDist2Well); //} //OPENOBJ_END(); if (!GlobalFunc::DocGetMeterUnitDraw()) dDist2Well = dDist2Well / 1000.0; //转换为米 XPoint ptPipe1, ptPipe2; ads_polar(ptTmp1, m_nLayoutRotation, dDist2Well * dScaleX, ptPipe1); ads_polar(ptPipe1, m_nLayoutRotation + PI / 2, nSheetHeight * GetPScale() / 2.0, ptPipe2); DrawLine(ptPipe1, ptPipe2, dc); } } } } XPoint ptBase = pSheet.GetTopLeft(FALSE); //if (dc.IsFullExplode()) //炸开时,以防多绘制一遍文字 // pSheet.DrawCellText(ptBase, dc, nGsMarker); //if (dc.IsFullExplode()) // pSheet.ExplodeOrDraw2d(dc); //else // dc.DrawEntity(pSheet); DrawBaseEx(dc, pSheet); // cet 2017.9.6 add 获得表格角点 double dAngle = pSheet.GetRotation(); AcGeVector3d vtX = AcGeVector3d::kXAxis; GlobalFunc::Ucs2Wcs(vtX, TRUE); vtX.rotateBy(dAngle, AcGeVector3d::kZAxis); AcGeVector3d vtY = vtX; vtY.rotateBy(PI / 2, AcGeVector3d::kZAxis); double dWidth = 0.0; for (int i = 0; i < pSheet.GetColumnNum(); ++i) { dWidth += pSheet.GetColumnWidth(i, FALSE); } double dHeight = pSheet.GetRowsHeight(0, pSheet.GetRowNum() - 1, FALSE); const_cast(m_ptTopLeft) = ptCivilIns; const_cast(m_ptTolRight) = m_ptTopLeft + vtX * dWidth; const_cast(m_ptBottomLeft) = ptCivilIns - vtY * dHeight; const_cast(m_ptBottomRight) = m_ptBottomLeft + vtX * dWidth; return Acad::eOk; } void CDbVerticalSectionFeed::GetAllPipes(DList &lstAllPipe) const { // cet 2016.7.6 add 纵断面图上的管道 std::set setId; for (int i = 0; i < m_lstFeedWell.Length(); ++i) { setId.insert(m_lstFeedWell[i].m_ID); } lstAllPipe.Reset(); SHAcDbBlockTableRecPtr objMSpace; if (!objMSpace) return; AcDbBlockTableRecordIterator* pBlockIterator = NULL; Acad::ErrorStatus es = objMSpace.m_pBlockTableRec->newIterator(pBlockIterator); ASSERT(es == Acad::eOk && pBlockIterator != NULL); for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step()) { AcDbEntity *pEntity = NULL; es = pBlockIterator->getEntity(pEntity, AcDb::kForRead); if (pEntity != NULL) { if (pEntity->isKindOf(CDbPipe::desc())) { AcDbObjectId id = pEntity->objectId(); if (setId.count(id) == 0) // cet 2016.7.6 add 排除纵断面图上的管道 { lstAllPipe.Append(new AcDbObjectId(id)); } } pEntity->close(); } } delete pBlockIterator; return; } Acad::ErrorStatus CDbVerticalSectionFeed::Draw2d(AcGiDraw &dc) const { // cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制) AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead); if (player.openStatus() == Acad::eOk && player->isOff()) { return Acad::eOk; } assertReadEnabled(); //if (g_bOsnapExpl)//不支持求交,速度太慢 // return Acad::eOk; InitPipeData(); // cet 2016.9.23 add 获得最新管道信息 XPoint ptEnd; if (!!objectId()) DrawScale(dc, ptEnd); DrawSectionFeed(dc); //给水系统 从左往右 if (!!objectId()) DrawCivilSheetFeed(dc, ptEnd); //给水系统 return Acad::eOk; } void CDbVerticalSectionFeed::Calc() { UpdateHidePipes(); // cet 2017.11.22 add 更新遮挡数据 InitPipeData(); // cet 2016.7.6 add 获得管道信息, m_nMaxDeep = m_lstFeedWell[0]->m_nUpEle; m_nMinDeep = m_lstFeedWell[0]->m_nUpEle; for (int i = 0; i < m_lstFeedWell.Length(); i++) { if (m_lstFeedWell[i]->m_bIsWell) { //井 AcDbObjectId id = m_lstFeedWell[i]->m_ID; double nWellEle = m_lstFeedWell[i]->m_nUpEle; double nWellDownEle = m_lstFeedWell[i]->m_nDownEle; if (nWellDownEle < m_nMinDeep) //找出最小标高 m_nMinDeep = nWellDownEle; if (nWellEle > m_nMaxDeep) //找出最大标高, 绘制Y比例尺 m_nMaxDeep = nWellEle; } else if (!m_lstFeedWell[i]->m_bIsWell) { //管 if (i == m_lstFeedWell.Length() - 1) continue; } } XPoint ptIns = m_ptIns; double dScaleY = m_iScaleY; double dScaleX = m_iScaleX; dScaleX = GetPScale() / dScaleX * 1000; dScaleY = GetPScale() / dScaleY * 1000;//转化为毫米 double nEleStart = m_lstFeedWell[0]->m_nUpEle; XPoint ptStart, ptEnd; ptStart = ptIns; double dPipeLen = 0; m_lstPt.Reset(); m_lstPt.NewAppend(ptIns); for (i = 0; i < m_lstFeedWell.Length(); i++) { double nEle = m_lstFeedWell[i]->m_nUpEle - nEleStart;//地面标高 if (m_lstFeedWell[i]->m_bIsWell) { //井 if (dPipeLen > 0) { ads_polar(ptStart, m_nLayoutRotation, dPipeLen, ptEnd); // ptEnd.y = ptIns.y; nEle = m_lstFeedWell[i]->m_nUpEle - m_lstFeedWell[i - 2]->m_nUpEle; //井面标高 ads_polar(ptEnd, m_nLayoutRotation + PI / 2, nEle * dScaleY, ptEnd); m_lstPt.NewAppend(ptEnd); ptStart = ptEnd; } dPipeLen = 0; } else if (!m_lstFeedWell[i]->m_bIsWell) { //管 dPipeLen = m_lstFeedWell[i]->m_nLength * dScaleX; if (m_lstFeedWell[i - 1]->m_csName == _T("断管")) dPipeLen = 0; } } } BOOL CDbVerticalSectionFeed::GetFeedWellListData(DList &lstWellSys, DList &lstFeedWellSys) { lstFeedWellSys.Reset(); BOOL bRet = TRUE; int len = lstWellSys.Length(); for (int i = 0; i < len; i++) { if (lstWellSys[i]->m_bIsWell) { TFeedWellData *pNewList = new TFeedWellData(); pNewList->m_csName = lstWellSys[i]->m_csName; pNewList->m_iDn = lstWellSys[i]->m_iDn; pNewList->m_nLength = lstWellSys[i]->m_nLength; pNewList->m_nGroundEle = lstWellSys[i]->m_nGroundEle; pNewList->m_nUpEle = lstWellSys[i]->m_nUpEle; pNewList->m_nDownEle = lstWellSys[i]->m_nDownEle; pNewList->m_nFrondDownEle = lstWellSys[i]->m_nFrondDownEle; pNewList->m_nDeep = lstWellSys[i]->m_nDeep; pNewList->m_bIsWell = lstWellSys[i]->m_bIsWell; pNewList->m_bIsDropWell = lstWellSys[i]->m_bIsDropWell;; pNewList->m_nWellRadius = lstWellSys[i]->m_nWellRadius; pNewList->m_ID = lstWellSys[i]->m_ID; pNewList->m_nI = lstWellSys[i]->m_nI; pNewList->m_nSpare = lstWellSys[i]->m_nSpare; lstFeedWellSys.Append(pNewList); } else { //管线 TFeedWellData *pNewList = new TFeedWellData(); pNewList->m_csName = lstWellSys[i]->m_csName; pNewList->m_iDn = lstWellSys[i]->m_iDn; pNewList->m_nGroundEle = lstWellSys[i]->m_nGroundEle; pNewList->m_nUpEle = lstWellSys[i]->m_nUpEle; pNewList->m_nDownEle = lstWellSys[i]->m_nDownEle; pNewList->m_nFrondDownEle = lstWellSys[i]->m_nFrondDownEle; pNewList->m_nDeep = lstWellSys[i]->m_nDeep; pNewList->m_bIsWell = lstWellSys[i]->m_bIsWell; pNewList->m_bIsDropWell = lstWellSys[i]->m_bIsDropWell;; pNewList->m_nWellRadius = lstWellSys[i]->m_nWellRadius; pNewList->m_nI = lstWellSys[i]->m_nI; pNewList->m_nSpare = lstWellSys[i]->m_nSpare; pNewList->m_nLength = 0; int idx = i; while (idx < len) { AcDbSoftPointerId id = lstWellSys[idx]->m_ID; pNewList->m_nLength += lstWellSys[idx]->m_nLength; pNewList->m_lstID.Append(new AcDbSoftPointerId(id)); i = idx; idx++; if (lstWellSys[idx]->m_bIsWell) break; } lstFeedWellSys.Append(pNewList); } } return bRet; } void CDbVerticalSectionFeed::GetWellDatas(DList& lstWell) const { int nCount = m_lstFeedWell.Length(); for (int i = 0; i < nCount; i++) { TFeedWellData *pData = new TFeedWellData; *pData = m_lstFeedWell[i]; lstWell.Append(pData); } } void CDbVerticalSectionFeed::SetWellDatas(DList& lstWell) { assertWriteEnabled(); m_lstFeedWell.Reset(); int nCount = lstWell.Length(); for (int i = 0; i < nCount; i++) { TFeedWellData *pData = new TFeedWellData; *pData = *lstWell[i];//值拷贝 m_lstFeedWell.Append(pData); } } //取动态属性显示数据 void CDbVerticalSectionFeed::GetTips(DList &info) const { info.Append(new ObjInfoUnit(_T("对象类型"), _T("给水纵断面图"))); } inline double CDbVerticalSectionFeed::OuterDn(const AcDbSoftPointerId &idPipe) const { std::map::const_iterator it = m_mapPipeData.find(idPipe.handle()); if (it != m_mapPipeData.end()) { return it->second.dOutDn; } return 0.0; } inline double CDbVerticalSectionFeed::InnerDn(const AcDbSoftPointerId &idPipe) const { std::map::const_iterator it = m_mapPipeData.find(idPipe.handle()); if (it != m_mapPipeData.end()) { return it->second.dInnerDn; } return 0.0; } inline void CDbVerticalSectionFeed::InitPipeData() const { std::map &mapData = const_cast&>(m_mapPipeData); mapData.clear(); for (int i = 0; i < m_lstFeedWell.Length(); ++i) { if (m_lstFeedWell[i].m_bIsWell) // cet 2016.9.23 add { continue; } PIPEDATA data; data.dDn = m_lstFeedWell[i].m_iDn; // cet 2016.9.23 add InitPipeData(m_lstFeedWell[i].m_ID, data); mapData[m_lstFeedWell[i].m_ID.handle()] = data; } } inline void CDbVerticalSectionFeed::InitPipeData(const AcDbSoftPointerId &idPipe, PIPEDATA &node) const { // cet 2016.9.22 modify 读取计算数据,以便实现单独修改纵断面图数据而不影响管道实体(如单元修改管道管径,只对纵断面图产生影响,而不对管道进行任何修改) // OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipe, pPipe); // if (pPipe != NULL) // { // node.dDn = pPipe->GetDnDiameter(); // node.dOutDn = ((pPipe->OuterDn() > 0.001) ? pPipe->OuterDn() : node.dDn); // node.dPipeThick = pPipe->GetPipeThick(); // node.dInnerDn = node.dOutDn - node.dPipeThick * 2; // } // OPENOBJ_END(); AcDbHandle handle = idPipe.handle(); TCHAR szHandle[256] = _T(""); handle.getIntoAsciiBuffer(szHandle); CString sHandle = szHandle; node.dOutDn = node.dDn; node.dInnerDn = node.dDn; GetPipeOuterDnInnerDn(idPipe, node.dOutDn, node.dInnerDn); node.dPipeThick = (node.dOutDn - node.dInnerDn) * 0.5; } bool CDbVerticalSectionFeed::IsOnlyShowBranch() const { assertReadEnabled(); const EntityFields &fd = GetFields(); Adesk::Boolean bFlag = Adesk::kTrue; fd.GFD(_T("ONLY_SHOW_BRANCH"), bFlag); return bFlag == Adesk::kTrue ? true : false; } void CDbVerticalSectionFeed::SetOnlyShowBranch(bool bShow) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("ONLY_SHOW_BRANCH"), bShow ? Adesk::kTrue : Adesk::kFalse); } bool CDbVerticalSectionFeed::IsShowEqualEleBranch() const { assertReadEnabled(); const EntityFields &fd = GetFields(); Adesk::Boolean bFlag = Adesk::kFalse; fd.GFD(_T("SHOW_EQUAL_ELEVATION_BRANCH"), bFlag); return bFlag == Adesk::kTrue ? true : false; } void CDbVerticalSectionFeed::SetShowEqualEleBranch(bool bShow) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("SHOW_EQUAL_ELEVATION_BRANCH"), bShow ? Adesk::kTrue : Adesk::kFalse); } bool CDbVerticalSectionFeed::IsBrach(CDbPipe *pPipe, const AcDbObjectId &idMainLinked) const { for (int i = 0; i < 2; ++i) { AcDbObjectId id = pPipe->GetNode(i); if (id == idMainLinked) // 主干一端连接的实体 { continue; } // 判断管道另一端连接的实体类型 OPENOBJ_BEGIN(id, AcDb::kForRead, CDbPipeNode, pEqup); if (pEqup != NULL) { return pEqup->isKindOf(AecXDbWell::desc()); } OPENOBJ_END(); } return false; } void CDbVerticalSectionFeed::UpdatePipeOuterDnInnerDn(const AcDbObjectId &id, double dOuterDn, double dInnerDn) { assertWriteEnabled(); AcDbHandle handle = id.handle(); TCHAR szHandle[256] = _T(""); handle.getIntoAsciiBuffer(szHandle); CString sHandle = szHandle; EntityFields &fd = Fields(); fd.SFD(sHandle + _T("-outerDn"), dOuterDn); fd.SFD(sHandle + _T("-innerDn"), dInnerDn); } void CDbVerticalSectionFeed::UpdateHidePipes() { //本图所有管线 DList lstAllPipe; GetAllPipes(lstAllPipe); // 管网中的管道 DList lstPipe; for (int i = 0; i < m_lstFeedWell.Length(); ++i) { if (!m_lstFeedWell[i]->m_bIsWell) { lstPipe.Append(new AcDbObjectId(m_lstFeedWell[i]->m_ID)); } } // 获取所有交叉信息 std::vector vecCrossPoint; CalcCrossPipes(lstPipe, lstAllPipe, vecCrossPoint, true); // 清除管道遮挡信息,避免出错 ClearHidePipes(); // 添加遮挡管道信息 EntityFields &fd = Fields(); if (fd.SFD(_T("HidePipesNum"), (Adesk::UInt16)vecCrossPoint.size())) { std::vector::iterator it, itEnd = vecCrossPoint.end(); CString sKey; int nIndex = 0; for (it = vecCrossPoint.begin(); it != itEnd; ++it) { sKey.Format(_T("HidePipe_%d"), nIndex); ++nIndex; it->WriteCrossPoint(fd, sKey); } } } CString CDbVerticalSectionFeed::GetFillingPattern() const { const EntityFields &fd = GetFields(); CString sPattern = _T("AR-HBONE"); fd.GFD(_T("FILLING_PATTERN"), sPattern); return sPattern; } void CDbVerticalSectionFeed::SetFillingPattern(const CString &sPattern) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("FILLING_PATTERN"), sPattern); } double CDbVerticalSectionFeed::GetFillingRatio() const { const EntityFields &fd = GetFields(); double dRatio = 0.5; fd.GFD(_T("FILLING_RATIO"), dRatio); return dRatio; } void CDbVerticalSectionFeed::SetFillingRatio(double dRatio) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("FILLING_RATIO"), dRatio); } Adesk::UInt16 CDbVerticalSectionFeed::GetFillingColor() const { const EntityFields &fd = GetFields(); Adesk::UInt16 nColor = 256; fd.GFD(_T("FILLING_COLOR"), nColor); return nColor; } void CDbVerticalSectionFeed::SetFillingColor(Adesk::UInt16 nColor) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("FILLING_COLOR"), nColor); } void CDbVerticalSectionFeed::GetPipeOuterDnInnerDn(const AcDbObjectId &id, double &dOuterDn, double &dInnerDn) const { assertReadEnabled(); const EntityFields &fd = GetFields(); AcDbHandle handle = id.handle(); TCHAR szHandle[256] = _T(""); handle.getIntoAsciiBuffer(szHandle); CString sHandle = szHandle; fd.GFD(sHandle + _T("-outerDn"), dOuterDn); fd.GFD(sHandle + _T("-innerDn"), dInnerDn); } void CDbVerticalSectionFeed::ClearHidePipes() { EntityFields &fd = Fields(); Adesk::UInt16 nNum = 0; if (fd.GFD(_T("HidePipesNum"), nNum)) { // 删除遮挡管道数参数 long nIndex = fd.Find(_T("HidePipesNum")); fd.Del(nIndex); // 删除遮挡管道记录 CString sIndex; CrossPoint crossTemp(AcDbObjectId::kNull); for (Adesk::UInt16 i = 0; i < nNum; ++i) { sIndex.Format(_T("HidePipe_%d"), i); crossTemp.DelCrossPoint(fd, sIndex); } } } bool CDbVerticalSectionFeed::IsExistHideData() const { assertReadEnabled(); const EntityFields &fd = GetFields(); Adesk::UInt16 nNum = 0; return fd.GFD(_T("HidePipesNum"), nNum); } void CDbVerticalSectionFeed::GetCrossPointInfo(std::vector &vecCrossPoint) const { const EntityFields &fd = GetFields(); Adesk::UInt16 nNum = 0; if (fd.GFD(_T("HidePipesNum"), nNum)) // 有交叉点数据 { CString sKey; for (Adesk::UInt16 i = 0; i < nNum; ++i) { CrossPoint cr; sKey.Format(_T("HidePipe_%d"), i); cr.ReadCrossPoint(fd, sKey); vecCrossPoint.push_back(cr); } } else // 没有现成数据,计算获得 { CDbVerticalSectionFeed *pVal = const_cast(this); if (pVal != NULL) { pVal->UpdateHidePipes(); } } } void CDbVerticalSectionFeed::DrawHatch(AcGiDraw &dc, XPoly2D &ploy) const { AcDbObjectId idOldLayer = dc.GetLayerId(); dc.SetLayer(m_idGridLayer); // cet 2018.2.8 modify 修改填充比例,颜色, 类型 // dc.DrawHatch(ploy, _T("AR-HBONE"), 0.5*GetPScale()); Adesk::UInt16 nOldColor = dc.GetColor(); dc.SetColor(GetFillingColor()); //dc.DrawHatch(ploy, GetFillingPattern(), GetFillingRatio() * GetPScale()); DrawPoly2D(dc, ploy); dc.SetColor(nOldColor); dc.SetLayer(idOldLayer); } bool CDbVerticalSectionFeed::IsShowPipeEndNotLinkedPipe() const { assertReadEnabled(); const EntityFields &fd = GetFields(); Adesk::Boolean bFlag = Adesk::kFalse; fd.GFD(_T("SHOW_PIPEEND_NOTLINKE_PIPE"), bFlag); return bFlag == Adesk::kTrue ? true : false; } void CDbVerticalSectionFeed::SetShowPipeEndNotLinkedPipe(bool bShow) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("SHOW_PIPEEND_NOTLINKE_PIPE"), bShow ? Adesk::kTrue : Adesk::kFalse); } void IniTDbVerticalSectionFeed(BOOL bTrue) { if (bTrue) { CDbVerticalSectionFeed::rxInit(); //CDbVerticalSectionFeed::InitMatchProtocol(TRUE); } else { //CDbVerticalSectionFeed::InitMatchProtocol(FALSE); deleteAcRxClass(CDbVerticalSectionFeed::desc()); } }