// SprinklerByRectDlg.cpp : implementation file // #include "stdafx.h" #include "xrect.h" #include "DbEquipment.h" //#include #include "dbPipe.h" #include "tregproperty.h" #include "layerdef.h" #include "SprinklerByRectDlg.h" #include "SprinklerByLineDlg.h" #include "SnapSprinkerJig.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern BOOL GetRectInsPt(XPoint ptS, XPoint ptE, double nAngle, int row_num, int col_num, XPointList &lstInsPt, double nShortDist, double nDist2Wall); extern BOOL GetDiamondInsPt(XPoint ptS, XPoint ptE, double nAngle, int row_num, int col_num, XPointList &lstInsPt, BOOL bIsColPipe); extern void GetPtPointList(XLine &line, int iNum, XPointList &lstPt, BOOL bIsReverse); extern void GetPointListSprinkler(XCurveSegment seg, int iNum, XPointList &lstPt, double nShortDist, double nDist2Wall); extern BOOL GetRectInsPt(XPoint ptS, XPoint ptE, double nAngle, int row_num, int col_num, XPointList &lstInsPt, double nShortDist, double nDist2Wall, XPointList &lstPtRow, XPointList &lstPtCol); extern void ModifyRect(XRect &rect); extern AcDbObjectId InitLayer(const TCHAR *szLayer, AcDbDatabase *pDb = NULL); BOOL GetSegPtByDiamondRow(XPoint ptS, XPoint ptE, double nAngle, int row_num, int col_num, XPointList &lstInsPt, int iRow) { lstInsPt.Reset(); XRect rect(ptS, ptE, nAngle); ModifyRect(rect);// 矩形构造不正确,重新构造 zxl 2014.01.08 add XCurveSegment seg; XLine line(rect.upLeft, rect.lowLeft, 1); seg = line; XPointList lstPt; GlobalFunc::GetPointList(seg, row_num, lstPt); if(lstPt.Length() != row_num) return FALSE; for(int i=0;i vOsMode(_T("OSMODE"), nOsMode); XPushVar vOrthoMode(_T("ORTHOMODE"), 0); //f8 CSprinklerByRectDlg dlg(acedGetAcadFrame()); { CTemporaryResourceOverride vTemp; dlg.Create(IDD_SPRINKLER_RECT, acedGetAcadFrame()); dlg.ShowWindow(SW_SHOW); acedGetAcadDwgView()->SetFocus(); } CString m_csSysBlk1 = _T("TWTSYS(00000283)"); CString m_csSysBlk2 = _T("TWTSYS(00000530)");//水喷雾 系统 zxl 2011.12.19 add while(1){ XPointList lstPt; XPoint ptStart, ptEnd; int nOsMode; xg_getvar(_T("OSMODE"), &nOsMode); nOsMode &= ~0x4000; nOsMode |= OS_INT|OS_NEA|OS_END; XPushVar vOsMode(_T("OSMODE"), nOsMode); //提示用户输入起始点 int iRet; //XString sKeyword; cet 2011.12.21 modify int nKeyWordIndex = -1; INITGET_BEG(0, _T("S")); //cet 2011.12.21 modify 支持捕捉墙隐藏的端点 //iRet = ads_getpoint(NULL,_T("\n请输入起始点[选取行向线(S)]<退出>:"), ptStart); iRet = GetSnapPoint(NULL, _T("\n请输入起始点[选取行向线(S)]<退出>:"), ptStart, 0, GlobalFunc::Ucs2Wcs(0.0), _T("S"), &nKeyWordIndex); //ptStart = GlobalFunc::Ucs2Wcs(ptStart); cet 2012.3.6 del INITGET_END(); if(iRet == RTNONE || iRet == RTCAN) break; //提示用户从当前屏幕选择行向线 if(iRet == RTKWORD){ double s_angle(0); s_angle = GlobalFunc::Ucs2Wcs(s_angle); // cet 2012.3.6 add int err_value=GlobalFunc::get_line_angle(s_angle); // ads_getinput(sKeyword); // cet 2011.12.21 modify // TCHAR cKey = sKeyword[0]; // if(cKey==_T('S')){ if (nKeyWordIndex == 1) { if(err_value == RTNORM){ s_angle = GlobalFunc::Wcs2Ucs(s_angle); // cet 2012.3.6 add s_angle = s_angle*180/PI; dlg.m_nAngle = s_angle; dlg.UpdateData(FALSE); } else if(err_value == RTERROR) break; } //提示用户输入起始点 // if(ads_getpoint(NULL,_T("\n请输入起始点:"),ptStart) != RTNORM) // cet 2011.12.21 modify // break; if (GetSnapPoint(NULL, _T("\n请输入起始点:"), ptStart) != RTNORM) { break; } //ptStart = GlobalFunc::Ucs2Wcs(ptStart); cet 2012.3.6 del } ptStart.z = 0; // TSprinklerJig jig(&dlg, ptStart); // cet 2011.12.21 modify 支持捕捉墙端点 TSnapSprinkerJig jig(&dlg, ptStart); jig.SetPrompt(_T("\n请输入终点<退出>:")); int nKeyIdx; if(jig.DoIt(&nKeyIdx) != RTNORM){ dlg.DestroyWindow(); return; } ptEnd = jig.GetPickPoint(); ptEnd.z = 0; XRect rect(ptStart, ptEnd, dlg.m_nAngle + GlobalFunc::Radian2Angle(GlobalFunc::Ucs2Wcs(0.0))); ModifyRect(rect);// 矩形构造不正确,重新构造 zxl 2014.01.08 add double nShortDist = 0; int iRow(0), iCol(0); double nDist2Wall = dlg.m_nDist2Wall - 0; //sr 2009-3-12 把-20 改为 -0 ,不记得当初为什么-20 if(dlg.m_iType == 0) { iRow = dlg.m_iRow; iCol = dlg.m_iCol; } else{ int iColDist = dlg.m_iCol; int iRowDist = dlg.m_iRow; XLine line1(rect.lowLeft, rect.lowRight); XCurveSegment seg1; seg1 = line1; iCol = GetCurvePartNum(seg1, iColDist, nDist2Wall); XLine line2(rect.upLeft, rect.lowLeft); XCurveSegment seg2; seg2 = line2; iRow = GetCurvePartNum(seg2, iRowDist, nDist2Wall); nShortDist = dlg.m_dMinDist / 2; // iCol = (int)(rect.nWidth / dlg.m_iCol); // iRow = (int)(rect.nHeight / dlg.m_iRow); // if(rect.nWidth / dlg.m_iCol - iCol > 0) // iCol ++; // if(rect.nHeight / dlg.m_iRow - iRow > 0) // iRow ++; // double nDist1(0), nDist2(0); // //计算间距 // if(dlg.m_iMode == 0){ //矩形 // nDist1 = rect.nWidth / iCol; // nDist2 = rect.nHeight / iRow; // } // else{ //菱形 // if(dlg.m_iConPipe == 0){ //行接管 // nDist1 = rect.nWidth / (iCol - 0.5); // nDist2 = rect.nHeight / iRow; // } // else if(dlg.m_iConPipe == 1){//列接管 // nDist1 = rect.nWidth / iCol; // nDist2 = rect.nHeight / (iRow - 0.5); // } // } // //如果小于2.4米,调整行列数,首先满足规范最小间距 // if(nDist1 < 2400){ // if(rect.nWidth - (iCol-1)*2400 < 1200) // iCol --; // } // if(nDist2 < 2400){ // if(rect.nHeight - (iRow-1)*2400 < 1200) // iRow --; // } } if(dlg.m_iMode == 0) { // cet 2012.12.19 modify 按行列间距布置时,考虑距墙最小间距 // GetRectInsPt(ptStart, ptEnd, dlg.m_nAngle + GlobalFunc::Radian2Angle(GlobalFunc::Ucs2Wcs(0.0)), iRow, iCol, lstPt, nShortDist, nDist2Wall); XPointList lstPt1, lstPt2; GetRectInsPt(ptStart, ptEnd, dlg.m_nAngle + GlobalFunc::Radian2Angle(GlobalFunc::Ucs2Wcs(0.0)), iRow, iCol, lstPt, nShortDist, nDist2Wall, lstPt1, lstPt2); // if (dlg.m_iType == 1) cet 2013.4.15 modify 是否考虑最小距墙间距 if (dlg.m_bMinDistToWall && dlg.m_iType == 1) { int nLen = lstPt2.Length(); int nLen2 = lstPt1.Length(); if (nLen >= 3 && nLen2 >= 3) // cet 2013.4.15 modify 考虑行列距墙距离 { double dDist1 = lstPt2[0]->Distance2d(*lstPt2[1]); double dDist2 = lstPt2[nLen - 1]->Distance2d(*lstPt2[nLen - 2]); // cet 2013.4.15 add 考虑列距墙距离 double dDist3 = lstPt1[0]->Distance2d(*lstPt1[1]); double dDist4 = lstPt1[nLen2 - 1]->Distance2d(*lstPt1[nLen2 - 2]); double dDist = dlg.m_dMinDistToWall; double dTol = 0.001; // 误差 if (GlobalFunc::DocGetCurMeterUnitDraw()) { dDist *= 0.001; } // 小于最小距墙间距 cet 2013.4.15 modify 考虑列距墙距离 if (dDist1 + dTol < dDist || dDist2 + dTol < dDist || dDist3 + dTol < dDist || dDist4 + dTol < dDist) { acutPrintf(_T("\n不满足距墙最小间距要求,无法绘制!")); continue; } } } } else GetDiamondInsPt(ptStart, ptEnd, dlg.m_nAngle + GlobalFunc::Radian2Angle(GlobalFunc::Ucs2Wcs(0.0)), iRow, iCol, lstPt, dlg.m_iConPipe); XPushVar vOsMode2(_T("OSMODE"), 0); int len = lstPt.Length(); //zxl 2011.08.15 modify 初始化管线图层 //InitPipeLayer(LAY_PIPE_SPRINKLE); GlobalFunc::InitPipeLayer(dlg.m_sLayer); InitLayer(LAY_EQUIP_SPRINKLE); for(int i=0;iSetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp2)); pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp5)); pEquip->SetSysBlock(m_csSysBlk1); } else if (dlg.m_bNoBreak == 3)//zxl 2011.12.19 add 增加水喷雾喷头 { pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp6)); pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength( -250 ); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3)); pEquip->SetSysBlock(m_csSysBlk2); } else if (dlg.m_bNoBreak == 4) // cet 2013.1.5 add 增加直立型水幕 { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); pEquip->SetSysBlock(_T("TWTSYS(00000542)")); pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp7)); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp4)); } else if (dlg.m_bNoBreak == 5) // cet 2013.1.5 add 增加下垂型水幕 { pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(-250); pEquip->SetSysBlock(_T("TWTSYS(00000542)")); pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp8)); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3)); } else{ pEquip->SetBlock2d(GlobalFunc::GetBlkIdByName(xsTmp)); if(dlg.m_bNoBreak == 0){ //上喷 pEquip->SetHidePipe(TRUE); pEquip->SetPipeLength(250); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp4)); pEquip->SetSysBlock(m_csSysBlk1); } else if(dlg.m_bNoBreak == 1){ pEquip->SetHidePipe(FALSE); pEquip->SetBlock3d(GlobalFunc::GetBlkIdByName(xsTmp3)); pEquip->SetPipeLength(-250); pEquip->SetSysBlock(m_csSysBlk1); } } pt.z = dlg.m_nEle * 1000; pEquip->SetLocation(pt); double nAng = GlobalFunc::Wcs2Ucs(GlobalFunc::A2R(dlg.m_nAngle)); pEquip->SetAngle(nAng); pEquip->SetNumber(_T("CIRCLE-1")); pEquip->SetScale(g_Option::instance().g_nSprinklerRadius); //pEquip->SetSysBlock(m_csSysBlk1); pEquip->setLayer(LAY_EQUIP_SPRINKLE); pEquip->setColor(AcCmColor()); //随层 GlobalFunc::AddToCurrentSpace(pEquip, Adesk::kTrue); Entity entLast; entLast.GetLast(); GlobalFunc::WriteXdata(entLast, _T("HYDRANT_RADIUS"), dlg.m_csRadius); } if(dlg.m_iConPipe == 2) //不接线 continue; int count(0), count2(0); if(dlg.m_iConPipe == 0){ //行向接线 count = iRow; count2 = iCol; } else if(dlg.m_iConPipe == 1){ //列向接线 count = iCol; count2 = iRow; } for(int j=0;jSetStartPoint(pt1); pPipe->SetEndPoint(pt2); // zxl 2011.08.15 modify 根据用户选择设置管线类型 //pPipe->setLayer(LAY_PIPE_SPRINKLE); //pPipe->setLinetype(GetPipeWireLayLineType(LAY_PIPE_SPRINKLE)); pPipe->setLayer(dlg.m_sLayer); pPipe->setLinetype(GlobalFunc::GetPipeWireLayLineType(dlg.m_sLayer)); pPipe->SetPipeWeight(g_Option::instance().g_nPipeWidth[8]); pPipe->SetDnDiameter(g_Option::instance().g_iDefaultPipeDn); pPipe->SetModelType(TPipeSys::kModel); pPipe->SetSysType(TPipeSys::kSprinkle); //zxl 2011.12.12 modify //pPipe->SetSysType(TPipeSys::kSprinkle); if (dlg.m_sLayer.Compare(LAY_PIPE_SPRINKLE) == 0) { pPipe->SetSysType(TPipeSys::kSprinkle); } else if (dlg.m_sLayer.Compare(LAY_PIPE_SPRINKLE2) == 0) { pPipe->SetSysType(TPipeSys::kSprinkle2); } else { pPipe->SetSysType(TPipeSys::kSprinkle3); } pPipe->SetRadius(g_Option::instance().g_nPipeRadius[8]); pPipe->setColor(AcCmColor()); //随层 GlobalFunc::AddToCurrentSpace(pPipe, Adesk::kTrue); } } } // while end dlg.DestroyWindow();//命令取消, 强制执行反应器 SHads_command(RTSTR, _T(".REDRAW"), RTNONE); } ///////////////////////////////////////////////////////////////////////////// // CSprinklerByRectDlg dialog IMPLEMENT_DYNAMIC(CSprinklerByRectDlg, CDialog) //int CSprinklerByRectDlg::m_iCol = 3600; cet 2012.12.19 del 改为随等级变化 //int CSprinklerByRectDlg::m_iRow = 3600; cet 2012.12.19 del 改为随等级变化 double CSprinklerByRectDlg::m_nColSpace = 3600; double CSprinklerByRectDlg::m_nRowSpace = 3600; int CSprinklerByRectDlg::m_nCol = 4; int CSprinklerByRectDlg::m_nRow = 3; int CSprinklerByRectDlg::m_iType = 1; int CSprinklerByRectDlg::m_iMode = 0; int CSprinklerByRectDlg::m_bNoBreak = 1; double CSprinklerByRectDlg::m_nEle = 0; int CSprinklerByRectDlg::m_iConPipe = 0; //int CSprinklerByRectDlg::m_iLevel = 1; cet 2012.12.19 del 存入注册表 double CSprinklerByRectDlg::m_dMinDist = 2400; int CSprinklerByRectDlg::m_iPipeType = 0; double CSprinklerByRectDlg::m_dMinDistToWall = 500; // cet 2012.12.21 add 记录当前值 BOOL CSprinklerByRectDlg::m_bMinDistToWall = TRUE; // cet 2013.04.15 add 是否考虑距墙最小距离 CSprinklerByRectDlg::CSprinklerByRectDlg(CWnd* pParent /*=NULL*/) : CDialog(CSprinklerByRectDlg::IDD, pParent), m_spinAngle(5), m_spinRow(1), m_spinCol(1) { //{{AFX_DATA_INIT(CSprinklerByRectDlg) m_bDrawCir = FALSE; m_nAngle = 0; m_csRadius = _T("2.12"); //}}AFX_DATA_INIT m_nDist2Wall = 1700; m_sLayer = LAY_PIPE_SPRINKLE; m_iLevel = 1; // cet 2012.12.19 add m_bInit = true; } void CSprinklerByRectDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSprinklerByRectDlg) DDX_Control(pDX, IDC_EDIT_ELE, m_editEle); DDX_Control(pDX, IDC_EDIT_ROWNUM, m_editRow); DDX_Control(pDX, IDC_EDIT_COLNUM, m_editCol); DDX_Control(pDX, IDC_EDIT_ANGLE, m_editAngle); DDX_Control(pDX, IDC_SPIN_ANGLE, m_spinAngle); DDX_Control(pDX, IDC_SPIN_ROW, m_spinRow); DDX_Control(pDX, IDC_SPIN_COL, m_spinCol); DDX_Check(pDX, IDC_CHECK_DRAW, m_bDrawCir); DDX_Text(pDX, IDC_EDIT_ANGLE, m_nAngle); DDX_CBString(pDX, IDC_COMBO_RADIUS, m_csRadius); DDX_CBIndex(pDX, IDC_COMBO_LEVEL, m_iLevel); DDX_Text(pDX, IDC_EDIT_COLNUM, m_iCol); DDX_Text(pDX, IDC_EDIT_ROWNUM, m_iRow); DDX_Radio(pDX, IDC_RADIO_MODE1, m_iMode); DDX_Radio(pDX, IDC_RADIO_POS1, m_bNoBreak); DDX_CBIndex(pDX, IDC_COMBO_PIPE, m_iConPipe); DDX_Text(pDX, IDC_EDIT_ELE, m_nEle); DDX_Radio(pDX, IDC_RADIO_TYPE1, m_iType); DDX_Text(pDX, IDC_EDIT_MIN_DIST, m_dMinDist); DDX_CBIndex(pDX, IDC_COMBO_PIPETYPE, m_iPipeType); DDX_Text(pDX, IDC_EDT_MIN_DIST_TOWALL, m_dMinDistToWall); DDX_Check(pDX, IDC_CHECK_MINDIST, m_bMinDistToWall); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSprinklerByRectDlg, CDialog) //{{AFX_MSG_MAP(CSprinklerByRectDlg) ON_WM_CLOSE() ON_BN_CLICKED(IDC_CHECK_DRAW, OnCheckDraw) ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioType1) ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioType2) ON_CBN_SELCHANGE(IDC_COMBO_LEVEL, OnSelchangeComboLevel) ON_CBN_SELCHANGE(IDC_COMBO_PIPETYPE, OnSelchangeComboType) ON_WM_DESTROY() ON_BN_CLICKED(IDC_RADIO_MODE1, OnRadioMode) ON_EN_CHANGE(IDC_EDT_MIN_DIST_TOWALL, OnChangeEdtMinDistTowall) ON_BN_CLICKED(IDC_CHECK_MINDIST, OnCheckMindist) ON_EN_KILLFOCUS(IDC_EDIT_COLNUM, OnKillfocusEditColnum) ON_EN_KILLFOCUS(IDC_EDIT_ROWNUM, OnKillfocusEditRownum) ON_EN_KILLFOCUS(IDC_EDIT_MIN_DIST, OnKillfocusEditMinDist) ON_EN_KILLFOCUS(IDC_EDT_MIN_DIST_TOWALL, OnKillfocusEdtMinDistTowall) ON_EN_KILLFOCUS(IDC_EDIT_ANGLE, OnKillfocusEditAngle) ON_EN_KILLFOCUS(IDC_EDIT_ELE, OnKillfocusEditEle) ON_BN_CLICKED(IDC_RADIO_MODE2, OnRadioMode) ON_CBN_KILLFOCUS(IDC_COMBO_RADIUS, OnKillfocusComboRadius) ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSprinklerByRectDlg message handlers void CSprinklerByRectDlg::OnClose() { CDialog::OnClose(); acedPostCommand(_T("\33\33")); } BOOL CSprinklerByRectDlg::OnInitDialog() { CDialog::OnInitDialog(); m_editAngle.SetDataType(CRealEdit::eInteger); m_editRow.SetDataType(CRealEdit::eInteger); m_editCol.SetDataType(CRealEdit::eInteger); m_editEle.SetDataType(CRealEdit::eReal); m_spinAngle.SetRange(0,360); m_spinCol.SetRange(1,9000); m_spinRow.SetRange(1,9000); OnCheckDraw(); CWnd *pWnd1 = GetDlgItem(IDC_STATIC_ROWNUM); CWnd *pWnd2 = GetDlgItem(IDC_STATIC_COLNUM); if(m_iType == 0){ pWnd1->SetWindowText(_T("行数:")); pWnd2->SetWindowText(_T("列数:")); m_spinCol.m_nDelta = 1; m_spinRow.m_nDelta = 1; } else{ pWnd1->SetWindowText(_T("行最大间距")); pWnd2->SetWindowText(_T("列最大间距")); m_spinCol.m_nDelta = 100; m_spinRow.m_nDelta = 100; } // cet 2012.12.19 add 读取注册表数据 ReadRegeditData(); UpdateData(FALSE); OnSelchangeComboLevel(); m_bInit = false; OnRadioMode(); OnSelchangeComboType(); // zxl 2010.08.15 add获取当前用户设置的管线类型 // OnSelchangeComboLevel(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } LONG_PTR CSprinklerByRectDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR) { POINT pt; ::GetCursorPos(&pt); CRect rect; GetWindowRect(&rect); if (!(rect.PtInRect(pt))) { return FALSE; } return TRUE; } void CSprinklerByRectDlg::OnCheckDraw() { UpdateData(); CWnd *pWnd1 = GetDlgItem(IDC_COMBO_RADIUS); pWnd1->EnableWindow(m_bDrawCir); } void CSprinklerByRectDlg::OnRadioType1() { UpdateData(TRUE); CWnd *pWnd1 = GetDlgItem(IDC_STATIC_ROWNUM); CWnd *pWnd2 = GetDlgItem(IDC_STATIC_COLNUM); pWnd1->SetWindowText(_T("行数:")); pWnd2->SetWindowText(_T("列数:")); if (m_iLevel == 4) { m_nColSpace = m_iCol; m_nRowSpace = m_iRow; } m_iCol = m_nCol; m_iRow = m_nRow; m_spinCol.m_nDelta = 1; m_spinRow.m_nDelta = 1; UpdateData(FALSE); // cet 2012.12.19 add OnRadioMode(); } void CSprinklerByRectDlg::OnRadioType2() { UpdateData(TRUE); CWnd *pWnd1 = GetDlgItem(IDC_STATIC_ROWNUM); // zxl 2012.01.17 add if (pWnd1 != NULL) { CString sText; pWnd1->GetWindowText(sText); if (sText.Compare(_T("行最大间距")) != 0) { m_nCol = m_iCol; m_nRow = m_iRow; } } CWnd *pWnd2 = GetDlgItem(IDC_STATIC_COLNUM); pWnd1->SetWindowText(_T("行最大间距")); pWnd2->SetWindowText(_T("列最大间距")); if(m_iLevel == 0){ m_iCol = 4400; m_iRow = 4400; m_nDist2Wall = 2200; } else if(m_iLevel == 1){ m_iCol = 3600; m_iRow = 3600; m_nDist2Wall = 1800; } else if(m_iLevel == 2){ m_iCol = 3400; m_iRow = 3400; m_nDist2Wall = 1700; } else if(m_iLevel == 3){ m_iCol = 3000; m_iRow = 3000; m_nDist2Wall = 1500; } else if (m_iLevel == 4) { m_iCol = m_nColSpace; m_iRow = m_nRowSpace; } m_spinCol.m_nDelta = 100; m_spinRow.m_nDelta = 100; UpdateData(FALSE); // cet 2012.12.19 add OnRadioMode(); } void CSprinklerByRectDlg::OnSelchangeComboLevel() { int iOldLevel = m_iLevel; UpdateData(TRUE); if (iOldLevel == 4 && !m_bInit && m_iType == 1) { m_nRowSpace = m_iRow; m_nColSpace = m_iCol; } // cet 2012.12.19 modify // if(m_iMode == 1 || m_iType == 0) // return; if(m_iType == 0) { m_iCol = m_nCol; m_iRow = m_nRow; UpdateData(FALSE); return; } if(m_iLevel == 0){ m_iCol = 4400; m_iRow = 4400; m_nDist2Wall = 2200; } else if(m_iLevel == 1){ m_iCol = 3600; m_iRow = 3600; m_nDist2Wall = 1800; } else if(m_iLevel == 2){ m_iCol = 3400; m_iRow = 3400; m_nDist2Wall = 1700; } else if(m_iLevel == 3){ m_iCol = 3000; m_iRow = 3000; m_nDist2Wall = 1500; } else if (m_iLevel == 4) { m_iCol = m_nColSpace; m_iRow = m_nRowSpace; } UpdateData(FALSE); } void CSprinklerByRectDlg::OnSelchangeComboType() { UpdateData(TRUE); if (m_iPipeType == 0) { m_sLayer = LAY_PIPE_SPRINKLE; } else if (m_iPipeType == 1) { m_sLayer = LAY_PIPE_SPRINKLE2; } else if (m_iPipeType == 2) { m_sLayer = LAY_PIPE_SPRINKLE3; } } void CSprinklerByRectDlg::ReadRegeditData() { TRegProperty regProp(_T("SoftWare\\SHANGHUASOFT\\2023"), _T("SHS-WTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); // 读取消防等级 regProp.GetValue(_T("RectSprinklerLevel"), m_iLevel); regProp.GetValue(_T("RectSprinklerCol"), m_nCol); regProp.GetValue(_T("RectSprinklerRow"), m_nRow); regProp.GetValue(_T("RectSprinklerColSpace"), m_nColSpace); regProp.GetValue(_T("RectSprinklerRowSpace"), m_nRowSpace); } void CSprinklerByRectDlg::WriteRegeditData() { TRegProperty regProp(_T("SoftWare\\SHANGHUASOFT\\2023"), _T("SHS-WTConfig")); regProp.SetTopRootKey(HKEY_CURRENT_USER); // 记录消防等级 regProp.SetValue(_T("RectSprinklerLevel"), m_iLevel); if (m_iLevel == 4 && m_iType == 1) { m_nRowSpace = m_iRow; m_nColSpace = m_iCol; } else if (m_iType == 0) { m_nRow= m_iRow; m_nCol = m_iCol; } regProp.SetValue(_T("RectSprinklerCol"), m_nCol); regProp.SetValue(_T("RectSprinklerRow"), m_nRow); regProp.SetValue(_T("RectSprinklerColSpace"), m_nColSpace); regProp.SetValue(_T("RectSprinklerRowSpace"), m_nRowSpace); } void CSprinklerByRectDlg::OnDestroy() { CDialog::OnDestroy(); WriteRegeditData(); // zxl 2012.01.17 add 记忆行列 CWnd *pWnd1 = GetDlgItem(IDC_STATIC_ROWNUM); if (pWnd1 != NULL) { UpdateData(TRUE); CString sText; pWnd1->GetWindowText(sText); if (sText.Compare(_T("行数:")) == 0) { m_nCol = m_iCol; m_nRow = m_iRow; } } } void CSprinklerByRectDlg::EnableWnd( DWORD nId, BOOL bEnable ) { CWnd *pWnd = GetDlgItem(nId); if (pWnd != NULL) { pWnd->EnableWindow(bEnable); } } void CSprinklerByRectDlg::OnRadioMode() { UpdateData(TRUE); if (m_iMode == 0 && m_iType == 1) { EnableWnd(IDC_EDT_MIN_DIST_TOWALL, m_bMinDistToWall ? TRUE : FALSE); // cet 2013.4.15 modify ShowWnd(IDC_CHECK_MINDIST, TRUE); // cet 2013.4.15 add } else { EnableWnd(IDC_EDT_MIN_DIST_TOWALL, false); ShowWnd(IDC_CHECK_MINDIST, FALSE); // cet 2013.4.15 add } } void CSprinklerByRectDlg::OnChangeEdtMinDistTowall() { //UpdateData(TRUE); } void CSprinklerByRectDlg::ShowWnd( DWORD nId, BOOL bShow ) { CWnd *pWnd = GetDlgItem(nId); if (pWnd != NULL) { pWnd->ShowWindow(bShow ? SW_SHOW : SW_HIDE); } } void CSprinklerByRectDlg::OnCheckMindist() { UpdateData(TRUE); if (m_bMinDistToWall && m_iMode == 0 && m_iType == 1) { EnableWnd(IDC_EDT_MIN_DIST_TOWALL, TRUE); } else { EnableWnd(IDC_EDT_MIN_DIST_TOWALL, FALSE); } } void CSprinklerByRectDlg::OnKillfocusEditColnum() { double dData = m_iCol; CEdit *pWnd = (CEdit *)GetDlgItem(IDC_EDIT_COLNUM); if (pWnd == NULL) { return; } CString sText; pWnd->GetWindowText(sText); m_iCol = _tstof(sText); if (m_iCol <= 0 || !GlobalFunc::IsStrAllNum(sText)) { m_iCol = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); pWnd->SetFocus(); pWnd->SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusEditRownum() { double dData = m_iRow; CEdit *pWnd = (CEdit *)GetDlgItem(IDC_EDIT_ROWNUM); if (pWnd == NULL) { return; } CString sText; pWnd->GetWindowText(sText); m_iRow = _tstof(sText); if (m_iRow <= 0 || !GlobalFunc::IsStrAllNum(sText)) { m_iRow = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); pWnd->SetFocus(); pWnd->SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusEditMinDist() { double dData = m_dMinDist; CEdit *pWnd = (CEdit *)GetDlgItem(IDC_EDIT_MIN_DIST); if (pWnd == NULL) { return; } CString sText; pWnd->GetWindowText(sText); m_dMinDist = _tstof(sText); if (m_dMinDist <= 0 || !GlobalFunc::IsStrAllNum(sText)) { m_dMinDist = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); pWnd->SetFocus(); pWnd->SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusEdtMinDistTowall() { double dData = m_dMinDistToWall; CEdit *pWnd = (CEdit *)GetDlgItem(IDC_EDT_MIN_DIST_TOWALL); if (pWnd == NULL) { return; } CString sText; pWnd->GetWindowText(sText); m_dMinDistToWall = _tstof(sText); if (m_dMinDistToWall <= 0 || !GlobalFunc::IsStrAllNum(sText)) { m_dMinDistToWall = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); pWnd->SetFocus(); pWnd->SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusEditAngle() { double dData = m_nAngle; CString sText; m_editAngle.GetWindowText(sText); m_nAngle = _tstof(sText); if (sText.IsEmpty() || !GlobalFunc::IsStrAllNum(sText)) { m_nAngle = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); m_editAngle.SetFocus(); m_editAngle.SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusEditEle() { double dData = m_nEle; CString sText; m_editEle.GetWindowText(sText); m_nEle = _tstof(sText); if (sText.IsEmpty() || !GlobalFunc::IsStrAllNum(sText)) { m_nEle = dData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); m_editEle.SetFocus(); m_editEle.SetSel(0, -1); } } void CSprinklerByRectDlg::OnKillfocusComboRadius() { CString csData = m_csRadius; CEdit *pWnd = (CEdit *)GetDlgItem(IDC_COMBO_RADIUS); if (pWnd == NULL) { return; } CString sText; pWnd->GetWindowText(sText); double dNewData = _tstof(sText); if (dNewData <= 0 || !GlobalFunc::IsStrAllNum(sText)) { m_csRadius = csData; UpdateData(FALSE); acedGetAcadDwgView()->SetFocus(); pWnd->SetFocus(); pWnd->SetSel(0, -1); } }