803 lines
21 KiB
C++
803 lines
21 KiB
C++
#include "stdafx.h"
|
|
#include "StdArx.h"
|
|
#include "PLGZDlg.h"
|
|
#include "dbobjptr.h"
|
|
|
|
#ifndef KTData_DB
|
|
#define KTData_DB _T("\\Plumbing.db")
|
|
#endif
|
|
|
|
IMPLEMENT_DYNAMIC(CPLGZDlg, CDialog)
|
|
|
|
CPLGZDlg::CPLGZDlg(CWnd *pParent /*=NULL*/)
|
|
: CDialog(CPLGZDlg::IDD, pParent)
|
|
, m_dBomEl(0.0)
|
|
, m_dH(3000.0)
|
|
, m_sMaterial(_T("钢筋混凝土"))
|
|
, m_sHatch(HATCH_DEFAULT)
|
|
, m_bAddHatch(TRUE)
|
|
, m_bInplace(false)
|
|
, m_sModel(_T(""))
|
|
{
|
|
m_nShape = 0;
|
|
m_dXSize = 500;
|
|
m_dYSize = 500;
|
|
|
|
m_sA = _T("");
|
|
m_sB = _T("");
|
|
m_sC = _T("");
|
|
m_sD = _T("Z-001");
|
|
//}}AFX_DATA_INIT
|
|
m_sBlockName = _T("_FZH.DWG");
|
|
m_pDb = NULL;
|
|
m_nCount = 0;
|
|
m_bIsBeam = 0;
|
|
}
|
|
|
|
CPLGZDlg::~CPLGZDlg(void)
|
|
{
|
|
}
|
|
|
|
void CPLGZDlg::DoDataExchange(CDataExchange *pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_CMBSTEEL, m_wndComSteel);
|
|
DDX_Control(pDX, IDC_CMB_YSIZE, m_wndComboYSize);
|
|
DDX_Control(pDX, IDC_CMB_XSIZE, m_wndComboXSize);
|
|
DDX_Control(pDX, IDC_CMB_SHAPE, m_wndComboShape);
|
|
|
|
DDX_Text(pDX, IDC_EDIT1, m_dBomEl);
|
|
DDX_Text(pDX, IDC_EDIT3, m_dH);
|
|
DDX_Text(pDX, IDC_EDITA, m_sA);
|
|
DDX_Text(pDX, IDC_EDITB, m_sB);
|
|
DDX_Text(pDX, IDC_EDITC, m_sC);
|
|
DDX_Text(pDX, IDC_EDITD, m_sD);
|
|
DDX_Text(pDX, IDC_EDIT2, m_sMaterial);
|
|
|
|
DDX_CBIndex(pDX, IDC_CMB_SHAPE, m_nShape);
|
|
DDX_Control(pDX, IDC_BTN_FILL, m_wndBtHatch);
|
|
DDX_Check(pDX, IDC_CHECK_HATCH, m_bAddHatch);
|
|
DDX_Text(pDX, IDC_BTN_FILL, m_sHatch);
|
|
DDX_CBString(pDX, IDC_CMBSTEEL, m_sModel);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CPLGZDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CCRZZDlg)
|
|
ON_CBN_SELCHANGE(IDC_CMB_SHAPE, OnSelchangeCmbShape)
|
|
ON_CBN_SELCHANGE(IDC_CMBSTEEL, OnSelchangeCmbsteel)
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDOK, &CPLGZDlg::OnBnClickedOk)
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDC_BTN_FILL, &CPLGZDlg::OnBnClickedBtnFill)
|
|
ON_BN_CLICKED(IDC_CHECK_HATCH, &CPLGZDlg::OnBnClickedCheckHatch)
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CPLGZDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
CString path = FilePath::GetSysDir() + KTData_DB;
|
|
if (!m_dbSQLite.InitADOServer(path))
|
|
{
|
|
AfxMessageBox(CString(_T("数据库初始化失败,请检查 sys")) + KTData_DB + _T("文件是否存在."));
|
|
return FALSE;
|
|
}
|
|
|
|
CString sXSize;
|
|
if (!m_bInplace)
|
|
{
|
|
sXSize.Format(_T("%d"), (int)m_dXSize);
|
|
int nCursel = m_wndComboXSize.FindString(0, sXSize);
|
|
if (nCursel != -1)
|
|
{
|
|
m_wndComboXSize.SetCurSel(nCursel);
|
|
}
|
|
else
|
|
{
|
|
m_wndComboXSize.SetWindowText(sXSize);
|
|
}
|
|
|
|
sXSize.Format(_T("%d"), (int)m_dYSize);
|
|
nCursel = m_wndComboYSize.FindString(0, sXSize);
|
|
if (nCursel != -1)
|
|
{
|
|
m_wndComboYSize.SetCurSel(nCursel);
|
|
}
|
|
else
|
|
{
|
|
m_wndComboYSize.SetWindowText(sXSize);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sXSize.Format(_T("%d"), (int)m_dXSize);
|
|
m_wndComboXSize.SetWindowText(sXSize);
|
|
sXSize.Format(_T("%d"), (int)m_dYSize);
|
|
m_wndComboYSize.SetWindowText(sXSize);
|
|
}
|
|
|
|
if (!m_wndPreview.SubclassDlgItem(IDC_STC_PICTURE, this))
|
|
return FALSE;
|
|
|
|
if (m_idCol.isValid())
|
|
{
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
OnSelchangeCmbShape();
|
|
|
|
#ifndef ZWCAD
|
|
#if ARX < 20
|
|
if (m_wndPreview.mpView)
|
|
m_wndPreview.mpView->setMode(AcGsView::k2DOptimized);
|
|
#else
|
|
AcGiVisualStyle style;
|
|
style.setType(AcGiVisualStyle::k2DWireframe);
|
|
if (m_wndPreview.mpView)
|
|
m_wndPreview.mpView->setVisualStyle(style);
|
|
#endif
|
|
#else
|
|
#if defined(R24)
|
|
if (m_wndPreview.mpView)
|
|
m_wndPreview.mpView->setMode(AcGsView::k2DOptimized);
|
|
#else
|
|
AcGiVisualStyle style;
|
|
style.setType(AcGiVisualStyle::k2DWireframe);
|
|
if (m_wndPreview.mpView)
|
|
m_wndPreview.mpView->setVisualStyle(style);
|
|
#endif
|
|
#endif
|
|
|
|
UpdateData(FALSE);
|
|
|
|
m_wndBtHatch.EnableWindow(m_bAddHatch);
|
|
|
|
CString sTitle;
|
|
if (m_bIsBeam)
|
|
{
|
|
sTitle.Format(_T("批量修改梁 (共匹配%d根相同梁)"), m_nCount);
|
|
|
|
GetDlgItem(IDC_STATIC_E)->SetWindowText(_T("顶标高:"));
|
|
GetDlgItem(IDC_STATIC_H)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT3)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STATIC_M)->ShowWindow(SW_HIDE);
|
|
}
|
|
else
|
|
{
|
|
sTitle.Format(_T("批量修改柱子 (共匹配%d根相同柱子)"), m_nCount);
|
|
}
|
|
SetWindowText(sTitle);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
AcDbObjectId CPLGZDlg::CreateIStellBlock()
|
|
{
|
|
double dA = _ttof(m_sA);
|
|
double dB = _ttof(m_sB);
|
|
double dC = _ttof(m_sC);
|
|
double dD = _ttof(m_sD);
|
|
|
|
AcGePoint3d ptGe[12], ptGeT;
|
|
ptGeT.set(0, 0, 0);
|
|
|
|
ptGeT.y += dA / 2.0;
|
|
ptGeT.x -= dB / 2.0;
|
|
ptGe[0] = ptGeT;
|
|
ptGe[1] = ptGe[0] + dB * AcGeVector3d::kXAxis;
|
|
ptGe[2] = ptGe[1] - dC * AcGeVector3d::kYAxis;
|
|
ptGe[3] = ptGe[2] - (dB - dD) / 2.0 * AcGeVector3d::kXAxis;
|
|
ptGe[4] = ptGe[3] - (dA - 2.0 * dC) * AcGeVector3d::kYAxis;
|
|
ptGe[5] = ptGe[4] + (dB - dD) / 2.0 * AcGeVector3d::kXAxis;
|
|
ptGe[6] = ptGe[5] - dC * AcGeVector3d::kYAxis;
|
|
ptGe[7] = ptGe[6] - dB * AcGeVector3d::kXAxis;
|
|
ptGe[8] = ptGe[7] + dC * AcGeVector3d::kYAxis;
|
|
ptGe[9] = ptGe[8] + (dB - dD) / 2.0 * AcGeVector3d::kXAxis;
|
|
ptGe[10] = ptGe[9] + (dA - 2.0 * dC) * AcGeVector3d::kYAxis;
|
|
ptGe[11] = ptGe[10] - (dB - dD) / 2.0 * AcGeVector3d::kXAxis;
|
|
|
|
AcDbBlockTableRecord *pRec = new AcDbBlockTableRecord;
|
|
pRec->setOrigin(AcGePoint3d::kOrigin);
|
|
pRec->setName(_T("*U"));
|
|
AcDbPolyline *pPl = new AcDbPolyline;
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
pPl->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl->setClosed(Adesk::kTrue);
|
|
pRec->appendAcDbEntity(pPl);
|
|
pPl->close();
|
|
|
|
AcDbBlockTable *pTable = NULL;
|
|
acdbCurDwg()->getBlockTable(pTable, AcDb::kForWrite);
|
|
|
|
if (pTable != NULL)
|
|
{
|
|
pTable->add(m_idStellCol, pRec);
|
|
pRec->close();
|
|
pTable->close();
|
|
}
|
|
return m_idStellCol;
|
|
}
|
|
|
|
AcDbObjectId CPLGZDlg::CreateOStellBlock()
|
|
{
|
|
AcGePoint3d ptGe[8], ptGeT;
|
|
ptGeT.set(0, 0, 0);
|
|
|
|
double dA = _ttof(m_sA);
|
|
double dB = _ttof(m_sB);
|
|
double dC = _ttof(m_sC);
|
|
double dD = _ttof(m_sD);
|
|
|
|
//ptGeT.x += dB / 2.0;
|
|
ptGeT.y += (dA - 2 * dC) / 2.0;
|
|
ptGe[0] = ptGeT;
|
|
ptGe[1] = ptGe[0] + dC * AcGeVector3d::kYAxis;
|
|
ptGe[2] = ptGe[1] + dB * AcGeVector3d::kXAxis;
|
|
ptGe[3] = ptGe[2] - dA * AcGeVector3d::kYAxis;
|
|
ptGe[4] = ptGe[3] - dB * AcGeVector3d::kXAxis;
|
|
ptGe[5] = ptGe[4] + dC * AcGeVector3d::kYAxis;
|
|
ptGe[6] = ptGe[5] + (dB - dD) * AcGeVector3d::kXAxis;
|
|
ptGe[7] = ptGe[6] + (dA - 2.0 * dC) * AcGeVector3d::kYAxis;
|
|
|
|
AcDbBlockTableRecord *pRec = new AcDbBlockTableRecord;
|
|
pRec->setOrigin(AcGePoint3d::kOrigin);
|
|
pRec->setName(_T("*U"));
|
|
//AcDbPolyline* pPl = new AcDbPolyline;
|
|
//for (int i = 0;i < 8;i++)
|
|
//{
|
|
// pPl->addVertexAt(i,ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
//}
|
|
//pPl->setClosed(Adesk::kTrue);
|
|
//pRec->appendAcDbEntity(pPl);
|
|
//pPl->close();
|
|
|
|
ptGeT = ptGe[2];
|
|
AcDbLine *pLine1 = new AcDbLine(ptGe[2], ptGeT.mirror(AcGePlane::kYZPlane));
|
|
pLine1->setVisibility(AcDb::kInvisible);
|
|
pRec->appendAcDbEntity(pLine1);
|
|
pLine1->close();
|
|
|
|
ptGeT = ptGe[3];
|
|
pLine1 = new AcDbLine(ptGe[3], ptGeT.mirror(AcGePlane::kYZPlane));
|
|
pLine1->setVisibility(AcDb::kInvisible);
|
|
pRec->appendAcDbEntity(pLine1);
|
|
pLine1->close();
|
|
|
|
AcDbPolyline *pPl2 = new AcDbPolyline;
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
ptGe[i].mirror(AcGePlane::kYZPlane);
|
|
pPl2->addVertexAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
|
|
}
|
|
pPl2->setClosed(Adesk::kTrue);
|
|
pRec->appendAcDbEntity(pPl2);
|
|
pPl2->close();
|
|
|
|
AcDbBlockTable *pTable = NULL;
|
|
acdbCurDwg()->getBlockTable(pTable, AcDb::kForWrite);
|
|
|
|
if (pTable != NULL)
|
|
{
|
|
pTable->add(m_idStellCol, pRec);
|
|
pRec->close();
|
|
pTable->close();
|
|
}
|
|
return m_idStellCol;
|
|
}
|
|
|
|
void CPLGZDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
CString sXScale, sYScale;
|
|
m_wndComboXSize.GetWindowText(sXScale);
|
|
m_wndComboYSize.GetWindowText(sYScale);
|
|
|
|
m_dYSize = _ttof(sYScale);
|
|
m_dXSize = _ttof(sXScale);
|
|
|
|
if (m_nShape == 0)//矩形
|
|
{
|
|
if (m_dXSize < 1.e-1 || m_dYSize < 1.e-1)
|
|
{
|
|
AfxMessageBox(_T("柱子尺寸不正确!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (m_nShape == 1) //圆形
|
|
{
|
|
if (m_dXSize < 1.e-1)
|
|
{
|
|
AfxMessageBox(_T("柱子尺寸不正确!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (m_nShape == 2)//正六边形
|
|
{
|
|
if (m_dXSize < 1.e-1)
|
|
{
|
|
AfxMessageBox(_T("柱子尺寸不正确!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (m_nShape == 3)//工字形
|
|
{
|
|
m_dYSize = 1.0;
|
|
m_dXSize = 1.0;
|
|
m_idStellCol = CreateIStellBlock();
|
|
}
|
|
|
|
if (m_nShape == 4)//槽钢
|
|
{
|
|
m_dYSize = 1.0;
|
|
m_dXSize = 1.0;
|
|
m_idStellCol = CreateOStellBlock();
|
|
}
|
|
|
|
if (m_dH < 1.e-1)
|
|
{
|
|
AfxMessageBox(_T("柱子高度尺寸不正确!"));
|
|
return;
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
BOOL CPLGZDlg::GetColumnData(ColumnParam& ColParam) const
|
|
{
|
|
ColParam.m_dXScale = m_dXSize;
|
|
ColParam.m_dYScale = m_dYSize;
|
|
ColParam.m_nShape = m_nShape;
|
|
_tcscpy(ColParam.m_sBlockName, m_sBlockName);
|
|
ColParam.m_idRec = m_idStellCol;
|
|
ColParam.m_nShape = m_nShape;
|
|
|
|
ColParam.m_dH = m_dH;
|
|
ColParam.m_dBomEl = m_dBomEl;
|
|
_tcscpy(ColParam.m_sMaterial, m_sMaterial);
|
|
|
|
if (m_nShape == 1 || m_nShape == 2) // 圆形,正六边
|
|
{
|
|
// 不然会变形
|
|
ColParam.m_dYScale = ColParam.m_dXScale;
|
|
}
|
|
else if (m_nShape == 3 || m_nShape == 4) // 工字,槽钢
|
|
{
|
|
|
|
ColParam.m_dYScale = ColParam.m_dXScale = 1;
|
|
}
|
|
|
|
ColParam.m_dSizes[0] = _ttof(m_sA);
|
|
ColParam.m_dSizes[1] = _ttof(m_sB);
|
|
ColParam.m_dSizes[2] = _ttof(m_sC);
|
|
ColParam.m_dSizes[3] = _ttof(m_sD);
|
|
|
|
_tcscpy(ColParam.m_sHatch, m_sHatch);
|
|
_tcscpy(ColParam.m_sModel, m_sModel);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CPLGZDlg::SetColumnData(ColumnParam &data, int nCount,BOOL bIsBeam)
|
|
{
|
|
m_sHatch = data.m_sHatch;
|
|
if (m_sHatch == HATCH_NO_NEED)
|
|
m_bAddHatch = FALSE;
|
|
else
|
|
m_bAddHatch = TRUE;
|
|
|
|
m_sModel = data.m_sModel;
|
|
m_sBlockName = data.m_sBlockName;
|
|
|
|
m_sA.Format(_T("%g"), data.m_dSizes[0]);
|
|
m_sB.Format(_T("%g"), data.m_dSizes[1]);
|
|
m_sC.Format(_T("%g"), data.m_dSizes[2]);
|
|
m_sD.Format(_T("%g"), data.m_dSizes[3]);
|
|
|
|
m_dXSize = data.m_dXScale;
|
|
m_dYSize = data.m_dYScale;
|
|
|
|
m_nShape = data.m_nShape;
|
|
m_dBomEl = data.m_dBomEl;
|
|
m_dH = data.m_dH;
|
|
m_sMaterial = data.m_sMaterial;
|
|
m_bInplace = false;
|
|
m_nCount = nCount;
|
|
m_bIsBeam = bIsBeam;
|
|
return FALSE;
|
|
}
|
|
|
|
void CPLGZDlg::OnSelchangeCmbsteel()
|
|
{
|
|
UpdateData();
|
|
//加载数据
|
|
int nCursel = m_wndComSteel.GetCurSel();
|
|
if (nCursel != -1)
|
|
{
|
|
CString sText, sSQL;
|
|
m_wndComSteel.GetLBText(nCursel, sText);
|
|
if (m_nShape == 3)
|
|
{
|
|
sSQL.Format(_T("select A,B,C,D from AecSteeldata where [型钢类型]='工字钢' and [型钢型号]='%s'"), sText);
|
|
}
|
|
else if (m_nShape == 4)
|
|
{
|
|
sSQL.Format(_T("select A,B,C,D from AecSteeldata where [型钢类型]='槽钢' and [型钢型号]='%s'"), sText);
|
|
}
|
|
CStringArray arValues;
|
|
m_dbSQLite.GetSelData(sSQL, arValues);
|
|
|
|
if (arValues.GetSize() == 4)
|
|
{
|
|
m_sA = arValues.GetAt(0);
|
|
m_sB = arValues.GetAt(1);
|
|
m_sC = arValues.GetAt(2);
|
|
m_sD = arValues.GetAt(3);
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CPLGZDlg::OnSelchangeCmbShape()
|
|
{
|
|
if (!m_bInplace)
|
|
UpdateData();
|
|
|
|
if (m_nShape >= 0 && m_nShape <= 2)
|
|
{
|
|
GetDlgItem(IDC_STEELTYPE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CMBSTEEL)->ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_A)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_B)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_C)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_D)->ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_EDITA)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDITB)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDITC)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDITD)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
if (m_nShape == 0) //矩形
|
|
{
|
|
m_sBlockName = _T("_FZH.DWG");
|
|
GetDlgItem(IDC_STC_XSIZE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_STC_YSIZE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_STC_DIAMETER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_EDGESIZE)->ShowWindow(SW_HIDE);
|
|
m_wndComboXSize.ShowWindow(SW_SHOW);
|
|
m_wndComboYSize.ShowWindow(SW_SHOW);
|
|
}
|
|
else if (m_nShape == 1) //圆形
|
|
{
|
|
m_sBlockName = _T("_YZH.DWG");
|
|
GetDlgItem(IDC_STC_XSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_YSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_DIAMETER)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_STC_EDGESIZE)->ShowWindow(SW_HIDE);
|
|
m_wndComboXSize.ShowWindow(SW_SHOW);
|
|
m_wndComboYSize.ShowWindow(SW_HIDE);
|
|
}
|
|
else if (m_nShape == 2) // 正六边形
|
|
{
|
|
m_sBlockName = _T("_DBXZH6.DWG");
|
|
GetDlgItem(IDC_STC_XSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_YSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_DIAMETER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_EDGESIZE)->ShowWindow(SW_SHOW);
|
|
m_wndComboXSize.ShowWindow(SW_SHOW);
|
|
m_wndComboYSize.ShowWindow(SW_HIDE);
|
|
}
|
|
else if (m_nShape == 3)// 工字形
|
|
{
|
|
m_sBlockName = _T("_ZZH.dwg");
|
|
GetDlgItem(IDC_STC_XSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_YSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_DIAMETER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_EDGESIZE)->ShowWindow(SW_HIDE);
|
|
m_wndComboXSize.ShowWindow(SW_HIDE);
|
|
m_wndComboYSize.ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_STEELTYPE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CMBSTEEL)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_A)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_B)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_C)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_D)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_EDITA)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITB)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITC)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITD)->ShowWindow(SW_SHOW);
|
|
|
|
//加载数据
|
|
|
|
CString sSQL = _T("select [型钢型号] from AecSteeldata where [型钢类型]='工字钢' order by A DESC");
|
|
|
|
CStringArray arValues;
|
|
m_dbSQLite.GetSelData(sSQL, arValues);
|
|
|
|
m_wndComSteel.ResetContent();
|
|
for (int i = 0; i < arValues.GetSize(); i++)
|
|
{
|
|
m_wndComSteel.AddString(arValues.GetAt(i));
|
|
}
|
|
if (!m_bInplace)
|
|
{
|
|
m_wndComSteel.SetCurSel(0);
|
|
OnSelchangeCmbsteel();
|
|
}
|
|
}
|
|
else if (m_nShape == 4) // 槽钢
|
|
{
|
|
m_sBlockName = _T("_OZH.dwg");
|
|
GetDlgItem(IDC_STC_XSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_YSIZE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_DIAMETER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STC_EDGESIZE)->ShowWindow(SW_HIDE);
|
|
m_wndComboXSize.ShowWindow(SW_HIDE);
|
|
m_wndComboYSize.ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_STEELTYPE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CMBSTEEL)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_A)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_B)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_C)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_D)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_EDITA)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITB)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITC)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDITD)->ShowWindow(SW_SHOW);
|
|
|
|
//加载数据
|
|
CString sSQL = _T("select [型钢型号] from AecSteeldata where [型钢类型]='槽钢' order by A DESC");
|
|
|
|
CStringArray arValues;
|
|
m_dbSQLite.GetSelData(sSQL, arValues);
|
|
|
|
m_wndComSteel.ResetContent();
|
|
for (int i = 0; i < arValues.GetSize(); i++)
|
|
{
|
|
m_wndComSteel.AddString(arValues.GetAt(i));
|
|
}
|
|
if (!m_bInplace)
|
|
{
|
|
m_wndComSteel.SetCurSel(0);
|
|
OnSelchangeCmbsteel();
|
|
}
|
|
}
|
|
PreviewColumn();
|
|
}
|
|
|
|
void CPLGZDlg::PreviewColumn()
|
|
{
|
|
CString sPath;
|
|
sPath = FilePath::GetSysDir();
|
|
sPath.Replace(_T("\\sys"), _T("\\Support"));
|
|
CString sDwgFile = sPath + _T("\\Cells\\") + m_sBlockName;
|
|
|
|
m_wndPreview.clearAll();
|
|
|
|
if (m_pDb != NULL)
|
|
delete m_pDb;
|
|
|
|
m_pDb = new AcDbDatabase(Adesk::kFalse);
|
|
Acad::ErrorStatus es = m_pDb->readDwgFile(sDwgFile);
|
|
if (es != Acad::eOk)
|
|
{
|
|
AfxMessageBox(CString(_T("打开文件失败 \"")) + sDwgFile + _T("\""));
|
|
delete m_pDb;
|
|
m_pDb = NULL;
|
|
return;
|
|
}
|
|
|
|
// now initialise the drawing control
|
|
InitDrawingControl(m_pDb);
|
|
Invalidate();
|
|
RedrawWindow();
|
|
}
|
|
|
|
Acad::ErrorStatus CPLGZDlg::InitDrawingControl(AcDbDatabase *pDb, const TCHAR *space)
|
|
{
|
|
// have we got a valid drawing
|
|
if (pDb == NULL)
|
|
return Acad::eNullBlockName;
|
|
|
|
AcDbBlockTableRecordPointer spaceRec(space, pDb, AcDb::kForRead);
|
|
// if ok
|
|
if (spaceRec.openStatus() == Acad::eOk)
|
|
{
|
|
// initialize the preview control
|
|
m_wndPreview.init(true);
|
|
// set the view to the *Active* AutoCAD view
|
|
|
|
AcGeMatrix3d xform;
|
|
SetViewTo(m_wndPreview.mpView, pDb, xform);
|
|
// tell the view to display this space
|
|
m_wndPreview.view()->add(spaceRec.object(), m_wndPreview.model());
|
|
}
|
|
return spaceRec.openStatus();
|
|
}
|
|
|
|
bool CPLGZDlg::GetActiveViewPortInfo(AcDbDatabase *pDb, ads_real &height, ads_real &width, AcGePoint3d &target, AcGeVector3d &viewDir, ads_real &viewTwist, bool getViewCenter)
|
|
{
|
|
// if not ok
|
|
if (pDb == NULL)
|
|
return false;
|
|
|
|
//以下{}导致崩溃
|
|
//{
|
|
// get the current working database as a backup
|
|
//AcDbDatabase *workingDataBase = acdbHostApplicationServices()->workingDatabase();
|
|
// now set the working database
|
|
//acdbHostApplicationServices()->setWorkingDatabase(pDb);
|
|
|
|
// make sure the active view port is uptodate
|
|
//acedVports2VportTableRecords();
|
|
//}
|
|
|
|
// open the view port records
|
|
AcDbViewportTable *pVTable = NULL;
|
|
Acad::ErrorStatus es = pDb->getViewportTable(pVTable, AcDb::kForRead);
|
|
// if we opened them ok
|
|
if (es == Acad::eOk)
|
|
{
|
|
AcDbViewportTableRecord *pViewPortRec = NULL;
|
|
es = pVTable->getAt(_T("*Active"), pViewPortRec, AcDb::kForRead);
|
|
if (es == Acad::eOk)
|
|
{
|
|
// get the height of the view
|
|
height = pViewPortRec->height();
|
|
// get the width
|
|
width = pViewPortRec->width();
|
|
// if the user wants the center of the viewport used
|
|
if (getViewCenter == true)
|
|
{
|
|
struct resbuf rb;
|
|
memset(&rb, 0, sizeof(struct resbuf));
|
|
// get the system var VIEWCTR
|
|
acedGetVar(_T("VIEWCTR"), &rb);
|
|
// set that as the target
|
|
target = AcGePoint3d(rb.resval.rpoint[X], rb.resval.rpoint[Y], rb.resval.rpoint[Z]);
|
|
}
|
|
// we want the viewports camera target setting
|
|
else
|
|
{
|
|
// get the target of the view
|
|
target = pViewPortRec->target();
|
|
}
|
|
|
|
// get the view direction
|
|
viewDir = pViewPortRec->viewDirection();
|
|
// get the view twist of the viewport
|
|
viewTwist = pViewPortRec->viewTwist();
|
|
}
|
|
// close after use
|
|
pVTable->close();
|
|
pViewPortRec->close();
|
|
}
|
|
|
|
//以下导致崩溃
|
|
// now restore the original working database
|
|
//acdbHostApplicationServices()->setWorkingDatabase(workingDataBase);
|
|
|
|
return (true);
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// set the passed AcGsView to the *Active* AutoCAD AcDbDatabase view
|
|
void CPLGZDlg::SetViewTo(AcGsView *pView, AcDbDatabase *pDb, AcGeMatrix3d &viewMat)
|
|
{
|
|
// we are going to set the view to the current view of the drawing
|
|
// The overall approach is to calculate the extents of the database in the coordinate system of the view
|
|
// Calculate the extents in WCS
|
|
AcGePoint3d extMax = pDb->extmax();
|
|
AcGePoint3d extMin = pDb->extmin();
|
|
|
|
// get the view port information - see parameter list
|
|
ads_real height = 0.0, width = 0.0, viewTwist = 0.0;
|
|
AcGePoint3d targetView;
|
|
AcGeVector3d viewDir;
|
|
GetActiveViewPortInfo(pDb, height, width, targetView, viewDir, viewTwist, true);
|
|
|
|
// we are only interested in the directions of the view, not the sizes, so we normalise.
|
|
viewDir = viewDir.normal();
|
|
|
|
//**********************************************
|
|
// Our view coordinate space consists of z direction
|
|
// get a perp vector off the z direction
|
|
// Make sure its normalised
|
|
AcGeVector3d viewXDir = viewDir.perpVector().normal();
|
|
// correct the x angle by applying the twist
|
|
viewXDir = viewXDir.rotateBy(viewTwist, -viewDir);
|
|
// now we can work out y, this is of course perp to the x and z directions. No need to normalise this,
|
|
// as we know that x and z are of unit length, and perpendicular, so their cross product must be on unit length
|
|
AcGeVector3d viewYDir = viewDir.crossProduct(viewXDir);
|
|
|
|
// find a nice point around which to transform the view. We'll use the same point as the center of the view.
|
|
AcGePoint3d boxCenter = extMin + 0.5 * (extMax - extMin);
|
|
|
|
//**********************************************
|
|
// create a transform from WCS to View space
|
|
// this represents the transformation from WCS to the view space. (Actually not quite since
|
|
// we are keeping the fixed point as the center of the box for convenience )
|
|
viewMat = AcGeMatrix3d::alignCoordSys(boxCenter, AcGeVector3d::kXAxis, AcGeVector3d::kYAxis, AcGeVector3d::kZAxis,
|
|
boxCenter, viewXDir, viewYDir, viewDir).inverse();
|
|
|
|
AcDbExtents wcsExtents(extMin, extMax);
|
|
// now we have the view Extents
|
|
AcDbExtents viewExtents = wcsExtents;
|
|
// transforms the extents in WCS->view space
|
|
viewExtents.transformBy(viewMat);
|
|
|
|
//**********************************************
|
|
// get the extents of the AutoCAD view
|
|
double xMax = fabs(viewExtents.maxPoint().x - viewExtents.minPoint().x);
|
|
double yMax = fabs(viewExtents.maxPoint().y - viewExtents.minPoint().y);
|
|
|
|
//**********************************************
|
|
// setup the view
|
|
AcGePoint3d eye = boxCenter + viewDir;
|
|
|
|
// upvector
|
|
pView->setView(eye, boxCenter, viewYDir, xMax, yMax);
|
|
// update the gsView
|
|
if (pView != NULL)
|
|
{
|
|
pView->invalidate();
|
|
pView->update();
|
|
}
|
|
}
|
|
|
|
void CPLGZDlg::OnDestroy()
|
|
{
|
|
CDialog::OnDestroy();
|
|
|
|
m_wndPreview.clearAll();
|
|
if (m_pDb != NULL)
|
|
delete m_pDb;
|
|
m_pDb = NULL;
|
|
}
|
|
|
|
extern bool __cdecl acedHatchPalletteDialog(wchar_t const *, bool, wchar_t *&);
|
|
void CPLGZDlg::OnBnClickedBtnFill()
|
|
{
|
|
UpdateData();
|
|
TCHAR *psz = new TCHAR[1024];
|
|
::memset(psz, 0, sizeof(TCHAR) * 1024);
|
|
|
|
CString sHatch(m_sMaterial);
|
|
if (!m_sHatch.IsEmpty())
|
|
sHatch = m_sHatch;
|
|
|
|
if (acedHatchPalletteDialog(sHatch, false, psz))
|
|
{
|
|
m_sHatch = psz;
|
|
m_wndBtHatch.SetWindowText(m_sHatch);
|
|
}
|
|
|
|
delete[] psz;
|
|
}
|
|
|
|
void CPLGZDlg::OnBnClickedCheckHatch()
|
|
{
|
|
UpdateData();
|
|
m_wndBtHatch.EnableWindow(m_bAddHatch);
|
|
if (!m_bAddHatch)
|
|
m_sHatch = HATCH_NO_NEED;
|
|
else
|
|
m_sHatch = HATCH_DEFAULT;
|
|
|
|
UpdateData(FALSE);
|
|
}
|