1069 lines
31 KiB
C++
1069 lines
31 KiB
C++
// GullyDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "GeCurveInline.h"
|
|
#include "AcDbObjectPtr.h"
|
|
#include "GullyDlg.h"
|
|
#include "TBlockEdJig.h"
|
|
#include "DbWell.h"
|
|
#include "PickEntSet.h"
|
|
#include "layerdef.h"
|
|
#include "globalFunc.h"
|
|
#include "DbPipe.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern AcDbObjectId InitTextStyle(TTextStyle ts, AcDbDatabase *pDb = NULL);
|
|
extern AcDbObjectId InitLayer(const TCHAR *szLayer, BOOL bApplyChange = TRUE);
|
|
|
|
//extern AcDbPolyline* GlobalFunc::GetNextPloyLine(Entity ent, Entity ent2, XPoint ptPick, XPoint ptPick2);
|
|
// 根据两点找到之间的唯一实体, 并将ptGiven点向该实体上投影
|
|
XPoint GetGullyProjectPoint(XPoint ptStart, XPoint ptEnd, XPoint ptGiven)
|
|
{
|
|
XPoint ptProjRet;
|
|
PickSet ssCurve(SS_FREE);
|
|
RBList rbMaskCurve = ads_buildlist( -4, _T("<or"), RTDXF0, _T("LINE"), RTDXF0, _T("ARC"), -4, _T("or>"), NULL);
|
|
struct resbuf* pointlist = ads_buildlist(RTPOINT, &ptStart, RTPOINT, &ptEnd, NULL);
|
|
ssCurve.Get(_T("F"), pointlist, NULL, rbMaskCurve);
|
|
ads_relrb(pointlist);
|
|
XLine line(ptStart, ptEnd);
|
|
// line.Make();
|
|
if (1 == ssCurve.Length())
|
|
{
|
|
OPENOBJ_BEGIN(ssCurve[0L], AcDb::kForRead, AcDbCurve, pCurve);
|
|
if (pCurve)
|
|
pCurve->getClosestPointTo(ptGiven, ptProjRet);
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
return ptProjRet;
|
|
}
|
|
void ReplaceGully(CGullyDlg &dlg)
|
|
{
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
|
-4, _T("<and"), RTDXF0, _T("AEC_ZT_EQUIPMENT"), 8, LAY_TWT_GULLY, -4, _T("and>"),
|
|
-4, _T("or>"), NULL);
|
|
PickSet ss(SS_FREE);
|
|
|
|
if(GlobalFunc::SelectEntities(_T("\n请选择要替换雨水口<退出>:"), ss, rbMask) != RTNORM)
|
|
return;
|
|
|
|
dlg.UpdateData(TRUE);
|
|
|
|
double dScale = dlg.m_dScale;
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
XString xsTmp1, xsTmp2, xsTmp3, xsTmp4;
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000424"), xsTmp1) != RTNORM) // 单蓖
|
|
return;
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000425"), xsTmp2) != RTNORM) // 双蓖
|
|
return;
|
|
//zxl 2011.09.09 add 添加雨水口类型三蓖、四蓖
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000527"), xsTmp3) != RTNORM) //三蓖
|
|
return;
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000528"), xsTmp4) != RTNORM) //四蓖
|
|
return;
|
|
|
|
if (dlg.m_iType == 0)
|
|
g_Option::instance().g_csInsBlkName = xsTmp1;
|
|
// else
|
|
// g_Option::instance().g_csInsBlkName = xsTmp2;
|
|
else if (dlg.m_iType == 1)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp2;
|
|
}
|
|
else if (dlg.m_iType == 2)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp3;
|
|
}
|
|
else
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp4;
|
|
}
|
|
|
|
double dGullyWidthOrigin(0.0);
|
|
double dGullyAngle(0.0);
|
|
XPoint ptGully, ptStart, ptEnd, ptProjRet;
|
|
|
|
for (long i = 0; i < ss.Length(); i++)
|
|
{
|
|
OPENOBJ_BEGIN(ss[i], AcDb::kForRead, CDbEquipment, pEquip);
|
|
if (pEquip)
|
|
{
|
|
double dOldWidth(0), dOldHeight(0);
|
|
double dOldScale = pEquip->GetScale(); // 图块比例
|
|
|
|
// Entity -> id -> name
|
|
AcDbObjectId idOld = pEquip->GetBlock2d();
|
|
CString csOldBlkName = GlobalFunc::GetBlkNameById(idOld);
|
|
|
|
GlobalFunc::GetBlkRecordWidth(csOldBlkName, dOldScale, dOldScale, dOldWidth, dOldHeight); // 图块尺寸
|
|
dGullyAngle = pEquip->GetAngle();
|
|
ptGully = pEquip->GetLocation();
|
|
dOldWidth = dOldWidth*GlobalFunc::DocGetPScale()/100.0;
|
|
|
|
ads_polar(ptGully, dGullyAngle + PI / 2, dOldWidth * 1.5, ptEnd);
|
|
ads_polar(ptGully, dGullyAngle - PI / 2, dOldWidth * 1.5, ptStart);
|
|
|
|
XPoint ptProjRet = GetGullyProjectPoint(ptStart, ptEnd, ptGully);
|
|
|
|
// 修改比例和雨水口样式
|
|
if (Acad::eOk == pEquip->upgradeOpen())
|
|
{
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetScale(dScale);
|
|
|
|
pEquip->downgradeOpen();
|
|
}
|
|
|
|
if (!!ptProjRet)
|
|
{
|
|
AcGeVector3d vt = AcGeVector3d::kIdentity;
|
|
vt = ptGully - ptProjRet;
|
|
vt.normalize();
|
|
|
|
double dNewScale = pEquip->GetScale();
|
|
AcDbObjectId idNew= pEquip->GetBlock2d();
|
|
CString csNewBlkName = GlobalFunc::GetBlkNameById(idNew);
|
|
|
|
double dNewGullyWidth(0.0), dNewGullyHeight(0.0);
|
|
GlobalFunc::GetBlkRecordWidth(csNewBlkName, dNewScale, dNewScale, dNewGullyWidth, dNewGullyHeight);
|
|
dNewGullyWidth = dNewGullyWidth*GlobalFunc::DocGetPScale()/100.0;
|
|
ptGully = ptProjRet + vt * dNewGullyWidth;
|
|
|
|
if (Acad::eOk == pEquip->upgradeOpen())
|
|
{
|
|
pEquip->SetInsert(ptGully);
|
|
pEquip->SetLocation(ptGully);
|
|
|
|
pEquip->downgradeOpen();
|
|
}
|
|
} // 有效点
|
|
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// 已知一个线段,在上面按等距布置井,并连管
|
|
BOOL InsGullyByCurve(AcDbCurve *pCurve, XPoint ptWell, XPoint &ptPick, double dDistEven, BOOL bMirror, double dScale)
|
|
{
|
|
|
|
double dEndParam, dStartParam, dWellParam, dPickParam;
|
|
XPointList lstPt;
|
|
lstPt.NewAppend(ptWell);
|
|
XPoint ptOnCurve;
|
|
pCurve->getClosestPointTo(ptWell, ptOnCurve);
|
|
double dDist = ads_distance(ptWell, ptOnCurve);
|
|
if(dDist > 0.001)
|
|
return FALSE;
|
|
ptWell = ptOnCurve;
|
|
pCurve->getClosestPointTo(ptPick, ptPick);
|
|
pCurve->getEndParam(dEndParam);
|
|
pCurve->getStartParam(dStartParam);
|
|
pCurve->getParamAtPoint(ptWell, dWellParam);
|
|
pCurve->getParamAtPoint(ptPick, dPickParam);
|
|
double dFromStart = fabs(dPickParam - dStartParam);
|
|
double dFromEnd = fabs(dPickParam - dEndParam);
|
|
|
|
BOOL bToStart = FALSE;
|
|
if(dPickParam > dWellParam)
|
|
bToStart = FALSE;
|
|
else if(dPickParam < dWellParam)
|
|
bToStart = TRUE;
|
|
double dDist2Well(0), dAllLength(0), dLength(0), dParamDist(0);
|
|
pCurve->getDistAtPoint(ptWell, dDist2Well);
|
|
pCurve->getDistAtParam(dPickParam, dAllLength);
|
|
if(bToStart)
|
|
dLength = dDist2Well - dAllLength;
|
|
else
|
|
dLength = dAllLength - dDist2Well;
|
|
int num = int(dLength / dDistEven);
|
|
double dTmpDist(dDist2Well);
|
|
|
|
for(int i=0;i<num;i++){
|
|
if(bToStart)
|
|
dTmpDist -= dDistEven;
|
|
else
|
|
dTmpDist += dDistEven;
|
|
XPoint ptTmp;
|
|
pCurve->getPointAtDist(dTmpDist, ptTmp);
|
|
lstPt.NewAppend(ptTmp);
|
|
ptPick = ptTmp;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// 第二步, 绘制井
|
|
int len = lstPt.Length();
|
|
if(len < 2)
|
|
return TRUE;
|
|
for(i=1;i<len;i++){
|
|
XPoint ptIns = *lstPt[i];
|
|
AcGeVector3d vtFirstDeriv;
|
|
pCurve->getFirstDeriv(ptIns, vtFirstDeriv);//该点的切向量
|
|
double nRotate = AcGeVector3d::kXAxis.angleTo(vtFirstDeriv, AcGeVector3d::kZAxis);
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetAngle(nRotate);
|
|
pEquip->MirrorByY(bMirror);
|
|
pEquip->SetScale(dScale);
|
|
pEquip->setLayer(LAY_TWT_GULLY);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
pEquip->SetInsert(ptIns);
|
|
pEquip->SetLocation(ptIns);
|
|
AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
XCurveSegment GetSegByPt2(Entity entWall,XPoint ptPickwcs,double dAngle)
|
|
{
|
|
AcDbCurve* pCurveR = NULL;
|
|
OPENOBJ_BEGIN(entWall, AcDb::kForRead, AcDbEntity, pRoad);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pRoad->explode(arCurPtrs);
|
|
|
|
AcGePoint3d ptOn;
|
|
|
|
AcDbCurve* pCurve = NULL;
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(i);
|
|
|
|
pCurve->getClosestPointTo(ptPickwcs,ptOn);
|
|
if (ptOn.distanceTo(ptPickwcs) < 1.e-2)
|
|
{
|
|
arCurPtrs.removeAt(i);
|
|
pCurveR = pCurve;
|
|
break;
|
|
}
|
|
}
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(i);
|
|
delete pCurve;
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (pCurveR != NULL)
|
|
{
|
|
AcDbLine* pLn = AcDbLine::cast(pCurveR);
|
|
if (pLn != NULL)
|
|
{
|
|
XPoint ptS(pLn->startPoint());
|
|
XPoint ptE(pLn->endPoint());
|
|
delete pLn;
|
|
return XCurveSegment(ptS,ptE,0);
|
|
}
|
|
|
|
AcDbArc* pArc = AcDbArc::cast(pCurveR);
|
|
if (pArc != NULL)
|
|
{
|
|
AcGePoint3d ptS,ptE;
|
|
pArc->getStartPoint(ptS);
|
|
pArc->getEndPoint(ptE);
|
|
double dAngle = pArc->endAngle() - pArc->startAngle();
|
|
|
|
delete pArc;
|
|
XCurveSegment cr;
|
|
cr.SetArc(XPoint(ptS),XPoint(ptE),dAngle);
|
|
return cr;
|
|
}
|
|
}
|
|
return XCurveSegment();
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 雨水口
|
|
//***************************************************************************************************
|
|
|
|
void InsGully()
|
|
{
|
|
CString csDwb = g_csDwbPath + _T("TwtSys");
|
|
// XString xsTmp1, xsTmp2;
|
|
XString xsTmp1, xsTmp2, xsTmp3, xsTmp4;
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000424"), xsTmp1) != RTNORM) //单蓖
|
|
return;
|
|
if(GlobalFunc::LoadDwbBlock(csDwb, _T("00000425"), xsTmp2) != RTNORM) //双蓖
|
|
return;
|
|
//zxl 2011.09.09 add 添加雨水口类型三蓖、四蓖
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000527"), xsTmp3) != RTNORM) //三蓖
|
|
return;
|
|
if (GlobalFunc::LoadDwbBlock(csDwb, _T("00000528"), xsTmp4) != RTNORM) //四蓖
|
|
return;
|
|
|
|
InitLayer(LAY_TWT_GULLY);
|
|
|
|
GlobalFunc::InitPipeLayer(LAY_PIPE_RAIN);
|
|
CGullyDlg dlg(acedGetAcadFrame());
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
dlg.Create(IDD_GULLY, acedGetAcadFrame());
|
|
}
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"), RTDXF0, _T("INSERT"), RTDXF0, _T("LWPOLYLINE"), RTDXF0, _T("LINE,CIRCLE"), _T("AEC_3DROAD"),RTDXF0, _T("ARC"),
|
|
-4, _T("or>"), NULL);
|
|
RBList rbMaskWell(RTDXF0, _T("AEC_ZT_WELL"), 8, LAY_WELL_RAIN, NULL);
|
|
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
while(1)
|
|
{
|
|
dlg.UpdateData(TRUE);
|
|
if(dlg.m_iType == 0)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp1;
|
|
}
|
|
// zxl 2011.09.06 modify 添加雨水口类型三蓖、四蓖的判断
|
|
// else
|
|
// g_Option::instance().g_csInsBlkName = xsTmp2;
|
|
else if (dlg.m_iType == 1)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp2;
|
|
}
|
|
else if (dlg.m_iType == 2)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp3;
|
|
}
|
|
else if(dlg.m_iType == 3)
|
|
{
|
|
g_Option::instance().g_csInsBlkName = xsTmp4;
|
|
}
|
|
|
|
double dScale = dlg.m_dScale;
|
|
|
|
if(dlg.m_iMode == 0){ //任意布置
|
|
XPoint ptIns;
|
|
xg_getvar(_T("VIEWCTR"), ptIns);
|
|
ptIns = GlobalFunc::Ucs2Wcs(ptIns);
|
|
|
|
TBlockEdJig jig(g_Option::instance().g_csInsBlkName, ptIns, 1);
|
|
int nOsMode=0;
|
|
nOsMode |= OS_INT|OS_NEA|OS_MID;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
jig.m_nSacle = dScale*(GlobalFunc::DocGetPScale()/100);
|
|
jig.m_nSacleY = dScale*(GlobalFunc::DocGetPScale()/100);
|
|
jig.SetPrompt(_T("\n请点取雨水口插入点<退出>:"));
|
|
int nKeyIndex = 0;
|
|
int ret = jig.DoIt(&nKeyIndex);
|
|
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
ptIns = jig.GetPickPoint();
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetAngle(GlobalFunc::Ucs2Wcs(g_Option::instance().g_nInsBlkRotate));
|
|
pEquip->SetScale(dScale);
|
|
pEquip->setLayer(LAY_TWT_GULLY);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
pEquip->SetInsert(ptIns);
|
|
pEquip->SetLocation(ptIns);
|
|
AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
Entity entLast;
|
|
entLast.GetLast();
|
|
double nRotate(0);
|
|
entLast.Rotate(ptIns, &nRotate);
|
|
|
|
}
|
|
else if(dlg.m_iMode == 1){ //替换
|
|
ReplaceGully(dlg);
|
|
// zxl 2011.9.16 modify 解决由替换变为自由布置时命令退出问题
|
|
// dlg.DestroyWindow();
|
|
// return;
|
|
if (dlg.m_iMode == 1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else if(dlg.m_iMode == 4 || dlg.m_iMode == 5){//沿线布置
|
|
XPoint ptPick,ptPicTemp;
|
|
Entity entWall;
|
|
int ret = GlobalFunc::SelectEntity1(0.3, _T("\n请拾取布置雨水口的外部参照、直线、弧线 <退出>"), entWall, ptPick, rbMask);
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
dlg.UpdateData(TRUE);
|
|
dScale = dlg.m_dScale;
|
|
|
|
ptPick = GlobalFunc::Ucs2Wcs(ptPick);
|
|
ptPicTemp = ptPick;
|
|
XCurveSegment seg;
|
|
if(entWall.Is(_T("INSERT")) && GlobalFunc::IsExternalBlock(entWall)){
|
|
seg = GlobalFunc::GetExternalBlockSeg(entWall, ptPick);// seg = GetBlkPickSeg(entWall, ptPick);
|
|
if(!seg)
|
|
break;
|
|
}
|
|
else if(entWall.Is(_T("LWPOLYLINE")))
|
|
{
|
|
double dAngle = 0.0;
|
|
seg = GlobalFunc::GetSegByPt(XPoly2D(entWall), ptPick, dAngle);
|
|
}
|
|
else if (entWall.Is(_T("AEC_3DROAD")))
|
|
{
|
|
double dAngle = 0.0;
|
|
seg = GetSegByPt2(entWall,ptPick,dAngle);
|
|
}
|
|
else
|
|
{
|
|
seg = XCurveSegment(entWall);
|
|
}
|
|
seg.ProjectToMe(ptPick, ptPick);
|
|
XPoint ptOnCurve = ptPick;
|
|
g_Option::instance().g_nInsBlkRotate = GlobalFunc::GetInsRotate(ptPick, seg);
|
|
AcGeVector3d vect;
|
|
vect.x = cos(g_Option::instance().g_nInsBlkRotate);
|
|
vect.y = sin(g_Option::instance().g_nInsBlkRotate);
|
|
vect.z = 0;
|
|
BOOL bMirror = FALSE;
|
|
|
|
BOOL bCancel = FALSE;
|
|
CString csPrompt;
|
|
double nWidth(0), nHeight(0);
|
|
GlobalFunc::GetBlkRecordWidth(g_Option::instance().g_csInsBlkName, dScale, dScale, nWidth, nHeight);
|
|
|
|
while(1){
|
|
TBlockEdJig jig(g_Option::instance().g_csInsBlkName, ptPick, 1, vect, nWidth*GlobalFunc::DocGetPScale()/100.0);
|
|
jig.m_nSacle = dScale*(GlobalFunc::DocGetPScale()/100);;
|
|
jig.m_nSacleY = dScale*(GlobalFunc::DocGetPScale()/100);;
|
|
|
|
jig.SetPrompt(_T("\n请点取雨水口插入方向<完成>:"));
|
|
int nKeyIndex = 0;
|
|
int nRetCode = jig.DoIt(&nKeyIndex);
|
|
if(nRetCode == RTNORM){
|
|
if(jig.m_iQuadrant == 2 || jig.m_iQuadrant == 3){
|
|
g_Option::instance().g_nInsBlkRotate += PI;
|
|
}
|
|
if(jig.m_iQuadrant == 1 || jig.m_iQuadrant == 3){
|
|
bMirror = TRUE;
|
|
}
|
|
ptPick = jig.m_ptRetIns;
|
|
break;
|
|
}
|
|
else{
|
|
bCancel = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
if(bCancel){
|
|
continue;
|
|
}
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetAngle(g_Option::instance().g_nInsBlkRotate);
|
|
pEquip->MirrorByY(bMirror);
|
|
pEquip->SetScale(dScale);
|
|
pEquip->setLayer(LAY_TWT_GULLY);
|
|
pEquip->setColor(AcCmColor());
|
|
pEquip->SetInsert(ptPick);
|
|
pEquip->SetLocation(ptPick);
|
|
AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
if(dlg.m_iMode == 5){//沿线定距
|
|
//RBList rbMask3(RTDXF0, _T("LWPOLYLINE,LINE,ARC"), NULL);
|
|
double dOffsetDist = nWidth*GlobalFunc::DocGetPScale()/100.0;
|
|
Entity ent3,ent4;
|
|
XPoint ptPick3,ptPick4, ptLastGully;
|
|
|
|
ptPick3 = ptPicTemp;
|
|
ptLastGully = ptPick;
|
|
ent3 = entWall;
|
|
RBList rbMaskLine(RTDXF0, _T("LWPOLYLINE,LINE,ARC"), NULL);
|
|
while(GlobalFunc::SelectEntity1(0.3, _T("\n请拾取下一段直线、弧线 <退出>"), ent4, ptPick4, rbMaskLine) == RTNORM){
|
|
AcDbPolyline *pLine = GlobalFunc::GetNextPloyLine(ent3, ent4, ptPick3, ptPick4);
|
|
if(pLine != NULL){
|
|
AcDbCurve *pCurve2 = GlobalFunc::GetOffsetCurve((AcDbCurve *)pLine, dOffsetDist, ptLastGully);
|
|
if(pCurve2 != NULL){
|
|
double dDistWell = dlg.m_dDist;
|
|
if(!GlobalFunc::DocGetMeterUnitDraw())
|
|
dDistWell = dDistWell*1000;
|
|
|
|
if(!InsGullyByCurve(pCurve2, ptLastGully, ptPick4, dDistWell, bMirror, dScale)){
|
|
delete pCurve2;
|
|
delete pLine;
|
|
//g_Option::instance().adsout << _T("请正确点取需要参考的沿线(本段或下一段)\n");
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptLastGully = ptPick4;
|
|
pLine->getClosestPointTo(ptPick4, ptPick4);
|
|
delete pCurve2;
|
|
}
|
|
delete pLine;
|
|
}
|
|
else{
|
|
g_Option::instance().adsout << _T("请正确点取需要参考的沿线(本段或下一段)\n");
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
ptPick3 = ptPick4;
|
|
ent3 = ent4;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if(dlg.m_iMode == 2)
|
|
{//井垂直连道路
|
|
|
|
int ret(0);
|
|
Entity entWell, entWall;
|
|
PickSet ssWell(SS_FREE);
|
|
ret = GlobalFunc::SelectEntities(_T("\n请选择雨水井:<退出>"), ssWell, rbMaskWell);
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
|
|
XPoint ptPick;
|
|
|
|
ret = GlobalFunc::SelectEntity1(0.3, _T("\n请拾取布置雨水口的外部参照、直线、弧线 <退出>"), entWall, ptPick, rbMask);
|
|
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
dlg.UpdateData(TRUE);
|
|
dScale = dlg.m_dScale;
|
|
|
|
ptPick = GlobalFunc::Ucs2Wcs(ptPick);
|
|
XCurveSegment seg;
|
|
if(entWall.Is(_T("INSERT")) && GlobalFunc::IsExternalBlock(entWall)){
|
|
seg = GlobalFunc::GetExternalBlockSeg(entWall, ptPick);
|
|
seg.ProjectToMe(ptPick, ptPick);
|
|
if(!seg)
|
|
break;
|
|
}
|
|
else if(entWall.Is(_T("LWPOLYLINE"))){
|
|
// cet 2011.5.25 del 参考线时PLINE时,需分别以井的插入点向整个PLINE做投影,非向ptPick所在部分线段做投影
|
|
// double dAngle;
|
|
// seg = GlobalFunc::GetSegByPt(XPoly2D(entWall), ptPick, dAngle);
|
|
}
|
|
else if (entWall.Is(_T("AEC_3DROAD")))
|
|
{
|
|
double dAngle = 0.0;
|
|
seg = GetSegByPt2(entWall,ptPick,dAngle);
|
|
}
|
|
else
|
|
seg = XCurveSegment(entWall);
|
|
double nWidth(0), nHeight(0);
|
|
GlobalFunc::GetBlkRecordWidth(g_Option::instance().g_csInsBlkName, 1, 1, nWidth, nHeight);
|
|
long lenWell = ssWell.Length();
|
|
for(long m =0;m<lenWell;m++)
|
|
{
|
|
entWell = ssWell[m];
|
|
XPoint ptWellLoc;
|
|
OPENOBJ_BEGIN(entWell, AcDb::kForRead, AecXDbWell, pEquip);
|
|
if(pEquip){
|
|
ptWellLoc = pEquip->GetLocation();
|
|
}
|
|
OPENOBJ_END();
|
|
XPoint ptClosest;
|
|
//1 首先得到井中心到线段的垂线点
|
|
// seg.ProjectToMe(ptWellLoc, ptClosest); cet 2011.5.25 modify
|
|
// if((ptClosest&seg) == PR_EXTEND)
|
|
// continue;
|
|
if(entWall.Is(_T("LWPOLYLINE")))
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id, entWall);
|
|
AcDbPolyline *pLine = NULL;
|
|
AcGeVector3d vt;
|
|
acdbOpenObject(pLine, id, AcDb::kForRead);
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->getClosestPointTo(ptWellLoc, ptClosest);
|
|
pLine->getFirstDeriv(ptClosest, vt); // 点在线上的切线
|
|
pLine->close();
|
|
}
|
|
|
|
AcGeVector3d vt2 = ptClosest - ptWellLoc;
|
|
if (!vt.isPerpendicularTo(vt2)) // 非垂直投影时,不处理
|
|
{
|
|
continue;
|
|
}
|
|
|
|
g_Option::instance().g_nInsBlkRotate = (AcGeVector3d::kXAxis).angleTo(vt, AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
{
|
|
seg.ProjectToMe(ptWellLoc, ptClosest);
|
|
if((ptClosest&seg) == PR_EXTEND)
|
|
continue;
|
|
}
|
|
|
|
ptPick = ptClosest;
|
|
|
|
//g_Option::instance().g_nInsBlkRotate = GlobalFunc::GetInsRotate(ptPick, seg); cet 2011.5.25 modify
|
|
if (!entWall.Is(_T("LWPOLYLINE")))
|
|
{
|
|
g_Option::instance().g_nInsBlkRotate = GlobalFunc::GetInsRotate(ptPick, seg);
|
|
}
|
|
|
|
//2 得到垂点到井的向量
|
|
AcGeVector3d vt = ptWellLoc - ptClosest;
|
|
vt.z = 0.0; // cet 2011.10.12 add 不考虑z轴
|
|
vt.normalize();
|
|
double dScale2 = dScale*(GlobalFunc::DocGetPScale()/100.0);
|
|
//3 根据这个向量计算雨水口需要偏移的距离
|
|
|
|
//ptPick += vt*nWidth*dScale2; //根据用户输入,控制雨水口位置 zxl 2011.09.09 modify
|
|
int iPos = dlg.GetGullyPos();
|
|
if (1 == iPos)
|
|
{
|
|
ptPick += vt*nWidth*dScale2;
|
|
}
|
|
else if (2 == iPos)
|
|
{
|
|
ptPick -=vt*nWidth*dScale2;
|
|
}
|
|
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetAngle(g_Option::instance().g_nInsBlkRotate);
|
|
pEquip->SetScale(dScale);
|
|
pEquip->setLayer(LAY_TWT_GULLY);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
pEquip->SetInsert(ptPick);
|
|
pEquip->SetLocation(ptPick);
|
|
AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
|
|
CDbPipe *pNewPipe = new CDbPipe;
|
|
pNewPipe->SetStartPoint(ptPick);
|
|
pNewPipe->SetEndPoint(ptWellLoc);
|
|
pNewPipe->SetPipeWeight(g_Option::instance().g_nPipeWidth[5]);
|
|
pNewPipe->SetSysType(TPipeSys::kRainWater);
|
|
pNewPipe->SetModelType(TPipeSys::kModel);
|
|
pNewPipe->SetMaterial(12);//钢筋混凝土
|
|
|
|
// zxl 2013.05.29 modify
|
|
// pNewPipe->SetDnDiameter(200);
|
|
if(dlg.m_iType == 0)
|
|
{
|
|
pNewPipe->SetDnDiameter(200);
|
|
}
|
|
else
|
|
{
|
|
pNewPipe->SetDnDiameter(300);
|
|
}
|
|
pNewPipe->SetPipeGradient(0.01);
|
|
pNewPipe->setLayer(LAY_PIPE_RAIN);
|
|
pNewPipe->setLinetype(GlobalFunc::GetPipeWireLayLineType(LAY_PIPE_RAIN));
|
|
pNewPipe->setColor(AcCmColor());
|
|
GlobalFunc::AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
|
|
|
}
|
|
}
|
|
else if(dlg.m_iMode == 3)
|
|
{//井斜连线
|
|
int ret(0);
|
|
Entity entWell, entWall;
|
|
ret = GlobalFunc::SelectEntity(_T("\n请选择雨水井:<退出>"), entWell, rbMaskWell);
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
|
|
XPoint ptPick;
|
|
|
|
ret = GlobalFunc::SelectEntity1(0.3, _T("\n请拾取布置雨水口的外部参照、直线、弧线 <退出>"), entWall, ptPick, rbMask);
|
|
|
|
if(ret == RTCAN && dlg.m_bCancel){
|
|
dlg.m_bCancel = FALSE;
|
|
continue;
|
|
}
|
|
else if(ret != RTNORM)
|
|
break;
|
|
dlg.UpdateData(TRUE);
|
|
dScale = dlg.m_dScale;
|
|
|
|
ptPick = GlobalFunc::Ucs2Wcs(ptPick);
|
|
XCurveSegment seg;
|
|
if(entWall.Is(_T("INSERT")) && GlobalFunc::IsExternalBlock(entWall)){
|
|
seg = GlobalFunc::GetExternalBlockSeg(entWall, ptPick);
|
|
seg.ProjectToMe(ptPick, ptPick);
|
|
if(!seg)
|
|
break;
|
|
}
|
|
else if(entWall.Is(_T("LWPOLYLINE"))){
|
|
double dAngle;
|
|
seg = GlobalFunc::GetSegByPt(XPoly2D(entWall), ptPick, dAngle);
|
|
}
|
|
else if (entWall.Is(_T("AEC_3DROAD")))
|
|
{
|
|
double dAngle = 0.0;
|
|
seg = GetSegByPt2(entWall,ptPick,dAngle);
|
|
}
|
|
else
|
|
seg = XCurveSegment(entWall);
|
|
double nWidth(0), nHeight(0);
|
|
GlobalFunc::GetBlkRecordWidth(g_Option::instance().g_csInsBlkName, 1, 1, nWidth, nHeight);
|
|
|
|
XPoint ptWellLoc;
|
|
OPENOBJ_BEGIN(entWell, AcDb::kForRead, AecXDbWell, pEquip);
|
|
if(pEquip){
|
|
ptWellLoc = pEquip->GetLocation();
|
|
}
|
|
OPENOBJ_END();
|
|
XPoint ptClosest;
|
|
//1 首先得到井中心到线段的垂线点
|
|
seg.ProjectToMe(ptWellLoc, ptClosest);
|
|
// if(dlg.m_iMode == 2){//垂直连井
|
|
// ptPick = ptClosest;
|
|
// }
|
|
g_Option::instance().g_nInsBlkRotate = GlobalFunc::GetInsRotate(ptPick, seg);
|
|
//2 得到垂点到井的向量
|
|
AcGeVector3d vt = ptWellLoc - ptClosest;
|
|
vt.z = 0.0; // cet 2011.10.12 add 不考虑z轴
|
|
vt.normalize();
|
|
double dScale2 = dScale*(GlobalFunc::DocGetPScale()/100.0);
|
|
//3 根据这个向量计算雨水口需要偏移的距离
|
|
|
|
// ptPick += vt*nWidth*dScale2; //根据用户输入,控制雨水口位置 zxl 2011.09.09 modify
|
|
int iPos = dlg.GetGullyPos();
|
|
if (1 == iPos)
|
|
{
|
|
ptPick += vt*nWidth*dScale2;
|
|
}
|
|
else if (2 == iPos)
|
|
{
|
|
ptPick -=vt*nWidth*dScale2;
|
|
}
|
|
|
|
CDbEquipment *pEquip = new CDbEquipment;
|
|
pEquip->SetBlock2d(GlobalFunc::GetBlockIdFromString(g_Option::instance().g_csInsBlkName));
|
|
pEquip->SetHidePipe(TRUE);
|
|
pEquip->SetAngle(g_Option::instance().g_nInsBlkRotate);
|
|
pEquip->SetScale(dScale);
|
|
pEquip->setLayer(LAY_TWT_GULLY);
|
|
pEquip->setColor(AcCmColor()); //随层
|
|
pEquip->SetInsert(ptPick);
|
|
pEquip->SetLocation(ptPick);
|
|
AcDbObjectId id = GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue);
|
|
|
|
CDbPipe *pNewPipe = new CDbPipe;
|
|
pNewPipe->SetStartPoint(ptPick);
|
|
pNewPipe->SetEndPoint(ptWellLoc);
|
|
pNewPipe->SetPipeWeight(g_Option::instance().g_nPipeWidth[5]);
|
|
pNewPipe->SetSysType(TPipeSys::kRainWater);
|
|
pNewPipe->SetModelType(TPipeSys::kModel);
|
|
pNewPipe->SetMaterial(12);//钢筋混凝土
|
|
// zxl 2013.05.29 modify
|
|
// pNewPipe->SetDnDiameter(200);
|
|
if(dlg.m_iType == 0)
|
|
{
|
|
pNewPipe->SetDnDiameter(200);
|
|
}
|
|
else
|
|
{
|
|
pNewPipe->SetDnDiameter(300);
|
|
}
|
|
pNewPipe->SetPipeGradient(0.01);
|
|
pNewPipe->setLayer(LAY_PIPE_RAIN);
|
|
pNewPipe->setLinetype(GlobalFunc::GetPipeWireLayLineType(LAY_PIPE_RAIN));
|
|
pNewPipe->setColor(AcCmColor());
|
|
GlobalFunc::AddToCurrentSpace(pNewPipe, Adesk::kTrue);
|
|
}
|
|
|
|
}
|
|
g_Option::instance().g_nInsBlkRotate = 0;
|
|
dlg.DestroyWindow();
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGullyDlg dialog
|
|
|
|
IMPLEMENT_DYNAMIC(CGullyDlg, CModelessDialog)
|
|
int CGullyDlg::m_iType = 0;
|
|
int CGullyDlg::m_iMode = 0;
|
|
double CGullyDlg::m_dDist = 20;
|
|
CString CGullyDlg::m_sGullyPos = _T("边线靠近接入井一侧"); //zxl 2011.09.09 add
|
|
CGullyDlg::CGullyDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CGullyDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CGullyDlg)
|
|
m_dScale = 1;
|
|
//}}AFX_DATA_INIT
|
|
m_bCancel = FALSE;
|
|
m_pMenuPos = NULL;
|
|
}
|
|
|
|
|
|
void CGullyDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CGullyDlg)
|
|
DDX_Control(pDX, IDC_BUTTON_GULLYPOS, m_wndBtnGullyPos);
|
|
DDX_Text(pDX, IDC_EDIT_LEN, m_dScale);
|
|
DDX_Radio(pDX, IDC_RADIO_GULLYTYPE1, m_iType);
|
|
DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode);
|
|
DDX_Text(pDX, IDC_EDIT_DIST, m_dDist);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CGullyDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CGullyDlg)
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode1)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode2)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE3, OnRadioMode3)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE4, OnRadioMode4)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE5, OnRadioMode5)
|
|
ON_BN_CLICKED(IDC_RADIO_MODE6, OnRadioMode6)
|
|
ON_BN_CLICKED(IDC_RADIO_GULLYTYPE1, OnRadioType1)
|
|
ON_BN_CLICKED(IDC_RADIO_GULLYTYPE2, OnRadioType2)
|
|
// zxl 2011.09.09 add
|
|
ON_BN_CLICKED(IDC_RADIO_GULLYTYPE3, OnRadioType3)
|
|
ON_BN_CLICKED(IDC_RADIO_GULLYTYPE4, OnRadioType4)
|
|
ON_BN_CLICKED(IDC_BUTTON_GULLYPOS, OnButtonGullyPos)
|
|
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGullyDlg message handlers
|
|
|
|
BOOL CGullyDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
// CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
|
// regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
//regProp.GetValue(_T("GullyScale"), m_dScale);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
if(m_iMode == 5)
|
|
pWnd->EnableWindow(TRUE);
|
|
else
|
|
pWnd->EnableWindow(FALSE);
|
|
|
|
//雨水口位置设置 zxl 2011.09.09 add
|
|
if (m_iMode == 2 || m_iMode == 3)
|
|
{
|
|
m_wndBtnGullyPos.EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
m_wndBtnGullyPos.EnableWindow(FALSE);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CGullyDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode1()
|
|
{
|
|
UpdateData(TRUE);
|
|
// if(m_iMode == 2){
|
|
// acedPostCommand(_T("\33\33"));
|
|
// PostCommand(_T(" "), false);
|
|
// }
|
|
// else
|
|
// PostCommand(_T("S\n"), false);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(FALSE);
|
|
m_bCancel = TRUE;
|
|
m_wndBtnGullyPos.EnableWindow(FALSE);//雨水口位置不可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode2()
|
|
{
|
|
//替换命令执行前判断其状态 zxl 2011.09.16 add
|
|
if (m_iMode == 1)
|
|
{
|
|
return;
|
|
}
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(FALSE);
|
|
m_bCancel = TRUE;
|
|
m_wndBtnGullyPos.EnableWindow(FALSE);//雨水口位置不可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode3()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(FALSE);
|
|
m_bCancel = TRUE;
|
|
m_wndBtnGullyPos.EnableWindow(TRUE);//雨水口位置可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode4()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(FALSE);
|
|
m_bCancel = TRUE;
|
|
m_wndBtnGullyPos.EnableWindow(TRUE);//雨水口位置可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode5()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(FALSE);
|
|
m_bCancel = TRUE;
|
|
m_wndBtnGullyPos.EnableWindow(FALSE);//雨水口位置不可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
void CGullyDlg::OnRadioMode6()
|
|
{
|
|
UpdateData(TRUE);
|
|
m_bCancel = TRUE;
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DIST);
|
|
pWnd->EnableWindow(TRUE);
|
|
m_wndBtnGullyPos.EnableWindow(FALSE);//雨水口位置不可设置 ZXL 2011.09.09 add
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
void CGullyDlg::OnRadioType1()
|
|
{
|
|
m_bCancel = TRUE;
|
|
// 替换雨水口时选择类型不发送 zxl 2011.09.16 modify
|
|
// acedPostCommand(_T("\33"));
|
|
if (m_iMode != 1)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
|
|
}
|
|
|
|
void CGullyDlg::OnRadioType2()
|
|
{
|
|
m_bCancel = TRUE;
|
|
// 替换雨水口时选择类型不发送 zxl 2011.09.16 modify
|
|
// acedPostCommand(_T("\33"));
|
|
if (m_iMode != 1)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
}
|
|
|
|
void CGullyDlg::OnRadioType3()
|
|
{
|
|
m_bCancel = TRUE;
|
|
// 替换雨水口时选择类型不发送 zxl 2011.09.16 modify
|
|
// acedPostCommand(_T("\33"));
|
|
if (m_iMode != 1)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
}
|
|
|
|
void CGullyDlg::OnRadioType4()
|
|
{
|
|
m_bCancel = TRUE;
|
|
// 替换雨水口时选择类型不发送 zxl 2011.09.16 modify
|
|
// acedPostCommand(_T("\33"));
|
|
if (m_iMode != 1)
|
|
{
|
|
acedPostCommand(_T("\33"));
|
|
}
|
|
}
|
|
|
|
void CGullyDlg::PostNcDestroy()
|
|
{
|
|
// CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
|
// regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
//regProp.SetValue(_T("GullyScale"), m_dScale);
|
|
CModelessDialog::PostNcDestroy();
|
|
}
|
|
|
|
const UINT MenuID = 9500;
|
|
void CGullyDlg::OnButtonGullyPos()
|
|
{
|
|
CWnd *pWnd = NULL;
|
|
pWnd = GetDlgItem(IDC_BUTTON_GULLYPOS);
|
|
|
|
if (pWnd == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CRect rc;
|
|
pWnd->GetWindowRect(rc);
|
|
|
|
if(m_pMenuPos != NULL)
|
|
{
|
|
m_pMenuPos->DestroyMenu();
|
|
m_pMenuPos->CreatePopupMenu();
|
|
}
|
|
else
|
|
{
|
|
m_pMenuPos = new CMenu;
|
|
m_pMenuPos->CreatePopupMenu();
|
|
}
|
|
|
|
m_pMenuPos->AppendMenu(m_sGullyPos.CompareNoCase(_T("边线靠近接入井一侧")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 1, _T("边线靠近接入井一侧"));
|
|
m_pMenuPos->AppendMenu(m_sGullyPos.CompareNoCase(_T("边线远离接入井一侧")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 2, _T("边线远离接入井一侧"));
|
|
m_pMenuPos->AppendMenu(m_sGullyPos.CompareNoCase(_T("中心位于边线上")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 3, _T("中心位于边线上"));
|
|
m_pMenuPos->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL, rc.left, rc.bottom, this, &rc);
|
|
}
|
|
|
|
BOOL CGullyDlg::OnCommand(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
if (m_pMenuPos != NULL)
|
|
{
|
|
CString strCmd;
|
|
m_pMenuPos->GetMenuString(wParam, strCmd, MF_BYCOMMAND);
|
|
|
|
if (!strCmd.IsEmpty())
|
|
{
|
|
m_sGullyPos = strCmd;
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
return CModelessDialog::OnCommand(wParam, lParam);
|
|
}
|
|
|
|
int CGullyDlg::GetGullyPos()
|
|
{
|
|
int i = 0;
|
|
if (m_sGullyPos.CompareNoCase(_T("边线靠近接入井一侧")) == 0)
|
|
{
|
|
i = 1;
|
|
}
|
|
else if (m_sGullyPos.CompareNoCase(_T("边线远离接入井一侧")) == 0)
|
|
{
|
|
i = 2;
|
|
}
|
|
return i;
|
|
}
|