Files
envi-code/SourceCode/Code2026/Dimension/AecDbDimension_Old.cpp
T
2026-09-28 15:28:50 +08:00

2641 lines
73 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "DimTextPos.h"
#include "DimTextContent.h"
#include "AecDbDimension_Old.h"
#include "PushProperty.h"
#include "AecDbText.h"
#include "globalFunc.h"
#include "AcDbObjectPtr.h"
#include "superlist.h"
#include "gecurveinline.h"
#include "ADSgepointdir2d.h"
#include "SortedVertexList.h"
#include "PushMemVar.h"
#include "DimOptionData.h"
#pragma region AecXDbDimension_Old
/////////////////////////////////////////////////////////////
// 尺寸对象类
/////////////////////////////////////////////////////////////
const Adesk::UInt8 AecXDbDimension_Old::g_nVersion = 3;
ACRX_DXF_DEFINE_MEMBERS(AecXDbDimension_Old, AecXDbEntityBaseEx, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
1, AEC_DIMENSION_OLD, "AEC_DIMENSIO_OLDN|缺乏上华解释器, 请下载上华软件|网址: www.shanghuasoft.com");
AecXDbDimension_Old::AecXDbDimension_Old()
{
m_nRotation = 0; //旋转角度
m_nDist2DimLine = 0; //定位点到尺寸线的距离, 可以为负值
m_nDimRadius = 0; //夹角,可以为负
m_nObjRadius = 0;
}
AecXDbDimension_Old::~AecXDbDimension_Old()
{
}
BOOL AecXDbDimension_Old::IsValid() const
{
//BOOL bRet = TDbEntity::IsValid();
//if (!bRet)
// return bRet;
BOOL bRet = m_lstSegment.Length() >= 1;
return bRet;
}
BOOL AecXDbDimension_Old::IsValidSegment(double nVal, BOOL bDist) const
{
double nPrec = IsAngular() ? g_DimOption::instance()._angSnap : g_Option::instance()._DIST_SNAP;
if (IsAngular() && bDist) {
ASSERT(m_nDimRadius > g_Option::instance()._DIST_SNAP);
nVal = nVal / m_nDimRadius;
}
return (nVal > nPrec);
}
void AecXDbDimension_Old::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
{
AssertWriteEnabled();
double nOldScale = GetPScale();
double nDimDist = GetDist2DimLine(FALSE);
AecXDbEntityBaseEx::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
AecXDbDimension_Old *pSrc = AecXDbDimension_Old::cast(pSrcEntity);
if (pSrc) {
if (database() == NULL ||
pSrcEntity->database() == NULL ||
database() == pSrcEntity->database())//add by whl on 060317
{
m_idDimStyle = pSrc->m_idDimStyle; //尺寸标注类型
}
UseDimStyleScale(pSrc->IsUseDimStyleScale());
}
double nNewScale = GetPScale();
if (fabs(nNewScale - nOldScale) > 1.0E-3 && IsAngular()) {
SetDist2DimLine(nDimDist, FALSE);
}
}
// 从DWG读入数据:
Acad::ErrorStatus AecXDbDimension_Old::dwgInFields(AcDbDwgFiler* pFiler)
{
AssertWriteEnabled();
Acad::ErrorStatus es = AecXDbEntityBaseEx::dwgInFields(pFiler);
if (es != Acad::eOk) return es;
Adesk::UInt8 nVer;
pFiler->readItem(&nVer);
if (nVer > g_nVersion) {// Version is too new
return Acad::eMakeMeProxy;
}
pFiler->readItem((AcGePoint3d *)&m_ptLocation); //定位点--即不动点
m_ptLocation.z = 0; //必须是二维
pFiler->readItem(&m_nRotation); //旋转角度
pFiler->readItem(&m_nDist2DimLine); //定位点到尺寸线的距离, 可以为负值
if (nVer < 2)
pFiler->readItem(&m_nDimRadius); //夹角,可以为负
pFiler->readItem(&m_idDimStyle); //尺寸标注类型
m_lstSegment.Reset();
Adesk::UInt16 nSeg = 0;
pFiler->readItem(&nSeg);
for (Adesk::UInt16 i = 0; i < nSeg; i++) {
double nVal = 0;
pFiler->readItem(&nVal);
m_lstSegment.Append(new double(nVal));
}
if (nVer > 1) {
pFiler->readItem(&m_nDimFlag);
}
else m_nDimFlag = 0;
m_lstTextPos.Reset();
if (nVer == 1 || (m_nDimFlag & DF_POSITION)) {
m_lstTextPos.Reset();
Adesk::UInt16 nTextSeg = 0;
pFiler->readItem(&nTextSeg);
for (i = 0; i < nTextSeg; i++) {
AcGePoint2d ptPos;
Adesk::UInt16 nIndex;
pFiler->readItem(&nIndex);
pFiler->readItem(&ptPos);
m_lstTextPos.Append(new DimTextPos(nIndex, ADSGePoint3d(ptPos[0], ptPos[1])));
}
}
m_lstTextContent.Reset();
if (nVer > 1) {
if (m_nDimFlag & DF_TEXT) {
Adesk::UInt16 nTextSeg = 0;
pFiler->readItem(&nTextSeg);
for (i = 0; i < nTextSeg; i++) {
TCString sText;
Adesk::UInt16 nIndex;
pFiler->readItem(&nIndex);
GlobalFunc::ReadString(pFiler, sText);
m_lstTextContent.Append(new DimTextContent(nIndex, sText));
}
}
if (m_nDimFlag & DF_BIND)
pFiler->readItem(&m_idBind);
if (nVer > 2 && IsAngular()) {
pFiler->readItem(&m_nDimRadius);
pFiler->readItem(&m_nObjRadius);
}
}
es = pFiler->filerStatus();
return es;
}
Acad::ErrorStatus AecXDbDimension_Old::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = AecXDbEntityBaseEx::dwgOutFields(pFiler);
if (es != Acad::eOk) return es;
pFiler->writeItem(g_nVersion);
pFiler->writeItem((const AcGePoint3d &)m_ptLocation); //定位点--即不动点
pFiler->writeItem(m_nRotation); //旋转角度
pFiler->writeItem(m_nDist2DimLine); //定位点到尺寸线的距离, 可以为负值
pFiler->writeItem(m_idDimStyle); //尺寸标注类型
Adesk::UInt16 nSeg = m_lstSegment.Length();
pFiler->writeItem(nSeg);
for (Adesk::UInt16 i = 0; i < nSeg; i++) {
double nVal = m_lstSegment[i];
pFiler->writeItem(nVal);
}
pFiler->writeItem(m_nDimFlag);
if (m_nDimFlag & DF_POSITION) {
Adesk::UInt16 nTextSeg = m_lstTextPos.Length();
pFiler->writeItem(nTextSeg);
for (i = 0; i < nTextSeg; i++) {
const DimTextPos &pTextPos = m_lstTextPos[i];
pFiler->writeItem(pTextPos.nIndex);
pFiler->writeItem((const AcGePoint2d &)pTextPos.ptPos);
}
}
if (m_nDimFlag & DF_TEXT) {
Adesk::UInt16 nTextSeg = m_lstTextContent.Length();
pFiler->writeItem(nTextSeg);
for (i = 0; i < nTextSeg; i++) {
const DimTextContent &text = m_lstTextContent[i];
pFiler->writeItem(text.nIndex);
pFiler->writeString(text.sText);
}
}
if (IsBind()) {
pFiler->writeItem(m_idBind);
}
if (IsAngular()) {
pFiler->writeItem(m_nDimRadius); //夹角,可以为负
pFiler->writeItem(m_nObjRadius);
}
return pFiler->filerStatus();
}
Acad::ErrorStatus AecXDbDimension_Old::dxfInFields(AcDbDxfFiler* pFiler)
{
AssertWriteEnabled();
Acad::ErrorStatus es = AecXDbEntityBaseEx::dxfInFields(pFiler);
if (es != Acad::eOk)
return es;
if (!pFiler->atSubclassData(_T("AecXDbDimension_Old"))) {
return Acad::eBadDxfSequence;
}
return pFiler->filerStatus();
// 不读入任何数据
}
Acad::ErrorStatus AecXDbDimension_Old::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = AecXDbEntityBaseEx::dxfOutFields(pFiler);
assert(es == Acad::eOk);
es = pFiler->writeItem(AcDb::kDxfSubclass, _T("AecXDbDimension_Old"));
assert(es == Acad::eOk);
return es;
}
// -----------------------------------------------------------------------
Acad::ErrorStatus
AecXDbDimension_Old::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
INT_PTR gsSelectionMark,
const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform,
AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds) const
{
assertReadEnabled();
Acad::ErrorStatus es = Acad::eOk;
switch (osnapMode) {
case AcDb::kOsModeNode:
case AcDb::kOsModeIns: {
double nOffDist = m_nDist2DimLine * GetPScale();
GeCurveSegment cv = GetDimCurve();
GeCurveSegment cvFix = cv.Offset(nOffDist, LS_FINITE);
GePoly2D poly;
GetPolySegOnDimLine(poly);
if (osnapMode == AcDb::kOsModeNode) {
int nVertNum = poly.Length();
for (int i = 0; i < nVertNum; i++) {
ADSGePoint3d ptFix;
cvFix.ProjectToMe(*poly[i], ptFix);
snapPoints.append(*poly[i]);
snapPoints.append(ptFix);
}
}
else {
int nSeg = poly.TotalSegments();
for (int i = 0; i < nSeg; i++) {
ADSGePoint3d ptText = GetTextPos(i);
snapPoints.append(ptText);
}
}
}
break;
default: {
//XPushMemVar<BOOL> vTemp(g_bExplAcadDim, FALSE);
AecXDbEntityBaseEx::subGetOsnapPoints(osnapMode, gsSelectionMark, pickPoint,
lastPoint, viewXform, snapPoints,
geomIds);
}
return Acad::eOk;
}
return es;
}
// Overriden functions for edit
// to do:
// 允许通过夹点改变边界
Acad::ErrorStatus AecXDbDimension_Old::subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
assertReadEnabled();
double nOffDist = m_nDist2DimLine * GetPScale();
GeCurveSegment cv = GetDimCurve();
GeCurveSegment cvFix = cv.Offset(nOffDist, LS_FINITE);
GeCurveSegment cvObj;
if (IsAngular()) {
double nDist2Obj = cv.GetArc().GetRadius() - m_nObjRadius;
cvObj = cv.Offset(-nDist2Obj, LS_FINITE);
}
GePoly2D poly;
GetPolySegOnDimLine(poly);
int nVertNum = poly.Length();
gripPoints.append(*poly.Head()); //0
gripPoints.append(*poly.Tail()); //1
for (int i = 0; i < nVertNum; i++) {
ADSGePoint3d ptFix;
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
cvObj.ProjectToMe(*poly[i], ptFix);
else cvFix.ProjectToMe(*poly[i], ptFix);
gripPoints.append(ptFix);
}
int nSeg = poly.TotalSegments();
for (i = 0; i < nSeg; i++) {
ADSGePoint3d ptText = GetTextPos(i);
gripPoints.append(ptText);
}
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
gripPoints.append(m_ptLocation);
return Acad::eOk;
}
Acad::ErrorStatus AecXDbDimension_Old::subGetGripPoints(AcDbGripDataPtrArray & grips, const double curViewUnitSize, const int gripSize, const AcGeVector3d & curViewDir, const int bitflags) const
{
return Acad::eNotImplementedYet;
}
// stretch points is diffrent from grep points, with no midpoint included
Acad::ErrorStatus AecXDbDimension_Old::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
{
assertReadEnabled();
AcDbIntArray osnapModes;
AcDbIntArray geomIds;
return subGetGripPoints(stretchPoints, osnapModes, geomIds);
}
// Active when being rotated, scaled, moved, etc.
// Scale is disabled here
Acad::ErrorStatus AecXDbDimension_Old::subTransformBy(const AcGeMatrix3d& xform)
{
AssertWriteEnabled();
AecXDbEntityBaseEx::subTransformBy(xform);
ads_matrix mat;
GlobalFunc::AsAdsMatrix(xform, mat);
for (int i = 0; i < m_lstTextPos.Length(); i++) {
m_lstTextPos[i]->ptPos.TransformBy(mat);
}
if (IsAngular()) {
GeCurveSegment cv = GetDimCurve();
cv.TransformBy(mat);
m_nRotation = cv.IDirection(0);
ads_polar(cv.StartPoint(), m_nRotation - PI / 2, GetDist2DimLine(FALSE), m_ptLocation);
if (GlobalFunc::IsMirrorMatrix(mat)) {
m_lstTextPos.Reverse();
m_lstTextContent.Reverse();
m_lstSegment.Reverse();
}
}
else {
m_ptLocation.TransformBy(mat);
m_ptLocation.z = 0;
Vector3D vt(cos(m_nRotation), sin(m_nRotation));
((AcGeVector3d &)vt).transformBy(xform);
m_nRotation = ads_angle(ADSGePoint3d(), vt);
if (GlobalFunc::IsMirrorMatrix(mat)) {
m_nDist2DimLine = -m_nDist2DimLine;
}
}
return Acad::eOk;
}
//设置尺寸线位置
BOOL AecXDbDimension_Old::SetDimLinePos(ADSGePoint3d pt)
{
AssertWriteEnabled();
BOOL bRet = FALSE;
GeCurveSegment seg = GetDimCurve();
ADSGePoint3d ptOnSeg;
if (seg.ProjectToMe(pt, ptOnSeg) == RTNORM) {
double nDistMove = pt.Distance2d(ptOnSeg);
int nSideLoc = seg.OnWhichSide(GetLocation());
int nSide = seg.OnWhichSide(pt);
double nDist2Dim = 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 (IsAngular()) {
nDist2Dim += nDistMove;
double nDistRad = GetDimRadius();
nDistRad -= nDistMove;
if (nDistRad > g_Option::instance()._DIST_SNAP) {
SetDimRadius(nDistRad);
SetDist2DimLine(nDist2Dim, FALSE);
}
}
else {
nDist2Dim += nDistMove;
SetDist2DimLine(nDist2Dim, FALSE);
}
bRet = TRUE;
}
return bRet;
}
//设置标注固定线位置
BOOL AecXDbDimension_Old::SetFixLinePos(ADSGePoint3d pt)
{
AssertWriteEnabled();
GeCurveSegment seg = GetDimCurve();
double nOffDist = m_nDist2DimLine * GetPScale();
GeCurveSegment cvFix = seg.Offset(nOffDist, LS_FINITE);
double nDist = cvFix.GetDist2Me(pt);
GeCurveSegment cvNewFix = cvFix.Offset(nDist, LS_FINITE);
if (!cvNewFix)
return FALSE;
ADSGePoint3d ptNew = cvNewFix.NearPoint(m_ptLocation);
m_nDist2DimLine = (nOffDist + nDist) / GetPScale();
m_ptLocation = ptNew;
return TRUE;
}
// 功能: 夹点操作, 还没有完全考虑圆弧类型
Acad::ErrorStatus AecXDbDimension_Old::MoveGripPointsAt1(
const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
AssertWriteEnabled();
AcGePoint3dArray gripPoints;
AcDbIntArray ar;
subGetGripPoints(gripPoints, ar, ar);
AcGeVector3d vtLocal(offset[0], offset[1], 0.0);
for (int i = 0; i < indices.length(); i++) {
int idx = indices[i];
gripPoints[idx] += vtLocal;
}
int nVertNum = m_lstSegment.Length() + 1;
GeCurveSegment cv = GetDimCurve();
cv.SetPoints(ADSGePoint3d(gripPoints[0]), ADSGePoint3d(gripPoints[1]));
ADSGePoint3d ptS, ptE;
ADSGePoint3d ptS1 = gripPoints[2], ptE1 = gripPoints[2 + nVertNum - 1];
if (cv.ProjectToMe(ptS1, ptS) == RTNORM &&
cv.ProjectToMe(ptE1, ptE) == RTNORM)
cv.SetPoints(ptS, ptE);
if (cv.GetLength() < g_Option::instance()._DIST_SNAP)
return Acad::eInvalidInput;
SortedVertexList lstVert(cv);
for (i = 1; i < nVertNum - 1; i++) {
ADSGePoint3d ptFix = gripPoints[2 + i];
ADSGePoint3d ptOnDim;
if (cv.ProjectToMe(ptFix, ptOnDim) == RTNORM) {
lstVert.Insert(ptOnDim);
}
}
GePoly2D poly;
lstVert.AsPoly2D(poly);
m_lstSegment.Reset();
int nSeg = poly.TotalSegments();
for (i = 0; i < nSeg; i++) {
GeCurveSegment seg;
poly.Nth(i, seg);
double nVal = seg.GetLength();
if (IsValidSegment(nVal))
AppendSegment(nVal);
}
if (IsAngular() && (IsDimChord() || IsDimArcLen())) {
m_nObjRadius = cv.GetArc().GetCenterPt().Distance2d(gripPoints[2]);
// Location???
GeLine ln(cv.StartPoint(), cv.IDirection(0) + PI / 2);
ADSGePoint3d ptNewLoc = m_ptLocation + ADSGePoint3d(offset[0], offset[1]);
ptNewLoc.Project(&ln, m_ptLocation);
m_ptLocation.z = 0;
}
else SetLocation(gripPoints[2]);
SetRotation(cv.IDirection(0));
double nDist2DimLine = m_ptLocation.Distance2d(cv.StartPoint());
int nSide = cv.OnWhichSide(m_ptLocation);
SetDist2DimLine(nSide == OFFSET_RIGHT ? nDist2DimLine : -nDist2DimLine, FALSE);
if (nSeg == nVertNum - 1) { //区间数目没有变化
for (i = 0; i < nSeg; i++) {
int nGripIndex = i + nVertNum + 2;
if (indices.contains(nGripIndex) && m_lstTextPos.FindNode(&i, DimTextPos::CompareByIndexForFind))
SetTextPos(i, gripPoints[nGripIndex]);
}
}
else {
m_lstTextPos.Reset();
m_lstTextContent.Reset();
}
AutoSetFlag();
return Acad::eOk;
}
// 功能: 夹点操作
// Modify on 2002/8/8 解决调用getGripPoints效率很低
Acad::ErrorStatus AecXDbDimension_Old::subMoveGripPointsAt(
const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
if (indices.length() > 1)
return MoveGripPointsAt1(indices, offset);
AssertWriteEnabled();
ADSGePoint3d vtOffset = *(ADSGePoint3d *)&offset;
vtOffset.z = 0;
GePoly2D poly, polyNew;
GetPolySegOnDimLine(poly);
polyNew = poly;
GeCurveSegment cv = GetDimCurve();
double nOffDist = m_nDist2DimLine * GetPScale();
GeCurveSegment cvFix = cv.Offset(nOffDist, LS_FINITE);
GeCurveSegment cvObj;
if (IsAngular())
{
double nDist2Obj = cv.GetArc().GetRadius() - m_nObjRadius;
cvObj = cv.Offset(-nDist2Obj, LS_FINITE);
}
for (int i = 0; i < indices.length(); i++)
{
int idx = indices[i];
if (idx <= 1)
{ //改变尺寸线位置
ADSGePoint3d ptVert = idx == 0 ? *poly.Head() : *poly.Tail();
double nExtDir = idx == 0 ? cv.IDirection(0) : cv.IDirection(1);
GeLine lnExt(ptVert, nExtDir + PI / 2);
ADSGePoint3d ptOnExt = ptVert + vtOffset;
ADSGePoint3d(ptOnExt).Project(&lnExt, ptOnExt);
int nSide = cv.OnWhichSide(ptOnExt);
double nDistMove = ptVert.Distance2d(ptOnExt);
double nOldDist2DimLine = m_nDist2DimLine, nOldDimRadius = m_nDimRadius;
int nSideLoc = cv.OnWhichSide(m_ptLocation);
if (fabs(m_nDist2DimLine) > g_Option::instance()._DIST_SNAP / GetPScale())
{
double nFactor = m_nDist2DimLine / fabs(m_nDist2DimLine);
if (nSide != nSideLoc)
m_nDist2DimLine += nFactor * nDistMove / GetPScale();
else
m_nDist2DimLine -= nFactor * nDistMove / GetPScale();
}
else
{
if (nSideLoc == OFFSET_LEFT)
m_nDist2DimLine = -nDistMove / GetPScale();
}
if (IsAngular())
{
if (nSide == OFFSET_RIGHT)
m_nDimRadius += nDistMove;
else
m_nDimRadius -= nDistMove;
if (m_nDimRadius < g_Option::instance()._DIST_SNAP)
{
m_nDist2DimLine = nOldDist2DimLine;
m_nDimRadius = nOldDimRadius;
}
}
}
else if (idx < poly.Length() + 2)
{ //改变定位点或区间
int ndx = idx - 2;
ADSGePoint3d ptGrip, ptGrip0;
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
cvObj.ProjectToMe(*poly[ndx], ptGrip);
else
cvFix.ProjectToMe(*poly[ndx], ptGrip);
int vtIdx = idx - 2;
ptGrip0 = ptGrip;
ptGrip += vtOffset;
if (!g_Option::instance().g_bStetchEntity && GetCtrlToggle())
{
if (!AddSegment(ptGrip) && GetSegmentNum() > 1)
FindAndRemoveSegment(ptGrip0);
}
else
{
ADSGePoint3d ptOnDim;
BOOL bGreatPrev = FALSE, bLessNext = FALSE;
if (cv.ProjectToMe(ptGrip, ptOnDim) == RTNORM)
{
if (vtIdx > 0)
{
double nPathDist = cv.PathDistance(ptOnDim); //小于0时,为圆弧标注
if (IsAngular() && nPathDist < -g_Option::instance()._DIST_SNAP)
{
if (vtIdx == polyNew.Length() - 1)
nPathDist = cv.GetArc().GeCircle::GetLength() + nPathDist;
}
double nPathDistPrev = cv.PathDistance(*polyNew[vtIdx - 1]);
bGreatPrev = (nPathDist - nPathDistPrev) > -g_Option::instance()._DIST_SNAP;
}
else
bGreatPrev = TRUE;
if (vtIdx < polyNew.Length() - 1)
bLessNext = (cv.PathDistance(ptOnDim) - cv.PathDistance(*polyNew[vtIdx + 1])) < g_Option::instance()._DIST_SNAP;
else bLessNext = TRUE;
if (bGreatPrev && bLessNext)
{
if (vtIdx == 0)
{
GeCurveSegment seg;
polyNew.Nth(0, seg);
seg.SetPoints(ptOnDim, seg.EndPoint());
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
{
GeArc ar = seg.GetArc();
GeCircle cir(ar.GetCenterPt(), ads_distance(ar.GetCenterPt(), m_ptLocation));
ADSGePoint3d ptabc = m_ptLocation + vtOffset;
ptabc.Project(&cir, m_ptLocation);
m_nObjRadius = cir.GetCenterPt().Distance2d(ptGrip);
}
else
m_ptLocation += vtOffset;
if (IsValidSegment(seg.GetLength()))
{
m_nRotation = seg.IDirection(0);
SetSegment(0, seg.GetLength());
double nFactor = cv.OnWhichSide(m_ptLocation) == OFFSET_LEFT ? -1.0 : 1.0;
if (!(IsAngular() && (IsDimChord() || IsDimArcLen())))
SetDist2DimLine(m_ptLocation.Distance2d(ptOnDim) * nFactor, FALSE);
}
else
{
if (m_lstSegment.Length() > 1)
{
RemoveSegment(0);
polyNew.Nth(1, seg);
m_nRotation = seg.IDirection(0);
double nFactor = cv.OnWhichSide(m_ptLocation) == OFFSET_LEFT ? -1.0 : 1.0;
if (!(IsAngular() && (IsDimChord() || IsDimArcLen())))
SetDist2DimLine(m_ptLocation.Distance2d(ptOnDim) * nFactor, FALSE);
}
}
}
else
{
BOOL bLast = (vtIdx == polyNew.Length() - 1);
GeCurveSegment seg, segPrev;
if (!bLast) polyNew.Nth(vtIdx, seg);
polyNew.Nth(vtIdx - 1, segPrev);
if (!bLast)
ASSERT(IsValidSegment(seg.GetLength()));
ASSERT(IsValidSegment(segPrev.GetLength()));
if (!bLast) seg.SetPoints(ptOnDim, ADSGePoint3d(seg.EndPoint()));
segPrev.SetPoints(ADSGePoint3d(segPrev.StartPoint()), ptOnDim);
if (!bLast)
{
if (!IsValidSegment(seg.GetLength()))
RemoveSegment(vtIdx);
else
SetSegment(vtIdx, seg.GetLength());
}
else
{
double nFactor = cv.OnWhichSide(ptGrip) == OFFSET_LEFT ? -1.0 : 1.0;
if (!(IsAngular() && (IsDimChord() || IsDimArcLen())))
SetDist2DimLine(ptGrip.Distance2d(ptOnDim) * nFactor, FALSE);
ads_polar(cv.StartPoint(), m_nRotation - PI / 2, GetDist2DimLine(FALSE), m_ptLocation);
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
{
//改标注半径
GeArc arDim = cv.GetArc();
arDim.SetRadius(m_nObjRadius);
GeCurveSegment cvObj;
cvObj = arDim;
ADSGePoint3d ptGrip = cvObj.EndPoint();
ptGrip += vtOffset;
m_nObjRadius = ptGrip.Distance2d(arDim.GetCenterPt());
}
}
if (!IsValidSegment(segPrev.GetLength()))
{
if (m_lstSegment.Length() > 1)
RemoveSegment(vtIdx - 1);
}
else
SetSegment(vtIdx - 1, segPrev.GetLength());
}
}
}
}
}
else
{
int nSeg = idx - poly.Length() - 2;
if (nSeg < poly.TotalSegments())
{
ADSGePoint3d ptText = GetTextPos(nSeg);
ptText += vtOffset;
SetTextPos(nSeg, ptText);
}
else
{
ASSERT(IsAngular() && (IsDimChord() || IsDimArcLen()));
GeLine ln(cv.StartPoint(), cv.IDirection(0) + PI / 2);
ADSGePoint3d ptNewLoc = m_ptLocation + vtOffset;
ptNewLoc.Project(&ln, m_ptLocation);
int nSide = cv.OnWhichSide(ptNewLoc);
double nFactor = cv.OnWhichSide(ptNewLoc) == OFFSET_LEFT ? -1.0 : 1.0;
SetDist2DimLine(ptNewLoc.Distance2d(cv.StartPoint()) * nFactor, FALSE);
}
}
}
//RemoveZeroSegment(); //把长度为0的区间移除
AutoSetFlag();
Acad::ErrorStatus es = Acad::eOk;
return es;
}
// 功能: 夹点操作
Acad::ErrorStatus AecXDbDimension_Old::subMoveStretchPointsAt(
const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
int nCount = indices.length();
GlobalFunc::PushMemVar<BOOL> vTemp(g_Option::instance().g_bStetchEntity, TRUE);
return subMoveGripPointsAt(indices, offset);
}
// 取得夹点说明
Acad::ErrorStatus AecXDbDimension_Old::GetGripText(int i, CString &cs) const
{
Acad::ErrorStatus es = Acad::eOk;
GePoly2D poly;
GetPolySegOnDimLine(poly);
if (i <= 1)
cs = _T("移动尺寸线");
else if (i < poly.Length() + 2)
{
if (!GetCtrlToggle())
{
if (i == 2 || i == poly.Length() + 1)
{
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
cs = _T("更改标注半径和开间(Ctrl-增补合并尺寸开间)");
else
cs = _T("移动定位点和更改开间(Ctrl-增补合并尺寸开间)");
}
else
cs = _T("更改合并尺寸开间(Ctrl-增补合并尺寸开间)");
}
else
{
if (i == 2 || i == poly.Length() + 1)
{
if (IsAngular() && (IsDimChord() || IsDimArcLen()))
cs = _T("增补合并尺寸开间(Ctrl-更改标注半径和开间)");
else
cs = _T("增补合并尺寸开间(Ctrl-移动定位点和更改开间)");
}
else
cs = _T("增补合并尺寸开间(Ctrl-更改合并尺寸开间)");
}
}
else
{
int iVert = i - 2 - poly.Length();
if (iVert < poly.TotalSegments())
cs = _T("移动尺寸文本");
else if (IsAngular() && (IsDimChord() || IsDimArcLen()))
cs = _T("改尺寸界线");
}
return es;
}
int AecXDbDimension_Old::ConvertText(TConvertTextPtr ptr, void *pData)
{
AssertWriteEnabled();
int nLen = m_lstTextContent.Length();
int nCode = RTNONE;
for (int i = 0; i < nLen; i++) {
DimTextContent *pContent = m_lstTextContent[i];
TCString sText;
int nRet = ptr(pContent->sText, sText, pData);
if (nRet == RTERROR)
nCode = nRet;
else if (nRet == RTNORM)
pContent->sText = sText;
}
return nCode;
}
// 返回发现的位置,同时posStart往前移动(以便继续找下一个使用),
TextPosition
AecXDbDimension_Old::FindSubText(const TCHAR *sSubText, TextPosition &posStart, TextRange *pRange) const
{
assertReadEnabled();
TextPosition pos;
if (!sSubText || !sSubText[0])
return pos;
AcDbObjectId idTextStyle;
double dimtxt = 3.0;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pStyle);
if (pStyle) {
idTextStyle = pStyle->dimtxsty();
dimtxt = pStyle->dimtxt();
}
OPENOBJ_END();
if (!idTextStyle)
return pos;
int nLen = GetSegmentNum(); //m_lstTextContent.Length();
int nCode = RTNONE;
TextPosition posNext = posStart;
for (int i = posStart.m_nCookies; i < nLen; i++) {
//DimTextContent content=m_lstTextContent[i];
TCString sTextDim = GetText(i);
AecXDbText dimText;
dimText.setPropertiesFrom(this);
dimText.SetAlignment(AcGiDraw::kMiddleCenter);
dimText.SetHeight(dimtxt);
dimText.SetStyleId(idTextStyle);
dimText.SetText(sTextDim);
dimText.SetLocation(GetTextPos(i));
posNext.m_nCookies = i;
TextPosition posRet = dimText.FindSubText(sSubText, posNext, pRange);
if (!posRet) {
posNext.m_nTextPos = 0;
}
else {
posStart = posNext;
if (!posStart && (int)posStart.m_nCookies < nLen - 1) {
posStart.m_nCookies++;
posStart.m_nTextPos = 0;
}
posRet.m_nCookies = i;
return posRet;
}
}
return pos;
}
// 返回下一次查找的开始位置
TextPosition
AecXDbDimension_Old::ReplaceSubText(const TextPosition &posRep, const TCHAR *sRepText, TextRange *pRange)
{
AssertWriteEnabled();
TextPosition pos;
pos.m_nBufLen = _tcslen(sRepText);
pos.m_nCookies = posRep.m_nCookies;
if (!posRep || (int)posRep.m_nCookies >= GetSegmentNum())
return pos;
AcDbObjectId idTextStyle;
double dimtxt = 3.0;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pStyle);
if (pStyle) {
idTextStyle = pStyle->dimtxsty();
dimtxt = pStyle->dimtxt();
}
OPENOBJ_END();
if (!idTextStyle)
return pos;
//DimTextContent *pContent=m_lstTextContent[posRep.m_nCookies];
TCString sTextDim = GetText(posRep.m_nCookies);
AecXDbText dimText;
dimText.setPropertiesFrom(this);
dimText.SetAlignment(AcGiDraw::kMiddleCenter);
dimText.SetHeight(dimtxt);
dimText.SetStyleId(idTextStyle);
dimText.SetText(sTextDim);
dimText.SetLocation(GetTextPos(posRep.m_nCookies));
TextPosition posRet = dimText.ReplaceSubText(posRep, sRepText, pRange);
SetTextContent(posRep.m_nCookies, dimText.GetText());
if (!posRet) {
if ((int)posRet.m_nCookies < GetSegmentNum() - 1) {
posRet.m_nCookies = posRep.m_nCookies + 1;
posRet.m_nTextPos = 0;
}
}
return posRet;
}
Adesk::UInt32
AecXDbDimension_Old::subSetAttributes(AcGiDrawableTraits * traits)
{
Adesk::UInt32 nRet = AecXDbEntityBaseEx::subSetAttributes(traits);
//if(g_nAcadVer<15.0001)
// nRet |= kDrawableIsCompoundObject;
return nRet;
}
SubText* AecXDbDimension_Old::GetSubText(long iText)const
{
GlobalFunc::PushMemVar<BOOL> bExpl(g_Option::instance().g_bSelfDrawDim, TRUE);
SubText*pSubText = AecXDbEntityBaseEx::GetSubText(iText);
if (pSubText != NULL)
pSubText->SetMenuType(6);
return pSubText;
}
SubText* AecXDbDimension_Old::HitTestText(ADSGePoint3d pt)const
{
GlobalFunc::PushMemVar<BOOL> bExpl(g_Option::instance().g_bSelfDrawDim, TRUE);
SubText*pSubText = AecXDbEntityBaseEx::HitTestText(pt);
if (pSubText != NULL)
pSubText->SetMenuType(6);
return pSubText;
}
Acad::ErrorStatus AecXDbDimension_Old::GetExtents2d(ADSGePoint3d &ptLow, ADSGePoint3d &ptUp) const
{
AcDbExtents ext;
Acad::ErrorStatus es = getGeomExtents(ext);
ptLow = ext.minPoint();
ptUp = ext.maxPoint();
return es;
}
Acad::ErrorStatus
AecXDbDimension_Old::Draw2d(AcGiDraw &dc) const
{
assertReadEnabled();
GlobalFunc::_LoadConfig();
if (Has2DBuffer())
{
dc.SetColor(colorIndex());
dc.SetLayer(layerId());
BaseEx::_Draw2DBuffers(dc, true);
return Acad::eOk;
}
//modified by whl on 060223
//BOOL bCheckDim=DocGetCheckDim();
BOOL bCheckDim = GlobalFunc::DocGetCheckDim() && !g_Option::instance().g_bExplodeSubText;
double nPScale = GetPScale();
if (!IsValid())
return Acad::eInvalidInput;
int nColorOld = dc.GetColor();
double nOffDist = m_nDist2DimLine * GetPScale();
//BOOL bDraw = (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0 || g_Option::instance().g_bSelfDrawDim);
BOOL bDraw = TRUE;
BOOL bQuickMode = (bDraw && !ownerId() && m_lstSegment.Length() >= g_Option::instance().g_nDimNumGripTip);
if (g_Option::instance().g_bDisableQuickMode)
bQuickMode = FALSE;
GePoly2D poly;
GetPolySegOnDimLine(poly);
BOOL bAngular = IsAngular();
BOOL bSelfDraw = (g_Option::instance().g_bOsnapExpl || bDraw || //g_bExpOtherDb ||
(IsAngular() && (IsDimChord() || IsDimArcLen()))
);
if (bSelfDraw || bCheckDim) {
//dc.SetAlignment(AcGiDraw::kMiddleCenter);
TCString sDimPrefix, sDimSuffix;
double dimgap = 0, dimtxt = 0, dimexe = 0, dimexo = 0;
double dimscale = 1.0, dimasz = 1.0, dimdle = 0.0;
int dimclre = 0, dimclrd = 0, dimclrt = 0;
int dimdec = 0, dimadec = 0;
double nArrowThick = 6.0 * nPScale;
double dimlfac = 1.0; //标注显示的单位换算系数
AcDbObjectId dimblk;
AcDbObjectId idTextStyle;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
if (pDimStyle) {
dimdec = pDimStyle->dimdec();
dimadec = pDimStyle->dimadec();
dimgap = pDimStyle->dimgap();
dimtxt = pDimStyle->dimtxt();
dimblk = pDimStyle->dimblk();
dimlfac = pDimStyle->dimlfac();
dimscale = nPScale;
dimdle = pDimStyle->dimdle();
dimasz = pDimStyle->dimasz();
idTextStyle = pDimStyle->dimtxsty();
dimexe = pDimStyle->dimexe();
dimexo = pDimStyle->dimexo();
dimclre = pDimStyle->dimclre().colorIndex();
dimclrd = pDimStyle->dimclrd().colorIndex();
dimclrt = pDimStyle->dimclrt().colorIndex();
const TCHAR *dimpost = pDimStyle->dimpost();
const TCHAR *pStr = NULL;
if (dimpost)
pStr = _tcsstr(dimpost, _T("<>"));
if (pStr) {
GlobalFunc::StrCpy(sDimPrefix, dimpost, pStr);
GlobalFunc::StrCpy(sDimSuffix, pStr + 2, NULL);
}
else if (dimpost) {
_tcscpy(sDimSuffix, dimpost);
}
}
else {
return Acad::eInvalidInput;
}
OPENOBJ_END();
GeCurveSegment cv = GetDimCurve();
BOOL bDimArcLen = (IsAngular() && IsDimArcLen());
if (bDimArcLen) { //弧长标注
int numSeg = poly.TotalSegments();
for (int i = 0; i < numSeg; i++) {
GeCurveSegment segDim, segFix, segObj;
poly.Nth(i, segDim);
segFix = segDim.Offset(OFFSET_LEFT, -GetDist2DimLine(FALSE), LS_FINITE);
double nOffDist0 = segDim.GetArc().GetRadius() - m_nObjRadius;
segObj = segDim.Offset(OFFSET_LEFT, nOffDist0, LS_FINITE);
ADSGePoint3d ptAr1, ptAr2;
double nChorldDir = segObj.GeLine::Direction();
GeLine ln1(segObj.StartPoint(), nChorldDir + PI / 2.0),
ln2(segObj.EndPoint(), nChorldDir + PI / 2.0);
ADSGePoint3d ptInt[2];
segDim.SetLineFlag(LS_INFINITE);
ln1.SetLineFlag(LS_INFINITE);
int nIntNum = segDim.Intersection(ln1, ptInt[0], ptInt[1]);
if (nIntNum == 0)
continue;
else if (nIntNum == 1)
ptAr1 = ptInt[0];
else
ptAr1 = GeLine(ptInt[0], ptInt[1]).NearPoint(segDim.StartPoint());
nIntNum = segDim.Intersection(ln2, ptInt[0], ptInt[1]);
if (nIntNum == 0)
continue;
else if (nIntNum == 1)
ptAr2 = ptInt[0];
else
ptAr2 = GeLine(ptInt[0], ptInt[1]).NearPoint(segDim.StartPoint());
segDim.SetPoints(ptAr1, ptAr2);
// 绘制尺寸线
if (dimclrd) dc.SetColor(dimclrd);
DrawSegment(dc, segDim);
//dc << segDim;
// 绘制尺寸界线
if (dimclre) dc.SetColor(dimclre);
if (bQuickMode);
else if (!g_Option::instance().g_bOsnapExpl) { //尺寸箭头
if (!dimblk) {
ADSGePointDir2d pt1, pt2;
segDim.Polar(2.0 * dimscale, pt1);
segDim.Polar(2.0 * dimscale, pt2, FALSE);
AcDbPolyline plArrow1;
plArrow1.setPropertiesFrom(this);
plArrow1.addVertexAt(0, segDim.StartPoint());
plArrow1.setWidthsAt(0, 0.0, 0.66 * dimscale);
plArrow1.addVertexAt(1, pt1);
plArrow1.setWidthsAt(1, 0.66 * dimscale, 0.0);
DrawPline(dc, plArrow1);
//dc.Polyline(plArrow1);
AcDbPolyline plArrow2;
plArrow2.setPropertiesFrom(this);
plArrow2.addVertexAt(0, pt2);
plArrow2.setWidthsAt(0, 0.66 * dimscale, 0.0);
plArrow2.addVertexAt(1, segDim.EndPoint());
plArrow2.setWidthsAt(1, 0.0, 0.0);
DrawPline(dc, plArrow2);
//dc.Polyline(plArrow2);
}
else {
// 打印时,不能使用新方法
//BOOL bNewMethod = (g_nAcadVer > 15.0001 && g_bMakeBlock);
BOOL bNewMethod = TRUE;
// sg add 091105,强制打印时,不使用新方法
//if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0 && dc.IsPlotGeneration())
// bNewMethod = FALSE;
AcGeScale3d scale(dimscale * dimasz, dimscale * dimasz, dimscale * dimasz);
DrawBlock(dc, dimblk, segDim.EndPoint(), scale, segDim.IDirection(1) + PI);
DrawBlock(dc, dimblk, segDim.StartPoint(), scale, segDim.IDirection(0));
//OPENOBJ_BEGIN(dimblk, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
//if (pBlock) {
//dc.DrawBlock(*pBlock, segDim.EndPoint(), AcGeScale3d(dimscale * dimasz, dimscale * dimasz, dimscale * dimasz),
// segDim.IDirection(1) + PI, bNewMethod);
// dc.DrawBlock(*pBlock, segDim.StartPoint(), AcGeScale3d(dimscale * dimasz, dimscale * dimasz, dimscale * dimasz),
// segDim.IDirection(0), bNewMethod);
//}
//OPENOBJ_END();
}
}
// 尺寸界限
ADSGePoint3d pt1, pt2;
double nFactor = fabs(nOffDist) > g_Option::instance()._DIST_SNAP ? nOffDist / fabs(nOffDist) : 1.0;
ads_polar(segDim.StartPoint(), nChorldDir - nFactor * PI / 2, fabs(nOffDist) - dimexo * dimscale, pt1);
ads_polar(segDim.StartPoint(), nChorldDir + nFactor * PI / 2, dimexe * dimscale, pt2);
DrawLine(dc, pt1, pt2);
//dc << GeLine(pt1, pt2);
ads_polar(segDim.EndPoint(), nChorldDir - nFactor * PI / 2, fabs(nOffDist) - dimexo * dimscale, pt1);
ads_polar(segDim.EndPoint(), nChorldDir + nFactor * PI / 2, dimexe * dimscale, pt2);
DrawLine(dc, pt1, pt2);
//dc << GeLine(pt1, pt2);
dc.SetColor(nColorOld);
// 尺寸文字
if (bQuickMode);
else if (!g_Option::instance().g_bOsnapExpl) {
AecXDbText dimText;
dimText.setPropertiesFrom(this);
dimText.SetAlignment(AcGiDraw::kMiddleCenter);
dimText.SetHeight(dimtxt);
dimText.SetStyleId(idTextStyle);
dimText.setColorIndex(dimclrt);
int numSeg = poly.TotalSegments();
BOOL bIsDefPos = TRUE;
ADSGePoint3d ptText = GetTextPos(i, &bIsDefPos);
ADSGePoint3d ptTemp;
ADSGePointDir2d ptTempDir;
cv.ProjectToMe(ptText, ptTemp);
double nDist = cv.PathDistance(ptTemp);
cv.Polar(nDist, ptTempDir);
double nTextRot = NormalViewAngle(ptTempDir.nDirection);
BOOL bIsDefText = TRUE;
TCString sText0 = GetText(i, &bIsDefText);
TCString sText;
if (bIsDefText)
sText << sDimPrefix << sText0 << sDimSuffix;
else
sText << sText0;
dimText.SetRotation(Wcs2Layout(nTextRot));
dimText.SetLocation(ptText);
if (bSelfDraw) {
PushProperty vProp(&dimText, dc);
dimText.SetText(sText);
DrawBaseEx(dc, dimText);
//if (dc.IsFullExplode())
// dimText.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(dimText);
ADSGePoint3d ext = dimText.GetExtents();
ADSGePoint3d ptMid, ptS, ptE;
ads_polar(ptText, nTextRot + PI / 2, ext.y, ptMid);
ads_polar(ptText, nTextRot - PI, ext.x / 2, ptS);
ads_polar(ptText, nTextRot, ext.x / 2, ptE);
ads_polar(ADSGePoint3d(ptS), nTextRot + PI / 2, ext.y / 2, ptS);
ads_polar(ADSGePoint3d(ptE), nTextRot + PI / 2, ext.y / 2, ptE);
DrawArc(dc, ptS, ptMid, ptE);
//dc << GeArc(ptS, ptMid, ptE);
}
if (bCheckDim && !bIsDefText) {
TCString sCheckText(256);
sCheckText << _T("(") << sDimPrefix << GetDefaultText(i) << sDimSuffix << _T(")");
ADSGePoint3d ptCheckText;
if (bIsDefPos) {
ADSGePoint3d ptOnSeg;
if (segDim.ProjectToMe(ptText, ptOnSeg) == RTNORM) {
ptOnSeg.Mirror(ptText, ptCheckText);
}
}
else {
int nSideText = segDim.OnWhichSide(ptText);
if (nSideText == OFFSET_RIGHT)
ads_polar(ptText, ptTempDir.nDirection - PI / 2, nPScale * (dimgap + dimtxt), ptCheckText);
else
ads_polar(ptText, ptTempDir.nDirection + PI / 2, nPScale * (dimgap + dimtxt), ptCheckText);
}
dimText.setColorIndex(1);
dimText.SetLocation(ptCheckText);
dimText.SetText(sCheckText);
{
PushProperty vProp(&dimText, dc);
DrawBaseEx(dc, dimText);
//if (dc.IsFullExplode())
// dimText.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(dimText);
}
dimText.setColorIndex(dimclrt);
} // bCheckDim
dc.SetColor(nColorOld);
} // g_bExplOsnap
} // End for
}
else if (IsAngular() && IsDimChord()) { //弦长标注
PushMemVar<BOOL> tVar1(g_Option::instance().g_bDisableQuickMode, TRUE);
int numSeg = poly.TotalSegments();
for (int i = 0; i < numSeg; i++) {
GeCurveSegment segDim, segFix, segObj;
poly.Nth(i, segDim);
segFix = segDim.Offset(OFFSET_LEFT, -GetDist2DimLine(FALSE), LS_FINITE);
double nOffDist0 = segDim.GetArc().GetRadius() - m_nObjRadius;
segObj = segDim.Offset(OFFSET_LEFT, nOffDist0, LS_FINITE);
double nRot = segObj.GeLine::Direction();
ADSGePoint3d ptFix;
double nObj2Fix = segFix.GetArc().GetRadius() - segObj.GetArc().GetRadius();
ads_polar(segObj.StartPoint(), nRot - PI / 2, nObj2Fix, ptFix);
AecXDbDimension_Old objDim;
objDim.setPropertiesFrom(this);
objDim.SetLocation(ptFix);
objDim.SetRotation(nRot);
objDim.SetDist2DimLine(GetDist2DimLine());
objDim.AppendSegment(segObj.GetArc().ChordLength());
objDim.SetStyleId(GetStyleId());
DimTextPos *pNode1 = ((AecXDbDimension_Old *)this)->m_lstTextPos.FindNode(&i, DimTextPos::CompareByIndexForFind);
if (pNode1) objDim.SetTextPos(0, pNode1->ptPos);
DimTextContent *pNode = ((AecXDbDimension_Old *)this)->m_lstTextContent.FindNode(&i, DimTextContent::CompareByIndexForFind);
if (pNode) objDim.SetTextContent(0, pNode->sText);
//objDim.ExplodeOrDraw2d(dc);
DrawBaseEx(dc, objDim);
}
}
else
{ //直线标注或角度标注
if (bSelfDraw)
{
if (dimclrd) dc.SetColor(dimclrd);
if (IsAngular())
{
DrawPoly2D(dc, poly);
//dc << poly;
}
else//使用的是样式比例
{
ADSGePoint3d ptStart, ptEnd;
ads_polar(*poly[0], m_nRotation + PI, dimdle * dimscale, ptStart);
DrawLine(dc, ptStart, *poly[0]);
//dc << GeLine(ptStart, *poly[0]);
ads_polar(*poly[poly.Length() - 1], m_nRotation, dimdle * dimscale, ptEnd);
DrawLine(dc, *poly[poly.Length() - 1], ptEnd);
//dc << GeLine(*poly[poly.Length() - 1], ptEnd);
DrawPoly2D(dc, poly);
//dc << poly;
}
//dc << cv;
if (dimclre) dc.SetColor(dimclre);
int numVert = poly.Length();
for (int i = 0; i < numVert; i++)
{
ADSGePoint3d ptVert = *poly[i];
double nPathDist = cv.PathDistance(ptVert);
ADSGePointDir2d ptVertDir;
cv.Polar(nPathDist, ptVertDir);
if (bQuickMode);
else if (!g_Option::instance().g_bOsnapExpl)
{
//尺寸箭头
if (!dimblk)
{
ADSGePointDir2d pt1, pt2;
cv.Polar(nPathDist + 2.0 * dimscale, pt1);
cv.Polar(nPathDist - 2.0 * dimscale, pt2);
AcDbPolyline plArrow;
plArrow.setPropertiesFrom(this);
int iVert = 0;
if (i > 0)
{
plArrow.addVertexAt(iVert, pt2);
plArrow.setWidthsAt(iVert, 0.66 * dimscale, 0.0);
iVert++;
}
plArrow.addVertexAt(iVert, ptVert);
plArrow.setWidthsAt(iVert, 0.0, 0.66 * dimscale);
iVert++;
if (i < numVert - 1)
{
plArrow.addVertexAt(iVert, pt1);
iVert++;
}
DrawPline(dc, plArrow);
//dc.Polyline(plArrow);
}
else
{
// 打印时,不能使用新方法
//BOOL bNewMethod = (g_nAcadVer > 15.0001 && g_bMakeBlock);
// sg add 091105,强制打印时,不使用新方法
//if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0 && dc.IsPlotGeneration())
// bNewMethod = FALSE;
DrawBlock(dc
, dimblk
, ptVert
, AcGeScale3d(dimscale * dimasz, dimscale * dimasz, dimscale * dimasz)
, NormalViewAngle(ptVertDir.nDirection));
//OPENOBJ_BEGIN(dimblk, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
//if (pBlock)
//{
// dc.DrawBlock(*pBlock, ptVert, AcGeScale3d(dimscale * dimasz, dimscale * dimasz, dimscale * dimasz),
// NormalViewAngle(ptVertDir.nDirection), bNewMethod);
//}
//OPENOBJ_END();
}
}
// 尺寸界限
ADSGePoint3d pt1, pt2;
double nFactor = fabs(nOffDist) > g_Option::instance()._DIST_SNAP ? nOffDist / fabs(nOffDist) : 1.0;
ads_polar(ptVert, ptVertDir.nDirection - nFactor * PI / 2, fabs(nOffDist) - dimexo * dimscale, pt1);
ads_polar(ptVert, ptVertDir.nDirection + nFactor * PI / 2, dimexe * dimscale, pt2);
DrawLine(dc, pt1, pt2);
//dc << GeLine(pt1, pt2);
}
}
dc.SetColor(nColorOld);
if (bQuickMode);
else if (!g_Option::instance().g_bOsnapExpl)
{
AecXDbText dimText;
dimText.setPropertiesFrom(this);
dimText.SetAlignment(AcGiDraw::kMiddleCenter);
dimText.SetHeight(dimtxt);
dimText.SetStyleId(idTextStyle);
dimText.setColorIndex(dimclrt);
int numSeg = poly.TotalSegments();
for (int i = 0; i < numSeg; i++)
{
GeCurveSegment seg;
poly.Nth(i, seg);
BOOL bIsDefPos = TRUE;
ADSGePoint3d ptText = GetTextPos(i, &bIsDefPos);
ADSGePoint3d ptTemp;
ADSGePointDir2d ptTempDir;
cv.ProjectToMe(ptText, ptTemp);
double nDist = cv.PathDistance(ptTemp);
cv.Polar(nDist, ptTempDir);
double nTextRot = NormalViewAngle(ptTempDir.nDirection);
BOOL bIsDefText = TRUE;
TCString sText0 = GetText(i, &bIsDefText);
TCString sText;
if (bIsDefText && !IsAngular())
sText << sDimPrefix << sText0 << sDimSuffix;
else
sText << sText0;
dimText.SetRotation(Wcs2Layout(nTextRot));
dimText.SetLocation(ptText);
if (bSelfDraw) {
PushProperty vProp(&dimText, dc);
dimText.SetText(sText);
DrawBaseEx(dc, dimText);
//if (dc.IsFullExplode())
// dimText.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(dimText);
}
if (bCheckDim && !bIsDefText) {
TCString sCheckText(256);
sCheckText << _T("(");
if (!IsAngular())
sCheckText << sDimPrefix;
sCheckText << GetDefaultText(i);
if (!IsAngular())
sCheckText << sDimSuffix;
sCheckText << _T(")");
ADSGePoint3d ptCheckText;
if (bIsDefPos) {
ADSGePoint3d ptOnSeg;
if (seg.ProjectToMe(ptText, ptOnSeg) == RTNORM) {
ptOnSeg.Mirror(ptText, ptCheckText);
}
}
else {
int nSideText = seg.OnWhichSide(ptText);
if (nSideText == OFFSET_RIGHT)
ads_polar(ptText, ptTempDir.nDirection - PI / 2, nPScale * (dimgap + dimtxt), ptCheckText);
else
ads_polar(ptText, ptTempDir.nDirection + PI / 2, nPScale * (dimgap + dimtxt), ptCheckText);
}
dimText.setColorIndex(1);
dimText.SetLocation(ptCheckText);
dimText.SetText(sCheckText);
{
PushProperty vProp(&dimText, dc);
DrawBaseEx(dc, dimText);
//if (dc.IsFullExplode())
// dimText.ExplodeOrDraw2d(dc);
//else
// dc.DrawEntity(dimText);
}
dimText.setColorIndex(dimclrt);
} // bCheckDim
}
dc.SetColor(nColorOld);
} // g_bExplOsnap
}
}
if (!bSelfDraw) {
//BOOL bDraw = (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor()) == 0);
//BOOL bExplode = (_tcscmp(dc.Desc(), XExplodeStream::Descriptor()) == 0);
int nSeg = poly.TotalSegments();
for (int i = 0; i < nSeg; i++) {
GeCurveSegment seg;
poly.Nth(i, seg);
ASSERT(!!seg);
GeCurveSegment segOnFix = seg.Offset(OFFSET_RIGHT, nOffDist, LS_FINITE);
AcDbDimension *pDim = NULL;
ADSGePoint3d ptText = seg.MidPoint();
if (!bAngular) {
ADSGePoint3d pt1 = segOnFix.StartPoint(), pt2 = segOnFix.EndPoint();
double nAng = NormalViewAngle(ads_angle(pt1, pt2));
if (!IsExactSameDrt(nAng, ads_angle(pt1, pt2), g_DimOption::instance()._angSnap))
GlobalFunc::Exchange(pt1, pt2);
pDim = new AcDbAlignedDimension(pt1, pt2, ptText);
}
else {
ADSGePoint3d ptCen = seg.GetArc().GetCenterPt();
pDim = new AcDb3PointAngularDimension(ptCen, segOnFix.StartPoint(), segOnFix.EndPoint(), ptText);
}
DimTextPos *pNode = ((AecXDbDimension_Old *)this)->m_lstTextPos.FindNode(&i, DimTextPos::CompareByIndexForFind);
if (pNode) {
pDim->setTextPosition(pNode->ptPos);
pDim->useSetTextPosition();
}
DimTextContent *pNode1 = ((AecXDbDimension_Old *)this)->m_lstTextContent.FindNode(&i, DimTextContent::CompareByIndexForFind);
if (pNode1) pDim->setDimensionText(pNode1->sText);
AcDbObjectId idDimStyle = GlobalFunc::DimStyleTch2Acad(m_idDimStyle, GetPScale(), IsAngular(), database(), 0.0);
pDim->setDimensionStyle(idDimStyle);
pDim->setDimstyleData(idDimStyle);
pDim->setPropertiesFrom(this);
//((XExplodeStream &)dc).Append(pDim, FALSE);
}
}
dc.SetColor(nColorOld);
return Acad::eOk;
}
const TCHAR *AecXDbDimension_Old::GetDefaultLayer() const
{
extern TCHAR* LAY_DIM;
return LAY_DIM;
}
DrawModeType AecXDbDimension_Old::GetDrawType() const
{
return k2DOnly;
}
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
void AecXDbDimension_Old::GetTips(PtrList<ObjInfoUnit> &lstInfo) const
{
lstInfo.Append(new ObjInfoUnit(_T("对象类型"), _T("连续标注")));
const TCHAR *pSubType;
if (!IsAngular()) pSubType = _T("线性标注");
else if (IsDimChord()) pSubType = _T("弦长标注");
else if (IsDimArcLen()) pSubType = _T("弧长标注");
else pSubType = _T("角度标注");
lstInfo.Append(new ObjInfoUnit(_T("子类型"), pSubType));
lstInfo.Append(new ObjInfoUnit(_T("标注样式"), GlobalFunc::GetSymbolName(m_idDimStyle)));
TCString sDist;
GlobalFunc::ftoa(fabs(m_nDist2DimLine), 1, sDist);
sDist << _T("P");
lstInfo.Append(new ObjInfoUnit(_T("尺寸线偏移"), sDist));
if (!IsAngular()) {
lstInfo.Append(new ObjInfoUnit(_T("旋转角度"), GlobalFunc::Angle2Str(m_nRotation * 180 / PI)));
}
else if (IsDimChord() || IsDimArcLen()) {
lstInfo.Append(new ObjInfoUnit(_T("所注半径"), GlobalFunc::Dist2Str(m_nObjRadius)));
}
}
//尺寸文字位置的自动调整
// 返回最后一个的调整结果
// 0--缺省, 1--上调, 2--下调, 3--侧调
// nFromUp--开始调整的状态,bAllowExt--是否允许外调,bAutoReset--无需调整的是否自动复位
int AecXDbDimension_Old::AdjustDim(BOOL bFromUp, BOOL bAllowExt, BOOL bAutoReset)
{
AssertWriteEnabled();
if (!IsValid())
return 0;
double nPScale = GetPScale();
double dimgap = 0, dimtxt = 0, dimexe = 0, dimexo = 0;
double dimscale = 1.0, dimasz = 1.0;
int dimdec = 0, dimadec = 0;
double dimlfac = 1.0;
double nArrowThick = 6.0 * nPScale;
AcDbObjectId dimblk;
AcDbObjectId dimtxsty;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
if (!pDimStyle)
return 0;
dimlfac = pDimStyle->dimlfac();
dimdec = pDimStyle->dimdec();
dimadec = pDimStyle->dimadec();
dimgap = pDimStyle->dimgap();
dimtxt = pDimStyle->dimtxt();
dimblk = pDimStyle->dimblk();
//dimscale=pDimStyle->dimscale();
dimscale = nPScale;
dimasz = pDimStyle->dimasz();
dimtxsty = pDimStyle->dimtxsty();
dimexe = pDimStyle->dimexe();
dimexo = pDimStyle->dimexo();
OPENOBJ_END();
if (!dimtxsty)
return 0;
int nRetCode = 0;
if (bAutoReset)
m_lstTextPos.Reset();
GeCurveSegment cv = GetDimCurve();
GePoly2D poly;
GetPolySegOnDimLine(poly);
if (IsAngular() && IsDimChord()) { //弦长标注
int numSeg = poly.TotalSegments();
int nCode = 0;
for (int i = 0; i < numSeg; i++) {
if (!bAutoReset && m_lstTextPos.FindNode(&i, DimTextPos::CompareByIndexForFind))
continue;
GeCurveSegment segDim, segFix, segObj;
poly.Nth(i, segDim);
segFix = segDim.Offset(OFFSET_LEFT, -GetDist2DimLine(FALSE), LS_FINITE);
double nOffDist = segDim.GetArc().GetRadius() - m_nObjRadius;
segObj = segDim.Offset(OFFSET_LEFT, nOffDist, LS_FINITE);
double nRot = segObj.GeLine::Direction();
ADSGePoint3d ptFix;
double nObj2Fix = segFix.GetArc().GetRadius() - segObj.GetArc().GetRadius();
ads_polar(segObj.StartPoint(), nRot - PI / 2, nObj2Fix, ptFix);
AecXDbDimension_Old objDim;
objDim.setPropertiesFrom(this);
objDim.SetLocation(ptFix);
objDim.SetRotation(nRot);
objDim.SetDist2DimLine(GetDist2DimLine());
objDim.AppendSegment(segObj.GetArc().ChordLength());
objDim.SetStyleId(GetStyleId());
DimTextContent *pNode = ((AecXDbDimension_Old *)this)->m_lstTextContent.FindNode(&i, DimTextContent::CompareByIndexForFind);
if (pNode) objDim.SetTextContent(0, pNode->sText);
BOOL bUpAdj = bFromUp;
if (!nCode)
nCode = objDim.AdjustDim(bUpAdj, (i == 0 || i == numSeg));
BOOL bDef = TRUE;
ADSGePoint3d ptTextPos = objDim.GetTextPos(0, &bDef);
if (!bDef)
SetTextPos(i, ptTextPos);
}
}
else { //直线标注或角度标注
double nOffDist = m_nDist2DimLine * GetPScale();
int numVert = poly.Length();
PtrList<GeLine> lstLineSet;
for (int i = 0; i < numVert; i++) {
ADSGePoint3d ptVert = *poly[i];
double nPathDist = cv.PathDistance(ptVert);
ADSGePointDir2d ptVertDir;
cv.Polar(nPathDist, ptVertDir);
// 尺寸界限
ADSGePoint3d pt1, pt2;
double nFactor = fabs(nOffDist) > g_Option::instance()._DIST_SNAP ? nOffDist / fabs(nOffDist) : 1.0;
ads_polar(ptVert, ptVertDir.nDirection - nFactor * PI / 2, dimexe * dimscale/*fabs(nOffDist)-dimexo*dimscale*/, pt1);
ads_polar(ptVert, ptVertDir.nDirection + nFactor * PI / 2, dimexe * dimscale, pt2);
lstLineSet.Append(new GeLine(pt1, pt2));
}
double nTextHeight = dimtxt * dimscale;
int numSeg = poly.TotalSegments();
// 0--缺省, 1--上调, 2--下调, 3--外调
TCHAR *pPosTable = new TCHAR[numSeg];
for (i = 0; i < numSeg; i++) {
pPosTable[i] = 0;
if (!bAutoReset && m_lstTextPos.FindNode(&i, DimTextPos::CompareByIndexForFind))
continue;
GeCurveSegment seg;
poly.Nth(i, seg);
ADSGePoint3d ptText = GetDefaultTextPos(i);
ADSGePoint3d ptTemp;
ADSGePointDir2d ptTempDir;
cv.ProjectToMe(ptText, ptTemp);
double nDist = cv.PathDistance(ptTemp);
cv.Polar(nDist, ptTempDir);
double nTextRot = NormalViewAngle(ptTempDir.nDirection);
TCString sText = GetText(i);
AecXDbText text;
text.setPropertiesFrom(this);
text.SetText(sText);
text.SetStyleId(dimtxsty);
text.SetHeight(nTextHeight, FALSE);
ADSGePoint3d ptExt = text.GetExtents();
//ptExt.y *= nEn2Ch;
GeLine lnUp, lnDown;
ADSGePoint3d ptMidRight;
ads_polar(ptText, nTextRot, ptExt.x / 2, ptMidRight);
ADSGePoint3d ptVert;
ads_polar(ptMidRight, nTextRot + PI / 2, ptExt.y / 2, ptVert);
lnUp.StartPoint() = ptVert;
ads_polar(ADSGePoint3d(ptVert), nTextRot + PI, ptExt.x, ptVert);
lnUp.EndPoint() = ptVert;
ads_polar(ADSGePoint3d(ptVert), nTextRot - PI / 2, ptExt.y, ptVert);
lnDown.StartPoint() = ptVert;
ads_polar(ADSGePoint3d(ptVert), nTextRot, ptExt.x, ptVert);
lnDown.EndPoint() = ptVert;
GeLine *ln1 = lstLineSet[i];
ln1->SetLineFlag(LS_FINITE);
lnUp.SetLineFlag(LS_FINITE);
lnDown.SetLineFlag(LS_FINITE);
if (lnUp.Intersection(ln1, ADSGePoint3d()) || lnDown.Intersection(ln1, ADSGePoint3d())) {
// 需要自调
if (bAllowExt && (i == 0 || i == numSeg - 1)) { //侧调
ADSGePointDir2d ptPosExt;
cv.Polar(-(ptExt.x / 2 + dimgap * nPScale), ptPosExt, i == 0);
double nDirNext = NormalViewAngle(ptPosExt.nDirection) + PI / 2;
ADSGePoint3d ptTextPos;
ads_polar(ptPosExt, nDirNext, (dimgap + dimtxt * 0.7) * nPScale, ptTextPos);
SetTextPos(i, ptTextPos);
pPosTable[i] = 3;
}
else {
BOOL bPrevAdj = FALSE;
if (i > 0 && pPosTable[i - 1] != 0)
bPrevAdj = TRUE;
if (bPrevAdj) {
pPosTable[i] = 0;
}
else {
BOOL bUpAdj = bFromUp;
ADSGePoint3d ptTextPos;
//double nFactor=fabs(nOffDist)>g_Option::instance()._DIST_SNAP? nOffDist/fabs(nOffDist) : 1.0;
ADSGePointDir2d ptVertDir;
seg.Polar(seg.GetLength() / 2, ptVertDir);
double nUpDir = NormalViewAngle(ptVertDir.nDirection);
if (bUpAdj) { //尺寸线方向外
ads_polar(ptVertDir, nUpDir + PI / 2,
(dimgap * 2 + dimtxt * 1.5 * 0.7) * nPScale, ptTextPos);
pPosTable[i] = 1;
}
else {
ads_polar(ptVertDir, nUpDir - PI / 2,
(dimgap + dimtxt * 0.5) * nPScale, ptTextPos);
pPosTable[i] = 2;
}
SetTextPos(i, ptTextPos);
}
}
}
else {
pPosTable[i] = 0;
}
}
nRetCode = pPosTable[numSeg - 1];
}
return nRetCode;
}
//取得尺寸线
GeCurveSegment
AecXDbDimension_Old::GetDimCurve() const
{
assertReadEnabled();
ASSERT(IsValid());
ADSGePoint3d ptStart, ptEnd;
double nDist = m_nDist2DimLine * GetPScale();
ads_polar(m_ptLocation, m_nRotation + PI / 2, nDist, ptStart);
double nSweepAngle = 0.0;
if (IsAngular()) {
ADSGePoint3d ptCen;
ads_polar(ptStart, m_nRotation + PI / 2, m_nDimRadius, ptCen);
nSweepAngle = GetTotalSegValue();
if (fabs(nSweepAngle - 2.0 * PI) < g_DimOption::instance()._angSnap)
nSweepAngle -= 2.0 * g_DimOption::instance()._angSnap;
double nEndAng = ads_angle(ptCen, ptStart) + nSweepAngle;
ads_polar(ptCen, nEndAng, m_nDimRadius, ptEnd);
}
else {
double nTotalDist = GetTotalSegValue();
ads_polar(ptStart, m_nRotation, nTotalDist, ptEnd);
}
return GeCurveSegment(ptStart, ptEnd, nSweepAngle);
}
void AecXDbDimension_Old::GetPolySegOnDimLine(GePoly2D &poly) const
{
assertReadEnabled();
GeCurveSegment cv = GetDimCurve();
SortedVertexList lstVert(cv);
int nSeg = m_lstSegment.Length();
double nDist = 0.0;
for (int i = 0; i < nSeg - 1; i++) {
ADSGePointDir2d ptVert;
double nVal = GetSegment(i);
nDist += nVal;
cv.Polar(nDist, ptVert);
lstVert.Insert(ptVert);
}
lstVert.AsPoly2D(poly);
}
int AecXDbDimension_Old::HitTestOnDimSeg(ADSGePoint3d pt) const
{
GeCurveSegment cv = GetDimCurve();
ADSGePoint3d ptOnDim;
if (cv.ProjectToMe(pt, ptOnDim) != RTNORM)
return -1;
GePoly2D poly;
GetPolySegOnDimLine(poly);
int nSeg = poly.TotalSegments();
for (int i = 0; i < nSeg; i++) {
GeCurveSegment seg;
poly.Nth(i, seg);
if ((ptOnDim & seg) == PR_INSIDE)
return i;
}
return -1;
}
int AecXDbDimension_Old::HitTestOnText(ADSGePoint3d pt) const
{
int nSeg = m_lstSegment.Length();
int nRet = -1;
double nDistMin = 0.0;
for (int i = 0; i < nSeg; i++) {
ADSGePoint3d ptPos = GetTextPos(i);
if (nRet < 0) {
nRet = i;
nDistMin = ptPos.Distance2d(pt);
}
else {
double nDist = ptPos.Distance2d(pt);;
if (nDist < nDistMin) {
nDistMin = nDist;
nRet = i;
}
}
}
return nRet;
}
//add by whl on 041020
//返回节点索引,输入为近似节点,输出为准确节点,以系统拾取框大小为距离精度。
int AecXDbDimension_Old::HitTestOnPoint(ADSGePoint3d&pt)const
{
GeCurveSegment cv = GetDimCurve();
ADSGePoint3d ptOnDim;
if (cv.ProjectToMe(pt, ptOnDim) != RTNORM)
return -1;
double nMaxDist = GlobalFunc::GetApertureWcs() / 2;
GePoly2D poly;
GetPolySegOnDimLine(poly);
for (long i = 0; i < poly.Length(); i++)
if (ptOnDim.Distance2d(*poly[i]) <= nMaxDist)
{
pt = *poly[i];
return i;
}
return -1;
}
// 角度-弦长-弧长
extern AcDbObjectId InitDimStyle(TDimStyle ds);
void AecXDbDimension_Old::SwitchDimChord()
{
if (!IsAngular())
return;
BOOL bChord = IsDimChord();
BOOL bArcLen = IsDimArcLen();
if (!bChord && !bArcLen) { //角度
GeCurveSegment cv = GetDimCurve();
GeArc arDim = cv.GetArc();
double nObjRadius = GetObjRadius();
if (arDim.GetRadius() < nObjRadius) { //自动反向
double nDiff = nObjRadius - arDim.GetRadius();
arDim.SetRadius(arDim.GetRadius() + 2 * nDiff);
SetDimRadius(arDim.GetRadius());
cv = arDim;
arDim.SetRadius(nObjRadius);
GeCurveSegment segObj;
segObj = arDim;
ADSGePoint3d ptNewLoc;
segObj.StartPoint().Mirror(GetLocation(), ptNewLoc);
double nDist = ptNewLoc.Distance2d(cv.StartPoint());
int nSide = cv.OnWhichSide(ptNewLoc);
if (nSide == OFFSET_LEFT)
nDist = -nDist;
SetDist2DimLine(nDist, FALSE);
SetLocation(ptNewLoc);
for (int i = 0; i < m_lstTextPos.Length(); i++) {
DimTextPos *pText = m_lstTextPos[i];
ADSGePoint3d ptOnObj;
segObj.ProjectToMe(pText->ptPos, ptOnObj);
ptOnObj.Mirror(ADSGePoint3d(pText->ptPos), pText->ptPos);
}
}
SetStyleId(InitDimStyle(DS_LINEAR));
SetDimChord(TRUE);
SetDimArcLen(FALSE);
}
else if (bChord) {
SetStyleId(InitDimStyle(DS_ANGLE));
SetDimChord(FALSE);
SetDimArcLen(TRUE);
}
else {
SetStyleId(InitDimStyle(DS_ANGLE));
SetDimChord(FALSE);
SetDimArcLen(FALSE);
}
}
void AecXDbDimension_Old::RemoveZeroSegment()
{
AssertWriteEnabled();
int nSeg = m_lstSegment.Length();
double nPrec = IsAngular() ? g_DimOption::instance()._angSnap : g_Option::instance()._DIST_SNAP;
for (int i = 0; i < nSeg; i++) {
if (*m_lstSegment[i] < nPrec) {
RemoveSegment(i);
i--;
nSeg--;
}
}
}
void AecXDbDimension_Old::RemoveSegment(int iSeg)
{
AssertWriteEnabled();
int nSeg = m_lstSegment.Length();
ASSERT(iSeg >= 0 && iSeg < nSeg);
m_lstSegment.Remove(iSeg);
if (m_lstTextPos.FindNode(&iSeg, DimTextPos::CompareByIndexForFind))
m_lstTextPos.Remove();
int nTextSeg = m_lstTextPos.Length();
for (int i = 0; i < nTextSeg; i++) {
DimTextPos *pNode = m_lstTextPos[i];
if (pNode->nIndex > iSeg)
pNode->nIndex--;
}
if (m_lstTextContent.FindNode(&iSeg, DimTextContent::CompareByIndexForFind))
m_lstTextContent.Remove();
nTextSeg = m_lstTextContent.Length();
for (i = 0; i < nTextSeg; i++) {
DimTextContent *pNode = m_lstTextContent[i];
if (pNode->nIndex > iSeg)
pNode->nIndex--;
}
AutoSetFlag();
}
void
AecXDbDimension_Old::InsertSegmentAt(int n, double nVal, BOOL bDist)
{
AssertWriteEnabled();
ASSERT(IsValidSegment(nVal, bDist));
if (n >= 0 && n < m_lstSegment.Length()) {
if (IsAngular() && bDist)
nVal = nVal / m_nDimRadius;
m_lstSegment[n];
m_lstSegment.Insert(new double(nVal));
int nTextSeg = m_lstTextPos.Length();
for (int i = 0; i < nTextSeg; i++) {
DimTextPos *pNode = m_lstTextPos[i];
if (pNode->nIndex >= n)
pNode->nIndex++;
}
nTextSeg = m_lstTextContent.Length();
for (i = 0; i < nTextSeg; i++) {
DimTextContent *pNode = m_lstTextContent[i];
if (pNode->nIndex >= n)
pNode->nIndex++;
}
}
else if (n >= m_lstSegment.Length()) {
AppendSegment(nVal, bDist);
}
AutoSetFlag();
}
void
AecXDbDimension_Old::SetSegment(int n, double nVal, BOOL bDist)
{
AssertWriteEnabled();
ASSERT(IsValidSegment(nVal, bDist));
if (n >= 0 && n < m_lstSegment.Length()) {
if (IsAngular() && bDist)
nVal = nVal / m_nDimRadius;
*m_lstSegment[n] = nVal;
}
}
// 在指定的位置加入一区间
BOOL AecXDbDimension_Old::AddSegment(ADSGePoint3d ptAdd)
{
AssertWriteEnabled();
GeCurveSegment cv = GetDimCurve();
ADSGePoint3d ptOnDim;
if (cv.ProjectToMe(ptAdd, ptOnDim) != RTNORM)
return FALSE;
int nPrFlag = (ptOnDim & cv);
if (nPrFlag == PR_ONPT1 && nPrFlag == PR_ONPT2)
return FALSE;
BOOL bRet = FALSE;
if (nPrFlag == PR_INSIDE)
{
GePoly2D poly;
GetPolySegOnDimLine(poly);
int nSeg = poly.TotalSegments();
for (int n = 0; n < nSeg; n++)
{
GeCurveSegment seg;
poly.Nth(n, seg);
if ((ptOnDim & seg) == PR_INSIDE)
{
double nVal = fabs(seg.PathDistance(ptOnDim));
double nVal1 = fabs(seg.PathDistance(ptOnDim, FALSE)); //距离终点的距离
if (IsValidSegment(nVal) && IsValidSegment(nVal1))
{
DimTextPos *pNode = m_lstTextPos.FindNode(&n, DimTextPos::CompareByIndexForFind);
if (pNode) m_lstTextPos.Remove();
SetSegment(n, nVal1);
InsertSegmentAt(n, nVal);
bRet = TRUE;
}
break;
}
}
}
else if (ptOnDim.Distance2d(cv.EndPoint()) < ptOnDim.Distance2d(cv.StartPoint()))
{
double nVal = fabs(cv.PathDistance(ptOnDim, FALSE));
if (IsValidSegment(nVal))
{
AppendSegment(nVal);
bRet = TRUE;
}
}
else
{
double nVal = fabs(cv.PathDistance(ptOnDim, TRUE));
if (IsValidSegment(nVal))
{
cv.SetPoints(ptOnDim, ADSGePoint3d(cv.EndPoint()));
InsertSegmentAt(0, nVal);
m_nRotation = cv.IDirection(0);
ads_polar(cv.StartPoint(), m_nRotation - PI / 2, m_nDist2DimLine * GetPScale(), m_ptLocation);
bRet = TRUE;
}
}
if (bRet)
AutoSetFlag();
return bRet;
}
//add by whl on 040810
BOOL AecXDbDimension_Old::FindAndRemoveSegment(ADSGePoint3d pt)
{
GeCurveSegment seg = GetDimCurve();
ADSGePoint3d ptOnSeg;
seg.ProjectToMe(pt, ptOnSeg);
double value = seg.PathDistance(ptOnSeg);
long i = -1;
if (value > g_Option::instance()._DIST_SNAP)
{
double curValue = 0;
for (i = 0; i < GetSegmentNum(); i++)
{
curValue += GetSegment(i);
if (fabs(curValue - value) < g_Option::instance()._DIST_SNAP)
break;
}
}
if (i >= GetSegmentNum())
return FALSE;//useful
if (i >= 0)
{
double temp = GetSegment(i);
if (i < GetSegmentNum() - 1)//是中间段
SetSegment(i + 1, temp + GetSegment(i + 1));//后一段合并之
RemoveSegment(i);
}
else//第一个标注段的起点特殊处理,弧段不对!
{
double temp = GetSegment(0);
RemoveSegment(0);
Vector3D vt = seg.EndPoint() - seg.StartPoint();
vt.Scale(temp / vt.Length());
SetLocation(GetLocation() + vt);
}
return TRUE;
}
BOOL AecXDbDimension_Old::MergeDim(const AecXDbDimension_Old *pDim)
{
AssertWriteEnabled();
if (!IsUseDefaultText())
return FALSE;
GeCurveSegment cv = GetDimCurve();
SortedVertexList lstVert(cv);
int nSeg = m_lstSegment.Length();
double nDist = 0.0;
for (int i = 0; i < nSeg - 1; i++) {
ADSGePointDir2d ptVert;
double nVal = GetSegment(i);
nDist += nVal;
cv.Polar(nDist, ptVert);
lstVert.Insert(ptVert);
}
GePoly2D poly;
pDim->GetPolySegOnDimLine(poly);
for (i = 0; i < poly.Length(); i++) {
ADSGePoint3d ptVert;
if (cv.ProjectToMe(*poly[i], ptVert) == RTNORM)
lstVert.Insert(ptVert, TRUE);
}
m_lstTextPos.Reset();
m_lstSegment.Reset();
GePoly2D polyNew;
lstVert.AsPoly2D(polyNew);
nSeg = polyNew.TotalSegments();
for (i = 0; i < nSeg; i++) {
GeCurveSegment seg;
polyNew.Nth(i, seg);
double nVal = seg.GetLength();
ASSERT(nVal > g_Option::instance()._DIST_SNAP);
if (IsValidSegment(nVal))
AppendSegment(nVal);
if (i == 0) {
m_nRotation = seg.IDirection(0);
ads_polar(seg.StartPoint(), m_nRotation - PI / 2, m_nDist2DimLine * GetPScale(), m_ptLocation);
}
}
AutoSetFlag();
return TRUE;
}
AcDbObjectId DimStyleAcad2Tch(AcDbObjectId idAcad, double &nScale);
BOOL AecXDbDimension_Old::ConvertFrom(const AcDbDimension *pDim)
{
AssertWriteEnabled();
double nScale = 100.0;
AcDbObjectId idStyle = DimStyleAcad2Tch(pDim->dimensionStyle(), nScale);
SetPScale(nScale);
//double val;
//VERIFY(pDim->measurement(val)==Acad::eOk);
TCString sText;
sText = pDim->dimensionText();
double dotVec = pDim->normal().dotProduct(AcGeVector3d(0, 0, 1));
if (fabs(dotVec - 1.0) > 1.0E-6 || !idStyle)
return FALSE;
setPropertiesFrom(pDim);
m_idDimStyle = idStyle;
m_lstTextPos.Reset();
if (!pDim->isUsingDefaultTextPosition()) {
m_lstTextPos.Append(new DimTextPos(0, ADSGePoint3d(pDim->textPosition())));
}
m_lstTextContent.Reset();
if (!!sText)
m_lstTextContent.Append(new DimTextContent(0, sText));
BOOL bRet = FALSE;
if (pDim->isKindOf(AcDb2LineAngularDimension::desc()) ||
pDim->isKindOf(AcDb3PointAngularDimension::desc())) {
AcDb3PointAngularDimension *pDim1 = AcDb3PointAngularDimension::cast(pDim);
AcDb2LineAngularDimension *pDim2 = AcDb2LineAngularDimension::cast(pDim);
ADSGePoint3d pt1, pt2, ptDim, ptCen;
if (pDim1) {
pt1 = pDim1->xLine1Point();
pt2 = pDim1->xLine2Point();
ptDim = pDim1->arcPoint();
ptCen = pDim1->centerPoint();
}
else {
pt1 = pDim2->xLine1Start();
pt2 = pDim2->xLine2Start();
ptDim = pDim2->arcPoint();
ADSGePoint3d qt1 = pDim2->xLine1End(),
qt2 = pDim2->xLine2End();
GeLine ll(pt2, qt2);
GeLine(pt1, qt1).Intersection(&ll, ptCen);
}
m_nDimRadius = ptCen.Distance2d(ptDim);
SetAngular(TRUE);
SetDimChord(FALSE);
m_ptLocation = pt1;
m_ptLocation.z = 0;
m_nRotation = ads_angle(ptCen, pt1) + PI / 2;
GeArc arDim(ptCen, m_nDimRadius, ads_angle(ptCen, pt1), ads_angle(ptCen, pt2));
GeCurveSegment segDim;
segDim = arDim;
//ADSGePoint3d ptOnDim1;
//pt1.Project(arDim, ptOnDim1);
double nDist2DimLine = fabs(m_nDimRadius - ptCen.Distance2d(pt1));
int nSide = segDim.OnWhichSide(m_ptLocation);
if (nSide == OFFSET_LEFT)
nDist2DimLine = -nDist2DimLine;
m_nObjRadius = m_nDimRadius + nDist2DimLine;
SetDist2DimLine(nDist2DimLine, FALSE);
m_lstSegment.Reset();
if (IsValidSegment(arDim.Bulge(), FALSE)) {
AppendSegment(arDim.Bulge(), FALSE);
bRet = TRUE;
}
}
else if (pDim->isKindOf(AcDbAlignedDimension::desc()) ||
pDim->isKindOf(AcDbRotatedDimension::desc())) {
AcDbAlignedDimension *pDim1 = AcDbAlignedDimension::cast(pDim);
AcDbRotatedDimension *pDim2 = AcDbRotatedDimension::cast(pDim);
ASSERT(pDim1 || pDim2);
ADSGePoint3d pt1, pt2, ptDim;
if (pDim1) {
pt1 = pDim1->xLine1Point();
pt2 = pDim1->xLine2Point();
ptDim = pDim1->dimLinePoint();
}
else {
pt1 = pDim2->xLine1Point();
pt2 = pDim2->xLine2Point();
ptDim = pDim2->dimLinePoint();
if (!IsSameDrt(ads_angle(pt1, pt2), pDim2->rotation(), g_DimOption::instance()._angSnap))
return FALSE;
}
m_nDimRadius = m_nObjRadius = 0;
SetAngular(FALSE);
SetDimChord(FALSE);
m_ptLocation = pt1;
m_ptLocation.z = 0;
m_nRotation = ads_angle(pt1, pt2);
ADSGePoint3d ptOnDim1, ptOnDim2;
GeLine ll(ptDim, m_nRotation);
pt1.Project(&ll, ptOnDim1);
pt2.Project(&ll, ptOnDim2);
int nSide = GeLine(ptDim, m_nRotation).OnWhichSide(m_ptLocation);
m_nDist2DimLine = pt1.Distance2d(ptOnDim1) / GetPScale();
if (nSide == OFFSET_LEFT)
m_nDist2DimLine = -m_nDist2DimLine;
m_lstSegment.Reset();
double nVal = ptOnDim1.Distance2d(ptOnDim2);
if (IsValidSegment(nVal)) {
AppendSegment(nVal);
bRet = TRUE;
}
}
if (bRet)
AutoSetFlag();
return bRet;
}
// Properties
double AecXDbDimension_Old::GetSegment(int n, BOOL bDist) const
{
ASSERT(n >= 0 && n < m_lstSegment.Length());
double nVal = m_lstSegment[n];
if (IsAngular() && bDist) {
ASSERT(m_nDimRadius > g_Option::instance()._DIST_SNAP);
nVal *= m_nDimRadius;
}
return nVal;
}
double
AecXDbDimension_Old::GetTotalSegValue() const
{
double nVal = 0.0;
int nCount = m_lstSegment.Length();
for (int i = 0; i < nCount; i++)
nVal += m_lstSegment[i];
return nVal;
}
BOOL
AecXDbDimension_Old::IsAngular() const
{
return ((m_nDimFlag & DF_ANGULAR) != 0);
//return (m_nDimRadius>g_DimOption::instance()._angSnap);
}
int AecXDbDimension_Old::GetSegmentNum() const
{
return m_lstSegment.Length();
}
double
AecXDbDimension_Old::GetObjRadius() const
{
return m_nObjRadius;
}
BOOL
AecXDbDimension_Old::IsDimChord() const
{
return ((m_nDimFlag & DF_CHORD));
}
BOOL
AecXDbDimension_Old::IsDimArcLen() const
{
return ((m_nDimFlag & DF_ARCLEN));
}
ADSGePoint3d
AecXDbDimension_Old::GetLocation() const
{
return m_ptLocation;
}
double
AecXDbDimension_Old::GetRotation() const
{
return m_nRotation;
}
double
AecXDbDimension_Old::GetDist2DimLine(BOOL bAsPaperUnit) const
{
double val = m_nDist2DimLine;
if (!bAsPaperUnit)
val *= GetPScale();
return val;
}
double
AecXDbDimension_Old::GetDimRadius() const
{
return m_nDimRadius;
}
AcDbObjectId
AecXDbDimension_Old::GetStyleId() const
{
return m_idDimStyle;
}
// Modify on 2002/02/05, 考虑dimlfac进行单位换算
TCString
AecXDbDimension_Old::GetDefaultText(int nIndex) const
{
ASSERT(nIndex < m_lstSegment.Length() && nIndex >= 0);
GePoly2D poly;
GetPolySegOnDimLine(poly);
GeCurveSegment seg;
poly.Nth(nIndex, seg);
int dimdec, dimadec;
double dimlfac = 1.0;
int dimaunit = 0;
int dimzin = 0;
int dimazin = 0;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
ASSERT(pDimStyle);
dimdec = pDimStyle->dimdec();
dimadec = pDimStyle->dimadec();
dimlfac = pDimStyle->dimlfac();
dimaunit = pDimStyle->dimaunit();
dimzin = pDimStyle->dimzin();
dimazin = pDimStyle->dimazin();
if (dimaunit > 1)
dimaunit = 1;
OPENOBJ_END();
TCString sText;
if (IsAngular()) {
if (IsDimChord()) {
ASSERT(0); //永远也不会执行这儿
GlobalFunc::ftoa(seg.GeLine::GetLength() * dimlfac, dimdec, sText);
}
else if (IsDimArcLen()) {
GeArc ar = seg.GetArc();
ar.SetRadius(m_nObjRadius);
GlobalFunc::ftoa(ar.GetLength() * dimlfac, dimdec, sText);
}
else {
TCString sTemp;
ads_angtos(fabs(seg.GetBulge()), dimaunit, dimadec, sTemp);
const TCHAR *pd = _tcschr(sTemp, _T('d'));
if (pd) {
GlobalFunc::StrCpy(sText, sTemp, pd);
sText << _T("%%d");
sText << (pd + 1);
}
else if (dimaunit == 0) {
if (dimazin & 0x02)
GlobalFunc::DelSuffixZero(sTemp);
sText << sTemp << _T("%%d");
}
else {
sText << sTemp;
}
}
}
else {
GlobalFunc::ftoa(seg.GetLength() * dimlfac, dimdec, sText);
if ((dimzin & 0x08) != 0) {
GlobalFunc::DelSuffixZero(sText);
}
}
return sText;
}
TCString
AecXDbDimension_Old::GetText(int nIndex, BOOL *bIsDefault) const
{
TCString sText;
DimTextContent *pNode = ((AecXDbDimension_Old *)this)->m_lstTextContent.FindNode(&nIndex, DimTextContent::CompareByIndexForFind);
if (pNode) {
sText = pNode->sText;
if (bIsDefault) *bIsDefault = FALSE;
}
else {
if (bIsDefault) *bIsDefault = TRUE;
sText = GetDefaultText(nIndex);
}
return sText;
}
ADSGePoint3d
AecXDbDimension_Old::GetTextPos(int nIndex, BOOL *bIsDefault) const
{
ASSERT(nIndex < m_lstSegment.Length() && nIndex >= 0);
DimTextPos *pNode = ((AecXDbDimension_Old *)this)->m_lstTextPos.FindNode(&nIndex, DimTextPos::CompareByIndexForFind);
if (pNode) {
if (bIsDefault) *bIsDefault = FALSE;
return pNode->ptPos;
}
if (bIsDefault)
*bIsDefault = TRUE;
ADSGePoint3d ptText = GetDefaultTextPos(nIndex);
return ptText;
}
ADSGePoint3d
AecXDbDimension_Old::GetDefaultTextPos(int nIndex) const
{
ASSERT(nIndex < m_lstSegment.Length() && nIndex >= 0);
GePoly2D poly;
GetPolySegOnDimLine(poly);
double nOffDist = m_nDist2DimLine * GetPScale();
BOOL bAngular = IsAngular();
int nSeg = poly.TotalSegments();
GeCurveSegment seg;
poly.Nth(nIndex, seg);
ASSERT(!!seg);
ADSGePointDir2d ptTextPos;
seg.Polar(seg.GetLength() / 2.0, ptTextPos);
ADSGePoint3d ptText = ptTextPos;
double nDist2Dim = 0.0;
OPENOBJ_BEGIN(m_idDimStyle, AcDb::kForRead, AcDbDimStyleTableRecord, pDimStyle);
if (pDimStyle)
nDist2Dim = (pDimStyle->dimgap() + pDimStyle->dimtxt() / 2) * GetPScale(); //pDimStyle->dimscale();
else
nDist2Dim = 3.0 * GetPScale();
OPENOBJ_END();
ADSGePoint3d ptBase;
if (IsAngular() && IsDimChord()) {
Midpoint(seg.StartPoint(), seg.EndPoint(), ptBase);
}
else {
ptBase = ptTextPos;
}
ads_polar(ptBase, NormalViewAngle(ptTextPos.nDirection) + PI / 2.0, nDist2Dim, ptText);
return ptText;
}
AcDbObjectId
AecXDbDimension_Old::GetBindId() const
{
return m_idBind;
}
void
AecXDbDimension_Old::SetLocation(ADSGePoint3d pt)
{
AssertWriteEnabled();
m_ptLocation = pt;
m_ptLocation.z = 0;
}
void
AecXDbDimension_Old::SetRotation(double nAng)
{
AssertWriteEnabled();
m_nRotation = nAng;
}
void
AecXDbDimension_Old::SetDist2DimLine(double nVal, BOOL bAsPaperUnit)
{
AssertWriteEnabled();
m_nDist2DimLine = nVal;
if (!bAsPaperUnit)
m_nDist2DimLine /= GetPScale();
}
void
AecXDbDimension_Old::SetAngular(BOOL bTrue)
{
AssertWriteEnabled();
if (bTrue) m_nDimFlag |= DF_ANGULAR;
else m_nDimFlag &= ~DF_ANGULAR;
}
void
AecXDbDimension_Old::SetDimChord(BOOL bTrue)
{
AssertWriteEnabled();
if (bTrue) m_nDimFlag |= DF_CHORD;
else m_nDimFlag &= ~DF_CHORD;
}
void
AecXDbDimension_Old::SetDimArcLen(BOOL bTrue)
{
AssertWriteEnabled();
if (bTrue) m_nDimFlag |= DF_ARCLEN;
else m_nDimFlag &= ~DF_ARCLEN;
}
void
AecXDbDimension_Old::SetObjRadius(double nVal)
{
AssertWriteEnabled();
m_nObjRadius = nVal;
}
void
AecXDbDimension_Old::SetDimRadius(double nAng)
{
AssertWriteEnabled();
m_nDimRadius = nAng;
}
void
AecXDbDimension_Old::SetStyleId(AcDbObjectId idStyle)
{
AssertWriteEnabled();
m_idDimStyle = idStyle;
}
void AecXDbDimension_Old::SetTextPos(int nIndex, ADSGePoint3d ptPos)
{
AssertWriteEnabled();
ASSERT(nIndex < m_lstSegment.Length() && nIndex >= 0);
DimTextPos *pNode = m_lstTextPos.FindNode(&nIndex, DimTextPos::CompareByIndexForFind);
if (!pNode) {
ADSGePoint3d ptOld = GetTextPos(nIndex);
if (ptOld.Distance2d(ptPos) > g_Option::instance()._DIST_SNAP)
m_lstTextPos.Append(new DimTextPos(nIndex, ptPos));
}
else {
int nPos = m_lstTextPos.CurPosition();
ADSGePoint3d ptDefault = GetDefaultTextPos(nIndex);
if (ptDefault.Distance2d(ptPos) < g_Option::instance()._DIST_SNAP)
m_lstTextPos.Remove(nPos);
else
m_lstTextPos[nPos]->ptPos = ptPos;
}
AutoSetFlag();
}
void AecXDbDimension_Old::SetTextContent(int n, const TCHAR *pszChar)
{
AssertWriteEnabled();
ASSERT(n < m_lstSegment.Length() && n >= 0);
DimTextContent *pNode = m_lstTextContent.FindNode(&n, DimTextContent::CompareByIndexForFind);
if (!pNode) {
if (pszChar && pszChar[0])
m_lstTextContent.Append(new DimTextContent(n, pszChar));
}
else {
if (!pszChar || !pszChar[0])
m_lstTextContent.Remove();
else
pNode->sText = pszChar;
}
AutoSetFlag();
}
void AecXDbDimension_Old::SetBindId(AcDbObjectId id)
{
AssertWriteEnabled();
m_idBind = id;
AutoSetFlag();
}
void
AecXDbDimension_Old::AppendSegment(double nVal, BOOL bDist)
{
AssertWriteEnabled();
ASSERT(IsValidSegment(nVal, bDist));
if (IsAngular() && bDist)
nVal = nVal / m_nDimRadius;
m_lstSegment.Append(new double(nVal));
}
void
AecXDbDimension_Old::ResetTextPos()
{
AssertWriteEnabled();
m_lstTextPos.Reset();
AutoSetFlag();
}
void
AecXDbDimension_Old::ResetTextContent()
{
AssertWriteEnabled();
m_lstTextContent.Reset();
AutoSetFlag();
}
BOOL
AecXDbDimension_Old::IsTextMoved() const
{
return ((m_nDimFlag & DF_POSITION) != 0 && m_lstTextPos.Length());
}
BOOL
AecXDbDimension_Old::IsUseDefaultText() const
{
return ((m_nDimFlag & DF_TEXT) == 0 || m_lstTextContent.Length() == 0);
}
BOOL
AecXDbDimension_Old::IsBind() const
{
return ((m_nDimFlag & DF_BIND) != 0 && !!m_idBind);
}
BOOL
AecXDbDimension_Old::IsUseDimStyleScale() const
{
return ((m_nDimFlag & DF_DSSCALE) != 0);
}
void
AecXDbDimension_Old::UseDimStyleScale(BOOL bTrue)
{
AssertWriteEnabled();
if (bTrue)
m_nDimFlag |= DF_DSSCALE;
else
m_nDimFlag &= ~DF_DSSCALE;
}
void AecXDbDimension_Old::AutoSetFlag()
{
AssertWriteEnabled();
if (!!m_idBind)
m_nDimFlag |= DF_BIND;
else
m_nDimFlag &= ~DF_BIND;
if (m_lstTextPos.Length())
m_nDimFlag |= DF_POSITION;
else
m_nDimFlag &= ~DF_POSITION;
if (m_lstTextContent.Length())
m_nDimFlag |= DF_TEXT;
else
m_nDimFlag &= ~DF_TEXT;
}
#pragma endregion