998 lines
27 KiB
C++
998 lines
27 KiB
C++
#include "StdAfx.h"
|
|
|
|
#include "SectionStructDef.h"
|
|
#include "SectionUtility.h"
|
|
#include "TDbSectionPathSign.h"
|
|
#include "TDbSection.h"
|
|
|
|
int nData[4] = {1, 2, 3, 4};
|
|
|
|
// TDbSectionPathSign
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSSectionPathSign, ATSCurveEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_SECTIONPATHSIGN, "ATS_SECTIONPATHSIGN图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbSectionPathSign);
|
|
|
|
TDbSectionPathSign::TDbSectionPathSign( const AcGePoint3d &ptStart, const AcGePoint3d &ptEnd,
|
|
const AcGeVector3d &vtDir, const double &length, const CString sNum, const bool bShowSlid/* = true*/)
|
|
: m_ptStart(ptStart), m_ptEnd(ptEnd), m_vtDirection(vtDir), m_arIdsOnSection(0),
|
|
m_dDirLength(length), m_style(kStyle1), m_bShowSide(bShowSlid), m_sSectionNum(sNum)
|
|
{
|
|
//CalcSectionHeight();
|
|
InitSectionSidePoints();
|
|
}
|
|
|
|
void TDbSectionPathSign::SetIdOnSection( TPickEntSet &ssSel )
|
|
{
|
|
m_arIdsOnSection.clear();
|
|
for (long i = 0; i < ssSel.Length(); ++i)
|
|
{
|
|
AcDbObjectId idEnt;
|
|
if (acdbGetObjectId(idEnt, ssSel[i]) != Acad::eOk)
|
|
continue;
|
|
m_arIdsOnSection.push_back(idEnt);
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::dwgInFields( AcDbDwgFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgInFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 0;
|
|
pFiler->readInt32(&nVer); // read version
|
|
|
|
if (nVer >= 1)
|
|
{
|
|
pFiler->readItem(&m_ptStart);
|
|
pFiler->readItem(&m_ptEnd);
|
|
pFiler->readItem(&m_vtDirection);
|
|
pFiler->readDouble(&m_dDirLength);
|
|
pFiler->readItem((int*)&m_style);
|
|
pFiler->readItem(&m_ptStartSide);
|
|
pFiler->readItem(&m_ptEndSide);
|
|
XString str;
|
|
ReadString(pFiler, str);
|
|
m_sSectionNum = CString(str);
|
|
|
|
m_arRegisterIds.clear();
|
|
Adesk::Int32 nCount = 0;
|
|
pFiler->readInt32(&nCount);
|
|
for (int i = 0; i < nCount; ++i)
|
|
{
|
|
AcDbSoftPointerId id;
|
|
pFiler->readSoftPointerId(&id);
|
|
m_arRegisterIds.push_back(id);
|
|
}
|
|
}
|
|
|
|
m_bShowSide = false;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::dwgOutFields( AcDbDwgFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 1;
|
|
pFiler->writeInt32(nVer); // write version
|
|
|
|
pFiler->writeItem(m_ptStart);
|
|
pFiler->writeItem(m_ptEnd);
|
|
pFiler->writeItem(m_vtDirection);
|
|
pFiler->writeDouble(m_dDirLength);
|
|
pFiler->writeItem((int)m_style);
|
|
pFiler->writeItem(m_ptStartSide);
|
|
pFiler->writeItem(m_ptEndSide);
|
|
pFiler->writeItem((LPCTSTR)m_sSectionNum);
|
|
|
|
pFiler->writeInt32((Adesk::Int32)(m_arRegisterIds.size()));
|
|
for (std::list<AcDbSoftPointerId>::const_iterator iter = m_arRegisterIds.begin();
|
|
iter != m_arRegisterIds.end(); ++iter)
|
|
{
|
|
pFiler->writeSoftPointerId(*iter);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::dxfInFields( AcDbDxfFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (TDbCurveEntity::dxfInFields(pFiler) != Acad::eOk || !pFiler->atSubclassData(_T("TDbSectionPathSign")))
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::dxfOutFields( AcDbDxfFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dxfOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
if ((es = pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbSectionPathSign"))) != Acad::eOk)
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::ExplodeOrDraw3d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
DrawSectionPathType(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
DrawSectionPathType(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subTransformBy( const AcGeMatrix3d& xform )
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
do
|
|
{
|
|
if ((es = TDbCurveEntity::subTransformBy(xform)) != Acad::eOk)
|
|
break;
|
|
m_ptStart.transformBy(xform);
|
|
m_ptEnd.transformBy(xform);
|
|
m_vtDirection.transformBy(xform);
|
|
m_ptStartSide.transformBy(xform);
|
|
m_ptEndSide.transformBy(xform);
|
|
} while (false);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subGetGripPoints( AcGePoint3dArray&gripPoints,AcDbIntArray&,AcDbIntArray& ) const
|
|
{
|
|
AcGeVector3d vec = m_vtDirection;
|
|
vec.normalize();
|
|
/*0*/gripPoints.append(AcGePoint3d((m_ptStart.x + m_ptEnd.x)*.5, (m_ptStart.y + m_ptEnd.y)*.5, (m_ptStart.z + m_ptEnd.z)*.5));
|
|
/*1*/gripPoints.append(m_ptStart);
|
|
if (m_bShowSide)
|
|
{
|
|
/*2*/gripPoints.append(AcGePoint3d((m_ptStartSide.x + m_ptEndSide.x)*.5, (m_ptStartSide.y + m_ptEndSide.y)*.5, (m_ptStartSide.z + m_ptEndSide.z)*.5));
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
|
{
|
|
assertWriteEnabled();
|
|
for (int i = 0; i < indices.length(); ++i)
|
|
{
|
|
int mode = indices[i];
|
|
if (mode == 0) // 中心 全体移动
|
|
{
|
|
subTransformBy(offset);
|
|
}
|
|
else if (mode == 2) // 横向改变宽度
|
|
{
|
|
AcGeVector3d vec = m_vtDirection * offset.length();
|
|
if (offset.dotProduct(m_vtDirection) < 0) // 异向
|
|
{
|
|
vec *= -1;
|
|
AcGePoint3d pt = m_ptStartSide + vec;
|
|
AcGeVector3d vDir = pt - m_ptStart;
|
|
if (vDir.dotProduct(m_vtDirection) < 0)
|
|
m_vtDirection *= -1;
|
|
}
|
|
m_ptStartSide += vec;
|
|
m_ptEndSide += vec;
|
|
m_dDirLength = m_ptStart.distanceTo(m_ptStartSide) *.2;
|
|
}
|
|
else if (mode == 1) // 纵向改变长度
|
|
{
|
|
AcGeVector3d vec = m_ptEnd - m_ptStart;
|
|
vec.normalize();
|
|
vec *= offset.length();
|
|
if (offset.dotProduct(vec) < 0)
|
|
vec *= -1;
|
|
m_ptStart += vec;
|
|
m_ptStartSide += vec;
|
|
}
|
|
}
|
|
UpdateSection(); // 更新自身数据,并通知TDbSection类也一起更新
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType,
|
|
AcGePoint3dArray &points, INT_PTR thisGsMarker /*= 0*/,
|
|
INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
AcDbLine line(m_ptStart, m_ptEnd);
|
|
line.intersectWith(ent, intType, points);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType,
|
|
const AcGePlane &projPlane, AcGePoint3dArray &points,
|
|
INT_PTR thisGsMarker /*= 0*/, INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
AcDbLine line(m_ptStart, m_ptEnd);
|
|
line.intersectWith(ent, intType, projPlane, points);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbSectionPathSign::UpdateSection()
|
|
{
|
|
SectionInfo info;
|
|
if (!GetSectionInfo(info, true))
|
|
return;
|
|
|
|
std::list<AcDbSoftPointerId>::const_iterator iter = m_arRegisterIds.begin();
|
|
for (;iter != m_arRegisterIds.end(); ++iter)
|
|
{
|
|
AcDbEntity *pEnt = NULL;
|
|
Acad::ErrorStatus stat = acdbOpenObject(pEnt, *iter, AcDb::kForWrite);
|
|
|
|
if (pEnt)
|
|
{
|
|
TDbSection *pSection = TDbSection::cast(pEnt);
|
|
if (pSection)
|
|
{
|
|
pSection->UpdateSection(info);
|
|
pSection->recordGraphicsModified();
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbSectionPathSign::CalcSectionHeight()
|
|
{
|
|
// 此函数主要目的是根据各个实体高度算出投影面的最大高度
|
|
// 现如今已把投影面改为 高 300M 低-100M 的面,对建筑来说已经算是无限的投影面了
|
|
// 故废弃不用
|
|
return;
|
|
AcDbExtents ext;
|
|
TADSGePoint3d ptUp, ptLow;
|
|
for (size_t i = 0; i < m_arIdsOnSection.size(); ++i)
|
|
{
|
|
AcDbEntity * pEnt;
|
|
|
|
acdbOpenObject(pEnt, m_arIdsOnSection[i], AcDb::kForRead);
|
|
if (pEnt)
|
|
{
|
|
TDbEntity *pTDbEnt = TDbEntity::cast(pEnt);
|
|
TDbCurveEntity *pTDbCurv = TDbCurveEntity::cast(pEnt);
|
|
|
|
if (pTDbEnt)
|
|
pTDbEnt->GetExtents(ptLow, ptUp);
|
|
if (pTDbCurv)
|
|
pTDbCurv->GetExtents(ptLow, ptUp);
|
|
pEnt->close();
|
|
ext.addPoint(ptUp.AsAcGePoint3d());
|
|
ext.addPoint(ptLow.AsAcGePoint3d());
|
|
}
|
|
}
|
|
m_SectionHeight.x = ext.maxPoint().z;
|
|
m_SectionHeight.y = ext.minPoint().z;
|
|
}
|
|
|
|
TGGeSectionPlane TDbSectionPathSign::GetSectionPlane()
|
|
{
|
|
// 投影面最高 300M 低 -100M
|
|
double dHeight = 300 * 1000;
|
|
AcGePoint3d pt1(m_ptStart), pt2(m_ptEnd), pt3(m_ptEnd), pt4(m_ptStart);
|
|
pt4.z = pt3.z = 300 * 1000;
|
|
pt1.z = pt2.z = -100 * 1000;
|
|
return TGGeSectionPlane(pt1, pt2, pt3, pt4, AcGeVector3d::kXAxis);
|
|
}
|
|
|
|
void TDbSectionPathSign::RegisterSection( const AcDbObjectId &id )
|
|
{
|
|
m_arRegisterIds.remove(id);
|
|
m_arRegisterIds.push_back(id);
|
|
}
|
|
|
|
void TDbSectionPathSign::UnRegisterSection( const AcDbObjectId &id )
|
|
{
|
|
m_arRegisterIds.remove(id);
|
|
}
|
|
|
|
bool TDbSectionPathSign::GetSectionInfo(SectionInfo &info, const bool bUpdate /*= false*/ )
|
|
{
|
|
if (bUpdate)
|
|
{
|
|
resbuf *rbPoints = acutBuildList(RTPOINT, &m_ptStart, RTPOINT, &m_ptStartSide,
|
|
RTPOINT, &m_ptEndSide, RTPOINT, &m_ptEnd, RTNONE);
|
|
TPickEntSet ssSel(SS_FREE);
|
|
CString strSel(_T("ATS_CORNER_WINDOW,ATS_COLUMN,ATS_OPENING,ATS_TRENCH,3DFACE,ATS_TESTSECTIONPLANE,ATS_TESTSECTIONLINE,ATS_WALL,ATS_PIPE,ATS_PIPEVALVE,ATS_DBHVACDUCT,ATS_DBHEQUIPMENT,ATS_DBHFITTING,ATS_RADIATOR,ATS_CABLETRY,ATS_EEQUIPMENT,ATS_EFITTING,ATS_EQUIPMENT,ATS_DOUBLELINEPIPE,ATS_FLANGE,ATS_PUMP,ATS_PIPEFITTING,ATS_VPIPEDIM,ATS_DBHEQUIPMENT,ATS_RADIATOR"));
|
|
resbuf *rbFilter = acutBuildList(RTDXF0, strSel, RTNONE);
|
|
acedSSGet(_T("CP"), rbPoints, NULL, rbFilter, ssSel);
|
|
acutRelRb(rbFilter);
|
|
acutRelRb(rbPoints);
|
|
|
|
if (!ssSel.Length())
|
|
return false;
|
|
|
|
SetIdOnSection(ssSel);
|
|
}
|
|
|
|
info.m_SectionFace = GetSectionPlane();
|
|
info.m_arObjID = m_arIdsOnSection;
|
|
info.m_Height = m_SectionHeight;
|
|
info.m_vecDir = m_vtDirection;
|
|
info.m_ptS = m_ptStart;
|
|
info.m_ptE = m_ptEnd;
|
|
info.m_sName = m_sSectionNum;
|
|
|
|
return true;
|
|
}
|
|
|
|
void TDbSectionPathSign::erased( const AcDbObject* dbObj, Adesk::Boolean pErasing /*= true*/ )
|
|
{
|
|
if (pErasing)
|
|
UnRegisterSection(dbObj->objectId());
|
|
else
|
|
RegisterSection(dbObj->objectId());
|
|
}
|
|
|
|
void TDbSectionPathSign::DrawSectionPathType(TGGiExplodeDrawBase &dc) const
|
|
{
|
|
double tempLineWidth = LINE_WIDTH * GetPScale();
|
|
|
|
TDbSectionPathSign::Style style = GetStyle();
|
|
AcGePoint3d ptS = GetStartPt(), ptE = GetEndPt();
|
|
AcGeVector3d vt = GetDirection();
|
|
double dDirLength = GetDirLength();
|
|
|
|
if (style == TDbSectionPathSign::kStyle1)
|
|
{
|
|
AcGeVector3d vec1 = -m_vtDirection;
|
|
AcGeVector3d vec2 = m_ptEnd - m_ptStart;
|
|
|
|
vec1.normalize();
|
|
vec2.normalize();
|
|
vec1 *= m_dDirLength;
|
|
vec2 *= m_dDirLength * 1.2;
|
|
|
|
AcDbPolyline polyL1, polyL2;
|
|
polyL1.addVertexAt(0, PT3DTOPT2D((ptS -vec1)));
|
|
polyL1.addVertexAt(1, PT3DTOPT2D(ptS));
|
|
polyL1.addVertexAt(2, PT3DTOPT2D((ptS + vec2)));
|
|
polyL1.setColorIndex(7);
|
|
polyL1.setConstantWidth(tempLineWidth);
|
|
dc.Polyline(polyL1);
|
|
polyL2.addVertexAt(0, PT3DTOPT2D((ptE - vec1)));
|
|
polyL2.addVertexAt(1, PT3DTOPT2D(ptE));
|
|
polyL2.addVertexAt(2, PT3DTOPT2D((ptE - vec2)));
|
|
polyL2.setColorIndex(7);
|
|
polyL2.setConstantWidth(tempLineWidth);
|
|
dc.Polyline(polyL2);
|
|
|
|
TDbText text;
|
|
text.setPropertiesFrom(this);
|
|
text.SetAlignment(XExplodeDraw::kMiddleCenter);
|
|
text.SetText(m_sSectionNum);
|
|
// sg modify 120106,给“TS_SECTION”独立出来一个文字样式
|
|
// text.SetStyleId(InitTextStyle(TS_LABEL));
|
|
text.SetStyleId(InitTextStyle(TS_SECTION));
|
|
text.SetHeight(WORD_HEIGHT);
|
|
double width, height;
|
|
text.GetExtents(&width, &height);
|
|
text.SetLocation((ptS -vec1) + vt * height * 1);
|
|
text.setColorIndex(7);
|
|
if(dc.IsFullExplode())
|
|
text.ExplodeOrDraw2d(dc);
|
|
else
|
|
dc.DrawEntity(text);
|
|
text.SetLocation((ptE -vec1) + vt * height * 1);
|
|
if(dc.IsFullExplode())
|
|
text.ExplodeOrDraw2d(dc);
|
|
else
|
|
dc.DrawEntity(text);
|
|
|
|
if (m_bShowSide)
|
|
{
|
|
AcDbPolyline polyLine1, polyLine2;
|
|
polyLine1.addVertexAt(0, PT3DTOPT2D((m_ptStartSide + vec1)));
|
|
polyLine1.addVertexAt(1, PT3DTOPT2D(m_ptStartSide));
|
|
polyLine1.addVertexAt(2, PT3DTOPT2D((m_ptStartSide + vec2)));
|
|
polyLine1.setConstantWidth(tempLineWidth);
|
|
polyLine1.setColorIndex(7);
|
|
dc.Polyline(polyLine1);
|
|
|
|
polyLine2.addVertexAt(0, PT3DTOPT2D((m_ptEndSide + vec1)));
|
|
polyLine2.addVertexAt(1, PT3DTOPT2D(m_ptEndSide));
|
|
polyLine2.addVertexAt(2, PT3DTOPT2D((m_ptEndSide - vec2)));
|
|
polyLine2.setConstantWidth(tempLineWidth);
|
|
polyLine2.setColorIndex(7);
|
|
dc.Polyline(polyLine2);
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbSectionPathSign::InitSectionSidePoints()
|
|
{
|
|
AcGeVector3d vec = m_vtDirection;
|
|
vec.normalize();
|
|
vec *= (5 * m_dDirLength);
|
|
m_ptStartSide = m_ptStart + vec;
|
|
m_ptEndSide = m_ptEnd + vec;
|
|
}
|
|
|
|
void TDbSectionPathSign::SetShowSide( const bool bShow )
|
|
{
|
|
m_bShowSide = bShow;
|
|
recordGraphicsModified();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::subDeepClone( AcDbObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary ) const
|
|
{
|
|
// 如果不想令这个函数起作用,则应令pClonedObject为NULL
|
|
// 在此处为空的目的是为了安全起见.
|
|
pClonedObject = NULL;
|
|
|
|
// 如果这个对象已经在 idMap内且已经clone了,退出
|
|
bool isPrim = false;
|
|
if (isPrimary)
|
|
isPrim = true;
|
|
|
|
AcDbIdPair idPair(objectId(), (AcDbObjectId)NULL, false, isPrim);
|
|
|
|
if (idMap.compute(idPair) && (idPair.value() != NULL))
|
|
return Acad::eOk;
|
|
|
|
// step1 : 新建一个clone
|
|
TDbSectionPathSign *pClone = (TDbSectionPathSign*)isA()->create();
|
|
|
|
if (pClone != NULL)
|
|
pClonedObject = pClone; // 设置返回值.
|
|
else
|
|
return Acad::eOutOfMemory;
|
|
|
|
// step2 : 为clone对象添加一个所有者.在这个例子里,
|
|
// 原始对象是继承自TDbCurveEntity类的子类.
|
|
// 所以,所有权应该是AcDbBlockTableRecord.
|
|
// 除非,此对象已经与另一个对象建立了所有权关系.
|
|
// 在这个例子里,建立一个与所有者的连接是非常重要的.
|
|
// 这个例子演示了一个通用的方法来实现以上的目的 setOwnerId().
|
|
|
|
AcDbBlockTableRecord *pBTR = AcDbBlockTableRecord::cast(pOwner);
|
|
if (pBTR != NULL)
|
|
{
|
|
pBTR->appendAcDbEntity(pClone);
|
|
}
|
|
else
|
|
{
|
|
if (isPrimary)
|
|
return Acad::eInvalidOwnerObject;
|
|
|
|
pOwner->database()->addAcDbObject(pClone);
|
|
pClone->setOwnerId(pOwner->objectId());
|
|
}
|
|
|
|
// Step 3: 现在把被拷贝对象的内容添充到clone对象内
|
|
// 在这里使用AcDbDeepCloneFiler. 这个 filer 保存了
|
|
// 这个对象及其基类内的所有的 AcDbHardOwnershipIds and
|
|
// AcDbSoftOwnershipIds的清单,此清单记录了"拥有者"需要
|
|
// 被clone的额外信息
|
|
|
|
AcDbDeepCloneFiler filer;
|
|
dwgOut(&filer);
|
|
|
|
// Step 4: 将 filer 内的数据存入clone对象
|
|
|
|
filer.seek(0L, AcDb::kSeekFromStart);
|
|
pClone->dwgIn(&filer);
|
|
|
|
// Step 5: 下面的函数必须被deepclone()内生成的对象调用,
|
|
// 它被 enddeepClone()关闭后,它会转换这些新值的参考
|
|
|
|
pClone->setAcDbObjectIdsInFlux();
|
|
|
|
// Step 6: 在 ID map 内添加新信息
|
|
|
|
idPair.setValue(pClonedObject->objectId());
|
|
idPair.setIsCloned(Adesk::kTrue);
|
|
idMap.assign(idPair);
|
|
|
|
// Step 7: 使用 filer 清单 对其它的拥有对象进行Clone
|
|
|
|
AcDbObjectId id;
|
|
|
|
while (filer.getNextOwnedObject(id)) {
|
|
AcDbObject *pSubObject;
|
|
AcDbObject *pClonedSubObject;
|
|
|
|
if (id == NULL)
|
|
continue;
|
|
|
|
acdbOpenAcDbObject(pSubObject, id, AcDb::kForRead);
|
|
pClonedSubObject = NULL;
|
|
pSubObject->deepClone(pClonedObject, pClonedSubObject, idMap, Adesk::kFalse);
|
|
|
|
if (pSubObject != pClonedSubObject)
|
|
pSubObject->close();
|
|
|
|
if (pClonedSubObject != NULL)
|
|
pClonedSubObject->close();
|
|
}
|
|
// 这才是我要干的事儿
|
|
pClone->m_arRegisterIds.clear();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbSectionPathSign::GetGripText( int i, CString &cs ) const
|
|
{
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
switch(i)
|
|
{
|
|
case 0:
|
|
cs = _T("移动剖切线");
|
|
break;
|
|
case 1:
|
|
cs = _T("改变剖切线长度");
|
|
break;
|
|
case 2:
|
|
cs = _T("改变剖切线宽度");
|
|
break;
|
|
default:
|
|
es = Acad::eInvalidInput;
|
|
}
|
|
|
|
return es;
|
|
}
|
|
|
|
// CCTestSectionPlane
|
|
ACRX_DXF_DEFINE_MEMBERS(CCTestSectionPlane, ATSCurveEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_TESTSECTIONPLANE, "ATS_TESTSECTIONPLANE图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(CCTestSectionPlane);
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::dwgInFields( AcDbDwgFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgInFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 0;
|
|
pFiler->readInt32(&nVer); // read version
|
|
|
|
if (nVer >= 1)
|
|
{
|
|
pFiler->readItem(&m_pt0);
|
|
pFiler->readItem(&m_pt1);
|
|
pFiler->readItem(&m_pt2);
|
|
pFiler->readItem(&m_pt3);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::dwgOutFields( AcDbDwgFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 1;
|
|
pFiler->writeInt32(nVer); // write version
|
|
|
|
pFiler->writeItem(m_pt0);
|
|
pFiler->writeItem(m_pt1);
|
|
pFiler->writeItem(m_pt2);
|
|
pFiler->writeItem(m_pt3);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::dxfInFields( AcDbDxfFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (TDbCurveEntity::dxfInFields(pFiler) != Acad::eOk || !pFiler->atSubclassData(_T("CCTestSectionPlane")))
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::dxfOutFields( AcDbDxfFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dxfOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
if ((es = pFiler->writeItem(AcDb::kDxfSubclass, _T("CCTestSectionPlane"))) != Acad::eOk)
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::ExplodeOrDraw3d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
std::vector<AcGePoint3d> arPt(4, AcGePoint3d(0., 0., 0.));
|
|
arPt[0] = m_pt0;
|
|
arPt[1] = m_pt1;
|
|
arPt[2] = m_pt3;
|
|
arPt[3] = m_pt2;
|
|
dc.DrawMesh(2, 2, &arPt[0]);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
TGGeLine line1(asDblArray(m_pt0), asDblArray(m_pt1), LS_FINITE),
|
|
line2(asDblArray(m_pt1), asDblArray(m_pt2), LS_FINITE),
|
|
line3(asDblArray(m_pt2), asDblArray(m_pt3), LS_FINITE),
|
|
line4(asDblArray(m_pt3), asDblArray(m_pt0), LS_FINITE);
|
|
dc.SetSelectionMarker(1);
|
|
dc.DrawLine(line1);
|
|
dc.SetSelectionMarker(2);
|
|
dc.DrawLine(line2);
|
|
dc.SetSelectionMarker(3);
|
|
dc.DrawLine(line3);
|
|
dc.SetSelectionMarker(4);
|
|
dc.DrawLine(line4);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subTransformBy( const AcGeMatrix3d& xform )
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
do
|
|
{
|
|
if ((es = TDbCurveEntity::subTransformBy(xform)) != Acad::eOk)
|
|
break;
|
|
m_pt0.transformBy(xform);
|
|
m_pt1.transformBy(xform);
|
|
m_pt2.transformBy(xform);
|
|
m_pt3.transformBy(xform);
|
|
} while (false);
|
|
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subGetGripPoints( AcGePoint3dArray&gripPoints,AcDbIntArray&,AcDbIntArray& ) const
|
|
{
|
|
gripPoints.append(m_pt0);
|
|
gripPoints.append(m_pt1);
|
|
gripPoints.append(m_pt2);
|
|
gripPoints.append(m_pt3);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
|
{
|
|
assertWriteEnabled();
|
|
subTransformBy(offset);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType, AcGePoint3dArray &points, INT_PTR thisGsMarker /*= 0*/, INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType, const AcGePlane &projPlane, AcGePoint3dArray &points, INT_PTR thisGsMarker /*= 0*/, INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGePoint3d CCTestSectionPlane::Get( const int i )
|
|
{
|
|
if (i == 0)
|
|
return m_pt0;
|
|
|
|
if (i == 1)
|
|
return m_pt1;
|
|
|
|
if (i == 2)
|
|
return m_pt2;
|
|
|
|
if (i == 3)
|
|
return m_pt3;
|
|
|
|
return m_pt0;
|
|
}
|
|
|
|
bool CCTestSectionPlane::GetSection( const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir, std::vector<TObjSectionRecord> §ionRecords, AcDbVoidPtrArray& arFillPtrs ) const
|
|
{
|
|
TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个剖面
|
|
TObjSectionRecord record;
|
|
TGGePoly2D poly;
|
|
TGGeSectionPlane pln(m_pt0, m_pt1, m_pt2, m_pt3, vtPlaneSecDir);
|
|
double dElevation = SectionUtility::Projection_plane2plane(section_pln, pln, poly);
|
|
sectionRecords.push_back(TObjSectionRecord(objectId(), layerId(), TObjSectionRecord::e3DFACE, dElevation, poly));
|
|
// 添充功能待定
|
|
return true;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::subGetGeomExtents( AcDbExtents& extents ) const
|
|
{
|
|
extents.addPoint(m_pt0);
|
|
extents.addPoint(m_pt1);
|
|
extents.addPoint(m_pt2);
|
|
extents.addPoint(m_pt3);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionPlane::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
|
{
|
|
AcDbExtents extents;
|
|
extents.addPoint(m_pt0);
|
|
extents.addPoint(m_pt1);
|
|
extents.addPoint(m_pt2);
|
|
extents.addPoint(m_pt3);
|
|
ptLow = TADSGePoint3d(extents.minPoint());
|
|
ptUp = TADSGePoint3d(extents.maxPoint());
|
|
return Acad::eOk;
|
|
}
|
|
void InitDbSection(BOOL bTrue)
|
|
{
|
|
if (bTrue)
|
|
{
|
|
TDbSectionPathSign::rxInit();
|
|
TDbSection::rxInit();
|
|
CCTestSectionPlane::rxInit();
|
|
CCTestSectionLine::rxInit();
|
|
acrxBuildClassHierarchy();
|
|
}
|
|
else
|
|
{
|
|
deleteAcRxClass(TDbSectionPathSign::desc());
|
|
deleteAcRxClass(TDbSection::desc());
|
|
deleteAcRxClass(CCTestSectionPlane::desc());
|
|
deleteAcRxClass(CCTestSectionLine::desc());
|
|
}
|
|
}
|
|
|
|
// CCTestSectionLine
|
|
ACRX_DXF_DEFINE_MEMBERS(CCTestSectionLine, ATSCurveEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
1, ATS_TESTSECTIONLINE, "ATS_TESTSECTIONLINE图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(CCTestSectionLine);
|
|
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::dwgInFields( AcDbDwgFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgInFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 0;
|
|
pFiler->readInt32(&nVer); // read version
|
|
|
|
if (nVer >= 1)
|
|
{
|
|
pFiler->readItem(&m_ptStart);
|
|
pFiler->readItem(&m_ptEnd);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::dwgOutFields( AcDbDwgFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dwgOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
Adesk::Int32 nVer = 1;
|
|
pFiler->writeInt32(nVer); // write version
|
|
|
|
pFiler->writeItem(m_ptStart);
|
|
pFiler->writeItem(m_ptEnd);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::dxfInFields( AcDbDxfFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (TDbCurveEntity::dxfInFields(pFiler) != Acad::eOk || !pFiler->atSubclassData(_T("CCTestSectionLine")))
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::dxfOutFields( AcDbDxfFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
if ((es = TDbCurveEntity::dxfOutFields(pFiler)) != Acad::eOk)
|
|
return es;
|
|
|
|
if ((es = pFiler->writeItem(AcDb::kDxfSubclass, _T("CCTestSectionLine"))) != Acad::eOk)
|
|
return pFiler->filerStatus();
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subTransformBy( const AcGeMatrix3d& xform )
|
|
{
|
|
m_ptStart.transformBy(xform);
|
|
m_ptEnd.transformBy(xform);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subGetGripPoints( AcGePoint3dArray&gripPoints,AcDbIntArray&,AcDbIntArray& ) const
|
|
{
|
|
gripPoints.append(m_ptStart);
|
|
gripPoints.append(AcGePoint3d((m_ptStart.x+m_ptEnd.x)/2., (m_ptStart.y+m_ptEnd.y)/2., (m_ptStart.z+m_ptEnd.z)/2.));
|
|
gripPoints.append(m_ptEnd);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
for (int i = 0; i < indices.length(); ++i)
|
|
{
|
|
int mode = indices[i];
|
|
if (mode == 0) // start
|
|
{
|
|
m_ptStart.transformBy(offset);
|
|
}
|
|
else if(mode == 1) // middle
|
|
{
|
|
subTransformBy(offset);
|
|
}
|
|
else if (mode == 2) // end
|
|
{
|
|
m_ptEnd.transformBy(offset);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType, AcGePoint3dArray &points, INT_PTR thisGsMarker /*= 0*/, INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
AcDbLine line(m_ptStart, m_ptEnd);
|
|
line.intersectWith(ent, intType, points);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subIntersectWith( const AcDbEntity *ent, AcDb::Intersect intType, const AcGePlane &projPlane, AcGePoint3dArray &points, INT_PTR thisGsMarker /*= 0*/, INT_PTR otherGsMarker /*= 0*/ ) const
|
|
{
|
|
AcDbLine line(m_ptStart, m_ptEnd);
|
|
line.intersectWith(ent, intType, projPlane, points);
|
|
return Acad::eOk;
|
|
}
|
|
Acad::ErrorStatus CCTestSectionLine::ExplodeOrDraw3d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
ExplodeOrDraw2d(dc);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
dc.DrawLine(TGGeLine(asDblArray(m_ptStart), asDblArray(m_ptEnd), LS_FINITE));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool CCTestSectionLine::GetSection( const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir, std::vector<TObjSectionRecord> §ionRecords, AcDbVoidPtrArray& arFillPtrs ) const
|
|
{
|
|
TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个剖面
|
|
TObjSectionRecord record;
|
|
TGGePoly2D poly;
|
|
|
|
AcGeLineSeg3d seg1(m_ptStart, m_ptEnd);
|
|
AcGeLineSeg3d seg_out;
|
|
AcGePoint3d pt;
|
|
|
|
if (!SectionUtility::Projection_line2plane(section_pln, seg1, seg_out, pt))
|
|
poly.AppendSegment(TGGeCurveSegment(seg_out.startPoint(), seg_out.endPoint(), 0.), false, true);
|
|
|
|
AcGePlane plane = section_pln.AsAcGePlane();
|
|
AcGePoint3d pt1 = m_ptStart.orthoProject(plane);
|
|
AcGePoint3d pt2 = m_ptEnd.orthoProject(plane);
|
|
double dElevation = pt1.distanceTo(m_ptStart);
|
|
double dTmp = pt2.distanceTo(m_ptEnd);
|
|
dElevation = dElevation > dTmp ? dElevation : dTmp;
|
|
sectionRecords.push_back(TObjSectionRecord(objectId(), layerId(), TObjSectionRecord::eTCH_WALL, -dElevation, poly));
|
|
// 添充功能待定
|
|
return true;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::subGetGeomExtents( AcDbExtents& extents ) const
|
|
{
|
|
extents.addPoint(m_ptStart);
|
|
extents.addPoint(m_ptEnd);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus CCTestSectionLine::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
|
{
|
|
AcDbExtents extents;
|
|
extents.addPoint(m_ptStart);
|
|
extents.addPoint(m_ptEnd);
|
|
ptLow = TADSGePoint3d(extents.minPoint());
|
|
ptUp = TADSGePoint3d(extents.maxPoint());
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
TSectionPathJig::TSectionPathJig(TDbSectionPathSign * pPath)
|
|
{
|
|
if (pPath)
|
|
{
|
|
m_pPath = pPath;
|
|
m_vDir = m_pPath->GetDirection();
|
|
m_ptS = m_pPath->GetStartPt();
|
|
m_ptE = m_pPath->GetEndPt();
|
|
}
|
|
}
|
|
|
|
AcDbEntity* TSectionPathJig::entity() const
|
|
{
|
|
return m_pPath;
|
|
}
|
|
|
|
bool TSectionPathJig::start()
|
|
{
|
|
const TCHAR *messBuf = _T("\n请确定投影范围: ");
|
|
setDispPrompt(messBuf);
|
|
|
|
AcEdJig::DragStatus stat = drag();
|
|
if ( kNormal == stat )
|
|
return true;
|
|
else
|
|
return false;
|
|
|
|
return false;
|
|
}
|
|
|
|
AcEdJig::DragStatus TSectionPathJig::sampler()
|
|
{
|
|
static AcGePoint3d ptStatic = AcGePoint3d::kOrigin;
|
|
AcGePoint3d pt1, pt2;
|
|
|
|
DragStatus stat = kNormal;
|
|
stat = acquirePoint(pt1);
|
|
|
|
if (stat == kCancel)
|
|
return stat;
|
|
|
|
if (ptStatic == pt1)
|
|
return kNoChange;
|
|
|
|
ptStatic = pt1;
|
|
|
|
AcGeVector3d vec = pt1 - m_ptS;
|
|
vec.normalize();
|
|
|
|
if (vec.dotProduct(m_vDir) < 0) // 异向
|
|
m_vDir *= -1;
|
|
|
|
AcGeLine3d line(m_ptS, m_ptE);
|
|
pt2 = line.closestPointTo(pt1);
|
|
m_dLength = pt1.distanceTo(pt2) * .2;
|
|
|
|
return kNormal;
|
|
}
|
|
|
|
Adesk::Boolean TSectionPathJig::update()
|
|
{
|
|
m_pPath->SetDirLength(m_dLength);
|
|
m_pPath->SetStartPt(m_ptS);
|
|
m_pPath->SetEndPt(m_ptE);
|
|
m_pPath->SetDirection(m_vDir);
|
|
m_pPath->InitSectionSidePoints();
|
|
m_pPath->recordGraphicsModified();
|
|
return true;
|
|
} |