1639 lines
37 KiB
C++
1639 lines
37 KiB
C++
#include "stdafx.h"
|
|
#include "LayFireExtinguisherDlg.h"
|
|
#include "SelectBlkDlg.h"
|
|
#include"TGAs.h"
|
|
#include "DbFireExtinguisher.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
IMPLEMENT_DYNAMIC(CLayFireExtinguisherDlg, CModelessDialog)
|
|
CLayFireExtinguisherDlg::CLayFireExtinguisherDlg(int iType, CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CLayFireExtinguisherDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CLayFireExtinguisherDlg)
|
|
m_iType = iType;
|
|
m_nSpecificationType = 0;
|
|
m_nLayType = 0;
|
|
m_nDimType = 0;
|
|
m_nLayDimType = 0;
|
|
m_sSpecification = _T("");
|
|
m_sGrade = _T("");
|
|
m_sTextStyle = _T("");
|
|
m_nPos = 0;
|
|
m_sCount = _T("1");
|
|
m_sScale = _T("1");
|
|
m_sTextHeight = _T("3.5");
|
|
m_sProtectRadius = _T("20");
|
|
m_bShowProtectRadius = FALSE;
|
|
m_nScale = 0;
|
|
m_bInit = TRUE;
|
|
//}}AFX_DATA_INIT
|
|
m_bRestartForLay = FALSE;
|
|
m_bIsDiffPre = false;
|
|
}
|
|
|
|
|
|
void CLayFireExtinguisherDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CLayFireExtinguisherDlg)
|
|
DDX_Control(pDX, IDC_SPIN_NUM, m_wndSpinCount);
|
|
DDX_Control(pDX, IDC_CMB_TEXT_STYLE, m_wndCmbTextStyle);
|
|
DDX_Control(pDX, IDC_CMB_GRADE, m_wndCmbGrade);
|
|
DDX_Control(pDX, IDC_CMB_SPECIFICATION, m_wndCmbSpec);
|
|
DDX_Control(pDX, IDC_COMBO_TEXT_HEIGHT, m_wndCmbTextHeight);
|
|
DDX_Radio(pDX, IDC_RADIO_TYPE1, m_nSpecificationType);
|
|
DDX_Radio(pDX, IDC_RADIO_RANG_LAY, m_nLayType);
|
|
DDX_Radio(pDX, IDC_RADIO_DIM, m_nDimType);
|
|
DDX_Radio(pDX, IDC_RADIO_MULTI_LAY, m_nLayDimType);
|
|
DDX_CBString(pDX, IDC_CMB_SPECIFICATION, m_sSpecification);
|
|
DDX_CBString(pDX, IDC_CMB_GRADE, m_sGrade);
|
|
DDX_CBString(pDX, IDC_CMB_TEXT_STYLE, m_sTextStyle);
|
|
DDX_Radio(pDX, IDC_RADIO_POS1, m_nPos);
|
|
DDX_Text(pDX, IDC_EDIT_NUM, m_sCount);
|
|
DDX_Text(pDX, IDC_EDIT_SCALE, m_sScale);
|
|
DDX_CBString(pDX, IDC_COMBO_TEXT_HEIGHT, m_sTextHeight);
|
|
DDX_Text(pDX, IDC_EDIT_PROTECT_RADIUS, m_sProtectRadius);
|
|
DDX_Check(pDX, IDC_CHECK_PORTECT_RADIUS, m_bShowProtectRadius);
|
|
DDX_Radio(pDX, IDC_RADIO_OLD, m_nScale);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_CMB_PRORADIUS, m_wndProRadius);
|
|
DDX_Control(pDX, IDC_CMB_SCALE, m_wndScale);
|
|
DDX_Control(pDX, IDC_CMB_NUM, m_wndNum);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CLayFireExtinguisherDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CLayFireExtinguisherDlg)
|
|
ON_BN_CLICKED(IDC_STATIC_PREVIEW, OnStaticPreview)
|
|
ON_WM_PAINT()
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioSpecType)
|
|
ON_BN_CLICKED(IDC_RADIO_DIM, OnRadioDim)
|
|
ON_CBN_SELCHANGE(IDC_CMB_SPECIFICATION, OnSelchangeCmbSpecification)
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_RADIO_RANG_LAY, OnRadioRangLay)
|
|
ON_BN_CLICKED(IDC_RADIO_RANDOM_LAY, OnRadioRandomLay)
|
|
ON_BN_CLICKED(IDC_RADIO_BYLINE, OnRadioByLineLay)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioSpecType)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE3, OnRadioSpecType)
|
|
ON_BN_CLICKED(IDC_RADIO_TYPE4, OnRadioSpecType)
|
|
ON_BN_CLICKED(IDC_RADIO_NO_DIM, OnRadioDim)
|
|
ON_BN_CLICKED(IDC_CHECK_PORTECT_RADIUS, OnCheckPortectRadius)
|
|
ON_BN_CLICKED(IDC_RADIO_OLD, OnRadioScaleOld)
|
|
ON_BN_CLICKED(IDC_RADIO_CUR, OnRadioScaleNew)
|
|
ON_CBN_KILLFOCUS(IDC_COMBO_TEXT_HEIGHT, OnKillfocusTextHeight)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_NUM, OnKillfocusNum)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_SCALE, OnKillfocusScale)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_PROTECT_RADIUS, OnKillfocusProtectRadius)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_SPECIFICATION, OnKillfocusSpecification)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_GRADE, OnKillfocusGrade)
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDOK, &CLayFireExtinguisherDlg::OnBnClickedOk)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_PRORADIUS, &CLayFireExtinguisherDlg::OnCbnKillfocusCmbProradius)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_SCALE, &CLayFireExtinguisherDlg::OnCbnKillfocusCmbScale)
|
|
ON_CBN_KILLFOCUS(IDC_CMB_NUM, &CLayFireExtinguisherDlg::OnCbnKillfocusCmbNum)
|
|
END_MESSAGE_MAP()
|
|
|
|
extern bool IsStrAllNum(CString csText);
|
|
void CLayFireExtinguisherDlg::OnKillfocusTextHeight()
|
|
{
|
|
CString csData = m_sTextHeight;
|
|
CString sText;
|
|
m_wndCmbTextHeight.GetWindowText(sText);
|
|
m_sTextHeight = sText;
|
|
if ((_tstof(sText) <= 0.0|| !IsStrAllNum(sText)) && sText.Compare(_T("*多种*"))!= 0)
|
|
{
|
|
m_sTextHeight = csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndCmbTextHeight.SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnKillfocusSpecification()
|
|
{
|
|
CString csData = m_sSpecification;
|
|
CString sText;
|
|
m_wndCmbSpec.GetWindowText(sText);
|
|
m_sSpecification = sText;
|
|
if (sText.IsEmpty())
|
|
{
|
|
m_sSpecification = csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndCmbSpec.SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnKillfocusGrade()
|
|
{
|
|
CString csData = m_sGrade;
|
|
CString sText;
|
|
m_wndCmbGrade.GetWindowText(sText);
|
|
m_sGrade = sText;
|
|
if (sText.IsEmpty())
|
|
{
|
|
m_sGrade = csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndCmbGrade.SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnKillfocusNum()
|
|
{
|
|
CString csData = m_sCount;
|
|
CString sText;
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NUM);
|
|
pEdit->GetWindowText(sText);
|
|
m_sCount = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0 || sText.Find(_T('.')) >=0)
|
|
{
|
|
m_sCount= csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
pEdit->SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnKillfocusScale()
|
|
{
|
|
CString csData = m_sScale;
|
|
CString sText;
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_SCALE);
|
|
pEdit->GetWindowText(sText);
|
|
m_sScale = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0)
|
|
{
|
|
m_sScale= csData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
pEdit->SetFocus();
|
|
}
|
|
}
|
|
void CLayFireExtinguisherDlg::OnKillfocusProtectRadius()
|
|
{
|
|
CString sData = m_sProtectRadius;
|
|
CString sText;
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_PROTECT_RADIUS);
|
|
pEdit->GetWindowText(sText);
|
|
m_sProtectRadius = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0)
|
|
{
|
|
m_sProtectRadius = sData;
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
pEdit->SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OpenSlide()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pImageBox = GetDlgItem(IDC_STATIC_PREVIEW);
|
|
CString sTKName, sRocord, sSlb, sBlkName;
|
|
sBlkName = GetSelBlkName();
|
|
SplitBlkStr(sBlkName, sTKName, sRocord);
|
|
sSlb.Format(_T("%s(%s)"), sTKName, sRocord);
|
|
DrawSlide((const TCHAR*)sSlb, pImageBox);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnStaticPreview()
|
|
{
|
|
UpdateData();
|
|
CTemporaryResourceOverride vTemp;
|
|
CSelectBlkDlg dlg;
|
|
CWnd *pWnd = GetDlgItem(IDC_STATIC_PREVIEW);
|
|
if (pWnd == NULL)
|
|
{
|
|
return;
|
|
}
|
|
CRect rect;
|
|
pWnd->GetWindowRect(&rect);
|
|
dlg.m_ptBase = rect.TopLeft();
|
|
dlg.m_csTkName = _T("TWTSYS");
|
|
dlg.m_csType = _T("灭火器");
|
|
if (m_nSpecificationType == 0)
|
|
{
|
|
dlg.m_csType += _T("\\手提式");
|
|
}
|
|
else if(m_nSpecificationType == 1)
|
|
{
|
|
dlg.m_csType += _T("\\推车式");
|
|
}
|
|
else if (m_nSpecificationType == 2)
|
|
{
|
|
dlg.m_csType += _T("\\手提贮压式");
|
|
}
|
|
else
|
|
{
|
|
dlg.m_csType += _T("\\推车贮压式");
|
|
}
|
|
|
|
CString sBlkName = GetSelBlkName();
|
|
sBlkName.Replace(_T("$"), _T("("));
|
|
dlg.m_staticSlide.m_csCurRecord = m_sBlkName;
|
|
if(dlg.DoModal() == IDOK)
|
|
{
|
|
CString sRet = dlg.m_staticSlide.m_csCurRecord;
|
|
CString sDes = dlg.m_staticSlide.m_csCurDesName;
|
|
XString xsTKName, xsRocord;
|
|
SplitSlbName(sRet, xsTKName, xsRocord);
|
|
acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);
|
|
XString xsBlk;
|
|
LoadDwbBlock(xsTKName, xsRocord, xsBlk);
|
|
m_sBlkName = sDes + _T("\\") + xsBlk;
|
|
acDocManager->unlockDocument(curDoc());
|
|
OpenSlide();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this);
|
|
OpenSlide();
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::ReadDataFromReg()
|
|
{
|
|
CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
// 选择的图块名
|
|
if (!regProp.GetValue(_T("FE_BlkName"), m_sBlkName))
|
|
{
|
|
m_sBlkName = _T("手提式灭火器\\$TWTSYS$00000545");
|
|
}
|
|
// 选型
|
|
//m_nSpecificationType = GetSpecTypeByBlkName(m_sBlkName);
|
|
regProp.GetValue(_T("FE_SpecificationType"), m_nSpecificationType);
|
|
// 规格
|
|
regProp.GetValue(_T("FE_Specification"), m_sSpecification);
|
|
// 级别
|
|
regProp.GetValue(_T("FE_Grade"), m_sGrade);
|
|
// 数量
|
|
if (!regProp.GetValue(_T("FE_Count"), m_sCount))
|
|
{
|
|
m_sCount = _T("1");
|
|
}
|
|
// 布置方式
|
|
regProp.GetValue(_T("FE_LayType"), m_nLayType);
|
|
// 是否标注
|
|
regProp.GetValue(_T("FE_IsDim"), m_nDimType);
|
|
// 布置与标注方式
|
|
regProp.GetValue(_T("FE_LayDimType"), m_nLayDimType);
|
|
// 文字样式
|
|
regProp.GetValue(_T("FE_TextStyle"), m_sTextStyle);
|
|
// 字高
|
|
regProp.GetValue(_T("FE_TextHeight"), m_sTextHeight);
|
|
// 比例
|
|
regProp.GetValue(_T("FE_Scale"), m_sScale);
|
|
// 布置位置
|
|
regProp.GetValue(_T("FE_Pos"), m_nPos);
|
|
// 保护半径
|
|
regProp.GetValue(_T("FE_ProtectRadius"), m_sProtectRadius);
|
|
// 是否显示保护半径
|
|
regProp.GetValue(_T("FE_ShowProtectRadius"), m_bShowProtectRadius);
|
|
// 布置比例
|
|
regProp.GetValue(_T("FE_ScaleType"), m_nScale);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::WriteToReg()
|
|
{
|
|
UpdateData(TRUE);
|
|
CRegProperty regProp(GetRegLocation(), _T("TWTConfig"));
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
// 选择的图块名
|
|
regProp.SetValue(_T("FE_BlkName"), m_sBlkName);
|
|
regProp.SetValue(_T("FE_SpecificationType"), m_nSpecificationType);
|
|
// 规格
|
|
regProp.SetValue(_T("FE_Specification"), m_sSpecification);
|
|
// 级别
|
|
regProp.SetValue(_T("FE_Grade"), m_sGrade);
|
|
// 数量
|
|
regProp.SetValue(_T("FE_Count"), m_sCount);
|
|
// 布置方式
|
|
regProp.SetValue(_T("FE_LayType"), m_nLayType);
|
|
// 是否标注
|
|
regProp.SetValue(_T("FE_IsDim"), m_nDimType);
|
|
// 布置与标注方式
|
|
regProp.SetValue(_T("FE_LayDimType"), m_nLayDimType);
|
|
// 文字样式
|
|
regProp.SetValue(_T("FE_TextStyle"), m_sTextStyle);
|
|
// 字高
|
|
regProp.SetValue(_T("FE_TextHeight"), m_sTextHeight);
|
|
// 比例
|
|
regProp.SetValue(_T("FE_Scale"), m_sScale);
|
|
// 布置位置
|
|
regProp.SetValue(_T("FE_Pos"), m_nPos);
|
|
// 保护半径
|
|
regProp.SetValue(_T("FE_ProtectRadius"), m_sProtectRadius);
|
|
// 是否显示保护半径
|
|
regProp.SetValue(_T("FE_ShowProtectRadius"), m_bShowProtectRadius);
|
|
// 布置比例
|
|
regProp.SetValue(_T("FE_ScaleType"), m_nScale);
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetSpecTypeByBlkName( const CString &sBlkName )
|
|
{
|
|
int nSpecType = -1;
|
|
m_sBlkName = sBlkName;
|
|
if (sBlkName.Find(_T("手提式灭火器")) != -1)
|
|
{
|
|
nSpecType = 0;
|
|
}
|
|
else if (sBlkName.Find(_T("推车式灭火器")) != -1)
|
|
{
|
|
nSpecType = 1;
|
|
}
|
|
else if (sBlkName.Find(_T("手提贮压式灭火器")) != -1)
|
|
{
|
|
nSpecType = 2;
|
|
}
|
|
else if (sBlkName.Find(_T("推车贮压式灭火器")) != -1)
|
|
{
|
|
nSpecType = 3;
|
|
}
|
|
|
|
return nSpecType;
|
|
}
|
|
|
|
BOOL CLayFireExtinguisherDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
m_wndSpinCount.SetRange(0, 100);
|
|
m_wndNum.ShowWindow(FALSE);
|
|
m_wndScale.ShowWindow(FALSE);
|
|
m_wndProRadius.ShowWindow(FALSE);
|
|
|
|
// 读取注册表数据
|
|
if (m_iType != 1 && m_iType != 2)
|
|
{
|
|
ReadDataFromReg();
|
|
if ( m_sBlkName.Compare(_T("手提式灭火器\$TWTSYS$00000545")) != 1 && m_sBlkName.Compare(_T("手提式灭火器\$TWTSYS$00000546")) != 1 && m_sBlkName.Compare(_T("手提式灭火器\$TWTSYS$00000549")) != 1
|
|
&& m_sBlkName.Compare(_T("手提式灭火器\$TWTSYS$00000551")) != 1 && m_sBlkName.Compare(_T("推车式灭火器\$TWTSYS$00000547")) != 1 && m_sBlkName.Compare(_T("推车式灭火器\$TWTSYS$00000548")) != 1
|
|
&& m_sBlkName.Compare(_T("推车式灭火器\$TWTSYS$00000550")) != 1)
|
|
{
|
|
m_sBlkName = _T("手提式灭火器\\$TWTSYS$00000545");
|
|
m_nSpecificationType = 0;
|
|
}
|
|
CRect rect;
|
|
this->GetWindowRect(&rect);
|
|
rect.bottom -= 27;
|
|
this->MoveWindow(&rect);
|
|
}
|
|
else if (m_iType == 1 || m_iType == 2)
|
|
{
|
|
if (m_iType == 2)// 修改模式
|
|
{
|
|
InitDlgData();
|
|
}
|
|
else
|
|
{
|
|
CString sTKName, sRocord, sBlkName;
|
|
sBlkName = m_sBlkName;
|
|
SplitBlkStr(sBlkName, sTKName, sRocord);
|
|
if (sRocord.Compare(_T("00000547")) == 0 || sRocord.Compare(_T("00000548")) == 0 || sRocord.Compare(_T("00000550")) == 0)
|
|
{
|
|
m_nSpecificationType = 1;
|
|
}
|
|
|
|
if (sRocord.IsEmpty())
|
|
{
|
|
m_nSpecificationType = -1;
|
|
}
|
|
}
|
|
|
|
}
|
|
UpdateData(FALSE);
|
|
// 加载文字样式
|
|
LoadTextStyle();
|
|
// 根据布置方式, 确定消火栓和灭火器位置关系是否可用 cet 2013.4.8 add
|
|
SetEnableWndPos();
|
|
|
|
// 从数据库中读取灭火器数据并初始化规格、级别
|
|
GetFireExtinguisherDataFromDbf();
|
|
InitSpecification();
|
|
UpdateData(FALSE);
|
|
InitGrade();
|
|
|
|
// 是否显示保护半径 cet 2013.4.22 add
|
|
if (m_iType != 1 || m_iType != 2)
|
|
{
|
|
if (!m_bShowProtectRadius)
|
|
{
|
|
m_bShowProtectRadius = TRUE;
|
|
OnCheckPortectRadius();
|
|
m_bShowProtectRadius = FALSE;
|
|
}
|
|
OnCheckPortectRadius();
|
|
}
|
|
|
|
m_bInit = false;
|
|
CWnd *pWnd1 = GetDlgItem(IDC_RADIO_RANG_LAY);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_RADIO_ONLY_LAY);
|
|
if (pWnd1 == NULL || pWnd2 == NULL)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (m_nDimType == 0)
|
|
{
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
m_nLayDimType = 0;
|
|
}
|
|
UpdateData(FALSE);
|
|
|
|
if (m_iType == 1 || m_iType == 2)// 编辑修改模式
|
|
{
|
|
m_nLayType = 1;
|
|
SetEnableWndPos();
|
|
CWnd *pWnd1 = GetDlgItem(IDC_RADIO_RANG_LAY);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_RADIO_RANDOM_LAY);
|
|
CWnd *pWnd3 = GetDlgItem(IDC_RADIO_MULTI_LAY);
|
|
CWnd *pWnd4 = GetDlgItem(IDC_RADIO_ONLY_LAY);
|
|
CWnd *pWnd5 = GetDlgItem(IDC_RADIO_BYLINE);
|
|
if (pWnd1 == NULL || pWnd2 == NULL || pWnd3 == NULL || pWnd4 == NULL || pWnd5 == NULL)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
pWnd3->EnableWindow(FALSE);
|
|
pWnd4->EnableWindow(FALSE);
|
|
pWnd5->EnableWindow(FALSE);
|
|
}
|
|
|
|
if (m_iType == 2)
|
|
{
|
|
if (m_vecProRadius.size() > 1)
|
|
{
|
|
m_wndProRadius.ShowWindow(TRUE);
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_PROTECT_RADIUS);
|
|
pEdit->ShowWindow(FALSE);
|
|
m_wndProRadius.AddString(_T("*多种*"));
|
|
std::vector<double>::iterator it = m_vecProRadius.begin();
|
|
for (; it != m_vecProRadius.end(); it++)
|
|
{
|
|
CString sText;
|
|
sText.Format(_T("%.2f"), *it);
|
|
m_wndProRadius.AddString(sText);
|
|
}
|
|
m_wndProRadius.SetCurSel(0);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
if (m_vecCount.size() > 1)
|
|
{
|
|
m_wndNum.ShowWindow(TRUE);
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_NUM);
|
|
pEdit->ShowWindow(FALSE);
|
|
m_wndSpinCount.ShowWindow(FALSE);
|
|
m_wndNum.AddString(_T("*多种*"));
|
|
std::vector<int>::iterator it = m_vecCount.begin();
|
|
for (; it != m_vecCount.end(); it++)
|
|
{
|
|
CString sText;
|
|
sText.Format(_T("%d"), *it);
|
|
m_wndNum.AddString(sText);
|
|
}
|
|
m_wndNum.SetCurSel(0);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
if (m_vecScale.size() > 1)
|
|
{
|
|
m_wndScale.ShowWindow(TRUE);
|
|
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDIT_SCALE);
|
|
pEdit->ShowWindow(FALSE);
|
|
m_wndScale.AddString(_T("*多种*"));
|
|
std::vector<double>::iterator it = m_vecScale.begin();
|
|
for (; it != m_vecScale.end(); it++)
|
|
{
|
|
CString sText;
|
|
sText.Format(_T("%.2f"), *it);
|
|
m_wndScale.AddString(sText);
|
|
}
|
|
m_wndScale.SetCurSel(0);
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnDestroy()
|
|
{
|
|
CModelessDialog::OnDestroy();
|
|
// 保存数据
|
|
if (m_iType != 1 && m_iType != 2)
|
|
{
|
|
WriteToReg();
|
|
}
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioSpecType()
|
|
{
|
|
// 上次选择
|
|
int nPreSpecType = m_nSpecificationType;
|
|
UpdateData(TRUE);
|
|
if (nPreSpecType == m_nSpecificationType)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (m_nSpecificationType == 0)
|
|
{
|
|
m_sBlkName = _T("手提式灭火器\\$TWTSYS$00000545");
|
|
}
|
|
else if (m_nSpecificationType == 1)
|
|
{
|
|
m_sBlkName = _T("推车式灭火器\\$TWTSYS$00000547");
|
|
}
|
|
else if (m_nSpecificationType == 2)
|
|
{
|
|
m_sBlkName = _T("手提贮压式灭火器\\$TWTSYS$00000559");
|
|
}
|
|
else if (m_nSpecificationType == 3)
|
|
{
|
|
m_sBlkName = _T("推车贮压式灭火器\\$TWTSYS$00000563");
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
OpenSlide();
|
|
|
|
UpdateData(FALSE);
|
|
InitSpecification();
|
|
UpdateData(FALSE);
|
|
InitGrade();
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
CString CLayFireExtinguisherDlg::GetSelBlkName()
|
|
{
|
|
CString sBlkName = m_sBlkName;
|
|
int nFind = sBlkName.Find(_T("\\"));
|
|
if (nFind != -1)
|
|
{
|
|
int nLen = sBlkName.GetLength();
|
|
sBlkName = sBlkName.Right(nLen - nFind - 1);
|
|
}
|
|
return sBlkName;
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetSpecType()
|
|
{
|
|
return m_nSpecificationType;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioDim()
|
|
{
|
|
int nPreSel = m_nDimType;
|
|
UpdateData(TRUE);
|
|
if (nPreSel == m_nDimType || m_iType == 1 || m_iType == 2)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CWnd *pWnd1 = GetDlgItem(IDC_RADIO_RANG_LAY);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_RADIO_ONLY_LAY);
|
|
if (pWnd1 == NULL || pWnd2 == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (m_nDimType == 0)
|
|
{
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
}
|
|
else if (m_nDimType == 1)
|
|
{
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
m_nLayDimType = 0;
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::GetFireExtinguisherDataFromDbf( )
|
|
{
|
|
CodeBase db;
|
|
XString fullFile;
|
|
if(!FindFile(_T("twtdatastore.dbf"), fullFile))
|
|
{
|
|
AfxMessageBox(_T("对不起,没有发现twtdatastore.dbf文件!"));
|
|
return;
|
|
}
|
|
|
|
XDbfTable *pTable = db.Open(fullFile);
|
|
if(pTable == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nTypeId = 0;
|
|
CString sTypeName, sTypeA, sTypeB, sRemark;
|
|
DataNode node;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext())
|
|
{
|
|
GET_FIELD(pTable, _T("Typeid"), nTypeId);
|
|
GET_FIELD(pTable, _T("Typename"), sTypeName);
|
|
GET_FIELD(pTable, _T("Typea"), sTypeA);
|
|
GET_FIELD(pTable, _T("Typeb"), sTypeB);
|
|
GET_FIELD(pTable, _T("Remark"), sRemark);
|
|
node.nTypeId = nTypeId;
|
|
node.sTypeName = sTypeName;
|
|
node.sTypeA = sTypeA;
|
|
node.sTypeB = sTypeB;
|
|
node.sRemark = sRemark;
|
|
m_vecData.push_back(node);
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::GetGradeData( int nTypeId, const CString &sSpec, std::vector<CString> &vecGrade )
|
|
{
|
|
if (sSpec == _T("*多种*") && m_vecGrade.size() > 1)
|
|
{
|
|
vecGrade = m_vecGrade;
|
|
return;
|
|
}
|
|
std::vector<DataNode>::iterator it, itEnd = m_vecData.end();
|
|
CString sGrade;
|
|
for (it = m_vecData.begin(); it != itEnd; ++it)
|
|
{
|
|
if ((it->nTypeId == nTypeId || m_sGrade == _T("*多种*"))&& (it->sTypeName).Compare(sSpec) == 0)
|
|
{
|
|
sGrade = it->sTypeA;
|
|
if (!sGrade.IsEmpty())
|
|
{
|
|
vecGrade.push_back(sGrade);
|
|
}
|
|
|
|
sGrade = it->sTypeB;
|
|
if (!sGrade.IsEmpty())
|
|
{
|
|
vecGrade.push_back(sGrade);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetTypeId()
|
|
{
|
|
if (m_nSpecificationType == 0)
|
|
{
|
|
return 1;
|
|
}
|
|
else if (m_nSpecificationType == 1)
|
|
{
|
|
return 2;
|
|
}
|
|
else if (m_nSpecificationType == 2)
|
|
{
|
|
return 9;
|
|
}
|
|
else if (m_nSpecificationType == 3)
|
|
{
|
|
return 10;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::InitSpecification()
|
|
{
|
|
// 获得当前类型灭火器规格
|
|
std::vector<DataNode>::iterator it, itEnd = m_vecData.end();
|
|
std::vector<CString> vecSpec;
|
|
int nTypeId = GetTypeId();
|
|
|
|
for (it = m_vecData.begin(); it != itEnd; ++it)
|
|
{
|
|
if (it->nTypeId == nTypeId)
|
|
{
|
|
vecSpec.push_back(it->sTypeName);
|
|
}
|
|
else if (nTypeId < 0 && m_iType == 2 && (m_setSpecification.find(it->nTypeId) != m_setSpecification.end()))
|
|
{
|
|
vecSpec.push_back(it->sTypeName);
|
|
}
|
|
}
|
|
|
|
m_wndCmbSpec.ResetContent();
|
|
if (m_bIsDiffPre)
|
|
{
|
|
m_wndCmbSpec.AddString(_T("*多种*"));
|
|
}
|
|
std::vector<CString>::iterator itSpec, itSpecEnd = vecSpec.end();
|
|
for (itSpec = vecSpec.begin(); itSpec != itSpecEnd; ++itSpec)
|
|
{
|
|
m_wndCmbSpec.AddString(*itSpec);
|
|
}
|
|
|
|
int nIndex = m_sSpecification.Compare(_T("*多种*"));
|
|
if (m_iType == 2 && (m_sSpecification.IsEmpty() || nIndex == 0))
|
|
{
|
|
m_sSpecification = _T("*多种*");
|
|
int nIndex = m_wndCmbSpec.FindString(0, m_sSpecification);
|
|
m_wndCmbSpec.SetCurSel(nIndex);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
if (m_iType == 1 && m_bInit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!m_sSpecification.IsEmpty() && m_bInit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nSel = m_wndCmbSpec.FindString(0, m_sSpecification);
|
|
if (nSel == -1)
|
|
{
|
|
nSel = 0;
|
|
m_wndCmbSpec.GetLBText(nSel, m_sSpecification);
|
|
}
|
|
m_wndCmbSpec.SetCurSel(nSel);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::InitGrade()
|
|
{
|
|
int nTypeId = GetTypeId();
|
|
std::vector<CString> vecGrade;
|
|
GetGradeData(nTypeId, m_sSpecification, vecGrade);
|
|
m_wndCmbGrade.ResetContent();
|
|
std::vector<CString>::iterator it, itEnd = vecGrade.end();
|
|
for (it = vecGrade.begin(); it != itEnd; ++it)
|
|
{
|
|
m_wndCmbGrade.AddString(*it);
|
|
}
|
|
|
|
if (m_wndCmbGrade.GetCount() == 0)
|
|
{
|
|
m_wndCmbGrade.AddString(m_sGrade);
|
|
}
|
|
|
|
if (m_iType == 2 && m_vecGrade.size() > 1)
|
|
{
|
|
m_sGrade = _T("*多种*");
|
|
m_wndCmbGrade.AddString(m_sGrade);
|
|
int nIndex = m_wndCmbGrade.FindString(0, m_sGrade);
|
|
m_wndCmbGrade.SetCurSel(nIndex);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
if (m_iType == 1 && m_bInit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!m_sGrade.IsEmpty() && m_bInit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nSel = m_wndCmbGrade.FindString(-1, m_sGrade);
|
|
if (nSel == -1)
|
|
{
|
|
nSel = 0;
|
|
m_wndCmbGrade.GetLBText(nSel, m_sGrade);
|
|
}
|
|
m_wndCmbGrade.SetCurSel(nSel);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnSelchangeCmbSpecification()
|
|
{
|
|
UpdateData(TRUE);
|
|
CString sPreSpec = m_sSpecification;
|
|
int nSel = m_wndCmbSpec.GetCurSel();
|
|
if (nSel == -1)
|
|
{
|
|
return;
|
|
}
|
|
m_wndCmbSpec.GetLBText(nSel, m_sSpecification);
|
|
//m_sGrade.Empty();
|
|
InitGrade();
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::LoadTextStyle()
|
|
{
|
|
AcDbDatabase *pCurDwg = acdbCurDwg();
|
|
if (pCurDwg == NULL)
|
|
{
|
|
return;
|
|
}
|
|
AcDbTextStyleTable* pTT = NULL;
|
|
VERIFY(pCurDwg->getSymbolTable(pTT, AcDb::kForRead) == Acad::eOk);
|
|
|
|
AcDbTextStyleTableIterator* pIter = NULL;
|
|
VERIFY(pTT->newIterator(pIter) == Acad::eOk);
|
|
pTT->close();
|
|
for (pIter->start(); !pIter->done(); pIter->step())
|
|
{
|
|
AcDbTextStyleTableRecord* pTTR;
|
|
if (pIter->getRecord(pTTR, AcDb::kForRead) != Acad::eOk)
|
|
continue;
|
|
const TCHAR* pName = NULL;
|
|
if (pTTR->getName(pName) == Acad::eOk && pName != NULL)
|
|
{
|
|
m_setTextStyle.insert(tstrnew(pName)); // 读字体风格
|
|
}
|
|
pTTR->close();
|
|
}
|
|
delete pIter;
|
|
|
|
std::set<CString>::iterator it, itEnd = m_setTextStyle.end();
|
|
for (it = m_setTextStyle.begin(); it != itEnd; ++it)
|
|
{
|
|
m_wndCmbTextStyle.AddString(*it);
|
|
}
|
|
|
|
if (m_iType == 2 && m_sTextStyle.IsEmpty())
|
|
{
|
|
m_sTextStyle = _T("*多种*");
|
|
m_wndCmbTextStyle.AddString(_T("*多种*"));
|
|
int nIndex = m_wndCmbTextStyle.FindString(-1, _T("*多种*"));
|
|
m_wndCmbTextStyle.SetCurSel(nIndex);
|
|
UpdateData(FALSE);
|
|
return;
|
|
}
|
|
|
|
int nIndex = m_wndCmbTextStyle.FindString(-1, m_sTextStyle);
|
|
if (nIndex == -1)
|
|
{
|
|
m_sTextStyle = _T("STANDARD");
|
|
nIndex = m_wndCmbTextStyle.FindString(-1, m_sTextStyle);
|
|
m_wndCmbTextStyle.SetCurSel(nIndex);
|
|
m_sTextHeight = _T("3.5");
|
|
}
|
|
else
|
|
{
|
|
m_wndCmbTextStyle.SetCurSel(nIndex);
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetLayType()
|
|
{
|
|
return m_nLayType;
|
|
}
|
|
|
|
BOOL CLayFireExtinguisherDlg::IsDim()
|
|
{
|
|
if (m_nDimType == 0)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetLayDimType()
|
|
{
|
|
return m_nLayDimType;
|
|
}
|
|
|
|
CString CLayFireExtinguisherDlg::GetTextStyle()
|
|
{
|
|
return m_sTextStyle;
|
|
}
|
|
|
|
double CLayFireExtinguisherDlg::GetTextHeight()
|
|
{
|
|
return _tstof(m_sTextHeight);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioRangLay()
|
|
{
|
|
int nLayType = m_nLayType;
|
|
UpdateData(TRUE);
|
|
if (nLayType == m_nLayType)
|
|
{
|
|
return;
|
|
}
|
|
// 根据布置方式, 确定消火栓和灭火器位置关系是否可用 cet 2013.4.8 add
|
|
SetEnableWndPos();
|
|
|
|
m_bRestartForLay = TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acedPostCommand(_T("\33\33"));
|
|
acedPostCommand(_T("BMHQ "));
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioRandomLay()
|
|
{
|
|
int nLayType = m_nLayType;
|
|
UpdateData(TRUE);
|
|
if (nLayType == m_nLayType)
|
|
{
|
|
return;
|
|
}
|
|
// 根据布置方式, 确定消火栓和灭火器位置关系是否可用 cet 2013.4.8 add
|
|
SetEnableWndPos();
|
|
|
|
m_bRestartForLay = TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acedPostCommand(_T("\33\33"));
|
|
acedPostCommand(_T("BMHQ "));
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioByLineLay()
|
|
{
|
|
int nLayType = m_nLayType;
|
|
UpdateData(TRUE);
|
|
if (nLayType == m_nLayType)
|
|
{
|
|
return;
|
|
}
|
|
// 根据布置方式, 确定消火栓和灭火器位置关系是否可用 cet 2013.4.8 add
|
|
SetEnableWndPos();
|
|
|
|
m_bRestartForLay = TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acedPostCommand(_T("\33\33"));
|
|
acedPostCommand(_T("BMHQ "));
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioScaleOld()
|
|
{
|
|
UpdateData(TRUE);
|
|
if (m_iType == 1 || m_iType == 2)
|
|
{
|
|
return;
|
|
}
|
|
m_bRestartForLay = TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acedPostCommand(_T("\33\33"));
|
|
acedPostCommand(_T("BMHQ "));
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnRadioScaleNew()
|
|
{
|
|
UpdateData(TRUE);
|
|
if (m_iType == 1 || m_iType == 2)
|
|
{
|
|
return;
|
|
}
|
|
m_bRestartForLay = TRUE;
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acedPostCommand(_T("\33\33"));
|
|
acedPostCommand(_T("BMHQ "));
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetCount()
|
|
{
|
|
return _ttoi(m_sCount);
|
|
}
|
|
|
|
CString CLayFireExtinguisherDlg::GetSpecification()
|
|
{
|
|
return m_sSpecification;
|
|
}
|
|
|
|
BOOL CLayFireExtinguisherDlg::IsReStartForLay()
|
|
{
|
|
return m_bRestartForLay;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::ReStartForLay( bool bReStart )
|
|
{
|
|
m_bRestartForLay = bReStart;
|
|
}
|
|
|
|
CString CLayFireExtinguisherDlg::GetGrade()
|
|
{
|
|
return m_sGrade;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetLayType( int nLayType )
|
|
{
|
|
m_nLayType = nLayType;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetCount( int nCount )
|
|
{
|
|
m_sCount.Format(_T("%d"), nCount);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetTextHeight( double dTextHeight )
|
|
{
|
|
m_sTextHeight.Format(_T("%f"), dTextHeight);
|
|
if (m_sTextHeight.Find(_T(".")) > -1)
|
|
{
|
|
m_sTextHeight.TrimRight(_T("0"));
|
|
m_sTextHeight.TrimRight(_T("."));
|
|
}
|
|
}
|
|
|
|
int CLayFireExtinguisherDlg::GetLayPos() const
|
|
{
|
|
return m_nPos;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetLayPos( int nPos )
|
|
{
|
|
m_nPos = nPos;
|
|
}
|
|
|
|
double CLayFireExtinguisherDlg::GetScale()
|
|
{
|
|
return _tstof(m_sScale);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetScale( double dScale )
|
|
{
|
|
m_sScale.Format(_T("%f"), dScale);
|
|
if (m_sScale.Find(_T(".")) > -1)
|
|
{
|
|
m_sScale.TrimRight(_T("0"));
|
|
m_sScale.TrimRight(_T("."));
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetEnableWndPos()
|
|
{
|
|
CWnd *pWnd3 = GetDlgItem(IDC_RADIO_POS1);
|
|
CWnd *pWnd4 = GetDlgItem(IDC_RADIO_POS2);
|
|
if (pWnd3 == NULL || pWnd4 == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (m_nLayType == 0)
|
|
{
|
|
pWnd3->EnableWindow(TRUE);
|
|
pWnd4->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
pWnd3->EnableWindow(FALSE);
|
|
pWnd4->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
BOOL CLayFireExtinguisherDlg::IsShowRadius()
|
|
{
|
|
UpdateData(TRUE);
|
|
return m_bShowProtectRadius;
|
|
}
|
|
|
|
double CLayFireExtinguisherDlg::GetProtectRadius()
|
|
{
|
|
UpdateData(TRUE);
|
|
return _tstof(m_sProtectRadius);
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnCheckPortectRadius()
|
|
{
|
|
if (!m_bInit)
|
|
{
|
|
UpdateData(TRUE);
|
|
}
|
|
AcApDocument* pDoc = acDocManager->curDocument();
|
|
acDocManager->lockDocument(pDoc, AcAp::kWrite);
|
|
// 是否显示保护半径 cet 2013.4.22 add
|
|
if (m_bShowProtectRadius) // 显示保护半径
|
|
{
|
|
if (m_ssShowCir.Length() == 0)
|
|
{
|
|
ShowProtectRadius(m_ssFireExtinguisher);
|
|
}
|
|
else
|
|
{
|
|
m_ssShowCir.Redraw(1);
|
|
}
|
|
}
|
|
else // 隐藏保护半径
|
|
{
|
|
m_ssShowCir.Redraw(2);
|
|
}
|
|
acDocManager->unlockDocument(curDoc());
|
|
acedUpdateDisplay();
|
|
actrTransactionManager->flushGraphics();
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetFireExtinguisher( PickSet &ss )
|
|
{
|
|
m_ssFireExtinguisher.Free();
|
|
ss -= m_ssNewCir;
|
|
m_ssFireExtinguisher += ss;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::DeleteProtectRadius()
|
|
{
|
|
acedGetAcadDwgView()->SetFocus();
|
|
acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);
|
|
m_ssShowCir.Redraw(1);
|
|
m_ssShowCir.Erase();
|
|
m_ssShowCir.Free();
|
|
|
|
m_ssNewCir.Redraw(1);
|
|
m_ssNewCir.Erase();
|
|
m_ssNewCir.Free();
|
|
actrTransactionManager->flushGraphics(); //acad 刷新
|
|
acedUpdateDisplay();
|
|
acDocManager->unlockDocument(curDoc());
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetNewFireExtinguisher(PickSet &ss)
|
|
{
|
|
m_ssNewCir += ss;
|
|
}
|
|
|
|
PickSet CLayFireExtinguisherDlg::GetNewFireExtinguisher()
|
|
{
|
|
return m_ssNewCir;
|
|
}
|
|
|
|
extern void GetBlkSize(const AcDbObjectId &idBlk, const AcGeScale3d &scale, double &dWidth, double &dHeight);
|
|
// 显示保护半径 cet 2013.4.22 add
|
|
void CLayFireExtinguisherDlg::ShowProtectRadius(Entity &entRef)
|
|
{
|
|
double dRadius = _tstof(m_sProtectRadius);
|
|
bool bAdd = false;
|
|
AcGePoint3dArray arrPts;
|
|
bool bIsNew = true;
|
|
if (m_ssFireExtinguisher.IsInclude(entRef))
|
|
{
|
|
bIsNew = false;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(entRef, AcDb::kForRead, TDbFireExtinguisher, pFire);
|
|
if (pFire != NULL)
|
|
{
|
|
dRadius = pFire->GetProtectRadius();
|
|
XPoint ptIns = pFire->GetLocation();
|
|
bAdd = true;
|
|
double dScale = pFire->GetScale();
|
|
if (pFire->GetScaleType() == 0)
|
|
{
|
|
dScale *= (pFire->GetPScale() / 100);
|
|
}
|
|
AcGeScale3d scale(dScale);
|
|
double dWidth = 0.0, dHeight = 0.0;
|
|
GetBlkSize(pFire->GetBlock2d(), scale, dWidth, dHeight);
|
|
//插入点
|
|
if (pFire->GetLayType() == 0) // 按数量进行布置并标注规格
|
|
{
|
|
// 图块出入点
|
|
int nMod = pFire->GetNum() % 2;
|
|
if (nMod == 1) // 奇数个灭火器
|
|
{
|
|
arrPts.append(ptIns);
|
|
}
|
|
|
|
int nNum = pFire->GetNum();
|
|
nNum /= 2;
|
|
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
|
vtDir.rotateBy(pFire->GetAngle(), AcGeVector3d::kZAxis);
|
|
double dDist = 0.0;
|
|
for (int i = 0; i < nNum; ++i)
|
|
{
|
|
if (i == 0 && nMod == 0)
|
|
{
|
|
dDist += dWidth * 0.5;
|
|
}
|
|
else
|
|
{
|
|
dDist += dWidth;
|
|
}
|
|
arrPts.append(ptIns + vtDir * dDist);
|
|
arrPts.append(ptIns - vtDir * dDist);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
arrPts.append(ptIns);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (!DocGetCurMeterUnitDraw())
|
|
{
|
|
dRadius *= 1000;
|
|
}
|
|
|
|
if (!bAdd)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nLen = arrPts.length();
|
|
for (int j = 0; j < nLen; ++j)
|
|
{
|
|
AcDbCircle *pCir = new AcDbCircle(arrPts[j], AcGeVector3d::kZAxis, dRadius);
|
|
AcDbObjectId idCir = AddToCurrentSpace(pCir, Adesk::kTrue);
|
|
Entity ent;
|
|
acdbGetAdsName(ent.name, idCir);
|
|
if (bIsNew)
|
|
{
|
|
m_ssNewCir += ent;
|
|
}
|
|
else
|
|
{
|
|
m_ssShowCir += ent;
|
|
}
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::ShowProtectRadius( PickSet &ss )
|
|
{
|
|
acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);
|
|
long nLen = ss.Length();
|
|
for (long i = 0; i < nLen; ++i)
|
|
{
|
|
Entity ent(ss[i]);
|
|
ShowProtectRadius(ent);
|
|
}
|
|
acDocManager->unlockDocument(curDoc());
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::SetPickset(PickSet ss)
|
|
{
|
|
m_ss = ss;
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::InitDlgData()
|
|
{
|
|
CString sBlkName, sPec;
|
|
int nNum = 0;
|
|
double dScale = 0.0;
|
|
double dRadius = 0.0;
|
|
bool bDim = false;
|
|
bool bAutoScale = true;
|
|
AcDbObjectId idTextStyle;
|
|
double dTextHeight = 0.0;
|
|
CString sGrade;
|
|
int nScaleType = 0;
|
|
int nSpecType = -1;
|
|
CString sTextStyle;
|
|
long l = 0;
|
|
for(; l < m_ss.Length(); l++)
|
|
{
|
|
OPENOBJ_BEGIN(m_ss[l], AcDb::kForRead, TDbFireExtinguisher, pFireExt);
|
|
if(pFireExt != NULL)
|
|
{
|
|
sBlkName = GetBlkNameById(pFireExt->GetBlock2d());
|
|
sPec = pFireExt->GetSpec();
|
|
nNum = pFireExt->GetNum();
|
|
dScale = pFireExt->GetScale();
|
|
dRadius = pFireExt->GetProtectRadius();
|
|
bDim = pFireExt->GetIsDim();
|
|
idTextStyle = pFireExt->GetTextStyleId();
|
|
dTextHeight = pFireExt->GetTextHeight();
|
|
sGrade = pFireExt->GetGrade();
|
|
nScaleType = pFireExt->GetScaleType();
|
|
nSpecType = pFireExt->GetSpecificationType();
|
|
OPENOBJ_BEGIN(idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle);
|
|
ASSERT(pStyle);
|
|
const TCHAR* pName = NULL;
|
|
if (pStyle->getName(pName) == Acad::eOk && pName != NULL)
|
|
sTextStyle = pName;
|
|
OPENOBJ_END();
|
|
if (l == 0)
|
|
{
|
|
SetScale(dScale);
|
|
SetTextHeight(dTextHeight);
|
|
m_sProtectRadius.Format(_T("%.2f"),dRadius);
|
|
SetCount(nNum);
|
|
GetSpecTypeByBlkName(sBlkName);
|
|
m_sSpecification = sPec;
|
|
m_sGrade = sGrade;
|
|
m_nScale = nScaleType;
|
|
m_nSpecificationType = nSpecType;
|
|
m_sTextStyle = sTextStyle;
|
|
if (bDim)
|
|
{
|
|
m_nDimType = 0;
|
|
}
|
|
else
|
|
{
|
|
m_nDimType = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_nSpecificationType != nSpecType)
|
|
{
|
|
m_nSpecificationType = -1;
|
|
}
|
|
|
|
if (m_sBlkName.Compare(sBlkName) != 0)
|
|
{
|
|
m_sBlkName = _T("");
|
|
}
|
|
|
|
if (m_sSpecification.Compare(sPec) != 0)
|
|
{
|
|
m_sSpecification = _T("");
|
|
m_bIsDiffPre = true;
|
|
}
|
|
|
|
if (m_sGrade.Compare(sGrade) != 0)
|
|
{
|
|
m_sGrade = _T("");
|
|
}
|
|
|
|
if (fabs(nNum - _tstof(m_sCount)) > 0.001)
|
|
{
|
|
m_sCount = _T("*多种*");
|
|
}
|
|
|
|
if (fabs(dScale - _tstof(m_sScale)) > 0.001)
|
|
{
|
|
m_sScale = _T("*多种*");
|
|
}
|
|
|
|
if (fabs(dRadius - _tstof(m_sProtectRadius)) > 0.1)
|
|
{
|
|
m_sProtectRadius = _T("*多种*");
|
|
}
|
|
|
|
if ((m_nDimType == 0 && !bDim) || (m_nDimType == 1 && bDim))
|
|
{
|
|
m_nDimType = -1;
|
|
}
|
|
|
|
if (m_nScale != nScaleType)
|
|
{
|
|
m_nScale = -1;
|
|
}
|
|
|
|
if (sTextStyle.Compare(m_sTextStyle) != 0)
|
|
{
|
|
m_sTextStyle = _T("");
|
|
}
|
|
|
|
if (fabs(dTextHeight - _tstof(m_sTextHeight)) > 0.001)
|
|
{
|
|
m_sTextHeight = _T("*多种*");
|
|
}
|
|
}
|
|
|
|
std::vector<int>::iterator it = m_vecCount.begin();
|
|
for (; it != m_vecCount.end(); it++)
|
|
{
|
|
if (*it == nNum)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (it == m_vecCount.end())
|
|
{
|
|
m_vecCount.push_back(nNum);
|
|
}
|
|
|
|
std::vector<double>::iterator it1 = m_vecScale.begin();
|
|
for (; it1 != m_vecScale.end(); it1++)
|
|
{
|
|
if (fabs(*it1 - dScale) < 0.1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (it1 == m_vecScale.end())
|
|
{
|
|
m_vecScale.push_back(dScale);
|
|
}
|
|
|
|
std::vector<double>::iterator it2 = m_vecProRadius.begin();
|
|
for (; it2 != m_vecProRadius.end(); it2++)
|
|
{
|
|
if (fabs(*it2 - dRadius) < 0.1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (it2 == m_vecProRadius.end())
|
|
{
|
|
m_vecProRadius.push_back(dRadius);
|
|
}
|
|
|
|
std::vector<CString>::iterator it3 = m_vecGrade.begin();
|
|
for (; it3 != m_vecGrade.end(); it3++)
|
|
{
|
|
if (*it3 == sGrade)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (it3 == m_vecGrade.end())
|
|
{
|
|
m_vecGrade.push_back(sGrade);
|
|
}
|
|
|
|
if (nSpecType == 0)
|
|
{
|
|
nSpecType = 1;
|
|
}
|
|
else if (nSpecType == 1)
|
|
{
|
|
nSpecType = 2;
|
|
}
|
|
else if (nSpecType == 2)
|
|
{
|
|
nSpecType = 9;
|
|
}
|
|
else if (nSpecType == 3)
|
|
{
|
|
nSpecType = 10;
|
|
}
|
|
std::set<int>::iterator it4 = m_setSpecification.begin();
|
|
it4 = m_setSpecification.find(nSpecType);
|
|
if (it4 == m_setSpecification.end())
|
|
{
|
|
m_setSpecification.insert(nSpecType);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
|
|
void CLayFireExtinguisherDlg::OnBnClickedOk()
|
|
{
|
|
CString sBlkName, sPec;
|
|
int nNum = 0;
|
|
double dScale = 0.0;
|
|
double dRadius = 0.0;
|
|
bool bDim = false;
|
|
bool bAutoScale = true;
|
|
AcDbObjectId idTextStyle;
|
|
double dTextHeight = 0.0;
|
|
CString sGrade;
|
|
int nScaleType = 0;
|
|
int nSpecType = -1;
|
|
CString sTextStyle;
|
|
long l = 0;
|
|
UpdateData(TRUE);
|
|
for(; l < m_ss.Length(); l++)
|
|
{
|
|
OPENOBJ_BEGIN(m_ss[l], AcDb::kForWrite, TDbFireExtinguisher, pFireExt);
|
|
if(pFireExt != NULL)
|
|
{
|
|
if (m_nSpecificationType != -1)
|
|
{
|
|
pFireExt->SetSpecificationType(m_nSpecificationType);
|
|
}
|
|
|
|
if (!m_sBlkName.IsEmpty())
|
|
{
|
|
sBlkName = GetSelBlkName();
|
|
AcDbObjectId id = GetBlkIdByName(sBlkName);
|
|
if (!id.isValid())
|
|
{
|
|
CString sBlkNum;
|
|
CString sDwb = g_csDwbPath + _T("TwtSys");
|
|
int nIndex = sBlkName.ReverseFind(_T('$'));
|
|
if (nIndex != -1)
|
|
{
|
|
int nSize = sBlkName.GetLength();
|
|
sBlkNum = sBlkName.Right(nSize - nIndex - 1);
|
|
}
|
|
XString xsTmp;
|
|
if(LoadDwbBlock(sDwb, sBlkNum, xsTmp) != RTNORM)
|
|
{
|
|
return ;
|
|
}
|
|
}
|
|
pFireExt->SetBlock2d(GetBlkIdByName(sBlkName));
|
|
}
|
|
|
|
if (m_sSpecification.Compare(_T("*多种*")) != 0)
|
|
{
|
|
pFireExt->SetSpec(m_sSpecification);
|
|
}
|
|
|
|
if (m_sGrade.Compare(_T("*多种*")) != 0)
|
|
{
|
|
pFireExt->SetGrade(m_sGrade);
|
|
}
|
|
|
|
if (m_vecCount.size() > 1)
|
|
{
|
|
m_wndNum.GetWindowText(m_sCount);
|
|
}
|
|
if (m_sCount.Compare(_T("*多种*")) != 0)
|
|
{
|
|
int nNum = GetCount();
|
|
pFireExt->SetNum(nNum);
|
|
}
|
|
|
|
if (m_vecScale.size() > 1)
|
|
{
|
|
m_wndScale.GetWindowText(m_sScale);
|
|
}
|
|
if (m_sScale.Compare(_T("*多种*")) != 0)
|
|
{
|
|
double dScale = GetScale();
|
|
pFireExt->SetScale(dScale);
|
|
}
|
|
|
|
if (m_vecProRadius.size() > 1)
|
|
{
|
|
m_wndProRadius.GetWindowText(m_sProtectRadius);
|
|
}
|
|
|
|
if (m_sProtectRadius.Compare(_T("*多种*")) != 0)
|
|
{
|
|
pFireExt->SetProtectRadius(_tstof(m_sProtectRadius));
|
|
}
|
|
|
|
if (m_nDimType != -1)
|
|
{
|
|
pFireExt->SetIsDim(IsDim() ? true : false);
|
|
}
|
|
|
|
if (m_nScale != -1)
|
|
{
|
|
pFireExt->SetScaleType(m_nScale);
|
|
}
|
|
|
|
if (m_sTextStyle.Compare(_T("*多种*")) != 0)
|
|
{
|
|
pFireExt->SetTextStyleId(GetTextStyleId(m_sTextStyle));
|
|
}
|
|
|
|
if (m_sTextHeight.Compare(_T("*多种*")) != 0)
|
|
{
|
|
pFireExt->SetTextHeight(_tstof(m_sTextHeight));
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnCbnKillfocusCmbProradius()
|
|
{
|
|
CString sData = m_sProtectRadius;
|
|
CString sText;
|
|
m_wndProRadius.GetWindowText(sText);
|
|
m_sProtectRadius = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0)
|
|
{
|
|
m_sProtectRadius = sData;
|
|
m_wndProRadius.SetWindowText(m_sProtectRadius);
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndProRadius.SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnCbnKillfocusCmbScale()
|
|
{
|
|
CString csData = m_sScale;
|
|
CString sText;
|
|
m_wndScale.GetWindowText(sText);
|
|
m_sScale = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0)
|
|
{
|
|
m_sScale= csData;
|
|
m_wndScale.SetWindowText(m_sScale);
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndScale.SetFocus();
|
|
}
|
|
}
|
|
|
|
void CLayFireExtinguisherDlg::OnCbnKillfocusCmbNum()
|
|
{
|
|
CString csData = m_sCount;
|
|
CString sText;
|
|
m_wndNum.GetWindowText(sText);
|
|
m_sCount = sText;
|
|
if ((_tstof(sText) <= 0.0 || !IsStrAllNum(sText)) && sText.Compare(_T("*多种*")) != 0 || sText.Find(_T('.')) >=0)
|
|
{
|
|
m_sCount= csData;
|
|
m_wndNum.SetWindowText(m_sCount);
|
|
UpdateData(FALSE);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
m_wndNum.SetFocus();
|
|
}
|
|
}
|