Files
envi-code/SourceCode/Code2026/ThunderProof/FoldLayPinDlg.cpp
T
2026-09-28 15:28:50 +08:00

1882 lines
40 KiB
C++

#include "stdafx.h"
#include "FoldLayPinDlg.h"
#include "LightningRodData.h"
#include "ThunderCaculate.h"
#include "dbxutil.h"
#include "dbgroup.h"
#include "GroupHelp.h"
#include "ThunderCmdGroup.h"
#include "CreateWordApp.h"
#include "TReactorAssociate.h"
#include "TThunderInsertPreviewJig.h"
#include "ktsetting.h"
#include <list>
#include <vector>
#include <algorithm>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CFoldLayPinDlg 对话框
IMPLEMENT_DYNAMIC(CFoldLayPinDlg, CDialog)
// 构造
CFoldLayPinDlg::CFoldLayPinDlg(const AcDbObjectId& entId, BOOL bIsModel, CWnd* pParent)
: CDialog(CFoldLayPinDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFoldLayPinDlg)
m_csTxtHight = _T("3.0");
m_csBlkScale = _T("1");
m_idThunder = entId;
m_bIsModel = bIsModel;
m_bTipChange = FALSE;
m_bValid = FALSE;
m_pDrawThunder = NULL;
m_pReactor = NULL;
m_pDrawThunder = NULL;
m_csGroupNo = _T("1");
//}}AFX_DATA_INIT
}
CFoldLayPinDlg::~CFoldLayPinDlg()
{
}
void CFoldLayPinDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFoldLayPinDlg)
DDX_Text(pDX, IDC_FOLD_EDT_GROUP_NO, m_csGroupNo);
DDX_Control(pDX, IDC_SPN_GROUP_NO, m_wndSpnGroupNo);
DDX_Control(pDX, IDC_BTN_GROUP_EXPLAIN, m_wndBtnGroupExp);
DDX_Control(pDX, IDC_EDT_NUM, m_wndEdtNumber);
DDX_Control(pDX, IDC_SPN_NUM, m_wndSpnNumber);
DDX_Text(pDX, IDC_EDT_TEXTHIGH, m_csTxtHight);
DDX_Control(pDX, IDC_SPN_TH, m_wndSpnHT);
DDX_Text(pDX, IDC_EDT_BLOCKSCALE, m_csBlkScale);
DDX_Text(pDX,IDC_EDT_HEIGHT,m_csPinHeight);
DDX_Control(pDX, IDC_EDT_HEIGHT, m_wndEdtHeight);
DDX_Control(pDX, IDC_BTN_THUNDER_HEIGHT_TIP, m_wndBtnTipExp);
DDX_Control(pDX, IDC_LST_SAFEHEIGHT, m_LstData);
DDX_Control(pDX, IDC_BTN_UPDATE, m_wndBtnUpdate);
DDX_Control(pDX, IDC_BTN_CANCEL, m_wndBtnCancel);
DDX_Control(pDX, IDC_STC_NUMCUE, m_wndStcNumCue);
DDX_Control(pDX, IDC_CHK_HILL_HILLSIDE, m_wndChkHillSile);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFoldLayPinDlg, CDialog)
//{{AFX_MSG_MAP(CFoldLayPinDlg)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
ON_BN_CLICKED(IDC_BTN_UPDATE, OnBtnUpdate)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
ON_EN_CHANGE(IDC_EDT_NUM, OnChangeEditNum)
ON_BN_CLICKED(IDC_BTN_THUNDER_HEIGHT_TIP, OnThunderHeightTip)
ON_EN_CHANGE(IDC_FOLD_EDT_GROUP_NO, OnChangeGroupNo)
ON_BN_CLICKED(IDC_BTN_GROUP_EXPLAIN, OnGroupExplain)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_CHK_HILL_HILLSIDE, OnBnClickedChkHillHillside)
ON_BN_CLICKED(IDC_BUTTON1, OnAddHeight)
ON_BN_CLICKED(IDC_BUTTON2, OnRemoveHeight)
END_MESSAGE_MAP()
// CFoldLayPinDlg 消息处理程序
// 初始化模式对话框
void CFoldLayPinDlg::InitModalDlg()
{
SetWindowText(_T("单针编辑(折线法)"));
if (!GetCurrentExData(m_idThunder))
return;
if (m_arsXData.GetSize() < 4) return;
// 编号,高度,图块系数, 字体高度
m_csPinHeight = m_arsXData.GetAt(CThunderXData::eXFoldPinHeight);
m_csBlkScale = m_arsXData.GetAt(CThunderXData::eXFoldBlockScale);
m_csTxtHight = m_arsXData.GetAt(CThunderXData::eXFoldTextHeight);
UpdateData(FALSE);
// 保护高度
CStringArray arProHt;
if (GetProtectHeightFromObj(m_idThunder, arProHt))
{
m_LstData.DeleteAllItems();
CString sValue;
long lRowIndex = 0;
for (int i = 0;i < arProHt.GetSize();++i)
{
if (!arProHt[i].IsEmpty())
{
lRowIndex = m_LstData.GetItemCount();
sValue.Format(_T("%d"),lRowIndex+1);
m_LstData.InsertItem(lRowIndex,sValue);
sValue = arProHt[i];
m_LstData.SetItemText(lRowIndex,1,sValue);
}
}
}
// 设置组名
CThunderXData thundXData;
CString sTemp;
thundXData.GetXData(m_idThunder, KEY_FOLD_GROUP_NO, sTemp);
SetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sTemp);
thundXData.GetXData(m_idThunder, TEL_ORDER_NUMBER, sTemp);
m_wndEdtNumber.SetWindowText(sTemp);
}
// 初始化非模式对话框
void CFoldLayPinDlg::InitModalessDlg()
{
ReadDlgData();
UpdateData(FALSE);
m_wndSpnNumber.SetPos(1);
m_wndSpnHT.SetPos(_ttoi(m_csTxtHight));
if (m_csPinHeight.IsEmpty())
{
m_wndEdtHeight.SetWindowText(_T("20"));
UpdateDlgData(TRUE);
}
m_wndRadShowType.SetCheck(1);
CString sGroundRadius,sThunderHeight,sProHeight;
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
regProp.GetValue(KEY_FOLD_LAST_GROUPNO,m_csGroupNo);
UpdateData(FALSE);
// 保护高度
CStringArray arProHt;
if (GetProtectHeightFromReg(arProHt))
{
m_LstData.DeleteAllItems();
CString sValue;
long lRowIndex = 0;
for (int i = 0;i < arProHt.GetSize();++i)
{
if (arProHt[i].IsEmpty())
{
continue;
}
lRowIndex = m_LstData.GetItemCount();
sValue.Format(_T("%d"), lRowIndex);
m_LstData.InsertItem(lRowIndex,sValue);
m_LstData.SetItemText(lRowIndex,1,arProHt[i]);
}
}
else // 增加默认
{
m_LstData.DeleteAllItems();
m_LstData.InsertItem(0,_T("1"));
m_LstData.SetItemText(0,1,_T("15"));
}
// 避雷针编号
AcGeIntArray arNum;
FoldManager->GetNumArrayBySpecGroup(_ttoi(m_csGroupNo),arNum);
if (arNum.length() > 0)
{
CString sNum;
sNum.Format(_T("%d"), arNum.last()+1);
m_wndEdtNumber.SetWindowText(sNum);
}
else
m_wndEdtNumber.SetWindowText(_T("1"));
}
BOOL CFoldLayPinDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_wndSpnNumber.SetRange32(SPNMIN,SPNMAX);
m_wndSpnGroupNo.SetRange32(SPNMIN,SPNMAX);
m_wndSpnHT.SetRange(0, 100);
UpdateData(FALSE);
DisplayOrHideBtn(m_bIsModel);
// 保护高度
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);
m_bValid = TRUE;
// 2012/3/19 for 支持山地坡地计算
int nCheck = -1;
CRegProperty reg(GetRegLocation(), _T("Thunder"));
reg.SetTopRootKey(HKEY_CURRENT_USER);
if (!reg.GetValue(KEY_FOLD_HILL_HILLSIDE, nCheck))
{
nCheck = 0;
}
m_wndChkHillSile.SetCheck(nCheck);
if (m_bIsModel)
{
InitModalDlg(); // 编辑(模式)
}
else
{
InitModalessDlg(); // 插入(非模式)
}
m_bitTip.LoadBitmap(IDB_BITMAPHELP);
m_wndBtnTipExp.SetBitmap(HBITMAP(m_bitTip));
m_wndBtnGroupExp.SetBitmap(HBITMAP(m_bitTip));
//CenterWindow();
return TRUE;
}
// 对话框的非模式形式
BOOL CFoldLayPinDlg::DoModeless()
{
if (!Create(IDD_FOLD_LAYPIN))
{
return FALSE;
}
ShowWindow(SW_SHOW);
return TRUE;
}
void CFoldLayPinDlg::OnAddHeight()
{
UpdateData();
int nCnt = m_LstData.GetItemCount();
CString sTxt;
sTxt.Format(_T("%d"),nCnt + 1);
m_LstData.InsertItem(nCnt,sTxt);
double dH = _ttof(m_csTxtHight);
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 CFoldLayPinDlg::OnRemoveHeight()
{
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);
}
}
}
}
HBRUSH CFoldLayPinDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (IDC_STC_NUMCUE == pWnd->GetDlgCtrlID())
{
if (m_bTipChange)
{
pDC->SetTextColor(RGB(255,0,0));
}
else
{
pDC->SetTextColor(RGB(0, 0, 0));
}
}
return hbr;
}
LONG_PTR CFoldLayPinDlg::OnAcadKeepFocus(UINT_PTR, LONG_PTR)
{
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
return (rc.PtInRect(pt) ? TRUE : FALSE);
}
void CFoldLayPinDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
}
void CFoldLayPinDlg::OnClose()
{
CDialog::OnClose();
acedPostCommand(_T("\33\33"));
}
void CFoldLayPinDlg::GetDlgProHT(AcGeDoubleArray& arProHTs)
{
// 保护高度arpro
arProHTs.setLogicalLength(0);
CString sValue;
for (long p = 0;p < m_LstData.GetItemCount();++p)
{
sValue = m_LstData.GetItemText(p,1);
if (!(_tstof(sValue) < -1e-6) && !sValue.IsEmpty())
{
arProHTs.append(_tstof(sValue));
}
}
}
// 获取用户填写对话框数据
BOOL CFoldLayPinDlg::GetDlgData(BOOL bIsUpdate)
{
if (!AssertProtectHeight())
{
return FALSE;
}
UpdateData();
// 首先输入的数据应合法
// 编号,高度
CString strHeight = _T(""),strProHeight = _T("");
CString strNum = _T(""), strRad = _T("");
CString strExRadius = _T("");
CString strTextHeight = _T(""),strBlockScale = _T("");
// 保护高度arpro
m_arProHeight.setLogicalLength(0);
CString sValue;
for (long p = 0;p < m_LstData.GetItemCount();++p)
{
sValue = m_LstData.GetItemText(p,1);
if (!(_tstof(sValue) < -1e-6) && !sValue.IsEmpty())
{
m_arProHeight.append(_tstof(sValue));
}
}
std::list<double> lstHT;
for (int s = 0;s < m_arProHeight.length();++s)
{
lstHT.push_back(m_arProHeight[s]);
}
lstHT.sort();
m_arProHeight.setLogicalLength(0);
std::list<double>::iterator it;
for (it = lstHT.begin();it != lstHT.end();++it)
{
m_arProHeight.append(*it);
}
m_wndEdtHeight.GetWindowText(strHeight);
// 避雷针高度应大于其保护高度
for (int i = 0;i < m_arProHeight.length();++i)
{
if (m_arProHeight[i] >= _tstof(strHeight))
{
AfxMessageBox(_T("避雷针高度应大于其保护高度!"));
return FALSE;
}
}
// 编号
m_wndEdtNumber.GetWindowText(strNum);
strRad = _T("1");
BOOL bIsRadiusChanged = FALSE;
BOOL bIsBlockScaleChanged = FALSE;
BOOL bIsTextHighChanged = FALSE;
CThunderXData thunderXData;
//如果是更新操作
if (bIsUpdate)
{
//注销对话框
CDialog::OnOK();
//判断字体高度是否改变
if (!thunderXData.GetIndexOf(m_idThunder, strTextHeight, CThunderXData::eXFoldTextHeight, TEL_THUNDER_BASEINFOR))
{
return FALSE;
}
if (m_csTxtHight != strTextHeight && bIsUpdate)
{
bIsTextHighChanged = TRUE;
}
//判断图块系数是否改变
if (!thunderXData.GetIndexOf(m_idThunder, strBlockScale, CThunderXData::eXFoldBlockScale, TEL_THUNDER_BASEINFOR))
{
return FALSE;
}
if (m_csBlkScale != strBlockScale && bIsUpdate)
{
bIsBlockScaleChanged = TRUE;
}
}
AcDbObjectId idRef = AcDbObjectId::kNull;
if (bIsUpdate)
{
idRef = m_idThunder;
}
else
{
AcDbObjectIdArray arIDThun;
ThunderContainer->GetGroupThunder(m_csGroupNo, arIDThun);
if (arIDThun.length() > 0)
{
idRef = arIDThun.first();
}
}
//用户选择"字高"和"图块"系数的更新方式
if (bIsTextHighChanged || bIsBlockScaleChanged)
{
CString sChose = _T("");
if (bIsTextHighChanged && !bIsBlockScaleChanged)
{
sChose.Format(_T("发现字体高度修改,请选择:\n")
_T("是:将所有字体高度%s替换为%s\n")
_T("否:将当前字体高度%s替换为%s\n")
_T("取消:放弃这次操作"),strTextHeight,m_csTxtHight,strTextHeight,m_csTxtHight);
m_eUs = UpdateAllTH;
}
else if (!bIsTextHighChanged && bIsBlockScaleChanged)
{
sChose.Format(_T("发现图块系数修改,请选择:\n")
_T("是:将所有图块系数%s替换为%s\n")
_T("否:将当前图块系数%s替换为%s\n")
_T("取消:放弃这次操作"),strBlockScale,m_csBlkScale,strBlockScale,m_csBlkScale);
m_eUs = UpdateAllSc;
}
else
{
sChose.Format(_T("发现字体高度和图块系数修改,请选择:\n")
_T("是:将所有字体高度%s和图块系数%s替换为%s和%s\n")
_T("否:将当前字体高度%s和图块系数%s替换为%s和%s\n")
_T("取消:放弃这次操作"),
strTextHeight,strBlockScale,m_csTxtHight,m_csBlkScale,
strTextHeight,strBlockScale,m_csTxtHight,m_csBlkScale);
m_eUs = UpdateAllTHAndSc;
}
int iRet = 0;
iRet = AfxMessageBox(sChose,MB_YESNOCANCEL);
if (iRet == IDNO)
{
int st = m_eUs;
st++;
m_eUs = (UpdateStyle)st;
}
else if (iRet == IDCANCEL)
{
m_eUs = UpdateNone;
}
}
m_arsXData.RemoveAll();
// 编号
m_arsXData.Add(strNum);
// 针高度
m_arsXData.Add(strHeight);
//图块系数
m_arsXData.Add(m_csBlkScale);
//字体高度
m_arsXData.Add(m_csTxtHight);
return TRUE;
}
void CFoldLayPinDlg::PostErrorToCue(CString& strError)
{
m_wndStcNumCue.SetWindowText(strError);
}
BOOL CFoldLayPinDlg::AssertProtectHeight(BOOL bBoxTip)
{
CString sPinHt;
GetDlgItemText(IDC_EDT_HEIGHT, sPinHt);
CString sValue;
AcGeDoubleArray arProHt;
for (long i = 0;i < m_LstData.GetItemCount();++i)
{
sValue = m_LstData.GetItemText(i,1);
if (_tstof(sPinHt) <= _tstof(sValue)) // 针高应大于保护高度
{
if (bBoxTip)
{
AfxMessageBox(_T("避雷针高度应大于其保护高度!"));
}
return FALSE;
}
if (!sValue.IsEmpty())
{
arProHt.append(_tstof(sValue));
}
}
// 判断保护高度是否存在重复值
double dT1,dT2;
for (int c = 0;c < arProHt.length();++c)
{
dT1 = arProHt[c];
for (int c2 = c+1;c2 < arProHt.length();++c2)
{
dT2 = arProHt[c2];
if (fabs(dT1 - dT2) < 1e-3)
{
if (bBoxTip)
{
sValue.Format(_T("%.2f"), dT2);
sValue = TrimDoubleString(sValue);
CString sTip;
sTip.Format(_T("保护高度值%s重复!"), sValue);
AfxMessageBox(sTip);
}
return FALSE;
}
}
}
return TRUE;
}
// 更新数据
void CFoldLayPinDlg::OnBtnUpdate()
{
CThunderCmdGroup::bReDrawFold = FALSE;
if (!AssertProtectHeight())
{
return;
}
TReactorAssociate temp(acdbCurDwg(), m_pReactor);
CString sGroundRadius = _T("");
// CString strRadius = m_arsXData.GetAt(CThunderXData::eXDataPinRadius);
CString sValue;
CStringArray arProHt;
for (long i = 0;i < m_LstData.GetItemCount();++i)
{
sValue = m_LstData.GetItemText(i,1);
if (!sValue.IsEmpty())
{
arProHt.Add(sValue);
}
}
BOOL bChange = FALSE;
CStringArray arsProHt;
GetProtectHeightFromObj(m_idThunder, arsProHt);
if (arsProHt.GetSize() == arProHt.GetSize())
{
for (int j = 0;j < arsProHt.GetSize();++j)
{
if (fabs(_tstof(arsProHt[j]) - _tstof(arProHt[j])) > 1e-3)
{
bChange = TRUE;
break;
}
}
}
else
{
bChange = TRUE;
}
if (m_arsXData.GetSize() < 4) return;
// 获取对话框数据
if (!GetDlgData(TRUE))
{
return;
}
//更新标注
CString strText;
CThunderXData xd;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, strText);
strText += _T("g,");
strText += m_arsXData.GetAt(CThunderXData::eXFoldPinNum);
ads_name entThunder;
acdbGetAdsName(entThunder,m_idThunder);
Entity entBlock(entThunder);
strText += _T("#,h=");
CString sPinHeight = m_arsXData.GetAt(CThunderXData::eXFoldPinHeight);
strText += sPinHeight;
strText += _T("m");
double dTestHeight = _tstof(m_csTxtHight);
SetBlkAttrText(entBlock, strText, _T("$TEXT$"), dTestHeight, TRUE, TRUE);
//修改字高和缩放比例
UpdateTHAndBkSc(m_eUs);
//保存设置
UpdateDlgData(TRUE);
SetCurrentExData(m_idThunder);
// 设置避雷针组号
CThunderXData thundXData;
CString sGroupNo,sOldGroupNo;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sGroupNo);
thundXData.GetXData(m_idThunder, KEY_FOLD_GROUP_NO, sOldGroupNo);
CString sNum;
GetDlgItemText(IDC_EDT_NUM, sNum);
thundXData.SetXData(m_idThunder, TEL_ORDER_NUMBER, sNum);
AcGeDoubleArray arPro;
for (int t = 0;t < arProHt.GetSize();++t)
{
arPro.append(_tstof(arProHt[t]));
}
if (_tstof(sGroupNo) != _tstof(sOldGroupNo))
{
//原组号重新生成
FoldManager->ShowUnionPro2d(m_idThunder,TRUE);
// 改变组号
thundXData.SetXData(m_idThunder, KEY_FOLD_GROUP_NO, sGroupNo);
}
//修改标高扩展数据
thundXData.SetFoldProHeightToObjEx(m_idThunder,arPro);
//更新避雷针映射数据
FoldManager->UpdateFoldPinInMap(_ttoi(sOldGroupNo),m_idThunder);
FoldManager->ShowUnionPro2d(m_idThunder);
CThunderCmdGroup::bExecute = TRUE;
}
void CFoldLayPinDlg::OnBtnCancel()
{
CDialog::OnCancel();
acedPostCommand(_T("\33\33"));
}
// 显示或隐藏控件
void CFoldLayPinDlg::DisplayOrHideBtn(BOOL bIsHide)
{
if (bIsHide)
{
// 显示更新按钮
m_wndBtnUpdate.ShowWindow(SW_SHOW);
m_wndBtnCancel.ShowWindow(SW_SHOW);
m_wndStcNumCue.ShowWindow(SW_HIDE);
}
else
{
// 显示编辑框提示
m_wndBtnUpdate.ShowWindow(SW_HIDE);
m_wndBtnCancel.ShowWindow(SW_HIDE);
m_wndStcNumCue.ShowWindow(SW_SHOW);
}
}
void CFoldLayPinDlg::OnChangeEditNum()
{
if (!m_bValid)
{
return;
}
CString sCurNo,sOldGNo,strTip;
m_wndEdtNumber.GetWindowText(sCurNo);
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sOldGNo);
if (_ttoi(sCurNo) < 1)
{
strTip.Format(_T("编号最小为1"));
m_bTipChange = TRUE;
PostErrorToCue(strTip);
return;
}
BOOL bValid = FALSE;
AcGeIntArray arNum;
FoldManager->GetNumArrayBySpecGroup(_ttoi(sOldGNo), arNum);
// 排除自身:当编辑时不提示自身编号已重复
if (m_bIsModel)
{
CString sNum,sGroupNo;
CThunderXData xd;
xd.GetXData(m_idThunder, TEL_ORDER_NUMBER, sNum);
xd.GetXData(m_idThunder, KEY_FOLD_GROUP_NO, sGroupNo);
// 统计是否存在多个重复编号
int nCount = 0;
for (int i = 0;i < arNum.length();++i)
{
if (arNum[i] == _ttoi(sNum))
{
nCount++;
}
}
if (nCount > 1)
{
int nPos;
if (!arNum.find(_ttoi(sCurNo),nPos))
{
bValid = TRUE;
}
}
else if (_ttoi(sNum) == _ttoi(sCurNo) &&
_ttoi(sOldGNo) == _ttoi(sGroupNo) )
{
bValid = TRUE;
}
else
{
int nPos;
if (!arNum.find(_ttoi(sCurNo),nPos))
{
bValid = TRUE;
}
}
}
else
{
int nPos;
if (!arNum.find(_ttoi(sCurNo),nPos))
{
bValid = TRUE;
}
}
if (!bValid)
{
// 提示错误(显示错误提示 + 隐藏更新和取消按钮)
strTip.Format(_T("组%s中编号%s已存在"), sOldGNo,sCurNo);
m_bTipChange = TRUE;
PostErrorToCue(strTip);
if (m_bIsModel)
{
DisplayOrHideBtn(FALSE);
}
}
else
{
// 清除错误提示(显示更新和取消按钮 + 隐藏错误提示)
strTip.Format(_T("组%s中编号%s可以使用"), sOldGNo,sCurNo);
m_bTipChange = FALSE;
PostErrorToCue(strTip);
if (m_bIsModel)
{
DisplayOrHideBtn(TRUE);
}
}
}
// 添加扩展数据
BOOL CFoldLayPinDlg::SetCurrentExData(const AcDbObjectId& idEnt)
{
// 设置扩展数据
CThunderXData thundXData;
if (!thundXData.SetBaseInformationExData(idEnt, m_arsXData, TEL_THUNDER_BASEINFOR))
{
return FALSE;
}
return TRUE;
}
// 读取扩展数据
BOOL CFoldLayPinDlg::GetCurrentExData(const AcDbObjectId& idEnt)
{
CThunderXData thundXData;
m_arsXData.RemoveAll();
m_arProHeight.setLogicalLength(0);
if (thundXData.GetBaseInformationExData(idEnt, m_arsXData, TEL_THUNDER_BASEINFOR) &&
thundXData.GetFoldProHeightFromObjEx(idEnt, m_arProHeight))
{
return TRUE;
}
return FALSE;
}
// 二维显示
void CFoldLayPinDlg::OnLayer2d()
{
if (!m_bIsModel)
{
TCurDocumentLock lockDoc;
if (m_pDrawThunder != NULL)
{
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
}
acedPostCommand(_T("\33\33"));
}
}
// 三维显示
void CFoldLayPinDlg::OnLayer3d()
{
if (!m_bIsModel)
{
TCurDocumentLock lockDoc;
if (m_pDrawThunder != NULL)
{
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_2D, FALSE);
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_3D, TRUE);
}
acedPostCommand(_T("\33\33"));
}
}
//获取组号
CString CFoldLayPinDlg::GetGroupNo()
{
CString sGroupNo;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sGroupNo);
return sGroupNo;
}
//获取编号
CString CFoldLayPinDlg::GetNo()
{
CString sNum;
GetDlgItemText(IDC_EDT_NUM, sNum);
return sNum;
}
void CFoldLayPinDlg::SetNo(LPCTSTR pszNo)
{
if (pszNo == NULL)
{
return;
}
m_wndEdtNumber.SetWindowText(pszNo);
}
//获取针高
CString CFoldLayPinDlg::GetPinHeight()
{
CString sHeight;
GetDlgItemText(IDC_EDT_HEIGHT,sHeight);
return sHeight;
}
double CFoldLayPinDlg::GetTextHeight()
{
return _tstof(m_csTxtHight);
}
// 插入避雷针
BOOL CFoldLayPinDlg::InsertFoldThunder(AcDbObjectId& idEnt,const AcGePoint3d& ptIns)
{
CString sGroupNo;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sGroupNo);
if (_ttoi(sGroupNo) < 1)
{
AfxMessageBox(_T("避雷针组号应大于0!"));
return TRUE;
}
CString sNum;
GetDlgItemText(IDC_EDT_NUM, sNum);
if (_ttoi(sNum) < 1)
{
AfxMessageBox(_T("避雷针编号应大于0!"));
return TRUE;
}
if (!GetDlgData())
{
return TRUE;
}
KTSetting::InitLayer(LAY_EL_THUNDER);
XPushVarStr cLayer(_T("CLAYER"), LAY_EL_THUNDER);
XPushVar<int> vOsMode(_T("OSMODE"), 0);
int dBlockScale = 0;
dBlockScale = _ttoi(m_csBlkScale);
if (dBlockScale == 0)
{
dBlockScale = 1;
}
XPoint xp(Wcs2Ucs(ptIns));
SHads_command(RTSTR, _T(".INSERT"), RTSTR, m_sBlkName, RT3DPOINT, &xp,
RTREAL, dBlockScale*10*DocGetPScale(), RTREAL, dBlockScale*10*DocGetPScale(), RTREAL,0.0, RTNONE);
Entity entLast;
entLast.GetLast();
acdbGetObjectId(idEnt, entLast);
CString strText;
strText += m_arsXData.GetAt(CThunderXData::eXFoldPinNum);
CString sPinHeight = m_arsXData.GetAt(CThunderXData::eXFoldPinHeight);
strText += _T("#,h=");
strText += sPinHeight;
strText += _T("m");
double dTextHeight = _tstof(m_csTxtHight);
SetBlkAttrText(entLast, strText, _T("$TEXT$"), dTextHeight, TRUE, TRUE);
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);
//设置保护高度
thundXData.SetFoldProHeightToObjEx(idEnt,m_arProHeight);
//记录保护高度设置到注册表,保持记忆
thundXData.SetProtectHeightToReg(m_arProHeight,KEY_FOLD_THUNDER_MULTIPROHT);
//设置折线法标志
thundXData.SetXData(idEnt,TEL_THUNDER_TYPE,_T("1"));
// 新插入的避雷针入库
FoldManager->AddFoldPinToMap(idEnt);
// //显示保护圆
// FoldManager->ShowProCircle(idEnt);
//显示2维联合范围
FoldManager->ShowUnionPro2d(idEnt);
CString sNO;
sNO.Format(_T("%d"), _ttoi(sNum)+1);
m_wndEdtNumber.SetWindowText(sNO);
acedUpdateDisplay();
actrTransactionManager->flushGraphics();
return TRUE;
}
void CFoldLayPinDlg::GetCurrentData(CStringArray& arData)
{
CString sTemp;
m_arsXData.RemoveAll();
// 编号
GetDlgItemText(IDC_EDT_NUM, sTemp);
m_arsXData.Add(sTemp);
// 针高度
GetDlgItemText(IDC_EDT_HEIGHT, sTemp);
m_arsXData.Add(sTemp);
//图块系数
GetDlgItemText(IDC_EDT_BLOCKSCALE, sTemp);
m_arsXData.Add(sTemp);
//字体高度
GetDlgItemText(IDC_EDT_HEIGHT, sTemp);
m_arsXData.Add(sTemp);
m_arProHeight.setLogicalLength(0);
CString sValue;
for (long p = 0;p < m_LstData.GetItemCount();++p)
{
sValue = m_LstData.GetItemText(p,1);
if (!(_tstof(sValue) < -1e-6) && !sValue.IsEmpty())
{
m_arProHeight.append(_tstof(sValue));
}
}
arData.RemoveAll();
arData.Append(m_arsXData);
}
// 将圆和避雷针生成组并添加到有名对象字典的组字典中
AcDbObjectId CFoldLayPinDlg::AddCurGroup(const AcDbObjectIdArray& arIds, LPCTSTR pszGroupName)
{
AcDbObjectId idGroup = AcDbObjectId::kNull;
return idGroup;
if (pszGroupName == NULL || arIds.length() < 1)
{
return idGroup;
}
// 将组添加到有名对象字典的组字典中
AcDbDictionary* pGroupDict = NULL;
acdbHostApplicationServices()->workingDatabase()->getGroupDictionary(pGroupDict, AcDb::kForWrite);
if (pGroupDict != NULL)
{
if (pGroupDict->has(pszGroupName))
{
AcDbGroup* pGroup = NULL;
pGroupDict->getAt(pszGroupName, (AcDbObject*&)pGroup, AcDb::kForWrite);
if (pGroup != NULL)
{
pGroup->clear();
pGroup->append(arIds);
pGroup->close();
}
pGroupDict->close();
}
else
{
AcDbGroup* pGroup = new AcDbGroup((TCHAR*)pszGroupName, true);
pGroup->append(arIds);
pGroupDict->setAt(pszGroupName, pGroup, idGroup);
pGroupDict->close();
pGroup->close();
}
}
return idGroup;
}
// 设置绘画指针
void CFoldLayPinDlg::SetThunderDraw2d(CDrawThunderTools* pThundDraw)
{
m_pDrawThunder = pThundDraw;
}
void CFoldLayPinDlg::UpdateDlgData(BOOL ReadOrWrite)
{
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
if (ReadOrWrite)
{
//读设置
regProp.GetValue(KEY_THUNDERPINHEIGHT,m_csPinHeight);
regProp.GetValue(KEY_THUNDERSCALE,m_csBlkScale);
regProp.GetValue(KEY_TEXTHIGHT,m_csTxtHight);
}
else
{
//写设置
regProp.SetValue(KEY_THUNDERPINHEIGHT,m_csPinHeight);
regProp.SetValue(KEY_THUNDERSCALE,m_csBlkScale);
regProp.SetValue(KEY_TEXTHIGHT,m_csTxtHight);
}
}
void CFoldLayPinDlg::OnThunderHeightTip()
{
CString sTip;
sTip = _T("1、独立避雷针的针高\n2、若非独立避雷针时,一种为避雷针有效高度加上被保护建筑物的高度;一种\n为针高加上到建筑物被保护平面部分的距离;");
AfxMessageBox(sTip,MB_OK,MB_ICONINFORMATION);
}
void CFoldLayPinDlg::UpdateTHAndBkSc(UpdateStyle us)
{
AcDbObjectIdArray arcIds;
switch(us)
{
case UpdateAllTH:
{
//更新所有字高
UpdateTextHeight();
break;
}
case UpdateCurTH:
{
// 更新当前字高
UpdateTextHeight(FALSE);
break;
}
case UpdateAllSc:
{
// 更新所有图块系数
UpdateBlkScale();
break;
}
case UpdateCurSc:
{
//更新当前图块系数
UpdateBlkScale(FALSE);
break;
}
case UpdateAllTHAndSc:
{
//更新所有 字高 和 图块系数
UpdateTextHeight();
UpdateBlkScale();
break;
}
case UpdateCurTHAndSc:
{
//更新当前字高 和 图块系数
UpdateTextHeight(FALSE);
UpdateBlkScale(FALSE);
break;
}
case UpdateNone:
{
//不做更新
break;
}
}
}
void CFoldLayPinDlg::GetAllInsert(AcDbObjectIdArray& arcId)
{
arcId.setLogicalLength(0);
TContainerSingleton::LstGroupIDMap::iterator itMap;
TContainerSingleton::LstIDData::iterator itLst;
TContainerSingleton::LstGroupIDMap mapData;
ThunderContainer->GetThunderMap(mapData);
for (itMap = mapData.begin();itMap != mapData.end();++itMap)
{
for (itLst = itMap->second.begin();itLst != itMap->second.end();++itLst)
{
arcId.append(*itLst);
}
}
}
void CFoldLayPinDlg::UpdateTextHeight(BOOL IsUpdataAll)
{
AcDbObjectIdArray arcIds;
arcIds.append(m_idThunder);
if (IsUpdataAll)
{
GetAllInsert(arcIds);
}
int iCount = 0;
iCount = arcIds.length();
ads_name entThunder;
CThunderXData thundXData;
CString strBlkTest = _T("");
double dTextHeight = _tstof(m_csTxtHight);
for (int i = 0;i < iCount; ++i)
{
acdbGetAdsName(entThunder,arcIds[i]);
Entity entBlock(entThunder);
GetBlkAttrText(arcIds[i],_T("$TEXT$"),strBlkTest);
//设置字体高度
SetBlkAttrText(entBlock,strBlkTest,_T("$TEXT$"),dTextHeight,TRUE,TRUE);
}
ModifyTHChanged(arcIds);
}
void CFoldLayPinDlg::UpdateBlkScale(BOOL IsUpdataAll)
{
AcDbObjectIdArray arcIds;
arcIds.append(m_idThunder);
if (IsUpdataAll)
{
GetAllInsert(arcIds);
}
double dBkScale = _tstof(m_csBlkScale);
AcGeScale3d tmpSc;
CThunderXData thundXData;
AcDbObject* pObj = NULL;
AcDbBlockReference* pRef = NULL;
AcGePoint3d ptAttrPos;
AcGePoint3d ptBlkPos;
for (int i = 0; i< arcIds.length();++i)
{
if (acdbOpenObject(pObj,arcIds[i],AcDb::kForRead) == Acad::eOk)
{
pRef = AcDbBlockReference::cast(pObj);
if (pRef != NULL)
{
CString Scale;
thundXData.GetIndexOf(arcIds[i],Scale,CThunderXData::eXFoldBlockScale,TEL_THUNDER_BASEINFOR);
double dOldScale = _tstof(Scale);
if (dOldScale < 1.0E-8)
{
dOldScale = 1;
}
//设置图块的缩放系数
tmpSc = pRef->scaleFactors();
tmpSc *= dBkScale/dOldScale;
pRef->upgradeOpen();
pRef->setScaleFactors(tmpSc);
pRef->downgradeOpen();
GetBlkAttrPos(arcIds[i],_T("$TEXT$"),ptAttrPos);
ptBlkPos = pRef->position();
AcGeVector3d pmVector;
if (dBkScale/dOldScale > 1)
{
pmVector = ptAttrPos - ptBlkPos;
pmVector *= (sqrt(dBkScale/dOldScale) - 1);
}
else
{
pmVector = ptBlkPos - ptAttrPos;
pmVector *= (1 - sqrt(dBkScale/dOldScale));
}
ptAttrPos += pmVector;
//调整属性字插入点
SetAttrPos(pRef,_T("$TEXT$"),ptAttrPos);
}
pObj->close();
}
//调整属性字插入点
CString sAttrText = _T("");
GetBlkAttrText(arcIds[i],_T("$TEXT$"),sAttrText);
ads_name Blkname;
acdbGetAdsName(Blkname,arcIds[i]);
Entity ent(Blkname);
double dTextHeight = _tstof(m_csTxtHight);
if (dTextHeight < 1.0E-8)
{
dTextHeight = 1;
}
SetBlkAttrText(ent,sAttrText,_T("$TEXT$"),dTextHeight,TRUE,TRUE);
}
ModifyBlkScaleChanged(arcIds);
}
void CFoldLayPinDlg::GetBlkAttrText(AcDbObjectId oid,LPCTSTR pszTag,CString& strBlkTest)
{
AcDbAttribute* pAttr = NULL;
AcDbObjectId attrid;
AcDbObject* pObj = NULL;
AcDbBlockReference* pRef = NULL;
if (acdbOpenObject(pObj,oid,AcDb::kForRead) == Acad::eOk)
{
pRef = AcDbBlockReference::cast(pObj);
if (pRef != NULL)
{
AcDbObjectIterator* pIter = NULL;
pIter = pRef->attributeIterator();
if (pIter != NULL)
{
AcDbEntity* pEnt = NULL;
for (pIter->start();!pIter->done();pIter->step())
{
attrid = pIter->objectId();
if (acdbOpenAcDbEntity(pEnt,attrid,AcDb::kForWrite) == Acad::eOk)
{
pAttr = AcDbAttribute::cast(pEnt);
if (pAttr != NULL)
{
CString sTag = pAttr->tag();
if (_tcsicmp(sTag,pszTag) == 0)
{
strBlkTest = pAttr->textString();
}
}
pEnt->close();
pAttr = NULL;
}
}
delete pIter;
pIter = NULL;
}
}
pObj->close();
pRef = NULL;
}
}
void CFoldLayPinDlg::GetBlkAttrPos(AcDbObjectId oid,LPCTSTR pszTag,AcGePoint3d& ptPos)
{
AcDbAttribute* pAttr = NULL;
AcDbObjectId attrid;
AcDbObject* pObj = NULL;
AcDbBlockReference* pRef = NULL;
if (acdbOpenObject(pObj,oid,AcDb::kForRead) == Acad::eOk)
{
pRef = AcDbBlockReference::cast(pObj);
if (pRef != NULL)
{
AcDbObjectIterator* pIter = NULL;
pIter = pRef->attributeIterator();
if (pIter != NULL)
{
AcDbEntity* pEnt = NULL;
for (pIter->start();!pIter->done();pIter->step())
{
attrid = pIter->objectId();
if (acdbOpenAcDbEntity(pEnt,attrid,AcDb::kForRead) == Acad::eOk)
{
pAttr = AcDbAttribute::cast(pEnt);
if (pAttr != NULL)
{
CString sTag = pAttr->tag();
if (_tcsicmp(sTag,pszTag) == 0)
{
ptPos = pAttr->position();
}
}
pEnt->close();
pAttr = NULL;
}
}
delete pIter;
pIter = NULL;
}
}
pObj->close();
pRef = NULL;
}
}
//修改扩展数据-字体高度
void CFoldLayPinDlg::ModifyTHChanged(const AcDbObjectIdArray& arcIds)
{
CThunderXData thundXData;
CStringArray strAttrs;
CString strPinNum,strPinHeight,strPinRadius,strPinIs2d,strBlkScale;
AcDbObjectId IdEnt;
for (int i = 0; i < arcIds.length(); ++i)
{
IdEnt = arcIds[i];
thundXData.GetIndexOf(IdEnt,strPinNum,CThunderXData::eXFoldPinNum,TEL_THUNDER_BASEINFOR);
thundXData.GetIndexOf(IdEnt,strPinHeight,CThunderXData::eXFoldPinHeight,TEL_THUNDER_BASEINFOR);
// thundXData.GetIndexOf(IdEnt,strPinRadius,CThunderXData::eXDataPinRadius,TEL_THUNDER_BASEINFOR);
// thundXData.GetIndexOf(IdEnt,strPinIs2d,CThunderXData::eXDataPinIs2d,TEL_THUNDER_BASEINFOR);
thundXData.GetIndexOf(IdEnt,strBlkScale,CThunderXData::eXFoldBlockScale,TEL_THUNDER_BASEINFOR);
strAttrs.Add(strPinNum);
strAttrs.Add(strPinHeight);
// strAttrs.Add(strPinRadius);
// strAttrs.Add(strPinIs2d);
strAttrs.Add(strBlkScale);
strAttrs.Add(m_csTxtHight);
thundXData.SetBaseInformationExData(IdEnt,strAttrs,TEL_THUNDER_BASEINFOR);
}
}
//修改扩展数据- 图块系数
void CFoldLayPinDlg::ModifyBlkScaleChanged(const AcDbObjectIdArray& arcIds)
{
CThunderXData thundXData;
CStringArray strAttrs;
CString strPinNum,strPinHeight,strPinRadius,strPinIs2d,strTextHigh;
AcDbObjectId IdEnt;
for (int i = 0; i < arcIds.length(); ++i)
{
IdEnt = arcIds[i];
thundXData.GetIndexOf(IdEnt,strPinNum,CThunderXData::eXFoldPinNum,TEL_THUNDER_BASEINFOR);
thundXData.GetIndexOf(IdEnt,strPinHeight,CThunderXData::eXFoldPinHeight,TEL_THUNDER_BASEINFOR);
// thundXData.GetIndexOf(IdEnt,strPinRadius,CThunderXData::eXDataPinRadius,TEL_THUNDER_BASEINFOR);
// thundXData.GetIndexOf(IdEnt,strPinIs2d,CThunderXData::eXDataPinIs2d,TEL_THUNDER_BASEINFOR);
thundXData.GetIndexOf(IdEnt,strTextHigh,CThunderXData::eXFoldTextHeight,TEL_THUNDER_BASEINFOR);
strAttrs.Add(strPinNum);
strAttrs.Add(strPinHeight);
// strAttrs.Add(strPinRadius);
// strAttrs.Add(strPinIs2d);
strAttrs.Add(m_csBlkScale);
strAttrs.Add(strTextHigh);
thundXData.SetBaseInformationExData(IdEnt,strAttrs,TEL_THUNDER_BASEINFOR);
}
}
Acad::ErrorStatus CFoldLayPinDlg::SetAttrPos(AcDbBlockReference* pRef,LPCTSTR pszTag,const AcGePoint3d& pt)
{
Acad::ErrorStatus us = Acad::eOk;
if (pRef != NULL && pszTag != NULL)
{
Acad::ErrorStatus es = pRef->upgradeOpen();
if (pRef->isWriteEnabled())
{
AcDbAttribute* pAttr = NULL;
AcDbObjectId attrid;
AcDbObjectIterator* pIter = NULL;
pIter = pRef->attributeIterator();
if (pIter != NULL)
{
AcDbEntity* pEnt = NULL;
for (pIter->start();!pIter->done();pIter->step())
{
attrid = pIter->objectId();
if (acdbOpenAcDbEntity(pEnt,attrid,AcDb::kForWrite) == Acad::eOk)
{
pAttr = AcDbAttribute::cast(pEnt);
if (pAttr != NULL)
{
CString sTag = pAttr->tag();
if (_tcsicmp(sTag,pszTag) == 0)
{
AcGePoint3d ptPos = pAttr->position();
AcGeVector3d v = pt - ptPos;
AcGeMatrix3d mat;
mat.setToTranslation(v);
pAttr->transformBy(mat);
}
}
pEnt->close();
pAttr = NULL;
}
}
delete pIter;
pIter = NULL;
}
}
pRef->downgradeOpen();
}
return us;
}
// 避雷针保护高度
BOOL CFoldLayPinDlg::GetProtectHeightFromReg(CStringArray& arProHeight)
{
arProHeight.RemoveAll();
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
CString sProHt;
if (regProp.GetValue(KEY_FOLD_THUNDER_MULTIPROHT, sProHt))
{
if (SplitValue(sProHt, TEL_SPLIT_CH, arProHeight))
{
// 排序
std::map<double,CString> mapData;
for (int i = 0;i < arProHeight.GetSize();++i)
{
mapData.insert(std::make_pair(_tstof(arProHeight[i]),arProHeight[i]));
}
arProHeight.RemoveAll();
std::map<double,CString>::iterator it;
for (it = mapData.begin();it != mapData.end();++it)
{
arProHeight.Add(it->second);
}
return TRUE;
}
}
return FALSE;
}
BOOL CFoldLayPinDlg::SetProtectHeightToReg(const CStringArray& arProHeight)
{
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
CString sProHt = ConvertToCString(arProHeight, TEL_SPLIT_CH);
if (regProp.SetValue(KEY_FOLD_THUNDER_MULTIPROHT, sProHt))
{
return TRUE;
}
return FALSE;
}
BOOL CFoldLayPinDlg::GetProtectHeightFromObj(const AcDbObjectId& idThunder, CStringArray& arProHeight)
{
arProHeight.RemoveAll();
CThunderXData thundXData;
CString sValue;
if (thundXData.GetXData(idThunder, KEY_FOLD_THUNDER_MULTIPROHT, sValue))
{
if (SplitValue(sValue, TEL_SPLIT_CH, arProHeight))
{
// 排序
std::map<double,CString> mapData;
for (int i = 0;i < arProHeight.GetSize();++i)
{
mapData.insert(std::make_pair(_tstof(arProHeight[i]),arProHeight[i]));
}
arProHeight.RemoveAll();
std::map<double,CString>::iterator it;
for (it = mapData.begin();it != mapData.end();++it)
{
arProHeight.Add(it->second);
}
return TRUE;
}
}
return FALSE;
}
BOOL CFoldLayPinDlg::SetProtectHeightToObj(LPCTSTR pszGNo, const CStringArray& arProHeight)
{
AcDbObjectIdArray arID;
ThunderContainer->GetGroupThunder(pszGNo, arID);
if (arID.length() < 1)
{
return FALSE;
}
AcGeDoubleArray arPHeight;
for (int j = 0;j < arProHeight.GetSize();++j)
{
arPHeight.append(_tstof(arProHeight[j]));
}
CThunderXData thundXData;
for (int i = 0;i < arID.length();++i)
{
thundXData.SetFoldProHeightToObjEx(arID[i], arPHeight);
}
return TRUE;
}
BOOL CFoldLayPinDlg::SplitValue(LPCTSTR pszSrc, LPCTSTR pszSplitCh, CStringArray& arValue)
{
arValue.RemoveAll();
CString sValue;
CString sSrc = pszSrc;
while (SplitString(sSrc, pszSplitCh, sValue))
{
sValue = TrimDoubleString(sValue);
arValue.Add(sValue);
}
return arValue.GetSize() > 0;
}
CString CFoldLayPinDlg::ConvertToCString(const CStringArray& arValue, LPCTSTR pszSplitCh)
{
CString sData;
for (int i = 0;i < arValue.GetSize();++i)
{
sData += arValue[i];
sData += pszSplitCh;
}
return sData;
}
BOOL CFoldLayPinDlg::SplitString(CString& sSrc, LPCTSTR pszSplitCh, CString& sValue)
{
if (!sSrc.IsEmpty())
{
int nIndex = sSrc.Find(pszSplitCh, 0);
if (nIndex > 0)
{
sValue = sSrc.Left(nIndex);
sSrc = sSrc.Right(sSrc.GetLength()-nIndex-1);
return TRUE;
}
}
return FALSE;
}
CString CFoldLayPinDlg::TrimDoubleString(LPCTSTR pszSrc)
{
CString sSrc = pszSrc;
sSrc.TrimLeft();
sSrc.TrimRight();
if (sSrc.Find(_T("."), 0) >= 0)
{
sSrc.TrimRight(_T("0"));
sSrc.TrimRight(_T("."));
}
return sSrc;
}
void CFoldLayPinDlg::UpdateThunderByProtectHeight()
{
return;
acedGetAcadFrame()->SetFocus();
if (!AssertProtectHeight())
{
return;
}
if (!GetDlgData())
{
return;
}
CString sGroupNo;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sGroupNo);
CString sValue;
AcGeDoubleArray arProHeight;
for (long i = 0;i < m_LstData.GetItemCount();++i)
{
sValue = m_LstData.GetItemText(i,1);
if (!sValue.IsEmpty() && _tstof(sValue) > 0)
{
arProHeight.append(_tstof(sValue));
}
}
TReactorAssociate rctAct(acdbCurDwg(), m_pReactor);
m_pDrawThunder->DrawThunder2DArea(arProHeight,sGroupNo);
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_2D, TRUE);
m_pDrawThunder->ShowLayer(LAY_EL_THUNDER_3D, FALSE);
acedUpdateDisplay();
actrTransactionManager->flushGraphics();
ThunderContainer->ClearProHeight();
}
AcGePoint3d CFoldLayPinDlg::GetThunderInsertPosition(const AcDbObjectId& id)
{
AcGePoint3d ptPos;
if (id.isValid())
{
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbBlockReference, pRef);
if (pRef != NULL)
{
ptPos = pRef->position();
}
OPENOBJ_END();
}
return ptPos;
}
double CFoldLayPinDlg::GetThunderHeight() const
{
CString sHt;
GetDlgItemText(IDC_EDT_HEIGHT, sHt);
return _tstof(sHt);
}
// 是否响应动态更新
BOOL CFoldLayPinDlg::IsDynamicUpdate() const
{
return m_bIsModel;
}
void CFoldLayPinDlg::HighlightSubEnt(double dProheight)
{
CString sGroupNO;
GetDlgItemText(IDC_FOLD_EDT_GROUP_NO, sGroupNO);
AcDbObjectIdArray arTemp,arAll;
ThunderContainer->GetCircle(sGroupNO, arTemp);
arAll.append(arTemp);
ThunderContainer->GetRegion(sGroupNO, arTemp);
arAll.append(arTemp);
CString sPro;
CThunderXData xd;
// 挑选合适的实体并高亮
for (int i = 0;i < arAll.length();++i)
{
if (arAll[i].isValid())
{
OPENOBJ_BEGIN(arAll[i], AcDb::kForRead, AcDbEntity, pEnt);
if (pEnt != NULL)
{
xd.GetXData(pEnt, TEL_CURRENT_PROHEIGHT, sPro);
if (fabs(dProheight-_tstof(sPro)) < 1e-3)
{
pEnt->highlight();
m_arHlEnt.append(arAll[i]);
}
}
OPENOBJ_END();
}
}
acedUpdateDisplay();
actrTransactionManager->flushGraphics();
}
void CFoldLayPinDlg::UnHighlightSubEnt()
{
for (int i = 0;i < m_arHlEnt.length();++i)
{
if (m_arHlEnt[i].isValid())
{
OPENOBJ_BEGIN(m_arHlEnt[i], AcDb::kForRead, AcDbEntity, pEnt);
if (pEnt != NULL)
{
pEnt->unhighlight();
}
OPENOBJ_END();
}
}
m_arHlEnt.setLogicalLength(0);
acedUpdateDisplay();
actrTransactionManager->flushGraphics();
}
void CFoldLayPinDlg::SetDbReactorPtr(CThunderDbReactor* pRector)
{
m_pReactor = pRector;
}
void CFoldLayPinDlg::GetThunderProHeight(AcGeDoubleArray& arPro)
{
arPro = m_arProHeight;
}
double CFoldLayPinDlg::GetThunderRadius() const
{
return _tstof(m_csRadius);
}
double CFoldLayPinDlg::GetBlkScale()
{
return _tstof(m_csBlkScale);
}
void CFoldLayPinDlg::OnDestroy()
{
if (!m_bIsModel)
{
SaveDlgData();
}
CDialog::OnDestroy();
UnHighlightSubEnt();
}
void CFoldLayPinDlg::OnChangeGroupNo()
{
if (!m_bValid)
{
return;
}
UpdateData();
if (_ttoi(m_csGroupNo) < 1)
{
CString strTip;
strTip.Format(_T("组号最小为1"));
m_bTipChange = TRUE;
PostErrorToCue(strTip);
return;
}
// 避雷针编号
AcGeIntArray arNum;
FoldManager->GetNumArrayBySpecGroup(_ttoi(m_csGroupNo), arNum);
if (arNum.length() > 0)
{
CString sNum;
sNum.Format(_T("%d"), arNum.last()+1);
m_wndEdtNumber.SetWindowText(sNum);
}
else
m_wndEdtNumber.SetWindowText(_T("1"));
}
void CFoldLayPinDlg::OnGroupExplain()
{
CAcModuleResourceOverride myResources;
CGroupHelp hlpDlg;
hlpDlg.DoModal();
}
void CFoldLayPinDlg::ReadDlgData()
{
//读取设置
CString sGroup;
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
regProp.GetValue(_T("PIN_HEIGHT"),m_csPinHeight);
}
void CFoldLayPinDlg::SaveDlgData()
{
//保存设置
UpdateData(TRUE);
CRegProperty regProp(GetRegLocation(), TEL_OBJECTKEY);
regProp.SetTopRootKey(HKEY_CURRENT_USER);
regProp.SetValue(_T("PIN_RADIUS"),m_csRadius);
regProp.SetValue(_T("PIN_HEIGHT"),m_csPinHeight);
}
void CFoldLayPinDlg::SetBlkName(const CString& sBlkName)
{
m_sBlkName = sBlkName;
}
void CFoldLayPinDlg::OnBnClickedChkHillHillside()
{
int nCheck = m_wndChkHillSile.GetCheck();
CRegProperty reg(GetRegLocation(), _T("Thunder"));
reg.SetTopRootKey(HKEY_CURRENT_USER);
reg.SetValue(KEY_FOLD_HILL_HILLSIDE, nCheck);
}