732 lines
17 KiB
C++
732 lines
17 KiB
C++
#include "stdafx.h"
|
|
#include "ThunderLineSetDlg.h"
|
|
#include "ThunderCmdGroup.h"
|
|
#include "GroupHelp.h"
|
|
#include "ProHeightHelp.h"
|
|
#include "TThunderInsertPreviewJig.h"
|
|
#include "ThunderXData.h"
|
|
|
|
#include "dbxutil.h"
|
|
#include "dbgroup.h"
|
|
|
|
CThunderLineSetDlg::CThunderLineSetDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CThunderLineSetDlg::IDD, pParent)
|
|
{
|
|
m_bValid = FALSE;
|
|
m_bTipChange = FALSE;
|
|
m_nUseType = eCreate;
|
|
m_strPinHeight = _T("25");
|
|
}
|
|
|
|
CThunderLineSetDlg::~CThunderLineSetDlg()
|
|
{
|
|
|
|
}
|
|
|
|
void CThunderLineSetDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CThunderLineSetDlg)
|
|
DDX_Control(pDX, IDC_SPIN2, m_wndSpinNum);
|
|
DDX_Control(pDX, IDC_SPIN1, m_wndSpinGroup);
|
|
DDX_Control(pDX, IDC_LST_PROHEIGHT, m_LstData);
|
|
DDX_Control(pDX, IDC_INFOR, m_wndStcInfor);
|
|
DDX_Control(pDX, IDC_EDT_NUM, m_wndEdtNum);
|
|
DDX_Control(pDX, IDC_EDT_LINEHEIGHT, m_wndEdtLineH);
|
|
DDX_Text(pDX,IDC_EDT_LINEHEIGHT,m_strPinHeight);
|
|
DDX_Control(pDX, IDC_EDT_GROUP, m_wndEdtGroup);
|
|
DDX_Control(pDX, IDC_COM_RADIUS, m_cmbRadius);
|
|
DDX_Control(pDX, IDC_BUT_HELP2, m_btnLineHHelp);
|
|
DDX_Control(pDX, IDC_BUT_HELP, m_btnGroupHelp);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CThunderLineSetDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CThunderLineSetDlg)
|
|
ON_BN_CLICKED(IDC_BUT_HELP, OnButGroupHelp)
|
|
ON_BN_CLICKED(IDC_BUT_HELP2, OnBtnLineHHelp)
|
|
ON_EN_CHANGE(IDC_EDT_GROUP, OnChangeEdtGroup)
|
|
ON_EN_CHANGE(IDC_EDT_NUM, OnChangeEdtNum)
|
|
ON_WM_CTLCOLOR()
|
|
ON_WM_CLOSE()
|
|
//}}AFX_MSG_MAP
|
|
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
|
|
ON_BN_CLICKED(IDOK,OnBnClickedOk)
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CThunderLineSetDlg::OnBnClickedButton1)
|
|
ON_BN_CLICKED(IDC_BUTTON2, &CThunderLineSetDlg::OnBnClickedButton2)
|
|
END_MESSAGE_MAP()
|
|
|
|
LONG_PTR CThunderLineSetDlg::OnAcadKeepFocus(UINT_PTR, LONG_PTR)
|
|
{
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
CRect rc;
|
|
GetWindowRect(&rc);
|
|
return (rc.PtInRect(pt) ? TRUE : FALSE);
|
|
}
|
|
|
|
// 对话框的非模式形式
|
|
BOOL CThunderLineSetDlg::DoModeless()
|
|
{
|
|
if (!Create(IDD_DRAW_THUNDER_LINE))
|
|
{
|
|
return FALSE;
|
|
}
|
|
ShowWindow(SW_SHOW);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CThunderLineSetDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
ReadDlgData();
|
|
|
|
// 保护高度
|
|
m_LstData.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
|
|
m_LstData.InsertColumn(0,_T("编号"),LVCFMT_LEFT,120);
|
|
m_LstData.InsertColumn(1,_T("保护高度"),LVCFMT_LEFT,200);
|
|
m_LstData.SetColumnItemData(1,NULL,ET_Edit);
|
|
|
|
InitProHeight();
|
|
|
|
CString sLineH;
|
|
m_wndEdtLineH.GetWindowText(sLineH);
|
|
if (sLineH.IsEmpty())
|
|
{
|
|
m_wndEdtLineH.SetWindowText(_T("25"));
|
|
}
|
|
CString sGNo,sNum;
|
|
AcDbIntArray arNum;
|
|
m_wndEdtGroup.GetWindowText(sGNo);
|
|
ThunderContainer->GetTLineNumArrayBySpecGroup(sGNo,arNum);
|
|
int nLastNum = 0;
|
|
for (int k = 0;k < arNum.length();k++)
|
|
{
|
|
if (arNum[k] > nLastNum)
|
|
{
|
|
nLastNum = arNum[k];
|
|
}
|
|
}
|
|
|
|
sNum.Format(_T("%d"),nLastNum+1);
|
|
m_wndEdtNum.SetWindowText(sNum);
|
|
m_wndSpinGroup.SetRange32(SPNMIN,SPNMAX);
|
|
m_wndSpinNum.SetRange32(SPNMIN,SPNMAX);
|
|
|
|
m_bitTip.LoadBitmap(IDB_BITMAPHELP);
|
|
m_btnGroupHelp.SetBitmap(HBITMAP(m_bitTip));
|
|
m_btnLineHHelp.SetBitmap(HBITMAP(m_bitTip));
|
|
if(m_nUseType == eEdit)
|
|
{
|
|
//如果是编辑修改
|
|
SetWindowText(_T("改避雷线"));
|
|
|
|
CThunderXData thunderXData;
|
|
CString sNum,sGroup,sHeight,sGRadius;
|
|
thunderXData.GetXData(m_idThunderLine,KEY_LINE_PRO_RADIUS,sGRadius);
|
|
thunderXData.GetXData(m_idThunderLine,KEY_LINE_HEIGHT,sHeight);
|
|
thunderXData.GetXData(m_idThunderLine,KEY_LINE_GROUP_NO,sGroup);
|
|
thunderXData.GetXData(m_idThunderLine,TEL_ORDER_NUMBER,sNum);
|
|
|
|
int nIndex = m_cmbRadius.FindString(0,sGRadius);
|
|
m_cmbRadius.SetCurSel(nIndex);
|
|
m_wndEdtNum.SetWindowText(sNum);
|
|
m_wndEdtGroup.SetWindowText(sGroup);
|
|
m_wndEdtLineH.SetWindowText(sHeight);
|
|
|
|
m_wndStcInfor.ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDOK)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_SHOW);
|
|
}
|
|
|
|
m_bValid = TRUE;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CThunderLineSetDlg::InitProHeight()
|
|
{
|
|
CThunderXData xd;
|
|
AcGeDoubleArray arProH;
|
|
if (m_nUseType == eCreate)
|
|
{
|
|
if (!xd.GetProtectHeightFromReg(arProH, KEY_THUNDERLINE_PH))
|
|
{
|
|
arProH.append(15.0);
|
|
}
|
|
}
|
|
else if (m_nUseType == eEdit)
|
|
{
|
|
xd.GetProtectHeightFromObjEx(m_idThunderLine, arProH);
|
|
}
|
|
|
|
long lIndex = -1;
|
|
CString sTmp;
|
|
for (int i = 0;i < arProH.length();++i)
|
|
{
|
|
lIndex = m_LstData.GetItemCount();
|
|
sTmp.Format(_T("%d"),lIndex + 1);
|
|
m_LstData.InsertItem(lIndex,sTmp);
|
|
|
|
sTmp.Format(_T("%g"), arProH[i]);
|
|
m_LstData.SetItemText(lIndex,1,sTmp);
|
|
}
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnButGroupHelp()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
|
|
CGroupHelp hlpDlg;
|
|
hlpDlg.DoModal();
|
|
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnBtnLineHHelp()
|
|
{
|
|
CAcModuleResourceOverride myResources;
|
|
|
|
CProHeightHelp hlpDlg;
|
|
hlpDlg.DoModal();
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnChangeEdtGroup()
|
|
{
|
|
if (!m_bValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CString sGNo,strTip;
|
|
m_wndEdtGroup.GetWindowText(sGNo);
|
|
|
|
if (_ttoi(sGNo) < 1)
|
|
{
|
|
strTip.Format(_T("组号最小为1"));
|
|
m_bTipChange = TRUE;
|
|
PostErrorToCue(strTip);
|
|
return;
|
|
}
|
|
|
|
// 避雷针编号
|
|
AcGeIntArray arNum;
|
|
ThunderContainer->GetTLineNumArrayBySpecGroup(sGNo, arNum);
|
|
if (arNum.length() > 0)
|
|
{
|
|
CString sNum;
|
|
sNum.Format(_T("%d"), arNum.last()+1);
|
|
m_wndEdtNum.SetWindowText(sNum);
|
|
}
|
|
else
|
|
{
|
|
m_wndEdtNum.SetWindowText(_T("1"));
|
|
}
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnChangeEdtNum()
|
|
{
|
|
if (!m_bValid)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CString sCurNo,sOldGNo,strTip;
|
|
m_wndEdtNum.GetWindowText(sCurNo);
|
|
m_wndEdtGroup.GetWindowText(sOldGNo);
|
|
|
|
if (_ttoi(sCurNo) < 1)
|
|
{
|
|
strTip.Format(_T("编号最小为1"));
|
|
m_bTipChange = TRUE;
|
|
PostErrorToCue(strTip);
|
|
return;
|
|
}
|
|
|
|
BOOL bValid = FALSE;
|
|
AcGeIntArray arNum;
|
|
ThunderContainer->GetTLineNumArrayBySpecGroup(sOldGNo, arNum);
|
|
|
|
int nPos;
|
|
if (!arNum.find(_ttoi(sCurNo),nPos))
|
|
{
|
|
bValid = TRUE;
|
|
}
|
|
|
|
if (m_nUseType == eEdit)
|
|
{
|
|
CThunderXData thunderXdata;
|
|
CString sNum;
|
|
thunderXdata.GetXData(m_idThunderLine,TEL_ORDER_NUMBER,sNum);
|
|
if (!sNum.CompareNoCase(sCurNo))
|
|
{
|
|
bValid = TRUE;
|
|
}
|
|
}
|
|
if (!bValid)
|
|
{
|
|
// 提示错误(显示错误提示 + 隐藏更新和取消按钮)
|
|
strTip.Format(_T("组%s中编号%s已存在"), sOldGNo,sCurNo);
|
|
m_bTipChange = TRUE;
|
|
if (m_nUseType)
|
|
{
|
|
m_wndStcInfor.ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
PostErrorToCue(strTip);
|
|
}
|
|
else
|
|
{
|
|
// 清除错误提示(显示更新和取消按钮 + 隐藏错误提示)
|
|
strTip.Format(_T("组%s中编号%s可以使用"), sOldGNo,sCurNo);
|
|
m_bTipChange = FALSE;
|
|
if (m_nUseType == eEdit)
|
|
{
|
|
m_wndStcInfor.ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDOK)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_SHOW);
|
|
}
|
|
|
|
PostErrorToCue(strTip);
|
|
}
|
|
}
|
|
|
|
void CThunderLineSetDlg::PostErrorToCue(LPCTSTR pszError)
|
|
{
|
|
m_wndStcInfor.SetWindowText(pszError);
|
|
}
|
|
|
|
void CThunderLineSetDlg::SetThunderDraw2d(CDrawThunderTools* pThundDraw)
|
|
{
|
|
m_pDrawThunder = pThundDraw;
|
|
}
|
|
|
|
bool CThunderLineSetDlg::DocGetMeterUnitDraw()
|
|
{
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"),&rb);
|
|
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
BOOL CThunderLineSetDlg::DrawThunderLine(AcDbObjectId& idOut)
|
|
{
|
|
//读取设置
|
|
CString sWidth;
|
|
double dWidth;
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
if (regProp.GetValue(KEY_LINETHINK,sWidth))
|
|
{
|
|
dWidth = _tstof(sWidth);
|
|
}
|
|
else
|
|
{
|
|
dWidth = 0.0;
|
|
}
|
|
|
|
int SinglePinColorIndex = 1;
|
|
regProp.GetValue(KEY_SINGLEPRO_COLOR,SinglePinColorIndex);
|
|
|
|
CString sKeyTip;
|
|
sKeyTip = _T("P A");
|
|
int nRet = -1;
|
|
ads_point ptAds;
|
|
BOOL bFixAngle = FALSE;
|
|
double dFixAngle = 0.0;
|
|
|
|
INITGET_BEG(0, sKeyTip);
|
|
nRet = acedGetPoint(0,_T("\n 请拾取避雷线起始点[平行于参照避雷线(P)/指定角度0~360(A)]<P>:"),ptAds);
|
|
INITGET_END();
|
|
|
|
if(nRet == RTKWORD || nRet == RTNONE)
|
|
{
|
|
TCHAR szKey[32];
|
|
memset(szKey,0,32);
|
|
ads_getinput(szKey);
|
|
CString sKeyword = szKey;
|
|
if (nRet == RTNONE)
|
|
sKeyword.Empty();
|
|
|
|
if (sKeyword.IsEmpty() || sKeyword.CompareNoCase(_T("P")) == 0) // 选择参照避雷线
|
|
{
|
|
// 选择避雷线取其旋转角度
|
|
Entity ent;
|
|
RBList rb = ads_buildlist(RTDXF0,_T("LWPOLYLINE"),8,LAY_EL_LIGHTNING_LINE,NULL);
|
|
if (SelectEntity(_T("\n 请选择参照的避雷线<退出>:"), ent, rb) != RTNORM)
|
|
{
|
|
return FALSE;
|
|
}
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbPolyline,pLine);
|
|
if (pLine != NULL)
|
|
{
|
|
AcGePoint3d ptS,ptE;
|
|
pLine->getStartPoint(ptS);
|
|
pLine->getEndPoint(ptE);
|
|
AcGeVector3d vtDir = ptE - ptS;
|
|
dFixAngle = vtDir.angleTo(AcGeVector3d::kXAxis);
|
|
double dFixAngle1 = vtDir.angleTo(AcGeVector3d::kYAxis);
|
|
if (dFixAngle1 > PI/2)
|
|
{
|
|
dFixAngle = PI - dFixAngle;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
bFixAngle = TRUE;
|
|
|
|
if (acedGetPoint(0,_T("\n 请拾取避雷线起始点<退出>:"),ptAds) != RTNORM)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
else if (sKeyword.CompareNoCase(_T("A")) == 0)// 指定避雷线角度
|
|
{
|
|
// 输入角度
|
|
if (acedGetReal(_T("\n 请输入避雷线角度<退出>:"), &dFixAngle) != RTNORM)
|
|
{
|
|
return FALSE;
|
|
}
|
|
bFixAngle = TRUE;
|
|
if (acedGetPoint(0,_T("\n 请拾取避雷线起始点<退出>:"),ptAds) != RTNORM)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
}
|
|
else if(nRet == RTCAN) // 退出
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
CString sGroupNo;
|
|
m_wndEdtGroup.GetWindowText(sGroupNo);
|
|
if (_ttoi(sGroupNo) < 1)
|
|
{
|
|
AfxMessageBox(_T("避雷线组号应大于0!"));
|
|
return TRUE;
|
|
}
|
|
|
|
CString sNum;
|
|
m_wndEdtNum.GetWindowText(sNum);
|
|
if (_ttoi(sNum) < 1)
|
|
{
|
|
AfxMessageBox(_T("避雷线编号应大于0!"));
|
|
return TRUE;
|
|
}
|
|
|
|
CString sGroup,sGRadius,sHeight;
|
|
m_wndEdtGroup.GetWindowText(sGroup);
|
|
m_wndEdtLineH.GetWindowText(sHeight);
|
|
m_cmbRadius.GetWindowText(sGRadius);
|
|
|
|
if (_tstof(sHeight) >= 2*_tstof(sGRadius))
|
|
{
|
|
AfxMessageBox(_T("避雷线高度应小于两倍的滚球半径!"));
|
|
return TRUE;
|
|
}
|
|
|
|
if (m_bTipChange)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
acdbUcs2Wcs(ptAds, ptAds, false);
|
|
AcGePoint3d ptInsert = asPnt3d(ptAds);
|
|
|
|
AcDbPolyline* pLine = new AcDbPolyline;
|
|
pLine->addVertexAt(0,ptInsert.convert2d(AcGePlane::kXYPlane));
|
|
pLine->addVertexAt(1,ptInsert.convert2d(AcGePlane::kXYPlane));
|
|
pLine->setNormal(AcGeVector3d::kZAxis);
|
|
pLine->setConstantWidth(dWidth);
|
|
pLine->setLayer(LAY_EL_LIGHTNING_LINE);
|
|
pLine->setColorIndex(SinglePinColorIndex);
|
|
|
|
TThunderLinePreviewJig jig(pLine);
|
|
jig.SetFixAngleState(bFixAngle);
|
|
jig.SetFixAngleValue(dFixAngle);
|
|
jig.setDispPrompt(_T("\n 请点取避雷线结束点<退出>:"));
|
|
if (jig.DoIt() != RTNORM)
|
|
{
|
|
if (pLine != NULL)
|
|
{
|
|
delete pLine;
|
|
pLine = NULL;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
AcGePoint3d ptLast = jig.GetLastPoint();
|
|
CString sTmp;
|
|
m_wndEdtLineH.GetWindowText(sTmp);
|
|
double dscale = 1.0;
|
|
if (!DocGetMeterUnitDraw())
|
|
{
|
|
dscale *= 1000;
|
|
}
|
|
pLine->setElevation(_tstof(sTmp)*dscale);
|
|
ptInsert.z = _tstof(sTmp)*dscale;
|
|
ptLast.z = _tstof(sTmp)*dscale;
|
|
// 避雷线
|
|
idOut = AddToCurrentSpace(pLine,Adesk::kTrue);
|
|
|
|
if (!idOut.isValid())
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
CThunderXData xd;
|
|
OPENOBJ_BEGIN(idOut,AcDb::kForWrite,AcDbEntity,pEnt);
|
|
if (pEnt != NULL)
|
|
{
|
|
xd.SetXData(pEnt,KEY_LINE_PRO_RADIUS,sGRadius);
|
|
xd.SetXData(pEnt,KEY_LINE_HEIGHT,sHeight);
|
|
xd.SetXData(pEnt,KEY_LINE_GROUP_NO,sGroup);
|
|
xd.SetXData(pEnt,TEL_ORDER_NUMBER,sNum);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
ThunderContainer->AppendThunderLine(sGroup, idOut);
|
|
|
|
AcGeDoubleArray arProHeight;
|
|
GetCurentProHeight(arProHeight);
|
|
|
|
if (m_pDrawThunder != NULL)
|
|
{
|
|
m_pDrawThunder->DrawThunderLine(sGroup,arProHeight);
|
|
}
|
|
|
|
xd.SetProtectHeightToReg(arProHeight, KEY_THUNDERLINE_PH);
|
|
|
|
CString sNO;
|
|
sNO.Format(_T("%d"), _ttoi(sNum)+1);
|
|
m_wndEdtNum.SetWindowText(sNO);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CThunderLineSetDlg::GetCurentProHeight(AcGeDoubleArray& arProHeight)
|
|
{
|
|
CString sData;
|
|
arProHeight.setLogicalLength(0);
|
|
|
|
for (long i = 0;i < m_LstData.GetItemCount();++i)
|
|
{
|
|
sData = m_LstData.GetItemText(i,1);
|
|
arProHeight.append(_tstof(sData));
|
|
}
|
|
}
|
|
|
|
HBRUSH CThunderLineSetDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
|
|
if (IDC_INFOR == pWnd->GetDlgCtrlID())
|
|
{
|
|
if (m_bTipChange)
|
|
{
|
|
pDC->SetTextColor(RGB(255,0,0));
|
|
}
|
|
else
|
|
{
|
|
pDC->SetTextColor(RGB(0, 0, 0));
|
|
}
|
|
|
|
}
|
|
return hbr;
|
|
}
|
|
|
|
void CThunderLineSetDlg::SetUseType(int nUseType)
|
|
{
|
|
m_nUseType = nUseType;
|
|
}
|
|
|
|
void CThunderLineSetDlg::SetCurrectThunderLine(const AcDbObjectId& idThunderLine)
|
|
{
|
|
m_idThunderLine = idThunderLine;
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnBnClickedOk()
|
|
{
|
|
CString sNum,sGroup,sHeight,sGRadius,sOldGroup;
|
|
CThunderXData thunderXData;
|
|
AcGeDoubleArray arProHeight,arOldHeight;
|
|
CString sProH;
|
|
|
|
thunderXData.GetProtectHeightFromObjEx(m_idThunderLine,arOldHeight);
|
|
thunderXData.GetXData(m_idThunderLine,KEY_LINE_GROUP_NO,sOldGroup);
|
|
|
|
int i = 0;
|
|
for (i = 0;i < m_LstData.GetItemCount();i++)
|
|
{
|
|
sProH = m_LstData.GetItemText(i,1);
|
|
if (_tstof(sProH) > 0)
|
|
{
|
|
arProHeight.append(_tstof(sProH));
|
|
}
|
|
}
|
|
|
|
m_cmbRadius.GetWindowText(sGRadius);
|
|
m_wndEdtNum.GetWindowText(sNum);
|
|
m_wndEdtGroup.GetWindowText(sGroup);
|
|
m_wndEdtLineH.GetWindowText(sHeight);
|
|
|
|
AcGePoint3d ptS,ptE;
|
|
OPENOBJ_BEGIN(m_idThunderLine,AcDb::kForWrite,AcDbPolyline,pLine);
|
|
if (pLine)
|
|
{
|
|
double dLineH = _tstof(sHeight)*1000;
|
|
AcGeVector3d vtNor = pLine->normal();
|
|
pLine->getStartPoint(ptS);
|
|
pLine->getEndPoint(ptE);
|
|
AcGePlane plane(AcGePoint3d::kOrigin,vtNor);
|
|
pLine->setPointAt(0,ptS.convert2d(plane));
|
|
pLine->setPointAt(1,ptE.convert2d(plane));
|
|
pLine->setElevation(dLineH);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (_tstof(sGroup) == _tstof(sOldGroup)) // 组号没有改变
|
|
{
|
|
int npos = 0;
|
|
for (i = 0;i < arOldHeight.length();i++)
|
|
{
|
|
//过滤 修改/删除 的保护高度
|
|
if (!arProHeight.find(arOldHeight[i],npos))
|
|
{
|
|
ThunderContainer->AppendRemoveLineProHeight(sGroup,arOldHeight[i]);
|
|
}
|
|
}
|
|
|
|
ThunderContainer->AppendLineProHeight(sGroup, arProHeight);
|
|
}
|
|
else // 改变组号
|
|
{
|
|
thunderXData.SetXData(m_idThunderLine, KEY_LINE_GROUP_NO, sGroup);
|
|
// 将该针从原组中移除
|
|
AcGeDoubleArray arOldPro;
|
|
thunderXData.GetProtectHeightFromObjEx(m_idThunderLine, arOldPro);
|
|
ThunderContainer->RemoveThunderLine(sOldGroup, m_idThunderLine);
|
|
ThunderContainer->AppendLineProHeight(sOldGroup, arOldPro);
|
|
|
|
// 将该针添加到新组
|
|
ThunderContainer->AppendThunderLine(sGroup, m_idThunderLine);
|
|
ThunderContainer->AppendLineProHeight(sGroup, arProHeight);
|
|
}
|
|
|
|
thunderXData.SetProtectHeightToObjEx(m_idThunderLine, arProHeight);
|
|
thunderXData.SetXData(m_idThunderLine,KEY_LINE_PRO_RADIUS,sGRadius);
|
|
thunderXData.SetXData(m_idThunderLine,KEY_LINE_HEIGHT,sHeight);
|
|
thunderXData.SetXData(m_idThunderLine,TEL_ORDER_NUMBER,sNum);
|
|
|
|
// 重绘
|
|
CThunderCmdGroup::bExecute = TRUE;
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CThunderLineSetDlg::ReadDlgData()
|
|
{
|
|
//读取设置
|
|
CString sGroup;
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
regProp.GetValue(KEY_LINE_GROUP_NO,sGroup); //线宽
|
|
if (!sGroup.IsEmpty())
|
|
{
|
|
m_wndEdtGroup.SetWindowText(sGroup);
|
|
}
|
|
else
|
|
m_wndEdtGroup.SetWindowText(_T("1"));
|
|
|
|
int npos = 0;
|
|
regProp.GetValue(_T("LINE_RADIUS"),npos);
|
|
m_cmbRadius.SetCurSel(npos);
|
|
CString sLineH;
|
|
regProp.GetValue(_T("LINE_HEIGHT"),sLineH);
|
|
m_wndEdtLineH.SetWindowText(sLineH);
|
|
}
|
|
|
|
void CThunderLineSetDlg::SaveDlgData()
|
|
{
|
|
//保存设置
|
|
CString sGroup;
|
|
m_wndEdtGroup.GetWindowText(sGroup);
|
|
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
regProp.SetValue(KEY_LINE_GROUP_NO,sGroup); //最后组号
|
|
int npos = m_cmbRadius.GetCurSel();
|
|
regProp.SetValue(_T("LINE_RADIUS"),npos);
|
|
CString sLineH;
|
|
m_wndEdtLineH.GetWindowText(sLineH);
|
|
regProp.SetValue(_T("LINE_HEIGHT"),sLineH);
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnClose()
|
|
{
|
|
CDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CThunderLineSetDlg::PostNcDestroy()
|
|
{
|
|
CDialog::PostNcDestroy();
|
|
}
|
|
void CThunderLineSetDlg::OnDestroy()
|
|
{
|
|
if(m_nUseType == eCreate)
|
|
{
|
|
SaveDlgData();
|
|
}
|
|
CDialog::OnDestroy();
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnBnClickedButton1()
|
|
{
|
|
UpdateData();
|
|
|
|
int nCnt = m_LstData.GetItemCount();
|
|
|
|
CString sTxt;
|
|
sTxt.Format(_T("%d"),nCnt + 1);
|
|
m_LstData.InsertItem(nCnt,sTxt);
|
|
|
|
double dH = _ttof(m_strPinHeight);
|
|
dH -= 1;
|
|
|
|
sTxt.Format(_T("%d"),(int)(dH));
|
|
m_LstData.SetItemText(nCnt,1,sTxt);
|
|
|
|
for (int i = 0;i < m_LstData.GetItemCount();i++)
|
|
{
|
|
sTxt.Format(_T("%d"),i + 1);
|
|
m_LstData.SetItemText(i,0,sTxt);
|
|
}
|
|
}
|
|
|
|
void CThunderLineSetDlg::OnBnClickedButton2()
|
|
{
|
|
POSITION ps = m_LstData.GetFirstSelectedItemPosition();
|
|
if (ps != NULL)
|
|
{
|
|
int nItem = m_LstData.GetNextSelectedItem(ps);
|
|
if (nItem != -1)
|
|
{
|
|
m_LstData.DeleteItem(nItem);
|
|
|
|
CString sTxt;
|
|
for (int i = 0;i < m_LstData.GetItemCount();i++)
|
|
{
|
|
sTxt.Format(_T("%d"),i + 1);
|
|
m_LstData.SetItemText(i,0,sTxt);
|
|
}
|
|
}
|
|
}
|
|
}
|