198 lines
3.9 KiB
C++
198 lines
3.9 KiB
C++
#include "stdafx.h"
|
|
#include "CJBWCDlg.h"
|
|
#include "KTSetting.h"
|
|
|
|
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
|
|
#ifndef ZWCAD
|
|
extern bool __cdecl acedLinetypeDialog(AcDbObjectId old_linetypeId
|
|
, bool IncludeByBlockByLayer
|
|
, TCHAR *&new_linetypeName
|
|
, AcDbObjectId &new_linetypeId);
|
|
|
|
extern bool __cdecl acedLineWeightDialog(AcDb::LineWeight oldLw, bool, AcDb::LineWeight &lw);
|
|
#else
|
|
extern bool __cdecl zcedLinetypeDialog(AcDbObjectId old_linetypeId
|
|
, bool IncludeByBlockByLayer
|
|
, TCHAR *&new_linetypeName
|
|
, AcDbObjectId &new_linetypeId);
|
|
|
|
extern bool __cdecl zcedLineWeightDialog(AcDb::LineWeight oldLw, bool, AcDb::LineWeight &lw);
|
|
#define acedLinetypeDialog zcedLinetypeDialog
|
|
#define acedLineWeightDialog zcedLinetypeDialog
|
|
#endif
|
|
|
|
IMPLEMENT_DYNAMIC(CJBWCDlg, CDialog)
|
|
|
|
CJBWCDlg::CJBWCDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(IDD_JBWC_DLG, pParent)
|
|
, m_dInsult(100)
|
|
, m_sLayer(_T("INSULATION"))
|
|
, m_sLnType(_T("TRACKS"))
|
|
{
|
|
m_nInsulColor = 6;
|
|
}
|
|
|
|
CJBWCDlg::~CJBWCDlg()
|
|
{
|
|
}
|
|
|
|
void CJBWCDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_dInsult);
|
|
DDX_Control(pDX, IDC_COMBO1, m_wndLayCombox);
|
|
DDX_CBString(pDX, IDC_COMBO1, m_sLayer);
|
|
DDX_Text(pDX, IDC_EDIT2, m_sLnType);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CJBWCDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CJBWCDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CJBWCDlg::OnBnClickedButton1)
|
|
ON_WM_CTLCOLOR()
|
|
ON_STN_CLICKED(IDC_STATIC_BW, &CJBWCDlg::OnStnClickedStaticBw)
|
|
END_MESSAGE_MAP()
|
|
|
|
static void GetCurDwgLayers(CStringArray &lstLayer)
|
|
{
|
|
AcDbLayerTable *pTbl = NULL;
|
|
AcDbDatabase *pDb = acdbCurDwg();
|
|
if (pDb != NULL)
|
|
{
|
|
if (Acad::eOk == pDb->getLayerTable(pTbl, AcDb::kForRead))
|
|
{
|
|
AcDbLayerTableIterator *pIt = NULL;
|
|
pTbl->newIterator(pIt);
|
|
|
|
if (pIt != NULL)
|
|
{
|
|
for (pIt->start(); !pIt->done(); pIt->step())
|
|
{
|
|
AcDbLayerTableRecord *pRec = NULL;
|
|
pIt->getRecord(pRec, AcDb::kForRead);
|
|
|
|
if (pRec != NULL)
|
|
{
|
|
const TCHAR *pszName = NULL;
|
|
pRec->getName(pszName);
|
|
|
|
if (pszName != NULL)
|
|
{
|
|
lstLayer.Add(pszName);
|
|
}
|
|
pRec->close();
|
|
}
|
|
}
|
|
delete pIt;
|
|
}
|
|
pTbl->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL CJBWCDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
//确认
|
|
KTSetting::InitLayer(_T("LAY_INSULATION"), true);
|
|
|
|
CStringArray lstLayer;
|
|
GetCurDwgLayers(lstLayer);
|
|
|
|
CString sLayer;
|
|
for (int i = 0; i < lstLayer.GetSize(); i++)
|
|
{
|
|
sLayer = lstLayer.GetAt(i);
|
|
m_wndLayCombox.AddString(sLayer);
|
|
|
|
if (sLayer.CompareNoCase(m_sLayer) == 0)
|
|
{
|
|
m_wndLayCombox.SetCurSel(i);
|
|
}
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CJBWCDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_sLayer.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请选图层!"));
|
|
return;
|
|
}
|
|
if (m_sLnType.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请选线型!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dInsult < 1.0)
|
|
{
|
|
AfxMessageBox(_T("保温层厚度国小!"));
|
|
return;
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CJBWCDlg::GetInsulation(InsulData& data) const
|
|
{
|
|
data.dThick = m_dInsult;
|
|
}
|
|
|
|
void CJBWCDlg::OnBnClickedButton1()
|
|
{
|
|
TCHAR* psznew_linetypeName = NULL;
|
|
AcDbObjectId new_linetypeId;
|
|
|
|
if ( acedLinetypeDialog(acdbCurDwg()->celtype(), false, psznew_linetypeName, new_linetypeId))
|
|
{
|
|
m_sLnType = psznew_linetypeName;
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
|
|
HBRUSH CJBWCDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC)
|
|
{
|
|
if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_BW)
|
|
{
|
|
COLORREF crColor = RGB(255, 255, 255);
|
|
|
|
if (m_nInsulColor == kColorByLayer)
|
|
{
|
|
//提取墙体图层的颜色
|
|
static int nColor = KTSetting::GetLayerColor(_T("LAY_INSUL"));
|
|
crColor = acedGetRGB(nColor);
|
|
}
|
|
else
|
|
{
|
|
crColor = acedGetRGB(m_nInsulColor);
|
|
}
|
|
|
|
CRect rc;
|
|
pWnd->GetClientRect(rc);
|
|
pDC->FillSolidRect(rc, crColor);
|
|
}
|
|
}
|
|
return hbr;
|
|
}
|
|
|
|
void CJBWCDlg::OnStnClickedStaticBw()
|
|
{
|
|
acedSetColorDialog(m_nInsulColor, Adesk::kFalse, m_nInsulColor);
|
|
if (m_nInsulColor == 0)
|
|
m_nInsulColor = kColorByLayer;
|
|
Invalidate();
|
|
}
|