4184 lines
113 KiB
C++
4184 lines
113 KiB
C++
#include "stdafx.h"
|
||
#include "AcDbObjectPtr.h"
|
||
#include "globalFunc.h"
|
||
#include "DbWell.h"
|
||
#include "DbVerticalSection.h"
|
||
#include "DbWellDim.h"
|
||
#include "EdJigEx.h"
|
||
#include "dbgridsheet.h"
|
||
#include "dbmtext.h"
|
||
#include "WellDimEditDlg.h"
|
||
#include "WellCoordSheetSettingDlg.h"
|
||
#include <list>
|
||
#include "PipeDownDimEditDlg.h"
|
||
#include "WellSerialDlg.h"
|
||
#include "WellSerial.h"
|
||
#include "DbPool.h"
|
||
#include "AecDbSymbCoord.h"
|
||
#include "AecDbSymbElevation.h"
|
||
#include "AecDbSymbMultiLeader.h"
|
||
#include "PickEntSet.h"
|
||
#include "layerdef.h"
|
||
#include "RBGroups.h"
|
||
#include "AecDbSymbArrow.h"
|
||
#include <set>
|
||
#include "EntitySet.h"
|
||
|
||
extern BOOL SearchOutdoorWell(Entity ent, Entity entEnd, SSearchPipeList *pListAll, PickSet &ssAll, BOOL bModifyDir);
|
||
extern BOOL GetWellListData(SSearchPipeList *pListAll, DList<TWellData> &lstWellSys);
|
||
extern AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL);
|
||
extern AcDbObjectId InitLayer(const TCHAR *szLayer, BOOL bApplyChange = TRUE);
|
||
extern int EvadeUpdating(Entity &ent);
|
||
|
||
//***************************************************************************************************
|
||
// 井坐标
|
||
//***************************************************************************************************
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// 坐标标注
|
||
class TCoordEdJig : public TSymbEdJig {
|
||
protected:
|
||
// I/O
|
||
AecXDbSymbCoord *m_pDrawEnt;
|
||
public:
|
||
TCoordEdJig(AecXDbSymbCoord *);
|
||
virtual int DoIt();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
};
|
||
|
||
|
||
TCoordEdJig::TCoordEdJig(AecXDbSymbCoord *pElev)
|
||
{
|
||
m_pDrawEnt = pElev;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TCoordEdJig::DoIt()
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
return TSymbEdJig::DoIt();
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TCoordEdJig::update()
|
||
{
|
||
//if(m_ptResult.Distance2d(m_pDrawEnt->GetTurnPoint())<_distSnap*10)
|
||
// return Adesk::kFalse;
|
||
BOOL bShift = GlobalFunc::IsKeyPressed(VK_SHIFT);
|
||
XVector3D vt = m_ptResult - m_pDrawEnt->GetLocation();
|
||
double nAngle = ads_angle(XPoint(), vt);
|
||
|
||
nAngle = CT_std_angle(nAngle - GlobalFunc::Ucs2Wcs(0.0));//add by whl
|
||
|
||
Adesk::UInt8 nQuadrant;
|
||
if (nAngle >= 0.0 && nAngle < PI / 2) {
|
||
nQuadrant = 0;
|
||
if (bShift)
|
||
nAngle = PI / 4;
|
||
}
|
||
else if (nAngle >= PI / 2 && nAngle < PI) {
|
||
nQuadrant = 1;
|
||
if (bShift)
|
||
nAngle = PI / 2 + PI / 4;
|
||
}
|
||
else if (nAngle >= PI && nAngle < PI * 1.5) {
|
||
nQuadrant = 2;
|
||
if (bShift)
|
||
nAngle = PI + PI / 4;
|
||
}
|
||
else {
|
||
nQuadrant = 3;
|
||
if (bShift)
|
||
nAngle = 2 * PI - PI / 4;
|
||
}
|
||
XLine ln(m_pDrawEnt->GetLocation(), nAngle);
|
||
if (bShift) {
|
||
XPoint(m_ptResult).Project(&ln, m_ptResult);
|
||
}
|
||
m_pDrawEnt->SetQuadrant(nQuadrant);
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TCoordEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
// Command: 坐标标注
|
||
void DimSingleWellCoord()
|
||
{
|
||
int iUnitType = GlobalFunc::DocGetMeterUnitDraw();
|
||
|
||
XPoint ptLoc, ptLastUcs;
|
||
while (true)
|
||
{
|
||
if (RTNORM != ads_getpoint(ptLastUcs, _T("\n请点取标注点<退出>:"), ptLoc))
|
||
return;
|
||
|
||
ptLastUcs = ptLoc;
|
||
ptLoc = GlobalFunc::Ucs2Wcs(ptLoc);
|
||
XPoint ptVal = ptLoc;
|
||
if (ptLastUcs != ptLoc)
|
||
{
|
||
TCHAR szTmp[32];
|
||
ads_getstring(0, _T("\n是否标注UCS坐标<Y>:"), szTmp);
|
||
if (_tcsicmp(szTmp, _T("N")) != 0)
|
||
ptVal = ptLastUcs;
|
||
}
|
||
|
||
XPoint ptLocWcs = ptLoc;
|
||
|
||
double x, y;
|
||
if (iUnitType == 0)//mm-M
|
||
{
|
||
x = _AS_METER(ptVal.y);
|
||
y = _AS_METER(ptVal.x);
|
||
}
|
||
else//M-M
|
||
{
|
||
x = ptVal.y;
|
||
y = ptVal.x;
|
||
}
|
||
if (fabs(x) < 1E-6)
|
||
x = 0;
|
||
if (fabs(y) < 1E-6)
|
||
y = 0;
|
||
AecXDbSymbCoord *pElev = new AecXDbSymbCoord;
|
||
pElev->SetLocation(ptLocWcs);
|
||
pElev->SetValue(XPoint(y, x));
|
||
pElev->SetTextStyleId(InitTextStyle(TS_DIM));
|
||
pElev->setLayer(pElev->GetDefaultLayer());
|
||
pElev->SetAB(g_Option::instance().g_bABCoord);
|
||
pElev->SetStyle((AecXDbSymbMultiLeader::TArrowStyle)g_Option::instance().g_nCoordArrowStyle);
|
||
pElev->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));//modified by whl
|
||
pElev->SetTextLayerId(InitLayer(LAY_TEXT, TRUE));
|
||
pElev->SetPrecNum(g_Option::instance().g_nCoordPrec);
|
||
TCoordEdJig jig(pElev);
|
||
jig.SetPrompt(_T("\n点取坐标标注方向<退出>:"));
|
||
int nRet = jig.DoIt();
|
||
if (nRet == RTNORM)
|
||
//pElev->AddToCSpace(Adesk::kTrue);
|
||
GlobalFunc::AddToCurrentSpace(pElev, Adesk::kTrue);
|
||
else
|
||
delete pElev;
|
||
}
|
||
}
|
||
|
||
//修改井编号
|
||
void ChangeWellNameSerial(Entity ent, const TCHAR* szNewName)
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
pEquip->SetWellName(szNewName);
|
||
if (!pEquip->IsDrawLabel())
|
||
pEquip->EnableDrawLabel(TRUE, 1.5);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void DimWellCoord()
|
||
{
|
||
RBList rbMaskDim(RTDXF0, _T("ATS_COORD"), NULL);
|
||
Entity entDim;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择已经标好的井坐标(参考):<逐个标注>"), entDim, rbMaskDim) != RTNORM) {
|
||
DimSingleWellCoord();
|
||
return;
|
||
}
|
||
XPoint ptLoc, ptTurn;
|
||
BOOL bIsAB = FALSE;
|
||
int iPrecNum(3);
|
||
int iQuadrant(0);
|
||
BOOL bIsUcs = TRUE;
|
||
AecXDbSymbMultiLeader::TArrowStyle arrowStyle;
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForWrite, AecXDbSymbCoord, pDim);
|
||
if (pDim) {
|
||
ptLoc = pDim->GetLocation();
|
||
ptLoc.z = 0;
|
||
ptTurn = pDim->GetTurnPoint();
|
||
bIsAB = pDim->IsAB();
|
||
arrowStyle = pDim->GetStyle();
|
||
iPrecNum = pDim->GetPrecNum();
|
||
iQuadrant = pDim->GetQuadrant();
|
||
pDim->setColor(AcCmColor());
|
||
XPoint ptVal2 = pDim->GetValue();
|
||
if (ptLoc == ptVal2)
|
||
bIsUcs = FALSE;
|
||
else {
|
||
ptVal2.x *= 1000;
|
||
ptVal2.y *= 1000;
|
||
if (ptLoc == ptVal2)
|
||
bIsUcs = FALSE;
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(AcGeVector3d(ptTurn[0] - ptLoc[0], ptTurn[1] - ptLoc[1], ptTurn[2] - ptLoc[2]));
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
if (GlobalFunc::SelectEntities(_T("\n请选择要标注的井:<退出>"), ss, rbMask) != RTNORM)
|
||
return;
|
||
// CString csLay = LAY_PIPE_RAIN;
|
||
TPipeSys::SysType sys;
|
||
|
||
|
||
int iUnitType = GlobalFunc::DocGetMeterUnitDraw();
|
||
|
||
for (long i = 0; i < ss.Length(); i++) {
|
||
Entity ent = ss[i];
|
||
double nEle(0), nEle2(0);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
ptLoc = pEquip->GetLocation();
|
||
int num = pEquip->GetInterfaceNum();
|
||
if (num > 0) {
|
||
CPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
sys = pPipe->GetSysType();
|
||
// int idx = GetPipeLayerIdxBySys(pPipe->GetSysType());
|
||
// csLay = pPipe->GetLayer();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
ptTurn = ptLoc;
|
||
XPoint ptVal = ptLoc;
|
||
if (bIsUcs)
|
||
ptVal = GlobalFunc::Wcs2Ucs(ptVal);
|
||
ptTurn.TransformBy(mat);
|
||
|
||
double x, y;
|
||
if (iUnitType == 0)//mm-M
|
||
{
|
||
x = _AS_METER(ptVal.y);
|
||
y = _AS_METER(ptVal.x);
|
||
}
|
||
else//M-M
|
||
{
|
||
x = ptVal.y;
|
||
y = ptVal.x;
|
||
}
|
||
if (fabs(x) < 1E-6)
|
||
x = 0;
|
||
if (fabs(y) < 1E-6)
|
||
y = 0;
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
AecXDbSymbCoord *pElev = new AecXDbSymbCoord;
|
||
pElev->setLayer(csLay);
|
||
pElev->SetLocation(ptLoc);
|
||
pElev->SetValue(XPoint(y, x));
|
||
pElev->SetTextStyleId(InitTextStyle(TS_DIM));
|
||
pElev->setLayer(pElev->GetDefaultLayer());
|
||
pElev->SetAB(bIsAB);
|
||
pElev->SetQuadrant(iQuadrant);
|
||
pElev->SetStyle(arrowStyle);
|
||
pElev->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
pElev->SetTextLayerId(InitLayer(LAY_TEXT, TRUE));
|
||
pElev->SetPrecNum(iPrecNum);
|
||
pElev->SetTurnPoint(ptTurn);
|
||
|
||
|
||
//pElev->AddToCSpace(Adesk::kTrue);
|
||
GlobalFunc::AddToCurrentSpace(pElev, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt) {
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 井坐标表
|
||
//***************************************************************************************************
|
||
|
||
void DoWellCoordSheet(DList<TWellData> &lstWellSys)
|
||
{
|
||
double nTextSize = g_Option::instance().g_nSheetHeight; //字高
|
||
double nTableHeight = g_Option::instance().g_nSheetHeight + 2;
|
||
|
||
XPoint pt;
|
||
if (XGetPoint(NULL, _T("点取表格左上角位置\n"), pt) != RTNORM)
|
||
return;
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csSheetStyle);
|
||
CDbSheet *pSheet = new CDbSheet;
|
||
|
||
GridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(nTextSize);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
|
||
SheetTitle &title = pSheet->GetTitle();
|
||
title.SetHeight(7.0);
|
||
title.SetText(_T("井表"));
|
||
GridStyle &gridStyle2 = title.GetGridStyle();
|
||
gridStyle2.SetTextHeight(nTextSize);
|
||
gridStyle2.SetTextStyleId(idTextStyle);
|
||
|
||
DividerStyle &style = title.GetDividerStyle();
|
||
style.SetDividerFlag(DividerStyle::kNone);
|
||
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetLineSpaceFactor(0.2);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
pSheet->SetGridStyle(gridStyle);
|
||
pSheet->SetRowHeight(nTableHeight);
|
||
pSheet->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
int iAllRow(0);
|
||
for (int i = 0; i < lstWellSys.Length(); i++) {
|
||
if (lstWellSys[i]->m_bIsWell) { //井
|
||
iAllRow++;
|
||
}
|
||
}
|
||
pSheet->InitSheet(iAllRow + 2, 7, nTableHeight, 50);
|
||
SheetColumn column;
|
||
column.SetWidth(8); //序号
|
||
pSheet->SetColumnAt(0, column);
|
||
column.SetWidth(12); //名称
|
||
pSheet->SetColumnAt(1, column);
|
||
column.SetWidth(20); //Y
|
||
pSheet->SetColumnAt(2, column);
|
||
column.SetWidth(20); //X
|
||
pSheet->SetColumnAt(3, column);
|
||
column.SetWidth(20); //井面标高
|
||
pSheet->SetColumnAt(4, column);
|
||
column.SetWidth(20); //井底标高
|
||
pSheet->SetColumnAt(5, column);
|
||
column.SetWidth(15); //规格
|
||
pSheet->SetColumnAt(6, column);
|
||
|
||
GridCell &cell = *(*pSheet)(0, 0);
|
||
cell.SetText(_T("序号"));
|
||
GridCell &cell2 = *(*pSheet)(0, 1);
|
||
cell2.SetText(_T("井编号"));
|
||
GridCell &cell3 = *(*pSheet)(0, 2);
|
||
cell3.SetText(_T("井坐标(m)"));
|
||
GridCell &cell4 = *(*pSheet)(0, 3);
|
||
cell4.SetText(_T("井坐标(m)"));
|
||
GridCell &cell5 = *(*pSheet)(0, 4);
|
||
cell5.SetText(_T("井面标高(m)"));
|
||
GridCell &cell6 = *(*pSheet)(0, 5);
|
||
cell6.SetText(_T("井底标高(m)"));
|
||
GridCell &cell7 = *(*pSheet)(0, 6);
|
||
cell7.SetText(_T("规格"));
|
||
pSheet->SetLocation(GlobalFunc::Ucs2Wcs(pt));
|
||
|
||
pSheet->MergeCells(0, 0, 1, 0);
|
||
pSheet->MergeCells(0, 1, 1, 1);
|
||
pSheet->MergeCells(0, 2, 0, 3);
|
||
pSheet->MergeCells(0, 4, 1, 4);
|
||
pSheet->MergeCells(0, 5, 1, 5);
|
||
pSheet->MergeCells(0, 6, 1, 6);
|
||
|
||
GridCell &cell8 = *(*pSheet)(1, 2);
|
||
GridCell &cell9 = *(*pSheet)(1, 3);
|
||
if (g_Option::instance().g_bABCoord)
|
||
{
|
||
cell8.SetText(_T("B"));
|
||
cell9.SetText(_T("A"));
|
||
}
|
||
else
|
||
{
|
||
cell8.SetText(_T("Y"));
|
||
cell9.SetText(_T("X"));
|
||
}
|
||
|
||
int iUnitType = GlobalFunc::DocGetMeterUnitDraw();
|
||
int index = 1;
|
||
for (i = 0; i < lstWellSys.Length(); i++) {
|
||
if (lstWellSys[i]->m_bIsWell) { //井
|
||
|
||
XPoint ptLoc;
|
||
AcDbObjectId id = lstWellSys[i]->m_ID;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
ptLoc = pEquip->GetLocation();
|
||
}
|
||
OPENOBJ_END();
|
||
ptLoc = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
double x, y;
|
||
if (iUnitType == 0)//mm-M
|
||
{
|
||
x = _AS_METER(ptLoc.y);
|
||
y = _AS_METER(ptLoc.x);
|
||
}
|
||
else//M-M
|
||
{
|
||
x = ptLoc.y;
|
||
y = ptLoc.x;
|
||
}
|
||
if (fabs(x) < 1E-6)
|
||
x = 0;
|
||
if (fabs(y) < 1E-6)
|
||
y = 0;
|
||
|
||
|
||
index++;
|
||
GridCell &Cell11 = *(*pSheet)(index, 0);
|
||
XString xsIndex(_T("%d"), index - 1);
|
||
Cell11.SetText(xsIndex);
|
||
|
||
GridCell &Cell12 = *(*pSheet)(index, 1);
|
||
Cell12.SetText(lstWellSys[i]->m_csName);
|
||
|
||
CString csDownEle;
|
||
csDownEle.Format(_T("%.3f"), lstWellSys[i]->m_nDownEle);
|
||
GridCell &Cell13 = *(*pSheet)(index, 5);
|
||
Cell13.SetText(csDownEle);
|
||
|
||
CString csUpEle;
|
||
csUpEle.Format(_T("%.3f"), lstWellSys[i]->m_nUpEle);
|
||
GridCell &Cell14 = *(*pSheet)(index, 4);
|
||
Cell14.SetText(csUpEle);
|
||
|
||
CString csWellRadius;
|
||
if (lstWellSys[i]->m_nWellRadius > 0)
|
||
csWellRadius.Format(_T("φ%.0f"), lstWellSys[i]->m_nWellRadius * 2);
|
||
else
|
||
csWellRadius = _T("矩形井");
|
||
GridCell &Cell15 = *(*pSheet)(index, 6);
|
||
Cell15.SetText(csWellRadius);
|
||
|
||
XString sCoordB(XString(_T("%%.%dlf"), g_Option::instance().g_nCoordPrec), y);
|
||
GridCell &Cell16 = *(*pSheet)(index, 2);
|
||
Cell16.SetText(sCoordB);
|
||
|
||
XString sCoordA(XString(_T("%%.%dlf"), g_Option::instance().g_nCoordPrec), x);
|
||
GridCell &Cell17 = *(*pSheet)(index, 3);
|
||
Cell17.SetText(sCoordA);
|
||
}
|
||
}
|
||
|
||
//pSheet->AddToCSpace(TRUE);
|
||
GlobalFunc::AddToCurrentSpace(pSheet, Adesk::kTrue);
|
||
}
|
||
|
||
//cet 2010.2.5 add
|
||
//根据表行数生成若干表存贮数据
|
||
void DoWellCoordSheet(DList<TWellData> &lstWellSys, int nRowNum, int nWellType, XPoint pt, double &dSheetHigh)
|
||
{
|
||
double nTextSize = g_Option::instance().g_nSheetHeight; //字高
|
||
double nTableHeight = g_Option::instance().g_nSheetHeight + 2;
|
||
|
||
//计算表个数
|
||
int nSheetNum = lstWellSys.Length() / nRowNum;
|
||
if (lstWellSys.Length() % nRowNum > 0)
|
||
{
|
||
++nSheetNum;
|
||
}
|
||
|
||
AcGePoint3d ptLoc = GlobalFunc::Ucs2Wcs(pt);
|
||
XPoint ptUcsLoc = pt;
|
||
double dSheetWidth = 0.0;
|
||
int i = 0;
|
||
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csSheetStyle);
|
||
int nSerNum = 0; //表序号
|
||
for (int j = 0; j < nSheetNum; j++)
|
||
{
|
||
CDbSheet *pSheet = new CDbSheet;
|
||
GridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(nTextSize);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
|
||
SheetTitle &title = pSheet->GetTitle();
|
||
title.SetHeight(7.0);
|
||
title.SetText(_T("")); //不加标题时应设置为空;否则表格编辑时,无法设置标题选项
|
||
GridStyle &gridStyle2 = title.GetGridStyle();
|
||
gridStyle2.SetTextHeight(nTextSize);
|
||
gridStyle2.SetTextStyleId(idTextStyle);
|
||
|
||
DividerStyle &style = title.GetDividerStyle();
|
||
style.SetDividerFlag(DividerStyle::kNone);
|
||
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetLineSpaceFactor(0.2);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
pSheet->SetGridStyle(gridStyle);
|
||
pSheet->SetRowHeight(nTableHeight);
|
||
pSheet->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
|
||
if (nSheetNum == 1)
|
||
{
|
||
pSheet->InitSheet(lstWellSys.Length() + 2, 7, nTableHeight, 50);
|
||
}
|
||
else
|
||
{
|
||
pSheet->InitSheet(nRowNum + 2, 7, nTableHeight, 50);
|
||
}
|
||
SheetColumn column;
|
||
column.SetWidth(8); //序号
|
||
pSheet->SetColumnAt(0, column);
|
||
column.SetWidth(12); //名称
|
||
pSheet->SetColumnAt(1, column);
|
||
column.SetWidth(20); //Y
|
||
pSheet->SetColumnAt(2, column);
|
||
column.SetWidth(20); //X
|
||
pSheet->SetColumnAt(3, column);
|
||
column.SetWidth(20); //井面标高
|
||
pSheet->SetColumnAt(4, column);
|
||
column.SetWidth(20); //井底标高
|
||
pSheet->SetColumnAt(5, column);
|
||
column.SetWidth(15); //规格
|
||
pSheet->SetColumnAt(6, column);
|
||
|
||
GridCell &cell = *(*pSheet)(0, 0);
|
||
cell.SetText(_T("序号"));
|
||
GridCell &cell2 = *(*pSheet)(0, 1);
|
||
cell2.SetText(_T("井编号"));
|
||
GridCell &cell3 = *(*pSheet)(0, 2);
|
||
cell3.SetText(_T("井坐标(m)"));
|
||
GridCell &cell4 = *(*pSheet)(0, 3);
|
||
cell4.SetText(_T("井坐标(m)"));
|
||
GridCell &cell5 = *(*pSheet)(0, 4);
|
||
cell5.SetText(_T("井面标高(m)"));
|
||
GridCell &cell6 = *(*pSheet)(0, 5);
|
||
cell6.SetText(_T("井底标高(m)"));
|
||
GridCell &cell7 = *(*pSheet)(0, 6);
|
||
cell7.SetText(_T("规格"));
|
||
|
||
//设置表位置
|
||
ads_polar(ptUcsLoc, 0, dSheetWidth, ptUcsLoc);//在UCS坐标下计算下一个表格的位置
|
||
pSheet->SetLocation(GlobalFunc::Ucs2Wcs(ptUcsLoc));
|
||
|
||
pSheet->MergeCells(0, 0, 1, 0);
|
||
pSheet->MergeCells(0, 1, 1, 1);
|
||
pSheet->MergeCells(0, 2, 0, 3);
|
||
pSheet->MergeCells(0, 4, 1, 4);
|
||
pSheet->MergeCells(0, 5, 1, 5);
|
||
pSheet->MergeCells(0, 6, 1, 6);
|
||
|
||
GridCell &cell8 = *(*pSheet)(1, 2);
|
||
GridCell &cell9 = *(*pSheet)(1, 3);
|
||
if (g_Option::instance().g_bABCoord)
|
||
{
|
||
cell8.SetText(_T("B"));
|
||
cell9.SetText(_T("A"));
|
||
}
|
||
else
|
||
{
|
||
cell8.SetText(_T("Y"));
|
||
cell9.SetText(_T("X"));
|
||
}
|
||
|
||
int iUnitType = GlobalFunc::DocGetMeterUnitDraw();
|
||
int index = 1;
|
||
for (; i < lstWellSys.Length() && i < nRowNum * (j + 1); i++)
|
||
{
|
||
if (lstWellSys[i]->m_bIsWell) //井
|
||
{
|
||
XPoint ptLoc;
|
||
AcDbObjectId id = lstWellSys[i]->m_ID;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip)
|
||
{
|
||
ptLoc = pEquip->GetLocation();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
ptLoc = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
double x, y;
|
||
if (iUnitType == 0)//mm-M
|
||
{
|
||
x = _AS_METER(ptLoc.y);
|
||
y = _AS_METER(ptLoc.x);
|
||
}
|
||
else//M-M
|
||
{
|
||
x = ptLoc.y;
|
||
y = ptLoc.x;
|
||
}
|
||
if (fabs(x) < 1E-6)
|
||
x = 0;
|
||
if (fabs(y) < 1E-6)
|
||
y = 0;
|
||
|
||
index++;
|
||
GridCell &Cell11 = *(*pSheet)(index, 0);
|
||
++nSerNum;
|
||
XString xsIndex(_T("%d"), nSerNum);
|
||
Cell11.SetText(xsIndex);
|
||
|
||
GridCell &Cell12 = *(*pSheet)(index, 1);
|
||
Cell12.SetText(lstWellSys[i]->m_csName);
|
||
|
||
CString csDownEle;
|
||
csDownEle.Format(_T("%.3f"), lstWellSys[i]->m_nDownEle);
|
||
GridCell &Cell13 = *(*pSheet)(index, 5);
|
||
Cell13.SetText(csDownEle);
|
||
|
||
CString csUpEle;
|
||
csUpEle.Format(_T("%.3f"), lstWellSys[i]->m_nUpEle);
|
||
GridCell &Cell14 = *(*pSheet)(index, 4);
|
||
Cell14.SetText(csUpEle);
|
||
|
||
CString csWellRadius;
|
||
if (lstWellSys[i]->m_nWellRadius > 0)
|
||
csWellRadius.Format(_T("φ%.0f"), lstWellSys[i]->m_nWellRadius * 2);
|
||
else
|
||
csWellRadius = _T("矩形井");
|
||
GridCell &Cell15 = *(*pSheet)(index, 6);
|
||
Cell15.SetText(csWellRadius);
|
||
|
||
XString sCoordB(XString(_T("%%.%dlf"), g_Option::instance().g_nCoordPrec), y);
|
||
GridCell &Cell16 = *(*pSheet)(index, 2);
|
||
Cell16.SetText(sCoordB);
|
||
|
||
XString sCoordA(XString(_T("%%.%dlf"), g_Option::instance().g_nCoordPrec), x);
|
||
GridCell &Cell17 = *(*pSheet)(index, 3);
|
||
Cell17.SetText(sCoordA);
|
||
}
|
||
}
|
||
|
||
dSheetWidth = pSheet->GetSheetWidth(FALSE);
|
||
dSheetHigh = pSheet->GetSheetHeight(FALSE, FALSE);
|
||
//pSheet->AddToCSpace(TRUE);
|
||
GlobalFunc::AddToCurrentSpace(pSheet, Adesk::kTrue);
|
||
}
|
||
|
||
//添加表头
|
||
CString strSheetTitle;
|
||
if (nWellType == 0)
|
||
{
|
||
strSheetTitle = _T("雨水检查井坐标表");
|
||
}
|
||
else if (nWellType == 1)
|
||
{
|
||
strSheetTitle = _T("污水检查井坐标表");
|
||
}
|
||
else if (nWellType == 2)
|
||
{
|
||
strSheetTitle = _T("给水检查井坐标表");
|
||
}
|
||
else if (nWellType == 3)
|
||
{
|
||
strSheetTitle = _T("废水检查井坐标表");
|
||
}
|
||
else if (nWellType == 4)
|
||
{
|
||
strSheetTitle = _T("中水检查井坐标表");
|
||
}
|
||
else if (nWellType == 5)
|
||
{
|
||
strSheetTitle = _T("消防检查井坐标表");
|
||
}
|
||
else if (nWellType == 6)
|
||
{
|
||
strSheetTitle = _T("其它检查井坐标表");
|
||
}
|
||
|
||
AecXDbText *pText = new AecXDbText;
|
||
pText->SetStyleId(idTextStyle);
|
||
pText->SetHeight(nTextSize * 2);
|
||
pText->SetAlignment(AcGiDraw::kBottomCenter);
|
||
pText->SetRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
pText->SetText(strSheetTitle);
|
||
|
||
XPoint ptTemp = pt;
|
||
ads_polar(ptTemp, 0, dSheetWidth * nSheetNum / 2, ptTemp);//在UCS坐标下计算下一个表格的位置
|
||
pText->SetLocation(GlobalFunc::Ucs2Wcs(ptTemp));
|
||
GlobalFunc::AddToCurrentSpace(pText, Adesk::kTrue);
|
||
}
|
||
|
||
void DoWellCoordSheetByWellType(DList<TWellData> &lstWellSys, int nRowNum, int nWellType, XPoint pt)
|
||
{
|
||
DList<TWellData> lstRain, lstFeedWater, lstSewage, lstWasteWater, lstMid, lstHydrant, lstOther;
|
||
AecXDbWell *pWell = NULL;
|
||
AcDbObjectId id;
|
||
TCHAR *pszLayerName = NULL;
|
||
for (int i = 0; i < lstWellSys.Length(); i++)
|
||
{
|
||
pWell = NULL;
|
||
id = lstWellSys[i]->m_ID;
|
||
acdbOpenObject(pWell, id, AcDb::kForRead);
|
||
if (pWell != NULL)
|
||
{
|
||
TWellData *pList = new TWellData();
|
||
pList->m_ID = lstWellSys[i]->m_ID;
|
||
pList->m_bIsWell = lstWellSys[i]->m_bIsWell;
|
||
pList->m_csName = lstWellSys[i]->m_csName;
|
||
pList->m_nUpEle = lstWellSys[i]->m_nUpEle;
|
||
pList->m_nDownEle = lstWellSys[i]->m_nDownEle;
|
||
pList->m_nWellRadius = lstWellSys[i]->m_nWellRadius;
|
||
|
||
pszLayerName = pWell->layer();
|
||
if (_tcsicmp(pszLayerName, /*_T("WELL_雨水")*/LAY_WELL_RAIN) == 0)
|
||
{
|
||
lstRain.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_给水")*/LAY_WELL_FEED) == 0)
|
||
{
|
||
lstFeedWater.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_污水")*/LAY_WELL_DIRT) == 0)
|
||
{
|
||
lstSewage.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_废水")*/LAY_WELL_USED) == 0)
|
||
{
|
||
lstWasteWater.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_中水")*/LAY_WELL_USELESS) == 0)
|
||
{
|
||
lstMid.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_消防")*/LAY_WELL_FIRE) == 0)
|
||
{
|
||
lstHydrant.Append(pList);
|
||
}
|
||
else if (_tcsicmp(pszLayerName, /*_T("WELL_其它")*/LAY_WELL_OTHER) == 0)
|
||
{
|
||
lstOther.Append(pList);
|
||
}
|
||
pWell->close();
|
||
}
|
||
}
|
||
|
||
double dSheetDist = 2000; //表间垂直距离
|
||
if (GlobalFunc::DocGetMeterUnitDraw())
|
||
{
|
||
dSheetDist = 20;
|
||
}
|
||
double dSheetHigh = 0.0;
|
||
if (lstRain.Length() != 0)
|
||
{
|
||
nWellType = 0;
|
||
DoWellCoordSheet(lstRain, nRowNum, nWellType, pt, dSheetHigh); //雨水
|
||
}
|
||
|
||
if (lstSewage.Length() != 0)
|
||
{
|
||
nWellType = 1;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstSewage, nRowNum, nWellType, pt, dSheetHigh); //污水
|
||
}
|
||
|
||
if (lstFeedWater.Length() != 0)
|
||
{
|
||
nWellType = 2;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstFeedWater, nRowNum, nWellType, pt, dSheetHigh); //给水
|
||
}
|
||
|
||
|
||
if (lstWasteWater.Length() != 0)
|
||
{
|
||
nWellType = 3;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstWasteWater, nRowNum, nWellType, pt, dSheetHigh); //废水
|
||
}
|
||
|
||
if (lstMid.Length() != 0)
|
||
{
|
||
nWellType = 4;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstMid, nRowNum, nWellType, pt, dSheetHigh); //中水
|
||
}
|
||
|
||
|
||
if (lstHydrant.Length() != 0)
|
||
{
|
||
nWellType = 5;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstHydrant, nRowNum, nWellType, pt, dSheetHigh); //消防
|
||
}
|
||
|
||
if (lstOther.Length() != 0)
|
||
{
|
||
nWellType = 6;
|
||
ads_polar(pt, -PI / 2, dSheetHigh + dSheetDist, pt);
|
||
dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstOther, nRowNum, nWellType, pt, dSheetHigh); //其它
|
||
}
|
||
}
|
||
|
||
// cet 2010.2.9 add 输出井坐标表
|
||
void OutputWellCoordSheet(DList<TWellData> &lstWellSys, int nRowNum, int nWellType)
|
||
{
|
||
if (lstWellSys.Length() == 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
XPoint pt;
|
||
if (acedGetPoint(NULL, _T("点取表格左上角位置\n"), pt) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (nWellType == 7) //全部井类型
|
||
{
|
||
DoWellCoordSheetByWellType(lstWellSys, nRowNum, nWellType, pt);
|
||
}
|
||
else //单一井类型
|
||
{
|
||
double dSheetHigh = 0.0;
|
||
DoWellCoordSheet(lstWellSys, nRowNum, nWellType, pt, dSheetHigh);
|
||
}
|
||
}
|
||
|
||
int SortByWellName(const TWellData *p1, const TWellData *p2)
|
||
{
|
||
TWellData *pp1 = (TWellData *)p1,
|
||
*pp2 = (TWellData *)p2;
|
||
|
||
CString csSpec1 = pp1->m_csName;
|
||
CString csSpec2 = pp2->m_csName;
|
||
int iBraNum1(0), iBraNum2(0);
|
||
int num1, num2, numWith;
|
||
XString xsText1, xsText2;
|
||
|
||
// cet 2010.2.9 del 井主编号排序支持支路编号等级不够
|
||
// if(csSpec1.Find(_T("-")) > -1)
|
||
// {
|
||
// GlobalFunc::StringAnalysis((const TCHAR*)csSpec1, xsText1, &num1, &numWith);
|
||
// iBraNum1 = num1;
|
||
// int idx = csSpec1.Find(_T("-"));
|
||
// csSpec1 = csSpec1.Left(csSpec1.GetLength() - idx);
|
||
// }
|
||
// if(csSpec2.Find(_T("-")) > -1)
|
||
// {
|
||
// GlobalFunc::StringAnalysis((const TCHAR*)csSpec2, xsText1, &num1, &numWith);
|
||
// iBraNum2 = num1;
|
||
// int idx = csSpec2.Find(_T("-"));
|
||
// csSpec2 = csSpec2.Left(csSpec2.GetLength() - idx);
|
||
// }
|
||
//
|
||
//
|
||
// GlobalFunc::StringAnalysis((const TCHAR*)csSpec1, xsText1, &num1, &numWith);
|
||
// GlobalFunc::StringAnalysis((const TCHAR*)csSpec2, xsText2, &num2, &numWith);
|
||
// int ret = _tcscmp(xsText1, xsText2); //第一次比较井编号前缀字母
|
||
// if(ret != 0)
|
||
// {
|
||
// return ret;
|
||
// }
|
||
// else
|
||
// {
|
||
// ret = IntCmp(&num1, &num2); //第二次比较井主编号
|
||
// if(ret == 0)
|
||
// ret = IntCmp(&iBraNum1, &iBraNum2);//第三次比较井支路编号
|
||
// }
|
||
// return ret;
|
||
|
||
// cet 2010.2.9 add 支持无限井支路编号排序
|
||
//保存字符串中的数字
|
||
std::list<int> lstLeft, lstRigt;
|
||
while (csSpec1.Find(_T("-")) > -1)
|
||
{
|
||
GlobalFunc::StringAnalysis((const TCHAR*)csSpec1, xsText1, &num1, &numWith);
|
||
lstLeft.push_front(num1);
|
||
int idx = csSpec1.Find(_T("-"));
|
||
int nTemp = 0;
|
||
while (idx != -1)
|
||
{
|
||
nTemp = idx;
|
||
idx = csSpec1.Find(_T("-"), idx + 1);
|
||
}
|
||
csSpec1 = csSpec1.Left(nTemp);
|
||
}
|
||
|
||
while (csSpec2.Find(_T("-")) > -1)
|
||
{
|
||
GlobalFunc::StringAnalysis((const TCHAR*)csSpec2, xsText2, &num1, &numWith);
|
||
lstRigt.push_front(num1);
|
||
int idx = csSpec2.Find(_T("-"));
|
||
int nTemp = 0;
|
||
while (idx != -1)
|
||
{
|
||
nTemp = idx;
|
||
idx = csSpec2.Find(_T("-"), idx + 1);
|
||
}
|
||
csSpec2 = csSpec2.Left(nTemp);
|
||
}
|
||
|
||
GlobalFunc::StringAnalysis((const TCHAR*)csSpec1, xsText1, &num1, &numWith);
|
||
lstLeft.push_front(num1);
|
||
GlobalFunc::StringAnalysis((const TCHAR*)csSpec2, xsText2, &num2, &numWith);
|
||
lstRigt.push_front(num2);
|
||
|
||
//第一次比较井编号前缀字母
|
||
int ret = _tcscmp(xsText1, xsText2);
|
||
if (ret != 0)
|
||
{
|
||
return ret;
|
||
}
|
||
else
|
||
{
|
||
//按从左到右顺序比较字符串中的数字
|
||
int nSizeL = (int)lstLeft.size(), nSizeR = (int)lstRigt.size();
|
||
if (nSizeL == 0 && nSizeR == 0) //两字符串完全相同
|
||
{
|
||
return 0;
|
||
}
|
||
else if (nSizeL == 0) //csSpec2包含csSpec1
|
||
{
|
||
return -1;
|
||
}
|
||
else if (nSizeR == 0) //csSpec1包含csSpec2
|
||
{
|
||
return 1;
|
||
}
|
||
|
||
std::list<int>::iterator itLeft = lstLeft.begin(), itRight = lstRigt.begin();
|
||
for (; itLeft != lstLeft.end() && itRight != lstRigt.end(); itLeft++, itRight++)
|
||
{
|
||
ret = *itLeft - *itRight;
|
||
if (ret != 0)
|
||
{
|
||
return ret;
|
||
}
|
||
}
|
||
|
||
bool bLeft = (itLeft == lstLeft.end()), bRight = (itRight == lstRigt.end());
|
||
|
||
if (bLeft && bRight) // 两个链表完全相同
|
||
{
|
||
return 0;
|
||
}
|
||
else if (bRight) // lstLeft 包含 lstRight的所有值
|
||
{
|
||
return 1;
|
||
}
|
||
else // lstRight 包含 lstLeft的所有值
|
||
{
|
||
return -1;
|
||
}
|
||
}
|
||
}
|
||
|
||
void WellCoordSheet()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
Entity entStartWell, entEndWell;
|
||
int ret(0);
|
||
TCHAR cRet = _T('\0');
|
||
DList<TWellData> lstWellSys;
|
||
|
||
XPoint pt;
|
||
INITGET_BEG(0, _T("M"));
|
||
ret = GlobalFunc::SelectEntity(_T("\n请选择起点井[多选(M)]:<退出>"), entStartWell, pt, rbMask, _T("M"), cRet);
|
||
INITGET_END();
|
||
#if (ARX == 19)
|
||
if (cRet == _T('\0'))
|
||
{
|
||
TCHAR szCh[20];
|
||
acedGetInput(szCh);
|
||
cRet = szCh[0];
|
||
}
|
||
#endif
|
||
|
||
if (ret == RTKWORD)
|
||
{
|
||
//cet 2010.2.4 add 选择井类型
|
||
CString strWellType;
|
||
int nWellType = 0;
|
||
int nSheetRowNum = 0;
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CWellCoordSheetSettingDlg dlg;
|
||
if (dlg.DoModal() == IDCANCEL)
|
||
{
|
||
return;
|
||
}
|
||
nWellType = dlg.m_nWndRadWellType;
|
||
nSheetRowNum = dlg.m_nWndEdtRowCount;
|
||
|
||
if (nWellType == 0)
|
||
{
|
||
//strWellType = _T("WELL_雨水");
|
||
strWellType = LAY_WELL_RAIN;
|
||
}
|
||
else if (nWellType == 1)
|
||
{
|
||
//strWellType = _T("WELL_污水");
|
||
strWellType = LAY_WELL_DIRT;
|
||
}
|
||
else if (nWellType == 2)
|
||
{
|
||
//strWellType = _T("WELL_给水");
|
||
strWellType = LAY_WELL_FEED;
|
||
}
|
||
else if (nWellType == 3)
|
||
{
|
||
//strWellType = _T("WELL_废水");
|
||
strWellType = LAY_WELL_USED;
|
||
}
|
||
else if (nWellType == 4)
|
||
{
|
||
//strWellType = _T("WELL_中水");
|
||
strWellType = LAY_WELL_USELESS;
|
||
}
|
||
else if (nWellType == 5)
|
||
{
|
||
//strWellType = _T("WELL_消防");
|
||
strWellType = LAY_WELL_FIRE;
|
||
}
|
||
else if (nWellType == 6)
|
||
{
|
||
//strWellType = _T("WELL_其它");
|
||
strWellType = LAY_WELL_OTHER;
|
||
}
|
||
else if (nWellType == 7)
|
||
{
|
||
strWellType = _T("*");
|
||
}
|
||
|
||
// cet 2010.2.4 del
|
||
// PickSet ss(SS_FREE);
|
||
// if(GlobalFunc::SelectEntities(_T("\n请选择要标注的井:<退出>"), ss, rbMask) != RTNORM)
|
||
// return;
|
||
|
||
// cet 2010.2.4 add
|
||
RBList rblist(RTDXF0, _T("AEC_ZT_WELL"), 8, strWellType, NULL);
|
||
PickSet ss(SS_FREE);
|
||
int nStatus(0);
|
||
TCHAR chKey;
|
||
INITGET_BEG(0, _T("P"));
|
||
nStatus = GlobalFunc::SelectEntities(_T("\n请框选范围{选择闭合pline线(P)}:<整张图>"), ss, rblist, _T("P"), chKey);
|
||
INITGET_END();
|
||
if (nStatus == RTKWORD) //选择关键字
|
||
{
|
||
Entity entPoly;
|
||
RBList rbMask2(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL);
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择表示范围的闭合PLINE:<退出>"), entPoly, rbMask2) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
AcDbObjectId idLine;
|
||
acdbGetObjectId(idLine, entPoly);
|
||
AcDbPolyline *pPLine = NULL;
|
||
acdbOpenObject(pPLine, idLine, AcDb::kForRead);
|
||
if (pPLine != NULL)
|
||
{
|
||
if (!pPLine->isClosed())
|
||
{
|
||
pPLine->close();
|
||
return;
|
||
}
|
||
pPLine->close();
|
||
}
|
||
XPoly2D poly2(entPoly);
|
||
XPoint ptLow3, ptUp3;
|
||
poly2.GetExtend(ptLow3, ptUp3);
|
||
poly2.TransUCS(RBGroups(0), RBGroups(1)); //RBGroups(0) wcs, RBGroups(1) ucs
|
||
RBList rbFence = poly2.Fence();
|
||
GlobalFunc::AssureInCurrentView(ptLow3, ptUp3);
|
||
ss.Get(_T("CP"), rbFence, NULL, rblist);
|
||
}
|
||
else if (nStatus == RTERROR) //默认选择
|
||
{
|
||
acedSSGet(_T("A"), NULL, NULL, rblist, ss);
|
||
}
|
||
else if (nStatus != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
|
||
for (long i = 0; i < ss.Length(); i++) {
|
||
Entity ent = ss[i];
|
||
TWellData *pList = new TWellData();
|
||
AcDbObjectId id;
|
||
acdbGetObjectId(id, ent);
|
||
|
||
pList->m_ID = id;
|
||
pList->m_bIsWell = TRUE;
|
||
BOOL bIsRectWell = FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
pList->m_csName = pEquip->GetWellName();
|
||
pList->m_nUpEle = pEquip->GetWellEleUp();
|
||
pList->m_nDownEle = pEquip->GetWellEleDown();
|
||
AcDbObjectId idRec = pEquip->GetBlock2d();
|
||
if (_tcsicmp(GlobalFunc::GetBlkNameById(idRec), _T("$TwtSys$00000336")) == 0)
|
||
bIsRectWell = TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
CString csWellRadius = GlobalFunc::ReadXdata(ent, _T("TG-WELL-RADIUS"));
|
||
pList->m_nWellRadius = _tstof(csWellRadius) / 2.0; //转化为半径
|
||
if (fabs(pList->m_nWellRadius) < 0.1)
|
||
pList->m_nWellRadius = 350;
|
||
if (bIsRectWell)
|
||
pList->m_nWellRadius *= (-1);
|
||
lstWellSys.Append(pList);
|
||
}
|
||
lstWellSys.QuickSort(SortByWellName);
|
||
// cet 2010.2.5 del
|
||
// DoWellCoordSheet(lstWellSys);
|
||
// cet 2010.2.9 add 根据表行数和井类型创建表
|
||
OutputWellCoordSheet(lstWellSys, nSheetRowNum, nWellType);
|
||
return;
|
||
}
|
||
else if (ret != RTNORM)
|
||
return;
|
||
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择终止井:<退出>"), entEndWell, rbMask) != RTNORM)
|
||
return;
|
||
SSearchPipeList *pListAll = new SSearchPipeList();
|
||
PickSet ssAll(SS_FREE);
|
||
if (!SearchOutdoorWell(entStartWell, entEndWell, pListAll, ssAll, TRUE)) {
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
int pos = entEndWell.In(&ssAll);
|
||
if (pos == 0) {
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
GetWellListData(pListAll, lstWellSys);
|
||
DoWellCoordSheet(lstWellSys);
|
||
delete pListAll; //删除链头
|
||
}
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 井编号增1减1
|
||
//***************************************************************************************************
|
||
|
||
void PlusMinusWellSerial(BOOL bPlus)
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
GlobalFunc::DocGetPickFirst().Free();
|
||
Entity entWell;
|
||
CString csPrompt;
|
||
if (bPlus)
|
||
csPrompt = _T("\n请选择要编号加1的井:<退出>");
|
||
else
|
||
csPrompt = _T("\n请选择要编号减1的井:<退出>");
|
||
if (GlobalFunc::SelectEntity(csPrompt, entWell, rbMask) != RTNORM)
|
||
return;
|
||
char szLay[256];
|
||
entWell.GetData(8, szLay);
|
||
|
||
CString csSerial;
|
||
int newIdx(0);
|
||
OPENOBJ_BEGIN(entWell, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
csSerial = pEquip->GetWellName();
|
||
XString xsText;
|
||
int num, numWith;
|
||
GlobalFunc::StringAnalysis(csSerial, xsText, &num, &numWith);
|
||
|
||
newIdx = num;
|
||
if (bPlus)
|
||
newIdx++;
|
||
else
|
||
newIdx--;
|
||
csSerial = GlobalFunc::PlusString(csSerial, 1, bPlus);
|
||
pEquip->SetWellName(csSerial);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
PickSet ss(SS_FREE), ssModify(SS_FREE);
|
||
RBList rbMask2(RTDXF0, _T("AEC_ZT_WELL"), 8, szLay, NULL);
|
||
ss.Get(_T("X"), NULL, NULL, rbMask2);
|
||
long len = ss.Length();
|
||
|
||
for (long i = 0; i < len; i++) {
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
CString csSerial2 = pEquip->GetWellName();
|
||
XString xsText;
|
||
int num, numWith;
|
||
GlobalFunc::StringAnalysis(csSerial2, xsText, &num, &numWith);
|
||
|
||
int newIdx2 = num;
|
||
int idx = newIdx - 1;
|
||
if (!bPlus)
|
||
idx = newIdx;
|
||
if (idx < newIdx2) {
|
||
ssModify += ent;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
ssModify -= entWell;
|
||
len = ssModify.Length();
|
||
if (len < 1)
|
||
return;
|
||
|
||
TCHAR szText[32];
|
||
int iLen = len;
|
||
|
||
csPrompt.Format(_T("\n发现还有%d个井需要修改编号,是否自动更新?<Y>"), iLen);
|
||
int ret = ads_getstring(NULL, csPrompt, szText);
|
||
if (_tcsicmp(szText, _T("Y")) == 0 || _tcsicmp(szText, _T("")) == 0) {
|
||
for (i = 0; i < len; i++) {
|
||
Entity ent = ssModify[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
csSerial = pEquip->GetWellName();
|
||
csSerial = GlobalFunc::PlusString(csSerial, 1, bPlus);
|
||
pEquip->SetWellName(csSerial);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
void PlusWellSerial()
|
||
{
|
||
PlusMinusWellSerial(TRUE);
|
||
}
|
||
|
||
void MinusWellSerial()
|
||
{
|
||
PlusMinusWellSerial(FALSE);
|
||
}
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 井编号
|
||
//***************************************************************************************************
|
||
// cet 2011.8.26 add 获得井的下游管线 bVal 表示是否找到下游管线
|
||
AcDbObjectId GetDownriverPipe(const AcDbObjectId &idWell, bool &bVal)
|
||
{
|
||
bVal = true;
|
||
AcDbObjectId id = AcDbObjectId::kNull;
|
||
AecXDbWell *pWell = NULL;
|
||
Acad::ErrorStatus st = acdbOpenObject(pWell, idWell, AcDb::kForRead);
|
||
if (pWell != NULL)
|
||
{
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
int nNum = pWell->GetInterfaceNum();
|
||
for (int i = 0; i < nNum; i++)
|
||
{
|
||
CPipeInterface face = pWell->GetInterface(i);
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, face.m_idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
TPipeSys::FlowDirection flow = pPipe->GetFlowDir();
|
||
if (flow == TPipeSys::kFromStart && ptLoc.Distance2d(pPipe->GetStartPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
id = face.m_idPipe;
|
||
pPipe->close();
|
||
break;
|
||
}
|
||
else if (flow == TPipeSys::kFromEnd && ptLoc.Distance2d(pPipe->GetEndPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
id = face.m_idPipe;
|
||
pPipe->close();
|
||
break;
|
||
}
|
||
pPipe->close();
|
||
}
|
||
}
|
||
pWell->close();
|
||
}
|
||
|
||
// 未找到下游管线时,选择任意一个井连接的管线
|
||
if (!id.isValid())
|
||
{
|
||
bVal = false;
|
||
acdbOpenObject(pWell, idWell, AcDb::kForRead);
|
||
if (pWell != NULL)
|
||
{
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
int nNum = pWell->GetInterfaceNum();
|
||
for (int i = 0; i < nNum; i++)
|
||
{
|
||
CPipeInterface face = pWell->GetInterface(i);
|
||
id = face.m_idPipe;
|
||
if (id.isValid())
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
pWell->close();
|
||
}
|
||
}
|
||
|
||
return id;
|
||
}
|
||
|
||
// cet 2011.8.26 add 修改井标注位置和角度
|
||
void ModifyWellDimPosAngle(Entity &ent)
|
||
{
|
||
// 获得下游管线
|
||
AcDbObjectId idWell;
|
||
acdbGetObjectId(idWell, ent);
|
||
bool bFind = true;
|
||
AcDbObjectId idPipe = GetDownriverPipe(idWell, bFind);
|
||
XPoint ptS, ptE;
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
ptS = pPipe->GetStartPoint();
|
||
ptE = pPipe->GetEndPoint();
|
||
pPipe->close();
|
||
}
|
||
|
||
// 井编号标注位置,角度
|
||
AecXDbWell *pWell = NULL;
|
||
acdbOpenObject(pWell, idWell, AcDb::kForWrite);
|
||
if (pWell != NULL)
|
||
{
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
double dAngle = 0.0;
|
||
if (idPipe.isValid())
|
||
{
|
||
AcGeVector3d vt;
|
||
if (fabs(ptLoc.Distance2d(ptS)) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vt = ptE - ptS;
|
||
}
|
||
else
|
||
{
|
||
vt = ptS - ptE;
|
||
}
|
||
vt.z = 0.0;
|
||
|
||
if (!bFind)
|
||
{
|
||
vt *= -1;
|
||
}
|
||
|
||
vt.rotateBy(GlobalFunc::Wcs2Ucs(0.0), AcGeVector3d::kZAxis);
|
||
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
||
dAngle = vtX.angleTo(vt, AcGeVector3d::kZAxis); // ucs角度
|
||
}
|
||
|
||
double Len = pWell->GetScale() * pWell->GetPScale();
|
||
double nLenText = Len / 2 * g_Option::instance().g_dDimWellNameDist;
|
||
XPoint ptLabel;
|
||
ptLoc = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
if (g_Option::instance().g_iDimWellNameAngle == 0) // 井编号角度保持0度
|
||
{
|
||
if (g_Option::instance().g_iDimWellNamePos == 0) // 井上方
|
||
{
|
||
ads_polar(ptLoc, PI / 2, nLenText, ptLabel);
|
||
}
|
||
else // 井下方
|
||
{
|
||
ads_polar(ptLoc, -PI / 2, nLenText, ptLabel);
|
||
}
|
||
dAngle = 0.0;
|
||
}
|
||
else // 井编号角度随下游管线
|
||
{
|
||
// cet 2011.10.11 add 井上下方需从ucs考虑
|
||
if (dAngle > PI / 2 && dAngle <= PI * 3 / 2)
|
||
{
|
||
dAngle += PI;
|
||
}
|
||
|
||
//if (!idPipe.isValid()) // 无下游管线 zxl 2011.11.04 modify
|
||
if (!idPipe.isValid() || !bFind) // 无下游管线
|
||
{
|
||
if (g_Option::instance().g_iDimWellNamePos == 0) // 井上方
|
||
{
|
||
ads_polar(ptLoc, PI / 2, nLenText, ptLabel);
|
||
}
|
||
else // 井下方
|
||
{
|
||
ads_polar(ptLoc, -PI / 2, nLenText, ptLabel);
|
||
}
|
||
dAngle = 0.0;
|
||
}
|
||
else if (g_Option::instance().g_iDimWellNamePos == 0) // 井上方
|
||
{
|
||
if (dAngle - PI * 2 >= 0)//角度大于2π时
|
||
{
|
||
dAngle -= (PI * 2);
|
||
}
|
||
//下游管线角度为0 90 180 270 度时,强制0度
|
||
if (fabs(dAngle - 0.0) < 0.003 || fabs(dAngle - PI / 2) < 0.003 || fabs(dAngle - PI) < 0.003 || fabs(dAngle - PI * 3 / 2) < 0.003)
|
||
{
|
||
ads_polar(ptLoc, PI / 2, nLenText, ptLabel);
|
||
dAngle = 0.0;
|
||
}
|
||
else if ((dAngle > PI / 2 && dAngle <= PI * 2 / 3) || (dAngle > PI * 3 / 2 && dAngle <= PI * 5 / 3))
|
||
{//下游管线角度为90-120 270-300区间时,角度附加180度
|
||
dAngle += PI;
|
||
ads_polar(ptLoc, dAngle + PI / 2, nLenText, ptLabel);
|
||
}
|
||
else
|
||
{
|
||
ads_polar(ptLoc, dAngle + PI / 2, nLenText, ptLabel);
|
||
}
|
||
}
|
||
else // 井下方
|
||
{
|
||
if (dAngle - PI * 2 >= 0)
|
||
{
|
||
dAngle -= (PI * 2);
|
||
}
|
||
if (fabs(dAngle - 0.0) < 0.003 || fabs(dAngle - PI / 2) < 0.003 || fabs(dAngle - PI) < 0.003 || fabs(dAngle - PI * 3 / 2) < 0.003)
|
||
{
|
||
ads_polar(ptLoc, -PI / 2, nLenText, ptLabel);
|
||
dAngle = 0.0;
|
||
}
|
||
else if ((dAngle > PI / 2 && dAngle <= PI * 2 / 3) || (dAngle > PI * 3 / 2 && dAngle <= PI * 5 / 3))
|
||
{
|
||
dAngle += PI;
|
||
ads_polar(ptLoc, dAngle - PI / 2, nLenText, ptLabel);
|
||
}
|
||
else
|
||
{
|
||
ads_polar(ptLoc, dAngle - PI / 2, nLenText, ptLabel);
|
||
}
|
||
}
|
||
}
|
||
ptLabel = GlobalFunc::Ucs2Wcs(ptLabel);
|
||
pWell->SetLabelLocation(ptLabel);
|
||
pWell->SetDimAngle(dAngle); // ucs角度
|
||
pWell->close();
|
||
}
|
||
}
|
||
|
||
// cet 2011.8.26 add 修改井编号位置及角度
|
||
void ModifyWellDimPosAngle(PickSet &ss)
|
||
{
|
||
for (long i = 0; i < ss.Length(); i++)
|
||
{
|
||
Entity ent(ss[i]);
|
||
ModifyWellDimPosAngle(ent);
|
||
}
|
||
}
|
||
|
||
CString GetWellLayer(Entity ent)
|
||
{
|
||
CString csLay;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbEquipment, pEquip);
|
||
if (pEquip) {
|
||
int num = pEquip->GetInterfaceNum();
|
||
if (num > 0) {
|
||
CPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
//int idx = GetPipeLayerIdxBySys(pPipe->GetSysType());
|
||
csLay = pPipe->GetLayer();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
return csLay;
|
||
}
|
||
|
||
|
||
|
||
//支路井编号
|
||
void BraWellSerialCmd()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
Entity entStartWell, entEndWell, entWell;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择主干管上的井:<退出>"), entEndWell, rbMask) != RTNORM)
|
||
return;
|
||
CString csWellName;
|
||
OPENOBJ_BEGIN(entEndWell, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
int num = pEquip->GetInterfaceNum();
|
||
if (num != 3) {
|
||
g_Option::instance().adsout << _T("\n不是交叉井。再见。");
|
||
return;
|
||
}
|
||
csWellName = pEquip->GetWellName();
|
||
}
|
||
OPENOBJ_END();
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择支路末端井:"), entStartWell, rbMask) == RTNORM) {
|
||
SSearchPipeList *pListAll = new SSearchPipeList();
|
||
PickSet ssAll(SS_FREE);
|
||
|
||
if (!SearchOutdoorWell(entStartWell, entEndWell, pListAll, ssAll, TRUE)) {
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
csWellName = csWellName + _T("-1");
|
||
DList<TWellData> lstWellSys;
|
||
GetWellListData(pListAll, lstWellSys);
|
||
delete pListAll; //删除链头
|
||
for (int i = 0; i < lstWellSys.Length(); i++) {
|
||
if (lstWellSys[i]->m_bIsWell) { //井
|
||
ads_name ename;
|
||
AcDbObjectId id = lstWellSys[i]->m_ID;
|
||
acdbGetAdsName(ename, id);
|
||
Entity entTmp = ename;
|
||
if (entEndWell == entTmp)
|
||
return;
|
||
if (entTmp.Is(_T("AEC_ZT_WELL")))
|
||
{
|
||
ChangeWellNameSerial(entTmp, csWellName);
|
||
ModifyWellDimPosAngle(entTmp); // cet 2011.8.26 add 修改井标注位置角度
|
||
csWellName = GlobalFunc::PlusString(csWellName, 1, TRUE);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//标支路井编号
|
||
//void DimBraWellSerial(SSearchPipeList *pListAll, CString csStartName)
|
||
void DimBraWellSerial(SSearchPipeList *pListAll, CString &csStartName, bool bAdd = true) // zxl 2011.09.06 modify 增加判断递增还是递减的标识
|
||
{
|
||
AcDbObjectId id = NULL;
|
||
id = pListAll->m_ID;
|
||
if (pListAll->m_iType == 3) { //井
|
||
OPENOBJ_BEGIN(id, AcDb::kForWrite, AecXDbWell, pEnt);
|
||
if (pEnt) {
|
||
pEnt->SetWellName(csStartName);
|
||
// 根据标识判断井编号递增还是递减 zxl 2011.09.06 modify
|
||
// csStartName = GlobalFunc::PlusString(csStartName, 1, TRUE);
|
||
if (bAdd)
|
||
{
|
||
csStartName = GlobalFunc::PlusString(csStartName, 1, TRUE);
|
||
}
|
||
else
|
||
{
|
||
csStartName = GlobalFunc::PlusString(csStartName, -1, TRUE);
|
||
}
|
||
|
||
//显示井编号 zxl 2011.09.23 add
|
||
pEnt->EnableDrawLabel(TRUE);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (pListAll->m_iType == 0) {
|
||
XPoint ptFront;
|
||
if (pListAll->m_pPrevious != NULL) {
|
||
OPENOBJ_BEGIN(pListAll->m_pPrevious->m_ID, AcDb::kForRead, CDbPipeNode, pNode);
|
||
if (pNode) {
|
||
ptFront = pNode->GetLocation();
|
||
}
|
||
OPENOBJ_END();
|
||
OPENOBJ_BEGIN(id, AcDb::kForWrite, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
XPoint p1 = ptFront;
|
||
p1.z = 0;
|
||
XPoint p2 = pPipe->StartPoint();
|
||
p2.z = 0;
|
||
if (p1 == p2)
|
||
pPipe->SetFlowDir(TPipeSys::kFromEnd);
|
||
else
|
||
pPipe->SetFlowDir(TPipeSys::kFromStart);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
long len = pListAll->m_lstNode.Length();
|
||
int lenTmp(0);
|
||
int idx(0);
|
||
if (len > 1) {//出户管(不接井),例外
|
||
for (long i = 0; i < len; i++)//
|
||
{
|
||
SSearchPipeList *pList = pListAll->m_lstNode[i];
|
||
long len2 = pList->m_lstNode.Length();
|
||
if (len2 == 1) {
|
||
SSearchPipeList *pList2 = pList->m_lstNode[0];
|
||
if (pList2->m_iType != 3)
|
||
lenTmp++;
|
||
else
|
||
idx = i;
|
||
}
|
||
}
|
||
}
|
||
if (len == 1 || len - lenTmp == 1) {//碰到分支就结束,无法进行支路的支路标注
|
||
SSearchPipeList *pList = pListAll->m_lstNode[idx];
|
||
// DimBraWellSerial(pList, csStartName); zxl 2011.09.06 modify
|
||
DimBraWellSerial(pList, csStartName, bAdd);
|
||
}
|
||
}
|
||
|
||
//判断井编号是否小于1 ZXL 2011.09.06 modify
|
||
bool IsLessEqual1(CString &strText)
|
||
{
|
||
TCHAR chText;
|
||
CString strText1 = _T("");
|
||
for (int i = strText.GetLength(); i > 0; i--)
|
||
{
|
||
chText = strText[i - 1];
|
||
if (chText <= _T('9') && chText >= _T('0'))
|
||
{
|
||
strText1.Insert(0, chText);
|
||
}
|
||
else
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
double dNo = 0.0;
|
||
dNo = _tstof(strText1);
|
||
if (dNo <= 1.0)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
//判断递增还是递减,重设井编号名字 zxl 2011.09.06 modify
|
||
void ChangeWellSerialName(CString &csNewName, BOOL bAdd)
|
||
{
|
||
if (bAdd)//井编号递增
|
||
{
|
||
csNewName = GlobalFunc::PlusString(csNewName, 1, TRUE);
|
||
}
|
||
else//井编号递减
|
||
{
|
||
if (IsLessEqual1(csNewName))//井编号递减为1时
|
||
{
|
||
;
|
||
}
|
||
else
|
||
{
|
||
csNewName = GlobalFunc::PlusString(csNewName, -1, TRUE);
|
||
}
|
||
}
|
||
}
|
||
|
||
// cet 2011.9.16 add 处理井编号左键无效选择
|
||
bool g_bLeftKey = false;
|
||
void DealLeftKey(const MSG* pMsg)
|
||
{
|
||
if (pMsg != NULL && pMsg->message == WM_LBUTTONDOWN)
|
||
{
|
||
g_bLeftKey = true;
|
||
}
|
||
}
|
||
|
||
//井编号
|
||
void WellSerialCmd()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
Entity entStartWell, entEndWell;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择起点井:<退出>"), entStartWell, rbMask) != RTNORM)
|
||
return;
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CWellSerialDlg *pDlg = NULL;
|
||
pDlg = new CWellSerialDlg;
|
||
pDlg->Create(IDD_WELL_SERIAL);
|
||
pDlg->ShowWindow(SW_SHOW);
|
||
pDlg->SetWellName(GlobalFunc::GetWellName(entStartWell));
|
||
pDlg->UpdateData(FALSE);
|
||
|
||
int nRet = GlobalFunc::SelectEntity(_T("\n请选择终止井(自动修改):<手工修改>"), entEndWell, rbMask);
|
||
if (nRet == RTNORM) // 自动修改
|
||
{
|
||
acutPrintf(_T("\n管网系统井编号进行中,请稍候...\n"));
|
||
CWellSerial wellSerial;
|
||
wellSerial.SetStartWell(entStartWell);
|
||
wellSerial.SetEndWell(entEndWell);
|
||
wellSerial.SetSerialType(pDlg->GetBranchSerialType());
|
||
wellSerial.SetAdd(pDlg->IsIncrease() ? true : false);
|
||
wellSerial.SetEvade(pDlg->IsResetPos() ? true : false);
|
||
wellSerial.SetWellSerial(pDlg->GetWellName());
|
||
wellSerial.UpdateWellSerival(); // 编号
|
||
}
|
||
else if (nRet != RTCAN) // 手动修改
|
||
{
|
||
//获取对话框变量
|
||
CString csNewName;
|
||
BOOL bIsDecrease = TRUE;
|
||
int iBranchSerial = 0;
|
||
|
||
pDlg->UpdateData(TRUE);
|
||
csNewName = pDlg->GetWellName();
|
||
bIsDecrease = pDlg->IsIncrease();
|
||
ChangeWellNameSerial(entStartWell, csNewName); // 设置起点井编号
|
||
ModifyWellDimPosAngle(entStartWell);
|
||
|
||
if (pDlg->IsResetPos())//躲避更新
|
||
{
|
||
EvadeUpdating(entStartWell);
|
||
}
|
||
ChangeWellSerialName(csNewName, bIsDecrease);
|
||
pDlg->SetWellName(csNewName); //及时更新对话框中的井编号
|
||
pDlg->UpdateData(FALSE);
|
||
|
||
Entity entNextWell;
|
||
while (GlobalFunc::SelectEntity(_T("\n请选择要标注的下一个井:<退出>"), entNextWell, rbMask) == RTNORM)
|
||
{
|
||
//响应手动修改过程中对话框的更新 zxl 2011.09.14 add
|
||
pDlg->UpdateData(TRUE);
|
||
csNewName = pDlg->GetWellName();
|
||
bIsDecrease = pDlg->IsIncrease();
|
||
ChangeWellNameSerial(entNextWell, csNewName);
|
||
|
||
ChangeWellSerialName(csNewName, bIsDecrease);
|
||
pDlg->SetWellName(csNewName); //及时更新对话框中的井编号 zxl 2011.09.14 add
|
||
pDlg->UpdateData(FALSE);
|
||
|
||
ModifyWellDimPosAngle(entNextWell); // cet 2011.8.26 add 修改井标注位置角度
|
||
if (pDlg->IsResetPos())//躲避更新 zxl 2011.11.03 add
|
||
{
|
||
EvadeUpdating(entNextWell);
|
||
}
|
||
}
|
||
}
|
||
|
||
pDlg->DestroyWindow();
|
||
delete pDlg;
|
||
pDlg = NULL;
|
||
}
|
||
|
||
//***************************************************************************************************
|
||
// 地面标高
|
||
//***************************************************************************************************
|
||
void GrdrawRect(XRectAngle &rect)
|
||
{
|
||
ads_grdraw(rect.GetLowLeft(), rect.GetUpLeft(), 7, 0);
|
||
ads_grdraw(rect.GetLowLeft(), rect.GetLowRight(), 7, 0);
|
||
ads_grdraw(rect.GetUpRight(), rect.GetLowRight(), 7, 0);
|
||
ads_grdraw(rect.GetUpLeft(), rect.GetUpRight(), 7, 0);
|
||
}
|
||
|
||
double GetGroundEle2()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("ATS_ELEVATION,TEXT,MTEXT,ATS_TEXT"), 8, _T("*"), NULL);
|
||
double nEle(0);
|
||
int ret(0);
|
||
INITGET_BEG(0, _T("R F"));
|
||
ret = ads_getreal(_T("\n请给出设计地面标高[拾取标高(R)/根据已标注井计算(F)]<退出>:"), &nEle);
|
||
INITGET_END();
|
||
if (ret == RTKWORD) {
|
||
XString sKeyword;
|
||
ads_getinput(sKeyword);
|
||
TCHAR cKey = sKeyword[0];
|
||
if (cKey == _T('R')) {
|
||
Entity ent;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择标高文字<退出>:"), ent, rbMask) != RTNORM)
|
||
return 8848;
|
||
CString csText;
|
||
if (ent.Is(_T("ATS_ELEVATION"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbSymbElevation, pEnt);
|
||
if (pEnt) {
|
||
csText = pEnt->GetText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_TEXT"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbText, pEnt);
|
||
if (pEnt) {
|
||
csText = pEnt->GetText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("TEXT"))) {
|
||
TCHAR szText[256];
|
||
ent.GetData(1, szText);
|
||
csText = szText;
|
||
}
|
||
else if (ent.Is(_T("MTEXT"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbMText, pText);
|
||
if (pText) {
|
||
AcDbVoidPtrArray entitySet;
|
||
pText->explode(entitySet);
|
||
long lNum = entitySet.length();
|
||
if (lNum == 1) {
|
||
AcDbEntity *pEnt = (AcDbEntity *)entitySet[0];
|
||
AcDbText *pText2 = NULL;
|
||
if (pText2 = AcDbText::cast(pEnt)) {
|
||
TCHAR *pStr = pText2->textString();
|
||
csText = pStr;
|
||
acutDelString(pStr);
|
||
}
|
||
}
|
||
GlobalFunc::ReleaseEntSet(entitySet);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
nEle = _tstof(csText);
|
||
}
|
||
else
|
||
return 8849;
|
||
}
|
||
else if (ret != RTNORM)
|
||
return 8848;
|
||
return nEle;
|
||
}
|
||
|
||
double GetGroundEle()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("ATS_ELEVATION,TEXT,MTEXT,ATS_TEXT"), 8, _T("*"), NULL);
|
||
double nEle(0);
|
||
|
||
Entity ent;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择标高文字<退出>:"), ent, rbMask) != RTNORM)
|
||
return -1;
|
||
CString csText;
|
||
if (ent.Is(_T("ATS_ELEVATION"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbSymbElevation, pEnt);
|
||
if (pEnt) {
|
||
csText = pEnt->GetText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_TEXT"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbText, pEnt);
|
||
if (pEnt) {
|
||
csText = pEnt->GetText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("TEXT"))) {
|
||
TCHAR szText[256];
|
||
ent.GetData(1, szText);
|
||
csText = szText;
|
||
}
|
||
else if (ent.Is(_T("MTEXT"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbMText, pText);
|
||
if (pText) {
|
||
AcDbVoidPtrArray entitySet;
|
||
pText->explode(entitySet);
|
||
long lNum = entitySet.length();
|
||
if (lNum == 1) {
|
||
AcDbEntity *pEnt = (AcDbEntity *)entitySet[0];
|
||
AcDbText *pText2 = NULL;
|
||
if (pText2 = AcDbText::cast(pEnt)) {
|
||
TCHAR *pStr = pText2->textString();
|
||
csText = pStr;
|
||
acutDelString(pStr);
|
||
}
|
||
}
|
||
GlobalFunc::ReleaseEntSet(entitySet);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
nEle = _tstof(csText);
|
||
|
||
return nEle;
|
||
}
|
||
|
||
AcDbObjectId GetPipeBy2Well(Entity ent1, Entity ent2)
|
||
{
|
||
AcDbObjectId id;
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, AecXDbWell, pWell);
|
||
if (pWell) {
|
||
int num = pWell->GetInterfaceNum();
|
||
for (int i = 0; i < num; i++) {
|
||
CPipeInterface face;
|
||
pWell->GetInterface(i, face);
|
||
AcDbObjectId PipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(ent2, AcDb::kForRead, AecXDbWell, pWell2);
|
||
if (pWell2) {
|
||
int num2 = pWell2->GetInterfaceNum();
|
||
for (int j = 0; j < num2; j++) {
|
||
CPipeInterface face2;
|
||
pWell2->GetInterface(j, face2);
|
||
AcDbObjectId PipeId2 = face2.m_idPipe;
|
||
if (PipeId == PipeId2) {
|
||
return PipeId;
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return id;
|
||
}
|
||
|
||
void DoCalcWellEleByFront(Entity entRef, Entity entDim, double dGradient)
|
||
{
|
||
if (entRef == entDim)
|
||
return;
|
||
AcDbObjectId idRef;
|
||
acdbGetObjectId(idRef, entRef);
|
||
double dGroundEleRef(0), dGroundEleDim(0);
|
||
OPENOBJ_BEGIN(idRef, AcDb::kForRead, AecXDbWell, pWell);
|
||
if (pWell) {
|
||
dGroundEleRef = pWell->GetWellEleUp();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
|
||
AcDbObjectId PipeId = GetPipeBy2Well(entRef, entDim);
|
||
if (PipeId == NULL) {
|
||
g_Option::instance().adsout << _T("\n2井之间没有连接管线!");
|
||
return;
|
||
}
|
||
OPENOBJ_BEGIN(PipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
double nPipeLength = pPipe->Length();
|
||
// if(!GlobalFunc::DocGetMeterUnitDraw())
|
||
// nPipeLength = nPipeLength/1000.0;
|
||
double dDrop = nPipeLength * dGradient;
|
||
TPipeSys::FlowDirection dir = pPipe->GetFlowDir();
|
||
AcDbObjectId id = pPipe->GetNode(0);
|
||
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AecXDbWell, pWell);
|
||
if (pWell) {
|
||
CString df = pWell->GetWellName();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
if (dir == TPipeSys::kFromStart) {
|
||
if (id == idRef)//参考井是起点
|
||
dGroundEleDim = dGroundEleRef - dDrop;
|
||
else
|
||
dGroundEleDim = dGroundEleRef + dDrop;
|
||
}
|
||
else if (dir == TPipeSys::kFromEnd) {
|
||
if (id == idRef)//参考井是起点
|
||
dGroundEleDim = dGroundEleRef + dDrop;
|
||
else
|
||
dGroundEleDim = dGroundEleRef - dDrop;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
RBList rbMaskDim(RTDXF0, _T("AEC_ZT_WELLDIM"), NULL);
|
||
XPoint ptLoc;
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
ptLoc = pEquip->GetLocation();
|
||
pEquip->SetWellEleUp(dGroundEleDim);
|
||
}
|
||
OPENOBJ_END();
|
||
PickSet ss2(SS_FREE);
|
||
XPoint ptUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
GlobalFunc::GetPointPickSet(ptUcs, ss2, rbMaskDim, 50);
|
||
GlobalFunc::UpdateGraphic(ss2);
|
||
}
|
||
|
||
//根据已标井计算其它相连的井标高
|
||
void DoCalcWellEle()
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
Entity entRef;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择已经标注的参考井:<退出>"), entRef, rbMask) != RTNORM)
|
||
return;
|
||
|
||
RBList reMaskRef = ads_buildlist(-4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_ARROW"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_TEXT"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("TEXT"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("AEC_ZT_PIPE"), -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
|
||
double dGradient(-1);
|
||
Entity entGradent;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择图中可参考坡度标注:<输入>"), entGradent, reMaskRef) == RTNORM) {
|
||
if (entGradent.Is(_T("AEC_ZT_PIPE"))) {
|
||
dGradient = GlobalFunc::GetPipeGradient(entGradent);
|
||
}
|
||
else if (entGradent.Is(_T("ATS_ARROW"))) {
|
||
OPENOBJ_BEGIN(entGradent, AcDb::kForRead, AecXDbSymbArrow, pEnt);
|
||
if (pEnt) {
|
||
CString csText = pEnt->GetText();
|
||
int idx = csText.Find(_T("="));
|
||
csText = csText.Right(csText.GetLength() - idx - 1);
|
||
dGradient = _tstof(csText);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else {
|
||
TCHAR szText[256];
|
||
entGradent.GetData(1, szText);
|
||
CString csText = szText;
|
||
int idx = csText.Find(_T("="));
|
||
csText = csText.Right(csText.GetLength() - idx - 1);
|
||
idx = csText.Find(_T("%"));
|
||
if (idx < 0)
|
||
idx = csText.Find(_T("%"));
|
||
|
||
if (idx > -1) {
|
||
csText = csText.Left(idx);
|
||
dGradient = _tstof(csText) / 100.0;
|
||
}
|
||
else
|
||
dGradient = _tstof(csText);
|
||
}
|
||
}
|
||
else {
|
||
if (ads_getreal(_T("\n请输入坡度<退出>:"), &dGradient) != RTNORM)
|
||
return;
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
while (1)
|
||
{
|
||
Entity entDim;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择要计算的井:<退出>"), entDim, rbMask) != RTNORM) {
|
||
return;
|
||
}
|
||
|
||
//得到2个井相连的管线
|
||
AcDbObjectId PipeId = GetPipeBy2Well(entRef, entDim);
|
||
if (PipeId == NULL) {
|
||
|
||
SSearchPipeList *pListAll = new SSearchPipeList();
|
||
PickSet ssAll(SS_FREE);
|
||
|
||
if (!SearchOutdoorWell(entRef, entDim, pListAll, ssAll, FALSE)) {
|
||
delete pListAll;
|
||
return;
|
||
}
|
||
|
||
DList<TWellData> lstWellSys;
|
||
GetWellListData(pListAll, lstWellSys);
|
||
delete pListAll; //删除链头
|
||
for (int i = 0; i < lstWellSys.Length(); i++) {
|
||
if (lstWellSys[i]->m_bIsWell) { //井
|
||
ads_name ename;
|
||
AcDbObjectId id = lstWellSys[i]->m_ID;
|
||
acdbGetAdsName(ename, id);
|
||
Entity entTmp = ename;
|
||
if (entRef == entTmp)
|
||
continue;
|
||
DoCalcWellEleByFront(entRef, entTmp, dGradient);
|
||
entRef = entTmp;
|
||
if (entDim == entTmp)
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else {
|
||
DoCalcWellEleByFront(entRef, entDim, dGradient);
|
||
entRef = entDim;
|
||
}
|
||
}
|
||
}
|
||
|
||
void DoDefineWellEle()
|
||
{
|
||
double nEle(0);
|
||
CString csEle;
|
||
RBList rbMask = ads_buildlist(-4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("AEC_ZT_WELL"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PUMP"), 8, LAY_TWT_OUT, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
|
||
RBList rbMaskDim(RTDXF0, _T("AEC_ZT_WELLDIM"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
|
||
BOOL bPickText = FALSE;
|
||
int ret(0);
|
||
INITGET_BEG(0, _T("R F"));
|
||
ret = ads_getreal(_T("\n请给出设计地面标高[拾取标高(R)/根据已标注井计算(F)]<退出>:"), &nEle);
|
||
INITGET_END();
|
||
if (ret == RTKWORD) {
|
||
XString sKeyword;
|
||
ads_getinput(sKeyword);
|
||
TCHAR cKey = sKeyword[0];
|
||
if (cKey == _T('R'))
|
||
{
|
||
bPickText = TRUE;
|
||
nEle = GetGroundEle();
|
||
}
|
||
else
|
||
{
|
||
DoCalcWellEle(); //根据已标井计算其它相连的井标高
|
||
return;
|
||
}
|
||
}
|
||
else if (ret != RTNORM)
|
||
return;
|
||
|
||
|
||
|
||
|
||
while (fabs(nEle) > 0)
|
||
{
|
||
if (GlobalFunc::SelectEntities(_T("\n请选择要标注的井(矩形框表示没有标高信息的井):<退出>"), ss, rbMask) != RTNORM)
|
||
return;
|
||
long len = ss.Length();
|
||
for (long i = 0; i < len; i++) {
|
||
Entity ent = ss[i];
|
||
XPoint ptLoc;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
ptLoc = pEquip->GetLocation();
|
||
pEquip->SetWellEleUp(nEle);
|
||
}
|
||
OPENOBJ_END();
|
||
//OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPump, pPump);
|
||
//if (pPump) {
|
||
// pPump->SetPumpSpare(nEle);
|
||
// continue;
|
||
//}
|
||
//OPENOBJ_END();
|
||
|
||
PickSet ss2(SS_FREE);
|
||
XPoint ptUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
GlobalFunc::GetPointPickSet(ptUcs, ss2, rbMaskDim, 50);
|
||
GlobalFunc::UpdateGraphic(ss2);
|
||
}
|
||
if (bPickText)
|
||
nEle = GetGroundEle();
|
||
}
|
||
}
|
||
|
||
void DefineWellEle()
|
||
{
|
||
CString csPrompt;
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
|
||
PickSet ssAll(SS_FREE);
|
||
ssAll.Get(_T("X"), NULL, NULL, rbMask);
|
||
for (long j = 0; j < ssAll.Length(); j++) {
|
||
Entity ent = ssAll[j];
|
||
XPoint ptLoc;
|
||
double nScale(1), nEle(0);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
if (pEquip->visibility() != AcDb::kInvisible)// 2011-1-21 SR 如果系统不显示,该系统的井就不必处理了,否则会丢失井
|
||
{
|
||
if (Acad::eOk == pEquip->upgradeOpen())
|
||
{
|
||
ptLoc = pEquip->GetLocation();
|
||
nScale = pEquip->GetScale();
|
||
pEquip->DrawPropertyText(TRUE);
|
||
nEle = pEquip->GetWellEleUp();
|
||
if (fabs(nEle) < 0.001) {
|
||
XRectAngle rect(ptLoc, nScale * GlobalFunc::DocGetPScale(), nScale * GlobalFunc::DocGetPScale());
|
||
GrdrawRect(rect);
|
||
}
|
||
pEquip->downgradeOpen();
|
||
}
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
GlobalFunc::UpdateGraphic(ssAll);
|
||
DoDefineWellEle();
|
||
for (j = 0; j < ssAll.Length(); j++) {
|
||
Entity ent = ssAll[j];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
if (pEquip->visibility() != AcDb::kInvisible)
|
||
{
|
||
if (Acad::eOk == pEquip->upgradeOpen())
|
||
{
|
||
|
||
pEquip->DrawPropertyText(FALSE);
|
||
pEquip->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
GlobalFunc::UpdateGraphic(ssAll);
|
||
}
|
||
|
||
|
||
|
||
|
||
//***************************************************************************************************
|
||
// 管底标注
|
||
//***************************************************************************************************
|
||
|
||
// cet 2011.6.17 add 以井的插入点为原点(pt),以与井相连的管道另一端点(pt2 与井插入点不重合的点)做向量
|
||
// vt2 = pt2 - pt, 求出角度dAngle = vt2.angleTo(vt, AcGeVector3d::kZAxis )的最小值
|
||
double GetMinDangle(AcGeVector3d &vt, const AcDbObjectId &idWell, AcDbObjectId &idPipe, bool bExtendPipe = false)
|
||
{
|
||
AcGeVector3d vt1 = vt;
|
||
vt1[2] = 0.0;
|
||
double dAngle = 3 * PI;
|
||
AecXDbWell *pWell = NULL;
|
||
CDbPool *pPool = NULL;
|
||
AcDbObjectId idOldPipe = idPipe;
|
||
acdbOpenObject(pWell, idWell, AcDb::kForRead);
|
||
acdbOpenObject(pPool, idWell, AcDb::kForRead);// 支持化粪池 zxl 2012.10.23 add
|
||
if (pWell != NULL)
|
||
{
|
||
int nPipeNum = pWell->GetInterfaceNum();
|
||
XPoint ptIns = pWell->GetLocation();
|
||
for (int i = 0; i < nPipeNum; i++)
|
||
{
|
||
CPipeInterface face;
|
||
pWell->GetInterface(i, face);
|
||
|
||
if (bExtendPipe && idOldPipe == face.m_idPipe)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, face.m_idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcGeVector3d vtTemp;
|
||
if (ptIns.Distance2d(pPipe->StartPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vtTemp = pPipe->EndPoint() - ptIns;
|
||
}
|
||
else
|
||
{
|
||
vtTemp = pPipe->StartPoint() - ptIns;
|
||
}
|
||
pPipe->close();
|
||
|
||
vtTemp[2] = 0.0;
|
||
double dTemp = vtTemp.angleTo(vt1, AcGeVector3d::kZAxis);
|
||
// zxl 2013.06.17 add
|
||
if (dTemp > PI && !bExtendPipe)
|
||
{
|
||
dTemp = dTemp - PI * 2;// 不延长时 获取反方向角度
|
||
}
|
||
|
||
bool bExtend = false;// 当前管线是否延长
|
||
if (bExtendPipe && dTemp > PI / 2)
|
||
{
|
||
if (dTemp >= PI)
|
||
{
|
||
dTemp = dTemp - PI * 2;
|
||
if (fabs(dTemp) > PI / 2)
|
||
{
|
||
dTemp += PI;
|
||
bExtend = true;
|
||
}
|
||
}
|
||
vt = -vt;
|
||
}
|
||
|
||
if (fabs(dTemp) <= fabs(dAngle) || (fabs(dTemp) == fabs(dAngle) && !bExtend))
|
||
{
|
||
dAngle = dTemp;
|
||
vtTemp.normalize();
|
||
vt = vtTemp * vt.length();
|
||
idPipe = face.m_idPipe;
|
||
}
|
||
}
|
||
}
|
||
pWell->close();
|
||
}
|
||
else if (pPool != NULL)// 支持化粪池 zxl 2012.10.23 add
|
||
{
|
||
int nPipeNum = pPool->GetInterfaceNum();
|
||
XPoint ptIns = pPool->GetLocation();
|
||
for (int i = 0; i < nPipeNum; i++)
|
||
{
|
||
CPipeInterface face;
|
||
pPool->GetInterface(i, face);
|
||
if (bExtendPipe && idOldPipe == face.m_idPipe)
|
||
{
|
||
continue;
|
||
}
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, face.m_idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcGeVector3d vtTemp;
|
||
if (ptIns.Distance2d(pPipe->StartPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vtTemp = pPipe->EndPoint() - ptIns;
|
||
}
|
||
else
|
||
{
|
||
vtTemp = pPipe->StartPoint() - ptIns;
|
||
}
|
||
pPipe->close();
|
||
|
||
vtTemp[2] = 0.0;
|
||
double dTemp = vtTemp.angleTo(vt1, AcGeVector3d::kZAxis);
|
||
// zxl 2013.06.17 add
|
||
if (dTemp > PI && !bExtendPipe)
|
||
{
|
||
dTemp = dTemp - PI * 2;// 不延长时 获取反方向角度
|
||
}
|
||
|
||
bool bExtend = false;// 当前管线是否延长
|
||
if (bExtendPipe && dTemp > PI / 2)
|
||
{
|
||
if (dTemp >= PI)
|
||
{
|
||
dTemp = dTemp - PI * 2;
|
||
if (fabs(dTemp) > PI / 2)
|
||
{
|
||
dTemp += PI;
|
||
bExtend = true;
|
||
}
|
||
}
|
||
vt = -vt;
|
||
}
|
||
|
||
if (fabs(dTemp) <= fabs(dAngle) || (fabs(dTemp) == fabs(dAngle) && !bExtend))
|
||
{
|
||
dAngle = dTemp;
|
||
vtTemp.normalize();
|
||
vt = vtTemp * vt.length();
|
||
idPipe = face.m_idPipe;
|
||
}
|
||
}
|
||
}
|
||
pPool->close();
|
||
}
|
||
|
||
if (fabs(dAngle - 3 * PI) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
dAngle = (AcGeVector3d::kXAxis).angleTo(vt1, AcGeVector3d::kZAxis);
|
||
}
|
||
|
||
return dAngle;
|
||
}
|
||
|
||
// cet 2011.6.20 add 根据参考标注 选择最佳标注位置
|
||
void GetStandardAngle(const AcDbObjectId &idWell, const AcGeVector3d &vtDim, AcGeVector3d &vt)
|
||
{
|
||
std::vector<AcGeVector3d> vec; // 保存所有向量
|
||
AecXDbWell *pWell = NULL;
|
||
CDbPool *pPool = NULL;
|
||
acdbOpenObject(pWell, idWell, AcDb::kForRead);
|
||
acdbOpenObject(pPool, idWell, AcDb::kForRead);// 支持化粪池 zxl 2012.10.23 add
|
||
if (pWell != NULL)
|
||
{
|
||
int nPipeNum = pWell->GetInterfaceNum();
|
||
XPoint ptIns = pWell->GetLocation();
|
||
for (int i = 0; i < nPipeNum; i++)
|
||
{
|
||
CPipeInterface face;
|
||
pWell->GetInterface(i, face);
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, face.m_idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcGeVector3d vtTemp;
|
||
if (ptIns.Distance2d(pPipe->StartPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vtTemp = pPipe->EndPoint() - ptIns;
|
||
}
|
||
else
|
||
{
|
||
vtTemp = pPipe->StartPoint() - ptIns;
|
||
}
|
||
vtTemp.normalize();
|
||
vtTemp[2] = 0.0;
|
||
vec.push_back(vtTemp);
|
||
pPipe->close();
|
||
}
|
||
}
|
||
pWell->close();
|
||
}
|
||
else if (pPool != NULL)// 支持化粪池 zxl 2012.10.23 add
|
||
{
|
||
int nPipeNum = pPool->GetInterfaceNum();
|
||
XPoint ptIns = pPool->GetLocation();
|
||
for (int i = 0; i < nPipeNum; i++)
|
||
{
|
||
CPipeInterface face;
|
||
pPool->GetInterface(i, face);
|
||
CDbPipe *pPipe = NULL;
|
||
acdbOpenObject(pPipe, face.m_idPipe, AcDb::kForRead);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcGeVector3d vtTemp;
|
||
if (ptIns.Distance2d(pPipe->StartPoint()) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vtTemp = pPipe->EndPoint() - ptIns;
|
||
}
|
||
else
|
||
{
|
||
vtTemp = pPipe->StartPoint() - ptIns;
|
||
}
|
||
vtTemp.normalize();
|
||
vtTemp[2] = 0.0;
|
||
vec.push_back(vtTemp);
|
||
pPipe->close();
|
||
}
|
||
}
|
||
pPool->close();
|
||
}
|
||
|
||
if (vec.size() < 2)
|
||
{
|
||
vt = vtDim;
|
||
return;
|
||
}
|
||
|
||
// 求出AcGeVector3d::kXAxis到各向量的角度
|
||
std::vector<AcGeVector3d>::iterator it;
|
||
std::set<double> setAngle;
|
||
for (it = vec.begin(); it != vec.end(); it++)
|
||
{
|
||
double dAngle = (AcGeVector3d::kXAxis).angleTo(*it, AcGeVector3d::kZAxis);
|
||
setAngle.insert(dAngle);
|
||
}
|
||
|
||
// 按逆时针旋转相邻向量间角度和平分线上的向量
|
||
std::multimap<double, AcGeVector3d> data;
|
||
std::set<double>::iterator it1, it2;
|
||
AcGeVector3d vtX = AcGeVector3d::kXAxis * vtDim.length();
|
||
for (it1 = setAngle.begin(); it1 != setAngle.end(); it1++)
|
||
{
|
||
it2 = it1;
|
||
++it2;
|
||
if (it2 != setAngle.end())
|
||
{
|
||
double dAngle = *it2 - *it1;
|
||
AcGeVector3d vtTemp = vtX;
|
||
vtTemp.rotateBy(*it1 + dAngle * 0.5, AcGeVector3d::kZAxis);
|
||
data.insert(std::make_pair(dAngle, vtTemp));
|
||
}
|
||
}
|
||
|
||
// 处理最后一个向量
|
||
AcGeVector3d vtFirst = AcGeVector3d::kXAxis;
|
||
vtFirst.rotateBy(*setAngle.begin(), AcGeVector3d::kZAxis);
|
||
AcGeVector3d vtLast = AcGeVector3d::kXAxis;
|
||
vtLast.rotateBy(*setAngle.rbegin(), AcGeVector3d::kZAxis);
|
||
double dAngle = vtLast.angleTo(vtFirst, AcGeVector3d::kZAxis);
|
||
data.insert(std::make_pair(dAngle, vtLast.rotateBy(dAngle * 0.5, AcGeVector3d::kZAxis) * vtDim.length()));
|
||
|
||
// 找出标注最佳位置
|
||
bool bFind = false; // 是否找到
|
||
std::multimap<double, AcGeVector3d>::iterator it3;
|
||
dAngle = (AcGeVector3d::kXAxis).angleTo(vtDim, AcGeVector3d::kZAxis);
|
||
double dMaxAngle = 0.0;
|
||
for (it3 = data.begin(); it3 != data.end(); it3++)
|
||
{
|
||
double dTemp = (AcGeVector3d::kXAxis).angleTo((*it3).second, AcGeVector3d::kZAxis);
|
||
if ((dAngle < PI && dAngle > 0 && dTemp < PI && dTemp > 0)
|
||
|| (dAngle > PI && dAngle < 2 * PI && dTemp > PI && dTemp < 2 * PI))
|
||
{
|
||
if (!bFind)
|
||
{
|
||
vt = (*it3).second;
|
||
bFind = true;
|
||
dMaxAngle = (*it3).first;
|
||
}
|
||
else if (dMaxAngle < (*it3).first)
|
||
{
|
||
vt = (*it3).second;
|
||
dMaxAngle = (*it3).first;
|
||
}
|
||
|
||
}
|
||
else if (fabs(dAngle - dTemp) < g_Option::instance()._DIST_SNAP || fabs(dAngle) < g_Option::instance()._DIST_SNAP && fabs(dTemp - 2 * PI) < g_Option::instance()._DIST_SNAP)
|
||
{
|
||
vt = (*it3).second;
|
||
bFind = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (bFind)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 未找到时,选择角度最大的
|
||
dMaxAngle = 0.0;
|
||
for (it3 = data.begin(); it3 != data.end(); it3++)
|
||
{
|
||
if (it3 == data.begin())
|
||
{
|
||
vt = (*it3).second;
|
||
dMaxAngle = (*it3).first;
|
||
}
|
||
else if (dMaxAngle < (*it3).first)
|
||
{
|
||
vt = (*it3).second;
|
||
dMaxAngle = (*it3).first;
|
||
}
|
||
}
|
||
}
|
||
|
||
// cet 2011.6.20 modify nDimType值表示标注算法
|
||
//void MutiWellDim()
|
||
// void MutiWellDim(int nDimType = 0)
|
||
// {
|
||
// RBList rbMaskDim(RTDXF0, _T("AEC_ZT_WELLDIM"), NULL);
|
||
// Entity entDim;
|
||
// if(GlobalFunc::SelectEntity(_T("\n请选择已经标好的井底标注:<退出>"), entDim, rbMaskDim) != RTNORM)
|
||
// return;
|
||
// TPipeSys::SysType sys;
|
||
// XPoint ptLoc, ptTurn;
|
||
// int iMode(0);
|
||
// BOOL bDirection = FALSE;
|
||
// double dRotation = 0.0; //布局转角
|
||
// AcDbObjectId idWell; // cet 2011.6.17 add
|
||
// OPENOBJ_BEGIN(entDim, AcDb::kForRead, CDbWellDim, pDim);
|
||
// if(pDim){
|
||
// ptLoc = pDim->GetStartPoint();
|
||
// ptTurn = pDim->GetTurnPoint();
|
||
// iMode = pDim->GetDrawMode();
|
||
// dRotation = pDim->GetLayoutRotation();
|
||
// if (pDim->GetTextBaseLen() > 0)
|
||
// bDirection = TRUE;
|
||
// else
|
||
// bDirection = FALSE;
|
||
// idWell = pDim->GetWellId(); // cet 2011.6.17 add
|
||
// }
|
||
// OPENOBJ_END();
|
||
// // cet 2011.6.17 modify 更改标注位置确定方式,参考标注存在向量vt = ptTurn - ptLoc, 找出管线逆时针与之角度最小的值dAngle
|
||
// // 新标注标注向量 vt2 = vt, 找出管线逆时针与之角度最小的值dAngle2, 根据角度大小关系旋转vt2, 使之与其成最小角度的管线之间的
|
||
// // 角度值变为dAngle;
|
||
// // AcGeMatrix3d mat;
|
||
// // mat.setToTranslation(AcGeVector3d(ptTurn[0]-ptLoc[0], ptTurn[1]-ptLoc[1], ptTurn[2]-ptLoc[2]));
|
||
// // cet 2011.6.20 modify
|
||
// // AcGeVector3d vt = ptTurn - ptLoc;
|
||
// // double dAngle = GetMinDangle(vt, idWell);
|
||
// AcGeVector3d vt = ptTurn - ptLoc;
|
||
// vt.z = 0.0; // cet 2011.8.31 add z值设置为0,否则可能导致标注长度异常
|
||
// double dAngle = 0.0;
|
||
// if (nDimType == 1)
|
||
// {
|
||
// dAngle = GetMinDangle(vt, idWell);
|
||
// }
|
||
//
|
||
// RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
// PickSet ss(SS_FREE);
|
||
// if(GlobalFunc::SelectEntities(_T("\n请选择要标注的井:<退出>"), ss, rbMask) != RTNORM)
|
||
// return;
|
||
// // CString csLay = LAY_PIPE_RAIN;
|
||
// for(long i=0;i<ss.Length();i++){
|
||
// Entity ent = ss[i];
|
||
// double nEle(0), nEle2(0);
|
||
// OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
// if(pEquip){
|
||
// nEle = pEquip->GetWellEleUp();
|
||
// nEle2 = pEquip->GetWellEleDown();
|
||
// ptLoc = pEquip->GetLocation();
|
||
//
|
||
// int num = pEquip->GetInterfaceNum();
|
||
// if(num > 0){
|
||
// CPipeInterface face;
|
||
// pEquip->GetInterface(0, face);
|
||
// AcDbObjectId nextPipeId = face.m_idPipe;
|
||
// OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
// if(pPipe){
|
||
// sys = pPipe->GetSysType();
|
||
// // int idx = GetPipeLayerIdxBySys(pPipe->GetSysType());
|
||
// // csLay = pPipe->GetLayer();
|
||
// }
|
||
// OPENOBJ_END();
|
||
// }
|
||
//
|
||
// }
|
||
// OPENOBJ_END();
|
||
// ptTurn = ptLoc;
|
||
// // ptTurn.TransformBy(mat); cet 2011.6.17 del
|
||
// AcDbObjectId id = NULL;
|
||
// acdbGetObjectId(id, ent);
|
||
// // cet 2011.6.20 modify 增加关键字N后的变动
|
||
// // // cet 2011.6.17 add
|
||
// // double dAngle2 = GetMinDangle(vt, id);
|
||
// // AcGeVector3d vt2 = vt;
|
||
// // vt2 = vt2.rotateBy(dAngle - dAngle2, AcGeVector3d::kZAxis);
|
||
// // AcGeMatrix3d mat;
|
||
// // mat.setToTranslation(vt2);
|
||
// // ptTurn.TransformBy(mat);
|
||
// if (nDimType == 1)
|
||
// {
|
||
// double dAngle2 = GetMinDangle(vt, id);
|
||
// AcGeVector3d vt2 = vt;
|
||
// vt2 = vt2.rotateBy(dAngle - dAngle2, AcGeVector3d::kZAxis);
|
||
// AcGeMatrix3d mat;
|
||
// mat.setToTranslation(vt2);
|
||
// ptTurn.TransformBy(mat);
|
||
// }
|
||
// else if (nDimType == 0)
|
||
// {
|
||
// AcGeVector3d vtTemp;
|
||
// GetStandardAngle(id, vt, vtTemp);
|
||
// AcGeMatrix3d mat;
|
||
// mat.setToTranslation(vtTemp);
|
||
// ptTurn.TransformBy(mat);
|
||
// }
|
||
//
|
||
// //只有一根管线连井时,该井标注方式为:管线水平角度为 0-90度时,标注角度 135度;否则标注角度为 45度 zxl 2011.11.04 add
|
||
// double dTempAngle = 0.0;//连井管线与X轴的夹角
|
||
// OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
// if(pEquip)
|
||
// {
|
||
// int num = pEquip->GetInterfaceNum();
|
||
// if(num == 1)
|
||
// {
|
||
// CPipeInterface face;
|
||
// pEquip->GetInterface(0, face);
|
||
// AcDbObjectId nextPipeId = face.m_idPipe;
|
||
// OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
// if(pPipe)
|
||
// {
|
||
// AcGeVector3d vtTemp;
|
||
// ptLoc = GlobalFunc::Wcs2Ucs(ptLoc);//在UCS下设定角度
|
||
// ptTurn = GlobalFunc::Wcs2Ucs(ptTurn);
|
||
// if (ptLoc.Distance2d(GlobalFunc::Wcs2Ucs(pPipe->StartPoint())) < g_Option::instance()._DIST_SNAP)
|
||
// {
|
||
// vtTemp = GlobalFunc::Wcs2Ucs(pPipe->EndPoint()) - ptLoc;
|
||
// }
|
||
// else
|
||
// {
|
||
// vtTemp = GlobalFunc::Wcs2Ucs(pPipe->StartPoint()) - ptLoc;
|
||
// }
|
||
// vtTemp[2] = 0.0;
|
||
// dTempAngle = vtTemp.angleTo(AcGeVector3d::kXAxis, AcGeVector3d::kZAxis);
|
||
// dTempAngle = 2 * PI - dTempAngle;
|
||
//
|
||
// AcGeVector3d vt = AcGeVector3d::kXAxis;
|
||
// if (dTempAngle > PI / 360 && dTempAngle < (PI / 2 - PI / 360))//0 - 90 度(精确度为0.5度)时, 标注角度135度
|
||
// {
|
||
// vt = vt.rotateBy(PI * 3 / 4, AcGeVector3d::kZAxis);
|
||
// ptTurn = ptLoc + vt * ptLoc.Distance(ptTurn);
|
||
// }
|
||
// else //90 - 360 度时, 标注角度 45度
|
||
// {
|
||
// vt = vt.rotateBy(PI / 4, AcGeVector3d::kZAxis);
|
||
// ptTurn = ptLoc + vt * ptLoc.Distance(ptTurn);
|
||
// }
|
||
// ptLoc = GlobalFunc::Ucs2Wcs(ptLoc);
|
||
// ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
// }
|
||
// OPENOBJ_END();
|
||
// }
|
||
// }
|
||
// OPENOBJ_END();
|
||
//
|
||
//
|
||
// CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
// InitLayer(csLay);
|
||
//
|
||
// CDbWellDim *pDim = new CDbWellDim;
|
||
// pDim->SetDrawMode(iMode);
|
||
// pDim->SetStartPoint(ptLoc);
|
||
// pDim->SetTurnPoint(ptTurn);
|
||
// pDim->AttachWell(id);
|
||
// pDim->setLayer(csLay);
|
||
// AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
// pDim->SetTextStyleId(idTextStyle);
|
||
// pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
// pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
// if (bDirection)
|
||
// pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
// else
|
||
// pDim->SetTextBaseLen(-(pDim->GetDefaultTextBaseLen()));
|
||
// pDim->SetLayoutRotation(dRotation);
|
||
// pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false); // cet 2011.8.29 add 是否底标高相同是单侧标注
|
||
//
|
||
// pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);// zxl 2012.07.12 add 设置对其方式
|
||
// GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
// Entity entLast;
|
||
// entLast.GetLast();
|
||
// // GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
// OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
// if(pEnt){
|
||
// pEnt->setLayer(csLay);
|
||
// }
|
||
// OPENOBJ_END()
|
||
// }
|
||
// }
|
||
|
||
/* cet 2011.8.25 del 将管底标注设置移入初始设置中
|
||
void DimPipeElevation()
|
||
{
|
||
Entity entStartWell;
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
CString csPrompt;
|
||
XPoint ptLoc, ptTurn;
|
||
TPipeSys::SysType sys;
|
||
// CString csLay = LAY_PIPE_RAIN;
|
||
//cet 2010.2.25 add
|
||
int nDimType = CPipeDownDimEditDlg::eType0;
|
||
//cet 2010.2.26 add
|
||
//从注册表中读取管底标注类型
|
||
CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
||
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
||
regProp.GetValue(_T("PipeDownDimType"), nDimType);
|
||
|
||
while (1) {
|
||
int ret(0);
|
||
TCHAR cRet;
|
||
// cet 2010.2.25 del
|
||
// INITGET_BEG(0, _T("M"));
|
||
// ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井[多选,学习上次标注(M)]:<退出>"), entStartWell, rbMask, _T("M"), cRet);
|
||
// INITGET_END();
|
||
// if(ret == RTKWORD){
|
||
// MutiWellDim();
|
||
// break;
|
||
// }
|
||
// else if(ret != RTNORM)
|
||
// break;
|
||
|
||
// cet 2010.2.25 add 增加关键字S,对管底标注样式进行选择 cet 2011.6.20 modify 增加关键字N
|
||
INITGET_BEG(0, _T("M S N"));
|
||
// ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井[多选,学习上次标注(M)/设置(S)]:<退出>"), entStartWell, rbMask, _T("M S"), cRet);
|
||
ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井[多选,参考上次标注角度(M)/多选,自动计算标准角度(N)/设置(S)]:<退出>"), entStartWell, rbMask, _T("M S N"), cRet);
|
||
INITGET_END();
|
||
if(ret == RTKWORD){
|
||
if(cRet==_T('M'))
|
||
{
|
||
MutiWellDim();
|
||
break;
|
||
}
|
||
else if(cRet==_T('S')) // cet 2010.1.18 add 选择井标注样式
|
||
{
|
||
//获取井标注样式
|
||
CTemporaryResourceOverride vTemp;
|
||
CPipeDownDimEditDlg dlg;
|
||
dlg.SetDimType(nDimType);
|
||
if (dlg.DoModal() == IDOK)
|
||
{
|
||
nDimType = dlg.GetDimType();
|
||
continue;
|
||
}
|
||
}
|
||
else if (cRet == _T('N')) // cet 2011.6.20 add
|
||
{
|
||
MutiWellDim(2);
|
||
break;
|
||
}
|
||
}
|
||
else if(ret != RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
|
||
// if(GlobalFunc::SelectEntity(_T("\n请选择要标注的井:<退出>"), entStartWell, rbMask) != RTNORM)
|
||
// return;
|
||
AcDbObjectId id = NULL;
|
||
int num(0);
|
||
double nEle(0), nEle2(0);
|
||
acdbGetObjectId(id, entStartWell);
|
||
OPENOBJ_BEGIN(entStartWell, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if(pEquip){
|
||
nEle = pEquip->GetWellEleUp();
|
||
nEle2 = pEquip->GetWellEleDown();
|
||
|
||
ptLoc = pEquip->GetLocation();
|
||
num = pEquip->GetInterfaceNum();
|
||
if(num > 0){
|
||
CPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if(pPipe){
|
||
sys = pPipe->GetSysType();
|
||
// int idx = GetPipeLayerIdxBySys(pPipe->GetSysType());
|
||
// csLay = pPipe->GetLayer();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
int iDrawMode(0);
|
||
if(num == 0){
|
||
continue;
|
||
}
|
||
if(fabs(nEle) < 0.001 && fabs(nEle2) < 0.001)
|
||
{
|
||
g_Option::instance().adsout << _T("提示:没有任何信息,请先执行【纵断面图】进行埋深计算,然后图面赋值,再执行本命令标注!\n");
|
||
//continue;
|
||
}
|
||
XPoint ptLocUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
if(ads_getpoint(ptLocUcs, _T("\n请点取标注的转折点<退出>:"), ptTurn) != RTNORM)
|
||
return;
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
if(!!ptTurn){
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
// cet 2010.2.25 modify 设置管底标注样式
|
||
// pDim->SetDrawMode(1);
|
||
pDim->SetDrawMode(nDimType);
|
||
pDim->SetStartPoint(ptLoc);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(id);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if(pEnt){
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
}
|
||
|
||
}
|
||
|
||
//cet 2010.2.26 add
|
||
//将管底标注类型写入注册表
|
||
regProp.SetValue(_T("PipeDownDimType"), nDimType);
|
||
}
|
||
*/
|
||
|
||
// cet 2011.8.25 add
|
||
// void DimPipeElevation()
|
||
// {
|
||
// Entity entStartWell;
|
||
// RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
// CString csPrompt;
|
||
// XPoint ptLoc, ptTurn;
|
||
// TPipeSys::SysType sys;
|
||
// while (1) {
|
||
// int ret(0);
|
||
// TCHAR cRet;
|
||
//
|
||
// INITGET_BEG(0, _T("M"));
|
||
// ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井或化粪池[多选,参考上次标注(M) ]:<退出>"), entStartWell, rbMask, _T("M"), cRet);
|
||
// INITGET_END();
|
||
// if(ret == RTKWORD){
|
||
// if(cRet==_T('M'))
|
||
// {
|
||
// MutiWellDim(g_Option::instance().g_iDimWellEleLeadAngle);
|
||
// break;
|
||
// }
|
||
// }
|
||
// else if(ret != RTNORM)
|
||
// {
|
||
// break;
|
||
// }
|
||
//
|
||
// AcDbObjectId id = NULL;
|
||
// int num(0);
|
||
// double nEle(0), nEle2(0);
|
||
// acdbGetObjectId(id, entStartWell);
|
||
// OPENOBJ_BEGIN(entStartWell, AcDb::kForRead, AecXDbWell, pEquip);
|
||
// if(pEquip){
|
||
// nEle = pEquip->GetWellEleUp();
|
||
// nEle2 = pEquip->GetWellEleDown();
|
||
//
|
||
// ptLoc = pEquip->GetLocation();
|
||
// num = pEquip->GetInterfaceNum();
|
||
// if(num > 0){
|
||
// CPipeInterface face;
|
||
// pEquip->GetInterface(0, face);
|
||
// AcDbObjectId nextPipeId = face.m_idPipe;
|
||
// OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
// if(pPipe){
|
||
// sys = pPipe->GetSysType();
|
||
// }
|
||
// OPENOBJ_END();
|
||
// }
|
||
// }
|
||
// OPENOBJ_END();
|
||
// int iDrawMode(0);
|
||
// if(num == 0){
|
||
// continue;
|
||
// }
|
||
// if(fabs(nEle) < 0.001 && fabs(nEle2) < 0.001)
|
||
// {
|
||
// g_Option::instance().adsout << _T("提示:没有任何信息,请先执行【纵断面图】进行埋深计算,然后图面赋值,再执行本命令标注!\n");
|
||
// }
|
||
// XPoint ptLocUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
// if(ads_getpoint(ptLocUcs, _T("\n请点取标注的转折点<退出>:"), ptTurn) != RTNORM)
|
||
// return;
|
||
//
|
||
// CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
// InitLayer(csLay);
|
||
//
|
||
// ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
// if(!!ptTurn){
|
||
// CDbWellDim *pDim = new CDbWellDim;
|
||
// pDim->SetDrawMode(g_Option::instance().g_iDimWellEleType);
|
||
// pDim->SetStartPoint(ptLoc);
|
||
// pDim->SetTurnPoint(ptTurn);
|
||
// pDim->AttachWell(id);
|
||
// pDim->setLayer(csLay);
|
||
// AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
// pDim->SetTextStyleId(idTextStyle);
|
||
// pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
// pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
// pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
// pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false);
|
||
//
|
||
// pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);// zxl 2012.07.12 add 设置对其方式
|
||
// GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
// Entity entLast;
|
||
// entLast.GetLast();
|
||
// GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
// OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
// if(pEnt){
|
||
// pEnt->setLayer(csLay);
|
||
// }
|
||
// OPENOBJ_END()
|
||
// }
|
||
//
|
||
// }
|
||
// }
|
||
|
||
|
||
bool GetWellInfo(const AcDbObjectId &id, AcGePoint3d &ptLoc, TPipeSys::SysType &sys)
|
||
{
|
||
int num(0);
|
||
double nEle(0), nEle2(0);
|
||
|
||
AcDbEntity *pEquip = NULL;
|
||
acdbOpenAcDbEntity(pEquip, id, AcDb::kForRead);
|
||
if (pEquip == NULL)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (pEquip->isKindOf(AecXDbWell::desc()))
|
||
{
|
||
AecXDbWell *pWell = NULL;
|
||
pWell = (AecXDbWell *)pEquip;
|
||
nEle = pWell->GetWellEleUp();
|
||
nEle2 = pWell->GetWellEleDown();
|
||
|
||
ptLoc = pWell->GetLocation();
|
||
num = pWell->GetInterfaceNum();
|
||
if (num > 0)
|
||
{
|
||
CPipeInterface face;
|
||
pWell->GetInterface(0, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
sys = pPipe->GetSysType();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
if (fabs(nEle) < 0.001 && fabs(nEle2) < 0.001)
|
||
{
|
||
g_Option::instance().adsout << _T("提示:没有任何信息,请先执行【纵断面图】进行埋深计算,然后图面赋值,再执行本命令标注!\n");
|
||
}
|
||
}
|
||
else if (pEquip->isKindOf(CDbPool::desc()))
|
||
{
|
||
CDbPool *pPool = (CDbPool *)pEquip;
|
||
ptLoc = pPool->GetLocation();
|
||
for (int i = 0; i < pPool->GetInterfaceNum(); i++)
|
||
{
|
||
CPipeInterface face;
|
||
pPool->GetInterface(i, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
sys = pPipe->GetSysType();
|
||
double dEle = pPipe->GetElevationAt(0);
|
||
double dEle1 = pPipe->GetElevationAt(1);
|
||
if (fabs(nEle) < 0.001 && fabs(dEle1) < 0.001)
|
||
{
|
||
g_Option::instance().adsout << _T("提示:没有任何信息,请先执行【纵断面图】进行埋深计算,然后图面赋值,再执行本命令标注!\n");
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
pEquip->close();
|
||
return true;
|
||
}
|
||
|
||
bool IsSameWellDim(const AcGePoint3d &ptLoc, const int nDrawMode, const AcGePoint3d &ptTurn)
|
||
{
|
||
AcGePoint3d pt = ptLoc;
|
||
pt.z = 0;
|
||
const double dDist = 100;
|
||
AcGePoint3d ptGeLB, ptGeLT, ptGeRB, ptGeRT;
|
||
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
||
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
||
ptGeLB = pt - vtX * dDist / 2;
|
||
ptGeLB = ptGeLB - vtY * dDist / 2;
|
||
ptGeLT = ptGeLB + vtY * dDist;
|
||
ptGeRB = ptGeLB + vtX * dDist;
|
||
ptGeRT = ptGeRB + vtY * dDist;
|
||
|
||
PickSet ssSel(SS_FREE);
|
||
RBList rbMaskDim(RTDXF0, _T("AEC_ZT_WELLDIM"), NULL);
|
||
ADSGePoint3d _ptGeLB = GlobalFunc::Wcs2Ucs(ptGeLB)
|
||
, _ptGeLT = GlobalFunc::Wcs2Ucs(ptGeLT)
|
||
, _ptGeRT = GlobalFunc::Wcs2Ucs(ptGeRT)
|
||
, _ptGeRB = GlobalFunc::Wcs2Ucs(ptGeRB);
|
||
RBList rbPt = acutBuildList(RTPOINT, &_ptGeLB, RTPOINT, &_ptGeLT, RTPOINT, &_ptGeRT, RTPOINT, &_ptGeRB, NULL);
|
||
acedSSGet(_T("CP"), rbPt, NULL, rbMaskDim, ssSel);
|
||
|
||
for (long l = 0l; l < ssSel.Length(); l++)
|
||
{
|
||
Entity ent = ssSel[l];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbWellDim, pDim);
|
||
if (pDim != NULL)
|
||
{
|
||
int iMode = pDim->GetDrawMode();
|
||
if (iMode == nDrawMode && ptTurn.distanceTo(pDim->GetTurnPoint()) < 0.001)
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void MutiPipeDimInWell(Entity entDim, PickSet ss, const int nDimType);
|
||
// zxl 2012.10.23 modify
|
||
void MutiWellDim(int nDimType = 0, bool bIsWellDim = false)
|
||
{
|
||
RBList rbMaskDim(RTDXF0, _T("AEC_ZT_WELLDIM"), NULL);
|
||
Entity entDim;
|
||
if (GlobalFunc::SelectEntity(_T("\n请选择已经标好的井底标注:<退出>"), entDim, rbMaskDim) != RTNORM)
|
||
return;
|
||
TPipeSys::SysType sys;
|
||
XPoint ptLoc, ptTurn;
|
||
int iMode(0);
|
||
BOOL bDirection = FALSE;
|
||
double dRotation = 0.0; //布局转角
|
||
AcDbObjectId idWell;
|
||
int nBaseLineType = 0;
|
||
bool bIsNewDim = false;
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, CDbWellDim, pDim);
|
||
if (pDim) {
|
||
ptLoc = pDim->GetStartPoint();
|
||
ptTurn = pDim->GetTurnPoint();
|
||
iMode = pDim->GetDrawMode();
|
||
dRotation = pDim->GetLayoutRotation();
|
||
nBaseLineType = pDim->GetBaseLineType();
|
||
if (pDim->GetTextBaseLen() > 0)
|
||
bDirection = TRUE;
|
||
else
|
||
bDirection = FALSE;
|
||
idWell = pDim->GetWellId();
|
||
|
||
if (pDim->GetIsNewDim())// 学习的标注为管线端标注
|
||
{
|
||
bIsNewDim = true;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
// cet 2011.6.17 modify 更改标注位置确定方式,参考标注存在向量vt = ptTurn - ptLoc, 找出管线逆时针与之角度最小的值dAngle
|
||
// 新标注标注向量 vt2 = vt, 找出管线逆时针与之角度最小的值dAngle2, 根据角度大小关系旋转vt2, 使之与其成最小角度的管线之间的
|
||
// 角度值变为dAngle;
|
||
AcGeVector3d vt = ptTurn - ptLoc;
|
||
vt.z = 0.0; // cet 2011.8.31 add z值设置为0,否则可能导致标注长度异常
|
||
double dAngle = 0.0;
|
||
AcGeVector3d vtDim = vt;
|
||
AcDbObjectId idPipe;
|
||
if (nDimType == 1)
|
||
{
|
||
dAngle = GetMinDangle(vt, idWell, idPipe);
|
||
}
|
||
|
||
PickSet ss(SS_FREE);
|
||
if (!bIsWellDim)
|
||
{
|
||
RBList rbMask = ads_buildlist(-4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("AEC_ZT_POOL"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("AEC_ZT_WELL"), -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
|
||
if (GlobalFunc::SelectEntities(_T("\n请选择要标注的井:<退出>"), ss, rbMask) != RTNORM)
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
if (GlobalFunc::SelectEntities(_T("\n请选择要标注的井:<退出>"), ss, rbMask) != RTNORM)
|
||
return;
|
||
}
|
||
|
||
// 学习的标注为管线端标注 zxl 20.3.06.26 add
|
||
if (bIsNewDim)
|
||
{
|
||
MutiPipeDimInWell(entDim, ss, nDimType);
|
||
return;
|
||
}
|
||
|
||
for (long i = 0; i < ss.Length(); i++) {
|
||
Entity ent = ss[i];
|
||
|
||
AcDbObjectId id = NULL;
|
||
acdbGetObjectId(id, ent);
|
||
if (!GetWellInfo(id, ptLoc, sys))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
ptTurn = ptLoc;
|
||
if (nDimType == 1)
|
||
{
|
||
AcGeVector3d vtPipe = vt;
|
||
AcDbObjectId idOldPipe = idPipe;
|
||
double dAngle2 = GetMinDangle(vtPipe, id, idOldPipe, true);
|
||
AcGeVector3d vt2 = vtDim;
|
||
// zxl 2013.06.09 add
|
||
if (fabs(dAngle2) < PI / 4)
|
||
{
|
||
vt2 = vt2.rotateBy(-dAngle2, AcGeVector3d::kZAxis);
|
||
}
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vt2);
|
||
ptTurn.TransformBy(mat);
|
||
}
|
||
else if (nDimType == 0)
|
||
{
|
||
AcGeVector3d vtTemp;
|
||
GetStandardAngle(id, vt, vtTemp);
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vtTemp);
|
||
ptTurn.TransformBy(mat);
|
||
}
|
||
|
||
// zxl 2013.06.18 add 标注存在且样式相同时 不标注
|
||
if (IsSameWellDim(ptLoc, iMode, ptTurn))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
//只有一根管线连井时,该井标注方式为:管线水平角度为 0-90度时,标注角度 135度;否则标注角度为 45度 zxl 2011.11.04 add
|
||
// double dTempAngle = 0.0;//连井管线与X轴的夹角
|
||
// int num = 0;
|
||
// AcDbObjectId nextPipeId = NULL;
|
||
// OPENOBJ_BEGIN(ent, AcDb::kForRead, AecXDbWell, pEquip);
|
||
// if(pEquip != NULL)
|
||
// {
|
||
// num = pEquip->GetInterfaceNum();
|
||
// if(num == 1)
|
||
// {
|
||
// CPipeInterface face;
|
||
// pEquip->GetInterface(0, face);
|
||
// nextPipeId = face.m_idPipe;
|
||
// }
|
||
// }
|
||
// OPENOBJ_END();
|
||
// OPENOBJ_BEGIN(ent, AcDb::kForRead, CDbPool, pEquip);
|
||
// if(pEquip != NULL)
|
||
// {
|
||
// num = pEquip->GetInterfaceNum();
|
||
// if(num == 1)
|
||
// {
|
||
// CPipeInterface face;
|
||
// pEquip->GetInterface(0, face);
|
||
// nextPipeId = face.m_idPipe;
|
||
// }
|
||
// }
|
||
// OPENOBJ_END();
|
||
//
|
||
// if (num == 1 && nextPipeId != NULL)
|
||
// {
|
||
// OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
// if(pPipe)
|
||
// {
|
||
// AcGeVector3d vtTemp;
|
||
// ptLoc = GlobalFunc::Wcs2Ucs(ptLoc);//在UCS下设定角度
|
||
// ptTurn = GlobalFunc::Wcs2Ucs(ptTurn);
|
||
// if (ptLoc.Distance2d(GlobalFunc::Wcs2Ucs(pPipe->StartPoint())) < g_Option::instance()._DIST_SNAP)
|
||
// {
|
||
// vtTemp = GlobalFunc::Wcs2Ucs(pPipe->EndPoint()) - ptLoc;
|
||
// }
|
||
// else
|
||
// {
|
||
// vtTemp = GlobalFunc::Wcs2Ucs(pPipe->StartPoint()) - ptLoc;
|
||
// }
|
||
// vtTemp[2] = 0.0;
|
||
// dTempAngle = vtTemp.angleTo(AcGeVector3d::kXAxis, AcGeVector3d::kZAxis);
|
||
// dTempAngle = 2 * PI - dTempAngle;
|
||
//
|
||
// AcGeVector3d vt = AcGeVector3d::kXAxis;
|
||
// if (dTempAngle > PI / 360 && dTempAngle < (PI / 2 - PI / 360))//0 - 90 度(精确度为0.5度)时, 标注角度135度
|
||
// {
|
||
// vt = vt.rotateBy(PI * 3 / 4, AcGeVector3d::kZAxis);
|
||
// ptTurn = ptLoc + vt * ptLoc.Distance(ptTurn);
|
||
// }
|
||
// else //90 - 360 度时, 标注角度 45度
|
||
// {
|
||
// vt = vt.rotateBy(PI / 4, AcGeVector3d::kZAxis);
|
||
// ptTurn = ptLoc + vt * ptLoc.Distance(ptTurn);
|
||
// }
|
||
// ptLoc = GlobalFunc::Ucs2Wcs(ptLoc);
|
||
// ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
// }
|
||
// OPENOBJ_END();
|
||
// }
|
||
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
pDim->SetDrawMode(iMode);
|
||
pDim->SetStartPoint(ptLoc);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(id);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
if (bDirection)
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
else
|
||
pDim->SetTextBaseLen(-(pDim->GetDefaultTextBaseLen()));
|
||
|
||
// 井底标注时根据引线角度确定基线方向 zxl 2013.06.28 add
|
||
if (iMode == 0 || iMode == 2 || iMode == 3 || iMode == 4)
|
||
{
|
||
AcGeVector3d vt = ptTurn - ptLoc;
|
||
vt.z = 0;
|
||
vt.rotateBy(-dRotation, AcGeVector3d::kZAxis);
|
||
double dAng = AcGeVector3d::kXAxis.angleTo(vt, AcGeVector3d::kZAxis);
|
||
if (dAng > PI / 2 && dAng < PI * 3 / 2 && bDirection)
|
||
{
|
||
pDim->SetTextBaseLen(-pDim->GetTextBaseLen());
|
||
}
|
||
else if (!bDirection && !(dAng > PI / 2 && dAng < PI * 3 / 2))
|
||
{
|
||
pDim->SetTextBaseLen(-pDim->GetTextBaseLen());
|
||
}
|
||
}
|
||
pDim->SetLayoutRotation(dRotation);
|
||
pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false);
|
||
pDim->SetBaseLineType(nBaseLineType);
|
||
|
||
pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt) {
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
|
||
void DimPipeInWell();
|
||
// zxl modify 2012.10.22
|
||
void DimPipeElevation()
|
||
{
|
||
// zxl 2013.06.24 add 标注位置为接管端
|
||
if (g_Option::instance().g_iDimPipeLinePos == 1)
|
||
{
|
||
DimPipeInWell();
|
||
return;
|
||
}
|
||
// 标注位置为井中心zxl 2013.06.24 add
|
||
Entity entStartWell;
|
||
// zxl 2013.04.18 modify
|
||
// RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
// -4, _T("<and"), RTDXF0, _T("AEC_ZT_POOL"), -4, _T("and>"),
|
||
// -4, _T("<and"), RTDXF0, _T("AEC_ZT_WELL"), -4, _T("and>"),
|
||
// -4, _T("or>"), NULL);
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL,AEC_ZT_POOL"), NULL);
|
||
CString csPrompt;
|
||
XPoint ptLoc, ptTurn;
|
||
TPipeSys::SysType sys;
|
||
while (1)
|
||
{
|
||
int ret(0);
|
||
TCHAR cRet = _T('\0');
|
||
|
||
XPoint pt;
|
||
INITGET_BEG(0, _T("M"));
|
||
ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井或化粪池[多选,参考上次标注(M) ]:<退出>"), entStartWell, pt, rbMask, _T("M"), cRet);
|
||
INITGET_END();
|
||
#if (ARX == 19)
|
||
if (cRet == _T('\0'))
|
||
{
|
||
TCHAR szCh[20];
|
||
acedGetInput(szCh);
|
||
cRet = szCh[0];
|
||
}
|
||
#endif
|
||
if (ret == RTKWORD)
|
||
{
|
||
if (cRet == _T('M'))
|
||
{
|
||
MutiWellDim(g_Option::instance().g_iDimWellEleLeadAngle);
|
||
break;
|
||
}
|
||
}
|
||
else if (ret != RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
|
||
AcDbObjectId id = NULL;
|
||
acdbGetObjectId(id, entStartWell);
|
||
if (!GetWellInfo(id, ptLoc, sys))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
XPoint ptLocUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
if (ads_getpoint(ptLocUcs, _T("\n请点取标注的转折点<退出>:"), ptTurn) != RTNORM)
|
||
return;
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
if (!!ptTurn)
|
||
{
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
pDim->SetDrawMode(g_Option::instance().g_iDimWellEleType);
|
||
pDim->SetStartPoint(ptLoc);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(id);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
// zxl 2013.10.23 modify
|
||
//pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false);
|
||
AcGeVector3d vt = ptTurn - ptLoc;
|
||
AcGeVector3d vtX(1.0, 0, 0);
|
||
double dAng = vtX.angleTo(vt);
|
||
if (dAng > PI / 2 && dAng < PI * 3 / 2 && g_Option::instance().g_iDimPipeBaseLineAng == 1 && pDim->IsOnlyDim())
|
||
{
|
||
pDim->SetTextBaseLen(-pDim->GetDefaultTextBaseLen());
|
||
}
|
||
else
|
||
{
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
}
|
||
|
||
pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);// zxl 2012.07.12 add 设置对其方式
|
||
pDim->SetBaseLineType(g_Option::instance().g_iDimPipeBaseLineAng);
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt)
|
||
{
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
}
|
||
|
||
// 根据管线和井或池子的关系,获取管线和井的接口 zxl 2013.06.08 add
|
||
bool GetPtPipe2Well(AcDbObjectId idPipe, AcDbObjectId idWell, XPoint &ptLoc)
|
||
{
|
||
XPoint ptS, ptE;
|
||
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
AcDbEntity *pEquip = NULL;
|
||
acdbOpenAcDbEntity(pEquip, idWell, AcDb::kForRead);
|
||
if (pEquip == NULL)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
ptS = pPipe->GetStartPoint();
|
||
ptE = pPipe->GetEndPoint();
|
||
if (ptS.Distance2d(ptLoc) > 1 && ptE.Distance2d(ptLoc) > 1 && pEquip->isKindOf(AecXDbWell::desc()))
|
||
{
|
||
pEquip->close();
|
||
return false;
|
||
}
|
||
else if (pEquip->isKindOf(CDbPool::desc()))
|
||
{
|
||
CDbPool *pPool = (CDbPool *)pEquip;
|
||
XPoint pt1 = pPool->GetInterface(0).m_ptLocation;
|
||
XPoint pt2 = pPool->GetInterface(1).m_ptLocation;
|
||
if (pt1.Distance2d(ptS) > 1 && pt2.Distance2d(ptE) > 1 && pt1.Distance2d(ptE) > 1 && pt2.Distance2d(ptS) > 1)
|
||
{
|
||
pEquip->close();
|
||
return false;
|
||
}
|
||
}
|
||
pEquip->close();
|
||
|
||
XCurveSegment cv;
|
||
pPipe->GetHideCurve(cv);
|
||
ptS = cv.GetStartPoint();
|
||
ptE = cv.GetEndPoint();
|
||
if (ptS.Distance2d(ptLoc) < ptE.Distance2d(ptLoc))
|
||
{
|
||
ptLoc = ptS;
|
||
}
|
||
else if (ptS.Distance2d(ptLoc) > ptE.Distance2d(ptLoc))
|
||
{
|
||
ptLoc = ptE;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return true;
|
||
}
|
||
|
||
// zxl 2013.06.08 add 根据老标注形式,标注井或池子与管线接口位置
|
||
void DimInterFace(Entity entDim, const AcDbObjectId idPipe, const AcDbObjectId idWell, const int nDimType)
|
||
{
|
||
TPipeSys::SysType sys;
|
||
XPoint ptLoc, ptTurn, ptLocDim;
|
||
int iMode(0);
|
||
BOOL bDirection = FALSE;
|
||
double dRotation = 0.0; //布局转角
|
||
int nFlowType = -1;// 管线流向:0流入 1流出
|
||
AcDbObjectId idW, idP;
|
||
AcGeVector3d vt;
|
||
double dAngle = 0.0;
|
||
double dLength = 0.0;
|
||
int nBaseLineType = -1;
|
||
// 获取旧标注相关信息
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, CDbWellDim, pDim);
|
||
if (pDim != NULL && pDim->GetIsNewDim())
|
||
{
|
||
ptLocDim = pDim->GetStartPoint();
|
||
ptTurn = pDim->GetTurnPoint();
|
||
vt = ptTurn - ptLocDim;
|
||
dLength = ptLocDim.Distance2d(ptTurn);
|
||
vt.z = 0.0;
|
||
iMode = pDim->GetDrawMode();
|
||
nBaseLineType = pDim->GetBaseLineType();
|
||
dRotation = pDim->GetLayoutRotation();
|
||
if (pDim->GetTextBaseLen() > 0)
|
||
bDirection = TRUE;
|
||
else
|
||
bDirection = FALSE;
|
||
idW = pDim->GetWellId();
|
||
ads_name nameWell;
|
||
acdbGetAdsName(nameWell, idW);
|
||
Entity entWell = nameWell;
|
||
if (!GetWellInfo(idW, ptLocDim, sys))
|
||
{
|
||
return;
|
||
}
|
||
idP = pDim->GetPipeId();
|
||
OPENOBJ_BEGIN(idP, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
// 取得管线流向,判断是流出管还是流入管
|
||
TPipeSys::FlowDirection dir = pPipe->GetFlowDir();
|
||
XPoint ptS = pPipe->StartPoint(), ptE = pPipe->EndPoint();
|
||
if (entWell.Is(_T("AEC_ZT_WELL")))
|
||
{
|
||
if ((dir == TPipeSys::kFromEnd && ptS.Distance2d(ptLocDim) < 0.001)
|
||
|| dir == TPipeSys::kFromStart && ptE.Distance2d(ptLocDim) < 0.001)
|
||
{
|
||
nFlowType = 0;
|
||
}
|
||
else if ((dir == TPipeSys::kFromEnd && ptE.Distance2d(ptLocDim) < 0.001)
|
||
|| dir == TPipeSys::kFromStart && ptS.Distance2d(ptLocDim) < 0.001)
|
||
{
|
||
nFlowType = 1;
|
||
}
|
||
}
|
||
else if (entWell.Is(_T("AEC_ZT_POOL")))
|
||
{
|
||
if ((dir == TPipeSys::kFromEnd && ptS.Distance2d(ptLocDim) < ptE.Distance2d(ptLocDim))
|
||
|| dir == TPipeSys::kFromStart && ptE.Distance2d(ptLocDim) < ptS.Distance2d(ptLocDim))
|
||
{
|
||
nFlowType = 0;
|
||
}
|
||
else if ((dir == TPipeSys::kFromEnd && ptE.Distance2d(ptLocDim) < ptS.Distance2d(ptLocDim))
|
||
|| dir == TPipeSys::kFromStart && ptS.Distance2d(ptLocDim) < ptE.Distance2d(ptLocDim))
|
||
{
|
||
nFlowType = 1;
|
||
}
|
||
}
|
||
// 管线相对标注角度
|
||
if (nDimType == 1)
|
||
{
|
||
AcGeVector3d vtPipe;
|
||
if (ptS.Distance2d(ptLocDim) < ptE.Distance2d(ptLocDim))
|
||
{
|
||
vtPipe = ptE - ptS;
|
||
}
|
||
else
|
||
{
|
||
vtPipe = ptS - ptE;
|
||
}
|
||
vtPipe.z = 0;
|
||
dAngle = vtPipe.angleTo(vt, AcGeVector3d::kZAxis);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
GetWellInfo(idWell, ptLoc, sys);
|
||
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe != NULL)
|
||
{
|
||
TPipeSys::SysType sys = pPipe->GetSysType();
|
||
TPipeSys::FlowDirection dir = pPipe->GetFlowDir();
|
||
XPoint ptS = pPipe->GetStartPoint(), ptE = pPipe->GetEndPoint();
|
||
// 该管线是否和所选标注匹配, 即:流出标注匹配流出管,流入标注匹配流入管
|
||
if ((((dir == TPipeSys::kFromEnd && ptS.Distance2d(ptLoc) < ptE.Distance2d(ptLoc))
|
||
|| dir == TPipeSys::kFromStart && ptE.Distance2d(ptLoc) < ptS.Distance2d(ptLoc)) && nFlowType == 0)//流入管
|
||
|| (((dir == TPipeSys::kFromEnd && ptE.Distance2d(ptLoc) < ptS.Distance2d(ptLoc))
|
||
|| dir == TPipeSys::kFromStart && ptS.Distance2d(ptLoc) < ptE.Distance2d(ptLoc)) && nFlowType == 1))//流出管
|
||
{
|
||
XPoint ptLocLab = ptLoc;
|
||
GetPtPipe2Well(idPipe, idWell, ptLocLab);
|
||
AcGeVector3d vtPipe;
|
||
if (ptS.Distance2d(ptLoc) < ptE.Distance2d(ptLoc))
|
||
{
|
||
vtPipe = ptE - ptS;
|
||
}
|
||
else
|
||
{
|
||
vtPipe = ptS - ptE;
|
||
}
|
||
vtPipe.z = 0;
|
||
|
||
|
||
if (nDimType == 1)//标注角度学习旧标注
|
||
{
|
||
ptTurn = ptLocLab;
|
||
AcGeVector3d vt2 = vt;
|
||
vt2 = vtPipe.normalize() * vt.length();
|
||
vt2 = vt2.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vt2);
|
||
ptTurn.TransformBy(mat);
|
||
}
|
||
|
||
if (IsSameWellDim(ptLocLab, iMode, ptTurn))
|
||
{
|
||
return;
|
||
}
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
pDim->SetDrawMode(iMode);
|
||
pDim->SetStartPoint(ptLocLab);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(idWell);
|
||
pDim->SetPipeId(idPipe);
|
||
pDim->SetIsNewDim(1);
|
||
pDim->SetBaseLineType(nBaseLineType);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
XPoint ptS = GlobalFunc::Wcs2Ucs(ptTurn);
|
||
XPoint ptE = GlobalFunc::Wcs2Ucs(ptLocLab);
|
||
if (bDirection)
|
||
{
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
}
|
||
else
|
||
{
|
||
pDim->SetTextBaseLen(-pDim->GetDefaultTextBaseLen());
|
||
}
|
||
pDim->SetLayoutRotation(dRotation);
|
||
pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false);
|
||
|
||
pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt != NULL)
|
||
{
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
// zxl 2013.06.07 add 根据已存在标注 标注新接口
|
||
void MutiPipeDimInWell(Entity entDim, PickSet ss, const int nDimType = 0)
|
||
{
|
||
for (long i = 0; i < ss.Length(); i++)
|
||
{
|
||
Entity ent = ss[i];
|
||
|
||
AcDbObjectId id = NULL;
|
||
acdbGetObjectId(id, ent);
|
||
AcDbEntity *pEquip = NULL;
|
||
acdbOpenAcDbEntity(pEquip, id, AcDb::kForRead);
|
||
if (pEquip == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (pEquip->isKindOf(AecXDbWell::desc()))
|
||
{
|
||
AecXDbWell *pWell = NULL;
|
||
pWell = (AecXDbWell *)pEquip;
|
||
int num = pWell->GetInterfaceNum();
|
||
for (int i = 0; i < num; i++)
|
||
{
|
||
CPipeInterface face;
|
||
pWell->GetInterface(i, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
DimInterFace(entDim, nextPipeId, id, nDimType);
|
||
}
|
||
}
|
||
else if (pEquip->isKindOf(CDbPool::desc()))
|
||
{
|
||
CDbPool *pPool = (CDbPool *)pEquip;
|
||
for (int i = 0; i < pPool->GetInterfaceNum(); i++)
|
||
{
|
||
CPipeInterface face;
|
||
pPool->GetInterface(i, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
DimInterFace(entDim, nextPipeId, id, nDimType);
|
||
}
|
||
}
|
||
pEquip->close();
|
||
}
|
||
}
|
||
|
||
// 单管接口标注 zxl 2013.06.08 add
|
||
void DimPipeInWell()
|
||
{
|
||
Entity entWell;
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL,AEC_ZT_POOL"), NULL);
|
||
RBList rbMask2(RTDXF0, _T("AEC_ZT_PIPE"), NULL);
|
||
CString csPrompt;
|
||
XPoint ptLoc, ptTurn;
|
||
TPipeSys::SysType sys;
|
||
while (1)
|
||
{
|
||
int ret(0);
|
||
TCHAR cRet = _T('\0');
|
||
|
||
XPoint pt;
|
||
INITGET_BEG(0, _T("M"));
|
||
ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井或化粪池[多选,参考上次标注(M) ]:<退出>"), entWell, pt, rbMask, _T("M"), cRet);
|
||
INITGET_END();
|
||
#if (ARX == 19)
|
||
if (cRet == _T('\0'))
|
||
{
|
||
TCHAR szCh[20];
|
||
acedGetInput(szCh);
|
||
cRet = szCh[0];
|
||
}
|
||
#endif
|
||
if (ret == RTKWORD)
|
||
{
|
||
if (cRet == _T('M'))
|
||
{
|
||
MutiWellDim(g_Option::instance().g_iDimWellEleLeadAngle);
|
||
break;
|
||
}
|
||
}
|
||
else if (ret != RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
|
||
while (1)
|
||
{
|
||
Entity entPipe;
|
||
int ret2(0);
|
||
INITGET_BEG(0, _T("M"));
|
||
ret2 = GlobalFunc::SelectEntity(_T("\n请选择要标注的管线:<返回>"), entPipe, pt, rbMask2, _T("M"), cRet);
|
||
INITGET_END();
|
||
if (ret2 != RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
AcDbObjectId id = NULL, idPipe = NULL;
|
||
acdbGetObjectId(id, entWell);
|
||
acdbGetObjectId(idPipe, entPipe);
|
||
if (!GetWellInfo(id, ptLoc, sys))
|
||
{
|
||
break;
|
||
}
|
||
|
||
if (!GetPtPipe2Well(idPipe, id, ptLoc))
|
||
{
|
||
acedPrompt(_T("\n选择无效, 重新选择!"));
|
||
continue;
|
||
}
|
||
|
||
XPoint ptLocUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
if (ads_getpoint(ptLocUcs, _T("\n请点取标注的转折点<退出>:"), ptTurn) != RTNORM)
|
||
return;
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
InitLayer(csLay);
|
||
|
||
ptTurn = GlobalFunc::Ucs2Wcs(ptTurn);
|
||
if (!!ptTurn)
|
||
{
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
pDim->SetDrawMode(g_Option::instance().g_iDimWellEleType);
|
||
pDim->SetIsNewDim(1);
|
||
pDim->SetBaseLineType(g_Option::instance().g_iDimPipeBaseLineAng);
|
||
AcDbObjectId idPipe;
|
||
acdbGetObjectId(idPipe, entPipe);
|
||
pDim->SetPipeId(idPipe);
|
||
|
||
pDim->SetStartPoint(ptLoc);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(id);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
// zxl 2013.06.25 add 设置基线方向
|
||
pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
AcGeVector3d vt = ptTurn - ptLoc;
|
||
AcGeVector3d vtX(1.0, 0, 0);
|
||
double dAng = vtX.angleTo(vt);
|
||
if (dAng > PI / 2 && dAng < PI * 3 / 2 && g_Option::instance().g_iDimPipeBaseLineAng == 1)
|
||
{
|
||
pDim->SetTextBaseLen(-pDim->GetDefaultTextBaseLen());
|
||
}
|
||
else
|
||
{
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
}
|
||
|
||
pDim->SetOnlyDim(g_Option::instance().g_bDimWellOnlyEle ? true : false);
|
||
|
||
pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);// zxl 2012.07.12 add 设置对其方式
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
GlobalFunc::WriteXdata(entLast, _T("TG-LAYER"), csLay);
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt)
|
||
{
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
//***************************************************************************************************
|
||
// 井底标注
|
||
//***************************************************************************************************
|
||
|
||
|
||
class TWellDimEdJig : public TSymbEdJig {
|
||
protected:
|
||
// I/O
|
||
CDbWellDim *m_pDrawEnt;
|
||
public:
|
||
TWellDimEdJig(CDbWellDim *);
|
||
virtual int DoIt();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
};
|
||
|
||
|
||
TWellDimEdJig::TWellDimEdJig(CDbWellDim *pDim)
|
||
{
|
||
m_pDrawEnt = pDim;
|
||
}
|
||
|
||
|
||
|
||
|
||
// 开始执行拖动
|
||
int TWellDimEdJig::DoIt()
|
||
{
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl
|
||
return TSymbEdJig::DoIt();
|
||
}
|
||
|
||
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TWellDimEdJig::update()
|
||
{
|
||
|
||
XVector3D vt = m_ptResult - m_pDrawEnt->GetStartPoint();
|
||
double nAngle = ads_angle(XPoint(), vt);
|
||
|
||
nAngle = CT_std_angle(nAngle - GlobalFunc::Ucs2Wcs(0.0));//add by whl
|
||
double dDist = fabs(m_pDrawEnt->GetTextBaseLen());
|
||
|
||
|
||
if (nAngle >= 0.0 && nAngle < PI / 2) {
|
||
dDist = dDist * 1;
|
||
}
|
||
else if (nAngle >= PI / 2 && nAngle < PI) {
|
||
dDist = dDist * -1;
|
||
}
|
||
else if (nAngle >= PI && nAngle < PI * 1.5) {
|
||
dDist = dDist * -1;
|
||
}
|
||
else {
|
||
dDist = dDist * 1;
|
||
}
|
||
XLine ln(m_pDrawEnt->GetStartPoint(), nAngle);
|
||
|
||
m_pDrawEnt->SetTextBaseLen(dDist);
|
||
m_pDrawEnt->SetTurnPoint(m_ptResult);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TWellDimEdJig::entity() const
|
||
{
|
||
return (AcDbEntity *)m_pDrawEnt;
|
||
}
|
||
|
||
// cet 2011.8.25 add
|
||
void WellDim()
|
||
{
|
||
Entity entStartWell;
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
CString csPrompt;
|
||
XPoint ptLoc, ptTurn;
|
||
TPipeSys::SysType sys = TPipeSys::kUnknownSys;
|
||
//从注册表中读取井标注类型
|
||
int nCurWellDimType = 0;
|
||
//CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
||
//regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
||
//regProp.GetValue(_T("CurWellDimType"), nCurWellDimType);
|
||
|
||
while (1) {
|
||
int ret(0);
|
||
TCHAR cRet = _T('\0');
|
||
XPoint pt;
|
||
INITGET_BEG(0, _T("M S"));
|
||
ret = GlobalFunc::SelectEntity(_T("\n请选择要标注的井[多选,参考上次标注(M)/设置(S)]:<退出>"), entStartWell, pt, rbMask, _T("M S"), cRet);
|
||
INITGET_END();
|
||
#if (ARX == 19)
|
||
if (cRet == _T('\0'))
|
||
{
|
||
TCHAR szCh[20];
|
||
acedGetInput(szCh);
|
||
cRet = szCh[0];
|
||
}
|
||
#endif
|
||
if (ret == RTKWORD) {
|
||
if (cRet == _T('M'))
|
||
{
|
||
MutiWellDim(g_Option::instance().g_iDimWellEleLeadAngle, true);
|
||
cRet = _T('\0');
|
||
break;
|
||
}
|
||
else if (cRet == _T('S')) // 选择井标注样式
|
||
{
|
||
//获取井标注样式
|
||
CTemporaryResourceOverride vTemp;
|
||
CWellDimEditDlg dlg;
|
||
dlg.SetWellDimType(nCurWellDimType);
|
||
if (dlg.DoModal() == IDOK)
|
||
{
|
||
nCurWellDimType = dlg.GetSelWellDimType();
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
else if (ret != RTNORM)
|
||
{
|
||
cRet = _T('\0');
|
||
break;
|
||
}
|
||
AcDbObjectId id = NULL;
|
||
int num(0);
|
||
double nEle(0), nEle2(0);
|
||
acdbGetObjectId(id, entStartWell);
|
||
BOOL bIsDim = TRUE;
|
||
CString sWellLayer;
|
||
OPENOBJ_BEGIN(entStartWell, AcDb::kForRead, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
nEle = pEquip->GetWellEleUp();
|
||
nEle2 = pEquip->GetWellEleDown();
|
||
bIsDim = pEquip->IsDrawLabel();
|
||
ptLoc = pEquip->GetLocation();
|
||
num = pEquip->GetInterfaceNum();
|
||
sWellLayer = pEquip->layer();
|
||
if (num > 0) {
|
||
CPipeInterface face;
|
||
pEquip->GetInterface(0, face);
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, CDbPipe, pPipe);
|
||
if (pPipe) {
|
||
sys = pPipe->GetSysType();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
csPrompt.Format(_T("\n请给出井面地面标高:<%.2f米>"), nEle);
|
||
ads_getreal(csPrompt, &nEle);
|
||
CString csEle;
|
||
csEle.Format(_T("%.2f"), nEle);
|
||
|
||
CString csEle2;
|
||
if (fabs(nEle2) > 0.001)
|
||
csPrompt.Format(_T("\n请给出井底标高:<%.2f米>"), nEle2);
|
||
else
|
||
csPrompt.Format(_T("\n请给出井底标高:<等计算完再标>"));
|
||
ads_getreal(csPrompt, &nEle2);
|
||
if (fabs(nEle2) > 0.001) {
|
||
csEle2.Format(_T("%.2f"), nEle2);
|
||
}
|
||
|
||
OPENOBJ_BEGIN(entStartWell, AcDb::kForWrite, AecXDbWell, pEquip);
|
||
if (pEquip) {
|
||
pEquip->SetWellEleUp(nEle);
|
||
pEquip->SetWellEleDown(nEle2);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
CString csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
// zxl 2013.06.20 add 无管线连井时,通过井图层获取标注图层
|
||
if (csLay.IsEmpty())
|
||
{
|
||
if (sWellLayer.Compare(LAY_WELL_FEED) == 0)
|
||
sys = TPipeSys::kFeedWater;
|
||
else if (sWellLayer.Compare(LAY_WELL_DIRT) == 0)
|
||
sys = TPipeSys::kDirtWater;
|
||
else if (sWellLayer.Compare(LAY_WELL_USELESS) == 0)
|
||
sys = TPipeSys::kUselessWater;
|
||
else if (sWellLayer.Compare(LAY_WELL_RAIN) == 0)
|
||
sys = TPipeSys::kRainWater;
|
||
else if (sWellLayer.Compare(LAY_WELL_USED) == 0)
|
||
sys = TPipeSys::kUsedWater;
|
||
else if (sWellLayer.Compare(LAY_WELL_FIRE) == 0)
|
||
sys = TPipeSys::kFireFighting;
|
||
else if (sWellLayer.Compare(LAY_WELL_OTHER) == 0)
|
||
sys = TPipeSys::kOther;
|
||
|
||
csLay = GlobalFunc::GetDimLayBySys(sys);
|
||
}
|
||
InitLayer(csLay);
|
||
XPoint ptLocUcs = GlobalFunc::Wcs2Ucs(ptLoc);
|
||
|
||
CDbWellDim *pDim = new CDbWellDim;
|
||
pDim->SetDrawMode(nCurWellDimType);
|
||
|
||
pDim->SetStartPoint(ptLoc);
|
||
pDim->SetTurnPoint(ptTurn);
|
||
pDim->AttachWell(id);
|
||
pDim->setLayer(csLay);
|
||
AcDbObjectId idTextStyle = GlobalFunc::InitTwtTextStyle(g_Option::instance().g_csDimWellStyle);
|
||
pDim->SetTextStyleId(idTextStyle);
|
||
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
||
pDim->SetTextHeight(g_Option::instance().g_nDimWellHeight);
|
||
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
||
pDim->SetLayoutRotation(GlobalFunc::Ucs2Wcs(0.0));
|
||
pDim->SetAlignType(g_Option::instance().g_nAlignTypeForWellDim);// zxl 2012.07.12 add 设置对其方式
|
||
|
||
TWellDimEdJig jig(pDim);
|
||
jig.SetPrompt(_T("\n点取井标注方向<退出>:"));
|
||
int nRet = jig.DoIt();
|
||
if (nRet == RTNORM) {
|
||
GlobalFunc::AddToCurrentSpace(pDim, Adesk::kTrue);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
if (pEnt) {
|
||
pEnt->setLayer(csLay);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
else
|
||
delete pDim;
|
||
}
|
||
|
||
//将井标注类型写入注册表
|
||
//regProp.SetValue(_T("CurWellDimType"), nCurWellDimType);
|
||
}
|
||
|
||
//***************************************************************************************************
|
||
// 井编号移动
|
||
//***************************************************************************************************
|
||
void MoveWellDimCmd()
|
||
{
|
||
GlobalFunc::DocGetPickFirst().Free();
|
||
RBList rbMask(RTDXF0, _T("AEC_ZT_WELL"), NULL);
|
||
PickSet ss(SS_FREE);
|
||
if (GlobalFunc::SelectEntities(_T("\n请选择需要移动编号的井: <退出>"), ss, rbMask) != RTNORM)
|
||
return;
|
||
long len = ss.Length();
|
||
if (len < 1)
|
||
return;
|
||
|
||
// cet 2010.9.9 add 根据井生成新的AecXDbText,用于动态预览
|
||
PickSet ssM(SS_FREE);
|
||
for (long j = 0; j < len; j++)
|
||
{
|
||
AcDbObjectId idWell;
|
||
acdbGetObjectId(idWell, ss[j]);
|
||
AecXDbWell *pWell = NULL;
|
||
acdbOpenObject(pWell, idWell, AcDb::kForWrite);
|
||
if (pWell != NULL)
|
||
{
|
||
AcDbVoidPtrArray arPtr;
|
||
pWell->explode(arPtr);
|
||
for (int i = 0; i < arPtr.length(); i++)
|
||
{
|
||
AcDbEntity *pEnt = (AcDbEntity*)(arPtr[i]);
|
||
AecXDbText *pText = AecXDbText::cast(pEnt);
|
||
if (pText != NULL)
|
||
{
|
||
GlobalFunc::AddToCurrentSpace(pText, Adesk::kFalse);
|
||
ads_name sName;
|
||
acdbGetAdsName(sName, pText->objectId());
|
||
Entity ent(sName);
|
||
ssM += ent;
|
||
pText->close();
|
||
continue;
|
||
}
|
||
delete pEnt;
|
||
pEnt = NULL;
|
||
}
|
||
pWell->close();
|
||
}
|
||
}
|
||
|
||
int iRet(0);
|
||
AcGeMatrix3d mat;
|
||
BOOL bReset = FALSE;
|
||
BOOL bResetUp = FALSE;
|
||
XPoint ptBase, ptMove;
|
||
|
||
if (ads_getpoint(NULL, _T("\n选择移动的参考点:<复位>"), ptBase) != RTNORM)
|
||
{
|
||
bReset = TRUE;
|
||
ssM.Erase(); // cet 2010.9.9 add
|
||
}
|
||
else
|
||
{
|
||
// cet 2010.9.9 modify 更改为动态预览样式
|
||
// if(ads_getpoint(ptBase, _T("\n选择移动的目标点<退出>"), ptMove) != RTNORM)
|
||
// return;
|
||
if (GlobalFunc::DragMovePickSet(ssM, _T("\n选择移动的目标点<退出>"), ptBase, ptMove) != RTNORM)
|
||
{
|
||
ssM.Erase();
|
||
return;
|
||
}
|
||
ssM.Erase();
|
||
|
||
ptBase = GlobalFunc::Ucs2Wcs(ptBase);
|
||
ptMove = GlobalFunc::Ucs2Wcs(ptMove);
|
||
AcGeVector3d vt(ptMove - ptBase);
|
||
mat.setToTranslation(vt);
|
||
}
|
||
|
||
|
||
for (long i = 0; i < len; i++)
|
||
{
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AecXDbWell, pWell);
|
||
if (pWell) {
|
||
|
||
|
||
XPoint ptLoc = pWell->GetLabelLocation();
|
||
if (pWell->IsDrawLabel())
|
||
{
|
||
if (bReset)
|
||
{
|
||
XPoint ptLable;
|
||
XPoint ptLoc = pWell->GetLocation();
|
||
double Len = pWell->GetScale() * pWell->GetPScale();
|
||
double nLenText = Len / 2 * 1.5;
|
||
ads_polar(ptLoc, PI / 2, nLenText, ptLable);
|
||
pWell->SetLabelLocation(ptLable);
|
||
|
||
// AcGePoint3d pt1 = ptLoc;
|
||
// AcGePoint3d pt2;
|
||
// pWell->getClosestPointTo(pt1, pt2);
|
||
// double dRotation=0;
|
||
// XPoint ptMid = pPipe->MidPoint();
|
||
// dRotation = pPipe->OrthoDirection(ptMid);
|
||
// dRotation = CT_std_angle(dRotation);
|
||
// if(fabs(dRotation) < 1e-6)
|
||
// dRotation = 0;
|
||
// if(fabs(dRotation - PI) < 1e-5)
|
||
// dRotation = PI;
|
||
// if(!(dRotation>0 && dRotation<=PI)) {
|
||
// dRotation = CT_std_angle(dRotation+PI);
|
||
// }
|
||
// double nScale = pPipe->GetPScale();
|
||
// XPoint ptNear = pt2;
|
||
// if(bResetUp)
|
||
// ads_polar(ptNear,dRotation,g_nDnDimDist2Pipe*nScale,ptLoc);
|
||
// else
|
||
// ads_polar(ptNear,dRotation,-g_nDnDimDist2Pipe*nScale,ptLoc);
|
||
//
|
||
// pWell->SetLabelLocation(ptLoc);
|
||
}
|
||
else
|
||
{
|
||
ptLoc.TransformBy(mat);
|
||
pWell->SetLabelLocation(ptLoc);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|