1071 lines
25 KiB
C++
1071 lines
25 KiB
C++
#include "stdafx.h"
|
|
#include "AECStatusRecord.h"
|
|
#include "AecDbECableJig.h"
|
|
#include "ECableParamDlg.h"
|
|
#include "AecDbECableLine.h"
|
|
#include "ReducerDlg.h"
|
|
#include "ChangElDlg.h"
|
|
#include "TJXGDlg.h"
|
|
#include "AecDbECableLine.h"
|
|
#include "CoreTools.h"
|
|
#include "AecDbECableTray.h"
|
|
#include "HDLGDlg.h"
|
|
#include "KTCADSysVar.h"
|
|
|
|
|
|
static double FormatZero(double dVal)
|
|
{
|
|
if ( fabs(dVal) < 1.e-6 )
|
|
return 0.0;
|
|
|
|
int nVal = (int)(dVal * 1000.0);
|
|
return nVal / 1000.0;
|
|
}
|
|
|
|
AecDbECableJig::AecDbECableJig(void)
|
|
{
|
|
m_pPipeLine = new AecDbECableLine(this);
|
|
m_tStartIntf.vtDir = AcGeVector3d::kIdentity;
|
|
m_tStartIntf.ptPos = AcGePoint3d::kOrigin;
|
|
m_vtStaDir.set(0.0,0.0,0.0);
|
|
m_nUndoGoupid = 0;
|
|
m_pDb = NULL;
|
|
}
|
|
|
|
AecDbECableJig::AecDbECableJig(AecHvac::DuctParam* pParam)
|
|
{
|
|
m_pPipeLine = new AecDbECableLine(this);
|
|
m_pPipeLine->SetPipeParam(pParam);
|
|
m_tStartIntf.vtDir = AcGeVector3d::kIdentity;
|
|
m_tStartIntf.ptPos = AcGePoint3d::kOrigin;
|
|
m_vtStaDir.set(0.0,0.0,0.0);
|
|
m_nUndoGoupid = 0;
|
|
m_pDb = NULL;
|
|
}
|
|
|
|
AecDbECableJig::~AecDbECableJig(void)
|
|
{
|
|
if (m_pPipeLine != NULL)
|
|
delete m_pPipeLine;
|
|
}
|
|
|
|
void AecDbECableJig::InitStatusBRecs()
|
|
{
|
|
FreeStatusRecs();
|
|
//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)/回退(U)/参数(P)<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("R E X U P"));
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
pRec2->SetNextStatus(pRec2, 1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void AecDbECableJig::InitStatusTRecs()
|
|
{
|
|
FreeStatusRecs();
|
|
//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)/斜沟(X)/回退(U)/参数(P)]<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("R E X U P"));
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
pRec2->SetNextStatus(pRec2, 1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
//多层桥架
|
|
void AecDbECableJig::InitXYPlanStatusRecs()
|
|
{
|
|
FreeStatusRecs();
|
|
//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)/回退(U)]<退出>:"));
|
|
pRec2->SetStatusType(AECStatusRecord::kPoint);
|
|
pRec2->SetKeywordList(_T("R E X U"));
|
|
|
|
pRec1->SetNextStatus(pRec2);
|
|
pRec2->SetPlanPosition(1);
|
|
pRec2->SetNextStatus(pRec2,1);
|
|
m_pCurStaRec = pRec1;
|
|
}
|
|
|
|
void AecDbECableJig::SetAngleWath(AcGePoint3d& ptCen,const AcGePoint3d& ptGeTo,const AcGeVector3d& vtDir)
|
|
{
|
|
((AecDbECableLine *)m_pPipeLine)->SetAngleWath(ptCen,ptGeTo,vtDir);
|
|
}
|
|
|
|
void AecDbECableJig::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 = ((AecDbECableLine*)m_pPipeLine)->GetEndElevation();
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)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 = ((AecDbECableLine*)m_pPipeLine)->GetEndElevation();
|
|
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
m_pCurStaRec->SetAcquirePoint(ptWcs);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
default:
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL AecDbECableJig::DoIt(WPipe::EApp app, BOOL bParamDlg/* = TRUE*/,BOOL bCalRefPoint/* = TRUE*/)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (bParamDlg)
|
|
{
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
InitStatusBRecs();
|
|
|
|
CECableParamDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
InitStatusTRecs();
|
|
|
|
CHDLGDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
XHolder lHolder, rHolder;
|
|
if ( drawCnfgDLg.GetXHolder(lHolder, rHolder) )
|
|
((AecDbECableLine *)m_pPipeLine)->SetXHolder(lHolder, rHolder);
|
|
}
|
|
}
|
|
if (m_arStaPtrs.IsEmpty())
|
|
{
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
InitStatusBRecs();
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
InitStatusTRecs();
|
|
}
|
|
}
|
|
|
|
//参考
|
|
if (bCalRefPoint)
|
|
{
|
|
CalReferencePoint();
|
|
}
|
|
|
|
AcEdJig::DragStatus eStat;
|
|
int nPlanPos = 0,nRes = 0;
|
|
|
|
while(TRUE)
|
|
{
|
|
CString sPrompt = m_pCurStaRec->Prompt();
|
|
SetDispPromptWithEleTip(sPrompt);
|
|
setDispPrompt(sPrompt);
|
|
|
|
if (((AecDbECableLine*)m_pPipeLine)->PipeFinished())
|
|
{
|
|
break;
|
|
}
|
|
|
|
eStat = drag();
|
|
nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
|
|
switch(eStat)
|
|
{
|
|
case AcEdJig::kNormal:
|
|
{
|
|
if (nPlanPos == 1) //Create Pipe
|
|
{
|
|
if ( -1 != (nRes = AfterDrag()))
|
|
{
|
|
return nRes;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kCancel:
|
|
case AcEdJig::kNull:// 退出
|
|
{
|
|
acutPrintf(_T("\n"));
|
|
return FALSE;
|
|
}
|
|
case AcEdJig::kKW1://R 变径
|
|
{
|
|
//至少创建了一个管段
|
|
if (((AecDbECableLine*)m_pPipeLine)->GetLastInterface() == NULL)
|
|
{
|
|
acutPrintf(_T("\n之前没有创建管段,无法变径!"));
|
|
continue;
|
|
}
|
|
|
|
AcGeVector3d vtDir;
|
|
AecInterface* pIntf = ((AecDbECableLine*)m_pPipeLine)->GetLastInterface();
|
|
if (pIntf == NULL)
|
|
vtDir = AcGeVector3d::kXAxis;
|
|
else
|
|
vtDir = pIntf->vtDir;
|
|
|
|
CReducerDlg redDLg;
|
|
AecHvac::DuctParam param;
|
|
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
|
memcpy(¶m,((AecDbECableLine*)m_pPipeLine)->GetPipeParam(),sizeof(AecHvac::DuctParam));
|
|
param.dSize[3] = param.dSize[0];
|
|
|
|
redDLg.SetCurWidth(param.dSize[0],param.m_dRatio * param.dSize[0]);
|
|
|
|
int nRes = redDLg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
AcGePoint3d ptSize;
|
|
int nEcCen = redDLg.GetReducer(ptSize);
|
|
param.dSize[0] = ptSize.y;
|
|
param.m_dL = ptSize.z;
|
|
param.m_nEcCen = nEcCen;
|
|
|
|
if (app == WPipe::eTrench)
|
|
{
|
|
param.dSize[4] = ptSize.y;
|
|
}
|
|
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
if ( ( (AecDbECableLine *)m_pPipeLine)->AddReducer(m_pCurStaRec,¶m) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW2://E 标高
|
|
{
|
|
CChangElDlg chelDlg;
|
|
double dEl = ((AecDbECableLine*)m_pPipeLine)->GetPipeParam()->m_dEl;
|
|
|
|
//上来就绘制立管,至少创建了一个管段
|
|
if (((AecDbECableLine*)m_pPipeLine)->GetLastInterface() == NULL)
|
|
{
|
|
//可以改为仅仅改标高对话框,当没有状态记录时
|
|
//acutPrintf(_T("\n之前没有创建管段,无法变标高!"));
|
|
|
|
//当前位置选择到实体的话,更新标高
|
|
AECStatusRecord* pRec = GetTailStatusRec();
|
|
dEl = PickWPipehereEl(pRec->GetAcquirePoint());
|
|
((AecDbECableLine*)m_pPipeLine)->GetPipeParam()->m_dEl = dEl;
|
|
|
|
//弹出标高对话框,创建立管,如果选择位置有三通,则三通连接
|
|
chelDlg.m_dCurEl = dEl;
|
|
int nRes = chelDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
//原位置 的改标高
|
|
m_pCurStaRec->SetAcquirePoint(pRec->GetAcquirePoint());
|
|
if ( ( (AecDbECableLine *)m_pPipeLine)->ChangeEl2(m_pCurStaRec,pRec,chelDlg.m_dNewEl,
|
|
FALSE,0.0,NULL ) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
continue;
|
|
}
|
|
|
|
//标高的变化
|
|
chelDlg.m_dCurEl = dEl;
|
|
int nRes = chelDlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
|
|
if ( ( (AecDbECableLine *)m_pPipeLine)->ChangeEl(m_pCurStaRec,chelDlg.m_dNewEl,FALSE,0.0,NULL ) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW3://X 协管
|
|
{
|
|
//至少创建了一个管段
|
|
AECStatusRecord* pLast = GetTailStatusRec();
|
|
if ( pLast == NULL)
|
|
{
|
|
acutPrintf(_T("\n之前没有拾取位置点!请先拾取第一点!"));
|
|
continue;
|
|
}
|
|
|
|
//添加斜管
|
|
CTJXGDlg dlg;
|
|
dlg.m_dLastEl = ((AecDbECableLine*)m_pPipeLine)->GetPipeParam()->m_dEl;
|
|
|
|
int nRes = dlg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
if ( fabs(dlg.m_dNewEl - dlg.m_dLastEl) < 1.e-6 )//同标高
|
|
{
|
|
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);
|
|
ptThis.z = dlg.m_dNewEl;
|
|
|
|
if (((AecDbECableLine *)m_pPipeLine)->ChangeEl3(m_pCurStaRec,ptThis))
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
}
|
|
SHacedCommand(RTSTR, _T("_undo"), RTSTR, _T("E"), RTNONE);
|
|
SetUndoGroupEnd();
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW4://U 回退
|
|
{
|
|
if (m_lstStaPtrsBack.GetCount() > 1)
|
|
{
|
|
SHacedCommand(RTSTR,_T("u"),RTNONE);
|
|
PopUpStatusRec();
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
case AcEdJig::kKW5://P 参数
|
|
{
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
CECableParamDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
|
|
AecHvac::DuctParam* pParam = ((AecDbECableLine *)m_pPipeLine)->GetPipeParam();
|
|
drawCnfgDLg.SetShowParam(*pParam);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->PushPipeParam();
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
AecHvac::DuctParam *pParam = ((AecDbECableLine *)m_pPipeLine)->GetPipeParam();
|
|
|
|
CHDLGDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
drawCnfgDLg.SetShowParam(*pParam);
|
|
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->PushPipeParam();
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
XHolder lHolder, rHolder;
|
|
if ( drawCnfgDLg.GetXHolder(lHolder, rHolder) )
|
|
((AecDbECableLine *)m_pPipeLine)->SetXHolder(lHolder, rHolder);
|
|
}
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
EndDragRecord();
|
|
}
|
|
|
|
acutPrintf(_T("\n"));
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL AecDbECableJig::DoItOnPath(WPipe::EApp app, const AcGePoint3dArray &arPts,bool bHasFit, bool bShowParamDlg)
|
|
{
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
InitStatusBRecs();
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
InitStatusTRecs();
|
|
}
|
|
|
|
if (bShowParamDlg)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
CECableParamDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
CHDLGDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
XHolder lHolder, rHolder;
|
|
if ( drawCnfgDLg.GetXHolder(lHolder, rHolder))
|
|
((AecDbECableLine *)m_pPipeLine)->SetXHolder(lHolder, rHolder);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//构造函数中已经设置了!!!!!
|
|
//((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
AecHvac::DuctParam *pParam = ((AecDbECableLine *)m_pPipeLine)->GetPipeParam();
|
|
if (pParam == NULL)
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
if (app == WPipe::eBridge)
|
|
{
|
|
CECableParamDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else if (app == WPipe::eTrench)
|
|
{
|
|
CHDLGDlg drawCnfgDLg;
|
|
drawCnfgDLg.EnableLoadLast(TRUE);
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes != IDOK)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AecHvac::DuctParam param;
|
|
memset(¶m, 0, sizeof(AecHvac::DuctParam));
|
|
param.m_app = app;
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
((AecDbECableLine *)m_pPipeLine)->SetPipeParam(¶m);
|
|
|
|
XHolder lHolder, rHolder;
|
|
if (drawCnfgDLg.GetXHolder(lHolder, rHolder))
|
|
((AecDbECableLine *)m_pPipeLine)->SetXHolder(lHolder, rHolder);
|
|
}
|
|
}
|
|
}
|
|
|
|
((AecDbECableLine *)m_pPipeLine)->SetElbowAndPipe(bHasFit);
|
|
|
|
//关闭提示
|
|
KTCADSysVar<int> var1(_T("CMDECHO"), 0);
|
|
|
|
AcGePoint3d ptGe;
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
ptGe = arPts.at(i);
|
|
ptGe.z = ((AecDbECableLine *)m_pPipeLine)->GetEndElevation();
|
|
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
|
|
AfterDrag();
|
|
|
|
EndDragRecord();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int AecDbECableJig::AfterDrag()
|
|
{
|
|
int nPlanPos = m_pCurStaRec->GetPlanPosition();
|
|
if (nPlanPos != 1)
|
|
return -1;
|
|
|
|
//设置回退记录
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("BE"),RTNONE);
|
|
SetUndoGroupBegin();
|
|
if ( ((AecDbECableLine *)m_pPipeLine)->AddPipeNode(m_pCurStaRec,WPipe::eToCreate) )
|
|
{
|
|
AECStatusRecord* pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
PushBackStatusRec(pRec);
|
|
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
|
|
if (m_pCurStaRec->IsCommand2Stop())
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
((AecDbECableLine *)m_pPipeLine)->PipeFinished();
|
|
return FALSE;
|
|
}
|
|
m_vtStaDir.set(0,0,0);//reset
|
|
SHacedCommand(RTSTR,_T("_undo"),RTSTR,_T("E"),RTNONE);
|
|
SetUndoGroupEnd();
|
|
|
|
return -1;
|
|
}
|
|
|
|
void AecDbECableJig::EndDragRecord()
|
|
{
|
|
//获取下个状态,plane判断是?
|
|
if (m_pCurStaRec->GetPlanPosition() == 0 )
|
|
{
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
}
|
|
}
|
|
|
|
BOOL AecDbECableJig::DoIt(AecInterface* pIntf,AecHvac::DuctParam* pParam)
|
|
{
|
|
if (pIntf == NULL) return FALSE;
|
|
|
|
if (pParam == NULL) //用户确定壁厚和外径 etc.
|
|
{
|
|
InitStatusBRecs();
|
|
|
|
//pParam == NULL 确认是桥架上的设备,调用桥架界面设置
|
|
CAcModuleResourceOverride myResources;
|
|
CECableParamDlg drawCnfgDLg;
|
|
|
|
double dSize(pIntf->dSize1),dSize1(pIntf->dSize2);
|
|
|
|
drawCnfgDLg.SetEleReadOnly(TRUE,FormatZero(pIntf->ptPos.z));//圆整
|
|
int nRes = drawCnfgDLg.DoModal();
|
|
if (nRes == IDOK)
|
|
{
|
|
AecHvac::DuctParam param;
|
|
memset(¶m,0,sizeof(AecHvac::DuctParam));
|
|
|
|
drawCnfgDLg.GetPipeParam(¶m);
|
|
param.m_dEl = pIntf->ptPos.z;//标高确定不变
|
|
((AecDbECableLine*)m_pPipeLine)->SetPipeParam(¶m);
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pParam->m_app == WPipe::eBridge)
|
|
{
|
|
InitStatusBRecs();
|
|
}
|
|
else if (pParam->m_app == WPipe::eTrench)
|
|
{
|
|
InitStatusTRecs();
|
|
}
|
|
//
|
|
((AecDbECableLine*)m_pPipeLine)->SetPipeParam(pParam);
|
|
}
|
|
|
|
//压入本次接口
|
|
if ( /*pParam != NULL &&*/ pIntf->idOwner.isValid())
|
|
{
|
|
((AecDbECableLine*)m_pPipeLine)->PushInterface(*pIntf,TRUE);
|
|
}
|
|
|
|
//压入本次状态,起点
|
|
m_pCurStaRec->SetAcquirePoint(pIntf->ptPos);
|
|
AECStatusRecord * pRec = new AECStatusRecord;
|
|
pRec->CopyFrom(m_pCurStaRec);
|
|
pRec->SetUndoGroupId(0);
|
|
PushBackStatusRec(pRec);
|
|
|
|
((AecDbECableLine *)m_pPipeLine)->SetAngleWath(pIntf->ptPos,pRec->GetAcquirePoint(),pIntf->vtDir);
|
|
m_pCurStaRec = m_pCurStaRec->GetNextStatus(m_pCurStaRec->GetPos());
|
|
|
|
return DoIt(pParam->m_app, FALSE,FALSE);
|
|
}
|
|
|
|
AcEdJig::DragStatus AecDbECableJig::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;
|
|
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 = ((AecDbECableLine*)m_pPipeLine)->GetEndElevation();
|
|
}
|
|
else
|
|
{
|
|
//管线的末端点
|
|
GetLastStatusAquire(ptGeBase);
|
|
eStat = acquirePoint(ptGe,ptGeBase);
|
|
ptGe.z = ((AecDbECableLine*)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;
|
|
}
|
|
}
|
|
return SetPickPoint(ptGe);
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return eStat;
|
|
}
|
|
|
|
AcEdJig::DragStatus AecDbECableJig::SetPickPoint(const AcGePoint3d& ptGe)
|
|
{
|
|
//上次点
|
|
AcGePoint3d ptGe2 = m_pCurStaRec->GetAcquirePoint();
|
|
|
|
//本次点
|
|
m_pCurStaRec->SetAcquirePoint(ptGe);
|
|
((AecDbECableLine *)m_pPipeLine)->AngWatchTo(ptGe);
|
|
|
|
if (m_pCurStaRec->GetPlanPosition() > 0 && m_lstStaPtrsBack.GetCount() > 0)
|
|
{
|
|
((AecDbECableLine *)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;
|
|
}
|
|
//}
|
|
return AcEdJig::kNormal;
|
|
}
|
|
return AcEdJig::kNormal;
|
|
}
|
|
|
|
AcDbEntity* AecDbECableJig::entity() const
|
|
{
|
|
return m_pPipeLine;
|
|
}
|
|
|
|
Adesk::Boolean AecDbECableJig::update()
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
void AecDbECableJig::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 AecDbECableJig::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* AecDbECableJig::GetTailStatusRec() const
|
|
{
|
|
int nSize = m_lstStaPtrsBack.GetCount();
|
|
if (nSize > 0)
|
|
{
|
|
return (AECStatusRecord*)m_lstStaPtrsBack.GetTail();
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AECStatusRecord* AecDbECableJig::GetCurStatusRec() const
|
|
{
|
|
return m_pCurStaRec;
|
|
}
|
|
|
|
void AecDbECableJig::PushBackStatusRec(AECStatusRecord* pRec)
|
|
{
|
|
pRec->SetUndoGroupId(m_nUndoGoupid);
|
|
m_lstStaPtrsBack.AddTail(pRec);
|
|
}
|
|
|
|
void AecDbECableJig::SetUndoGroupBegin()
|
|
{
|
|
m_nUndoGoupid += 1;
|
|
}
|
|
|
|
void AecDbECableJig::SetUndoGroupEnd()
|
|
{
|
|
((AecDbECableLine *)m_pPipeLine)->PushPipeParam();
|
|
}
|
|
|
|
int AecDbECableJig::GetUndoGroupID()
|
|
{
|
|
return m_nUndoGoupid;
|
|
}
|
|
|
|
void AecDbECableJig::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 回退一次,调整接口记录
|
|
((AecDbECableLine *)m_pPipeLine)->PopUpInterface(nID);
|
|
((AecDbECableLine *)m_pPipeLine)->MoveAngWatchPosition();
|
|
}
|
|
}
|
|
|
|
void AecDbECableJig::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 AecDbECableJig::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_DBCABTRY"));
|
|
|
|
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) )
|
|
{
|
|
AecDbECableTray* pWPipe = AecDbECableTray::cast(pEnt);
|
|
if (pWPipe != NULL)
|
|
{
|
|
dEl = pWPipe->EndPoint().z;
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
acedSSFree(ss);
|
|
return dEl;
|
|
}
|