1312 lines
29 KiB
C++
1312 lines
29 KiB
C++
//-----------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TDbBlockInsert.cpp
|
|
// = Version : ver2.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2002-09-09
|
|
// = Description: 上华图块类的定义
|
|
// = Maintainers:
|
|
//
|
|
//-----------------------------------------------------------------------------+
|
|
#include "StdAfx.h"
|
|
#include "TDbBlockInsert.h"
|
|
#include "TDPtrList.h"
|
|
#include "TIdPointPair.h"
|
|
#include "TAcDbObjectPtr.h"
|
|
#include "TGGiWorldViewportDraw.h"
|
|
#include "TConfigBase.h"
|
|
#include "TchPrivateGlobalFunc.h"
|
|
|
|
#if ADS > 15
|
|
#include "TDbGrip.h"
|
|
#include "TDbGripDistDim.h"
|
|
#endif
|
|
|
|
#define TCHXD _T("_TCH") //扩展实体数据的应用程序名称
|
|
static TDPtrList<TIdPointPair> g_lstBlockInsertIds;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSBlockInsert, AcDbBlockReference, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, AEC_BLOCK_INSERT, "AEC_BLOCK_INSERT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
// 1--TArch5
|
|
// 2--TArch6Beta1
|
|
// 3--TArch6Beta2
|
|
// 4--TArch8
|
|
const Adesk::UInt8 TDbBlockInsert::g_nVersion = 4;
|
|
|
|
TDbBlockInsert::TDbBlockInsert()
|
|
{
|
|
m_nMaskFlag = 0;
|
|
}
|
|
|
|
TDbBlockInsert::~TDbBlockInsert()
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::setLayer(AcDbObjectId newVal, Adesk::Boolean doSubents)
|
|
{
|
|
BOOL bHasId = objectId().isValid();
|
|
BOOL bCurDb =(database() == acdbCurDwg());
|
|
BOOL bMView = IsMultiView();
|
|
BOOL bDisable = FALSE;
|
|
BOOL nDrawMode = GetDrawMode();
|
|
|
|
if (bHasId && bCurDb && bMView )
|
|
{
|
|
bDisable = TRUE;
|
|
}
|
|
|
|
if (bDisable)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
return AcDbBlockReference::setLayer(newVal, doSubents);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::setLayer(const TCHAR * newVal, Adesk::Boolean doSubents)
|
|
{
|
|
BOOL bHasId = objectId().isValid();
|
|
BOOL bCurDb = (database() == acdbCurDwg());
|
|
BOOL bMView = IsMultiView();
|
|
BOOL nDrawMode= GetDrawMode();
|
|
BOOL bDisable = FALSE;
|
|
if (bHasId && bCurDb && bMView )
|
|
{
|
|
bDisable = TRUE;
|
|
}
|
|
|
|
if (bDisable)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
return AcDbBlockReference::setLayer(newVal, doSubents);
|
|
}
|
|
|
|
|
|
Adesk::UInt32
|
|
TDbBlockInsert::subSetAttributes(AcGiDrawableTraits* pTraits)
|
|
{
|
|
Adesk::UInt32 nFlag = AcDbBlockReference::subSetAttributes(pTraits);
|
|
if (g_nAcadVer < 15.0001)
|
|
{
|
|
return nFlag;
|
|
}
|
|
|
|
int nDrawMode = GetDrawMode();
|
|
int nDraw = 0;
|
|
if (nDrawMode == 3 && IsMultiView())
|
|
{
|
|
nDraw = 3;
|
|
}
|
|
|
|
Adesk::UInt32 nFlagNew = nFlag;
|
|
if (g_nAcadVer > 15.0001)
|
|
{
|
|
nFlagNew |= AcGiDrawable::kDrawableViewIndependentViewportDraw;
|
|
}
|
|
else
|
|
{
|
|
if (nDraw != 3)
|
|
{
|
|
nFlagNew |= AcGiDrawable::kDrawableViewIndependentViewportDraw;
|
|
}
|
|
}
|
|
|
|
return nFlagNew;
|
|
}
|
|
|
|
Adesk::UInt32 TDbBlockInsert::subViewportDrawLogicalFlags(AcGiViewportDraw * vd)
|
|
{
|
|
Adesk::UInt32 nRet = AcDbBlockReference::subViewportDrawLogicalFlags(vd);
|
|
|
|
ASSERT(g_nAcadVer > 15.0001);
|
|
Adesk::UInt32 nFlagNew = nRet;
|
|
|
|
int nDrawMode = GetDrawMode();
|
|
int nDraw = 0;
|
|
if (nDrawMode == 3 && IsMultiView())
|
|
{
|
|
nDraw = 3;
|
|
}
|
|
|
|
if (nDraw != 3)
|
|
{
|
|
nFlagNew |= AcGiDrawable::kDrawableViewIndependentViewportDraw;
|
|
}
|
|
else
|
|
{
|
|
nFlagNew |= 256;
|
|
}
|
|
|
|
return nFlagNew;
|
|
}
|
|
|
|
// 基类,不能正常克隆,因此需要重载
|
|
AcRxObject *TDbBlockInsert::clone() const
|
|
{
|
|
TDbBlockInsert *pClone = new TDbBlockInsert;
|
|
CopyObject(*this, *pClone);
|
|
return pClone;
|
|
}
|
|
|
|
Adesk::Boolean TDbBlockInsert::subCloneMeForDragging()
|
|
{
|
|
Adesk::Boolean bClone = AcDbBlockReference::subCloneMeForDragging();
|
|
return bClone;
|
|
}
|
|
|
|
// 从DWG读入数据:
|
|
Acad::ErrorStatus TDbBlockInsert::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
// extern BOOL g_bUpdateMViewBlock;
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = AcDbBlockReference::dwgInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
if (nVer > g_nVersion)
|
|
{
|
|
// 版本太新
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
|
|
pFiler->readItem(&m_nMaskFlag);
|
|
|
|
if (nVer == 1)
|
|
{
|
|
m_idBlock2d = _Get2DBlockId();
|
|
}
|
|
else
|
|
{
|
|
pFiler->readItem(&m_idBlock2d);
|
|
}
|
|
|
|
if (IsMultiView())
|
|
{
|
|
//g_bUpdateMViewBlock = TRUE;
|
|
UpdateMVBlockVal(TRUE);
|
|
|
|
if (nVer == 2 && database() == acdbCurDwg())
|
|
{
|
|
m_nMaskFlag |= BIF_T6BETA1;
|
|
}
|
|
}
|
|
|
|
if (nVer > 3)
|
|
{
|
|
es = TEntityBase::DwgInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = AcDbBlockReference::dwgOutFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
if (g_nSaveTArchVer == 5)
|
|
{
|
|
pFiler->writeItem((Adesk::UInt8)1);
|
|
}
|
|
else if (g_nSaveTArchVer < 8)//6、7
|
|
{
|
|
pFiler->writeItem((Adesk::UInt8)3);
|
|
}
|
|
else
|
|
{
|
|
pFiler->writeItem(g_nVersion);
|
|
}
|
|
|
|
pFiler->writeItem(m_nMaskFlag);
|
|
|
|
if (g_nSaveTArchVer == 5)
|
|
{// TArch5
|
|
if (m_idBlock2d.isValid() && IsMultiView())
|
|
{
|
|
_Set2DBlockId(m_idBlock2d);
|
|
}
|
|
}
|
|
|
|
if (g_nSaveTArchVer > 5)
|
|
{
|
|
pFiler->writeItem(m_idBlock2d);
|
|
}
|
|
|
|
if (g_nSaveTArchVer > 7)
|
|
{
|
|
es = TEntityBase::DwgOutFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = AcDbBlockReference::dxfInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbBlockInsert")))
|
|
{
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
resbuf rb;
|
|
while ((es == Acad::eOk) && ((es = pFiler->readResBuf(&rb)) == Acad::eOk))
|
|
{
|
|
switch (rb.restype)
|
|
{
|
|
case 61:
|
|
m_nMaskFlag = (Adesk::UInt8)rb.resval.rint;
|
|
break;
|
|
default:
|
|
// 不识别的组抛出,让子类读取
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
if (es != Acad::eEndOfFile)
|
|
{
|
|
return Acad::eInvalidResBuf;
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es;
|
|
|
|
es = AcDbBlockReference::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbBlockInsert"));
|
|
assert(es == Acad::eOk);
|
|
ASSERT(pFiler->writeUInt16(61, (Adesk::UInt16)m_nMaskFlag) == Acad::eOk);
|
|
|
|
return es;
|
|
}
|
|
|
|
Adesk::Boolean TDbBlockInsert::subWorldDraw(AcGiWorldDraw *pWd)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGiRegenType rType=pWd->regenType();
|
|
if (rType == kAcGiSaveWorldDrawForProxy)
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
TGGiWorldViewportDraw dc(pWd,NULL);
|
|
if (!OnExplodeOrDraw(dc))
|
|
{
|
|
return Adesk::kTrue;
|
|
}
|
|
|
|
pWd->subEntityTraits().setSelectionMarker(0); // 解决ACAD2002消隐崩溃的问题
|
|
int nDraw = GetDrawMode();
|
|
AcDbObjectId idBlock2d = Get2DBlockId();
|
|
|
|
Adesk::Boolean bRet = Adesk::kTrue;
|
|
if ((m_nMaskFlag & BIF_T6BETA1) != 0)
|
|
{ //如果块表记录没有渲染材质,就没有必要执行这儿
|
|
// AutoCAD 2000不支持多视图图块, 2000i以上才支持
|
|
if (!idBlock2d.isValid() || !IsMultiView() ||
|
|
nDraw != DRAW_2D || g_nAcadVer < 15.0001)
|
|
{ //默认使用三维
|
|
AcDbBlockReference::subWorldDraw(pWd);
|
|
}
|
|
else
|
|
{ //完全二维,才使用二维视图,由于遇到包含材质的图块,多视图崩溃
|
|
AcGeMatrix3d matTrans = BlockTransform(this);
|
|
matTrans(2,3) = 0.0;
|
|
OPENOBJ_BEGIN(idBlock2d, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if (pBlock)
|
|
{
|
|
AcGiSubEntityTraits &traits = pWd->subEntityTraits();
|
|
AcDbObjectId idLayer = traits.layerId();
|
|
Adesk::UInt16 nColor = traits.color();
|
|
AcDbObjectId idLineType = traits.lineTypeId();
|
|
#if ADS>16
|
|
AcDbObjectId idMaterial = traits.materialId();
|
|
#endif
|
|
AcGiGeometry *geom = pWd->rawGeometry();
|
|
geom->pushModelTransform(matTrans);
|
|
geom->draw(pBlock);
|
|
geom->popModelTransform();
|
|
traits.setLayer(idLayer);
|
|
traits.setColor(nColor);
|
|
traits.setLineType(idLineType);
|
|
#if ADS>16
|
|
traits.setMaterial(idMaterial);
|
|
#endif
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nDraw == DRAW_3D)
|
|
{
|
|
bRet = AcDbBlockReference::subWorldDraw(pWd);
|
|
}
|
|
else if (nDraw == DRAW_2D && idBlock2d.isValid() && IsMultiView())
|
|
{
|
|
AcGeMatrix3d matTrans = BlockTransform(this);
|
|
matTrans(2,3) = 0.0;
|
|
OPENOBJ_BEGIN(idBlock2d, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if (pBlock)
|
|
{
|
|
AcGiSubEntityTraits &traits = pWd->subEntityTraits();
|
|
AcDbObjectId idLayer = traits.layerId();
|
|
Adesk::UInt16 nColor = traits.color();
|
|
AcDbObjectId idLineType = traits.lineTypeId();
|
|
#if ADS>16
|
|
AcDbObjectId idMaterial = traits.materialId();
|
|
#endif
|
|
AcGiGeometry *geom = pWd->rawGeometry();
|
|
geom->pushModelTransform(matTrans);
|
|
geom->draw(pBlock);
|
|
geom->popModelTransform();
|
|
traits.setLayer(idLayer);
|
|
traits.setColor(nColor);
|
|
traits.setLineType(idLineType);
|
|
#if ADS>16
|
|
traits.setMaterial(idMaterial);
|
|
#endif
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
else if (!idBlock2d.isValid())
|
|
{
|
|
bRet = AcDbBlockReference::subWorldDraw(pWd);
|
|
}
|
|
else
|
|
{
|
|
bRet = Adesk::kFalse;
|
|
}
|
|
}
|
|
return bRet;
|
|
}
|
|
|
|
void TDbBlockInsert::subViewportDraw(AcGiViewportDraw* pMode)
|
|
{
|
|
TGGiWorldViewportDraw dc(NULL,pMode);
|
|
if (!OnExplodeOrDraw(dc))
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGiRegenType nRegenType = pMode->regenType();
|
|
AcGiViewport &vp = pMode->viewport();
|
|
AcGePoint3d ptCamera, ptTarget;
|
|
vp.getCameraTarget(ptTarget);
|
|
vp.getCameraLocation(ptCamera);
|
|
|
|
AcGeVector3d vtViewDrt = ptCamera-ptTarget;
|
|
AcGeVector3d vtViewDir1= vp.viewDir();
|
|
AcGeVector3d vtCamera;
|
|
vp.getCameraUpVector(vtCamera);
|
|
vtViewDrt.normalize();
|
|
|
|
if (!!ownerId())
|
|
{
|
|
pMode->subEntityTraits().setSelectionMarker(0);
|
|
}
|
|
|
|
int nDrawMode = GetDrawMode();
|
|
AcDbObjectId idBlock2d = Get2DBlockId();
|
|
AcDbObjectId idBlock;
|
|
if (!idBlock2d)
|
|
{
|
|
idBlock = blockTableRecord();
|
|
}
|
|
else
|
|
{
|
|
if (nDrawMode == 3)
|
|
{
|
|
if (g_nAcadVer > 15.0001)
|
|
{
|
|
if (nRegenType == kAcGiRenderCommand || nRegenType == kAcGiHideOrShadeCommand
|
|
|| vp.isPerspective() || vtViewDrt != AcGeVector3d(0,0,1))
|
|
{ // Draw3d
|
|
idBlock = blockTableRecord();
|
|
}
|
|
else
|
|
{
|
|
idBlock=idBlock2d;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (nRegenType == kAcGiRenderCommand || vp.isPerspective() || vtViewDrt != AcGeVector3d(0,0,1))
|
|
{ // Draw3d
|
|
idBlock = blockTableRecord();
|
|
}
|
|
else
|
|
{
|
|
idBlock = idBlock2d;
|
|
}
|
|
}
|
|
}
|
|
else if (nDrawMode == 1)
|
|
{
|
|
idBlock = idBlock2d;
|
|
}
|
|
else if (nDrawMode == 2)
|
|
{
|
|
idBlock = blockTableRecord();
|
|
}
|
|
}
|
|
|
|
if (g_nAcadVer > 15.0001)
|
|
{
|
|
AcGeMatrix3d matTrans = BlockTransform(this);
|
|
if (idBlock == idBlock2d)
|
|
{
|
|
matTrans(2,3) = 0.0;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if (pBlock)
|
|
{
|
|
AcGiSubEntityTraits &traits = pMode->subEntityTraits();
|
|
AcDbObjectId idLayer = traits.layerId();
|
|
Adesk::UInt16 nColor = traits.color();
|
|
AcDbObjectId idLineType = traits.lineTypeId();
|
|
#if ADS>16
|
|
AcDbObjectId idMaterial = traits.materialId();
|
|
#endif
|
|
|
|
AcGiGeometry *geom = pMode->rawGeometry();
|
|
geom->pushModelTransform(matTrans);
|
|
geom->draw(pBlock);
|
|
geom->popModelTransform();
|
|
traits.setLayer(idLayer);
|
|
traits.setColor(nColor);
|
|
traits.setLineType(idLineType);
|
|
#if ADS>16
|
|
traits.setMaterial(idMaterial);
|
|
#endif
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
//AcDbBlockReference的transformBy还没有完全实现镜像操作
|
|
//vtNormal!=(0,0,1)时不正确
|
|
Acad::ErrorStatus
|
|
TDbBlockInsert::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
AcGeVector3d vtNormal = normal();
|
|
|
|
assertWriteEnabled();
|
|
AcGePoint3d origin;
|
|
OPENOBJ_BEGIN(blockTableRecord(), AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
|
|
ASSERT(pBlock);
|
|
origin = pBlock->origin();
|
|
OPENOBJ_END();
|
|
|
|
ads_matrix mat;
|
|
{
|
|
AcGeScale3d scale = scaleFactors();
|
|
TADSGePoint3d ptInsert = position();
|
|
double nRotation = rotation();
|
|
ConstructMatrix(origin, ptInsert, scale[0], scale[1], scale[2], nRotation, mat);
|
|
}
|
|
AcGeMatrix3d matTran = AsAcGeMatrix3d(mat);
|
|
matTran.preMultBy(xform);
|
|
|
|
AcGeVector3d vt(1.0, 0.0, 0.0);
|
|
vt.transformBy(matTran);
|
|
|
|
double nRot = ads_angle(TADSGePoint3d(), TADSGePoint3d(vt[0],vt[1],vt[2]));
|
|
origin.transformBy(matTran);
|
|
|
|
ads_matrix matRot, matMov;
|
|
TADSGePoint3d(origin).GetMoveMatrix(TADSGePoint3d(),matMov);
|
|
matTran.preMultBy(AsAcGeMatrix3d(matMov));
|
|
|
|
TADSGePoint3d().GetRotationMatrix(-nRot, matRot);
|
|
matTran.preMultBy(AsAcGeMatrix3d(matRot));
|
|
|
|
AcGeScale3d scales = AcGeScale3d(matTran(0,0), matTran(1,1), matTran(2,2));
|
|
|
|
if (fabs(scales[0])<1.0E-6 || fabs(scales[1])<1.0E-6 || fabs(scales[2])<1.0E-6)
|
|
{
|
|
return Acad::eNotApplicable;
|
|
}
|
|
|
|
setPosition(origin);
|
|
setRotation(nRot);
|
|
setScaleFactors(scales);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
// Overriden functions for edit
|
|
// 定义了6个夹点:
|
|
// 中心点: 用来移动
|
|
// 四个角点: 用来改尺寸
|
|
// 边点: 用来改角度
|
|
Acad::ErrorStatus TDbBlockInsert::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
TBlockGeomInfo geom = GetGeomInfo();
|
|
gripPoints.append((TADSGePoint3d &)geom.GetCenter());
|
|
gripPoints.append((TADSGePoint3d &)geom.GetLowLeft());
|
|
gripPoints.append((TADSGePoint3d &)geom.GetLowRight());
|
|
gripPoints.append((TADSGePoint3d &)geom.GetUpRight());
|
|
gripPoints.append((TADSGePoint3d &)geom.GetUpLeft());
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//交点捕捉函数
|
|
Acad::ErrorStatus
|
|
TDbBlockInsert::subIntersectWith(const AcDbEntity* ent,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
if (IsKeyPressed(VK_CONTROL))
|
|
{
|
|
return AcDbBlockReference::subIntersectWith(ent, intType, points, thisGsMarker, otherGsMarker);
|
|
}
|
|
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
// Extend, Trim
|
|
Acad::ErrorStatus
|
|
TDbBlockInsert::subIntersectWith(const AcDbEntity* ent,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
return AcDbBlockReference::subIntersectWith(ent, intType, projPlane, points, thisGsMarker, otherGsMarker);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::subGetOsnapPoints(
|
|
AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
int nCount = snapPoints.length();
|
|
switch(osnapMode)
|
|
{
|
|
case AcDb::kOsModeIns:
|
|
snapPoints.append(position());
|
|
break;
|
|
case AcDb::kOsModeCen:
|
|
if (IsKeyPressed(VK_CONTROL))
|
|
{
|
|
AcDbBlockReference::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint,
|
|
viewXform, snapPoints, geomIds);
|
|
}
|
|
else
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((TADSGePoint3d &)geom.GetCenter());
|
|
}
|
|
break;
|
|
case AcDb::kOsModeNode:
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((TADSGePoint3d &)geom.GetCenter());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetLowLeft());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetLowRight());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetUpRight());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetUpLeft());
|
|
break;
|
|
}
|
|
case AcDb::kOsModeQuad:
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((TADSGePoint3d &)geom.GetLowLeft());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetLowRight());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetUpRight());
|
|
snapPoints.append((TADSGePoint3d &)geom.GetUpLeft());
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
if(IsKeyPressed(VK_CONTROL))
|
|
{
|
|
AcDbBlockReference::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint,
|
|
viewXform, snapPoints, geomIds);
|
|
}
|
|
else
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
AcDbPolyline pline;
|
|
geom.GetPolyline(pline);
|
|
pline.getOsnapPoints(osnapMode, 0, ptPick, lastPoint, viewXform, snapPoints, geomIds);
|
|
}
|
|
}
|
|
}
|
|
int nCount1 = snapPoints.length();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 取得夹点说明
|
|
Acad::ErrorStatus TDbBlockInsert::GetGripText(int i, CString &cs) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
switch(i)
|
|
{
|
|
case 0:
|
|
cs = (GetCtrlToggle()? _T("移动(Ctrl-中心旋转)") : _T("中心旋转(Ctrl-移动)"));
|
|
break;
|
|
case 1:
|
|
cs = (GetCtrlToggle()? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 2:
|
|
cs = (GetCtrlToggle()? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 3:
|
|
cs = (GetCtrlToggle()? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
case 4:
|
|
cs = (GetCtrlToggle()? _T("移动(Ctrl-对角拉伸)") : _T("对角拉伸(Ctrl-移动)"));
|
|
break;
|
|
default:
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
return es;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
Acad::ErrorStatus TDbBlockInsert::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
|
|
{
|
|
TBlockGeomInfo geom = GetGeomInfo();
|
|
assertWriteEnabled();
|
|
|
|
BOOL bCtrlPressed = GetCtrlToggle(); //IsKeyPressed(VK_CONTROL);
|
|
|
|
AcDbObjectId objId = objectId();
|
|
TADSGePoint3d &vtOffset = *(TADSGePoint3d *)&offset;
|
|
TADSGePoint3d ptFix = geom.m_ptCen;
|
|
int idx = 0;
|
|
for (int i = 0; i < indices.length(); i++)
|
|
{
|
|
idx = indices[i];
|
|
switch(idx)
|
|
{
|
|
case 0: // Move Center
|
|
if(bCtrlPressed)
|
|
{
|
|
geom.m_ptCen += vtOffset;
|
|
}
|
|
else
|
|
{
|
|
double nRot = ads_angle(TADSGePoint3d(), vtOffset);
|
|
geom.m_nRotation = nRot;
|
|
}
|
|
break;
|
|
case 1: // Move LowLeft
|
|
if(bCtrlPressed)
|
|
{
|
|
geom.m_ptCen += vtOffset;
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptLowLeft=geom.GetLowLeft();
|
|
TADSGePoint3d ptUpRight=geom.GetUpRight();
|
|
ptFix=ptUpRight;
|
|
ptLowLeft += vtOffset;
|
|
ptLowLeft.z = ptUpRight.z;
|
|
|
|
TGGeLine ln(ptUpRight, geom.m_nRotation);
|
|
TADSGePoint3d ptPrj;
|
|
ptLowLeft.Project(&ln, ptPrj);
|
|
geom.m_nSizeX = ads_distance(ptPrj, ptUpRight);
|
|
geom.m_nSizeY = ads_distance(ptPrj, ptLowLeft);
|
|
Midpoint(ptUpRight, ptLowLeft, geom.m_ptCen);
|
|
}
|
|
break;
|
|
case 2: // Move LowRight
|
|
if(bCtrlPressed)
|
|
{
|
|
geom.m_ptCen += vtOffset;
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptLowRight=geom.GetLowRight();
|
|
TADSGePoint3d ptUpLeft=geom.GetUpLeft();
|
|
ptFix = ptUpLeft;
|
|
ptLowRight += vtOffset;
|
|
ptLowRight.z = ptUpLeft.z;
|
|
|
|
TGGeLine ln(ptUpLeft, geom.m_nRotation);
|
|
TADSGePoint3d ptPrj;
|
|
ptLowRight.Project(&ln, ptPrj);
|
|
geom.m_nSizeX = ads_distance(ptPrj, ptUpLeft);
|
|
geom.m_nSizeY = ads_distance(ptPrj, ptLowRight);
|
|
Midpoint(ptLowRight, ptUpLeft, geom.m_ptCen);
|
|
}
|
|
break;
|
|
case 3: // Move UpRight
|
|
if(bCtrlPressed)
|
|
{
|
|
geom.m_ptCen += vtOffset;
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptUpRight=geom.GetUpRight();
|
|
TADSGePoint3d ptLowLeft=geom.GetLowLeft();
|
|
ptFix = ptLowLeft;
|
|
ptUpRight += vtOffset;
|
|
ptUpRight.z = ptLowLeft.z;
|
|
|
|
TGGeLine ln(ptLowLeft, geom.m_nRotation);
|
|
TADSGePoint3d ptPrj;
|
|
ptUpRight.Project(&ln, ptPrj);
|
|
geom.m_nSizeX = ads_distance(ptPrj, ptLowLeft);
|
|
geom.m_nSizeY = ads_distance(ptPrj, ptUpRight);
|
|
Midpoint(ptUpRight, ptLowLeft, geom.m_ptCen);
|
|
}
|
|
break;
|
|
case 4: // Move UpLeft
|
|
if(bCtrlPressed)
|
|
{
|
|
geom.m_ptCen += vtOffset;
|
|
}
|
|
else
|
|
{
|
|
TADSGePoint3d ptUpLeft=geom.GetUpLeft();
|
|
TADSGePoint3d ptLowRight=geom.GetLowRight();
|
|
ptFix=ptLowRight;
|
|
ptUpLeft += vtOffset;
|
|
ptUpLeft.z = ptUpLeft.z;
|
|
|
|
TGGeLine ln(ptLowRight, geom.m_nRotation);
|
|
TADSGePoint3d ptPrj;
|
|
ptUpLeft.Project(&ln, ptPrj);
|
|
geom.m_nSizeX = ads_distance(ptPrj, ptLowRight);
|
|
geom.m_nSizeY = ads_distance(ptPrj, ptUpLeft);
|
|
Midpoint(ptLowRight, ptUpLeft, geom.m_ptCen);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
UpdateFrom(geom);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 功能: 夹点操作
|
|
// ACAD漏洞,stretch修改后,仍然被复原
|
|
Acad::ErrorStatus TDbBlockInsert::subMoveStretchPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
if(indices.length())
|
|
{
|
|
AcGePoint3d ptPos=position();
|
|
ptPos += offset;
|
|
setPosition(ptPos);
|
|
AcGePoint3d ptPos1=position();
|
|
AcDbObjectId idThis=objectId();
|
|
|
|
if(!!idThis)
|
|
{
|
|
TCHAR szHand[17]=_T("");
|
|
AcDbHandle hand=idThis.handle();
|
|
hand.getIntoAsciiBuffer(szHand);
|
|
setPosition(ptPos1);
|
|
|
|
//modify by xlc on 100401 调整调用kernal内容的方式
|
|
//TCString &sCmd=GetCurDocData()->m_sCurCommand;
|
|
CString sCmd;
|
|
TConfigBase* pBase = GetConfigBase();
|
|
if (pBase != NULL)
|
|
{
|
|
sCmd = pBase->GetCurrentCommand();
|
|
pBase->Close();
|
|
}
|
|
|
|
if(_tcsicmp(sCmd, _T("STRETCH")) == 0)
|
|
{
|
|
TIdPointPair *p0=g_lstBlockInsertIds.FindNode(&idThis, TIdPointPair::CompareIdForFind);
|
|
if(p0)
|
|
{
|
|
p0->m_pt = ptPos;
|
|
}
|
|
else
|
|
{
|
|
g_lstBlockInsertIds.Append(new TIdPointPair(idThis, ptPos));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
TBlockGeomInfo TDbBlockInsert::GetGeomInfo() const
|
|
{
|
|
TBlockGeomInfo geom;
|
|
geom.SetFromInsert(this);
|
|
return geom;
|
|
}
|
|
|
|
//修改相应的Insert
|
|
Acad::ErrorStatus TDbBlockInsert::UpdateFrom(const TBlockGeomInfo &geom)
|
|
{
|
|
assertWriteEnabled();
|
|
// 用当前选择集是否包含图块来判断, 图块是否曾经被选择过, 十分不可靠
|
|
// 取当前选择集是一个十分不可靠的函数
|
|
TADSGePoint3d ptNewBase;
|
|
double nNewRot;
|
|
AcGeScale3d scale;
|
|
if(geom.CalInsertParameters(this, ptNewBase, &nNewRot, &scale[0], &scale[1], &scale[2]) != Acad::eOk)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
setPosition(ptNewBase);
|
|
setRotation(nNewRot);
|
|
setScaleFactors(scale);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
// 有待改进
|
|
Acad::ErrorStatus TDbBlockInsert::subExplode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
entitySet.append(NewBlockInsert());
|
|
return Acad::eOk;
|
|
}
|
|
Acad::ErrorStatus TDbBlockInsert::GetExtents2d(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
|
|
{
|
|
AcDbExtents ext;
|
|
Acad::ErrorStatus es = getGeomExtents(ext);
|
|
ptLow = ext.minPoint();
|
|
ptUp = ext.maxPoint();
|
|
return es;
|
|
}
|
|
|
|
|
|
AcDbBlockReference * TDbBlockInsert::NewBlockInsert() const
|
|
{
|
|
int nExpMode = 1;
|
|
AcDbObjectId idBlock2d;
|
|
if(IsMultiView())
|
|
{
|
|
idBlock2d = Get2DBlockId();
|
|
}
|
|
|
|
if(idBlock2d.isValid())
|
|
{
|
|
nExpMode = IsExplode3D(); //0--2D; 1--3D
|
|
}
|
|
if(nExpMode == 1)
|
|
{
|
|
idBlock2d = blockTableRecord();
|
|
}
|
|
|
|
AcDbBlockReference *pInsert= new AcDbBlockReference;
|
|
pInsert->setPropertiesFrom(this);
|
|
pInsert->setBlockTableRecord(idBlock2d);
|
|
pInsert->setNormal(normal());
|
|
pInsert->setPosition(position());
|
|
pInsert->setRotation(rotation());
|
|
pInsert->setScaleFactors(scaleFactors());
|
|
return pInsert;
|
|
}
|
|
|
|
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
|
void TDbBlockInsert::GetTips(TDPtrList<TObjInfoUnit> &lstInfo) const
|
|
{
|
|
TBlockGeomInfo geom = GetGeomInfo();
|
|
TCString sBlockName = TchExport::GetSymbolName(blockTableRecord());
|
|
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("上华图块")));
|
|
lstInfo.Append(new TObjInfoUnit(_T("中心点"), TchExport::Point2d2Str(geom.m_ptCen)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("转角"), TCString(_T("%d"), AS_INT(geom.m_nRotation * 180 / PI))));
|
|
lstInfo.Append(new TObjInfoUnit(_T("长度X"), TchExport::Dist2Str(geom.m_nSizeX)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("宽度Y"), TchExport::Dist2Str(geom.m_nSizeY)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("高度Z"), TchExport::Dist2Str(geom.m_nSizeZ)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("图块名称"), sBlockName));
|
|
}
|
|
|
|
void TDbBlockInsert::SetMaskFlag(Adesk::UInt8 nFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
m_nMaskFlag = nFlag;
|
|
}
|
|
|
|
Adesk::UInt8
|
|
TDbBlockInsert::GetMaskFlag() const
|
|
{
|
|
return m_nMaskFlag;
|
|
}
|
|
|
|
BOOL TDbBlockInsert::IsMultiView() const
|
|
{
|
|
return ((m_nMaskFlag&BIF_MULTIVIEW) != 0);
|
|
}
|
|
|
|
void TDbBlockInsert::SetMultiView(BOOL bTrue)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bTrue)
|
|
{
|
|
m_nMaskFlag |= BIF_MULTIVIEW;
|
|
}
|
|
else
|
|
{
|
|
m_nMaskFlag &= ~BIF_MULTIVIEW;
|
|
}
|
|
}
|
|
|
|
AcDbObjectId TDbBlockInsert::Get2DBlockId() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_idBlock2d;
|
|
}
|
|
|
|
void TDbBlockInsert::Set2DBlockId(AcDbObjectId id)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idBlock2d = id;
|
|
}
|
|
|
|
AcDbObjectId TDbBlockInsert::_Get2DBlockId() const
|
|
{
|
|
AcDbObjectId idBlock = blockTableRecord();
|
|
AcDbObjectId idBlock2d = GetBlock2dFromBlock3d(idBlock);
|
|
return idBlock2d;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::_Set2DBlockId(AcDbObjectId idBlock2d) const
|
|
{
|
|
if(!idBlock2d.isValid())
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
AcDbObjectId idBlock = blockTableRecord();
|
|
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if(pBlock)
|
|
{
|
|
AcDbHandle hand=idBlock2d.handle();
|
|
TCHAR szHand[256] = _T("");
|
|
hand.getIntoAsciiBuffer(szHand);
|
|
|
|
BOOL bExist = FALSE;
|
|
resbuf *pxData = pBlock->xData(TCHXD); // 读扩展数据
|
|
if(pxData)
|
|
{
|
|
resbuf *pNext = pxData->rbnext;
|
|
if(pNext && pNext->restype == 1005)
|
|
{
|
|
if(_tcsicmp(pNext->resval.rstring, szHand) == 0)
|
|
{
|
|
bExist = TRUE;
|
|
}
|
|
}
|
|
ads_relrb(pxData);
|
|
}
|
|
|
|
if(!bExist)
|
|
{
|
|
if(pBlock->upgradeOpen() == Acad::eOk)
|
|
{
|
|
TRBList xd = ads_buildlist(1001, TCHXD, 1005, szHand, NULL);
|
|
pBlock->setXData(xd);
|
|
pBlock->downgradeOpen();
|
|
es = Acad::eOk;
|
|
}
|
|
else
|
|
{
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
OPENOBJ_END();
|
|
return es;
|
|
}
|
|
|
|
#if ADS > 15
|
|
void TDbBlockInsert::subGripStatus(const AcDb::GripStat status)
|
|
{
|
|
assertReadEnabled();
|
|
TEntityBase::GripStatus(status);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::subGetGripPoints(AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
return TEntityBase::GetGripPoints(grips,curViewUnitSize,gripSize,curViewDir,bitflags);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::subMoveGripPointsAt(const AcDbVoidPtrArray& appData,
|
|
const AcGeVector3d& offset,
|
|
const int bitflags)
|
|
{
|
|
assertWriteEnabled();
|
|
return TEntityBase::MoveGripPointsAt(appData,offset,bitflags);
|
|
}
|
|
|
|
void TDbBlockInsert::CreateGrip()
|
|
{
|
|
TEntityBase::CreateGrip();
|
|
|
|
for(long i = 1;i<5;i++)
|
|
{
|
|
GetGrip(i)->AppendDim(new TDbGripDistDim(AcDbDimData::kDimResultantLength));//X
|
|
GetGrip(i)->AppendDim(new TDbGripDistDim(AcDbDimData::kDimResultantLength));//Y
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::EntityToDim(long iGrip,long iDim,const AcDbEntity*pEnt)
|
|
{
|
|
TDbGripDim*pDim = GetGripDim(iGrip,iDim);
|
|
if(pDim == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
if(pEnt == NULL)
|
|
{
|
|
pEnt = this;
|
|
}
|
|
TDbBlockInsert *pInsert = TDbBlockInsert::cast(pEnt);
|
|
if(pInsert == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
TBlockGeomInfo info = pInsert->GetGeomInfo();
|
|
TDbGripDistDim *pDistDim = (TDbGripDistDim*)pDim;
|
|
if(iGrip == 2 || iGrip == 4)
|
|
{
|
|
if(iDim == 0)
|
|
{
|
|
pDistDim->SetData(pInsert->GetGripPoint((iGrip+2)%4+1),pInsert->GetGripPoint(iGrip),info.GetSizeY()/3);
|
|
}
|
|
else if(iDim == 1)
|
|
{
|
|
pDistDim->SetData(pInsert->GetGripPoint(iGrip),pInsert->GetGripPoint(iGrip%4+1),info.GetSizeX()/3);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
}
|
|
else if(iGrip == 1 || iGrip == 3)
|
|
{
|
|
if(iDim == 1)
|
|
{
|
|
pDistDim->SetData(pInsert->GetGripPoint((iGrip+2)%4+1),pInsert->GetGripPoint(iGrip),info.GetSizeX()/3);
|
|
}
|
|
else if(iDim == 0)
|
|
{
|
|
pDistDim->SetData(pInsert->GetGripPoint(iGrip),pInsert->GetGripPoint(iGrip%4+1),info.GetSizeY()/3);
|
|
}
|
|
else
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbBlockInsert::DimToEntity(long iGrip,long iDim,double newValue,const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if(newValue<1E-9)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
TBlockGeomInfo info = GetGeomInfo();
|
|
double d;
|
|
if(iDim == 0)
|
|
{
|
|
d=newValue-info.m_nSizeX;
|
|
info.m_nSizeX = newValue;
|
|
}
|
|
else if(iDim == 1)
|
|
{
|
|
d = newValue-info.m_nSizeY;
|
|
info.m_nSizeY = newValue;
|
|
}
|
|
else
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
if(!GetCtrlToggle())
|
|
{
|
|
TADSGePoint3d vt = iDim == 0 ? TADSGePoint3d(d/2,0) : TADSGePoint3d(0,d/2);
|
|
switch(iGrip)
|
|
{
|
|
case 1:
|
|
vt.Rotate(info.GetRotation()+PI);
|
|
break;
|
|
case 2:
|
|
if(iDim == 0)
|
|
{
|
|
vt.Rotate(info.GetRotation());
|
|
}
|
|
else
|
|
{
|
|
vt.Rotate(info.GetRotation()+PI);
|
|
}
|
|
break;
|
|
case 3:
|
|
vt.Rotate(info.GetRotation());
|
|
break;
|
|
case 4:
|
|
if(iDim == 0)
|
|
{
|
|
vt.Rotate(info.GetRotation()+PI);
|
|
}
|
|
else
|
|
{
|
|
vt.Rotate(info.GetRotation());
|
|
}
|
|
break;
|
|
default:
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
info.m_ptCen += vt;
|
|
}
|
|
|
|
UpdateFrom(info);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#endif
|
|
|
|
AcDbEntity * TDbBlockInsert::GetMe()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
const AcDbEntity * TDbBlockInsert::GetMe() const
|
|
{
|
|
return this;
|
|
}
|
|
|
|
int TDbBlockInsert::GetCtrlToggleIndex()const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
bool TDbBlockInsert::IsModelEntity() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void* TDbBlockInsert::operator new[](size_t nSize)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void TDbBlockInsert::operator delete[](void *p)
|
|
{
|
|
|
|
}
|
|
|
|
void* TDbBlockInsert::operator new[](size_t nSize, const TCHAR *file, int line)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
AcDbObjectId TDbBlockInsert::GetBlock2dFromBlock3d(AcDbObjectId idBlock) const
|
|
{
|
|
AcDbObjectId idBlock2d;
|
|
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if (pBlock)
|
|
{
|
|
resbuf *pxData = pBlock->xData(TCHXD); // 读扩展数据
|
|
if (pxData)
|
|
{
|
|
resbuf *pNext = pxData->rbnext;
|
|
if (pNext && pNext->restype == 1005)
|
|
{
|
|
AcDbHandle handle(pNext->resval.rstring);
|
|
pBlock->database()->getAcDbObjectId(idBlock2d, false, handle);
|
|
}
|
|
|
|
ads_relrb(pxData);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
return idBlock2d;
|
|
}
|
|
|
|
void InitBlockInsertIds(BOOL bCmdEnd)
|
|
{
|
|
if (bCmdEnd)
|
|
{
|
|
for (int i = 0; i < g_lstBlockInsertIds.Length(); i++)
|
|
{
|
|
TIdPointPair *p0 = g_lstBlockInsertIds[i];
|
|
OPENOBJ_BEGIN(p0->m_id, AcDb::kForWrite, TDbBlockInsert, pInsert);
|
|
if (pInsert)
|
|
{
|
|
pInsert->setPosition(p0->m_pt);
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
|
|
g_lstBlockInsertIds.Reset();
|
|
}
|