#include "stdafx.h" #include "SymbolTableRecord.h" #include "AcDbObjectPtr.h" #include "PickEntSet.h" #include "globalFunc.h" #include "globalDefine.h" #include "DbWell.h" #include "WellDlg.h" #include "SelectBlkDlg.h" #include "TWellJig.h" #include "DbPipe.h" #include "TGAs.h" #include "TImageDrawDC.h" #include "TGGiDrawingStorage.h" #include "layerdef.h" extern CString GetLayerNames(const TCHAR * szTgSubName); extern AcDbObjectId InitTextStyle(const TCHAR *pszStyle, AcDbDatabase *pDb = NULL); extern AcDbObjectId InitLayer(const TCHAR *szLayer, BOOL bApplyChange = TRUE); namespace { CString GetWellName(AcDbObjectId id) { CString csWellName; OPENOBJ_BEGIN(id, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { csWellName = pEquip->GetWellName(); } OPENOBJ_END(); return csWellName; } CString GetWellName(Entity ent) { CString csWellName; OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { csWellName = pEquip->GetWellName(); } OPENOBJ_END(); return csWellName; } Entity GetWellByPt(XPoint &pt, int &iPipeIdx) { RBList rbMaskPipe(RTDXF0, _T("AEC_ZT_WELL"), NULL); PickSet ss(SS_FREE); XPoint ptUcs = GlobalFunc::Wcs2Ucs(pt); // 设置外包框大小 int nLen = int(g_Option::instance().g_nWellRadius * GlobalFunc::DocGetPScale() / 2); if (nLen == 0) { nLen = 1; } GlobalFunc::GetPointPickSet(ptUcs, ss, rbMaskPipe, nLen); // 过滤多余# PickSet ssDel(SS_FREE); for (long i = 0; i < ss.Length(); i++) { Entity ent = ss[i]; XPoint pt1; OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { pt1 = pEquip->GetLocation(); if (pt1.Distance2d(pt) > 1e-3) { ssDel += ent; } } OPENOBJ_END(); } ss -= ssDel; if (ss.Length() != 1) return Entity(); Entity entPipe = ss[0L]; TCHAR szLay[256]; entPipe.GetData(8, szLay); if (_tcsicmp(szLay, LAY_WELL_RAIN) == 0) iPipeIdx = 5; else if (_tcsicmp(szLay, LAY_WELL_DIRT) == 0) iPipeIdx = 3; else if (_tcsicmp(szLay, LAY_WELL_FEED) == 0) iPipeIdx = 0; else if (_tcsicmp(szLay, LAY_WELL_FIRE) == 0) iPipeIdx = 7; else if (_tcsicmp(szLay, LAY_WELL_USED) == 0) iPipeIdx = 6; else if (_tcsicmp(szLay, LAY_WELL_OTHER) == 0) iPipeIdx = 14; else if (_tcsicmp(szLay, LAY_WELL_USELESS) == 0) iPipeIdx = 4; BOOL bFlag = FALSE; double nRadius(0); XPoint ptLoc; OPENOBJ_BEGIN(entPipe, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { ptLoc = pEquip->GetLocation(); nRadius = pEquip->GetScale() * pEquip->GetPScale(); if (fabs(ptLoc.z) > 0.001) { ptLoc.z = 0; if (pEquip->upgradeOpen() == Acad::eOk) { pEquip->SetLocation(ptLoc); pEquip->downgradeOpen(); } } } OPENOBJ_END(); pt.z = 0; double nDist = fabs(ads_distance(pt, ptLoc)); if (nDist < nRadius) pt = ptLoc; else return Entity(); return entPipe; } BOOL GetInterPipeLevel(XPoint pt1, XPoint pt2, double nElevation, int &up, int &low) { pt1 = GlobalFunc::Wcs2Ucs(pt1); pt2 = GlobalFunc::Wcs2Ucs(pt2); BOOL ret = FALSE; up = 256; low = 256; double nRotate = ads_angle(pt1, pt2); ads_polar(pt1, ads_angle(pt1, pt2), 20, pt1); ads_polar(pt2, ads_angle(pt2, pt1), 20, pt2); RBList rbMaskPipe(RTDXF0, _T("AEC_ZT_PIPE"), 8, GetLayerNames(_T("管线")), NULL); PickSet ss(SS_FREE); struct resbuf *pointlist; pointlist = ads_buildlist(RTPOINT, &pt1, RTPOINT, &pt2, NULL); ss.Get(_T("F"), pointlist, NULL, rbMaskPipe); ads_relrb(pointlist); for (long i = 0; i < ss.Length(); i++) { Entity ent = ss[i]; OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe); if (pPipe && !pPipe->IsVertical()) { nElevation = pPipe->StartPoint().z; if (up < pPipe->GetHideLevel() || up == 256) up = pPipe->GetHideLevel(); if (low > pPipe->GetHideLevel() || low == 256) low = pPipe->GetHideLevel(); ret = TRUE; } OPENOBJ_END(); } return ret; } } //专给室外用 void DrawPipeByIdx(XPoint p1, XPoint p2, int idx, double nGradient, double nDn, int iMat = 12) { int up(0), low(0); double nElevation(0); BOOL ret = GetInterPipeLevel(p1, p2, nElevation, up, low); p1.z = 0; p2.z = 0; GlobalFunc::InitPipeLayer(GlobalFunc::GetPipeLayerByIdx(idx)); CDbPipe *pPipe = new CDbPipe; pPipe->SetStartPoint(p1); pPipe->SetEndPoint(p2); // cet 2011.11.1 add 调整线型 // 2008.10.27 自动修正上华带文字线型的逆向管线 CString csLineType = GlobalFunc::GetPipeWireLayLineType(GlobalFunc::GetPipeLayerByIdx(idx)); // 2011.7.8 sr GetPipeWireLayLineType有时候会返回byLayer CString csLineType2 = GlobalFunc::GetLayerLineType(GlobalFunc::GetPipeLayerByIdx(idx)); if (csLineType2.Find(_T("TG")) > -1) { XLine line(p1, p2); double nAng = line.Direction(); if (nAng > PI / 2 && nAng < (PI / 2 * 3 + 0.001)) { pPipe->SetStartPoint(p2); pPipe->SetEndPoint(p1); } } if (up != 256) pPipe->SetHideLevel(up + 1); else pPipe->SetHideLevel(low + 1); pPipe->SetDnDiameter(nDn); //专给室外用 pPipe->SetPipeGradient(nGradient); pPipe->setLayer(GlobalFunc::GetPipeLayerByIdx(idx)); pPipe->setLinetype(GlobalFunc::GetPipeWireLayLineType(GlobalFunc::GetPipeLayerByIdx(idx))); pPipe->SetModelType(TPipeSys::kModel); pPipe->SetMaterial(iMat); //钢筋混凝土 专给室外用 pPipe->SetPipeWeight(g_Option::instance().g_nPipeWidth[idx]); pPipe->SetSysType(GlobalFunc::GetPipeSysByLayer(GlobalFunc::GetPipeLayerByIdx(idx))); pPipe->SetRadius(g_Option::instance().g_nPipeRadius[idx]); pPipe->setColor(AcCmColor()); //随层 GlobalFunc::AddToCurrentSpace(pPipe, Adesk::kTrue); } int GetCurWellSerial(const TCHAR* szLay) { RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL); PickSet ss(SS_FREE); ss.Get(_T("X"), NULL, NULL, rbMask); long len = ss.Length(); int iRet(0); CString csLay = szLay; int l = csLay.GetLength(); for (long i = 0; i < len; i++) { Entity ent = ss[i]; CString csSerial = GetWellName(ent); int idx = csSerial.Find(csLay); if (idx < 0) continue; CString csTmp = csSerial.Right(csSerial.GetLength() - l); int iTmp = _ttoi(csTmp); if (iTmp > iRet) iRet = iTmp; } return iRet; } //*************************************************************************************************** // 布置井 //*************************************************************************************************** CString GetBlkDesName(const TCHAR *szBlk) { CString csBlkName = szBlk; CString csTKName, csRocord, csDesName; GlobalFunc::SplitBlkStr(csBlkName, csTKName, csRocord); csTKName = g_csDwbPath + csTKName + _T(".tk"); //csDesName = GlobalFunc::GetBlkDesName((const TCHAR*)csRocord, (const TCHAR*)csTKName); return csDesName; } // 已知一个线段,在上面按等距布置井,并连管 //如果pCurve为空退出 BOOL InsWellByCurve(AcDbCurve *pCurve, XPoint ptWell, XPoint &ptPick, Entity &entLastWell, CWellDlg &dlg) { if (pCurve == NULL) return FALSE; double dDistEven = dlg.m_nDist; if (!GlobalFunc::DocGetMeterUnitDraw()) dDistEven = dDistEven * 1000; double dEndParam, dStartParam, dWellParam, dPickParam; XPointList lstPt; lstPt.NewAppend(ptWell); XPoint ptOnCurve; pCurve->getClosestPointTo(ptWell, ptOnCurve); double dDist = ads_distance(ptWell, ptOnCurve); if (dDist > 0.001) return FALSE; ptWell = ptOnCurve; pCurve->getClosestPointTo(ptPick, ptPick); pCurve->getEndParam(dEndParam); pCurve->getStartParam(dStartParam); pCurve->getParamAtPoint(ptWell, dWellParam); pCurve->getParamAtPoint(ptPick, dPickParam); double dFromStart = fabs(dPickParam - dStartParam); double dFromEnd = fabs(dPickParam - dEndParam); BOOL bToStart = FALSE; if (dPickParam > dWellParam) bToStart = FALSE; else if (dPickParam < dWellParam) bToStart = TRUE; double dDist2Well(0), dAllLength(0), dLength(0), dParamDist(0); pCurve->getDistAtPoint(ptWell, dDist2Well); pCurve->getDistAtParam(dPickParam, dAllLength); if (bToStart) dLength = dDist2Well - dAllLength; else dLength = dAllLength - dDist2Well; int num = int(dLength / dDistEven); double dTmpDist(dDist2Well); for (int i = 0; i < num; i++) { if (bToStart) dTmpDist -= dDistEven; else dTmpDist += dDistEven; XPoint ptTmp; pCurve->getPointAtDist(dTmpDist, ptTmp); lstPt.NewAppend(ptTmp); ptPick = ptTmp; } //////////////////////////////////////////////////////////////////////////////////////////////////// // 第二步, 绘制井 int len = lstPt.Length(); if (len < 2) return FALSE; double nRotate = 0; CString csName = dlg.m_csName; for (i = 1; i < len; i++) { XPoint ptIns = *lstPt[i]; AecXDbWell *pEquip = new AecXDbWell; pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(dlg.m_csBlkName)); if (_tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) == 0) { pEquip->SetHidePipe(FALSE); nRotate += PI / 2; } else pEquip->SetHidePipe(TRUE); pEquip->SetAngle(nRotate); if (!!entLastWell && _tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) != 0) { OPENOBJ_BEGIN(entLastWell, AcDb::kForWrite, AecXDbWell, pEquip2); if (pEquip2) { pEquip2->SetAngle(nRotate); } OPENOBJ_END(); } ptIns.z = 0; pEquip->SetLocation(ptIns); pEquip->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEquip->SetWellName(csName); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); pEquip->SetLabelLayer(InitLayer(LAY_WELL_TEXT)); pEquip->SetWellEleDown(0); // if(g_bEquipByScale) //pEquip->SetScale(dlg.m_nScale); // zxl 2013.07.26 modify if (dlg.m_iDrawType == 1) { pEquip->SetScale(dlg.m_nScale / GlobalFunc::DocGetPScale()); } else { pEquip->SetScale(dlg.m_nScale); } // else // pEquip->SetScale(dlg.m_nScale*GlobalFunc::DocGetPScale()); pEquip->setLayer(dlg.GetWellLayer()); pEquip->SetWellEleUp(dlg.m_nElevation); if (GetBlkDesName(dlg.m_csBlkName).Find(_T("方")) < 0) pEquip->SetNumber(_T("CIRCLE-0.5")); pEquip->setColor(AcCmColor()); //随层 if (dlg.m_csDimPos == _T("不标注")) pEquip->EnableDrawLabel(FALSE); else pEquip->EnableDrawLabel(TRUE, _tstof(dlg.m_csDimPos)); GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); entLastWell.GetLast(); GlobalFunc::WriteXdata(entLastWell, _T("TG-WELL-RADIUS"), XString(_T("%.2f"), dlg.m_dWellRadius)); csName = GlobalFunc::PlusString(csName, 1, TRUE); XPoint p1, p2; p1 = *lstPt[i - 1]; p2 = ptIns; if (dlg.m_bDrawPipe) { int iPipeIdx(0); if (dlg.m_iPipeSys == 0) iPipeIdx = 0; else if (dlg.m_iPipeSys == 1) iPipeIdx = 3; else if (dlg.m_iPipeSys == 2) iPipeIdx = 4; else if (dlg.m_iPipeSys == 3) iPipeIdx = 5; else if (dlg.m_iPipeSys == 4) iPipeIdx = 6; else if (dlg.m_iPipeSys == 5) iPipeIdx = 7; else if (dlg.m_iPipeSys == 6) iPipeIdx = 14; DrawPipeByIdx(p1, p2, iPipeIdx, dlg.m_nGradient, _tstof(dlg.m_csDn), dlg.m_iMaterial); } } dlg.m_csName = csName; dlg.UpdateData(FALSE); //TPipePerDocData *pData = GetCurPipeDocData(); //pData->ApplyUpdates(); return TRUE; } // 沿线等距布置井(支持OFFSET) void InsWellByLine(XPoint ptWell, Entity &entLastWell, CWellDlg &dlg) { XPoint ptTemp = ptWell; PickSet ss(SS_FREE); RBList rbMask(RTDXF0, _T("LWPOLYLINE,LINE,ARC"), NULL); GlobalFunc::GetPointPickSet(ptTemp, ss, rbMask, 1); ptWell.z = 0; Entity ent, ent2; XPoint ptPick, ptPick2; double dOffsetDist(0); if (ss.Length() <= 0) { //井不在所选的线上面 if (GlobalFunc::SelectEntity1(0.3, _T("\n请拾取布置井需要沿的PLINE、直线、弧线 <退出>"), ent, ptPick, rbMask) != RTNORM) return; ptPick = GlobalFunc::Ucs2Wcs(ptPick); ptWell.z = ptPick.z; // cet 2012.8.21 add 保持z值一致 OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbCurve, pCurve); if (pCurve) { XPoint ptOnCurve; pCurve->getClosestPointTo(ptWell, ptOnCurve); dOffsetDist = ads_distance(ptWell, ptOnCurve); if (dOffsetDist > 0.001) { AcDbCurve *pCurve2 = GlobalFunc::GetOffsetCurve(pCurve, dOffsetDist, ptWell); if (pCurve2 == NULL) return; InsWellByCurve(pCurve2, ptWell, ptPick, entLastWell, dlg); delete pCurve2; ptWell = ptPick; pCurve->getClosestPointTo(ptPick, ptPick); } else InsWellByCurve(pCurve, ptWell, ptPick, entLastWell, dlg); } OPENOBJ_END(); if (ent.Is(_T("LWPOLYLINE"))) return; } else { ptPick = ptTemp; long lIndex = 0; ent = ss[lIndex]; } while (GlobalFunc::SelectEntity1(0.3, _T("\n请拾取下一段PLINE、直线、弧线 <退出>"), ent2, ptPick2, rbMask) == RTNORM) { ptPick2 = GlobalFunc::Ucs2Wcs(ptPick2); //临时创建1条PLINE线,反复调用InsWellByCurve AcDbPolyline *pLine = GlobalFunc::GetNextPloyLine(ent, ent2, ptPick, ptPick2); if (pLine != NULL) { ptWell.z = pLine->elevation(); // cet 2012.8.21 add 保持z值一致 ptPick.z = pLine->elevation(); // cet 2012.8.21 add 保持z值一致 if (dOffsetDist > 0.001) { AcDbCurve *pCurveOffset = GlobalFunc::GetOffsetCurve((AcDbCurve *)pLine, dOffsetDist, ptWell); pCurveOffset->getClosestPointTo(ptPick, ptWell); pCurveOffset->getClosestPointTo(ptPick2, ptPick2); InsWellByCurve(pCurveOffset, ptWell, ptPick2, entLastWell, dlg); ptWell = ptPick2; delete pCurveOffset; // GlobalFunc::AddToCurrentSpace(pCurveOffset, Adesk::kTrue); pLine->getClosestPointTo(ptPick2, ptPick2); } else InsWellByCurve(pLine, ptPick, ptPick2, entLastWell, dlg); delete pLine; ptPick = ptPick2; ent = ent2; } } } // cet 2011.5.26 ad 判断是否需调整井插入点标高值 bool IsModifyWellLocation(const XPoint &ptStart, double &dEle) { bool bModifyWell = false; PickSet ss(SS_FREE); RBList rbPipe(RTDXF0, _T("AEC_ZT_PIPE"), NULL); ss.Get(GlobalFunc::Wcs2Ucs(ptStart), rbPipe); if (ss.Length() > 1) { bModifyWell = true; for (long i = 0; i < ss.Length(); i++) { XPoint pt1, pt2; GlobalFunc::GetPipePoint(ss[i], pt1, pt2); if (pt1.Distance2d(ptStart) < g_Option::instance()._DIST_SNAP) { if (i == 0) { dEle = pt1.z; } else if (fabs(dEle - pt1.z) > g_Option::instance()._DIST_SNAP) { bModifyWell = false; break; } } else if (pt2.Distance2d(ptStart) < g_Option::instance()._DIST_SNAP) { if (i == 0) { dEle = pt2.z; } else if (fabs(dEle - pt2.z) > g_Option::instance()._DIST_SNAP) { bModifyWell = false; break; } } } } return bModifyWell; } // zxl add 2012.10.16 更换井编号图层从WELL_TEXT到对应管线标注文字图层 void GetWellSerialLayer(CString &sWellLayer, CString &sWellSerialLayer) { if (sWellLayer == LAY_WELL_FEED) { sWellSerialLayer = LAY_TEXT_FEED; } else if (sWellLayer == LAY_WELL_DIRT) { sWellSerialLayer = LAY_TEXT_DIRT; } else if (sWellLayer == LAY_WELL_USED) { sWellSerialLayer = LAY_TEXT_USED; } else if (sWellLayer == LAY_WELL_RAIN) { sWellSerialLayer = LAY_TEXT_RAIN; } else if (sWellLayer == LAY_WELL_USELESS) { sWellSerialLayer = LAY_TEXT_USELESS; } else if (sWellLayer == LAY_WELL_FIRE) { sWellSerialLayer = LAY_TEXT_FIRE; } else if (sWellLayer == LAY_WELL_OTHER) { sWellSerialLayer = LAY_TEXT_OTHER; } } // 布置交点井 void CreatWell(std::vector > &vecPts, CWellDlg &dlg) { CString csBlkName = dlg.m_csBlkName; CString csTK, csRecord; GlobalFunc::SplitBlkStr(csBlkName, csTK, csRecord); XString xsTmp; if (GlobalFunc::LoadDwbBlock((const TCHAR*)csTK, (const TCHAR*)csRecord, xsTmp) != RTNORM) { dlg.DestroyWindow(); return; } std::vector vecWell; std::vector >::iterator it; for (it = vecPts.begin(); it != vecPts.end(); it++) { AcGePoint3d ptIns = it->first; double dElev = it->second; AecXDbWell *pEquip = new AecXDbWell; pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(dlg.m_csBlkName)); if (_tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) == 0) { pEquip->SetHidePipe(FALSE); } else { pEquip->SetHidePipe(TRUE); } double nElevation(0), nRotate2(0); int iPipeIdx(-1); Entity entWire = GlobalFunc::GetPipeByPt(ptIns, nElevation, iPipeIdx); if (!!entWire) { XPoint pt3, pt4; GlobalFunc::GetPipePoint(entWire, pt3, pt4); nRotate2 = ads_angle(pt3, pt4); OPENOBJ_BEGIN(entWire, AcDb::kForWrite, CDbPipe, pPipe); if (pPipe) { AcGePoint3d p1 = ptIns; AcGePoint3d p2 = p1; p2.z = 100; AcDbLine line(p1, p2); AcGePoint3dArray arry; arry.setLogicalLength(0); pPipe->intersectWith(&line, AcDb::kExtendBoth, arry); if (arry.length() > 0) { p2 = arry[0]; } pPipe->BreakAt(p2, PS_SNAP); } OPENOBJ_END(); } pEquip->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEquip->SetAngle(nRotate2); CString sWellLayer = dlg.GetWellLayer(); CString sWellSerialLayer = LAY_WELL_TEXT; GetWellSerialLayer(sWellLayer, sWellSerialLayer); pEquip->SetLabelLayer(InitLayer(sWellSerialLayer)); if (vecPts.size() == 1) { pEquip->SetWellName(dlg.m_csName); } pEquip->SetLocation(ptIns); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); //pEquip->SetScale(dlg.m_nScale); // zxl 2013.07.26 modify if (dlg.m_iDrawType == 1) { pEquip->SetScale(dlg.m_nScale / GlobalFunc::DocGetPScale()); } else { pEquip->SetScale(dlg.m_nScale); } pEquip->setLayer(dlg.GetWellLayer()); pEquip->SetWellEleUp(dlg.m_nElevation); pEquip->SetWellEleDown(0); if (dlg.m_csDimPos == _T("不标注") || vecPts.size() > 1) pEquip->EnableDrawLabel(FALSE); else pEquip->EnableDrawLabel(TRUE, _tstof(dlg.m_csDimPos)); if (GetBlkDesName(dlg.m_csBlkName).Find(_T("方")) < 0) pEquip->SetNumber(_T("CIRCLE-0.5")); pEquip->setColor(AcCmColor()); //随层 AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); vecWell.push_back(id); dlg.UpdateData(FALSE); Entity entLastWell; entLastWell.GetLast(); GlobalFunc::WriteXdata(entLastWell, _T("TG-WELL-RADIUS"), XString(_T("%.2f"), dlg.m_dWellRadius)); //TPipePerDocData *pData = GetCurPipeDocData(); //pData->ApplyUpdates(); // 对于不同标高的插入点都要set一次 AecXDbWell *pWell = NULL; acdbOpenObject(pWell, id, AcDb::kForWrite); if (pWell != NULL) { XPoint pt = pWell->GetLocation(); pt.z = dElev; pWell->SetLocation(pt); pWell->close(); } //TPipePerDocData *pData2 = GetCurPipeDocData(); //pData2->ApplyUpdates(); } // 将井插入点还原 std::vector::iterator itW; for (itW = vecWell.begin(); itW != vecWell.end(); itW++) { AecXDbWell *pWell = NULL; acdbOpenObject(pWell, *itW, AcDb::kForWrite); if (pWell != NULL) { XPoint pt = pWell->GetLocation(); pt.z = 0.0; pWell->SetLocation(pt); pWell->close(); } } //TPipePerDocData *pData3 = GetCurPipeDocData(); //pData3->ApplyUpdates(); } // 判断当前点是否存在 bool HasPushInVec(std::vector > &vecPts, const AcGePoint3d &ptOnLine) { std::vector >::iterator it; AcGePoint3d ptCur = ptOnLine; ptCur.z = 0; for (it = vecPts.begin(); it != vecPts.end(); it++) { AcGePoint3d pt = it->first; pt.z = 0; if (pt.distanceTo(ptCur) < 0.001) { return true; } } return false; } // 判断管线图层是否和当前选定图层是同一系统 bool IsSameSys(const CString &sLayer1, const CString &sLayer2) { if (sLayer1.Compare(sLayer2) == 0) { return true; } else if ((sLayer1 == LAY_PIPE_FEED || sLayer1 == LAY_PIPE_FEED2 || sLayer1 == LAY_PIPE_FEED3) && (sLayer2 == LAY_PIPE_FEED || sLayer2 == LAY_PIPE_FEED2 || sLayer2 == LAY_PIPE_FEED3)) { return true; } else if ((sLayer1 == LAY_PIPE_FIRE || sLayer1 == LAY_PIPE_FIRE2 || sLayer1 == LAY_PIPE_FIRE3) && (sLayer2 == LAY_PIPE_FIRE || sLayer2 == LAY_PIPE_FIRE2 || sLayer2 == LAY_PIPE_FIRE3)) { return true; } else if ((sLayer1 == LAY_PIPE_USED || sLayer1 == LAY_PIPE_USED2 || sLayer1 == LAY_PIPE_USED3) && (sLayer2 == LAY_PIPE_USED || sLayer2 == LAY_PIPE_USED2 || sLayer2 == LAY_PIPE_USED3)) { return true; } return false; } // 获取交点布置井可用的管线 void GetUsefulPipe(PickSet &ss, const CString &sLayer) { PickSet ssPipe(SS_FREE); for (long l = 0; l < ss.Length(); l++) { Entity ent = ss[l]; CString sPipeLayer; OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPipe, pPipe); if (pPipe != NULL) { sPipeLayer = pPipe->GetLayer(); } OPENOBJ_END(); if (IsSameSys(sLayer, sPipeLayer)) { ssPipe += ent; } } ss.Free(); ss += ssPipe; } void InsWellByIntersect(PickSet &ssPipe, CWellDlg &dlg) { GetUsefulPipe(ssPipe, dlg.GetPipeLayer()); if (ssPipe.Length() < 2) { return; } double dMaxDist = GlobalFunc::DocGetCurMeterUnitDraw() ? 3 : 3000; std::vector > vecPts; Entity ent1, ent2; XPoint ptS, ptE; for (long l = 0; l < ssPipe.Length(); l++) { ent1 = ssPipe[l]; GlobalFunc::GetPipePoint(ent1, ptS, ptE); AcDbLine lPipe1(ptS, ptE); ptS.z = 0; ptE.z = 0; AcDbLine line1(ptS, ptE); for (long ll = l + 1; ll < ssPipe.Length(); ll++) { ent2 = ssPipe[ll]; GlobalFunc::GetPipePoint(ent2, ptS, ptE); AcDbLine lPipe2(ptS, ptE); ptS.z = 0; ptE.z = 0; AcDbLine line2(ptS, ptE); AcGePoint3dArray arry; arry.setLogicalLength(0); line1.intersectWith(&line2, AcDb::kOnBothOperands, arry); if (arry.length() == 1) { AcGePoint3d ptOnLine = arry[0]; AcGePoint3d pt1, pt2, ptIns = ptOnLine; ptIns.z = dMaxDist; AcDbLine lIns(ptOnLine, ptIns); AcGePoint3dArray arry; arry.setLogicalLength(0); lIns.intersectWith(&lPipe1, AcDb::kExtendBoth, arry); if (arry.length() > 0) { pt1 = arry[0]; arry.setLogicalLength(0); } lIns.intersectWith(&lPipe2, AcDb::kExtendBoth, arry); if (arry.length() > 0) { pt2 = arry[0]; arry.setLogicalLength(0); } int idx(0); XPoint pt = ptOnLine; Entity entEq = GetWellByPt(pt, idx); if (fabs(pt1.z - pt2.z) < dMaxDist && !entEq) { if (!HasPushInVec(vecPts, ptOnLine)) { // 两根管线上的井插入点都要保存(保存第一点和第二点的标高) vecPts.push_back(std::make_pair(pt1, pt2.z)); } } } } } CreatWell(vecPts, dlg); } void InsWellCmd() { xg_setvar(_T("CMDECHO"), 0); // cet 2012.2.14 add 关闭回显 int nOsMode = 0; xg_getvar(_T("OSMODE"), &nOsMode); //if (g_bTgOsnap) //{ // nOsMode &= ~0x4000; // nOsMode |= OS_INT | OS_END | OS_NEA; //} XPushVar vOsMode(_T("OSMODE"), nOsMode); CWellDlg dlg(acedGetAcadFrame()); { // if(GlobalFunc::DocGetPScale() < 10 && dlg.m_nDist > 1000.0) // dlg.m_nDist = dlg.m_nDist/1000.0; CTemporaryResourceOverride vTemp; dlg.Create(IDD_WELL, acedGetAcadFrame()); dlg.ShowWindow(SW_SHOW); acedGetAcadDwgView()->SetFocus(); } std::vector vecWell; // cet 2011.5.26 add 保存修改了井插入点标高的井id,以便恢复标高 g_Option::instance().g_nInsBlkRotate = 0; GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle); XPoint ptStart; int ret0(0); Entity entLastWell; PickSet ssPipe(SS_FREE); while (ret0 != RTNORM) { //交点布井 zxl 2013.04.09 add ssPipe.Free(); TCHAR cKey = _T('\0'); dlg.UpdateData(TRUE); dlg.m_bChangeSys = false; bool bSelKeyWord = false; RBList rbMask(RTDXF0, _T("AEC_ZT_PIPE"), 8, GetLayerNames(_T("管线")), NULL); if (dlg.m_iMode == 4) { INITGET_BEG(0, _T("P A ")); ret0 = GlobalFunc::SelectEntities(_T("\n请选择管道交点{选取闭合PLINE(P)/整张图(A)}<退出>:"), ssPipe, rbMask, _T("P A "), cKey); INITGET_END(); } else { INITGET_BEG(0, _T("F R L")); ret0 = ads_getpoint(NULL, _T("\n请点取插入点{输入参考点(F)/选取参考线(L)}<退出>:"), ptStart); INITGET_END(); } if (ret0 == RTKWORD) { if (dlg.m_iMode != 4) { XString sKeyword; ads_getinput(sKeyword); cKey = sKeyword[0]; } if (cKey == _T('F')) { if (ads_getpoint(NULL, _T("\n请输入参考点:"), ptStart) != RTNORM) { dlg.DestroyWindow(); return; } ptStart = GlobalFunc::Ucs2Wcs(ptStart); ads_getpoint(ptStart, _T("\n请输入距参考点的距离<确定>:"), ptStart); ptStart = GlobalFunc::Ucs2Wcs(ptStart); break; } if (cKey == _T('L')) { RBList rbMask(RTDXF0, _T("LINE"), NULL); Entity entLine; XPoint ptPick; if (GlobalFunc::SelectEntity(_T("\n请拾取布置井需要参考的边线<退出>"), entLine, ptPick, rbMask) != RTNORM) { dlg.DestroyWindow(); return; } ptPick = GlobalFunc::Ucs2Wcs(ptPick); XCurveSegment seg(entLine); seg.ProjectToMe(ptPick, ptPick); double nAng = ads_angle(seg.EndPoint(), seg.StartPoint()); double dDist2Line(1000); ads_getreal(_T("\n请输入距基线距离<1000>"), &dDist2Line); XPoint ptend, ptPipe; int itype = -1; ads_prompt(_T("\n请选择插入方向<确定>")); while (1) { struct resbuf pointbuf; int iRet = ads_grread(5, &itype, &pointbuf); ads_point_set(pointbuf.resval.rpoint, ptend); ptend = GlobalFunc::Ucs2Wcs(ptend); if (itype != 5 && itype != 3 && itype != 11) break; AcGeVector3d vectBase(seg.EndPoint().x - seg.StartPoint().x, seg.EndPoint().y - seg.StartPoint().y, 0); AcGeVector3d vectTmp(ptend.x - ptPick.x, ptend.y - ptPick.y, 0); double dAng2 = vectBase.angleTo(vectTmp, AcGeVector3d::kZAxis); if (dAng2 < PI) ads_polar(ptPick, nAng - PI / 2, dDist2Line, ptPipe); else { ads_polar(ptPick, nAng + PI / 2, dDist2Line, ptPipe); } ads_redraw(NULL, 1); if (itype == 3 || itype == 11) { ptStart = GlobalFunc::Wcs2Ucs(ptPipe); break; } else { XPoint ptTmpUcs1 = GlobalFunc::Wcs2Ucs(ptPick); XPoint ptTmpUcs2 = GlobalFunc::Wcs2Ucs(ptPipe); ads_grdraw(ptTmpUcs1, ptTmpUcs2, -1, 0); } } break; }//PLINE线选择范围 zxl 2013.04.09 add else if (cKey == _T('p') || cKey == _T('P')) { bSelKeyWord = true; Entity entPoly; RBList rbMask2(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL); if (GlobalFunc::SelectEntity(_T("\n请选择表示范围的闭合PLINE:<退出>"), entPoly, rbMask2) != RTNORM) { return; } XPoly2D poly2(entPoly); XPoint ptLow3, ptUp3; poly2.GetExtend(ptLow3, ptUp3);; poly2.TransUCS(RBGroups(0), RBGroups(1)); RBList rbFence = poly2.Fence(); GlobalFunc::AssureInCurrentView_New(ptLow3, ptUp3); ssPipe.Get(_T("CP"), rbFence, NULL, rbMask); }// 全图范围 else if (cKey == _T('a') || cKey == _T('A')) { bSelKeyWord = true; acedSSGet(_T("A"), NULL, NULL, rbMask, ssPipe); } else { dlg.UpdateData(TRUE); dlg.m_csHead = dlg.GetHead(); int iSerial = GetCurWellSerial(dlg.m_csHead); iSerial++; dlg.m_csName.Format(_T("%s%d"), dlg.m_csHead, iSerial); dlg.UpdateData(FALSE); } } else if (ret0 == RTCAN || ret0 == RTNONE || (ret0 == RTERROR && dlg.m_iMode == 4 && !dlg.m_bChangeSys)) { dlg.DestroyWindow(); return; } if (ssPipe.Length() > 0 || bSelKeyWord)// 交点布井 zxl 2013.04.09 add { InsWellByIntersect(ssPipe, dlg); return; } } if (!GlobalFunc::IsLayerOn(dlg.GetWellLayer())) { g_Option::instance().adsout << _T("\n该图层已经关闭!请打开该图层后,继续绘制!\n"); dlg.DestroyWindow(); return; } UNDOB; ptStart = GlobalFunc::Ucs2Wcs(ptStart); double nDist(0); int idx(0); Entity entEq = GetWellByPt(ptStart, idx); if (!entEq) { dlg.UpdateData(TRUE); CString csBlkName = dlg.m_csBlkName; CString csTK, csRecord; GlobalFunc::SplitBlkStr(csBlkName, csTK, csRecord); XString xsTmp; if (GlobalFunc::LoadDwbBlock((const TCHAR*)csTK, (const TCHAR*)csRecord, xsTmp) != RTNORM) { dlg.DestroyWindow(); return; } double nElevation(0), nRotate2(0); int iPipeIdx(-1); Entity entWire = GlobalFunc::GetPipeByPt(ptStart, nElevation, iPipeIdx); // zxl 2012.08.21 add if (iPipeIdx >= 0) { if (iPipeIdx == 0) dlg.m_iPipeSys = 0; else if (iPipeIdx == 5) dlg.m_iPipeSys = 3; else if (iPipeIdx == 3) dlg.m_iPipeSys = 1; else if (iPipeIdx == 7) dlg.m_iPipeSys = 5; else if (iPipeIdx == 6) dlg.m_iPipeSys = 4; else if (iPipeIdx == 14) dlg.m_iPipeSys = 6; else if (iPipeIdx == 4) dlg.m_iPipeSys = 2; dlg.UpdateData(FALSE); dlg.m_csHead = dlg.GetHead(); int iSerial = GetCurWellSerial(dlg.m_csHead); iSerial++; dlg.m_csName.Format(_T("%s%d"), dlg.m_csHead, iSerial); if (dlg.m_iPipeSys == 0) { // 给水 dlg.m_csDn = _T("200"); dlg.m_nGradient = 0; dlg.m_iMaterial = 1;//给水铸铁管 dlg.UpdateData(FALSE); } else { dlg.m_csDn = _T("300"); dlg.m_nGradient = 0.003; dlg.m_iMaterial = 12; dlg.UpdateData(FALSE); } dlg.m_nElevation = 0.0; dlg.UpdateData(FALSE); } if (!!entWire) { XPoint pt3, pt4; GlobalFunc::GetPipePoint(entWire, pt3, pt4); nRotate2 = ads_angle(pt3, pt4); OPENOBJ_BEGIN(entWire, AcDb::kForWrite, CDbPipe, pPipe); if (pPipe) { AcGePoint3d p1 = ptStart; AcGePoint3d p2; pPipe->getClosestPointTo(p1, p2); pPipe->BreakAt(p2, PS_SNAP); } OPENOBJ_END(); } // cet 2011.5.26 add 当有多于一根管子的端点与井插入点位置重合(不考虑z值)时, // 并且管线端点标高不为0时,井无法与管子建立关联,需先将井 // 插入点标高调整到与管道端点标高一致,在命令结束时,再调整回 // 井插入点原标高值 bool bModifyWell = false; double dEle = 0.0; bModifyWell = IsModifyWellLocation(ptStart, dEle); AecXDbWell *pEquip = new AecXDbWell; pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(csBlkName)); if (_tcsicmp(_T("$TwtSys$00000389"), csBlkName) == 0) { pEquip->SetHidePipe(FALSE); } else { pEquip->SetHidePipe(TRUE); } ptStart.z = 0; if (bModifyWell)// cet 2011.5.26 add { ptStart.z = dEle; } pEquip->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEquip->SetAngle(nRotate2); // zxl modify 2012.10.16 CString sWellLayer = dlg.GetWellLayer(); CString sWellSerialLayer = LAY_WELL_TEXT; GetWellSerialLayer(sWellLayer, sWellSerialLayer); pEquip->SetLabelLayer(InitLayer(sWellSerialLayer)); pEquip->SetWellName(dlg.m_csName); pEquip->SetLocation(ptStart); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); //pEquip->SetScale(dlg.m_nScale); // zxl 2013.07.26 modify if (dlg.m_iDrawType == 1) { pEquip->SetScale(dlg.m_nScale / GlobalFunc::DocGetPScale()); dlg.m_dWellRadius = dlg.m_nScale; dlg.UpdateData(FALSE); } else { pEquip->SetScale(dlg.m_nScale); } pEquip->setLayer(dlg.GetWellLayer()); pEquip->SetWellEleUp(dlg.m_nElevation); pEquip->SetWellEleDown(0); if (dlg.m_csDimPos == _T("不标注")) pEquip->EnableDrawLabel(FALSE); else pEquip->EnableDrawLabel(TRUE, _tstof(dlg.m_csDimPos)); if (GetBlkDesName(dlg.m_csBlkName).Find(_T("方")) < 0) pEquip->SetNumber(_T("CIRCLE-0.5")); pEquip->setColor(AcCmColor()); //随层 GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); dlg.m_csName = GlobalFunc::PlusString(dlg.m_csName, 1, TRUE); dlg.UpdateData(FALSE); entLastWell.GetLast(); GlobalFunc::WriteXdata(entLastWell, _T("TG-WELL-RADIUS"), XString(_T("%.2f"), dlg.m_dWellRadius)); // cet 2011.5.26 add if (bModifyWell) { AcDbObjectId idWell; acdbGetObjectId(idWell, entLastWell); vecWell.push_back(idWell); } //TPipePerDocData *pData = GetCurPipeDocData(); //pData->ApplyUpdates(); } else { entLastWell = entEq; OPENOBJ_BEGIN(entLastWell, AcDb::kForRead, AecXDbWell, pEquip); if (pEquip) { dlg.m_nScale = pEquip->GetScale(); dlg.m_nElevation = pEquip->GetWellEleUp(); } OPENOBJ_END(); if (idx == 0) dlg.m_iPipeSys = 0; else if (idx == 5) dlg.m_iPipeSys = 3; else if (idx == 3) dlg.m_iPipeSys = 1; else if (idx == 7) dlg.m_iPipeSys = 5; else if (idx == 6) dlg.m_iPipeSys = 4; else if (idx == 14) dlg.m_iPipeSys = 6; else if (idx == 4) dlg.m_iPipeSys = 2; dlg.UpdateData(FALSE); } XPointList lstPt; lstPt.NewAppend(ptStart); double nOld = g_Option::instance().g_nSprinklerRadius; double dJigLockAng(-1); while (1) { TWellJig jig(ptStart); jig.m_nLockAng = dJigLockAng; dlg.UpdateData(TRUE); dlg.m_csHead = dlg.GetHead(); int iSerial = GetCurWellSerial(dlg.m_csHead); iSerial++; dlg.m_csName.Format(_T("%s%d"), dlg.m_csHead, iSerial); dlg.UpdateData(FALSE); // zxl 2013.07.26 add if (dlg.m_iDrawType == 1) { dlg.m_dRealScale = dlg.m_nScale; dlg.m_dWellRadius = dlg.m_nScale; dlg.UpdateData(FALSE); } else { dlg.m_dOutScale = dlg.m_nScale; } double dDistWell = dlg.m_nDist; if (!GlobalFunc::DocGetMeterUnitDraw()) dDistWell = dDistWell * 1000; if (dlg.m_iMode == 1) jig.SetDist(dDistWell); else if (dlg.m_iMode == 0) jig.SetDist(0); else if (dlg.m_iMode == 2) jig.SetDist2(dDistWell); else if (dlg.m_iMode == 3) {//沿线定距 InsWellByLine(ptStart, entLastWell, dlg); break; } // if(g_bEquipByScale) //g_Option::instance().g_nSprinklerRadius = dlg.m_nScale/2*100; // zxl 2013.07.26 modify if (dlg.m_iDrawType == 0) { g_Option::instance().g_nSprinklerRadius = dlg.m_nScale / 2 * 100; } else { g_Option::instance().g_nSprinklerRadius = dlg.m_nScale / 2 * 100 / GlobalFunc::DocGetPScale(); } // else // g_Option::instance().g_nSprinklerRadius = dlg.m_nScale/2*GlobalFunc::DocGetPScale(); jig.SetPrompt(_T("\n请点取井插入点[回退(U)/选取行向线(F)]<退出>:")); jig.SetKeyword(_T("U F R")); int nKeyIndex; int nRetCode = jig.DoIt(&nKeyIndex); if (nRetCode == RTKWORD) { if (nKeyIndex == 0) { int len = lstPt.Length(); if (len == 1) continue; //最后一个, 不能再退了 SHads_command(RTSTR, _T("UNDO"), RTSTR, _T("BACK"), NULL); lstPt.Remove(len - 1); XPoint ptTemp = *lstPt[len - 2]; jig.SetStartPoint(ptTemp); ptStart = ptTemp; } else if (nKeyIndex == 1) { double s_angle(0); int err_value = GlobalFunc::get_line_angle(s_angle); if (err_value == RTNORM) { dJigLockAng = s_angle; //jig.m_nLockAng = s_angle; } } continue; } else if (nRetCode != RTNORM) break; dJigLockAng = -1; if (dlg.m_iMode == 2) { XLine line(ptStart, jig.GetPickPoint(), 1); double nRotate = line.Direction(); // double nRotate(0); XCurveSegment seg; seg = line; XPointList lstPt; GlobalFunc::GetPointList(seg, dDistWell, lstPt); int len = lstPt.Length(); //int len = jig.m_pDrawEnt->m_lstPt.Length(); // if(len > 1){ // XPoint pt3 = *jig.m_pDrawEnt->m_lstPt[0]; // XPoint pt4 = *jig.m_pDrawEnt->m_lstPt[1]; // nRotate = GlobalFunc::Wcs2Ucs(ads_angle(pt3, pt4)); // } CString csName = dlg.m_csName; for (int i = 1; i < len; i++) { XPoint ptIns = *lstPt[i]; AecXDbWell *pEquip = new AecXDbWell; pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(dlg.m_csBlkName)); if (_tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) == 0) { pEquip->SetHidePipe(FALSE); nRotate += PI / 2; } else pEquip->SetHidePipe(TRUE); pEquip->SetAngle(nRotate); if (!!entLastWell && _tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) != 0) { OPENOBJ_BEGIN(entLastWell, AcDb::kForWrite, AecXDbWell, pEquip2); if (pEquip2) { pEquip2->SetAngle(nRotate); } OPENOBJ_END(); } ptIns.z = 0; pEquip->SetLocation(ptIns); pEquip->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEquip->SetWellName(csName); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); // pEquip->SetLabelLayer(InitLayer(LAY_WELL_TEXT)); zxl modify 2012.10.16 CString sWellLayer = dlg.GetWellLayer(); CString sWellSerialLayer = LAY_WELL_TEXT; GetWellSerialLayer(sWellLayer, sWellSerialLayer); pEquip->SetLabelLayer(InitLayer(sWellSerialLayer)); pEquip->SetWellEleDown(0); // if(g_bEquipByScale) // pEquip->SetScale(dlg.m_nScale); // zxl 2013.07.26 modify if (dlg.m_iDrawType == 1) { pEquip->SetScale(dlg.m_nScale / GlobalFunc::DocGetPScale()); } else { pEquip->SetScale(dlg.m_nScale); } // else // pEquip->SetScale(dlg.m_nScale*GlobalFunc::DocGetPScale()); pEquip->setLayer(dlg.GetWellLayer()); pEquip->SetWellEleUp(dlg.m_nElevation); if (GetBlkDesName(dlg.m_csBlkName).Find(_T("方")) < 0) pEquip->SetNumber(_T("CIRCLE-0.5")); pEquip->setColor(AcCmColor()); //随层 if (dlg.m_csDimPos == _T("不标注")) pEquip->EnableDrawLabel(FALSE); else pEquip->EnableDrawLabel(TRUE, _tstof(dlg.m_csDimPos)); GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); entLastWell.GetLast(); GlobalFunc::WriteXdata(entLastWell, _T("TG-WELL-RADIUS"), XString(_T("%.2f"), dlg.m_dWellRadius)); csName = GlobalFunc::PlusString(csName, 1, TRUE); XPoint p1, p2; //p1 = *jig.m_pDrawEnt->m_lstPt[i-1]; p1 = *lstPt[i - 1]; p2 = ptIns; if (dlg.m_bDrawPipe) { int iPipeIdx(0); if (dlg.m_iPipeSys == 0) iPipeIdx = 0; else if (dlg.m_iPipeSys == 1) iPipeIdx = 3; else if (dlg.m_iPipeSys == 2) iPipeIdx = 4; else if (dlg.m_iPipeSys == 3) iPipeIdx = 5; else if (dlg.m_iPipeSys == 4) iPipeIdx = 6; else if (dlg.m_iPipeSys == 5) iPipeIdx = 7; else if (dlg.m_iPipeSys == 6) iPipeIdx = 14; DrawPipeByIdx(p1, p2, iPipeIdx, dlg.m_nGradient, _tstof(dlg.m_csDn), dlg.m_iMaterial); } } break;//两点均布只执行一次,不连续 } // zxl 2012.08.21 add double nElev = 0.0; int iNdx = -1; GlobalFunc::GetPipeByPt(jig.GetPickPoint(), nElev, iNdx); if (!dlg.m_bDrawPipe && iNdx >= 0 && dlg.GetWellStyleChangble()) { if (iNdx == 0) dlg.m_iPipeSys = 0; else if (iNdx == 5) dlg.m_iPipeSys = 3; else if (iNdx == 3) dlg.m_iPipeSys = 1; else if (iNdx == 7) dlg.m_iPipeSys = 5; else if (iNdx == 6) dlg.m_iPipeSys = 4; else if (iNdx == 14) dlg.m_iPipeSys = 6; else if (iNdx == 4) dlg.m_iPipeSys = 2; dlg.UpdateData(FALSE); dlg.m_csHead = dlg.GetHead(); int iSerial = GetCurWellSerial(dlg.m_csHead); iSerial++; dlg.m_csName.Format(_T("%s%d"), dlg.m_csHead, iSerial); if (dlg.m_iPipeSys == 0) { // 给水 dlg.m_csDn = _T("200"); dlg.m_nGradient = 0; dlg.m_iMaterial = 1;//给水铸铁管 dlg.UpdateData(FALSE); } else { dlg.m_csDn = _T("300"); dlg.m_nGradient = 0.003; dlg.m_iMaterial = 12; dlg.UpdateData(FALSE); } dlg.m_nElevation = 0.0; dlg.UpdateData(FALSE); } XPoint ptIns = jig.GetPickPoint(); XPoint ptUcs = GlobalFunc::Ucs2Wcs(jig.GetPickPoint()); if (jig.m_nLockAng > -1) { ptUcs = jig.GetCorrectPt(); ptIns = jig.GetCorrectPt(); jig.m_nLockAng = -1; } SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), NULL); // Make a undo mark dlg.UpdateData(TRUE); Entity entEq2 = GetWellByPt(ptIns, idx); if (!!entEq2) { TCHAR szLayer[256]; entEq2.GetData(8, szLayer); if (_tcsicmp(szLayer, dlg.GetWellLayer()) == 0) { if (dlg.m_bDrawPipe) { int iPipeIdx(0); if (dlg.m_iPipeSys == 0) iPipeIdx = 0; else if (dlg.m_iPipeSys == 1) iPipeIdx = 3; else if (dlg.m_iPipeSys == 2) iPipeIdx = 4; else if (dlg.m_iPipeSys == 3) iPipeIdx = 5; else if (dlg.m_iPipeSys == 4) iPipeIdx = 6; else if (dlg.m_iPipeSys == 5) iPipeIdx = 7; else if (dlg.m_iPipeSys == 6) iPipeIdx = 14; DrawPipeByIdx(ptStart, ptIns, iPipeIdx, dlg.m_nGradient, _tstof(dlg.m_csDn), dlg.m_iMaterial); } break; } } AecXDbWell *pEquip = new AecXDbWell; double nRotate = ads_angle(ptStart, ptIns); pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(dlg.m_csBlkName)); if (_tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) == 0) { pEquip->SetHidePipe(FALSE); nRotate += PI / 2; } else pEquip->SetHidePipe(TRUE); pEquip->SetAngle(nRotate); if (!!entLastWell && _tcsicmp(_T("$TwtSys$00000389"), dlg.m_csBlkName) != 0) { OPENOBJ_BEGIN(entLastWell, AcDb::kForWrite, AecXDbWell, pEquip2); if (pEquip2) { pEquip2->SetAngle(nRotate); } OPENOBJ_END(); } ptIns.z = 0; pEquip->SetLocation(ptIns); pEquip->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0)); pEquip->SetWellName(dlg.m_csName); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); // pEquip->SetLabelLayer(InitLayer(LAY_WELL_TEXT));zxl modify 2012.10.16 CString sWellLayer = dlg.GetWellLayer(); CString sWellSerialLayer = LAY_WELL_TEXT; GetWellSerialLayer(sWellLayer, sWellSerialLayer); pEquip->SetLabelLayer(InitLayer(sWellSerialLayer)); pEquip->SetWellEleDown(0); // if(g_bEquipByScale) //pEquip->SetScale(dlg.m_nScale); // zxl 2013.07.26 modify if (dlg.m_iDrawType == 1) { pEquip->SetScale(dlg.m_nScale / GlobalFunc::DocGetPScale()); } else { pEquip->SetScale(dlg.m_nScale); } // else // pEquip->SetScale(dlg.m_nScale*GlobalFunc::DocGetPScale()); pEquip->setLayer(dlg.GetWellLayer()); pEquip->SetWellEleUp(dlg.m_nElevation); if (GetBlkDesName(dlg.m_csBlkName).Find(_T("方")) < 0) pEquip->SetNumber(_T("CIRCLE-0.5")); pEquip->setColor(AcCmColor()); //随层 if (dlg.m_csDimPos == _T("不标注")) pEquip->EnableDrawLabel(FALSE); else pEquip->EnableDrawLabel(TRUE, _tstof(dlg.m_csDimPos)); GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); entLastWell.GetLast(); GlobalFunc::WriteXdata(entLastWell, _T("TG-WELL-RADIUS"), XString(_T("%.2f"), dlg.m_dWellRadius)); if (dlg.m_bDrawPipe) { int iPipeIdx(0); if (dlg.m_iPipeSys == 0) iPipeIdx = 0; else if (dlg.m_iPipeSys == 1) iPipeIdx = 3; else if (dlg.m_iPipeSys == 2) iPipeIdx = 4; else if (dlg.m_iPipeSys == 3) iPipeIdx = 5; else if (dlg.m_iPipeSys == 4) iPipeIdx = 6; else if (dlg.m_iPipeSys == 5) iPipeIdx = 7; else if (dlg.m_iPipeSys == 6) iPipeIdx = 14; DrawPipeByIdx(ptStart, ptIns, iPipeIdx, dlg.m_nGradient, _tstof(dlg.m_csDn), dlg.m_iMaterial); } ptStart = ptIns; jig.SetStartPoint(ptStart); lstPt.NewAppend(ptStart); dlg.m_csName = GlobalFunc::PlusString(dlg.m_csName, 1, TRUE); dlg.UpdateData(FALSE); //TPipePerDocData *pData = GetCurPipeDocData(); //pData->ApplyUpdates(); } UNDOE; g_Option::instance().g_nSprinklerRadius = nOld; g_Option::instance().g_nWellRadius = dlg.m_nScale; //CRegProperty regProp(GetRegLocation(), _T("TWTConfig")); //regProp.SetTopRootKey(HKEY_CURRENT_USER); //regProp.SetValue(_T("WellRadius"), dlg.m_dOutScale); //regProp.SetValue(_T("WellRadiusReal"), dlg.m_dRealScale);// zxl 2013.07.26 add //regProp.SetValue(_T("WellRadiusDrawType"), dlg.m_iDrawType);// zxl 2013.07.26 add //regProp.SetValue(_T("LastWellBlk"), dlg.m_csBlkName); SHads_command(RTNONE); dlg.DestroyWindow(); // cet 2011.5.26 add 将井插入点还原 std::vector::iterator it; for (it = vecWell.begin(); it != vecWell.end(); it++) { AecXDbWell *pWell = NULL; acdbOpenObject(pWell, *it, AcDb::kForWrite); if (pWell != NULL) { XPoint pt = pWell->GetLocation(); pt.z = 0.0; pWell->SetLocation(pt); pWell->close(); } } } //*************************************************************************************************** // 给水节点 //*************************************************************************************************** void InsOutdoorFeedNode() { int nOsMode = 0; xg_getvar(_T("OSMODE"), &nOsMode); nOsMode &= ~0x4000; nOsMode |= OS_INT | OS_END | OS_NEA; XPushVar vOsMode(_T("OSMODE"), nOsMode); CString csDwb = g_csDwbPath + _T("TwtSys"); XString xsBlockName; if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000389"), xsBlockName) != RTNORM) return; g_Option::instance().g_nInsBlkRotate = 0; GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle); XPoint ptStart; int ret0(0); Entity entLastWell; if (ads_getpoint(NULL, _T("\n请点取插入点[输入参考点(F)]<退出>:"), ptStart) != RTNORM) return; UNDOB; ptStart = GlobalFunc::Ucs2Wcs(ptStart); double nDist(0); int idx(0); Entity entEq = GetWellByPt(ptStart, idx); if (!entEq) { double nElevation(0), nRotate2(0); int iPipeIdx(0); Entity entWire = GlobalFunc::GetPipeByPt(ptStart, nElevation, iPipeIdx); if (!!entWire) { XPoint pt3, pt4; GlobalFunc::GetPipePoint(entWire, pt3, pt4); nRotate2 = ads_angle(pt3, pt4); OPENOBJ_BEGIN(entWire, AcDb::kForWrite, CDbPipe, pPipe); if (pPipe) { AcGePoint3d p1 = ptStart; AcGePoint3d p2; pPipe->getClosestPointTo(p1, p2); pPipe->BreakAt(p2, PS_SNAP); } OPENOBJ_END(); } AecXDbWell *pEquip = new AecXDbWell; pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(xsBlockName)); pEquip->SetHidePipe(FALSE); ptStart.z = 0; pEquip->SetAngle(nRotate2); pEquip->SetLabelLayer(InitLayer(LAY_WELL_TEXT)); pEquip->SetLocation(ptStart); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); pEquip->SetScale(g_Option::instance().g_nWellRadius); pEquip->setLayer(LAY_WELL_FEED); pEquip->SetWellEleUp(0); pEquip->SetWellEleDown(0); pEquip->EnableDrawLabel(FALSE); pEquip->setColor(AcCmColor()); //随层 GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); entLastWell.GetLast(); } else { entLastWell = entEq; } XPointList lstPt; lstPt.NewAppend(ptStart); double nOld = g_Option::instance().g_nSprinklerRadius; TWellJig jig(ptStart); while (1) { jig.m_nDist = 0; jig.SetPrompt(_T("\n请点取井插入点[回退(U)/选取行向线(F)]<退出>:")); jig.SetKeyword(_T("U F R")); int nKeyIndex; int nRetCode = jig.DoIt(&nKeyIndex); if (nRetCode == RTKWORD) { if (nKeyIndex == 0) { int len = lstPt.Length(); if (len == 1) continue; //最后一个, 不能再退了 SHads_command(RTSTR, _T("UNDO"), RTSTR, _T("BACK"), NULL); lstPt.Remove(len - 1); XPoint ptTemp = *lstPt[len - 2]; jig.SetStartPoint(ptTemp); ptStart = ptTemp; } else if (nKeyIndex == 1) { double s_angle(0); int err_value = GlobalFunc::get_line_angle(s_angle); if (err_value == RTNORM) { jig.m_nLockAng = s_angle; } } continue; } else if (nRetCode != RTNORM) break; XPoint ptIns = jig.GetPickPoint(); XPoint ptUcs = GlobalFunc::Ucs2Wcs(jig.GetPickPoint()); if (jig.m_nLockAng > -1) { ptUcs = jig.GetCorrectPt(); ptIns = jig.GetCorrectPt(); jig.m_nLockAng = -1; } SHads_command(RTSTR, _T(".UNDO"), RTSTR, _T("MARK"), NULL); // Make a undo mark AecXDbWell *pEquip = new AecXDbWell; double nRotate = ads_angle(ptStart, ptIns); pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(xsBlockName)); pEquip->SetHidePipe(FALSE); nRotate += PI / 2; pEquip->SetAngle(nRotate); pEquip->SetScale(g_Option::instance().g_nWellRadius); ptIns.z = 0; pEquip->SetLocation(ptIns); pEquip->SetTextHeight(g_Option::instance().g_nDimWellHeight); pEquip->SetTextStyleId(InitTextStyle(g_Option::instance().g_csDimWellStyle)); pEquip->SetLabelLayer(InitLayer(LAY_WELL_TEXT)); pEquip->SetWellEleDown(0); pEquip->setLayer(LAY_WELL_FEED); pEquip->SetWellEleUp(0); pEquip->setColor(AcCmColor()); //随层 pEquip->EnableDrawLabel(FALSE); GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); entLastWell.GetLast(); DrawPipeByIdx(ptStart, ptIns, 0, 0, 300, 0); ptStart = ptIns; jig.SetStartPoint(ptStart); lstPt.NewAppend(ptStart); //TPipePerDocData *pData = GetCurPipeDocData(); //pData->ApplyUpdates(); } UNDOE; } ///////////////////////////////////////////////////////////////////////////// // CWellDlg dialog IMPLEMENT_DYNAMIC(CWellDlg, CModelessDialog) int CWellDlg::m_iPipeSys = 3; int CWellDlg::m_iMaterial = 12; double CWellDlg::m_nDist = 20; double CWellDlg::m_dWellRadius = 700; CString CWellDlg::m_csDimPos = _T("1.5"); BOOL CWellDlg::m_bDrawPipe = TRUE; double CWellDlg::m_nElevation = 0.0; // cet 2010.9.7 add double CWellDlg::m_nGradient = 0.003; // cet 2010.9.7 add CString CWellDlg::m_csDn = _T("300"); // cet 2010.9.7 add BOOL CWellDlg::m_bFirstRun = TRUE; // cet 2010.9.7 add int CWellDlg::m_iMode = 0; // cet 2011.6.14 add int CWellDlg::m_iDrawType = 0; // zxl 2013.07.26 add double CWellDlg::m_dRealScale = 800; // zxl 2013.07.26 add double CWellDlg::m_dOutScale = g_Option::instance().g_nWellRadius; // zxl 2013.07.26 add CWellDlg::CWellDlg(CWnd* pParent /*=NULL*/) : CModelessDialog(CWellDlg::IDD, pParent) { //{{AFX_DATA_INIT(CWellDlg) m_nScale = g_Option::instance().g_nWellRadius; m_csName = _T("Y1"); //}}AFX_DATA_INIT m_csHead = _T("Y"); m_csBlkName = _T("$TwtSys$00000187"); m_bCanChangeStyle = true; m_bChangeSys = false; } bool CWellDlg::GetWellStyleChangble() { return m_bCanChangeStyle; } void CWellDlg::DoDataExchange(CDataExchange* pDX) { CModelessDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWellDlg) DDX_Control(pDX, IDC_STATIC_REALDN, m_wndReal); DDX_Control(pDX, IDC_STATIC_OUT, m_wndOut); DDX_Control(pDX, IDC_EDIT_WELL_RADIUS, m_edtRadius); DDX_Control(pDX, IDC_COMBO_MAT, m_comboMat); DDX_Text(pDX, IDC_EDIT_DIM, m_nScale); DDX_Text(pDX, IDC_EDIT_NAME, m_csName); DDX_Check(pDX, IDC_CHECK_PIPE, m_bDrawPipe); DDX_Text(pDX, IDC_EDIT_ELEV, m_nElevation); DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode); DDX_Text(pDX, IDC_EDIT_DIST, m_nDist); DDX_Text(pDX, IDC_EDIT_GRADIENT, m_nGradient); DDX_CBString(pDX, IDC_COMBO_DN, m_csDn); DDX_CBIndex(pDX, IDC_COMBO_MAT, m_iMaterial); DDX_CBIndex(pDX, IDC_COMBO_PIPE, m_iPipeSys); DDX_CBString(pDX, IDC_COMBO_DIMPOS, m_csDimPos); DDX_Text(pDX, IDC_EDIT_WELL_RADIUS, m_dWellRadius); DDX_Radio(pDX, IDC_RADIO_OUT, m_iDrawType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CWellDlg, CModelessDialog) //{{AFX_MSG_MAP(CWellDlg) ON_WM_PAINT() ON_WM_CLOSE() ON_BN_CLICKED(IDC_CHECK_PIPE, OnCheckPipe) ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode1) ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode2) ON_EN_KILLFOCUS(IDC_EDIT_DIST, OnKillfocusEditDist) ON_CBN_SELCHANGE(IDC_COMBO_PIPE, OnSelchangeComboPipe) ON_BN_CLICKED(IDC_PREVIEW_WELL, OnPreviewWell) ON_BN_CLICKED(IDC_RADIO_MODE3, OnRadioMode3) ON_BN_CLICKED(IDC_RADIO_MODE4, OnRadioMode4) ON_BN_CLICKED(IDC_RADIO_INTERSECT, OnRadioMode5) ON_BN_CLICKED(IDC_RADIO_OUT, OnRadioOut) ON_BN_CLICKED(IDC_RADIO_REAL, OnRadioReal) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWellDlg message handlers BOOL CWellDlg::OnInitDialog() { CModelessDialog::OnInitDialog(); int iold = m_iMaterial; CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); // pWnd->EnableWindow(FALSE); cet 2011.6.14 modify if (pWnd != NULL) { pWnd->EnableWindow(m_iMode == 0 ? FALSE : TRUE); } OpenSlide(); m_csHead = GetHead(); int iSerial = GetCurWellSerial(m_csHead); iSerial++; m_csName.Format(_T("%s%d"), m_csHead, iSerial); XStringList lstMat; GlobalFunc::GetPipeMaterialList(lstMat); for (int i = 0; i < lstMat.Length(); i++) { m_comboMat.AddString(lstMat[i]); } m_iMaterial = iold; //CRegProperty regProp(GetRegLocation(), _T("TWTConfig")); //regProp.SetTopRootKey(HKEY_CURRENT_USER); CString csTmp; //regProp.GetValue(_T("LastWellBlk"), csTmp); //regProp.GetValue(_T("WellRadiusReal"), m_dRealScale); // zxl 2013.07.26 add //regProp.GetValue(_T("WellRadius"), m_dOutScale);// zxl 2013.07.26 add //regProp.GetValue(_T("WellRadiusDrawType"), m_iDrawType);// zxl 2013.07.26 add if (m_iDrawType == 0) { m_nScale = m_dOutScale; m_wndOut.SetWindowText(_T("出图尺寸mm")); m_wndReal.ShowWindow(SW_SHOW); m_edtRadius.ShowWindow(SW_SHOW); } else { m_nScale = m_dRealScale; m_wndOut.SetWindowText(_T("实际尺寸mm")); m_wndReal.ShowWindow(SW_HIDE); m_edtRadius.ShowWindow(SW_HIDE); m_dWellRadius = m_dRealScale; } if (csTmp != _T("")) m_csBlkName = csTmp; // cet 2010.9.7 modify // if(m_iPipeSys == 0){ // 给水 if (m_iPipeSys == 0 && m_bFirstRun) { // 给水并且第一次运行 m_csDn = _T("200"); m_nGradient = 0; m_iMaterial = 1;//给水铸铁管 m_bFirstRun = FALSE; // cet 2010.9.7 add } if (m_iMode == 4) // zxl add 2013.04.15 { CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(FALSE); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CWellDlg::OnPaint() { CPaintDC dc(this); // device context for painting OpenSlide(); } void CWellDlg::OpenSlide() { UpdateData(TRUE); CWnd *pImageBox1 = GetDlgItem(IDC_PREVIEW_WELL); CString csSldName; CString csTK, csRecord; GlobalFunc::SplitBlkStr(m_csBlkName, csTK, csRecord); csSldName.Format(_T("TWTSYS(%s)"), csRecord); GlobalFunc::DrawSlide((const TCHAR*)csSldName, pImageBox1); } void CWellDlg::OnClose() { CModelessDialog::OnClose(); acedPostCommand(_T("\33\33")); } void CWellDlg::OnCheckPipe() { UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_COMBO_PIPE); if (m_bDrawPipe) pWnd->EnableWindow(TRUE); else { pWnd->EnableWindow(FALSE); m_bCanChangeStyle = false;//zxl 2012.08.21 add } } void CWellDlg::OnRadioMode1() { // zxl 2013.04.15 add 布置井方式改变时,发送不同命令(下同) CString sCmd = _T("R "); if (m_iMode == 4) { sCmd = _T(" "); } UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); pWnd->EnableWindow(FALSE); CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(TRUE); GlobalFunc::PostCommand(sCmd, false); acedGetAcadDwgView()->SetFocus(); } void CWellDlg::OnRadioMode2() { CString sCmd = _T("R "); if (m_iMode == 4) { sCmd = _T(" "); } UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); pWnd->EnableWindow(TRUE); CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(TRUE); GlobalFunc::PostCommand(sCmd, false); acedGetAcadDwgView()->SetFocus(); } void CWellDlg::OnRadioMode3() { CString sCmd = _T("R "); if (m_iMode == 4) { sCmd = _T(" "); } UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); pWnd->EnableWindow(TRUE); CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(TRUE); GlobalFunc::PostCommand(sCmd, false); acedGetAcadDwgView()->SetFocus(); } void CWellDlg::OnRadioMode4() { CString sCmd = _T("R "); if (m_iMode == 4) { sCmd = _T(" "); } UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); pWnd->EnableWindow(TRUE); CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(TRUE); GlobalFunc::PostCommand(sCmd, false); acedGetAcadDwgView()->SetFocus(); } void CWellDlg::OnKillfocusEditDist() { CWnd *pWnd = GetFocus(); CWnd *pWnd2 = GetDlgItem(IDC_RADIO_MODE1); if (pWnd2 == pWnd)//如果修改完长度,又改为“自由”,容易引起死锁 return; double nTmp = m_nDist; UpdateData(TRUE); if (fabs(nTmp - m_nDist) < 0.01) return; GlobalFunc::PostCommand(_T("R "), false); } void CWellDlg::OnSelchangeComboPipe() { int iOld = m_iPipeSys; UpdateData(TRUE); if (iOld == m_iPipeSys) // cet 2010.9.7 add { return; } if (m_iPipeSys == 0) { // 给水 m_csDn = _T("200"); m_nGradient = 0; m_iMaterial = 1;//给水铸铁管 UpdateData(FALSE); } else /*if(iOld == 0)*/ { // cet 2010.9.7 modify 删除判断条件 m_csDn = _T("300"); m_nGradient = 0.003; m_iMaterial = 12; UpdateData(FALSE); } // cet 2010.9.7 add m_nElevation = 0.0; UpdateData(FALSE); CString sCmd = _T("R "); if (m_iMode == 4) { sCmd = _T(" "); } GlobalFunc::PostCommand(sCmd, false); acedGetAcadDwgView()->SetFocus(); m_bChangeSys = true; } void CWellDlg::OnPreviewWell() { CString csSldName; CString csTK, csRecord; GlobalFunc::SplitBlkStr(m_csBlkName, csTK, csRecord); csSldName.Format(_T("TWTSYS(%s)"), csRecord); CTemporaryResourceOverride vTemp; CSelectBlkDlg dlg; dlg.m_csTkName = _T("TWTSYS"); dlg.m_csType = _T("室外\\井"); CWnd *pWnd = GetDlgItem(IDC_PREVIEW_WELL); CRect rect; dlg.m_staticSlide.m_csCurRecord = csSldName; pWnd->GetWindowRect(&rect); dlg.m_ptBase = rect.TopLeft(); if (dlg.DoModal() == IDOK) { CString csRet = dlg.m_staticSlide.m_csCurRecord; XString xsTKName, xsRocord, xsTmp; GlobalFunc::SplitSlbName(csRet, xsTKName, xsRocord); AcDbDatabase *dwg = acdbCurDwg(); AcAxDocLock docLock(dwg); VERIFY(docLock.lockStatus() == Acad::eOk); if (GlobalFunc::LoadDwbBlock((const TCHAR*)xsTKName, (const TCHAR*)xsRocord, xsTmp) != RTNORM) return; m_csBlkName = (const TCHAR*)xsTmp; OpenSlide(); } } const TCHAR* CWellDlg::GetHead() { UpdateData(TRUE); if (m_iPipeSys == 0) return g_Option::instance().g_csPipeDim[0]; else if (m_iPipeSys == 1) return g_Option::instance().g_csPipeDim[3]; else if (m_iPipeSys == 2) return g_Option::instance().g_csPipeDim[4]; else if (m_iPipeSys == 3) return g_Option::instance().g_csPipeDim[5]; else if (m_iPipeSys == 4) return g_Option::instance().g_csPipeDim[6]; else if (m_iPipeSys == 5) return g_Option::instance().g_csPipeDim[7]; else if (m_iPipeSys == 6) return g_Option::instance().g_csPipeDim[9]; return _T(""); } const TCHAR* CWellDlg::GetPipeLayer() { UpdateData(TRUE); if (m_iPipeSys == 0) return LAY_PIPE_FEED; else if (m_iPipeSys == 1) return LAY_PIPE_DIRT; else if (m_iPipeSys == 2) return LAY_PIPE_USELESS; else if (m_iPipeSys == 3) return LAY_PIPE_RAIN; else if (m_iPipeSys == 4) return LAY_PIPE_USED; else if (m_iPipeSys == 5) return LAY_PIPE_FIRE; else if (m_iPipeSys == 6) return LAY_PIPE_OTHER; return _T(""); } const TCHAR* CWellDlg::GetWellLayer() { UpdateData(TRUE); if (m_iPipeSys == 0) { InitLayer(LAY_WELL_FEED); return LAY_WELL_FEED; } else if (m_iPipeSys == 1) { InitLayer(LAY_WELL_DIRT); return LAY_WELL_DIRT; } else if (m_iPipeSys == 2) { InitLayer(LAY_WELL_USELESS); return LAY_WELL_USELESS; } else if (m_iPipeSys == 3) { InitLayer(LAY_WELL_RAIN); return LAY_WELL_RAIN; } else if (m_iPipeSys == 4) { InitLayer(LAY_WELL_USED); return LAY_WELL_USED; } else if (m_iPipeSys == 5) { InitLayer(LAY_WELL_FIRE); return LAY_WELL_FIRE; } else if (m_iPipeSys == 6) { InitLayer(LAY_WELL_OTHER); return LAY_WELL_OTHER; } return _T(""); } // 交点布置井 zxl 2013.04.15 add void CWellDlg::OnRadioMode5() { UpdateData(TRUE); CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST); ASSERT(pWnd); pWnd->EnableWindow(FALSE); CWnd *pWnd2 = GetDlgItem(IDC_CHECK_PIPE); ASSERT(pWnd2); pWnd2->EnableWindow(FALSE); GlobalFunc::PostCommand(_T("R "), false); acedGetAcadDwgView()->SetFocus(); } void CWellDlg::OnRadioOut() { DrawTypeChanged(); } void CWellDlg::OnRadioReal() { DrawTypeChanged(); } void CWellDlg::DrawTypeChanged() { int nOldType = m_iDrawType; UpdateData(TRUE); if (m_iDrawType == 0 && nOldType != m_iDrawType) { m_dRealScale = m_nScale; m_wndOut.SetWindowText(_T("出图尺寸mm")); m_wndReal.ShowWindow(SW_SHOW); m_edtRadius.ShowWindow(SW_SHOW); m_nScale = m_dOutScale; m_dWellRadius = 700; } else if (m_iDrawType == 1 && nOldType != m_iDrawType) { m_dOutScale = m_nScale; m_wndOut.SetWindowText(_T("实际尺寸mm")); m_wndReal.ShowWindow(SW_HIDE); m_edtRadius.ShowWindow(SW_HIDE); m_nScale = m_dRealScale; m_dWellRadius = m_dRealScale; } UpdateData(FALSE); GlobalFunc::PostCommand(_T("R "), false); acedGetAcadDwgView()->SetFocus(); }