245 lines
6.2 KiB
C++
245 lines
6.2 KiB
C++
// PipeChangeMatDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "PipeChangeMatDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
//***************************************************************************************************
|
|
// 变更管材
|
|
//***************************************************************************************************
|
|
|
|
void ChangePipeMatCmd()
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
CPipeChangeMatDlg dlg;
|
|
if(dlg.DoModal() != IDOK)
|
|
return;
|
|
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"),NULL);
|
|
|
|
PickSet ss(SS_FREE);
|
|
PickSet ssErr(SS_FREE);
|
|
if(SelectEntities(_T("\n请选择要变更的范围:<整张图>"), ss, rbMask) != RTNORM)
|
|
ss.Get(_T("X"), NULL, NULL, rbMask);
|
|
ss.Redraw(3);
|
|
TCHAR szTmp[32];
|
|
ads_getstring(0, _T("\n所有要修改管材的管线已经亮显。是否确认变更它们的管材?<N>:"), szTmp);
|
|
ss.Redraw(4);
|
|
if(_tcsicmp(szTmp, _T("Y")) != 0)
|
|
return;
|
|
|
|
|
|
long len = ss.Length();
|
|
for(long i=0;i<len;i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
int iMat = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMat);
|
|
if(iMat == dlg.m_iMatOld){
|
|
if(pPipe->upgradeOpen()==Acad::eOk) {
|
|
pPipe->SetMaterial(dlg.m_iMatNew);
|
|
if(dlg.m_bDn){ // 同时修改管径标注
|
|
CString csLable = pPipe->GetLabel();
|
|
double dDn = pPipe->GetDnDiameter();
|
|
CString csDim;
|
|
csDim.Format(_T("%s%.0f"), csLable, dDn);
|
|
if(csLable == dlg.m_csDnOld){
|
|
CString csVal;
|
|
if(!dlg.m_map.Lookup(csDim, csVal))
|
|
{
|
|
if(!dlg.m_map2.Lookup(csDim, csVal))
|
|
{
|
|
ssErr += ent;
|
|
continue;
|
|
}
|
|
}
|
|
XString xsText;
|
|
int num, numWith;
|
|
StringAnalysis((const TCHAR*)csVal, xsText, &num, &numWith);
|
|
CString csLable2 = (const TCHAR*)xsText;
|
|
if(csLable2 == dlg.m_csDnNew){
|
|
pPipe->SetLabel((const TCHAR*)xsText);
|
|
pPipe->SetDnDiameter(num);
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
pPipe->downgradeOpen();
|
|
ssErr += ent;
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
len = ssErr.Length();
|
|
if(len > 0)
|
|
{
|
|
adsout << _T("还有一些管线由于没有对应管径,无法修改其标注。已选中");
|
|
ads_sssetfirst(ssErr, ssErr);
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPipeChangeMatDlg dialog
|
|
|
|
|
|
CPipeChangeMatDlg::CPipeChangeMatDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CPipeChangeMatDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CPipeChangeMatDlg)
|
|
m_bDn = FALSE;
|
|
m_csDnNew = _T("DN");
|
|
m_csDnOld = _T("De");
|
|
m_iMatNew = -1;
|
|
m_iMatOld = -1;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CPipeChangeMatDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CPipeChangeMatDlg)
|
|
DDX_Control(pDX, IDC_COMBO_OLD, m_comboMatOld);
|
|
DDX_Control(pDX, IDC_COMBO_NEW, m_comboMatNew);
|
|
DDX_Check(pDX, IDC_CHECK_DN, m_bDn);
|
|
DDX_CBString(pDX, IDC_COMBO_DN_NEW, m_csDnNew);
|
|
DDX_CBString(pDX, IDC_COMBO_DN_OLD, m_csDnOld);
|
|
DDX_CBIndex(pDX, IDC_COMBO_NEW, m_iMatNew);
|
|
DDX_CBIndex(pDX, IDC_COMBO_OLD, m_iMatOld);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CPipeChangeMatDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CPipeChangeMatDlg)
|
|
ON_BN_CLICKED(IDC_CHECK_DN, OnCheckDn)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CPipeChangeMatDlg message handlers
|
|
|
|
BOOL CPipeChangeMatDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
XStringList lstMat;
|
|
GetPipeMaterialList(lstMat);
|
|
for(int i=0;i<lstMat.Length();i++){
|
|
m_comboMatOld.AddString(lstMat[i]);
|
|
m_comboMatNew.AddString(lstMat[i]);
|
|
}
|
|
OnCheckDn();
|
|
m_comboMatOld.SetCurSel(7);
|
|
m_comboMatNew.SetCurSel(0);
|
|
|
|
m_grid.Clear();
|
|
m_grid.Create(this, IDC_LIST_PIPE);
|
|
m_grid.FitLastCol();
|
|
m_grid.AppendCol(_T("标注样式1"), 90);
|
|
m_grid.AppendCol(_T("标注样式2"), 90);
|
|
m_grid.SetColPosFix();
|
|
m_grid.SetColFixLength();
|
|
m_grid.SetNoPaste();
|
|
|
|
|
|
ResetGrid();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CPipeChangeMatDlg::ResetGrid()
|
|
{
|
|
m_grid.Clear();
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(0, 0).SetText(_T("De20"));
|
|
m_grid.GetCell(0, 1).SetText(_T("DN15"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(1, 0).SetText(_T("De25"));
|
|
m_grid.GetCell(1, 1).SetText(_T("DN20"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(2, 0).SetText(_T("De32"));
|
|
m_grid.GetCell(2, 1).SetText(_T("DN25"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(3, 0).SetText(_T("De40"));
|
|
m_grid.GetCell(3, 1).SetText(_T("DN25"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(4, 0).SetText(_T("De50"));
|
|
m_grid.GetCell(4, 1).SetText(_T("DN40"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(5, 0).SetText(_T("De63"));
|
|
m_grid.GetCell(5, 1).SetText(_T("DN50"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(6, 0).SetText(_T("De75"));
|
|
m_grid.GetCell(6, 1).SetText(_T("DN65"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(7, 0).SetText(_T("De90"));
|
|
m_grid.GetCell(7, 1).SetText(_T("DN75"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(8, 0).SetText(_T("De110"));
|
|
m_grid.GetCell(8, 1).SetText(_T("DN90"));
|
|
|
|
m_grid.AppendRow();
|
|
m_grid.GetCell(9, 0).SetText(_T("De160"));
|
|
m_grid.GetCell(9, 1).SetText(_T("DN150"));
|
|
|
|
}
|
|
|
|
void CPipeChangeMatDlg::OnCheckDn()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_DN_OLD);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_COMBO_DN_NEW);
|
|
CWnd *pWnd3 = GetDlgItem(IDC_LIST_PIPE);
|
|
if(m_bDn){
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
pWnd3->EnableWindow(TRUE);
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
pWnd3->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void CPipeChangeMatDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
if(m_iMatOld == m_iMatNew){
|
|
MessageBox(_T("原管材和新管材一致,无需变更!"));
|
|
return;
|
|
}
|
|
if(m_bDn){
|
|
for(m_grid.MoveToFirst(); !m_grid.IsOut(); m_grid.MoveToNext()){
|
|
WDGridRow *pRow = m_grid.CurRow();
|
|
CString csDn1 = (*pRow)[0].GetText().cs();
|
|
CString csDn2 = (*pRow)[1].GetText().cs();
|
|
if(csDn1 == _T("") || csDn2 == _T(""))
|
|
continue;
|
|
m_map.SetAt(csDn1, csDn2);
|
|
m_map2.SetAt(csDn2, csDn1);
|
|
}
|
|
|
|
}
|
|
CDialog::OnOK();
|
|
}
|