445 lines
10 KiB
C++
445 lines
10 KiB
C++
#include "stdafx.h"
|
|
#include "EditVPipeDimDlg.h"
|
|
#include "DbVPipeDim.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
//编辑立管标注
|
|
int EditVPipeDim(AcDbObjectId id)
|
|
{
|
|
if (id.isNull())
|
|
return 0;
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
|
|
CEditVPipeDimDlg dlg;
|
|
//重新绑定立管和标注
|
|
dlg.RenewDimInfo(id);
|
|
|
|
AcDbEntity *pEnt;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
|
{
|
|
TDbVPipeDim *pDim = TDbVPipeDim::cast(pEnt);
|
|
if (pDim != NULL)
|
|
{
|
|
CString sNum;
|
|
pDim->GetDimVPipeNum(sNum);
|
|
dlg.m_sDimNum = sNum;
|
|
pDim->GetDimTypeText(dlg.m_sDimBefore);
|
|
dlg.m_dTextHeight = pDim->GetTextHeight();
|
|
AcDbObjectId idStyle = pDim->GetTextStyleId();
|
|
dlg.m_sTextStyle = GetSymbolName(idStyle);
|
|
dlg.m_dDimR = pDim->GetDimRadius();
|
|
pDim->GetVPipeFloorNum(dlg.m_sFloorNum);
|
|
dlg.m_nFloorType = pDim->GetVPipeFloorType();
|
|
dlg.m_nVPipeDimTypePic = pDim->GetDimType();
|
|
dlg.m_dDistDn = pDim->GetDnDistance2LabelLoc() / DocGetPScale();// zxl 2013.08.23 add
|
|
}
|
|
pEnt->close();
|
|
}
|
|
|
|
dlg.SetEditId(id);
|
|
|
|
dlg.DoModal();
|
|
|
|
return 0;
|
|
}
|
|
|
|
CEditVPipeDimDlg::CEditVPipeDimDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CEditVPipeDimDlg::IDD, pParent),m_spinDimNum(1)
|
|
{
|
|
//{{AFX_DATA_INIT(CEditVPipeDimDlg)
|
|
m_sTextStyle = _T("");
|
|
m_dTextHeight = 0.0;
|
|
m_sDimBefore = _T("");
|
|
m_dDimR = 0.0;
|
|
m_nFloorType = -1;
|
|
m_sFloorNum = _T("");
|
|
m_nVPipeDimTypePic = -1;
|
|
m_sDimNum = _T("");
|
|
m_dDistDn = 0.0;// zxl 2013.08.23 add
|
|
//}}AFX_DATA_INIT
|
|
|
|
m_nVPipeDimTypePic = TVPipeDim::eDimType1;
|
|
}
|
|
|
|
|
|
void CEditVPipeDimDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CEditVPipeDimDlg)
|
|
DDX_Control(pDX, IDC_CMB_TEXT_STYLE, m_cmbTextStyle);
|
|
DDX_Control(pDX, IDC_SPIN_VPIPE_DIM_NUM, m_spinDimNum);
|
|
DDX_Control(pDX, IDC_SPIN_TEXT_HEIGHT, m_spinTextHeight);
|
|
DDX_CBString(pDX, IDC_CMB_TEXT_STYLE, m_sTextStyle);
|
|
DDX_Text(pDX, IDC_EDIT_TEXT_HEIGHT, m_dTextHeight);
|
|
DDX_Text(pDX, IDC_EDIT_VPIPE_DIM_BEFORE, m_sDimBefore);
|
|
DDX_Text(pDX, IDC_EDIT_VPIPE_DIM_RADIUS, m_dDimR);
|
|
DDX_CBIndex(pDX, IDC_CMB_FLOOR_TYPE, m_nFloorType);
|
|
DDX_Text(pDX, IDC_EDIT_FLOOR_NUM, m_sFloorNum);
|
|
DDX_Radio(pDX, IDC_RADIO1, m_nVPipeDimTypePic);
|
|
DDX_Text(pDX, IDC_EDIT_VPIPE_DIM_NUM, m_sDimNum);
|
|
DDX_Text(pDX, IDC_EDIT_DNDIST, m_dDistDn);// zxl 2013.08.23 add
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CEditVPipeDimDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CEditVPipeDimDlg)
|
|
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VPIPE_DIM_NUM, OnDeltaposSpinVpipeDimNum)
|
|
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_TEXT_HEIGHT, OnDeltaposSpinTextHeight)
|
|
ON_WM_PAINT()
|
|
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
|
|
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
|
|
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
|
|
ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
|
|
ON_BN_CLICKED(IDC_RADIO5, OnRadio5)// zxl 2013.08.23 add
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
void CEditVPipeDimDlg::SetEditId(const AcDbObjectId &id)
|
|
{
|
|
m_id = id;
|
|
}
|
|
|
|
BOOL CEditVPipeDimDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if (m_nVPipeDimTypePic != TVPipeDim::eDimType2)
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("文字离线距离:"));
|
|
else
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("标注半径:"));
|
|
|
|
XSymbolList lstStyle(_T("STYLE"));
|
|
for (int i = 0; i < lstStyle.Length(); ++i)
|
|
{
|
|
m_cmbTextStyle.AddString(lstStyle[i]);
|
|
}
|
|
|
|
m_spinDimNum.SetRange32(0,10000);
|
|
m_spinTextHeight.SetRange32(0,100);
|
|
|
|
m_wndToolTip.Create(this);
|
|
CWnd *pWnd = GetDlgItem(IDC_STATIC_DSTDN);
|
|
BOOL bRet = m_wndToolTip.AddTool(pWnd, _T("编号文字左侧与管径文字左侧的距离"));
|
|
m_wndToolTip.SetDelayTime(300);
|
|
m_wndToolTip.Activate(TRUE);
|
|
|
|
EnableTextRect();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CEditVPipeDimDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
switch(pMsg->message)
|
|
{
|
|
case WM_MOUSEMOVE:
|
|
m_wndToolTip.RelayEvent(pMsg);
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
|
|
void CEditVPipeDimDlg::OnDeltaposSpinVpipeDimNum(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
|
|
// TODO: Add your control notification handler code here
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnDeltaposSpinTextHeight(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
|
|
TCHAR szText[10] = {0};
|
|
GetDlgItemText(IDC_EDIT_TEXT_HEIGHT,szText, 10);
|
|
double dTemp = _tstof(szText);
|
|
// 当数据为0继续减少时数据保持为0
|
|
if (dTemp <= 0.0 && pNMUpDown->iDelta == -1)
|
|
{
|
|
dTemp = 0.0;
|
|
m_dTextHeight = dTemp;
|
|
}
|
|
else
|
|
{
|
|
m_dTextHeight = dTemp + 0.5 * pNMUpDown->iDelta;
|
|
}
|
|
_stprintf(szText,_T("%.1f"),m_dTextHeight);
|
|
SetDlgItemText(IDC_EDIT_TEXT_HEIGHT,szText);
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnOK()
|
|
{
|
|
if (UpdateData() != TRUE)// zxl 2013.08.29 modify
|
|
{
|
|
return;
|
|
}
|
|
//修改立管标注
|
|
|
|
if (!ChangeVPipeDimData())
|
|
return;
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
//修改立管标注数据
|
|
BOOL CEditVPipeDimDlg::ChangeVPipeDimData()
|
|
{
|
|
if (IsSameVPipeNum())
|
|
{
|
|
if (AfxMessageBox(_T("当前图存在该编号,是否继续"),MB_YESNO) == IDNO)
|
|
return FALSE;
|
|
}
|
|
|
|
AcDbEntity *pEnt;
|
|
if (acdbOpenAcDbEntity(pEnt,m_id,AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
TDbVPipeDim *pDim = TDbVPipeDim::cast(pEnt);
|
|
if (pDim != NULL)
|
|
{
|
|
pDim->SetDimVPipeNum(m_sDimNum);
|
|
pDim->SetDimTypeText(m_sDimBefore);
|
|
pDim->SetTextHeight(m_dTextHeight);
|
|
pDim->SetTextStyleId(InitTextStyle(m_sTextStyle));
|
|
pDim->SetDimRadius(m_dDimR);
|
|
pDim->SetVPipeFloorType(m_nFloorType);
|
|
pDim->SetVPipeFloorNum(m_sFloorNum);
|
|
pDim->SetDimType(m_nVPipeDimTypePic);
|
|
pDim->SetDnDistance2LabelLoc(m_dDistDn * DocGetPScale());// zxl 2013.08.23 add
|
|
|
|
if (m_nVPipeDimTypePic != TVPipeDim::eDimType2)
|
|
pDim->SetText2BaseRatio(m_dDimR);
|
|
pDim->RenewDimLen();
|
|
}
|
|
pEnt->close();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CEditVPipeDimDlg::IsSameVPipeNum()
|
|
{
|
|
BOOL bHasNum = FALSE;
|
|
PickSet ssAll(SS_FREE);
|
|
RBList rbMaskVPipe(RTDXF0, _T("ATS_VPIPEDIM"),NULL);
|
|
ssAll.Get(_T("A"),NULL,NULL,rbMaskVPipe);
|
|
long lLen = ssAll.Length();
|
|
|
|
for (long m = 0; m < lLen; ++m)
|
|
{
|
|
OPENOBJ_BEGIN(ssAll[m], AcDb::kForRead, TDbVPipeDim, pDim);
|
|
if (pDim != NULL)
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id,ssAll[m]);
|
|
if (m_id == id)
|
|
continue;
|
|
CString sNum,sFloor;
|
|
pDim->GetDimVPipeNum(sNum);
|
|
CString sDimBefore;
|
|
pDim->GetDimTypeText(sDimBefore);
|
|
pDim->GetVPipeFloorNum(sFloor);
|
|
|
|
if (m_sDimNum.CompareNoCase(sNum) == 0 && sDimBefore.CompareNoCase(m_sDimBefore) == 0
|
|
&& sFloor.CompareNoCase(m_sFloorNum) == 0)
|
|
{
|
|
bHasNum = TRUE;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
return bHasNum;
|
|
}
|
|
|
|
//重新绑定立管和标注
|
|
void CEditVPipeDimDlg::RenewDimInfo(const AcDbObjectId id)
|
|
{
|
|
RebindVPipeDim(id);
|
|
|
|
// 检查是否绑定成功, 不成功时,重新搜索绑定 zxl 2012.07.02 add
|
|
AcGePoint3d ptLoc;
|
|
if (!CheckRebindPipe(id, ptLoc))
|
|
{
|
|
AcDbObjectId idPipe;
|
|
RebindPipeDim(idPipe, ptLoc);// 绑定立管不成功, 搜索支管绑定
|
|
if (!idPipe.isNull())
|
|
{
|
|
SetRebindPipe(id, idPipe);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 检查是否绑定成功 zxl 2012.07.02 add
|
|
bool CEditVPipeDimDlg::CheckRebindPipe(const AcDbObjectId id, AcGePoint3d &ptLoc)
|
|
{
|
|
AcDbEntity *pEnt;
|
|
AcDbObjectId idPipe;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead) == Acad::eOk)
|
|
{
|
|
TDbVPipeDim *pDim = TDbVPipeDim::cast(pEnt);
|
|
if (pDim != NULL)
|
|
{
|
|
ptLoc = pDim->GetStartPt();
|
|
idPipe = pDim->GetVPipeId();
|
|
if (!idPipe.isNull())
|
|
{
|
|
pEnt->close();
|
|
return true;
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// 绑定不成功时,重新搜索 zxl 2012.07.02 add
|
|
void CEditVPipeDimDlg::RebindPipeDim(AcDbObjectId &id, const AcGePoint3d &pt)
|
|
{
|
|
const double dDist = 10;
|
|
AcGePoint3d ptGeLB ,ptGeLT, ptGeRB, ptGeRT;
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
ptGeLB = pt - vtX * dDist / 2;
|
|
ptGeLB = ptGeLB - vtY * dDist / 2;
|
|
ptGeLT = ptGeLB + vtY * dDist;
|
|
ptGeRB = ptGeLB + vtX * dDist;
|
|
ptGeRT = ptGeRB + vtY * dDist;
|
|
|
|
PickSet ss(SS_FREE);
|
|
RBList rbFilter(RTDXF0, _T("ATS_PIPE"), NULL);
|
|
|
|
TADSGePoint3d _pt1 = Wcs2Ucs(ptGeLB)
|
|
, _pt2 = Wcs2Ucs(ptGeLT)
|
|
, _pt3 = Wcs2Ucs(ptGeRT)
|
|
, _pt4 = Wcs2Ucs(ptGeRB);
|
|
RBList rbPt = acutBuildList(RTPOINT,&_pt1,RTPOINT,&_pt2,RTPOINT,&_pt3, RTPOINT,&_pt4,NULL);
|
|
|
|
acedSSGet(_T("CP"),rbPt,NULL,rbFilter,ss);
|
|
|
|
Entity ent = ss[0L];
|
|
acdbGetObjectId(id, ent);
|
|
}
|
|
|
|
// 重新绑定 zxl 2012.07.02 add
|
|
void CEditVPipeDimDlg::SetRebindPipe(const AcDbObjectId id, const AcDbObjectId idPipe)
|
|
{
|
|
AcDbEntity *pEnt;
|
|
if (acdbOpenAcDbEntity(pEnt,id,AcDb::kForWrite) == Acad::eOk)
|
|
{
|
|
TDbVPipeDim *pDim = TDbVPipeDim::cast(pEnt);
|
|
if (pDim != NULL)
|
|
{
|
|
pDim->SetVPipeId(idPipe);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
//绘制立管标注图片
|
|
void CEditVPipeDimDlg::DrawSlidPic()
|
|
{
|
|
CWnd *pWnd = GetDlgItem(IDC_VPIPE_DIM_PIC);
|
|
if(m_nVPipeDimTypePic == 0)
|
|
DrawSlide(_T("TWT(JL1)"), pWnd);
|
|
else if(m_nVPipeDimTypePic == 1)
|
|
DrawSlide(_T("TWT(JL2)"), pWnd);
|
|
else if(m_nVPipeDimTypePic == 2)
|
|
DrawSlide(_T("TWT(JL3)"), pWnd);
|
|
else if(m_nVPipeDimTypePic == 3)
|
|
DrawSlide(_T("TWT(JL4)"), pWnd);
|
|
else if(m_nVPipeDimTypePic == 4)
|
|
DrawSlide(_T("TWT(JL5)"), pWnd);
|
|
}
|
|
|
|
void CEditVPipeDimDlg::EnableTextRect()
|
|
{
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_DNDIST);
|
|
if (pWnd == NULL)
|
|
{
|
|
return;
|
|
}
|
|
if (m_nVPipeDimTypePic == 4)
|
|
{
|
|
pWnd->EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
pWnd->EnableWindow(FALSE);
|
|
}
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this);
|
|
|
|
DrawSlidPic();
|
|
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnRadio1()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
DrawSlidPic();
|
|
EnableTextRect();// zxl 2013.08.29 add
|
|
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("文字离线距离:"));
|
|
m_dDimR = g_nDimCirDiam;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnRadio2()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
DrawSlidPic();
|
|
EnableTextRect();// zxl 2013.08.29 add
|
|
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("标注半径:"));
|
|
m_dDimR = g_nDimCirDiam;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnRadio3()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
DrawSlidPic();
|
|
EnableTextRect();// zxl 2013.08.29 add
|
|
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("文字离线距离:"));
|
|
m_dDimR = g_nDimCirDiam;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CEditVPipeDimDlg::OnRadio4()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
DrawSlidPic();
|
|
EnableTextRect();// zxl 2013.08.29 add
|
|
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("文字离线距离:"));
|
|
m_dDimR = g_nDimCirDiam;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
// zxl 2013.08.23 add
|
|
void CEditVPipeDimDlg::OnRadio5()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
DrawSlidPic();
|
|
EnableTextRect();// zxl 2013.08.29 add
|
|
GetDlgItem(IDC_STATIC_DIM_R)->SetWindowText(_T("文字离线距离:"));
|
|
m_dDimR = g_nDimCirDiam;
|
|
UpdateData(FALSE);
|
|
} |