379 lines
8.0 KiB
C++
379 lines
8.0 KiB
C++
#include "stdafx.h"
|
|
#include "TVPipeDimJig.h"
|
|
#include "DbVPipeDim.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
TVPipeDimJig::TVPipeDimJig(TDbVPipeDim *pDim)
|
|
{
|
|
m_pDrawEnt = pDim;
|
|
}
|
|
|
|
TVPipeDimJig::~TVPipeDimJig()
|
|
{
|
|
|
|
}
|
|
|
|
void TVPipeDimJig::SetStartPt(const AcGePoint3d &pt)
|
|
{
|
|
m_ptStart = pt;
|
|
}
|
|
|
|
AcEdJig::DragStatus
|
|
TVPipeDimJig::GetPoint(XPoint &pt)
|
|
{
|
|
DragStatus drag = acquirePoint(pt, m_ptStart);
|
|
m_ptTurn = pt;
|
|
|
|
double dS = Wcs2Ucs(m_ptStart).x;
|
|
double dT = Wcs2Ucs(pt).x;
|
|
|
|
if (fabs(dS - dT) < 1e-3)
|
|
{
|
|
CPoint pt;
|
|
::GetCursorPos(&pt);
|
|
acedGetAcadDwgView()->ScreenToClient(&pt);
|
|
//AUTOCAD误差值 减小误差
|
|
|
|
int nIndex = acedGetWinNum(pt.x, pt.y);
|
|
acedDwgPoint ptDwg;
|
|
acedCoordFromPixelToWorld(nIndex,pt,ptDwg);
|
|
dT = ptDwg[0];
|
|
}
|
|
|
|
if (dS > dT)
|
|
m_vtDir = Ucs2Wcs(-AcGeVector3d::kXAxis);
|
|
else
|
|
m_vtDir = Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
|
|
SetPrompt(_T("\n请选择文字的落点:"));
|
|
return drag;
|
|
}
|
|
|
|
|
|
int TVPipeDimJig::DoIt(int *keyIndex)
|
|
{
|
|
int nRet = TSymbEdJig::DoIt(keyIndex);
|
|
return nRet;
|
|
}
|
|
|
|
// 更新实体数据
|
|
Adesk::Boolean TVPipeDimJig::update()
|
|
{
|
|
Adesk::Boolean bRet=Adesk::kTrue;
|
|
if (m_pDrawEnt != NULL)
|
|
{
|
|
m_pDrawEnt->SetTurnPt(m_ptTurn);
|
|
m_pDrawEnt->SetVtDir(m_vtDir);
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
AcDbEntity* TVPipeDimJig::entity() const
|
|
{
|
|
return (AcDbEntity *)m_pDrawEnt;
|
|
}
|
|
|
|
|
|
// 多立管标注jig
|
|
TMultVPipeDimJig::TMultVPipeDimJig(std::vector<TDbVPipeDim *> &vecDim, AcGePoint3d &ptEnd, AcGeVector3d &vtDir)
|
|
{
|
|
m_vecDim = vecDim;
|
|
m_ptEnd = ptEnd;
|
|
m_vtDir = vtDir;
|
|
m_bPrjOnPipe = false;
|
|
m_pDrawEnt = new CMultVpipeDimPreview(vecDim, ptEnd, vtDir);
|
|
}
|
|
|
|
TMultVPipeDimJig::~TMultVPipeDimJig()
|
|
{
|
|
if (m_pDrawEnt != NULL)
|
|
{
|
|
delete m_pDrawEnt;
|
|
m_pDrawEnt = NULL;
|
|
}
|
|
}
|
|
|
|
AcGePoint3d& TMultVPipeDimJig::GetTurnPt()
|
|
{
|
|
return m_ptTurn;
|
|
}
|
|
|
|
AcGeVector3d& TMultVPipeDimJig::GetDimDir()
|
|
{
|
|
return m_vtDimDir;
|
|
}
|
|
void TMultVPipeDimJig::SetStartPt(const AcGePoint3d &pt)
|
|
{
|
|
m_ptStart = pt;
|
|
}
|
|
|
|
AcEdJig::DragStatus
|
|
TMultVPipeDimJig::GetPoint(XPoint &pt)
|
|
{
|
|
DragStatus drag = acquirePoint(pt, m_ptStart);
|
|
m_ptTurn = pt;
|
|
|
|
double dSx = Wcs2Ucs(m_ptStart).x;
|
|
double dEx = Wcs2Ucs(m_ptEnd).x;
|
|
double dSy = Wcs2Ucs(m_ptStart).y;
|
|
double dTx = Wcs2Ucs(m_ptTurn).x;
|
|
double dTy = Wcs2Ucs(m_ptTurn).y;
|
|
m_bIsProj = false;
|
|
if (fabs(dSx - dTx) < 1e-3)
|
|
{
|
|
CPoint pt;
|
|
::GetCursorPos(&pt);
|
|
acedGetAcadDwgView()->ScreenToClient(&pt);
|
|
|
|
int nIndex = acedGetWinNum(pt.x, pt.y);
|
|
acedDwgPoint ptDwg;
|
|
acedCoordFromPixelToWorld(nIndex,pt,ptDwg);
|
|
|
|
AcGePoint3d ptDwg3d;
|
|
ptDwg3d.x = ptDwg[0];
|
|
ptDwg3d.y = ptDwg[1];
|
|
ptDwg3d.z = ptDwg[2];
|
|
dTx = Wcs2Ucs(ptDwg3d).x;
|
|
m_bIsProj = true;
|
|
}
|
|
else if (fabs(dSy - dTy) < 1e-3)
|
|
{
|
|
return AcEdJig::kNull;
|
|
}
|
|
|
|
AcGeTol tolVec;
|
|
tolVec.setEqualVector(0.001);
|
|
// 共线平行于X轴时
|
|
if (m_vtDir.isParallelTo(AcGeVector3d::kXAxis, tolVec))// 根据当前点位置 确定标注具体位置
|
|
{
|
|
if (dSx > dTx && !m_bIsProj)
|
|
{
|
|
m_bPrjOnPipe = false;
|
|
m_vtDimDir = Ucs2Wcs(-AcGeVector3d::kXAxis);
|
|
m_vtNext = Ucs2Wcs(AcGeVector3d::kYAxis);
|
|
if (dSy > dTy)
|
|
{
|
|
m_vtNext = Ucs2Wcs(-AcGeVector3d::kYAxis);
|
|
}
|
|
}
|
|
else if (dTx > dEx && !m_bIsProj)
|
|
{
|
|
m_bPrjOnPipe = false;
|
|
m_vtDimDir = Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
m_vtNext = Ucs2Wcs(-AcGeVector3d::kYAxis);
|
|
if (dSy > dTy)
|
|
{
|
|
m_vtNext = Ucs2Wcs(AcGeVector3d::kYAxis);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_vtDimDir = Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
m_vtNext = m_ptTurn - m_ptStart;
|
|
m_bPrjOnPipe = true;
|
|
|
|
if (m_bIsProj)// 处理正交
|
|
{
|
|
if (dSx > dTx)
|
|
{
|
|
m_vtDimDir = Ucs2Wcs(-AcGeVector3d::kXAxis);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else// 共线平行于Y轴
|
|
{
|
|
m_vtDimDir = Ucs2Wcs(AcGeVector3d::kXAxis);
|
|
if (dSx > dTx )
|
|
{
|
|
m_vtDimDir = Ucs2Wcs(-AcGeVector3d::kXAxis);
|
|
}
|
|
m_vtNext = Ucs2Wcs(AcGeVector3d::kYAxis);
|
|
}
|
|
m_vtNext.normalize();
|
|
SetPrompt(_T("\n请选择文字的落点:"));
|
|
return drag;
|
|
}
|
|
|
|
|
|
int TMultVPipeDimJig::DoIt(int *keyIndex)
|
|
{
|
|
int nRet = TSymbEdJig::DoIt(keyIndex);
|
|
return nRet;
|
|
}
|
|
|
|
// 更新实体数据
|
|
Adesk::Boolean TMultVPipeDimJig::update()
|
|
{
|
|
Adesk::Boolean bRet=Adesk::kTrue;
|
|
if (m_pDrawEnt != NULL)
|
|
{
|
|
m_pDrawEnt->SetDimDir(m_vtDimDir);
|
|
double dDist2Turn = 0.0;
|
|
std::vector<TDbVPipeDim *>::iterator it;
|
|
int i = 0;
|
|
for (it = m_vecDim.begin(); it != m_vecDim.end(); it++)
|
|
{
|
|
TDbVPipeDim *pDim = *it;
|
|
if (pDim != NULL)
|
|
{
|
|
double dScale = DocGetPScale();;
|
|
double dTextHeight = g_nVPipeHeight * dScale;
|
|
double dDistPipe2Text = g_nVPipeHeight * g_nDimCirDiam * dScale / 10;
|
|
double dDist = dTextHeight + dDistPipe2Text * 2;
|
|
double dLen = m_ptStart.Distance(m_ptTurn);
|
|
AcDbObjectId id = pDim->GetVPipeId();
|
|
ads_name name;
|
|
acdbGetAdsName(name, id);
|
|
Entity entPipe = name;
|
|
if (g_bIsPipeDimCir == TVPipeDim::eDimType4 && IsShowVPipeDimDn(GetPipeLayer(entPipe)))
|
|
{
|
|
dDist = dDist * 2;
|
|
}
|
|
|
|
if (i != 0 && m_bIsProj && Wcs2Ucs(m_vtDimDir).x < 0)// 反向正交处理
|
|
{
|
|
if (Wcs2Ucs(m_vtNext).y > 0)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (i != 0 && Wcs2Ucs(m_vtNext).y < 0 && m_bPrjOnPipe)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
else if (i != 0 && Wcs2Ucs(m_vtNext).y > 0 && !m_bPrjOnPipe)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
}
|
|
|
|
|
|
if (m_bPrjOnPipe && i != 0)
|
|
{
|
|
if (m_bIsProj && Wcs2Ucs(m_vtDimDir).x < 0)// 处理正交情形
|
|
{
|
|
pDim->SetTurnPt(pDim->GetStartPt() + (dLen + dDist2Turn) * m_vtNext);
|
|
}
|
|
else
|
|
{
|
|
pDim->SetTurnPt(pDim->GetStartPt() + (dLen - dDist2Turn) * m_vtNext);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pDim->SetTurnPt(m_ptTurn + dDist2Turn * m_vtNext);
|
|
}
|
|
|
|
if (m_bIsProj && Wcs2Ucs(m_vtDimDir).x < 0)
|
|
{
|
|
if (m_vtNext.y < 0)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_bPrjOnPipe && Wcs2Ucs(m_vtNext).y > 0)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
else if (Wcs2Ucs(m_vtNext).y < 0 && !m_bPrjOnPipe)
|
|
{
|
|
dDist2Turn += dDist;
|
|
}
|
|
}
|
|
|
|
pDim->SetVtDir(m_vtDimDir);
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
AcDbEntity* TMultVPipeDimJig::entity() const
|
|
{
|
|
return (AcDbEntity *)m_pDrawEnt;
|
|
}
|
|
|
|
|
|
|
|
// 多管线标注
|
|
CMultVpipeDimPreview::CMultVpipeDimPreview(std::vector<TDbVPipeDim *> &vecDim, AcGePoint3d &ptEnd, AcGeVector3d &vtDir)
|
|
{
|
|
m_vecDim = vecDim;
|
|
m_vtDir = vtDir;
|
|
}
|
|
|
|
CMultVpipeDimPreview::~CMultVpipeDimPreview()
|
|
{
|
|
|
|
}
|
|
|
|
void CMultVpipeDimPreview::SetDimDir(AcGeVector3d &vtDim)
|
|
{
|
|
m_vtDir = vtDim;
|
|
}
|
|
|
|
Acad::ErrorStatus CMultVpipeDimPreview::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
std::vector<TDbVPipeDim *>::const_iterator it;
|
|
AcGePoint3d ptStart, ptTurn;
|
|
double dS = 0.0, dT = 0.0;
|
|
AcGeVector3d vt;
|
|
for (it = m_vecDim.begin(); it != m_vecDim.end(); it++)
|
|
{
|
|
TDbVPipeDim *pDim = new TDbVPipeDim;
|
|
ptStart = (*it)->GetStartPt();
|
|
pDim->SetStartPt(ptStart);
|
|
ptTurn = (*it)->GetTurnPt();
|
|
pDim->SetTurnPt(ptTurn);
|
|
|
|
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
|
pDim->SetVtDir(m_vtDir);
|
|
|
|
pDim->SetDimRadius(g_nDimCirDiam);
|
|
pDim->SetDimType(g_bIsPipeDimCir);
|
|
CString csDim;
|
|
(*it)->GetDimTypeText(csDim);
|
|
pDim->SetDimTypeText(csDim);
|
|
pDim->SetTextHeight(g_nVPipeHeight);
|
|
pDim->SetTextStyleId((*it)->GetTextStyleId());
|
|
pDim->SetText2BaseRatio(g_nDimCirDiam);
|
|
|
|
if (g_bIsPipeDimCir == TVPipeDim::eDimType4)
|
|
{
|
|
AcDbObjectId id = (*it)->GetVPipeId();
|
|
ads_name name;
|
|
acdbGetAdsName(name, id);
|
|
Entity entPipe = name;
|
|
pDim->SetShowDnForDimType4(IsShowVPipeDimDn(GetPipeLayer(entPipe)) ? true : false);
|
|
pDim->SetAlignTypeForDimType4(g_nAlignTypeForVPipeDim4);
|
|
}
|
|
else if (g_bIsPipeDimCir == TVPipeDim::eDimType5)
|
|
{
|
|
pDim->SetDnDistance2LabelLoc((*it)->GetDnDistance2LabelLoc());
|
|
pDim->SetTextBaseLineLen((*it)->GetTextBaseLineLen());
|
|
pDim->SetDnDistBetweenLabel((*it)->GetDnDistBetweenLabel());
|
|
}
|
|
|
|
AcDbObjectId id = pDim->GetVPipeId();
|
|
ads_name name;
|
|
acdbGetAdsName(name, id);
|
|
Entity entPipe = name;
|
|
pDim->setLayer((*it)->layer());
|
|
pDim->SetVPipeFloorType(g_iVPipeDimStyle);
|
|
pDim->SetVPipeId((*it)->GetVPipeId());
|
|
|
|
Acad::ErrorStatus es = pDim->ExplodeOrDraw2d(dc);
|
|
}
|
|
return Acad::eOk;
|
|
} |