590 lines
18 KiB
C++
590 lines
18 KiB
C++
#include "stdafx.h"
|
|
|
|
|
|
extern BOOL GetCtrlToggle();
|
|
const Adesk::UInt8 TDbMultiViewInsert::g_nVersion = 1;
|
|
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSMultiViewInsert, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_MVINSERT, "ATS_MVINSERT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
|
|
IMPLEMENT_TENTBASE(TDbMultiViewInsert);
|
|
|
|
TDbMultiViewInsert::TDbMultiViewInsert()
|
|
:m_nFlag(0), m_xScale(1.0), m_yScale(1.0), m_zScale(1.0), m_nRotation(0.0)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
BOOL TDbMultiViewInsert::IsValid() const
|
|
{
|
|
BOOL bRet=TDbEntity::IsValid();
|
|
if(!bRet)
|
|
return bRet;
|
|
double minScale=TchExport::Minimum(3, fabs(m_xScale), fabs(m_yScale), fabs(m_zScale));
|
|
bRet=(m_idBlock2d.isValid() &&
|
|
m_idBlock3d.isValid() &&
|
|
minScale>1.0E-9
|
|
);
|
|
return bRet;
|
|
}
|
|
|
|
|
|
// 提供对格式刷的支持
|
|
void TDbMultiViewInsert::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|
TDbMultiViewInsert *pSrc=TDbMultiViewInsert::cast(pSrcEntity);
|
|
if(pSrc) {
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
//return TDbEntity::getClassID(pClsid);
|
|
}
|
|
|
|
// 从DWG读入数据:
|
|
// 注意: 有待加入版本控制
|
|
Acad::ErrorStatus TDbMultiViewInsert::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::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(&m_nFlag);
|
|
pFiler->readItem(&m_idBlock2d);
|
|
pFiler->readItem(&m_idBlock3d);
|
|
pFiler->readItem(&(AcGePoint3d &)m_ptLocation);
|
|
pFiler->readItem(&m_xScale);
|
|
pFiler->readItem(&m_yScale);
|
|
pFiler->readItem(&m_zScale); // nWidth有正负, nHeight>0
|
|
pFiler->readItem(&m_nRotation); // 0~2*PI
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
// 写出数据到dwg:
|
|
Acad::ErrorStatus TDbMultiViewInsert::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem(m_nFlag);
|
|
pFiler->writeItem(m_idBlock2d);
|
|
pFiler->writeItem(m_idBlock3d);
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
|
|
pFiler->writeItem(m_xScale);
|
|
pFiler->writeItem(m_yScale);
|
|
pFiler->writeItem(m_zScale); // nWidth有正负, nHeight>0
|
|
pFiler->writeItem(m_nRotation); // 0~2*PI
|
|
return es;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus TDbMultiViewInsert::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler);
|
|
if(es!=Acad::eOk)
|
|
return es;
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbMultiViewInsert"))) {
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
|
|
TDbMultiViewInsert bakClone;
|
|
CopyObject(*this, bakClone);
|
|
|
|
int fieldsFlags=0;
|
|
resbuf rb;
|
|
while ((es == Acad::eOk)
|
|
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
|
switch (rb.restype) {
|
|
case 10:
|
|
m_ptLocation=rb.resval.rpoint;
|
|
fieldsFlags |= 0x01;
|
|
break;
|
|
case 1:
|
|
m_idBlock2d=GetBlockIdFromString(rb.resval.rstring, database());
|
|
free(rb.resval.rstring);
|
|
fieldsFlags |= 0x02;
|
|
break;
|
|
case 2:
|
|
m_idBlock3d=GetBlockIdFromString(rb.resval.rstring, database());
|
|
free(rb.resval.rstring);
|
|
fieldsFlags |= 0x04;
|
|
break;
|
|
case 40:
|
|
m_xScale=rb.resval.rreal;
|
|
break;
|
|
case 41:
|
|
m_yScale=rb.resval.rreal;
|
|
break;
|
|
case 42:
|
|
m_zScale=rb.resval.rreal;
|
|
break;
|
|
case 50:
|
|
m_nRotation=rb.resval.rreal;
|
|
break;
|
|
default:
|
|
// An unrecognized group. Push it back so that
|
|
// the subclass can read it again.
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
if (es != Acad::eEndOfFile) {
|
|
CopyObject(bakClone, *this);
|
|
return Acad::eInvalidResBuf;
|
|
}
|
|
int bitFlags[]={10, 0x01, 1, 0x02, 2, 0x04};
|
|
for(int i=0; i<ELEMENTS(bitFlags); i+=2) {
|
|
if(!(fieldsFlags&bitFlags[i])) {
|
|
pFiler->setError(Acad::eMissingDxfField,
|
|
XString(_T("\nMissing DXF group code: %d"), bitFlags[i+1]));
|
|
CopyObject(bakClone, *this);
|
|
return Acad::eMissingDxfField;
|
|
}
|
|
}
|
|
|
|
if(!m_idBlock2d || !m_idBlock3d) {
|
|
CopyObject(bakClone, *this);
|
|
return Acad::eInvalidResBuf;
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbMultiViewInsert::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es;
|
|
|
|
es = TDbEntity::dxfOutFields(pFiler);
|
|
assert(es == Acad::eOk);
|
|
|
|
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbMultiViewInsert"));
|
|
assert(es == Acad::eOk);
|
|
|
|
pFiler->writePoint3d(10, m_ptLocation);
|
|
pFiler->writeString(1, (const TCHAR *)GetSymbolName(m_idBlock2d));
|
|
pFiler->writeString(2, (const TCHAR *)GetSymbolName(m_idBlock3d));
|
|
pFiler->writeDouble(40, m_xScale);
|
|
pFiler->writeDouble(41, m_yScale);
|
|
pFiler->writeDouble(42, m_zScale);
|
|
pFiler->writeDouble(50, m_nRotation);
|
|
return es;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_ptLocation.TransformBy(xform);
|
|
AcDbBlockReference insert(m_ptLocation, m_idBlock3d);
|
|
insert.setScaleFactors(AcGeScale3d(m_xScale, m_yScale, m_zScale));
|
|
insert.setRotation(m_nRotation);
|
|
|
|
insert.transformBy(xform);
|
|
m_nRotation=insert.rotation();
|
|
AcGeScale3d scales=insert.scaleFactors();
|
|
m_xScale=scales[0];
|
|
m_yScale=scales[1];
|
|
m_zScale=scales[2];
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
// Overriden functions for edit
|
|
// 定义了6个夹点:
|
|
// 中心点: 用来移动
|
|
// 四个角点: 用来改尺寸
|
|
// 边点: 用来改角度
|
|
Acad::ErrorStatus TDbMultiViewInsert::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
//gripPoints.append(m_ptLocation);
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
gripPoints.append((XPoint &)geom.GetCenter());
|
|
gripPoints.append((XPoint &)geom.GetLowLeft());
|
|
gripPoints.append((XPoint &)geom.GetLowRight());
|
|
gripPoints.append((XPoint &)geom.GetUpRight());
|
|
gripPoints.append((XPoint &)geom.GetUpLeft());
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbMultiViewInsert::subGetOsnapPoints(
|
|
AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
if(GetExplodeMode()==DRAW_3D) {
|
|
int nLen=snapPoints.length();
|
|
while(!snapPoints.isEmpty())
|
|
snapPoints.removeLast();
|
|
snapPoints.append(m_ptLocation);
|
|
} else {
|
|
TDbEntity::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds);
|
|
}
|
|
/*
|
|
int nCount=snapPoints.length();
|
|
switch(osnapMode) {
|
|
case AcDb::kOsModeIns:
|
|
snapPoints.append(m_ptLocation);
|
|
break;
|
|
case AcDb::kOsModeCen:
|
|
//if(IsKeyPressed(VK_CONTROL)) {
|
|
//AcDbBlockReference::getOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint,
|
|
// viewXform, snapPoints, geomIds);
|
|
//} else
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((XPoint &)geom.GetCenter());
|
|
}
|
|
break;
|
|
case AcDb::kOsModeNode: {
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((XPoint &)geom.GetCenter());
|
|
snapPoints.append((XPoint &)geom.GetLowLeft());
|
|
snapPoints.append((XPoint &)geom.GetLowRight());
|
|
snapPoints.append((XPoint &)geom.GetUpRight());
|
|
snapPoints.append((XPoint &)geom.GetUpLeft());
|
|
}
|
|
break;
|
|
case AcDb::kOsModeQuad: {
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
snapPoints.append((XPoint &)geom.GetLowLeft());
|
|
snapPoints.append((XPoint &)geom.GetLowRight());
|
|
snapPoints.append((XPoint &)geom.GetUpRight());
|
|
snapPoints.append((XPoint &)geom.GetUpLeft());
|
|
}
|
|
break;
|
|
default: {
|
|
//if(IsKeyPressed(VK_CONTROL)) {
|
|
//AcDbBlockReference::getOsnapPoints(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);
|
|
//}
|
|
}
|
|
}
|
|
*/
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
stretchPoints.append(m_ptLocation);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
// 取得夹点说明
|
|
Acad::ErrorStatus TDbMultiViewInsert::GetGripText(int i, CString &cs) const
|
|
{
|
|
//cs=_T("移动");
|
|
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 TDbMultiViewInsert::subMoveGripPointsAt(
|
|
const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
XPoint &vtOffset=*(XPoint *)&offset;
|
|
//m_ptLocation += vtOffset;
|
|
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
assertWriteEnabled();
|
|
|
|
BOOL bCtrlPressed=GetCtrlToggle(); //IsKeyPressed(VK_CONTROL);
|
|
|
|
AcDbObjectId objId=objectId();
|
|
XPoint 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(XPoint(), vtOffset);
|
|
geom.m_nRotation = nRot;
|
|
}
|
|
break; // stretch begin point
|
|
case 1: // Move LowLeft
|
|
if(bCtrlPressed) {
|
|
geom.m_ptCen += vtOffset;
|
|
} else {
|
|
XPoint ptLowLeft=geom.GetLowLeft();
|
|
XPoint ptUpRight=geom.GetUpRight();
|
|
ptFix=ptUpRight;
|
|
ptLowLeft += vtOffset;
|
|
ptLowLeft.z = ptUpRight.z;
|
|
XLine ln(ptUpRight, geom.m_nRotation);
|
|
XPoint 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 {
|
|
XPoint ptLowRight=geom.GetLowRight();
|
|
XPoint ptUpLeft=geom.GetUpLeft();
|
|
ptFix = ptUpLeft;
|
|
ptLowRight += vtOffset;
|
|
ptLowRight.z = ptUpLeft.z;
|
|
XLine ln(ptUpLeft, geom.m_nRotation);
|
|
XPoint 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 {
|
|
XPoint ptUpRight=geom.GetUpRight();
|
|
XPoint ptLowLeft=geom.GetLowLeft();
|
|
ptFix = ptLowLeft;
|
|
ptUpRight += vtOffset;
|
|
ptUpRight.z = ptLowLeft.z;
|
|
XLine ln(ptLowLeft, geom.m_nRotation);
|
|
XPoint 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 {
|
|
XPoint ptUpLeft=geom.GetUpLeft();
|
|
XPoint ptLowRight=geom.GetLowRight();
|
|
ptFix=ptLowRight;
|
|
ptUpLeft += vtOffset;
|
|
ptUpLeft.z = ptUpLeft.z;
|
|
XLine ln(ptLowRight, geom.m_nRotation);
|
|
XPoint 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::ErrorStatus
|
|
TDbMultiViewInsert::subMoveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(offset);
|
|
return transformBy(mat);
|
|
//return moveGripPointsAt(indices, offset);
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
|
{
|
|
return DrawOneView(dc, FALSE);
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
|
{
|
|
return DrawOneView(dc, TRUE);
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::DrawOneView(XExplodeDraw &dc, BOOL bDraw3d) const
|
|
{
|
|
// extern BOOL g_bMakeBlock;
|
|
extern double g_nAcadVer;
|
|
|
|
XPoint ptInsert=m_ptLocation;
|
|
if(!bDraw3d)
|
|
ptInsert.z=0;
|
|
|
|
BOOL bMakeBlock=g_bMakeBlock;
|
|
if(_tcsicmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0) {
|
|
//modified by whl on 0706524,解决在三维视图下崩溃问题
|
|
//bMakeBlock=(g_nAcadVer>15.0001);
|
|
bMakeBlock=FALSE;
|
|
}
|
|
dc<<XBlockRef(bDraw3d? m_idBlock3d : m_idBlock2d,ptInsert, AcGeScale3d(m_xScale, m_yScale, m_zScale),
|
|
m_nRotation, bMakeBlock);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
//交点捕捉函数
|
|
Acad::ErrorStatus
|
|
TDbMultiViewInsert::subIntersectWith(const AcDbEntity* ent,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
if(GetExplodeMode()==DRAW_3D) {
|
|
int nLen=points.length();
|
|
while(!points.isEmpty())
|
|
points.removeLast();
|
|
points.append(m_ptLocation);
|
|
} else {
|
|
TDbEntity::subIntersectWith(ent, intType, points, thisGsMarker, otherGsMarker);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TDbMultiViewInsert::GetTips(DList<TObjInfoUnit> &lstInfo) const
|
|
{
|
|
TBlockGeomInfo geom=GetGeomInfo();
|
|
|
|
|
|
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("多视图块")));
|
|
//lstInfo.Append(new TObjInfoUnit(_T("插入点"), Point2d2Str(m_ptLocation)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("中心点"), Point2d2Str(geom.m_ptCen)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("转角"), XString(_T("%d"), AS_INT(m_nRotation*180/PI))));
|
|
lstInfo.Append(new TObjInfoUnit(_T("比例X"), Dist2Str(m_xScale)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("比例Y"), Dist2Str(m_yScale)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("比例Z"), Dist2Str(m_zScale)));
|
|
|
|
lstInfo.Append(new TObjInfoUnit(_T("长度X"), Dist2Str(geom.m_nSizeX)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("宽度Y"), Dist2Str(geom.m_nSizeY)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("高度Z"), Dist2Str(geom.m_nSizeZ)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("二维图块"), GetSymbolName(m_idBlock2d)));
|
|
lstInfo.Append(new TObjInfoUnit(_T("三维图块"), GetSymbolName(m_idBlock3d)));
|
|
}
|
|
|
|
AcDbBlockReference *
|
|
TDbMultiViewInsert::NewBlock(BOOL b3D) const
|
|
{
|
|
XPoint ptInsert=m_ptLocation;
|
|
if(!b3D)
|
|
ptInsert.z=0.0;
|
|
AcDbBlockReference *pInsert=new AcDbBlockReference(ptInsert, GetBlockId(b3D));
|
|
pInsert->setPropertiesFrom(this);
|
|
pInsert->setScaleFactors(GetScaleFactors());
|
|
pInsert->setRotation(GetRotation());
|
|
return pInsert;
|
|
}
|
|
|
|
|
|
TBlockGeomInfo
|
|
TDbMultiViewInsert::GetGeomInfo() const
|
|
{
|
|
AcDbBlockReference *pBlock=NewBlock(TRUE);
|
|
ASSERT(pBlock);
|
|
TBlockGeomInfo geom;
|
|
geom.SetFromInsert(pBlock);
|
|
delete pBlock;
|
|
return geom;
|
|
}
|
|
|
|
//修改相应的Insert
|
|
Acad::ErrorStatus TDbMultiViewInsert::UpdateFrom(const TBlockGeomInfo &geom)
|
|
{
|
|
assertWriteEnabled();
|
|
AcDbBlockReference *pBlock=NewBlock(TRUE);
|
|
ASSERT(pBlock);
|
|
|
|
XPoint ptNewBase;
|
|
double nNewRot;
|
|
AcGeScale3d scale;
|
|
if(geom.CalInsertParameters(pBlock, ptNewBase, &nNewRot, &scale[0], &scale[1], &scale[2])!=Acad::eOk) {
|
|
// the block is just opened for notify
|
|
delete pBlock;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
SetLocation(ptNewBase);
|
|
SetRotation(nNewRot);
|
|
SetScaleFactors(scale);
|
|
delete pBlock;
|
|
return Acad::eOk;
|
|
}
|