Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

526 lines
13 KiB
C++

#include "stdafx.h"
#include "EarThwormDef.h"
#include "WPipeDimConfigDlg.h"
#include "AECDimScriptDlg.h"
#include "AECElSetupDlg.h"
IMPLEMENT_DYNAMIC(CWPipeDimConfigDlg, CDialog)
CWPipeDimConfigDlg::CWPipeDimConfigDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWPipeDimConfigDlg::IDD, pParent)
, m_dTextHeight(0)
, m_dTextWFact(0)
, m_dEqpTxtHeight(0)
, m_dEqpTxtWFact(0)
, m_bDN(FALSE)
, m_bD(FALSE)
, m_sElType(_T(""))
{
m_sEl = _T("");
m_sTopEl = _T("");
m_sCenEl = _T("");
m_sBomEl = _T("");
m_sScriptUp = _T("");
m_sScriptDown = _T("");
m_pPipeInitData = NULL;
}
CWPipeDimConfigDlg::~CWPipeDimConfigDlg()
{
}
void CWPipeDimConfigDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDITTEXTHEIGHT, m_dTextHeight);
DDX_Text(pDX, IDC_EDITTEXTWFACT, m_dTextWFact);
DDX_Text(pDX, IDC_EDITEQPTXTHEIGHT, m_dEqpTxtHeight);
DDX_Text(pDX, IDC_EDITEQPTXTWFACT, m_dEqpTxtWFact);
DDX_Control(pDX, IDC_STATIC_BMP_TOPEL, m_wndBmpTopEl);
DDX_Control(pDX, IDC_STATIC_BMP_EL, m_wndBmpEl);
DDX_Control(pDX, IDC_STATIC_BMP_CENEL, m_wndBmpCenEl);
DDX_Control(pDX, IDC_STATIC_BMP_BOMEL, m_wndBmpBomEl);
DDX_Control(pDX, IDC_STATIC_EL, m_wndEl);
DDX_Control(pDX, IDC_STATIC_EL_BOM, m_wndElBom);
DDX_Control(pDX, IDC_STATIC_EL_CEN, m_wndElCen);
DDX_Control(pDX, IDC_STATIC_EL_TOP, m_wndElTop);
//DDX_Control(pDX, IDC_STATIC_EL_TYPE, m_wndElType);
DDX_Text(pDX, IDC_EDITDIMUP, m_sScriptUp);
DDX_Text(pDX, IDC_EDITDIMBOTTOM, m_sScriptDown);
DDX_Check(pDX, IDC_CHECKDN, m_bDN);
DDX_Check(pDX, IDC_CHECKD, m_bD);
DDX_Check(pDX, IDC_CHECKO, m_bO);
}
BEGIN_MESSAGE_MAP(CWPipeDimConfigDlg, CDialog)
ON_BN_CLICKED(IDC_BTELSETUP, &CWPipeDimConfigDlg::OnBnClickedBtelsetup)
ON_BN_CLICKED(IDC_BUTTONUPSET, &CWPipeDimConfigDlg::OnBnClickedButtonupset)
ON_BN_CLICKED(IDC_BUTTONDOWNSET, &CWPipeDimConfigDlg::OnBnClickedButtondownset)
ON_BN_CLICKED(IDOK, &CWPipeDimConfigDlg::OnBnClickedOk)
ON_BN_CLICKED(IDC_CHECKO, &CWPipeDimConfigDlg::OnBnClickedChecko)
END_MESSAGE_MAP()
void CWPipeDimConfigDlg::SetPipeInitData(AecDbObjXDataMap* pXData)
{
m_pPipeInitData = pXData;
}
BOOL CWPipeDimConfigDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_bmpEl.LoadBitmap(IDB_BITMAPEL);
m_bmpTopEl.LoadBitmap(IDB_BITMAPTOPEL);
m_bmpCenEl.LoadBitmap(IDB_BITMAPCENEL);
m_bmpBomEl.LoadBitmap(IDB_BITMAPBOTEL);
InitFromMap();
GetDlgItem(IDC_CHECKD)->EnableWindow(!m_bO);
GetDlgItem(IDC_CHECKDN)->EnableWindow(!m_bO);
return TRUE;
}
void CWPipeDimConfigDlg::OnBnClickedBtelsetup()
{
int nVal = 0;
m_pPipeInitData->GetAt(DOC_ELTYPE,nVal);
AECElSetupDlg wndElDlg;
wndElDlg.m_nElGroup = nVal;
wndElDlg.m_sEl = m_sEl;
wndElDlg.m_sTopEl = m_sTopEl;
wndElDlg.m_sCenEl = m_sCenEl;
wndElDlg.m_sBomEl = m_sBomEl;
int nRes = wndElDlg.DoModal();
if (nRes == IDOK)
{
m_pPipeInitData->SetAt(DOC_ELTYPE,wndElDlg.m_nElGroup);
nVal = wndElDlg.m_nElGroup;
if (nVal >= 0 && nVal <= 2)
{
CString sText;
sText = g_pszElTypeTxt;
sText += g_pszElType[nVal];
//m_wndElType.SetWindowText(sText);
m_sElType = sText;
switch(nVal)
{
case 0: //符号标高
{
m_wndEl.ShowWindow(SW_HIDE);
m_wndBmpEl.ShowWindow(SW_SHOW);
m_wndBmpEl.SetBitmap(m_bmpEl);
m_wndElBom.ShowWindow(SW_HIDE);
m_wndBmpBomEl.ShowWindow(SW_SHOW);
m_wndBmpBomEl.SetBitmap(m_bmpBomEl);
m_wndElCen.ShowWindow(SW_HIDE);
m_wndBmpCenEl.ShowWindow(SW_SHOW);
m_wndBmpCenEl.SetBitmap(m_bmpCenEl);
m_wndElTop.ShowWindow(SW_HIDE);
m_wndBmpTopEl.ShowWindow(SW_SHOW);
m_wndBmpTopEl.SetBitmap(m_bmpTopEl);
break;
}
case 1: //简写标高
{
m_sEl = PIPE_EL;
m_wndEl.SetWindowText(m_sEl);
m_wndEl.ShowWindow(SW_SHOW);
m_wndBmpEl.ShowWindow(SW_HIDE);
m_sTopEl = PIPE_TOP_EL;
m_wndElTop.SetWindowText(m_sTopEl);
m_wndElTop.ShowWindow(SW_SHOW);
m_wndBmpTopEl.ShowWindow(SW_HIDE);
m_sCenEl = PIPE_CEN_EL;
m_wndElCen.SetWindowText(m_sCenEl);
m_wndElCen.ShowWindow(SW_SHOW);
m_wndBmpCenEl.ShowWindow(SW_HIDE);
m_sBomEl = PIPE_BOM_EL;
m_wndElBom.SetWindowText(m_sBomEl);
m_wndElBom.ShowWindow(SW_SHOW);
m_wndBmpBomEl.ShowWindow(SW_HIDE);
break;
}
case 2: //自定义标高
{
m_sEl = wndElDlg.m_sEl;
m_sTopEl = wndElDlg.m_sTopEl;
m_sCenEl = wndElDlg.m_sCenEl;
m_sBomEl = wndElDlg.m_sBomEl;
m_wndEl.SetWindowText(m_sEl);
m_wndEl.ShowWindow(SW_SHOW);
m_wndBmpEl.ShowWindow(SW_HIDE);
m_wndElTop.SetWindowText(m_sTopEl);
m_wndElTop.ShowWindow(SW_SHOW);
m_wndBmpTopEl.ShowWindow(SW_HIDE);
m_wndElCen.SetWindowText(m_sCenEl);
m_wndElCen.ShowWindow(SW_SHOW);
m_wndBmpCenEl.ShowWindow(SW_HIDE);
m_wndElBom.SetWindowText(m_sBomEl);
m_wndElBom.ShowWindow(SW_SHOW);
m_wndBmpBomEl.ShowWindow(SW_HIDE);
sText.Format(_T("%s|%s|%s|%s"),m_sEl,m_sTopEl,m_sCenEl,m_sBomEl);
m_pPipeInitData->SetAt(DOC_ELDESCR,sText);
break;
}
default:
break;
}
}
}
}
void CWPipeDimConfigDlg::OnBnClickedButtonupset()
{
CString sText,sText2;
m_pPipeInitData->GetAt(DOC_SCRIPTT,sText); //上标脚本
//{0}{-}{1}{-}{2}{-}{3} -> {公称直径}{-}{介质}{-}{管道等级}
PipeScript2Detail(sText,sText2);
AECDimScriptDlg scrDlg;
scrDlg.SetPipeDimScript(sText2);
if (IDOK == scrDlg.DoModal())
{
//{..}{..}{..}
scrDlg.GetPipeDimScript(m_sScriptUp);
sText2 = _T("");
PipeDetail2Script(m_sScriptUp,sText2);
m_pPipeInitData->SetAt(DOC_SCRIPTT,sText2);
m_sScriptUp.Replace(_T("{"),_T(""));
m_sScriptUp.Replace(_T("}"),_T(""));
UpdateData(FALSE);
}
}
void CWPipeDimConfigDlg::OnBnClickedButtondownset()
{
CString sText,sText2;
m_pPipeInitData->GetAt(DOC_SCRIPTB,sText); //上标脚本
//{0}{-}{1}{-}{2}{-}{3} -> {公称直径}{-}{介质}{-}{管道等级}
PipeScript2Detail(sText,sText2);
AECDimScriptDlg scrDlg;
scrDlg.SetPipeDimScript(sText2);
if (IDOK == scrDlg.DoModal())
{
scrDlg.GetPipeDimScript(m_sScriptDown);
sText2 = _T("");
PipeDetail2Script(m_sScriptDown,sText2);
m_pPipeInitData->SetAt(DOC_SCRIPTB,sText2);
m_sScriptDown.Replace(_T("{"),_T(""));
m_sScriptDown.Replace(_T("}"),_T(""));
UpdateData(FALSE);
}
}
void CWPipeDimConfigDlg::InitFromMap()
{
if (m_pPipeInitData == NULL) return;
double dVal = 0.0;
int nVal = 0;
m_pPipeInitData->GetAt(DOC_DIMTERM,nVal); //标注端符
CheckRadioButton(IDC_RADIONONE,IDC_RADIOARROW,nVal + IDC_RADIONONE);
m_pPipeInitData->GetAt(DOC_DIMTXTH,m_dTextHeight); //标注文字高度
m_pPipeInitData->GetAt(DOC_DIMTXTF,m_dTextWFact); //标注文字宽度系数
m_pPipeInitData->GetAt(DOC_EQPTXTH,m_dEqpTxtHeight); //设备标注文字高度
m_pPipeInitData->GetAt(DOC_EQPTXTF,m_dEqpTxtWFact); //设备标注文字宽度系数
/*enum PipeDim
{
kDN = 0,// 公称直径
kMedium = 1,// 介质
kPipeNo = 2,// 管号
kPipeGrade = 3,// 管道等级
kDxt = 4,// 外径x 壁厚
kEl = 5,// 标高
kType = 6,// 类型
kHeatIns = 7,// 保温伴热
kElbowRat = 8,// 弯头比率
kStandard = 9,// 标准
kMaterial = 10,//材质
kZone = 11,
};*/
CString sText,sText2;//{0}{-}{1}{-}{2}{-}{3} -> {公称直径}{-}{介质}{-}{管道等级}
m_pPipeInitData->GetAt(DOC_SCRIPTT,sText); //上标脚本
PipeScript2Detail(sText,sText2);
m_sScriptUp = sText2;
m_pPipeInitData->GetAt(DOC_SCRIPTB,sText); //下标脚本
PipeScript2Detail(sText,sText2);
m_sScriptDown = sText2;
m_pPipeInitData->GetAt(DOC_DNPRE,m_bDN);
m_pPipeInitData->GetAt(DOC_DPRE,m_bD);
m_pPipeInitData->GetAt(DOC_ADPRE,m_bO);
m_sScriptDown.Replace(_T("{"),_T(""));
m_sScriptDown.Replace(_T("}"),_T(""));
m_sScriptUp.Replace(_T("{"),_T(""));
m_sScriptUp.Replace(_T("}"),_T(""));
m_pPipeInitData->GetAt(DOC_ELTYPE,nVal); //标高设置
if (nVal >= 0 && nVal <= 2)
{
sText = g_pszElTypeTxt;
sText += g_pszElType[nVal];
//m_wndElType.SetWindowText(sText);
m_sElType = sText;
switch(nVal)
{
case 0: //符号标高
{
m_wndEl.ShowWindow(SW_HIDE);
m_wndBmpEl.SetBitmap(m_bmpEl);
m_wndElBom.ShowWindow(SW_HIDE);
m_wndBmpBomEl.SetBitmap(m_bmpBomEl);
m_wndElCen.ShowWindow(SW_HIDE);
m_wndBmpCenEl.SetBitmap(m_bmpCenEl);
m_wndElTop.ShowWindow(SW_HIDE);
m_wndBmpTopEl.SetBitmap(m_bmpTopEl);
break;
}
case 1: //简写标高
{
m_sEl = PIPE_EL;
m_wndEl.SetWindowText(m_sEl);
m_wndBmpEl.ShowWindow(SW_HIDE);
m_sTopEl = PIPE_TOP_EL;
m_wndElTop.SetWindowText(m_sTopEl);
m_wndBmpTopEl.ShowWindow(SW_HIDE);
m_sCenEl = PIPE_CEN_EL;
m_wndElCen.SetWindowText(m_sCenEl);
m_wndBmpCenEl.ShowWindow(SW_HIDE);
m_sBomEl = PIPE_BOM_EL;
m_wndElBom.SetWindowText(m_sBomEl);
m_wndBmpBomEl.ShowWindow(SW_HIDE);
break;
}
case 2: //自定义标高
{
m_pPipeInitData->GetAt(DOC_ELDESCR,sText);
ElDescr2EveryOne(sText);
m_wndEl.SetWindowText(m_sEl);
m_wndBmpEl.ShowWindow(SW_HIDE);
m_wndElTop.SetWindowText(m_sTopEl);
m_wndBmpTopEl.ShowWindow(SW_HIDE);
m_wndElCen.SetWindowText(m_sCenEl);
m_wndBmpCenEl.ShowWindow(SW_HIDE);
m_wndElBom.SetWindowText(m_sBomEl);
m_wndBmpBomEl.ShowWindow(SW_HIDE);
break;
}
default:
break;
}
}
UpdateData(FALSE);
}
void CWPipeDimConfigDlg::ElDescr2EveryOne(CString& sText)
{
//--|--|--
int nLen = sText.GetLength();
if (nLen == 0) return;
int nIndex = sText.Find(KT_SEPARATOR_CHAR,0);
m_sEl = sText.Mid(0,nIndex);
sText.SetAt(nIndex,KT_SUBTRACT_CHAR); //'-'
int nIndex1 = nIndex;
nIndex = sText.Find(KT_SEPARATOR_CHAR,0); //'|'
if (nIndex != -1)
{
m_sTopEl = sText.Mid(nIndex1 + 1,nIndex - nIndex1 - 1);
sText.SetAt(nIndex,KT_SUBTRACT_CHAR);
}
nIndex1 = nIndex;
nIndex = sText.Find(KT_SEPARATOR_CHAR,0);
if (nIndex != -1)
{
m_sCenEl = sText.Mid(nIndex1 + 1,nIndex - nIndex1 - 1);
sText.SetAt(nIndex,KT_SUBTRACT_CHAR);
m_sBomEl = sText.Mid(nIndex + 1);
}
}
BOOL CWPipeDimConfigDlg::DownLoad2Map()
{
UpdateData();
if (m_pPipeInitData == NULL) return FALSE;
//1.验证比例是否合法
m_pPipeInitData->SetAt(DOC_DIMTXTH,m_dTextHeight); //标注文字高度
m_pPipeInitData->SetAt(DOC_DIMTXTF,m_dTextWFact); //标注文字宽度系数
m_pPipeInitData->SetAt(DOC_EQPTXTH,m_dEqpTxtHeight); //设备标注文字高度
m_pPipeInitData->SetAt(DOC_EQPTXTF,m_dEqpTxtWFact); //设备标注文字宽度系数
int nVal = GetCheckedRadioButton(IDC_RADIONONE,IDC_RADIOARROW);
m_pPipeInitData->SetAt(DOC_DIMTERM,(nVal - IDC_RADIONONE));
CString sText(m_sElType);
//m_wndElType.GetWindowText(sText);
nVal = 0;
if (sText.Find(g_pszElType[0],0) != -1)
{
nVal = 0;
}
if (sText.Find(g_pszElType[1],0) != -1)
{
nVal = 1;
}
if (sText.Find(g_pszElType[2],0) != -1)
{
nVal = 2;
}
m_pPipeInitData->SetAt(DOC_ELTYPE,nVal);
sText = _T("0");
if (nVal == 0)
{
m_pPipeInitData->SetAt(DOC_ELDESCR,sText);
}
if (nVal == 2 || nVal == 1)
{
if (nVal == 1)
{
m_sEl = PIPE_EL; //_T("EL")
m_sTopEl = PIPE_TOP_EL; //_T("TOP.EL")
m_sCenEl = PIPE_CEN_EL; //_T("CEN.EL")
m_sBomEl = PIPE_BOM_EL; //_T("BOM.EL")
}
sText = m_sEl + KT_SEPARATOR_STR + m_sTopEl + KT_SEPARATOR_STR + m_sCenEl + KT_SEPARATOR_STR + m_sBomEl;
m_pPipeInitData->SetAt(DOC_ELDESCR,sText);
}
return TRUE;
}
//{公称直径}{-}{介质}{-}{管道等级} -> {0}{-}{1}{-}{2}{-}{3}
int CWPipeDimConfigDlg::PipeDetail2Script(CString& sText,CString& sText2,BOOL bAddBrace)
{
int nIndex = 0;
CString sIndex,sTemp = sText;
while(TRUE)
{
if (g_pszPipeDim[nIndex] == NULL)
break;
if (sTemp.Find(g_pszPipeDim[nIndex]) != -1)
{
if (bAddBrace)
{
sIndex.Format(_T("{%d}"),nIndex);
}
else
{
sIndex.Format(_T("%d"),nIndex);
}
sTemp.Replace(g_pszPipeDim[nIndex],sIndex);
}
nIndex += 1;
}
sText2 = sTemp;
return TRUE;
}
//{0}{-}{1}{-}{2}{-}{3} -> {公称直径}{-}{介质}{-}{管道等级}
int CWPipeDimConfigDlg::PipeScript2Detail(CString& sText,CString& sText2)
{
CString sIndex;
sText2 = sText;
int i = 0;
while(TRUE)
{
sIndex.Format(_T("%d"),i);
if (g_pszPipeDim[i] == NULL)
break;
sText2.Replace(sIndex,g_pszPipeDim[i]);
i++;
}
return sText2.GetLength();
}
void CWPipeDimConfigDlg::OnBnClickedOk()
{
UpdateData();
CString sUpScr,sDonScr;
PipeDetail2Script(m_sScriptUp,sUpScr,TRUE);
PipeDetail2Script(m_sScriptDown,sDonScr,TRUE);
m_pPipeInitData->SetAt(DOC_SCRIPTT,sUpScr);
m_pPipeInitData->SetAt(DOC_SCRIPTB,sDonScr);
m_pPipeInitData->SetAt(DOC_DNPRE,m_bDN);
m_pPipeInitData->SetAt(DOC_DPRE,m_bD);
m_pPipeInitData->SetAt(DOC_ADPRE,m_bO);
//标高设置
//默认符号标注,如果不是,在标高设置中设置
//标注端符号
int nVal = GetCheckedRadioButton(IDC_RADIONONE,IDC_RADIOARROW) - IDC_RADIONONE;
m_pPipeInitData->SetAt(DOC_DIMTERM,nVal); //标注端符
m_pPipeInitData->SetAt(DOC_DIMTXTH,m_dTextHeight);
m_pPipeInitData->SetAt(DOC_DIMTXTF,m_dTextWFact);
m_pPipeInitData->SetAt(DOC_EQPTXTH,m_dTextHeight);
m_pPipeInitData->SetAt(DOC_EQPTXTF,m_dTextWFact);
OnOK();
}
void CWPipeDimConfigDlg::OnBnClickedChecko()
{
UpdateData();
GetDlgItem(IDC_CHECKD)->EnableWindow(!m_bO);
GetDlgItem(IDC_CHECKDN)->EnableWindow(!m_bO);
}