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

278 lines
7.4 KiB
C++

// InsHydrantDlg.cpp : implementation file
//
#include "stdafx.h"
#include "twtdef.h"
#include "TAPI.h"
#include <DbWell.h>
#include <TBlockEdJig.h>
#include <dbPipeValve.h>
#include <PipeWireMonitor.h>
#include "InsHydrantDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//***************************************************************************************************
// 室外消火栓
//***************************************************************************************************
void InsOutHydrant()
{
CString csDwb = g_csDwbPath + _T("TwtSys");
XString xsTmp, xsTmp2;
if(LoadDwbBlock(csDwb, _T("00000385"), xsTmp) != RTNORM)
return;
if(LoadDwbBlock(csDwb, _T("00000483"), xsTmp2) != RTNORM)
return;
g_csInsBlkName = (const TCHAR*)xsTmp;
CInsHydrantDlg dlg(acedGetAcadFrame());
{
CTemporaryResourceOverride vTemp;
dlg.Create(IDD_HYDRANT, acedGetAcadFrame());
}
dlg.ShowWindow(SW_SHOW);
acedGetAcadDwgView()->SetFocus();
XPoint ptIns;
InitLayer(LAY_EQUIP_HYDRANT);
xg_getvar(_T("VIEWCTR"), ptIns);
ptIns = Ucs2Wcs(ptIns);
BOOL bRotate(FALSE), bMirror(FALSE);
int nOsMode=0;
double nScale = 1;
// if(g_bEquipByScale)
// nScale = 1;
nOsMode |= OS_INT|OS_NEA|OS_MID;
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
while(1){
dlg.UpdateData(TRUE);
if(dlg.m_iType == 0)
g_csInsBlkName = (const TCHAR*)xsTmp;
else
g_csInsBlkName = (const TCHAR*)xsTmp2;
TBlockEdJig jig(g_csInsBlkName, ptIns, 1);
jig.m_nSacle = nScale*(DocGetPScale()/100);
jig.m_nSacleY = nScale*(DocGetPScale()/100);
jig.m_bReversal = bMirror;
CString csPrompt, csRotate;
if(bRotate)
csRotate = _T("不旋转");
else
csRotate = _T("旋转");
csPrompt.Format(_T("\n请点取消火栓插入点{放大[E]/缩小[D]/左右翻转[F]/%s[R]}<完成>:"), csRotate);
jig.SetPrompt(csPrompt);
jig.SetKeyword(_T("E D F R W"));
int nKeyIndex = 0;
int ret = jig.DoIt(&nKeyIndex);
if(ret == RTKWORD){
if(nKeyIndex == 0)
nScale += 0.5;
else if(nKeyIndex == 1 && nScale > 0.5)
nScale -= 0.5;
else if(nKeyIndex == 2)
bMirror = !bMirror;
else if(nKeyIndex == 3)
bRotate = !bRotate;
continue;
}
else if(ret != RTNORM)
break;
ptIns = jig.GetPickPoint();
double nElevation(0);
int iPipeIdx(0);
Entity entWire = GetPipeByPt(ptIns, nElevation, iPipeIdx);
if(!!entWire){
XPoint ptPipe = Wcs2Ucs(ptIns);
XPoint ptPipe2;
while(1){
if(ads_getpoint(ptPipe, _T("\n请点取管线下一点<直接布置>:"), ptPipe2) != RTNORM){
ptIns = Ucs2Wcs(ptPipe);
break;
}
OPENOBJ_BEGIN(entWire, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
TDbPipe *pNewPipe = (TDbPipe *)pPipe->clone();
dlg.UpdateData(TRUE);
if (dlg.m_nDimNewPipe == 1 && pPipe->IsDrawLabel())
{
pNewPipe->EnableDrawLabel(FALSE);
}
pNewPipe->SetStartPoint(Ucs2Wcs(ptPipe));
pNewPipe->SetEndPoint(Ucs2Wcs(ptPipe2));
AddToCurrentSpace(pNewPipe, Adesk::kTrue);
}
OPENOBJ_END();
ptPipe = ptPipe2;
TPipePerDocData *pData = GetCurPipeDocData();
pData->ApplyUpdates();
}
if(!ptPipe2){
XPoint ptS, ptE;
TPipeSys::SysType sysType;
OPENOBJ_BEGIN(entWire, AcDb::kForRead, TDbPipe, pPipe);
if(pPipe){
sysType = pPipe->GetSysType();
ptS = pPipe->StartPoint();
ptE = pPipe->EndPoint();
}
OPENOBJ_END();
// XVector3D vectBase(ptE.x - ptS.x, ptE.y - ptS.y, 0);
// TDbPipeValve *pValve = new TDbPipeValve;
// pValve->SetBlock2d(GetBlkIdByName(g_csInsBlkName));
// pValve->SetLocation(ptIns);
// pValve->SetScale(nScale);
// pValve->SetYScale(nScale);
// pValve->setLayer(LAY_EQUIP_HYDRANT);
// pValve->setColor(AcCmColor()); //随层
// pValve->SetDirection(vectBase);
// pValve->SetQuadrant(1);
// pValve->SetSysType(sysType);
// AddToCurrentSpace(pValve, Adesk::kTrue);
double dAng = ads_angle(ptS, ptE);
TDbEquipment *pEquip = new TDbEquipment;
pEquip->SetBlock2d(GetBlkIdByName(g_csInsBlkName));
pEquip->SetHidePipe(TRUE);
pEquip->SetAngle(dAng);
pEquip->SetScale(nScale);
pEquip->MirrorByY(bMirror);
pEquip->setLayer(LAY_EQUIP_HYDRANT);
pEquip->setColor(AcCmColor()); //随层
pEquip->SetLocation(ptIns);
AcDbObjectId id = AddToCurrentSpace(pEquip, Adesk::kTrue);
continue;
}
}
TDbEquipment *pEquip = new TDbEquipment;
pEquip->SetBlock2d(GetBlkIdByName(g_csInsBlkName));
pEquip->SetHidePipe(TRUE);
pEquip->SetScale(nScale);
pEquip->MirrorByY(bMirror);
pEquip->setLayer(LAY_EQUIP_HYDRANT);
pEquip->setColor(AcCmColor()); //随层
pEquip->SetLocation(ptIns);
AcDbObjectId id = AddToCurrentSpace(pEquip, Adesk::kTrue);
if(bRotate){
Entity entLast;
entLast.GetLast();
double nRotate(0);
entLast.Rotate(ptIns, &nRotate);
}
}
dlg.DestroyWindow();
}
int CInsHydrantDlg::m_iType = 0;
int CInsHydrantDlg::m_nDimNewPipe = 0;
/////////////////////////////////////////////////////////////////////////////
// CInsHydrantDlg dialog
IMPLEMENT_DYNAMIC(CInsHydrantDlg, CModelessDialog)
CInsHydrantDlg::CInsHydrantDlg(CWnd* pParent /*=NULL*/)
: CModelessDialog(CInsHydrantDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInsHydrantDlg)
//}}AFX_DATA_INIT
}
void CInsHydrantDlg::DoDataExchange(CDataExchange* pDX)
{
CModelessDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInsHydrantDlg)
DDX_Radio(pDX, IDC_RADIO_TYPE1, m_iType);
//}}AFX_DATA_MAP
DDX_Radio(pDX, IDC_RADIO_DIM, m_nDimNewPipe);
}
BEGIN_MESSAGE_MAP(CInsHydrantDlg, CModelessDialog)
//{{AFX_MSG_MAP(CInsHydrantDlg)
ON_WM_CLOSE()
ON_WM_PAINT()
ON_BN_CLICKED(IDC_RADIO_TYPE1, OnRadioType1)
ON_BN_CLICKED(IDC_RADIO_TYPE2, OnRadioType2)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_RADIO_DIM, &CInsHydrantDlg::OnBnClickedRadioDim)
ON_BN_CLICKED(IDC_RADIO_NODIM, &CInsHydrantDlg::OnBnClickedRadioNodim)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInsHydrantDlg message handlers
BOOL CInsHydrantDlg::OnInitDialog()
{
CModelessDialog::OnInitDialog();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInsHydrantDlg::OnClose()
{
CModelessDialog::OnClose();
acedPostCommand(_T("\33\33"));
}
void CInsHydrantDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
OpenSlide();
}
void CInsHydrantDlg::OpenSlide()
{
UpdateData();
CWnd *pWnd = GetDlgItem(IDC_PREVIEW1);
CString csTmp;
if(m_iType == 0)
csTmp.Format(_T("TWTSYS(00000385)"));
else
csTmp.Format(_T("TWTSYS(00000483)"));
DrawSlide(csTmp, pWnd);
}
void CInsHydrantDlg::OnRadioType1()
{
OpenSlide();
PostCommand(_T("W "), false);
}
void CInsHydrantDlg::OnRadioType2()
{
OpenSlide();
PostCommand(_T("W "), false);
}
void CInsHydrantDlg::OnBnClickedRadioDim()
{
acedGetAcadDwgView()->SetFocus();
}
void CInsHydrantDlg::OnBnClickedRadioNodim()
{
acedGetAcadDwgView()->SetFocus();
}