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

453 lines
12 KiB
C++

// PrincipleSysDlg.cpp : implementation file
//
#include "stdafx.h"
#include <dbPipeValve.h>
#include <DbSymbolAnnotate.h>
#include <xtext.h>
#include <DbEquipment.h>
#include <PipeWireMonitor.h>
#include "PrincipleSysDlg.h"
#include "DistFloorDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// 绘展开图
/////////////////////////////////////////////////////////////////////////////
extern void DrawFloorLine(XPoint p1, XPoint p2, const TCHAR*szPipeLayer, const TCHAR*szText, double nHeight, const TCHAR*szSerial);
CString GetEquipLayByPipeLay(CString csLay)
{
CString csRet;
if(csLay == LAY_PIPE_FEED)
csRet = LAY_EQ_FEED;
else if(csLay == LAY_PIPE_HEADFEED)
csRet = LAY_EQ_HEADFEED;
else if(csLay == LAY_PIPE_HEADBACK)
csRet = LAY_EQ_HEADBACK;
else if(csLay == LAY_PIPE_DIRT)
csRet = LAY_EQ_DIRT;
else if(csLay == LAY_PIPE_USELESS)
csRet = LAY_EQ_USELESS;
else if(csLay == LAY_PIPE_RAIN)
csRet = LAY_EQ_RAIN;
else if(csLay == LAY_PIPE_USED)
csRet = LAY_EQ_USED;
else if(csLay == LAY_PIPE_FIRE)
csRet = LAY_EQ_FIRE;
else if(csLay == LAY_PIPE_SPRINKLE)
csRet = LAY_EQ_SPRINKLE;
else if(csLay == LAY_PIPE_COAGULATE)
csRet = LAY_EQ_COAGULATE;
else if(csLay == LAY_PIPE_DRINK)
csRet = LAY_EQ_DRINK;
else if(csLay == LAY_PIPE_PRESSDIRT)
csRet = LAY_EQ_PRESSDIRT;
else if(csLay == LAY_PIPE_PRESSUSELESS)
csRet = LAY_EQ_PRESSUSELESS;
else if(csLay == LAY_PIPE_PRESSRAIN)
csRet = LAY_EQ_PRESSRAIN;
else if(csLay == LAY_PIPE_USER1)
csRet = LAY_EQ_USER1;
else if(csLay == LAY_PIPE_USER2)
csRet = LAY_EQ_USER2;
else if(csLay == LAY_PIPE_OTHER)
csRet = LAY_EQ_OTHER;
return csRet;
}
void PrincipleSys()
{
CTemporaryResourceOverride vTemp;
CPrincipleSysDlg dlg;
if(dlg.DoModal() != IDOK)
return;
CString csLayer = GetPipeLayerByIdx(dlg.m_iType);
InitPipeLayer(csLayer);
CString csEqLay = GetEquipLayByPipeLay(csLayer);
InitLayer(csEqLay);
XPoint ptIns, ptStart, ptEnd, ptFloor;
xg_getvar(_T("VIEWCTR"), ptIns);
ptIns = Ucs2Wcs(ptIns);
PickSet ss(SS_FREE);
ss.IncludeBegin();
double nAllHeight = dlg.m_nAllHeight;
double nBraLength = dlg.m_nFloorLen;
ptStart = ptIns;
ads_polar(ptStart, PI/2*3, dlg.m_nHeight*1000, ptStart);
ads_polar(ptIns, PI/2, nAllHeight, ptEnd);
DrawSysPipeByLayer(ptStart, ptEnd, csLayer);
ptFloor = ptIns;
CString csDwb = g_csDwbPath + _T("TwtSys");
XString xsTmp, xsTmp2, xsTmp4, xsTmp5, xsTmp6;
if(LoadDwbBlock(csDwb, _T("00000132"), xsTmp) != RTNORM) //断线
return;
if(dlg.m_iType == 5){ //雨水
if(LoadDwbBlock(csDwb, _T("00000145"), xsTmp4) != RTNORM) //雨水斗
return;
InsEquipmentByName((const TCHAR*)xsTmp4, ptEnd, 0, csEqLay, FALSE, FALSE);
}
else if(dlg.m_iType != 5 && dlg.m_iType != 3 && dlg.m_iType != 4){
csDwb = g_csDwbPath + _T("valve");
if(LoadDwbBlock(csDwb, _T("00000295"), xsTmp5) != RTNORM) //阀门
return;
ads_polar(ptStart, PI/2, dlg.m_nHeight*1000/2, ptEnd);
InsValveByName((const TCHAR*)xsTmp5, ptEnd, csLayer);
}
if(dlg.m_bValve){
csDwb = g_csDwbPath + _T("valve");
if(LoadDwbBlock(csDwb, _T("00000497"), xsTmp2) != RTNORM) //截止阀
return;
if(LoadDwbBlock(csDwb, _T("00000499"), xsTmp6) != RTNORM) //(斜)截止阀
return;
}
double nCountHeight = dlg.m_nMinEle;
for(int i=0;i<dlg.m_iNum+1;i++){
ptStart = ptFloor;
if(dlg.m_bFloor){
//楼板线和字
ads_polar(ptStart, PI, dlg.m_nHeight*1000, ptStart);
ads_polar(ptFloor, 0, dlg.m_nFloorLen, ptEnd);
CString csText;
if(i == dlg.m_iNum)
csText = _T("屋面");
else
csText = dlg.m_lstName[i];
double nLastHeight(0);
if(i > 0)
nLastHeight = _tstof(dlg.m_lstHeight[i-1]);
nCountHeight += nLastHeight;
DrawFloorLine(ptStart, ptEnd, csLayer, csText, nCountHeight,_T(""));
// //标高
// XPoint ptEle;
// CString csEle;
// double nLastHeight(0);
// if(i > 0)
// nLastHeight = _tstof(dlg.m_lstHeight[i-1]);
// nCountHeight += nLastHeight;
// csEle.Format(_T("%.3f"), nCountHeight);
//
// ads_polar(ptFloor, PI, dlg.m_nHeight*1000/2+200, ptEle);
// InsElevation(ptEle, csEle, csLayer);
}
if(i == dlg.m_iNum)
break;
//干管
XPoint ptPipeS, ptPipeE, ptValve;
ads_polar(ptFloor, PI/2, dlg.m_nElevation*1000, ptPipeS);
// ads_polar(ptFloor, PI/2, dlg.m_iDist2Floor, ptClear);
BOOL bLeft = FALSE;
double nRotate(0);
if(dlg.m_iMode == 0 || dlg.m_iMode == 4)
nRotate = 0;
else if(dlg.m_iMode == 1){
nRotate = PI;
bLeft = TRUE;
}
else if(dlg.m_iMode == 2){
nRotate = PI/4;
xsTmp2 = xsTmp6;
}
else if(dlg.m_iMode == 3){
nRotate = PI+PI/4;
xsTmp2 = xsTmp6;
bLeft = TRUE;
}
ads_polar(ptPipeS, nRotate, dlg.m_nLen, ptPipeE);
ads_polar(ptPipeS, nRotate, dlg.m_nLen/2, ptValve);
if(bLeft)
DrawSysPipeByLayer(ptPipeE, ptPipeS, csLayer);
else
DrawSysPipeByLayer(ptPipeS, ptPipeE, csLayer);
// if(dlg.m_bClear){
// if((i%2 == 0 && dlg.m_iCheckSingle == 0) || (i%2 == 1 && dlg.m_iCheckSingle == 1))
// InsEquipmentByName((const TCHAR*)xsTmp3, ptClear, 0, csEqLay, FALSE, FALSE);
// }
InsEquipmentByName(xsTmp, ptPipeE, nRotate, csEqLay, FALSE, FALSE);
Entity entLast;
entLast.GetLast();
WriteXdata(entLast, _T("TG-LAYER"), csLayer);
if(dlg.m_bValve)
InsValveByName((const TCHAR*)xsTmp2, ptValve, csLayer);
if(dlg.m_iMode == 4){
ads_polar(ptPipeS, PI, dlg.m_nLen, ptPipeE);
ads_polar(ptPipeS, PI, dlg.m_nLen/2, ptValve);
DrawSysPipeByLayer(ptPipeE, ptPipeS, csLayer);
InsEquipmentByName(xsTmp, ptPipeE, nRotate, csEqLay, FALSE, FALSE);
if(dlg.m_bValve)
InsValveByName((const TCHAR*)xsTmp2, ptValve, csLayer);
}
ads_polar(ptFloor, PI/2, _tstof(dlg.m_lstHeight[i])*1000, ptFloor);
}
ss.IncludeEnd();
int nOsMode=0;
xg_getvar(_T("OSMODE"), &nOsMode);
nOsMode &= ~0x4000;
nOsMode |= OS_INT|OS_END|OS_NEA|OS_MID;
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
ptIns = Wcs2Ucs(ptIns);
ss.Redraw(2);
actrTransactionManager->flushGraphics(); //acad 刷新
XPoint xp;
int nRet = DragMovePickSet(ss, _T("\n请点取系统图位置<退出>: "), ptIns, xp);
if(nRet != RTNORM){
ss.Erase();
TPipePerDocData *pData = GetCurPipeDocData();
pData->EnableWork(FALSE);
return;
}
ss.Redraw(1);
}
/////////////////////////////////////////////////////////////////////////////
// CPrincipleSysDlg dialog
int CPrincipleSysDlg::m_iType = 0;
BOOL CPrincipleSysDlg::m_bFloor = TRUE;
BOOL CPrincipleSysDlg::m_bValve = TRUE;
double CPrincipleSysDlg::m_nElevation = 0.15;
int CPrincipleSysDlg::m_iNum = 6;
CPrincipleSysDlg::CPrincipleSysDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPrincipleSysDlg::IDD, pParent), m_spinFloor(1), m_spinLen(50)
{
//{{AFX_DATA_INIT(CPrincipleSysDlg)
m_nHeight = 3;
m_nLen = 400;
m_nFloorLen = 16000;
m_iMode = 0;
//}}AFX_DATA_INIT
m_nAllHeight = 0;
m_nMinEle= 0;
}
void CPrincipleSysDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrincipleSysDlg)
DDX_Control(pDX, IDC_SPIN_LEN, m_spinLen);
DDX_Control(pDX, IDC_SPIN_FLOOR, m_spinFloor);
DDX_Text(pDX, IDC_EDIT_FOOR_HEIGHT, m_nHeight);
DDX_Text(pDX, IDC_FLOOR_LEN, m_nLen);
DDX_Text(pDX, IDC_FLOOR_LEN2, m_nFloorLen);
DDX_Radio(pDX, IDC_RADIO_TYPE1, m_iMode);
DDX_Check(pDX, IDC_CHECK_VALVE, m_bValve);
DDX_Text(pDX, IDC_EDIT_ELEVATION, m_nElevation);
DDX_Text(pDX, IDC_FLOOR_NUM, m_iNum);
DDX_Check(pDX, IDC_CHECK_FLOOR, m_bFloor);
DDX_CBIndex(pDX, IDC_COMBO_TYPE, m_iType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPrincipleSysDlg, CDialog)
//{{AFX_MSG_MAP(CPrincipleSysDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BUTTON_HEIGHT, OnButtonHeight)
ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioType1)
ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioType2)
ON_BN_CLICKED(IDC_RADIO_TYPE3, OnRadioType3)
ON_BN_CLICKED(IDC_RADIO_TYPE4, OnRadioType4)
ON_BN_CLICKED(IDC_RADIO_TYPE5, OnRadioType5)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPrincipleSysDlg message handlers
BOOL CPrincipleSysDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_spinFloor.SetRange(1, 50);
m_spinLen.SetRange(50, 5000);
// if(m_iType == 3 || m_iType == 4 || m_iType == 5 ){
// m_bClear = TRUE;
// UpdateData(FALSE);
// }
// OnCheckClear();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPrincipleSysDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
OpenSlide();
}
void CPrincipleSysDlg::OpenSlide()
{
CWnd *pWnd = GetDlgItem(IDC_STATIC_PREVIEW);
CString csTmp;
UpdateData(TRUE);
csTmp.Format(_T("TWT(ZKT%d)"), m_iMode+1);
DrawSlide(csTmp, pWnd);
}
void CPrincipleSysDlg::OnButtonHeight()
{
UpdateData(TRUE);
CTemporaryResourceOverride vTemp;
CDistFloorDlg dlg;
for(int i=0;i<m_iNum;i++){
CString csText, csHeight;
csText.Format(_T("%d楼"), i+1);
dlg.m_lstName.Append(tstrnew(csText));
csHeight.Format(_T("%.2f"), m_nHeight);
dlg.m_lstHeight.Append(tstrnew(csHeight));
}
if(dlg.DoModal() != IDOK)
return;
m_lstName.Reset();
m_lstHeight.Reset();
m_nMinEle = _tstof(dlg.m_sStartBaseEle);//zxl 2011.10.20 add
m_iNum = dlg.m_lstHeight.Length();
for(i=0;i<m_iNum;i++){
CString csText, csHeight;
csText = dlg.m_lstName[i];
csHeight = dlg.m_lstHeight[i];
m_lstName.Append(tstrnew(csText));
m_lstHeight.Append(tstrnew(csHeight));
}
UpdateData(FALSE);
}
void CPrincipleSysDlg::OnRadioType1()
{
OpenSlide();
}
void CPrincipleSysDlg::OnRadioType2()
{
OpenSlide();
}
void CPrincipleSysDlg::OnRadioType3()
{
OpenSlide();
}
void CPrincipleSysDlg::OnRadioType4()
{
OpenSlide();
}
void CPrincipleSysDlg::OnRadioType5()
{
OpenSlide();
}
void CPrincipleSysDlg::OnSelchangeComboType()
{
UpdateData(TRUE);
if(m_iType == 3){ //污水
m_nElevation = -0.25;
m_bValve = FALSE;
}
else if(m_iType == 4 || m_iType == 5){ //废水
m_bValve = FALSE;
m_nElevation = 0.15;
}
else{
m_nElevation = 0.15;
}
UpdateData(FALSE);
}
//void CPrincipleSysDlg::OnCheckClear()
//{
// UpdateData(TRUE);
// CWnd *pWnd1 = GetDlgItem(IDC_EDIT_DIST2FLOOR);
// CWnd *pWnd2 = GetDlgItem(IDC_SPIN_DIST2FLOOR);
// CWnd *pWnd3 = GetDlgItem(IDC_RADIO_CHECK1);
// CWnd *pWnd4 = GetDlgItem(IDC_RADIO_CHECK2);
// if(m_bClear){
// pWnd1->EnableWindow(TRUE);
// pWnd2->EnableWindow(TRUE);
// pWnd3->EnableWindow(TRUE);
// pWnd4->EnableWindow(TRUE);
// }
// else{
// pWnd1->EnableWindow(FALSE);
// pWnd2->EnableWindow(FALSE);
// pWnd3->EnableWindow(FALSE);
// pWnd4->EnableWindow(FALSE);
// }
//}
void CPrincipleSysDlg::OnOK()
{
UpdateData(TRUE);
CString csText, csHeight;
if(m_lstHeight.Length() < 1){
for(int i=0;i<m_iNum;i++){
csText.Format(_T("%d楼"), i+1);
m_lstName.Append(tstrnew(csText));
csHeight.Format(_T("%.2f"), m_nHeight);
m_lstHeight.Append(tstrnew(csHeight));
}
}
int len = m_iNum - m_lstHeight.Length();
for(int j=0;j<len;j++){
csHeight.Format(_T("%.2f"), m_nHeight);
m_lstHeight.Append(tstrnew(csHeight));
csText.Format(_T("%d楼"), m_lstHeight.Length());
m_lstName.Append(tstrnew(csText));
}
for(int i=0;i<m_iNum;i++){
csText = m_lstHeight[i];
m_nAllHeight += (_tstof(csText)*1000);
csText = m_lstName[i];
//if(csText.Find(_T("地下")) > -1)
if(csText.Find(_T("地下")) > -1 || csText.Find(_T("-")) > -1)//添加-1F -2F表示楼层 zxl 2011.10.20 add
m_nMinEle -= _tstof(m_lstHeight[i]);
}
CDialog::OnOK();
}