671 lines
19 KiB
C++
671 lines
19 KiB
C++
#include "StdAfx.h"
|
||||
|
|
#include "LayFireExtinguisherDlg.h"
|
|||
|
|
#include "FireExtinguisherJig.h"
|
|||
|
|
#include "DbEquipment.h"
|
|||
|
|
#include "DbFireExtinguisher.h"
|
|||
|
|
#include "AcDbObjectPtr.h"
|
|||
|
|
#include "globalFunc.h"
|
|||
|
|
#include "layerdef.h"
|
|||
|
|
#include "RBGroups.h"
|
|||
|
|
|
|||
|
|
extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL);
|
|||
|
|
extern XCurveSegment GetEntitySegByPt(XPoint &ptPick, Entity &entWall, AcGeMatrix3d &mat);
|
|||
|
|
void FireExtinguisherEditCmd()
|
|||
|
|
{
|
|||
|
|
GlobalFunc::DocGetPickFirst().Free();
|
|||
|
|
PickSet ss;
|
|||
|
|
RBList rbMask(RTDXF0, _T("AEC_ZT_EQUIPMENT"), 8, LAY_TWT_EXTINGUISHER, NULL);
|
|||
|
|
int nRet = GlobalFunc::SelectEntities(_T("\n请选择要修改的灭火器:<退出>"), ss, rbMask);
|
|||
|
|
if (nRet != RTNORM)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CTemporaryResourceOverride vTemp;
|
|||
|
|
CLayFireExtinguisherDlg dlg(2);
|
|||
|
|
dlg.SetPickset(ss);
|
|||
|
|
dlg.DoModal();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int EditFireExtinguisher(AcDbObjectId id)
|
|||
|
|
{
|
|||
|
|
if(!id)
|
|||
|
|
return RTERROR;
|
|||
|
|
CString sBlkName, sPec;
|
|||
|
|
int nNum = 0;
|
|||
|
|
double dScale = 0.0;
|
|||
|
|
double dRadius = 0.0;
|
|||
|
|
bool bDim = false;
|
|||
|
|
bool bAutoScale = true;
|
|||
|
|
AcDbObjectId idTextStyle;
|
|||
|
|
double dTextHeight = 0.0;
|
|||
|
|
CString sGrade;
|
|||
|
|
int nScaleType = 0;
|
|||
|
|
int nSpecType = -1;
|
|||
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, CDbFireExtinguisher, pFireExt);
|
|||
|
|
if(pFireExt != NULL)
|
|||
|
|
{
|
|||
|
|
sBlkName = GlobalFunc::GetBlkNameById(pFireExt->GetBlock2d());
|
|||
|
|
sPec = pFireExt->GetSpec();
|
|||
|
|
nNum = pFireExt->GetNum();
|
|||
|
|
dScale = pFireExt->GetScale();
|
|||
|
|
dRadius = pFireExt->GetProtectRadius();
|
|||
|
|
bDim = pFireExt->GetIsDim();
|
|||
|
|
idTextStyle = pFireExt->GetTextStyleId();
|
|||
|
|
dTextHeight = pFireExt->GetTextHeight();
|
|||
|
|
sGrade = pFireExt->GetGrade();
|
|||
|
|
nScaleType = pFireExt->GetScaleType();
|
|||
|
|
nSpecType = pFireExt->GetSpecificationType();
|
|||
|
|
}
|
|||
|
|
OPENOBJ_END();
|
|||
|
|
CTemporaryResourceOverride vTemp;
|
|||
|
|
CLayFireExtinguisherDlg dlg(1);
|
|||
|
|
dlg.SetScale(dScale);
|
|||
|
|
dlg.SetTextHeight(dTextHeight);
|
|||
|
|
dlg.m_sProtectRadius.Format(_T("%.2f"), dRadius);
|
|||
|
|
if (dlg.m_sProtectRadius.Find(_T(".")) > -1)
|
|||
|
|
{
|
|||
|
|
dlg.m_sProtectRadius.TrimRight(_T("0"));
|
|||
|
|
dlg.m_sProtectRadius.TrimRight(_T("."));
|
|||
|
|
}
|
|||
|
|
dlg.SetCount(nNum);
|
|||
|
|
dlg.GetSpecTypeByBlkName(sBlkName);
|
|||
|
|
dlg.m_sSpecification = sPec;
|
|||
|
|
dlg.m_sGrade = sGrade;
|
|||
|
|
dlg.m_nScale = nScaleType;
|
|||
|
|
dlg.m_nSpecificationType = nSpecType;
|
|||
|
|
if (bDim)
|
|||
|
|
{
|
|||
|
|
dlg.m_nDimType = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dlg.m_nDimType = 1;
|
|||
|
|
}
|
|||
|
|
OPENOBJ_BEGIN(idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle);
|
|||
|
|
ASSERT(pStyle);
|
|||
|
|
const TCHAR* pName = NULL;
|
|||
|
|
if (pStyle->getName(pName) == Acad::eOk && pName != NULL)
|
|||
|
|
dlg.m_sTextStyle = pName;
|
|||
|
|
OPENOBJ_END();
|
|||
|
|
if (dlg.DoModal() != IDOK)
|
|||
|
|
{
|
|||
|
|
return RTNORM;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
OPENOBJ_BEGIN(id, AcDb::kForWrite, CDbFireExtinguisher, pFireExt);
|
|||
|
|
if(pFireExt != NULL)
|
|||
|
|
{
|
|||
|
|
sBlkName = dlg.GetSelBlkName();
|
|||
|
|
AcDbObjectId id = GlobalFunc::GetBlkIdByName(sBlkName);
|
|||
|
|
if (!id.isValid())
|
|||
|
|
{
|
|||
|
|
CString sBlkNum;
|
|||
|
|
CString sDwb = g_csDwbPath + _T("TwtSys");
|
|||
|
|
int nIndex = sBlkName.ReverseFind(_T('$'));
|
|||
|
|
if (nIndex != -1)
|
|||
|
|
{
|
|||
|
|
int nSize = sBlkName.GetLength();
|
|||
|
|
sBlkNum = sBlkName.Right(nSize - nIndex - 1);
|
|||
|
|
}
|
|||
|
|
XString xsTmp;
|
|||
|
|
if(GlobalFunc::LoadDwbBlock(sDwb, sBlkNum, xsTmp) != RTNORM)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
pFireExt->SetBlock2d(GlobalFunc::GetBlkIdByName(sBlkName));
|
|||
|
|
pFireExt->SetSpec(dlg.m_sSpecification);
|
|||
|
|
pFireExt->SetNum(dlg.GetCount());
|
|||
|
|
double dScale = dlg.GetScale();
|
|||
|
|
pFireExt->SetScale(dScale);
|
|||
|
|
pFireExt->SetProtectRadius(_tstof(dlg.m_sProtectRadius));
|
|||
|
|
pFireExt->SetIsDim(dlg.IsDim() ? true : false);
|
|||
|
|
pFireExt->SetTextStyleId(GlobalFunc::GetTextStyleId(dlg.m_sTextStyle));
|
|||
|
|
pFireExt->SetTextHeight(_tstof(dlg.m_sTextHeight));
|
|||
|
|
pFireExt->SetGrade(dlg.m_sGrade);
|
|||
|
|
pFireExt->SetScaleType(dlg.m_nScale);
|
|||
|
|
pFireExt->SetSpecificationType(dlg.m_nSpecificationType);
|
|||
|
|
}
|
|||
|
|
OPENOBJ_END();
|
|||
|
|
return 1;
|
|||
|
|
}
|
|||
|
|
// 图块大小
|
|||
|
|
static void GetBlkSize(const AcDbObjectId &idBlk, const AcGeScale3d &scale, double &dWidth, double &dHeight)
|
|||
|
|
{
|
|||
|
|
AcGePoint3d ptIns = AcGePoint3d::kOrigin;
|
|||
|
|
AcDbBlockReference blkRef(ptIns, idBlk);
|
|||
|
|
blkRef.setScaleFactors(scale);
|
|||
|
|
AcDbExtents extent;
|
|||
|
|
blkRef.getGeomExtents(extent);
|
|||
|
|
AcGePoint3d ptMin = extent.minPoint();
|
|||
|
|
AcGePoint3d ptMax = extent.maxPoint();
|
|||
|
|
dWidth = ptMax.x - ptMin.x;
|
|||
|
|
dHeight = ptMax.y - ptMin.y;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
static bool GetBlkSize(const CString &sBlkName, const AcGeScale3d &scale, double &dWidth, double &dHeight)
|
|||
|
|
{
|
|||
|
|
AcDbObjectId idBlk = GlobalFunc::GetBlockIdFromString(sBlkName);
|
|||
|
|
if (idBlk.isNull())
|
|||
|
|
{
|
|||
|
|
// 加载灭火器图块
|
|||
|
|
CString sDwb = g_csDwbPath + _T("TwtSys");
|
|||
|
|
CString sBlkNum;
|
|||
|
|
int nIndex = sBlkName.ReverseFind(_T('$'));
|
|||
|
|
if (nIndex != -1)
|
|||
|
|
{
|
|||
|
|
int nSize = sBlkName.GetLength();
|
|||
|
|
sBlkNum = sBlkName.Right(nSize - nIndex - 1);
|
|||
|
|
}
|
|||
|
|
XString xsTmp;
|
|||
|
|
if(GlobalFunc::LoadDwbBlock(sDwb, sBlkNum, xsTmp) != RTNORM)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 重新获取图块id
|
|||
|
|
idBlk = GlobalFunc::GetBlockIdFromString(sBlkName);
|
|||
|
|
if (idBlk.isNull())
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
GetBlkSize(idBlk, scale, dWidth, dHeight);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 图块插入点距图块0度时外包框底边的距离 cet 2013.4.8 add
|
|||
|
|
double GetPtinsToExtentBottomDist(const CString &sBlkName)
|
|||
|
|
{
|
|||
|
|
AcDbObjectId idBlk = GlobalFunc::GetBlockIdFromString(sBlkName);
|
|||
|
|
if (idBlk.isNull())
|
|||
|
|
{
|
|||
|
|
// 加载灭火器图块
|
|||
|
|
CString sDwb = g_csDwbPath + _T("TwtSys");
|
|||
|
|
CString sBlkNum;
|
|||
|
|
int nIndex = sBlkName.ReverseFind(_T('$'));
|
|||
|
|
if (nIndex != -1)
|
|||
|
|
{
|
|||
|
|
int nSize = sBlkName.GetLength();
|
|||
|
|
sBlkNum = sBlkName.Right(nSize - nIndex - 1);
|
|||
|
|
}
|
|||
|
|
XString xsTmp;
|
|||
|
|
if(GlobalFunc::LoadDwbBlock(sDwb, sBlkNum, xsTmp) != RTNORM)
|
|||
|
|
{
|
|||
|
|
return 0.0;
|
|||
|
|
}
|
|||
|
|
return GetPtinsToExtentBottomDist(sBlkName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AcGePoint3d ptIns = AcGePoint3d::kOrigin;
|
|||
|
|
AcDbBlockReference blkRef(ptIns, idBlk);
|
|||
|
|
AcDbExtents extent;
|
|||
|
|
if (blkRef.getGeomExtents(extent) != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
return 0.0;
|
|||
|
|
}
|
|||
|
|
return fabs(extent.minPoint().y);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void AddToCurSpace(CLayFireExtinguisherDlg &dlg, CDbFireExtinguisher &fireExtinguisher)
|
|||
|
|
{
|
|||
|
|
// 灭火器数量
|
|||
|
|
int nNum = dlg.GetCount();
|
|||
|
|
|
|||
|
|
if (nNum <= 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
CDbFireExtinguisher *pFireExtinguisher = new CDbFireExtinguisher;
|
|||
|
|
pFireExtinguisher->SetNum(nNum);
|
|||
|
|
|
|||
|
|
CString sBlkName = dlg.GetSelBlkName();
|
|||
|
|
//插入点
|
|||
|
|
int nLayDimType = dlg.GetLayDimType();
|
|||
|
|
pFireExtinguisher->SetLayType(nLayDimType);
|
|||
|
|
AcGePoint3d ptIns = fireExtinguisher.GetLocation();
|
|||
|
|
pFireExtinguisher->SetLocation(ptIns);
|
|||
|
|
|
|||
|
|
CString sProtectRadius, sSpecification;
|
|||
|
|
sProtectRadius.Format(_T("%.3f"), fireExtinguisher.GetProtectRadius());
|
|||
|
|
pFireExtinguisher->SetProtectRadius(_tstof(sProtectRadius));
|
|||
|
|
sSpecification = dlg.GetSpecification();
|
|||
|
|
pFireExtinguisher->SetSpec(sSpecification);
|
|||
|
|
pFireExtinguisher->setLayer(InitLayer(LAY_TWT_EXTINGUISHER));
|
|||
|
|
|
|||
|
|
// 文字
|
|||
|
|
pFireExtinguisher->SetIsDim(dlg.IsDim() ? true : false);
|
|||
|
|
pFireExtinguisher->SetDimTextPos(fireExtinguisher.GetDimTextPos());
|
|||
|
|
pFireExtinguisher->SetTextStyleId(GlobalFunc::GetTextStyleId(dlg.GetTextStyle()));
|
|||
|
|
pFireExtinguisher->SetTextHeight(dlg.GetTextHeight());
|
|||
|
|
|
|||
|
|
double dScale = fireExtinguisher.GetScale();
|
|||
|
|
double dAngle = fireExtinguisher.GetAngle();
|
|||
|
|
pFireExtinguisher->SetAngle(dAngle);
|
|||
|
|
pFireExtinguisher->SetScale(dScale);
|
|||
|
|
pFireExtinguisher->SetScaleType(dlg.m_nScale);
|
|||
|
|
pFireExtinguisher->SetGrade(dlg.m_sGrade);
|
|||
|
|
|
|||
|
|
pFireExtinguisher->SetTextRotation(fireExtinguisher.GetTextRotation());
|
|||
|
|
pFireExtinguisher->SetTextAlignment(fireExtinguisher.GetTextAlignment());
|
|||
|
|
|
|||
|
|
pFireExtinguisher->SetLabelLoc(fireExtinguisher.GetLabelLoc());
|
|||
|
|
pFireExtinguisher->SetTextLayer(InitLayer(LAY_TWT_EXTINGUISHER_TEXT));
|
|||
|
|
pFireExtinguisher->SetBlock2d(GlobalFunc::GetBlkIdByName(sBlkName));
|
|||
|
|
pFireExtinguisher->SetSpecificationType(dlg.m_nSpecificationType);
|
|||
|
|
GlobalFunc::AddToCurrentSpace(pFireExtinguisher, Adesk::kTrue);
|
|||
|
|
//AcDbObjectId id = pFireExtinguisher->AddToCSpace(Adesk::kTrue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LayFireExtinguisher(Entity &entHydrant, CDbFireExtinguisher &entPreview, CLayFireExtinguisherDlg *pDlg)
|
|||
|
|
{
|
|||
|
|
if (pDlg == NULL)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 消火栓出入点,角度,尺寸
|
|||
|
|
AcDbObjectId idBlock2d;
|
|||
|
|
XPoint ptLoc;
|
|||
|
|
double dScaleX = 0.0, dScaleY = 0.0, dAngle = 0.0;
|
|||
|
|
BOOL bMirrorX = FALSE;
|
|||
|
|
OPENOBJ_BEGIN(entHydrant, AcDb::kForRead, CDbEquipment, pEuip);
|
|||
|
|
if (pEuip != NULL)
|
|||
|
|
{
|
|||
|
|
idBlock2d = pEuip->GetBlock2d();
|
|||
|
|
//ptLoc = pEuip->GetLocation();// zxl 2013.12.25 modify 改为设备基点,自动比例时,灭火器也要按照对应比例
|
|||
|
|
ptLoc = pEuip->GetInsert();
|
|||
|
|
if (pEuip->IsAutoScale())
|
|||
|
|
{
|
|||
|
|
dScaleX = pEuip->GetScale() * pEuip->GetPScale() / 100;
|
|||
|
|
dScaleY = pEuip->GetYScale() * pEuip->GetPScale() / 100;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
dScaleX = pEuip->GetScale();
|
|||
|
|
dScaleY = pEuip->GetYScale();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
dAngle = pEuip->GetAngle();
|
|||
|
|
bMirrorX = pEuip->IsMirrorByX();
|
|||
|
|
}
|
|||
|
|
OPENOBJ_END();
|
|||
|
|
|
|||
|
|
if (idBlock2d.isNull() && !ptLoc)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double dWidth = 0.0, dHeight = 0.0;
|
|||
|
|
AcGeScale3d scale(dScaleX, dScaleY, 1);
|
|||
|
|
GetBlkSize(idBlock2d, scale, dWidth, dHeight);
|
|||
|
|
// 布置灭火器
|
|||
|
|
entPreview.SetDimTextPos(true);
|
|||
|
|
if (bMirrorX) // 沿x轴镜像
|
|||
|
|
{
|
|||
|
|
dAngle += PI;
|
|||
|
|
}
|
|||
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|||
|
|
vtDir.rotateBy(dAngle + PI/2, AcGeVector3d::kZAxis);
|
|||
|
|
dAngle = GlobalFunc::Wcs2Ucs(dAngle);
|
|||
|
|
dAngle = GlobalFunc::AngleRangeTo2PI(dAngle);
|
|||
|
|
double dDist = 0.0;
|
|||
|
|
// 考虑图块插入点距图块外包框底边的高差 cet 2013.4.8 add
|
|||
|
|
double dScale = pDlg->GetScale() /** DocGetPScale() / 100*/; // 指定比例 cet 2013.4.8 modify // zxl 2013.12.25 modify
|
|||
|
|
if (pDlg->m_nScale == 0)
|
|||
|
|
{
|
|||
|
|
dScale = pDlg->GetScale() * GlobalFunc::DocGetPScale() / 100;
|
|||
|
|
}
|
|||
|
|
dDist = GetPtinsToExtentBottomDist(pDlg->GetSelBlkName()) * dScale;
|
|||
|
|
CString sBlkName = pDlg->GetSelBlkName();
|
|||
|
|
double dWidth2 = 0.0, dHeight2 = 0.0;
|
|||
|
|
double dTemp = pDlg->GetScale();
|
|||
|
|
AcGeScale3d scale2(dScale, dScale, 1);
|
|||
|
|
if (!GetBlkSize(sBlkName, scale2, dWidth2, dHeight2))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
entPreview.SetDimTextPos(true);
|
|||
|
|
if (dAngle > PI / 2 + 0.001 && dAngle < PI * 1.5 + 0.001 && pDlg->GetLayPos() == 1) // [PI, PI * 2)
|
|||
|
|
{
|
|||
|
|
dDist = dHeight2 - dDist; // 180度旋转图块,移动距离
|
|||
|
|
dAngle += PI;
|
|||
|
|
dAngle = GlobalFunc::AngleRangeTo2PI(dAngle);
|
|||
|
|
entPreview.SetDimTextPos(false);
|
|||
|
|
}
|
|||
|
|
dAngle = GlobalFunc::Ucs2Wcs(dAngle);
|
|||
|
|
dAngle = GlobalFunc::AngleRangeTo2PI(dAngle);
|
|||
|
|
entPreview.SetAngle(dAngle);
|
|||
|
|
AcGePoint3d ptIns = ptLoc + vtDir * (dHeight * 0.5 + dDist); // 灭火器与消火栓间距为消火栓宽度的高度的一半 // cet 2013.4.8 moidfy 紧贴消火栓
|
|||
|
|
entPreview.SetLocation(ptIns);
|
|||
|
|
|
|||
|
|
XPoint ptTextIns;
|
|||
|
|
vtDir = AcGeVector3d::kXAxis;
|
|||
|
|
vtDir.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|||
|
|
if (pDlg->GetLayDimType() == 0) // 按数量布置
|
|||
|
|
{
|
|||
|
|
if (!entPreview.GetDimTextPos())
|
|||
|
|
{
|
|||
|
|
vtDir.rotateBy(-PI/2, AcGeVector3d::kZAxis);
|
|||
|
|
ptTextIns = ptIns + vtDir * pDlg->GetTextHeight() * GlobalFunc::DocGetPScale();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
vtDir.rotateBy(PI/2, AcGeVector3d::kZAxis);
|
|||
|
|
ptTextIns = ptIns + vtDir * dHeight2 * 1.2;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else // 单布
|
|||
|
|
{
|
|||
|
|
ptTextIns = ptIns + vtDir * dWidth2 * 0.7;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
dAngle = GlobalFunc::Wcs2Ucs(dAngle);
|
|||
|
|
if(pDlg->GetLayDimType() != 0)
|
|||
|
|
{
|
|||
|
|
if (dAngle - 7 * PI / 4 < 0.001 && dAngle - PI * 3 / 4 > 0.001)
|
|||
|
|
{
|
|||
|
|
ptTextIns = ptIns - vtDir * dWidth2 * 0.7;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ptTextIns = ptIns + vtDir * dWidth2 * 0.7;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double dAngUcs = dAngle;
|
|||
|
|
AcGiViewDraw::TextAlignment align = AcGiViewDraw::kBottomCenter;
|
|||
|
|
if (dAngUcs - 7 * PI / 4 < 0.001 && dAngUcs - PI * 3 / 4 > 0.001)
|
|||
|
|
{
|
|||
|
|
dAngUcs -= PI;
|
|||
|
|
if (pDlg->GetLayDimType() == 1)
|
|||
|
|
{
|
|||
|
|
align = AcGiViewDraw::kTopLeft;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
align = AcGiViewDraw::kTopCenter;
|
|||
|
|
if (!entPreview.GetDimTextPos())
|
|||
|
|
{
|
|||
|
|
align = AcGiViewDraw::kBottomCenter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (pDlg->GetLayDimType() == 1)
|
|||
|
|
{
|
|||
|
|
align = AcGiViewDraw::kBottomLeft;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
align = AcGiViewDraw::kBottomCenter;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
entPreview.SetTextRotation(GlobalFunc::Ucs2Wcs(dAngUcs));
|
|||
|
|
entPreview.SetTextAlignment(align);
|
|||
|
|
|
|||
|
|
entPreview.SetLabelLoc(ptTextIns);
|
|||
|
|
entPreview.SetLayType(pDlg->GetLayDimType());
|
|||
|
|
entPreview.SetScale(pDlg->GetScale()); // 原始大小
|
|||
|
|
AddToCurSpace(*pDlg, entPreview); // 将灭火器插入当前模型空间
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 当前图纸上所有灭火器 cet 2013.4.22 add
|
|||
|
|
void GetCurAllFireExtinguisher(PickSet &ss)
|
|||
|
|
{
|
|||
|
|
RBList rbMask(RTDXF0, _T("AEC_ZT_EQUIPMENT"), 8, LAY_TWT_EXTINGUISHER, NULL);
|
|||
|
|
acedSSGet(_T("A"), NULL, NULL, rbMask, ss);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void LayFireExtinguisher()
|
|||
|
|
{
|
|||
|
|
// 获得图纸上所有灭火器 cet 2013.4.22 add
|
|||
|
|
PickSet ss(SS_FREE);
|
|||
|
|
GetCurAllFireExtinguisher(ss);
|
|||
|
|
int n = ss.Length();
|
|||
|
|
|
|||
|
|
GlobalFunc::DocGetPickFirst().Free();
|
|||
|
|
CTemporaryResourceOverride vTemp;
|
|||
|
|
static CLayFireExtinguisherDlg *pLayFireExtinguisherDlg = NULL;
|
|||
|
|
if (pLayFireExtinguisherDlg == NULL)
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg = new CLayFireExtinguisherDlg(IDD_LAY_FIRE_EXTINGUISHER, acedGetAcadFrame());
|
|||
|
|
pLayFireExtinguisherDlg->SetFireExtinguisher(ss);
|
|||
|
|
pLayFireExtinguisherDlg->Create(IDD_LAY_FIRE_EXTINGUISHER, acedGetAcadFrame());
|
|||
|
|
pLayFireExtinguisherDlg->ShowWindow(SW_SHOW);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->SetFireExtinguisher(ss);
|
|||
|
|
pLayFireExtinguisherDlg->ReStartForLay(FALSE);
|
|||
|
|
pLayFireExtinguisherDlg->SetFocus();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CDbFireExtinguisher *pFireE = new CDbFireExtinguisher; // 预览灭火器对象,可用于创建灭火器
|
|||
|
|
PickSet ssAdd(SS_FREE); // 执行命令过程中产生的灭火器 cet 2013.4.22 add
|
|||
|
|
PickSet ssCir(SS_FREE); // 保护半径显示的圆 cet 2013.4.22 add
|
|||
|
|
while(true)
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(TRUE);
|
|||
|
|
int nLayType = pLayFireExtinguisherDlg->GetLayType(); // 布置方式
|
|||
|
|
if (nLayType == 0) // 框选
|
|||
|
|
{
|
|||
|
|
RBList rbMask(RTDXF0, _T("AEC_ZT_EQUIPMENT"), 8, LAY_EQUIP_HYDRANT, NULL);
|
|||
|
|
PickSet ss(SS_FREE);
|
|||
|
|
int nRet = 0;
|
|||
|
|
TCHAR chKey;
|
|||
|
|
nRet = GlobalFunc::SelectEntities(_T("\n请选择消火栓的范围{选取闭合PLINE(P)}<退出>:"), ss, rbMask, _T("P"), chKey);
|
|||
|
|
if (nRet == RTKWORD) // 闭合PLINE
|
|||
|
|
{
|
|||
|
|
Entity entPoly;
|
|||
|
|
RBList rbMask2(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL);
|
|||
|
|
if(GlobalFunc::SelectEntity(_T("\n请选择表示范围的闭合PLINE:<退出>"), entPoly, rbMask2) != RTNORM)
|
|||
|
|
{
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
XPoly2D poly2(entPoly);
|
|||
|
|
XPoint ptLow3, ptUp3;
|
|||
|
|
poly2.GetExtend(ptLow3, ptUp3);;
|
|||
|
|
poly2.TransUCS(RBGroups(0), RBGroups(1));
|
|||
|
|
RBList rbFence = poly2.Fence();
|
|||
|
|
GlobalFunc::AssureInCurrentView_New(ptLow3, ptUp3);
|
|||
|
|
ss.Get(_T("CP"), rbFence, NULL, rbMask);
|
|||
|
|
}
|
|||
|
|
else if (nRet != RTNORM) // 退出
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ssAdd.IncludeBegin(); // 开始记录命令过程中产生的灭火器 cet 2013.4.22 add
|
|||
|
|
pFireE->SetProtectRadius(pLayFireExtinguisherDlg->GetProtectRadius());
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(TRUE);
|
|||
|
|
int nLen = ss.Length();
|
|||
|
|
for (long i = 0; i < nLen; ++i)
|
|||
|
|
{
|
|||
|
|
Entity ent(ss[i]);
|
|||
|
|
LayFireExtinguisher(ent, *pFireE, pLayFireExtinguisherDlg);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 更新当前灭火器数量 cet 2013.4.22 add
|
|||
|
|
ssAdd.IncludeEnd();
|
|||
|
|
nLen = ssAdd.Length();
|
|||
|
|
if (ssAdd.Length() > 0)
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->ShowProtectRadius(ssAdd);
|
|||
|
|
ssAdd.Free();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (nLayType == 1)
|
|||
|
|
// 任意布置
|
|||
|
|
{
|
|||
|
|
double dScale = pLayFireExtinguisherDlg->GetScale(), dAngle = GlobalFunc::Ucs2Wcs(0.0);
|
|||
|
|
pFireE->SetAngle(GlobalFunc::Ucs2Wcs(0.0));
|
|||
|
|
RANDOM_1:
|
|||
|
|
FireExtinguisherJig jig(pLayFireExtinguisherDlg, pFireE);
|
|||
|
|
//pFireE->ShowProtectRadius(true); // 显示保护半径 cet 2013.4.22 add
|
|||
|
|
jig.SetKeyWord(_T("A E D 1 2 3 4 5 6 7 8 9 = - 0"));
|
|||
|
|
jig.SetTipPrompt(_T("\n请指定灭火器的插入点 [90度旋转(A) /放大(E)/缩小(D)/2具(2)/3具(3)/4具(4)/5具(5)]<退出>"));
|
|||
|
|
int nRet = jig.doIt();
|
|||
|
|
if (nRet == RTKWORD)
|
|||
|
|
{
|
|||
|
|
int nKeyIndex = jig.GetKeyWordIndex();
|
|||
|
|
if (nKeyIndex == 0) // A
|
|||
|
|
{
|
|||
|
|
dAngle += PI / 2;
|
|||
|
|
dAngle = GlobalFunc::AngleRangeTo2PI(dAngle);
|
|||
|
|
jig.SetRotate(dAngle);
|
|||
|
|
}
|
|||
|
|
else if (nKeyIndex == 1) // E
|
|||
|
|
{
|
|||
|
|
dScale += 0.5;
|
|||
|
|
jig.SetScale(dScale);
|
|||
|
|
pLayFireExtinguisherDlg->SetScale(dScale);
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else if (nKeyIndex == 2) // D
|
|||
|
|
{
|
|||
|
|
if (dScale > 0.5)
|
|||
|
|
{
|
|||
|
|
dScale -= 0.5;
|
|||
|
|
jig.SetScale(dScale);
|
|||
|
|
pLayFireExtinguisherDlg->SetScale(dScale);
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (nKeyIndex >= 3 && nKeyIndex <= 11) // 1 - 9
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->SetCount(nKeyIndex - 2);
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else if (nKeyIndex == 12) // = 代表加
|
|||
|
|
{
|
|||
|
|
int nCount = pLayFireExtinguisherDlg->GetCount();
|
|||
|
|
pLayFireExtinguisherDlg->SetCount(++nCount);
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else if (nKeyIndex == 13) // - 代表减
|
|||
|
|
{
|
|||
|
|
int nCount = pLayFireExtinguisherDlg->GetCount();
|
|||
|
|
pLayFireExtinguisherDlg->SetCount(nCount > 1 ? --nCount : 1);
|
|||
|
|
pLayFireExtinguisherDlg->UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
// 将0作为关键字不进行任何操作,原因防止等待用户输入点时,键入0并回车后,选中一点插入灭火器
|
|||
|
|
// 此点非用户有意选中
|
|||
|
|
goto RANDOM_1;
|
|||
|
|
}
|
|||
|
|
else if (nRet == RTCAN || nRet == RTNONE || nRet == RTERROR)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ssAdd.IncludeBegin(); // 开始记录命令过程中产生的灭火器 cet 2013.4.22 add
|
|||
|
|
AddToCurSpace(*pLayFireExtinguisherDlg, *pFireE);
|
|||
|
|
// 更新当前灭火器数量 cet 2013.4.22 add
|
|||
|
|
ssAdd.IncludeEnd();
|
|||
|
|
if (ssAdd.Length() > 0)
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->ShowProtectRadius(ssAdd);
|
|||
|
|
ssAdd.Free();
|
|||
|
|
}
|
|||
|
|
goto RANDOM_1;
|
|||
|
|
}
|
|||
|
|
else// 沿线
|
|||
|
|
{
|
|||
|
|
double dScale = pLayFireExtinguisherDlg->GetScale(), dAngle = GlobalFunc::Ucs2Wcs(0.0);
|
|||
|
|
bool bBlk = false;
|
|||
|
|
XPoint ptPick;
|
|||
|
|
Entity entWall;
|
|||
|
|
RANDOM_2:
|
|||
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"), RTDXF0, _T("INSERT"), RTDXF0, _T("LWPOLYLINE"), RTDXF0, _T("LINE"), RTDXF0, _T("ARC"), RTDXF0, _T("ATS_WALL"), RTDXF0, _T("ATS_COLUMN"),
|
|||
|
|
-4, _T("or>"), NULL);
|
|||
|
|
int nRet(0);
|
|||
|
|
if (!bBlk)
|
|||
|
|
{
|
|||
|
|
INITGET_BEG(0, _T("R "));
|
|||
|
|
nRet = GlobalFunc::SelectEntity1(0.3, _T("\n请拾取布置消火栓的外部参照、直线、弧线 <退出>"), entWall, ptPick, rbMask);
|
|||
|
|
INITGET_END();
|
|||
|
|
|
|||
|
|
if (nRet != RTNORM && nRet != RTKWORD)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(entWall.Is(_T("INSERT")) && GlobalFunc::IsExternalBlock(entWall))
|
|||
|
|
{
|
|||
|
|
bBlk = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bBlk = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ptPick = GlobalFunc::Ucs2Wcs(ptPick);
|
|||
|
|
XCurveSegment seg; // 得到点所在的线段
|
|||
|
|
AcGeMatrix3d mat;
|
|||
|
|
Entity ent = entWall;
|
|||
|
|
seg = GetEntitySegByPt(ptPick, ent, mat);
|
|||
|
|
if(!seg)
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
double dAng = GlobalFunc::GetInsRotate(ptPick, seg);
|
|||
|
|
pFireE->SetAngle(dAng);
|
|||
|
|
pFireE->SetLocation(ptPick);
|
|||
|
|
FireExtinguisherJig jig(pLayFireExtinguisherDlg, pFireE, 1);
|
|||
|
|
jig.m_ptOnLine = ptPick;
|
|||
|
|
jig.SetKeyWord(_T("A E D 1 2 3 4 5 6 7 8 9 = - 0"));
|
|||
|
|
jig.SetTipPrompt(_T("\n请指定灭火器的方向:<退出>"));
|
|||
|
|
nRet = jig.doIt();
|
|||
|
|
|
|||
|
|
if (nRet == RTCAN || nRet == RTNONE || nRet == RTERROR)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ssAdd.IncludeBegin(); // 开始记录命令过程中产生的灭火器 cet 2013.4.22 add
|
|||
|
|
AddToCurSpace(*pLayFireExtinguisherDlg, *pFireE);
|
|||
|
|
// 更新当前灭火器数量 cet 2013.4.22 add
|
|||
|
|
ssAdd.IncludeEnd();
|
|||
|
|
long nLen = ssAdd.Length();
|
|||
|
|
PickSet ssDel;
|
|||
|
|
for (long i = 0; i < nLen; ++i)
|
|||
|
|
{
|
|||
|
|
if (ssAdd[i].Is(_T("AEC_DANHTEXT")))
|
|||
|
|
{
|
|||
|
|
ssDel += ssAdd[i];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
ssAdd -= ssDel;
|
|||
|
|
if (ssAdd.Length() > 0)
|
|||
|
|
{
|
|||
|
|
ss += ssAdd;
|
|||
|
|
pLayFireExtinguisherDlg->SetFireExtinguisher(ss);
|
|||
|
|
pLayFireExtinguisherDlg->ShowProtectRadius(ssAdd);
|
|||
|
|
ssAdd.Free();
|
|||
|
|
}
|
|||
|
|
goto RANDOM_2;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pFireE != NULL)
|
|||
|
|
{
|
|||
|
|
delete pFireE;
|
|||
|
|
pFireE = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!pLayFireExtinguisherDlg->IsReStartForLay())
|
|||
|
|
{
|
|||
|
|
pLayFireExtinguisherDlg->DeleteProtectRadius(); // cet 2013.4.22 add 删除保护半径
|
|||
|
|
pLayFireExtinguisherDlg->DestroyWindow();
|
|||
|
|
delete pLayFireExtinguisherDlg;
|
|||
|
|
pLayFireExtinguisherDlg = NULL;
|
|||
|
|
acedUpdateDisplay();
|
|||
|
|
actrTransactionManager->flushGraphics();
|
|||
|
|
}
|
|||
|
|
//PostCommand(_T("REGEN "));
|
|||
|
|
}
|
|||
|
|
|