8872 lines
233 KiB
C++
8872 lines
233 KiB
C++
#include "stdafx.h"
|
||
#include "acgiutil.h"
|
||
#include "dbcfilrs.h"
|
||
#include "TDbColumn.h"
|
||
#include "actrans.h"
|
||
#include "FindParser.h"
|
||
#include "ParallelDimStyle.h"
|
||
#include "ArcRadDimStyle.h"
|
||
//add by lxb on 2011/11/22
|
||
#include "AcEdInputPointMonitorEx.h"
|
||
|
||
// add by xly on 100928 增减递增文字接口是需要用到
|
||
#include "xtext.h"
|
||
#include "InsTextDlg.h"
|
||
|
||
//extern GEOAPI int XGetCorner(const XPoint &ptCorn1, const TCHAR *pszMsg, XPoint &ptCorn2);
|
||
|
||
// add by xly On 110107 引入设置实体的图层并将实体添加到图纸中
|
||
extern AcDbObjectId AddToSpace(Adesk::Boolean bClosed, TDbEntity *pEntSymb);
|
||
//
|
||
//wlw add 130529 作为两点标注时门窗的高亮使用
|
||
static TEntitySet entShow;
|
||
static CString entFilter = _T("");
|
||
|
||
namespace
|
||
{
|
||
BOOL GetEntFromPt(const AcGePoint3d& pt, LPCTSTR sDxfName, TEntitySet& ent)
|
||
{
|
||
TRBList tgMask(RTDXF0, sDxfName, NULL);
|
||
TPickEntSet ssEnts(SS_FREE);
|
||
TADSGePoint3d pt1, pt2;
|
||
pt1[X] = pt.x;
|
||
pt1[Y] = pt.y;
|
||
pt1[Z] = pt.z;
|
||
pt1 = Wcs2Ucs(pt1);
|
||
pt2 = pt1;
|
||
//得到拾取框大小
|
||
double dAperture = 50.0;//GetPickBoxWcs();
|
||
pt1[X] -= dAperture;
|
||
pt1[Y] += dAperture;
|
||
pt2[X] += dAperture;
|
||
pt2[Y] -= dAperture;
|
||
AcDbObjectId id = AcDbObjectId::kNull;
|
||
if (ssEnts.Get(_T("C"), pt1, pt2, tgMask) == RTNORM)
|
||
{
|
||
ent = ssEnts[0L];
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
}
|
||
}
|
||
//TUTIL_IMPEXP void SetHandCursorSelectType(LPCTSTR pszType);
|
||
//TUTIL_IMPEXP void SetHandCursorSelectEntity(TEntitySet & ent);
|
||
//TUTIL_IMPEXP BOOL MouseMoveMonitorByHandCursor(MSG* msg) ;
|
||
//TUTIL_IMPEXP void StartChangeCursor();
|
||
//TUTIL_IMPEXP void EndChangeCursor();
|
||
|
||
int GetFullOsMode(int nFlagsAdd)
|
||
{
|
||
int nOsMode=0;
|
||
xg_getvar(_T("OSMODE"), &nOsMode);
|
||
nOsMode &= ~0x4000;
|
||
nOsMode |= nFlagsAdd;
|
||
return nOsMode;
|
||
}
|
||
|
||
//数据结构,辅助计算角度标注起点和终点
|
||
typedef struct CptData
|
||
{
|
||
AcGePoint2d ptCenter;
|
||
|
||
AcGePoint2d ptTem;
|
||
}PTDATA,*pPTDATA;
|
||
|
||
|
||
//双层JIG通用
|
||
class TMulDimEntity : public AcDbEntity
|
||
{
|
||
public:
|
||
TMulDimEntity() {}
|
||
virtual ~TMulDimEntity() {}
|
||
|
||
TDbDimension2 *m_pDrawEnt; //临时实体,
|
||
TDbDimension2 *m_pDrawEntAll; //临时实体,
|
||
int m_iFlag;
|
||
virtual Adesk::Boolean subWorldDraw(AcGiWorldDraw* mode)
|
||
{
|
||
assertReadEnabled();
|
||
TGGiWorldViewportDraw dc(mode, NULL);
|
||
|
||
m_pDrawEnt->ExplodeOrDraw2d(dc);
|
||
if (m_iFlag == 2 && m_pDrawEntAll != NULL)
|
||
{
|
||
m_pDrawEntAll->ExplodeOrDraw2d(dc);
|
||
}
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
};
|
||
|
||
//双层JIG通用
|
||
class TMulDimEntity1 : public AcDbEntity
|
||
{
|
||
public:
|
||
TMulDimEntity1() {}
|
||
virtual ~TMulDimEntity1() {}
|
||
|
||
TDbDimension2 *m_pDrawEnt; //临时实体,
|
||
TDbDimension2 *m_pDrawEnt2; //临时实体,
|
||
virtual Adesk::Boolean subWorldDraw(AcGiWorldDraw* mode)
|
||
{
|
||
assertReadEnabled();
|
||
TGGiWorldViewportDraw dc(mode, NULL);
|
||
|
||
m_pDrawEnt->ExplodeOrDraw2d(dc);
|
||
m_pDrawEnt2->ExplodeOrDraw2d(dc);
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
};
|
||
|
||
//双层标注动态效果类 add by wlw on 2012/12/12
|
||
class TDimDoubleJig:public AcEdJig
|
||
{
|
||
public:
|
||
TDimDoubleJig(TDbDimension2 * pdim, TDbDimension2 * pdim2)
|
||
{
|
||
m_pDim.m_pDrawEnt = pdim;
|
||
m_pDim.m_pDrawEnt2 = pdim2;
|
||
}
|
||
~TDimDoubleJig() {}
|
||
AcEdJig::DragStatus doIt();
|
||
virtual AcEdJig::DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
|
||
public:
|
||
AcGePoint3d m_ptDim;
|
||
TMulDimEntity1 m_pDim;//标注
|
||
};
|
||
|
||
AcEdJig::DragStatus TDimDoubleJig::doIt()
|
||
{
|
||
return drag();
|
||
}
|
||
AcEdJig::DragStatus TDimDoubleJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates|
|
||
AcEdJig::kNullResponseAccepted));
|
||
|
||
TADSGePoint3d ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptDim) > _DIST_SNAP)
|
||
m_ptDim = ptCursor;
|
||
else
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean TDimDoubleJig::update()
|
||
{
|
||
XPoint ptOnSeg;
|
||
TGGeCurveSegment seg;
|
||
seg = m_pDim.m_pDrawEnt->GetDimCurve();
|
||
if(seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = ptOnSeg.Distance2d(m_ptDim);
|
||
int nSideLoc = seg.OnWhichSide(m_pDim.m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptDim);
|
||
double nDist2Dim = m_pDim.m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
double nFactor = nDist2Dim/fabs(nDist2Dim);
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
if(nSide != nSideLoc)
|
||
{
|
||
nDistMove *= nFactor;
|
||
}
|
||
else
|
||
{
|
||
nDistMove *= -nFactor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
nDistMove *= -1;
|
||
}
|
||
nDist2Dim += nDistMove;
|
||
m_pDim.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
if(nDist2Dim >= 0)
|
||
nDist2Dim -= 1000;
|
||
else
|
||
nDist2Dim += 1000;
|
||
m_pDim.m_pDrawEnt2->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
}
|
||
return Adesk::kTrue;
|
||
}
|
||
AcDbEntity* TDimDoubleJig::entity() const
|
||
{
|
||
return (AcDbEntity*)&m_pDim;
|
||
}
|
||
|
||
//角度标注动态效果类 add by lxb on 2011/11/24
|
||
class TDimAngleJig:public AcEdJig
|
||
{
|
||
public:
|
||
TDimAngleJig(TDbDimension2 *pDim,
|
||
AcGeLine2d &line1, AcGeLine2d &line2, XPoint &pt,
|
||
TCHAR *pszPrompt, TCHAR *pszKeyword=NULL);
|
||
|
||
~TDimAngleJig();
|
||
AcEdJig::DragStatus doIt();
|
||
|
||
protected:
|
||
virtual AcEdJig::DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
|
||
static int QsortFun(const void *p1,const void *p2);//交点排序函数
|
||
|
||
private:
|
||
TDbDimension2 *m_pDim;//标注
|
||
|
||
TCHAR *m_pszPrompt; //提示语
|
||
TCHAR *m_pszKeyword; //关键字
|
||
AcGePoint3d m_ptLast; //记录鼠标上次位置
|
||
AcGePoint3d m_ptCur; //记录鼠标当前位置
|
||
AcGeLine2d m_line1; //成角直线1
|
||
AcGeLine2d m_line2; //成角直线2
|
||
XPoint m_ptCen; //成角顶点
|
||
|
||
};
|
||
|
||
TDimAngleJig::TDimAngleJig(TDbDimension2 *pDim,
|
||
AcGeLine2d &line1, AcGeLine2d &line2, XPoint &pt ,
|
||
TCHAR *pszPrompt, TCHAR *pszKeyword):
|
||
m_pDim(pDim),
|
||
m_line1(line1),m_line2(line2),m_ptCen(pt),
|
||
m_pszPrompt(pszPrompt),m_pszKeyword(pszKeyword)
|
||
{
|
||
}
|
||
|
||
TDimAngleJig::~TDimAngleJig()
|
||
{
|
||
}
|
||
|
||
AcEdJig::DragStatus TDimAngleJig::doIt()
|
||
{
|
||
setDispPrompt(m_pszPrompt);
|
||
AcEdJig::DragStatus status =AcEdJig::kNull;
|
||
try
|
||
{
|
||
status = drag();
|
||
}
|
||
catch(...)
|
||
{
|
||
status = AcEdJig::kCancel;
|
||
}
|
||
return status;
|
||
}
|
||
|
||
AcEdJig::DragStatus TDimAngleJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)(AcEdJig::kAccept3dCoordinates|
|
||
AcEdJig::kNullResponseAccepted));
|
||
|
||
AcEdJig::DragStatus status =AcEdJig::kCancel;
|
||
|
||
status = acquirePoint(m_ptCur);
|
||
|
||
if (status == AcEdJig::kNormal)
|
||
{
|
||
if (m_ptCur.isEqualTo(m_ptLast))
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
m_ptLast = m_ptCur;
|
||
|
||
return status;
|
||
}
|
||
|
||
int TDimAngleJig::QsortFun(const void *p1,const void *p2)
|
||
{
|
||
double dangle1 = ads_angle(asDblArray(((pPTDATA)p1)->ptCenter),asDblArray(((pPTDATA)p1)->ptTem));
|
||
double dangle2 = ads_angle(asDblArray(((pPTDATA)p2)->ptCenter),asDblArray(((pPTDATA)p2)->ptTem)) ;
|
||
return( dangle1 > dangle2);
|
||
}
|
||
|
||
Adesk::Boolean TDimAngleJig::update()
|
||
{
|
||
double dRadiu = m_ptCen.Distance(m_ptCur);
|
||
if (dRadiu < 5.0)
|
||
{
|
||
return Adesk::kFalse;
|
||
}
|
||
|
||
//构造圆
|
||
AcGeCircArc2d circle(m_ptCen,dRadiu);
|
||
|
||
//求圆与直线交点
|
||
int iCount = 0;
|
||
AcGePoint2d pt[4];
|
||
circle.intersectWith(m_line1,iCount,pt[0],pt[1]);
|
||
circle.intersectWith(m_line2,iCount,pt[2],pt[3]);
|
||
|
||
//点队列
|
||
CArray<PTDATA,PTDATA> arr;
|
||
for (int i=0;i<4;i++)
|
||
{
|
||
PTDATA temp;
|
||
temp.ptCenter = m_ptCen;
|
||
temp.ptTem = pt[i];
|
||
arr.Add(temp);
|
||
}
|
||
|
||
PTDATA temp;
|
||
temp.ptCenter = m_ptCen;
|
||
temp.ptTem = AcGePoint2d(m_ptCur.x,m_ptCur.y);
|
||
arr.Add(temp);
|
||
|
||
//队列排序(升序)
|
||
qsort(&arr[0],arr.GetSize(),sizeof(PTDATA&),QsortFun);
|
||
|
||
//取标注起点和终点
|
||
XPoint qt1(arr[0].ptTem),qt2(arr[1].ptTem);
|
||
|
||
int iPos = 1;
|
||
for (int j=0;j<arr.GetSize();j++)
|
||
{
|
||
if (arr[j].ptTem.isEqualTo(AcGePoint2d(m_ptCur.x,m_ptCur.y)))
|
||
{
|
||
iPos = j;
|
||
break;
|
||
}
|
||
}
|
||
if (iPos == arr.GetSize()-1)
|
||
{
|
||
qt1 = arr[iPos-1].ptTem;
|
||
qt2 = arr[0].ptTem;
|
||
}
|
||
else if (iPos == 0)
|
||
{
|
||
qt1 = arr[arr.GetSize()-1].ptTem;
|
||
qt2 = arr[1].ptTem;
|
||
}
|
||
else
|
||
{
|
||
qt1 = arr[iPos-1].ptTem;
|
||
qt2 = arr[iPos+1].ptTem;
|
||
}
|
||
|
||
//初始化
|
||
m_pDim->RemoveSegment(m_pDim->GetSegmentNum()-1);
|
||
|
||
//更新标注属性
|
||
XPoint ptLoc;
|
||
ads_polar(qt1, ads_angle(m_ptCen, qt1),
|
||
2.0*DocGetPScale(),
|
||
ptLoc);
|
||
m_pDim->SetLocation(ptLoc);
|
||
m_pDim->SetDimRadius(m_ptCen.Distance2d(qt1));
|
||
m_pDim->SetRotation(CT_std_angle(ads_angle(m_ptCen, qt1)+PI/2));
|
||
m_pDim->SetObjRadius(m_ptCen.Distance2d(qt1)+2.0*DocGetPScale());
|
||
|
||
XArc ar(m_ptCen, m_ptCen.Distance2d(qt1),
|
||
ads_angle(m_ptCen, qt1),
|
||
ads_angle(m_ptCen, qt2));
|
||
|
||
if(m_pDim->IsValidSegment(ar.GetLength()))
|
||
{
|
||
m_pDim->AppendSegment(ar.GetLength());
|
||
}
|
||
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity * TDimAngleJig::entity() const
|
||
{
|
||
return(m_pDim);
|
||
}
|
||
|
||
// 拖曳显示点
|
||
class TDimensionEdJig : public AcEdJig
|
||
{
|
||
public:
|
||
TDimensionEdJig(TDbDimension2 *pDim, const TCHAR *pszPrompt, const TCHAR *pszKeyword=NULL);
|
||
~TDimensionEdJig();
|
||
int doIt();
|
||
virtual DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
void Swap();
|
||
|
||
int GetRetCode(int *kwordId=NULL) const;
|
||
int m_nRetCode; //返回码
|
||
const TCHAR *m_pszPrompt; //提示信息
|
||
const TCHAR *m_pszKeyword; //关键字
|
||
TDbDimension2 *m_pDrawEnt; //临时实体,
|
||
TDbDimension2 *m_pTemp; //临时实体, 用于m_nFlag==3
|
||
|
||
TGGeArc m_ObjarDim;// 被标注对象
|
||
BOOL m_bKeyword;//是否按下关键字,玄长标注用
|
||
|
||
XPoint m_ptDim;
|
||
int m_nFlag; //0--尺寸方向, 1--尺寸线位置, 2--第二个标注点, 3--其它标注点
|
||
|
||
//add by whl on 03/08/08
|
||
DListStack<XPoint> ptStack;//标注点栈
|
||
void Step();//当前点入栈
|
||
void Undo();//撤消
|
||
XPoint GetLastPoint();
|
||
bool CanUndo();//是否可撤消
|
||
//add by lgy 20120315 设置弧长标注标记
|
||
void SetIsArcDim();
|
||
|
||
BOOL m_bInView; //add by lgy 20120503 保存标注是否是在视口中绘制
|
||
int m_nPortNum; //视口编号
|
||
TPickEntSet m_entSet;//add by lgy 20120507 保存所有视口对象
|
||
AcDbObjectId m_idDimNew;//新标注样式ID
|
||
AcDbObjectId m_idDimOld;//老标注样式ID
|
||
BOOL m_bSaveStyle; //保存是不是设置新样式
|
||
protected:
|
||
void FindAndRemoveSeg(XPoint pt);//由一标注点找出对应段并且正确去除之
|
||
|
||
private:
|
||
//add by lxb on 2011/11/22
|
||
AcEdInputPointMonitorEx m_cMonitor;//监视器
|
||
bool m_bIsArcDim; //add by lgy 20120315 弧长标注标记
|
||
};
|
||
|
||
|
||
//add by lgy 20120509 判断点在不在实体上
|
||
//pt:模型空间中的点
|
||
//返回值:如果pt在当前图纸中的莫个实体上,返回TRUE,否则返回FALSE
|
||
BOOL GetIsOnEntity(XPoint pt)
|
||
{
|
||
BOOL bOn = FALSE; //用来保存点是否在实体上
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
AcDbBlockTable *pTable = NULL;
|
||
es = acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTable, AcDb::kForRead);
|
||
if (es != Acad::eOk)
|
||
{
|
||
return bOn;
|
||
}
|
||
|
||
AcDbBlockTableRecord *pBlockTableRecord = NULL;
|
||
es = pTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead);
|
||
if (es != Acad::eOk)
|
||
{
|
||
pTable->close();
|
||
return bOn;
|
||
}
|
||
|
||
AcDbBlockTableRecordIterator *pBlockIterator = NULL;
|
||
if (Acad::eOk == pBlockTableRecord->newIterator(pBlockIterator))
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
for (pBlockIterator->start(); !pBlockIterator->done(); pBlockIterator->step())
|
||
{
|
||
if (Acad::eOk == pBlockIterator->getEntity(pEnt, AcDb::kForRead))
|
||
{
|
||
TPickEntSet entSet(SS_FREE);
|
||
entSet += pEnt->id();
|
||
if (entSet.Length() == 0)
|
||
{
|
||
continue;
|
||
}
|
||
Entity ent = entSet[0L];
|
||
XPoly2D poly(ent);
|
||
|
||
for (int i = 0; i < poly.TotalSegments(); i++)
|
||
{
|
||
TGGeCurveSegment cvSeg;
|
||
poly.Nth(i, cvSeg);
|
||
double dDistance = cvSeg.GetDist2Me(pt);
|
||
if (cvSeg.GetLength() > 0)
|
||
{
|
||
//转换点时由于从图纸空间转换到模型空间中时转换误差较大
|
||
//设置为50的另外一个原因是对象捕捉的距离
|
||
if (fabs(dDistance) < 50)
|
||
{
|
||
bOn = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
/*if (pEnt->isKindOf(TDbCurveEntity::desc())|| pEnt->isKindOf(TDbEntity::desc()))*/
|
||
if (pEnt->isKindOf(TDbOpening::desc()))
|
||
{
|
||
AcDbVoidPtrArray dbArray;
|
||
pEnt->explode(dbArray);
|
||
int n = dbArray.length();
|
||
for (int i = 0; i < dbArray.length(); i++)
|
||
{
|
||
AcDbLine *pLine = AcDbLine::cast((AcDbEntity *)dbArray[i]);
|
||
if (pLine != NULL)
|
||
{
|
||
TGGeCurveSegment seg(pLine->startPoint(), pLine->endPoint(), 0);
|
||
double dDist = fabs(seg.GetDist2Me(pt));
|
||
if (fabs(seg.GetDist2Me(pt))< 100) //上华对象炸开后可能引起的误差值会更大些
|
||
{
|
||
bOn = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
|
||
AcDbBlockTableRecord *pBlock = AcDbBlockTableRecord::cast((AcDbObject*)dbArray[i]);
|
||
if (pBlock != NULL)
|
||
{
|
||
acutPrintf(_T("aa"));
|
||
}
|
||
AcDbArc *pArc = AcDbArc::cast((AcDbEntity*)dbArray[i]);
|
||
if (pArc != NULL)
|
||
{
|
||
XPoint ptCenter = pArc->center();
|
||
XArc arc(ptCenter, pArc->radius(), pArc->startAngle(), pArc->endAngle());
|
||
TGGeCurveSegment segArc;
|
||
segArc = arc;
|
||
double dDist = fabs(segArc.GetDist2Me(pt));
|
||
if (fabs(segArc.GetDist2Me(pt))< 100)
|
||
{
|
||
bOn = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
if (bOn) //点在实体上
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
delete pBlockIterator;
|
||
pBlockIterator = NULL;
|
||
}
|
||
pTable->close();
|
||
pBlockTableRecord->close();
|
||
return bOn;
|
||
}
|
||
|
||
//add by lgy 20120509 以下函数目的是为了获得点在的视口编号和视口比例
|
||
//pt:图纸空间中点取的点
|
||
//dScale:对应视口的比例
|
||
//entSet:当前图纸所有视口对象
|
||
//返回值:视口编号 如果为0表示没有点中视口
|
||
int GetPtOnWhichPort(XPoint pt, double &dScale,BOOL &bOnEnt, TPickEntSet entSet)
|
||
{
|
||
for(long i = 0; i < entSet.Length(); i++)
|
||
{
|
||
Entity ent = entSet[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbViewport, pViewPort);
|
||
if (pViewPort == NULL)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
double dWidth = pViewPort->width();
|
||
double dHeight = pViewPort->height();
|
||
XPoint ptCenter = pViewPort->centerPoint();
|
||
|
||
XPoly2D poly;
|
||
XRectAngle rect(ptCenter, dWidth, dHeight);
|
||
rect.AsPoly2D(poly);
|
||
poly.SetClosed();
|
||
poly.SetElevation(0.0);
|
||
if ((pt&poly) == PR_INSIDE) //在视口内
|
||
{
|
||
dScale = pViewPort->customScale();
|
||
|
||
XPoint ptPortCenter = pViewPort->viewCenter();
|
||
XPoint ptCenter = pViewPort->centerPoint();
|
||
double dAngle = ads_angle(ptCenter, pt); //点取的点跟视口中心点的角度
|
||
double dDistance = ptCenter.Distance2d(pt);
|
||
XPoint ptView2Mod;
|
||
ads_polar(ptPortCenter, dAngle, dDistance/dScale, ptView2Mod);
|
||
bOnEnt = GetIsOnEntity(ptView2Mod); //判断点是否在实体上
|
||
|
||
return pViewPort->number();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
//add by lgy 20120315 设置弧长标记
|
||
void TDimensionEdJig::SetIsArcDim()
|
||
{
|
||
m_bIsArcDim = true;
|
||
}
|
||
|
||
//add by whl on 03/08/08
|
||
void TDimensionEdJig::FindAndRemoveSeg(XPoint pt)
|
||
{
|
||
TGGeCurveSegment seg=m_pDrawEnt->GetDimCurve();
|
||
XPoint ptOnSeg;
|
||
seg.ProjectToMe(pt, ptOnSeg);
|
||
double value=seg.StartPoint().Distance2d(ptOnSeg);
|
||
long i=-1;
|
||
if(value>_DIST_SNAP)
|
||
{
|
||
double curValue=0;
|
||
for(i=0;i<m_pDrawEnt->GetSegmentNum();i++)
|
||
{
|
||
curValue+=m_pDrawEnt->GetSegment(i);
|
||
if(fabs(curValue-value)<_DIST_SNAP)
|
||
break;
|
||
}
|
||
}
|
||
if(i>=m_pDrawEnt->GetSegmentNum())
|
||
return;//useful
|
||
|
||
if(i>=0)
|
||
{
|
||
double temp=m_pDrawEnt->GetSegment(i);
|
||
if(i<(m_pDrawEnt->GetSegmentNum()-1))//是中间段
|
||
m_pDrawEnt->SetSegment(i+1,temp+m_pDrawEnt->GetSegment(i+1));//后一段合并之
|
||
m_pDrawEnt->RemoveSegment(i);
|
||
}
|
||
else//第一个标注段的起点(不一定是DimContinue中提示的第一点)特殊处理
|
||
{
|
||
double temp=m_pDrawEnt->GetSegment(0);
|
||
m_pDrawEnt->RemoveSegment(0);
|
||
XVector3D vt=seg.EndPoint()-seg.StartPoint();
|
||
vt.Scale(temp/vt.Length());
|
||
m_pDrawEnt->SetLocation(m_pDrawEnt->GetLocation()+vt);
|
||
}
|
||
}
|
||
void TDimensionEdJig::Step()
|
||
{
|
||
ptStack.Push(m_ptDim);
|
||
}
|
||
bool TDimensionEdJig::CanUndo()
|
||
{
|
||
return ptStack.GetDepth()>1;
|
||
}
|
||
void TDimensionEdJig::Undo()
|
||
{
|
||
XPoint pt;
|
||
ptStack.GetTopData(pt);
|
||
ptStack.GoBack();
|
||
if(CanUndo())
|
||
m_pDrawEnt->FindAndRemoveSegment(pt);
|
||
}
|
||
XPoint TDimensionEdJig::GetLastPoint()
|
||
{
|
||
XPoint pt;
|
||
ptStack.GetTopData(pt);
|
||
return pt;
|
||
}
|
||
//end
|
||
|
||
void TDimensionEdJig::Swap()
|
||
{
|
||
if(m_pTemp) {
|
||
AcDbDeepCloneFiler filer;
|
||
if(m_pTemp->dwgOut(&filer)==Acad::eOk) {
|
||
filer.seek(0L,0);
|
||
VERIFY(m_pDrawEnt->dwgIn(&filer)==Acad::eOk);
|
||
}
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
} else {
|
||
m_pTemp = (TDbDimension2 *)m_pDrawEnt->clone();
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
}
|
||
}
|
||
|
||
// 转换成ADS代码
|
||
int TDimensionEdJig::GetRetCode(int *kwordId) const
|
||
{
|
||
int ret = m_nRetCode;
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if(ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else {
|
||
if(kwordId) *kwordId = ret;
|
||
ret = RTKWORD;
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
|
||
TDimensionEdJig::TDimensionEdJig(TDbDimension2 *pDim, const TCHAR *pszPrompt, const TCHAR *pszKeyword)
|
||
:m_pDrawEnt(pDim), m_pszPrompt(pszPrompt), m_pszKeyword(pszKeyword), m_nRetCode(0),m_cMonitor(curDoc())
|
||
{
|
||
m_pTemp=NULL;
|
||
m_nFlag=0;
|
||
m_ptDim=pDim->GetLocation();
|
||
//add by lgy 20120315 弧长标注标记
|
||
m_bIsArcDim = false; //false为不是弧长标注
|
||
|
||
m_bInView = FALSE; //add by lgy 20120503 保存标注是否是在视口中绘制
|
||
m_nPortNum = 0; //add by lgy 20120509 默认视口为0
|
||
m_bSaveStyle = FALSE;//add by lgy 20120519 默认不保存标注样式
|
||
m_bKeyword = FALSE;
|
||
}
|
||
|
||
|
||
TDimensionEdJig::~TDimensionEdJig()
|
||
{
|
||
if(m_pTemp)
|
||
delete m_pTemp;
|
||
}
|
||
|
||
// 开始执行拖动
|
||
int TDimensionEdJig::doIt()
|
||
{
|
||
setDispPrompt(m_pszPrompt);
|
||
try
|
||
{
|
||
if (m_nFlag == 1)
|
||
{
|
||
if (m_pDrawEnt->IsDimChord() && m_pDrawEnt->IsAngular())
|
||
{//玄长jig
|
||
|
||
TGGeCurveSegment seg=m_pDrawEnt->GetDimCurve();
|
||
TADSGePoint3d pt1,pt2,ptc;
|
||
ptc = seg.MidPoint();
|
||
pt1 = seg.GetStartPoint();
|
||
pt2 = seg.GetEndPoint();
|
||
|
||
while(m_pDrawEnt->GetSegmentNum() > 0)
|
||
m_pDrawEnt->RemoveSegment(0);
|
||
|
||
m_pDrawEnt->SetObjRadius(0);
|
||
m_pDrawEnt->SetDimRadius(0);
|
||
|
||
m_pDrawEnt->SetAngular(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
|
||
m_pDrawEnt->AppendSegment(pt1.Distance2d(pt2));
|
||
m_pDrawEnt->AddSegment(pt1);
|
||
|
||
m_pDrawEnt->SetLocation(pt1);
|
||
m_pDrawEnt->SetFixLinePos(pt1);
|
||
TGGeCurveSegment seg1(pt1,pt2,0);
|
||
double nDirection=seg1.Direction(ptc);
|
||
m_pDrawEnt->SetRotation(nDirection);
|
||
}
|
||
}
|
||
m_nRetCode = drag();
|
||
}
|
||
catch(...)
|
||
{
|
||
m_nRetCode=AcEdJig::kCancel;
|
||
}
|
||
return GetRetCode();
|
||
}
|
||
|
||
// 反馈
|
||
AcEdJig::DragStatus TDimensionEdJig::sampler()
|
||
{
|
||
DragStatus stat;
|
||
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates|AcEdJig::kNullResponseAccepted));
|
||
|
||
if (m_pszKeyword) setKeywordList(m_pszKeyword);
|
||
XPoint ptTemp;
|
||
if(m_nFlag==0)
|
||
{
|
||
stat=acquirePoint(ptTemp, m_pDrawEnt->GetLocation().AsAcGePoint3d());
|
||
}
|
||
else if((m_nFlag == 1) || (m_nFlag == 2) || (m_nFlag == 5))
|
||
{
|
||
TADSGePoint3d ptCur;
|
||
GetWcsCursor(ptCur);
|
||
ptCur.z = 0;
|
||
//辅助计算直线wlw mod 20150518 辅助线需要清零z,否则引线会飞
|
||
XPoint pt1(ptStack[0]),pt2(ptStack[1]);
|
||
pt1.z = 0.0;
|
||
pt2.z = 0.0;
|
||
XLine line1(pt1,pt2);
|
||
ads_real rAng = line1.Direction();
|
||
XPoint pt;
|
||
ads_polar(ptCur, rAng + 0.5 * PI, 100.0, pt);
|
||
XLine line2(ptCur, pt);
|
||
|
||
//获取基点
|
||
ads_point ptIntersection;
|
||
line1.Intersection(&line2,ptIntersection);
|
||
AcGePoint3d ptBase = asPnt3d(ptIntersection);
|
||
|
||
if (!m_bIsArcDim)
|
||
{
|
||
stat = acquirePoint(ptTemp,ptBase);
|
||
}
|
||
else
|
||
{
|
||
stat = acquirePoint(ptTemp);
|
||
}
|
||
}
|
||
else if(m_nFlag==3)
|
||
{
|
||
//modidfied by whl on 03/08/08
|
||
XPoint ptLast=GetLastPoint();
|
||
stat=acquirePoint(ptTemp, ptLast);
|
||
}
|
||
else if(m_nFlag==4)
|
||
{
|
||
XPoint ptLast;
|
||
xg_getvar(_T("LASTPOINT"), ptLast);
|
||
ptLast = Ucs2Wcs(ptLast);
|
||
stat=acquirePoint(ptTemp, ptLast);
|
||
}
|
||
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptTemp.Distance2d(m_ptDim)>_DIST_SNAP)
|
||
{
|
||
double nDist=m_ptDim.Distance2d(ptTemp);
|
||
m_ptDim=ptTemp;
|
||
}
|
||
else
|
||
{
|
||
return AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
Adesk::Boolean TDimensionEdJig::update()
|
||
{
|
||
if(m_nFlag==0)
|
||
{
|
||
m_pDrawEnt->SetRotation(ads_angle(m_ptDim, m_pDrawEnt->GetLocation())+PI);
|
||
double nVal=m_ptDim.Distance2d(m_pDrawEnt->GetLocation());
|
||
//modify by lgy 20120503 如果标注在图纸空间中的视口中
|
||
//if(m_pDrawEnt->IsValidSegment(nVal))
|
||
// m_pDrawEnt->SetSegment(0, nVal);
|
||
if(m_pDrawEnt->IsValidSegment(nVal))
|
||
{
|
||
m_pDrawEnt->SetSegment(0, nVal);
|
||
|
||
if (m_bInView)
|
||
{
|
||
double dScale = 1.0;
|
||
BOOL bFit = FALSE;
|
||
int nNum = GetPtOnWhichPort(m_ptDim, dScale, bFit, m_entSet);
|
||
if (nNum == m_nPortNum || !bFit)
|
||
{
|
||
m_pDrawEnt->SetStyleId(m_idDimNew);
|
||
m_bSaveStyle = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_pDrawEnt->SetStyleId(m_idDimOld);
|
||
m_bSaveStyle = FALSE;
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
else if(m_nFlag==1)
|
||
{
|
||
TGGeCurveSegment seg=m_pDrawEnt->GetDimCurve();
|
||
XPoint ptOnSeg;
|
||
if(seg.ProjectToMe(m_ptDim, ptOnSeg)==RTNORM)
|
||
{
|
||
double nDistMove=m_ptDim.Distance2d(ptOnSeg);
|
||
int nSideLoc=seg.OnWhichSide(m_pDrawEnt->GetLocation());
|
||
int nSide=seg.OnWhichSide(m_ptDim);
|
||
double nDist2Dim = m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
double nFactor=nDist2Dim/fabs(nDist2Dim);
|
||
if(nSide!=nSideLoc)
|
||
nDistMove *= nFactor;
|
||
else
|
||
nDistMove *= -nFactor;
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
nDistMove = -nDistMove;
|
||
}
|
||
if(m_pDrawEnt->IsAngular())
|
||
{ //弧墙有错,不知道原因
|
||
nDist2Dim += nDistMove;
|
||
double nDistRad= m_pDrawEnt->GetDimRadius();
|
||
//seg.GetArc().center.Distance(m_ptDim);
|
||
nDistRad -= nDistMove;
|
||
if(nDistRad>_DIST_SNAP)
|
||
{
|
||
m_pDrawEnt->SetDimRadius(nDistRad);
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
nDist2Dim += nDistMove;
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
|
||
}
|
||
}
|
||
else if(m_nFlag==2)
|
||
{ //修改标注位置
|
||
AcDbIntArray indices;
|
||
indices.append(3);
|
||
AcGePoint3dArray ptArray;
|
||
m_pDrawEnt->getStretchPoints(ptArray);
|
||
ASSERT(ptArray.length()>3);
|
||
AcGeVector3d vtOffset=m_ptDim.AsAcGePoint3d()-ptArray[3];
|
||
m_pDrawEnt->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
else if(m_nFlag==3)
|
||
{//modified by whl on 03/08/08
|
||
ASSERT(m_pTemp);
|
||
CopyObject(*m_pDrawEnt, *m_pTemp);
|
||
if(CanUndo())
|
||
{
|
||
if(!m_pTemp->AddSegment(m_ptDim))
|
||
return Adesk::kFalse;
|
||
}
|
||
else
|
||
{
|
||
m_pTemp->SetRotation(ads_angle(m_ptDim, m_pTemp->GetLocation())+PI);
|
||
double nVal=m_ptDim.Distance2d(m_pTemp->GetLocation());
|
||
if(m_pTemp->IsValidSegment(nVal))
|
||
m_pTemp->SetSegment(0, nVal);
|
||
}
|
||
ASSERT(m_pTemp && m_pTemp->IsValid());
|
||
}
|
||
else if(m_nFlag==4)
|
||
{
|
||
ASSERT(m_pTemp);
|
||
CopyObject(*m_pDrawEnt, *m_pTemp);
|
||
m_pTemp->AddSegment(m_ptDim);
|
||
}
|
||
else if(m_nFlag==5)
|
||
{
|
||
double dr = m_pDrawEnt->GetObjRadius();
|
||
TADSGePoint3d pt1,pt2;
|
||
m_ObjarDim.GetStartPoint(pt1);
|
||
m_ObjarDim.GetEndPoint(pt2);
|
||
double dDist2d = m_ptDim.Distance2d(m_ObjarDim.GetCenterPt());
|
||
TGGeCurveSegment ln1(m_ObjarDim.GetCenterPt(), m_ptDim,0), ln2(pt1,pt2,0);
|
||
ln2.SetLineFlag(LS_FINITE);
|
||
ln1.SetLineFlag(LS_FINITE);
|
||
int nptins = ln1.Intersection(ln2,pt1,pt2);
|
||
m_pDrawEnt->SetStyleId(InitDimStyle(DS_ANGLE));
|
||
if (dDist2d < dr)
|
||
{//圆内
|
||
if (nptins > 0)
|
||
{//玄长
|
||
m_pDrawEnt->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(TRUE);
|
||
m_pDrawEnt->SetDist2DimLine(0.0);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius()/*-6*DocGetPScale()*/);
|
||
}
|
||
else
|
||
{//角度
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(10);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius()-10*DocGetPScale());
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (nptins > 0)
|
||
{//弧长
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(TRUE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(-6);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius()+6.0*DocGetPScale());
|
||
}
|
||
else
|
||
{//角度
|
||
m_pDrawEnt->SetAngular(TRUE);
|
||
m_pDrawEnt->SetDimArcLen(FALSE);
|
||
m_pDrawEnt->SetDimChord(FALSE);
|
||
m_pDrawEnt->SetDist2DimLine(10);
|
||
m_pDrawEnt->SetDimRadius(m_ObjarDim.GetRadius()-10*DocGetPScale());
|
||
|
||
}
|
||
}
|
||
}
|
||
ASSERT(m_pDrawEnt && m_pDrawEnt->IsValid());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TDimensionEdJig::entity() const
|
||
{
|
||
if((m_nFlag==3 || m_nFlag==4) && m_pTemp)
|
||
return m_pTemp;
|
||
else
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
|
||
|
||
//排序的点建立在墙体基线
|
||
class XThirdDimData: public TSortedVertexList {
|
||
public:
|
||
double m_nDistToFixPos, //不动点距离墙线的距离
|
||
m_nDistToTextBaseline; //文本线距离墙线的距离
|
||
int m_nOnSide; //标注所在的一侧
|
||
public:
|
||
XThirdDimData(const TGGeCurveSegment &seg);
|
||
void AddPoints(const TDbWall *pWall, BOOL bAddCol = FALSE);
|
||
AcDbObjectId Apply(); //开始标注
|
||
};
|
||
|
||
XThirdDimData::XThirdDimData(const TGGeCurveSegment &seg)
|
||
: XSortedVertexList(seg), m_nDistToFixPos(0.0), m_nDistToTextBaseline(0.0)
|
||
{
|
||
}
|
||
|
||
void XThirdDimData::AddPoints(const TDbWall *pWall, BOOL bAddCol)
|
||
{
|
||
ASSERT(pWall);
|
||
TGGeCurveSegment segWall=*pWall;
|
||
segWall.SetLineFlag(LS_FINITE);
|
||
segWall.SetElevation(0.0);
|
||
if (bAddCol)
|
||
{
|
||
AcDbExtents extents;
|
||
AcGePoint3d ptS,ptE,pt1,pt2,pttmp;
|
||
// 开始端
|
||
AcDbObjectId id = pWall->GetStartColumnId();
|
||
if (id.isValid())
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbColumn, pLeftCol)
|
||
if (pLeftCol->m_polyOutline.Length() > 2)
|
||
{
|
||
pLeftCol->getGeomExtents(extents);
|
||
pt1 = extents.minPoint();
|
||
pt2 = extents.maxPoint();
|
||
|
||
pWall->getClosestPointTo(pt1, ptS, Adesk::kTrue);
|
||
pWall->getClosestPointTo(pt2, ptE, Adesk::kTrue);
|
||
if (ptS.distanceTo(pWall->GetEndPoint().AsAcGePoint3d()) < ptE.distanceTo(pWall->GetEndPoint().AsAcGePoint3d()))
|
||
{
|
||
pttmp = ptS;
|
||
ptS = ptE;
|
||
ptE = pttmp;
|
||
}
|
||
Replace(new TADSGePoint3d(ptE),0);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
// 开始端
|
||
id = pWall->GetEndColumnId();
|
||
if (id.isValid())
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbColumn, pLeftCol)
|
||
if (pLeftCol->m_polyOutline.Length() > 2)
|
||
{
|
||
pLeftCol->getGeomExtents(extents);
|
||
pt1 = extents.minPoint();
|
||
pt2 = extents.maxPoint();
|
||
|
||
pWall->getClosestPointTo(pt1, ptS, Adesk::kTrue);
|
||
pWall->getClosestPointTo(pt2, ptE, Adesk::kTrue);
|
||
|
||
if (ptS.distanceTo(pWall->GetStartPoint().AsAcGePoint3d()) < ptE.distanceTo(pWall->GetStartPoint().AsAcGePoint3d()))
|
||
{
|
||
pttmp = ptS;
|
||
ptS = ptE;
|
||
ptE = pttmp;
|
||
}
|
||
|
||
Replace(new TADSGePoint3d(ptE),Length()-1);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
|
||
RBList axisFence=segWall.AsFence();
|
||
RBList axisMask(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, LAY_AXIS, NULL);
|
||
TPickEntSet ssAxis(SS_FREE);
|
||
if(ssAxis.Get(_T("F"), axisFence, NULL, axisMask)==RTNORM)
|
||
{
|
||
long lCount = ssAxis.Length();
|
||
for(long i=0L; i<lCount; i++)
|
||
{
|
||
Entity entAxis = ssAxis[i];
|
||
TGGeCurveSegment segAxis(entAxis, LS_FINITE);
|
||
segAxis.SetElevation(0.0);
|
||
XPoint ptIntsect[2];
|
||
int nIntNum=segAxis.Intersection(segWall, ptIntsect[0], ptIntsect[1]);
|
||
for(int n=0; n<nIntNum; n++)
|
||
{
|
||
Insert(ptIntsect[n]);
|
||
}
|
||
}
|
||
}
|
||
|
||
//加入门窗的节点
|
||
DList<TOpeningData> lstOpenings;
|
||
pWall->GetOpenings(lstOpenings, FALSE);
|
||
int nOpNum=lstOpenings.Length();
|
||
for(int i=0; i<nOpNum; i++)
|
||
{
|
||
TOpeningData *pWin=lstOpenings[i];
|
||
if(pWin->IsHighLevel())
|
||
{
|
||
lstOpenings.Remove(i);
|
||
nOpNum--;
|
||
}
|
||
}
|
||
pWall->GetOpeningSidePoints(segWall, lstOpenings, FALSE, *this);
|
||
}
|
||
|
||
|
||
//开始标注
|
||
AcDbObjectId XThirdDimData::Apply()
|
||
{
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
XPoly2D poly(0);
|
||
AsPoly2D(poly);
|
||
|
||
TDbDimension2 *pDim=new TDbDimension2;
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
double nSweepAngle=0.0;
|
||
for(int i=0; i<poly.TotalSegments(); i++) {
|
||
TGGeCurveSegment seg;
|
||
poly.Nth(i, seg);
|
||
TGGeCurveSegment segOnFix= seg.Offset(m_nOnSide, m_nDistToFixPos, LS_FINITE);
|
||
TGGeCurveSegment segOnTextBase = seg.Offset(m_nOnSide, m_nDistToTextBaseline, LS_FINITE);
|
||
nSweepAngle += seg.GetBulge();
|
||
if(i==0) {
|
||
pDim->SetLocation(segOnFix.StartPoint());
|
||
pDim->SetRotation(seg.IDirection(0));
|
||
double nDist2DimLine=fabs(m_nDistToTextBaseline-m_nDistToFixPos);
|
||
pDim->SetDist2DimLine(m_nOnSide==OFFSET_LEFT? nDist2DimLine : -nDist2DimLine, FALSE);
|
||
if(seg.Is(CURVE_ARC)) {
|
||
pDim->SetAngular(TRUE);
|
||
pDim->SetObjRadius(seg.GetArc().GetRadius());
|
||
pDim->SetDimRadius(segOnTextBase.GetArc().GetRadius());
|
||
}
|
||
}
|
||
double nVal=segOnTextBase.GetLength();
|
||
if(pDim->IsValidSegment(nVal))
|
||
pDim->AppendSegment(nVal);
|
||
|
||
}
|
||
|
||
|
||
pDim->SetStyleId(InitDimStyle(pDim->IsAngular()? DS_ANGLE : DS_LINEAR));
|
||
if(g_nDimAdjust) pDim->AdjustDim(g_nDimAdjust!=2, FALSE); //不允许侧调
|
||
pDim->RemoveZeroSegment();//add by whl
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//return pDim->AddToMSpace(TRUE);
|
||
return AddToSpace(Adesk::kTrue, (TDbEntity *)pDim);
|
||
}
|
||
|
||
double XYDistance(XPoint pt1,XPoint pt2)
|
||
{
|
||
double XDis=pt1.x-pt2.x;
|
||
double YDis=pt1.y-pt2.y;
|
||
return sqrt(XDis*XDis+YDis*YDis);
|
||
}
|
||
|
||
|
||
// Command: 内门标注
|
||
void DimIndoor()
|
||
{
|
||
static BOOL bOnBase=TRUE;
|
||
XPoint pt1, pt2;
|
||
int nRet;
|
||
LAB_REINPUT:
|
||
adsout << (bOnBase? _T("\n标注方式:轴线定位.") : _T("\n标注方式:垛宽定位.")) << _T(" 请用线选门窗,并且第二点作为尺寸线位置!");
|
||
INITGET_BEG(0, _T("A"));
|
||
nRet=ads_getpoint(NULL,
|
||
(bOnBase? _T("\n起点或 [垛宽定位(A)]<退出>: ") : _T("\n起点或 [轴线定位(A)]<退出>: ") ),
|
||
pt1);
|
||
INITGET_END();
|
||
if(nRet==RTKWORD) {
|
||
bOnBase=!bOnBase;
|
||
goto LAB_REINPUT;
|
||
} else if(nRet==RTNORM) {
|
||
} else {
|
||
return;
|
||
}
|
||
|
||
|
||
if(ads_getpoint(pt1, _T("\n终点<退出>: "), pt2)!=RTNORM)
|
||
return;
|
||
InitLayer(LAY_DIM, TRUE);
|
||
|
||
TPickEntSet ssDim(SS_FREE), ssWall(SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
TPickEntSet ssOpening(SS_FREE);
|
||
RBList opMask(RTDXF0, _T("ATS_OPENING"), NULL);
|
||
if(ssOpening.Get(_T("F"), rbFence, NULL, opMask)!=RTNORM || ssOpening.Length()!=1) {
|
||
adsout << _T("\n没有正确选中一个门窗!");
|
||
return;
|
||
}
|
||
Entity entDoor=ssOpening[0L];
|
||
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
XPoint ptInt;
|
||
XPoint ptSide1, ptSide2;
|
||
XPoint ptOther;
|
||
OPENOBJ_BEGIN(entDoor, AcDb::kForRead, TDbOpening, pDoor);
|
||
ASSERT(pDoor);
|
||
pDoor->GetSidePoints(ptSide1, ptSide2);
|
||
|
||
// modidy by xly on 101014 当门有门槛时,计算交点时,去掉标高
|
||
//if(!XLine(ptSide1, ptSide2, LS_INFINITE).Intersection(&XLine(pt1, pt2, LS_INFINITE), ptInt))
|
||
XLine lnDoor(ptSide1, ptSide2, LS_INFINITE);
|
||
lnDoor.SetElevation(0);
|
||
|
||
XLine ll(pt1, pt2, LS_INFINITE);
|
||
if(!lnDoor.Intersection(&ll, ptInt))
|
||
return;
|
||
OPENOBJ_BEGIN(pDoor->GetWallId(), AcDb::kForRead, TDbWall, pWall);
|
||
if(!pWall)
|
||
return;
|
||
if(bOnBase) {
|
||
XPoint ptNearSide=XLine(ptSide1, ptSide2).NearPoint(ptInt);
|
||
XLine ln(pt1, pt2);
|
||
int nSideFlag=ln.OnWhichSide(ptNearSide);
|
||
int nSide1=ln.OnWhichSide(pWall->StartPoint());
|
||
if(nSide1==nSideFlag) ptOther=pWall->StartPoint();
|
||
else ptOther=pWall->EndPoint();
|
||
} else {
|
||
TGGeCurveSegment lCurve, rCurve;
|
||
pWall->GetSideCurve(lCurve, rCurve);
|
||
int nSide=pWall->OnWhichSide(pt2);
|
||
TGGeCurveSegment segCurve=nSide? rCurve : lCurve;
|
||
|
||
XPoint ptNearSide=XLine(ptSide1, ptSide2).NearPoint(ptInt);
|
||
XLine ln(pt1, pt2);
|
||
int nSideFlag=ln.OnWhichSide(ptNearSide);
|
||
int nSide1=ln.OnWhichSide(segCurve.StartPoint());
|
||
if(nSide1==nSideFlag) ptOther=segCurve.StartPoint();
|
||
else ptOther=segCurve.EndPoint();
|
||
}
|
||
OPENOBJ_END();
|
||
OPENOBJ_END();
|
||
|
||
|
||
// 由 ptSide1, ptSide2, ptOther, pt2(尺寸线位置)确定尺寸标注
|
||
TGGeCurveSegment segDoor(ptSide1, ptSide2, 0.0, LS_FINITE);
|
||
XThirdDimData dim3(segDoor);
|
||
BOOL bThirdOnly=FALSE;
|
||
//XPoint ptFix1, ptTextBase1; //文字位置,引脚位置
|
||
//XPoint ptTextBase2, ptFix2;
|
||
|
||
XPoint ptTextBasePrj1, ptFix1;
|
||
if(segDoor.ProjectToMe(pt2, ptTextBasePrj1)!=RTNORM) {
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
dim3.m_nDistToTextBaseline = XYDistance(pt2,ptTextBasePrj1);
|
||
ads_polar(pt2, ads_angle(pt2, ptTextBasePrj1), 1500.0, ptFix1);
|
||
bThirdOnly=TRUE;
|
||
|
||
XPoint ptFixPrj1;
|
||
if(segDoor.ProjectToMe(ptFix1, ptFixPrj1)!=RTNORM) {
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
|
||
dim3.m_nOnSide = segDoor.OnWhichSide(pt2);
|
||
dim3.m_nDistToFixPos = XYDistance(ptFix1,ptFixPrj1);
|
||
|
||
|
||
AcDbObjectId idMaster=dim3.Apply();
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim) {
|
||
pDim->AddSegment(ptOther);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
|
||
struct EntAng
|
||
{
|
||
Entity ent;
|
||
double angle;
|
||
};
|
||
|
||
void ArrangeEnt(BOOL bIncrease)
|
||
{
|
||
|
||
}
|
||
|
||
// Command: 标注第三道尺寸线
|
||
// 支持尺寸自调
|
||
void DimThird()
|
||
{
|
||
XPoint pt1, pt2;
|
||
adsout << _T("\n请用线选第一、二道尺寸线及墙体!");
|
||
if(ads_getpoint(NULL, _T("\n起点<退出>: "), pt1)!=RTNORM)
|
||
return;
|
||
if(ads_getpoint(pt1, _T("\n终点<退出>: "), pt2)!=RTNORM)
|
||
return;
|
||
|
||
InitLayer(LAY_DIM, TRUE);
|
||
|
||
TPickEntSet ssDim(SS_FREE), ssWall(SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
RBList dimMask(RTDXF0, _T("ATS_DIMENSION2"), NULL),
|
||
wallMask(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL"), NULL);
|
||
Entity entWall;
|
||
{
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
if(ssWall.Get(_T("F"), rbFence, NULL, wallMask)!=RTNORM || ssWall.Length()!=1)
|
||
{
|
||
TPickEntSet ssOpening(SS_FREE);
|
||
RBList opMask(RTDXF0, _T("ATS_OPENING"), NULL);
|
||
if(ssOpening.Get(_T("F"), rbFence, NULL, opMask)!=RTNORM || ssOpening.Length()!=1)
|
||
{
|
||
adsout << _T("\n没有正确选中一段墙!");
|
||
return;
|
||
}
|
||
Entity entOp=ssOpening[0L];
|
||
OPENOBJ_BEGIN(entOp, AcDb::kForRead, TDbOpening, pOpening);
|
||
if(!pOpening) {
|
||
adsout << _T("\n没有正确选中一段墙!");
|
||
return;
|
||
}
|
||
if(acdbGetAdsName(entWall.name, pOpening->GetWallId())!=Acad::eOk)
|
||
{
|
||
adsout << _T("\n没有正确选中一段墙!");
|
||
return;
|
||
}
|
||
OPENOBJ_END();
|
||
} else
|
||
{
|
||
entWall=ssWall[0L];
|
||
}
|
||
}
|
||
|
||
|
||
OPENOBJ_BEGIN(entWall, AcDb::kForRead, TDbWall, pWall);
|
||
TGGeCurveSegment segWall=*pWall;
|
||
segWall.SetLineFlag(LS_FINITE);
|
||
segWall.SetElevation(0.0);
|
||
|
||
XThirdDimData dim3(segWall);
|
||
|
||
BOOL bThirdOnly=FALSE;
|
||
XPoint ptFix1, ptTextBase1; //文字位置,引脚位置
|
||
XPoint ptTextBase2, ptFix2;
|
||
if(ssDim.Get(_T("F"), rbFence, NULL, dimMask)!=RTNORM || ssDim.Length()!=2)
|
||
{
|
||
//if(ads_getpoint(NULL, _T("\n尺寸线位置: "), ptTextBase1)!=RTNORM)
|
||
// return;
|
||
//ptTextBase1=Ucs2Wcs(ptTextBase1);
|
||
ptTextBase1=Ucs2Wcs(pt2); //取第二点作为标注位置
|
||
XPoint ptTextBasePrj1;
|
||
if(pWall->ProjectToMe(ptTextBase1, ptTextBasePrj1)!=RTNORM)
|
||
{
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
dim3.m_nDistToTextBaseline = XYDistance(ptTextBase1,ptTextBasePrj1);
|
||
|
||
//modified by whl on 060724
|
||
//ads_polar(ptTextBase1, ads_angle(ptTextBase1, ptTextBasePrj1), 1500.0, ptFix1);
|
||
ads_polar(ptTextBase1, ads_angle(ptTextBase1, ptTextBasePrj1), 15.0*DocGetPScale(), ptFix1);
|
||
|
||
bThirdOnly=TRUE;
|
||
} else {
|
||
Entity ent1=ssDim[0L], ent2=ssDim[1L];
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, TDbDimension2, pDim1);
|
||
if(!pDim1)
|
||
return;
|
||
ptFix1=pDim1->GetLocation();
|
||
ptTextBase1=pDim1->GetDimCurve().MidPoint();
|
||
OPENOBJ_END();
|
||
OPENOBJ_BEGIN(ent2, AcDb::kForRead, TDbDimension2, pDim2);
|
||
if(!pDim2)
|
||
return;
|
||
ptFix2=pDim2->GetLocation();
|
||
ptTextBase2=pDim2->GetDimCurve().MidPoint();
|
||
OPENOBJ_END();
|
||
|
||
XPoint ptTextBasePrj1, ptTextBasePrj2;
|
||
if(pWall->ProjectToMe(ptTextBase1, ptTextBasePrj1)!=RTNORM ||
|
||
pWall->ProjectToMe(ptTextBase2, ptTextBasePrj2)!=RTNORM) {
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
|
||
double nDist1 = XYDistance(ptTextBase1,ptTextBasePrj1);
|
||
double nDist2 = XYDistance(ptTextBase2,ptTextBasePrj2);
|
||
dim3.m_nDistToTextBaseline = min(nDist1, nDist2) - fabs(nDist1-nDist2);
|
||
if(dim3.m_nDistToTextBaseline<0) {
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
}
|
||
XPoint ptFixPrj1;
|
||
if(pWall->ProjectToMe(ptFix1, ptFixPrj1)!=RTNORM) {
|
||
adsout << _T("\n无效的选择!");
|
||
return;
|
||
}
|
||
|
||
dim3.m_nOnSide = segWall.OnWhichSide(ptTextBase1);
|
||
dim3.m_nDistToFixPos = XYDistance(ptFix1,ptFixPrj1);
|
||
|
||
dim3.AddPoints(pWall);//WLW 2013.10.12 不计算墙两端的柱子
|
||
AcDbObjectId idMaster=dim3.Apply();
|
||
if(!idMaster)
|
||
return;
|
||
|
||
TPickEntSet ssOtherWall(SS_FREE);
|
||
//adsout << _T("\n请选择其他墙体!");
|
||
if(SelectEntities(_T("\n选择其他墙体:"), ssOtherWall, wallMask)==RTNORM)
|
||
{
|
||
ssOtherWall -= entWall; // Exclude first wall
|
||
BOOL bArcFirst=pWall->Is(CURVE_ARC);
|
||
long lCount = ssOtherWall.Length();
|
||
|
||
//modify by xlc on 090514 解决框选时非标注段弧墙对标注的影响
|
||
double dRadiusFirst=segWall.GetArc ().GetRadius(); //标注段弧墙的半径
|
||
|
||
//add by xlc on 070815 解决了墙体顺序不一致时的标注混乱问题
|
||
TPickEntSet ssArcWall(SS_FREE);
|
||
if(bArcFirst) //弧形墙调整标注顺序
|
||
{
|
||
XPoint mid;
|
||
segWall.GetArc().MidPoint(mid);
|
||
AcGeVector3d vect = asPnt3d(mid) - asPnt3d(segWall.GetArc().GetCenterPt());
|
||
|
||
Array<EntAng> leftArray;
|
||
Array<EntAng> rightArray;
|
||
|
||
//获得弧形墙的实体及到参考墙的夹角数组
|
||
for(long i=0;i<lCount; i++)
|
||
{
|
||
Entity eWall=ssOtherWall[i];
|
||
OPENOBJ_BEGIN(eWall, AcDb::kForRead, TDbWall, pOtherWall);
|
||
if(pOtherWall)
|
||
{
|
||
TGGeCurveSegment segOther=*pOtherWall;
|
||
segOther.SetElevation(0.0);
|
||
BOOL bArcOther=pWall->Is(CURVE_ARC);
|
||
if(bArcFirst!=bArcOther)
|
||
continue;
|
||
if(bArcOther)
|
||
{
|
||
XArc arcFirst=segWall.GetArc();
|
||
XArc arcOther=segOther.GetArc();
|
||
|
||
//modify by xlc on 090514 去除框选时非标注段弧墙对标注的影响
|
||
double dRadiusOther=segOther.GetArc ().GetRadius();
|
||
if (fabs(dRadiusFirst-dRadiusOther)>_DIST_SNAP)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
if(XYDistance(arcFirst.GetCenterPt(),arcOther.GetCenterPt())>_DIST_SNAP)
|
||
continue;
|
||
|
||
segOther.GetArc().MidPoint(mid);
|
||
AcGeVector3d vect1 = asPnt3d(mid) - asPnt3d(segOther.GetArc().GetCenterPt());
|
||
double ang = vect1.angleTo(vect,AcGeVector3d::kZAxis);
|
||
|
||
|
||
EntAng entAng;
|
||
entAng.ent = eWall;
|
||
entAng.angle = ang;
|
||
if(ang < PI)
|
||
{
|
||
rightArray.AddTail(entAng);
|
||
}
|
||
else
|
||
{
|
||
leftArray.AddTail(entAng);
|
||
}
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
//将弧形墙体排序
|
||
Array <double> angArray;
|
||
for(i = 0; i < rightArray.GetLength();i++)
|
||
{
|
||
angArray.AddTail(rightArray[i].angle);
|
||
}
|
||
angArray.Arrange();
|
||
if(rightArray.GetLength() == angArray.GetLength())
|
||
{
|
||
for(i = 0; i < angArray.GetLength(); i++)
|
||
{
|
||
for(long j=0;j<rightArray.GetLength();j++)
|
||
{
|
||
if(fabs(rightArray[j].angle-angArray[i])<1.0E-6)
|
||
{
|
||
ssArcWall += rightArray[j].ent;
|
||
rightArray.Del(j);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
angArray.Clear();
|
||
for(i = 0; i < leftArray.GetLength();i++)
|
||
{
|
||
angArray.AddTail(leftArray[i].angle);
|
||
}
|
||
angArray.Arrange(false);
|
||
if(leftArray.GetLength() == angArray.GetLength())
|
||
{
|
||
for(i = 0; i < angArray.GetLength(); i++)
|
||
{
|
||
for(long j=0;j<leftArray.GetLength();j++)
|
||
{
|
||
if(fabs(leftArray[j].angle-angArray[i])<1.0E-6)
|
||
{
|
||
ssArcWall += leftArray[j].ent;
|
||
leftArray.Del(j);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
ssOtherWall.Free();
|
||
ssOtherWall += ssArcWall;
|
||
lCount = ssOtherWall.Length();
|
||
}
|
||
|
||
for(long i=0L; i<lCount; i++)
|
||
{
|
||
Entity eWall=ssOtherWall[i];
|
||
OPENOBJ_BEGIN(eWall, AcDb::kForRead, TDbWall, pOtherWall);
|
||
if(pOtherWall)
|
||
{
|
||
TGGeCurveSegment segOther=*pOtherWall;
|
||
segOther.SetElevation(0.0);
|
||
BOOL bArcOther=pWall->Is(CURVE_ARC);
|
||
if(bArcFirst!=bArcOther)
|
||
continue;
|
||
if(bArcOther)
|
||
{
|
||
XArc arcFirst=segWall.GetArc();
|
||
XArc arcOther=segOther.GetArc();
|
||
if(XYDistance(arcFirst.GetCenterPt(),arcOther.GetCenterPt())>_DIST_SNAP)
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
if(!CT_IsSameDrt(segWall.XLine::Direction(), segOther.XLine::Direction(), _angSnap))
|
||
continue;
|
||
}
|
||
|
||
XThirdDimData dimOther(segOther);
|
||
dimOther.m_nDistToTextBaseline = dim3.m_nDistToTextBaseline;
|
||
dimOther.m_nDistToFixPos = dim3.m_nDistToFixPos;
|
||
dimOther.m_nOnSide = segOther.OnWhichSide(ptTextBase1);
|
||
|
||
XPoint ptOtherFixPrj1;
|
||
if(pOtherWall->ProjectToMe(ptFix1, ptOtherFixPrj1)==RTNORM) {
|
||
dimOther.m_nDistToFixPos = XYDistance(ptFix1,ptOtherFixPrj1);
|
||
}
|
||
|
||
XPoint ptOtherTextBasePrj1, ptOtherTextBasePrj2;
|
||
if(!bThirdOnly)
|
||
{
|
||
if(pOtherWall->ProjectToMe(ptTextBase1, ptOtherTextBasePrj1)==RTNORM &&
|
||
pOtherWall->ProjectToMe(ptTextBase2, ptOtherTextBasePrj2)==RTNORM)
|
||
{
|
||
double nOtherDist1 = XYDistance(ptTextBase1,ptOtherTextBasePrj1);
|
||
double nOtherDist2 = XYDistance(ptTextBase2,ptOtherTextBasePrj2);
|
||
double nOtherDist = min(nOtherDist1, nOtherDist2) - fabs(nOtherDist1-nOtherDist2);
|
||
|
||
if(nOtherDist>0)
|
||
dimOther.m_nDistToTextBaseline = nOtherDist;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(pOtherWall->ProjectToMe(ptTextBase1, ptOtherTextBasePrj1)==RTNORM)
|
||
{
|
||
dimOther.m_nDistToTextBaseline = XYDistance(ptTextBase1,ptOtherTextBasePrj1);
|
||
}
|
||
}
|
||
|
||
|
||
dimOther.AddPoints(pOtherWall);//WLW 2013.10.12 不计算墙两端的柱子
|
||
AcDbObjectId idSlaver=dimOther.Apply();
|
||
if(!!idSlaver)
|
||
{
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pMaster);
|
||
if(pMaster)
|
||
{
|
||
OPENOBJ_BEGIN(idSlaver, AcDb::kForWrite, TDbDimension2, pSlaver);
|
||
if(pSlaver)
|
||
{
|
||
//modify by xlc on 070807
|
||
//解决弧墙标注顺时针错误问题
|
||
//if(pMaster->MergeDim(pSlaver))
|
||
// pSlaver->erase();
|
||
BOOL bMaster=TRUE;//是否合并到主尺寸
|
||
if(bArcFirst)
|
||
{
|
||
XPoint mid;
|
||
segWall.GetArc().MidPoint(mid);
|
||
AcGeVector3d vect = asPnt3d(mid) - asPnt3d(segWall.GetArc().GetCenterPt()),
|
||
//vect2 = asPnt3d(pt2) - asPnt3d(pt1);//modify by xlc on 090430 UCS下标注出错
|
||
vect2 = Ucs2Wcs(asPnt3d(pt2)) - Ucs2Wcs(asPnt3d(pt1));
|
||
double angle = vect2.angleTo(vect,AcGeVector3d::kZAxis);
|
||
|
||
//XLine lineTmp(pt1,pt2);//modify by xlc on 090430 UCS下标注出错
|
||
XLine lineTmp(Ucs2Wcs(pt1),Ucs2Wcs(pt2));
|
||
|
||
//modify by xlc on 090515 弧形门窗框选出错
|
||
XPoint ptProj1=Ucs2Wcs(pt1),ptProj2=Ucs2Wcs(pt2);
|
||
XLine lineMid(mid,segWall.GetArc().GetCenterPt());
|
||
if(ptProj1.Project (&lineMid,ptProj1)==RTNORM
|
||
&&ptProj2.Project (&lineMid,ptProj2)==RTNORM)
|
||
{
|
||
lineTmp.StartPoint()=ptProj1;
|
||
lineTmp.EndPoint()=ptProj2;
|
||
}
|
||
|
||
segOther.GetArc().MidPoint(mid);
|
||
if(angle < PI*0.5 || angle > PI*1.5)
|
||
{
|
||
if(lineTmp.HitTest2d(mid) == 2)
|
||
bMaster = FALSE;
|
||
}
|
||
else
|
||
{
|
||
if(lineTmp.HitTest2d(mid) == 1)
|
||
bMaster = FALSE;
|
||
}
|
||
}
|
||
|
||
if(bMaster)
|
||
{
|
||
if(pMaster->MergeDim(pSlaver))
|
||
pSlaver->erase();
|
||
}
|
||
else
|
||
{
|
||
if(pSlaver->MergeDim(pMaster))
|
||
{
|
||
idMaster = pSlaver->objectId();
|
||
pMaster->erase();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pMaster);
|
||
if(pMaster)
|
||
{
|
||
pMaster->RemoveZeroSegment();
|
||
if(g_nDimAdjust)
|
||
pMaster->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
OPENOBJ_END();
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
|
||
// 把pDim2合并到pDim1去
|
||
int MergeDim(TDbDimension2 *pDim1, TDbDimension2 *pDim2)
|
||
{
|
||
if(!CT_IsSameDrt(pDim1->GetRotation(), pDim2->GetRotation(), _angSnap)) {
|
||
adsout << _T("\n方向不平齐!");
|
||
return RTERROR;
|
||
} else if(pDim1->IsAngular()!=pDim2->IsAngular()) {
|
||
adsout << _T("\n类型不匹配!");
|
||
return RTERROR;
|
||
} else if(!!pDim1->GetBindId() || !!pDim2->GetBindId()) {
|
||
adsout << _T("\n尺寸对象已经绑定在其他对象上!");
|
||
return RTERROR;
|
||
}
|
||
|
||
if(pDim1->MergeDim(pDim2))
|
||
return RTNORM;
|
||
adsout << _T("\n不能合并!");
|
||
return RTERROR;
|
||
}
|
||
// Add by lcf on 2005/05/26
|
||
BOOL MergeDimFromTo(TDbDimension2 *pTo, const TDbDimension2 *pFrom)
|
||
{
|
||
XPoly2D poly;
|
||
pFrom->GetPolySegOnDimLine(poly);
|
||
TGGeCurveSegment cv = pTo->GetDimCurve();
|
||
if(!pTo->IsUseDefaultText() || !pFrom->IsUseDefaultText())
|
||
{
|
||
for(int i=0; i<poly.Length(); i++)
|
||
{
|
||
XPoint ptVert;
|
||
if(cv.ProjectToMe(*poly[i], ptVert) != RTNORM)
|
||
continue;
|
||
if((ptVert & cv) != 4)
|
||
{
|
||
adsout << _T("\n尺寸文字被更改过, 并且尺寸线重叠, 不能连接尺寸!");
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
|
||
int nSeg = pTo->GetSegmentNum();
|
||
for(int i=0; i<poly.Length(); i++)
|
||
{
|
||
XPoint ptVert;
|
||
if(cv.ProjectToMe(*poly[i], ptVert) != RTNORM)
|
||
continue;
|
||
pTo->AddSegment(ptVert);
|
||
}
|
||
cv = pTo->GetDimCurve();
|
||
|
||
int nTo = pTo->GetSegmentNum();
|
||
int nFrom = pFrom->GetSegmentNum();
|
||
|
||
XPoint ptSta, ptEnd;
|
||
cv.ProjectToMe(*poly.Head(), ptSta);
|
||
cv.ProjectToMe(*poly.Tail(), ptEnd);
|
||
|
||
int nFlag = 0;
|
||
if(ptSta.Distance2d(cv.StartPoint()) < 1E-6)
|
||
{
|
||
nFlag = 0;
|
||
}
|
||
else if(ptSta.Distance2d(cv.EndPoint()) < 1E-6)
|
||
{
|
||
nFlag = 1;
|
||
}
|
||
else if(ptEnd.Distance2d(cv.StartPoint()) < 1E-6)
|
||
{
|
||
nFlag = 2;
|
||
}
|
||
else if(ptEnd.Distance2d(cv.EndPoint()) < 1E-6)
|
||
{
|
||
nFlag = 3;
|
||
}
|
||
else
|
||
{
|
||
// sg modify 120615,解决在中间部分的尺寸标注如果文字不在默认位置,连接尺寸后,文字不在默认位置的问题
|
||
// return TRUE;
|
||
for (i=0; i<nFrom; i++)
|
||
{
|
||
XPoint ptVert;
|
||
if (cv.ProjectToMe(*poly[i], ptVert) != RTNORM)
|
||
continue;
|
||
|
||
BOOL bIsDefText = TRUE;
|
||
XString szText = pFrom->GetText(i, &bIsDefText);
|
||
BOOL bIsDefPos = TRUE;
|
||
XPoint ptPos = pFrom->GetTextPos(i, &bIsDefPos);
|
||
if (bIsDefText && bIsDefPos)
|
||
continue;
|
||
|
||
XPoint ptNew = ptPos;
|
||
ptNew += ptVert - *poly[i];
|
||
|
||
int nPos = pTo->HitTestOnDimSeg(ptNew);
|
||
if (nPos==-1 || nPos>nTo)
|
||
continue;
|
||
|
||
double dCur = pFrom->GetSegment(i),
|
||
dProject = pTo->GetSegment(nPos);
|
||
if (fabs(dCur-dProject) > _DIST_SNAP) // 中间部分的外偏情况,不处理
|
||
continue;
|
||
|
||
if (!bIsDefText)
|
||
pTo->SetTextContent(nPos, szText);
|
||
|
||
if (!bIsDefPos)
|
||
{
|
||
if (_tcscmp(szText, pTo->GetText(nPos)) == 0)
|
||
pTo->SetTextPos(nPos, ptNew);
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
for(i=0; i<nFrom; i++)
|
||
{
|
||
XPoint ptVert;
|
||
if(cv.ProjectToMe(*poly[i], ptVert) != RTNORM)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
BOOL bIsDefText = TRUE;
|
||
XString szText = pFrom->GetText(i, &bIsDefText);
|
||
BOOL bIsDefPos = TRUE;
|
||
XPoint ptPos = pFrom->GetTextPos(i, &bIsDefPos);
|
||
if(bIsDefText && bIsDefPos)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
int nPos;
|
||
if(nFlag == 0)
|
||
{
|
||
nPos = i;
|
||
}
|
||
else if(nFlag == 1)
|
||
{
|
||
nPos = nTo - i - 1;
|
||
}
|
||
else if(nFlag == 2)
|
||
{
|
||
nPos = nFrom - i - 1;
|
||
}
|
||
else if(nFlag == 3)
|
||
{
|
||
nPos = nTo - nFrom + i;
|
||
}
|
||
|
||
if(!bIsDefText)
|
||
pTo->SetTextContent(nPos, szText);
|
||
|
||
if(!bIsDefPos)
|
||
{
|
||
if(_tcscmp(szText, pTo->GetText(nPos)) == 0)
|
||
{
|
||
ptPos += ptVert - *poly[i];
|
||
pTo->SetTextPos(nPos, ptPos);
|
||
}
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
// Command: 连接尺寸标注
|
||
// 不支持自调
|
||
void MergeDim()
|
||
{
|
||
//Add by lxb on 2011/11/17
|
||
//允许用户通过框选的方式,同时选中多道尺寸线与主尺寸连接
|
||
//修改系统变量PICKADD
|
||
XPushVar<int> pickmode(_T("PICKADD"), 1);
|
||
|
||
//与主尺寸连接标注选择集
|
||
TPickEntSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2"), NULL);
|
||
TEntitySet entMaster;
|
||
if (entMaster.FilterSelect(_T("\n选择主尺寸标注<退出>: "),mask) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
entMaster.Redraw(3);
|
||
|
||
|
||
g_ssPickFirst.Free();
|
||
|
||
if(RTNORM != SelectEntities(_T("\n选择需要连接尺寸标注<退出>: "),ss, mask))
|
||
{
|
||
entMaster.Redraw(4);
|
||
return;
|
||
}
|
||
ss -= entMaster;
|
||
|
||
Entity entDim;
|
||
if(entMaster.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(entMaster, entDim))
|
||
{
|
||
adsout << _T("\n不能转化ACAD尺寸标注对象!");
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
else if(!entDim.Is(_T("ATS_DIMENSION2")))
|
||
{
|
||
adsout << _T("\n不是线性标注!");
|
||
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
entDim = entMaster;
|
||
}
|
||
|
||
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pMaster);
|
||
if (!pMaster)
|
||
{
|
||
return;
|
||
}
|
||
//连接操作
|
||
long nLen = ss.Length();
|
||
for (long i = 0;i < nLen; i++)
|
||
{
|
||
Entity entDim;
|
||
if(entMaster.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(ss[i], entDim))
|
||
{
|
||
adsout << _T("\n不能转化ACAD尺寸标注对象!");
|
||
{
|
||
continue;;
|
||
}
|
||
}
|
||
else if(!entDim.Is(_T("ATS_DIMENSION2")))
|
||
{
|
||
adsout << _T("\n不是线性标注!");
|
||
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
entDim = ss[i];
|
||
}
|
||
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForWrite, TDbDimension2, pSlaver);
|
||
if(pSlaver)
|
||
{
|
||
if(pMaster->upgradeOpen()!=Acad::eOk)
|
||
{
|
||
adsout << _T("\n不能修改主尺寸!");
|
||
continue;
|
||
}
|
||
if(pMaster->IsAngular()!=pSlaver->IsAngular())
|
||
{
|
||
adsout << _T("\n直线类型的尺寸不能和角度类型的尺寸进行连接!");
|
||
}
|
||
else
|
||
{
|
||
BOOL bCanMerge=TRUE;
|
||
if(!pMaster->IsAngular())
|
||
{
|
||
if(!CT_IsSameDrt(pMaster->GetRotation(), pSlaver->GetRotation(), _DIST_SNAP))
|
||
{
|
||
adsout << _T("\n尺寸线的方向不平行, 无法连接!");
|
||
bCanMerge=FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
XArc ar1=pMaster->GetDimCurve().GetArc();
|
||
XArc ar2=pSlaver->GetDimCurve().GetArc();
|
||
if(ar1.GetCenterPt().Distance2d(ar2.GetCenterPt())>_DIST_SNAP)
|
||
{
|
||
adsout << _T("\n角度类型的尺寸圆心不一样, 无法连接!");
|
||
bCanMerge=FALSE;
|
||
}
|
||
}
|
||
if(bCanMerge)
|
||
{
|
||
if(MergeDimFromTo(pMaster, pSlaver))
|
||
{
|
||
pSlaver->erase();
|
||
}
|
||
}
|
||
}
|
||
pMaster->downgradeOpen();
|
||
}
|
||
else
|
||
{
|
||
adsout << _T("\n不能修改尺寸标注!");
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
// Command: 转化尺寸标注 (AcDbDimension -> TDbDimension2)
|
||
void ConvertDim()
|
||
{
|
||
RBList mask(RTDXF0, _T("DIMENSION,ATS_DIMENSION"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
if(SelectEntities(_T("\n请选择ACAD尺寸标注: "), ss, mask)==RTNORM) {
|
||
TPickEntSet ss1(SS_FREE|SS_CREATE);
|
||
long lCount=ss.Length();
|
||
for(long i=0; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
Entity ee;
|
||
if(!ConvertDim(ent, ee))
|
||
ss1 += ent;
|
||
}
|
||
long num=ss1.Length();
|
||
if(num) {
|
||
adsout << _T("\n有") << int(num) << _T("个对象不能被转化!");
|
||
ss1.Redraw(3);
|
||
} else {
|
||
adsout << _T("\n全部选中的") << int(lCount) << _T("个对象成功的转化为上华尺寸标注!");
|
||
}
|
||
}
|
||
}
|
||
// Command: 切换角标
|
||
void TogDimAngular()
|
||
{
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
if(SelectEntities(_T("\n请选择上华角度标注: "), ss, mask)==RTNORM) {
|
||
long lCount=ss.Length();
|
||
for(long i=0; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim && pDim->IsAngular()) {
|
||
pDim->SwitchDimChord();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
// Command: 尺寸复位
|
||
void ResetDimP()
|
||
{
|
||
// modify by xly on 100913 支持符号标注中:标高符号、箭头引注、剖面剖切和断面剖切四种文字复位,(20111222新加)指北针
|
||
// RBList mask(RTDXF0, _T("ATS_DIMENSION2,ATS_RADIUSDIM"), NULL);
|
||
// RBList mask(RTDXF0, _T("ATS_DIMENSION2,ATS_RADIUSDIM,ATS_ARROW,ATS_ELEVATION,ATS_SYMB_SECTION,ATS_NORTHTHUMB"), NULL);
|
||
// sg modify 120117,根据9.0的需求,增加了对索引图名对象的支持,主要是将圆圈外的文字还原
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2,ATS_RADIUSDIM,ATS_ARROW,ATS_ELEVATION,ATS_SYMB_SECTION,ATS_NORTHTHUMB,ATS_DRAWINGINDEX"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
|
||
// if(SelectEntities(_T("\n请选择上华尺寸标注: "), ss, mask)==RTNORM) {
|
||
if(SelectEntities(_T("\n请选择需复位文字的对象: "), ss, mask)==RTNORM)
|
||
{
|
||
long lCount=ss.Length();
|
||
for(long i=0; i<lCount; i++)
|
||
{
|
||
Entity ent=ss[i];
|
||
|
||
// modify by xly 0n 100913 添加部分符号标注的文字复位
|
||
/*OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pDim);
|
||
TDbDimension2 *pDim1=TDbDimension2::cast(pDim);
|
||
TDbRadiusDim *pDim2=TDbRadiusDim::cast(pDim);
|
||
if(pDim1)
|
||
pDim1->ResetTextPos();
|
||
else if(pDim2)
|
||
{
|
||
pDim2->SetTextPos(pDim2->GetDefaultTextPos());
|
||
}
|
||
OPENOBJ_END();*/
|
||
|
||
if (ent.Is(_T("ATS_DIMENSION2"))) // 标注对象
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim != NULL)
|
||
{
|
||
pDim->ResetTextPos();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_RADIUSDIM"))) // 半径标注对象
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbRadiusDim, pDim);
|
||
if (pDim != NULL)
|
||
{
|
||
pDim->SetTextPos(pDim->GetDefaultTextPos());
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_ARROW"))) // 箭头引注对象
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbArrow, pArrow);
|
||
if (pArrow != NULL)
|
||
{
|
||
pArrow->SetTextLocation(pArrow->GetDefaultTextLocation());
|
||
|
||
// 支持下标文字复位
|
||
pArrow->SetText2Location(pArrow->GetDefaultText2Location());
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_ELEVATION"))) // 标高标注对象
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbElevation, pEle);
|
||
if (pEle != NULL)
|
||
{
|
||
pEle->SetTextPoint(pEle->GetDefaultTextLocation());
|
||
|
||
// 支持相对标高,上下排列的文字复位
|
||
pEle->SetLowTextPt(pEle->GetDefaultTextLocation2());
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_SYMB_SECTION")))// 剖面剖切,断面剖切对象
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbSection, pSection);
|
||
if (pSection != NULL)
|
||
{
|
||
pSection->SetTextLocation(0,pSection->GetDefaultTextLocation(0));
|
||
pSection->SetTextLocation(1,pSection->GetDefaultTextLocation(1));
|
||
//add by lgy 20120528 为剖切图号设置文字位置
|
||
pSection->SetIndexLocation(0, pSection->GetDefaultIndexLocation(0));
|
||
pSection->SetIndexLocation(1, pSection->GetDefaultIndexLocation(1));
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_NORTHTHUMB")))//指北针 add by lxb on 2011/12/22
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbNorthThumb, pNorthThumb);
|
||
if (pNorthThumb != NULL)
|
||
{
|
||
pNorthThumb->SetTextPoint(pNorthThumb->GetDefaultTextLocation());
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (ent.Is(_T("ATS_DRAWINGINDEX"))) // 索引图名,sg add 120117
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbSymbDrawingIndex, pDrawingIndex);
|
||
if (pDrawingIndex != NULL)
|
||
{
|
||
pDrawingIndex->SetScaleTextPt(pDrawingIndex->GetDefaultScaleTextLocation());
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// Command: 尺寸复原
|
||
void ResetDimT()
|
||
{
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2,ATS_RADIUSDIM"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
if(SelectEntities(_T("\n请选择上华尺寸标注: "), ss, mask)==RTNORM) {
|
||
long lCount=ss.Length();
|
||
for(long i=0; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pDim);
|
||
TDbDimension2 *pDim1=TDbDimension2::cast(pDim);
|
||
TDbRadiusDim *pDim2=TDbRadiusDim::cast(pDim);
|
||
if(pDim1) pDim1->ResetTextContent();
|
||
else if(pDim2) pDim2->SetText(NULL);
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
// Command: 更改文字
|
||
void DimChText()
|
||
{
|
||
RBList mask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2,ATS_RADIUSDIM"), NULL);
|
||
Entity entMaster;
|
||
XPoint ptPick;
|
||
while(entMaster.FilterSelect(_T("\n请选择尺寸区间<退出>: "), mask, ptPick)==RTNORM) {
|
||
Entity entDim;
|
||
if(entMaster.Is(_T("DIMENSION"))) {
|
||
if(!ConvertDim(entMaster, entDim)) {
|
||
adsout << _T("\n不能转化ACAD尺寸标注对象!");
|
||
return;
|
||
}
|
||
} else {
|
||
entDim=entMaster;
|
||
}
|
||
|
||
if(entDim.Is(_T("ATS_RADIUSDIM"))) {
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbRadiusDim, pDim);
|
||
ASSERT(pDim);
|
||
XString sText;
|
||
XString sTemp=pDim->GetText();
|
||
adsout << _T("\n输入标注文字<") << sTemp << _T(">: ");
|
||
if(ads_getstring(1, _T(""), sText)==RTNORM) {
|
||
if(pDim->upgradeOpen()==Acad::eOk) {
|
||
pDim->SetText(sText);
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
} else if(entDim.Is(_T("ATS_DIMENSION2"))) {
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pDim);
|
||
ASSERT(pDim);
|
||
int nSeg=pDim->HitTestOnText(Ucs2Wcs(ptPick));
|
||
if(nSeg<0) {
|
||
adsout << _T("\n请正确点取在尺寸线上!");
|
||
} else {
|
||
XString sText;
|
||
adsout << _T("\n输入标注文字<") << pDim->GetText(nSeg) << _T(">: ");
|
||
if(ads_getstring(1, _T(""), sText)==RTNORM) {
|
||
if(pDim->upgradeOpen()==Acad::eOk) {
|
||
pDim->SetTextContent(nSeg, sText);
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
//得到标注点
|
||
//传入:pWall 墙指针
|
||
// ptOnIt 墙上一点(标注参考点)
|
||
//传出:ptL 左标注点
|
||
// ptM 中标注点
|
||
// ptR 右标注点
|
||
void GetDimPoint(TWallData *pWall, XPoint &ptOnIt, XPoint &ptL, XPoint &ptM, XPoint &ptR)
|
||
{
|
||
//得到墙两边
|
||
TGGeCurveSegment cvLeft, cvRight;
|
||
pWall->GetSideCurve(cvLeft, cvRight);
|
||
ads_real rAng = pWall->Direction(ptOnIt);
|
||
XPoint pt;
|
||
ads_polar(ptOnIt, rAng + 0.5 * PI, 100.0, pt);
|
||
XLine line(ptOnIt, pt);
|
||
cvLeft.SetLineFlag(LS_FINITE);
|
||
cvRight.SetLineFlag(LS_FINITE);
|
||
cvLeft.Intersection(line, ptL, pt); //得到左边上的标注点
|
||
cvRight.Intersection(line, ptR, pt); //得到右边上的标注点
|
||
pWall->Intersection(line, ptM, pt); //得到轴线上的标注点
|
||
}
|
||
|
||
//标注一根墙宽
|
||
//传入:ptLeft 左标注点
|
||
// ptMid 中标注点
|
||
// ptRight 右标注点
|
||
// nDimAxis 轴线标志
|
||
// = 1 标
|
||
// = 0, 2 不标
|
||
//返回:成功, RTNORM; 出错, RTERROR
|
||
int DimOne(XPoint ptLeft, XPoint ptMid, XPoint ptRight, BOOL nDimAxis)
|
||
{
|
||
if(ptMid.Distance2d(ptLeft)<_DIST_SNAP || ptMid.Distance2d(ptRight)<_DIST_SNAP)
|
||
{
|
||
nDimAxis=FALSE;
|
||
}
|
||
TDbDimension2 *pDim=new TDbDimension2;
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
pDim->SetLocation(ptLeft);
|
||
pDim->SetRotation(ads_angle(ptLeft, ptRight));
|
||
pDim->SetDist2DimLine(6.0, TRUE);
|
||
pDim->AppendSegment(ptLeft.Distance2d(ptRight));
|
||
AcDbObjectId idStyle=InitDimStyle(DS_LINEAR);
|
||
pDim->SetStyleId(idStyle);
|
||
|
||
|
||
AcGiTextStyle txtStyle;
|
||
OPENOBJ_BEGIN(idStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pStyle);
|
||
ASSERT(pStyle);
|
||
VERIFY(fromAcDbTextStyle(txtStyle, pStyle->dimtxsty())==Acad::eOk);
|
||
int nRetFlag=txtStyle.loadStyleRec();
|
||
txtStyle.setTextSize(pStyle->dimtxt()*pDim->GetPScale()*0.8);
|
||
OPENOBJ_END();
|
||
|
||
if(nDimAxis)
|
||
{
|
||
pDim->AddSegment(ptMid);
|
||
|
||
//add by lxb on 2011/11/18
|
||
//针对基线在墙外时调整标注的显示位置
|
||
XLine line(ptLeft, ptRight, LS_FINITE);
|
||
TADSGePoint3d ptLRMid = line.MidPoint();
|
||
|
||
ads_real rHLeft = ads_distance(ptLeft, ptMid)/2, // ZJQ modify 2 to 4, so it is more close to wall
|
||
rHRight = ads_distance(ptMid, ptRight)/2,
|
||
// rALeft = ads_angle(ptMid, ptLeft), //左标移动方向
|
||
// rARight = ads_angle(ptMid, ptRight); //右标移动方向
|
||
rALeft = ads_angle(ptLRMid, ptLeft), //左标移动方向
|
||
rARight = ads_angle(ptLRMid, ptRight); //右标移动方向
|
||
AcGePoint2d ptExt=txtStyle.extents(pDim->GetText(0), Adesk::kFalse, -1, Adesk::kTrue);
|
||
rHLeft += ptExt[0]/2 + 1.0*pDim->GetPScale();
|
||
ptExt = txtStyle.extents(pDim->GetText(1), Adesk::kFalse, -1, Adesk::kTrue);
|
||
rHRight += ptExt[0]/2 + 1.0*pDim->GetPScale();
|
||
XVector3D vtLeft(rHLeft*cos(rALeft), rHLeft*sin(rALeft));
|
||
XVector3D vtRight(rHRight*cos(rARight), rHRight*sin(rARight));
|
||
XPoint ptLText=pDim->GetTextPos(0);
|
||
ptLText += vtLeft;
|
||
XPoint ptRText=pDim->GetTextPos(1);
|
||
ptRText += vtRight;
|
||
pDim->SetTextPos(0, ptLText);
|
||
pDim->SetTextPos(1, ptRText);
|
||
}
|
||
else
|
||
{
|
||
ads_real rHWidth = ads_distance(ptLeft, ptRight)/2, // ZJQ modify 2 to 4, so it is more close to wall
|
||
rAngle = ads_angle(ptLeft, ptRight); //移动方向
|
||
AcGePoint2d ptExt=txtStyle.extents(pDim->GetText(0), Adesk::kTrue, -1, Adesk::kTrue);
|
||
rHWidth += ptExt[0]/2 + 1.0*pDim->GetPScale();
|
||
XVector3D vtMove(rHWidth*cos(rAngle), rHWidth*sin(rAngle));
|
||
XPoint ptText=pDim->GetTextPos(0);
|
||
ptText += vtMove;
|
||
pDim->SetTextPos(0, ptText);
|
||
}
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->AddToMSpace(Adesk::kTrue);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity *)pDim);
|
||
return RTNORM;
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
// Command: 打断尺寸
|
||
void DimBreak()
|
||
{
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
if(SelectEntity(_T("\n请在要打断的一侧点取尺寸线<退出>: "), ent, ptPick, mask)==RTNORM)
|
||
{
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim)
|
||
{
|
||
if(pDim->IsBind())
|
||
{
|
||
adsout << _T("\n此尺寸标注绑定在其他对象上, 因此不能编辑!");
|
||
return;
|
||
}
|
||
int nSeg = pDim->HitTestOnDimSeg(ptPick);
|
||
if(nSeg < 0||nSeg>=pDim->GetSegmentNum())
|
||
return;
|
||
|
||
XPoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
|
||
XDirectionCurve seg;
|
||
poly.Nth(nSeg, seg);
|
||
XPoint ptLoc;
|
||
double nDist1 = ads_distance(seg.StartPoint(), ptPick);
|
||
double nDist2 = ads_distance(seg.EndPoint(), ptPick);
|
||
if(nDist1>nDist2)
|
||
nSeg++;
|
||
|
||
if(nSeg<0||nSeg>=pDim->GetSegmentNum())
|
||
return;
|
||
poly.Nth(nSeg, seg);
|
||
|
||
double nRot = seg.IDirection(0);
|
||
ads_polar(seg.StartPoint(), nRot-PI/2.0, pDim->GetDist2DimLine(FALSE), ptLoc);
|
||
|
||
TDbDimension2 *pDimNew=(TDbDimension2 *)pDim->clone();
|
||
for(int i=0; i<nSeg; i++)
|
||
pDimNew->RemoveSegment(0);
|
||
pDimNew->SetLocation(ptLoc);
|
||
pDimNew->SetRotation(nRot);
|
||
AddToCurrentSpace(pDimNew, Adesk::kTrue);
|
||
int nTotalSeg=poly.TotalSegments();
|
||
for(i=nSeg; i<nTotalSeg; i++)
|
||
pDim->RemoveSegment(nSeg);
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////
|
||
// Command: 取消尺寸区间
|
||
void RemoveDimSeg()
|
||
{
|
||
// 解决选中标注后,运行“取消标注”命令,当删除最后一个标注崩溃的问题
|
||
ads_name name = {0, 0};
|
||
acedSSSetFirst(name, NULL);
|
||
// end
|
||
|
||
TPickEntSet sets(SS_FREE);
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
|
||
while(1)
|
||
{
|
||
int iRet;
|
||
THookMsg hookmsg;
|
||
INITGET_BEG(0,_T("A"))
|
||
iRet = SelectEntity(_T("\n选择待删除尺寸的区间线或尺寸文字[整体删除(A)]<退出>: "), ent, ptPick, mask);
|
||
INITGET_END()
|
||
if (iRet == RTERROR)
|
||
{
|
||
if (hookmsg.GetValue() == 0)
|
||
continue;
|
||
else
|
||
return;
|
||
}
|
||
if (iRet == RTCAN)
|
||
return;
|
||
if (iRet == RTKWORD)
|
||
{
|
||
TCHAR buf[256];
|
||
acedGetInput(buf);
|
||
if(buf[0] == _T('A') || buf[0] == _T('a'))
|
||
{
|
||
if (SelectEntities(_T("\n选择待删除的所有尺寸对象<退出>:"), sets, TRBList(RTDXF0, _T("ATS_DIMENSION2"), NULL)) != RTNORM)
|
||
return;
|
||
sets.Erase();
|
||
return;
|
||
}
|
||
}
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim)
|
||
{
|
||
if (pDim->IsBind())
|
||
{
|
||
adsout << _T("\n此尺寸标注绑定在其他对象上, 因此不能编辑!");
|
||
return;
|
||
}
|
||
int nSeg = -1;
|
||
TSubText* psubtext = pDim->HitTestText(ptPick);
|
||
if (psubtext == NULL)
|
||
{
|
||
nSeg = pDim->HitTestOnDimSeg(ptPick);
|
||
}
|
||
else
|
||
{
|
||
nSeg = psubtext->GetIndex();
|
||
delete psubtext;
|
||
psubtext = NULL;
|
||
}
|
||
|
||
if (nSeg >= 0)
|
||
{
|
||
XPoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
int n = poly.TotalSegments();
|
||
ASSERT(nSeg < poly.TotalSegments());
|
||
if (nSeg == poly.TotalSegments() - 1)
|
||
{
|
||
pDim->RemoveSegment(nSeg);
|
||
if (!pDim->IsValid())
|
||
pDim->erase();
|
||
}
|
||
else if (nSeg == 0)
|
||
{
|
||
XDirectionCurve seg;
|
||
poly.Nth(1, seg);
|
||
double nDist2DimLine = pDim->GetDist2DimLine(FALSE);
|
||
double nRot = seg.IDirection(0);
|
||
XPoint ptLoc;
|
||
ads_polar(seg.StartPoint(), nRot - PI / 2.0, nDist2DimLine, ptLoc);
|
||
pDim->RemoveSegment(nSeg);
|
||
pDim->SetLocation(ptLoc);
|
||
pDim->SetRotation(nRot);
|
||
}
|
||
else
|
||
{
|
||
TDbDimension2 *pDimNew = (TDbDimension2 *)pDim->clone();
|
||
XDirectionCurve seg;
|
||
poly.Nth(nSeg + 1, seg);
|
||
double nRot = seg.IDirection(0);
|
||
XPoint ptLoc;
|
||
ads_polar(seg.StartPoint(), nRot - PI / 2.0, pDimNew->GetDist2DimLine(FALSE), ptLoc);
|
||
for (int i = 0; i <= nSeg; i++)
|
||
pDimNew->RemoveSegment(0);
|
||
pDimNew->SetLocation(ptLoc);
|
||
pDimNew->SetRotation(nRot);
|
||
AddToCurrentSpace(pDimNew, Adesk::kTrue);
|
||
int nTotalSeg = poly.TotalSegments();
|
||
for (i = nSeg; i < nTotalSeg; i++)
|
||
pDim->RemoveSegment(nSeg);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
void DimTextMirror()
|
||
{
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
if(SelectEntity(_T("\n请选择上华尺寸标注<退出>: "), ent, ptPick, mask)==RTNORM) {
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim) {
|
||
int nSeg=pDim->HitTestOnText(ptPick);
|
||
if(nSeg>=0) {
|
||
XPoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
ASSERT(nSeg<poly.TotalSegments());
|
||
XPoint ptText=pDim->GetTextPos(nSeg);
|
||
TGGeCurveSegment seg;
|
||
poly.Nth(nSeg, seg);
|
||
XPoint ptOnSeg;
|
||
if(pDim->IsAngular() && pDim->IsDimChord())
|
||
seg=XLine(seg.StartPoint(), seg.EndPoint());
|
||
if(seg.ProjectToMe(ptText, ptOnSeg)==RTNORM) {
|
||
XPoint ptTextNew;
|
||
ptOnSeg.Mirror(ptText, ptTextNew);
|
||
pDim->SetTextPos(nSeg, ptTextNew);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
//多段墙宽标注(线标墙宽)
|
||
void DimWallThick()
|
||
{
|
||
//modify by lxb on 2011/11/18
|
||
//当轴线在墙体外,且用户给出的点跨过了轴线,则应能标注出墙皮与轴线的尺寸
|
||
|
||
InitLayer(LAY_DIM, TRUE);
|
||
|
||
XPoint pt1, pt2;
|
||
if(ads_getpoint(NULL, _T("\n直线第一点<退出>: "), pt1) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
if(ads_getpoint(pt1, _T("\n直线第二点<退出>: "), pt2) != RTNORM)
|
||
{
|
||
return ;
|
||
}
|
||
|
||
//获取选取范围内墙集合
|
||
TPickEntSet ssWall(SS_CREATE|SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
ssWall.Get(_T("F"), rbFence, NULL, RBList(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL"), NULL));
|
||
|
||
//线段描述选取范围
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
XLine line(pt1, pt2, LS_FINITE);
|
||
|
||
//标注处理
|
||
long nLen = ssWall.Length();
|
||
for(long i = 0; i < nLen; i++)
|
||
{
|
||
TWallData wall(ssWall[i]);
|
||
wall.SetElevation(0.0); // Add on 2002/6/12, 解决不爱国标高不在0上时,无法标注墙厚的问题
|
||
wall.SetLineFlag(LS_FINITE);
|
||
XPoint ptOnIt, ptMid, ptLeft, ptRight;
|
||
if(!wall.Intersection(line, ptOnIt, ptMid))
|
||
{
|
||
continue;
|
||
}
|
||
|
||
//获取标注点
|
||
GetDimPoint(&wall, ptOnIt, ptLeft, ptMid, ptRight);
|
||
|
||
//三点排序
|
||
std::vector<TADSGePoint3d> vecPt;
|
||
vecPt.push_back(ptLeft);
|
||
vecPt.push_back(ptMid);
|
||
vecPt.push_back(ptRight);
|
||
sort(vecPt.begin(),vecPt.end());
|
||
|
||
TADSGePoint3d ptBegin = vecPt[0];
|
||
TADSGePoint3d ptEnd = vecPt[vecPt.size()-1];
|
||
|
||
//轴线上的标注点
|
||
TPickEntSet ssAxis(SS_FREE);
|
||
TADSGePoint3d __pt1(Wcs2Ucs(ptEnd));
|
||
TADSGePoint3d __pt2(Wcs2Ucs(ptBegin));
|
||
RBList rbFence1=ads_buildlist(RT3DPOINT, &__pt2, RT3DPOINT, &__pt1, NULL);
|
||
BOOL bHasAxis = false;
|
||
if(((ssAxis.Get(_T("F"), rbFence1, NULL, RBList(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, LAY_AXIS, NULL))==RTNORM ) &&
|
||
(ssAxis.Length() == 1)))
|
||
{
|
||
bHasAxis = true;
|
||
}
|
||
if(bHasAxis)
|
||
{
|
||
TGGeCurveSegment seg(ssAxis[0L]);
|
||
XLine ln(ptBegin, ptEnd, LS_FINITE);
|
||
seg.Intersection(ln, ptMid, XPoint());
|
||
}
|
||
|
||
//画标注
|
||
if(DimOne(ptLeft, ptMid, ptRight, bHasAxis) != RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
/* InitLayer(LAY_DIM, TRUE);
|
||
|
||
RBList rbAxisMask=RBList(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, LAY_AXIS, NULL);
|
||
XPoint pt1, pt2;
|
||
if(ads_getpoint(NULL, _T("\n直线第一点<退出>: "), pt1) == RTNORM) {
|
||
if(ads_getpoint(pt1, _T("\n直线第二点<退出>: "), pt2) == RTNORM) {
|
||
TPickEntSet ssWall(SS_CREATE|SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
ssWall.Get(_T("F"), rbFence, NULL, RBList(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL"), NULL));
|
||
int nLen = ssWall.Length();
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
XLine line(pt1, pt2, LS_FINITE);
|
||
if(nLen > 0) {
|
||
int nDimAxis = 0, nAskFlag = 3;
|
||
for(long i = 0; i < nLen; i++) {
|
||
TWallData wall(ssWall[i]);
|
||
wall.SetElevation(0.0); // Add on 2002/6/12, 解决不爱国标高不在0上时,无法标注墙厚的问题
|
||
wall.SetLineFlag(LS_FINITE);
|
||
XPoint ptOnIt, ptMid, ptLeft, ptRight;
|
||
if(!wall.Intersection(line, ptOnIt, ptMid))
|
||
continue;
|
||
GetDimPoint(&wall, ptOnIt, ptLeft, ptMid, ptRight);
|
||
|
||
TPickEntSet ssAxis(SS_FREE);
|
||
RBList rbFence1=ads_buildlist(RT3DPOINT, &(Wcs2Ucs(ptLeft)), RT3DPOINT, &(Wcs2Ucs(ptRight)), NULL);
|
||
BOOL bHasAxis=(ssAxis.Get(_T("F"), rbFence1, NULL, rbAxisMask)==RTNORM &&
|
||
ssAxis.Length()==1);
|
||
if(bHasAxis) {
|
||
TGGeCurveSegment seg(ssAxis[0L]);
|
||
XLine ln(ptLeft, ptRight, LS_FINITE);
|
||
seg.Intersection(ln, ptMid, XPoint());
|
||
}
|
||
if(DimOne(ptLeft, ptMid, ptRight, bHasAxis) != RTNORM)
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
}
|
||
|
||
|
||
|
||
// Command: 裁剪延伸
|
||
// 支持尺寸自调
|
||
void DimTrimOrExt()
|
||
{
|
||
//wlw mod 2013.5.29 先选尺寸线后裁剪
|
||
Entity entDim;
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2,DIMENSION"), NULL);
|
||
XPoint ptPick;
|
||
if(entDim.FilterSelect(_T("\n要裁剪或延伸的尺寸线<退出>: "), mask, ptPick) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
if(entDim.Is(_T("DIMENSION")))
|
||
{
|
||
Entity entNew;
|
||
if(!ConvertDim(entDim, entNew))
|
||
{
|
||
adsout << _T("\n不能转化ACAD尺寸标注对象!");
|
||
return;
|
||
}
|
||
else if(!entDim.Is(_T("ATS_DIMENSION2")))
|
||
{
|
||
adsout << _T("\n不是线性标注!");
|
||
return;
|
||
}
|
||
entDim=entNew;
|
||
}
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pDim1);
|
||
if(pDim1 !=NULL && pDim1->IsBind())
|
||
{
|
||
adsout << _T("\n尺寸对象已经绑定在其他对象上,不能进行编辑!");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
pDim1->getClosestPointTo(ptPick,ptPick);
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
entDim.Redraw(3);
|
||
|
||
XPoint ptBase;
|
||
ptPick=Wcs2Ucs(ptPick);
|
||
|
||
if(acedGetPoint(ptPick, _T("\n请给出裁剪延伸的基准点"), ptBase) != RTNORM)
|
||
{
|
||
entDim.Redraw(4);
|
||
return;
|
||
}
|
||
entDim.Redraw(4);
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim->IsBind())
|
||
{
|
||
adsout << _T("\n尺寸对象已经绑定在其他对象上,不能进行编辑!");
|
||
return;
|
||
}
|
||
ptBase=Ucs2Wcs(ptBase);
|
||
TGGeCurveSegment seg=pDim->GetDimCurve();
|
||
XPoint ptBaseOnSeg;
|
||
VERIFY(seg.ProjectToMe(ptBase, ptBaseOnSeg)==RTNORM);
|
||
if((ptBaseOnSeg&seg)!=PR_INSIDE)
|
||
{
|
||
if(pDim->AddSegment(ptBaseOnSeg))
|
||
{
|
||
AcGePoint3dArray ptArray;
|
||
pDim->getStretchPoints(ptArray);
|
||
AcDbIntArray indices;
|
||
if(ptBaseOnSeg.Distance2d(seg.StartPoint())<ptBaseOnSeg.Distance2d(seg.EndPoint()))
|
||
{
|
||
AcGeVector3d vtOffset=ptArray[2]-ptArray[2+1];
|
||
indices.append(3);
|
||
pDim->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
else
|
||
{
|
||
int numSeg=pDim->GetSegmentNum();
|
||
AcGeVector3d vtOffset=ptArray[2+numSeg]-ptArray[2+numSeg-1];
|
||
indices.append(2+numSeg-1);
|
||
pDim->moveGripPointsAt(indices, vtOffset);
|
||
}
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2, TRUE, FALSE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pDim->getClosestPointTo(ptBase, ptBase);
|
||
AcGePoint3dArray points;
|
||
AcDbVoidPtrArray curveSegments;
|
||
points.append(ptBase);
|
||
if (pDim->getSplitCurves(points, curveSegments) != Acad::eOk)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (curveSegments.length() == 2)
|
||
{
|
||
pDim->erase();
|
||
|
||
TDbDimension2 *pDim1 = (TDbDimension2*)curveSegments[0];
|
||
TDbDimension2 *pDim2 = (TDbDimension2*)curveSegments[1];
|
||
|
||
if (pDim1->GetTotalSegValue() > pDim2->GetTotalSegValue() )
|
||
{
|
||
AddToModelSpace((AcDbEntity*)curveSegments[0]);
|
||
delete pDim2;
|
||
}
|
||
else
|
||
{
|
||
AddToModelSpace((AcDbEntity*)curveSegments[1]);
|
||
delete pDim1;
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
// Command: 逐点标注
|
||
// 支持尺寸自调
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//modified by cwk on 060914
|
||
void DimContinue()
|
||
{
|
||
|
||
//add by lgy 20120507 保存当前空间是模型空间还是图纸空间
|
||
int iTitleMode = 0;
|
||
if (xg_getvar(_T("TILEMODE"), &iTitleMode) != RTNORM)//模型空间
|
||
{
|
||
return;
|
||
}
|
||
BOOL b = FALSE;
|
||
InitLayer(LAY_DIM, TRUE);
|
||
TDbDimension2 dim;
|
||
XPoint ptStart;
|
||
XPointList lstAddPoint; //wcs
|
||
XPointList lstBasePoint;//ucs
|
||
XPushVar<int> osmode(_T("OSMODE"), GetFullOsMode(OS_INT|OS_END));
|
||
|
||
if(XGetPoint(NULL, _T("\n起点"), ptStart)==RTNORM)
|
||
{
|
||
XPushVar<int> osmode1(_T("OSMODE"), GetFullOsMode(OS_PER|OS_INT|OS_END));
|
||
lstBasePoint.Append(new XPoint(ptStart));
|
||
ptStart=Ucs2Wcs(ptStart);
|
||
|
||
TDbDimension2 *pDim=&dim;
|
||
//add by cwk on 060915
|
||
if (pDim->GetSegmentNum() >= 1)
|
||
{
|
||
pDim->RemoveSegment(1);
|
||
}
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->setLayer(LAY_DIM);
|
||
pDim->SetDist2DimLine(6.0);
|
||
pDim->SetLocation(ptStart);
|
||
pDim->AppendSegment(2.0*_DIST_SNAP);
|
||
//modify by lgy 20120507 保存标注样式id,以用来在视口空间中是否需要转换
|
||
//pDim->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
AcDbObjectId idDimStyle = InitDimStyle(DS_LINEAR);
|
||
pDim->SetStyleId(idDimStyle);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
TDimensionEdJig jig(pDim, _T("\n第二点<退出>: "));
|
||
|
||
//add by lgy 20120507 如果当前是图纸空间
|
||
BOOL bExist = FALSE; //如果添加的新的标注样式已经存在,默认不添加不存在
|
||
if (iTitleMode == 0) //当前空间是图纸空间
|
||
{
|
||
TPickEntSet entSet;
|
||
entSet.Get(_T("X"), NULL, NULL, RBList(RTDXF0, _T("VIEWPORT"), NULL));
|
||
|
||
double dScale = 1.0;
|
||
BOOL bOnEnt = FALSE;
|
||
int nNum = GetPtOnWhichPort(ptStart, dScale, bOnEnt, entSet); //得到视口编号和视口比例
|
||
|
||
if (nNum > 1 && bOnEnt) //不是最外层的大视口
|
||
{
|
||
jig.m_bInView = TRUE;
|
||
jig.m_entSet = entSet;
|
||
jig.m_nPortNum = nNum;
|
||
jig.m_idDimOld = idDimStyle;
|
||
|
||
//获得原来标注样式在标注样式表中的名字
|
||
CString strName;
|
||
AcDbDimStyleTableRecord *pNewDimStyle = NULL;
|
||
OPENOBJ_BEGIN(idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
|
||
if (pDimStyle != NULL)
|
||
{
|
||
const TCHAR *pName = NULL;
|
||
pDimStyle->getName(pName);
|
||
strName = pName;
|
||
strName.Format(_T("%s_%.0f"), strName, 1/dScale);
|
||
pNewDimStyle = (AcDbDimStyleTableRecord*)pDimStyle->clone();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
AcDbDimStyleTable *pDimStyleTbl = NULL;
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
es = acdbHostApplicationServices()->workingDatabase()->getDimStyleTable(pDimStyleTbl, AcDb::kForWrite);
|
||
if (es != Acad::eOk)
|
||
{
|
||
delete pNewDimStyle;
|
||
pNewDimStyle = NULL;
|
||
return;
|
||
}
|
||
|
||
AcDbObjectId id;
|
||
if (!pDimStyleTbl->has(strName))
|
||
{
|
||
if (pNewDimStyle != NULL)
|
||
{
|
||
pNewDimStyle->setName(strName);
|
||
pNewDimStyle->setDimlfac(1/dScale);
|
||
|
||
pDimStyleTbl->add(id, pNewDimStyle);
|
||
pDim->SetStyleId(id);
|
||
jig.m_idDimNew = id;
|
||
pNewDimStyle->close();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pNewDimStyle != NULL)
|
||
{
|
||
delete pNewDimStyle;
|
||
pNewDimStyle = NULL;
|
||
}
|
||
pDimStyleTbl->getAt(strName, id);
|
||
pDim->SetStyleId(id);
|
||
jig.m_idDimNew = id;
|
||
bExist = TRUE;
|
||
}
|
||
pDimStyleTbl->close();
|
||
}
|
||
}
|
||
|
||
jig.Step();//add by whl
|
||
jig.m_nFlag=0;
|
||
jig.doIt();
|
||
//modify by lgy 20120510 逐点标注jig时如果退出了命令需要删除添加的标注样式
|
||
//if(jig.GetRetCode()!=RTNORM)
|
||
// return;
|
||
if (jig.GetRetCode() != RTNORM)
|
||
{
|
||
if (!bExist)
|
||
{
|
||
OPENOBJ_BEGIN(jig.m_idDimNew, AcDb::kForWrite, AcDbDimStyleTableRecord, pRecord);
|
||
if (pRecord)
|
||
{
|
||
pRecord->erase();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return;
|
||
}
|
||
|
||
if(!pDim->IsValid())
|
||
{
|
||
adsout << _T("请正确点取!");
|
||
return;
|
||
}
|
||
|
||
//add by lgy 20120509 如果标注样式没有考虑视口,需要将之前添加到标注样式表中的
|
||
//标注样式删除掉
|
||
if (!jig.m_bSaveStyle && !bExist)
|
||
{
|
||
OPENOBJ_BEGIN(jig.m_idDimNew, AcDb::kForWrite, AcDbDimStyleTableRecord, pRecord);
|
||
if (pRecord)
|
||
{
|
||
pRecord->erase();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
/*
|
||
static int nAnswer=Q_NO;
|
||
nAnswer=YesNoQuestion(_T("\n是否同时作为标注点"), nAnswer);
|
||
if(nAnswer==RTCAN)
|
||
return;
|
||
*/
|
||
XPoint ptSec=jig.m_ptDim;
|
||
XPoint ptAdd;
|
||
XPoint ptBase;
|
||
ptAdd = ptSec;
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
ptBase = Wcs2Ucs(ptAdd);
|
||
lstBasePoint.Append(new XPoint(ptAdd));
|
||
LAB_REINPUT:
|
||
jig.m_pszPrompt=_T("\n请点取尺寸线位置或 [更正尺寸线方向(D)]<退出>: ");
|
||
jig.Step();//add by whl
|
||
jig.m_nFlag=1;
|
||
jig.m_pszKeyword=_T("D");
|
||
int nKeywordIndex=0;
|
||
INITGET_BEG(-1, _T("D"));
|
||
jig.doIt();
|
||
INITGET_END();
|
||
int nRetCode=jig.GetRetCode();
|
||
//modify by lgy 20120510
|
||
//if(nRetCode==RTCAN)
|
||
// return;
|
||
if (nRetCode == RTCAN)
|
||
{
|
||
if (!bExist)
|
||
{
|
||
OPENOBJ_BEGIN(jig.m_idDimNew, AcDb::kForWrite, AcDbDimStyleTableRecord, pRecord);
|
||
if (pRecord)
|
||
{
|
||
pRecord->erase();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return;
|
||
}
|
||
|
||
else if(nRetCode==RTKWORD)
|
||
{
|
||
Entity entDir;
|
||
double nDirection=0.0;
|
||
if(entDir.FilterSelect(_T("\n选择墙或线确定尺寸方向<退出>:"),
|
||
RBList(RTDXF0, _T("LINE,ATS_WALL,ATS_CURTAIN_WALL"), NULL), XPoint())==RTNORM)
|
||
{
|
||
if(entDir.Is(_T("LINE")))
|
||
{
|
||
XLine ln(entDir);
|
||
nDirection=ln.Direction();
|
||
}
|
||
else
|
||
{
|
||
OPENOBJ_BEGIN(entDir, AcDb::kForRead, TDbWall, pWall);
|
||
if(pWall)
|
||
nDirection=pWall->XLine::Direction();
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
else
|
||
return;
|
||
|
||
XVector3D vt=ptSec-ptStart;
|
||
double nVal = (vt&XVector3D(cos(nDirection), sin(nDirection)));
|
||
pDim->SetRotation(nDirection);
|
||
pDim->SetSegment(0, nVal);
|
||
goto LAB_REINPUT;
|
||
}
|
||
LAB_RE:
|
||
AcDbObjectId m_id;
|
||
if(pDim->IsValid() && jig.GetRetCode()!=RTCAN)
|
||
{
|
||
TDbDimension2 *pDimNew = (TDbDimension2 *)pDim->clone();
|
||
ASSERT(pDimNew);
|
||
if(g_nDimAdjust) pDimNew->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDimNew->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//m_id = pDimNew->AddToCSpace(Adesk::kTrue);
|
||
m_id = AddToSpace(Adesk::kTrue, (TDbEntity*)pDimNew);
|
||
}
|
||
TDbDimension2 *pDimTemp;
|
||
acdbOpenObject(pDimTemp,m_id,AcDb::kForRead);
|
||
int nRet;
|
||
XString szPrompt;
|
||
while(1)
|
||
{
|
||
pDimTemp->getEndPoint(ptBase);
|
||
ptBase = Wcs2Ucs(ptBase);
|
||
int nLen = lstAddPoint.Length();
|
||
_stprintf(szPrompt, _T("\n请输入其他标注点或 [撤消上一标注点(U)]<退出>: "));
|
||
|
||
INITGET_BEG(0, _T("U R"));
|
||
nRet = acedGetPoint(ptBase, szPrompt, ptAdd);
|
||
INITGET_END();
|
||
if(nRet == RTNORM)
|
||
{
|
||
ptBase = ptAdd;
|
||
ptAdd = Ucs2Wcs(ptAdd);
|
||
if(pDimTemp->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(!pDimTemp->AddSegment(ptAdd))
|
||
adsout << _T("\n点取位置不合适!");
|
||
else
|
||
{
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDimTemp->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
|
||
pDimTemp->downgradeOpen();
|
||
}
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('R'))
|
||
acedGetPoint(NULL, _T("\n参考点:"), ptBase);
|
||
else if(sKey[0] == _T('U'))
|
||
{
|
||
if(pDimTemp->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(nLen > 0)
|
||
{
|
||
ptAdd = *lstAddPoint.Tail();
|
||
lstAddPoint.Remove(nLen-1);
|
||
pDimTemp->HitTestOnPoint(ptAdd);
|
||
pDimTemp->FindAndRemoveSegment(ptAdd);
|
||
lstBasePoint.Remove(nLen);
|
||
ptBase = *lstBasePoint.Tail();
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDimTemp->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
}
|
||
pDimTemp->downgradeOpen();
|
||
}
|
||
}
|
||
if (lstAddPoint.Length() <= 0)
|
||
{
|
||
b = FALSE;
|
||
if(pDimTemp->upgradeOpen() == Acad::eOk)
|
||
{
|
||
pDimTemp->erase();
|
||
}
|
||
jig.m_pszKeyword=NULL;
|
||
BOOL bFirst=TRUE;
|
||
jig.m_nFlag=3;
|
||
jig.m_pTemp=(TDbDimension2 *)pDim->clone();
|
||
jig.Undo(); //add by cwk on 060918
|
||
jig.m_pszKeyword=_T("U");
|
||
jig.m_pszPrompt = _T("\n请输入第二标注点<退出>: ");
|
||
int nRet=jig.doIt();
|
||
if(nRet==RTNORM)
|
||
{
|
||
jig.Swap();
|
||
jig.Step();
|
||
ptAdd = jig.m_ptDim;
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
ptBase = Wcs2Ucs(ptAdd);
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDimTemp->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
else
|
||
break;
|
||
goto LAB_RE;
|
||
}
|
||
}
|
||
else if (nRet == RTCAN)
|
||
{
|
||
if(pDimTemp->upgradeOpen() == Acad::eOk)
|
||
{
|
||
pDimTemp->erase();
|
||
pDimTemp->downgradeOpen();
|
||
}
|
||
return;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
pDimTemp->close();
|
||
}
|
||
}
|
||
|
||
int CmpPoint(const XPoint *pt1, const XPoint *pt2)
|
||
{
|
||
if(pt1->z < pt2->z)
|
||
return -1;
|
||
else
|
||
return 1;
|
||
}
|
||
// add by lcf 2004/08/11
|
||
class TDimTwoPointArg
|
||
{
|
||
public:
|
||
DListStack<XPoint> m_ptStack;
|
||
void AddDim(AcDbObjectId idDim, XPoint ptNew);
|
||
void RemoveDim(AcDbObjectId idDim, XPoint ptOld);
|
||
void Step(XPoint ptNew);
|
||
BOOL CanUndo();
|
||
void Undo(AcDbObjectId idDim);
|
||
XPoint GetLastPoint();
|
||
};
|
||
|
||
void TDimTwoPointArg::AddDim(AcDbObjectId idDim, XPoint ptNew)
|
||
{
|
||
ptNew = Ucs2Wcs(ptNew);
|
||
OPENOBJ_BEGIN(idDim, AcDb::kForWrite, TDbDimension2, pDimNew);
|
||
ASSERT(pDimNew);
|
||
pDimNew->AddSegment(ptNew);
|
||
if(g_nDimAdjust)
|
||
pDimNew->AdjustDim(g_nDimAdjust!=2);
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
void TDimTwoPointArg::RemoveDim(AcDbObjectId idDim, XPoint ptOld)
|
||
{
|
||
ptOld = Ucs2Wcs(ptOld);
|
||
OPENOBJ_BEGIN(idDim, AcDb::kForWrite, TDbDimension2, pDimNew);
|
||
ASSERT(pDimNew);
|
||
pDimNew->FindAndRemoveSegment(ptOld);
|
||
if(g_nDimAdjust) pDimNew->AdjustDim(g_nDimAdjust!=2);
|
||
OPENOBJ_END();
|
||
}
|
||
void TDimTwoPointArg::Step(XPoint ptNew)
|
||
{
|
||
m_ptStack.Push(ptNew);
|
||
}
|
||
|
||
BOOL TDimTwoPointArg::CanUndo()
|
||
{
|
||
return m_ptStack.GetDepth() > 0;
|
||
}
|
||
|
||
void TDimTwoPointArg::Undo(AcDbObjectId idDim)
|
||
{
|
||
XPoint pt;
|
||
m_ptStack.GetTopData(pt);
|
||
if(CanUndo())
|
||
RemoveDim(idDim, pt);
|
||
m_ptStack.GoBack();
|
||
}
|
||
|
||
XPoint TDimTwoPointArg::GetLastPoint()
|
||
{
|
||
XPoint pt;
|
||
m_ptStack.GetTopData(pt);
|
||
return pt;
|
||
}
|
||
|
||
//得到墙离pt点较近一端相邻的墙的门窗和柱子idOpenList1。和较远一端相邻的墙的门窗和柱子idOpenList2两点标注用
|
||
BOOL GetOtherWallOpens(TDbWall* pWall, const TADSGePoint3d& pt, TGGeCurveSegment& segWall,
|
||
TDPtrList<AcDbSoftPointerId>& idOpenList1,TDPtrList<AcDbSoftPointerId>& idOpenList2)
|
||
{
|
||
AcDbObjectId idOther,idcolum;
|
||
TADSGePoint3d ptProj;
|
||
TADSGePoint3d ptS,ptE;
|
||
AcGeVector3d vt,vt1;
|
||
|
||
TDPtrList<AcDbSoftPointerId> idOpenListTmp;
|
||
idOpenList1.Reset();
|
||
idOpenList2.Reset();
|
||
pWall->ProjectToMe(pt, ptProj);
|
||
vt = pWall->StartPoint().AsAcGePoint3d() - pWall->EndPoint().AsAcGePoint3d();
|
||
if (ptProj.Distance2d(pWall->StartPoint()) < ptProj.Distance2d(pWall->EndPoint()))
|
||
{
|
||
segWall.SetPoints(pWall->StartPoint(), pWall->EndPoint());
|
||
//start近
|
||
idOther = pWall->GetLeftStart(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList1 << idOpenListTmp;
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
idOther = pWall->GetRightStart(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList1 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
//wlw 默认去掉柱子的标注14.08.20
|
||
//idcolum = pWall->GetStartColumnId();
|
||
//if (idcolum.isValid())
|
||
//{
|
||
//idOpenList1.Append(new AcDbSoftPointerId(idcolum));
|
||
//}
|
||
|
||
//远
|
||
idOther = pWall->GetLeftEnd(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList2 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
idOther = pWall->GetRightEnd(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList2 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
//wlw 默认去掉柱子的标注14.08.20
|
||
//idcolum = pWall->GetEndColumnId();
|
||
//if (idcolum.isValid())
|
||
//{
|
||
//idOpenList2.Append(new AcDbSoftPointerId(idcolum));
|
||
//}
|
||
|
||
}
|
||
else
|
||
{
|
||
segWall.SetPoints(pWall->EndPoint(), pWall->StartPoint());
|
||
//end近
|
||
idOther = pWall->GetLeftEnd(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList1 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
idOther = pWall->GetRightEnd(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList1 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
//wlw 默认去掉柱子的标注14.08.20
|
||
//idcolum = pWall->GetEndColumnId();
|
||
//if (idcolum.isValid())
|
||
//{
|
||
//idOpenList1.Append(new AcDbSoftPointerId(idcolum));
|
||
//}
|
||
|
||
//start远
|
||
idOther = pWall->GetLeftStart(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList2 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
idOther = pWall->GetRightStart(FALSE);
|
||
OPENOBJ_BEGIN(idOther, AcDb::kForRead, TDbWall, pOther)
|
||
if (pOther != NULL)
|
||
{
|
||
vt1 = pOther->StartPoint().AsAcGePoint3d() - pOther->EndPoint().AsAcGePoint3d();
|
||
if (!vt.isParallelTo(vt1))
|
||
{
|
||
idOpenListTmp.Reset();
|
||
idOpenListTmp.copyFrom(pOther->GetOpeningIdList());
|
||
idOpenList2 << idOpenListTmp;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
//wlw 默认去掉柱子的标注14.08.20
|
||
//idcolum = pWall->GetStartColumnId();
|
||
//if (idcolum.isValid())
|
||
//{
|
||
//idOpenList2.Append(new AcDbSoftPointerId(idcolum));
|
||
//}
|
||
}
|
||
return idOpenList1.Length() > 0;
|
||
}
|
||
|
||
//wlw 121017 显示两点标注后的jig效果,实现距离墙远近不同标注内容
|
||
class T2PtDimensionJig : public AcEdJig
|
||
{
|
||
public:
|
||
T2PtDimensionJig(TDbDimension2 *pDim, const TGGeCurveSegment& wall,const TADSGePointList& lstPts,
|
||
const TADSGePointList& lstPts1,const TADSGePointList& lstPts2);
|
||
AcEdJig::DragStatus doIt();
|
||
virtual DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
TDbDimension2 *m_pDrawEnt;
|
||
AcGePoint3d m_ptDim;
|
||
int m_bFlag; //判断近端还是远端
|
||
BOOL m_bAppend; //用来决定远近端变换的
|
||
TGGeCurveSegment m_segwall; //用来判断远近端的参考墙基线
|
||
TADSGePointList m_lstPts; //所有墙的投影点
|
||
TADSGePointList m_lstPts1; //近端门窗的投影点
|
||
TADSGePointList m_lstPts2; //远端门窗的投影点
|
||
};
|
||
|
||
T2PtDimensionJig::T2PtDimensionJig(TDbDimension2 *pDim, const TGGeCurveSegment& wall,const TADSGePointList& lstPts,
|
||
const TADSGePointList& lstPts1,const TADSGePointList& lstPts2)
|
||
{
|
||
m_pDrawEnt = pDim;
|
||
m_bFlag = 1;
|
||
m_bAppend = FALSE;
|
||
m_segwall = wall;
|
||
m_lstPts.copyFrom(lstPts);
|
||
m_lstPts1.copyFrom(lstPts1);
|
||
m_lstPts2.copyFrom(lstPts2);
|
||
|
||
int nLen = m_lstPts.Length();
|
||
for(int n = 0; n < nLen; n++)
|
||
{
|
||
m_pDrawEnt->AddSegment(*m_lstPts[n]);
|
||
}
|
||
//初始值为墙近端的门窗标注
|
||
nLen = m_lstPts1.Length();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDrawEnt->AddSegment(*m_lstPts1[n]);
|
||
}
|
||
m_pDrawEnt->SetFixLinePos(m_segwall.StartPoint());
|
||
|
||
}
|
||
|
||
AcEdJig::DragStatus T2PtDimensionJig::doIt()
|
||
{
|
||
setDispPrompt(_T("\n选择标注位置点"));
|
||
return drag();
|
||
}
|
||
|
||
AcEdJig::DragStatus T2PtDimensionJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
XPoint ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptDim) > _DIST_SNAP)
|
||
m_ptDim = ptCursor;
|
||
else
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean T2PtDimensionJig::update()
|
||
{
|
||
TADSGePoint3d ptProj;
|
||
m_segwall.ProjectToMe(m_ptDim, ptProj);
|
||
int nLen = 0;
|
||
int nNum = 0, n = 0;
|
||
TADSGePoint3d ptSide,ptSide1;
|
||
if (m_bFlag == 1)
|
||
{//当前标注在近端
|
||
if (ptProj.Distance2d(m_segwall.StartPoint()) > ptProj.Distance2d(m_segwall.EndPoint()))
|
||
{
|
||
m_bFlag = 2;
|
||
m_bAppend = TRUE;
|
||
}
|
||
}
|
||
else if (m_bFlag == 2)
|
||
{//当前标注在远端
|
||
if (ptProj.Distance2d(m_segwall.StartPoint()) < ptProj.Distance2d(m_segwall.EndPoint()))
|
||
{
|
||
m_bFlag = 1;
|
||
m_bAppend = TRUE;
|
||
}
|
||
}
|
||
|
||
if (m_bAppend)
|
||
{
|
||
m_bAppend = FALSE;
|
||
double dr = m_segwall.Direction(m_ptDim);
|
||
int ncount = m_pDrawEnt->GetSegmentNum();
|
||
while(m_pDrawEnt->GetSegmentNum() > 0)
|
||
m_pDrawEnt->RemoveSegment(0);
|
||
|
||
m_pDrawEnt->SetLocation(*m_lstPts[0]);
|
||
|
||
nLen = m_lstPts.Length();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDrawEnt->AddSegment(*m_lstPts[n]);
|
||
}
|
||
if (m_bFlag == 2)
|
||
{
|
||
nLen = m_lstPts2.Length();
|
||
ptSide = m_segwall.EndPoint();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDrawEnt->AddSegment(*m_lstPts2[n]);
|
||
}
|
||
}
|
||
else if (m_bFlag == 1)
|
||
{
|
||
nLen = m_lstPts1.Length();
|
||
ptSide = m_segwall.StartPoint();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDrawEnt->AddSegment(*m_lstPts1[n]);
|
||
}
|
||
}
|
||
TADSGePoint3d ptEnd=*m_lstPts[m_lstPts.Length()-1],ptStart=*m_lstPts[0];
|
||
XVector3D vt=ptEnd-ptStart;
|
||
XVector3D vtSeg(m_segwall.EndPoint().x-m_segwall.StartPoint().x,m_segwall.EndPoint().y-m_segwall.StartPoint().y);
|
||
if((vt*vtSeg).z<0)
|
||
dr+=PI/2;
|
||
else
|
||
dr-=PI/2;
|
||
m_pDrawEnt->SetFixLinePos(ptSide);
|
||
}
|
||
|
||
TGGeCurveSegment seg = m_pDrawEnt->GetDimCurve();
|
||
seg.ProjectToMe(m_ptDim, ptProj);
|
||
double nDistMove = ptProj.Distance2d(m_ptDim);
|
||
int nSideLoc=seg.OnWhichSide(m_pDrawEnt->GetLocation());
|
||
int nSide=seg.OnWhichSide(m_ptDim);
|
||
double nDist2Dim = m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
double nFactor=nDist2Dim/fabs(nDist2Dim);
|
||
if(nSide!=nSideLoc)
|
||
nDistMove *= nFactor;
|
||
else
|
||
nDistMove *= -nFactor;
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
nDistMove = -nDistMove;
|
||
}
|
||
if(m_pDrawEnt->IsAngular())
|
||
{ //弧墙有错,不知道原因
|
||
nDist2Dim += nDistMove;
|
||
double nDistRad= m_pDrawEnt->GetDimRadius();
|
||
//seg.GetArc().center.Distance(m_ptDim);
|
||
nDistRad -= nDistMove;
|
||
if(nDistRad>_DIST_SNAP)
|
||
{
|
||
m_pDrawEnt->SetDimRadius(nDistRad);
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
nDist2Dim += nDistMove;
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* T2PtDimensionJig::entity() const
|
||
{
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
//wlw 130529 显示两点标注后的双线标注jig效果,实现距离墙远近不同标注内容
|
||
class T2PtDimensionJig2 : public AcEdJig
|
||
{
|
||
public:
|
||
T2PtDimensionJig2(TDbDimension2 *pDim, const TGGeCurveSegment& wall,const TADSGePointList& lstPts,
|
||
const TADSGePointList& lstPts1,const TADSGePointList& lstPts2, TDbDimension2 *pDim2);
|
||
AcEdJig::DragStatus doIt();
|
||
virtual DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity* entity() const;
|
||
//TDbDimension2 *m_pDrawEnt;
|
||
AcGePoint3d m_ptDim;
|
||
int m_bFlag; //判断近端还是远端
|
||
BOOL m_bAppend; //用来决定远近端变换的
|
||
TGGeCurveSegment m_segwall; //用来判断远近端的参考墙基线
|
||
TADSGePointList m_lstPts; //所有墙的投影点
|
||
TADSGePointList m_lstPts1; //近端门窗的投影点
|
||
TADSGePointList m_lstPts2; //远端门窗的投影点
|
||
|
||
TMulDimEntity1 m_pDim;//标注
|
||
|
||
};
|
||
|
||
T2PtDimensionJig2::T2PtDimensionJig2(TDbDimension2 *pDim, const TGGeCurveSegment& wall,const TADSGePointList& lstPts,
|
||
const TADSGePointList& lstPts1,const TADSGePointList& lstPts2,TDbDimension2 *pDim2)
|
||
{
|
||
m_pDim.m_pDrawEnt = pDim;
|
||
m_pDim.m_pDrawEnt2 = pDim2;
|
||
m_bFlag = 1;
|
||
m_bAppend = FALSE;
|
||
m_segwall = wall;
|
||
m_lstPts.copyFrom(lstPts);
|
||
m_lstPts1.copyFrom(lstPts1);
|
||
m_lstPts2.copyFrom(lstPts2);
|
||
|
||
int nLen = m_lstPts.Length();
|
||
for(int n = 0; n < nLen; n++)
|
||
{
|
||
m_pDim.m_pDrawEnt->AddSegment(*m_lstPts[n]);
|
||
}
|
||
//初始值为墙近端的门窗标注
|
||
nLen = m_lstPts1.Length();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDim.m_pDrawEnt->AddSegment(*m_lstPts1[n]);
|
||
}
|
||
m_pDim.m_pDrawEnt->SetFixLinePos(m_segwall.StartPoint());
|
||
|
||
AcGePoint3d pts,pte;
|
||
m_pDim.m_pDrawEnt->getStartPoint(pts);
|
||
m_pDim.m_pDrawEnt->getEndPoint(pte);
|
||
|
||
m_pDim.m_pDrawEnt2->SetLocation(pts);
|
||
|
||
m_pDim.m_pDrawEnt2->AddSegment(pts);
|
||
m_pDim.m_pDrawEnt2->AppendSegment(pte.distanceTo(pts));
|
||
|
||
m_pDim.m_pDrawEnt2->SetFixLinePos(m_segwall.StartPoint());
|
||
|
||
|
||
}
|
||
|
||
AcEdJig::DragStatus T2PtDimensionJig2::doIt()
|
||
{
|
||
setDispPrompt(_T("\n选择标注位置点"));
|
||
return drag();
|
||
}
|
||
|
||
AcEdJig::DragStatus T2PtDimensionJig2::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
XPoint ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptDim) > _DIST_SNAP)
|
||
m_ptDim = ptCursor;
|
||
else
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
Adesk::Boolean T2PtDimensionJig2::update()
|
||
{
|
||
TADSGePoint3d ptProj;
|
||
m_segwall.ProjectToMe(m_ptDim, ptProj);
|
||
int nLen = 0;
|
||
int nNum = 0, n = 0;
|
||
TADSGePoint3d ptSide,ptSide1;
|
||
if (m_bFlag == 1)
|
||
{//当前标注在近端
|
||
if (ptProj.Distance2d(m_segwall.StartPoint()) > ptProj.Distance2d(m_segwall.EndPoint()))
|
||
{
|
||
m_bFlag = 2;
|
||
m_bAppend = TRUE;
|
||
}
|
||
}
|
||
else if (m_bFlag == 2)
|
||
{//当前标注在远端
|
||
if (ptProj.Distance2d(m_segwall.StartPoint()) < ptProj.Distance2d(m_segwall.EndPoint()))
|
||
{
|
||
m_bFlag = 1;
|
||
m_bAppend = TRUE;
|
||
}
|
||
}
|
||
|
||
if (m_bAppend)
|
||
{
|
||
m_bAppend = FALSE;
|
||
double dr = m_segwall.Direction(m_ptDim);
|
||
int ncount = m_pDim.m_pDrawEnt->GetSegmentNum();
|
||
while(m_pDim.m_pDrawEnt->GetSegmentNum() > 0)
|
||
m_pDim.m_pDrawEnt->RemoveSegment(0);
|
||
|
||
while(m_pDim.m_pDrawEnt2->GetSegmentNum() > 0)
|
||
m_pDim.m_pDrawEnt2->RemoveSegment(0);
|
||
|
||
m_pDim.m_pDrawEnt->SetLocation(*m_lstPts[0]);
|
||
|
||
nLen = m_lstPts.Length();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDim.m_pDrawEnt->AddSegment(*m_lstPts[n]);
|
||
}
|
||
if (m_bFlag == 2)
|
||
{
|
||
nLen = m_lstPts2.Length();
|
||
ptSide = m_segwall.EndPoint();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDim.m_pDrawEnt->AddSegment(*m_lstPts2[n]);
|
||
}
|
||
}
|
||
else if (m_bFlag == 1)
|
||
{
|
||
nLen = m_lstPts1.Length();
|
||
ptSide = m_segwall.StartPoint();
|
||
for(n = 0; n < nLen; n++)
|
||
{
|
||
m_pDim.m_pDrawEnt->AddSegment(*m_lstPts1[n]);
|
||
}
|
||
}
|
||
TADSGePoint3d ptEnd=*m_lstPts[m_lstPts.Length()-1],ptStart=*m_lstPts[0];
|
||
XVector3D vt=ptEnd-ptStart;
|
||
XVector3D vtSeg(m_segwall.EndPoint().x-m_segwall.StartPoint().x,m_segwall.EndPoint().y-m_segwall.StartPoint().y);
|
||
if((vt*vtSeg).z<0)
|
||
dr+=PI/2;
|
||
else
|
||
dr-=PI/2;
|
||
|
||
m_pDim.m_pDrawEnt->SetFixLinePos(ptSide);
|
||
|
||
m_pDim.m_pDrawEnt->getStartPoint(ptStart);
|
||
m_pDim.m_pDrawEnt->getEndPoint(ptEnd);
|
||
m_pDim.m_pDrawEnt2->SetLocation(ptStart);
|
||
m_pDim.m_pDrawEnt2->AddSegment(ptStart);
|
||
m_pDim.m_pDrawEnt2->AppendSegment(ptEnd.Distance2d(ptStart));
|
||
m_pDim.m_pDrawEnt2->SetFixLinePos(ptSide);
|
||
|
||
}
|
||
|
||
XPoint ptOnSeg;
|
||
TGGeCurveSegment seg;
|
||
seg = m_pDim.m_pDrawEnt->GetDimCurve();
|
||
if(seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = ptOnSeg.Distance2d(m_ptDim);
|
||
int nSideLoc = seg.OnWhichSide(m_pDim.m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptDim);
|
||
double nDist2Dim = m_pDim.m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
double nFactor = nDist2Dim/fabs(nDist2Dim);
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
if(nSide != nSideLoc)
|
||
{
|
||
nDistMove *= nFactor;
|
||
}
|
||
else
|
||
{
|
||
nDistMove *= -nFactor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
nDistMove *= -1;
|
||
}
|
||
nDist2Dim += nDistMove;
|
||
m_pDim.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
double ddis = m_pDim.m_pDrawEnt->GetPScale() * 8;
|
||
if(nDist2Dim >= 0)
|
||
nDist2Dim += ddis;
|
||
else
|
||
nDist2Dim -= ddis;
|
||
m_pDim.m_pDrawEnt2->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
}
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* T2PtDimensionJig2::entity() const
|
||
{
|
||
return (AcDbEntity*)&m_pDim;
|
||
}
|
||
|
||
class TLeaderJig : public AcEdJig
|
||
{
|
||
public:
|
||
TLeaderJig(AcGePoint3d pt)
|
||
{
|
||
|
||
m_pEnt = new AcDbLine;
|
||
m_pt = pt;
|
||
m_pEnt->setStartPoint(m_pt);
|
||
}
|
||
~TLeaderJig(){delete m_pEnt;}
|
||
int doIt()
|
||
{
|
||
setDispPrompt(_T("\n选择标注位置点"));
|
||
return drag();
|
||
}
|
||
virtual DragStatus sampler()
|
||
{
|
||
setSpecialCursorType(AcEdJig::kNoSpecialCursor);
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
AcGePoint3d ptCursor;
|
||
return acquirePoint(ptCursor, m_pt);
|
||
}
|
||
|
||
virtual Adesk::Boolean update(){return Adesk::kTrue;}
|
||
virtual AcDbEntity* entity() const{return (AcDbEntity*)m_pEnt;}
|
||
protected:
|
||
AcGePoint3d m_pt;
|
||
AcGePoint3d m_ptE;
|
||
AcDbLine *m_pEnt;
|
||
};
|
||
|
||
Adesk::Boolean isParallelToEnt(TEntitySet ent1,TEntitySet ent2)
|
||
{
|
||
AcGeTol tol;
|
||
tol.setEqualPoint(0.1);
|
||
tol.setEqualVector(0.1);
|
||
AcGePoint3d pt1s,pt1e,pt2s,pt2e;
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, AcDbCurve, pent1)
|
||
if (pent1 != NULL)
|
||
{
|
||
pent1->getEndPoint(pt1e);
|
||
pent1->getStartPoint(pt1s);
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
OPENOBJ_BEGIN(ent2, AcDb::kForRead, AcDbCurve, pent2)
|
||
if (pent2 != NULL)
|
||
{
|
||
pent2->getEndPoint(pt2e);
|
||
pent2->getStartPoint(pt2s);
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
AcGeVector3d vt1 = pt1s - pt1e,vt2 = pt2s - pt2e;
|
||
return vt1.isParallelTo(vt2, tol);
|
||
}
|
||
|
||
BOOL FindWallFromDote(TEntitySet entDote, TADSGePoint3d pt, TEntitySet &entWall)
|
||
{
|
||
TPickEntSet ssDimObj(SS_FREE);
|
||
|
||
TGGeCurveSegment segDote(entDote);
|
||
AcGeVector3d vt;
|
||
|
||
TADSGePoint3d pt1,pt2,ptOn;
|
||
segDote.ProjectToMe(pt, ptOn);
|
||
|
||
vt = ptOn.AsAcGePoint3d() - pt.AsAcGePoint3d();
|
||
vt.normalize();
|
||
pt1 = segDote.GetStartPoint();
|
||
pt2 = segDote.GetEndPoint();
|
||
AcGeVector3d vtDote = pt1.AsAcGePoint3d() - pt2.AsAcGePoint3d();
|
||
|
||
pt1 += vt * 500;
|
||
pt2 -= vt * 500;
|
||
|
||
//RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
RBList dimMask(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL"), NULL);
|
||
if (ssDimObj.Get(_T("C"), pt1, pt2, dimMask) != RTNORM)
|
||
{
|
||
return FALSE;
|
||
}
|
||
long nLen = ssDimObj.Length();
|
||
long i =0;
|
||
TPickEntSet ssDimDel(SS_FREE);
|
||
for(i=0;i<ssDimObj.Length();i++)
|
||
{
|
||
if (!isParallelToEnt(entDote, ssDimObj[i]))
|
||
{
|
||
ssDimDel += ssDimObj[i];
|
||
}
|
||
}
|
||
ssDimObj-=ssDimDel;
|
||
|
||
double minDist=1E10, distTmp = 0;
|
||
long nNum = 0;
|
||
BOOL bRet = FALSE;
|
||
for(i=0;i<ssDimObj.Length();i++)//最近的线作为方向基准
|
||
{
|
||
OPENOBJ_BEGIN(ssDimObj[i],AcDb::kForRead,TDbWall,pSeg);
|
||
if(pSeg!=NULL)
|
||
{
|
||
distTmp=ptOn.Distance2d(pSeg->MidPoint());
|
||
if(distTmp < minDist)
|
||
{
|
||
minDist = distTmp;
|
||
nNum = i;
|
||
bRet = TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
if (bRet)
|
||
{
|
||
entWall = ssDimObj[nNum];
|
||
}
|
||
return bRet;
|
||
|
||
}
|
||
//wlw add t9 的两点标注
|
||
void DimTwoPointArgOLD()
|
||
{
|
||
static BOOL bDimCen=FALSE;
|
||
|
||
XPoint pt1, pt2;
|
||
BOOL bPick1=FALSE, bPick2=FALSE; //顶点1, 2是否有物体
|
||
BOOL bPickObj=FALSE; //是否立即选物体
|
||
XCurveSegment seg1, seg2;
|
||
{
|
||
XPushVar<int> vOsMode(_T("OSMODE"), OS_NEA);
|
||
int iRet;
|
||
while(true)
|
||
{
|
||
INITGET_BEG(0,_T("C"));
|
||
if(!bDimCen)
|
||
iRet=ads_getpoint(NULL, _T("\n起点<退出>: "), pt1);
|
||
else
|
||
iRet=ads_getpoint(NULL, _T("\n起点<退出>: "), pt1);
|
||
INITGET_END();
|
||
|
||
if(iRet==RTKWORD)
|
||
bDimCen=!bDimCen;
|
||
else
|
||
break;
|
||
}
|
||
if(iRet!=RTNORM)
|
||
return;
|
||
|
||
PickSet ss1(SS_FREE);
|
||
RBList mask(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL,LINE"), NULL);
|
||
bPick1=(ss1.Get(NULL, &pt1, NULL, mask)==RTNORM);
|
||
if(bPick1 && ss1.Length()>0) {
|
||
Entity ent=ss1[0L];
|
||
if(ent.Is(_T("LINE")))
|
||
seg1=XCurveSegment(ent);
|
||
else {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
ASSERT(pWall);
|
||
XCurveSegment lCurve, rCurve, cCurve;
|
||
pWall->GetSideCurve(lCurve, rCurve);
|
||
cCurve=pWall->OffsetGeomCenter(LS_FINITE);
|
||
if(cCurve.OnWhichSide(Ucs2Wcs(pt1))==0)
|
||
seg1=lCurve;
|
||
else seg1=rCurve;
|
||
OPENOBJ_END();
|
||
}
|
||
XPoint ptOnCurve;
|
||
seg1.ProjectToMe(Ucs2Wcs(pt1), ptOnCurve);
|
||
pt1=Wcs2Ucs(ptOnCurve);
|
||
}
|
||
|
||
if(bPick1) {
|
||
int nInput=ads_getpoint(pt1, _T("\n终点<选物体>: "), pt2);
|
||
if(nInput==RTNONE)
|
||
bPickObj=TRUE;
|
||
else if(nInput==RTNORM)
|
||
;
|
||
else
|
||
return;
|
||
} else {
|
||
if(ads_getpoint(pt1, _T("\n终点<退出>: "), pt2)!=RTNORM)
|
||
return;
|
||
}
|
||
if(!bPickObj) {
|
||
PickSet ss2(SS_FREE);
|
||
bPick2=(ss2.Get(NULL, &pt2, NULL, mask)==RTNORM);
|
||
|
||
if(bPick2 && ss2.Length()>0) {
|
||
Entity ent=ss2[0L];
|
||
if(ent.Is(_T("LINE")))
|
||
seg2=XCurveSegment(ent);
|
||
else {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
ASSERT(pWall);
|
||
XCurveSegment lCurve, rCurve, cCurve;
|
||
pWall->GetSideCurve(lCurve, rCurve);
|
||
cCurve=pWall->OffsetGeomCenter(LS_FINITE);
|
||
if(cCurve.OnWhichSide(Ucs2Wcs(pt2))==0)
|
||
seg2=lCurve;
|
||
else seg2=rCurve;
|
||
OPENOBJ_END();
|
||
}
|
||
if(bPick1) {
|
||
XLine lnDim(Ucs2Wcs(pt1), seg1.Direction(Ucs2Wcs(pt1))+PI/2);
|
||
XPoint ptInt[2];
|
||
int nIntNum=seg2.Intersection(lnDim, ptInt[0], ptInt[1]);
|
||
if(nIntNum==1)
|
||
pt2=Wcs2Ucs(ptInt[0]);
|
||
else if(nIntNum==2)
|
||
pt2=Wcs2Ucs(XPoint(XLine(ptInt[0], ptInt[1]).NearPoint(Ucs2Wcs(pt2))));
|
||
} else {
|
||
XPoint ptOnCurve;
|
||
seg2.ProjectToMe(Ucs2Wcs(pt2), ptOnCurve);
|
||
pt2=Wcs2Ucs(ptOnCurve);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
InitLayer(LAY_DIM, TRUE);
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
|
||
PickSet ssDimObj(SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
RBList dimMask(-4, _T("<or"),
|
||
RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL"),
|
||
-4, _T("<and"), RTDXF0, _T("LINE"), 8, LAY_AXIS, -4, _T("and>"),
|
||
-4, _T("or>"), NULL);
|
||
if(bPickObj || ssDimObj.Get(_T("F"), rbFence, NULL, dimMask)==RTNORM)
|
||
{
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
XLine ln(pt1, pt2);
|
||
ln.SetElevation(0.0);
|
||
|
||
XPointList lstDimPoints;
|
||
if(bPick1)
|
||
lstDimPoints.NewAppend(pt1);
|
||
|
||
if(bPickObj)
|
||
ln = XLine(pt1, seg1.Direction(pt1));
|
||
else
|
||
{
|
||
//决定标注线方向
|
||
if(!bPick1)//起点未选线
|
||
{
|
||
double minDist=1E10;
|
||
for(long i=0;i<ssDimObj.Length();i++)//最近的线作为方向基准
|
||
{
|
||
Entity ent=ssDimObj[i];
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbCurve,pSeg);
|
||
if(pSeg!=NULL)
|
||
{
|
||
AcGePoint3d ptCurve;
|
||
pSeg->getClosestPointTo(pt1,ptCurve);
|
||
double dist=pt1.Distance2d(ptCurve);
|
||
if(dist<minDist)
|
||
{
|
||
minDist=dist;
|
||
if(pSeg->isKindOf(TDbWall::desc()))
|
||
{
|
||
TDbWall*pWall=(TDbWall*)pSeg;
|
||
seg1=*pWall;
|
||
}
|
||
else
|
||
seg1=XCurveSegment(ent);
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
PickSet ssExclude(SS_FREE);
|
||
|
||
//过滤与标注线不正交的曲线
|
||
AcGeVector2d vt(seg1.EndPoint().x-seg1.StartPoint().x,seg1.EndPoint().y-seg1.StartPoint().y);//定位线矢量
|
||
vt.normalize();
|
||
for(long i=0;i<ssDimObj.Length();i++)
|
||
{
|
||
Entity ent=ssDimObj[i];
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbCurve,pCurve);
|
||
if(pCurve!=NULL)
|
||
{
|
||
XCurveSegment seg;
|
||
if(pCurve->isKindOf(TDbWall::desc()))
|
||
{
|
||
TDbWall*pWall=(TDbWall*)pCurve;
|
||
seg=*pWall;
|
||
}
|
||
else
|
||
seg=XCurveSegment(ent);
|
||
|
||
if(!seg.Is(CURVE_LINE))
|
||
ssExclude+=ssDimObj[i];
|
||
else
|
||
{
|
||
AcGeVector2d vt1(seg.EndPoint().x-seg.StartPoint().x,seg.EndPoint().y-seg.StartPoint().y);
|
||
vt1.normalize();
|
||
if(!vt1.isParallelTo(vt))
|
||
ssExclude+=ssDimObj[i];
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
ssDimObj-=ssExclude;
|
||
|
||
ssDimObj.Redraw(3);
|
||
const TCHAR *szPrompts[2]={ _T("请选择不要标注的轴线和墙体:"), _T("") };
|
||
while(ssExclude.Get(_T(":S:$"), szPrompts, NULL, dimMask)==RTNORM) {
|
||
ssExclude.Redraw(4);
|
||
ssDimObj -= ssExclude;
|
||
}
|
||
ssDimObj.Redraw(4);
|
||
|
||
DList<XCurveSegment> lstSegment; //要标注的曲线
|
||
int nLen=ssDimObj.Length();
|
||
for(i=0L; i<nLen; i++) {
|
||
Entity ent=ssDimObj[i];
|
||
if(ent.Is(_T("ATS_WALL"))||ent.Is(_T("ATS_CURTAIN_WALL"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
ASSERT(pWall);
|
||
if(bDimCen) {
|
||
XCurveSegment segCen=pWall->OffsetGeomCenter();
|
||
if(!!segCen)
|
||
lstSegment.Append(new XCurveSegment(segCen));
|
||
} else {
|
||
XCurveSegment lCurve, rCurve;
|
||
pWall->GetSideCurve(lCurve, rCurve);
|
||
if(!!lCurve)
|
||
lstSegment.Append(new XCurveSegment(lCurve));
|
||
if(!!rCurve)
|
||
lstSegment.Append(new XCurveSegment(rCurve));
|
||
}
|
||
OPENOBJ_END();
|
||
} else {
|
||
XCurveSegment seg(ent);
|
||
if(!!seg)
|
||
lstSegment.Append(new XCurveSegment(seg));
|
||
}
|
||
}
|
||
|
||
ln.SetLineFlag(LS_FINITE);
|
||
int nCount=lstSegment.Length();
|
||
for(int n=0; n<nCount; n++) {
|
||
XCurveSegment seg=*lstSegment[n];
|
||
seg.SetLineFlag(LS_FINITE);
|
||
XPoint ptInt[2];
|
||
seg.SetElevation(0.0);
|
||
int nIntNum=seg.Intersection(ln, ptInt[0], ptInt[1]);
|
||
for(int k=0; k<nIntNum; k++)
|
||
lstDimPoints.NewAppend(ptInt[k]);
|
||
}
|
||
|
||
if(bPick2)
|
||
lstDimPoints.NewAppend(pt2);
|
||
}
|
||
|
||
double nDirection=seg1.Direction(pt1);
|
||
XPoint ptFixLinePos;
|
||
bool bLinePosFixed=false;
|
||
|
||
PickSet ssOther(SS_FREE);
|
||
RBList rbOtherMask(RTDXF0, _T("ATS_OPENING,ATS_COLUMN"),NULL);
|
||
const TCHAR *sPrompt[2] = {_T("选择其他要标注的门窗和柱子:"), _T("")};
|
||
int nRet=ssOther.Get(_T(":$"), sPrompt, NULL, rbOtherMask);
|
||
if(nRet==RTCAN)
|
||
return;
|
||
|
||
if(nRet==RTNORM) {
|
||
long lOther=ssOther.Length();
|
||
for(long i=0L; i<lOther; i++) {
|
||
Entity entOther=ssOther[i];
|
||
if(entOther.Is(_T("ATS_COLUMN"))) {
|
||
XPoint ptLow, ptUp;
|
||
entOther.GetExtend(ptLow, ptUp);
|
||
ptLow.z=ptUp.z=0;
|
||
lstDimPoints.NewAppend(ptLow);
|
||
lstDimPoints.NewAppend(ptUp);
|
||
} else if(entOther.Is(_T("ATS_OPENING"))) {
|
||
OPENOBJ_BEGIN(entOther, AcDb::kForRead, TDbOpening, pWin);
|
||
ASSERT(pWin);
|
||
XPoint ptSide1, ptSide2;
|
||
pWin->GetSidePoints(ptSide1, ptSide2);
|
||
ptSide1.z=ptSide2.z=0;
|
||
lstDimPoints.NewAppend(ptSide1);
|
||
lstDimPoints.NewAppend(ptSide2);
|
||
if(!bDimCen)
|
||
{
|
||
ptFixLinePos=ptSide1;
|
||
bLinePosFixed=true;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
int nVertNum=lstDimPoints.Length();
|
||
if(nVertNum<2) {
|
||
adsout << _T("\n选中的对象数目太少, 不能进行两点标注!");
|
||
return;
|
||
}
|
||
|
||
// Add By LCF 2004/07/27
|
||
double dis = 0.0;
|
||
for(long i=0; i<nVertNum; i++)
|
||
{
|
||
dis = pt1.Distance2d(*lstDimPoints[i]);
|
||
lstDimPoints[i]->z = dis;
|
||
}
|
||
lstDimPoints.QuickSort(CmpPoint);
|
||
// Add End
|
||
for(i=0;i<nVertNum;i++)
|
||
lstDimPoints[i]->z=0;
|
||
|
||
XPoint ptEnd=*lstDimPoints[lstDimPoints.Length()-1],ptStart=*lstDimPoints[0];
|
||
XVector3D vt=ptEnd-ptStart;
|
||
XVector3D vtSeg(seg1.EndPoint().x-seg1.StartPoint().x,seg1.EndPoint().y-seg1.StartPoint().y);
|
||
if((vt*vtSeg).z<0)
|
||
nDirection+=PI/2;
|
||
else
|
||
nDirection-=PI/2;
|
||
TDbDimension2 dbDim;
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//dbDim.setLayer(InitLayer(LAY_DIM, FALSE));
|
||
dbDim.SetDist2DimLine(6.0);
|
||
dbDim.SetStyleId(InitDimStyle(DS_LINEAR));
|
||
dbDim.SetLocation(ptStart);
|
||
dbDim.SetRotation(nDirection);
|
||
if(!bLinePosFixed)
|
||
ads_polar(ptStart, nDirection-PI/2, 6.0*DocGetPScale(), ptFixLinePos);
|
||
double nVal = fabs(vt&XVector3D(cos(nDirection), sin(nDirection)));
|
||
if(nVal<_DIST_SNAP)
|
||
{
|
||
adsout << _T("\n选中的对象数目太少, 不能进行两点标注!");
|
||
return;
|
||
}
|
||
dbDim.AppendSegment(nVal);
|
||
dbDim.SetFixLinePos(ptFixLinePos);
|
||
dbDim.SetDimLinePos(ptStart);
|
||
|
||
for(int n=1; n<nVertNum-1; n++)
|
||
dbDim.AddSegment(*lstDimPoints[n]);
|
||
|
||
if(!dbDim.IsValid())
|
||
return;
|
||
|
||
TDbDimension2 *pDim=(TDbDimension2 *)dbDim.clone();
|
||
if(g_nDimAdjust) pDim->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//AcDbObjectId idDim=pDim->AddToMSpace(Adesk::kTrue);
|
||
AcDbObjectId idDim= AddToSpace(Adesk::kTrue, (TDbEntity *)pDim);
|
||
|
||
// modify by lcf 2004/08/11
|
||
TDimTwoPointArg dimTwo;
|
||
XPushVar<int> osmode(_T("OSMODE"), GetFullOsMode(OS_INT|OS_END));
|
||
XPoint ptBase = Wcs2Ucs(*lstDimPoints[nVertNum-1]);
|
||
XPoint ptShirr = ptBase;
|
||
XPoint ptOther;
|
||
while(true)
|
||
{
|
||
if(!dimTwo.CanUndo())
|
||
{
|
||
if(XGetPoint(ptShirr, _T("\n请输入其他标注点"), ptOther)== RTNORM)
|
||
{
|
||
ptShirr = ptOther;
|
||
dimTwo.Step(ptOther);
|
||
dimTwo.AddDim(idDim, ptOther);
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
|
||
int nRet2;
|
||
INITGET_BEG(0, _T("U R"));
|
||
nRet2 = acedGetPoint(ptShirr, _T("\n请输入其他标注点或 [参考点(R)/撤消上一标注点(U)]<退出>:"), ptOther);
|
||
INITGET_END();
|
||
|
||
if(nRet2 == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('R'))
|
||
acedGetPoint(NULL, _T("\n参考点:"), ptShirr);
|
||
else if(sKey[0] == _T('U'))
|
||
{
|
||
dimTwo.Undo(idDim);
|
||
if(dimTwo.CanUndo())
|
||
ptShirr = dimTwo.GetLastPoint();
|
||
else
|
||
ptShirr = ptBase;
|
||
}
|
||
}
|
||
else if(nRet2 == RTNORM)
|
||
{
|
||
ptShirr = ptOther;
|
||
dimTwo.Step(ptOther);
|
||
dimTwo.AddDim(idDim, ptOther);
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Add End
|
||
// Command: 两点标注/或墙中标注
|
||
// 用于平面图
|
||
// 支持尺寸自调
|
||
// 需要增加“标注位置的提示”
|
||
//nDoubleLine = 1 双线标注 wlw add 130529
|
||
void DimTwoPointArg(int nDoubleLine)
|
||
{
|
||
//wlw mod 130529支持jig,支持单选门窗
|
||
static BOOL bDimCen = FALSE;
|
||
XPoint pt1, pt2;
|
||
BOOL bPick1 = FALSE, bPick2 = FALSE; //顶点1, 2是否有物体
|
||
BOOL bPickObj = FALSE; //是否立即选物体
|
||
TGGeCurveSegment seg1, segx;
|
||
//XPushVar<int> vOsMode(_T("OSMODE"), OS_NEA);
|
||
int iRet;
|
||
InitLayer(LAY_DIM, TRUE);
|
||
|
||
for (;;)
|
||
{
|
||
INITGET_BEG(0, _T("C"));
|
||
if(!bDimCen)
|
||
iRet = ads_getpoint(NULL, _T("\n选择起点<退出>: "), pt1);
|
||
else
|
||
iRet = ads_getpoint(NULL, _T("\n选择起点<退出>: "), pt1);
|
||
INITGET_END();
|
||
|
||
if (iRet == RTNORM)
|
||
{
|
||
break;
|
||
}
|
||
else if (iRet == RTKWORD)
|
||
{
|
||
bDimCen = !bDimCen;
|
||
continue;
|
||
}
|
||
else
|
||
return;
|
||
}
|
||
|
||
if ( ads_getpoint(pt1, _T("\n选择终点<退出>: "), pt2) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
BOOL bDrawFisrtpt = FALSE;
|
||
long nLen = 0, nNum = 0;
|
||
for (;;)
|
||
{
|
||
TPickEntSet ssDimObj(SS_FREE);
|
||
TPickEntSet ssExclude(SS_FREE);
|
||
RBList rbFence=ads_buildlist(RT3DPOINT, &pt1, RT3DPOINT, &pt2, NULL);
|
||
RBList dimMask(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL,LINE"), NULL);
|
||
if (ssDimObj.Get(_T("F"), rbFence, NULL, dimMask) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
nLen = ssDimObj.Length();
|
||
pt1=Ucs2Wcs(pt1);
|
||
pt2=Ucs2Wcs(pt2);
|
||
long i =0;
|
||
|
||
TGGeCurveSegment ln(pt1, pt2,0),lndim;
|
||
ln.SetElevation(0.0);
|
||
|
||
TADSGePointList lstDimPoints;
|
||
if (bDrawFisrtpt)
|
||
{
|
||
lstDimPoints.NewAppend(pt1);
|
||
bDrawFisrtpt = FALSE;
|
||
}
|
||
double minDist=1E10, distTmp = 0;
|
||
bool bHaswall = false;
|
||
for(i=0;i<ssDimObj.Length();i++)//最近的线作为方向基准
|
||
{
|
||
Entity ent=ssDimObj[i];
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbCurve,pSeg);
|
||
if(pSeg!=NULL)
|
||
{
|
||
AcGePoint3d ptCurve;
|
||
pSeg->getClosestPointTo(pt1,ptCurve);
|
||
distTmp=pt1.Distance2d(ptCurve);
|
||
if(distTmp < minDist)
|
||
{
|
||
minDist=distTmp;
|
||
nNum = i;
|
||
if(pSeg->isKindOf(TDbWall::desc()))
|
||
{
|
||
TDbWall*pWall=(TDbWall*)pSeg;
|
||
seg1=*pWall;
|
||
bHaswall = true;
|
||
}
|
||
else
|
||
seg1=TGGeCurveSegment(ent);
|
||
}
|
||
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
//两点划过时在只经过轴线无墙时,需要遍历每一个轴线,得到该轴线下的墙线
|
||
ssExclude.Free();
|
||
ssExclude += ssDimObj;
|
||
ssExclude.BaseFilter(TRBList(RTDXF0, _T("Line"), NULL));
|
||
nLen = ssExclude.Length();
|
||
if (ssDimObj.Length() == nLen)
|
||
{
|
||
TGGeCurveSegment axline,axwall,axTmp;
|
||
OPENOBJ_BEGIN(ssExclude[0L], AcDb::kForRead, AcDbLine, pline)
|
||
if (pline)
|
||
{
|
||
pline->getStartPoint(axline.StartPoint());
|
||
pline->getEndPoint(axline.EndPoint());
|
||
}
|
||
OPENOBJ_END()
|
||
TADSGePoint3d ptonln;
|
||
axline.ProjectToMe(pt1, ptonln);
|
||
|
||
axline.SetStartPoint(pt1);
|
||
axline.SetEndPoint(ptonln);
|
||
axline.SetLineFlag(LS_INFINITE);
|
||
|
||
TEntitySet entWall;
|
||
TPickEntSet OnLineWall;
|
||
minDist = 10E10;
|
||
double ds,de;
|
||
for (i = 0; i < nLen; i++)
|
||
{
|
||
if(FindWallFromDote(ssExclude[i], pt1, entWall))
|
||
{
|
||
OPENOBJ_BEGIN(entWall, AcDb::kForRead, TDbWall, pline)
|
||
if (pline)
|
||
{
|
||
pline->getStartPoint(axwall.StartPoint());
|
||
pline->getEndPoint(axwall.EndPoint());
|
||
}
|
||
OPENOBJ_END()
|
||
ds = axline.GetDist2Me(axwall.StartPoint());
|
||
de = axline.GetDist2Me(axwall.EndPoint());
|
||
if (de < ds)
|
||
{
|
||
ds = de;
|
||
}
|
||
if (ds < minDist)
|
||
{//找到最近的墙
|
||
OnLineWall.Free();
|
||
minDist = ds;
|
||
}
|
||
if (fabs (ds - minDist) < 0.1)
|
||
{//找到距离相等的墙
|
||
OnLineWall += entWall;
|
||
}
|
||
}
|
||
}
|
||
ssDimObj += OnLineWall;
|
||
|
||
}
|
||
|
||
//过滤与标注线不正交的曲线
|
||
ssExclude.Free();
|
||
nLen = ssDimObj.Length();
|
||
AcGeVector3d vtFirst = seg1.StartPoint().AsAcGePoint3d() - seg1.EndPoint().AsAcGePoint3d();
|
||
vtFirst.normalize();
|
||
// seg1.ProjectToMe(pt1,pt1);
|
||
// pt2 = pt1 + vtFirst;
|
||
// ln.SetStartPoint(pt1);
|
||
// ln.SetEndPoint(pt2);
|
||
TEntitySet entfirst = ssDimObj[nNum];
|
||
|
||
for(i=0;i<nLen;i++)
|
||
{
|
||
if (!isParallelToEnt(entfirst,ssDimObj[i]))
|
||
{
|
||
ssExclude += ssDimObj[i];
|
||
}
|
||
}
|
||
ssDimObj-=ssExclude;
|
||
nLen = ssDimObj.Length();
|
||
DList<TGGeCurveSegment> lstSegment; //要标注的曲线
|
||
nLen = ssDimObj.Length();
|
||
minDist = 10000000;
|
||
for(i=0; i<nLen; i++)
|
||
{
|
||
Entity ent=ssDimObj[i];
|
||
if(ent.Is(_T("ATS_WALL"))||ent.Is(_T("ATS_CURTAIN_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
if (pWall == NULL)
|
||
continue;
|
||
|
||
distTmp = pWall->GetLength();
|
||
if (distTmp < minDist)
|
||
{//找到最短的墙 jig判断远近端时用
|
||
minDist = distTmp;
|
||
seg1 = *pWall;
|
||
}
|
||
if(bDimCen)
|
||
{
|
||
TGGeCurveSegment segCen=pWall->OffsetGeomCenter();
|
||
if(!!segCen)
|
||
lstSegment.Append(new TGGeCurveSegment(segCen));
|
||
}
|
||
else
|
||
{
|
||
TGGeCurveSegment lCurve, rCurve;
|
||
pWall->GetSideCurve(lCurve, rCurve,0.0,TRUE);
|
||
if(!!lCurve)
|
||
lstSegment.Append(new TGGeCurveSegment(lCurve));
|
||
if(!!rCurve)
|
||
lstSegment.Append(new TGGeCurveSegment(rCurve));
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
//wlw 默认去掉轴网的标注14.08.20
|
||
TGGeCurveSegment seg(ent);
|
||
if(!!seg)
|
||
lstSegment.Append(new TGGeCurveSegment(seg));
|
||
}
|
||
}
|
||
ln.SetLineFlag(LS_INFINITE);
|
||
int nCount=lstSegment.Length();
|
||
for(int n=0; n<nCount; n++)
|
||
{
|
||
segx=*lstSegment[n];
|
||
segx.SetLineFlag(LS_INFINITE);
|
||
XPoint ptInt[2];
|
||
segx.SetElevation(0.0);
|
||
int nIntNum=segx.Intersection(ln, ptInt[0], ptInt[1]);
|
||
for(int k=0; k<nIntNum; k++)
|
||
lstDimPoints.NewAppend(ptInt[k]);
|
||
}
|
||
|
||
int nVertNum = lstDimPoints.Length();
|
||
if(nVertNum < 1)
|
||
{
|
||
adsout << _T("\n选中的对象数目太少, 不能进行两点标注!");
|
||
return;
|
||
}
|
||
|
||
double nDirection=seg1.Direction(pt1);
|
||
XPoint ptFixLinePos;
|
||
bool bLinePosFixed=false;
|
||
|
||
// Add By LCF 2004/07/27
|
||
double dis = 0.0;
|
||
for(i=0; i<nVertNum; i++)
|
||
{
|
||
dis = pt1.Distance2d(*lstDimPoints[i]);
|
||
lstDimPoints[i]->z = dis;
|
||
}
|
||
lstDimPoints.QuickSort(CmpPoint);
|
||
// Add End
|
||
for(i=0;i<nVertNum;i++)
|
||
lstDimPoints[i]->z=0;
|
||
|
||
XPoint ptEnd = *lstDimPoints[lstDimPoints.Length()-1], ptStart=*lstDimPoints[0];
|
||
TVector3D vt = ptEnd - ptStart;
|
||
XVector3D vtSeg(seg1.EndPoint().x - seg1.StartPoint().x, seg1.EndPoint().y - seg1.StartPoint().y);
|
||
if((vt*vtSeg).z<0)
|
||
nDirection+=PI/2;
|
||
else
|
||
nDirection-=PI/2;
|
||
|
||
nLen = ssDimObj.Length();
|
||
TDPtrList<AcDbSoftPointerId> idOpenList1,idOpenList2;
|
||
TADSGePointList lstPoints1,lstPoints2;
|
||
TGGeCurveSegment segWall,segWall1(seg1),segWall2; //保留该seg用来判断jig时的方向
|
||
TGGeCurveSegment segDimBase(ptStart,ptEnd,0.0); //标注的基线范围
|
||
AcDbObjectId idTmp;
|
||
ads_name entCol;
|
||
TADSGePoint3d ptSide1, ptSide2, pttmp;
|
||
minDist = 10000000;
|
||
double dminWall = 0;
|
||
|
||
for(i= 0L; i < nLen; ++i)
|
||
{
|
||
OPENOBJ_BEGIN(ssDimObj[i], AcDb::kForRead, TDbWall, pWall);
|
||
if (pWall == NULL)
|
||
continue;
|
||
//if (fabs(pWall->GetLength() - minDist) > 0)
|
||
{//得到临墙的门窗和柱子
|
||
GetOtherWallOpens(pWall, pt1, segWall, idOpenList1,idOpenList2);
|
||
pWall->ProjectToMe(pt1, pttmp);
|
||
segWall2.SetStartPoint(pt1);
|
||
segWall2.SetEndPoint(pttmp);
|
||
segWall2.SetLineFlag(LS_INFINITE);
|
||
segWall2.ProjectToMe(segWall.StartPoint(), pttmp);
|
||
distTmp = pttmp.Distance2d(segWall.StartPoint());
|
||
if (distTmp < minDist)
|
||
{//找到距离标注点最近的点
|
||
minDist = distTmp;
|
||
segWall1.SetStartPoint(segWall.StartPoint());
|
||
segWall1.SetEndPoint(segWall.EndPoint());
|
||
dminWall = segWall1.GetLength();
|
||
}
|
||
else if (fabs(distTmp - minDist) < 0.1)
|
||
{//距离最近的点如果有很多,找最短的墙
|
||
if (segWall.GetLength() < dminWall)
|
||
{
|
||
segWall1.SetStartPoint(segWall.StartPoint());
|
||
segWall1.SetEndPoint(segWall.EndPoint());
|
||
dminWall = segWall.GetLength();
|
||
}
|
||
}
|
||
for (int k = 0; k < idOpenList2.Length(); ++k)
|
||
{
|
||
idTmp = *idOpenList2[k];
|
||
OPENOBJ_BEGIN(idTmp, AcDb::kForRead, TDbOpening, pWin)
|
||
if (pWin != NULL)
|
||
{
|
||
pWin->GetSidePoints(ptSide1, ptSide2);
|
||
segDimBase.ProjectToMe(ptSide1,pttmp);
|
||
if ((pttmp & segDimBase) == PR_INSIDE)
|
||
{
|
||
ptSide1.z=ptSide2.z=0;
|
||
lstPoints2.NewAppend(ptSide1);
|
||
lstPoints2.NewAppend(ptSide2);
|
||
if(!bDimCen)
|
||
{
|
||
ptFixLinePos=ptSide1;
|
||
bLinePosFixed=true;
|
||
}
|
||
}
|
||
continue;
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
OPENOBJ_BEGIN(idTmp, AcDb::kForRead, TDbColumn, pCol)
|
||
if (pCol != NULL)
|
||
{
|
||
acdbGetAdsName(entCol, idTmp);
|
||
Entity col1(entCol);
|
||
col1.GetExtend(ptSide1, ptSide2);
|
||
ptSide1.z=ptSide2.z=0;
|
||
lstPoints2.NewAppend(ptSide1);
|
||
lstPoints2.NewAppend(ptSide2);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
for (k = 0; k < idOpenList1.Length(); ++k)
|
||
{
|
||
idTmp = *idOpenList1[k];
|
||
OPENOBJ_BEGIN(idTmp, AcDb::kForRead, TDbOpening, pWin)
|
||
if (pWin != NULL)
|
||
{
|
||
pWin->GetSidePoints(ptSide1, ptSide2);
|
||
segDimBase.ProjectToMe(ptSide1, pttmp);
|
||
if ((pttmp & segDimBase) == PR_INSIDE)
|
||
{
|
||
ptSide1.z=ptSide2.z=0;
|
||
lstPoints1.NewAppend(ptSide1);
|
||
lstPoints1.NewAppend(ptSide2);
|
||
if(!bDimCen)
|
||
{
|
||
ptFixLinePos=ptSide1;
|
||
bLinePosFixed=true;
|
||
}
|
||
}
|
||
continue;
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
OPENOBJ_BEGIN(idTmp, AcDb::kForRead, TDbColumn, pCol)
|
||
if (pCol != NULL)
|
||
{
|
||
acdbGetAdsName(entCol, idTmp);
|
||
Entity col(entCol);
|
||
col.GetExtend(ptSide1, ptSide2);
|
||
ptSide1.z=ptSide2.z=0;
|
||
lstPoints1.NewAppend(ptSide1);
|
||
lstPoints1.NewAppend(ptSide2);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
TDbDimension2 dbDim;
|
||
dbDim.SetDist2DimLine(0.0);
|
||
dbDim.SetStyleId(InitDimStyle(DS_LINEAR));
|
||
dbDim.SetLocation(ptStart);
|
||
dbDim.SetRotation(nDirection);
|
||
if(!bLinePosFixed)
|
||
ads_polar(ptStart, nDirection-PI/2, 1.0, ptFixLinePos);
|
||
double nVal = fabs(vt&XVector3D(cos(nDirection), sin(nDirection)));
|
||
if(nVal<_DIST_SNAP)
|
||
{
|
||
adsout << _T("\n选中的对象数目太少, 不能进行两点标注!");
|
||
return;
|
||
}
|
||
//尺寸最大距离
|
||
dbDim.AppendSegment(nVal);
|
||
if(!dbDim.IsValid())
|
||
return;
|
||
|
||
|
||
//AddToModelSpace(new AcDbLine(segWall1.StartPoint(),segWall1.EndPoint()));
|
||
//AddToModelSpace(new AcDbLine(seg1.StartPoint(),seg1.EndPoint()));
|
||
AcEdJig::DragStatus esjig;
|
||
AcDbObjectId idDim,idDim2;
|
||
if (nDoubleLine == 1)
|
||
{//双线标注 wlw add 130529
|
||
TDbDimension2 *pdbDim2 = new TDbDimension2;
|
||
pdbDim2->SetDist2DimLine(0.0);
|
||
pdbDim2->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
pdbDim2->SetLocation(ptStart);
|
||
pdbDim2->SetRotation(nDirection);
|
||
|
||
T2PtDimensionJig2 jig2(&dbDim, segWall1,lstDimPoints,lstPoints1, lstPoints2, pdbDim2);
|
||
esjig = jig2.doIt();
|
||
if (esjig != AcEdJig::kNormal)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbDimension2 *pDim=(TDbDimension2 *)dbDim.clone();
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
pdbDim2->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
pDim->getEndPoint(pt1);
|
||
pDim->getStartPoint(ptStart);
|
||
pDim->getEndPoint(ptEnd);
|
||
if(g_nDimAdjust) pDim->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
idDim = AddToSpace(Adesk::kTrue, (TDbEntity *)pDim);
|
||
//标注合并
|
||
idDim2 = AddToSpace(Adesk::kTrue, (TDbEntity *)pdbDim2);
|
||
}
|
||
else
|
||
{
|
||
T2PtDimensionJig jig(&dbDim, segWall1,lstDimPoints,lstPoints1, lstPoints2);
|
||
esjig = jig.doIt();
|
||
|
||
if (esjig != AcEdJig::kNormal)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbDimension2 *pDim=(TDbDimension2 *)dbDim.clone();
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
pDim->getEndPoint(pt1);
|
||
pDim->getStartPoint(ptStart);
|
||
pDim->getEndPoint(ptEnd);
|
||
if(g_nDimAdjust) pDim->AdjustDim(g_nDimAdjust!=2);
|
||
idDim = AddToSpace(Adesk::kTrue, (TDbEntity *)pDim);
|
||
}
|
||
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
|
||
//SetHandCursorSelectEntity(entShow);
|
||
//SetHandCursorSelectType(_T("ATS_OPENING,ATS_COLUMN"));
|
||
//acedRegisterFilterWinMsg(MouseMoveMonitorByHandCursor);
|
||
//StartChangeCursor();
|
||
|
||
for (;;)
|
||
{
|
||
TADSGePoint3d ptPick;
|
||
BOOL bpickok = FALSE;
|
||
Entity ent1;
|
||
BOOL bisok = FALSE;
|
||
pt1 = Wcs2Ucs(pt1);
|
||
int nret = ads_getpoint(pt1, _T("\n选择终点或增删轴线、墙、门窗、柱子"), ptPick);
|
||
if(nret == RTNORM)
|
||
{
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
GetEntFromPt(ptPick, _T("ATS_OPENING,ATS_COLUMN,LINE,ATS_WALL,ATS_CURTAIN_WALL"), ent1);
|
||
if (ent1.Is(_T("ATS_OPENING")))
|
||
{
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, TDbOpening, pWin)
|
||
if (pWin != NULL)
|
||
{
|
||
pWin->GetSidePoints(ptSide1, ptSide2);
|
||
bpickok = 2;
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
if (ent1.Is(_T("ATS_COLUMN")))
|
||
{
|
||
ent1.GetExtend(ptSide1, ptSide2);
|
||
bpickok = 2;
|
||
}
|
||
if (ent1.Is(_T("LINE")))
|
||
{
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, AcDbLine, pLn)
|
||
if (pLn != NULL)
|
||
{
|
||
pLn->getEndPoint(ptSide1);
|
||
bpickok = 1;
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
if (ent1.Is(_T("ATS_CURTAIN_WALL")) || ent1.Is(_T("ATS_WALL")))
|
||
{
|
||
TGGeCurveSegment lCurve, rCurve;
|
||
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, TDbWall, pWall)
|
||
if (pWall != NULL)
|
||
{
|
||
pWall->GetSideCurve(lCurve, rCurve,0.0,TRUE);
|
||
}
|
||
OPENOBJ_END()
|
||
ptSide1 = lCurve.StartPoint();
|
||
ptSide2 = rCurve.StartPoint();
|
||
bpickok = 2;
|
||
}
|
||
|
||
ptSide1.z=ptSide2.z=0;
|
||
if (bpickok)
|
||
{
|
||
OPENOBJ_BEGIN(idDim, AcDb::kForWrite, TDbDimension2, pdimok)
|
||
if (pdimok->FindPoint(ptSide1))
|
||
{
|
||
pdimok->FindAndRemoveSegment(ptSide1);
|
||
}
|
||
else
|
||
{
|
||
pdimok->AddSegment(ptSide1);
|
||
}
|
||
if (bpickok > 1)
|
||
{
|
||
if (pdimok->FindPoint(ptSide2))
|
||
{
|
||
pdimok->FindAndRemoveSegment(ptSide2);
|
||
}
|
||
else
|
||
{
|
||
pdimok->AddSegment(ptSide2);
|
||
}
|
||
}
|
||
pdimok->getEndPoint(pt1);
|
||
TADSGePoint3d ptbase,ptbaseold;
|
||
ptbaseold = pdimok->GetLocation();
|
||
if(g_nDimAdjust) pdimok->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
//TGGeCurveSegment lntmp(ptSide1, ptSide2, 0);
|
||
//lntmp.ProjectToMe(ptbaseold,ptbase);
|
||
|
||
//double dlen = pdimok->GetDist2DimLine();
|
||
//double dddd = ptbase.Distance2d(ptbaseold) / pdimok->GetPScale();
|
||
//pdimok->SetDist2DimLine(dlen - dddd);
|
||
//pdimok->SetLocation(ptbase);
|
||
|
||
pdimok->recordGraphicsModified();
|
||
if (nDoubleLine == 1)
|
||
{
|
||
|
||
OPENOBJ_BEGIN(idDim2, AcDb::kForWrite, TDbDimension2, pdimok2)
|
||
if (pdimok2 != NULL)
|
||
{
|
||
TADSGePoint3d ptend2 = pt1;
|
||
TGGeCurveSegment segdim2 = pdimok2->GetDimCurve();
|
||
segdim2.ProjectToMe(ptend2, ptend2);
|
||
pdimok2->AddSegment(ptend2);
|
||
if (ptend2.Distance2d(segdim2.EndPoint()) > 1)
|
||
{
|
||
pdimok2->FindAndRemoveSegment(segdim2.EndPoint());
|
||
}
|
||
if(g_nDimAdjust) pdimok2->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
|
||
}
|
||
|
||
OPENOBJ_END()
|
||
}
|
||
OPENOBJ_END()
|
||
entShow.Redraw(4);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
else
|
||
{
|
||
entShow.Redraw(4);
|
||
pt2 = ptPick;
|
||
pt1 = Ucs2Wcs(pt1);
|
||
lndim.SetStartPoint(ptStart);
|
||
lndim.SetEndPoint(ptEnd);
|
||
lndim.ProjectToMe(pt2, pt2);
|
||
AcGeVector2d vt1 = ptEnd.AsAcGePoint2d() - ptStart.AsAcGePoint2d();
|
||
AcGeVector2d vt2 = pt2.AsAcGePoint2d() - pt1.AsAcGePoint2d();
|
||
|
||
if (!vt1.isCodirectionalTo(vt2))
|
||
{
|
||
continue;
|
||
}
|
||
//投影的开始的划过区域
|
||
// ln.ProjectToMe(pt1, pt1);
|
||
// ln.ProjectToMe(pt2, pt2);
|
||
// pt1 = Wcs2Ucs(pt1);
|
||
// pt2 = Wcs2Ucs(pt2);
|
||
// AcDbCircle *pcir = new AcDbCircle(pt1.AsAcGePoint3d(),AcGeVector3d::kZAxis,300);
|
||
// AddToModelSpace(pcir);
|
||
// AcDbLine *pln = new AcDbLine(ln.StartPoint().AsAcGePoint3d(),ln.EndPoint().AsAcGePoint3d());
|
||
// AddToModelSpace(pln);
|
||
|
||
bDrawFisrtpt = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
entShow.Redraw(4);
|
||
//EndChangeCursor();
|
||
//acedRemoveFilterWinMsg(MouseMoveMonitorByHandCursor);
|
||
return;
|
||
}
|
||
}
|
||
//EndChangeCursor();
|
||
//acedRemoveFilterWinMsg(MouseMoveMonitorByHandCursor);
|
||
}
|
||
}
|
||
// Command: 两点标注
|
||
// 用于平面图
|
||
// 支持尺寸自调
|
||
void DimTwoPoint()
|
||
{
|
||
int nORTHOMODE = 0;
|
||
TGGetVar(_T("ORTHOMODE"), &nORTHOMODE);
|
||
TGSetVar(_T("ORTHOMODE"), 0);//强制打开正交
|
||
DimTwoPointArg(0);
|
||
TGSetVar(_T("ORTHOMODE"), nORTHOMODE);
|
||
|
||
}
|
||
void DimTwoPointOld()
|
||
{
|
||
int nORTHOMODE = 0;
|
||
TGGetVar(_T("ORTHOMODE"), &nORTHOMODE);
|
||
TGSetVar(_T("ORTHOMODE"), 0);//强制打开正交
|
||
DimTwoPointArgOLD();
|
||
TGSetVar(_T("ORTHOMODE"), nORTHOMODE);
|
||
}
|
||
|
||
// Command: 尺寸自调
|
||
void DimAdjust()
|
||
{
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
if(SelectEntities(_T("\n请选择上华尺寸标注: "), ss, mask)==RTNORM) {
|
||
long lCount=ss.Length();
|
||
for(long i=0L; i<lCount; i++) {
|
||
Entity ent=ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim) {
|
||
pDim->ResetTextPos();
|
||
pDim->AdjustDim(g_nDimAdjust!=2, TRUE);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
//modified by whl
|
||
extern void ExplodeEx(AcDbEntity* pEntity,AcDbVoidPtrArray &res);
|
||
void DimRadOrDia(BOOL bDia)
|
||
{
|
||
InitLayer(LAY_DIM, TRUE);
|
||
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
if(SelectEntity1(_T("\n请选择待标注的圆弧<退出>: "), ent, ptPick, RBList())==RTNORM) {
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
XCircle cir;
|
||
if(ent.Is(_T("ATS_WALL"))||ent.Is(_T("ATS_CURTAIN_WALL"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
ASSERT(pWall);
|
||
if(!pWall->Is(CURVE_ARC)) {
|
||
adsout << _T("\n不能选择直墙!");
|
||
return;
|
||
}
|
||
TGGeCurveSegment segCen=pWall->OffsetGeomCenter();
|
||
int nSide=segCen.OnWhichSide(ptPick);
|
||
double nWidth=pWall->GetWidth();
|
||
TGGeCurveSegment segSide=segCen.Offset(nSide, nWidth/2, LS_FINITE);
|
||
cir=segSide.GetArc();
|
||
OPENOBJ_END();
|
||
} else if(ent.Is(_T("ATS_COLUMN"))) {
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbColumn, pColu);
|
||
XPoly2D poly2d(1);
|
||
pColu->GetOutline(poly2d);
|
||
poly2d.SetElevation(0.0);
|
||
XPoint pt=ptPick; pt.z=0;
|
||
int nHitFlag=poly2d.HitTestOnCurve(pt);
|
||
if(nHitFlag<0) {
|
||
int idx = abs(nHitFlag)-1;
|
||
ASSERT(idx<poly2d.TotalSegments());
|
||
TGGeCurveSegment seg;
|
||
poly2d.Nth(idx, seg);
|
||
if(seg.Is(CURVE_ARC))
|
||
cir=seg.GetArc();
|
||
else if(seg.Is(CURVE_CIRCLE))
|
||
cir=seg.GetCircle();
|
||
else {
|
||
adsout << _T("\n点取位置不是柱子的圆弧部位!");
|
||
return;
|
||
}
|
||
|
||
} else {
|
||
adsout << _T("\n请恰当的点取柱子位置!");
|
||
return;
|
||
}
|
||
OPENOBJ_END();
|
||
} else if(ent.Is(_T("ARC")) || ent.Is(_T("CIRCLE"))) {
|
||
cir=XCircle(ent);
|
||
}else{
|
||
bool bFoundArc=false;
|
||
AcDbVoidPtrArray subEnt;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
ExplodeEx((AcDbEntity*)pEnt->clone(),subEnt);
|
||
OPENOBJ_END();
|
||
for(long i=0;i<subEnt.length();i++)
|
||
{
|
||
AcDbEntity *pEnt=(AcDbEntity*)subEnt[i];
|
||
if(pEnt->isKindOf(AcDbArc::desc()))
|
||
{
|
||
AcDbArc* pArc=AcDbArc::cast(pEnt);
|
||
ads_point c;
|
||
XArc arc(c,pArc->radius(),pArc->startAngle(),pArc->endAngle());
|
||
|
||
arc.SetCenterPt(pArc->center());
|
||
int flag=arc.HitTest2d(ptPick);
|
||
if(flag>2)
|
||
{
|
||
bFoundArc=true;
|
||
cir.SetCenterPt(arc.GetCenterPt());
|
||
cir.SetRadius(arc.GetRadius());
|
||
break;
|
||
}
|
||
}
|
||
else if(pEnt->isKindOf(AcDbCircle::desc()))
|
||
{
|
||
AcDbCircle *pCir=AcDbCircle::cast(pEnt);
|
||
cir.SetRadius(pCir->radius());
|
||
cir.SetCenterPt(pCir->center());
|
||
if(cir.HitTest2d(ptPick)>2)
|
||
{
|
||
bFoundArc=true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
ReleaseEntSet(subEnt);
|
||
if(!bFoundArc)
|
||
{
|
||
ads_printf(_T("\n请选择弧线!"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
XPoint ptOnCir;
|
||
ptPick.Project(&cir, ptOnCir);
|
||
|
||
TDbRadiusDim *pDim = new TDbRadiusDim;
|
||
// jsx add 160914,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
pDim->SetStyleId(InitDimStyle(DS_RADIUS));
|
||
pDim->SetDimCenter(cir.GetCenterPt());
|
||
pDim->SetDimEndPoint(ptOnCir);
|
||
if(!bDia) {
|
||
double nDimDist=pDim->GetDimLen(FALSE);
|
||
if(nDimDist>cir.GetCenterPt().Distance2d(ptOnCir))
|
||
pDim->SetDimLen(-nDimDist, FALSE);
|
||
} else {
|
||
TDbText text;
|
||
pDim->GetDimText(text); // if is default, then it is empty
|
||
XString sText=pDim->GetText();
|
||
text.SetText(sText);
|
||
XPoint ptExt=text.GetExtents();
|
||
if(pDim->GetRadius()<ptExt.x)
|
||
pDim->SetDimLen(-ptExt.x*1.5, FALSE);
|
||
}
|
||
pDim->SetDiameter(bDia);
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->AddToCSpace(Adesk::kTrue);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)pDim);
|
||
}
|
||
}
|
||
|
||
// Command: 半径标注
|
||
void DimRadius()
|
||
{
|
||
DimRadOrDia(FALSE);
|
||
}
|
||
|
||
// Command: 直径标注
|
||
void DimDiameter()
|
||
{
|
||
DimRadOrDia(TRUE);
|
||
}
|
||
|
||
//
|
||
void CheckDim()
|
||
{
|
||
InitLayer(LAY_TEXT, TRUE);
|
||
TPickEntSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("DIMENSION"), NULL);
|
||
if(ss.Get(NULL,NULL,NULL, mask)!=RTNORM)
|
||
return;
|
||
AcDbVoidPtrArray entSet;
|
||
XExplodeStream dc(entSet);
|
||
dc.SetLayer(_T("PUB_TEXT"));
|
||
dc.SetColor(1);
|
||
dc.SetAlignment(XExplodeDraw::kMiddleCenter);
|
||
long ssLen=ss.Length();
|
||
for(long ssIndex=0; ssIndex<ssLen; ssIndex++) {
|
||
Entity ent=ss[ssIndex];
|
||
XString sTextOut(256);
|
||
XPoint ptTextPos;
|
||
double nTextSize=300.0;
|
||
BOOL bUseDefault=FALSE;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbDimension, pDim);
|
||
if(pDim) {
|
||
TCHAR *pszText=pDim->dimensionText();
|
||
ASSERT(pszText);
|
||
bUseDefault=(pszText[0]==EOS || _tcscmp(pszText, _T("<>"))==0);
|
||
#if(ADS>14)
|
||
double nMeasureValue=0.0;
|
||
VERIFY(pDim->measurement(nMeasureValue)==Acad::eOk);
|
||
if(fabs(_tstof(pszText)-nMeasureValue)>_DIST_SNAP) {
|
||
_stprintf(sTextOut, _T("(%.f)"), nMeasureValue);
|
||
}
|
||
#endif
|
||
delete [] pszText;
|
||
ptTextPos=pDim->textPosition();
|
||
AcDbObjectId idStyle=pDim->dimensionStyle();
|
||
OPENOBJ_BEGIN(idStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
|
||
nTextSize=pDimStyle->dimtxt()*pDimStyle->dimscale();
|
||
OPENOBJ_END();
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
if(ent.Is(_T("DIMENSION")) && !bUseDefault) {
|
||
//为了支持CONTINUE类型的变比例
|
||
int nDimType;
|
||
ent.GetData(70, &nDimType);
|
||
BOOL bTextMoved = (nDimType&128)!=0;
|
||
nDimType &= ~(32+128); //Clear 32 and 128
|
||
if(nDimType==0 || nDimType==1) { //Linear
|
||
ads_real nDimDirection=0.0;
|
||
XPoint ptLimStart, ptLimEnd, ptTextBaseline;
|
||
ent.GetData(10, &ptTextBaseline);
|
||
ent.GetData(13, &ptLimStart);
|
||
ent.GetData(14, &ptLimEnd);
|
||
if(nDimType==0) { //Rotate,Horizontal,Vertical
|
||
ent.GetData(50, &nDimDirection);
|
||
} else if(nDimType==1) {
|
||
nDimDirection = ads_angle(ptLimStart, ptLimEnd);
|
||
}
|
||
|
||
XLine lnTextBase(ptTextBaseline, nDimDirection);
|
||
XPoint ptOnTextBase, ptNewPos;
|
||
if(ptTextPos.Project(&lnTextBase, ptOnTextBase)==RTNORM) {
|
||
ads_polar(ptOnTextBase, ads_angle(ptTextPos, ptOnTextBase),
|
||
ads_distance(ptTextPos, ptOnTextBase), ptNewPos);
|
||
dc.SetRotation(xg_angle(nDimDirection));
|
||
dc.SetHeight(nTextSize);
|
||
dc.SetLocation(ptNewPos);
|
||
#if (ADS<=14)
|
||
XPoint ptLim1, ptLim2;
|
||
ptLimStart.Project(lnTextBase, ptLim1);
|
||
ptLimEnd.Project(lnTextBase, ptLim2);
|
||
_stprintf(sTextOut, _T("(%.f)"), ads_distance(ptLim1, ptLim2));
|
||
#endif
|
||
dc.DrawText(sTextOut);
|
||
}
|
||
}
|
||
}
|
||
int nCount=entSet.length();
|
||
for(int i=0; i<nCount; i++) {
|
||
AcDbEntity *pEnt=(AcDbEntity *)entSet[i];
|
||
AddToModelSpace(pEnt, TRUE);
|
||
}
|
||
}
|
||
}
|
||
|
||
// sg add 120615,主要解决64位下使用ln1.Intersection(&ln2, ptCen)函数无法判断是否相交的问题
|
||
BOOL Is2LineIntersection(const TGGeLine* pLine1, const TGGeLine* pLine2, ads_point ptrp)
|
||
{
|
||
TADSGePoint3d ptGe;
|
||
AcDbLine line1, line2;
|
||
line1.setStartPoint(pLine1->StartPoint().AsAcGePoint3d());
|
||
line1.setEndPoint(pLine1->EndPoint().AsAcGePoint3d());
|
||
line2.setStartPoint(pLine2->StartPoint().AsAcGePoint3d());
|
||
line2.setEndPoint(pLine2->EndPoint().AsAcGePoint3d());
|
||
|
||
AcDb::Intersect intType;
|
||
if (pLine1->GetLineFlag()==LS_FINITE && pLine2->GetLineFlag()==LS_FINITE) // 都不延长
|
||
intType = AcDb::kOnBothOperands;
|
||
else if (pLine1->GetLineFlag()==LS_FINITE && pLine2->GetLineFlag()==LS_INFINITE)
|
||
intType = AcDb::kExtendThis;
|
||
else if (pLine1->GetLineFlag()==LS_INFINITE && pLine2->GetLineFlag()==LS_FINITE)
|
||
intType = AcDb::kExtendArg;
|
||
else
|
||
intType = AcDb::kExtendBoth;
|
||
|
||
AcGePoint3dArray points;
|
||
Acad::ErrorStatus es = line1.intersectWith(&line2, intType, points);
|
||
if (es!=Acad::eOk || points.logicalLength()<1)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
ptGe = points[0];
|
||
|
||
ptrp[X] = ptGe.x;
|
||
ptrp[Y] = ptGe.y;
|
||
ptrp[Z] = ptGe.z;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
//modified by whl
|
||
// 角度标注
|
||
void DimAngle()
|
||
{
|
||
XPoint pt1, pt2;
|
||
Entity ent1, ent2;
|
||
|
||
if(SelectEntity1(_T("\n请选择第一条直线<退出>: "), ent1, pt1,RBList())!=RTNORM)
|
||
return;
|
||
pt1=Ucs2Wcs(pt1);
|
||
XLine ln1(ent1, LS_INFINITE);
|
||
if(!ent1.Is(_T("LINE")))
|
||
{
|
||
bool bFoundLine=false;
|
||
AcDbVoidPtrArray subEnt;
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, AcDbEntity, pEnt);
|
||
ExplodeEx((AcDbEntity*)pEnt->clone(),subEnt);
|
||
OPENOBJ_END();
|
||
for(long i=0;i<subEnt.length();i++)
|
||
{
|
||
AcDbEntity *pEnt=(AcDbEntity*)subEnt[i];
|
||
if(pEnt->isKindOf(AcDbLine::desc()))
|
||
{
|
||
AcDbLine* pLine=AcDbLine::cast(pEnt);
|
||
ln1.StartPoint()=pLine->startPoint();
|
||
ln1.EndPoint()=pLine->endPoint();
|
||
int flag=ln1.HitTest2d(pt1);
|
||
if(flag>2&&flag<6)
|
||
{
|
||
bFoundLine=true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
ReleaseEntSet(subEnt);
|
||
if(!bFoundLine)
|
||
{
|
||
adsout<<_T("\n请选择直线!");
|
||
return;
|
||
}
|
||
}
|
||
|
||
if(SelectEntity1(_T("\n请选择第二条直线<退出>: "),ent2, pt2, RBList())!=RTNORM)
|
||
return;
|
||
pt2=Ucs2Wcs(pt2);
|
||
XLine ln2(ent2, LS_INFINITE);
|
||
if(!ent2.Is(_T("LINE")))
|
||
{
|
||
bool bFoundLine=false;
|
||
AcDbVoidPtrArray subEnt;
|
||
OPENOBJ_BEGIN(ent2, AcDb::kForRead, AcDbEntity, pEnt);
|
||
ExplodeEx((AcDbEntity*)pEnt->clone(),subEnt);
|
||
OPENOBJ_END();
|
||
for(long i=0;i<subEnt.length();i++)
|
||
{
|
||
AcDbEntity *pEnt=(AcDbEntity*)subEnt[i];
|
||
if(pEnt->isKindOf(AcDbLine::desc()))
|
||
{
|
||
AcDbLine* pLine=AcDbLine::cast(pEnt);
|
||
ln2.StartPoint()=pLine->startPoint();
|
||
ln2.EndPoint()=pLine->endPoint();
|
||
int flag=ln2.HitTest2d(pt2);
|
||
if(flag>2&&flag<6)
|
||
{
|
||
bFoundLine=true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
ReleaseEntSet(subEnt);
|
||
if(!bFoundLine)
|
||
{
|
||
adsout<<_T("\n请选择直线!");
|
||
return;
|
||
}
|
||
}
|
||
|
||
//add by lxb on 2011/11/24
|
||
//顶点
|
||
XPoint ptCen;
|
||
//#ifndef _WIN64
|
||
// if(!ln1.Intersection(&ln2, ptCen))
|
||
//#else
|
||
if (!Is2LineIntersection(&ln1, &ln2, ptCen))
|
||
//#endif
|
||
{
|
||
adsout << _T("\n两条线互相平行!");
|
||
return;
|
||
}
|
||
|
||
TDbDimension2 *pDim=new TDbDimension2;
|
||
pDim->SetAngular(TRUE);
|
||
pDim->SetDist2DimLine(2.0);
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));
|
||
pDim->SetStyleId(InitDimStyle(DS_ANGLE));
|
||
|
||
AcGePoint2d pt01 = pt1.AsAcGePoint2d();
|
||
AcGePoint2d pt02 = pt2.AsAcGePoint2d();
|
||
AcGePoint2d ptCenter = ptCen.AsAcGePoint2d();
|
||
AcGeLine2d line1(ptCenter,pt01);
|
||
AcGeLine2d line2(ptCenter,pt02);
|
||
TDimAngleJig jig(pDim,line1,line2,ptCen,(LPTSTR)_T("\n请确定尺寸线位置<退出>: "),NULL);
|
||
if(jig.doIt() != AcEdJig::kNormal)
|
||
{
|
||
delete pDim;
|
||
return;
|
||
}
|
||
|
||
/*
|
||
XPoint qt1, qt2;
|
||
pt1.Project(&ln1, qt1);
|
||
pt2.Project(&ln2, qt2);
|
||
|
||
XPoint ptCen;
|
||
if(!ln1.Intersection(&ln2, ptCen)) {
|
||
adsout << _T("\n两条线互相平行!");
|
||
return;
|
||
}
|
||
|
||
TDbDimension2 *pDim=new TDbDimension2;
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
XPoint ptLoc;
|
||
ads_polar(qt1, ads_angle(ptCen, qt1), 2.0*DocGetPScale(), ptLoc);
|
||
pDim->SetLocation(ptLoc);
|
||
pDim->SetRotation(CT_std_angle(ads_angle(ptCen, qt1)+PI/2));
|
||
pDim->SetDist2DimLine(2.0);
|
||
pDim->SetAngular(TRUE);
|
||
pDim->SetObjRadius(ptCen.Distance2d(qt1)+2.0*DocGetPScale());
|
||
pDim->SetDimRadius(ptCen.Distance2d(qt1));
|
||
XArc ar(ptCen, ptCen.Distance2d(qt1), ads_angle(ptCen, qt1),
|
||
ads_angle(ptCen, qt2));
|
||
if(!pDim->IsValidSegment(ar.GetLength())) {
|
||
delete pDim;
|
||
return;
|
||
}
|
||
pDim->AppendSegment(ar.GetLength());
|
||
pDim->SetStyleId(InitDimStyle(DS_ANGLE));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->setLayer(InitLayer(LAY_DIM, TRUE));
|
||
|
||
/* 动态拖动有错误,不知原因
|
||
TDimensionEdJig jig(pDim, _T("\n请确定尺寸线位置: "));
|
||
jig.m_nFlag=1;
|
||
if(jig.doIt()!=RTNORM) {
|
||
delete pDim;
|
||
return;
|
||
}*/
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->AddToMSpace(TRUE);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)pDim);
|
||
}
|
||
|
||
|
||
// Command: 弧长标注
|
||
//modified by whl
|
||
void DimArcLen()
|
||
{
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
int nRetCode = 0;
|
||
TGGeArc arDim;
|
||
for (;;)
|
||
{
|
||
if(SelectEntity1(_T("\n请选择要标注的弧段<退出>:"),ent,ptPick,RBList()) != RTNORM)
|
||
return;
|
||
|
||
ptPick=Ucs2Wcs(ptPick);
|
||
if(ent.Is(_T("ARC")))
|
||
{
|
||
arDim = XArc(ent);
|
||
break;
|
||
}
|
||
else if(ent.Is(_T("ATS_WALL"))||ent.Is(_T("ATS_CURTAIN_WALL")))
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWall, pWall);
|
||
if(!pWall->Is(CURVE_ARC))
|
||
{
|
||
adsout << _T("\n请选弧墙!");
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
AcDbVoidPtrArray entSet;
|
||
BOOL bBold=DocGetIsLineWeight();
|
||
DocSetIsLineWeight(FALSE);
|
||
XExplodeStream dc(entSet);
|
||
pWall->ExplodeOrDraw2d(dc);
|
||
DocSetIsLineWeight(bBold);
|
||
int nCount=entSet.length();
|
||
BOOL bFindArc=FALSE;
|
||
double nMinDist=0.0;
|
||
for(int n=0; n<nCount; n++)
|
||
{
|
||
AcDbEntity *pEnt=(AcDbEntity *)entSet[n];
|
||
if(pEnt->isA()==AcDbArc::desc()) {
|
||
AcDbArc *pArc=AcDbArc::cast(pEnt);
|
||
XArc ar;
|
||
ar.SetCenterPt(pArc->center());
|
||
ar.SetStarAngle(pArc->startAngle());
|
||
ar.SetEndAngle(pArc->endAngle());
|
||
ar.SetRadius(pArc->radius());
|
||
TGGeCurveSegment seg;
|
||
seg=ar;
|
||
XPoint ptPrj;
|
||
if(seg.ProjectToMe(ptPick, ptPrj)==RTNORM && (ptPrj&seg)==PR_INSIDE)
|
||
{
|
||
if(!bFindArc)
|
||
{
|
||
arDim=ar;
|
||
bFindArc=TRUE;
|
||
nMinDist=ptPick.Distance2d(ptPrj);
|
||
}
|
||
else if(ptPick.Distance2d(ptPrj)<nMinDist)
|
||
{
|
||
nMinDist=ptPick.Distance2d(ptPrj);
|
||
arDim=ar;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(!bFindArc)
|
||
continue;
|
||
else
|
||
break;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
bool bFoundArc=false;
|
||
AcDbVoidPtrArray subEnt;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
ExplodeEx((AcDbEntity*)pEnt->clone(),subEnt);
|
||
OPENOBJ_END();
|
||
for(long i=0;i<subEnt.length();i++)
|
||
{
|
||
AcDbEntity *pEnt=(AcDbEntity*)subEnt[i];
|
||
if(pEnt->isKindOf(AcDbArc::desc()))
|
||
{
|
||
AcDbArc* pArc=AcDbArc::cast(pEnt);
|
||
arDim.SetCenterPt(pArc->center());
|
||
arDim.SetRadius(pArc->radius());
|
||
arDim.SetStarAngle(pArc->startAngle());
|
||
arDim.SetEndAngle(pArc->endAngle());
|
||
int flag=arDim.HitTest2d(ptPick);
|
||
if(flag>2)
|
||
{
|
||
bFoundArc=true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
ReleaseEntSet(subEnt);
|
||
if(!bFoundArc)
|
||
{
|
||
adsout<<_T("\n请选择弧段!");
|
||
continue;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
|
||
// 已经取得标注弧
|
||
InitLayer(LAY_DIM, TRUE);
|
||
TDbDimension2 dim;
|
||
TGGeCurveSegment segDim;
|
||
segDim = arDim;
|
||
XPushVar<int> osmode1(_T("OSMODE"), GetFullOsMode(OS_PER|OS_INT|OS_END));
|
||
TDbDimension2 *pDim=&dim;
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDim->setLayer(LAY_DIM);
|
||
pDim->SetStyleId(InitDimStyle(DS_ANGLE));
|
||
pDim->SetDist2DimLine(-6.0);
|
||
XPoint ptFix;
|
||
ads_polar(segDim.StartPoint(), segDim.IDirection(0)-PI/2, 2.0*DocGetPScale(), ptFix);
|
||
pDim->SetLocation(segDim.StartPoint());
|
||
pDim->SetRotation(segDim.IDirection(0));
|
||
pDim->SetAngular(TRUE);
|
||
pDim->SetDimArcLen(TRUE);
|
||
pDim->SetDimChord(FALSE);
|
||
pDim->SetObjRadius(arDim.GetRadius());
|
||
pDim->SetDimRadius(arDim.GetRadius()+6.0*DocGetPScale());
|
||
XArc arDimLine=arDim;
|
||
arDimLine.SetRadius(arDimLine.GetRadius() + 6.0 * DocGetPScale());
|
||
pDim->AppendSegment(arDimLine.GetLength());
|
||
//((TDbDimension2 *)pDim->clone())->AddToCSpace(Adesk::kTrue);
|
||
//return;
|
||
|
||
TDimensionEdJig jig(pDim, _T("\n请移动光标位置确定要标注的尺寸类型<退出>: "));
|
||
jig.m_ObjarDim = arDim;
|
||
jig.m_nFlag=5;
|
||
jig.SetIsArcDim();
|
||
jig.doIt();
|
||
if (jig.m_nRetCode != AcEdJig::kNormal)
|
||
{
|
||
return;
|
||
}
|
||
|
||
jig.m_pszPrompt = _T("\n请指定标注点: ");
|
||
jig.m_nFlag=1;
|
||
jig.doIt();
|
||
if (jig.m_nRetCode == AcEdJig::kCancel)
|
||
{
|
||
return;
|
||
}
|
||
/*
|
||
//add by wlw 201201015 在做jig之前要先设置是弧长标注
|
||
jig.m_pszKeyword=_T("L A C");
|
||
for(;;)
|
||
{
|
||
INITGET_BEG(-1, _T("L A C"));
|
||
jig.doIt();
|
||
INITGET_END();
|
||
jig.m_bKeyword = TRUE;
|
||
|
||
if (jig.m_nRetCode == AcEdJig::kCancel)
|
||
{
|
||
return;
|
||
}
|
||
else if (jig.m_nRetCode == AcEdJig::kKW1)
|
||
{
|
||
pDim->SetDimArcLen(TRUE);
|
||
pDim->SetDimChord(FALSE);
|
||
continue;
|
||
}
|
||
else if (jig.m_nRetCode == AcEdJig::kKW2)
|
||
{
|
||
pDim->SetDimArcLen(FALSE);
|
||
pDim->SetDimChord(FALSE);
|
||
continue;
|
||
}
|
||
else if (jig.m_nRetCode == AcEdJig::kKW3)
|
||
{
|
||
pDim->SetDimArcLen(FALSE);
|
||
pDim->SetDimChord(TRUE);
|
||
continue;
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
*/
|
||
|
||
BOOL bFirst=TRUE;
|
||
jig.m_nFlag=4;
|
||
jig.m_pszPrompt = _T("\n请输入其他标注点<退出>: ");
|
||
jig.m_pTemp=(TDbDimension2 *)pDim->clone();
|
||
while(jig.doIt()==RTNORM)
|
||
{
|
||
jig.Swap(); //更新pDim
|
||
jig.m_nFlag=4;
|
||
}
|
||
if(pDim->IsValid() && jig.GetRetCode()!=RTCAN)
|
||
{
|
||
TDbDimension2 *pDimNew=(TDbDimension2 *)pDim->clone();
|
||
ASSERT(pDimNew);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//pDimNew->AddToCSpace(Adesk::kTrue);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)pDimNew);
|
||
}
|
||
}
|
||
// Command: 增补尺寸区间
|
||
// 支持自调
|
||
// modify by lcf 2004/10/25
|
||
void BreakDim()
|
||
{
|
||
//wlw mod 2013.5.29 引线位置太乱
|
||
RBList mask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2"), NULL);
|
||
Entity entMaster;
|
||
TADSGePoint3d ptPick;
|
||
if(SelectEntity(_T("\n请选择尺寸标注<退出>: "), entMaster, mask) != RTNORM)
|
||
return;
|
||
|
||
Entity entDim;
|
||
if(entMaster.Is(_T("DIMENSION"))) {
|
||
if(!ConvertDim(entMaster, entDim)) {
|
||
adsout << _T("\n不能转化ACAD尺寸标注对象!");
|
||
return;
|
||
} else if(!entDim.Is(_T("ATS_DIMENSION2"))) {
|
||
adsout << _T("\n不是线性标注!");
|
||
return;
|
||
}
|
||
} else {
|
||
entDim=entMaster;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pDim);
|
||
if(pDim!=NULL)
|
||
{
|
||
XPoint ptBase;
|
||
int nSeg = pDim->HitTestOnText(ptPick);
|
||
TGGePoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
int nCount = poly.Length();
|
||
ptBase = *poly[nSeg];
|
||
int nRet;
|
||
XPoint ptAdd;
|
||
XString szPrompt;
|
||
XPointList lstAddPoint, lstBasePoint;
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
while(1)
|
||
{
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
int nCount = poly.Length();
|
||
int nLen = lstAddPoint.Length();
|
||
if(nLen == 0)
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置或 [参考点(R)]<退出>:"));
|
||
else
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置或 [参考点(R)/撤消上一标注点(U)]<退出>:"));
|
||
|
||
INITGET_BEG(0, _T("U R"));
|
||
nRet = acedGetPoint(ptBase, szPrompt, ptAdd);
|
||
INITGET_END();
|
||
if(nRet == RTNORM)
|
||
{
|
||
ptAdd = Ucs2Wcs(ptAdd);
|
||
ptBase = ptAdd;
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(!pDim->AddSegment(ptAdd))
|
||
adsout << _T("\n点取位置不合适!");
|
||
else
|
||
{
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
TGGeCurveSegment seg(*poly[0],*poly[nCount-1],0);
|
||
seg.ProjectToMe(ptBase,ptBase);
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('R'))
|
||
acedGetPoint(NULL, _T("\n参考点:"), ptBase);
|
||
else if(sKey[0] == _T('U'))
|
||
{
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(nLen > 0)
|
||
{
|
||
ptAdd = *lstAddPoint.Tail();
|
||
lstAddPoint.Remove(nLen-1);
|
||
pDim->HitTestOnPoint(ptAdd);
|
||
pDim->FindAndRemoveSegment(ptAdd);
|
||
lstBasePoint.Remove(nLen);
|
||
ptBase = *lstBasePoint.Tail();
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
int EditDim(AcDbObjectId id)
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbDimension2, pDim);
|
||
if(pDim!=NULL)
|
||
{
|
||
XPoint ptBase=Wcs2Ucs(pDim->GetLocation());
|
||
int nRet;
|
||
XPoint ptAdd;
|
||
XString szPrompt;
|
||
XPointList lstAddPoint, lstBasePoint;
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
while(1)
|
||
{
|
||
int nLen = lstAddPoint.Length();
|
||
if(nLen == 0)
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置或 [参考点(R)]<退出>:"));
|
||
else
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置或 [参考点(R)/撤消上一标注点(U)]<退出>:"));
|
||
|
||
INITGET_BEG(0, _T("U R"));
|
||
nRet = acedGetPoint(ptBase, szPrompt, ptAdd);
|
||
INITGET_END();
|
||
if(nRet == RTNORM)
|
||
{
|
||
ptBase = ptAdd;
|
||
ptAdd = Ucs2Wcs(ptAdd);
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(!pDim->AddSegment(ptAdd))
|
||
adsout << _T("\n点取位置不合适!");
|
||
else
|
||
{
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('R'))
|
||
acedGetPoint(NULL, _T("\n参考点:"), ptBase);
|
||
else if(sKey[0] == _T('U'))
|
||
{
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(nLen > 0)
|
||
{
|
||
ptAdd = *lstAddPoint.Tail();
|
||
lstAddPoint.Remove(nLen-1);
|
||
pDim->HitTestOnPoint(ptAdd);
|
||
pDim->FindAndRemoveSegment(ptAdd);
|
||
lstBasePoint.Remove(nLen);
|
||
ptBase = *lstBasePoint.Tail();
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
return RTNORM;
|
||
}
|
||
// Command: 合并尺寸
|
||
// create by lcf 2004/10/25
|
||
class TEntityPoint
|
||
{
|
||
public:
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
};
|
||
|
||
//可以框选合并尺寸wlw130929mod
|
||
void ConbineDim()
|
||
{
|
||
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
int nRet;
|
||
DList<TEntityPoint> lstEntPt;
|
||
while(1)
|
||
{
|
||
int nLen = lstEntPt.Length();
|
||
XPoint ptStart, ptEnd;
|
||
Entity ent;
|
||
if(nLen == 0)
|
||
nRet = acedGetPoint(NULL, _T("\n请框选合并区间中的尺寸界线箭头<退出>: "), ptStart);
|
||
else
|
||
{
|
||
INITGET_BEG(0, _T("U"));
|
||
nRet = acedGetPoint(NULL, _T("\n请框选合并区间中的尺寸界线箭头或 [撤消(U)]<退出>: "), ptStart);
|
||
INITGET_END();
|
||
}
|
||
|
||
if(nRet == RTNORM)
|
||
{
|
||
if(XGetCorner(ptStart,NULL, ptEnd) != RTNORM)
|
||
continue;
|
||
|
||
XPoint ptLowLeft, ptLowRight, ptUpRight, ptUpLeft;
|
||
if(ptStart.x > ptEnd.x)
|
||
{
|
||
ptLowLeft.x = ptEnd.x;
|
||
ptUpLeft.x = ptEnd.x;
|
||
ptLowRight.x = ptStart.x;
|
||
ptUpRight.x = ptStart.x;
|
||
}
|
||
else
|
||
{
|
||
ptLowLeft.x = ptStart.x;
|
||
ptUpLeft.x = ptStart.x;
|
||
ptLowRight.x = ptEnd.x;
|
||
ptUpRight.x = ptEnd.x;
|
||
}
|
||
if(ptStart.y > ptEnd.y)
|
||
{
|
||
ptLowLeft.y = ptEnd.y;
|
||
ptLowRight.y = ptEnd.y;
|
||
ptUpLeft.y = ptStart.y;
|
||
ptUpRight.y = ptStart.y;
|
||
}
|
||
else
|
||
{
|
||
ptLowLeft.y = ptStart.y;
|
||
ptLowRight.y = ptStart.y;
|
||
ptUpLeft.y = ptEnd.y;
|
||
ptUpRight.y = ptEnd.y;
|
||
}
|
||
|
||
XPoly2D poly(1);
|
||
poly.AppendNode(ptLowLeft);
|
||
poly.AppendNode(ptLowRight);
|
||
poly.AppendNode(ptUpRight);
|
||
poly.AppendNode(ptUpLeft);
|
||
|
||
RBList rbRegion = poly.Polygon();
|
||
PickSet ss(SS_FREE);
|
||
if(ss.Get(_T("CP"), rbRegion, NULL, mask) != RTNORM)
|
||
continue;
|
||
|
||
poly.TransUCS(Groups(1), Groups(0));
|
||
|
||
long num = ss.Length();
|
||
for(long i=0;i<num;i++)
|
||
{
|
||
ent = ss[i];
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim)
|
||
{
|
||
if(pDim->IsBind())
|
||
{
|
||
adsout << _T("\n此尺寸标注绑定在其他对象上, 因此不能编辑!");
|
||
return;
|
||
}
|
||
|
||
XPoly2D polyLimit;
|
||
pDim->GetPolySegOnDimLine(polyLimit);
|
||
|
||
for(int j = 1; j < polyLimit.Length() - 1; j++)
|
||
{
|
||
ptPick = *polyLimit[j];
|
||
int rtInside = ptPick & poly;
|
||
if(rtInside != PR_OUTSIDE)
|
||
{
|
||
TEntityPoint *pEntPt = new TEntityPoint;
|
||
pEntPt->ent = ent;
|
||
pEntPt->ptPick = ptPick;
|
||
lstEntPt.Append(pEntPt);
|
||
pDim->FindAndRemoveSegment(ptPick);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
TEntityPoint *pEntPt = lstEntPt.Tail();
|
||
if(pEntPt == NULL)
|
||
{
|
||
acutPrintf(_T("\n不能撤销!"));
|
||
continue;
|
||
}
|
||
|
||
ent = pEntPt->ent;
|
||
ptPick = pEntPt->ptPick;
|
||
lstEntPt.Remove(nLen-1);
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if(pDim)
|
||
{
|
||
if(pDim->IsBind())
|
||
{
|
||
adsout << _T("\n此尺寸标注绑定在其他对象上, 因此不能编辑!");
|
||
return;
|
||
}
|
||
pDim->AddSegment(ptPick);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
}
|
||
//拆分区间WLW ADD 13.06.07 仅仅限于一个区间内的自由拆分
|
||
void DivideDimSeg()
|
||
{
|
||
TDocLock doclock;
|
||
TEntitySet ent1;
|
||
XPoint ptPick;
|
||
TPickEntSet setshow(SS_FREE);
|
||
AcDbObjectId idshow;
|
||
RBList mask(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
if (SelectEntity(_T("\n选择待拆分的尺寸区间<退出>: "), ent1, ptPick, mask) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
TGGePoly2D polyLimit2(1);
|
||
OPENOBJ_BEGIN(ent1, AcDb::kForRead, TDbDimension2, pDim);
|
||
if(pDim == NULL)
|
||
{
|
||
return;
|
||
}
|
||
if(pDim->IsBind())
|
||
{
|
||
adsout << _T("\n此尺寸标注绑定在其他对象上, 因此不能编辑!");
|
||
return;
|
||
}
|
||
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
XPoint ptBase;
|
||
int nSeg = -1;
|
||
TSubText* psubtext = pDim->HitTestText(ptPick);
|
||
if (psubtext == NULL)
|
||
{
|
||
nSeg = pDim->HitTestOnDimSeg(ptPick);
|
||
}
|
||
else
|
||
{
|
||
nSeg = psubtext->GetIndex();
|
||
delete psubtext;
|
||
psubtext = NULL;
|
||
}
|
||
|
||
TGGePoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
|
||
AcDbLine *pln = new AcDbLine(*poly[nSeg],*poly[nSeg+1]);
|
||
pln->setColorIndex(1);
|
||
idshow = AddToModelSpace(pln);
|
||
TGGeCurveSegment segFirst(*poly[nSeg],*poly[nSeg+1],0);
|
||
|
||
int nCount = poly.Length();
|
||
ptBase = *poly[nSeg];
|
||
int nRet;
|
||
XPoint ptAdd;
|
||
XString szPrompt;
|
||
XPointList lstAddPoint, lstBasePoint;
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
while(1)
|
||
{
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
int nCount = poly.Length();
|
||
int nLen = lstAddPoint.Length();
|
||
TGGeCurveSegment seg(*poly[0],*poly[nCount-1],0);
|
||
if(nLen == 0)
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置<退出>:"));
|
||
else
|
||
_stprintf(szPrompt, _T("\n点取待增补的标注点的位置或[撤消(U)]<退出>:"));
|
||
|
||
INITGET_BEG(0, _T("U"));
|
||
ptBase = Wcs2Ucs(ptBase);
|
||
nRet = acedGetPoint(ptBase, szPrompt, ptAdd);
|
||
INITGET_END();
|
||
if(nRet == RTNORM)
|
||
{
|
||
ptAdd = Ucs2Wcs(ptAdd);
|
||
|
||
segFirst.ProjectToMe(ptAdd,ptAdd);
|
||
if ((ptAdd & segFirst) != PR_INSIDE)
|
||
{
|
||
adsout << _T("\n请点取区域内部!");
|
||
continue;
|
||
}
|
||
ptBase = ptAdd;
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(!pDim->AddSegment(ptAdd))
|
||
adsout << _T("\n点取位置不合适!");
|
||
else
|
||
{
|
||
lstAddPoint.Append(new XPoint(ptAdd));
|
||
lstBasePoint.Append(new XPoint(ptBase));
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
TGGeCurveSegment seg(*poly[0],*poly[nCount-1],0);
|
||
seg.ProjectToMe(ptBase,ptBase);
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('U'))
|
||
{
|
||
if(pDim->upgradeOpen() == Acad::eOk)
|
||
{
|
||
if(nLen > 0)
|
||
{
|
||
ptAdd = *lstAddPoint.Tail();
|
||
lstAddPoint.Remove(nLen-1);
|
||
pDim->HitTestOnPoint(ptAdd);
|
||
pDim->FindAndRemoveSegment(ptAdd);
|
||
lstBasePoint.Remove(nLen);
|
||
ptBase = *lstBasePoint.Tail();
|
||
if(g_nDimAdjust)//add by whl on 050530
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
seg.ProjectToMe(ptBase,ptBase);
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
OPENOBJ_END()
|
||
OPENOBJ_BEGIN(idshow, AcDb::kForWrite, AcDbEntity, pent)
|
||
if (pent)
|
||
{
|
||
pent->erase();
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
// Command: 快速标注
|
||
// Create By LCF 2004/10/27
|
||
/////////////////////////////////////////////////////
|
||
int CmpPointByX(const XPoint *pt1, const XPoint *pt2)
|
||
{
|
||
if(pt1->x< pt2->x)
|
||
return -1;
|
||
else
|
||
return 1;
|
||
}
|
||
|
||
int CmpPointByY(const XPoint *pt1, const XPoint *pt2)
|
||
{
|
||
if(pt1->y < pt2->y)
|
||
return -1;
|
||
else
|
||
return 1;
|
||
}
|
||
|
||
////////////////////////////////////////////////////
|
||
class TQuickDimensionJig : public AcEdJig
|
||
{
|
||
public:
|
||
TQuickDimensionJig();
|
||
virtual ~TQuickDimensionJig();
|
||
int doIt();
|
||
virtual DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity *entity() const;
|
||
|
||
const TCHAR *m_pszKeyword; //关键字
|
||
// TDbDimension2 *m_pDrawEnt; //临时实体,
|
||
// TDbDimension2 *m_pDrawEntALL;
|
||
TDbDimension2 *m_pDrawEntX; //临时实体,
|
||
TDbDimension2 *m_pDrawEntY; //临时实体,
|
||
double m_dFactor;
|
||
int m_iFlag;
|
||
XPoint m_ptDim;
|
||
XPoint m_lowPt, m_upPt;
|
||
void SetKeyword(const TCHAR *pszKeyword);
|
||
void SetExtents(XPoint lowPt, XPoint upPt);
|
||
void SetMidPoints(AcGePoint3dArray &dimPoints);
|
||
void SetDimType(int iFlag);
|
||
void AddToDataBase();
|
||
TMulDimEntity m_dimbEntity;
|
||
};
|
||
|
||
TQuickDimensionJig::TQuickDimensionJig()
|
||
{
|
||
m_pszKeyword = NULL;
|
||
m_pDrawEntX = NULL;
|
||
m_pDrawEntY = NULL;
|
||
m_dimbEntity.m_iFlag = m_iFlag;
|
||
m_dFactor = 0.0;
|
||
m_dimbEntity.m_pDrawEntAll = NULL;
|
||
m_dimbEntity.m_pDrawEnt = new TDbDimension2;
|
||
}
|
||
|
||
TQuickDimensionJig::~TQuickDimensionJig()
|
||
{
|
||
if(m_pDrawEntX != NULL)
|
||
delete m_pDrawEntX;
|
||
if(m_pDrawEntY != NULL)
|
||
delete m_pDrawEntY;
|
||
}
|
||
|
||
void TQuickDimensionJig::SetKeyword(const TCHAR *pszKeyword)
|
||
{
|
||
m_pszKeyword = pszKeyword;
|
||
}
|
||
|
||
void TQuickDimensionJig::SetDimType(int iFlag)
|
||
{
|
||
m_iFlag = iFlag;
|
||
m_dimbEntity.m_iFlag = m_iFlag;
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll == NULL)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll = new TDbDimension2;
|
||
}
|
||
}
|
||
|
||
void TQuickDimensionJig::SetExtents(XPoint lowPt, XPoint upPt)
|
||
{
|
||
m_lowPt = Wcs2Ucs(lowPt);
|
||
m_upPt = Wcs2Ucs(upPt);
|
||
|
||
if(m_pDrawEntX != NULL)
|
||
{
|
||
delete m_pDrawEntX;
|
||
m_pDrawEntX = NULL;
|
||
}
|
||
m_pDrawEntX = new TDbDimension2;
|
||
m_pDrawEntX->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
m_pDrawEntX->SetDist2DimLine(6.0);
|
||
m_pDrawEntX->SetLocation(lowPt);
|
||
m_pDrawEntX->SetRotation(Ucs2Wcs(0.0));
|
||
double dValX = m_upPt.x - m_lowPt.x;
|
||
if(fabs(dValX) > 1E-3)
|
||
m_pDrawEntX->AppendSegment(dValX);
|
||
|
||
AcDbObjectId idStyle = InitDimStyle(DS_LINEAR);
|
||
m_pDrawEntX->SetStyleId(idStyle);
|
||
m_pDrawEntX->setLayer(LAY_DIM);
|
||
|
||
if(m_pDrawEntY != NULL)
|
||
{
|
||
delete m_pDrawEntY;
|
||
m_pDrawEntY = NULL;
|
||
}
|
||
m_pDrawEntY = new TDbDimension2;
|
||
m_pDrawEntY->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
m_pDrawEntY->SetDist2DimLine(6.0);
|
||
m_pDrawEntY->SetLocation(lowPt);
|
||
m_pDrawEntY->SetRotation(PI/2 + Ucs2Wcs(0.0));
|
||
double dValY = m_upPt.y - m_lowPt.y;
|
||
if(fabs(dValY) > 1E-3)
|
||
m_pDrawEntY->AppendSegment(dValY);
|
||
|
||
m_pDrawEntY->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
m_pDrawEntY->setLayer(LAY_DIM);
|
||
|
||
double dTexth = 3.5;
|
||
OPENOBJ_BEGIN(idStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
|
||
ASSERT(pDimStyle);
|
||
dTexth = pDimStyle->dimtxt() * pDimStyle->dimscale();
|
||
OPENOBJ_END();
|
||
m_dFactor = 2 * dTexth * DocGetPScale();
|
||
m_dimbEntity.m_pDrawEnt->SetStyleId(idStyle);
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll->SetStyleId(idStyle);
|
||
}
|
||
|
||
}
|
||
|
||
void TQuickDimensionJig::SetMidPoints(AcGePoint3dArray &dimPoints)
|
||
{
|
||
if(m_iFlag == 0)
|
||
return;
|
||
|
||
long i;
|
||
XPointList lstPointsX, lstPointsY;
|
||
for(i=0; i<dimPoints.length(); i++)
|
||
{
|
||
XPoint ptDim = dimPoints[i];
|
||
lstPointsX.Append(new XPoint(ptDim));
|
||
lstPointsY.Append(new XPoint(ptDim));
|
||
}
|
||
lstPointsX.QuickSort(CmpPointByX);
|
||
lstPointsY.QuickSort(CmpPointByY);
|
||
|
||
if(m_pDrawEntX->GetSegmentNum() > 0)
|
||
{
|
||
for(i=0; i<lstPointsX.Length(); i++)
|
||
m_pDrawEntX->AddSegment(*lstPointsX[i]);
|
||
}
|
||
if(m_pDrawEntY->GetSegmentNum() > 0)
|
||
{
|
||
for(i=0; i<lstPointsY.Length(); i++)
|
||
m_pDrawEntY->AddSegment(*lstPointsY[i]);
|
||
}
|
||
m_pDrawEntX->RemoveZeroSegment();
|
||
m_pDrawEntY->RemoveZeroSegment();
|
||
}
|
||
|
||
void TQuickDimensionJig::AddToDataBase()
|
||
{
|
||
if(m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
if(g_nDimAdjust)
|
||
m_dimbEntity.m_pDrawEntAll->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
m_dimbEntity.m_pDrawEntAll->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)m_dimbEntity.m_pDrawEntAll);
|
||
}
|
||
|
||
//add by whl on 060119
|
||
if(g_nDimAdjust)
|
||
m_dimbEntity.m_pDrawEnt->AdjustDim(g_nDimAdjust!=2);
|
||
|
||
// sg add 120410,增加布局转角的设置,解决UCS下,文字方向错误的问题
|
||
m_dimbEntity.m_pDrawEnt->SetLayoutRotation(Ucs2Wcs(0.0));
|
||
|
||
// modify by xly on 110107 支持图层切换
|
||
//m_dimbEntity.m_pDrawEnt->AddToCSpace(Adesk::kTrue);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)m_dimbEntity.m_pDrawEnt);
|
||
}
|
||
|
||
int TQuickDimensionJig::doIt()
|
||
{
|
||
int ret;
|
||
try
|
||
{
|
||
ret = drag();
|
||
}
|
||
catch(...)
|
||
{
|
||
ret = AcEdJig::kCancel;
|
||
}
|
||
|
||
if (ret == AcEdJig::kCancel)
|
||
ret = RTCAN;
|
||
else if(ret == AcEdJig::kNull)
|
||
ret = RTNONE;
|
||
else if (ret <= 0)
|
||
ret = RTNORM;
|
||
else
|
||
ret = RTKWORD;
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus TQuickDimensionJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
if (m_pszKeyword)
|
||
setKeywordList(m_pszKeyword);
|
||
|
||
XPoint ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
ptCursor = ptCursor;
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptDim) > _DIST_SNAP)
|
||
m_ptDim = ptCursor;
|
||
else
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
// 更新实体数据
|
||
//modified by whl on 050811
|
||
Adesk::Boolean TQuickDimensionJig::update()
|
||
{
|
||
double nDist2Dim = 0.0;
|
||
BOOL b2 = FALSE;
|
||
while(m_dimbEntity.m_pDrawEnt->GetSegmentNum()>0)
|
||
m_dimbEntity.m_pDrawEnt->RemoveSegment(0);
|
||
if (m_iFlag == 2 && m_dimbEntity.m_pDrawEntAll != NULL)
|
||
{
|
||
b2 = TRUE;
|
||
while(m_dimbEntity.m_pDrawEntAll->GetSegmentNum() > 0)
|
||
m_dimbEntity.m_pDrawEntAll->RemoveSegment(0);
|
||
}
|
||
|
||
|
||
|
||
XPoint ptLoc(m_lowPt);
|
||
XPoint ptDim = Wcs2Ucs(m_ptDim);
|
||
double dangle;
|
||
if(ptDim.y < m_upPt.y && ptDim.y > m_lowPt.y && (ptDim.x < m_lowPt.x || ptDim.x > m_upPt.x))
|
||
{
|
||
if(m_pDrawEntY->GetSegmentNum() > 0)
|
||
{
|
||
//m_dimbEntity.m_pDrawEnt->copyFrom(m_pDrawEntY);
|
||
for(long i=0;i<m_pDrawEntY->GetSegmentNum();i++)
|
||
m_dimbEntity.m_pDrawEnt->AppendSegment(m_pDrawEntY->GetSegment(i));
|
||
|
||
dangle = PI/2 + Ucs2Wcs(0.0);
|
||
m_dimbEntity.m_pDrawEnt->SetRotation(dangle);
|
||
|
||
if (b2)
|
||
{
|
||
double dValY = m_upPt.y - m_lowPt.y;
|
||
if(fabs(dValY) > 1E-3)
|
||
m_dimbEntity.m_pDrawEntAll->AppendSegment(dValY);
|
||
m_dimbEntity.m_pDrawEntAll->SetRotation(dangle);
|
||
}
|
||
if(ptDim.x < (m_lowPt.x + m_upPt.x) * 0.5)
|
||
ptLoc.x = m_lowPt.x;
|
||
else
|
||
ptLoc.x = m_upPt.x;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(m_pDrawEntX->GetSegmentNum() > 0)
|
||
{
|
||
//m_dimbEntity.m_pDrawEnt->copyFrom(m_pDrawEntX);
|
||
for(long i=0;i<m_pDrawEntX->GetSegmentNum();i++)
|
||
m_dimbEntity.m_pDrawEnt->AppendSegment(m_pDrawEntX->GetSegment(i));
|
||
m_dimbEntity.m_pDrawEnt->SetRotation(Ucs2Wcs(0.0));
|
||
|
||
if (b2)
|
||
{
|
||
double dValX = m_upPt.x - m_lowPt.x;
|
||
if(fabs(dValX) > 1E-3)
|
||
m_dimbEntity.m_pDrawEntAll->AppendSegment(dValX);
|
||
m_dimbEntity.m_pDrawEntAll->SetRotation(Ucs2Wcs(0.0));
|
||
}
|
||
|
||
if(ptDim.y < (m_lowPt.y + m_upPt.y) * 0.5)
|
||
{
|
||
ptLoc.y = m_lowPt.y;
|
||
}
|
||
else
|
||
{
|
||
|
||
ptLoc.y = m_upPt.y;
|
||
}
|
||
}
|
||
}
|
||
m_dimbEntity.m_pDrawEnt->SetLocation(Ucs2Wcs(ptLoc));
|
||
if (b2)
|
||
m_dimbEntity.m_pDrawEntAll->SetLocation(Ucs2Wcs(ptLoc));
|
||
|
||
XPoint ptOnSeg;
|
||
TGGeCurveSegment seg;
|
||
seg = m_dimbEntity.m_pDrawEnt->GetDimCurve();
|
||
if (b2)
|
||
seg = m_dimbEntity.m_pDrawEntAll->GetDimCurve();
|
||
if(seg.ProjectToMe(m_ptDim, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = m_ptDim.Distance2d(ptOnSeg);
|
||
int nSideLoc = seg.OnWhichSide(m_dimbEntity.m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptDim);
|
||
nDist2Dim = m_dimbEntity.m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
if (b2)
|
||
{
|
||
nSideLoc = seg.OnWhichSide(m_dimbEntity.m_pDrawEntAll->GetLocation());
|
||
nDist2Dim = m_dimbEntity.m_pDrawEntAll->GetDist2DimLine(FALSE);
|
||
}
|
||
double nFactor = nDist2Dim/fabs(nDist2Dim);
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
if(nSide != nSideLoc)
|
||
{
|
||
nDistMove *= nFactor;
|
||
}
|
||
else
|
||
{
|
||
nDistMove *= -nFactor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
nDistMove *= -1;
|
||
}
|
||
nDist2Dim += nDistMove;
|
||
if (b2)
|
||
{
|
||
m_dimbEntity.m_pDrawEntAll->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
if(nDist2Dim >= 0)
|
||
nDist2Dim -= m_dFactor;
|
||
else
|
||
nDist2Dim += m_dFactor;
|
||
m_dimbEntity.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
}
|
||
else
|
||
m_dimbEntity.m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
|
||
}
|
||
ASSERT(m_dimbEntity.m_pDrawEnt && m_dimbEntity.m_pDrawEnt->IsValid());
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
AcDbEntity* TQuickDimensionJig::entity() const
|
||
{
|
||
return (AcDbEntity*)&m_dimbEntity;
|
||
}
|
||
|
||
// 快速标注
|
||
////////////////////////////////////////////////////
|
||
void QuickDim()
|
||
{
|
||
extern TARCH_IMPEXP BOOL g_bQuickCalWallExtent;
|
||
XPushMemVar<BOOL> vTemp(TchGeLib::g_bQuickCalWallExtent,FALSE);
|
||
|
||
RBList mask(-4, _T("<NOT"), RTDXF0,
|
||
_T("ATS_TEXT,ATS_MTEXT,ATS_DIMENSION2,ATS_SHEET,ATS_AXIS_LABEL,ATS_DRAWINGINDEX,ATS_COORD,ATS_ELEVATION,ATS_INDEXPOINTER,ATS_DRAWINGINDEX,ATS_SYMB_SECTION,ATS_RUPTURE,ATS_ARROW,ATS_MULTILEADER,ATS_COMPOSING,ATS_SYMMETRY,ATS_NORTHTHUMB,TEXT,MTEXT,DIMENSION,TABLE,LEADER,")
|
||
, -4, _T("NOT>"), NULL);
|
||
TPickEntSet ss(SS_FREE);
|
||
if(SelectEntities(_T("\n选择要标注的几何图形:"), ss, mask) != RTNORM)
|
||
return;
|
||
|
||
XPoint lowPt, upPt;
|
||
double dAngle = Ucs2Wcs(0.0) * 180 / PI;
|
||
XPoint ptWcsBase=Wcs2Ucs(XPoint());
|
||
BOOL bUcs=FALSE;
|
||
if(fabs(dAngle) > 1E-6||ptWcsBase.Distance2d(XPoint())>1E-6)
|
||
{
|
||
bUcs=TRUE;
|
||
XPoint basePt;
|
||
XPushVar<int> osmode(_T("OSMODE"), 0);//add by whl on 060223
|
||
|
||
// Zyu modify on 100726,支持64位
|
||
//SHads_command(RTSTR, _T(".ROTATE"), RTPICKS, (long *)ss, RTSTR, _T(""),
|
||
// RT3DPOINT, &basePt, RTREAL, -dAngle, RTNONE);
|
||
//SHads_command(RTSTR, _T(".MOVE"), RTPICKS, (long *)ss, RTSTR, _T(""),
|
||
// RT3DPOINT, &basePt, RT3DPOINT,&ptWcsBase, RTNONE);
|
||
SHads_command(RTSTR, _T(".ROTATE"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RT3DPOINT, &basePt, RTREAL, -dAngle, RTNONE);
|
||
SHads_command(RTSTR, _T(".MOVE"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RT3DPOINT, &basePt, RT3DPOINT,&ptWcsBase, RTNONE);
|
||
|
||
ss.GetExtend(lowPt, upPt);
|
||
lowPt = Ucs2Wcs(lowPt);
|
||
upPt = Ucs2Wcs(upPt);
|
||
|
||
// Zyu modify on 100726,支持64位
|
||
//SHads_command(RTSTR, _T(".MOVE"), RTPICKS, (long *)ss, RTSTR, _T(""),
|
||
// RT3DPOINT, &ptWcsBase, RT3DPOINT,&basePt, RTNONE);
|
||
//SHads_command(RTSTR, _T(".ROTATE"), RTPICKS, (long *)ss, RTSTR, _T(""),
|
||
// RT3DPOINT, &basePt, RTREAL, dAngle, RTNONE);
|
||
SHads_command(RTSTR, _T(".MOVE"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RT3DPOINT, &ptWcsBase, RT3DPOINT,&basePt, RTNONE);
|
||
SHads_command(RTSTR, _T(".ROTATE"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RT3DPOINT, &basePt, RTREAL, dAngle, RTNONE);
|
||
}
|
||
else
|
||
ss.GetExtend(lowPt, upPt);
|
||
|
||
long i, j;
|
||
AcGePoint3dArray dimPoints;
|
||
ss.BaseFilter(RBList(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL,ATS_OPENING,LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE"), NULL));
|
||
for(i=0; i<ss.Length(); i++)
|
||
{
|
||
Entity ent = ss[i];
|
||
OPENOBJ_BEGIN(ent, AcDb::kForWrite, AcDbEntity, pEnt);
|
||
if(pEnt == NULL)
|
||
continue;
|
||
if(pEnt->isKindOf(TDbWall::desc()))
|
||
{
|
||
AcGePoint3dArray stretchPoints;
|
||
pEnt->getStretchPoints(stretchPoints);
|
||
dimPoints.append(stretchPoints);
|
||
|
||
TDbWall *pWall = TDbWall::cast(pEnt);
|
||
DList<TOpeningData> lstOpenings;
|
||
pWall->GetOpenings(lstOpenings, FALSE);
|
||
for(int j=0; j<lstOpenings.Length(); j++)
|
||
{
|
||
TOpeningData *pWin = lstOpenings[j];
|
||
XPoint ptSideBack, ptSideFront;
|
||
XPoint ptBackRes, ptFrontRes;
|
||
pWin->GetSidePoints(ptSideBack, ptSideFront);
|
||
pWall->ProjectToMe(ptSideBack, ptBackRes);
|
||
pWall->ProjectToMe(ptSideFront, ptFrontRes);
|
||
dimPoints.append(ptBackRes);
|
||
dimPoints.append(ptFrontRes);
|
||
}
|
||
}
|
||
else if(pEnt->isKindOf(TDbOpening::desc()))
|
||
{
|
||
TDbOpening *pWin = TDbOpening::cast(pEnt);
|
||
OPENOBJ_BEGIN(pWin->GetWallId(), AcDb::kForRead, TDbWall, pWall);
|
||
if(pWall != NULL)
|
||
{
|
||
XPoint ptSideBack, ptSideFront;
|
||
XPoint ptBackRes, ptFrontRes;
|
||
pWin->GetSidePoints(ptSideBack, ptSideFront);
|
||
pWall->ProjectToMe(ptSideBack, ptBackRes);
|
||
pWall->ProjectToMe(ptSideFront, ptFrontRes);
|
||
dimPoints.append(ptBackRes);
|
||
dimPoints.append(ptFrontRes);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else
|
||
{
|
||
AcGePoint3dArray stretchPoints;
|
||
pEnt->getStretchPoints(stretchPoints);
|
||
dimPoints.append(stretchPoints);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
AcGePoint3d ptBack, ptFront;
|
||
long lCount = dimPoints.length();
|
||
for(i=lCount-1; i>0; i--)
|
||
{
|
||
ptBack = dimPoints[i];
|
||
for(j=i-1; j>=0; j--)
|
||
{
|
||
ptFront = dimPoints[j];
|
||
if(ptBack.distanceTo(ptFront) < 1E-6)
|
||
{
|
||
dimPoints.removeAt(i);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
static int s_iFlag = 2;
|
||
InitLayer(LAY_DIM, TRUE);
|
||
TQuickDimensionJig jig;
|
||
jig.SetKeyword(_T("T C A"));
|
||
XString szState;
|
||
while(1)
|
||
{
|
||
jig.SetDimType(s_iFlag);
|
||
jig.SetExtents(lowPt, upPt);
|
||
jig.SetMidPoints(dimPoints);
|
||
if(s_iFlag == 0)
|
||
szState = _T("整体");
|
||
else if(s_iFlag == 1)
|
||
szState = _T("连续");
|
||
else
|
||
szState = _T("连续加整体");
|
||
|
||
jig.setDispPrompt(_T("\n请指定尺寸线位置(当前标注方式:%s)或 [整体(T)/连续(C)/连续加整体(A)]<退出>:"), szState);
|
||
int nRet;
|
||
INITGET_BEG(-1, _T("T C A"));
|
||
nRet = jig.doIt();
|
||
INITGET_END();
|
||
if(nRet == RTNORM)
|
||
{
|
||
jig.AddToDataBase();
|
||
break;
|
||
}
|
||
else if(nRet == RTKWORD)
|
||
{
|
||
#if ADS > 25
|
||
AcString ss;
|
||
jig.acquireString(ss);
|
||
if(_tcscmp(ss, _T("T")) == 0)
|
||
s_iFlag = 0;
|
||
else if(_tcscmp(ss, _T("C")) == 0)
|
||
s_iFlag = 1;
|
||
else
|
||
s_iFlag = 2;
|
||
#else
|
||
TCHAR sKey[2049];
|
||
jig.acquireString(sKey);
|
||
if (_tcscmp(sKey, _T("T")) == 0)
|
||
s_iFlag = 0;
|
||
else if (_tcscmp(sKey, _T("C")) == 0)
|
||
s_iFlag = 1;
|
||
else
|
||
s_iFlag = 2;
|
||
#endif
|
||
}
|
||
else
|
||
{
|
||
if(jig.m_dimbEntity.m_pDrawEnt != NULL)
|
||
delete jig.m_dimbEntity.m_pDrawEnt;
|
||
break;
|
||
}
|
||
}
|
||
|
||
//add by whl on 060223
|
||
if(bUcs)
|
||
SHads_command(RTSTR, _T(""), RTSTR, _T(""), RTNONE);
|
||
}
|
||
|
||
// Add By lcf on 2005/03/21
|
||
// 等分标注
|
||
void AverageDim()
|
||
{
|
||
Entity ent;
|
||
XPoint ptPick;
|
||
RBList rbMask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2"), NULL);
|
||
while(ent.FilterSelect(_T("\n请选择需要等分的尺寸区间<退出>: "), rbMask, ptPick) == RTNORM)
|
||
{
|
||
Entity entDim;
|
||
if(ent.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(ent, entDim))
|
||
{
|
||
acutPrintf(_T("\n不能转化ACAD尺寸标注对象!"));
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
entDim = ent;
|
||
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pDim);
|
||
ASSERT(pDim);
|
||
int nSeg = pDim->HitTestOnDimSeg(Ucs2Wcs(ptPick));
|
||
if(nSeg < 0)
|
||
acutPrintf(_T("\n请正确选取尺寸区间!"));
|
||
else
|
||
{
|
||
int nAverage;
|
||
if(acedGetInt(_T("\n输入等分数<退出>:"), &nAverage) != RTNORM)
|
||
return;
|
||
|
||
if(pDim->upgradeOpen()==Acad::eOk)
|
||
{
|
||
XPoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
ASSERT(nSeg < poly.TotalSegments());
|
||
TGGeCurveSegment seg;
|
||
poly.Nth(nSeg, seg);
|
||
for(int i=0; i<nAverage; i++)
|
||
{
|
||
XPointDir2d ptIn;
|
||
seg.Polar(seg.GetLength() * (i+1)/nAverage, ptIn);
|
||
pDim->AddSegment(ptIn);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
//add by cwk on 060914
|
||
void DivideDim()
|
||
{
|
||
TPickEntSet setshow(SS_FREE);
|
||
TEntitySet ent;
|
||
XPoint ptPick;
|
||
RBList rbMask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2"), NULL);
|
||
while(ent.FilterSelect(_T("\n请选择需要等分的尺寸区间<退出>: "), rbMask, ptPick) == RTNORM)
|
||
{
|
||
Entity entDim;
|
||
if(ent.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(ent, entDim))
|
||
{
|
||
acutPrintf(_T("\n不能转化ACAD尺寸标注对象!"));
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
entDim = ent;
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pDim);
|
||
if(pDim==NULL)
|
||
break;
|
||
ASSERT(pDim);
|
||
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
int nSeg = -1;
|
||
TSubText* psubtext = pDim->HitTestText(ptPick);
|
||
if (psubtext == NULL)
|
||
{
|
||
nSeg = pDim->HitTestOnDimSeg(ptPick);
|
||
}
|
||
else
|
||
{
|
||
nSeg = psubtext->GetIndex();
|
||
delete psubtext;
|
||
psubtext = NULL;
|
||
}
|
||
|
||
if(nSeg < 0)
|
||
acutPrintf(_T("\n请正确选取尺寸区间!"));
|
||
else
|
||
{
|
||
TGGePoly2D poly;
|
||
pDim->GetPolySegOnDimLine(poly);
|
||
if (poly.Length() > nSeg)
|
||
{
|
||
AcDbLine *pln = new AcDbLine(*poly[nSeg],*poly[nSeg+1]);
|
||
|
||
pln->setColorIndex(1);
|
||
setshow += AddToModelSpace(pln);
|
||
}
|
||
int nAverage;
|
||
//moidfy by xlc on 070815 等分数不能为0
|
||
//if(acedGetInt(_T("\n输入等分数<退出>:"), &nAverage) != RTNORM)
|
||
// return;
|
||
while(TRUE)
|
||
{
|
||
if(acedGetInt(_T("\n输入等分数<退出>:"), &nAverage) != RTNORM)
|
||
{
|
||
setshow.Erase();
|
||
return;
|
||
}
|
||
|
||
if(abs(nAverage) < 1.0e-6)
|
||
{
|
||
acutPrintf(_T("\n等分数不能为0!"));
|
||
continue;
|
||
}
|
||
break;
|
||
}
|
||
|
||
if(pDim->upgradeOpen()==Acad::eOk)
|
||
{
|
||
XString xstr = pDim->GetText(nSeg);
|
||
CString str = xstr.cs();
|
||
if (str.ReverseFind(_T('=')) >= 0)
|
||
{
|
||
int i = str.Find(_T('=')) + 1;
|
||
TCHAR *sText = new TCHAR[str.GetLength()];
|
||
int j = 0;
|
||
do
|
||
{
|
||
sText[j] = str.GetAt(i);
|
||
j++;
|
||
i++;
|
||
} while(i < str.GetLength());
|
||
sText[j] = _T('\0');
|
||
str = sText;
|
||
xstr = str;
|
||
}
|
||
CString s;
|
||
if (str.Find(_T('.')) < 0)
|
||
{
|
||
int i = _ttoi(LPCTSTR(str));
|
||
int j;
|
||
double m;
|
||
if (i % nAverage == 0)
|
||
{
|
||
j = i /nAverage;
|
||
s.Format(_T("%d"),j);
|
||
}
|
||
else
|
||
{
|
||
//modified by yujie
|
||
//m = (double)i / (double)nAverage;
|
||
m = i / (double)nAverage;
|
||
s.Format(_T("%.1f"),m);
|
||
if (s[s.GetLength() - 1] == _T('0'))
|
||
s.Delete(s.GetLength() - 1);
|
||
if (s[s.GetLength() - 1] == _T('.')) //add by yujie
|
||
s.Delete(s.GetLength() - 1);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
double d = _tstof(LPCTSTR(str));
|
||
double m = d / nAverage;
|
||
s.Format(_T("%.1f"),m);
|
||
if (s[s.GetLength() - 1] == _T('0'))
|
||
s.Delete(s.GetLength() - 1);
|
||
if (s[s.GetLength() - 1] == _T('.')) //add by yujie
|
||
s.Delete(s.GetLength() - 1);
|
||
}
|
||
|
||
str = s;
|
||
str += _T('X');
|
||
s.Format(_T("%d"),nAverage);
|
||
str += s;
|
||
str += _T('=');
|
||
str += xstr;
|
||
pDim->SetTextContent(nSeg,LPCTSTR(str));
|
||
pDim->downgradeOpen();
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
setshow.Erase();
|
||
|
||
}
|
||
}
|
||
// Add By lcf on 2005/03/23
|
||
// 对齐标注
|
||
void ArrangeDim()
|
||
{
|
||
// [12/19/2007 nsh]
|
||
//----------begin--------------
|
||
BOOL bChoose=TRUE;//选择的标注是直线标注或是圆弧标注 TRUE为直线标注,FALSE为圆弧标注
|
||
XPoint CenterPoint;
|
||
int WhichSide;
|
||
double dRadius;
|
||
//-----------end---------------
|
||
Entity entFirst;
|
||
RBList rbMask(RTDXF0, _T("DIMENSION,ATS_DIMENSION2"), NULL);
|
||
if(SelectEntity(_T("\n选择参考标注<退出>: "), entFirst, rbMask) != RTNORM)
|
||
return;
|
||
|
||
Entity entDim;
|
||
if(entFirst.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(entFirst, entDim))
|
||
{
|
||
acutPrintf(_T("\n不能转化ACAD尺寸标注对象!"));
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
entDim = entFirst;
|
||
|
||
double dRotFirst, dDist;
|
||
AcDbObjectId objid;
|
||
TGGeCurveSegment seg;
|
||
TDbDimension2 *pClone = NULL;
|
||
OPENOBJ_BEGIN(entDim, AcDb::kForRead, TDbDimension2, pFirst);
|
||
ASSERT(pFirst);
|
||
// [12/14/2007 nsh]
|
||
//-----------------------begin-----------------------
|
||
if(pFirst->IsAngular())
|
||
{//选择的是圆弧标注
|
||
bChoose =FALSE;
|
||
dDist =pFirst->GetDist2DimLine();
|
||
dRadius =pFirst->GetDimRadius();
|
||
TGGeCurveSegment se=pFirst->GetDimCurve();
|
||
XArc xa=se.GetArc();
|
||
WhichSide =se.OnWhichSide(pFirst->GetLocation());
|
||
CenterPoint=xa.GetCenterPt();
|
||
}
|
||
//-------------------------end-----------------------
|
||
else
|
||
{//选择的是直线标注
|
||
bChoose =TRUE;
|
||
dRotFirst = pFirst->GetRotation();
|
||
dDist = pFirst->GetDist2DimLine();
|
||
seg = pFirst->GetDimCurve();
|
||
seg = seg.Offset(dDist * DocGetPScale(), 1);
|
||
pClone = (TDbDimension2 *)pFirst->clone();
|
||
if(pClone == NULL)
|
||
return;
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
TPickEntSet ss(SS_FREE);
|
||
const TCHAR *szPrompts[2]={_T("\n选择其它标注<退出>: "), _T("") };
|
||
if(ss.Get(_T(":$"), szPrompts, NULL, rbMask) != RTNORM)
|
||
{
|
||
delete pClone;
|
||
return;
|
||
}
|
||
|
||
if(bChoose)
|
||
{//选择的为直线标注
|
||
for(long i=0; i<ss.Length(); i++)
|
||
{
|
||
Entity entOther = ss[i];
|
||
|
||
Entity entDimOther;
|
||
if(entOther.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(entOther, entDimOther))
|
||
continue;
|
||
}
|
||
else
|
||
entDimOther = entOther;
|
||
|
||
OPENOBJ_BEGIN(entDimOther, AcDb::kForRead, TDbDimension2, pOther);
|
||
ASSERT(pOther);
|
||
if(pOther->IsAngular())
|
||
continue;
|
||
|
||
double dRot = CT_std_angle(dRotFirst) - CT_std_angle(pOther->GetRotation());
|
||
dRot = fabs(dRot);
|
||
if(dRot > 1E-6 && fabs(dRot - PI) > 1E-6)
|
||
continue;
|
||
|
||
XPoint ptRes;
|
||
seg.ProjectToMe(pOther->GetLocation(), ptRes);
|
||
if(pOther->upgradeOpen()==Acad::eOk)
|
||
{
|
||
// add by xly on 110107 支持图层切换,记录其他对象的图层
|
||
CString csLayer = pOther->layer();
|
||
pOther->CopyPropertiesFrom(pClone, AcDbMatchProperties::kSetAllFlagsOn);
|
||
pOther->setLayer(csLayer);
|
||
pOther->SetDist2DimLine((dRot < 1E-6) ? dDist : -dDist);
|
||
pOther->SetLocation(ptRes);
|
||
if(g_nDimAdjust)
|
||
pOther->AdjustDim(g_nDimAdjust!=2);
|
||
pOther->downgradeOpen();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
// [12/19/2007 nsh]
|
||
//--------------------------begin------------------------------
|
||
else
|
||
{//选择的圆弧标注
|
||
for(long i=0; i<ss.Length(); i++)
|
||
{
|
||
Entity entOther = ss[i];
|
||
|
||
Entity entDimOther;
|
||
if(entOther.Is(_T("DIMENSION")))
|
||
{
|
||
if(!ConvertDim(entOther, entDimOther))
|
||
continue;
|
||
}
|
||
else
|
||
entDimOther = entOther;
|
||
|
||
OPENOBJ_BEGIN(entDimOther, AcDb::kForWrite, TDbDimension2, pOther);
|
||
ASSERT(pOther);
|
||
if(!pOther->IsAngular())
|
||
continue;
|
||
TGGeCurveSegment seg=pOther->GetDimCurve();
|
||
XArc xarc=seg.GetArc();
|
||
int temp=seg.OnWhichSide(pOther->GetLocation());
|
||
if(xarc.GetCenterPt()!=CenterPoint || seg.OnWhichSide(pOther->GetLocation())!=WhichSide)
|
||
continue;
|
||
AcDbObjectId oID=pOther->GetStyleId();
|
||
if(oID==InitDimStyle(DS_ANGLE))
|
||
{//角度标注的情况下
|
||
double ddd=8.0*DocGetPScale();
|
||
TGGeCurveSegment cv =pOther->GetDimCurve();
|
||
if(!cv.Is(CURVE_LINE))
|
||
{
|
||
XArc arc=cv.GetArc();
|
||
arc.GetCenterPt();
|
||
XPoint ptStart;
|
||
pOther->getStartPoint(ptStart);
|
||
ads_polar(arc.GetCenterPt(),ads_angle(arc.GetCenterPt(),ptStart),dRadius+dDist*DocGetPScale(),ptStart);
|
||
pOther->SetLocation(ptStart);
|
||
pOther->SetDimRadius(dRadius);
|
||
pOther->SetDist2DimLine(dDist);
|
||
}
|
||
}
|
||
else
|
||
{//弧长标注的情况
|
||
pOther->SetDimRadius(dRadius);
|
||
pOther->SetDist2DimLine(dDist);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
//--------------------------end---------------------------------
|
||
delete pClone;
|
||
}
|
||
//wlw add 121212
|
||
void FreedomDim()
|
||
{
|
||
TPickEntSet set,setsub,setsubTmp;
|
||
TRBList tgMask(RTDXF0, _T("ATS_WALL,ATS_CURTAIN_WALL,ATS_COLUMN"), NULL);
|
||
int nRet;
|
||
BOOL bAddCol = FALSE;
|
||
TCHAR szRet;
|
||
nRet = SelectEntities(_T("\n请选择需要尺寸标注的墙[带柱子(Y)]<退出>:"), set, tgMask,_T("Y"), szRet);
|
||
if (nRet == -5005)
|
||
{
|
||
nRet = SelectEntities(_T("\n请选择需要尺寸标注的墙、柱<退出>:"), set, tgMask);
|
||
bAddCol = TRUE;
|
||
}
|
||
|
||
if (nRet != RTNORM )
|
||
{
|
||
return;
|
||
}
|
||
|
||
TADSGePoint3d ptcen,ptSide1,ptSide2;
|
||
long j = 0;
|
||
int i;
|
||
TPickEntSet ssCol;//所有框选的柱子
|
||
for (j = 0; j < set.Length(); j++)
|
||
{
|
||
if (set[j].Is(_T("ATS_COLUMN")))
|
||
{
|
||
ssCol += set[j];
|
||
}
|
||
}
|
||
set -= ssCol;
|
||
|
||
double dw,dh;
|
||
set.GetExtend(ptcen,&dw,&dh);
|
||
AcDbObjectIdArray ids;
|
||
set.AsIdArray(ids);
|
||
TADSGePoint3d ptOnIt, ptMid, ptLeft, ptRight;
|
||
double dDist = 12;//引线长度wlw13.10.12
|
||
for(j = 0; j < ids.length(); j++)
|
||
{
|
||
OPENOBJ_BEGIN(ids[j], AcDb::kForRead, TDbWall, pWall)
|
||
// wlw过滤没有窗的墙
|
||
// if (pWall->GetOpeningIdList().Length() == 0)
|
||
// continue;
|
||
TGGeCurveSegment segWall=*pWall;
|
||
segWall.SetLineFlag(LS_FINITE);
|
||
segWall.SetElevation(0.0);
|
||
|
||
XThirdDimData dim3(segWall);
|
||
|
||
dim3.m_nDistToTextBaseline = DocGetPScale() * dDist;
|
||
//dim3.m_nDistToFixPos = 5;
|
||
|
||
if (segWall.OnWhichSide(ptcen) == 0)
|
||
dim3.m_nOnSide = 1;
|
||
else
|
||
dim3.m_nOnSide = 0;
|
||
|
||
|
||
dim3.AddPoints(pWall, bAddCol);//WLW 2013.10.12 计算墙两端的柱子
|
||
|
||
dim3.Apply();
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
AcGePoint3d ptS,ptE,ptOn;
|
||
while(set.Length() > 0)
|
||
{
|
||
setsubTmp.Free();
|
||
OPENOBJ_BEGIN(set[0L],AcDb::kForRead, TDbWall, pWall)
|
||
setsub += set[0L];
|
||
for (j = 0; j < ids.length(); j++)
|
||
{
|
||
OPENOBJ_BEGIN(ids[j], AcDb::kForRead, TDbWall, pWallTmp)
|
||
ptS = pWallTmp->StartPoint();
|
||
pWall->getClosestPointTo(ptS,ptOn,Adesk::kTrue);
|
||
if (ptS.distanceTo(ptOn) < 0.001)
|
||
{
|
||
ptE = pWallTmp->EndPoint();
|
||
pWall->getClosestPointTo(ptE,ptOn,Adesk::kTrue);
|
||
if (ptE.distanceTo(ptOn) < 0.001)
|
||
{
|
||
setsubTmp += ids[j];
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
set -= setsubTmp;
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
for(j = 0; j < setsub.Length(); j++)
|
||
{
|
||
OPENOBJ_BEGIN(setsub[j], AcDb::kForRead, TDbWall, pWall)
|
||
TADSGePoint3d pt;
|
||
ptOnIt = pWall->MidPoint();
|
||
TGGeCurveSegment cvLeft, cvRight;
|
||
pWall->GetSideCurve(cvLeft, cvRight);
|
||
double dAng = pWall->Direction(ptOnIt);
|
||
ads_polar(ptOnIt, dAng + 0.5 * PI, 100.0, pt);
|
||
TGGeLine line(ptOnIt, pt);
|
||
cvLeft.Intersection(line, ptLeft, pt); //得到左边上的标注点
|
||
cvRight.Intersection(line, ptRight, pt); //得到右边上的标注点
|
||
pWall->Intersection(line, ptMid, pt); //得到轴线上的标注点
|
||
//画墙厚标注
|
||
if(DimOne(ptLeft, ptMid, ptRight, true) != RTNORM)
|
||
{
|
||
continue;
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
if (!bAddCol)
|
||
{
|
||
return;
|
||
}
|
||
for(j = 0; j < ssCol.Length(); j++)
|
||
{
|
||
OPENOBJ_BEGIN(ssCol[j], AcDb::kForRead, TDbColumn, pCol)
|
||
|
||
if (pCol->GetSectionShape() == TColumnData::kRect)
|
||
{
|
||
ptLeft = *(pCol->m_polyOutline[3]);
|
||
ptRight = *(pCol->m_polyOutline[2]);
|
||
}
|
||
else
|
||
{
|
||
ptLeft = *(pCol->m_polyOutline[0]);
|
||
ptRight = *(pCol->m_polyOutline[1]);
|
||
}
|
||
|
||
ptLeft.z=ptRight.z=0;
|
||
TDbDimension2 *pDim = new TDbDimension2;
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));
|
||
pDim->SetLocation(ptLeft);
|
||
pDim->SetRotation(ads_angle(ptLeft, ptRight));
|
||
pDim->AppendSegment(ptLeft.Distance2d(ptRight));
|
||
AcDbObjectId idStyle=InitDimStyle(DS_LINEAR);
|
||
pDim->SetStyleId(idStyle);
|
||
|
||
|
||
double dDistCol = 12;
|
||
TGGeCurveSegment segCol(ptLeft,ptRight,0);
|
||
for (i = 0; i < pCol->m_lstWallIds.Length(); i++)
|
||
{
|
||
OPENOBJ_BEGIN(*(pCol->m_lstWallIds[i]), AcDb::kForRead, TDbWall, pWall);
|
||
if (pWall)
|
||
{
|
||
if (fabs(pWall->Direction(pWall->StartPoint()) - segCol.Direction(ptLeft)) < 0.001)
|
||
{
|
||
//柱子标注尺寸的位置要和墙的同高
|
||
pWall->getClosestPointTo(ptLeft, ptOn,Adesk::kTrue);
|
||
//dDistCol = ptOn.distanceTo(ptLeft.AsAcGePoint3d());
|
||
dDistCol = dDist - ptOn.distanceTo(ptLeft.AsAcGePoint3d()) / pCol->GetPScale();
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
pDim->SetDist2DimLine(dDistCol, TRUE);
|
||
TRBList axisFence = segCol.AsFence();
|
||
TRBList axisMask(RTDXF0, _T("LINE,ARC,CIRCLE"), 8, LAY_AXIS, NULL);
|
||
TPickEntSet ssAxis(SS_FREE);
|
||
long k,lCount = 0;
|
||
TADSGePoint3d ptIntsect[2];
|
||
int nIntNum = 0;
|
||
if(ssAxis.Get(_T("F"), axisFence, NULL, axisMask)==RTNORM)
|
||
{
|
||
lCount = ssAxis.Length();
|
||
for(k = 0L; k < lCount; k++)
|
||
{
|
||
TGGeCurveSegment segAxis(ssAxis[k], LS_FINITE);
|
||
segAxis.SetElevation(0.0);
|
||
nIntNum = segAxis.Intersection(segCol, ptIntsect[0], ptIntsect[1]);
|
||
if (nIntNum > 0)
|
||
{
|
||
pDim->AddSegment(ptIntsect[0]);
|
||
}
|
||
if (nIntNum > 1)
|
||
{
|
||
pDim->AddSegment(ptIntsect[1]);
|
||
}
|
||
}
|
||
}
|
||
|
||
AcGiTextStyle txtStyle;
|
||
OPENOBJ_BEGIN(idStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pStyle);
|
||
ASSERT(pStyle);
|
||
VERIFY(fromAcDbTextStyle(txtStyle, pStyle->dimtxsty())==Acad::eOk);
|
||
int nRetFlag=txtStyle.loadStyleRec();
|
||
txtStyle.setTextSize(pStyle->dimtxt()*pDim->GetPScale()*0.8);
|
||
OPENOBJ_END();
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2, TRUE, FALSE);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)pDim);
|
||
|
||
if (pCol->GetSectionShape() == TColumnData::kRect)
|
||
{
|
||
ptLeft = *(pCol->m_polyOutline[0]);
|
||
ptRight = *(pCol->m_polyOutline[3]);
|
||
ptLeft.z=ptRight.z=0;
|
||
|
||
segCol.SetPoints(ptLeft,ptRight);
|
||
pDim = new TDbDimension2;
|
||
pDim->SetLayoutRotation(Ucs2Wcs(0));//add by whl on 060306
|
||
pDim->SetLocation(ptLeft);
|
||
pDim->SetRotation(ads_angle(ptLeft, ptRight));
|
||
pDim->AppendSegment(ptLeft.Distance2d(ptRight));
|
||
pDim->SetStyleId(idStyle);
|
||
|
||
for (i = 0; i < pCol->m_lstWallIds.Length(); i++)
|
||
{
|
||
OPENOBJ_BEGIN(*(pCol->m_lstWallIds[i]), AcDb::kForRead, TDbWall, pWall);
|
||
if (pWall)
|
||
{
|
||
if (fabs(pWall->Direction(pWall->StartPoint()) - segCol.Direction(ptLeft)) < 0.001)
|
||
{
|
||
//柱子标注尺寸的位置要和墙的同高
|
||
pWall->getClosestPointTo(ptLeft, ptOn,Adesk::kTrue);
|
||
//dDistCol = ptOn.distanceTo(ptLeft.AsAcGePoint3d());
|
||
dDistCol = dDist - ptOn.distanceTo(ptLeft.AsAcGePoint3d()) / pCol->GetPScale();
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
pDim->SetDist2DimLine(dDistCol, TRUE);
|
||
TRBList axisFence1 = segCol.AsFence();
|
||
ssAxis.Free();
|
||
if(ssAxis.Get(_T("F"), axisFence1, NULL, axisMask) == RTNORM)
|
||
{
|
||
lCount = ssAxis.Length();
|
||
for(k = 0L; k < lCount; k++)
|
||
{
|
||
TGGeCurveSegment segAxis(ssAxis[k], LS_FINITE);
|
||
segAxis.SetElevation(0.0);
|
||
nIntNum = segAxis.Intersection(segCol, ptIntsect[0], ptIntsect[1]);
|
||
if (nIntNum > 0)
|
||
{
|
||
pDim->AddSegment(ptIntsect[0]);
|
||
}
|
||
if (nIntNum > 1)
|
||
{
|
||
pDim->AddSegment(ptIntsect[1]);
|
||
}
|
||
}
|
||
}
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2, TRUE, FALSE);
|
||
AddToSpace(Adesk::kTrue, (TDbEntity*)pDim);
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
return;
|
||
}
|
||
|
||
void DoubleLineDim()
|
||
{
|
||
DimTwoPointArg(1);
|
||
return ;
|
||
}
|
||
|
||
void OuterDim()
|
||
{
|
||
TPickEntSet ss(SS_FREE);
|
||
RBList rb(RTDXF0, _T("ATS_COLUMN,ATS_WALL,ATS_WALL_PATCH,ATS_CURTAIN_WALL"), NULL);
|
||
if (SelectEntities(_T("请选择建筑构件:"),ss,rb) != RTNORM)
|
||
return;
|
||
TPickEntSet ss2(SS_FREE);
|
||
RBList rb2(RTDXF0, _T("ATS_DIMENSION2"), NULL);
|
||
if (SelectEntities(_T("请选择第一、二道尺寸线:"),ss2,rb2) != RTNORM)
|
||
return;
|
||
XPoint ptLow,ptUp;
|
||
{
|
||
extern TARCH_IMPEXP BOOL g_bQuickCalWallExtent;
|
||
XPushMemVar<BOOL> vTemp(TchGeLib::g_bQuickCalWallExtent,FALSE);//add by whl on 070601
|
||
ss.GetExtend(ptLow,ptUp);
|
||
}
|
||
AcDbObjectIdArray idArr;
|
||
ss2.AsIdArray(idArr);
|
||
|
||
AcDbVoidPtrArray entSet;
|
||
XExplodeStream dc(entSet);
|
||
long m= 0;
|
||
while (m < ss.Length())
|
||
{
|
||
Entity ent;
|
||
ent = ss[m];
|
||
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbEntity,pEnt);
|
||
TEntityBase *pTchEnt = TEntityBase::Cast(pEnt);
|
||
if (pTchEnt != NULL)
|
||
{
|
||
pTchEnt->ExplodeOrDraw2d(dc);
|
||
}
|
||
OPENOBJ_END();
|
||
m++;
|
||
}
|
||
int i = 0;
|
||
while (i < idArr.length())
|
||
{
|
||
TDbDimension2 *pDim = NULL;
|
||
acdbOpenObject(pDim,idArr[i],AcDb::kForWrite);
|
||
double nAngle = pDim->GetRotation();
|
||
if (fabs(nAngle - 0.0) < 1.0E-6 || fabs(nAngle - PI / 2) < 1.0E-6)
|
||
{
|
||
XPoint ptTemp = pDim->GetLocation();
|
||
if (pDim->GetSegmentNum() == 1)
|
||
{
|
||
XPoint pt2;
|
||
if (fabs(nAngle - 0.0) < 1.0E-6)
|
||
{
|
||
pt2.x = ptTemp.x + pDim->GetSegment(0);
|
||
pt2.y = ptTemp.y;
|
||
pt2.z = ptTemp.z;
|
||
if (pDim->HitTestOnPoint(pt2) != pDim->GetSegmentNum())
|
||
{
|
||
pt2.x = ptTemp.x - pDim->GetSegment(0);
|
||
if (pDim->AddSegment(ptLow))
|
||
pDim->FindAndRemoveSegment(pt2);
|
||
if (pDim->AddSegment(ptUp))
|
||
pDim->FindAndRemoveSegment(ptTemp);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
}
|
||
else if (fabs(nAngle - PI / 2) < 1.0E-6)
|
||
{
|
||
pt2.x = ptTemp.x;
|
||
pt2.y = ptTemp.y + pDim->GetSegment(0);
|
||
pt2.z = ptTemp.z;
|
||
if (pDim->HitTestOnPoint(pt2) != pDim->GetSegmentNum())
|
||
{
|
||
pt2.y = ptTemp.y - pDim->GetSegment(0);
|
||
if (pDim->AddSegment(ptLow))
|
||
pDim->FindAndRemoveSegment(pt2);
|
||
if (pDim->AddSegment(ptUp))
|
||
pDim->FindAndRemoveSegment(ptTemp);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
}
|
||
if (pDim->AddSegment(ptLow))
|
||
pDim->FindAndRemoveSegment(ptTemp);
|
||
if (pDim->AddSegment(ptUp))
|
||
pDim->FindAndRemoveSegment(pt2);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
else
|
||
{
|
||
pDim->AddSegment(ptLow);
|
||
pDim->AddSegment(ptUp);
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
BOOL bFlag = FALSE;
|
||
XPoint ptTemp = pDim->GetLocation();
|
||
double d;
|
||
if (pDim->GetSegmentNum() == 1)
|
||
{
|
||
d = pDim->GetSegment(0);
|
||
bFlag = TRUE;
|
||
}
|
||
XPoint ptMin,ptMax;
|
||
AcGeMatrix3d mat,matRev;
|
||
ads_matrix temp;
|
||
XPoint().GetRotationMatrix(-nAngle,temp);
|
||
mat = AsAcGeMatrix3d(temp);
|
||
XPoint().GetRotationMatrix(nAngle,temp);
|
||
matRev = AsAcGeMatrix3d(temp);
|
||
XPoint ptMinTemp,ptMaxTemp;
|
||
m = 0;
|
||
while(m < entSet.length())
|
||
{
|
||
AcDbEntity *pEnt = (AcDbEntity*)entSet[m];
|
||
pEnt->transformBy(mat);
|
||
AcDbExtents ext;
|
||
pEnt->getGeomExtents(ext);
|
||
pEnt->transformBy(matRev);
|
||
ptMinTemp = ext.minPoint();
|
||
ptMaxTemp = ext.maxPoint();
|
||
if (m == 0)
|
||
{
|
||
ptMin = ptMinTemp;
|
||
ptMax = ptMaxTemp;
|
||
}
|
||
else
|
||
{
|
||
ptMin = Min(ptMin,ptMinTemp);
|
||
ptMax = Max(ptMax,ptMaxTemp);
|
||
}
|
||
m++;
|
||
}
|
||
ptMin.TransformBy(matRev);
|
||
ptMax.TransformBy(matRev);
|
||
if (bFlag)
|
||
{
|
||
XPoint pt2;
|
||
pt2.x = ptTemp.x + d * cos(nAngle);
|
||
pt2.y = ptTemp.y + d * sin(nAngle);
|
||
pt2.z = ptTemp.z;
|
||
if (pDim->HitTestOnPoint(pt2) != pDim->GetSegmentNum())
|
||
{
|
||
pt2.x = ptTemp.x - d * cos(nAngle);
|
||
pt2.y = ptTemp.y - d * sin(nAngle);
|
||
if (pDim->AddSegment(ptMin))
|
||
{
|
||
pDim->FindAndRemoveSegment(pt2);
|
||
}
|
||
if (pDim->AddSegment(ptMax))
|
||
{
|
||
pDim->FindAndRemoveSegment(ptTemp);
|
||
}
|
||
}
|
||
if (pDim->AddSegment(ptMin))
|
||
{
|
||
pDim->FindAndRemoveSegment(ptTemp);
|
||
}
|
||
if (pDim->AddSegment(ptMax))
|
||
{
|
||
pDim->FindAndRemoveSegment(pt2);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pDim->AddSegment(ptMin);
|
||
pDim->AddSegment(ptMax);
|
||
}
|
||
if(g_nDimAdjust)
|
||
pDim->AdjustDim(g_nDimAdjust!=2);
|
||
}
|
||
i++;
|
||
pDim->close();
|
||
}
|
||
ReleaseEntSet(entSet);
|
||
}
|
||
|
||
// add by xly on 101028 引入文件"InsTextDlg.h"中的函数
|
||
extern CString PlusString(const TCHAR* szRes, int step, BOOL bIsPlus, bool bHasChineseNum = false);
|
||
|
||
// add by xly on 101115 在FindAndReplaceDlg中已经去掉了这个函数,所以添加
|
||
extern TARCH_IMPEXP BOOL g_bTextStyleEx;
|
||
TTextPosition FindEntText1(Entity ent, const TCHAR *sSubText, TTextPosition &posStart, TTextRange *pRange)
|
||
{
|
||
TTextPosition posFind;
|
||
if(!sSubText || !sSubText[0])
|
||
return posFind;
|
||
|
||
// sg add 110504,解决查找时,可能受“全字匹配”影响的问题,临时去掉全字匹配的设置
|
||
DWORD dwMaskOld = g_FindParser.GetFindOption(),
|
||
dwMaskNew = dwMaskOld;
|
||
dwMaskNew = dwMaskNew & ~FP_WHOLE_WORD;
|
||
g_FindParser.SetFindOption(dwMaskNew);
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if(pEnt->isKindOf(TDbEntity::desc()))
|
||
{
|
||
TDbEntity *pText=TDbEntity::cast(pEnt);
|
||
posFind=pText->FindSubText(sSubText, posStart, pRange);
|
||
}
|
||
else if(pEnt->isKindOf(AcDbText::desc()))
|
||
{
|
||
XPushMemVar<BOOL> vTemp(g_bTextStyleEx, FALSE);
|
||
TDbText text;
|
||
AcDbText *pText=AcDbText::cast(pEnt);
|
||
if(text.ConvertFrom(pText))
|
||
{
|
||
posFind = text.FindSubText(sSubText, posStart, pRange);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
// sg add 110504,解决查找时,可能受“全字匹配”影响的问题,恢复默认
|
||
g_FindParser.SetFindOption(dwMaskOld);
|
||
|
||
return posFind;
|
||
}
|
||
|
||
// add by xly on 100927 为选择到的字符绘制红色外包盒;poly选择到的字符的外包盒的pline线
|
||
void GrdrawPoly(XPoly2D &poly)
|
||
{
|
||
int len = poly.Length();
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
TGGeCurveSegment seg;
|
||
poly.Nth(i, seg);
|
||
XPoint ptS, ptE;
|
||
ads_grdraw(seg.StartPoint(), seg.EndPoint(), 1, 0);
|
||
}
|
||
}
|
||
|
||
// add by xly on 100927 红色框选选择到的字符,同时将为字符串csText分为两部分;
|
||
// 说明:csText:待选字符串;entSel:选择集;ptPickWcs:点选的位置;csLeft:选择到的字符的左部(包含选择到的字符);
|
||
// csRight:选择到的字符的右部(不包含选择到的字符);
|
||
void HightShow(CString csText, TEntitySet entSel, XPoint ptPickWcs,CString &csLeft, CString &csRight)
|
||
{
|
||
// 获得字符串中每个字符的信息
|
||
int len = csText.GetLength();
|
||
TTextPosition pos;
|
||
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
CString csUnit;
|
||
#if (ADS < 17)
|
||
int unicode = (int)csText.GetAt(i);
|
||
if((unicode <='9' && unicode >= '0') || (unicode <= 'z' && unicode >= 'a') || (unicode <= 'Z' && unicode >= 'A'))
|
||
{
|
||
TCHAR cUnit = csText[i];
|
||
BYTE byte = (BYTE)cUnit;
|
||
csUnit = cUnit;
|
||
}
|
||
else
|
||
{
|
||
csUnit = csText.Mid(i,2);
|
||
i++;
|
||
}
|
||
#else
|
||
TCHAR cUnit = csText[i];
|
||
BYTE byte = (BYTE)cUnit;
|
||
csUnit = cUnit;
|
||
#endif
|
||
|
||
// 查找字符的位置
|
||
TTextRange range;
|
||
TTextPosition posFind = FindEntText1(entSel, csUnit, pos, &range);
|
||
|
||
// 反复查找csUnit字符的位置
|
||
while(!!posFind)
|
||
{
|
||
// 获得字符的外包盒
|
||
XPoint ptMin, ptMax;
|
||
if(range.GetExtend(ptMin, ptMax))
|
||
{
|
||
int ll = range.m_lstRanges.Length();
|
||
for(int n=0; n<ll; n++)
|
||
{
|
||
XPoly2D poly = *range.m_lstRanges[n];
|
||
poly.SetElevation(0.0);
|
||
|
||
// 根据用户的拾取点判断本个字符是不是宣道的字符
|
||
int ret = ptPickWcs&poly;
|
||
if(ret == PR_INSIDE)// 点选位置在字符的范围内
|
||
{
|
||
csLeft = csText.Left(pos.m_nTextPos);
|
||
csRight = csText.Right(len - pos.m_nTextPos);
|
||
// add by xly on 101115 选择到的文字为上标或者下标文字时调整返回的左右字符串
|
||
if (csLeft.GetLength()>0)
|
||
{
|
||
if (csLeft.Right(1)==_T('^'))
|
||
{
|
||
csLeft = csText.Left(pos.m_nTextPos+2);
|
||
csRight = csText.Right(len - pos.m_nTextPos-2);
|
||
}
|
||
if (csLeft.Right(2)==_T("^C"))
|
||
{
|
||
csLeft = csText.Left(pos.m_nTextPos+1);
|
||
csRight = csText.Right(len - pos.m_nTextPos-1);
|
||
}
|
||
}
|
||
poly.TransUCS(Groups(0), Groups(1));
|
||
// 为选择到的字符绘制红色外包盒
|
||
GrdrawPoly(poly);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
posFind = FindEntText1(entSel, csUnit, pos, &range);
|
||
}
|
||
TTextPosition posTemp;
|
||
pos = posTemp;
|
||
}
|
||
}
|
||
|
||
// add by xly on 101209 捕获用户输入的取消、右键、回车、点取左键
|
||
// 捕获键盘输入关键字的动作
|
||
static int s_nInputRet;// 键盘输入的返回结果
|
||
static POINT s_ptInPut;// 记录拖拽选择集是点取的位置
|
||
#if ADS > 22
|
||
static bool InputKeyWord(MSG* msg)
|
||
#else
|
||
static BOOL InputKeyWord(MSG* msg)
|
||
#endif
|
||
{
|
||
BOOL bRet = FALSE;
|
||
if (!acdbCurDwg())
|
||
{
|
||
return bRet;
|
||
}
|
||
// 没有关键字输入的时候支持判断结果
|
||
switch(msg->message)
|
||
{
|
||
case WM_KEYDOWN: // 键盘输入关键字
|
||
{
|
||
if (msg->wParam==VK_RETURN || msg->wParam==VK_ESCAPE) // 键盘输入回车
|
||
{
|
||
s_nInputRet = RTNONE;
|
||
}
|
||
}
|
||
break;
|
||
case WM_RBUTTONDOWN: // 鼠标右键
|
||
{
|
||
s_nInputRet = RTNONE;
|
||
}
|
||
break;
|
||
case WM_LBUTTONDOWN :// 捕获move操作最后的点取位置
|
||
{
|
||
s_ptInPut = msg->pt;
|
||
}
|
||
default:
|
||
break;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////
|
||
// 递增文字命令接口
|
||
// add by xly on 100926
|
||
void PassTextCmd()
|
||
{
|
||
Entity entSel;// 选择到的实体
|
||
XPoint ptPick;// 点选位置
|
||
CString csText, csLeft, csRight;// 拆分的文字,拆分为选中的字符左部分(包括选中的字符),拆分为选中的字符右部分
|
||
XPoint ptPos; // 对象的基点
|
||
TPickEntSet ss(SS_FREE);
|
||
|
||
// 标记点取的位置是在名字上
|
||
bool bIsName = true;
|
||
while(1)
|
||
{
|
||
// 定义选择集
|
||
CString csPompt = _T("\n请选择要递增拷贝的文字(注:同时按CTRL键进行递减拷贝,仅对单个选中字符进行操作)<退出>:");
|
||
RBList rb(RTDXF0, _T("ATS_SYMB_SECTION,ATS_DRAWINGNAME,ATS_TEXT,TEXT,ATS_DRAWINGINDEX"), NULL);
|
||
if(SelectEntity(csPompt, entSel, ptPick, rb) != RTNORM)
|
||
return;
|
||
|
||
if (entSel.Is(_T("ATS_TEXT"))|| entSel.Is(_T("TEXT")))// 上华单行文字、CAD文字对象
|
||
{
|
||
XText text(entSel);
|
||
csText = text.m_csText;
|
||
ptPos = text.m_ptInsert;
|
||
}
|
||
else if (entSel.Is(_T("ATS_DRAWINGINDEX")))// 索引图名
|
||
{
|
||
OPENOBJ_BEGIN(entSel,AcDb::kForRead,TDbSymbDrawingIndex,pSymb);
|
||
|
||
// 获得图名索引的中心
|
||
ptPos = pSymb->GetCenter();
|
||
if (ptPick.y>ptPos.y && ptPick.x<ptPos.x+pSymb->GetRadius(FALSE))// 点取位置在中心的上方
|
||
{
|
||
csText =pSymb->GetIndexLabel();
|
||
}
|
||
else if (ptPick.x<ptPos.x+pSymb->GetRadius(FALSE))// 点取位置在中心的下方
|
||
{
|
||
csText =pSymb->GetDrawingLabel();
|
||
|
||
// 没有图号的情况
|
||
if (csText.IsEmpty())
|
||
{
|
||
csText = pSymb->GetIndexLabel();
|
||
}
|
||
}
|
||
else // 点取位置在圆形外部
|
||
{
|
||
csText = pSymb->GetScaleText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (entSel.Is(_T("ATS_SYMB_SECTION")))// 剖面,断面剖切
|
||
{
|
||
OPENOBJ_BEGIN(entSel,AcDb::kForWrite,TDbSymbSection,pSymb);
|
||
csText = pSymb->GetText();
|
||
|
||
// 获得标注两端的文字
|
||
XPoint pt1,pt2;
|
||
pt1 = pSymb->GetDefaultTextLocation(0);
|
||
pt2 = pSymb->GetDefaultTextLocation(1);
|
||
|
||
if (ptPick.Distance(pt1)<ptPick.Distance(pt2))// 选择起始位置
|
||
{
|
||
pSymb->SetTextLocation(0,pt1);
|
||
pSymb->SetTextLocation(1,pt2);
|
||
ptPos = pt1;
|
||
}
|
||
else // 选择终点位置
|
||
{
|
||
pSymb->SetTextLocation(0,pt2);
|
||
pSymb->SetTextLocation(1,pt1);
|
||
ptPos = pt2;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (entSel.Is(_T("ATS_DRAWINGNAME")))// 图名标注
|
||
{
|
||
OPENOBJ_BEGIN(entSel,AcDb::kForRead,TDbDrawingName,pSymb);
|
||
ptPos = pSymb->GetMidLocation();
|
||
|
||
if (pSymb->GetShowScale())// 显示比例
|
||
{
|
||
// 获得比例文字的位置
|
||
XPoint ptScale = pSymb->GetScaleLocation();
|
||
// 判断选中图名还是选中比例
|
||
if (ptPick.x<ptScale.x)
|
||
{
|
||
csText = pSymb->GetNameText(); // 获得图名文字
|
||
bIsName = true;
|
||
}
|
||
else
|
||
{
|
||
bIsName = false;
|
||
csText = pSymb->GetScaleText();// 获得图名文字
|
||
}
|
||
}
|
||
else // 不显示比例
|
||
{
|
||
csText = pSymb->GetNameText();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
ss += entSel;
|
||
|
||
XPoint ptPickWcs = Ucs2Wcs(ptPick);
|
||
|
||
// 点选到的字符红色框选
|
||
HightShow(csText, entSel, ptPickWcs, csLeft, csRight);
|
||
if(csLeft != _T("") || csRight != _T(""))// 已经选择字符
|
||
break;
|
||
}
|
||
|
||
// 定义基点,默认基点为对象的基点
|
||
XPoint ptBase = ptPos;
|
||
if(ads_getpoint(Wcs2Ucs(ptPos), _T("\n请指定基点:"), ptBase) == RTNORM)
|
||
{
|
||
// delete by xly on 110314 使用用户坐标系
|
||
//ptBase = Ucs2Wcs(ptBase);
|
||
}
|
||
else // 取消操作
|
||
{
|
||
// add by xly on 101206 刷新屏幕
|
||
acedRedraw(NULL,1);
|
||
return;
|
||
}
|
||
|
||
// 生成递增文字
|
||
while(1)
|
||
{
|
||
// 计算所选的文字的递增文字,ctrl键控制增加或者减少
|
||
// 注:int型数字最大值2,147,483,647 如果超过最大值将变为0
|
||
SHORT nStateCtrl = GetKeyState(VK_CONTROL);
|
||
BOOL bCtrl = (nStateCtrl&256)!=0;
|
||
if(bCtrl)
|
||
csLeft = PlusString(csLeft, 1, FALSE, true);
|
||
else
|
||
csLeft = PlusString(csLeft, 1, TRUE, true);
|
||
csText = csLeft + csRight;
|
||
|
||
// 复制选择集中的实体信息
|
||
TPickEntSet ss1(SS_FREE);
|
||
ss1.IncludeBegin();
|
||
{
|
||
XPushVar<int> tVar(_T("OSMODE"), 0);
|
||
SHads_command(RTSTR, _T("COPY"), RTPICKS, (TLong_ptr *)ss, RTSTR, _T(""),
|
||
RTSTR, _T("0,0"), RTSTR, _T("0,0"), RTNONE);
|
||
}
|
||
ss1.IncludeEnd();
|
||
int n = ss1.Length();
|
||
if (ss1.Length()<1)
|
||
{
|
||
// 选择集为空的时候,将已经做过的字符串递增、减做相反的操作
|
||
if(bCtrl)
|
||
csLeft = PlusString(csLeft, 1, TRUE, true);
|
||
else
|
||
csLeft = PlusString(csLeft, 1, FALSE, true);
|
||
continue;
|
||
}
|
||
|
||
// 修改生成递增后的文字
|
||
if (entSel.Is(_T("ATS_TEXT"))) // 上华单行文字
|
||
{
|
||
OPENOBJ_BEGIN(ss1[(long)0],AcDb::kForWrite,TDbText,pSymb);
|
||
pSymb->SetText(csText);
|
||
OPENOBJ_END();
|
||
}
|
||
else if (entSel.Is(_T("TEXT"))) // CAD文字对象
|
||
{
|
||
OPENOBJ_BEGIN(ss1[(long)0],AcDb::kForWrite,AcDbText,pSymb);
|
||
pSymb->setTextString(csText);
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
else if (entSel.Is(_T("ATS_DRAWINGINDEX")))// 索引图名
|
||
{
|
||
OPENOBJ_BEGIN(ss1[(long)0],AcDb::kForWrite,TDbSymbDrawingIndex,pSymb);
|
||
// 根据点取的位置的不同,设置相应的文字
|
||
if (ptPick.y>ptPos.y && ptPick.x<ptPos.x +pSymb->GetRadius(FALSE))
|
||
{
|
||
pSymb->SetIndexLabel(csText); // 索引编号
|
||
}
|
||
else if(ptPick.x<ptPos.x+pSymb->GetRadius(FALSE))
|
||
{
|
||
CString csDrawLable = pSymb->GetDrawingLabel();
|
||
if (csDrawLable.IsEmpty())
|
||
{
|
||
pSymb->SetIndexLabel(csText); // 索引编号
|
||
}
|
||
else
|
||
{
|
||
pSymb->SetDrawingLabel(csText); // 图名
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pSymb->SetScaleText(csText); // 比例
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (entSel.Is(_T("ATS_SYMB_SECTION")))// 剖面剖切
|
||
{
|
||
OPENOBJ_BEGIN(ss1[(long)0],AcDb::kForWrite,TDbSymbSection,pSymb);
|
||
pSymb->SetText(csText);
|
||
OPENOBJ_END();
|
||
}
|
||
else if (entSel.Is(_T("ATS_DRAWINGNAME")))// 图名索引
|
||
{
|
||
OPENOBJ_BEGIN(ss1[(long)0], AcDb::kForWrite, TDbDrawingName, pEnt);
|
||
if (pEnt->GetShowScale())// 显示比例
|
||
{
|
||
// 获得比例文字的位置
|
||
XPoint ptScale = pEnt->GetScaleLocation();
|
||
|
||
// 判断选中图名还是选中比例
|
||
if (bIsName)
|
||
{
|
||
pEnt->SetNameText(csText);
|
||
}
|
||
else
|
||
{
|
||
pEnt->SetScaleText(csText);
|
||
}
|
||
|
||
}
|
||
else // 不显示比例
|
||
{
|
||
pEnt->SetNameText(csText);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
// modify by xly on 101210 用move命令模拟jig效果
|
||
//// 拖动文字的位置
|
||
//if (DragMovePickSet(ss1, _T("\n请点取插入位置<退出>:"), ptBase, XPoint()) != RTNORM)
|
||
//{
|
||
// // add by xly on 101206 刷新屏幕
|
||
// acedRedraw(NULL,1);
|
||
// ss1.Erase();
|
||
// return;
|
||
//}
|
||
|
||
// 钩子函数监视键盘中输入关键字
|
||
s_nInputRet = 0;
|
||
acedRegisterFilterWinMsg(InputKeyWord);
|
||
|
||
acutPrintf( _T("\n请点取插入位置<退出>:"));
|
||
ss1.Redraw(2);
|
||
|
||
// lgh add.
|
||
// old extents
|
||
AcDbExtents oldExtens;
|
||
OPENOBJ_BEGIN(ss1[(long)0], AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt != NULL)
|
||
pEnt->getGeomExtents(oldExtens);
|
||
OPENOBJ_END();
|
||
|
||
// 移动实体,实现jig效果
|
||
SHads_command(RTSTR, _T("MOVE"), RTPICKS, (TLong_ptr *)ss1, RTSTR, _T(""),
|
||
RT3DPOINT, &ptBase, RTSTR, _T("\\"), RTNONE);
|
||
if (s_nInputRet == RTNONE)// 按Esc 或者右键、回车退出
|
||
{
|
||
ss1.Erase();
|
||
acedRedraw(NULL,1);
|
||
return;
|
||
}
|
||
|
||
AcDbExtents newExtents;
|
||
OPENOBJ_BEGIN(ss1[(long)0], AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt != NULL)
|
||
pEnt->getGeomExtents(newExtents);
|
||
OPENOBJ_END();
|
||
|
||
AcGeVector3d vec(newExtents.minPoint() - oldExtens.minPoint());
|
||
|
||
// lgh remmove, 2011-05017
|
||
// // 将屏幕坐标转化为CAD世界坐标
|
||
// XPoint ptLoc;
|
||
// CPoint ptTemp(s_ptInPut);
|
||
// acedGetAcadDwgView()->ScreenToClient(&ptTemp);
|
||
// acedCoordFromPixelToWorld(ptTemp, ptLoc);
|
||
//
|
||
// // modify by xly on 110314 将DCS转化为用户坐标系
|
||
// // 更新基点和选择集
|
||
// //ptBase = ptLoc;
|
||
// struct resbuf fromrb, torb;
|
||
// fromrb.restype = RTSHORT;
|
||
// fromrb.resval.rint = 2; // DCS
|
||
// torb.restype = RTSHORT;
|
||
// torb.resval.rint = 1; // UCS
|
||
//
|
||
// XPoint ptResult;
|
||
// acedTrans(ptLoc, &fromrb, &torb, FALSE, ptResult);
|
||
|
||
// ptBase = ptResult;
|
||
ptBase = (ptBase + vec);
|
||
ss.Free();
|
||
ss += ss1;
|
||
|
||
// 释放函数
|
||
acedRemoveFilterWinMsg(InputKeyWord);
|
||
}
|
||
|
||
// add by xly on 101206 刷新屏幕
|
||
acedRedraw(NULL,1);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
//add by lgy 20120201 画出标注,同时返回标注id
|
||
AcDbObjectId GetStairDim(TDbLineStair *pStair, XPoint ptPos, bool bSideChose = false)
|
||
{
|
||
XDirectionCurve leftCurve;
|
||
if (bSideChose)
|
||
{
|
||
leftCurve = pStair->GetSideCurve2d(2);
|
||
}
|
||
else
|
||
{
|
||
leftCurve = pStair->GetSideCurve2d(0);
|
||
}
|
||
|
||
TGGeCurveSegment segStair(leftCurve.StartPoint(), leftCurve.EndPoint(), 0.0, LS_FINITE);
|
||
XThirdDimData dim(segStair);
|
||
|
||
XPoint ptTextBasePrj1, ptFix1;
|
||
if (segStair.ProjectToMe(ptPos, ptTextBasePrj1)!=RTNORM)
|
||
{
|
||
adsout << _T("\n无效的选择!");
|
||
return AcDbObjectId::kNull;
|
||
}
|
||
|
||
dim.m_nDistToTextBaseline = XYDistance(ptPos,ptTextBasePrj1);
|
||
ads_polar(ptPos, ads_angle(ptPos, ptTextBasePrj1), XYDistance(ptPos,ptTextBasePrj1), ptFix1);
|
||
|
||
XPoint ptFixPrj1;
|
||
if (segStair.ProjectToMe(ptFix1, ptFixPrj1)!=RTNORM)
|
||
{
|
||
adsout << _T("\n无效的选择!");
|
||
return AcDbObjectId::kNull;
|
||
}
|
||
|
||
dim.m_nOnSide = segStair.OnWhichSide(ptPos);
|
||
dim.m_nDistToFixPos = XYDistance(ptFix1,ptFixPrj1);
|
||
|
||
AcDbObjectId idMaster = dim.Apply();
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim == NULL)
|
||
{
|
||
return AcDbObjectId::kNull;
|
||
}
|
||
|
||
//文字显示
|
||
int iStepNum = pStair->GetStepNum();
|
||
double dStepWidth = pStair->GetStepWidth();
|
||
double dTotalWidth =segStair.GetLength();
|
||
|
||
CString strDimText;
|
||
strDimText.Format(_T("%.0f×%d=%.0f"), dStepWidth, iStepNum - 1, dTotalWidth);
|
||
|
||
pDim->SetTextContent(0, strDimText);
|
||
OPENOBJ_END();
|
||
return idMaster;
|
||
}
|
||
|
||
// add by lgy 20120202 根据标注线创建标注对象
|
||
AcDbObjectId GetStairDimId(TGGeCurveSegment segStair, XPoint ptPos)
|
||
{
|
||
XThirdDimData dim(segStair);
|
||
|
||
XPoint ptTextBasePrj1, ptFix1;
|
||
if(segStair.ProjectToMe(ptPos, ptTextBasePrj1)!=RTNORM)
|
||
{
|
||
adsout << _T("\n无效的选择!");
|
||
return AcDbObjectId::kNull;
|
||
}
|
||
|
||
dim.m_nDistToTextBaseline = XYDistance(ptPos,ptTextBasePrj1);
|
||
ads_polar(ptPos, ads_angle(ptPos, ptTextBasePrj1), XYDistance(ptPos,ptTextBasePrj1), ptFix1);
|
||
|
||
XPoint ptFixPrj1;
|
||
if( segStair.ProjectToMe(ptFix1, ptFixPrj1)!=RTNORM)
|
||
{
|
||
adsout << _T("\n无效的选择!");
|
||
return AcDbObjectId::kNull;
|
||
}
|
||
|
||
dim.m_nOnSide = segStair.OnWhichSide(ptPos);
|
||
dim.m_nDistToFixPos = XYDistance(ptFix1, ptFixPrj1);
|
||
|
||
AcDbObjectId idMaster = dim.Apply();
|
||
return idMaster;
|
||
}
|
||
|
||
//add by lgy 20120201 循环提示输入其他标注点
|
||
BOOL InputOtherPt(AcDbObjectId idDim, TDimTwoPointArg &dim)
|
||
{
|
||
XPoint ptOther, ptPosition;
|
||
while(TRUE)
|
||
{
|
||
while(TRUE)
|
||
{
|
||
ptPosition = dim.GetLastPoint();
|
||
if(XGetPoint(ptPosition, _T("\n请输入其他标注点"), ptOther)== RTNORM)
|
||
{
|
||
dim.Step(ptOther);
|
||
dim.AddDim(idDim, ptOther);
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
ptPosition = dim.GetLastPoint();
|
||
int nRet2;
|
||
INITGET_BEG(0, _T("U R"));
|
||
nRet2 = acedGetPoint(ptPosition, _T("\n请输入其他标注点或 [参考点(R)/撤消上一标注点(U)]<退出>:"), ptOther);
|
||
INITGET_END();
|
||
|
||
if (nRet2 == RTKWORD)
|
||
{
|
||
XString sKey;
|
||
acedGetInput(sKey);
|
||
if(sKey[0] == _T('R'))
|
||
acedGetPoint(NULL, _T("\n参考点:"), ptPosition);
|
||
else if(sKey[0] == _T('U'))
|
||
{
|
||
dim.Undo(idDim);
|
||
if(dim.CanUndo())
|
||
ptPosition = dim.GetLastPoint();
|
||
else
|
||
ptPosition = ptOther;
|
||
}
|
||
}
|
||
else if(nRet2 == RTNORM)
|
||
{
|
||
ptPosition = ptOther;
|
||
dim.Step(ptOther);
|
||
dim.AddDim(idDim, ptOther);
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
//add by lgy 20120202 获得poly中的第n条边上的起始点或终止点
|
||
XPoint GetPtOnPoly(XPoly2D poly, int n, BOOL bFalg)
|
||
{
|
||
TGGeCurveSegment seg;
|
||
poly.Nth(n, seg);
|
||
if (bFalg)
|
||
{
|
||
return seg.EndPoint();
|
||
}
|
||
return seg.StartPoint();
|
||
}
|
||
|
||
//add by lgy 20120314 为楼梯标注写一jig预览效果
|
||
class StairDimJig : public AcEdJig
|
||
{
|
||
public:
|
||
StairDimJig(TDbDimension2 *pDim, XPoint pt);
|
||
virtual ~StairDimJig();
|
||
int doIt();
|
||
virtual DragStatus sampler();
|
||
virtual Adesk::Boolean update();
|
||
virtual AcDbEntity *entity() const;
|
||
XPoint GetDimLocalPt(); //返回jig最后获得的点的位置
|
||
TDbDimension2 *m_pDrawEnt;
|
||
XPoint m_ptJig;
|
||
};
|
||
|
||
XPoint StairDimJig::GetDimLocalPt()
|
||
{
|
||
return m_ptJig;
|
||
}
|
||
|
||
StairDimJig::StairDimJig(TDbDimension2 *pDim, XPoint pt)
|
||
{
|
||
m_pDrawEnt = pDim;
|
||
m_ptJig = pt;
|
||
}
|
||
|
||
StairDimJig::~StairDimJig()
|
||
{
|
||
}
|
||
|
||
int StairDimJig::doIt()
|
||
{
|
||
int ret;
|
||
try
|
||
{
|
||
ret = drag();
|
||
}
|
||
catch(...)
|
||
{
|
||
ret = AcEdJig::kCancel;
|
||
}
|
||
|
||
if (ret == AcEdJig::kCancel)
|
||
{
|
||
ret = RTCAN;
|
||
}
|
||
else if(ret == AcEdJig::kNull)
|
||
{
|
||
ret = RTNONE;
|
||
}
|
||
else if (ret <= 0)
|
||
{
|
||
ret = RTNORM;
|
||
}
|
||
else
|
||
{
|
||
ret = RTKWORD;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
|
||
AcEdJig::DragStatus StairDimJig::sampler()
|
||
{
|
||
setUserInputControls((UserInputControls)
|
||
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
|
||
|
||
XPoint ptCursor;
|
||
DragStatus stat = acquirePoint(ptCursor);
|
||
if(stat == AcEdJig::kNormal)
|
||
{
|
||
if (ptCursor.Distance2d(m_ptJig) > _DIST_SNAP)
|
||
{
|
||
m_ptJig = ptCursor;
|
||
}
|
||
else
|
||
{
|
||
stat = AcEdJig::kNoChange;
|
||
}
|
||
}
|
||
return stat;
|
||
}
|
||
|
||
AcDbEntity* StairDimJig::entity() const
|
||
{
|
||
return m_pDrawEnt;
|
||
}
|
||
|
||
Adesk::Boolean StairDimJig::update()
|
||
{
|
||
XPoint ptOnSeg;
|
||
TGGeCurveSegment seg = m_pDrawEnt->GetDimCurve();
|
||
if(seg.ProjectToMe(m_ptJig, ptOnSeg) == RTNORM)
|
||
{
|
||
double nDistMove = m_ptJig.Distance2d(ptOnSeg);
|
||
int nSideLoc = seg.OnWhichSide(m_pDrawEnt->GetLocation());
|
||
int nSide = seg.OnWhichSide(m_ptJig);
|
||
double nDist2Dim = m_pDrawEnt->GetDist2DimLine(FALSE);
|
||
|
||
if(fabs(nDist2Dim) > 1.0E-6)
|
||
{
|
||
double nFactor = nDist2Dim/fabs(nDist2Dim);
|
||
if(nSide != nSideLoc)
|
||
{
|
||
nDistMove *= nFactor;
|
||
}
|
||
else
|
||
{
|
||
nDistMove *= -nFactor;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(nSideLoc == OFFSET_LEFT)
|
||
{
|
||
nDistMove = -nDistMove;
|
||
}
|
||
}
|
||
|
||
nDist2Dim += nDistMove;
|
||
m_pDrawEnt->SetDist2DimLine(nDist2Dim, FALSE);
|
||
m_pDrawEnt->AdjustDim(0);
|
||
m_pDrawEnt->SetStyleId(InitDimStyle(DS_LINEAR));
|
||
}
|
||
return Adesk::kTrue;
|
||
}
|
||
|
||
|
||
// sg add 120120,楼梯标注
|
||
void DimStairLen()
|
||
{
|
||
Entity ent;
|
||
XPoint ptPick, ptPosition;
|
||
TRBList mask(RTDXF0, _T("ATS_LINESTAIR,ATS_RECTSTAIR,ATS_ARCSTAIR,ATS_CURVESTAIR,ATS_MULTISTAIR,ATS_PARALLELSTAIR,ATS_CORNERSTAIR,ATS_DOUBLEMULSTAIR,ATS_SCISSORSSTAIR,ATS_RECTCORNERSTAIR,ATS_TRIANGLESTAIR,ATS_CROSSSTAIR"), NULL);
|
||
|
||
TDimTwoPointArg dimTwo;
|
||
AcDbObjectId idMaster;
|
||
while (TRUE)
|
||
{
|
||
if (SelectEntity1(_T("\n请点取待标注的楼梯(注: 双跑、双分平行、交叉、剪刀楼梯点取其不同位置可标注不同尺寸)<退出>: "), ent, ptPick, mask) != RTNORM)
|
||
{
|
||
return;
|
||
}
|
||
ptPick = Ucs2Wcs(ptPick);
|
||
|
||
XDbObject obj(ent, AcDb::kForRead);
|
||
if (!obj)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (ent.Is(_T("ATS_LINESTAIR"))) // 如果是直线梯段
|
||
{
|
||
TDbLineStair *pStair = TDbLineStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
idMaster = GetStairDim(pStair, ptPick, true);
|
||
}
|
||
else if (ent.Is(_T("ATS_CROSSSTAIR"))) // 剪刀梯段
|
||
{
|
||
TDbCrossStair *pStair = TDbCrossStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab lSlab, rSlab; // 左右休息平台
|
||
TDbHandRail lHandRail, rHandRail; // 左右侧扶手
|
||
TDbLineStair lLineStair, rLineStair; // 左右梯段
|
||
pStair->ExplodeTo(lLineStair, rLineStair, lSlab, rSlab, lHandRail, rHandRail);
|
||
|
||
// 获得楼梯对象的各个外包框
|
||
XPoly2D lPoly, rPoly, lHandPoly, rHandPoly;
|
||
lLineStair.GetOutline2d(lPoly);
|
||
rLineStair.GetOutline2d(rPoly);
|
||
lHandRail.GetPolyTrace(lHandPoly);
|
||
rHandRail.GetPolyTrace(rHandPoly);
|
||
|
||
if (((ptPick&lPoly)!=PR_OUTSIDE) && ((ptPick&lHandPoly)==PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&lLineStair,ptPick);
|
||
}
|
||
else if (((ptPick&rPoly)!=PR_OUTSIDE) && ((ptPick&rHandPoly)==PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&rLineStair, ptPick);
|
||
}
|
||
else if ((ptPick&lHandPoly)!=PR_OUTSIDE || (ptPick&rHandPoly)!=PR_OUTSIDE)
|
||
{
|
||
TGGeCurveSegment cvSeg(lLineStair.GetLowLeft2d(), lLineStair.GetLowRight2d(), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rLineStair.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rLineStair.GetLowRight2d()));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_RECTSTAIR"))) // 双跑梯段
|
||
{
|
||
TDbRectStair *pStair = TDbRectStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab slab;
|
||
TDbHandRail rail;
|
||
TDbLineStair lStair, rStair;
|
||
pStair->ExplodeTo(lStair, rStair, slab, rail);
|
||
|
||
XPoly2D lLinePoly, rLinePoly, slabPoly, lRailPoly, rRailPoly;
|
||
rail.GetSidePoly2d(lRailPoly, rRailPoly);
|
||
lStair.GetOutline2d(lLinePoly);
|
||
rStair.GetOutline2d(rLinePoly);
|
||
slabPoly = slab.GetOutline();
|
||
|
||
// 设置扶手轮廓线闭合,解决经常首层、顶层经常出现的错误选择,sg add 120616
|
||
lRailPoly.SetClosed();
|
||
rRailPoly.SetClosed();
|
||
|
||
if (((ptPick&lLinePoly)!=PR_OUTSIDE) && ((ptPick&lRailPoly)==PR_OUTSIDE)) // 一跑
|
||
{
|
||
idMaster = GetStairDim(&lStair, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpLeft2d()));
|
||
}
|
||
else if (((ptPick&rLinePoly)!=PR_OUTSIDE) && ((ptPick&lRailPoly)==PR_OUTSIDE)) // 二跑
|
||
{
|
||
idMaster = GetStairDim(&rStair, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
}
|
||
else if ((ptPick&lRailPoly) != PR_OUTSIDE) // 扶手
|
||
{
|
||
TGGeCurveSegment cvSeg(lStair.GetLowLeft2d(), lStair.GetLowRight2d(), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowRight2d()));
|
||
}
|
||
else if (pStair->GetStairFlag() == 0)// 首层,优先标注扶手,但是就无法单独标注休息平台,sg add 120616
|
||
{
|
||
TGGeCurveSegment cvSeg(lStair.GetLowLeft2d(), lStair.GetLowRight2d(), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowRight2d()));
|
||
}
|
||
else // 休息平台
|
||
{
|
||
TGGeCurveSegment cvSeg(GetPtOnPoly(slabPoly, 1, FALSE), GetPtOnPoly(slabPoly, 2, FALSE), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_MULTISTAIR"))) //多跑楼梯
|
||
{
|
||
TDbMultiStair *pStair = TDbMultiStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
DList<TDbEntity> lstComponents;
|
||
pStair->ExplodeTo(lstComponents);
|
||
|
||
XPoly2D poly;
|
||
pStair->GetSidePoly2d(0, poly);
|
||
|
||
//XPoly2D linePoly;
|
||
for (int k=0; k<lstComponents.Length(); k++)
|
||
{
|
||
TDbEntity *pEnt = lstComponents[k];
|
||
if (pEnt->isKindOf(TDbLineStair::desc()))
|
||
{
|
||
TDbLineStair *pLineStair = (TDbLineStair *)pEnt;
|
||
|
||
XPoly2D linePoly; // sg modify 120616,从循环外挪到此处,解决多跑楼梯标注错误
|
||
pLineStair->GetOutline2d(linePoly);
|
||
|
||
if ((ptPick&linePoly) != PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(pLineStair, ptPick);
|
||
// sg delete 120616,由于不好确定“休息平台”的位置,改为多跑楼梯的话,只标注梯段
|
||
//if (k != lstComponents.Length()-3)
|
||
//{
|
||
// TGGeCurveSegment seg;
|
||
// poly.Nth(k, seg);
|
||
// dimTwo.AddDim(idMaster, Wcs2Ucs(seg.EndPoint()));
|
||
//}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_PARALLELSTAIR")))//双分平行
|
||
{
|
||
TDbParallelStair *pStair = TDbParallelStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab slab;
|
||
TDbHandRail lRail, rRail;
|
||
TDbLineStair lStair, midStair, rStair;
|
||
pStair->ExplodeTo(lStair, midStair, rStair, slab, lRail, rRail);
|
||
|
||
XPoly2D lStairPoly, midStairPoly, rStairPoly, lRailPoly, rRailPoly, slabPoly;
|
||
lStair.GetOutline2d(lStairPoly);
|
||
midStair.GetOutline2d(midStairPoly);
|
||
rStair.GetOutline2d(rStairPoly);
|
||
lRail.GetPolyTrace(lRailPoly);
|
||
rRail.GetPolyTrace(rRailPoly);
|
||
slabPoly = slab.GetOutline(); // sg add 120617,需求希望单独标注休息平台
|
||
|
||
if (((ptPick&lStairPoly)!=PR_OUTSIDE) && ((ptPick&lRailPoly)==PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&lStair, ptPick, true);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpLeft2d()));
|
||
}
|
||
else if (((ptPick&rStairPoly)!=PR_OUTSIDE) && ((ptPick&rRailPoly)==PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&rStair, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
}
|
||
else if (((ptPick&midStairPoly)!=PR_OUTSIDE) && ((ptPick&rRailPoly)==PR_OUTSIDE) && ((ptPick&lRailPoly)==PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&midStair, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpLeft2d()));
|
||
}
|
||
else if (((ptPick&lRailPoly)!=PR_OUTSIDE) || ((ptPick&rRailPoly)!=PR_OUTSIDE))
|
||
{
|
||
TGGeCurveSegment cvSeg(lStair.GetUpLeft2d(), lStair.GetUpRight2d(), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(midStair.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(midStair.GetLowRight2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetLowRight2d()));
|
||
}
|
||
else // sg add 120617,需求希望单独标注休息平台
|
||
{
|
||
// continue;
|
||
TGGeCurveSegment cvSeg(GetPtOnPoly(slabPoly, 1, FALSE), GetPtOnPoly(slabPoly, 2, FALSE), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(cvSeg, ptPick);
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_CORNERSTAIR"))) // 双分转角
|
||
{
|
||
TDbCornerStair *pStair = TDbCornerStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab slab;
|
||
TDbHandRail lRail, rRail;
|
||
TDbLineStair lStair, midStair, rStair;
|
||
pStair->ExplodeTo(lStair, midStair, rStair, slab, lRail, rRail);
|
||
|
||
XPoly2D lStairPoly, midStairPoly, rStairPoly;
|
||
lStair.GetOutline2d(lStairPoly);
|
||
midStair.GetOutline2d(midStairPoly);
|
||
rStair.GetOutline2d(rStairPoly);
|
||
|
||
if (((ptPick&lStairPoly)!=PR_OUTSIDE) || ((ptPick&rStairPoly)!=PR_OUTSIDE))
|
||
{
|
||
idMaster = GetStairDim(&lStair, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(rStair.GetUpLeft2d()));
|
||
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim == NULL)
|
||
{
|
||
return;
|
||
}
|
||
CString strText;
|
||
TGGeCurveSegment seg;
|
||
seg = rStair.GetSideCurve2d(0);
|
||
strText.Format(_T("%.0f×%d=%.0f"), rStair.GetStepWidth(), rStair.GetStepNum(), seg.GetLength());
|
||
pDim->SetTextContent(2, strText);
|
||
OPENOBJ_END()
|
||
}
|
||
else if ((ptPick&midStairPoly) != PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&midStair, ptPick, true);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_DOUBLEMULSTAIR"))) // 双分三跑楼梯
|
||
{
|
||
TDbDoubleMulStair *pStair = TDbDoubleMulStair::cast(obj.m_pObject);
|
||
if (pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab slab;
|
||
TDbHandRail rail;
|
||
TDbLineStair stair1, stair2, stair3, stair4, stair5;
|
||
pStair->ExplodeTo(stair1, stair2, stair3, stair4, stair5, slab, slab, slab, rail, rail);
|
||
|
||
XPoly2D lStairPoly, rStairPoly, midStairPoly, upleftPoly, upRightPoly;
|
||
stair1.GetOutline2d(lStairPoly);
|
||
stair2.GetOutline2d(midStairPoly);
|
||
stair3.GetOutline2d(rStairPoly);
|
||
stair4.GetOutline2d(upleftPoly);
|
||
stair5.GetOutline2d(upRightPoly);
|
||
|
||
if ((ptPick&upleftPoly)!=PR_OUTSIDE || (ptPick&upRightPoly)!=PR_OUTSIDE) // 点中中段梯段
|
||
{
|
||
idMaster = GetStairDim(&stair4, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair5.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair5.GetUpLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
CString strText;
|
||
TGGeCurveSegment seg;
|
||
seg = stair5.GetSideCurve2d(0);
|
||
strText.Format(_T("%.0f×%d=%.0f"), stair5.GetStepWidth(), stair5.GetStepNum(), seg.GetLength());
|
||
pDim->SetTextContent(3, strText);
|
||
OPENOBJ_END()
|
||
}
|
||
else if ((ptPick&lStairPoly) != PR_OUTSIDE) // 点中两边梯段的左边楼梯
|
||
{
|
||
idMaster = GetStairDim(&stair1, ptPick);
|
||
// sg modify 120617,解决双分三跑楼梯(中间为上楼方向)梯段方向的尺寸标注缺少休息平台的问题
|
||
if (pStair->GetStartSide() == OFFSET_MID)
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
else
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair5.GetUpRight2d()));
|
||
}
|
||
else if ((ptPick&rStairPoly) != PR_OUTSIDE) // 点中两边楼梯的右边楼梯
|
||
{
|
||
idMaster = GetStairDim(&stair3, ptPick, true);
|
||
// sg modify 120617,解决双分三跑楼梯(中间为上楼方向)梯段方向的尺寸标注缺少休息平台的问题
|
||
if (pStair->GetStartSide() == OFFSET_MID)
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
else
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair5.GetUpRight2d()));
|
||
}
|
||
else if ((ptPick&midStairPoly) != PR_OUTSIDE) // 点中中间梯段
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick, true);
|
||
// sg modify 120617,解决双分三跑楼梯(中间为上楼方向)梯段方向的尺寸标注缺少休息平台的问题
|
||
if (pStair->GetStartSide() == OFFSET_MID)
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(pStair->GetUpRight2d()));
|
||
else
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair5.GetUpRight2d()));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_SCISSORSSTAIR"))) //交叉楼梯
|
||
{
|
||
TDbScissorsStair *pStair = TDbScissorsStair::cast(obj.m_pObject);
|
||
if(pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbSlab slab;
|
||
TDbHandRail lRail, rRail;
|
||
TDbLineStair stair1,stair2,stair3,stair4;
|
||
XPoly2D poly1, poly2, poly3, poly4, slabPoly, lRailPoly, rRailPoly;
|
||
pStair->ExplodeTo(stair1, stair2, stair3, stair4, slab, lRail, rRail);
|
||
|
||
stair1.GetOutline2d(poly1);
|
||
stair2.GetOutline2d(poly2);
|
||
stair3.GetOutline2d(poly3);
|
||
stair4.GetOutline2d(poly4);
|
||
slabPoly = slab.GetOutline();
|
||
lRail.GetPolyTrace(lRailPoly);
|
||
rRail.GetPolyTrace(rRailPoly);
|
||
|
||
if ((((ptPick&poly1)!=PR_OUTSIDE) && ((ptPick&lRailPoly)==PR_OUTSIDE)) || (((ptPick&poly4)!=PR_OUTSIDE) && ((ptPick&rRailPoly)==PR_OUTSIDE)))
|
||
{
|
||
idMaster = GetStairDim(&stair4, ptPick, true);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair1.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair1.GetUpLeft2d()));
|
||
CString strText;
|
||
TGGeCurveSegment seg;
|
||
seg = stair4.GetSideCurve2d(0);
|
||
strText.Format(_T("%.0f×%d=%.0f"), stair4.GetStepWidth(), stair4.GetStepNum()-1, seg.GetLength());
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (!pDim)
|
||
{
|
||
return;
|
||
}
|
||
pDim->SetTextContent(0, strText);
|
||
OPENOBJ_END();
|
||
}
|
||
else if ((((ptPick&poly2)!=PR_OUTSIDE)&&((ptPick&lRailPoly)==PR_OUTSIDE))||(((ptPick&poly3)!=PR_OUTSIDE)&&((ptPick&rRailPoly)==PR_OUTSIDE)))
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick, true);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair3.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair3.GetUpLeft2d()));
|
||
CString strText;
|
||
TGGeCurveSegment seg;
|
||
seg = stair3.GetSideCurve2d(0);
|
||
strText.Format(_T("%.0f×%d=%.0f"), stair3.GetStepWidth(), stair3.GetStepNum()-1, seg.GetLength());
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (!pDim)
|
||
{
|
||
return;
|
||
}
|
||
pDim->SetTextContent(2, strText);
|
||
OPENOBJ_END();
|
||
}
|
||
else if (((ptPick&rRailPoly)!=PR_OUTSIDE)||((ptPick&lRailPoly)!=PR_OUTSIDE))
|
||
{
|
||
TGGeCurveSegment seg(stair2.GetLowLeft2d(), stair2.GetLowRight2d(), 0.0, LS_FINITE);
|
||
idMaster = GetStairDimId(seg, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair1.GetLowLeft2d()));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(stair1.GetLowRight2d()));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_TRIANGLESTAIR"))) //三角楼梯
|
||
{
|
||
TDbTriangleStair *pStair = TDbTriangleStair::cast(obj.m_pObject);
|
||
if(pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbHandRail rail;
|
||
TDbSlab slab1, slab2, slab3;
|
||
TDbLineStair stair1,stair2,stair3;
|
||
pStair->ExplodeTo(stair1, stair2, stair3, slab1, slab2, slab3, rail, rail, rail);
|
||
|
||
XPoly2D stairPloy1, stairPloy2, stairPloy3, slabPloy1, slabPloy2, slabPloy3;
|
||
stair1.GetOutline2d(stairPloy1);
|
||
stair2.GetOutline2d(stairPloy2);
|
||
stair3.GetOutline2d(stairPloy3);
|
||
slabPloy1 = slab1.GetOutline();
|
||
slabPloy2 = slab2.GetOutline();
|
||
slabPloy3 = slab3.GetOutline();
|
||
|
||
if ((ptPick&stairPloy1) != PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair1, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 2, FALSE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy3, 0, TRUE)));
|
||
}
|
||
else if ((ptPick&stairPloy2) != PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 2, FALSE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 0, TRUE)));
|
||
}
|
||
else if ((ptPick&stairPloy3) != PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair3, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy3, 2, FALSE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 0, TRUE)));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (ent.Is(_T("ATS_RECTCORNERSTAIR")))//矩形转角
|
||
{
|
||
TDbRectCornerStair *pStair = TDbRectCornerStair::cast(obj.m_pObject);
|
||
if(pStair == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TDbHandRail rail;
|
||
TDbSlab slab1, slab2, slab3, slab4;
|
||
TDbLineStair stair1,stair2,stair3,stair4;
|
||
pStair->ExplodeTo(stair1,stair2,stair3,stair4,slab1,slab2,slab3,slab4,rail,rail,rail,rail);
|
||
|
||
XPoly2D stairPloy1, stairPloy2, stairPloy3, stairPloy4, slabPloy1, slabPloy2, slabPloy3, slabPloy4;
|
||
stair1.GetOutline2d(stairPloy1);
|
||
stair2.GetOutline2d(stairPloy2);
|
||
stair3.GetOutline2d(stairPloy3);
|
||
stair4.GetOutline2d(stairPloy4);
|
||
slabPloy1 = slab1.GetOutline();
|
||
slabPloy2 = slab2.GetOutline();
|
||
slabPloy3 = slab3.GetOutline();
|
||
slabPloy4 = slab4.GetOutline();
|
||
|
||
int nNum = pStair->GetStairNum();
|
||
if (nNum == 2)
|
||
{
|
||
if ((ptPick&stairPloy1)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair1, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 2, FALSE)));
|
||
}
|
||
else if ((ptPick&stairPloy2)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 1, TRUE)));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (nNum == 3)
|
||
{
|
||
if ((ptPick&stairPloy1)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair1, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 2, FALSE)));
|
||
}
|
||
else if ((ptPick&stairPloy2)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 1, TRUE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 2, FALSE)));
|
||
}
|
||
else if ((ptPick&stairPloy3)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair3, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 1, TRUE)));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
else if (nNum == 4)
|
||
{
|
||
if ((ptPick&stairPloy1)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair1, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 2, FALSE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy4, 1, TRUE)));
|
||
}
|
||
else if ((ptPick&stairPloy2)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair2, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy1, 1, TRUE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 2, FALSE)));
|
||
}
|
||
else if ((ptPick&stairPloy3)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair3, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy2, 1, TRUE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy3, 2, FALSE)));
|
||
}
|
||
else if ((ptPick&stairPloy4)!=PR_OUTSIDE)
|
||
{
|
||
idMaster = GetStairDim(&stair4, ptPick);
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy3, 1, TRUE)));
|
||
dimTwo.AddDim(idMaster, Wcs2Ucs(GetPtOnPoly(slabPloy4, 2, FALSE)));
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
|
||
TDbDimension2 *pOtherEnt;
|
||
OPENOBJ_BEGIN(idMaster, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (!pDim)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcRxObject *pObject = pDim->clone();
|
||
if (pObject != NULL)
|
||
{
|
||
pOtherEnt = TDbDimension2::cast(pObject);
|
||
if (pOtherEnt == NULL)
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
pDim->erase();
|
||
pDim->close();
|
||
acutPrintf(_T("\n请点取尺寸线位置<退出>:"));
|
||
|
||
StairDimJig dimJig(pOtherEnt, ptPick);
|
||
if (dimJig.doIt() != RTNORM)
|
||
{
|
||
delete pOtherEnt;
|
||
return;
|
||
};
|
||
AcDbObjectId id = AddToModelSpace(pOtherEnt);
|
||
|
||
dimTwo.Step(Wcs2Ucs(dimJig.GetDimLocalPt()));
|
||
InputOtherPt(id, dimTwo); // 提示是否添加标注点或者删除标注点
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
|
||
// add by zyc 20120423 TDimIsometry命令的实现
|
||
static double s_dIsometry = 800.0f;
|
||
struct SDim
|
||
{
|
||
AcGeVector2d vtDirection;
|
||
TEntitySet es;
|
||
double dDistance; // 到参考标注的距离
|
||
};
|
||
|
||
// 根据在参考标注的哪一侧,将标注对象分为两组
|
||
void SplitDims(TEntitySet setRef, const TPickEntSet& pickSet,
|
||
std::vector<SDim>& vtLeft, std::vector<SDim>& vtRight)
|
||
{
|
||
// 获取参考标注所在直线的方向向量
|
||
AcGeVector2d vtRefDir;
|
||
AcGePoint3d ptStart;
|
||
AcGePoint3d ptEnd;
|
||
|
||
OPENOBJ_BEGIN(setRef, AcDb::kForRead, TDbDimension2, pDim);
|
||
if (pDim)
|
||
{
|
||
pDim->getStartPoint(ptStart);
|
||
pDim->getEndPoint(ptEnd);
|
||
vtRefDir.set(ptStart.x-ptEnd.x, ptStart.y-ptEnd.y);
|
||
}
|
||
OPENOBJ_END();
|
||
AcGeLine3d lineRef;
|
||
lineRef.set(ptStart, ptEnd);
|
||
|
||
// 与参考标注垂直的方向向量
|
||
AcGeVector2d vtLeftDir, vtRightDir;
|
||
vtLeftDir = vtRefDir;
|
||
vtLeftDir.rotateBy(PI/2.0f);
|
||
vtLeftDir.normalize();
|
||
vtRightDir = vtRefDir;
|
||
vtRightDir.rotateBy(-PI/2.0f);
|
||
vtRightDir.normalize();
|
||
|
||
// 遍历选择集
|
||
double dDistance;
|
||
SDim sDim;
|
||
// 设置误差范围
|
||
AcGeTol tol;
|
||
tol.setEqualPoint(_DIST_SNAP);
|
||
tol.setEqualVector(_DIST_SNAP);
|
||
for (int i=0; i<pickSet.Length(); i++)
|
||
{
|
||
OPENOBJ_BEGIN(pickSet[(long)i], AcDb::kForRead, TDbDimension2, pDim);
|
||
if (pDim)
|
||
{
|
||
// 判断是否与参考标注平行
|
||
AcGePoint3d ptStartTemp,ptEndTemp;
|
||
pDim->getStartPoint(ptStartTemp);
|
||
pDim->getEndPoint(ptEndTemp);
|
||
AcGeVector2d vtDir;
|
||
vtDir.set(ptStartTemp.x-ptEndTemp.x,
|
||
ptStartTemp.y-ptEndTemp.y);
|
||
if (Adesk::kTrue != vtDir.isParallelTo(vtRefDir, tol) ||
|
||
pickSet[(long)i] == setRef)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
|
||
// 获取到参考标注的距离
|
||
dDistance = lineRef.distanceTo(ptStartTemp);
|
||
sDim.dDistance = dDistance;
|
||
sDim.es = pickSet[(long)i];
|
||
if (dDistance-0 < _DIST_SNAP)
|
||
{
|
||
sDim.vtDirection = vtLeftDir;
|
||
vtLeft.push_back(sDim);
|
||
continue;
|
||
}
|
||
|
||
// 判断在参考标注的哪一边
|
||
AcGeVector2d vtTemp;
|
||
vtTemp.set(ptStartTemp.x-ptEnd.x,
|
||
ptStartTemp.y-ptEnd.y);
|
||
vtTemp.rotateBy(-vtRefDir.angle());
|
||
if (vtTemp.angle() > PI)
|
||
{
|
||
sDim.vtDirection = vtRightDir;
|
||
vtRight.push_back(sDim);
|
||
}
|
||
else
|
||
{
|
||
sDim.vtDirection = vtLeftDir;
|
||
vtLeft.push_back(sDim);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
void AdjustDims(std::vector<SDim>& vtDims)
|
||
{
|
||
AcGeMatrix3d matrix;
|
||
AcGeVector3d vec;
|
||
for (int i=0; i<(int)vtDims.size(); i++)
|
||
{
|
||
vec.set(vtDims[i].vtDirection.x,
|
||
vtDims[i].vtDirection.y, 0);
|
||
matrix.setToTranslation(vec *
|
||
(s_dIsometry*(i+1)-vtDims[i].dDistance));
|
||
OPENOBJ_BEGIN(vtDims[i].es, AcDb::kForWrite, TDbDimension2, pDim);
|
||
if (pDim)
|
||
{
|
||
// pDim->TransformBy(matrix);
|
||
pDim->subTransformBy(matrix);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
bool SortDims(const SDim& dim1, const SDim& dim2)
|
||
{
|
||
return dim1.dDistance < dim2.dDistance;
|
||
}
|
||
|
||
void DimIsometry()
|
||
{
|
||
// 清空初始选择集
|
||
g_ssPickFirst.Free();
|
||
|
||
// 选择参考标注
|
||
TEntitySet setRef;
|
||
TRBList mask = TRBList(RTDXF0, _T("TCH_Dimension2"), NULL);
|
||
int iRet = SelectEntity(_T("\n请选择参考标注<退出>:"), setRef, mask);
|
||
if (RTNORM != iRet)
|
||
{
|
||
return;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(setRef, AcDb::kForRead, TDbDimension2, pDim);
|
||
if (pDim)
|
||
{
|
||
if (pDim->IsAngular())
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
// 选择需要对齐的标注
|
||
TPickEntSet setNeedAlign;
|
||
iRet = SelectEntities(_T("\n请选择其它标注:"), setNeedAlign, mask);
|
||
if (RTNORM != iRet)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 将需要对齐的标注根据参考标注的两侧分为两组
|
||
std::vector<SDim> vtLeft, vtRight;
|
||
SplitDims(setRef, setNeedAlign, vtLeft, vtRight);
|
||
setNeedAlign.Free();
|
||
|
||
// 如果两组均为空,退出命令
|
||
if (vtLeft.size() == 0 &&
|
||
vtRight.size()== 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 提示输入间距
|
||
CString sIsometry;
|
||
sIsometry.Format(_T("%lf"), s_dIsometry);
|
||
sIsometry.TrimRight('0');
|
||
sIsometry.TrimRight('.');
|
||
CString sPrompt;
|
||
sPrompt.Format(_T("\n请输入尺寸线间距<%s>:"), (LPCTSTR)sIsometry);
|
||
iRet = acedGetReal((LPCTSTR)sPrompt, &s_dIsometry);
|
||
if (RTCAN == iRet)
|
||
{
|
||
return;
|
||
}
|
||
|
||
// 对两组分别进行排序(根据与参考标注的距离)
|
||
sort(vtLeft.begin(), vtLeft.end(), SortDims);
|
||
sort(vtRight.begin(), vtRight.end(), SortDims);
|
||
|
||
// 对需要等距处理的标注进行相应的偏移
|
||
AdjustDims(vtLeft);
|
||
AdjustDims(vtRight);
|
||
}
|
||
// end of TDbDimIsometry
|
||
|
||
void ParallelDim()
|
||
{
|
||
CParallelDimStyle parallelDim;
|
||
parallelDim.ParallelDimensioning(TRUE);
|
||
}
|
||
void RoadWideDim()
|
||
{
|
||
CParallelDimStyle parallelDim;
|
||
parallelDim.ParallelDimensioning(FALSE);
|
||
}
|
||
|
||
void ArcRadDim()
|
||
{
|
||
CArcRadDimStyle arcRadStyle;
|
||
arcRadStyle.ArcRadDimensioning();
|
||
} |