907 lines
24 KiB
C++
907 lines
24 KiB
C++
// DimPipeRadiusDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <DbPipeLabel.h>
|
|
#include <DbWell.h>
|
|
#include <DbPipe.h>
|
|
#include <PipeWireMonitor.h>
|
|
#include <dbSymbolAnnotate.h>
|
|
#include "DbDoubleLinePipe.h"
|
|
|
|
#include "DimPipeRadiusDlg.h"
|
|
#include "jig.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
const UINT OpenMenuID = 9310;
|
|
|
|
extern bool ReadRegData(const CString &sRegName, const CString &strKey, CString &sVal);
|
|
extern bool WriteRegData(const CString &sRegName, const CString &strKey, CString sVal);
|
|
|
|
//***************************************************************************************************
|
|
// 管径标注
|
|
//***************************************************************************************************
|
|
|
|
void SplitDnDim(const TCHAR* szDim, CString &csHead, int &iDn)
|
|
{
|
|
CString csTmp = szDim;
|
|
int idx = csTmp.Find(_T(" "));
|
|
if(idx < 0){
|
|
return;
|
|
}
|
|
int len = csTmp.GetLength();
|
|
CString csLeft, csRight;
|
|
csLeft = csTmp.Left(idx);
|
|
csRight = csTmp.Right(len - idx - 1);
|
|
csHead = csLeft;
|
|
iDn = _ttoi(csRight);
|
|
}
|
|
|
|
void DoDimPipeDnByPt(Entity ent, int iRadius, const TCHAR* szType, double nHeight, BOOL bIsDown = FALSE, XPoint ptPick = XPoint())
|
|
{
|
|
if(!ent.Is(_T("ATS_PIPE")) && !ent.Is(_T("ATS_DOUBLELINEPIPE")))
|
|
return;
|
|
AcDbObjectId idTextStyle = InitTwtTextStyle(g_csPipeDnStyle);
|
|
double nDnDiameter = (double)iRadius;
|
|
double nRadius(0);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDoubleLinePipe, pPipe);
|
|
if(pPipe){
|
|
pPipe->SetWidth(iRadius);
|
|
nRadius= nDnDiameter/2;
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(!pPipe)
|
|
return;
|
|
XLine line(pPipe->StartPoint(), pPipe->EndPoint(), 1);
|
|
if(pPipe->IsVertical()){ //立管不标注,但把管径信息写入管
|
|
if(iRadius > 0)
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
return;
|
|
}
|
|
|
|
double nRotate(0);
|
|
|
|
// cet 2011.8.29 modify 在ucs下考虑
|
|
// if(pPipe->Is(CURVE_LINE)){
|
|
// ptPick.Project(&line, ptPick);//有可能PICK点不在管线上
|
|
// nRotate = ads_angle(pPipe->GetStartPoint(), pPipe->GetEndPoint());
|
|
// }
|
|
// else if(pPipe->Is(CURVE_ARC)){
|
|
// XPoint ptCenter;
|
|
// pPipe->GetArc().Center(ptCenter);
|
|
// nRotate = ads_angle(ptCenter, ptPick) + PI/2;
|
|
// }
|
|
//
|
|
//
|
|
// if(nRotate > PI/2 && nRotate <=PI*3/2)//管反了
|
|
// nRotate += PI;
|
|
// if(bIsDown)
|
|
// ads_polar(ptPick, nRotate+PI/2, -g_nDnDimDist2Pipe*DocGetPScale()+nRadius, ptPick);
|
|
// else
|
|
// ads_polar(ptPick, nRotate+PI/2, g_nDnDimDist2Pipe*DocGetPScale()+nRadius, ptPick);
|
|
if(pPipe->Is(CURVE_LINE)){
|
|
ptPick.Project(&line, ptPick);//有可能PICK点不在管线上
|
|
nRotate = ads_angle(Wcs2Ucs(pPipe->GetStartPoint()), Wcs2Ucs(pPipe->GetEndPoint()));
|
|
}
|
|
else if(pPipe->Is(CURVE_ARC)){
|
|
XPoint ptCenter;
|
|
pPipe->GetArc().Center(ptCenter);
|
|
nRotate = ads_angle(Wcs2Ucs(ptCenter), Wcs2Ucs(ptPick)) + PI/2;
|
|
}
|
|
|
|
if(nRotate > PI/2 && nRotate <=PI*3/2)//管反了
|
|
nRotate += PI;
|
|
ptPick = Wcs2Ucs(ptPick);
|
|
if(bIsDown)
|
|
ads_polar(ptPick, nRotate+PI/2, -g_nDnDimDist2Pipe*DocGetPScale()+nRadius, ptPick);
|
|
else
|
|
ads_polar(ptPick, nRotate+PI/2, g_nDnDimDist2Pipe*DocGetPScale()+nRadius, ptPick);
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
|
|
pPipe->SetLabelLocation(ptPick);
|
|
|
|
if(iRadius > 0)
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
pPipe->EnableDrawLabel(TRUE);
|
|
pPipe->SetTextHeight(nHeight);
|
|
if(_tcsicmp(szType, _T("自动")) == 0){
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
pPipe->SetLabel(GetDnByMat(csMat));
|
|
}
|
|
else
|
|
pPipe->SetLabel(szType);
|
|
pPipe->SetTextStyle(idTextStyle);
|
|
OPENOBJ_END();
|
|
UpdateMultDim(ent);
|
|
}
|
|
|
|
|
|
//写扩展数据
|
|
BOOL WriteXdata1(AcDbEntity *pEnt, const TCHAR*szName, const TCHAR*szValue)
|
|
{
|
|
AcDbObjectId eId;
|
|
if(!XSymbolTable(_T("APPID"), szName))
|
|
ads_regapp(szName);
|
|
if(!pEnt)
|
|
return FALSE;
|
|
resbuf *pXData = ads_buildlist(1001, szName, 1000, szValue, NULL);
|
|
pEnt->setXData(pXData);
|
|
ads_relrb(pXData);
|
|
return TRUE;
|
|
}
|
|
|
|
void DoDimPipeDnByUser(Entity ent, int iRadius, const TCHAR* szType, const TCHAR* szLabel, double nHeight, BOOL bIsDown, BOOL bModifyPos)
|
|
{
|
|
if(!ent.Is(_T("ATS_PIPE")) && !ent.Is(_T("ATS_DOUBLELINEPIPE")))
|
|
return;
|
|
|
|
WriteXdata(ent, _T("TG_PIPELABEL_THICK_SHOW"), _T("0"));
|
|
CString csLabel = szLabel;
|
|
if (csLabel == _T("φ"))
|
|
{
|
|
csLabel = _T("%%c");
|
|
}
|
|
|
|
CString csType = szType;
|
|
CString csPn = ReadXdata(ent, _T("TG-PIPE-FLANGE-PN"));
|
|
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDoubleLinePipe, pPipe);
|
|
if(pPipe && iRadius > 0){
|
|
int iPn=2;
|
|
if(csPn == _T("0.25MPa"))
|
|
iPn = 0;
|
|
else if(csPn == _T("0.6MPa"))
|
|
iPn = 1;
|
|
else if(csPn == _T("1.0MPa"))
|
|
iPn = 2;
|
|
else if(csPn == _T("1.6MPa"))
|
|
iPn = 3;
|
|
double dFlangeDn(0), dFlangeThick(0);
|
|
GetFlangeDataByDn(iPn, iRadius, dFlangeDn, dFlangeThick);
|
|
pPipe->SetWidth(iRadius);
|
|
pPipe->SetDnDiameter(iRadius);
|
|
pPipe->SetFlangeDn(dFlangeDn);
|
|
pPipe->SetFlangeThick(dFlangeThick);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
CString csOldType;
|
|
int iDnOld;
|
|
double dPipeThick(0);
|
|
AcDbObjectId idTextStyle = InitTwtTextStyle(g_csPipeDnStyle);
|
|
double nDnDiameter = (double)iRadius;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(!pPipe)
|
|
return;
|
|
csOldType = pPipe->GetLabel();
|
|
iDnOld = (int)pPipe->GetDnDiameter();
|
|
if(csType == _T("φ外径") || csType == _T("外径壁厚") || csType == _T("外径壁厚2"))
|
|
{ //用于设备给建筑提条件图,需要标注外径。不推荐用户使用,因为SetDnDiameter实体以为是DN
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
if(iRadius == 0)
|
|
iRadius = (int)pPipe->GetDnDiameter();
|
|
|
|
double nDnOut = GetPipeOutDByDn(csMat, iRadius)*1000;
|
|
double nDnIn = GetPipeDjByDn(csMat, iRadius)*1000;
|
|
nDnDiameter = nDnOut;
|
|
dPipeThick = (nDnDiameter - nDnIn) / 2;
|
|
if(_tcsicmp(szType, _T("外径壁厚")) == 0 || _tcsicmp(szType, _T("外径壁厚2")) == 0)
|
|
{
|
|
pPipe->SetPipeThick(dPipeThick);
|
|
WriteXdata1(pPipe, _T("TG_PIPELABEL_THICK_SHOW"), _T("1"));
|
|
}
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
}
|
|
if(pPipe->IsVertical()){ //立管不标注,但把管径信息写入管
|
|
if(iRadius > 0)
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
return;
|
|
}
|
|
|
|
if(csType == _T("φ外径"))
|
|
csType = csLabel;
|
|
else if(csType == _T("外径壁厚"))
|
|
csType = csLabel;
|
|
else if(csType == _T("外径壁厚2")) //沈睿 2009-12-28添加 支持 中船动力专业的标注样式
|
|
{
|
|
TCHAR szLayer[256];
|
|
ent.GetData(8, szLayer);
|
|
int idx = GetPipeLayerIdxByName(szLayer);
|
|
CString csPipeLable = g_csPipeDim[idx];
|
|
csType = csPipeLable + csLabel;
|
|
}
|
|
|
|
BOOL bIsDrawLable = pPipe->IsDrawLabel();
|
|
if(iRadius > 0)
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
|
|
if(!bIsDrawLable || bModifyPos){
|
|
if(bIsDown)
|
|
pPipe->InitLabelLocation(-g_nDnDimDist2Pipe*DocGetPScale());
|
|
else
|
|
pPipe->InitLabelLocation(g_nDnDimDist2Pipe*DocGetPScale());
|
|
if(nHeight < 2.99)
|
|
{
|
|
if((DocGetMeterUnitDraw() && pPipe->Length() > 5) || (!DocGetMeterUnitDraw() && pPipe->Length() > DocGetPScale()/200.0)) //太短,无法标注
|
|
pPipe->EnableDrawLabel(TRUE);
|
|
else
|
|
pPipe->EnableDrawLabel(FALSE);
|
|
}
|
|
else
|
|
{
|
|
if((DocGetMeterUnitDraw() && pPipe->Length() > 8) || (!DocGetMeterUnitDraw() && pPipe->Length() > DocGetPScale()/150.0)) //太短,无法标注
|
|
pPipe->EnableDrawLabel(TRUE);
|
|
else
|
|
pPipe->EnableDrawLabel(FALSE);
|
|
}
|
|
}
|
|
if(pPipe->GetSpare() < 0) //室外有时候不希望标注 2009-6-11
|
|
pPipe->EnableDrawLabel(FALSE);
|
|
|
|
|
|
pPipe->SetTextHeight(nHeight);
|
|
double dType = pPipe->GetSpare();
|
|
if(dType < 1)
|
|
pPipe->SetSpare(0);
|
|
if(_tcsicmp(szType, _T("自动")) == 0){
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
pPipe->SetLabel(GetDnByMat(csMat));
|
|
}
|
|
else
|
|
pPipe->SetLabel(csType);
|
|
pPipe->SetTextStyle(idTextStyle);
|
|
OPENOBJ_END();
|
|
UpdatePipeTextDim(ent, csOldType, iDnOld);
|
|
}
|
|
|
|
void DimPipeDnRadius()
|
|
{
|
|
g_ssPickFirst.Free();
|
|
CDimPipeRadiusDlg dlg(acedGetAcadFrame());
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
dlg.Create(IDD_DIM_PIPE_RADIUS, acedGetAcadFrame());
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
InitLayer(LAY_DIM);
|
|
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
|
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, _T("*"), -4, _T("and>"),
|
|
-4, _T("<and"), RTDXF0, _T("ATS_DOUBLELINEPIPE"), 8, _T("*"), -4, _T("and>"),
|
|
-4, _T("or>"), NULL);
|
|
|
|
while(1){
|
|
dlg.UpdateData();
|
|
double nFiltrateDn(0);
|
|
CString csPrompt = _T("\n请选取要标注管径的管线(多选,标注在管线中间)<退出>:");
|
|
if(dlg.m_iType == 11)
|
|
csPrompt = _T("\n请选取要删除管径标注的管线:");
|
|
int ret = SelectEntities(csPrompt, ss, rbMask);
|
|
if(ret == RTNORM) {
|
|
dlg.UpdateData(TRUE);
|
|
if(dlg.m_iType == 11){//删除标注
|
|
for(long i=0;i<ss.Length();i++){
|
|
Entity ent = ss[i];
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
pPipe->EnableDrawLabel(FALSE);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
else{
|
|
XString xsDim(_T("%s %d"), dlg.m_csType, dlg.m_iRadius);
|
|
int idx = dlg.m_lstDim.Index((const TCHAR*)xsDim);
|
|
if(idx > -1)
|
|
dlg.m_lstDim.Remove(idx);
|
|
dlg.m_lstDim.Append(tstrnew((const TCHAR*)xsDim));
|
|
|
|
if(dlg.m_bModifyDn){
|
|
Entity entTmp;
|
|
if(SelectEntity(_T("\n请选择要选择修改的管线(同管径管线将一同被修改)<退出>:"), entTmp, rbMask) != RTNORM){
|
|
dlg.DestroyWindow();
|
|
return;
|
|
}
|
|
OPENOBJ_BEGIN(entTmp, AcDb::kForRead, TDbPipe, pPipe2);
|
|
if(pPipe2){
|
|
nFiltrateDn = pPipe2->GetDnDiameter();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
acedSetStatusBarProgressMeter(_T("标注中..."), 0, ss.Length());
|
|
for(long i=0;i<ss.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
Entity ent = ss[i];
|
|
BOOL bNeedDim = TRUE;
|
|
CString csMat;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipeMain);
|
|
if(pPipeMain){
|
|
if(dlg.m_bDimNull){
|
|
if(pPipeMain->IsDrawLabel())
|
|
bNeedDim = FALSE;
|
|
}
|
|
if(dlg.m_bModifyDn){
|
|
double nDnTmp = pPipeMain->GetDnDiameter();
|
|
if(fabs(nDnTmp - nFiltrateDn) > 0.001)
|
|
bNeedDim = FALSE;
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
if(bNeedDim)
|
|
DoDimPipeDnByUser(ent, dlg.m_iRadius, dlg.m_csType, dlg.m_csLabel, dlg.m_nHeight, dlg.m_iPos, dlg.m_bModifyPos);
|
|
}
|
|
acedRestoreStatusBar();
|
|
}
|
|
UpdateMultDim();
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->ApplyUpdates();
|
|
}
|
|
else if(ret == RTERROR && dlg.m_bChangeMode){
|
|
dlg.m_bChangeMode = FALSE;
|
|
continue;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
dlg.UpdateData(TRUE);
|
|
WriteRegData(_T("PIPEDIMLABEL"), _T("LABEL"), dlg.m_csLabel);
|
|
dlg.DestroyWindow();
|
|
}
|
|
|
|
CString CDimPipeRadiusDlg::m_csType = _T("DN");
|
|
CString CDimPipeRadiusDlg::m_csLabel = _T("D");
|
|
BOOL CDimPipeRadiusDlg::m_bModifyPos = TRUE;
|
|
|
|
IMPLEMENT_DYNAMIC(CDimPipeRadiusDlg, CModelessDialog)
|
|
CDimPipeRadiusDlg::CDimPipeRadiusDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CDimPipeRadiusDlg::IDD, pParent), m_spinHeight(0.5)
|
|
{
|
|
//{{AFX_DATA_INIT(CDimPipeRadiusDlg)
|
|
m_iRadius = 20;
|
|
m_iType = 0;
|
|
m_iPos = 0;
|
|
m_nHeight = g_nPipeDnHeight;
|
|
m_bDimNull = FALSE;
|
|
m_bModifyDn = FALSE;
|
|
//}}AFX_DATA_INIT
|
|
m_bIsOutDoor = FALSE;
|
|
m_bChangeMode = FALSE;
|
|
m_pMenu = NULL;
|
|
}
|
|
|
|
CDimPipeRadiusDlg::~CDimPipeRadiusDlg()
|
|
{
|
|
if(::IsWindow(m_hWnd))
|
|
DestroyWindow();
|
|
|
|
if(m_pMenu) {
|
|
m_pMenu->DestroyMenu();
|
|
delete m_pMenu;
|
|
}
|
|
|
|
int len = m_lstDim.Length();
|
|
|
|
TCHAR strTmpPath[256] = _T("");
|
|
GetTempPath(255, strTmpPath);
|
|
_tcscat(strTmpPath, _T("PipeDim.his"));
|
|
int n=0;
|
|
if(len > 10)
|
|
n = len - 10;
|
|
for(int j=0;j<n;j++)
|
|
m_lstDim.Remove(0);
|
|
|
|
|
|
FILE *fp = fopen(_AS(strTmpPath), "w");
|
|
if(!fp)
|
|
return;
|
|
for(int i=0;i<m_lstDim.Length();i++){
|
|
CString csTmp3 = m_lstDim[i];
|
|
csTmp3 +=_T("\n");
|
|
fputs(_AS(csTmp3), fp);
|
|
}
|
|
fclose(fp);
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDimPipeRadiusDlg)
|
|
DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType);
|
|
DDX_Control(pDX, IDC_SPIN_TEXT, m_spinHeight);
|
|
DDX_Text(pDX, IDC_EDIT_RADIUS, m_iRadius);
|
|
DDX_Radio(pDX, IDC_RADIO_RADIUS0, m_iType);
|
|
DDX_Radio(pDX, IDC_RADIO_POS, m_iPos);
|
|
DDX_Text(pDX, IDC_EDIT_TEXT_HEIGHT, m_nHeight);
|
|
DDX_Check(pDX, IDC_CHECK_NULL, m_bDimNull);
|
|
DDX_Check(pDX, IDC_CHECK_SPEC, m_bModifyDn);
|
|
DDX_CBString(pDX, IDC_COMBO_TYPE, m_csType);
|
|
DDX_CBString(pDX, IDC_COMBO_LABEL, m_csLabel);
|
|
DDX_Control(pDX, IDC_COMBO_LABEL, m_comboLabel);
|
|
DDX_Check(pDX, IDC_CHECK_MODIFYPOS, m_bModifyPos);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDimPipeRadiusDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CDimPipeRadiusDlg)
|
|
ON_WM_CLOSE()
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS1, OnRadioRadius1)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS2, OnRadioRadius2)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS3, OnRadioRadius3)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS4, OnRadioRadius4)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS5, OnRadioRadius5)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS6, OnRadioRadius6)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS7, OnRadioRadius7)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS8, OnRadioRadius8)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS9, OnRadioRadius9)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS10, OnRadioRadius10)
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS0, OnRadioRadius0)
|
|
ON_BN_CLICKED(IDC_BUTTON_TYPE, OnButtonType)
|
|
ON_BN_CLICKED(IDC_CHECK_NULL, OnCheckNull)
|
|
ON_BN_CLICKED(IDC_CHECK_SPEC, OnCheckSpec)
|
|
ON_BN_CLICKED(IDC_BUTTON_USER, OnButtonUser)
|
|
ON_WM_CTLCOLOR()
|
|
ON_BN_CLICKED(IDC_RADIO_RADIUS11, OnRadioRadius11)
|
|
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDimPipeRadiusDlg message handlers
|
|
|
|
BOOL CDimPipeRadiusDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
// CWnd *pWnd = GetDlgItem(IDC_CHECK_OUT);
|
|
// CWnd *pWnd2 = GetDlgItem(IDC_CHECK_ELEV);
|
|
// pWnd->EnableWindow(FALSE);
|
|
// pWnd2->EnableWindow(FALSE);
|
|
SetRadius();
|
|
m_spinHeight.SetRange(1, 10);
|
|
|
|
LoadHisText();
|
|
if(m_lstDim.Length() == 0)
|
|
m_lstDim.Append(tstrnew(_T("De 110")));
|
|
else{
|
|
CString csTmp = m_lstDim[m_lstDim.Length() - 1];
|
|
SplitDnDim(csTmp, m_csType, m_iRadius);
|
|
m_iType = -1;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
CRegProperty regProp(GetRegLocation(), _T("TWT9"));
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
CString csMenu;
|
|
regProp.GetValue(_T("menu"), csMenu);
|
|
|
|
if(csMenu.Find(_T("OUT")) > -1 || csMenu.Find(_T("out")) > -1){
|
|
m_bIsOutDoor = TRUE;
|
|
}
|
|
ResetRadius();
|
|
|
|
int len = m_comboType.GetCount();
|
|
BOOL bFlag = FALSE;
|
|
for(int i=0;i<len;i++)
|
|
{
|
|
CString csTmp;
|
|
m_comboType.GetLBText(i, csTmp);
|
|
if(csTmp == m_csType)
|
|
{
|
|
m_comboType.SetCurSel(i);
|
|
bFlag = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
if(!bFlag)
|
|
m_comboType.SetWindowText(m_csType);
|
|
|
|
OnSelchangeComboType();
|
|
ReadRegData(_T("PIPEDIMLABEL"), _T("LABEL"), m_csLabel);
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::ResetRadius()
|
|
{
|
|
CWnd *pWnd1= GetDlgItem(IDC_RADIO_RADIUS0);
|
|
CWnd *pWnd2= GetDlgItem(IDC_RADIO_RADIUS1);
|
|
CWnd *pWnd3= GetDlgItem(IDC_RADIO_RADIUS2);
|
|
CWnd *pWnd4= GetDlgItem(IDC_RADIO_RADIUS3);
|
|
CWnd *pWnd5= GetDlgItem(IDC_RADIO_RADIUS4);
|
|
CWnd *pWnd6= GetDlgItem(IDC_RADIO_RADIUS5);
|
|
CWnd *pWnd7= GetDlgItem(IDC_RADIO_RADIUS6);
|
|
CWnd *pWnd8= GetDlgItem(IDC_RADIO_RADIUS7);
|
|
CWnd *pWnd9= GetDlgItem(IDC_RADIO_RADIUS8);
|
|
CWnd *pWnd10= GetDlgItem(IDC_RADIO_RADIUS9);
|
|
CString csType;
|
|
|
|
int iSel = m_comboType.GetCurSel();
|
|
m_comboType.GetLBText(iSel, csType);
|
|
|
|
if(csType == _T("De"))
|
|
{
|
|
pWnd1->SetWindowText(_T("20"));
|
|
pWnd2->SetWindowText(_T("25"));
|
|
pWnd3->SetWindowText(_T("32"));
|
|
pWnd4->SetWindowText(_T("40"));
|
|
pWnd5->SetWindowText(_T("50"));
|
|
pWnd6->SetWindowText(_T("63"));
|
|
pWnd7->SetWindowText(_T("75"));
|
|
pWnd8->SetWindowText(_T("90"));
|
|
pWnd9->SetWindowText(_T("110"));
|
|
pWnd10->SetWindowText(_T("160"));
|
|
}
|
|
else
|
|
{
|
|
if(m_bIsOutDoor)
|
|
{
|
|
pWnd1->SetWindowText(_T("150"));
|
|
pWnd2->SetWindowText(_T("200"));
|
|
pWnd3->SetWindowText(_T("250"));
|
|
pWnd4->SetWindowText(_T("300"));
|
|
pWnd5->SetWindowText(_T("400"));
|
|
pWnd6->SetWindowText(_T("500"));
|
|
pWnd7->SetWindowText(_T("600"));
|
|
pWnd8->SetWindowText(_T("700"));
|
|
pWnd9->SetWindowText(_T("800"));
|
|
pWnd10->SetWindowText(_T("900"));
|
|
}
|
|
else
|
|
{
|
|
pWnd1->SetWindowText(_T("20"));
|
|
pWnd2->SetWindowText(_T("25"));
|
|
pWnd3->SetWindowText(_T("32"));
|
|
pWnd4->SetWindowText(_T("40"));
|
|
pWnd5->SetWindowText(_T("50"));
|
|
pWnd6->SetWindowText(_T("65"));
|
|
pWnd7->SetWindowText(_T("80"));
|
|
pWnd8->SetWindowText(_T("100"));
|
|
pWnd9->SetWindowText(_T("125"));
|
|
pWnd10->SetWindowText(_T("150"));
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::PostNcDestroy()
|
|
{
|
|
CModelessDialog::PostNcDestroy();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius0()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius1()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius2()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius3()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius4()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius5()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius6()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius7()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius8()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius9()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius10()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius11()
|
|
{
|
|
m_bChangeMode = TRUE;
|
|
PostCommand(_T(" "), false);
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnRadioRadius12()
|
|
{
|
|
SetRadius();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::SetRadius()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd = GetDlgItem(IDC_EDIT_RADIUS);
|
|
if(m_iType == 10)
|
|
pWnd->EnableWindow(FALSE);
|
|
else
|
|
pWnd->EnableWindow(TRUE);
|
|
CWnd *pWnd1= GetDlgItem(IDC_RADIO_RADIUS0);
|
|
CWnd *pWnd2= GetDlgItem(IDC_RADIO_RADIUS1);
|
|
CWnd *pWnd3= GetDlgItem(IDC_RADIO_RADIUS2);
|
|
CWnd *pWnd4= GetDlgItem(IDC_RADIO_RADIUS3);
|
|
CWnd *pWnd5= GetDlgItem(IDC_RADIO_RADIUS4);
|
|
CWnd *pWnd6= GetDlgItem(IDC_RADIO_RADIUS5);
|
|
CWnd *pWnd7= GetDlgItem(IDC_RADIO_RADIUS6);
|
|
CWnd *pWnd8= GetDlgItem(IDC_RADIO_RADIUS7);
|
|
CWnd *pWnd9= GetDlgItem(IDC_RADIO_RADIUS8);
|
|
CWnd *pWnd10= GetDlgItem(IDC_RADIO_RADIUS9);
|
|
CString csText;
|
|
if(m_iType == 0)
|
|
pWnd1->GetWindowText(csText);
|
|
else if(m_iType == 1)
|
|
pWnd2->GetWindowText(csText);
|
|
else if(m_iType == 2)
|
|
pWnd3->GetWindowText(csText);
|
|
else if(m_iType == 3)
|
|
pWnd4->GetWindowText(csText);
|
|
else if(m_iType == 4)
|
|
pWnd5->GetWindowText(csText);
|
|
else if(m_iType == 5)
|
|
pWnd6->GetWindowText(csText);
|
|
else if(m_iType == 6)
|
|
pWnd7->GetWindowText(csText);
|
|
else if(m_iType == 7)
|
|
pWnd8->GetWindowText(csText);
|
|
else if(m_iType == 8)
|
|
pWnd9->GetWindowText(csText);
|
|
else if(m_iType == 9)
|
|
pWnd10->GetWindowText(csText);
|
|
|
|
m_iRadius = _ttoi(csText);
|
|
|
|
/* if(m_bIsOutDoor){
|
|
if(m_iType == 0)
|
|
m_iRadius = 150;
|
|
else if(m_iType == 1)
|
|
m_iRadius = 200;
|
|
else if(m_iType == 2)
|
|
m_iRadius = 250;
|
|
else if(m_iType == 3)
|
|
m_iRadius = 300;
|
|
else if(m_iType == 4)
|
|
m_iRadius = 350;
|
|
else if(m_iType == 12)
|
|
m_iRadius = 400;
|
|
else if(m_iType == 5)
|
|
m_iRadius = 450;
|
|
else if(m_iType == 6)
|
|
m_iRadius = 500;
|
|
else if(m_iType == 7)
|
|
m_iRadius = 600;
|
|
else if(m_iType == 8)
|
|
m_iRadius = 700;
|
|
else if(m_iType == 9)
|
|
m_iRadius = 800;
|
|
else if(m_iType == 10)
|
|
m_iRadius = -1;
|
|
}
|
|
else{
|
|
if(m_iType == 0)
|
|
m_iRadius = 20;
|
|
else if(m_iType == 1)
|
|
m_iRadius = 25;
|
|
else if(m_iType == 2)
|
|
m_iRadius = 32;
|
|
else if(m_iType == 3)
|
|
m_iRadius = 40;
|
|
else if(m_iType == 4)
|
|
m_iRadius = 50;
|
|
else if(m_iType == 12)
|
|
m_iRadius = 65;
|
|
else if(m_iType == 5)
|
|
m_iRadius = 70;
|
|
else if(m_iType == 6)
|
|
m_iRadius = 80;
|
|
else if(m_iType == 7)
|
|
m_iRadius = 100;
|
|
else if(m_iType == 8)
|
|
m_iRadius = 125;
|
|
else if(m_iType == 9)
|
|
m_iRadius = 150;
|
|
else if(m_iType == 10)
|
|
m_iRadius = -1;
|
|
}
|
|
*/
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnSelchangeComboType()
|
|
{
|
|
// UpdateData(TRUE);
|
|
// UpdateData(FALSE);
|
|
int nPos = m_comboType.GetCurSel();
|
|
CString csType;
|
|
m_comboType.GetLBText(nPos, csType);
|
|
if (csType == _T("φ外径") || csType == _T("外径壁厚") || csType == _T("外径壁厚2"))
|
|
{
|
|
m_comboLabel.EnableWindow(TRUE);
|
|
}
|
|
else
|
|
{
|
|
m_comboLabel.EnableWindow(FALSE);
|
|
}
|
|
ResetRadius();
|
|
}
|
|
|
|
|
|
void CDimPipeRadiusDlg::OnButtonType()
|
|
{
|
|
RBList rbCmd=ads_buildlist(RTSTR, _T("ISetPipeMatDnType"), NULL);
|
|
resbuf *rbRes=NULL;
|
|
if(ads_invoke(rbCmd, &rbRes)==RTNORM && rbRes)
|
|
{
|
|
ads_relrb(rbRes);
|
|
}
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnCheckNull()
|
|
{
|
|
UpdateData(TRUE);
|
|
if(m_bDimNull)
|
|
m_bModifyDn = FALSE;
|
|
UpdateData(FALSE);
|
|
m_bChangeMode = TRUE;
|
|
PostCommand(_T(" "), false);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnCheckSpec()
|
|
{
|
|
UpdateData(TRUE);
|
|
if(m_bModifyDn)
|
|
m_bDimNull = FALSE;
|
|
UpdateData(FALSE);
|
|
m_bChangeMode = TRUE;
|
|
PostCommand(_T(" "), false);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::OnButtonUser()
|
|
{
|
|
|
|
CWnd *pWnd = GetDlgItem(IDC_BUTTON_USER);
|
|
CRect rc;
|
|
pWnd->GetWindowRect(rc);
|
|
|
|
|
|
if(m_pMenu) {
|
|
m_pMenu->DestroyMenu();
|
|
m_pMenu->CreatePopupMenu();
|
|
} else {
|
|
m_pMenu = new CMenu;
|
|
m_pMenu->CreatePopupMenu();
|
|
}
|
|
for(int i=m_lstDim.Length(); i>0;i--) // 将最近使用过的库加入菜单
|
|
m_pMenu->AppendMenu(MF_STRING, OpenMenuID + i, m_lstDim[i-1]);
|
|
|
|
m_pMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
|
|
rc.left, rc.bottom, this, &rc);
|
|
|
|
}
|
|
|
|
void CDimPipeRadiusDlg::LoadHisText()
|
|
{
|
|
TCHAR strTmpPath[100] = _T("");
|
|
GetTempPath(100, strTmpPath);
|
|
_tcscat(strTmpPath, _T("PipeDim.his"));
|
|
FILE *fp=fopen(_AS(strTmpPath), "r");
|
|
if(!fp)
|
|
return;
|
|
while(!feof(fp)) {
|
|
char sBuf[256]="";
|
|
fgets(sBuf, 255, fp);
|
|
CString csTmp = sBuf;
|
|
csTmp.TrimRight();
|
|
if(csTmp != _T(""))
|
|
m_lstDim.Append(tstrnew(csTmp));
|
|
}
|
|
fclose(fp);
|
|
}
|
|
|
|
|
|
BOOL CDimPipeRadiusDlg::OnCommand(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
CString csCommand;
|
|
if(!m_pMenu)
|
|
return CModelessDialog::OnCommand(wParam, lParam);
|
|
m_pMenu->GetMenuString(wParam, csCommand, MF_BYCOMMAND); //判断用户是否点的是弹出菜单
|
|
if(csCommand.IsEmpty())
|
|
return CModelessDialog::OnCommand(wParam, lParam);
|
|
SplitDnDim(csCommand, m_csType, m_iRadius);
|
|
m_iType = -1;
|
|
UpdateData(FALSE);
|
|
return CModelessDialog::OnCommand(wParam, lParam);
|
|
}
|
|
|
|
HBRUSH CDimPipeRadiusDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CModelessDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
|
|
int nID=pWnd->GetDlgCtrlID();
|
|
if(nID==IDC_EDIT_RADIUS)
|
|
pDC->SetTextColor(acedGetRGB(6));
|
|
|
|
return hbr;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|