1038 lines
24 KiB
C++
1038 lines
24 KiB
C++
#include "StdAfx.h"
|
|
#include "aecPipeJig.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "AecPipeline.h"
|
|
#include "AECStatusRecord.h"
|
|
#include "AecAngleWatch.h"
|
|
#include "ReducerDlg.h"
|
|
#include "ChangElDlg.h"
|
|
#include "TJXGDlg.h"
|
|
#include "RadioDlg.h"
|
|
#include "KTCADSysVar.h"
|
|
#include "DJGXDlg.h"
|
|
#include "coretools.h"
|
|
|
|
TDbPipeJig::TDbPipeJig()
|
|
{
|
|
m_pPipeLine = new TDbPipeLine(this);
|
|
m_tStartIntf.vtDir = AcGeVector3d::kIdentity;
|
|
m_tStartIntf.ptPos = AcGePoint3d::kOrigin;
|
|
m_vtStaDir.set(0.0,0.0,0.0);
|
|
InitStatusRecs();
|
|
m_nUndoGoupid = 0;
|
|
m_sSystem = _T("");
|
|
}
|
|
|
|
TDbPipeJig::~TDbPipeJig(void)
|
|
{
|
|
if (m_pPipeLine != NULL)
|
|
DELETE_PTR(m_pPipeLine);
|
|
acutPrintf(_T("\n"));
|
|
|
|
if (HasWipeClip())
|
|
{
|
|
acedPostCommand(_T("regen "));
|
|
}
|
|
}
|
|
|
|
void TDbPipeJig::SetAdoDb(CUIISQLiteServer* pDb)
|
|
{
|
|
m_pDb = pDb;
|
|
}
|
|
|
|
CUIISQLiteServer* TDbPipeJig::GetAdoDb()
|
|
{
|
|
return m_pDb;
|
|
}
|
|
|
|
void TDbPipeJig::SetInitDataMapPartFrom(AecDbObjXDataMap* pXDataMap)
|
|
{
|
|
if (m_pPipeLine != NULL)
|
|
{
|
|
m_pPipeLine->SetInitDataMapPartFrom(pXDataMap);
|
|
}
|
|
}
|
|
|
|
bool TDbPipeJig::HasWipeClip()
|
|
{
|
|
if (m_pPipeLine != NULL)
|
|
{
|
|
m_pPipeLine->HasWipeClip();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void TDbPipeJig::SetAngleWath(AcGePoint3d& ptCen,const AcGePoint3d& ptGeTo,const AcGeVector3d& vtDir)
|
|
{
|
|
((TDbPipeLine *)m_pPipeLine)->SetAngleWath(ptCen,ptGeTo,vtDir);
|
|
}
|
|
|
|
void TDbPipeJig::CalReferencePoint()
|
|
{
|
|
AcGePoint3d ptWcs;
|
|
ads_point ptBase,pt22,pt33;
|
|
|
|
acedInitGet(RSG_NONULL,_T("R"));
|
|
int nRes = acedGetPoint(NULL,_T("\n指定起点或[参考点(R)]<退出>:"),ptBase);
|
|
switch(nRes)
|
|
{
|
|
case RTNORM:
|
|
{
|
|
acdbUcs2Wcs(ptBase,pt22,false);
|
|
ptWcs = asPnt3d(pt22);
|
|
ptWcs.z = ((TDbPipeLine*)m_pPipeLine)->GetEndElevation();
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
break;
|
|
}
|
|
case RTKWORD:
|
|
{
|
|
TCHAR szKey[2];
|
|
szKey[0] = '0';
|
|
acedGetInput(szKey);
|
|
|
|
switch(szKey[0])
|
|
{
|
|
case _T('R'):
|
|
case _T('r'):
|
|
{
|
|
//参考点<退出>:
|
|
nRes = acedGetPoint(NULL,_T("\n参考点<退出>:"),ptBase);
|
|
if (nRes == RTNORM)
|
|
{
|
|
//起点<退出>:
|
|
nRes = acedGetPoint(ptBase,_T("\n指定起点<退出>:"),pt22);
|
|
if (nRes == RTNORM)
|
|
{
|
|
acdbUcs2Wcs(pt22,pt33,false);
|
|
ptWcs = asPnt3d(pt33);
|
|
ptWcs.z = ((TDbPipeLine*)m_pPipeLine)->GetEndElevation();
|
|
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbPipeJig::SetReferencePoint(const AcGePoint3d& ptRef)
|
|
{
|
|
AcGePoint3d ptWcs = ptRef;
|
|
ptWcs.z = ((TDbPipeLine*)m_pPipeLine)->GetEndElevation();
|
|
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoIt(WPipe::EApp app, const AcGePoint3d& ptRef,BOOL bParamDlg/* = TRUE*/)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (bParamDlg)
|
|
{
|
|
CDJGXDlg drawCnfgDLg;
|
|
drawCnfgDLg.SetDbServer(m_pDb);
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
drawCnfgDLg.setApp(app);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
WPipe::PipeParam param;
|
|
memset(¶m,0,sizeof(WPipe::PipeParam));
|
|
param.m_app = app;
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((TDbPipeLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
|
|
SetReferencePoint(ptRef);
|
|
|
|
return DoDrag();
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoIt(WPipe::EApp app, BOOL bParamDlg,BOOL bCalRefPoint)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (bParamDlg)
|
|
{
|
|
CDJGXDlg drawCnfgDLg;
|
|
drawCnfgDLg.SetDbServer(m_pDb);
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
drawCnfgDLg.setApp(app);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
WPipe::PipeParam param;
|
|
memset(¶m,0,sizeof(WPipe::PipeParam));
|
|
param.m_app = app;
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((TDbPipeLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
|
|
//参考
|
|
if (bCalRefPoint)
|
|
{
|
|
CalReferencePoint();
|
|
}
|
|
|
|
return DoDrag();
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoDrag()
|
|
{
|
|
AcEdJig::DragStatus eStat;
|
|
int nPlanPos = 0;
|
|
|
|
while(TRUE)
|
|
{
|
|
CString sPrompt = m_pCurStaRec->Prompt();
|
|
SetDispPromptWithEleTip(sPrompt);
|
|
setDispPrompt(sPrompt);
|
|
|
|
if (((TDbPipeLine*)m_pPipeLine)->PipeFinished())
|
|
{
|
|
break;
|
|
}
|
|
|
|
eStat = drag();
|
|
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
switch(eStat)
|
|
{
|
|
case AcEdJig::kNormal:
|
|
{
|
|
if (nPlanPos == 1) //Create Pipe
|
|
{
|
|
AfterDrag();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kCancel:
|
|
case AcEdJig::kNull:// 退出
|
|
{
|
|
acutPrintf(_T("\n"));
|
|
return FALSE;
|
|
}
|
|
case AcEdJig::kKW1://R 变径
|
|
{
|
|
//至少创建了一个管段
|
|
if (((TDbPipeLine*)m_pPipeLine)->GetLastInterface() == NULL)
|
|
{
|
|
acutPrintf(_T("\n之前没有创建管段,无法变径!"));
|
|
continue;
|
|
}
|
|
|
|
AcGeVector3d vtDir;
|
|
AecInterface* pIntf = ((TDbPipeLine*)m_pPipeLine)->GetLastInterface();
|
|
if (pIntf == NULL)
|
|
vtDir = AcGeVector3d::kXAxis;
|
|
else
|
|
vtDir = pIntf->vtDir;
|
|
|
|
CReducerDlg redDLg;
|
|
WPipe::PipeParam param;
|
|
memset(¶m,0,sizeof(WPipe::PipeParam));
|
|
memcpy(¶m,((TDbPipeLine*)m_pPipeLine)->GetPipeParam(),sizeof(WPipe::PipeParam));
|
|
param.m_vtECCen.set(0.0,0.0,0.0);
|
|
|
|
if (CoreTools::IsMetersUnit())
|
|
{
|
|
param.m_dD *= 1000;
|
|
param.m_dDN *= 1000;
|
|
param.m_dOD *= 1000;
|
|
}
|
|
|
|
redDLg.Set(m_pDb,¶m,vtDir);
|
|
int nRes = redDLg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
if (CoreTools::IsMetersUnit())
|
|
{
|
|
param.m_dD *= 0.001;
|
|
param.m_dDN *= 0.001;
|
|
param.m_dOD *= 0.001;
|
|
param.m_dInterfaceL3 *= 0.001;
|
|
}
|
|
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
if ( ( (TDbPipeLine *)m_pPipeLine)->AddReducer(m_pCurStaRec,¶m) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW2://E 标高
|
|
{
|
|
CChangElDlg chelDlg;
|
|
|
|
//至少创建了一个管段
|
|
AecInterface* pLastInf = ((TDbPipeLine*)m_pPipeLine)->GetLastInterface();
|
|
if (pLastInf == NULL)
|
|
{
|
|
//可以改为仅仅改标高对话框,当没有状态记录时
|
|
//acutPrintf(_T("\n之前没有创建管段,无法变标高!"));
|
|
|
|
//当前位置选择到实体的话,更新标高
|
|
double dEl = ((TDbPipeLine*)m_pPipeLine)->GetPipeParam()->m_dEl;
|
|
AECStatusRecord* pRec = GetTailStatusRec();
|
|
dEl = PickWPipehereEl(pRec->GetAcquirePoint());
|
|
((TDbPipeLine*)m_pPipeLine)->GetPipeParam()->m_dEl = dEl;
|
|
|
|
//弹出标高对话框,创建立管,如果选择位置有三通,则三通连接
|
|
chelDlg.SetCurParam(m_pDb,((TDbPipeLine*)m_pPipeLine)->GetPipeParam());
|
|
int nRes = chelDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
//原位置 的改标高
|
|
m_pCurStaRec->SetAcquirePoint(pRec->GetAcquirePoint());
|
|
if ( ( (TDbPipeLine *)m_pPipeLine)->ChangeEl2(m_pCurStaRec,pRec,chelDlg.m_dNewEl,
|
|
chelDlg.m_bCheckRec,chelDlg.m_dRedElPos,&chelDlg.m_pipeParamRec ) )
|
|
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
continue;
|
|
}
|
|
/*else
|
|
{
|
|
if ( pLastInf->vtDir.isParallelTo(AcGeVector3d::kZAxis) )
|
|
{
|
|
acutPrintf(_T("\n上段已经是立管,本次添加立管失败!"));
|
|
continue;
|
|
}
|
|
}*/
|
|
|
|
//标高的变化
|
|
chelDlg.SetCurParam(m_pDb,((TDbPipeLine*)m_pPipeLine)->GetPipeParam());
|
|
if (pLastInf != NULL)
|
|
{
|
|
if ( pLastInf->vtDir.isParallelTo(AcGeVector3d::kZAxis) )
|
|
{
|
|
chelDlg.m_dCurEl = pLastInf->ptPos.z;
|
|
}
|
|
}
|
|
|
|
int nRes = chelDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
if ( ( (TDbPipeLine *)m_pPipeLine)->ChangeEl(m_pCurStaRec,chelDlg.m_dNewEl,chelDlg.m_bCheckRec,chelDlg.m_dRedElPos,&chelDlg.m_pipeParamRec ) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW3://U 回退 X 斜管
|
|
{
|
|
//至少创建了一个管段
|
|
AECStatusRecord* pLast = GetTailStatusRec();
|
|
if ( pLast == NULL)
|
|
{
|
|
acutPrintf(_T("\n之前没有拾取位置点!请先拾取第一点!"));
|
|
continue;
|
|
}
|
|
|
|
//添加斜管
|
|
CTJXGDlg dlg;
|
|
dlg.m_dLastEl = ((TDbPipeLine*)m_pPipeLine)->GetPipeParam()->m_dEl;
|
|
|
|
int nRes = dlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
if ( fabs(dlg.m_dNewEl - dlg.m_dLastEl) < 1.e-6 && dlg.m_bElType == 0)//同标高
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
AcGePoint3d ptLast = pLast->GetAcquirePoint();
|
|
|
|
//选择下一点
|
|
ads_point pt,pt2,pt3;
|
|
acdbWcs2Ucs(asDblArray(ptLast),pt,false);
|
|
nRes = acedGetPoint(pt,_T("\n指定下一点(或直接输入管线真实长度):"),pt2);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcGePoint3d ptThis;
|
|
acdbUcs2Wcs(pt2,pt3,false);
|
|
ptThis = asPnt3d(pt3);
|
|
|
|
// 如果userstring不为空,说明用户输入的是管线长度
|
|
// 重新计算pt2
|
|
TCHAR userstring[511] = {};
|
|
acedGetInput(userstring);
|
|
CString sInput(userstring);
|
|
if (!sInput.IsEmpty())
|
|
{
|
|
AcGePoint2d ptX1(ptLast.x,ptLast.y);
|
|
AcGePoint2d ptX2(ptThis.x,ptThis.y);
|
|
double dL(ptX1.distanceTo(ptX2));
|
|
double dAngle(.0);
|
|
if (dlg.m_bElType) // 坡度
|
|
dAngle = atan(dlg.m_dPD * .01);
|
|
else
|
|
dAngle = asin(abs(dlg.m_dLastEl - dlg.m_dNewEl) / dL);
|
|
|
|
AcGeVector3d vt(ptThis - ptLast);
|
|
vt.normalize();
|
|
ptThis = ptLast + vt * (dL * cos(dAngle));
|
|
}
|
|
|
|
if (dlg.m_bElType)//坡度
|
|
{
|
|
AcGePoint2d ptX1(ptLast.x,ptLast.y);
|
|
AcGePoint2d ptX2(ptThis.x,ptThis.y);
|
|
double dLX = ptX1.distanceTo(ptX2);
|
|
dlg.m_dNewEl = ptLast.z + dlg.m_dPD * dLX * 0.01;//新的标高增量
|
|
}
|
|
|
|
ptThis.z = dlg.m_dNewEl;
|
|
|
|
if (((TDbPipeLine *)m_pPipeLine)->ChangeEl3(m_pCurStaRec,ptThis))
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetAcquirePoint(ptThis);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
}
|
|
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW4://O 曲率
|
|
{
|
|
//弹出界面修改当前曲率半径
|
|
CRadioDlg rDlg;
|
|
rDlg.SetDbServer(m_pDb);
|
|
rDlg.SetShowParam(m_pPipeLine->GetPipeParam());
|
|
rDlg.DoModal();
|
|
|
|
break;
|
|
}
|
|
case AcEdJig::kKW5://U 回退
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() > 1)
|
|
{
|
|
SHacedCommand(RTSTR,_T("u"),RTNONE);
|
|
PopUpStatusRec();
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW6://表盘精度
|
|
{
|
|
double nSp = 10;
|
|
TCHAR szPrompt[65];
|
|
_stprintf(szPrompt, _T("\n请输入角度表盘刻度精度(0-30]度:<%.1f>"), ((TDbPipeLine *)m_pPipeLine)->GetAngWatchSp());
|
|
int nRes = acedGetReal(szPrompt,&nSp);
|
|
if (nRes == RTNORM)
|
|
{
|
|
if (nSp > 0 && nSp < 31)
|
|
{
|
|
((TDbPipeLine *)m_pPipeLine)->SetAngWatchSp(nSp);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//获取下个状态,plane判断是?
|
|
if (m_pCurStaRec->GetPlanPosition() == 0 )
|
|
{
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TDbPipeJig::AfterDrag()
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("BE"), RTNONE);
|
|
SetUndoGroupBegin();
|
|
if (((TDbPipeLine *)m_pPipeLine)->AddPipeNode(m_pCurStaRec, WPipe::eToCreate))
|
|
{
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
((TDbPipeLine *)m_pPipeLine)->PipeFinished();
|
|
return FALSE;
|
|
}
|
|
m_vtStaDir.set(0, 0, 0);//reset
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoItOnPath(WPipe::EApp app, const AcGePoint3dArray &arPts, WPipe::PipeParam* pParam)
|
|
{
|
|
WPipe::PipeParam param;
|
|
memset(¶m, 0, sizeof(WPipe::PipeParam));
|
|
|
|
if (pParam == NULL)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CDJGXDlg drawCnfgDLg;
|
|
drawCnfgDLg.SetDbServer(m_pDb);
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
drawCnfgDLg.setApp(app);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
param.m_app = app;
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
}
|
|
else
|
|
{
|
|
memcpy(¶m, pParam, sizeof(WPipe::PipeParam));
|
|
}
|
|
|
|
((TDbPipeLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
//关闭提示
|
|
KTCADSysVar<int> var1(_T("CMDECHO"), 0);
|
|
|
|
int nPlanPos = 0;
|
|
AcGePoint3d ptGe;
|
|
for (int i = 0; i < arPts.length(); i++)
|
|
{
|
|
ptGe = arPts.at(i);
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
if (nPlanPos == 1) //Create Pipe
|
|
{
|
|
AfterDrag();
|
|
}
|
|
|
|
//获取下个状态,plane判断是?
|
|
if (m_pCurStaRec->GetPlanPosition() == 0)
|
|
{
|
|
AECStatusRecord *pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
static double FormatZero(double dVal)
|
|
{
|
|
if ( fabs(dVal) < 1.e-6 )
|
|
return 0.0;
|
|
|
|
int nVal = (int)(dVal * 1000.0);
|
|
return nVal / 1000.0;
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoIt(AecInterface* pIntf,WPipe::PipeParam* pParam)
|
|
{
|
|
if (pIntf == NULL) return FALSE;
|
|
|
|
if (pParam == NULL) //用户确定壁厚和外径 etc.
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
CDJGXDlg drawCnfgDLg;
|
|
drawCnfgDLg.SetDbServer(m_pDb);
|
|
|
|
double dSize(pIntf->dSize1),dSize1(pIntf->dSize2);
|
|
//pIntf->GetSize(dSize,dSize1);
|
|
|
|
drawCnfgDLg.SetOnlyByDN( (int)dSize );
|
|
drawCnfgDLg.SetEleReadOnly(TRUE,FormatZero(pIntf->ptPos.z));//圆整
|
|
drawCnfgDLg.m_sCurrSys = m_sSystem;
|
|
drawCnfgDLg.m_nConnectType = pIntf->nConnectType;
|
|
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
WPipe::PipeParam param;
|
|
memset(¶m,0,sizeof(WPipe::PipeParam));
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
param.m_dEl = pIntf->ptPos.z;//标高确定不变
|
|
//param.m_app = pParam->m_app;
|
|
param.m_app = WPipe::eButtweld;
|
|
((TDbPipeLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
((TDbPipeLine*)m_pPipeLine)->SetPipeParam(pParam);
|
|
}
|
|
|
|
//压入本次接口
|
|
if ( /*pParam != NULL &&*/ pIntf->idOwner.isValid())
|
|
{
|
|
((TDbPipeLine*)m_pPipeLine)->PushInterface(*pIntf,TRUE);
|
|
}
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(pIntf->ptPos);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
//((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
((TDbPipeLine *)m_pPipeLine)->SetAngleWath(pIntf->ptPos,pRec->GetAcquirePoint(),pIntf->vtDir);
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
|
|
//开始JIG
|
|
WPipe::EApp app(WPipe::eButtweld);
|
|
if (pParam)
|
|
app = pParam->m_app;
|
|
|
|
return DoIt(app, FALSE,FALSE);
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoItSpec(WPipe::EApp app, BOOL bParamDlg,BOOL bCalRefPoint)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (bParamDlg)
|
|
{
|
|
CDJGXDlg drawCnfgDLg;
|
|
drawCnfgDLg.SetDbServer(m_pDb);
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
drawCnfgDLg.setApp(app);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
WPipe::PipeParam param;
|
|
memset(¶m,0,sizeof(WPipe::PipeParam));
|
|
param.m_app = app;
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((TDbPipeLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
|
|
//参考
|
|
if (bCalRefPoint)
|
|
{
|
|
CalReferencePoint();
|
|
}
|
|
return DoDrag();
|
|
}
|
|
|
|
BOOL TDbPipeJig::DoItNotPipe(WPipe::EApp app, BOOL bParamDlg)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AcEdJig::DragStatus TDbPipeJig::sampler()
|
|
{
|
|
setUserInputControls( ( UserInputControls)
|
|
( AcEdJig::kAccept3dCoordinates |
|
|
AcEdJig::kNullResponseAccepted ) );
|
|
|
|
CString sKeywordsList;
|
|
sKeywordsList = m_pCurStaRec->KeywordList();
|
|
if (!sKeywordsList.IsEmpty())
|
|
{
|
|
setKeywordList(sKeywordsList);
|
|
}
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
AcGePoint3d ptGe,ptGeBase,ptGe2,ptBk;
|
|
ptGeBase = AcGePoint3d::kOrigin;
|
|
|
|
AECStatusRecord::EAcquire eAcquire = m_pCurStaRec->GetStatusType();
|
|
switch(eAcquire)
|
|
{
|
|
case AECStatusRecord::kPoint:
|
|
{
|
|
m_pPipeLine->SwitchAutoSnapOrF8();
|
|
|
|
//开始状态
|
|
int nPos = m_pCurStaRec->GetPlanPosition();
|
|
if (nPos == 0)
|
|
{
|
|
eStat = acquirePoint(ptGe);
|
|
|
|
//动态获取的点的标高始终和上次一致
|
|
ptGe.z = ((TDbPipeLine*)m_pPipeLine)->GetEndElevation();
|
|
}
|
|
else
|
|
{
|
|
//管线的末端点
|
|
GetLastStatusAquire(ptGeBase);
|
|
eStat = acquirePoint(ptGe,ptGeBase);
|
|
ptGe.z = ((TDbPipeLine*)m_pPipeLine)->GetEndElevation();
|
|
|
|
double dDist = ptGeBase.distanceTo(ptGe);
|
|
if (!m_vtStaDir.isZeroLength())
|
|
{
|
|
m_vtStaDir.normalize();
|
|
ptGe = ptGeBase + dDist * m_vtStaDir;
|
|
}
|
|
}
|
|
|
|
if (eStat == AcEdJig::kNormal)
|
|
{
|
|
if (m_pCurStaRec->IsValSeted())
|
|
{
|
|
ptGe2 = m_pCurStaRec->GetAcquirePoint();
|
|
double dDis = ptGe2.distanceTo(ptGe);
|
|
if (dDis < 1.e-6)
|
|
{
|
|
//鼠标原地不动
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
}
|
|
|
|
ptGe2 = m_pCurStaRec->GetAcquirePoint();
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
((TDbPipeLine *)m_pPipeLine)->AngWatchTo(ptGe);
|
|
|
|
ptBk = ptGe;
|
|
if (m_pCurStaRec->GetPlanPosition() > 0 && m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
((TDbPipeLine *)m_pPipeLine)->AddPipeNode(m_pCurStaRec,WPipe::eToPreView);
|
|
//if (AecAngleWatch::m_bFallInSnap )
|
|
//{
|
|
ptGe = m_pCurStaRec->GetAcquirePoint();
|
|
if (ptGe.distanceTo(ptGe2) < 1.e-6)
|
|
{
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
//}
|
|
m_pCurStaRec->SetAcquirePoint(ptBk);
|
|
return AcEdJig::kNormal;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return eStat;
|
|
}
|
|
|
|
AcDbEntity* TDbPipeJig::entity() const
|
|
{
|
|
return m_pPipeLine;
|
|
}
|
|
|
|
Adesk::Boolean TDbPipeJig::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
void TDbPipeJig::InitStatusRecs()
|
|
{
|
|
//1.起端为管子的状态
|
|
AECStatusRecord* pRec1 = NULL;
|
|
pRec1 = new AECStatusRecord;
|
|
m_arStaPtrs.Add(pRec1);
|
|
pRec1->SetPrompt(_T("\n指定起点<退出>:"));
|
|
pRec1->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec1->SetPlanPosition(0);
|
|
|
|
AECStatusRecord* pRec2 = NULL;
|
|
pRec2 = new AECStatusRecord;
|
|
m_arStaPtrs.Add(pRec2);
|
|
|
|
pRec2->SetPrompt(_T("\n指定下一点或 [变径(R)/立管(E)/斜管(X)/曲率(O)/回退(U)/表盘(B)<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("R E X O U B"));
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
pRec2->SetNextStatus(pRec2,1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void TDbPipeJig::FreeStatusRecs()
|
|
{
|
|
AECStatusRecord* pRecord = NULL;
|
|
|
|
int nSize = m_arStaPtrs.GetSize();
|
|
for(int i = 0;i < nSize;i++)
|
|
{
|
|
pRecord = (AECStatusRecord*)m_arStaPtrs.GetAt(i);
|
|
if (pRecord != NULL) DELETE_PTR(pRecord);
|
|
}
|
|
m_arStaPtrs.RemoveAll();
|
|
|
|
for(POSITION ps = m_lstStaPtrsBack.GetHeadPosition();ps != NULL;)
|
|
{
|
|
pRecord = (AECStatusRecord*)m_lstStaPtrsBack.GetNext(ps);
|
|
if (pRecord != NULL) DELETE_PTR(pRecord);
|
|
}
|
|
m_lstStaPtrsBack.RemoveAll();
|
|
}
|
|
|
|
BOOL TDbPipeJig::GetLastStatusAquire(AcGePoint3d& ptGe)
|
|
{
|
|
int nSize = m_lstStaPtrsBack.GetCount();
|
|
if (nSize > 0)
|
|
{
|
|
AECStatusRecord* pRec = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
if (pRec != NULL)
|
|
ptGe = pRec->GetAcquirePoint();
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
AECStatusRecord* TDbPipeJig::GetTailStatusRec()
|
|
{
|
|
int nSize = m_lstStaPtrsBack.GetCount();
|
|
if (nSize > 0)
|
|
{
|
|
return (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void TDbPipeJig::PushBackStatusRec(AECStatusRecord* pRec)
|
|
{
|
|
pRec->SetUndoGroupId(m_nUndoGoupid);
|
|
m_lstStaPtrsBack.AddTail(pRec);
|
|
}
|
|
|
|
void TDbPipeJig::SetUndoGroupBegin()
|
|
{
|
|
m_nUndoGoupid += 1;
|
|
}
|
|
|
|
void TDbPipeJig::SetUndoGroupEnd()
|
|
{
|
|
((TDbPipeLine *)m_pPipeLine)->PushPipeParam();
|
|
}
|
|
|
|
int TDbPipeJig::GetUndoGroupID()
|
|
{
|
|
return m_nUndoGoupid;
|
|
}
|
|
|
|
void TDbPipeJig::PopUpStatusRec()
|
|
{
|
|
//按 id 回退一次,调整当前状态
|
|
if (m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
AECStatusRecord* pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
int nID = pLast->GetUndoGroupId();
|
|
while(m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
m_lstStaPtrsBack.RemoveTail();
|
|
|
|
DELETE_PTR(pLast);
|
|
pLast = NULL;
|
|
if (m_lstStaPtrsBack.GetCount() == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
pLast = (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
if (nID != pLast->GetUndoGroupId())
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//pipeline 回退一次,调整接口记录
|
|
((TDbPipeLine *)m_pPipeLine)->PopUpInterface(nID);
|
|
((TDbPipeLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
}
|
|
|
|
void TDbPipeJig::SetDispPromptWithEleTip(CString& sPrompt)
|
|
{
|
|
CString sEl;
|
|
if (m_pCurStaRec != NULL)
|
|
{
|
|
sEl.Format(_T("(当前标高:%g)"),m_pCurStaRec->GetAcquirePoint().z);
|
|
|
|
int nIndex = sPrompt.ReverseFind(_T(':'));
|
|
if (nIndex != -1)
|
|
{
|
|
sPrompt.Insert(nIndex,sEl);
|
|
}
|
|
}
|
|
}
|
|
|
|
double TDbPipeJig::PickWPipehereEl(const AcGePoint3d& ptGe)
|
|
{
|
|
double dEl = ptGe.z;
|
|
|
|
ads_point pt[5];
|
|
double dSize = CoreTools::PixelToWcs(5);//5
|
|
|
|
AcGePoint3d ptGeX[5];
|
|
ptGeX[0] = ptGe;
|
|
ptGeX[0] -= dSize * AcGeVector3d::kYAxis;
|
|
ptGeX[0] -= dSize * AcGeVector3d::kXAxis;
|
|
|
|
ptGeX[1] = ptGeX[0] + 2 * dSize * AcGeVector3d::kYAxis;
|
|
ptGeX[2] = ptGeX[1] + 2 * dSize * AcGeVector3d::kXAxis;
|
|
ptGeX[3] = ptGeX[0] + 2 * dSize * AcGeVector3d::kXAxis;
|
|
ptGeX[4] = ptGeX[0];
|
|
|
|
for (int i = 0;i < 5;i++)
|
|
{
|
|
acdbWcs2Ucs(asDblArray(ptGeX[i]),pt[i],false);
|
|
}
|
|
|
|
TCHAR szBuf[64];
|
|
memset(szBuf,0,sizeof(szBuf));
|
|
_tcscpy(szBuf, _T("AEC_EWPIPE"));
|
|
|
|
struct resbuf rb;
|
|
rb.restype = 0;
|
|
rb.resval.rstring = szBuf;
|
|
rb.rbnext = NULL;
|
|
|
|
struct resbuf* pointlist;
|
|
pointlist = acutBuildList(RTPOINT, pt[0], RTPOINT, pt[1],
|
|
RTPOINT, pt[2], RTPOINT, pt[3], 0);
|
|
|
|
ads_name ss,ent;
|
|
acedSSGet(_T("CP"),pointlist,NULL,&rb,ss);
|
|
acutRelRb(pointlist);
|
|
|
|
Adesk::Int32 lLen = 0;
|
|
acedSSLength(ss,&lLen);
|
|
|
|
AcDbObjectId id;
|
|
AcGePoint3d ptOn;
|
|
if (lLen > 0)
|
|
{
|
|
acedSSName(ss,0,ent);
|
|
acdbGetObjectId(id,ent);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) )
|
|
{
|
|
AecDbEwPipe* pWPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pWPipe != NULL)
|
|
{
|
|
dEl = pWPipe->EndPoint().z;
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
acedSSFree(ss);
|
|
return dEl;
|
|
}
|