1176 lines
33 KiB
C++
1176 lines
33 KiB
C++
#include "stdafx.h"
|
|
#include <PipeWireMonitor.h>
|
|
//#include <ImageDc.h>
|
|
#include <DbPipeLabel.h>
|
|
#include <xtext.h>
|
|
|
|
#include "jig.h"
|
|
#include "DimSinglePipeRadiusDlg.h"
|
|
#include "TDbPipeMultDim.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern void DoDimPipeDnByPt(Entity ent, int iRadius, const TCHAR* szType, double nHeight, BOOL bIsDown = FALSE, XPoint ptPick = XPoint());
|
|
extern void SplitDnDim(const TCHAR* szDim, CString &csHead, int &iDn);
|
|
|
|
//***************************************************************************************************
|
|
// 单管管径
|
|
//***************************************************************************************************
|
|
|
|
void DoDimPipeDn2ByPt(Entity ent, int iRadius, const TCHAR* szType, double nHeight, BOOL bIsDown, XPoint ptPick)
|
|
{
|
|
if(!ent.Is(_T("ATS_PIPE")))
|
|
return;
|
|
// cet 2014.4.25 modify 修改标注文字样式使其与初始设置中管径标注相同
|
|
// AcDbObjectId idTextStyle = InitTwtTextStyle(g_csTwtDimStyle);
|
|
AcDbObjectId idTextStyle = InitTwtTextStyle(g_csPipeDnStyle);
|
|
|
|
InitLayer(LAY_DIM_TEXT);
|
|
double nDnDiameter(-1);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(!pPipe)
|
|
return;
|
|
AcGePoint3d pt1 = ptPick;
|
|
AcGePoint3d pt2;
|
|
pPipe->getClosestPointTo(pt1, pt2);//有可能PICK点不在管线上
|
|
ptPick = pt2;
|
|
|
|
double nRotate(0);
|
|
// cet 2011.8.30 modify 支持ucs
|
|
// if(pPipe->Is(CURVE_LINE)){
|
|
// 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(pPipe->Is(CURVE_LINE))
|
|
{
|
|
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;
|
|
}
|
|
|
|
XPoint ptS, ptE;
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
XVector3D vectBase(ptE.x - ptS.x, ptE.y - ptS.y, 0);
|
|
vectBase.Normalize();
|
|
|
|
nDnDiameter = pPipe->GetDnDiameter();
|
|
|
|
|
|
if(!(iRadius < 0 && nDnDiameter > 0))
|
|
nDnDiameter = (double)iRadius;
|
|
pPipe->SetDnDiameter(nDnDiameter);
|
|
pPipe->SetLabel(szType);
|
|
|
|
if(pPipe->IsVertical())
|
|
return;
|
|
CString csLay = GetTextLayBySys(pPipe->GetSysType());
|
|
InitLayer(csLay);
|
|
|
|
TDbPipeLabel *pLabel = new TDbPipeLabel;
|
|
pLabel->SetDistToPipe(-g_nDnDimDist2Pipe*DocGetPScale()); //cet 2012.2.7 modify 默认在管线下方,距离为正
|
|
//pLabel->SetDistToPipe(g_nDnDimDist2Pipe*DocGetPScale());
|
|
|
|
if(bIsDown)
|
|
pLabel->SetDistToPipe((-1)*pLabel->GetDistToPipe());
|
|
|
|
if(nRotate > PI/2 && nRotate <=PI*3/2)//管反了
|
|
pLabel->SetDistToPipe((-1)*pLabel->GetDistToPipe());
|
|
|
|
pLabel->SetPipeType(TDbPipeLabel::kCommon);
|
|
pLabel->SetTextStyleId(idTextStyle);
|
|
pLabel->SetPipeDiameter(nDnDiameter);
|
|
pLabel->SetPipeId(pPipe->objectId());
|
|
pLabel->SetLocation(ptPick);
|
|
pLabel->setLayer(csLay);
|
|
|
|
pLabel->SetTextHeight(nHeight);
|
|
pLabel->SetDirection(vectBase);
|
|
pLabel->SetLeftText(szType);
|
|
AddToCurrentSpace(pLabel, Adesk::kTrue);
|
|
|
|
OPENOBJ_END();
|
|
|
|
}
|
|
|
|
CString GetPipeDimLayByEnt(Entity ent)
|
|
{
|
|
CString csLay;
|
|
TPipeSys::SysType sysType;
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
sysType = pPipe->GetSysType();
|
|
}
|
|
OPENOBJ_END();
|
|
csLay = GetDimLayBySys(sysType);
|
|
return csLay;
|
|
}
|
|
|
|
// 删除图层 cet 2011.11.28 add
|
|
void RemoveLayer(const CString &sLayerName)
|
|
{
|
|
AcDbLayerTable *pTbl = NULL;
|
|
acdbHostApplicationServices()->workingDatabase()->getLayerTable(pTbl, AcDb::kForRead);
|
|
if (pTbl != NULL)
|
|
{
|
|
AcDbLayerTableRecord *pRec = NULL;
|
|
pTbl->getAt(sLayerName, pRec, AcDb::kForWrite);
|
|
if (pRec != NULL)
|
|
{
|
|
pRec->erase();
|
|
pRec->close();
|
|
}
|
|
pTbl->close();
|
|
}
|
|
}
|
|
|
|
void DimSinglePipeDnRadius()
|
|
{
|
|
// DocSetText2Base(0.2);
|
|
g_ssPickFirst.Free();
|
|
CDimSinglePipeRadiusDlg dlg(acedGetAcadFrame());
|
|
{
|
|
CTemporaryResourceOverride vTemp;
|
|
dlg.Create(IDD_DIM_PIPE_RADIUS_SINGLE, acedGetAcadFrame());
|
|
}
|
|
dlg.ShowWindow(SW_SHOW);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
//InitLayer(LAY_PIPE_DIM); //干掉无关图层 zxl 2011.11.24 Del
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), NULL);
|
|
AcDbObjectId idTextStyle = InitTwtTextStyle(g_csPipeDnStyle);
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
BOOL bExistLayer = IsLayerExistInDb(LAY_CALC_TEXT); // cet 2011.11.28 add
|
|
XText text(_T(""), XPoint(), g_nTwtDimHeight * DocGetPScale(), g_nDimScale, g_csPipeDnStyle, LAY_CALC_TEXT);
|
|
text.Draw(AcDb::kTextBase, AcDb::kTextRight);
|
|
Entity ent;
|
|
ent.GetLast();
|
|
ent.Erase();
|
|
//写1个字,然后删除,很弱智。TDbPipeText::GetWidth()第一次执行时AcGiTextStyle计算外框用的是STANDARD样式
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
SHads_command(RTNONE);
|
|
|
|
while(1){
|
|
dlg.UpdateData();
|
|
Entity entSel;
|
|
XPoint ptPick;
|
|
int ret(0);
|
|
/* cet 2011.4.27 modify 标注位置增加左上、右下
|
|
INITGET_BEG(0, _T("R"));
|
|
// ret = SelectEntity1(g_nCurPipeWidth*DocGetPScale(), _T("\n请选取要标注管径的管线(单选,标注在点取位置) <退出>:"), entSel, ptPick, rbMask);
|
|
// ret = SelectEntity(_T("\n请选取要标注管径的管线(单选,标注在点取位置)<退出>:"), entSel, ptPick, rbMask); cet 2011.4.25 modify
|
|
ret = SelectEntity(_T("\n请单选需要标注管径的管线(标注位置参照光标与管线的相对位置)<退出>:"), entSel, ptPick, rbMask);
|
|
INITGET_END();
|
|
if(ret == RTNORM) {
|
|
|
|
// cet 2011.2.15 add 据选取管线时点的位置自动设置标注位置
|
|
XPoint pt, pt1, pt2;
|
|
GetPipePoint(entSel, pt1, pt2, pt);
|
|
XLine line(pt1, pt2, 1);
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
if (ptPick.Project(&line, pt) != RTNORM)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int nPos = 0; // 标注方向左上
|
|
pt = Wcs2Ucs(pt);
|
|
if (ptPick.y < pt.y || (fabs(pt.y - ptPick.y) < 0.001 && ptPick.x > pt.x))
|
|
{
|
|
nPos = 1; // 右下
|
|
}
|
|
|
|
ptPick = pt;
|
|
*/
|
|
|
|
ret = SelectEntity(_T("\n请单选需要标注管径的管线(标注位置参照光标与管线的相对位置)<退出>:"), entSel, ptPick, rbMask);
|
|
if (ret != RTNORM)
|
|
{
|
|
break;
|
|
}
|
|
|
|
WriteXdata(entSel, _T("TG_PIPELABEL_THICK_SHOW"), _T("0"));
|
|
// 选择点到管线的投影(xy平面)
|
|
BOOL bArc = FALSE;
|
|
double dBulge = 0.0;
|
|
XPoint pt, pt1, pt2;
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPipe, pPipe);
|
|
if (pPipe != NULL)
|
|
{
|
|
bArc = pPipe->Is(CURVE_ARC);
|
|
pPipe->getStartPoint(pt1);
|
|
pPipe->getEndPoint(pt2);
|
|
dBulge = pPipe->GetBulge();
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
ptPick = Ucs2Wcs(ptPick);
|
|
if (bArc) // 弧管
|
|
{
|
|
pt1.z = 0.0;
|
|
pt2.z = 0.0;
|
|
XArc arc(pt1, pt2, dBulge);
|
|
if (ptPick.Project(&arc, pt) != RTNORM)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else // 直管
|
|
{
|
|
XLine line(pt1, pt2, 1);
|
|
line.StartPoint().z = 0.0;
|
|
line.EndPoint().z = 0.0;
|
|
if (ptPick.Project(&line, pt) != RTNORM)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForRead, TDbPipe, pPipe);
|
|
if (pPipe != NULL)
|
|
{
|
|
pPipe->getClosestPointTo(pt, AcGeVector3d::kZAxis, pt); // 获取投影点对应的管线上一点
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
int nPos = 0;
|
|
CString strDimPos = dlg.m_strWndEdtPos;
|
|
if (strDimPos.CompareNoCase(_T("屏幕拾取")) == 0)
|
|
{
|
|
nPos = 0; // 标注方向左上
|
|
pt = Wcs2Ucs(pt);
|
|
ptPick = Wcs2Ucs(ptPick);
|
|
if (ptPick.y < pt.y || (fabs(pt.y - ptPick.y) < 0.001 && ptPick.x > pt.x))
|
|
{
|
|
nPos = 1; // 右下
|
|
}
|
|
|
|
ptPick = pt;
|
|
}
|
|
else if (strDimPos.CompareNoCase(_T("左上")) == 0)
|
|
{
|
|
nPos = 0;
|
|
ptPick = Wcs2Ucs(pt);
|
|
}
|
|
else if (strDimPos.CompareNoCase(_T("右下")) == 0)
|
|
{
|
|
nPos = 1;
|
|
ptPick = Wcs2Ucs(pt);
|
|
}
|
|
|
|
dlg.UpdateData(TRUE);
|
|
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);
|
|
if(_tcsicmp(dlg.m_csType, _T("自动")) != 0)
|
|
dlg.m_lstDim.Append(tstrnew((const TCHAR*)xsDim));
|
|
if(dlg.m_iRet == 0){
|
|
//cet 2011.2.15 modify 根据选取管线时点的位置自动设置标注位置
|
|
//DoDimPipeDnByPt(entSel, dlg.m_iRadius, dlg.m_csType, dlg.m_nHeight, dlg.m_iPos, Ucs2Wcs(ptPick));
|
|
DoDimPipeDnByPt(entSel, dlg.m_iRadius, dlg.m_csType, dlg.m_nHeight, nPos, Ucs2Wcs(ptPick));
|
|
}
|
|
else if(dlg.m_iRet == 1){//管线文字
|
|
CString csType = dlg.m_csType;
|
|
int iDn = dlg.m_iRadius;
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(iDn > 0)
|
|
pPipe->SetDnDiameter(dlg.m_iRadius);
|
|
else
|
|
iDn = (int)pPipe->GetDnDiameter();
|
|
if(_tcsicmp(dlg.m_csType, _T("自动")) == 0){
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
csType = GetDnByMat(csMat);
|
|
pPipe->SetLabel(csType);
|
|
}
|
|
else
|
|
pPipe->SetLabel(dlg.m_csType);
|
|
}
|
|
OPENOBJ_END();
|
|
XString xsDim1(_T("%s%d"), csType, iDn);
|
|
|
|
CString csLay = GetPipeTextLayByEnt(entSel);
|
|
InitLayer(csLay);
|
|
|
|
TDbPipeText *pText = new TDbPipeText();
|
|
pText->SetTextStyleId(idTextStyle);
|
|
pText->SetLocation(Ucs2Wcs(ptPick));
|
|
pText->SetTextHeight(dlg.m_nHeight);
|
|
pText->setLayer(csLay);
|
|
pText->setColor(AcCmColor());
|
|
pText->SetText((const TCHAR*)xsDim1);
|
|
AddToCurrentSpace(pText, Adesk::kTrue);
|
|
}
|
|
else if(dlg.m_iRet == 2){//引出管径
|
|
TCHAR szLayer[256];
|
|
entSel.GetData(8, szLayer);
|
|
int iDn = dlg.m_iRadius;
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(iDn > 0)
|
|
pPipe->SetDnDiameter(dlg.m_iRadius);
|
|
else
|
|
iDn = (int)pPipe->GetDnDiameter();
|
|
if(_tcsicmp(dlg.m_csType, _T("自动")) == 0){
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
pPipe->SetLabel(GetDnByMat(csMat));
|
|
}
|
|
else
|
|
pPipe->SetLabel(dlg.m_csType);
|
|
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
CString csLay = GetPipeDimLayByEnt(entSel);
|
|
InitLayer(csLay);
|
|
|
|
XPoint ptStart, ptEnd;
|
|
GetPipePoint(entSel, ptStart, ptEnd);
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id, entSel);
|
|
TDbPipeMultDim *pDim = new TDbPipeMultDim;
|
|
pDim->AddPipe(id);
|
|
double nAng = ads_angle(ptStart, ptEnd);
|
|
pDim->SetLayoutRotation(nAng);
|
|
pDim->setLayer(csLay);
|
|
pDim->SetStartPoint(ptPick);
|
|
pDim->SetTextStyleId(idTextStyle);
|
|
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
|
pDim->SetDimType(0);
|
|
pDim->SetTextHeight(g_nPipeDnHeight);
|
|
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
|
|
|
TMultPipeDimEdJig jig(pDim);
|
|
XPoint ptlnMinStart, ptlnMinEnd, ptlnMinStart2, ptlnMinEnd2;
|
|
ptlnMinEnd = ptEnd;
|
|
ptlnMinStart = ptStart;
|
|
ptlnMinEnd2 = ptlnMinEnd;
|
|
ptlnMinStart2 = ptlnMinStart;
|
|
ptlnMinStart.z = 0;
|
|
ptlnMinEnd.z = 0;
|
|
ptlnMinStart2.z = 0;
|
|
ptlnMinEnd2.z = 0;
|
|
jig.m_ptLeftUp = ptlnMinStart;
|
|
jig.m_ptRightUp = ptlnMinEnd;
|
|
jig.m_ptLeftDown = ptlnMinStart2;
|
|
jig.m_ptRightDown = ptlnMinEnd2;
|
|
jig.SetPrompt(_T("\n请给出标注点<退出>:"));
|
|
if(jig.DoIt()==RTNORM) {
|
|
((TDbEntity *)pDim)->AddToCSpace(Adesk::kTrue);
|
|
Entity entLast;
|
|
entLast.GetLast();
|
|
// WriteXdata(entLast, _T("TG-LAYER"), szLayer);
|
|
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, TDbEntity, pEnt)
|
|
if(pEnt){
|
|
pEnt->setLayer(csLay);
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
else {
|
|
delete pDim;
|
|
continue;
|
|
}
|
|
}
|
|
else if(dlg.m_iRet == 3){//多点标注
|
|
CString csType = dlg.m_csType;
|
|
int iDn = dlg.m_iRadius;
|
|
OPENOBJ_BEGIN(entSel, AcDb::kForWrite, TDbPipe, pPipe);
|
|
if(pPipe){
|
|
if(iDn > 0)
|
|
pPipe->SetDnDiameter(dlg.m_iRadius);
|
|
else
|
|
iDn = (int)pPipe->GetDnDiameter();
|
|
if(_tcsicmp(dlg.m_csType, _T("自动")) == 0){
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
csType = GetDnByMat(csMat);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
//cet 2011.2.15 modify 根据选取管线时点的位置自动设置标注位置
|
|
//DoDimPipeDn2ByPt(entSel, iDn, csType, dlg.m_nHeight, dlg.m_iPos, Ucs2Wcs(ptPick));
|
|
DoDimPipeDn2ByPt(entSel, iDn, csType, dlg.m_nHeight, nPos, Ucs2Wcs(ptPick));
|
|
}
|
|
TPipePerDocData *pData = GetCurPipeDocData();
|
|
pData->ApplyUpdates();
|
|
// cet 2011.4.27 del
|
|
// }
|
|
// else if(ret == RTKWORD){
|
|
// continue;
|
|
// }
|
|
// else
|
|
// break;
|
|
|
|
}
|
|
|
|
if (!bExistLayer)
|
|
{
|
|
RemoveLayer(LAY_CALC_TEXT);
|
|
}
|
|
dlg.DestroyWindow();
|
|
}
|
|
|
|
//***************************************************************************************************
|
|
// 多管标注
|
|
//***************************************************************************************************
|
|
extern CString GetDimLayByEnt(Entity ent);
|
|
extern double GetLayoutRotate(double nRotateIn);
|
|
|
|
// 获取用户选择的管线 zxl 2012.06.26 ADD
|
|
void GetIntersectPipe(const XPoint &ptStartPick, const XPoint &ptEndPick, PickSet &ss)
|
|
{
|
|
AcDbLine line;
|
|
line.setStartPoint(ptStartPick);
|
|
line.setEndPoint(ptEndPick);
|
|
AcGePoint3dArray arryPts;
|
|
std::map<double, Entity> mapPipe;
|
|
for (long i = 0; i < ss.Length(); i++)
|
|
{
|
|
double dDist(0.0);
|
|
arryPts.setLogicalLength(0);
|
|
Entity ent = ss[i];
|
|
AcDbObjectId id = NULL;
|
|
acdbGetObjectId(id, ent);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe)
|
|
if(pPipe)
|
|
{
|
|
AcDbLine linePipe;
|
|
AcGePoint3d ptS, ptE;
|
|
ptS = pPipe->StartPoint();
|
|
ptS.z = 0;
|
|
ptE = pPipe->EndPoint();
|
|
ptE.z = 0;
|
|
linePipe.setStartPoint(ptS);
|
|
linePipe.setEndPoint(ptE);
|
|
linePipe.intersectWith(&line, AcDb::kOnBothOperands, arryPts);
|
|
if (pPipe->IsVertical())
|
|
{
|
|
AcGePoint3d ptPipe = pPipe->StartPoint();
|
|
ptPipe.z = 0;
|
|
AcGePoint3d ptOnline;
|
|
line.getClosestPointTo(ptPipe, ptOnline);
|
|
if (ptPipe.distanceTo(ptOnline) < pPipe->GetRadius() * DocGetPScale())
|
|
{
|
|
dDist = ptPipe.distanceTo(ptStartPick);
|
|
mapPipe.insert(std::make_pair(dDist, ent));
|
|
}
|
|
}
|
|
else if (arryPts.length() > 0)
|
|
{
|
|
AcGePoint3d ptOnPipe = arryPts[0];
|
|
if (ptOnPipe.distanceTo(ptS) > pPipe->GetRadius() * DocGetPScale() && ptOnPipe.distanceTo(ptE) > pPipe->GetRadius() * DocGetPScale())
|
|
{
|
|
dDist = ptOnPipe.distanceTo(ptStartPick);
|
|
mapPipe.insert(std::make_pair(dDist, ent));
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
|
|
PickSet ssPipe(SS_FREE);
|
|
ss.Free();
|
|
std::map<double, Entity>::iterator it;
|
|
for (it = mapPipe.begin(); it != mapPipe.end(); it++)
|
|
{
|
|
ss += it->second;
|
|
}
|
|
}
|
|
|
|
void MultiPipeDimDn()
|
|
{
|
|
|
|
InitLayer(LAY_PIPE_DIM);
|
|
|
|
// zxl 2012.06.27 add 更改选择管线形式
|
|
g_ssPickFirst.Free();
|
|
PickSet ssAll(SS_FREE);
|
|
RBList rbMask(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
|
if(SelectEntities(_T("\n请选择需要标注的管线或立管: <退出>"), ssAll, rbMask) != RTNORM)
|
|
return;
|
|
if (ssAll.Length() < 1)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// DocSetText2Base(0.2);
|
|
// XPushVarStr clayer(_T("CLAYER"), LAY_PIPE_DIM);
|
|
Entity entLast;
|
|
TCHAR szLayer[256];
|
|
//用户输入参数
|
|
adsout<<_T("\n多管标注:")
|
|
<<_T("\n确定一直线的起点与终点")
|
|
<<_T("\n用该直线与待标注的管线(可以是多根)相交");
|
|
XPoint ptStartPick,ptEndPick;
|
|
if(ads_getpoint(NULL, _T("\n起点:"), ptStartPick) != RTNORM)
|
|
return;
|
|
if(ads_getpoint(ptStartPick, _T("\n终点:"), ptEndPick) != RTNORM)
|
|
return;
|
|
|
|
PickSet ss(SS_FREE);
|
|
|
|
// zxl 2012.009.21 add
|
|
ptStartPick.z = 0;
|
|
ptEndPick.z = 0;
|
|
|
|
UCS2WCS(ptStartPick);
|
|
UCS2WCS(ptEndPick);
|
|
GetIntersectPipe(ptStartPick, ptEndPick, ssAll);
|
|
ss = ssAll;
|
|
// zxl 2012.06.26 del
|
|
// struct resbuf *pointlist;
|
|
// PickSet ss(SS_FREE);
|
|
// pointlist = ads_buildlist(RTPOINT, &ptStartPick, RTPOINT, &ptEndPick, NULL);
|
|
// ss.Get(_T("F"), pointlist, NULL, RBList(RTDXF0, _T("ATS_PIPE"), 0));
|
|
// ads_relrb(pointlist);
|
|
|
|
if(ss.Length() < 1)
|
|
return;
|
|
ss[0L].GetData(8, szLayer);
|
|
XPoint ptlnMinStart, ptlnMinEnd, ptlnMinStart2, ptlnMinEnd2;
|
|
XLine line(1);
|
|
int iDimType = 0;
|
|
DList<AcDbObjectId> lstId;
|
|
double nDistMax(-1);
|
|
|
|
BOOL bAllVer = TRUE;//看是否全是立管
|
|
// BOOL bAllOut = TRUE;//看是否全是室外管线
|
|
for(long i=0;i<ss.Length(); i++){
|
|
Entity ent = ss[i];
|
|
if(!IsPipeVertical(ent)){
|
|
bAllVer = FALSE;
|
|
break;
|
|
}
|
|
}
|
|
if(bAllVer){
|
|
// 设定一键响应 zxl 2012.06.29 modify
|
|
// TCHAR szText[256];
|
|
// ads_getstring(0, _T("\n进行管径标注(键入N进行立管编号标注)<Y>:"), szText);
|
|
// if(_tcsicmp(szText, _T("N")) == 0){
|
|
// iDimType = 1;
|
|
// }
|
|
|
|
TCHAR szText[256];
|
|
int nStatus = 0;
|
|
INITGET_BEG(0, _T("N Y"));
|
|
nStatus = acedGetString(0, _T("进行管径标注(键入N进行立管编号标注)<Y>:"), szText);
|
|
INITGET_END();
|
|
if (nStatus == RTNORM)
|
|
{
|
|
if (szText[0] == _T('n') || szText[0] == _T('N'))
|
|
{
|
|
iDimType = 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
CString csDimLay;
|
|
BOOL bIsVer = FALSE;
|
|
XString csFloor;
|
|
for (i=0;i<ss.Length(); i++){
|
|
Entity ent = ss[i];
|
|
csDimLay = GetDimLayByEnt(ent);
|
|
|
|
AcDbObjectId id = NULL;
|
|
acdbGetObjectId(id, ent);
|
|
if(iDimType == 1){
|
|
CString csSerial = ReadXdata(ent, _T("PIPE-SERIAL"));
|
|
if (csFloor == _T(""))
|
|
{
|
|
csFloor = ReadXdata(ent, _T("BUILDING-SERIAL"));
|
|
}
|
|
|
|
if(csSerial == _T("")){
|
|
ent.Redraw(3);
|
|
CString csLay = GetPipeLayer(ent);
|
|
CString csDim = g_csPipeDim[GetPipeLayerIdxByName(csLay)] + _T("L");
|
|
|
|
// TPipeSys::SysType sys = GetPipeSys(ent);
|
|
// CString csDim = g_csPipeDim[GetPipeLayerIdxBySys(sys)] + _T("L");
|
|
TCHAR szName[256];
|
|
CString csPrompt;
|
|
csPrompt.Format(_T("\n请输入立管编号 %s-<退出>"), csDim);
|
|
int ret = ads_getstring(0, csPrompt, szName);
|
|
if(ret != RTNORM && ret != RTNONE)
|
|
return;
|
|
if(_tcsicmp(szName, _T("")) == 0)
|
|
return;
|
|
WriteXdata(ent, _T("PIPE-SERIAL"), szName);
|
|
}
|
|
lstId.Append(new AcDbObjectId(id));
|
|
continue;
|
|
}
|
|
|
|
double nDn(-1);
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe)
|
|
if(pPipe){
|
|
if(pPipe->IsVertical())
|
|
bIsVer = TRUE;
|
|
if(i == 0){
|
|
ptlnMinEnd = pPipe->EndPoint();
|
|
ptlnMinStart = pPipe->StartPoint();
|
|
ptlnMinEnd2 = ptlnMinEnd;
|
|
ptlnMinStart2 = ptlnMinStart;
|
|
}
|
|
else{
|
|
if(i == ss.Length() - 1){
|
|
ptlnMinEnd2 = pPipe->EndPoint();
|
|
ptlnMinStart2 = pPipe->StartPoint();
|
|
}
|
|
double nTmp = (pPipe->StartPoint()).Distance(&line);
|
|
if(nTmp > nDistMax)
|
|
nDistMax = nTmp;
|
|
}
|
|
|
|
nDn =pPipe->GetDnDiameter();
|
|
if(_tcsicmp(pPipe->GetLabel(), _T("")) == 0){
|
|
// flag = TRUE;
|
|
if(pPipe->upgradeOpen()==Acad::eOk) {
|
|
// 2008-6-23 如果没有标注过,给一个默认的前缀
|
|
int iMaterial = pPipe->GetMaterial();
|
|
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
|
pPipe->SetLabel(GetDnByMat(csMat));
|
|
pPipe->downgradeOpen();
|
|
}
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
|
|
lstId.Append(new AcDbObjectId(id));
|
|
}
|
|
|
|
if (bAllVer && iDimType == 1)
|
|
{
|
|
CString csPrompt;
|
|
CString sTmp;
|
|
csPrompt.Format(_T("\n请输入立管所属楼号:"));
|
|
if(csFloor != _T(""))
|
|
{
|
|
sTmp = csFloor;
|
|
csPrompt.Format(_T("\n请输入立管所属楼号(按ESC设置为空):<%s>"), csFloor);
|
|
}
|
|
|
|
int ret = ads_getstring(0, csPrompt, csFloor);
|
|
if(ret != RTNORM && ret != RTNONE && ret != RTCAN)
|
|
return;
|
|
|
|
if(sTmp != _T("") && csFloor == _T(""))
|
|
{
|
|
csFloor = sTmp;
|
|
}
|
|
if(ret == RTCAN)
|
|
csFloor = _T("");
|
|
|
|
for (i=0;i<ss.Length(); i++)
|
|
{
|
|
Entity ent = ss[i];
|
|
WriteXdata(ent, _T("BUILDING-SERIAL"), csFloor);
|
|
}
|
|
}
|
|
|
|
if(lstId.Length() < 1)
|
|
return;
|
|
double nRotate = GetLayoutRotate(ads_angle(ptStartPick, ptEndPick));
|
|
TDbPipeMultDim *pDim = new TDbPipeMultDim;
|
|
for(int j=0;j<lstId.Length();j++){
|
|
pDim->AddPipe(*lstId[j]);
|
|
}
|
|
pDim->setLayer(InitLayer(csDimLay));
|
|
pDim->SetLayoutRotation(nRotate);
|
|
pDim->SetStartPoint(ptStartPick);
|
|
pDim->SetTurnPoint(ptEndPick);
|
|
pDim->SetTextLayerId(InitLayer(LAY_TEXT));
|
|
if(iDimType == 1)
|
|
pDim->SetTextStyleId(InitTwtTextStyle(g_csVPipeStyle));
|
|
else
|
|
pDim->SetTextStyleId(InitTwtTextStyle(g_csPipeDnStyle));
|
|
pDim->SetDimType(iDimType);
|
|
pDim->SetTextHeight(g_nPipeDnHeight);
|
|
// zxl 2013.01.21 add
|
|
pDim->SetDimAlignType(0);
|
|
pDim->SetDimDist2Line(2.0);
|
|
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
|
|
|
if(bAllVer){
|
|
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
|
((TDbEntity *)pDim)->AddToCSpace(Adesk::kTrue);
|
|
entLast.GetLast();
|
|
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, TDbEntity, pEnt)
|
|
if(pEnt){
|
|
pEnt->setLayer(csDimLay);
|
|
}
|
|
OPENOBJ_END()
|
|
return;
|
|
}
|
|
|
|
TMultPipeDimEdJig jig(pDim);
|
|
double nAng = ads_angle(ptStartPick, ptEndPick);
|
|
ptlnMinStart.z = 0;
|
|
ptlnMinEnd.z = 0;
|
|
ptlnMinStart2.z = 0;
|
|
ptlnMinEnd2.z = 0;
|
|
|
|
jig.m_ptLeftUp = ptlnMinStart;
|
|
jig.m_ptRightUp = ptlnMinEnd;
|
|
jig.m_ptLeftDown = ptlnMinStart2;
|
|
jig.m_ptRightDown = ptlnMinEnd2;
|
|
|
|
// cet 2011.4.25 add 标注类型选择
|
|
TCHAR szSelChar[10];
|
|
int nStatus = 0;
|
|
INITGET_BEG(0, _T("E F D"));
|
|
nStatus = acedGetString(0, _T("\n进行管径标注[标高标注(E)/管径、标高同时标注(F)/管代号-管径标注(D)]<管径标注>"), szSelChar);
|
|
INITGET_END();
|
|
if (nStatus == RTNORM)
|
|
{
|
|
if (szSelChar[0] == _T('E') || szSelChar[0] == _T('e'))
|
|
{
|
|
iDimType = 3; // 标高标注
|
|
}
|
|
else if (szSelChar[0] == _T('f') || szSelChar[0] == _T('F'))// 管径、标高同时标注 zxl 2012.06.28 add
|
|
{
|
|
iDimType = 4;
|
|
}
|
|
else if (szSelChar[0] == _T('d') || szSelChar[0] == _T('D'))// 管代号-管径标注 zxl 2013.02.21 add
|
|
{
|
|
iDimType = 5;
|
|
CString csText;
|
|
for (long l = 0l; l < ss.Length(); l++)
|
|
{
|
|
Entity entOne = ss[l];
|
|
TCHAR szLayer[256];
|
|
|
|
entOne.GetData(8, szLayer);
|
|
int idx = GetPipeLayerIdxByName(szLayer);
|
|
CString sLabel;
|
|
if(idx >= 0)
|
|
|
|
sLabel = g_csPipeDim[idx];
|
|
sLabel += _T(",");
|
|
csText += sLabel;
|
|
}
|
|
pDim->SetPipeLabel(csText);
|
|
}
|
|
else
|
|
{
|
|
iDimType = 0; // 管径标注
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
pDim->SetDimType(iDimType);
|
|
pDim->SetPipePrefix(_T(""));
|
|
pDim->SetTextBaseLen(pDim->GetDefaultTextBaseLen());
|
|
|
|
// zxl modify 2013.04.22
|
|
// jig.SetPrompt(_T("\n请给出标注点<退出>:"));
|
|
// if(jig.DoIt()==RTNORM) {
|
|
//
|
|
// ((TDbEntity *)pDim)->setLayer(LAY_PIPE_DIM);
|
|
// ((TDbEntity *)pDim)->AddToCSpace(Adesk::kTrue);
|
|
// entLast.GetLast();
|
|
//
|
|
// OPENOBJ_BEGIN(entLast, AcDb::kForWrite, TDbEntity, pEnt)
|
|
// if(pEnt){
|
|
// pEnt->setLayer(csDimLay);
|
|
// }
|
|
// OPENOBJ_END()
|
|
//
|
|
// }
|
|
// else {
|
|
// delete pDim;
|
|
// return;
|
|
// }
|
|
jig.SetPrompt(_T("\n请给出标注点[左右翻转(F)]<退出>:"));
|
|
jig.SetKeyword(_T("F"));
|
|
int nKeyIndex;
|
|
while(true)
|
|
{
|
|
int nRet = jig.DoIt(&nKeyIndex);
|
|
if (nRet == RTKWORD)
|
|
{
|
|
pDim->SetTextBaseLen(-pDim->GetTextBaseLen());
|
|
}
|
|
else if(nRet == RTNORM)
|
|
{
|
|
((TDbEntity *)pDim)->setLayer(LAY_PIPE_DIM);
|
|
((TDbEntity *)pDim)->AddToCSpace(Adesk::kTrue);
|
|
entLast.GetLast();
|
|
|
|
OPENOBJ_BEGIN(entLast, AcDb::kForWrite, TDbEntity, pEnt)
|
|
if(pEnt)
|
|
{
|
|
pEnt->setLayer(csDimLay);
|
|
}
|
|
OPENOBJ_END()
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
delete pDim;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDimSinglePipeRadiusDlg dialog
|
|
|
|
IMPLEMENT_DYNAMIC(CDimSinglePipeRadiusDlg, CModelessDialog)
|
|
int CDimSinglePipeRadiusDlg::m_iRet = 0;
|
|
int CDimSinglePipeRadiusDlg::m_iRadius = 20;
|
|
CString CDimSinglePipeRadiusDlg::m_csType = _T("DN");
|
|
CString CDimSinglePipeRadiusDlg::m_strWndEdtPos = _T("左上"); // cet 2011.4.27 add
|
|
CDimSinglePipeRadiusDlg::CDimSinglePipeRadiusDlg(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CDimSinglePipeRadiusDlg::IDD, pParent), m_spinHeight(0.5)
|
|
{
|
|
//{{AFX_DATA_INIT(CDimSinglePipeRadiusDlg)
|
|
m_bAuto = FALSE;
|
|
m_nHeight = g_nPipeDnHeight;
|
|
//}}AFX_DATA_INIT
|
|
m_pMenuPos = NULL; // cet 2011.5.26 add
|
|
}
|
|
|
|
CDimSinglePipeRadiusDlg::~CDimSinglePipeRadiusDlg()
|
|
{
|
|
|
|
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 CDimSinglePipeRadiusDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDimSinglePipeRadiusDlg)
|
|
DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType);
|
|
DDX_Control(pDX, IDC_LIST_DN, m_listDn);
|
|
DDX_Control(pDX, IDC_SPIN_TEXT, m_spinHeight);
|
|
DDX_Check(pDX, IDC_CHECK_AUTO, m_bAuto);
|
|
DDX_Text(pDX, IDC_EDIT_TEXT_HEIGHT, m_nHeight);
|
|
DDX_CBString(pDX, IDC_COMBO_TYPE, m_csType);
|
|
DDX_Text(pDX, IDC_EDIT_RADIUS, m_iRadius);
|
|
DDX_Text(pDX, IDC_EDIT_POS, m_strWndEdtPos);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDimSinglePipeRadiusDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CDimSinglePipeRadiusDlg)
|
|
ON_LBN_SELCHANGE(IDC_LIST_DN, OnSelchangeListDn)
|
|
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
|
ON_WM_PAINT()
|
|
ON_WM_CLOSE()
|
|
ON_WM_LBUTTONUP()
|
|
ON_BN_CLICKED(IDC_BUTTON_TYPE, OnButtonType)
|
|
ON_BN_CLICKED(IDC_CHECK_AUTO, OnCheckAuto)
|
|
ON_BN_CLICKED(IDC_BUTTON_POS, OnButtonPos)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDimSinglePipeRadiusDlg message handlers
|
|
|
|
BOOL CDimSinglePipeRadiusDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
|
|
m_spinHeight.SetRange(1, 10);
|
|
LoadHisText();
|
|
for(int i=0;i<m_lstDim.Length();i++){
|
|
CString csDn = m_lstDim[i];
|
|
m_listDn.AddString(csDn);
|
|
}
|
|
int len = m_comboType.GetCount();
|
|
for(i=0;i<len;i++)
|
|
{
|
|
CString csTmp;
|
|
m_comboType.GetLBText(i, csTmp);
|
|
if(csTmp == m_csType)
|
|
{
|
|
m_comboType.SetCurSel(i);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::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);
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnSelchangeListDn()
|
|
{
|
|
UpdateData();
|
|
int idx = m_listDn.GetCurSel();
|
|
if(idx < 0)
|
|
return;
|
|
CString csDn;
|
|
m_listDn.GetText(idx, csDn);
|
|
SplitDnDim(csDn, m_csType, m_iRadius);
|
|
UpdateData(FALSE);
|
|
SetSelDNString(); // zxl 2011.8.25 add 由于combox无法区分大小写,需单独设置管径选择项
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnButtonDel()
|
|
{
|
|
UpdateData();
|
|
int idx = m_listDn.GetCurSel();
|
|
if(idx < 0)
|
|
return;
|
|
CString csDn;
|
|
m_listDn.GetText(idx, csDn);
|
|
int i = m_lstDim.Index(csDn);
|
|
if(i > -1)
|
|
m_lstDim.Remove(i);
|
|
m_listDn.DeleteString(idx);
|
|
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnPaint()
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
CWnd *pImageBox1 = GetDlgItem(IDC_PREVIEW1);
|
|
CWnd *pImageBox2 = GetDlgItem(IDC_PREVIEW2);
|
|
CWnd *pImageBox3 = GetDlgItem(IDC_PREVIEW3);
|
|
CWnd *pImageBox4 = GetDlgItem(IDC_PREVIEW4);
|
|
|
|
CImageDC img1;
|
|
CDC *pDC1 = pImageBox1->GetDC();
|
|
CRect rc1;
|
|
pImageBox1->GetClientRect(&rc1);
|
|
if(m_iRet == 0)
|
|
img1.InitDC(pDC1, rc1, RGB(255, 255, 255));
|
|
else
|
|
img1.InitDC(pDC1, rc1, GetAcadBackColor());
|
|
img1.PaintSlide(_T("TWT(DN1)"));
|
|
img1.SetDC(NULL);
|
|
pImageBox1->ReleaseDC(pDC1);
|
|
|
|
|
|
CImageDC img2;
|
|
CDC *pDC2 = pImageBox2->GetDC();
|
|
CRect rc2;
|
|
pImageBox2->GetClientRect(&rc2);
|
|
if(m_iRet == 1)
|
|
img2.InitDC(pDC2, rc2, RGB(255, 255, 255));
|
|
else
|
|
img2.InitDC(pDC2, rc2, GetAcadBackColor());
|
|
img2.PaintSlide(_T("TWT(DN2)"));
|
|
img2.SetDC(NULL);
|
|
pImageBox2->ReleaseDC(pDC2);
|
|
|
|
|
|
CImageDC img3;
|
|
CDC *pDC3 = pImageBox3->GetDC();
|
|
CRect rc3;
|
|
pImageBox3->GetClientRect(&rc3);
|
|
if(m_iRet == 2)
|
|
img3.InitDC(pDC3, rc3, RGB(255, 255, 255));
|
|
else
|
|
img3.InitDC(pDC3, rc3, GetAcadBackColor());
|
|
img3.PaintSlide(_T("TWT(DN3)"));
|
|
img3.SetDC(NULL);
|
|
pImageBox3->ReleaseDC(pDC3);
|
|
|
|
CImageDC img4;
|
|
CDC *pDC4 = pImageBox4->GetDC();
|
|
CRect rc4;
|
|
pImageBox4->GetClientRect(&rc4);
|
|
if(m_iRet == 3)
|
|
img4.InitDC(pDC4, rc4, RGB(255, 255, 255));
|
|
else
|
|
img4.InitDC(pDC4, rc4, GetAcadBackColor());
|
|
img4.PaintSlide(_T("TWT(DN4)"));
|
|
img4.SetDC(NULL);
|
|
pImageBox4->ReleaseDC(pDC4);
|
|
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnClose()
|
|
{
|
|
CModelessDialog::OnClose();
|
|
acedPostCommand(_T("\33\33"));
|
|
}
|
|
|
|
int CDimSinglePipeRadiusDlg::GetIndex(CPoint & pt)
|
|
{
|
|
CRect rc1,rc2,rc3,rc4;
|
|
CPoint point = pt;
|
|
ClientToScreen(&point);
|
|
CWnd *pImageBox1 = GetDlgItem(IDC_PREVIEW1);
|
|
CWnd *pImageBox2 = GetDlgItem(IDC_PREVIEW2);
|
|
CWnd *pImageBox3 = GetDlgItem(IDC_PREVIEW3);
|
|
CWnd *pImageBox4 = GetDlgItem(IDC_PREVIEW4);
|
|
pImageBox1->GetWindowRect(&rc1);
|
|
pImageBox2->GetWindowRect(&rc2);
|
|
pImageBox3->GetWindowRect(&rc3);
|
|
pImageBox4->GetWindowRect(&rc4);
|
|
if (rc1.PtInRect(point))
|
|
return 0;
|
|
if (rc2.PtInRect(point))
|
|
return 1;
|
|
if (rc3.PtInRect(point))
|
|
return 2;
|
|
if (rc4.PtInRect(point))
|
|
return 3;
|
|
return -1;
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnLButtonUp(UINT nFlags, CPoint point)
|
|
{
|
|
int idx = GetIndex(point);
|
|
if(idx > -1){
|
|
m_iRet = idx;
|
|
PostCommand(_T("R "), false);
|
|
}
|
|
Invalidate(TRUE);
|
|
UpdateWindow();
|
|
CModelessDialog::OnLButtonUp(nFlags, point);
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnButtonType()
|
|
{
|
|
RBList rbCmd=ads_buildlist(RTSTR, _T("ISetPipeMatDnType"), NULL);
|
|
resbuf *rbRes=NULL;
|
|
if(ads_invoke(rbCmd, &rbRes)==RTNORM && rbRes)
|
|
{
|
|
ads_relrb(rbRes);
|
|
}
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::OnCheckAuto()
|
|
{
|
|
UpdateData(TRUE);
|
|
CWnd *pWnd1 = GetDlgItem(IDC_COMBO_TYPE);
|
|
CWnd *pWnd2 = GetDlgItem(IDC_EDIT_RADIUS);
|
|
if(m_bAuto){
|
|
pWnd1->EnableWindow(FALSE);
|
|
pWnd2->EnableWindow(FALSE);
|
|
m_iRadius = -1;
|
|
m_csType = "自动";
|
|
}
|
|
else{
|
|
pWnd1->EnableWindow(TRUE);
|
|
pWnd2->EnableWindow(TRUE);
|
|
m_iRadius = 25;
|
|
m_csType = "DN";
|
|
}
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
const UINT MenuID = 9500;
|
|
void CDimSinglePipeRadiusDlg::OnButtonPos()
|
|
{
|
|
CWnd *pWnd = GetDlgItem(IDC_BUTTON_POS);
|
|
CRect rc;
|
|
pWnd->GetWindowRect(rc);
|
|
|
|
if(m_pMenuPos != NULL)
|
|
{
|
|
m_pMenuPos->DestroyMenu();
|
|
m_pMenuPos->CreatePopupMenu();
|
|
} else
|
|
{
|
|
m_pMenuPos = new CMenu;
|
|
m_pMenuPos->CreatePopupMenu();
|
|
}
|
|
|
|
m_pMenuPos->AppendMenu(m_strWndEdtPos.CompareNoCase(_T("屏幕拾取")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 1, _T("屏幕拾取"));
|
|
m_pMenuPos->AppendMenu(m_strWndEdtPos.CompareNoCase(_T("左上")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 2, _T("左上"));
|
|
m_pMenuPos->AppendMenu(m_strWndEdtPos.CompareNoCase(_T("右下")) == 0 ? MF_CHECKED : MF_UNCHECKED, MenuID + 3, _T("右下"));
|
|
m_pMenuPos->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
|
|
rc.left, rc.bottom, this, &rc);
|
|
|
|
}
|
|
|
|
BOOL CDimSinglePipeRadiusDlg::OnCommand(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
if (m_pMenuPos != NULL)
|
|
{
|
|
CString strCmd;
|
|
m_pMenuPos->GetMenuString(wParam, strCmd, MF_BYCOMMAND);
|
|
|
|
if (!strCmd.IsEmpty())
|
|
{
|
|
m_strWndEdtPos = strCmd;
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
|
|
return CModelessDialog::OnCommand(wParam, lParam);
|
|
}
|
|
|
|
void CDimSinglePipeRadiusDlg::SetSelDNString()
|
|
{
|
|
CString strText;
|
|
for (int iComType = 0; iComType < m_comboType.GetCount(); iComType++)
|
|
{
|
|
m_comboType.GetLBText(iComType,strText);
|
|
if (strText == m_csType)
|
|
{
|
|
m_comboType.SetCurSel(iComType);
|
|
break;
|
|
}
|
|
}
|
|
} |