3377 lines
88 KiB
C++
3377 lines
88 KiB
C++
#include "stdafx.h"
|
||
#include "resource.h"
|
||
#include <migrtion.h>
|
||
|
||
#include "ThunderCmdGroup.h"
|
||
#include "ThunderDbReactor.h"
|
||
#include "ThunderEditReactor.h"
|
||
#include "ThunderCaculate.h"
|
||
#include "LightningRodData.h"
|
||
#include "DrawThunder2D.h"
|
||
#include "ThunderXData.h"
|
||
#include "LayPinDlg.h"
|
||
#include "ThunderSetDlg.h"
|
||
#include "ThunderEditReactor.h"
|
||
#include "ThunderPolyLineJig.h"
|
||
#include "DrawSheet.h"
|
||
#include "CreateWordApp.h"
|
||
#include "dbgroup.h"
|
||
#include "dbxutil.h"
|
||
#include "TReactorAssociate.h"
|
||
#include "TThunderSectionJig.h"
|
||
#include "TViewPortThunders.h"
|
||
#include "ThunderLineSetDlg.h"
|
||
#include "LableThunderBX.h"
|
||
#include "FoldPinJig.h"
|
||
#include "FoldLayPinDlg.h"
|
||
#include "FoldSetDlg.h"
|
||
#include "FoldPinRelation.h"
|
||
#include "FoldToolKit.h"
|
||
#include "ktsetting.h"
|
||
|
||
#ifdef _DEBUG
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[]=__FILE__;
|
||
#define new DEBUG_NEW
|
||
#endif
|
||
|
||
|
||
IMPLEMENT_DYNCREATE(CThunderCmdGroup, ArxCmdGroup)
|
||
BOOL CThunderCmdGroup::bIsAllowDraw = TRUE;
|
||
BOOL CThunderCmdGroup::bExecute = FALSE;
|
||
BOOL CThunderCmdGroup::bReDraw = FALSE;
|
||
BOOL CThunderCmdGroup::bReDrawFold = TRUE;
|
||
|
||
CThunderCmdGroup::CThunderCmdGroup()
|
||
{
|
||
m_pThunderReactor = new CThunderDbReactor();
|
||
m_pThunderDocReactor = new TelThunderDocReactor;
|
||
m_pThunderDraw2d = new CDrawThunderTools;
|
||
m_pThunderEditReactor = new TelThunderEditReactor(this);
|
||
}
|
||
|
||
CThunderCmdGroup::~CThunderCmdGroup()
|
||
{
|
||
if (m_pThunderReactor != NULL)
|
||
{
|
||
delete m_pThunderReactor;
|
||
m_pThunderReactor = NULL;
|
||
}
|
||
if (m_pThunderDraw2d != NULL)
|
||
{
|
||
delete m_pThunderDraw2d;
|
||
m_pThunderDraw2d = NULL;
|
||
}
|
||
if (m_pThunderDocReactor != NULL)
|
||
{
|
||
delete m_pThunderDocReactor;
|
||
m_pThunderDocReactor = NULL;
|
||
}
|
||
if (m_pThunderEditReactor != NULL)
|
||
{
|
||
delete m_pThunderEditReactor;
|
||
m_pThunderEditReactor = NULL;
|
||
}
|
||
|
||
TContainerSingleton::ReleaseInstance();
|
||
CFoldToolKit::DisInstance();
|
||
CFoldPinRelation::DisInstance();
|
||
}
|
||
|
||
BEGIN_AEC_ARXCMD_MAP(CThunderCmdGroup,THUNDERPROOF)
|
||
//{{AFX_AEC_ARX_CMD(TGTPMCmdGroup)
|
||
//滚球法
|
||
ON_AEC_ARXCMD(Thunder_test, Thunder_test, ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, ThunderTest) //测试
|
||
ON_AEC_ARXCMD(EL_BLSZ, EL_BLSZ, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderSetPinCmd) //避雷设置
|
||
ON_AEC_ARXCMD(EL_CBLZ, EL_CBLZ, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderLayPinCmd) //插避雷针
|
||
ON_AEC_ARXCMD(EL_GBLZ, EL_GBLZ, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderEditPinCmd) //改避雷针
|
||
ON_AEC_ARXCMD(EL_SBLZ, EL_SBLZ, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderErasePinCmd) //删避雷针
|
||
ON_AEC_ARXCMD(EL_DZYD, EL_DZYD, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderMovePinCmd) //单针移动
|
||
|
||
ON_AEC_ARXCMD(EL_HBLX, EL_HBLX,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, DrawThunderLine) //绘制避雷线
|
||
ON_AEC_ARXCMD(EL_GBLX, EL_GBLX,ACRX_CMD_MODAL|ACRX_CMD_USEPICKSET,ThunderEditLineCmd) //改避雷线
|
||
ON_AEC_ARXCMD(EL_SBLX, EL_SBLX,ACRX_CMD_MODAL|ACRX_CMD_USEPICKSET,ThunderEraseLineCmd) //删避雷线
|
||
ON_AEC_ARXCMD(EL_DXYD, EL_DXYD, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderMoveLineCmd) //单线移动
|
||
ON_AEC_ARXCMD(EL_SPER, EL_SPER, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, newspheretest) //单线移动测试
|
||
|
||
ON_AEC_ARXCMD(EL_BZBJ, ELBZBJ, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderDimentRadiusCmd)//标注半径
|
||
ON_AEC_ARXCMD(EL_BZBX, EL_BZBX, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderDimentBxCmd) //标注BX
|
||
ON_AEC_ARXCMD(EL_DBLB, EL_DBLB, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderSinSheetCmd) //单避雷表
|
||
ON_AEC_ARXCMD(EL_SBLB, EL_SBLB, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderDblSheetCmd) //双避雷表
|
||
ON_AEC_ARXCMD(EL_BLPQ, EL_BLPQ,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, ThunderSection) //避雷剖切
|
||
ON_AEC_ARXCMD(EL_LJSS, EL_LJSS,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, ThunderCaculateBook) //雷计算书
|
||
|
||
ON_AEC_ARXCMD(EL_JZGD, EL_JZGD,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, ThunderArchHeight) //赋高度
|
||
ON_AEC_ARXCMD(EL_CKSW, EL_CKSW, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderPart3DCmd) //查看三维
|
||
ON_AEC_ARXCMD(EL_HYEW, EL_HYEW, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, ThunderPart3DBackCmd) //还原二维
|
||
|
||
ON_AEC_ARXCMD(EL_SPTT,EL_SPTT,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, Sphere) //测试
|
||
ON_AEC_ARXCMD(EL_DBLEDT, EL_DBLEDT,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, DblEditThunder) //双击编辑避雷针
|
||
ON_AEC_ARXCMD(EL_DBDEDT, EL_DBDEDT,ACRX_CMD_MODAL| ACRX_CMD_USEPICKSET, DbDEditThunder) //双击编辑避雷带
|
||
|
||
//折线法
|
||
ON_AEC_ARXCMD(EL_BLSZF, EL_BLSZF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldSetPinCmd) //避雷设置
|
||
ON_AEC_ARXCMD(EL_CBLZF, EL_CBLZF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldLayPinCmd) //插避雷针
|
||
ON_AEC_ARXCMD(EL_GBLZF, EL_GBLZF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldEditPinCmd) //改避雷针
|
||
ON_AEC_ARXCMD(EL_SBLZF, EL_SBLZF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldErasePinCmd) //删避雷针
|
||
ON_AEC_ARXCMD(EL_DZYDF, EL_DZYDF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldMovePinCmd) //单针移动
|
||
ON_AEC_ARXCMD(EL_test1, EL_test1, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, maptest) //测试
|
||
|
||
ON_AEC_ARXCMD(EL_BZBJF, EL_BZBJF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldDimentRadiusCmd)//标注半径
|
||
ON_AEC_ARXCMD(EL_BZBXF, EL_BZBXF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldDimentBxCmd) //标注BX
|
||
ON_AEC_ARXCMD(EL_DBLBF, EL_DBLBF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldSinSheetCmd) //单避雷表
|
||
ON_AEC_ARXCMD(EL_SBLBF, EL_SBLBF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldDblSheetCmd) //双避雷表
|
||
ON_AEC_ARXCMD(EL_LJSSF, EL_LJSSF, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, FoldCalcBookCmd) //雷计算书
|
||
|
||
//}}AFX_AEC_ARX_CMD
|
||
END_AEC_ARXCMD_MAP(CThunderCmdGroup)
|
||
|
||
//加入命令
|
||
void CThunderCmdGroup::OnAddCommands()
|
||
{
|
||
ArxCmdGroup::OnAddCommands();
|
||
OnLoadApp();
|
||
}
|
||
|
||
//移除命令
|
||
void CThunderCmdGroup::OnRemoveCommands()
|
||
{
|
||
ArxCmdGroup::OnRemoveCommands();
|
||
OnUnloadApp();
|
||
}
|
||
|
||
void CThunderCmdGroup::ThunderDraw()
|
||
{
|
||
if (m_pThunderDraw2d != NULL)
|
||
{
|
||
TCurDocumentLock lockDoc;
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
|
||
AcGeDoubleArray arProHeight;
|
||
TContainerSingleton::LstProHeightMap mapData;
|
||
TContainerSingleton::LstProHeightMap::iterator it;
|
||
|
||
ThunderContainer->GetProHeightMap(mapData);
|
||
for (it = mapData.begin();it != mapData.end();++it)
|
||
{
|
||
ThunderContainer->GetGroupProHeight(it->first, arProHeight);
|
||
m_pThunderDraw2d->DrawThunder2DArea(arProHeight,it->first);
|
||
}
|
||
|
||
ThunderContainer->GetProLineHeightMap(mapData);
|
||
for (it = mapData.begin();it != mapData.end();++it)
|
||
{
|
||
ThunderContainer->GetGroupLineProHeight(it->first, arProHeight);
|
||
m_pThunderDraw2d->DrawThunderLine(it->first, arProHeight);
|
||
}
|
||
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
|
||
|
||
acedUpdateDisplay();
|
||
actrTransactionManager->flushGraphics();
|
||
ThunderContainer->ClearProHeight();
|
||
ThunderContainer->ClearLineProHeight();
|
||
}
|
||
}
|
||
|
||
int CThunderCmdGroup::Sphere()
|
||
{
|
||
ads_point ptUser1,ptUser2,ptUser3;
|
||
double dShpere = 0.0;
|
||
if (acedGetPoint(NULL,_T("\n 请选择第一点"),ptUser1) != RTNORM)
|
||
return 0;
|
||
|
||
if (acedGetPoint(NULL,_T("\n 请选择第二点"),ptUser2) != RTNORM)
|
||
return 0;
|
||
|
||
if (acedGetPoint(NULL,_T("\n 请选择第三点"),ptUser3) != RTNORM)
|
||
return 0;
|
||
|
||
if (acedGetReal(_T("\n 请给出圆半径:"),&dShpere) != RTNORM)
|
||
return 0;
|
||
|
||
AcGePoint3d pt1,pt2,pt3;
|
||
pt1 = Ucs2Wcs(asPnt3d(ptUser1));
|
||
pt2 = Ucs2Wcs(asPnt3d(ptUser2));
|
||
pt3 = Ucs2Wcs(asPnt3d(ptUser3));
|
||
|
||
AcGePoint3d ptCenter;
|
||
AcGePlane plan(pt1,pt2,pt3);
|
||
AcGeVector3d vecNormal = plan.normal();
|
||
|
||
AcGeVector3d vec12,vec23,vec31;
|
||
vec12 = pt1 - pt2;
|
||
vec23 = pt2 - pt3;
|
||
vec31 = pt3 - pt1;
|
||
|
||
AcGeVector3d vecNormal12,vecNormal23,vecNormal31;
|
||
AcGePlane plan12(pt1,vec12,vecNormal);
|
||
AcGePlane plan23(pt2,vec23,vecNormal);
|
||
AcGePlane plan31(pt3,vec31,vecNormal);
|
||
|
||
vecNormal12 = plan12.normal();
|
||
vecNormal23 = plan23.normal();
|
||
vecNormal31 = plan31.normal();
|
||
vecNormal12.normalize();
|
||
vecNormal23.normalize();
|
||
vecNormal31.normalize();
|
||
|
||
//得到各边中点
|
||
AcGePoint3d ptCen12,ptCen23,ptCen31;
|
||
ptCen12.x = (pt1.x + pt2.x)/2;
|
||
ptCen12.y = (pt1.y + pt2.y)/2;
|
||
ptCen12.z = (pt1.z + pt2.z)/2;
|
||
ptCen23.x = (pt3.x + pt2.x)/2;
|
||
ptCen23.y = (pt3.y + pt2.y)/2;
|
||
ptCen23.z = (pt3.z + pt2.z)/2;
|
||
ptCen31.x = (pt1.x + pt3.x)/2;
|
||
ptCen31.y = (pt1.y + pt3.y)/2;
|
||
ptCen31.z = (pt1.z + pt3.z)/2;
|
||
|
||
AcGePoint3d ptEnd12,ptEnd23,ptEnd31;
|
||
ptEnd12 = ptCen12 + vecNormal12*dShpere;
|
||
ptEnd23 = ptCen23 + vecNormal23*dShpere;
|
||
ptEnd31 = ptCen31 + vecNormal31*dShpere;
|
||
|
||
AcDbLine line12(ptCen12,ptEnd12);
|
||
AcDbLine line23(ptCen23,ptEnd23);
|
||
|
||
AcGePoint3dArray arPts;
|
||
line12.intersectWith(&line23,AcDb::kExtendBoth,arPts);
|
||
if (arPts.length() != 1)
|
||
return 0;
|
||
|
||
//中垂线交点到点距离
|
||
double dDis = arPts[0].distanceTo(pt1);
|
||
//球心到面的投影距离
|
||
double dDisPer = pow(pow(dShpere,2) - pow(dDis,2),0.5);
|
||
vecNormal.normalize();
|
||
ptCenter = arPts[0] + vecNormal*dDisPer;
|
||
|
||
AcDb3dSolid *pSolid1 = new AcDb3dSolid;
|
||
AcDb3dSolid *pSolid2 = new AcDb3dSolid;
|
||
|
||
Acad::ErrorStatus es;
|
||
es = pSolid1->createSphere(dShpere);
|
||
AcGeMatrix3d matrix;
|
||
matrix.setCoordSystem(ptCenter,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,AcGeVector3d::kZAxis);
|
||
pSolid1->transformBy(matrix);
|
||
|
||
ptCenter = arPts[0] - vecNormal*dDisPer;
|
||
es = pSolid2->createSphere(dShpere);
|
||
matrix.setCoordSystem(ptCenter,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,AcGeVector3d::kZAxis);
|
||
pSolid2->transformBy(matrix);
|
||
|
||
AddToCurrentSpace(pSolid1,Adesk::kTrue);
|
||
AddToCurrentSpace(pSolid2,Adesk::kTrue);
|
||
|
||
return 1;
|
||
}
|
||
|
||
int CThunderCmdGroup::ThunderTest()
|
||
{
|
||
// 截取圆弧
|
||
Entity entCir;
|
||
RBList rb = acutBuildList(RTDXF0, _T("CIRCLE"), NULL);
|
||
|
||
AcGePoint3d ptCen,ptS,ptE;
|
||
if (SelectEntity(_T("\n 选择圆 <退出>:"), entCir,rb) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
ads_point ptCn;
|
||
if (acedGetPoint(NULL, _T("\n 点取弧起点 <退出>:"), ptCn) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
ptS = Ucs2Wcs(asPnt3d(ptCn));
|
||
|
||
if (acedGetPoint(NULL, _T("\n 点取弧终点 <退出>:"), ptCn) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
ptE = Ucs2Wcs(asPnt3d(ptCn));
|
||
|
||
OPENOBJ_BEGIN(entCir,AcDb::kForRead,AcDbCircle,pCir);
|
||
if (pCir != NULL)
|
||
{
|
||
double dPara,dPara2;
|
||
pCir->getParamAtPoint(ptS,dPara);
|
||
pCir->getParamAtPoint(ptE,dPara2);
|
||
|
||
if (dPara < dPara2)
|
||
{
|
||
double dT = dPara2;
|
||
dPara2 = dPara;
|
||
dPara = dT;
|
||
}
|
||
|
||
AcDbArc* pArc = new AcDbArc(pCir->center(),pCir->radius(),dPara2,dPara);
|
||
pArc->setColorIndex(1);
|
||
AddToCurrentSpace(pArc,Adesk::kTrue);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
return 0;
|
||
|
||
Entity ent;
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("3dsolid"), NULL);
|
||
if(SelectEntity(_T("\n 请选择实体<退出>:"), ent, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
PickSet ssSub(SS_FREE);
|
||
if (SelectEntities(_T("\n 请选择需要减去的实体<退出>"), ssSub, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDb3dSolid,pMainSolid);
|
||
if (pMainSolid != NULL)
|
||
{
|
||
AcDb3dSolid* pNewMain = new AcDb3dSolid;
|
||
pNewMain->copyFrom(pMainSolid);
|
||
|
||
AcDb3dSolid* pNewSub = NULL;
|
||
for (long i = 0;i < ssSub.Length();++i)
|
||
{
|
||
OPENOBJ_BEGIN(ssSub[i],AcDb::kForRead,AcDb3dSolid,pSubSolid);
|
||
if (pSubSolid != NULL)
|
||
{
|
||
pNewSub = new AcDb3dSolid;
|
||
pNewSub->copyFrom(pSubSolid);
|
||
|
||
Acad::ErrorStatus es = pNewMain->booleanOper(AcDb::kBoolSubtract, pNewSub);
|
||
|
||
delete pNewSub;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
AddToCurrentSpace(pNewMain, Adesk::kTrue);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 单针插入命令
|
||
int CThunderCmdGroup::ThunderLayPinCmd()
|
||
{
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_2D);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_3D);
|
||
KTSetting::InitLayer(LAY_EL_TEXT);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER);
|
||
KTSetting::InitLayer(LAY_PREVIEW_THUNDER);
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
CLayPinDlg dlg;
|
||
if (!dlg.DoModeless())
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AdjustWndToViewport(&dlg);
|
||
|
||
dlg.SetThunderDraw2d(m_pThunderDraw2d);
|
||
// 插入避雷针
|
||
if (m_pThunderDraw2d != NULL)
|
||
{
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
|
||
}
|
||
|
||
TTempDrawState temp(FALSE);
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
|
||
AcDbObjectId idThunder;
|
||
while (true)
|
||
{
|
||
// 插入避雷针
|
||
if (!dlg.InsertThunderBlock(idThunder))
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
dlg.DestroyWindow();
|
||
acedPostCommand(_T("\33"));
|
||
return 0;
|
||
}
|
||
|
||
// 单针设置命令
|
||
int CThunderCmdGroup::ThunderSetPinCmd()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CThunderSetDlg dlg;
|
||
dlg.DoModal();
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 单针编辑命令
|
||
int CThunderCmdGroup::ThunderEditPinCmd()
|
||
{
|
||
Entity ent;
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("INSERT,LWPOLYLINE"), NULL);
|
||
if(SelectEntity(_T("\n 请在编号上选择要编辑的避雷针<退出>:"), ent, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 获取避雷针ID
|
||
AcDbObjectId idThunder;
|
||
if (acdbGetObjectId(idThunder, ent) != Acad::eOk)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CLayPinDlg dlg(idThunder, TRUE);
|
||
dlg.SetDbReactorPtr(m_pThunderReactor);
|
||
dlg.DoModal();
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 双击编辑避雷针
|
||
// 双击编辑避雷针
|
||
int CThunderCmdGroup::DblEditThunder()
|
||
{
|
||
AcDbObjectId idThunder;
|
||
PickSet ssThunder(SS_FREE);
|
||
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("INSERT"), NULL);
|
||
ssThunder.Get(_T("I"), NULL, NULL, rbMask);
|
||
long sss = ssThunder.Length();
|
||
if (ssThunder.Length() == 1)
|
||
{
|
||
if (acdbGetObjectId(idThunder, ssThunder[0l]) != Acad::eOk)
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//滚球避雷针
|
||
ssThunder.Free();
|
||
RBList rbMask2 = ads_buildlist(RTDXF0, _T("CIRCLE"), RTNONE);
|
||
ssThunder.Get(_T("I"), NULL, NULL, rbMask2);
|
||
sss = ssThunder.Length();
|
||
CThunderXData thunderXData;
|
||
if (ssThunder.Length() > 0)
|
||
{
|
||
// 获取圆的id
|
||
AcDbObjectId idCir;
|
||
if (acdbGetObjectId(idCir, ssThunder[0l]) != Acad::eOk)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 由圆id获取避雷针ID
|
||
if (!thunderXData.GetEntityIdFromExData(idCir, idThunder, TEL_THUNDER_ID))
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//折线避雷针
|
||
ssThunder.Free();
|
||
RBList rbMask2 = ads_buildlist(RTDXF0, _T("CIRCLE"), RTNONE);
|
||
ssThunder.Get(_T("I"), NULL, NULL, rbMask2);
|
||
sss = ssThunder.Length();
|
||
if (ssThunder.Length() > 0)
|
||
{
|
||
// 获取圆的id
|
||
AcDbObjectId idCir;
|
||
if (acdbGetObjectId(idCir, ssThunder[0l]) != Acad::eOk)
|
||
{
|
||
return 0;
|
||
}
|
||
// 由圆id获取避雷针ID
|
||
if (!thunderXData.GetXData(idCir, KEY_FOLD_THUNDER_ID,idThunder))
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
else
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CThunderXData thunderXData;
|
||
CString sType = _T("");
|
||
thunderXData.GetXData(idThunder,TEL_THUNDER_TYPE,sType);
|
||
if (sType.CompareNoCase(_T("1")) == 0)
|
||
{
|
||
//折线避雷针
|
||
CFoldLayPinDlg dlg(idThunder,TRUE);
|
||
dlg.DoModal();
|
||
}
|
||
else
|
||
{
|
||
CLayPinDlg dlg(idThunder, TRUE);
|
||
dlg.SetDbReactorPtr(m_pThunderReactor);
|
||
dlg.DoModal();
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::DbDEditThunder()
|
||
{
|
||
PickSet ssThunder(SS_FREE);
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("LWPOLYLINE"),RTNONE);
|
||
|
||
ssThunder.Get(_T("I"), NULL, NULL, rbMask);
|
||
|
||
long sss = ssThunder.Length();
|
||
if(sss < 1)
|
||
return 0;
|
||
|
||
CThunderXData ThunderXData;
|
||
CString sNo = _T("");
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
AcDbObjectId idThunder;
|
||
acdbGetObjectId(idThunder, ssThunder[0l]);
|
||
|
||
ThunderXData.GetXData(idThunder,KEY_LINE_GROUP_NO,sNo);
|
||
if (!sNo.IsEmpty())
|
||
{
|
||
CThunderLineSetDlg dlg;
|
||
dlg.SetUseType(CThunderLineSetDlg::eEdit);
|
||
dlg.SetCurrectThunderLine(idThunder);
|
||
dlg.DoModal();
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
// 避雷针删除命令
|
||
int CThunderCmdGroup::ThunderErasePinCmd()
|
||
{
|
||
// 过滤框选的圆
|
||
PickSet ssAll(SS_FREE);
|
||
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("CIRCLE"), 8, LAY_EL_THUNDER_2D, -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("INSERT"), 8, LAY_EL_THUNDER, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
// 选择要删除的避雷针
|
||
if(SelectEntities(_T("\n 请在编号上选择要删除的避雷针:<退出>"), ssAll, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
// 删除
|
||
// 避免重复删除
|
||
AcDbObjectIdArray arThunderId;
|
||
ads_name entName;
|
||
int nPos = -1;
|
||
CThunderXData thunderXData;
|
||
AcDbObjectId idCircle, idThunder;
|
||
int nNo = -1;
|
||
for (long i = 0;i < ssAll.Length();i++)
|
||
{
|
||
Entity ent = ssAll[i];
|
||
//判断是否滚球法避雷针
|
||
if (thunderXData.GetGroupNO(ent) > 0)
|
||
{
|
||
if (acdbGetObjectId(idCircle, ssAll[i]) == Acad::eOk)
|
||
{
|
||
|
||
if (ent.Is(_T("CIRCLE")))
|
||
{
|
||
// 获取避雷針id
|
||
thunderXData.GetEntityIdFromExData(idCircle, idThunder, TEL_THUNDER_ID);
|
||
|
||
OPENOBJ_BEGIN(idCircle, AcDb::kForRead, AcDbCircle, pCircle);
|
||
if(pCircle)
|
||
{
|
||
// 删除标注信息(如果存在)
|
||
DeleteOldDim(pCircle);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
idThunder = idCircle;
|
||
}
|
||
|
||
if (idThunder.isValid())
|
||
{
|
||
if (!arThunderId.find(idThunder, nPos, 0))
|
||
{
|
||
arThunderId.append(idThunder);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
CString sNo;
|
||
AcGeDoubleArray arProHeight;
|
||
for (int j = 0;j < arThunderId.length();++j)
|
||
{
|
||
thunderXData.GetProtectHeightFromObjEx(arThunderId[j], arProHeight);
|
||
ThunderContainer->GetThunderGroupNo(arThunderId[j], sNo);
|
||
ThunderContainer->AppendProHeight(sNo, arProHeight);
|
||
ThunderContainer->RemoveThunder(sNo, arThunderId[j]);
|
||
if (acdbGetAdsName(entName, arThunderId[j]) == Acad::eOk)
|
||
{
|
||
// 删除避雷针
|
||
acdbEntDel(entName);
|
||
}
|
||
}
|
||
|
||
CThunderCmdGroup::bExecute = TRUE;
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 单针移动命令
|
||
int CThunderCmdGroup::ThunderMovePinCmd()
|
||
{
|
||
// 获取需要移动的避雷针
|
||
Entity ent;
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("INSERT"), NULL);
|
||
if(SelectEntity(_T("\n 请在编号上选择要移动的避雷针<退出>:\n"), ent, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 获取避雷针的idThunder
|
||
AcDbObjectId idThunder;
|
||
AcGePoint3d ptOld;
|
||
CThunderXData thunderXdata;
|
||
//如果不是滚球法避雷针
|
||
if(thunderXdata.GetGroupNO(ent) <= 0)
|
||
return 0;
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbBlockReference,pRef);
|
||
if (pRef != NULL)
|
||
{
|
||
ptOld = pRef->position();
|
||
idThunder = pRef->objectId();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
ads_point ptDes;
|
||
if (acedGetPoint(asDblArray(ptOld), _T("\n 请选择要移动到的位置<退出>: "), ptDes) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
|
||
// 获取要移动到的位置点
|
||
acdbUcs2Wcs(ptDes, ptDes, false);
|
||
AcGePoint3d ptInsert = asPnt3d(ptDes);
|
||
|
||
// 得到偏移矩阵
|
||
AcGeMatrix3d matThund;
|
||
ptInsert.z = 0;
|
||
ptOld.z = 0;
|
||
AcGeVector3d vtThunder = ptInsert - ptOld;
|
||
matThund.setToTranslation(vtThunder);
|
||
|
||
// 移动避雷针
|
||
AcDbEntity* pEnt = NULL;
|
||
if (acdbOpenAcDbEntity(pEnt, idThunder, AcDb::kForWrite) == Acad::eOk)
|
||
{
|
||
pEnt->transformBy(matThund);
|
||
pEnt->close();
|
||
}
|
||
|
||
CString sNo;
|
||
CThunderXData thunderXData;
|
||
AcGeDoubleArray arProHeight;
|
||
thunderXData.GetProtectHeightFromObjEx(idThunder, arProHeight);
|
||
|
||
ThunderContainer->GetThunderGroupNo(idThunder, sNo);
|
||
ThunderContainer->AppendProHeight(sNo, arProHeight);
|
||
|
||
CThunderCmdGroup::bExecute = TRUE;
|
||
|
||
return 0;
|
||
}
|
||
|
||
void CThunderCmdGroup::RecursiveExplodeGetArcAndCir(AcDbEntity* pEnt, AcDbVoidPtrArray& arPtr)
|
||
{
|
||
if (pEnt != NULL)
|
||
{
|
||
AcDbArc* pArc = AcDbArc::cast(pEnt);
|
||
if (pArc != NULL) // 圆弧
|
||
{
|
||
AcDbArc* pNewArc = new AcDbArc;
|
||
pNewArc->copyFrom(pArc);
|
||
arPtr.append(pNewArc);
|
||
}
|
||
else
|
||
{
|
||
AcDbCircle* pCir = AcDbCircle::cast(pEnt);
|
||
if (pCir != NULL) // 圆
|
||
{
|
||
AcDbCircle* pNewCir = new AcDbCircle;
|
||
pNewCir->copyFrom(pCir);
|
||
arPtr.append(pNewCir);
|
||
}
|
||
else // 其它
|
||
{
|
||
AcDbVoidPtrArray arLoc;
|
||
pEnt->explode(arLoc);
|
||
for (int i = 0;i < arLoc.length();++i)
|
||
{
|
||
RecursiveExplodeGetArcAndCir((AcDbEntity*)arLoc[i], arPtr);
|
||
delete (AcDbEntity*) arLoc[i];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 标注半径命令
|
||
int CThunderCmdGroup::ThunderDimentRadiusCmd()
|
||
{
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
TTempDrawState temp(FALSE);
|
||
|
||
//增加避雷线标注
|
||
RBList rbMask(RTDXF0, _T("CIRCLE,REGION"),8,LAY_EL_THUNDER_2D,NULL);
|
||
XPoint ptStart,ptEnd,ptPick;
|
||
Entity ent;
|
||
int nRet = SelectEntity1(_T("\n 请选择要标注的对象(圆或面域):<退出>"), ent, ptPick, rbMask);
|
||
if(nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
CThunderXData thunXData;
|
||
|
||
//滚球法避雷针判断
|
||
if (thunXData.GetGroupNO(ent) <= 0)
|
||
return 0;
|
||
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
AcDbCircle* pCircle = NULL;
|
||
AcDbRegion* pRegion = NULL;
|
||
AcDbArc* pArc = NULL;
|
||
CString sProH;
|
||
double dProH = 0.0;
|
||
|
||
AcDbVoidPtrArray arPtrs;
|
||
|
||
|
||
BOOL bSel = FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
pCircle = AcDbCircle::cast(pEnt);
|
||
if(pCircle != NULL)
|
||
{
|
||
CString strHeight = _T("");
|
||
// 获取当前避雷针的保护高度
|
||
thunXData.GetXData(pCircle,TEL_CURRENT_PROHEIGHT,sProH);
|
||
dProH = _tstof(sProH);
|
||
int nMode = OS_INS|OS_INT|OS_NEA|XD_POINT|OS_MID|OS_CEN|OS_END;
|
||
XPushVar<int> vOsModeOpen(_T("OSMODE"), nMode);
|
||
ptStart = pCircle->center();
|
||
bSel = TRUE;
|
||
}
|
||
else
|
||
{
|
||
pRegion = AcDbRegion::cast(pEnt);
|
||
if (pRegion != NULL)
|
||
{
|
||
int nMode = OS_INS|OS_INT|OS_NEA|XD_POINT|OS_MID|OS_CEN|OS_END;
|
||
XPushVar<int> vOsModeOpen(_T("OSMODE"), nMode);
|
||
thunXData.GetXData(pRegion,TEL_CURRENT_PROHEIGHT,sProH);
|
||
dProH = _tstof(sProH);
|
||
|
||
RecursiveExplodeGetArcAndCir(pRegion, arPtrs);
|
||
|
||
//AcGePoint3d ptM1,ptM2;
|
||
AcDbEntity* pTemp = NULL;
|
||
|
||
//AcDbArc* pArc1 = NULL;
|
||
//AcDbArc* pArc2 = NULL;
|
||
//double dRaidus = 0.0;
|
||
|
||
double dTmp;
|
||
std::multimap<double,void*> mapTmp;
|
||
|
||
for (int i = 0;i < arPtrs.length();i++)
|
||
{
|
||
pTemp = (AcDbEntity*)arPtrs[i];
|
||
pArc = AcDbArc::cast(pTemp);
|
||
if (pArc != NULL)
|
||
{
|
||
dTmp = ptPick.Distance(pArc->center());
|
||
mapTmp.insert(std::make_pair(dTmp,pArc));
|
||
}
|
||
else
|
||
{
|
||
pCircle = AcDbCircle::cast(pTemp);
|
||
dTmp = ptPick.Distance(pCircle->center());
|
||
mapTmp.insert(std::make_pair(dTmp,pCircle));
|
||
}
|
||
}
|
||
|
||
if (mapTmp.size() > 0)
|
||
{
|
||
AcDbEntity* pNew = (AcDbEntity*)mapTmp.begin()->second;
|
||
pArc = AcDbArc::cast(pNew);
|
||
if (pArc != NULL)
|
||
{
|
||
ptStart = pArc->center();
|
||
bSel = TRUE;
|
||
}
|
||
else
|
||
{
|
||
pCircle = AcDbCircle::cast(pNew);
|
||
if (pCircle != NULL)
|
||
{
|
||
ptStart = pCircle->center();
|
||
bSel = TRUE;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
if (bSel)
|
||
{
|
||
TelThunderPolyLineJig jig;
|
||
jig.SetPLinePoints(ptStart,ptPick);
|
||
jig.SetHeight(dProH);
|
||
if (pCircle)
|
||
{
|
||
jig.SetEntity(pCircle);
|
||
}
|
||
else
|
||
{
|
||
jig.SetEntity(pArc);
|
||
}
|
||
|
||
jig.start();
|
||
}
|
||
|
||
for (int t = 0;t < arPtrs.length();++t)
|
||
{
|
||
delete (AcDbEntity*)arPtrs[t];
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 标注bx命令
|
||
int CThunderCmdGroup::ThunderDimentBxCmd()
|
||
{
|
||
TCHAR sRet[24];
|
||
int nRet = 0;
|
||
CString sInput;
|
||
int nType = -1;
|
||
while(1)
|
||
{
|
||
nRet = acedGetString(0,_T("\n标注避雷针(Z)/标注避雷线(L):<Z>"),sRet);
|
||
sInput = sRet;
|
||
if (nRet == RTCAN)
|
||
{
|
||
return 0;
|
||
}
|
||
if (nRet == RTNORM)
|
||
{
|
||
if (!sInput.CompareNoCase(_T("Z")) ||
|
||
!sInput.CompareNoCase(_T("z")) ||
|
||
sInput.IsEmpty())
|
||
{
|
||
nType = 0;
|
||
break;
|
||
}
|
||
else if (!sInput.CompareNoCase(_T("L")) ||
|
||
!sInput.CompareNoCase(_T("l")))
|
||
{
|
||
nType = 1;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
CLableThunderBX drawBx;
|
||
switch(nType)
|
||
{
|
||
case 0:
|
||
{
|
||
drawBx.LablePntBX();
|
||
break;
|
||
}
|
||
case 1:
|
||
{
|
||
drawBx.LabeLineBX();
|
||
break;
|
||
}
|
||
default:return 0;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
//局部3d查看命令
|
||
int CThunderCmdGroup::ThunderPart3DCmd()
|
||
{
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
TTempDrawState temp(FALSE);
|
||
|
||
TViewPortThunders view3d(m_pThunderDraw2d);
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 局部3d查看恢复命令
|
||
int CThunderCmdGroup::ThunderPart3DBackCmd()
|
||
{
|
||
if (m_pThunderDraw2d == NULL)
|
||
return 0;
|
||
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
TTempDrawState temp(FALSE);
|
||
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_2D);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_3D);
|
||
KTSetting::InitLayer(LAY_EL_TEXT);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER);
|
||
KTSetting::InitLayer(LAY_PREVIEW_THUNDER);
|
||
KTSetting::InitLayer(LAY_EL_LIGHTNING_LINE);
|
||
|
||
// 显示2d层
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_TEXT,TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER,TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_LIGHTNING_LINE,TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_PREVIEW_THUNDER,FALSE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
|
||
|
||
SHads_command(RTSTR, _T("_view"), RTSTR, _T("_top"), RTNONE);
|
||
SHads_command(RTSTR, _T("_shademode"), RTSTR, _T("_2"), RTNONE);
|
||
|
||
// 删除预览实体
|
||
ThunderContainer->EreasePreview3DSolid();
|
||
|
||
acedUpdateDisplay();
|
||
actrTransactionManager->flushGraphics();
|
||
|
||
return 0;
|
||
}
|
||
// 生成单针防护表格命令
|
||
int CThunderCmdGroup::ThunderSinSheetCmd()
|
||
{
|
||
// 获取防护表的插入位置
|
||
ads_point ptTemp;
|
||
if (acedGetPoint(NULL, _T("\n 请选择单针防护表的插入位置<退出>: "), ptTemp) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
AcGePoint3d ptInsert = asPnt3d(ptTemp);
|
||
// 获取所有避雷针数据
|
||
lstCltResult lstResult;
|
||
int iColCount = 0;
|
||
if (m_pThunderDraw2d == NULL)
|
||
{
|
||
return 0;
|
||
}
|
||
iColCount = m_pThunderDraw2d->GetNowCaculateResult(lstResult);
|
||
int nSize = (int)lstResult.size();
|
||
if (nSize < 1)
|
||
{
|
||
return 0;
|
||
}
|
||
// 排序
|
||
SortAscendEntities(lstResult);
|
||
// 创建表
|
||
TelDrawSheet telSinSheet;
|
||
telSinSheet.SetLayer(LAY_LIGHTSHEET);
|
||
double dTextSize(4), dTableHeight(7),dTitleHeight(4);
|
||
AcDbObjectId idTextStyle = NULL;
|
||
|
||
idTextStyle = KTSetting::InitTextStyle(G_CSDIMSTYLE);
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(dTextSize);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
telSinSheet.SetRotation(Ucs2Wcs(0.0));
|
||
telSinSheet.SetGridStyle(gridStyle);
|
||
telSinSheet.SetRowHeight(dTableHeight*2);
|
||
telSinSheet.SetTitleVisible(TRUE);
|
||
telSinSheet.SetLocation(ptInsert);
|
||
telSinSheet.InitSheet(nSize + 1, 5+iColCount, dTableHeight*2, 50);
|
||
AcDbObjectId idStyle = KTSetting::InitTextStyle(G_CSDIMSTYLE);
|
||
// 设置表格标题
|
||
gridStyle.SetTextHeight(6.0);
|
||
gridStyle.SetVerMode(AcDb::kTextBottom);
|
||
telSinSheet.SetTitleText(_T("避雷针单针保护范围表"));
|
||
telSinSheet.SetTitleHeight(0.01);
|
||
telSinSheet.SetTitleTestStyle(gridStyle);
|
||
// 设置列列标题
|
||
telSinSheet.SetColumnText(0, _T("避雷针组号"), 20);
|
||
telSinSheet.SetColumnText(1, _T("避雷针编号"), 20);
|
||
telSinSheet.SetColumnText(2, _T("滚球半径hr(米)"), 35);
|
||
telSinSheet.SetColumnText(3, _T("避雷针高度h(米)"), 35);
|
||
for (int k = 0;k < iColCount;++k)
|
||
{
|
||
telSinSheet.SetColumnText(4 + k, _T("保护高度hx(米)/\n保护半径rx(米)"), 35);
|
||
//telSinSheet.SetColumnText(4 + k*2, _T("保护半径rx(米)"), 35);
|
||
}
|
||
telSinSheet.SetColumnText(5+iColCount - 1, _T("备注"), 35);
|
||
// 显示数据
|
||
double dRadius = 0.0;
|
||
double dProHeight = 0.0;
|
||
double dProRadius = 0.0;
|
||
CString strTemp = _T("");
|
||
lstCltResult::iterator it;
|
||
AcGeDoubleArray arProHTemp;
|
||
int i = 0;
|
||
for (it = lstResult.begin();it != lstResult.end();++it)
|
||
{
|
||
// 插入数据
|
||
strTemp.Format(_T("%d"),it->m_nGroupNO);
|
||
telSinSheet.SetText(i + 1, 0, strTemp);
|
||
strTemp.Format(_T("%d#"), it->m_nNumber);
|
||
telSinSheet.SetText(i + 1, 1, strTemp);
|
||
dRadius = it->m_dGroundRadius;
|
||
strTemp.Format(_T("%.0f"), dRadius);
|
||
telSinSheet.SetText(i + 1, 2, strTemp);
|
||
strTemp.Format(_T("%.2f"), it->m_dHeight);
|
||
telSinSheet.SetText(i + 1, 3, strTemp);
|
||
|
||
//插入保护高度和对应的保护半径
|
||
arProHTemp = it->m_arProHeight;
|
||
SorProHeight(arProHTemp);
|
||
for (int j = 0;j < arProHTemp.length();++j)
|
||
{
|
||
dProHeight = arProHTemp[j];
|
||
dProRadius = it->m_dProRadius - pow(dProHeight * (2 * dRadius - dProHeight), 0.5);
|
||
strTemp.Format(_T("%.2f/%.2f"),dProHeight,dProRadius);
|
||
telSinSheet.SetText(i + 1, 4 + j, strTemp);
|
||
}
|
||
|
||
i++;
|
||
}
|
||
telSinSheet.AddToCSpace(TRUE);
|
||
return 0;
|
||
}
|
||
|
||
// 生成双针防护表格命令
|
||
int CThunderCmdGroup::ThunderDblSheetCmd()
|
||
{
|
||
// 获取防护表的插入位置
|
||
ads_point ptTemp;
|
||
if (acedGetPoint(NULL, _T("\n 请选择双针防护表的插入位置<退出>: "), ptTemp) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
AcGePoint3d ptInsert = asPnt3d(ptTemp);
|
||
// 获取所有避雷针数据
|
||
lstCltResult lstResult;
|
||
if (m_pThunderDraw2d != NULL)
|
||
m_pThunderDraw2d->GetNowCaculateResult(lstResult);
|
||
else
|
||
return 0;
|
||
size_t nRtLength = lstResult.size();
|
||
if (nRtLength < 2)
|
||
{
|
||
acutPrintf(_T("\n 双避雷表至少需要两个避雷针!"));
|
||
return 0;
|
||
}
|
||
|
||
CCaculateResult rtTemp;
|
||
double dScale = 0.0;
|
||
if (!DocGetMeterUnitDraw())
|
||
dScale = 1000.0;
|
||
else
|
||
dScale = 1.0;
|
||
|
||
lstCltResult::iterator itStart;
|
||
|
||
std::map<int,lstCltResult> mapTemp;
|
||
std::map<int,lstCltResult>::iterator itMap;
|
||
|
||
int nGroupNO = 0;
|
||
for (itStart = lstResult.begin();itStart != lstResult.end();++itStart)
|
||
{
|
||
nGroupNO = itStart->m_nGroupNO;
|
||
if ((itMap = mapTemp.find(nGroupNO)) != mapTemp.end())
|
||
{
|
||
itMap->second.push_back(*itStart);
|
||
}
|
||
else
|
||
{
|
||
lstCltResult arSub;
|
||
arSub.push_back(*itStart);
|
||
mapTemp.insert(std::make_pair(nGroupNO,arSub));
|
||
}
|
||
}
|
||
|
||
// 统计所有可形成双针保护的避雷针
|
||
//CThunderXData thunderData; //del
|
||
AcArray<DblSheetData> arDblSheetData;
|
||
DblSheetData dblData;
|
||
CString strTemp = _T("");
|
||
// int l = 0; //del
|
||
// int t = 0; //del
|
||
double dDis = 0.0;
|
||
AcGeDoubleArray arProHTemp;
|
||
lstCltResult arSub;
|
||
lstCltResult::iterator it,itSub;
|
||
for (itMap = mapTemp.begin();itMap != mapTemp.end();++itMap)
|
||
{
|
||
arSub = itMap->second;
|
||
SortAscendEntities2(arSub);
|
||
|
||
for (it = arSub.begin();it != arSub.end();++it)
|
||
{
|
||
itSub = it;
|
||
itSub++;
|
||
for (itSub;itSub != arSub.end();++itSub)
|
||
{
|
||
strTemp.Format(_T("%d# - %d#"), it->m_nNumber, itSub->m_nNumber);
|
||
dDis = it->m_ptInsert.distanceTo(itSub->m_ptInsert);
|
||
// 判断是否可以形成双针保护
|
||
//多个保护高度处理
|
||
arProHTemp = itSub->m_arProHeight;
|
||
SorProHeight(arProHTemp);
|
||
double dHeight1 = 0.0, dRadius = 0.0, dHeight2 = 0.0;
|
||
for (int k = 0;k < arProHTemp.length();++k)
|
||
{
|
||
dHeight1 = it->m_dHeight;
|
||
dHeight2 = itSub->m_dHeight;
|
||
dRadius = itSub->m_dGroundRadius;
|
||
if (fabs(dHeight1 - dHeight2) < 0.01)
|
||
{
|
||
if (dDis >= 2 * pow(dHeight2 * dScale * (2 * dRadius * dScale- dHeight2 * dScale), 0.5))
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (dDis >= pow(dHeight1 * dScale * (2 * dRadius * dScale -
|
||
dHeight1 * dScale), 0.5) +
|
||
pow(dHeight2 * dScale * (2 * dRadius * dScale -
|
||
dHeight2 * dScale), 0.5))
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
_tcscpy(dblData.szThunderNumb,strTemp);
|
||
dblData.dThunderDblDis = dDis / dScale;
|
||
dblData.nGroupNO = it->m_nGroupNO;
|
||
|
||
dblData.dThunderRadius = it->m_dGroundRadius;
|
||
double dProHeight = arProHTemp[k];
|
||
dblData.dThunderProHeight = dProHeight;
|
||
// 计算d1
|
||
double dTemp = 0.0;
|
||
// 交换两针高,dHeight1矮针的高度
|
||
if (dHeight1 > dHeight2)
|
||
{
|
||
dTemp = dHeight1;
|
||
dHeight1 = dHeight2;
|
||
dHeight2 = dTemp;
|
||
}
|
||
double d1 = ((dRadius - dHeight2) * (dRadius - dHeight2)
|
||
- (dRadius - dHeight1) * (dRadius - dHeight1)
|
||
+ (dDis/dScale)*(dDis/dScale)) / (2 * dDis/dScale);
|
||
|
||
double dBx = sqrt(dHeight1 * (2 * dRadius - dHeight1) - (d1) * (d1))
|
||
- sqrt(dProHeight * (2 * dRadius - dProHeight));
|
||
if (dBx > 0.01)
|
||
{
|
||
dblData.dThunderBx = dBx;
|
||
arDblSheetData.append(dblData);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 创建表
|
||
TelDrawSheet teldblSheet;
|
||
teldblSheet.SetLayer(LAY_LIGHTSHEET);
|
||
double dTextSize(4), dTableHeight(7),dTitleHeight(4);
|
||
AcDbObjectId idTextStyle = NULL;
|
||
idTextStyle = KTSetting::InitTextStyle(G_CSDIMSTYLE);
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(dTextSize);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
teldblSheet.SetRotation(Ucs2Wcs(0.0));
|
||
teldblSheet.SetGridStyle(gridStyle);
|
||
teldblSheet.SetRowHeight(dTableHeight);
|
||
teldblSheet.SetTitleVisible(TRUE);
|
||
teldblSheet.SetLocation(ptInsert);
|
||
int xLen = arDblSheetData.length();
|
||
teldblSheet.InitSheet(xLen + 1, 7, dTableHeight, 50);
|
||
// 设置表格标题
|
||
gridStyle.SetTextHeight(6.0);
|
||
gridStyle.SetVerMode(AcDb::kTextBottom);
|
||
teldblSheet.SetTitleText(_T("避雷针双针联合保护范围表"));
|
||
teldblSheet.SetTitleHeight(0.01);
|
||
teldblSheet.SetTitleTestStyle(gridStyle);
|
||
// 设置列标题
|
||
teldblSheet.SetColumnText(0, _T("避雷针组号"), 35);
|
||
teldblSheet.SetColumnText(1, _T("避雷针编号"), 35);
|
||
teldblSheet.SetColumnText(2, _T("滚球半径hr(米)"), 35);
|
||
teldblSheet.SetColumnText(3, _T("保护高度hx(米)"), 35);
|
||
teldblSheet.SetColumnText(4, _T("两针间距d(米)"), 35);
|
||
teldblSheet.SetColumnText(5, _T("联合保护范围bx(米)"), 35);
|
||
teldblSheet.SetColumnText(6, _T("备注"), 35);
|
||
// 将数据添加到双针保护表
|
||
CString strTemp1 = _T("");
|
||
for (int tt = 0;tt < arDblSheetData.length();tt++)
|
||
{
|
||
strTemp1.Format(_T("%.2f"), arDblSheetData[tt].dThunderBx);
|
||
teldblSheet.SetText(tt+1, 5, strTemp1);
|
||
strTemp1.Format(_T("%d"),arDblSheetData[tt].nGroupNO);
|
||
teldblSheet.SetText(tt+1, 0, strTemp1);
|
||
strTemp1 = arDblSheetData[tt].szThunderNumb;
|
||
teldblSheet.SetText(tt+1, 1, strTemp1);
|
||
strTemp1.Format(_T("%.0f"), arDblSheetData[tt].dThunderRadius);
|
||
teldblSheet.SetText(tt+1, 2, strTemp1);
|
||
strTemp1.Format(_T("%.2f"), arDblSheetData[tt].dThunderProHeight);
|
||
teldblSheet.SetText(tt+1, 3, strTemp1);
|
||
strTemp1.Format(_T("%.2f"), arDblSheetData[tt].dThunderDblDis);
|
||
teldblSheet.SetText(tt+1, 4, strTemp1);
|
||
}
|
||
teldblSheet.AddToCSpace(TRUE);
|
||
return 0;
|
||
}
|
||
|
||
// typedef std::list<CCaculateResult> lstCltResult;
|
||
// 排序所有过滤的实体Entity
|
||
void CThunderCmdGroup::SortAscendEntities(lstCltResult& lstSrc)
|
||
{
|
||
// 先按组号排序再按编号排序每组的避雷针
|
||
lstCltResult::iterator it;
|
||
std::map<int,lstCltResult> mapTemp;
|
||
std::map<int,lstCltResult>::iterator itMap;
|
||
|
||
int nGroupNO = 0;
|
||
for (it = lstSrc.begin();it != lstSrc.end();++it)
|
||
{
|
||
nGroupNO = it->m_nGroupNO;
|
||
if ((itMap = mapTemp.find(nGroupNO)) != mapTemp.end())
|
||
{
|
||
itMap->second.push_back(*it);
|
||
}
|
||
else
|
||
{
|
||
lstCltResult arSub;
|
||
arSub.push_back(*it);
|
||
mapTemp.insert(std::make_pair(nGroupNO,arSub));
|
||
}
|
||
}
|
||
|
||
lstSrc.clear();
|
||
lstCltResult lstSub;
|
||
for (itMap = mapTemp.begin();itMap != mapTemp.end();++itMap)
|
||
{
|
||
lstSub = itMap->second;
|
||
SortAscendEntities2(lstSub);
|
||
for (it = lstSub.begin();it != lstSub.end();++it)
|
||
{
|
||
lstSrc.push_back(*it);
|
||
}
|
||
}
|
||
}
|
||
|
||
void CThunderCmdGroup::SortAscendEntities2(lstCltResult& lstSrc)
|
||
{
|
||
if (lstSrc.size() > 1)
|
||
{
|
||
std::map<int,CCaculateResult> mapTemp;
|
||
std::map<int,CCaculateResult>::iterator itMap;
|
||
lstCltResult::iterator itSub;
|
||
|
||
for (itSub = lstSrc.begin();itSub != lstSrc.end();++itSub)
|
||
{
|
||
mapTemp.insert(std::make_pair(itSub->m_nNumber,*itSub));
|
||
}
|
||
|
||
lstSrc.clear();
|
||
for (itMap = mapTemp.begin();itMap != mapTemp.end();++itMap)
|
||
{
|
||
lstSrc.push_back(itMap->second);
|
||
}
|
||
}
|
||
}
|
||
|
||
//删除标注半径
|
||
void CThunderCmdGroup::DeleteOldDim(AcDbCircle* pCircle)
|
||
{
|
||
if (pCircle == NULL)
|
||
return;
|
||
|
||
double dRadius = pCircle->radius();
|
||
AcDbPolyline *pPLine = new AcDbPolyline;
|
||
XPoint pt = pCircle->center();
|
||
pt.z = 0;
|
||
XPoint ptLeft = pt;
|
||
XPoint ptRight = pt;
|
||
|
||
ptLeft.x -= dRadius;
|
||
ptRight.x += dRadius;
|
||
|
||
AcGeVector3d vt1(ptLeft-pt);
|
||
AcGeVector3d vt2(ptRight-pt);
|
||
double dAngle1 = vt1.angleTo(vt2);
|
||
double dBulge1 = tan(0.25 * dAngle1);
|
||
double dAngle2 = vt2.angleTo(vt1);
|
||
double dBulge2 = tan(0.25 * dAngle2);
|
||
|
||
pPLine->addVertexAt(0,ptLeft,dBulge1);
|
||
pPLine->addVertexAt(1,ptRight,dBulge2);
|
||
pPLine->addVertexAt(2,ptLeft,dBulge1);
|
||
|
||
PickSet ss(SS_FREE);
|
||
RBList rbMask(RTDXF0, _T("TEXT,LWPOLYLINE"), NULL);
|
||
XPoly2D poly;
|
||
PolyConvert(*pPLine, poly);
|
||
delete pPLine;
|
||
XPoint ptLow,ptUp;
|
||
|
||
poly.GetExtend(ptLow,ptUp);
|
||
//Groups(0) wcs, Groups(1) ucs
|
||
poly.TransUCS(Groups(0), Groups(1));
|
||
RBList rbFence = poly.Fence();
|
||
|
||
AssureInCurrentView(ptLow, ptUp);
|
||
ss.Get(_T("CP"), rbFence, NULL, rbMask);
|
||
int iTest = ss.Length();
|
||
CStringArray arData;
|
||
AcDbObjectId id;
|
||
for (long i = 0; i < ss.Length(); ++i)
|
||
{
|
||
arData.RemoveAll();
|
||
acdbGetObjectId(id,ss[i]);
|
||
CThunderXData data;
|
||
data.GetBaseInformationExData(id,arData,TEL_THUNDER_LABLE);
|
||
|
||
if (arData.GetSize() > 0)
|
||
{
|
||
if (arData[0].CompareNoCase(_T("FORDEL")) == 0)
|
||
ss[i].Erase();
|
||
}
|
||
}
|
||
}
|
||
|
||
// 判断点是否在此圆弧上
|
||
bool CThunderCmdGroup::PointIsAtAcDbArc(const AcGePoint3d& ptTest, AcDbArc* pArc)
|
||
{
|
||
// 测试点到圆弧圆心的距离和此圆弧半径相等则点在此圆弧上
|
||
if (pArc == NULL)
|
||
{
|
||
return false;
|
||
}
|
||
AcGePoint3d ptArc = pArc->center();
|
||
double dDistance = ptTest.distanceTo(ptArc);
|
||
double dArcRadius = pArc->radius();
|
||
if (fabs(dDistance - dArcRadius) > 0.001)
|
||
{
|
||
return false;
|
||
}
|
||
else
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
//ARX加载
|
||
void CThunderCmdGroup::OnLoadApp()
|
||
{
|
||
if (m_pThunderDocReactor != NULL)
|
||
{
|
||
m_pThunderDocReactor->SetThunderDraw2D(m_pThunderDraw2d);
|
||
m_pThunderDocReactor->SetThunderDbReactor(m_pThunderReactor);
|
||
m_pThunderEditReactor->SetThunderDbReactor(m_pThunderReactor);
|
||
|
||
acDocManager->addReactor(m_pThunderDocReactor);
|
||
}
|
||
|
||
if (m_pThunderReactor != NULL)
|
||
{
|
||
acdbCurDwg()->addReactor(m_pThunderReactor);
|
||
}
|
||
|
||
if (m_pThunderEditReactor != NULL)
|
||
{
|
||
acedEditor->addReactor(m_pThunderEditReactor);
|
||
}
|
||
}
|
||
|
||
//ARX卸载
|
||
void CThunderCmdGroup::OnUnloadApp()
|
||
{
|
||
//卸载文档反应器
|
||
acDocManager->removeReactor(m_pThunderDocReactor);
|
||
|
||
//卸载命令反应器
|
||
acedEditor->removeReactor(m_pThunderEditReactor);
|
||
|
||
//卸载数据库反应器
|
||
AcApDocumentIterator *pIter = acDocManager->newAcApDocumentIterator();
|
||
if (pIter == NULL)
|
||
return;
|
||
|
||
for (;!pIter->done();pIter->step())
|
||
{
|
||
(pIter->document()->database())->removeReactor(m_pThunderReactor);
|
||
}
|
||
delete pIter;
|
||
}
|
||
|
||
// 获取指定避雷针的保护高度
|
||
bool CThunderCmdGroup::GetCurPinProHeight(AcDbCircle* pCircle, CString& strHeight)
|
||
{
|
||
if (pCircle == NULL)
|
||
{
|
||
return false;
|
||
}
|
||
// 获取圆的id
|
||
AcDbObjectId circleId = pCircle->objectId();
|
||
if (circleId == AcDbObjectId::kNull)
|
||
{
|
||
return false;
|
||
}
|
||
// 由圆id获取避雷针ID
|
||
CThunderXData thunderXData;
|
||
AcDbObjectId thundId;
|
||
if (!thunderXData.GetEntityIdFromExData(circleId, thundId, TEL_THUNDER_ID))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
CStringArray arsDatas;
|
||
if (!thunderXData.GetBaseInformationExData(circleId,arsDatas,TEL_THUNDER_PROHT))
|
||
{
|
||
return false;
|
||
}
|
||
strHeight = arsDatas[0];
|
||
return true;
|
||
}
|
||
|
||
//建筑高度
|
||
int CThunderCmdGroup::ThunderArchHeight()
|
||
{
|
||
PickSet ssAll(SS_FREE);
|
||
RBList rbMask(RTDXF0, _T("LWPOLYLINE,3DSOLID,CIRCLE"), NULL);
|
||
Entity ent;
|
||
|
||
if (SelectEntities(_T("请选择PLINE线,圆或3D实体:"),ssAll,rbMask) != RTNORM)
|
||
return 0;
|
||
|
||
double dHeight = 0.0;
|
||
if (acedGetReal(_T("请输入高度(m):"),&dHeight) != RTNORM)
|
||
return 0;
|
||
|
||
if (!DocGetMeterUnitDraw())
|
||
dHeight *= 1000;
|
||
|
||
CString sLayer;
|
||
AcDbRegion *pReg = NULL;
|
||
for (long i = 0; i < ssAll.Length(); ++i)
|
||
{
|
||
ent = ssAll[i];
|
||
AcDb3dSolid *pSolid = new AcDb3dSolid;
|
||
if (ent.Is(_T("3DSOLID")))
|
||
{
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDb3dSolid,pOldSolid)
|
||
{
|
||
if (pSolid != NULL)
|
||
{
|
||
sLayer = pSolid->layer();
|
||
|
||
AcGePoint3d ptOrg(0,0,0);
|
||
AcGePlane plan(ptOrg,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis);
|
||
|
||
pOldSolid->getSection(plan,pReg);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
if (sLayer.CompareNoCase(LAY_EL_THUNDER_3D) == 0)
|
||
continue;
|
||
if (pReg != NULL)
|
||
{
|
||
pSolid->extrude(pReg,dHeight,0);
|
||
pSolid->setColorIndex(1);
|
||
AddToCurrentSpace(pSolid,Adesk::kTrue);
|
||
}
|
||
|
||
ent.Erase();
|
||
}
|
||
else
|
||
{
|
||
AcDbVoidPtrArray arRegs;
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,AcDbPolyline,pPline)
|
||
{
|
||
if (pPline != NULL)
|
||
{
|
||
pPline->setClosed(Adesk::kTrue);
|
||
arRegs.append(pPline);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,AcDbCircle,pCircle)
|
||
{
|
||
if (pCircle != NULL)
|
||
{
|
||
CString sLayer = pCircle->layer();
|
||
if (sLayer.CompareNoCase(LAY_EL_THUNDER_2D) != 0)
|
||
arRegs.append(pCircle);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
Acad::ErrorStatus es = Acad::eOutOfMemory;
|
||
//生成3D实体
|
||
int nLen = arRegs.length();
|
||
AcDbVoidPtrArray arRegions;
|
||
arRegions.setPhysicalLength(10);
|
||
arRegions.setGrowLength(1);
|
||
es = AcDbRegion::createFromCurves(arRegs, arRegions);
|
||
|
||
if (arRegions.length() <= 0)
|
||
continue;
|
||
|
||
AcDbRegion *pReg = AcDbRegion::cast((AcRxObject*)arRegions[0]);
|
||
|
||
if (pReg != NULL)
|
||
{
|
||
pSolid->extrude(pReg,dHeight,0);
|
||
pSolid->setColorIndex(1);
|
||
AddToCurrentSpace(pSolid,Adesk::kTrue);
|
||
}
|
||
for (int i = 0; i < arRegions.length(); ++i)
|
||
{
|
||
delete (AcDbEntity*)arRegions[i];
|
||
}
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
//计算书
|
||
int CThunderCmdGroup::ThunderCaculateBook()
|
||
{
|
||
lstCltResult lstResult;
|
||
if (m_pThunderDraw2d != NULL)
|
||
m_pThunderDraw2d->GetNowCaculateResult(lstResult);
|
||
|
||
if (lstResult.size() < 2)
|
||
{
|
||
AfxMessageBox(_T("避雷针少于2个,无法出计算书!"));
|
||
return 0;
|
||
}
|
||
|
||
SortAscendEntities(lstResult);
|
||
|
||
lstCltResult::iterator itStart;
|
||
|
||
std::map<int,lstCltResult> mapTemp;
|
||
std::map<int,lstCltResult>::iterator itMap;
|
||
|
||
int nGroupNO = 0;
|
||
for (itStart = lstResult.begin();itStart != lstResult.end();++itStart)
|
||
{
|
||
nGroupNO = itStart->m_nGroupNO;
|
||
if ((itMap = mapTemp.find(nGroupNO)) != mapTemp.end())
|
||
{
|
||
itMap->second.push_back(*itStart);
|
||
}
|
||
else
|
||
{
|
||
lstCltResult arSub;
|
||
arSub.push_back(*itStart);
|
||
mapTemp.insert(std::make_pair(nGroupNO,arSub));
|
||
}
|
||
}
|
||
|
||
//初始化
|
||
TelCreateWordApp word;
|
||
word.SetAlignment(1); // 0: 居左 1:居中 2:居右
|
||
//设置文字样式
|
||
word.SetFont(_T("黑体"),18,0);
|
||
word.TypeText(_T("滚球法防雷设计计算书\n\n"));
|
||
word.SetAlignment(0);
|
||
|
||
CString sTempText;
|
||
CString sGroundType; //del
|
||
int nNumber = 0;
|
||
double dHeight = 0.0;
|
||
double dGroundRadius = 0.0;
|
||
double dProHeight = 0.0;
|
||
double dProRadius0 = 0.0;
|
||
double dProRadiusX = 0.0;
|
||
double dDis = 0.0;
|
||
double dBx = 0.0;
|
||
double dH0 = 0.0;
|
||
double dHeight1 = 0.0;
|
||
double dHeight2 = 0.0;
|
||
double dD1 = 0.0;
|
||
AcGeDoubleArray arProHTemp;
|
||
word.SetFont(_T("宋体"),10,0);
|
||
//bsl 2011.9.27 规范更新
|
||
//word.TypeText(_T("工程名:\n计算者:\n计算时间:\n参考规范:《建筑物防雷设计规范》(2000年版)\n\n"));
|
||
word.TypeText(_T("工程名:\n计算者:\n计算时间:\n参考规范:《建筑物防雷设计规范》GB50057―2010\n\n"));
|
||
lstCltResult::iterator it,itSub;
|
||
lstCltResult lstGroup;
|
||
for (itMap = mapTemp.begin();itMap != mapTemp.end();++itMap)
|
||
{
|
||
lstGroup = itMap->second;
|
||
if (lstGroup.size() < 2)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
SortAscendEntities2(lstGroup);
|
||
|
||
for (it = lstGroup.begin();it != lstGroup.end();++it)
|
||
{
|
||
nGroupNO = it->m_nGroupNO; // 组号
|
||
nNumber = it->m_nNumber; // 编号
|
||
dHeight = it->m_dHeight; // 针高
|
||
dGroundRadius = it->m_dGroundRadius;
|
||
//多保护高度处理
|
||
arProHTemp = it->m_arProHeight;
|
||
SorProHeight(arProHTemp);
|
||
for (int j = 0;j < arProHTemp.length();++j)
|
||
{
|
||
dProHeight = arProHTemp[j];
|
||
dProRadius0 = it->m_dProRadius;
|
||
dProRadiusX = dProRadius0 - pow(dProHeight*(2*dGroundRadius - dProHeight),0.5);
|
||
word.SetFont(_T("宋体"),12,1);
|
||
word.TypeText(_T("已知条件\n"));
|
||
word.SetFont(_T("宋体"),10,0);
|
||
sTempText.Format(_T(" 算法:滚球法\n 避雷针组号%d\n 避雷针编号%d\n 针高:%.2f米\n 避雷针计算高度:%.2f米\n 被保护物的防雷等级要求:滚球半径%.0f米\n 被保护物的高度:%.2f米\n\n"),nGroupNO,nNumber,dHeight,dHeight,dGroundRadius,dProHeight);
|
||
word.TypeText(sTempText);
|
||
|
||
word.SetFont(_T("宋体"),12,1);
|
||
word.TypeText(_T("计算过程和公式\n"));
|
||
word.SetFont(_T("宋体"),10,0);
|
||
sTempText.Format(_T(" r0 =√[h*(2hr -h)] \n =√[%.2f*(2*%.2f -%.2f)] \n =%.2f(米)\n"),dHeight,dGroundRadius,dHeight,dProRadius0);
|
||
word.TypeText(sTempText);
|
||
sTempText.Format(_T(" rx =√[h*(2hr -h)] - √[hx (2hr -hx )] \n =√[%.2f*(2*%.2f -%.2f)] - √[%.2f (2*%.2f -%.2f )]\n =%.2f(米)\n"),dHeight,dGroundRadius,dHeight,dProHeight,dGroundRadius,dProHeight,dProRadiusX);
|
||
word.TypeText(sTempText);
|
||
|
||
itSub = it;
|
||
itSub++;
|
||
for (itSub;itSub != lstGroup.end();++itSub)
|
||
{
|
||
dHeight1 = it->m_dHeight;
|
||
dHeight2 = itSub->m_dHeight;
|
||
dDis = it->m_ptInsert.distanceTo(itSub->m_ptInsert);
|
||
|
||
if (!DocGetMeterUnitDraw())
|
||
dDis /= 1000;
|
||
|
||
dD1 = (pow((dGroundRadius - dHeight2),2) - pow((dGroundRadius - dHeight1),2) + dDis*dDis)/(2*dDis);
|
||
dBx = pow(dHeight*(2*dGroundRadius - dHeight) - dD1*dD1,0.5) - pow(dProHeight*(2*dGroundRadius - dProHeight),0.5);
|
||
dH0 = dGroundRadius - pow(pow((dGroundRadius - dHeight),2) + dD1*dD1,0.5);
|
||
if (dH0 < 0)
|
||
continue;
|
||
if (fabs(dHeight1 - dHeight2) > 0.01)
|
||
sTempText.Format(_T("%d-%d\n 两针距离 D = %.2f\n D1 = [(hr - h2)*(hr - h2) - (hr - h1)*(hr - h1) + D*D]/(2*D)\n = [(%.2f - %.2f)*(%.2f - %.2f) - (%.2f - %.2f)*(%.2f - %.2f) + %.2f*%.2f]/(2*%.2f)\n = %.2f(米)\n"),it->m_nNumber,itSub->m_nNumber,dDis,dGroundRadius,dHeight2,dGroundRadius,dHeight2,dGroundRadius,dHeight1,dGroundRadius,dHeight1,dDis,dDis,dDis,dD1);
|
||
else
|
||
sTempText.Format(_T("%d-%d\n 两针距离 D = %.2f\n D1 = D/2\n = %.2f/2\n = %.2f(米)\n"),it->m_nNumber,itSub->m_nNumber,dDis,dDis,dDis/2);
|
||
word.TypeText(sTempText);
|
||
sTempText.Format(_T(" Bx =√[h(2*hr -h)-D1*D1] - √[hx(2*hr - hx)]\n =√[%.2f(2*%.2f -%.2f)-%.2f*%.2f] - √[%.2f(2*%.2f - %.2f)]\n =%.2f(米)\n"),dHeight,dGroundRadius,dHeight,dD1,dD1,dProHeight,dGroundRadius,dProHeight,dBx);
|
||
if (dBx > 0)
|
||
word.TypeText(sTempText);
|
||
sTempText.Format(_T(" 中心点最低高度h0\n h0 =hr - √[(hr - h)*(hr - h) +D1*D1]\n =%.2f - √[(%.2f - %.2f)*(%.2f - %.2f) +%.2f*%.2f]\n =%.2f(米)\n"),dGroundRadius,dGroundRadius,dHeight,dGroundRadius,dHeight,dD1,dD1,dH0);
|
||
if (dH0 > 0)
|
||
word.TypeText(sTempText);
|
||
}
|
||
|
||
word.SetFont(_T("宋体"),12,1);
|
||
word.TypeText(_T("计算结果\n"));
|
||
word.SetFont(_T("宋体"),10,0);
|
||
sTempText.Format(_T(" 避雷针在%.2f米处的保护范围为%.2f米\n\n"),dProHeight,dProRadiusX);
|
||
word.TypeText(sTempText);
|
||
}
|
||
}
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
void CThunderCmdGroup::SorProHeight(AcGeDoubleArray& arPro)
|
||
{
|
||
std::list<double> lstTemp;
|
||
std::list<double>::iterator it;
|
||
for (int i = 0;i < arPro.length();++i)
|
||
{
|
||
lstTemp.push_back(arPro[i]);
|
||
}
|
||
|
||
lstTemp.sort();
|
||
arPro.setLogicalLength(0);
|
||
for (it = lstTemp.begin();it != lstTemp.end();++it)
|
||
{
|
||
arPro.append(*it);
|
||
}
|
||
}
|
||
|
||
// 避雷剖切
|
||
int CThunderCmdGroup::ThunderSection()
|
||
{
|
||
if (m_pThunderDraw2d == NULL)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
TCHAR szNO[50];
|
||
if (ads_getstring(0, _T("\n 请输入剖切编号<1>:"), szNO) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
CString sNO = szNO;
|
||
if(sNO.IsEmpty())
|
||
{
|
||
sNO = _T("1");
|
||
}
|
||
|
||
ads_point ptFir;
|
||
if(acedGetPoint(NULL,_T("\n 点取第一个剖切点<退出>: "), ptFir) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 正交打开
|
||
XPushVar<int> vOrthoMode(_T("ORTHOMODE"), 1); //f8
|
||
|
||
acdbUcs2Wcs(ptFir, ptFir, false);
|
||
AcGePoint3d ptF = asPnt3d(ptFir);
|
||
|
||
XPoly2D poly(0);
|
||
poly.AppendNode(ptF);
|
||
poly.AppendNode(ptF);
|
||
|
||
AecDbSymbSection ent;
|
||
ent.SetText(sNO);
|
||
ent.SetLayoutRotation(Ucs2Wcs(0.0));
|
||
ent.setLayer(ent.GetDefaultLayer());
|
||
ent.SetTextStyleId(KTSetting::InitTextStyle(TS_EL_LABEL));
|
||
ent.SetTextLayerId(KTSetting::InitLayer(LAY_EL_TEXT, false));
|
||
ent.SetViewLine(TRUE);
|
||
ent.SetPoly2D(poly);
|
||
|
||
TThunderSectionJig jig(&ent);
|
||
jig.SetPrompt(_T("\n 点取第二个剖切点<退出>:"));
|
||
jig.SetOperCode(TThunderSectionJig::kSectPoint);
|
||
|
||
if(jig.DoIt() != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
ent.GetPoly2D(poly);
|
||
jig.SetPrompt(_T("\n 点取剖视方向<当前方向>:"));
|
||
jig.SetOperCode(TThunderSectionJig::kViewDirection);
|
||
|
||
int nRet = jig.DoIt();
|
||
|
||
AcDbObjectId idSec;
|
||
if((nRet == RTNORM || nRet == RTNONE) && ent.IsValid())
|
||
{
|
||
ent.SetTextLocation(0, ent.GetDefaultTextLocation(0));
|
||
ent.SetTextLocation(1, ent.GetDefaultTextLocation(1));
|
||
|
||
idSec = ((AecEntity*)ent.clone())->AddToCSpace(Adesk::kTrue);
|
||
}
|
||
|
||
// 剖切点
|
||
AcGePoint3d pt1,pt2;
|
||
ent.GetPoly2D(poly);
|
||
if (poly.Length() > 0)
|
||
{
|
||
pt1 = *poly[0];
|
||
pt2 = *poly[1];
|
||
}
|
||
|
||
AcDbLine ln(pt1, pt2);
|
||
AcGePoint3d ptOn;
|
||
ln.getClosestPointTo(jig.GetDirPosition(), ptOn, Adesk::kTrue);
|
||
AcGeVector3d vtDir = jig.GetDirPosition() - ptOn;
|
||
AcGePoint3d pt3 = pt2 + vtDir;
|
||
AcGePoint3d pt4 = pt1 + vtDir;
|
||
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, FALSE);
|
||
|
||
acedUpdateDisplay();
|
||
actrTransactionManager->flushGraphics();
|
||
|
||
// 过滤实体
|
||
PickSet ssSel(SS_FREE);
|
||
|
||
XPoint xp1(Wcs2Ucs(pt1)), xp2(Wcs2Ucs(pt2)), xp3(Wcs2Ucs(pt3)), xp4(Wcs2Ucs(pt4));
|
||
RBList pPtLst = acutBuildList(RTPOINT,&xp1,RTPOINT,&xp2,RTPOINT,&xp3, RTPOINT,&xp4,NULL);
|
||
RBList lstRb3d = ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("3DSOLID"), 8, LAY_EL_THUNDER_3D, -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("3DSOLID"), -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
|
||
acedSSGet(_T("CP"), pPtLst, NULL, lstRb3d, ssSel);
|
||
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
|
||
|
||
if (ssSel.Length() > 0)
|
||
{
|
||
TCreateThunderSection sec(pt1, pt2, vtDir, ssSel);
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 绘制避雷线
|
||
int CThunderCmdGroup::DrawThunderLine()
|
||
{
|
||
XPushVar<int> vOrthoMode(_T("ORTHOMODE"), 1);
|
||
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_2D);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER_3D);
|
||
KTSetting::InitLayer(LAY_EL_TEXT);
|
||
KTSetting::InitLayer(LAY_EL_THUNDER);
|
||
KTSetting::InitLayer(LAY_EL_LIGHTNING_LINE);
|
||
KTSetting::InitLayer(LAY_PREVIEW_THUNDER);
|
||
|
||
if (m_pThunderDraw2d != NULL)
|
||
{
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_LIGHTNING_LINE, TRUE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
|
||
m_pThunderDraw2d->ShowLayer(LAY_PREVIEW_THUNDER, FALSE);
|
||
}
|
||
|
||
CThunderLineSetDlg dlg;
|
||
if (!dlg.DoModeless())
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AdjustWndToViewport(&dlg);
|
||
|
||
dlg.SetThunderDraw2d(m_pThunderDraw2d);
|
||
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
|
||
AcDbObjectId idNew;
|
||
while (true)
|
||
{
|
||
// 绘制避雷带
|
||
if (!dlg.DrawThunderLine(idNew))
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
dlg.DestroyWindow();
|
||
|
||
acedPostCommand(_T("\33\33"));
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::ThunderEditLineCmd()
|
||
{
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("LWPOLYLINE"), NULL);
|
||
Entity ent;
|
||
int nRet = 0;
|
||
nRet = SelectEntity(_T("请选择需要修改的避雷线:<退出>"),ent,rbMask);
|
||
if (nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
CThunderXData ThunderXData;
|
||
CString sNo = _T("");
|
||
|
||
AcDbObjectId idThunderLine;
|
||
acdbGetObjectId(idThunderLine,ent);
|
||
|
||
ThunderXData.GetXData(idThunderLine,KEY_LINE_GROUP_NO,sNo);
|
||
if (!sNo.IsEmpty())
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CThunderLineSetDlg dlg;
|
||
dlg.SetUseType(CThunderLineSetDlg::eEdit);
|
||
dlg.SetCurrectThunderLine(idThunderLine);
|
||
dlg.DoModal();
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::ThunderEraseLineCmd()
|
||
{
|
||
RBList rb = ads_buildlist(RTDXF0,_T("LWPOLYLINE"),NULL);
|
||
PickSet ss(SS_FREE);
|
||
int nRet = SelectEntities(_T("请选择要删除的避雷线:<退出>"),ss,rb);
|
||
if (nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
CThunderXData thundXData;
|
||
|
||
CString sNO = _T("");
|
||
for (long i = 0;i < ss.Length();i++)
|
||
{
|
||
OPENOBJ_BEGIN(ss[i],AcDb::kForWrite,AcDbPolyline,pLine);
|
||
if (pLine)
|
||
{
|
||
thundXData.GetXData((AcDbEntity*)pLine,KEY_LINE_GROUP_NO,sNO);
|
||
if (!sNO.IsEmpty())
|
||
{
|
||
pLine->erase();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::ThunderMoveLineCmd()
|
||
{
|
||
RBList rb = ads_buildlist(RTDXF0,_T("LWPOLYLINE"),NULL);
|
||
Entity ent;
|
||
int nRet = 0;
|
||
nRet = SelectEntity(_T("请选择要移动的避雷线:<退出>"),ent,rb);
|
||
if (nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AcGePoint3d ptS,ptE,ptPick,ptEnd;
|
||
CThunderXData thundXData;
|
||
|
||
CString sNO = _T("");
|
||
BOOL bSel = FALSE;
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbPolyline,pLine);
|
||
if (pLine)
|
||
{
|
||
thundXData.GetXData((AcDbEntity*)pLine,KEY_LINE_GROUP_NO,sNO);
|
||
if (!sNO.IsEmpty())
|
||
{
|
||
pLine->getStartPoint(ptS);
|
||
pLine->getEndPoint(ptE);
|
||
ptPick = AcGePoint3d((ptS.x + ptE.x) / 2.0,(ptS.y + ptE.y) / 2.0,(ptS.z + ptE.z) / 2.0);
|
||
bSel = TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
if (bSel)
|
||
{
|
||
ads_point ptStart,pt;
|
||
AcGePoint3d ptTemp;
|
||
|
||
nRet = acedGetPoint(NULL,_T("\n请指定基点<退出>:"),pt);
|
||
if(nRet != RTNORM)
|
||
return 0;
|
||
ptPick = asPnt3d(pt);
|
||
ptPick.z = ptS.z;
|
||
ptTemp = Wcs2Ucs(ptPick);
|
||
|
||
ptStart[X] = ptTemp.x;
|
||
ptStart[Y] = ptTemp.y;
|
||
ptStart[Z] = ptS.z;
|
||
|
||
nRet = acedGetPoint(ptStart,_T("\n请选择要移动到的位置<退出>"),pt);
|
||
if(nRet != RTNORM)
|
||
return 0;
|
||
|
||
ptEnd = Ucs2Wcs(asPnt3d(pt));
|
||
ptEnd[Z] = ptS.z;
|
||
|
||
//PickSet ss(SS_FREE);
|
||
//ss += ent;
|
||
//SHads_command(RTSTR,_T("MOVE"),RTPICKS,(LONG_PTR*)ss,RTSTR,_T(""),RT3DPOINT,&ptPick,RT3DPOINT,&ptEnd,RTNONE);
|
||
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbPolyline,pLine);
|
||
if (pLine)
|
||
{
|
||
thundXData.GetXData((AcDbEntity*)pLine,KEY_LINE_GROUP_NO,sNO);
|
||
if (!sNO.IsEmpty())
|
||
{
|
||
if (pLine->upgradeOpen() == Acad::eOk)
|
||
{
|
||
AcGeMatrix3d mat;
|
||
AcGeVector3d vtTranf = ptEnd - ptPick;
|
||
mat.setTranslation(vtTranf);
|
||
pLine->transformBy(mat);
|
||
pLine->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
void CThunderCmdGroup::AdjustWndToViewport(CWnd* pWnd,int nXOff,int nYOff)
|
||
{
|
||
if (pWnd != NULL)
|
||
{
|
||
CRect rect,rectWnd;
|
||
acedGetAcadFrame()->GetWindowRect(rect);
|
||
pWnd->GetWindowRect(&rectWnd);
|
||
|
||
if (!PtInRect(rect, rectWnd.TopLeft()) &&
|
||
!PtInRect(rect, rectWnd.BottomRight()))
|
||
{
|
||
int nX = rect.TopLeft().x + nXOff;
|
||
int nY = rect.TopLeft().y = nYOff;
|
||
pWnd->MoveWindow(nX,nY,rectWnd.Width(),rectWnd.Height());
|
||
}
|
||
}
|
||
}
|
||
|
||
int CThunderCmdGroup::newspheretest()
|
||
{
|
||
AcDbObjectId idSign = AcDbObjectId::kNull;
|
||
AcDb3dSolid *pSolid = new AcDb3dSolid;
|
||
if (pSolid != NULL)
|
||
{
|
||
pSolid->createSphere(200);
|
||
pSolid->setColorIndex(1);
|
||
pSolid->setVisibility(AcDb::kVisible);
|
||
idSign = AddToCurrentSpace(pSolid,Adesk::kTrue);
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
|
||
/******************折线法 命令***********************/
|
||
int CThunderCmdGroup::FoldSetPinCmd()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CFoldSetDlg dlg;
|
||
dlg.DoModal();
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 插避雷针
|
||
int CThunderCmdGroup::FoldLayPinCmd()
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
|
||
CString xstrTemp;
|
||
xstrTemp.Format(_T("$Ectrical$%s"),FOLD_BLOCK_SIGN);
|
||
AcDbObjectId idBlock = InitBlock((const TCHAR*)xstrTemp);
|
||
|
||
int nKeyInput = 0;
|
||
|
||
CFoldLayPinDlg* pDlg = new CFoldLayPinDlg;
|
||
if (pDlg != NULL)
|
||
{
|
||
pDlg->DoModeless();
|
||
}
|
||
|
||
CFoldPinJig jig;
|
||
AcGePoint3d ptIns;
|
||
jig.SetDlgPtr(pDlg);
|
||
jig.SetProBlock(idBlock);
|
||
jig.SetBlockName((const TCHAR*)xstrTemp);
|
||
jig.setDispPrompt(_T("\n请选择插入点<退出>:"));
|
||
while (jig.DoIt(&nKeyInput) == RTNORM)
|
||
{
|
||
//插避雷针
|
||
ptIns = jig.GetLastPoint();
|
||
|
||
CString sGroupNo = pDlg->GetGroupNo();
|
||
if (_ttoi(sGroupNo) < 1)
|
||
{
|
||
AfxMessageBox(_T("避雷针组号应大于0!"));
|
||
return TRUE;
|
||
}
|
||
|
||
CString sNum = pDlg->GetNo();
|
||
if (_ttoi(sNum) < 1)
|
||
{
|
||
AfxMessageBox(_T("避雷针编号应大于0!"));
|
||
return TRUE;
|
||
}
|
||
|
||
//更新对话框数据
|
||
if (!pDlg->GetDlgData())
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
KTSetting::InitLayer(LAY_EL_THUNDER);
|
||
XPushVarStr cLayer(_T("CLAYER"), LAY_EL_THUNDER);
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
|
||
double dBlockScale = pDlg->GetBlkScale();
|
||
if (dBlockScale < 1e-3)
|
||
{
|
||
dBlockScale = 1.0;
|
||
}
|
||
|
||
//插入图块
|
||
XPoint xp(Wcs2Ucs(ptIns));
|
||
SHads_command(RTSTR, _T(".INSERT"), RTSTR, (const TCHAR*)xstrTemp, RT3DPOINT, &xp,
|
||
RTREAL, dBlockScale*10*DocGetPScale(), RTREAL, dBlockScale*10*DocGetPScale(), RTREAL,0.0,RTSTR, _T(""), RTNONE);
|
||
Entity entLast;
|
||
entLast.GetLast();
|
||
|
||
AcDbObjectId idEnt;
|
||
acdbGetObjectId(idEnt, entLast);
|
||
|
||
CString strText;
|
||
strText += sNum;
|
||
CString sPinHeight = pDlg->GetPinHeight();
|
||
//标注
|
||
strText += _T("#,h=");
|
||
strText += sPinHeight;
|
||
strText += _T("m");
|
||
double dTextHeight = pDlg->GetTextHeight();
|
||
|
||
SetBlkAttrText(entLast, strText, _T("$TEXT$"), dTextHeight, TRUE, TRUE);
|
||
|
||
//写扩展数据
|
||
pDlg->SetCurrentExData(idEnt);
|
||
|
||
// 设置避雷针组号
|
||
CThunderXData thundXData;
|
||
thundXData.SetXData(idEnt, KEY_FOLD_GROUP_NO, sGroupNo);
|
||
|
||
//记忆最后一次组号
|
||
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
||
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
||
regProp.SetValue(KEY_FOLD_LAST_GROUPNO,sGroupNo);
|
||
|
||
// 设置避雷针编号
|
||
thundXData.SetXData(idEnt, TEL_ORDER_NUMBER, sNum);
|
||
|
||
//设置保护高度
|
||
AcGeDoubleArray arProHeight;
|
||
pDlg->GetDlgProHT(arProHeight);
|
||
thundXData.SetFoldProHeightToObjEx(idEnt,arProHeight);
|
||
//记录保护高度设置到注册表,保持记忆
|
||
thundXData.SetProtectHeightToReg(arProHeight,KEY_FOLD_THUNDER_MULTIPROHT);
|
||
|
||
//设置折线法标志
|
||
thundXData.SetXData(idEnt,TEL_THUNDER_TYPE,_T("1"));
|
||
|
||
// 新插入的避雷针入库
|
||
FoldManager->AddFoldPinToMap(idEnt);
|
||
|
||
//显示2维联合范围
|
||
FoldManager->ShowUnionPro2d(idEnt);
|
||
|
||
CString sNO;
|
||
sNO.Format(_T("%d"), _ttoi(sNum)+1);
|
||
pDlg->SetNo(sNO);
|
||
|
||
acedUpdateDisplay();
|
||
actrTransactionManager->flushGraphics();
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::FoldErasePinCmd()
|
||
{
|
||
//删除折线法避雷针
|
||
// RBList rb = ads_buildlist(RTDXF0,_T("INSERT"),8,LAY_EL_THUNDER,RTNONE);
|
||
// PickSet ss(SS_FREE);
|
||
// int nRet = SelectEntities(_T("\n请选择需要删除的避雷针<退出>"),ss,rb);
|
||
// if (nRet != RTNORM)
|
||
// {
|
||
// return 0;
|
||
// }
|
||
//
|
||
// Entity ent;
|
||
// CThunderXData thunderXdata;
|
||
// CString sType,sGroup;
|
||
// AcDbObjectId oid;
|
||
// for (long i = 0;i < ss.Length();++i)
|
||
// {
|
||
// acdbGetObjectId(oid,ss[i]);
|
||
// thunderXdata.GetXData(oid,TEL_GROUP_NO,sGroup);
|
||
// if (!sGroup.IsEmpty())
|
||
// {
|
||
// thunderXdata.GetXData(oid,TEL_THUNDER_TYPE,sType);
|
||
// if (sType.CompareNoCase(_T("1")) == 0)
|
||
// {
|
||
// //折线法避雷针
|
||
// FoldManager->DelFoldPinFromMap(sGroup,oid);
|
||
// }
|
||
// }
|
||
//
|
||
// OPENOBJ_BEGIN(oid,AcDb::kForWrite,AcDbEntity,pEnt);
|
||
// if (pEnt)
|
||
// {
|
||
// //删除避雷针
|
||
// pEnt->erase();
|
||
// }
|
||
// OPENOBJ_END();
|
||
// }
|
||
//
|
||
// FoldManager->ShowUnionPro2d(sGroup);
|
||
//删除折线法避雷针
|
||
RBList rb = ads_buildlist(RTDXF0,_T("INSERT"),RTNONE);
|
||
PickSet ss(SS_FREE);
|
||
int nRet = SelectEntities(_T("\n请选择需要删除的避雷针<退出>"),ss,rb);
|
||
if (nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
Entity ent;
|
||
CThunderXData thunderXdata;
|
||
CString sType,sGroup;
|
||
AcDbObjectId oid;
|
||
|
||
//禁止更新
|
||
CThunderCmdGroup::bReDrawFold = FALSE;
|
||
|
||
std::vector<CString> arGroup;
|
||
|
||
typedef std::vector<CString>::iterator ITT;
|
||
|
||
for (long i = 0;i < ss.Length();++i)
|
||
{
|
||
acdbGetObjectId(oid,ss[i]);
|
||
thunderXdata.GetXData(oid,KEY_FOLD_GROUP_NO,sGroup);
|
||
if (!sGroup.IsEmpty())
|
||
{
|
||
thunderXdata.GetXData(oid,TEL_THUNDER_TYPE,sType);
|
||
if (sType.CompareNoCase(_T("1")) == 0)
|
||
{
|
||
//折线法避雷针
|
||
FoldManager->DelFoldPinFromMap(sGroup,oid);
|
||
if (std::find<ITT,CString>(arGroup.begin(),arGroup.end(),sGroup) == arGroup.end())
|
||
{
|
||
arGroup.push_back(sGroup);
|
||
}
|
||
}
|
||
}
|
||
|
||
OPENOBJ_BEGIN(oid,AcDb::kForWrite,AcDbEntity,pEnt);
|
||
if (pEnt)
|
||
{
|
||
//删除避雷针
|
||
pEnt->erase();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
for (unsigned t = 0;t < arGroup.size();++t)
|
||
{
|
||
FoldManager->ShowUnionPro2d(sGroup);
|
||
}
|
||
|
||
CThunderCmdGroup::bReDrawFold = TRUE;
|
||
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::FoldEditPinCmd()
|
||
{
|
||
Entity ent;
|
||
RBList rbMask = ads_buildlist(RTDXF0, _T("INSERT"), NULL);
|
||
if(SelectEntity(_T("\n 请在编号上选择要编辑的避雷针<退出>:"), ent, rbMask) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
AcDbObjectId idThunder;
|
||
acdbGetObjectId(idThunder,ent);
|
||
if (idThunder.isValid())
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CThunderXData thunderXData;
|
||
CString sType = _T("");
|
||
thunderXData.GetXData(idThunder,TEL_THUNDER_TYPE,sType);
|
||
if (sType.CompareNoCase(_T("1")) == 0)
|
||
{
|
||
//折线避雷针
|
||
CFoldLayPinDlg dlg(idThunder,TRUE);
|
||
dlg.DoModal();
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::FoldMovePinCmd()
|
||
{
|
||
Entity ent;
|
||
RBList rb = ads_buildlist(RTDXF0,_T("INSERT"),RTNONE);
|
||
if(SelectEntity(_T("\n 请在编号上选择要移动的避雷针<退出>:"), ent, rb) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
CThunderXData thunderXdata;
|
||
//是否折线法避雷针
|
||
CString sGroupNo = _T("");
|
||
int nGroupNo = thunderXdata.GetFoldGroupNO(ent);
|
||
if (nGroupNo <= 0)
|
||
return 0;
|
||
|
||
sGroupNo.Format(_T("%d"),nGroupNo);
|
||
|
||
AcDbObjectId idThunder;
|
||
acdbGetObjectId(idThunder,ent);
|
||
|
||
XPoint ptPos,ptDes;
|
||
ent.GetData(10,ptPos);
|
||
|
||
acedGetPoint(Wcs2Ucs(ptPos),_T("\n点取目标位置:"),ptDes);
|
||
|
||
AcGeMatrix3d matrix;
|
||
AcGeVector3d vtTrans = ptDes - ptPos;
|
||
matrix.setToTranslation(vtTrans);
|
||
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,AcDbEntity,pRef);
|
||
if (pRef)
|
||
{
|
||
pRef->transformBy(matrix);
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
|
||
FoldManager->UpdateFoldPinInMap(nGroupNo,idThunder);
|
||
FoldManager->ShowUnionPro2d(sGroupNo);
|
||
return 0;
|
||
}
|
||
|
||
int CThunderCmdGroup::maptest()
|
||
{
|
||
std::map<int,CString> arMap;
|
||
// arMap.insert(std::make_pair(100,_T("a")));
|
||
// arMap.insert(std::make_pair(50,_T("a")));
|
||
// arMap.insert(std::make_pair(200,_T("a")));
|
||
// arMap.insert(std::make_pair(10,_T("a")));
|
||
// arMap.insert(std::make_pair(30,_T("a")));
|
||
// arMap.insert(std::make_pair(20,_T("a")));
|
||
// arMap.insert(std::make_pair(150,_T("a")));
|
||
// arMap.insert(std::make_pair(170,_T("a")));
|
||
|
||
std::map<int,CString>::iterator itor;
|
||
CString sTemp;
|
||
for (itor = arMap.begin();itor != arMap.end();++itor)
|
||
{
|
||
sTemp.Format(_T("%d,"),itor->first);
|
||
ads_prompt(sTemp);
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
// 标注半径
|
||
int CThunderCmdGroup::FoldDimentRadiusCmd()
|
||
{
|
||
// 环境
|
||
TReactorAssociate rctAct(acdbCurDwg(), m_pThunderReactor);
|
||
TTempDrawState temp(FALSE);
|
||
|
||
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("CIRCLE"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("LWPOLYLINE"), -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
XPoint ptStart, ptPick;
|
||
Entity ent;
|
||
int nRet = SelectEntity1(_T("\n 请选择要标注的对象<退出>:"), ent, ptPick, rbMask);
|
||
if(nRet != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
CString sGroupNo = _T("");
|
||
AcDbObjectId objId;
|
||
CThunderXData thunderXData;
|
||
acdbGetObjectId(objId, ent);
|
||
|
||
//判断是否折线避雷针保护圆
|
||
thunderXData.GetXData(objId, KEY_FOLD_PRO_GROUP, sGroupNo);
|
||
if (sGroupNo.IsEmpty())
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 数据
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
AcDbCircle* pCircle = NULL;
|
||
AcDbRegion* pRegion = NULL;
|
||
AcDbPolyline* pLine = NULL;
|
||
AcDbArc* pArc = NULL;
|
||
CString sProH = _T("");
|
||
double dProH = 0.0;
|
||
AcDbVoidPtrArray arPtrs;
|
||
CString sType = _T(""), sGroup = _T("");
|
||
BOOL bSel = FALSE;
|
||
int iLen = 0;
|
||
|
||
// ptStart, ptPick
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if(pEnt != NULL)
|
||
{
|
||
int nMode = OS_INS | OS_INT | OS_NEA | XD_POINT | OS_MID | OS_CEN | OS_END;
|
||
XPushVar<int> vOsModeOpen(_T("OSMODE"), nMode);
|
||
|
||
pCircle = AcDbCircle::cast(pEnt);
|
||
if(pCircle != NULL)
|
||
{
|
||
thunderXData.GetXData(pCircle, KEY_FOLD_CURRENT_PROHEIGHT, sProH);
|
||
if(!sProH.IsEmpty())
|
||
dProH = _tstof(sProH);
|
||
ptStart = pCircle->center();
|
||
bSel = TRUE;
|
||
}
|
||
else
|
||
{
|
||
pLine = AcDbPolyline::cast(pEnt);
|
||
if(pLine != NULL)
|
||
{
|
||
thunderXData.GetXData(pLine, KEY_FOLD_PRO_GROUP, sGroup);
|
||
thunderXData.GetXData(pLine, KEY_FOLD_CURRENT_PROHEIGHT, sProH);
|
||
if(!sProH.IsEmpty())
|
||
dProH = _tstof(sProH);
|
||
|
||
RecursiveExplodeGetArcAndCir(pLine, arPtrs);
|
||
|
||
double dTemp = 0.0;
|
||
AcDbEntity* pTemp = NULL;
|
||
std::multimap<double, void*> mapTemp;
|
||
iLen = arPtrs.length();
|
||
for(int i = 0; i < iLen; ++i)
|
||
{
|
||
pTemp = (AcDbEntity*)arPtrs[i];
|
||
if((pArc = AcDbArc::cast(pTemp)) != NULL)
|
||
{
|
||
ptStart = pArc->center();
|
||
dTemp = ptPick.Distance(ptStart);
|
||
mapTemp.insert(std::make_pair(dTemp, pArc));
|
||
}
|
||
else if((pCircle = AcDbCircle::cast(pTemp)) != NULL)
|
||
{
|
||
ptStart = pCircle->center();
|
||
dTemp = ptPick.Distance(ptStart);
|
||
mapTemp.insert(std::make_pair(dTemp, pCircle));
|
||
}
|
||
}
|
||
BOOL bSuc = FALSE;
|
||
if(mapTemp.size() > 0)
|
||
{
|
||
AcDbEntity* pNew = (AcDbEntity*) mapTemp.begin()->second;
|
||
if((pArc = AcDbArc::cast(pNew)) != NULL)
|
||
{
|
||
ptStart = pArc->center();
|
||
thunderXData.SetXData((AcDbEntity*)pArc, TEL_THUNDER_TYPE, sType);
|
||
bSuc = thunderXData.SetXData(pArc, KEY_FOLD_PRO_GROUP, sGroup);
|
||
bSel = TRUE;
|
||
}
|
||
else if((pCircle = AcDbCircle::cast(pNew)) != NULL)
|
||
{
|
||
ptStart = pCircle->center();
|
||
bSel = TRUE;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
if(bSel)
|
||
{
|
||
TelThunderPolyLineJig jig;
|
||
jig.SetPLinePoints(ptStart, ptPick);
|
||
jig.SetHeight(dProH);
|
||
|
||
if(pCircle != NULL)
|
||
jig.SetEntity(pCircle);
|
||
else if(pArc != NULL)
|
||
{
|
||
jig.SetEntity(pArc);
|
||
}
|
||
jig.start();
|
||
}
|
||
|
||
// 回收
|
||
while(iLen-- > 0)
|
||
{
|
||
delete (AcDbEntity*)arPtrs[iLen];
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 标注Bx
|
||
int CThunderCmdGroup::FoldDimentBxCmd()
|
||
{
|
||
// 数据
|
||
//TCHAR sRet[24];
|
||
int nRet = 0;
|
||
CString sInput = _T("");
|
||
int nType = -1;
|
||
|
||
// 命令入口
|
||
// while(1)
|
||
// {
|
||
// //nRet = acedGetString(0, _T("\n标注避雷针<退出>:"), sRet); // 标注避雷针(Z)/标注避雷线(L):<Z> 等待避雷线
|
||
// sInput = sRet;
|
||
// if (nRet == RTCAN)
|
||
// {
|
||
// return 0;
|
||
// }
|
||
// else if (nRet == RTNORM)
|
||
// {
|
||
// if (!sInput.CompareNoCase(_T("Z"))
|
||
// || !sInput.CompareNoCase(_T("z"))
|
||
// || sInput.IsEmpty())
|
||
// {
|
||
// nType = 0;
|
||
// break;
|
||
// }
|
||
// else if (!sInput.CompareNoCase(_T("L"))
|
||
// || !sInput.CompareNoCase(_T("l")))
|
||
// {
|
||
// nType = 1;
|
||
// break;
|
||
// }
|
||
// }
|
||
// nRet = acedGetString(0, _T("\n标注避雷针<退出>:"), NULL); // 标注避雷针(Z)/标注避雷线(L):<Z> 等待避雷线
|
||
// CLableThunderBX drawBx;
|
||
// drawBx.LableFoldPntBX();
|
||
//
|
||
// }
|
||
|
||
|
||
//按关键字类型 操作
|
||
CLableThunderBX drawBx;
|
||
nType = 0;
|
||
switch(nType)
|
||
{
|
||
case 0:
|
||
{
|
||
drawBx.LableFoldPntBX();
|
||
break;
|
||
}
|
||
case 1:
|
||
{
|
||
drawBx.LabeFoldLineBX();
|
||
break;
|
||
}
|
||
default:
|
||
return 0;
|
||
}
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 单避雷表(折线)
|
||
int CThunderCmdGroup::FoldSinSheetCmd()
|
||
{
|
||
// 获取表插入位置
|
||
ads_point ptX;
|
||
if(acedGetPoint(NULL, _T("\n 请选择 避雷针单针保护范围表 插入位置<退出>: "), ptX) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
AcGePoint3d ptPlugIn = asPnt3d(ptX);
|
||
|
||
|
||
// 读取所有避雷针数据
|
||
FoldManager->FilterAllFoldPin(); // 过滤出所有折线避雷针数据
|
||
FOLDPINGROUP mapPin; // 折线避雷针数据
|
||
FoldManager->GetAllFoldThunder(mapPin); // 获取所有避雷针数据
|
||
|
||
int nSize = 0; // 表行数
|
||
int iColCount = 0; // 列数(保护高度 / 保护半径)
|
||
int i = 0, p = 0; // 遍历计数器
|
||
|
||
FOLDPINGROUP::iterator mapItr;
|
||
FOLDPINGROUP::iterator mapItrEnd = mapPin.end();
|
||
int xLen = mapPin.size();
|
||
|
||
FOLDPINLST arPin; // 同组避雷针数据
|
||
FOLDPINLST::iterator itrPin;
|
||
FOLDPINLST::iterator itrPinEnd = arPin.end();
|
||
|
||
std::map<int,XFoldThunder> arThunder;
|
||
std::map<int,XFoldThunder>::iterator itrOlder;
|
||
FOLDPINLST arMaxPin; // 输出表数据集
|
||
std::list<double> lstCol;
|
||
for (mapItr = mapPin.begin(); mapItr != mapItrEnd; ++mapItr)
|
||
{
|
||
arPin = mapItr->second;
|
||
|
||
// 计算列数(保护高度 / 保护半径)
|
||
i = 0;
|
||
iColCount = arPin.at(i).m_arProHeight.length();
|
||
if (iColCount < 1)
|
||
{
|
||
return 0;
|
||
}
|
||
lstCol.push_back(iColCount);
|
||
|
||
//将避雷针按 组号 和 编号 排序
|
||
arThunder.clear();
|
||
for (itrPin = arPin.begin(); itrPin != arPin.end(); ++itrPin)
|
||
{
|
||
arThunder.insert(std::make_pair(itrPin->m_nNo,*itrPin));
|
||
}
|
||
|
||
arPin.clear();
|
||
for (itrOlder = arThunder.begin(); itrOlder != arThunder.end(); ++itrOlder)
|
||
{
|
||
arPin.push_back(itrOlder->second);
|
||
}
|
||
|
||
for (itrPin = arPin.begin(); itrPin != arPin.end(); ++itrPin)
|
||
{
|
||
arMaxPin.push_back(*itrPin); // 所有避雷针
|
||
}
|
||
}
|
||
|
||
nSize = arMaxPin.size(); // 行数
|
||
if (nSize < 1)
|
||
{
|
||
return 0;
|
||
}
|
||
lstCol.sort();
|
||
lstCol.reverse();
|
||
std::list<double>::iterator lstItr = lstCol.begin();
|
||
if (lstItr != lstCol.end())
|
||
{
|
||
// 列数 (保护高度/保护半径)
|
||
iColCount = (int)*lstItr;
|
||
}
|
||
|
||
|
||
// 建表
|
||
TelDrawSheet telFoldSinSheet; // 折线法单表
|
||
telFoldSinSheet.SetLayer(LAY_LIGHTSHEET); // 设置单表图层
|
||
double dTxtSize(4), dTxtHeight(4);
|
||
double dTableHeight(7);
|
||
// 表风格
|
||
TGridStyle gridStyle;
|
||
AcDbObjectId idTxtStyle = NULL;
|
||
idTxtStyle = KTSetting::InitTextStyle(G_CSDIMSTYLE); // 获取文本风格ID
|
||
gridStyle.SetTextStyleId(idTxtStyle); // 设置表格中文本风格ID
|
||
gridStyle.SetOverrideAll(TRUE); // ? 覆盖
|
||
gridStyle.SetTextHeight(dTxtHeight); // 设置文本高度
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
telFoldSinSheet.SetLocation(ptPlugIn); // 表插入点
|
||
telFoldSinSheet.SetGridStyle(gridStyle); // 设置表格风格
|
||
telFoldSinSheet.SetRotation(Ucs2Wcs(0.0)); // 设置旋转角度
|
||
telFoldSinSheet.SetRowHeight(dTableHeight * 2); // 设置表宽
|
||
telFoldSinSheet.SetTitleVisible(TRUE);
|
||
AcDbObjectId idStyle = KTSetting::InitTextStyle(EL_DIM); // 文本ID
|
||
// 初始化表
|
||
telFoldSinSheet.InitSheet(nSize + 1, iColCount + 5, dTableHeight * 2, 50);
|
||
// 设置表格标题
|
||
gridStyle.SetTextHeight(6.0);
|
||
gridStyle.SetVerMode(AcDb::kTextBottom);
|
||
telFoldSinSheet.SetTitleText(_T("避雷针单针保护范围表"));
|
||
telFoldSinSheet.SetTitleHeight(0.01);
|
||
telFoldSinSheet.SetTitleTestStyle(gridStyle);
|
||
// 设置列标题
|
||
telFoldSinSheet.SetColumnText(0, _T("避雷针组号"), 35);
|
||
telFoldSinSheet.SetColumnText(1, _T("避雷针编号"), 35);
|
||
telFoldSinSheet.SetColumnText(2, _T("针高 h(米)"), 35);
|
||
telFoldSinSheet.SetColumnText(3, _T("高度影响系数 p"), 40);
|
||
for(int m = 0; m < iColCount; ++m)
|
||
{
|
||
telFoldSinSheet.SetColumnText(4 + m, _T("保护高度 hx(米) /\n保护半径 rx(米)"), 45);
|
||
}
|
||
telFoldSinSheet.SetColumnText(5 + iColCount - 1, _T("备注"), 35);
|
||
|
||
|
||
// 插入数据
|
||
CFoldToolKit* pToolKit = CFoldToolKit::Instance();
|
||
CString csTemp = _T(""); // 输出临时字符处变量
|
||
double dHtemp = 0.0; // 临时针高
|
||
double dPbyH = 0.0; // 高度影响系数p
|
||
double dProHeight = 0.0; // 保护高度 hx
|
||
double dProRadius = 0.0; // 保护半径 rx
|
||
int nLen = 0; // 保护高度个数
|
||
AcGeDoubleArray arProHTemp; // 保护高度临时数组
|
||
i = 0;
|
||
int mapLen = arMaxPin.size();//cs
|
||
xLen = arPin.size();//cs
|
||
for(itrPin = arMaxPin.begin(); itrPin != arMaxPin.end(); ++itrPin)
|
||
{
|
||
if (i == mapLen)
|
||
{
|
||
break;
|
||
}
|
||
// 插入数据
|
||
csTemp.Format(_T("%d"),(*itrPin).m_nGroup);
|
||
telFoldSinSheet.SetText(i + 1, 0, csTemp); // 避雷针组号
|
||
|
||
csTemp.Format(_T("%d#"), (*itrPin).m_nNo);
|
||
telFoldSinSheet.SetText(i + 1, 1, csTemp); // 避雷针编号
|
||
|
||
csTemp.Format(_T("%.2f"), (*itrPin).m_dHeight);
|
||
telFoldSinSheet.SetText(i + 1, 2, csTemp); // 针高 h
|
||
|
||
// 高度影响系数p
|
||
dHtemp = (*itrPin).m_dHeight;
|
||
if (dHtemp < 30.0)
|
||
dPbyH = 1;
|
||
else if (dHtemp >= 30.0 && dHtemp <= 120.0)
|
||
dPbyH = 5.5 / (pow(dHtemp, 0.5));
|
||
else if (dHtemp > 120.0)
|
||
dPbyH = 0.502079;
|
||
csTemp.Format(_T("%.2f"), dPbyH);
|
||
telFoldSinSheet.SetText(i + 1, 3, csTemp);
|
||
|
||
// 2012/3/21 for 支持山地坡地计算
|
||
int nCheck = -1;
|
||
CRegProperty reg(GetRegLocation(), _T("Thunder"));
|
||
reg.SetTopRootKey(HKEY_CURRENT_USER);
|
||
if (!reg.GetValue(KEY_FOLD_HILL_HILLSIDE, nCheck))
|
||
{
|
||
nCheck = 0;
|
||
}
|
||
|
||
// 插入保护高度hx / 对应的保护半径rx
|
||
arProHTemp = (*itrPin).m_arProHeight;
|
||
SorProHeight(arProHTemp); // 排序保护高度hx
|
||
nLen = arProHTemp.length();
|
||
for(int j = 0; j < nLen; ++j)
|
||
{
|
||
dProHeight = arProHTemp[j];
|
||
|
||
// 保护半径需要重新计算
|
||
|
||
if(dProHeight >= 0.5*dHtemp)
|
||
{
|
||
dProRadius = (dHtemp - dProHeight) * dPbyH;
|
||
}
|
||
else if (dProHeight < 0.5*dHtemp)
|
||
{
|
||
dProRadius = (1.5*dHtemp - 2*dProHeight) * dPbyH;
|
||
}
|
||
|
||
// 2012/3/21
|
||
if (nCheck)
|
||
{
|
||
dProRadius *= 0.75;
|
||
}
|
||
|
||
csTemp.Format(_T("%.2f/%.2f"),dProHeight, dProRadius);
|
||
telFoldSinSheet.SetText(i + 1, 4 + j, csTemp); // 保护高度/保护半径
|
||
}
|
||
|
||
i++;
|
||
}
|
||
|
||
telFoldSinSheet.AddToCSpace(TRUE);
|
||
|
||
return 0;
|
||
}
|
||
|
||
bool CThunderCmdGroup::DocGetMeterUnitDraw()
|
||
{
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"),&rb);
|
||
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// 双避雷表(折线)
|
||
int CThunderCmdGroup::FoldDblSheetCmd()
|
||
{
|
||
// 获取表插入位置
|
||
ads_point ptTemp;
|
||
if(acedGetPoint(NULL, _T("\n 请选择 避雷针双针联合保护范围表 插入位置<退出>: "), ptTemp) != RTNORM)
|
||
{
|
||
return 0;
|
||
}
|
||
AcGePoint3d ptPlugIn = asPnt3d(ptTemp);
|
||
|
||
|
||
// 读取避雷针数据
|
||
double dScale = 0.0;
|
||
if (!DocGetMeterUnitDraw())
|
||
dScale = 1000.0;
|
||
else
|
||
dScale = 1.0;
|
||
|
||
FOLDPINGROUP mapPin; // 所有避雷针数据
|
||
FOLDPINGROUP::iterator mapItr;
|
||
FoldManager->FilterAllFoldPin();
|
||
FoldManager->GetAllFoldThunder(mapPin);
|
||
|
||
// 排序
|
||
// 组号默认
|
||
AcArray<FoldDblSheetData> arDblSheetData; // 双表数据数组
|
||
FoldDblSheetData dblData; // 避雷针数据结构体单元
|
||
|
||
FOLDPINLST arSubPin; // 同组避雷针数组
|
||
FOLDPINLST::iterator itrS, itrSub;
|
||
FOLDPINLST arCanUniPin; // 可形成联合防护的避雷针数组
|
||
|
||
std::map<int, XFoldThunder> mapThunder;
|
||
std::map<int, XFoldThunder>::iterator oldItr;
|
||
|
||
// 判断是否出双表
|
||
FOLDPINLST arAllPin;
|
||
for (mapItr = mapPin.begin(); mapItr != mapPin.end(); ++mapItr)
|
||
{
|
||
arSubPin = mapItr->second;
|
||
|
||
mapThunder.clear();
|
||
for (itrS = arSubPin.begin(); itrS != arSubPin.end(); ++itrS)
|
||
{
|
||
mapThunder.insert(std::make_pair(itrS->m_nNo, *itrS));
|
||
}
|
||
arSubPin.clear();
|
||
for (oldItr = mapThunder.begin(); oldItr != mapThunder.end(); ++oldItr)
|
||
{
|
||
arAllPin.push_back(oldItr->second);
|
||
}
|
||
}
|
||
int nPinLen = arAllPin.size();
|
||
if (nPinLen < 2)
|
||
{
|
||
acutPrintf(_T("\n 双避雷表至少需要两个避雷针!"));
|
||
return 0;
|
||
}
|
||
|
||
|
||
CString csTemp = _T(""); // 临时数据信息变量
|
||
double dDis = 0.0, dDisX = 0.0; // 针距 D->dDis, D'->dDisX
|
||
AcGeDoubleArray arProHTemp; // 保护高度数组
|
||
int nProHLen = 0; // 保护高度个数
|
||
double dH1 = 0.0, dH2 = 0.0; //
|
||
double dmin = 0.0, dmax = 0.0;
|
||
double dX = 0.0;
|
||
double dHx = 0.0;
|
||
double dBx = 0.0;
|
||
CFoldToolKit* pToolKit = CFoldToolKit::Instance();
|
||
CFoldPinRelation* pRelation = CFoldPinRelation::Instance();
|
||
|
||
for(mapItr = mapPin.begin(); mapItr != mapPin.end(); ++mapItr)
|
||
{
|
||
arSubPin = mapItr->second;
|
||
|
||
// 当前同组 编号排序
|
||
mapThunder.clear();
|
||
for (itrS = arSubPin.begin(); itrS != arSubPin.end(); ++itrS)
|
||
{
|
||
mapThunder.insert(std::make_pair(itrS->m_nNo, *itrS));
|
||
}
|
||
|
||
arSubPin.clear();
|
||
for (oldItr = mapThunder.begin(); oldItr != mapThunder.end(); ++oldItr)
|
||
{
|
||
arSubPin.push_back(oldItr->second);
|
||
}
|
||
|
||
// 整理数据
|
||
for(itrS = arSubPin.begin(); itrS != arSubPin.end(); ++itrS)
|
||
{
|
||
itrSub = itrS; //
|
||
itrSub++; //
|
||
dH1 = itrS->m_dHeight;
|
||
|
||
for(itrSub; itrSub != arSubPin.end(); ++itrSub)
|
||
{
|
||
dH2 = itrSub->m_dHeight;
|
||
dDis = itrS->m_ptPos.distanceTo(itrSub->m_ptPos) / dScale; // 针距
|
||
|
||
// 多个保护高度处理
|
||
arProHTemp = itrSub->m_arProHeight;
|
||
SorProHeight(arProHTemp);
|
||
nProHLen = arProHTemp.length();
|
||
for(int k = 0; k < nProHLen; ++k)
|
||
{
|
||
// 组号
|
||
dblData.nGroupNo = itrS->m_nGroup;
|
||
|
||
// 编号
|
||
csTemp.Format(_T("%d# - %d#"), itrS->m_nNo, itrSub->m_nNo);
|
||
_tcscpy(dblData.szNo, csTemp);
|
||
|
||
// 针高
|
||
csTemp.Format(_T("%.2f"), dH1);
|
||
if (dH1 != dH2)
|
||
{
|
||
csTemp.Format(_T("%.2f/%.2f"), dH1, dH2);
|
||
}
|
||
_tcscpy(dblData.szPinH, csTemp);
|
||
|
||
// 保护高度
|
||
dHx = arProHTemp[k];
|
||
dblData.dProHeight = dHx;
|
||
|
||
// D和D'
|
||
csTemp.Format(_T("%.2f"), dDis);
|
||
if (dH1 != dH2)
|
||
{
|
||
dDisX = pToolKit->CalcEffectDist(dH1, dH2, dDis, dHx);
|
||
csTemp.Format(_T("%.2f/%.2f"), dDis, dDisX);
|
||
}
|
||
_tcscpy(dblData.szDist, csTemp);
|
||
|
||
// 折线法的联合保护BX计算2011/11/7
|
||
// 联合保护宽度Bx
|
||
if (pToolKit->CalcFoldBx(dH1, dH2, dDis, dHx, dBx))
|
||
{
|
||
dblData.dBx = dBx;
|
||
arDblSheetData.append(dblData);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// 建表
|
||
TelDrawSheet telFoldDblSheet;
|
||
telFoldDblSheet.SetLayer(_T("LINGHTNING_SINSHEET)"));
|
||
double dTitleH(4);
|
||
double dTextH(4);
|
||
double dTableH(7);
|
||
AcDbObjectId idTextStyle = NULL;
|
||
idTextStyle = KTSetting::InitTextStyle(G_CSDIMSTYLE);
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(dTextH);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
|
||
telFoldDblSheet.SetLocation(ptPlugIn);
|
||
telFoldDblSheet.SetGridStyle(gridStyle);
|
||
telFoldDblSheet.SetTitleVisible(TRUE);
|
||
telFoldDblSheet.SetRowHeight(dTableH * 2); // 2011/11/8
|
||
telFoldDblSheet.SetRotation(Ucs2Wcs(0.0));
|
||
int nDblSheetLen = arDblSheetData.length();
|
||
telFoldDblSheet.InitSheet(nDblSheetLen + 1, 7, dTableH * 2, 50); // 2011/11/8
|
||
|
||
// 设置表格标题
|
||
gridStyle.SetTextHeight(6.0);
|
||
gridStyle.SetVerMode(AcDb::kTextBottom);
|
||
telFoldDblSheet.SetTitleText(_T("避雷针双针联合保护范围表"));
|
||
telFoldDblSheet.SetTitleHeight(0.01);
|
||
telFoldDblSheet.SetTitleTestStyle(gridStyle);
|
||
|
||
// 设置列标题
|
||
telFoldDblSheet.SetColumnText(0, _T("避雷针组号"), 35);
|
||
telFoldDblSheet.SetColumnText(1, _T("避雷针编号"), 35);
|
||
telFoldDblSheet.SetColumnText(2, _T("针高h(米)"), 35);
|
||
telFoldDblSheet.SetColumnText(3, _T("保护高度hx(米)"), 35);
|
||
telFoldDblSheet.SetColumnText(4, _T("两针距离D/D'(米)"), 35);
|
||
telFoldDblSheet.SetColumnText(5, _T("联合保护宽度bx(米)"), 35);
|
||
telFoldDblSheet.SetColumnText(6, _T("备注"), 40);
|
||
|
||
// 显示数据
|
||
for(int m = 0; m < nDblSheetLen; ++m)
|
||
{
|
||
// 避雷针组号
|
||
csTemp.Format(_T("%d"),arDblSheetData[m].nGroupNo);
|
||
telFoldDblSheet.SetText(m+1, 0, csTemp);
|
||
|
||
// 避雷针编号
|
||
csTemp = arDblSheetData[m].szNo;
|
||
telFoldDblSheet.SetText(m+1, 1, csTemp);
|
||
|
||
// 针高h
|
||
csTemp = arDblSheetData[m].szPinH;
|
||
telFoldDblSheet.SetText(m+1, 2, csTemp);
|
||
|
||
// 保护高度hx
|
||
csTemp.Format(_T("%.2f"), arDblSheetData[m].dProHeight);
|
||
telFoldDblSheet.SetText(m+1, 3, csTemp);
|
||
|
||
// D和D'
|
||
csTemp = arDblSheetData[m].szDist;
|
||
telFoldDblSheet.SetText(m+1, 4, csTemp);
|
||
|
||
// 联合保护范围bx
|
||
csTemp.Format(_T("%.2f"), arDblSheetData[m].dBx);
|
||
telFoldDblSheet.SetText(m+1, 5, csTemp);
|
||
}
|
||
|
||
telFoldDblSheet.AddToCSpace(TRUE);
|
||
|
||
return 0;
|
||
}
|
||
|
||
// 雷计算书(折线)
|
||
int CThunderCmdGroup::FoldCalcBookCmd()
|
||
{
|
||
// 避雷针数据
|
||
FOLDPINGROUP mapPin; // 所有避雷针数据
|
||
FOLDPINGROUP::iterator mapItr;
|
||
FoldManager->FilterAllFoldPin();
|
||
FoldManager->GetAllFoldThunder(mapPin);
|
||
|
||
if(mapPin.size() == 1)
|
||
{
|
||
// 判断是否出书
|
||
mapItr = mapPin.begin();
|
||
if(mapItr->second.size() < 2)
|
||
{
|
||
AfxMessageBox(_T("避雷针少于2个,无法出计算书!"));
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
double dScale = 0.0;
|
||
if (!DocGetMeterUnitDraw())
|
||
dScale = 1000.0;
|
||
else
|
||
dScale = 1.0;
|
||
|
||
// 初始化
|
||
TelCreateWordApp word;
|
||
word.SetAlignment(1); // 0->居左 1->居中 2->居右
|
||
word.SetFont(_T("黑体"), 18, 0);
|
||
word.TypeText(_T("折线法防雷设计计算书\n\n"));
|
||
word.SetAlignment(0);
|
||
word.SetFont(_T("宋体"), 10, 0);
|
||
word.TypeText(_T("工程名:\n计算者:\n计算时间:\n参考规范:《工业与民用配电设计手册》第三版\n\t\t 交流电气装置的过电压保护和绝缘配合DL/T 620-1997\n\n\n"));
|
||
|
||
|
||
// 参量
|
||
CString csTmp = _T("");
|
||
int nGroupNo = 0; // 组号
|
||
int nNum = 0; // 编号
|
||
double dH = 0.0; // 针高
|
||
double dHx = 0.0; // 保护高度
|
||
AcGeDoubleArray arProH; // 保护高度数组
|
||
int nLen = 0;
|
||
|
||
double dH1 = 0.0, dH2 = 0;
|
||
double dHmin = 0.0, dHmax = 0.0;
|
||
double dPbyH = 0.0, dPmax = 0.0; // 高度影响系数
|
||
double dRx = 0.0; // 保护半径
|
||
|
||
double dDis = 0.0, dDisX; // 针距
|
||
double dH0 = 0.0;
|
||
double dX = 0.0;
|
||
double dY = 0.0;
|
||
double dBx = 0.0; // 联合保护范围
|
||
double dhap = 0.0;
|
||
|
||
FOLDPINLST arSubPin;
|
||
FOLDPINLST::iterator itrS, itrSub;
|
||
|
||
std::map<int, XFoldThunder> mapPinTmp;
|
||
std::map<int, XFoldThunder>::iterator tmpItr;
|
||
|
||
CFoldToolKit* pToolKit = CFoldToolKit::Instance();
|
||
FoldCalcResult foldCalc; // 2012/1/10 for 计算dY,dBx by wzh
|
||
BOOL bSuc = FALSE;
|
||
|
||
// 2012/3/21 for 支持山地坡地计算
|
||
int nCheck = -1;
|
||
CRegProperty reg(GetRegLocation(), _T("Thunder"));
|
||
reg.SetTopRootKey(HKEY_CURRENT_USER);
|
||
if (!reg.GetValue(KEY_FOLD_HILL_HILLSIDE, nCheck))
|
||
{
|
||
nCheck = 0;
|
||
}
|
||
|
||
// 计算出书
|
||
for(mapItr = mapPin.begin(); mapItr != mapPin.end(); ++mapItr)
|
||
{
|
||
arSubPin = mapItr->second;
|
||
|
||
// 编号排序
|
||
mapPinTmp.clear();
|
||
for(itrS = arSubPin.begin(); itrS != arSubPin.end(); ++itrS)
|
||
{
|
||
mapPinTmp.insert(std::make_pair(itrS->m_nNo, *itrS));
|
||
}
|
||
|
||
arSubPin.clear();
|
||
for(tmpItr = mapPinTmp.begin(); tmpItr != mapPinTmp.end(); ++tmpItr)
|
||
{
|
||
arSubPin.push_back(tmpItr->second);
|
||
}
|
||
|
||
// 整理数据
|
||
for(itrS = arSubPin.begin(); itrS != arSubPin.end(); ++itrS)
|
||
{
|
||
nGroupNo = itrS->m_nGroup; // 组号
|
||
nNum = itrS->m_nNo; // 编号
|
||
dH1 = dH = itrS->m_dHeight; // 针高
|
||
|
||
// 多保护高度处理
|
||
arProH = itrS->m_arProHeight;
|
||
SorProHeight(arProH);
|
||
nLen = arProH.length();
|
||
for(int i = 0; i < nLen; ++i)
|
||
{
|
||
dHx = arProH[i]; // 被保护物的高度
|
||
|
||
// 已知条件
|
||
word.SetFont(_T("宋体"), 12, 1);
|
||
word.TypeText(_T("已知条件\n"));
|
||
word.SetFont(_T("宋体"), 10, 0);
|
||
if (nCheck)
|
||
{
|
||
csTmp.Format(_T("\t 算法:折线法\n\t 避雷针组号%d\n\t 避雷针编号%d\n\t 针高:%.2f米\n\t 被保护物的高度:%.2f米\n\t 布置于山地和坡地\n"), nGroupNo, nNum, dH, dHx);
|
||
}
|
||
else
|
||
csTmp.Format(_T("\t 算法:折线法\n\t 避雷针组号%d\n\t 避雷针编号%d\n\t 针高:%.2f米\n\t 被保护物的高度:%.2f米\n"), nGroupNo, nNum, dH, dHx);
|
||
word.TypeText(csTmp);
|
||
|
||
/* 高度影响系数p */
|
||
//word.SetFont(_T("宋体"),10,0);
|
||
word.TypeText(_T("\t 高度影响系数p:\n"));
|
||
word.TypeText(_T("\t\t a, h<30m时, p = 1\n\t\t b, 30≤h≤120m时,p=(5.5)/√h\n\t\t c, h>120m时,h 取120,按b中公式计算。 p=0.502079\n\n"));
|
||
|
||
|
||
|
||
// 计算过程和公式
|
||
word.SetFont(_T("宋体"),12,1);
|
||
word.TypeText(_T("计算过程和公式\n"));
|
||
|
||
// /* 高度影响系数p */
|
||
word.SetFont(_T("宋体"),10,0);
|
||
// word.TypeText(_T("\t 高度影响系数p:\n"));
|
||
// word.TypeText(_T("\t\t a, h<30m时, p = 1\n\t\t b, 30≤h≤120m时,p=(5.5)/√h\n\t\t c, h>120m时,h 取120,按b中公式计算。 p=0.502079\n"));
|
||
word.TypeText(_T("\t hx保护高度保护单针保护半径rx\n"));
|
||
|
||
if (dH - 30 < 1e-6)
|
||
{
|
||
dPbyH = 1.0;
|
||
}
|
||
else
|
||
{
|
||
dPbyH = 5.5 / pow(dH, 0.5);
|
||
if (dH - 120 >1e-6)
|
||
{
|
||
dPbyH = 0.502079; // dPbyH = 5.5 / pow(120, 0.5);
|
||
}
|
||
}
|
||
|
||
// 2012/4/6
|
||
dRx = pToolKit->CalcFoldRx(dH, dHx);
|
||
if (0.5*dH - dHx < 1e-6)
|
||
{
|
||
if (nCheck)
|
||
{
|
||
// 2012/3/21 支持山地坡地计算
|
||
csTmp.Format(_T("\t\t hx >= 0.5h\n\t\t rx =0.75*(h - hx)p\n\t\t = 0.75*(%.2f - %.2f)*%.2f\n\t\t = %.2f (米)\n"), dH, dHx, dPbyH, dRx);
|
||
}
|
||
else
|
||
{
|
||
csTmp.Format(_T("\t\t hx >= 0.5h\n\t\t rx =(h - hx)p\n\t\t = (%.2f - %.2f)*%.2f\n\t\t = %.2f (米)\n"), dH, dHx, dPbyH, dRx);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nCheck)
|
||
{
|
||
// 2012/3/21 支持山地坡地计算
|
||
csTmp.Format(_T("\t\t hx < 0.5h\n\t\t rx =0.75*(1.5h - 2hx)p\n\t\t = 0.75*(%.2f - %.2f)*%.2f\n\t\t = %.2f (米)\n"), 1.5*dH, 2*dHx, dPbyH, dRx);
|
||
}
|
||
else
|
||
{
|
||
csTmp.Format(_T("\t\t hx < 0.5h\n\t\t rx =(1.5h - 2hx)p\n\t\t = (%.2f - %.2f)*%.2f\n\t\t = %.2f (米)\n"), 1.5*dH, 2*dHx, dPbyH, dRx);
|
||
}
|
||
}
|
||
word.TypeText(csTmp);
|
||
|
||
|
||
// if (nLen >= 2)
|
||
// {
|
||
// X-X 两针联合保护
|
||
// word.SetFont(_T("宋体"), 12, 1);
|
||
// word.TypeText(_T("\nX-X两针联合保护\n"));
|
||
word.SetFont(_T("宋体"), 10, 0);
|
||
|
||
itrSub = itrS;
|
||
++itrSub;
|
||
for(itrSub; itrSub != arSubPin.end(); ++itrSub)
|
||
{
|
||
dH2 = itrSub->m_dHeight;
|
||
|
||
if(dH1 == dH2)
|
||
{
|
||
// 等高
|
||
dDis = itrS->m_ptPos.distanceTo(itrSub->m_ptPos) / dScale;
|
||
dX = dDis / (dH1 - dHx) * dPbyH;
|
||
|
||
//word.TypeText(_T("\t 等高:\n"));
|
||
csTmp.Format(_T(" %d - %d两针等高\n\t 两针距离 D = %.2f (米)\n"), itrS->m_nNo,itrSub->m_nNo, dDis);
|
||
word.TypeText(csTmp);
|
||
csTmp.Format(_T("\t x = D/(h - hx)p\n\t = %.2f /(%.2f - %.2f)*%.2f\n\t = %.2f (米)\n"), dDis, dH1, dHx, dPbyH, dX);
|
||
word.TypeText(csTmp);
|
||
|
||
if (pToolKit->CalcFoldBx(dH1, dH2, dDis, dHx, foldCalc))
|
||
{
|
||
dY =foldCalc.m_dY;
|
||
dBx = foldCalc.m_dBx;
|
||
}
|
||
|
||
csTmp.Format(_T("\t 查表得 y = %.2f\n"), dY);
|
||
word.TypeText(csTmp);
|
||
word.TypeText(_T("\t 避雷针联合保护宽度\n"));
|
||
if (nCheck)
|
||
{
|
||
// 2012/3/21 for 支持山地坡地开发
|
||
csTmp.Format(_T("\t Bx = 0.75 * y * (h - hx) * p\n\t = 0.75 * %.2f * (%.2f - %.2f) * %.2f\n\t = %.2f (米)\n"), dY, dH1, dHx, dPbyH, dBx);
|
||
}
|
||
else
|
||
{
|
||
csTmp.Format(_T("\t Bx = y * (h - hx) * p\n\t = %.2f * (%.2f - %.2f) * %.2f\n\t = %.2f (米)\n"), dY, dH1, dHx, dPbyH, dBx);
|
||
}
|
||
word.TypeText(csTmp);
|
||
}
|
||
else
|
||
{
|
||
// 不等高
|
||
//word.TypeText(_T("\t 不等高:\n"));
|
||
// 2012/4/6
|
||
// dHmin = min(dH1, dH2);
|
||
// dHmax = max(dH1, dH2);
|
||
// csTmp.Format(_T("\t hmin = min(h , h2) = %.2f (米)\n"), dHmin);
|
||
// word.TypeText(csTmp);
|
||
// csTmp.Format(_T(" hmax = max(h , h2) = %.2f (米)\n"), dHmax);
|
||
// word.TypeText(csTmp);
|
||
|
||
// 2012/4/6
|
||
// word.TypeText(_T("\t 高度影响系数p:\n")); // 取dHmax
|
||
if (dHmax - 30 < 1e-6)
|
||
{
|
||
dPmax = 1.0;
|
||
}
|
||
else
|
||
{
|
||
dPmax = 5.5 / pow(dHmax, 0.5);
|
||
if (dHmax - 120 >1e-6)
|
||
{
|
||
dPmax = 5.5 / pow(120, 0.5); //dPmax = 0.502079;
|
||
}
|
||
}
|
||
// word.TypeText(_T("\t\t a, h<30m时, p = 1\n\t\t b, 30≤h≤120m时,p=(5.5)/√h\n\t\t c, h>120m时,h 取120,按b中公式计算。 p=0.502079\n"));
|
||
|
||
dDis = itrS->m_ptPos.distanceTo(itrSub->m_ptPos) / dScale;
|
||
csTmp.Format(_T(" %d - %d两针不等高\n\t 两针距离 D = %.2f (米)\n"), itrS->m_nNo, itrSub->m_nNo, dDis);
|
||
word.TypeText(csTmp);
|
||
|
||
dHmin = min(dH1, dH2);
|
||
dHmax = max(dH1, dH2);
|
||
csTmp.Format(_T("\t hmin = min(h , h2) = %.2f (米)\n"), dHmin);
|
||
word.TypeText(csTmp);
|
||
csTmp.Format(_T(" hmax = max(h , h2) = %.2f (米)\n"), dHmax);
|
||
word.TypeText(csTmp);
|
||
|
||
// D'
|
||
dDisX = pToolKit->CalcEffectDist(dH1, dH2, dDis, dHx);
|
||
if (dHmin >= 0.5*dHmax)
|
||
{
|
||
//dDisX = dDis - (dHmax - dHmin)*dPmax;
|
||
csTmp.Format(_T(" hmin ≥ 0.5hmax时\n\t D' = D - rh\n\t = D - (hmax - hmin)p\n\t = %.2f - (%.2f - %.2f) * %.2f\n\t = %.2f (米)\n"), dDis, dHmax, dHmin, dPmax, dDisX);
|
||
}
|
||
else if (dHmin - 0.5*dHmax < 1e-6)
|
||
{
|
||
word.TypeText(_T("\t 不等高避雷针等价等高距离 D'\n"));
|
||
//dDisX = dDis - (1.5*dHmax - 2*dHmin)*dPmax;
|
||
csTmp.Format(_T("\t hmin<0.5hmax时\n\t D' = D - rh\n\t = D - (1.5hmax - 2hmin)p\n\t = %.2f - (1.5*%.2f - 2*%.2f)*%.2f\n\t = %.2f (米)"), dDis, dHmax, dHmin, dPmax, dDisX);
|
||
}
|
||
word.TypeText(csTmp);
|
||
|
||
// dH0
|
||
if (nCheck)
|
||
{
|
||
// 2012/3/21 for 支持山地坡地开发
|
||
dH0 = dHmin - dDisX/(5*dPbyH);
|
||
csTmp.Format(_T("\t h0 = hmin - D' / 5p\n\t = %.2f - %.2f / %.2f\n\t = %.2f (米)\n"), dHmin, dDisX, 5 * dPbyH, dH0);
|
||
}
|
||
else
|
||
{
|
||
// 2012/1/12 三维待用 两针联合最低保护高度
|
||
dH0 = dHmin - dDisX / (7*dPbyH);
|
||
csTmp.Format(_T("\t h0 = hmin - D' / 7p\n\t = %.2f - %.2f / %.2f\n\t = %.2f (米)\n"), dHmin, dDisX, 7 * dPbyH, dH0);
|
||
}
|
||
word.TypeText(csTmp);
|
||
|
||
// x
|
||
dhap = (dHmin - dHx) * dPmax;
|
||
dX = dDisX / dhap;
|
||
csTmp.Format(_T("\t x = D' / hap\n\t = D' / ((hmin - hx)*p)\n\t = %.2f / ((%.2f - %.2f)*%.2f)\n\t = %.2f (米)\n"), dDisX, dHmin, dHx, dPmax, dX);
|
||
word.TypeText(csTmp);
|
||
|
||
//dY
|
||
bSuc = pToolKit->CalcFoldBx(dH1, dH2, dDis, dHx, foldCalc);
|
||
if (bSuc)
|
||
{
|
||
dY = foldCalc.m_dY;
|
||
dBx = foldCalc.m_dBx;
|
||
}
|
||
csTmp.Format(_T("\t 查表得 y = %.2f\n"), dY);
|
||
word.TypeText(csTmp);
|
||
|
||
word.TypeText(_T("\t 避雷针联合保护宽度\n"));
|
||
if (bSuc)
|
||
{
|
||
|
||
if (nCheck)
|
||
{
|
||
// 2012/3/21 for 支持山地坡地开发
|
||
csTmp.Format(_T("\t Bx = 0.75 * y * (hmin - hx)*p\n\t = 0.75 * %.2f * (%.2f - %.2f) * %.2f\n\t = %.2f (米)\n"), dY, dHmin, dHx, dPmax, dBx);
|
||
}
|
||
else
|
||
{
|
||
csTmp.Format(_T("\t Bx = y*(hmin - hx)*p\n\t = %.2f * (%.2f - %.2f) * %.2f\n\t = %.2f (米)\n"), dY, dHmin, dHx, dPmax, dBx);
|
||
}
|
||
word.TypeText(csTmp);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
// }
|
||
|
||
|
||
|
||
// 计算结果
|
||
word.SetFont(_T("宋体"), 12, 1);
|
||
word.TypeText(_T("\n计算结果\n"));
|
||
word.SetFont(_T("宋体"), 10, 0);
|
||
csTmp.Format(_T("\t 避雷针在%.2f米处的保护范围为%.2f米\n\n\n"), dHx, dRx);
|
||
word.TypeText(csTmp);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}// 计算书
|
||
|
||
return 0;
|
||
} |