1104 lines
26 KiB
C++
1104 lines
26 KiB
C++
//------------------------------------------------------------------------+
|
|
// Copyright (C), 1998-2011, Beijing Tangent Software Co. Ltd.
|
|
// = FileName : TDbStruNodePoint类
|
|
// = Version : ver1.0
|
|
// = Author : xlc
|
|
// = CreateDate : 2011-07-20
|
|
// = Description: 结构节点类实现
|
|
// = Maintainers:
|
|
//
|
|
//------------------------------------------------------------------------+
|
|
|
|
#include "stdafx.h"
|
|
#ifdef TASD
|
|
#include "TDbStruNodePoint.h"
|
|
|
|
extern bool g_bShowNode; // 是否显示节点
|
|
extern double g_dNodeDiameter; // 节点直径
|
|
extern Adesk::UInt16 g_iSolidNodeColor; // 实节点颜色
|
|
extern Adesk::UInt16 g_iVirtualNodeColor; // 虚节点颜色
|
|
|
|
const Adesk::UInt8 TDbStruNodePoint::g_nVersion = 1;
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSStruNodePoint, ATSStruEntityBase, AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_STRUNODEPOINT,
|
|
"ATS_STRUNODEPOINT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbStruNodePoint);
|
|
|
|
TDbStruNodePoint::TDbStruNodePoint()
|
|
{
|
|
|
|
}
|
|
|
|
TDbStruNodePoint::~TDbStruNodePoint()
|
|
{
|
|
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::dwgInFields( AcDbDwgFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es = TDbStruEntityBase::dwgInFields(pFiler);
|
|
if(es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
|
|
// 版本号
|
|
Adesk::UInt8 nVer;
|
|
pFiler->readItem(&nVer);
|
|
|
|
// xy平面关联对象ID数组
|
|
Adesk::UInt8 nCount = 0;
|
|
pFiler->readItem(&nCount);
|
|
AcDbSoftPointerId id;
|
|
m_arAssocIds.setLogicalLength(0);
|
|
for(Adesk::UInt8 i = 0; i < nCount; i++)
|
|
{
|
|
pFiler->readItem(&id);
|
|
m_arAssocIds.append(id);
|
|
}
|
|
|
|
pFiler->readItem(&m_idLayerLoad);
|
|
pFiler->readItem(&m_idLayerLoadL);
|
|
pFiler->readItem(&m_idLayerLoadC);
|
|
pFiler->readItem(&m_idTextStyle);
|
|
pFiler->readItem(&m_idTextStyleRB);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::dwgOutFields( AcDbDwgFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbStruEntityBase::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk)
|
|
{
|
|
return es;
|
|
}
|
|
pFiler->writeItem(g_nVersion);
|
|
|
|
// xy平面关联对象ID数组
|
|
Adesk::UInt8 nCount=(Adesk::UInt8)m_arAssocIds.length();
|
|
pFiler->writeItem(nCount);
|
|
for (Adesk::UInt8 i = 0; i < nCount; i++)
|
|
{
|
|
pFiler->writeItem(AcDbSoftPointerId(m_arAssocIds[i]));
|
|
}
|
|
|
|
pFiler->writeItem(m_idLayerLoad);
|
|
pFiler->writeItem(m_idLayerLoadL);
|
|
pFiler->writeItem(m_idLayerLoadC);
|
|
pFiler->writeItem(m_idTextStyle);
|
|
pFiler->writeItem(m_idTextStyleRB);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::dxfInFields( AcDbDxfFiler* pFiler )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbStruEntityBase::dxfInFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
if (!pFiler->atSubclassData(_T("TDbStruNodePoint")))
|
|
return Acad::eBadDxfSequence;
|
|
|
|
try
|
|
{
|
|
// Object Version
|
|
struct resbuf rb;
|
|
pFiler->readItem(&rb);
|
|
if (rb.restype != AcDb::kDxfInt8)
|
|
throw AcDb::kDxfInt8;
|
|
|
|
Adesk::Int16 version = rb.resval.rint;
|
|
if (version > g_nVersion)
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
catch (AcDb::DxfCode code)
|
|
{
|
|
pFiler->pushBackItem();
|
|
pFiler->setError(Acad::eInvalidDxfCode, _T("\nError: expected group code %d"), code);
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::dxfOutFields( AcDbDxfFiler* pFiler ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbStruEntityBase::dxfOutFields(pFiler);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
|
|
pFiler->writeItem(AcDb::kDxfSubclass, _T("TDbStruNodePoint"));
|
|
pFiler->writeItem(AcDb::kDxfInt8, g_nVersion);
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subGetOsnapPoints( AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds ) const
|
|
{
|
|
assertReadEnabled();
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() > 0)
|
|
{
|
|
snapPoints.append(ptArr[0]);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subTransformBy( const AcGeMatrix3d& xform )
|
|
{
|
|
assertWriteEnabled();
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() > 0)
|
|
{
|
|
ptArr[0].transformBy(xform);
|
|
SetAt(KEY_PTS, ptArr);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subGetTransformedCopy( const AcGeMatrix3d& xform, AcDbEntity*& pEnt ) const
|
|
{
|
|
assertReadEnabled();
|
|
pEnt = new TDbStruNodePoint;
|
|
pEnt->copyFrom(this);
|
|
pEnt->transformBy(xform);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::copyFrom( const AcRxObject* pSrc )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (pSrc != NULL)
|
|
{
|
|
TDbStruEntityBase::copyFrom(pSrc);
|
|
|
|
TDbStruNodePoint* pNode = TDbStruNodePoint::cast(pSrc);
|
|
if (pNode != NULL)
|
|
{
|
|
GetSpecialtyData()->Empty();
|
|
*GetSpecialtyData() = *pNode->GetSpecialtyData();
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subGetGripPoints( AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds ) const
|
|
{
|
|
assertReadEnabled();
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() > 0)
|
|
{
|
|
gripPoints.append(ptArr[0]);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subGetStretchPoints( AcGePoint3dArray& stretchPoints ) const
|
|
{
|
|
assertReadEnabled();
|
|
return TDbStruEntityBase::subGetStretchPoints(stretchPoints);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
|
{
|
|
assertWriteEnabled();
|
|
if (indices.length() == 1 && indices[0] == 0)
|
|
{
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() > 0)
|
|
{
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(offset);
|
|
ptArr[0].transformBy(mat);
|
|
SetAt(KEY_PTS, ptArr);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
|
{
|
|
assertWriteEnabled();
|
|
return TDbStruEntityBase::subMoveStretchPointsAt(indices, offset);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subGetClassID( CLSID* pClsid ) const
|
|
{
|
|
#if (ADS >= 17)
|
|
assertReadEnabled();
|
|
#endif
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subWblockClone( AcRxObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary ) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbStruEntityBase::subWblockClone(pOwner, pClonedObject, idMap, isPrimary);
|
|
if (es != Acad::eOk)
|
|
return es;
|
|
|
|
TDbStruNodePoint *pNode = TDbStruNodePoint::cast(pClonedObject);
|
|
if (pNode != NULL)
|
|
{
|
|
pNode->GetSpecialtyData()->Empty();
|
|
*pNode->GetSpecialtyData() = *GetSpecialtyDataReadOnly();
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::subDeepClone( AcDbObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary ) const
|
|
{
|
|
assertReadEnabled();
|
|
return TDbStruEntityBase::subDeepClone(pOwner, pClonedObject, idMap, isPrimary);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::GetGripText( int i, CString &cs ) const
|
|
{
|
|
assertReadEnabled();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::ExplodeOrDraw3d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() == 0)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
int nNodeType = 0;
|
|
GetAt(KEY_TYPE, nNodeType);
|
|
Adesk::UInt16 nColor = dc.GetColor();
|
|
if (nNodeType == 1) // 实节点
|
|
{
|
|
dc.SetColor(g_iSolidNodeColor);
|
|
}
|
|
else // 虚节点
|
|
{
|
|
dc.SetColor(g_iVirtualNodeColor);
|
|
}
|
|
|
|
// 绘制球
|
|
AcGePoint3d ptIns = ptArr[0];
|
|
double dDiameter = g_dNodeDiameter * DocGetPScale();
|
|
double dAngle = 2 * PI / 30;
|
|
AcDbLine line(ptIns + AcGeVector3d::kZAxis * dDiameter * 0.5, ptIns - AcGeVector3d::kZAxis * dDiameter * 0.5);
|
|
std::vector<AcGePoint3d> vecPt1, vecPt2;
|
|
vecPt1.push_back(ptIns + AcGeVector3d::kZAxis * dDiameter * 0.5);
|
|
vecPt2.push_back(ptIns + AcGeVector3d::kZAxis * dDiameter * 0.5);
|
|
AcGeVector3d vt = AcGeVector3d::kZAxis * dDiameter * 0.5;
|
|
AcGePoint3d pt1, pt2;
|
|
for (int i = 0; i < 14; i++)
|
|
{
|
|
vt.rotateBy(dAngle, AcGeVector3d::kYAxis);
|
|
pt1 = ptIns + vt;
|
|
line.getClosestPointTo(pt1, pt2);
|
|
vecPt1.push_back(pt1);
|
|
vecPt2.push_back(pt2);
|
|
}
|
|
vecPt1.push_back(ptIns - AcGeVector3d::kZAxis * dDiameter * 0.5);
|
|
vecPt2.push_back(ptIns - AcGeVector3d::kZAxis * dDiameter * 0.5);
|
|
|
|
AcGePoint3dArray ptArr2;
|
|
AcGeVector3d vtX;
|
|
for (i = 0; i < 16; i++)
|
|
{
|
|
vtX = vecPt1[i] - vecPt2[i];
|
|
for (int j = 0; j < 30; j++)
|
|
{
|
|
ptArr2.append(vecPt2[i] + vtX);
|
|
vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
}
|
|
ptArr2.append(vecPt1[i]);
|
|
}
|
|
|
|
//add by xlc on 120112荷载显示控制
|
|
BOOL bShowGraphic = true; //显示图形
|
|
if(g_nLoadDrawMode == NODELOAD)
|
|
{
|
|
bShowGraphic = GetViewStyle(BYGRAPHIC);
|
|
}
|
|
|
|
// add by wjx 绘制荷载
|
|
TStruLoad loadData;
|
|
if(GetLoadData(loadData, 1, dc) && bShowGraphic)
|
|
{
|
|
dc.SetColor(1);
|
|
DrawLoad3d(loadData, dc);
|
|
}
|
|
|
|
|
|
dc.DrawMesh(16, 31, ptArr2.asArrayPtr());
|
|
|
|
dc.SetColor(nColor);
|
|
|
|
if (DocGetShowNo() && DocGetNodeShowNo())
|
|
{
|
|
DrawClab(dc);
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() == 0)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
TADSGePoint3d ptIns = ptArr[0];
|
|
|
|
int nNodeType = 0;
|
|
GetAt(KEY_TYPE, nNodeType);
|
|
Adesk::UInt16 nColor = dc.GetColor();
|
|
double dRadius = g_dNodeDiameter * DocGetPScale() * 0.25;
|
|
TGGeCircle cir(ptIns, dRadius);
|
|
TGGeCurveSegment seg;
|
|
seg = cir;
|
|
TGGePoly2D poly;
|
|
seg.AsPoly2D(poly);
|
|
AcDbPolyline *pLine = static_cast<AcDbPolyline*>(poly.AsAcDbCurve());
|
|
if (pLine == NULL)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
poly.m_nFlag = 1;
|
|
if (nNodeType == 1) // 实节点
|
|
{
|
|
dc.SetColor(g_iSolidNodeColor);
|
|
}
|
|
else // 虚节点
|
|
{
|
|
dc.SetColor(g_iVirtualNodeColor);
|
|
}
|
|
pLine->setConstantWidth(dRadius * 2);
|
|
dc.Polyline(*pLine);
|
|
delete pLine;
|
|
|
|
// add by xlc on 120112荷载显示控制
|
|
if((DocGetNodeShowLoad() && g_nLoadDrawMode == BYOBJLOAD)|| g_nLoadDrawMode == NODELOAD)
|
|
{
|
|
DrawNodeLoad(dc, poly);
|
|
}
|
|
|
|
dc.SetColor(nColor);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbStruNodePoint::DrawClab(TGGiExplodeDrawBase &dc) const
|
|
{
|
|
CString strNo;
|
|
GetAt(KEY_NO, strNo);
|
|
|
|
if (strNo.IsEmpty())
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcDbText text;
|
|
text.setTextString(strNo); // 设置文字的显示内容
|
|
|
|
// 设置文字样式
|
|
AcDbObjectId idStyle = DocGetNodeNoStyle();
|
|
if(!idStyle.isNull())
|
|
{
|
|
text.setTextStyle(idStyle);
|
|
}
|
|
else
|
|
{
|
|
text.setTextStyle(InitTextStyle(TS_STANDARD));
|
|
}
|
|
|
|
text.setHeight(DocGetNodeNoHigh() * GetPScale()); // 设置文字字高
|
|
|
|
text.setColorIndex(DocGetNodeNoColor()); // 设置文字颜色
|
|
|
|
// 设置文字法向
|
|
if(_tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor())==0)
|
|
{
|
|
AcGiViewport &vp = ((TGGiWorldViewportDraw&)dc).m_pVd->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();
|
|
|
|
text.setNormal(vtViewDrt);
|
|
}
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TADSGePoint3d ptIns = ptArr[0];
|
|
double dDis = (DocGetNodeNoDist() + g_dNodeDiameter*0.5)* GetPScale();// 得到文字到节点距离(考虑图纸比例)
|
|
ptIns.x += dDis;
|
|
|
|
text.setPosition(ptIns); // 设置文字的插入位置
|
|
text.setHorizontalMode(AcDb::kTextMid); // 设置文字的对齐方式
|
|
|
|
dc.DrawEntity(text);
|
|
}
|
|
Acad::ErrorStatus TDbStruNodePoint::GetExtents2d( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
|
{
|
|
assertReadEnabled();
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() == 0)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
ptLow = ptUp = ptArr[0];
|
|
double dRadius = g_dNodeDiameter * DocGetPScale() * 0.5;
|
|
ptLow.x -= dRadius;
|
|
ptLow.y -= dRadius;
|
|
ptLow.z = 0;
|
|
|
|
ptUp.x += dRadius;
|
|
ptUp.y += dRadius;
|
|
ptUp.z = 0;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbStruNodePoint::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
if (ptArr.length() == 0)
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
ptLow = ptUp = ptArr[0];
|
|
double dRadius = g_dNodeDiameter * DocGetPScale() * 0.5;
|
|
ptLow.x -= dRadius;
|
|
ptLow.y -= dRadius;
|
|
ptLow.z -= dRadius;
|
|
|
|
ptUp.x += dRadius;
|
|
ptUp.y += dRadius;
|
|
ptUp.z += dRadius;
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool TDbStruNodePoint::UnifyElevation( double dElevation )
|
|
{
|
|
assertWriteEnabled();
|
|
return true;
|
|
}
|
|
|
|
void TDbStruNodePoint::GetTips( TDPtrList<TObjInfoUnit> & ) const
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
|
|
const TCHAR * TDbStruNodePoint::GetDefaultLayer() const
|
|
{
|
|
assertReadEnabled();
|
|
return LAY_S_NODE;
|
|
}
|
|
|
|
BOOL TDbStruNodePoint::IsValid() const
|
|
{
|
|
assertReadEnabled();
|
|
return TRUE;
|
|
}
|
|
|
|
void TDbStruNodePoint::CopyPropertiesFrom( AcDbEntity *pSrcEntity, unsigned gMatchFlag )
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
TDbStruEntityBase::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
|
TDbStruNodePoint *pEnt = TDbStruNodePoint::cast(pSrcEntity);
|
|
if (pEnt != NULL)
|
|
{
|
|
copyFrom(pEnt);
|
|
|
|
if(database() == NULL ||
|
|
pSrcEntity->database() == NULL ||
|
|
database() == pSrcEntity->database())
|
|
{
|
|
m_idLayerLoad = pEnt->m_idLayerLoad;
|
|
m_idLayerLoadL = pEnt->m_idLayerLoadL;
|
|
m_idLayerLoadC = pEnt->m_idLayerLoadC;
|
|
m_idTextStyle = pEnt->m_idTextStyle;
|
|
m_idTextStyleRB = pEnt->m_idTextStyleRB;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TDbStruNodePoint::GetStandardFaceBody( AcDbVoidPtrArray& arFacePtrs ) const
|
|
{
|
|
assertReadEnabled();
|
|
return false;
|
|
}
|
|
|
|
bool TDbStruNodePoint::GetSafeProtectedSpace( AcDbVoidPtrArray& arFacePtrs ) const
|
|
{
|
|
assertReadEnabled();
|
|
return false;
|
|
}
|
|
|
|
bool TDbStruNodePoint::GetSection( const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir, std::vector<TObjSectionRecord> §ionRecords, AcDbVoidPtrArray& arFillPtrs ) const
|
|
{
|
|
assertReadEnabled();
|
|
return false;
|
|
}
|
|
|
|
CString TDbStruNodePoint::GetXml(const AcGeMatrix3d& mat) const
|
|
{
|
|
return CString();
|
|
}
|
|
|
|
void TDbStruNodePoint::MakeAssocRelation( AcDbObjectIdArray& ids )
|
|
{
|
|
|
|
}
|
|
|
|
void TDbStruNodePoint::RemoveAssocRelation( AcDbObjectId& id )
|
|
{
|
|
|
|
}
|
|
|
|
void TDbStruNodePoint::GetAssocRelation( int nType, AcDbObjectIdArray& ar ) const
|
|
{
|
|
|
|
}
|
|
|
|
// add by wjx on 111227
|
|
// 绘制节点荷载
|
|
void TDbStruNodePoint::DrawNodeLoad(TGGiExplodeDrawBase &dc, TGGePoly2D poly)const
|
|
{
|
|
//add by xlc on 120112荷载显示控制
|
|
BOOL bShowGraphic = true; //显示图形
|
|
if(g_nLoadDrawMode == NODELOAD)
|
|
{
|
|
bShowGraphic = GetViewStyle(BYGRAPHIC);
|
|
}
|
|
|
|
TPushProperty vProp(this, dc);
|
|
if (m_idLayerLoad.isValid())
|
|
{
|
|
dc.SetLayer(m_idLayerLoad);
|
|
}
|
|
|
|
TStruLoad loadData;
|
|
if(GetLoadData(loadData, 0, dc) && bShowGraphic)
|
|
{
|
|
TGGePoly2D polyOut;
|
|
poly.Offset(50, polyOut);
|
|
AcDbPolyline *pLine = static_cast<AcDbPolyline*>(polyOut.AsAcDbCurve());
|
|
if (pLine != NULL)
|
|
{
|
|
pLine->setConstantWidth(50);
|
|
pLine->setColorIndex(1);
|
|
dc.Polyline(*pLine);
|
|
|
|
delete pLine;
|
|
}
|
|
}
|
|
}
|
|
|
|
// add by wjx 0n 111228
|
|
// 得到荷载信息
|
|
// [in]: n2dOr3dFlag: 0:2d 1:3d
|
|
BOOL TDbStruNodePoint::GetLoadData(TStruLoad &loadData,int n2dOr3dFlag, TGGiExplodeDrawBase &dc)const
|
|
{
|
|
//if(NULL == g_pStruSubProject)
|
|
//{
|
|
// return FALSE;
|
|
//}
|
|
|
|
//add by xlc on 120112荷载显示控制
|
|
BOOL bShowGraphic = false; //显示图形
|
|
BOOL bShowLive = false; //显示活荷
|
|
BOOL bShowUnLive = false; //显示恒荷
|
|
|
|
if(g_nLoadDrawMode == BYOBJLOAD)
|
|
{
|
|
bShowGraphic = DocGetNodeShowLoad();
|
|
if (!bShowGraphic)
|
|
{
|
|
return FALSE;
|
|
}
|
|
bShowLive = bShowUnLive = DocGetShowLoadPara();
|
|
}
|
|
else
|
|
{
|
|
bShowGraphic = GetViewStyle(BYGRAPHIC);
|
|
bShowLive = GetViewStyle(BYVARYING);
|
|
bShowUnLive = GetViewStyle(BYUNVARYING);
|
|
}
|
|
|
|
//都不显示时直接返回
|
|
if (!(bShowGraphic||bShowLive||bShowUnLive))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
// modify by wjx on 120130 修改荷载的读取方式
|
|
BOOL bFind = FALSE;
|
|
std::vector<TStruLoad> vecLoad;
|
|
GetLoadsArray(vecLoad);
|
|
int nSize = vecLoad.size();
|
|
if(nSize < 1)
|
|
{
|
|
return bFind;
|
|
}
|
|
|
|
bFind = TRUE;
|
|
|
|
double dTextDis = g_dNodeDiameter * DocGetPScale()/2 + 50; // 文字到节点的距离
|
|
|
|
for(int i = 0; i < nSize; i++)
|
|
{
|
|
loadData = vecLoad[i];
|
|
|
|
if ((loadData.GetLoadKind() == TStruLoad::LK_VARYING && bShowLive) //活荷
|
|
||(loadData.GetLoadKind() == TStruLoad::LK_UNVARYING && bShowUnLive) //恒荷
|
|
)
|
|
{
|
|
DrawLoadText(loadData, n2dOr3dFlag, dTextDis, dc);
|
|
}
|
|
}
|
|
|
|
// AcDbHandle hNode;
|
|
// getAcDbHandle(hNode);
|
|
// int nHandle = hNode.low();
|
|
//
|
|
// // 在自然层中找到该句柄对应的荷载信息
|
|
// int nSize = g_pStruSubProject->m_vecFloorData.size();// 自然层数
|
|
// int nLoadSize = 0; // 自然层中荷载数量
|
|
// TStruEntLoads entLoad;
|
|
//
|
|
// BOOL bFind = false; // 是否找到梁的荷载信息
|
|
// for(int i = 0; i < nSize; i++)
|
|
// {
|
|
// nLoadSize = g_pStruSubProject->m_vecFloorData[i].m_arEntLoads.size();
|
|
// for (int j = 0; j < nLoadSize; j++)
|
|
// {
|
|
// entLoad = g_pStruSubProject->m_vecFloorData[i].m_arEntLoads[j];
|
|
// if (entLoad.GetEntHandle().low() == nHandle)
|
|
// {
|
|
// bFind = true;
|
|
//
|
|
// // 得到荷载数据
|
|
// int nLoadInfoCount = g_pStruSubProject->m_vecFloorData[i].m_arEntLoads[j].m_vecLoads.size();
|
|
// double dTextDis = g_dNodeDiameter * DocGetPScale()/2 + 50; // 文字到节点的距离
|
|
// for(int k = 0; k < nLoadInfoCount; k++)
|
|
// {
|
|
// loadData = g_pStruSubProject->m_vecFloorData[i].m_arEntLoads[j].m_vecLoads[k];
|
|
//
|
|
// if ((loadData.GetLoadKind() == TStruLoad::LK_VARYING && bShowLive) //活荷
|
|
// ||(loadData.GetLoadKind() == TStruLoad::LK_UNVARYING && bShowUnLive) //恒荷
|
|
// )
|
|
// {
|
|
// DrawLoadText(loadData, n2dOr3dFlag, dTextDis, dc);
|
|
// }
|
|
// }
|
|
// break;
|
|
// }
|
|
// }
|
|
//
|
|
// if(bFind)
|
|
// {
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
return bFind;
|
|
}
|
|
|
|
// add by wjx on 111228
|
|
// 绘制节点荷载(3d)
|
|
void TDbStruNodePoint::DrawLoad3d(TStruLoad loadData, TGGiExplodeDrawBase &dc)const
|
|
{
|
|
double dP, dMx, dMy, dMz, dPx, dPy;
|
|
dP = loadData.GetValue();
|
|
dMx = loadData.GetPara1();
|
|
dMy = loadData.GetPara2();
|
|
dMz = loadData.GetPara3();
|
|
dPx = loadData.GetForceX();
|
|
dPy = loadData.GetForceY();
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
AcGePoint3d ptIns = ptArr[0];
|
|
double dDis = 50; // 荷载图形到节点的距离
|
|
|
|
double dDiameter = g_dNodeDiameter * DocGetPScale();
|
|
double dLen = 400;
|
|
|
|
AcDbLine line;
|
|
AcDbArc arcLine;
|
|
line.setColorIndex(7);
|
|
arcLine.setColorIndex(7);
|
|
|
|
if(fabs(dP) > _DIST_SNAP)
|
|
{
|
|
line.setStartPoint(XPoint(ptIns.x, ptIns.y, ptIns.z+dDiameter/2));
|
|
line.setEndPoint(XPoint(ptIns.x, ptIns.y, ptIns.z+dDiameter/2+dLen));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x+dDis, ptIns.y, ptIns.z+dDiameter/2+dDis));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x, ptIns.y+dDis, ptIns.z+dDiameter/2+dDis));
|
|
dc.DrawEntity(line);
|
|
}
|
|
|
|
if(fabs(dMx) > _DIST_SNAP)
|
|
{
|
|
XPoint ptS(ptIns.x+dDiameter/2, ptIns.y, ptIns.z+dDiameter/2+dDis);
|
|
XPoint ptE(ptIns.x+dDiameter/2+5, ptIns.y, ptIns.z+dDiameter/2+dDis+10);
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x, ptE.y+3*i, ptE.z+(5-i)*i);
|
|
}
|
|
|
|
for(int i = 0; i < 2; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x, ptE.y+i, ptE.z-2*i);
|
|
}
|
|
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x, ptE.y+(5-i)*i, ptE.z-(8-i)*i);
|
|
}
|
|
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(XPoint(ptS.x, ptE.y+dDis, ptE.z+dDis));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptS.x, ptE.y+dDis, ptE.z-dDis));
|
|
dc.DrawEntity(line);
|
|
}
|
|
|
|
if(fabs(dMy) > _DIST_SNAP)
|
|
{
|
|
XPoint ptS(ptIns.x, ptIns.y+dDiameter/2, ptIns.z+dDiameter/2+dDis);
|
|
XPoint ptE(ptIns.x+5, ptIns.y+dDiameter/2, ptIns.z+dDiameter/2+dDis+10);
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x+3*i, ptE.y, ptE.z+(5-i)*i);
|
|
}
|
|
|
|
for(int i = 0; i < 2; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x+i, ptE.y, ptE.z-2*i);
|
|
}
|
|
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(ptE);
|
|
dc.DrawEntity(line);
|
|
ptS = ptE;
|
|
ptE = XPoint(ptE.x+(5-i)*i, ptE.y, ptE.z-(8-i)*i);
|
|
}
|
|
|
|
line.setStartPoint(ptS);
|
|
line.setEndPoint(XPoint(ptS.x+dDis, ptE.y, ptE.z+dDis));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptS.x+dDis, ptE.y, ptE.z-dDis));
|
|
dc.DrawEntity(line);
|
|
}
|
|
|
|
if(fabs(dMz) > _DIST_SNAP)
|
|
{
|
|
arcLine.setCenter(XPoint(ptIns.x, ptIns.y,ptIns.z));
|
|
arcLine.setStartAngle(0);
|
|
arcLine.setEndAngle(PI*3/2);
|
|
arcLine.setRadius(200);
|
|
arcLine.setNormal(AcGeVector3d::kZAxis);
|
|
dc.DrawEntity(arcLine);
|
|
|
|
XPoint ptE;
|
|
arcLine.getEndPoint(ptE);
|
|
line.setStartPoint(ptE);
|
|
line.setEndPoint(XPoint(ptE.x-dDis, ptE.y+dDis, ptE.z));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptE.x-dDis, ptE.y-dDis, ptE.z));
|
|
dc.DrawEntity(line);
|
|
}
|
|
|
|
if(fabs(dPx) > _DIST_SNAP)
|
|
{
|
|
line.setStartPoint(XPoint(ptIns.x-dDiameter/2, ptIns.y, ptIns.z));
|
|
line.setEndPoint(XPoint(ptIns.x-dDiameter/2-dLen, ptIns.y, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x-dDiameter/2-dDis, ptIns.y+dDis, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x-dDiameter/2-dDis, ptIns.y-dDis, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
}
|
|
|
|
if(fabs(dPy) > _DIST_SNAP)
|
|
{
|
|
line.setStartPoint(XPoint(ptIns.x, ptIns.y-dDiameter/2, ptIns.z));
|
|
line.setEndPoint(XPoint(ptIns.x, ptIns.y-dDiameter/2-dLen, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x-dDis, ptIns.y-dDiameter/2-dDis, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
|
|
line.setEndPoint(XPoint(ptIns.x+dDis, ptIns.y-dDiameter/2-dDis, ptIns.z));
|
|
dc.DrawEntity(line);
|
|
}
|
|
}
|
|
|
|
// 绘制节点荷载文字
|
|
// [in]: n2dOr3dFlag: 0:2d 1:3d
|
|
// [in]: dDis:文字到节点的距离
|
|
void TDbStruNodePoint::DrawLoadText(TStruLoad loadData,int n2dOr3dFlag,
|
|
double &dDis, TGGiExplodeDrawBase &dc)const
|
|
{
|
|
int nKind = loadData.GetLoadKind(); // 荷载种类
|
|
|
|
//if(!GetViewStyle(nKind))
|
|
//{
|
|
// return;
|
|
//}
|
|
|
|
// 设置文字
|
|
AcDbText text;
|
|
text.setTextStyle(InitTextStyle(TS_STANDARD));
|
|
text.setHeight(DocGetLoadTextHeight());// 设置文字高度
|
|
|
|
double dP, dMx, dMy, dMz, dPx, dPy;
|
|
dP = loadData.GetValue();
|
|
dMx = loadData.GetPara1();
|
|
dMy = loadData.GetPara2();
|
|
dMz = loadData.GetPara3();
|
|
dPx = loadData.GetForceX();
|
|
dPy = loadData.GetForceY();
|
|
|
|
AcGePoint3dArray ptArr;
|
|
GetAt(KEY_PTS, ptArr);
|
|
AcGePoint3d ptIns = ptArr[0];
|
|
|
|
double dDiameter = g_dNodeDiameter * DocGetPScale();
|
|
|
|
CString strText;
|
|
// strText.Format(_T("%.1f*%.1f*%.1f*%.1f*%.1f*%.1f"), dP, dMx, dMy, dMz, dPx, dPy);
|
|
strText.Format(_T("%s*%s*%s*%s*%s*%s"), TrimDoubleZero(dP), TrimDoubleZero(dMx),
|
|
TrimDoubleZero(dMy), TrimDoubleZero(dMz),
|
|
TrimDoubleZero(dPx), TrimDoubleZero(dPy));
|
|
text.setTextString(strText);
|
|
|
|
if(n2dOr3dFlag == 0)
|
|
{
|
|
text.setPosition(XPoint(ptIns.x, ptIns.y+dDiameter/2+dDis, ptIns.z));
|
|
}
|
|
else
|
|
{
|
|
// 设置文字法向
|
|
if(_tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor())==0)
|
|
{
|
|
AcGiViewport &vp = ((TGGiWorldViewportDraw&)dc).m_pVd->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();
|
|
|
|
text.setNormal(vtViewDrt);
|
|
}
|
|
|
|
text.setPosition(XPoint(ptIns.x, ptIns.y, ptIns.z+dDiameter/2+dDis));
|
|
}
|
|
|
|
TPushProperty vProp(this, dc);
|
|
if(nKind == TStruLoad::LK_UNVARYING)
|
|
{
|
|
//text.setColorIndex(7);
|
|
if (m_idLayerLoadC.isValid())
|
|
{
|
|
dc.SetLayer(m_idLayerLoadC);
|
|
text.setLayer(m_idLayerLoadC);
|
|
}
|
|
}
|
|
else if(nKind == TStruLoad::LK_VARYING)
|
|
{
|
|
//text.setColorIndex(2);
|
|
if (m_idLayerLoadL.isValid())
|
|
{
|
|
dc.SetLayer(m_idLayerLoadL);
|
|
text.setLayer(m_idLayerLoadL);
|
|
}
|
|
}
|
|
|
|
dc.DrawEntity(text);
|
|
dDis += DocGetLoadTextHeight();
|
|
}
|
|
|
|
//add by xlc on 120118
|
|
//设置荷载数组
|
|
bool TDbStruNodePoint::SetLoadsArray(const std::vector<TStruLoad>& vectLoads)
|
|
{
|
|
assertWriteEnabled();
|
|
ClearLoadsArray();
|
|
return SetAt(KEY_NODE, vectLoads);
|
|
}
|
|
//获得荷载数组
|
|
bool TDbStruNodePoint::GetLoadsArray(std::vector<TStruLoad>& vectLoads)const
|
|
{
|
|
assertReadEnabled();
|
|
return GetAt(KEY_NODE, vectLoads);
|
|
}
|
|
//清除荷载数组
|
|
void TDbStruNodePoint::ClearLoadsArray()
|
|
{
|
|
assertWriteEnabled();
|
|
RemoveLoadsKey(KEY_NODE);
|
|
}
|
|
|
|
//荷载
|
|
AcDbObjectId TDbStruNodePoint::GetLayerLoad() const
|
|
{
|
|
return m_idLayerLoad;
|
|
}
|
|
void TDbStruNodePoint::SetLayerLoad(AcDbObjectId idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idLayerLoad = idLayer;
|
|
}
|
|
|
|
//活荷值
|
|
AcDbObjectId TDbStruNodePoint::GetLayerLoadL() const
|
|
{
|
|
return m_idLayerLoadL;
|
|
}
|
|
void TDbStruNodePoint::SetLayerLoadL(AcDbObjectId idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idLayerLoadL = idLayer;
|
|
}
|
|
|
|
//恒荷值
|
|
AcDbObjectId TDbStruNodePoint::GetLayerLoadC() const
|
|
{
|
|
return m_idLayerLoadC;
|
|
}
|
|
void TDbStruNodePoint::SetLayerLoadC(AcDbObjectId idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idLayerLoadC = idLayer;
|
|
}
|
|
|
|
//文字样式
|
|
AcDbObjectId TDbStruNodePoint::GetTextStyle() const
|
|
{
|
|
return m_idTextStyle;
|
|
}
|
|
void TDbStruNodePoint::SetTextStyle(AcDbObjectId idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idTextStyle = idLayer;
|
|
}
|
|
|
|
//文字样式
|
|
AcDbObjectId TDbStruNodePoint::GetTextStyleRB() const
|
|
{
|
|
return m_idTextStyleRB;
|
|
}
|
|
void TDbStruNodePoint::SetTextStyleRB(AcDbObjectId idLayer)
|
|
{
|
|
assertWriteEnabled();
|
|
m_idTextStyleRB = idLayer;
|
|
}
|
|
|
|
int TDbStruNodePoint::GetFirstVersion()const
|
|
{
|
|
return 10;
|
|
}
|
|
bool TDbStruNodePoint::IsModelEntity() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void InitStruNodePoint(bool bTrue)
|
|
{
|
|
if (bTrue)
|
|
{
|
|
TDbStruNodePoint::rxInit();
|
|
acrxBuildClassHierarchy();
|
|
TDbStruNodePoint::InitMatchProtocol(TRUE);
|
|
}
|
|
else
|
|
{
|
|
TDbStruNodePoint::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbStruNodePoint::desc());
|
|
}
|
|
}
|
|
#endif |