2787 lines
70 KiB
C++
2787 lines
70 KiB
C++
#include "stdafx.h"
|
|
#include "StdArx.h"
|
|
#include "HFitingStyleDlg.h"
|
|
#include "DuctlineTools.h"
|
|
#include "PropCtrl.h"
|
|
#include "KTCadUtility.h"
|
|
#include "HVACFittingToolkit.h"
|
|
|
|
#define IDD_GRID_PREVIEW 1001
|
|
#define IDC_PROPTREE_EQUIINFO 2001
|
|
#define FLANGE_LENGTH_ON_FITTING 50.0
|
|
|
|
IMPLEMENT_DYNAMIC(CHFitingStyleDlg, CDialog)
|
|
|
|
extern double MayAsMUnit(double dVal);
|
|
|
|
|
|
CHFitingStyleDlg::CHFitingStyleDlg(UINT nFitType, int nSectType,AcDbObjectId idToEdit/* = NULL*/, CWnd* pParent/* = NULL*/)
|
|
: CDialog(CHFitingStyleDlg::IDD, pParent)
|
|
, m_bFloorDir(FALSE)
|
|
{
|
|
// 由构造参数设置设备类型
|
|
m_nFitType = nFitType;
|
|
m_idToEdit = idToEdit;
|
|
m_pCurRoot = NULL;
|
|
m_iRadSectType = nSectType - 1;//0rect 1 circle
|
|
// 默认连接件索引
|
|
m_iCurDefaIndexRow = 0;
|
|
m_iCurDefaIndexCol = 0;
|
|
|
|
m_nFitCode = 1;
|
|
|
|
m_pAdoUi = new CUIISQLiteServer;
|
|
if ( !DuctlineTools::getSqliteDB(_T("HvacConfig.db"), *m_pAdoUi))
|
|
{
|
|
AfxMessageBox(_T("未找到数据库文件HvacConfig.db,请重新安装!"));
|
|
delete m_pAdoUi;
|
|
return;
|
|
}
|
|
|
|
//{{AFX_DATA_INIT(CHFitingStyleDlg)
|
|
m_csSysType = _T("");
|
|
m_bChkSingleLine = FALSE;
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
CHFitingStyleDlg::~CHFitingStyleDlg()
|
|
{
|
|
}
|
|
|
|
void CHFitingStyleDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CHFitingStyleDlg)
|
|
DDX_Radio(pDX, IDC_RAD_RECT, m_iRadSectType);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_CHECK1, m_wndFllowDirBt);
|
|
DDX_Check(pDX, IDC_CHECK1, m_bFloorDir);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CHFitingStyleDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CHFitingStyleDlg)
|
|
ON_NOTIFY(NM_CLICK, IDD_GRID_PREVIEW, OnGridPreviewClick)
|
|
ON_BN_CLICKED(IDC_RAD_RECT, OnRadRect)
|
|
ON_BN_CLICKED(IDC_RAD_ROUND, OnRadRoun)
|
|
ON_MESSAGE(WM_SELECTCHANGED, OnGridSelectChanged)
|
|
ON_MESSAGE(WM_EBTNCLICK, OnGridButtonClick)
|
|
ON_WM_DESTROY()
|
|
ON_BN_CLICKED(IDOK, &CHFitingStyleDlg::OnBnClickedOk)
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CHFitingStyleDlg::OnInitDialog()
|
|
{
|
|
//属性控件
|
|
DWORD dwStyle = WS_CHILD|WS_VISIBLE | PTS_NOTIFY;
|
|
CRect rcProp;
|
|
GetDlgItem(IDC_PIC_INFORECT)->GetWindowRect(&rcProp);
|
|
ScreenToClient(rcProp);
|
|
|
|
m_wndPorpInfo.SetInfoHeigh(25);
|
|
m_wndPorpInfo.Create(dwStyle, rcProp, this, IDC_PROPTREE_EQUIINFO);
|
|
|
|
// 示意图表格
|
|
CRect rcPreview;
|
|
GetDlgItem(IDC_PIC_PREVIEW)->GetWindowRect(rcPreview);
|
|
ScreenToClient(rcPreview);
|
|
m_wndGridPreview.Create(rcPreview, this, IDD_GRID_PREVIEW, WS_CHILD | WS_VISIBLE);
|
|
m_wndGridPreview.SetLineWidth(5);
|
|
m_wndGridPreview.SetBkColor(RGB(235, 233, 237));
|
|
m_wndGridPreview.SetGridLineColor(RGB(235, 233, 237));
|
|
m_wndGridPreview.SetEditable(FALSE);
|
|
m_wndGridPreview.EnableSelection(FALSE);
|
|
m_wndGridPreview.EnableTitleTips(FALSE);
|
|
|
|
ShowFittingStyle();
|
|
|
|
if (m_nFitType == 2 || m_nFitType == 3)
|
|
{
|
|
//三通,四通 可以改向
|
|
}
|
|
else
|
|
{
|
|
//关闭
|
|
m_wndFllowDirBt.ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
/*
|
|
int nFitType = -1;
|
|
eElbow:nFitType = 0;
|
|
eReduce:nFitType = 1;
|
|
eTee:nFitType = 2;
|
|
eCross:nFitType = 3;
|
|
eOffset:nFitType = 5;
|
|
*/
|
|
|
|
BOOL CHFitingStyleDlg::ShowFittingStyle()
|
|
{
|
|
// 获得指定类型的构件(矩形)
|
|
CString sFitRectSql;
|
|
sFitRectSql.Format(_T("SELECT [Code],[Type], [Sect], [Name], [ParameterTable],")
|
|
_T("[Preview] FROM [EquiInfo] WHERE [Type] = '%d' AND [Sect] = '0' ORDER BY [Sort] ASC"), m_nFitType);
|
|
|
|
// 执行Sql,获得指定的构件(矩形)
|
|
int nCount = m_pAdoUi->GetSelData(sFitRectSql, m_cTblFitInfoRect);
|
|
if (nCount < 1)
|
|
return FALSE;
|
|
|
|
// 获得圆形构件
|
|
CString sFitRounSql;
|
|
sFitRounSql.Format(_T("SELECT [Code],[Type], [Sect], [Name], [ParameterTable],")
|
|
_T("[Preview] FROM [EquiInfo] WHERE [Type] = '%d' AND [Sect] = '1'"), m_nFitType);
|
|
// 执行Sql,获得指定的构件(圆形)
|
|
if (!m_pAdoUi->GetSelData(sFitRounSql, m_cTblFitInfoRoun))
|
|
return FALSE;
|
|
|
|
// 获得矩形的默认连接件名称
|
|
CString sSQL;
|
|
sSQL.Format(_T("SELECT [Name] FROM [EquiInfo] WHERE [Type] = '%d' ")
|
|
_T("AND [Sect] = '0' AND [IsDefault] = '%d'"), m_nFitType,m_iRadSectType);
|
|
if (!m_pAdoUi->GetSelData(sSQL, m_sDefaFitRect))
|
|
return FALSE;
|
|
|
|
// 获得圆形的默认连接件名称
|
|
sSQL.Format(_T("SELECT [Name] FROM [EquiInfo] WHERE [Type] = '%d'")
|
|
_T("AND [Sect] = '1' AND [IsDefault] = '%d'"), m_nFitType,m_iRadSectType);
|
|
if (!m_pAdoUi->GetSelData(sSQL, m_sDefaFitRoun))
|
|
return FALSE;
|
|
|
|
// 编辑模式,连接件类型从实体获取
|
|
if (m_idToEdit.isValid())
|
|
{
|
|
DialogVarsFromID();
|
|
}
|
|
|
|
// 数据为空时,设置为默认连接件名称
|
|
if (m_sCurFitRect.IsEmpty())
|
|
m_sCurFitRect = m_sDefaFitRect;
|
|
|
|
if (m_sCurFitRoun.IsEmpty())
|
|
m_sCurFitRoun = m_sDefaFitRoun;
|
|
|
|
// 界面需要显示的连接件名称
|
|
CString sFitName = _T("");
|
|
if (m_iRadSectType == 0)
|
|
sFitName = m_sCurFitRect;
|
|
else
|
|
sFitName = m_sCurFitRoun;
|
|
|
|
// 获取界面需要显示的构件代码
|
|
CString sEquiCode = _T("");
|
|
sSQL.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Type] = '%d'")
|
|
_T("AND [Sect] = '%d' AND [Name] = '%s'"), m_nFitType, m_iRadSectType, sFitName);
|
|
|
|
if (!m_pAdoUi->GetSelData(sSQL, sEquiCode))
|
|
return FALSE;
|
|
m_iCode = _ttoi(sEquiCode);
|
|
|
|
// 指定构件的条数(默认矩形)
|
|
int iCount = 0;
|
|
if (m_iRadSectType == 0)
|
|
iCount = m_cTblFitInfoRect.GetTableLogicSize();
|
|
else
|
|
iCount = m_cTblFitInfoRoun.GetTableLogicSize();
|
|
if (0 == iCount)
|
|
return FALSE;
|
|
|
|
// 设置单元格行、列数
|
|
m_wndGridPreview.SetColumnCount(5);
|
|
int iRow = iCount / 5;
|
|
if (0 != iCount % 5)
|
|
iRow++;
|
|
m_wndGridPreview.SetRowCount(iRow);
|
|
|
|
// 示意图文件名
|
|
CString sPreview;
|
|
// 构件名
|
|
CString sName;
|
|
// 单条记录
|
|
CUIIValueRecord cRecord;
|
|
// 查找构件示意图
|
|
CFileFind cFile;
|
|
|
|
////圆形三通,目前只支持这两种-2022-5-5----------------------------------->>>
|
|
CUIIValueTable tblCir;
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得构件示意图和名称
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
|
|
cRecord.GetValue(5, sPreview);
|
|
cRecord.GetValue(3, sName);
|
|
|
|
//圆形三通,目前只支持这两种
|
|
if (m_iRadSectType == 1 && m_nFitType == 2)//如果三通
|
|
{
|
|
//过滤,只支持 普通三通 型三通
|
|
//if (sName.CompareNoCase(_T("普通三通")) == 0 ||
|
|
// sName.CompareNoCase(_T("Y型三通")) == 0 )
|
|
//{
|
|
// tblCir.AddValueRecord(cRecord);
|
|
//}
|
|
//else
|
|
{
|
|
tblCir.AddValueRecord(cRecord);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
tblCir.AddValueRecord(cRecord);
|
|
}
|
|
}
|
|
|
|
if (m_iRadSectType == 1)
|
|
{
|
|
m_cTblFitInfoRoun.RemoveAll();
|
|
m_cTblFitInfoRoun = tblCir;
|
|
iCount = m_cTblFitInfoRoun.GetTableLogicSize();
|
|
}
|
|
//<<<------------------------------------------------------------------------
|
|
|
|
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得构件示意图和名称
|
|
if (m_iRadSectType == 0)
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
else
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(5, sPreview);
|
|
cRecord.GetValue(3, sName);
|
|
|
|
sPreview.Format(_T("HvacFitingIcons\\%s"), sPreview);
|
|
sPreview = GetPath(1) + sPreview;
|
|
// 目录下有对应的图片名称
|
|
if (cFile.FindFile(sPreview))
|
|
{
|
|
m_wndGridPreview.SetItemBMP(i / 5, i % 5, sPreview);
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
else // 没有对应的示意图,显示构件名称
|
|
{
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
|
|
// 查找并保存当前连接件的示意图索引
|
|
if (sFitName == sName)
|
|
{
|
|
m_iCurDefaIndexRow = i / 5;
|
|
m_iCurDefaIndexCol = i % 5;
|
|
}
|
|
}
|
|
|
|
// 设置示意图索引,选中当前连接件示意图
|
|
m_wndGridPreview.SetItemCheck(m_iCurDefaIndexRow, m_iCurDefaIndexCol, TRUE);
|
|
sSQL.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Name] = '%s' AND [Sect] = '%d'"), sFitName, m_iRadSectType);
|
|
|
|
CString sCode;
|
|
if (!m_pAdoUi->GetSelData(sSQL, sCode))
|
|
return FALSE;
|
|
m_nFitCode = _ttoi(sCode);
|
|
|
|
// 设置单元格的大小
|
|
for (i = 0; i < iRow; i++)
|
|
{
|
|
m_wndGridPreview.SetRowHeight(i, 75);
|
|
}
|
|
|
|
for (i = 0; i < m_wndGridPreview.GetColumnCount(); i++)
|
|
{
|
|
m_wndGridPreview.SetColumnWidth(i,85);
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
|
|
// 设置设备参数信息
|
|
ShowFitingInfo(sFitName, 3);
|
|
|
|
if (m_idToEdit.isValid())
|
|
{
|
|
ChangCtrlByMode();
|
|
ModifyGridValueByEnt();
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
|
|
if (m_iRadSectType == 0)//RECT
|
|
{
|
|
OnRadRect();
|
|
}
|
|
else
|
|
{
|
|
OnRadRoun();
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
// 获得数据库路径
|
|
CString CHFitingStyleDlg::GetPath(int nStyle)
|
|
{
|
|
// 使用宏,获取路径
|
|
CString sPath(_T(""));
|
|
sPath = FilePath::GetSysDir();
|
|
|
|
if (1 == nStyle) // 图片路径
|
|
sPath += _T("\\");
|
|
|
|
else if (0 == nStyle) // 数据库路径
|
|
sPath += _T("\\HvacEquiInfo.db");
|
|
else
|
|
;
|
|
return sPath;
|
|
}
|
|
|
|
// 双击编辑时,设置控件显示
|
|
void CHFitingStyleDlg::ChangCtrlByMode()
|
|
{
|
|
if (m_iRadSectType == 0)
|
|
{
|
|
GetDlgItem(IDC_RAD_RECT)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_RAD_ROUND)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_RAD_ROUND)->ShowWindow(SW_HIDE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_RAD_RECT)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_RAD_RECT)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_RAD_ROUND)->EnableWindow(TRUE);
|
|
}
|
|
|
|
if (m_nFitType == 0)
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(_T("角度"));
|
|
if (NULL != pItem)
|
|
{
|
|
m_wndPorpInfo.ReadOnly(pItem, TRUE);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 双击编辑时,设置对话框 主要变量值为当前管件值
|
|
void CHFitingStyleDlg::DialogVarsFromID()
|
|
{
|
|
AcAxDocLock lock;
|
|
AecDbHvacFitting* pFitting = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pFitting, m_idToEdit, AcDb::kForRead ) )
|
|
{
|
|
AecDbObjXDataMap* pMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
|
|
|
pMap->GetAt(HVAC_IsSingleLine, m_bChkSingleLine);
|
|
|
|
int nSectType = 0;
|
|
pMap->GetAt(HVAC_SectType, nSectType);
|
|
m_iRadSectType = nSectType - 1;
|
|
|
|
pMap->GetAt(HVAC_System, m_csSysType);
|
|
|
|
EFittingType eKind = ePipe;
|
|
AecHvac::HvacOffsetType eType;
|
|
pMap->GetAt(KEY_RUNTIME, (int&)eKind);
|
|
if (eKind == eOffset)
|
|
{
|
|
eType = AecHvac::eArcuateLink;
|
|
pMap->GetAt(HOFF_Type, (int&)eType);
|
|
if (eType == AecHvac::eArcuateLink)
|
|
{
|
|
m_sCurFitRect = _T("双弧"); //(矩形)
|
|
m_sCurFitRoun = _T("双弧"); //(圆形)
|
|
}
|
|
else if (eType == AecHvac::eLinearLink)
|
|
{
|
|
m_sCurFitRect = _T("角接"); //(矩形)
|
|
m_sCurFitRoun = _T("角接"); //(圆形)
|
|
}
|
|
}
|
|
else if (eKind == eReduce)
|
|
{
|
|
AecHvac::HvacSectType eStaSect, eEndSect;
|
|
pMap->GetAt(HRED_StartSectType, (int&)eStaSect);
|
|
pMap->GetAt(HRED_EndSectType, (int&)eEndSect);
|
|
|
|
if(eStaSect == eEndSect)
|
|
{
|
|
m_sCurFitRect = _T("变径");
|
|
m_sCurFitRoun = _T("变径");
|
|
}
|
|
else
|
|
{
|
|
m_sCurFitRect = _T("天圆地方");
|
|
m_sCurFitRoun = _T("天圆地方");
|
|
}
|
|
}
|
|
else if (eKind == eElbow)
|
|
{
|
|
AecHvac::HvacElbowType eType = AecHvac::eAllArcuate;
|
|
pMap->GetAt(HELB_Type, (int&)eType);
|
|
|
|
if (eType == AecHvac::eArcuate)
|
|
{
|
|
m_sCurFitRect = _T("内弧线");
|
|
}
|
|
else if (eType == AecHvac::eOrthoLead)
|
|
{
|
|
m_sCurFitRect = _T("内外直角导流");
|
|
}
|
|
else if (eType == AecHvac::eOrthoWrap)
|
|
{
|
|
m_sCurFitRect = _T("内外直角消声");
|
|
}
|
|
else if (eType == AecHvac::eAllOrtho)
|
|
{
|
|
m_sCurFitRect = _T("内外直角矩形");
|
|
}
|
|
else if (eType == AecHvac::eArcuateLead)
|
|
{
|
|
m_sCurFitRect = _T("内弧线导流");
|
|
}
|
|
else if (eType == AecHvac::eArcuateSieve)
|
|
{
|
|
m_sCurFitRect = _T("内弧线筛板消声");
|
|
}
|
|
else if (eType == AecHvac::eArcuateWrap)
|
|
{
|
|
m_sCurFitRect = _T("内弧线消声");
|
|
}
|
|
else if (eType == AecHvac::eArcuateBoard)
|
|
{
|
|
m_sCurFitRect = _T("内弧线隔板消声");
|
|
}
|
|
else if (eType == AecHvac::eAllArcuate)
|
|
{
|
|
m_sCurFitRect = _T("内外圆弧"); //(矩形)
|
|
m_sCurFitRoun = _T("内外圆弧"); //(圆形)
|
|
}
|
|
else if (eType == AecHvac::eAllArcWrap)
|
|
{
|
|
m_sCurFitRect = _T("内外圆弧消声"); //(矩形)
|
|
m_sCurFitRoun = _T("内外圆弧消声"); //(圆形)
|
|
}
|
|
else if (eType == AecHvac::eSegmental)
|
|
{
|
|
m_sCurFitRoun = _T("分段拟合");
|
|
}
|
|
else if (eType == AecHvac::eIncline)
|
|
{
|
|
m_sCurFitRect = _T("内斜线");
|
|
}
|
|
else if (eType == AecHvac::eInclineWrap)
|
|
{
|
|
m_sCurFitRect = _T("内斜线消声");
|
|
}
|
|
else if (eType == AecHvac::eInclineBoard)
|
|
{
|
|
m_sCurFitRect = _T("内斜线隔板消声");
|
|
}
|
|
else if (eType == AecHvac::eInclineLead)
|
|
{
|
|
m_sCurFitRect = _T("内斜线导流");
|
|
}
|
|
}
|
|
else if (eKind == eTee)
|
|
{
|
|
AecHvac::HvacTeeType eTeeType = AecHvac::eOrthoBranch;
|
|
pMap->GetAt(HTEE_Type, (int&)eTeeType);
|
|
switch (eTeeType)
|
|
{
|
|
case AecHvac::eOrthoBranch:
|
|
m_sCurFitRect = _T("普通三通"); //(矩形)
|
|
m_sCurFitRoun = _T("普通三通"); //(圆形)
|
|
break;
|
|
case AecHvac::eInsertBranch:
|
|
m_sCurFitRect = _T("承插三通"); //(矩形)
|
|
m_sCurFitRoun = _T("承插三通"); //(圆形)
|
|
break;
|
|
case AecHvac::eInsertIntubBranch:
|
|
m_sCurFitRect = _T("承插三通(插管式)");//(矩形)
|
|
break;
|
|
case AecHvac::eInclineBranch:
|
|
m_sCurFitRect = _T("斜接三通"); //(矩形)
|
|
m_sCurFitRoun = _T("斜接三通"); //(圆形)
|
|
break;
|
|
case AecHvac::eYShapeBranch:
|
|
m_sCurFitRect = _T("Y型三通"); //(矩形)
|
|
m_sCurFitRoun = _T("Y型三通"); //(圆形)
|
|
break;
|
|
case AecHvac::eVShapeBranch:
|
|
m_sCurFitRect = _T("V型三通"); //(矩形)
|
|
m_sCurFitRoun = _T("V型三通"); //(圆形)
|
|
break;
|
|
case AecHvac::eTShapeBranch:
|
|
m_sCurFitRect = _T("T型三通");
|
|
break;
|
|
case AecHvac::eArcuateBranch:
|
|
m_sCurFitRect = _T("圆角三通");
|
|
break;
|
|
case AecHvac::eArcuateIntubBranch:
|
|
m_sCurFitRect = _T("圆角三通(插管式)");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else if (eKind == eCross)
|
|
{
|
|
AecHvac::HvacCrossType eType = AecHvac::eOrthoCross;
|
|
pMap->GetAt(HCRS_Type, (int&)eType);
|
|
if (eType == AecHvac::eOrthoCross)
|
|
{
|
|
m_sCurFitRect = _T("普通四通"); //(矩形)
|
|
m_sCurFitRoun = _T("普通四通"); //(圆形)
|
|
}
|
|
if (eType == AecHvac::eInsertCross)
|
|
{
|
|
m_sCurFitRect = _T("承插四通"); //(矩形)
|
|
m_sCurFitRoun = _T("承插四通"); //(圆形)
|
|
}
|
|
if (eType == AecHvac::eInsertIntubCross)
|
|
{
|
|
m_sCurFitRect = _T("承插四通(插管式)");//(矩形)
|
|
}
|
|
if (eType == AecHvac::eInclineCross)
|
|
{
|
|
m_sCurFitRoun = _T("斜接四通"); //(圆形)
|
|
}
|
|
if (eType == AecHvac::eArcuateCross)
|
|
{
|
|
m_sCurFitRect = _T("圆角四通");
|
|
}
|
|
if (eType == AecHvac::eArcuateIntubCross)
|
|
{
|
|
m_sCurFitRect = _T("圆角四通(插管式)");
|
|
}
|
|
if (eType == AecHvac::eLinearCross)
|
|
{
|
|
m_sCurFitRect = _T("直角四通");
|
|
}
|
|
if (eType == AecHvac::eInterCross)
|
|
{
|
|
m_sCurFitRect = _T("交叉四通");
|
|
}
|
|
}
|
|
pFitting->close();
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
// 设置用户界面
|
|
void CHFitingStyleDlg::ShowFitingInfo(LPCTSTR pszName, UINT nFalg)
|
|
{
|
|
UpdateData();
|
|
// 删除先前属性树中的信息
|
|
m_wndPorpInfo.DeleteAllItems();
|
|
|
|
// 初始化对话框时
|
|
CString sName = pszName;
|
|
sName.TrimLeft();
|
|
sName.TrimRight();
|
|
if (sName.IsEmpty())
|
|
{
|
|
// 第一个构件信息(默认构件)
|
|
CUIIValueRecord cRecFirst;
|
|
// 当前是矩形
|
|
CString sPrev;
|
|
if (0 == m_iRadSectType)
|
|
{
|
|
// 获得指定构件
|
|
m_cTblFitInfoRect.GetValueRecord(m_iCode, cRecFirst);
|
|
|
|
cRecFirst.GetValue(5, sPrev);
|
|
}
|
|
else if (1 == m_iRadSectType) // 当前选择的是圆形
|
|
{
|
|
m_cTblFitInfoRoun.GetValueRecord(m_iCode, cRecFirst);
|
|
cRecFirst.GetValue(5, sPrev);
|
|
}
|
|
|
|
// 第一个构件对应的参数表
|
|
cRecFirst.GetValue(4, m_sCurParamTable);
|
|
|
|
// 第一个构件对应的参数信息
|
|
CUIIValueTable cParaFirst;
|
|
GetFitParamMap(cParaFirst, m_sCurParamTable);
|
|
|
|
// 构件名称
|
|
CString sNameFirst;
|
|
cRecFirst.GetValue(3, sNameFirst);
|
|
|
|
// 将构件名称添加到属性树中
|
|
m_pCurRoot = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
m_pCurRoot->SetLabelText(_T("名称"));
|
|
m_pCurRoot->SetInfoText(sNameFirst);
|
|
m_pCurRoot->Expand();
|
|
|
|
// 显示子项(名称)
|
|
CPropItem* pItem;
|
|
pItem = m_wndPorpInfo.InsertItem(new CPropItem(), m_pCurRoot);
|
|
pItem->SetLabelText(sNameFirst);
|
|
m_pCurRoot->Expand();
|
|
|
|
// 添加构件参数项
|
|
CPropItem* pRootComp = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootComp->SetLabelText(_T("构件参数"));
|
|
pRootComp->SetInfoText(_T("显示构参数信息"));
|
|
|
|
// 添加几何参数项
|
|
CPropItem* pRootGeom = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootGeom->SetLabelText(_T("几何参数"));
|
|
pRootGeom->SetInfoText(_T("显示几何参数"));
|
|
|
|
// 单个变量信息
|
|
CUIIValueRecord cRecordParam;
|
|
// 参数类型
|
|
CString sTypeParam;
|
|
// 控件类型
|
|
CString sCtrlType;
|
|
UINT nCtrlType = 0;
|
|
// 变量代号
|
|
CString sCodeParam;
|
|
// 变量显示状态
|
|
CString sShowStatus;
|
|
UINT nShowStatus = 0;
|
|
|
|
// 参数个数
|
|
int iCount = cParaFirst.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得每一个参数信息
|
|
cParaFirst.GetValueRecord(i, cRecordParam);
|
|
// 获得参数类型
|
|
cRecordParam.GetValue(1, sTypeParam);
|
|
// 参数代号
|
|
cRecordParam.GetValue(0, sCodeParam);
|
|
// 显示状态
|
|
cRecordParam.GetValue(8, sShowStatus);
|
|
nShowStatus = _ttoi(sShowStatus);
|
|
|
|
// 变量不显示
|
|
if (2 == nShowStatus)
|
|
continue;
|
|
|
|
// 构件参数
|
|
if (_T("0") == sTypeParam)
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootComp, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else // 几何参数
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootGeom, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 展开
|
|
pRootGeom->Expand();
|
|
pRootComp->Expand();
|
|
pRootComp = NULL;
|
|
pRootGeom = NULL;
|
|
}
|
|
else // 选择不同的构件
|
|
{
|
|
// 删除先前属性信息
|
|
m_wndPorpInfo.DeleteAllItems();
|
|
|
|
// 一条记录
|
|
CUIIValueRecord cRecord;
|
|
CString sPrev;
|
|
int iCount = 0;
|
|
// 当前是矩形
|
|
if (0 == m_iRadSectType)
|
|
{
|
|
// 根据传入的构件名称,确定构件
|
|
iCount = m_cTblFitInfoRect.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(nFalg, sPrev);
|
|
// 找到对应的构件,退出循环,i为当前构件索引
|
|
if (pszName == sPrev)
|
|
break;
|
|
}
|
|
|
|
// 获得指定构件
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
//m_nFitCode = i;
|
|
}
|
|
else if (1 == m_iRadSectType) // 当前选择的是圆形
|
|
{
|
|
// 根据传入的构件名称,确定构件
|
|
iCount = m_cTblFitInfoRoun.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(nFalg, sPrev);
|
|
// 找到对应的构件,退出循环,i为当前构件索引
|
|
if (pszName == sPrev)
|
|
break;
|
|
}
|
|
|
|
// 获得指定构件
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
//m_nFitCode = i;
|
|
}
|
|
|
|
// 指定构件对应的参数表
|
|
cRecord.GetValue(4, m_sCurParamTable);
|
|
|
|
// 指定构件对应的参数信息(函数内部保存了当前选择构件的参数信息)
|
|
CUIIValueTable cTblParam;
|
|
GetFitParamMap(cTblParam, m_sCurParamTable);
|
|
|
|
// 构件名称
|
|
CString sName;
|
|
cRecord.GetValue(3, sName);
|
|
|
|
// 将构件名称添加到属性树中
|
|
m_pCurRoot = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
m_pCurRoot->SetLabelText(_T("名称"));
|
|
m_pCurRoot->SetInfoText(sName);
|
|
m_pCurRoot->Expand();
|
|
|
|
// 显示子项(名称)
|
|
CPropItem* pItem;
|
|
pItem = m_wndPorpInfo.InsertItem(new CPropItem(), m_pCurRoot);
|
|
if (NULL == pItem)
|
|
return;
|
|
|
|
pItem->SetLabelText(sName);
|
|
pItem->SetLabelText(sName);
|
|
m_pCurRoot->Expand();
|
|
|
|
// 添加构件参数项
|
|
CPropItem* pRootComp = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootComp->SetLabelText(_T("构件参数"));
|
|
pRootComp->SetInfoText(_T("显示构参数信息"));
|
|
|
|
// 添加几何参数项
|
|
CPropItem* pRootGeom = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootGeom->SetLabelText(_T("几何参数"));
|
|
pRootGeom->SetInfoText(_T("显示几何参数"));
|
|
|
|
// 参数个数
|
|
iCount = cTblParam.GetTableLogicSize();
|
|
// 单个变量信息
|
|
CUIIValueRecord cRecordParam;
|
|
// 参数类型
|
|
CString sTypeParam;
|
|
// 控件类型
|
|
CString sCtrlType;
|
|
UINT nCtrlType = 0;
|
|
// 变量代号
|
|
CString sCodeParam;
|
|
// 变量显示状态
|
|
CString sShowStatus;
|
|
UINT nShowStatus = 0;
|
|
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得每一个参数信息
|
|
cTblParam.GetValueRecord(i, cRecordParam);
|
|
// 参数类型
|
|
cRecordParam.GetValue(1, sTypeParam);
|
|
// 参数代号
|
|
cRecordParam.GetValue(0, sCodeParam);
|
|
// 获得显示状态
|
|
cRecordParam.GetValue(8, sShowStatus);
|
|
nShowStatus = _ttoi(sShowStatus);
|
|
// 变量不显示
|
|
if (2 == nShowStatus)
|
|
continue;
|
|
|
|
// 构件参数
|
|
if (_T("0") == sTypeParam)
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootComp, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else // 几何参数
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootGeom, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 展开
|
|
pRootGeom->Expand();
|
|
pRootComp->Expand();
|
|
pRootComp = NULL;
|
|
pRootGeom = NULL;
|
|
}
|
|
|
|
if (m_idToEdit.isValid())
|
|
{
|
|
ModifyGridValueByEnt();
|
|
|
|
if (m_nFitType == 0)
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(_T("角度"));
|
|
if (NULL != pItem)
|
|
{
|
|
m_wndPorpInfo.ReadOnly(pItem, TRUE);
|
|
}
|
|
}
|
|
}
|
|
ShowTreeItem();
|
|
}
|
|
|
|
UINT CHFitingStyleDlg::GetFitCode()
|
|
{
|
|
return m_nFitCode;
|
|
}
|
|
|
|
// 截面信息0:矩形,1:圆形,2:椭圆
|
|
int CHFitingStyleDlg::GetFitSect()
|
|
{
|
|
if (::IsWindow(m_hWnd) )
|
|
{
|
|
UpdateData();
|
|
}
|
|
return m_iRadSectType;
|
|
}
|
|
|
|
// 显示或隐藏属性条目
|
|
void CHFitingStyleDlg::ShowTreeItem()
|
|
{
|
|
// 取得变径所需各种参数
|
|
CMapFitaram mapData;
|
|
GetFitParamMap(mapData);
|
|
|
|
if (1 == m_nFitType) // 变径或天圆地方
|
|
{
|
|
CString csComType; // 计算方法
|
|
SFitParam eParm;
|
|
if (mapData.Lookup(REDUCE_COMTYPE, eParm))
|
|
{
|
|
if (eParm.sDefault == _T("自动计算"))
|
|
{
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SubShowTreeItem(_T("角度"), FALSE);
|
|
}
|
|
else if (eParm.sDefault == _T("角度"))
|
|
{
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SubShowTreeItem(_T("角度"), TRUE);
|
|
}
|
|
else if (eParm.sDefault == _T("长度"))
|
|
{
|
|
SubShowTreeItem(_T("长度(mm)"), TRUE);
|
|
SubShowTreeItem(_T("角度"), FALSE);
|
|
}
|
|
}
|
|
}
|
|
else if (2 == m_nFitType) // 三通
|
|
{
|
|
int nType = GetFitCode();
|
|
int nSect = GetFitSect();
|
|
if (nSect == 0)
|
|
{
|
|
if ( AecHvac::eYShapeBranch == nType ||
|
|
AecHvac::eTShapeBranch == nType ||
|
|
AecHvac::eArcuateBranch == nType ||
|
|
AecHvac::eArcuateIntubBranch == nType ||
|
|
AecHvac::eInclineBranch == nType)
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
|
|
if ( AecHvac::eInclineBranch == nType)//斜接三通
|
|
{
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
}
|
|
|
|
if (AecHvac::eInclineBranch == nType ||
|
|
AecHvac::eArcuateBranch == nType)
|
|
{
|
|
SetTreeItemWrite(_T("添加阀门"), TRUE);
|
|
}
|
|
}
|
|
else
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
}
|
|
else if (nSect == 1)
|
|
{
|
|
if ( AecHvac::eOrthoBranch == nType)
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
else
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
}
|
|
}
|
|
}
|
|
else if (3 == m_nFitType) // 四通
|
|
{
|
|
int nType = GetFitCode();
|
|
int nSect = GetFitSect();
|
|
if (nSect == 0)
|
|
{
|
|
if ( AecHvac::eArcuateCross == nType ||
|
|
AecHvac::eArcuateIntubCross == nType)
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
else
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
}
|
|
else if (nSect == 1)
|
|
{
|
|
if ( AecHvac::eOrthoCross == nType)
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
else
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
SetTreeItemWrite(_T("角度"), TRUE);
|
|
}
|
|
}
|
|
}
|
|
else if (5 == m_nFitType) // 乙子弯
|
|
{
|
|
CString csComType; // 计算方法
|
|
SFitParam eParm;
|
|
if (mapData.Lookup(REDUCE_COMTYPE, eParm))
|
|
{
|
|
if (!m_idToEdit.isValid())
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
|
|
if (eParm.sDefault == _T("曲率"))
|
|
{
|
|
SubShowTreeItem(_T("偏移距离(mm)"), FALSE);
|
|
SubShowTreeItem(_T("曲率半径"), TRUE);
|
|
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SubShowTreeItem(_T("弯头角度"), TRUE);
|
|
SetTreeItemWrite(_T("弯头角度"), TRUE);
|
|
}
|
|
else if (eParm.sDefault == _T("偏移"))
|
|
{
|
|
if (!m_idToEdit.isValid())
|
|
SubShowTreeItem(_T("偏移距离(mm)"), TRUE);
|
|
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SubShowTreeItem(_T("弯头角度"), TRUE);
|
|
SetTreeItemWrite(_T("弯头角度"), TRUE);
|
|
}
|
|
|
|
else if (eParm.sDefault == _T("长度"))
|
|
{
|
|
if (!m_idToEdit.isValid())
|
|
SubShowTreeItem(_T("偏移距离(mm)"), TRUE);
|
|
else
|
|
SubShowTreeItem(_T("偏移距离(mm)"), FALSE);
|
|
|
|
SubShowTreeItem(_T("长度(mm)"), TRUE);
|
|
SetTreeItemWrite(_T("长度(mm)"), TRUE);
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
SubShowTreeItem(_T("弯头角度"), FALSE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
}
|
|
|
|
int nSect = GetFitCode();
|
|
if (nSect == 3)
|
|
{
|
|
m_wndPorpInfo.ReadOnly(m_wndPorpInfo.GetRootItem(), TRUE);
|
|
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SubShowTreeItem(_T("几何参数"), TRUE);
|
|
|
|
SubShowTreeItem(_T("计算方法"), TRUE); //FALSE
|
|
SubShowTreeItem(_T("曲率半径"), TRUE);
|
|
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(_T("计算方法"));
|
|
if (NULL != pItem)
|
|
{
|
|
CPropItemCombo* pComboItem = (CPropItemCombo*)pItem;
|
|
if (pComboItem->GetCount() == 3)
|
|
{
|
|
pComboItem->DeleteString(1);
|
|
}
|
|
|
|
if (pComboItem->GetCurSel() == 0)
|
|
{
|
|
SetItemValueByLable(_T("计算方法"), _T("曲率"));
|
|
}
|
|
else
|
|
{
|
|
SetItemValueByLable(_T("计算方法"), _T("长度"));
|
|
}
|
|
}
|
|
|
|
SetTreeItemWrite(_T("计算方法"), TRUE);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
SetTreeItemWrite(_T("弯头角度"), TRUE);
|
|
SetTreeItemWrite(_T("长度(mm)"), TRUE);
|
|
SetTreeItemWrite(_T("偏移距离(mm)"), TRUE);
|
|
|
|
SubShowTreeItem(_T("宽A(mm)"), FALSE);
|
|
SubShowTreeItem(_T("宽B(mm)"), FALSE);
|
|
SubShowTreeItem(_T("厚度(mm)"), FALSE);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::SubShowTreeItem(const CString &csItemLable, BOOL bShow)
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(csItemLable);
|
|
if (pItem != NULL)
|
|
{
|
|
pItem->Hide(!bShow);
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::SetItemValueByLable( CString csLable, double dValue, int nPreci /*= 0*/ )
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(csLable);
|
|
if (NULL != pItem)
|
|
{
|
|
CString csValue;
|
|
CString csPreci;
|
|
csPreci.Format(_T("%d"), nPreci);
|
|
csValue.Format(_T("%.") + csPreci + _T("f"), dValue);
|
|
SetItemValueByLable(csLable, csValue);
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::SetItemValueByLable(CString csLable, CString csValue)
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(csLable);
|
|
if (NULL != pItem)
|
|
{
|
|
if (pItem->m_nItemType == ITEMTYPE_EDIT)
|
|
{
|
|
CPropItemEdit* pEdti = (CPropItemEdit*)pItem;
|
|
pEdti->SetValueText(csValue);
|
|
}
|
|
else if (pItem->m_nItemType == ITEMTYPE_COMBOBOX)
|
|
{
|
|
CPropItemCombo* pComb = (CPropItemCombo*)pItem;
|
|
pComb->SetSelText(csValue);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::SetTreeItemWrite( const CString &csItemLable, BOOL bWrite )
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(csItemLable);
|
|
if (NULL != pItem)
|
|
pItem->ReadOnly(!bWrite);
|
|
}
|
|
|
|
CString CHFitingStyleDlg::GetDefTblName(UINT nType)
|
|
{
|
|
CString sDefTblName = _T("");
|
|
switch (nType)
|
|
{
|
|
case 0:
|
|
sDefTblName = _T("_ElbowDefaultData");
|
|
break;
|
|
case 1:
|
|
sDefTblName = _T("_BianJingDefaultData");
|
|
break;
|
|
case 2:
|
|
sDefTblName = _T("_TeeDeaultData");
|
|
break;
|
|
case 3:
|
|
sDefTblName = _T("_CrossDefaultData");
|
|
break;
|
|
case 4:
|
|
sDefTblName = _T("_BianJingDefaultData");
|
|
break;
|
|
case 5:
|
|
sDefTblName = _T("_YiElbowDefaultData");
|
|
break;
|
|
}
|
|
|
|
return sDefTblName;
|
|
}
|
|
|
|
// 填充组合框数据(可编辑)
|
|
void CHFitingStyleDlg::FillDropDownComb(LPCTSTR pszParamCode, CPropItem* pRoot, UINT nShowStatus)
|
|
{
|
|
// 根指针无效
|
|
if (NULL == pRoot)
|
|
return;
|
|
|
|
// 从映射中获得指定代号代表的变量
|
|
SFitParam FitParam;
|
|
m_mapCurFitParam.Lookup(pszParamCode, FitParam);
|
|
// 创建组合框(不可编辑)
|
|
CPropItemCombo* pCombo = NULL;
|
|
pCombo = (CPropItemCombo*)m_wndPorpInfo.InsertItem(new CPropItemCombo(), pRoot);
|
|
if (NULL == pRoot)
|
|
return;
|
|
|
|
CString sCodeSql, sEquValue;
|
|
sCodeSql.Format(_T("SELECT [Default] FROM [%s] WHERE [Code] = '%s'"), GetDefTblName(m_nFitType), pszParamCode);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sCodeSql, sEquValue))
|
|
return;
|
|
|
|
// 标签文本
|
|
pCombo->SetLabelText(FitParam.sDesc);
|
|
// 提示信息
|
|
pCombo->SetInfoText(FitParam.sPrompt);
|
|
|
|
// 组合框与构件参数的"默认值"相关
|
|
m_mapCurFitParam[pszParamCode].sDefault = sEquValue;
|
|
pCombo->CreateDropDownComb(&(m_mapCurFitParam[pszParamCode].sDefault));
|
|
pCombo->SetWindowText(sEquValue);
|
|
// 只读
|
|
if (1 == nShowStatus)
|
|
{
|
|
pCombo->ReadOnly();
|
|
}
|
|
|
|
// 组合框中数据
|
|
CString sRemark;
|
|
sRemark = FitParam.sRemark;
|
|
// 去掉空格
|
|
sRemark.Remove(' ');
|
|
// 当前","的位置
|
|
int iCurSpace = 0;
|
|
// 下一个","位置
|
|
int iNextSpace = sRemark.Find(',');
|
|
|
|
// 把值依次取出,添加到组合框
|
|
CString sValue;
|
|
while (-1 != iNextSpace)
|
|
{
|
|
// 取出以","分开的每一项
|
|
sValue = sRemark.Mid(iCurSpace, iNextSpace);
|
|
// 添加到组合框
|
|
pCombo->AddString(sValue);
|
|
// "下一位置"置"当前位置"
|
|
sRemark = sRemark.Mid(iNextSpace + 1);
|
|
// 查找下一个","
|
|
iNextSpace = sRemark.Find(',');
|
|
}
|
|
pCombo = NULL;
|
|
}
|
|
|
|
// 填充组合框数据(不可编辑),控件与构件的变量值相关
|
|
void CHFitingStyleDlg::FillDropListComb(LPCTSTR pszParamCode, CPropItem* pRoot, UINT nShowStatus)
|
|
{
|
|
// 根指针无效
|
|
if (NULL == pRoot)
|
|
return;
|
|
|
|
// 从映射中获得指定代号代表的变量
|
|
SFitParam FitParam;
|
|
m_mapCurFitParam.Lookup(pszParamCode, FitParam);
|
|
// 组合框中的数据
|
|
CString sRemark;
|
|
// 创建组合框
|
|
CPropItemCombo* pCombo;
|
|
pCombo = (CPropItemCombo*)m_wndPorpInfo.InsertItem(new CPropItemCombo(), pRoot);
|
|
if (NULL == pCombo)
|
|
return;
|
|
|
|
CString sCodeSql, sEquValue;
|
|
sCodeSql.Format(_T("SELECT [Default] FROM [%s] WHERE [Code] = '%s'"), GetDefTblName(m_nFitType), pszParamCode);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sCodeSql, sEquValue))
|
|
return;
|
|
|
|
// 标签文本
|
|
pCombo->SetLabelText(FitParam.sDesc);
|
|
// 提示信息
|
|
pCombo->SetInfoText(FitParam.sPrompt);
|
|
// pCombo->SetWindowText(FitParam.sDefault);
|
|
// 组合框与构件参数的"默认值"相关
|
|
pCombo->CreateDropListComb(&(m_mapCurFitParam[pszParamCode].sDefault));
|
|
if (1 == nShowStatus)
|
|
{
|
|
pCombo->ReadOnly();
|
|
}
|
|
|
|
// 组合框中数据
|
|
sRemark = FitParam.sRemark;
|
|
// 去掉空格
|
|
sRemark.Remove(_T(' '));
|
|
|
|
// 当前","的位置
|
|
int iCurSpace = 0;
|
|
// 下一个","位置
|
|
int iNextSpace = sRemark.Find(_T(','));
|
|
|
|
// 把值依次取出,添加到组合框
|
|
CString sValue;
|
|
while (-1 != iNextSpace)
|
|
{
|
|
// 取出以","分开的每一项
|
|
sValue = sRemark.Mid(iCurSpace, iNextSpace);
|
|
// 添加到组合框
|
|
pCombo->AddString(sValue);
|
|
// "下一位置"置"当前位置"
|
|
//iCurSpace = iNextSpace;
|
|
sRemark = sRemark.Mid(iNextSpace + 1);
|
|
// 查找下一个","
|
|
iNextSpace = sRemark.Find(_T(','));
|
|
}
|
|
int iSel = pCombo->FindString(0, sEquValue);
|
|
if (iSel >= 0)
|
|
pCombo->SetSelText(sEquValue);
|
|
else
|
|
pCombo->SetCurSel(1);
|
|
|
|
pCombo = NULL;
|
|
}
|
|
|
|
// 填充编辑框
|
|
void CHFitingStyleDlg::FillEditItem(LPCTSTR pszParamCode, UINT nOption, CPropItem* pRoot,UINT nShowStatus)
|
|
{
|
|
// 根指针无效
|
|
if (NULL == pRoot)
|
|
return;
|
|
|
|
// 从映射中获得指定代号代表的变量
|
|
SFitParam FitParam = m_mapCurFitParam[pszParamCode];
|
|
// 创建编辑框控件
|
|
CPropItemEdit* pEdit = new CPropItemEdit(&(m_mapCurFitParam[pszParamCode].sDefault));
|
|
pEdit = (CPropItemEdit*)m_wndPorpInfo.InsertItem(pEdit, pRoot);
|
|
if (NULL == pEdit)
|
|
return;
|
|
|
|
CString sCodeSql, sEquValue;
|
|
sCodeSql.Format(_T("SELECT [Default] FROM [%s] WHERE [Code] = '%s'"), GetDefTblName(m_nFitType), pszParamCode);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sCodeSql, sEquValue))
|
|
return;
|
|
|
|
// 编辑框后有按钮
|
|
if (1 == nOption)
|
|
pEdit->HasButton();
|
|
// 编辑框后有Spin
|
|
if (2 == nOption)
|
|
pEdit->HasSpinCtrl();
|
|
// 标签文本
|
|
pEdit->SetLabelText(FitParam.sDesc);
|
|
|
|
// 提示信息
|
|
pEdit->SetInfoText(FitParam.sPrompt);
|
|
pEdit->SetValueText(sEquValue);
|
|
// 变量不可编辑
|
|
if (1 == nShowStatus)
|
|
{
|
|
pEdit->ReadOnly();
|
|
}
|
|
pEdit->HasButton();
|
|
|
|
pEdit = NULL;
|
|
}
|
|
|
|
|
|
// 获得当前设备参数
|
|
void CHFitingStyleDlg::GetFitParamMap(CMapFitaram& mapFitParam)
|
|
{
|
|
// key
|
|
CString sParamCode;
|
|
// Value
|
|
SFitParam FitParamTemp;
|
|
// 映射中的位置
|
|
POSITION pos = m_mapCurFitParam.GetStartPosition();
|
|
// 获得变量信息
|
|
while (NULL != pos)
|
|
{
|
|
m_mapCurFitParam.GetNextAssoc(pos, sParamCode, FitParamTemp);
|
|
mapFitParam.SetAt(sParamCode, FitParamTemp);
|
|
}
|
|
}
|
|
|
|
// 根据参数表名获得参数映射
|
|
void CHFitingStyleDlg::GetFitParamMap(CUIIValueTable& cFitParam, LPCTSTR pszFitParam)
|
|
{
|
|
// 数据库未打开
|
|
if (NULL == m_pAdoUi || !m_pAdoUi->IsDatabaseOpen())
|
|
return;
|
|
|
|
// 删除先前数据
|
|
m_mapCurFitParam.RemoveAll();
|
|
|
|
// 获得指定类型的构件
|
|
CString sFitarqSql;
|
|
sFitarqSql.Format(_T("SELECT [Code],[Type], [Control], [Remark], [Desc],")
|
|
_T("[Unit],[Default],[Prompt],[ShowStatus] FROM [%s] ORDER BY [NO]"), pszFitParam);
|
|
// 执行Sql,获得构件参数信息
|
|
if (!m_pAdoUi->GetSelData(sFitarqSql, cFitParam))
|
|
return;
|
|
|
|
// 构件参数个数
|
|
int iCount = cFitParam.GetTableLogicSize();
|
|
if (0 == iCount)
|
|
return;
|
|
|
|
// 参数表信息存入映射key:示意图,Value:参数所有信息
|
|
CString sKeyFitrev;
|
|
SFitParam eValueFitParam;
|
|
// 单条记录
|
|
CUIIValueRecord cRecord;
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得一个变量信息
|
|
cFitParam.GetValueRecord(i, cRecord);
|
|
// 获得key
|
|
cRecord.GetValue(0, sKeyFitrev);
|
|
// 获得value
|
|
cRecord.GetValue(0, eValueFitParam.sCode);
|
|
cRecord.GetValue(1, eValueFitParam.sType);
|
|
cRecord.GetValue(2, eValueFitParam.sControlType);
|
|
cRecord.GetValue(3, eValueFitParam.sRemark);
|
|
cRecord.GetValue(4, eValueFitParam.sDesc);
|
|
cRecord.GetValue(5, eValueFitParam.sUnit);
|
|
cRecord.GetValue(6, eValueFitParam.sDefault);
|
|
cRecord.GetValue(7, eValueFitParam.sPrompt);
|
|
cRecord.GetValue(8, eValueFitParam.sShowStatus);
|
|
// 存入映射
|
|
m_mapCurFitParam.SetAt(sKeyFitrev, eValueFitParam);
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::ModifyGridValueByEnt()
|
|
{
|
|
AcAxDocLock lock;
|
|
AecDbHvacFitting* pFitting = NULL;
|
|
|
|
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pFitting,m_idToEdit, AcDb::kForRead) )
|
|
{
|
|
AecDbObjXDataMap* pMap = pFitting->GetSpecialtyData(AcDb::kForRead);
|
|
ASSERT(NULL != pMap);
|
|
|
|
EFittingType eKind = ePipe;
|
|
|
|
pMap->GetAt(KEY_RUNTIME, (int&)eKind);
|
|
if (eKind == eOffset)
|
|
{
|
|
double dStartWidth(0), dEndWidth(0), dThick(0), dAngle(0.0);
|
|
double dOffset(0.0), dLen(0.0);
|
|
AecHvac::HvacOffsetComType eType = AecHvac::eOffComRatio;
|
|
|
|
pMap->GetAt(HOFF_StartWidth, dStartWidth);
|
|
pMap->GetAt(HOFF_EndWidth, dEndWidth);
|
|
pMap->GetAt(HOFF_Thick, dThick);
|
|
pMap->GetAt(HOFF_Angle, dAngle);
|
|
pMap->GetAt(HOFF_Offset, dOffset);
|
|
pMap->GetAt(HOFF_Length, dLen);
|
|
pMap->GetAt(HOFF_ComputeType, (int&)eType);
|
|
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SetTreeItemWrite(_T("计算方法"), TRUE);
|
|
|
|
if (AecHvac::eOffComRatio == eType)
|
|
{
|
|
SubShowTreeItem(_T("弯头角度"), TRUE);
|
|
SetTreeItemWrite(_T("弯头角度"), TRUE);
|
|
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
SubShowTreeItem(_T("偏移距离(mm)"), FALSE);
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SetItemValueByLable(_T("计算方法"), _T("曲率"));
|
|
}
|
|
else if (AecHvac::eOffComOffset == eType)
|
|
{
|
|
SubShowTreeItem(_T("弯头角度"), TRUE);
|
|
SetTreeItemWrite(_T("弯头角度"), TRUE);
|
|
|
|
SubShowTreeItem(_T("偏移距离(mm)"), FALSE);
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SetItemValueByLable(_T("计算方法"), _T("偏移"));
|
|
}
|
|
else if (AecHvac::eOffComLength == eType)
|
|
{
|
|
SubShowTreeItem(_T("长度(mm)"), TRUE);
|
|
SetTreeItemWrite(_T("长度(mm)"), TRUE);
|
|
SubShowTreeItem(_T("偏移距离(mm)"), FALSE);
|
|
SubShowTreeItem(_T("弯头角度"), FALSE);
|
|
SubShowTreeItem(_T("曲率半径"), FALSE);
|
|
SetItemValueByLable(_T("计算方法"), _T("长度"));
|
|
}
|
|
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("厚度(mm)"), dThick);
|
|
SetItemValueByLable(_T("直径D(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("弯头角度"), dAngle * 180/PI);
|
|
SetItemValueByLable(_T("偏移距离(mm)"), dOffset);
|
|
SetItemValueByLable(_T("长度(mm)"), dLen);
|
|
}
|
|
else if (eKind == eReduce)
|
|
{
|
|
// 先隐藏布置时才有的参数
|
|
SubShowTreeItem(_T("偏心距离(mm)"), FALSE);
|
|
SetTreeItemWrite(_T("构件参数"), TRUE);
|
|
SetTreeItemWrite(_T("计算方法"), TRUE);
|
|
SetTreeItemWrite(_T("角度"), TRUE);
|
|
SetTreeItemWrite(_T("长度(mm)"), TRUE);
|
|
|
|
double dStartWidth(0), dEndWidth(0), dStartThick(0.0), dEndThick(0.0);
|
|
double dStartDia(0), dEndDia(0);
|
|
|
|
pMap->GetAt(HRED_StartWidth, dStartWidth);
|
|
pMap->GetAt(HRED_StartThick, dStartThick);
|
|
pMap->GetAt(HRED_EndWidth, dEndWidth);
|
|
pMap->GetAt(HRED_EndThick, dEndThick);
|
|
|
|
ESection eStartSect, eEndSect;
|
|
AecHvac::HvacReduComType eType = AecHvac::eAuto;
|
|
pMap->GetAt(HRED_StartSectType, (int&)eStartSect);
|
|
pMap->GetAt(HRED_EndSectType, (int&)eEndSect);
|
|
pMap->GetAt(HRED_ComputeType, (int&)eType);
|
|
|
|
if (eType == AecHvac::eAuto)
|
|
{
|
|
SetItemValueByLable(_T("计算方法"), _T("自动计算"));
|
|
SubShowTreeItem(_T("角度"), FALSE);
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
}
|
|
else if (eType == AecHvac::eAngle)
|
|
{
|
|
SetItemValueByLable(_T("计算方法"), _T("角度"));
|
|
SubShowTreeItem(_T("长度(mm)"), FALSE);
|
|
SubShowTreeItem(_T("角度"), TRUE);
|
|
double dAngle(0.0);
|
|
pMap->GetAt(HRED_Angle, dAngle);
|
|
SetItemValueByLable(_T("角度"), dAngle/PI * 180);
|
|
}
|
|
else if (eType == AecHvac::eLength)
|
|
{
|
|
SetItemValueByLable(_T("计算方法"), _T("长度"));
|
|
SubShowTreeItem(_T("角度"), FALSE);
|
|
SubShowTreeItem(_T("长度(mm)"), TRUE);
|
|
double dLen(0.0);
|
|
pMap->GetAt(HRED_Length, dLen);
|
|
SetItemValueByLable(_T("长度(mm)"), dLen);
|
|
}
|
|
|
|
if(eStartSect == eEndSect)
|
|
{
|
|
eStartSect = eEndSect = (0 == m_iRadSectType) ? eRect : eCircle;
|
|
}
|
|
else
|
|
{
|
|
if(0 == m_iRadSectType)
|
|
{
|
|
eStartSect = eRect;
|
|
eEndSect = eCircle;
|
|
}
|
|
else
|
|
{
|
|
eStartSect = eCircle;
|
|
eEndSect = eRect;
|
|
}
|
|
}
|
|
|
|
if(!m_sCurrName.IsEmpty())
|
|
{
|
|
if(0 == m_sCurrName.CompareNoCase(_T("天圆地方")))
|
|
eEndSect = (eRect == eStartSect) ? eCircle : eRect;
|
|
else
|
|
eEndSect = eStartSect;
|
|
}
|
|
|
|
if (eStartSect == eRect)
|
|
{
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("厚A(mm)"), dStartThick);
|
|
|
|
if (eEndSect == eRect)
|
|
{
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("厚B(mm)"), dEndThick);
|
|
}
|
|
else
|
|
{
|
|
SetItemValueByLable(_T("直径"), dEndWidth);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (eEndSect == eRect)
|
|
{
|
|
SetItemValueByLable(_T("直径"), dStartWidth);
|
|
SetItemValueByLable(_T("宽A(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("厚A(mm)"), dEndThick);
|
|
}
|
|
else
|
|
{
|
|
SetItemValueByLable(_T("直径A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("直径B(mm)"), dEndWidth);
|
|
}
|
|
}
|
|
}
|
|
else if (eKind == eElbow)
|
|
{
|
|
double dStartWidth(0.0), dEndWidth(0.0), dThick(0.0), dRatio(0.0);;
|
|
int iSeg(3);
|
|
pMap->GetAt(HELB_StartWidth, dStartWidth);
|
|
pMap->GetAt(HELB_EndWidth, dEndWidth);
|
|
pMap->GetAt(HELB_Thick, dThick);
|
|
pMap->GetAt(HELB_Segments, iSeg);
|
|
|
|
double dEndThick(0.0);
|
|
pMap->GetAt(HELB_EndThick, dEndThick);
|
|
ESection eSectType = eRect;
|
|
pMap->GetAt(HVAC_SectType, (int&)eSectType);
|
|
AecHvac::HvacElbowType eType = AecHvac::eAllArcuate;
|
|
pMap->GetAt(HELB_Type, (int&)eType);
|
|
pMap->GetAt(HELB_RadRatio, dRatio);
|
|
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
SetTreeItemWrite(_T("虾米弯节数"), TRUE);
|
|
SetItemValueByLable(_T("曲率半径"), dRatio, 1);
|
|
|
|
if (eSectType == eRect)
|
|
{
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
|
|
SetItemValueByLable(_T("厚A(mm)"), dThick);
|
|
SetItemValueByLable(_T("厚B(mm)"), dEndThick);
|
|
}
|
|
else
|
|
{
|
|
if (eType == AecHvac::eSegmental)
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SetItemValueByLable(_T("虾米弯节数"), iSeg);
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
}
|
|
else
|
|
{
|
|
SetItemValueByLable(_T("直径A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("直径B(mm)"), dEndWidth);
|
|
}
|
|
}
|
|
|
|
double dAngle(0.0);
|
|
AcGePoint3d ptStart, ptEnd, ptCorner;
|
|
pMap->GetAt(HELB_StartPoint, ptStart);
|
|
pMap->GetAt(HELB_EndPoint, ptEnd);
|
|
pMap->GetAt(HELB_CornerPoint, ptCorner);
|
|
dAngle = (ptStart - ptCorner).angleTo(ptCorner - ptEnd);
|
|
if (dAngle > PI)
|
|
dAngle = PI*2 - dAngle;
|
|
|
|
dAngle = dAngle * 180/PI;
|
|
SetItemValueByLable(_T("角度"), dAngle);
|
|
}
|
|
else if (eKind == eTee)
|
|
{
|
|
// 设置共有参数
|
|
double dStartWidth = 0.0;
|
|
pMap->GetAt(HTEE_StartWidth, dStartWidth);
|
|
double dEndWidth = 0.0;
|
|
pMap->GetAt(HTEE_EndWidth, dEndWidth);
|
|
double dBranchWidth = 0.0;
|
|
pMap->GetAt(HTEE_BranchWidth, dBranchWidth);
|
|
|
|
double dStartThick(0.0), dEndThick(0.0), dBranchThick(0.0);
|
|
pMap->GetAt(HTEE_BranchThick, dBranchThick);
|
|
pMap->GetAt(HTEE_Thick, dStartThick);
|
|
pMap->GetAt(HTEE_EndThick, dEndThick);
|
|
|
|
if (0 == dEndThick)
|
|
{
|
|
dEndThick = dStartThick;
|
|
}
|
|
|
|
AecHvac::HvacTeeType eTeeType =AecHvac::eOrthoBranch;
|
|
pMap->GetAt(HTEE_Type, (int&)eTeeType);
|
|
if (AecHvac::eVShapeBranch == eTeeType)
|
|
{
|
|
SetItemValueByLable(_T("宽A(mm)"), dBranchWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽C(mm)"), dEndWidth);
|
|
|
|
SetItemValueByLable(_T("厚A(mm)"), dStartThick);
|
|
SetItemValueByLable(_T("厚B(mm)"), dEndThick);
|
|
SetItemValueByLable(_T("厚C(mm)"), dBranchThick);
|
|
}
|
|
else
|
|
{
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("宽C(mm)"), dBranchWidth);
|
|
|
|
SetItemValueByLable(_T("厚A(mm)"), dStartThick);
|
|
SetItemValueByLable(_T("厚B(mm)"), dEndThick);
|
|
SetItemValueByLable(_T("厚C(mm)"), dBranchThick);
|
|
}
|
|
|
|
ESection eSectType = eRect;
|
|
pMap->GetAt(HVAC_SectType, (int&)eSectType);
|
|
if (eRect == eSectType)
|
|
{
|
|
double dThick = 0.0;
|
|
pMap->GetAt(HTEE_Thick, dThick);
|
|
|
|
SetItemValueByLable(_T("厚A(mm)"), dStartThick);
|
|
|
|
// 添加支管厚
|
|
if ( AecHvac::eInsertBranch == eTeeType ||
|
|
AecHvac::eInsertIntubBranch == eTeeType ||
|
|
AecHvac::eArcuateIntubBranch == eTeeType)
|
|
{
|
|
double dBranchThick = 0.0;
|
|
pMap->GetAt(HTEE_BranchThick, dBranchThick);
|
|
|
|
SetItemValueByLable(_T("厚C(mm)"), dBranchThick);
|
|
}
|
|
|
|
// 添加曲率半径
|
|
if ( AecHvac::eYShapeBranch == eTeeType ||
|
|
AecHvac::eTShapeBranch == eTeeType ||
|
|
AecHvac::eArcuateBranch == eTeeType ||
|
|
AecHvac::eArcuateIntubBranch == eTeeType )
|
|
{
|
|
double dCR = 1.5;
|
|
pMap->GetAt(HTEE_RadRatio, dCR);
|
|
SetItemValueByLable(_T("曲率半径"), dCR, 1);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
}
|
|
|
|
// 添加夹角
|
|
if ( AecHvac::eVShapeBranch == eTeeType)
|
|
{
|
|
AcGePoint3d ptStart;
|
|
pMap->GetAt(HTEE_StartPoint, ptStart);
|
|
AcGeVector3d vtStart;
|
|
pMap->GetAt(HTEE_StartDir, vtStart);
|
|
vtStart.normalize();
|
|
AcGePoint3d ptEnd;
|
|
pMap->GetAt(HTEE_EndPoint, ptEnd);
|
|
AcGeVector3d vtEnd;
|
|
pMap->GetAt(HTEE_EndDir, vtEnd);
|
|
vtEnd.normalize();
|
|
AcGePoint3d ptBranch;
|
|
pMap->GetAt(HTEE_BranchPoint, ptBranch);
|
|
AcGeVector3d vtBranch;
|
|
pMap->GetAt(HTEE_BranchDir, vtBranch);
|
|
vtBranch.normalize();
|
|
|
|
AcGePoint3d ptFixedStart = ptStart - vtStart * FLANGE_LENGTH_ON_FITTING;
|
|
AcGePoint3d ptFixedEnd = ptEnd - vtEnd * FLANGE_LENGTH_ON_FITTING;
|
|
AcGePoint3d ptFixedBranch = ptBranch - vtBranch * FLANGE_LENGTH_ON_FITTING;
|
|
AcGeVector3d vtFixedStart = ptFixedStart - ptFixedBranch;
|
|
AcGeVector3d vtFixedEnd = ptFixedEnd - ptFixedBranch;
|
|
AcGeVector3d vtNormal;
|
|
pMap->GetAt(HVAC_Normal, vtNormal);
|
|
double dAng = vtFixedEnd.angleTo(vtFixedStart);
|
|
dAng *= 180 / PI;
|
|
dAng += 5;
|
|
const int iAdjust = int(dAng / 15);
|
|
dAng = 15 * iAdjust;
|
|
SetItemValueByLable(_T("角度"), dAng);
|
|
}
|
|
|
|
//对支持阀门的三通添加阀门选项(目前为圆角三通和斜接三通)
|
|
if ( AecHvac::eArcuateBranch == eTeeType ||
|
|
AecHvac::eInclineBranch == eTeeType)
|
|
{
|
|
int iHasValve = -1;
|
|
pMap->GetAt(HTEE_HasValve, iHasValve);
|
|
|
|
switch(iHasValve)
|
|
{
|
|
case 0:
|
|
SetItemValueByLable(_T("添加阀门"), _T("否"));
|
|
break;
|
|
case 1:
|
|
SetItemValueByLable(_T("添加阀门"), _T("是"));
|
|
break;
|
|
default:
|
|
acutPrintf(_T("\n未定义情况!"));
|
|
break;
|
|
}
|
|
|
|
SetTreeItemWrite(_T("添加阀门"), TRUE);
|
|
}
|
|
}
|
|
else if (eCircle == eSectType)
|
|
{
|
|
// 添加曲率
|
|
if ( AecHvac::eYShapeBranch == eTeeType ||
|
|
AecHvac::eVShapeBranch == eTeeType)
|
|
{
|
|
double dCR = 1.5;
|
|
pMap->GetAt(HTEE_RadRatio, dCR);
|
|
SetItemValueByLable(_T("曲率半径"), dCR, 1);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
}
|
|
|
|
// 添加夹角
|
|
if ( AecHvac::eInsertBranch == eTeeType ||
|
|
AecHvac::eInclineBranch == eTeeType)
|
|
{
|
|
AcGeVector3d vtBranch;
|
|
pMap->GetAt(HTEE_BranchDir, vtBranch);
|
|
AcGeVector3d vtEnd;
|
|
pMap->GetAt(HTEE_EndDir, vtEnd);
|
|
AcGeVector3d vtNormal;
|
|
pMap->GetAt(HVAC_Normal, vtNormal);
|
|
double dAng = vtBranch.angleTo(vtEnd);
|
|
dAng *= 180 / PI;
|
|
dAng += 5;
|
|
const int iAdjust = int(dAng / 15);
|
|
dAng = 15 * iAdjust;
|
|
SetItemValueByLable(_T("角度"), dAng);
|
|
SetTreeItemWrite(_T("角度"), TRUE);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
;
|
|
}
|
|
}
|
|
else if (eKind == eCross)
|
|
{
|
|
ESection eSectType = eRect;
|
|
pMap->GetAt(HVAC_SectType, (int&)eSectType);
|
|
AecHvac::HvacCrossType eType = AecHvac::eOrthoCross;
|
|
pMap->GetAt(HCRS_Type, (int&)eType);
|
|
double dStartWidth(0.0), dEndWidth(0.0), dBr1Width(0.0), dBr2Width(0.0);
|
|
|
|
double dThick(0.0), dRad(0.0), dEndThick(0.0), dB1Thick(0.0), dB2Thick(0.0);
|
|
AcGeVector3d vtEnd(1,0,0),vtBr1(1,0,0);
|
|
pMap->GetAt(HCRS_StartWidth, dStartWidth);
|
|
pMap->GetAt(HCRS_EndWidth, dEndWidth);
|
|
pMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
|
pMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
|
pMap->GetAt(HCRS_Thick, dThick);
|
|
|
|
pMap->GetAt(HCRS_EndThick, dEndThick);
|
|
pMap->GetAt(HCRS_Branch1Thick, dB1Thick);
|
|
pMap->GetAt(HCRS_Branch2Thick, dB2Thick);
|
|
|
|
pMap->GetAt(HCRS_RadRatio, dRad);
|
|
pMap->GetAt(HCRS_EndDir,vtEnd);
|
|
pMap->GetAt(HCRS_BranchDir1,vtBr1);
|
|
double dAngle = vtEnd.angleTo(vtBr1,AcGeVector3d::kZAxis);
|
|
if (dAngle > PI)
|
|
{
|
|
dAngle = 2 * PI - dAngle;
|
|
}
|
|
dAngle = dAngle * 180 / PI;
|
|
|
|
if (eSectType == eRect)
|
|
{
|
|
if ( eType == AecHvac::eArcuateCross ||
|
|
eType == AecHvac::eArcuateIntubCross)
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SetItemValueByLable(_T("曲率半径"), dRad, 1);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
}
|
|
else
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
}
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("宽C(mm)"), dBr1Width);
|
|
SetItemValueByLable(_T("宽D(mm)"), dBr2Width);
|
|
//kyf add设置四通各个管的厚度
|
|
SetItemValueByLable(_T("厚A(mm)"), dThick);
|
|
SetItemValueByLable(_T("厚B(mm)"), dEndThick);
|
|
SetItemValueByLable(_T("厚C(mm)"), dB1Thick);
|
|
SetItemValueByLable(_T("厚D(mm)"), dB2Thick);
|
|
|
|
}
|
|
if (eSectType == eCircle)
|
|
{
|
|
if (eType == AecHvac::eOrthoCross)
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), FALSE);
|
|
}
|
|
else
|
|
{
|
|
SubShowTreeItem(_T("构件参数"), TRUE);
|
|
SetItemValueByLable(_T("曲率半径"), dRad, 1);
|
|
SetItemValueByLable(_T("角度"), dAngle);
|
|
SetTreeItemWrite(_T("曲率半径"), TRUE);
|
|
SetTreeItemWrite(_T("角度"), TRUE);
|
|
}
|
|
SetItemValueByLable(_T("宽A(mm)"), dStartWidth);
|
|
SetItemValueByLable(_T("宽B(mm)"), dEndWidth);
|
|
SetItemValueByLable(_T("宽C(mm)"), dBr1Width);
|
|
SetItemValueByLable(_T("宽D(mm)"), dBr2Width);
|
|
}
|
|
}
|
|
pFitting->close();
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CHFitingStyleDlg::UpdateDbDefault()
|
|
{
|
|
if (m_idToEdit.isValid()) // 双击编辑时的参数修改不作为默认存储
|
|
return;
|
|
|
|
if (NULL == m_pAdoUi)
|
|
return;
|
|
|
|
// 映射首位置
|
|
POSITION pos = m_mapCurFitParam.GetStartPosition();
|
|
// 更新数据库的Sql语句
|
|
CString sUpdateSql;
|
|
// key
|
|
CString sKey;
|
|
// value
|
|
SFitParam FitParamRec;
|
|
// 依次获得变量
|
|
while (NULL != pos)
|
|
{
|
|
// 获得变量信息
|
|
m_mapCurFitParam.GetNextAssoc(pos, sKey, FitParamRec);
|
|
// 构造更新数据库Sql语句
|
|
sUpdateSql.Format(_T("UPDATE [%s] SET [Default] = '%s' WHERE [Code] = '%s'"),
|
|
GetDefTblName(m_nFitType), FitParamRec.sDefault, FitParamRec.sCode);//m_sCurParamTable,
|
|
// 执行Sql语句,更新数据
|
|
m_pAdoUi->ExecuteSQL(sUpdateSql);
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::SettingInterface(LPCTSTR pszName, UINT nFalg)
|
|
{
|
|
UpdateData();
|
|
|
|
// 删除先前属性树中的信息
|
|
m_wndPorpInfo.DeleteAllItems();
|
|
|
|
// 初始化对话框时
|
|
if (_T("") == pszName)
|
|
{
|
|
// 第一个构件信息(默认构件)
|
|
CUIIValueRecord cRecFirst;
|
|
// 当前是矩形
|
|
CString sPrev;
|
|
if (0 == m_iRadSectType)
|
|
{
|
|
// 获得指定构件
|
|
m_cTblFitInfoRect.GetValueRecord(m_iCode, cRecFirst);
|
|
|
|
cRecFirst.GetValue(5, sPrev);
|
|
}
|
|
else if (1 == m_iRadSectType) // 当前选择的是圆形
|
|
{
|
|
m_cTblFitInfoRoun.GetValueRecord(m_iCode, cRecFirst);
|
|
cRecFirst.GetValue(5, sPrev);
|
|
}
|
|
|
|
// 第一个构件对应的参数表
|
|
cRecFirst.GetValue(4, m_sCurParamTable);
|
|
// 第一个构件对应的参数信息
|
|
CUIIValueTable cParaFirst;
|
|
GetFitParamMap(cParaFirst, m_sCurParamTable);
|
|
// 构件名称
|
|
CString sNameFirst;
|
|
cRecFirst.GetValue(3, sNameFirst);
|
|
|
|
// 将构件名称添加到属性树中
|
|
m_pCurRoot = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
m_pCurRoot->SetLabelText(_T("名称"));
|
|
m_pCurRoot->SetInfoText(sNameFirst);
|
|
|
|
m_pCurRoot->Expand();
|
|
// 显示子项(名称)
|
|
CPropItem* pItem;
|
|
pItem = m_wndPorpInfo.InsertItem(new CPropItem(), m_pCurRoot);
|
|
pItem->SetLabelText(sNameFirst);
|
|
m_pCurRoot->Expand();
|
|
// 添加构件参数项
|
|
CPropItem* pRootComp = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootComp->SetLabelText(_T("构件参数"));
|
|
pRootComp->SetInfoText(_T("显示构参数信息"));
|
|
// 添加几何参数项
|
|
CPropItem* pRootGeom = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootGeom->SetLabelText(_T("几何参数"));
|
|
pRootGeom->SetInfoText(_T("显示几何参数"));
|
|
|
|
// 单个变量信息
|
|
CUIIValueRecord cRecordParam;
|
|
// 参数类型
|
|
CString sTypeParam;
|
|
// 控件类型
|
|
CString sCtrlType;
|
|
UINT nCtrlType = 0;
|
|
// 变量代号
|
|
CString sCodeParam;
|
|
// 变量显示状态
|
|
CString sShowStatus;
|
|
UINT nShowStatus = 0;
|
|
|
|
// 参数个数
|
|
int iCount = cParaFirst.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得每一个参数信息
|
|
cParaFirst.GetValueRecord(i, cRecordParam);
|
|
// 获得参数类型
|
|
cRecordParam.GetValue(1, sTypeParam);
|
|
// 参数代号
|
|
cRecordParam.GetValue(0, sCodeParam);
|
|
// 显示状态
|
|
cRecordParam.GetValue(8, sShowStatus);
|
|
nShowStatus = _ttoi(sShowStatus);
|
|
// 变量不显示
|
|
if (2 == nShowStatus)
|
|
continue;
|
|
|
|
// 构件参数
|
|
if (_T("0") == sTypeParam)
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootComp, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else // 几何参数
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootGeom, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 展开
|
|
pRootGeom->Expand();
|
|
pRootComp->Expand();
|
|
pRootComp = NULL;
|
|
pRootGeom = NULL;
|
|
}
|
|
else // 选择不同的构件
|
|
{
|
|
// 删除先前属性信息
|
|
m_wndPorpInfo.DeleteAllItems();
|
|
|
|
// 一条记录
|
|
CUIIValueRecord cRecord;
|
|
CString sPrev;
|
|
int iCount = 0;
|
|
// 当前是矩形
|
|
if (0 == m_iRadSectType)
|
|
{
|
|
// 根据传入的构件名称,确定构件
|
|
iCount = m_cTblFitInfoRect.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(nFalg, sPrev);
|
|
// 找到对应的构件,退出循环,i为当前构件索引
|
|
if (pszName == sPrev)
|
|
break;
|
|
}
|
|
|
|
// 获得指定构件
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
//m_nFitCode = i;
|
|
}
|
|
else if (1 == m_iRadSectType) // 当前选择的是圆形
|
|
{
|
|
// 根据传入的构件名称,确定构件
|
|
iCount = m_cTblFitInfoRoun.GetTableLogicSize();
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(nFalg, sPrev);
|
|
// 找到对应的构件,退出循环,i为当前构件索引
|
|
if (pszName == sPrev)
|
|
break;
|
|
}
|
|
|
|
// 获得指定构件
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
//m_nFitCode = i;
|
|
}
|
|
|
|
// 指定构件对应的参数表
|
|
cRecord.GetValue(4, m_sCurParamTable);
|
|
// 指定构件对应的参数信息(函数内部保存了当前选择构件的参数信息)
|
|
CUIIValueTable cTblParam;
|
|
GetFitParamMap(cTblParam, m_sCurParamTable);
|
|
// 构件名称
|
|
CString sName;
|
|
cRecord.GetValue(3, sName);
|
|
|
|
// 将构件名称添加到属性树中
|
|
m_pCurRoot = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
m_pCurRoot->SetLabelText(_T("名称"));
|
|
m_pCurRoot->SetInfoText(sName);
|
|
m_pCurRoot->Expand();
|
|
// 显示子项(名称)
|
|
CPropItem* pItem;
|
|
pItem = m_wndPorpInfo.InsertItem(new CPropItem(), m_pCurRoot);
|
|
if (NULL == pItem)
|
|
return;
|
|
|
|
pItem->SetLabelText(sName);
|
|
pItem->SetLabelText(sName);
|
|
m_pCurRoot->Expand();
|
|
|
|
// 添加构件参数项
|
|
CPropItem* pRootComp = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootComp->SetLabelText(_T("构件参数"));
|
|
pRootComp->SetInfoText(_T("显示构参数信息"));
|
|
// 添加几何参数项
|
|
CPropItem* pRootGeom = m_wndPorpInfo.InsertItem(new CPropItem());
|
|
pRootGeom->SetLabelText(_T("几何参数"));
|
|
pRootGeom->SetInfoText(_T("显示几何参数"));
|
|
|
|
// 参数个数
|
|
iCount = cTblParam.GetTableLogicSize();
|
|
// 单个变量信息
|
|
CUIIValueRecord cRecordParam;
|
|
// 参数类型
|
|
CString sTypeParam;
|
|
// 控件类型
|
|
CString sCtrlType;
|
|
UINT nCtrlType = 0;
|
|
// 变量代号
|
|
CString sCodeParam;
|
|
// 变量显示状态
|
|
CString sShowStatus;
|
|
UINT nShowStatus = 0;
|
|
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得每一个参数信息
|
|
cTblParam.GetValueRecord(i, cRecordParam);
|
|
// 参数类型
|
|
cRecordParam.GetValue(1, sTypeParam);
|
|
// 参数代号
|
|
cRecordParam.GetValue(0, sCodeParam);
|
|
// 获得显示状态
|
|
cRecordParam.GetValue(8, sShowStatus);
|
|
nShowStatus = _ttoi(sShowStatus);
|
|
// 变量不显示
|
|
if (2 == nShowStatus)
|
|
continue;
|
|
|
|
// 构件参数
|
|
if (_T("0") == sTypeParam)
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootComp, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootComp, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else // 几何参数
|
|
{
|
|
// 控件类型
|
|
cRecordParam.GetValue(2, sCtrlType);
|
|
nCtrlType = _ttoi(sCtrlType);
|
|
// 根据控件类型显示数据
|
|
switch (nCtrlType)
|
|
{
|
|
// 组合框(可编辑)
|
|
case 4:
|
|
FillDropDownComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 组合框(不可编辑)
|
|
case 3:
|
|
FillDropListComb(sCodeParam, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带Spin
|
|
case 2:
|
|
FillEditItem(sCodeParam, 2, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框带按钮
|
|
case 1:
|
|
FillEditItem(sCodeParam, 1, pRootGeom, nShowStatus);
|
|
break;
|
|
// 编辑框
|
|
case 0:
|
|
FillEditItem(sCodeParam, 0, pRootGeom, nShowStatus);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 展开
|
|
pRootGeom->Expand();
|
|
pRootComp->Expand();
|
|
pRootComp = NULL;
|
|
pRootGeom = NULL;
|
|
}
|
|
|
|
if (m_idToEdit.isValid())
|
|
{
|
|
ModifyGridValueByEnt();
|
|
|
|
if (m_nFitType == 0)
|
|
{
|
|
CPropItem* pItem = m_wndPorpInfo.FindItem(_T("角度"));
|
|
if (NULL != pItem)
|
|
{
|
|
m_wndPorpInfo.ReadOnly(pItem, TRUE);
|
|
}
|
|
}
|
|
}
|
|
ShowTreeItem();
|
|
}
|
|
|
|
// 选择构件
|
|
void CHFitingStyleDlg::OnGridPreviewClick(NMHDR *pNotifyStruct, LRESULT* pResult)
|
|
{
|
|
UpdateDbDefault();
|
|
NM_GRIDVIEW* pItem = (NM_GRIDVIEW*) pNotifyStruct;
|
|
|
|
// 当单元格中构件的名称或示意图
|
|
CString sCurName = m_wndGridPreview.GetItemText(pItem->iRow, pItem->iColumn);
|
|
CString sCurPrev = m_wndGridPreview.GetCurrBMP(pItem->iRow, pItem->iColumn);
|
|
// 当前选中是一空表格
|
|
if (_T("") == sCurName && _T("") == sCurPrev)
|
|
{
|
|
pResult = 0;
|
|
return;
|
|
}
|
|
|
|
m_sCurrName = sCurName;
|
|
|
|
if (m_iRadSectType == 0)
|
|
m_sCurFitRect = sCurName;
|
|
else
|
|
m_sCurFitRoun = sCurName;
|
|
|
|
m_wndGridPreview.SetItemCheck(m_iCurDefaIndexRow, m_iCurDefaIndexCol, FALSE);
|
|
m_wndGridPreview.SetItemCheck(pItem->iRow, pItem->iColumn, TRUE);
|
|
m_iCurDefaIndexRow = pItem->iRow;
|
|
m_iCurDefaIndexCol = pItem->iColumn;
|
|
m_wndGridPreview.Refresh();
|
|
|
|
// 通过名称从数据库中获得指定构件参数信息和构件代号
|
|
if (NULL == m_pAdoUi)
|
|
return;
|
|
|
|
CString sFitCode;
|
|
CString sSqlQuery;
|
|
if (_T("") != sCurName)
|
|
{
|
|
// 设置当前构件的参数信息
|
|
sSqlQuery.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Name] = '%s'"), sCurName);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sSqlQuery, sFitCode))
|
|
return;
|
|
m_nFitCode = _ttoi(sFitCode);
|
|
|
|
SettingInterface(sCurName, 3);
|
|
}
|
|
else // 通过示意图
|
|
{
|
|
// 设置当前构件的参数信息
|
|
sSqlQuery.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Preview] = '%s'"), sCurPrev);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sSqlQuery, sFitCode))
|
|
return;
|
|
m_nFitCode = _ttoi(sFitCode);
|
|
|
|
SettingInterface(sCurPrev, 4);
|
|
}
|
|
*pResult = 0;
|
|
}
|
|
|
|
// 截面类型为矩形
|
|
void CHFitingStyleDlg::OnRadRect()
|
|
{
|
|
m_wndGridPreview.DeleteAllItems();
|
|
|
|
// 设置单元格行、列数
|
|
m_wndGridPreview.SetColumnCount(5);
|
|
int iCount = m_cTblFitInfoRect.GetTableLogicSize();
|
|
int iRow = iCount / 5;
|
|
if (0 != iCount % 5)
|
|
iRow++;
|
|
m_wndGridPreview.SetRowCount(iRow);
|
|
|
|
// 填充表格
|
|
CString sPreview;
|
|
// 构件名称
|
|
CString sName;
|
|
// 单条记录
|
|
CUIIValueRecord cRecord;
|
|
// 查找构件示意图
|
|
CFileFind cFile;
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得构件示意图和名称
|
|
m_cTblFitInfoRect.GetValueRecord(i, cRecord);
|
|
cRecord.GetValue(5, sPreview);
|
|
cRecord.GetValue(3, sName);
|
|
sPreview.Format(_T("HvacFitingIcons\\%s"), sPreview);
|
|
sPreview = GetPath(1) + sPreview;
|
|
|
|
// 目录下有对应的图片名称
|
|
if (cFile.FindFile(sPreview))
|
|
{
|
|
m_wndGridPreview.SetItemBMP(i / 5, i % 5, sPreview);
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
else // 没有对应的示意图,显示构件名称
|
|
{
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
|
|
// 查找并保存当前连接件索引
|
|
if (m_sCurFitRect == sName)
|
|
{
|
|
m_iCurDefaIndexRow = i / 5;
|
|
m_iCurDefaIndexCol = i % 5;
|
|
}
|
|
}
|
|
|
|
// 设置默认构件提示
|
|
m_wndGridPreview.SetItemCheck(m_iCurDefaIndexRow, m_iCurDefaIndexCol, TRUE);
|
|
m_wndGridPreview.Refresh();
|
|
|
|
// 设置单元格的大小
|
|
for (i = 0; i < iRow; i++)
|
|
{
|
|
m_wndGridPreview.SetRowHeight(i, 75);
|
|
}
|
|
|
|
// mcl add.2010.03.19.win7下必须加上跟OnInitDialog()中一致,否则变大
|
|
for (i=0;i<m_wndGridPreview.GetColumnCount();i++)
|
|
{
|
|
m_wndGridPreview.SetColumnWidth(i,85);
|
|
}
|
|
|
|
UpdateData();
|
|
|
|
CString sCurName = _T("");
|
|
if (m_iRadSectType == 0)
|
|
sCurName = m_sCurFitRect;
|
|
else
|
|
sCurName = m_sCurFitRoun;
|
|
|
|
CString sCodeSql = _T("");
|
|
CString sFitCode = _T("");
|
|
sCodeSql.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Name] = '%s'"), sCurName);
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sCodeSql, sFitCode))
|
|
return;
|
|
m_nFitCode = _ttoi(sFitCode);
|
|
|
|
// 设置 参数信息
|
|
SettingInterface(sCurName, 3);
|
|
}
|
|
|
|
// 截面类型为圆形
|
|
void CHFitingStyleDlg::OnRadRoun()
|
|
{
|
|
// 删除先前属性信息
|
|
m_wndGridPreview.DeleteAllItems();
|
|
|
|
// 设置单元格行、列数
|
|
m_wndGridPreview.SetColumnCount(5);
|
|
int iCount = m_cTblFitInfoRoun.GetTableLogicSize();
|
|
int iRow = iCount / 5;
|
|
if (0 != iCount % 5)
|
|
iRow++;
|
|
m_wndGridPreview.SetRowCount(iRow);
|
|
|
|
// 填充表格
|
|
CString sPreview;
|
|
// 构件名称
|
|
CString sName;
|
|
// 单条记录
|
|
CUIIValueRecord cRecord;
|
|
|
|
|
|
// 查找构件示意图
|
|
CFileFind cFile;
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
// 获得构件示意图和名称
|
|
m_cTblFitInfoRoun.GetValueRecord(i, cRecord);
|
|
|
|
cRecord.GetValue(5, sPreview);
|
|
cRecord.GetValue(3, sName);
|
|
|
|
|
|
// 构造图片路径
|
|
sPreview.Format(_T("HvacFitingIcons\\%s"), sPreview);
|
|
sPreview = GetPath(1) + sPreview;
|
|
// 目录下有对应的图片名称
|
|
if (cFile.FindFile(sPreview))
|
|
{
|
|
m_wndGridPreview.SetItemBMP(i / 5, i % 5, sPreview);
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
else // 没有对应的示意图,显示构件名称
|
|
{
|
|
m_wndGridPreview.SetItemText(i / 5, i % 5, sName);
|
|
}
|
|
|
|
// 查找并保存当前连接件索引
|
|
if (m_sCurFitRoun == sName)
|
|
{
|
|
m_iCurDefaIndexRow = i / 5;
|
|
m_iCurDefaIndexCol = i % 5;
|
|
}
|
|
}
|
|
|
|
// 设置默认构件提示
|
|
m_wndGridPreview.SetItemCheck(m_iCurDefaIndexRow, m_iCurDefaIndexCol, TRUE);
|
|
m_wndGridPreview.Refresh();
|
|
|
|
// 设置单元格的大小
|
|
for (i = 0; i < iRow; i++)
|
|
{
|
|
m_wndGridPreview.SetRowHeight(i, 75);
|
|
}
|
|
|
|
for (i=0;i<m_wndGridPreview.GetColumnCount();i++)
|
|
{
|
|
m_wndGridPreview.SetColumnWidth(i,85);
|
|
}
|
|
|
|
UpdateData();
|
|
CString sDefName = _T("");
|
|
|
|
if (m_iRadSectType == 0)
|
|
sDefName = m_sCurFitRect;
|
|
else
|
|
sDefName = m_sCurFitRoun;
|
|
|
|
CString sCodeSql = _T("");
|
|
CString sFitCode = _T("");
|
|
sCodeSql.Format(_T("SELECT [Code] FROM [EquiInfo] WHERE [Name] = '%s'"), sDefName);
|
|
|
|
// 获得连接件代号
|
|
if (!m_pAdoUi->GetSelData(sCodeSql, sFitCode))
|
|
return;
|
|
|
|
m_nFitCode = _ttoi(sFitCode);
|
|
|
|
// 设置用户接口(设备参数信息)依赖于m_nFitCode
|
|
SettingInterface(sDefName, 3);
|
|
}
|
|
|
|
LRESULT CHFitingStyleDlg::OnGridSelectChanged( WPARAM iParam1, LPARAM iParam2 )
|
|
{
|
|
CPropItemCombo* pComBo = (CPropItemCombo*)iParam2;
|
|
if (NULL == pComBo)
|
|
return FALSE;
|
|
|
|
CString csText = pComBo->GetLabelText();
|
|
if (csText == _T("计算方法"))
|
|
{
|
|
ShowTreeItem();
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void CHFitingStyleDlg::BeginEditorCommand()
|
|
{
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();;
|
|
}
|
|
|
|
LRESULT CHFitingStyleDlg::OnGridButtonClick(WPARAM iParam1, LPARAM iParam2)
|
|
{
|
|
CPropItemEdit *pItem = (CPropItemEdit*)iParam2;
|
|
CString sCmbText;
|
|
if (pItem != NULL)
|
|
{
|
|
BeginEditorCommand();
|
|
|
|
//判断当前操作的控件是接口还是设备型号
|
|
CString sLabelText = pItem->GetLabelText();
|
|
CString sValue;
|
|
sValue = pItem->GetValueText();
|
|
|
|
ads_name entMainDuct;
|
|
ads_point ptIns;
|
|
|
|
AcGePoint3d ptStartDuct;
|
|
AcGePoint3d ptEndDuct;
|
|
CString csPrompt;
|
|
bool bReadDuct = false;
|
|
struct resbuf* pResbuf = acutBuildList(RTDXF0, _T("AEC_DBDUCT"), 0); ;
|
|
|
|
AcAxDocLock lock;
|
|
int nRet = 0;
|
|
if (sLabelText.Find(_T("长度")) > -1)
|
|
{
|
|
csPrompt = _T("\n请选择风管端点:");
|
|
if (RTNORM != ( nRet = CKTCadUtility::SelectEntity1(csPrompt,entMainDuct,pResbuf,ptIns) ) )
|
|
{
|
|
acutRelRb(pResbuf);
|
|
bReadDuct = false;
|
|
}
|
|
else if (nRet == RTNORM)
|
|
{
|
|
bReadDuct = true;
|
|
}
|
|
}
|
|
else if ( sLabelText.Find(_T("偏移")) == -1 &&
|
|
sLabelText.Find(_T("长度")) == -1)
|
|
{
|
|
csPrompt = _T("\n请选择风管<退出>:");
|
|
if (RTNORM == ( nRet = CKTCadUtility::SelectEntity1(csPrompt,entMainDuct,pResbuf,ptIns) ) )
|
|
{
|
|
bReadDuct = true;
|
|
}
|
|
}
|
|
|
|
double dWidth(0.0),dThick(0.0);
|
|
if (bReadDuct)
|
|
{
|
|
AcDbObjectId idDuct;
|
|
acdbGetObjectId(idDuct,entMainDuct);
|
|
|
|
AecDbHvacDuct* pDuct = NULL;
|
|
|
|
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pDuct,idDuct, AcDb::kForRead ) )
|
|
{
|
|
AecDbObjXDataMap* pMap = pDuct->GetSpecialtyData(AcDb::kForRead);
|
|
if (NULL != pMap)
|
|
{
|
|
pMap->GetAt(HDCT_Width, dWidth); // 管径
|
|
pMap->GetAt(HDCT_Thick, dThick); // 管径
|
|
|
|
pMap->GetAt(HDCT_START, ptStartDuct);
|
|
pMap->GetAt(HDCT_END, ptEndDuct);
|
|
}
|
|
pDuct->close();
|
|
}
|
|
}
|
|
|
|
if (sLabelText.Find(_T("宽")) > -1 && dWidth > 0)
|
|
{
|
|
sValue.Format(_T("%.0f"),dWidth);
|
|
}
|
|
else if (sLabelText.Find(_T("厚")) > -1 && dWidth > 0)
|
|
{
|
|
sValue.Format(_T("%.0f"),dThick);
|
|
}
|
|
else if (sLabelText.Find(_T("直径")) > -1 && dWidth > 0)
|
|
{
|
|
sValue.Format(_T("%.0f"),dWidth);
|
|
}
|
|
else if (sLabelText.Find(_T("长度")) > -1)
|
|
{
|
|
double dPlusEdge = 0.0;
|
|
double dLength = -1;
|
|
ads_point ptResult;
|
|
if (bReadDuct)
|
|
{
|
|
int nRet = acedGetPoint(ptIns, _T("\n请指定另一风管的端点:"), ptResult);
|
|
if (nRet == RTNORM)
|
|
{
|
|
AcGeVector3d vtStd = ptEndDuct - ptStartDuct;
|
|
vtStd.normalize();
|
|
|
|
AcGeVector3d vtAssist = asPnt3d(ptResult) - asPnt3d(ptIns);
|
|
dLength = fabs(vtStd.dotProduct(vtAssist));
|
|
sValue.Format(_T("%.0f"), dLength);
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n另一风管的端点选择失败!\n"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n参考风管端点选择失败!\n"));
|
|
}
|
|
}
|
|
else if (sLabelText.Find(_T("偏移")) > -1)
|
|
{
|
|
ads_point ptStart;
|
|
double dDist = -1.0;
|
|
int nRet = RTERROR;
|
|
nRet = acedGetPoint(NULL, _T("\n请指定测量偏移的起点:"), ptStart);
|
|
if (nRet == RTNORM)
|
|
{
|
|
nRet = acedGetDist(ptStart, _T("\n请指定测量偏移的终点:"), &dDist);
|
|
if (nRet == RTNORM)
|
|
{
|
|
sValue.Format(_T("%.0f"), dDist);
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n偏移终点选择失败!\n"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n偏移起点选择失败!\n"));
|
|
}
|
|
}
|
|
pItem->SetValueText(sValue);
|
|
|
|
EndEditorCommand();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void CHFitingStyleDlg::EndEditorCommand ()
|
|
{
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
}
|
|
|
|
void CHFitingStyleDlg::OnBnClickedOk()
|
|
{
|
|
if (m_idToEdit.isValid())
|
|
{
|
|
OnReplace();
|
|
EndDialog(IDOK);
|
|
}
|
|
else
|
|
{
|
|
OnOK();
|
|
}
|
|
}
|
|
|
|
void CHFitingStyleDlg::OnReplace()
|
|
{
|
|
CMapFitaram mapFitParam;
|
|
GetFitParamMap(mapFitParam);
|
|
|
|
int nFitCode = GetFitCode();
|
|
int nFitSect = GetFitSect();
|
|
|
|
switch(m_nFitType)
|
|
{
|
|
case 0:
|
|
{
|
|
//弯头替换
|
|
CHVACFittingToolkit::EblowReplace(mapFitParam,nFitCode,nFitSect,m_idToEdit);
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
//变径替换
|
|
CHVACFittingToolkit::ReducerReplace(mapFitParam,nFitCode,nFitSect,m_idToEdit);
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
//三通替换
|
|
CHVACFittingToolkit::TeeReplace(mapFitParam,nFitCode,nFitSect,m_idToEdit);
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
//四通替换
|
|
CHVACFittingToolkit::CrossReplace(mapFitParam,nFitCode,nFitSect,m_idToEdit);
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
//乙字弯替换
|
|
CHVACFittingToolkit::OffsetReplace(mapFitParam,nFitCode,nFitSect,m_idToEdit);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
} |