Files

1245 lines
29 KiB
C++
Raw Permalink Normal View History

2026-10-04 00:04:20 +08:00
#include "stdafx.h"
2026-09-28 15:28:50 +08:00
#include "AcGiExplodeDraw.h"
#include "shlwapi.h"
#include "GiDrawutility.h"
#include "EarThwormDef.h"
static const Adesk::UInt16 kColorByBlock = 0;
static const Adesk::UInt16 kColorByLayer = 256;
AcGiExplodeDraw::AcGiExplodeDraw()
{
m_parEntPtrs = NULL;
m_plan = AcGePlane::kXYPlane;
m_dLineWidth = 0.0;
}
AcGiExplodeDraw::AcGiExplodeDraw(AcDbVoidPtrArray& entitySet)
{
m_parEntPtrs = &entitySet;
m_plan = AcGePlane::kXYPlane;
m_dLineWidth = 0.0;
}
AcGiExplodeDraw::~AcGiExplodeDraw(void)
{
}
AcGiCommonDraw * AcGiExplodeDraw::GetCommonDraw() const
{
return NULL;
}
void AcGiExplodeDraw::SetColor(const Adesk::UInt16 color)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setColor(color);
}
}
Adesk::UInt16 AcGiExplodeDraw::GetColor() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().color();
}
return 255;
}
void AcGiExplodeDraw::SetTrueColor(const AcCmEntityColor& color)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setTrueColor(color);
}
}
AcCmEntityColor AcGiExplodeDraw::GetTrueColor() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().trueColor();
}
AcCmEntityColor cr;
return cr;
}
bool AcGiExplodeDraw::SetColorLayer(int nColor,const AcDbObjectId layerId)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL && layerId.isValid())
{
pCommDraw->subEntityTraits().setColor(nColor);
pCommDraw->subEntityTraits().setLayer(layerId);
return true;
}
return false;
}
void AcGiExplodeDraw::SetLayer(const AcDbObjectId layerId)
{
m_idLayerId = layerId;
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL && layerId.isValid())
{
if (layerId.isNull())
{
pCommDraw->subEntityTraits().setLayer(acdbCurDwg()->clayer());
return;
}
return pCommDraw->subEntityTraits().setLayer(layerId);
}
}
void AcGiExplodeDraw::SetLayer(LPCTSTR pszLayer)
{
AcDbLayerTable *pLayerTable;
Acad::ErrorStatus es = acdbCurDwg()->getLayerTable(pLayerTable, AcDb::kForRead);
AcDbObjectId idLayer = acdbCurDwg()->clayer();
if (es == Acad::eOk)
{
es = pLayerTable->getAt(pszLayer, idLayer);
pLayerTable->close();
}
m_idLayerId = idLayer;
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().setLayer(idLayer);
}
}
AcDbObjectId AcGiExplodeDraw::GetLayerId() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().layerId();
}
return m_idLayerId;
}
#if ARX > 17
AcCmTransparency AcGiExplodeDraw::SetTransparency(const AcCmTransparency& transparency)
{
AcCmTransparency tr;
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
tr = pCommDraw->subEntityTraits().transparency();
pCommDraw->subEntityTraits().setTransparency(transparency);
}
return tr;
}
#endif
void AcGiExplodeDraw::SetLineType(const AcDbObjectId linetypeId)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
if (linetypeId.isNull())
{
pCommDraw->subEntityTraits().setLineType(acdbCurDwg()->celtype());
return;
}
pCommDraw->subEntityTraits().setLineType(linetypeId);
}
}
AcDbObjectId AcGiExplodeDraw::GetLineTypeId() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().lineTypeId();
}
return AcDbObjectId::kNull;
}
void AcGiExplodeDraw::SetFillType(const AcGiFillType fillType)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setFillType(fillType);
}
}
AcGiFillType AcGiExplodeDraw::GetFillType() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().fillType();
}
return kAcGiFillAlways;
}
void AcGiExplodeDraw::SetLineWeight(const AcDb::LineWeight lw)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setLineWeight(lw);
}
}
AcDb::LineWeight AcGiExplodeDraw::GetLineWeight() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().lineWeight();
}
return AcDb::kLnWt000;
}
void AcGiExplodeDraw::SetLineWidth(double dW)
{
m_dLineWidth = dW;
}
double AcGiExplodeDraw::GetLineWidth() const
{
return m_dLineWidth;
}
void AcGiExplodeDraw::SetLineTypeScale(double dScale)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setLineTypeScale(dScale);
}
}
double AcGiExplodeDraw::GetLineTypeScale() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().lineTypeScale();
}
return 0.0;
}
void AcGiExplodeDraw::SetThickness(double dThickness)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setThickness(dThickness);
}
}
double AcGiExplodeDraw::GetThickness() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().thickness();
}
return 0.0;
}
void AcGiExplodeDraw::SetPropertiesFrom(const AcDbEntity *pEnt)
{
if (pEnt != NULL)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setColor(pEnt->colorIndex());
pCommDraw->subEntityTraits().setLayer(pEnt->layerId());
pCommDraw->subEntityTraits().setLineType(pEnt->linetypeId());
#if ARX>16
pCommDraw->subEntityTraits().setMaterial(pEnt->materialId());
#endif
}
}
}
void AcGiExplodeDraw::SetSelectionMarker(int nMark)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setSelectionMarker(nMark);
}
}
void AcGiExplodeDraw::SetTextStyle(const TCHAR * szStyle)
{
AcDbTextStyleTable *pStyleTable;
Acad::ErrorStatus es = acdbCurDwg()->getTextStyleTable(pStyleTable, AcDb::kForRead);
AcDbObjectId styleId;
if (es == Acad::eOk)
{
es = pStyleTable->getAt(szStyle, m_idTextStyle);
pStyleTable->close();
}
es = fromAcDbTextStyle(m_textStyle, m_idTextStyle);
if (es != Acad::eOk)
{
m_bInitStyle = FALSE;
return;
}
else
{
m_bInitStyle = TRUE;
}
int nRetFlag = m_textStyle.loadStyleRec();
}
void AcGiExplodeDraw::SetTextStyle(AcDbObjectId id)
{
m_idTextStyle = id;
Acad::ErrorStatus es = fromAcDbTextStyle(m_textStyle, m_idTextStyle);
if (es != Acad::eOk)
{
m_bInitStyle = FALSE;
return;
}
else
{
m_bInitStyle = TRUE;
}
int nRetFlag = m_textStyle.loadStyleRec();
}
AcDbObjectId AcGiExplodeDraw::GetTextStyle() const
{
return m_idTextStyle;
}
AcDbObjectId AcGiExplodeDraw::GetTextStyle(const TCHAR * szStyle) const
{
if (szStyle == NULL)
return GetTextStyle();
AcDbObjectId idStyle = acdbCurDwg()->textstyle();
AcDbTextStyleTable* pTable = NULL;
if ( Acad::eOk == acdbCurDwg()->getTextStyleTable(pTable,AcDb::kForRead) )
{
pTable->getAt(szStyle,idStyle);
pTable->close();
}
return idStyle;
}
AcDbObjectId AcGiExplodeDraw::GetMaterialId() const
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
return pCommDraw->subEntityTraits().materialId();
}
return AcDbObjectId::kNull;
}
Acad::ErrorStatus AcGiExplodeDraw::SetMaterial(AcDbObjectId idMaterial)
{
AcGiCommonDraw * pCommDraw = GetCommonDraw();
if (pCommDraw != NULL)
{
pCommDraw->subEntityTraits().setMaterial(idMaterial);
}
return Acad::eOk;
}
Adesk::Boolean AcGiExplodeDraw::DrawCircle( const AcGePoint3d& center,
const double radius,
const AcGeVector3d& normal) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;
AcDbCircle* pCir = new AcDbCircle(center,normal,radius);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pCir);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawCircle( const AcGePoint3d& pt1,
const AcGePoint3d& pt2,
const AcGePoint3d& pt3) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcGeCircArc3d cir(pt1,pt2,pt3);
AcDbCircle* pCir = new AcDbCircle(cir.center(),cir.normal(),cir.radius());
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pCir);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawCircularArc(const AcGePoint3d& center,
const double radius,
const AcGeVector3d& normal,
const AcGeVector3d& startVector,
const double sweepAngle,
const AcGiArcType arcType) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcGeVector3d vtSta = startVector;
vtSta.normalize();
AcGePoint3d pt1 = center + radius * vtSta;
vtSta.rotateBy(0.5 * sweepAngle,normal);
AcGePoint3d pt2 = center + radius * vtSta;
vtSta.rotateBy(0.5 * sweepAngle,normal);
AcGePoint3d pt3 = center + radius * vtSta;
AcGeCircArc3d cirArc(pt1,pt2,pt3);
double dSta = cirArc.startAng();
double dEnd = cirArc.endAng();
if (dEnd < dSta)
dEnd += 2.0 * PI;
AcDbArc* pArc = new AcDbArc(center, normal,cirArc.radius(),dSta,dEnd);
m_parEntPtrs->append(pArc);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawCircularArc(const AcGePoint3d& start,
const AcGePoint3d& point,
const AcGePoint3d& end,
const AcGiArcType arcType) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcGeCircArc3d cirArc(start,point,end);
double dSta = cirArc.startAng();
double dEnd = cirArc.endAng();
if (dEnd < dSta)
dEnd += 2.0 * PI;
AcDbArc* pArc = new AcDbArc(cirArc.center(), cirArc.normal(),cirArc.radius(),dSta,dEnd);
m_parEntPtrs->append(pArc);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawPolyline(const Adesk::UInt32 nbPoints,const AcGePoint3d* pVertexList,const AcGeVector3d* pNormal) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
if (pVertexList == NULL )
return Adesk::kFalse;
AcGePlane plane;
if (pNormal != NULL)
plane.set(pVertexList[0],*pNormal);
else
plane = AcGePlane::kXYPlane;
AcGePoint3d ptOnPlan;
ptOnPlan = plane.closestPointTo(AcGePoint3d::kOrigin);
AcGeVector3d vtOrg = AcGePoint3d::kOrigin - ptOnPlan;
double dEl = vtOrg.length();
if (vtOrg.dotProduct(*pNormal) < 1.e-10)//<0
dEl *= -1.0;
AcDbPolyline* pPline = new AcDbPolyline;
pPline->setNormal(*pNormal);
pPline->setElevation(dEl);
for (int i = 0;i < nbPoints;i++)
{
pPline->addVertexAt(pPline->numVerts(),pVertexList[i].convert2d(plane));
}
m_parEntPtrs->append(pPline);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawPolygon(const Adesk::UInt32 nbPoints,const AcGePoint3d* pVertexList) const
{
return Adesk::kFalse;
}
AcDbEntity* AcGiExplodeDraw::DrawMesh( const Adesk::UInt32 rows,
const Adesk::UInt32 columns,
const AcGePoint3d* pVertexList,
const AcGiEdgeData* pEdgeData,
const AcGiFaceData* pFaceDataL,
const AcGiVertexData* pVertexData) const
{
//TEST
int nIndex = 0;
for (int i = 0;i < rows;i++)
{
for (int j = 0;j < columns;j++)
{
nIndex = i * columns + j;
AcDbPoint* pPt = new AcDbPoint(pVertexList[nIndex]);
pPt->setNormal(AcGeVector3d::kZAxis);
pPt->setColorIndex(i);
m_parEntPtrs->append(pPt);
}
}
AcDbEntity* pEnt = GiDrawUtility::DrawMesh(rows, columns, pVertexList);
if (pEnt)
{
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawMeshS( const Adesk::UInt32 rows,
const Adesk::UInt32 columns,
const AcGePoint3d* pVertexList,
bool bHasSeal) const
{
AcDbEntity* pEnt = GiDrawUtility::DrawMesh(rows, columns, pVertexList,bHasSeal);
if (pEnt)
{
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
Adesk::Boolean AcGiExplodeDraw::DrawShell( const Adesk::UInt32 nbVertex,
const AcGePoint3d* pVertexList,
const Adesk::UInt32 faceListSize,
const Adesk::Int32* pFaceList,
const AcGiEdgeData* pEdgeData,
const AcGiFaceData* pFaceData,
const AcGiVertexData* pVertexData,
const struct resbuf* pResBuf) const
{
return Adesk::kFalse;
}
Adesk::Boolean AcGiExplodeDraw::DrawText( const AcGePoint3d& position,
const AcGeVector3d& normal,
const AcGeVector3d& direction,
const double height,
const double width,
const double oblique,
const TCHAR* pMsg) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcDbObjectId idStyle = GetTextStyle();
if (!idStyle)
{
idStyle = acdbCurDwg()->textstyle();
}
AcDbText *pText = new AcDbText;
pText->setHorizontalMode(AcDb::kTextLeft);
pText->setVerticalMode(AcDb::kTextBase);
pText->setTextStyle(idStyle);
pText->setLayer(GetLayerId());
pText->setTextString(pMsg);
pText->setPosition(position);
pText->setAlignmentPoint(position);
pText->setHeight(height);
pText->setOblique(oblique);
pText->setWidthFactor(width / height);
pText->setHorizontalMode(AcDb::kTextFit);
double dAng = direction.convert2d(AcGePlane::kXYPlane).angle();
pText->setRotation(dAng);
pText->setNormal(AcGeVector3d::kZAxis);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pText);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawText( const AcGePoint3d& position,
const AcGeVector3d& normal,
const AcGeVector3d& direction,
const TCHAR* pMsg,
const Adesk::Int32 length,
const Adesk::Boolean raw,
const AcGiTextStyle &pTextStyle) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcDbObjectId idStyle = GetTextStyle();
if (!idStyle)
{
AcGiTextStyle& style = (AcGiTextStyle&)pTextStyle;
toAcDbTextStyle(style,idStyle);
if (!idStyle)
{
idStyle = acdbCurDwg()->textstyle();
}
}
AcDbText *pText = new AcDbText;
pText->setHorizontalMode(AcDb::kTextLeft);
pText->setVerticalMode(AcDb::kTextBase);
pText->setTextStyle(idStyle);
pText->setTextString(pMsg);
pText->setPosition(position);
pText->setPosition(position);
pText->setAlignmentPoint(position);
pText->setHeight(pTextStyle.textSize());
pText->setOblique(pTextStyle.obliquingAngle());
pText->setWidthFactor(pTextStyle.xScale());
pText->setHorizontalMode(AcDb::kTextFit);
double dAng = direction.convert2d(AcGePlane::kXYPlane).angle();
pText->setRotation(dAng);
pText->setNormal(AcGeVector3d::kZAxis);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pText);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawXline( const AcGePoint3d& pt1,const AcGePoint3d& pt2) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcDbXline* pXLine = new AcDbXline;
pXLine->setBasePoint(pt1);
pXLine->setUnitDir(pt2 - pt1);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pXLine);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawRay(const AcGePoint3d& pt1,const AcGePoint3d& pt2) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcDbRay* pRay = new AcDbRay;
pRay->setBasePoint(pt1);
pRay->setUnitDir(pt2 - pt1);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pRay);
return Adesk::kTrue;
}
Adesk::Boolean AcGiExplodeDraw::DrawPline(const AcDbPolyline& lwBuf,Adesk::UInt32 fromIndex /*= 0*/,Adesk::UInt32 numSegs) const
{
if (m_parEntPtrs == NULL) return Adesk::kFalse;;
AcDbPolyline* pPline = new AcDbPolyline;
pPline->setNormal(lwBuf.normal());
pPline->setElevation(lwBuf.elevation());
AcGePoint2d pt;
for (int i = fromIndex;i < numSegs + 1;i++)
{
lwBuf.getPointAt(i,pt);
pPline->addVertexAt(i - fromIndex,pt);
}
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pPline);
return Adesk::kTrue;
}
void AcGiExplodeDraw::DrawPolyline(AcDbPolyline &pline)
{
if (m_parEntPtrs == NULL) return;
AcDbPolyline* pPline = (AcDbPolyline*)pline.clone();
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pPline);
}
void AcGiExplodeDraw::DrawLine(const AcGeLineSeg3d &ln, double nThickness )
{
if (m_parEntPtrs == NULL) return;
if (nThickness < 1.0e-8)
{
if (m_dLineWidth < 1.e-6)
{
AcDbLine* pLine = new AcDbLine(ln.startPoint(),ln.endPoint());
pLine->setThickness(nThickness);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pLine);
}
else
{
AcGeVector3d vtL = ln.endPoint() - ln.startPoint();
if (ln.isParallelTo(AcGePlane::kXYPlane))
{
AcDbPolyline* pPl = new AcDbPolyline;
pPl->setConstantWidth(m_dLineWidth);
pPl->addVertexAt(0,ln.startPoint().convert2d(AcGePlane::kXYPlane));
pPl->addVertexAt(1,ln.endPoint().convert2d(AcGePlane::kXYPlane));
pPl->setElevation(ln.startPoint().z);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pPl);
}
else
{
AcDbLine* pLine = new AcDbLine(ln.startPoint(),ln.endPoint());
pLine->setThickness(nThickness);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pLine);
}
}
}
}
void AcGiExplodeDraw::DrawText(const TCHAR *pszContent,const AcGePoint3d& ptLocation,AcGiDraw::TextAlignment align,
double dHeight,double dWidthFact,double dRotation,const TCHAR * pszStyle)
{
Acad::ErrorStatus es;
AcDbObjectId idTextStyle;
if (pszStyle == NULL)
{
idTextStyle = m_idTextStyle;
}
else
{
AcDbTextStyleTable *pStyleTable = NULL;
Acad::ErrorStatus es = acdbCurDwg()->getTextStyleTable(pStyleTable, AcDb::kForRead);
AcDbObjectId styleId;
if (es == Acad::eOk)
{
es = pStyleTable->getAt(pszStyle, idTextStyle);
pStyleTable->close();
}
}
AcGiTextStyle textStyle;
AcGeVector3d vDirection(cos(dRotation), sin(dRotation), 0.0);
es = fromAcDbTextStyle(textStyle, idTextStyle);
textStyle.setTextSize(dHeight);
textStyle.setXScale(dWidthFact);
AcGePoint2d ptExt = textStyle.extents(pszContent, Adesk::kFalse, -1, Adesk::kFalse);
double nWidth = ptExt[0];
double nHeight = ptExt[1];
AcGePoint3d ptBase = AcGiDraw::Align2Base(align, ptLocation, AcGePoint3d(nWidth, dHeight, nHeight));
AcGeMatrix3d xform;
xform.setToRotation(dRotation, AcGeVector3d::kZAxis, ptLocation);
ptBase.transformBy(xform);
AcDbText *pText = new AcDbText;
pText->setHorizontalMode(AcDb::kTextLeft);
pText->setVerticalMode(AcDb::kTextBase);
pText->setTextStyle(idTextStyle);
pText->setTextString(pszContent);
pText->setPosition(ptBase);
pText->setAlignmentPoint(ptBase);
pText->setHeight(dHeight);
pText->setOblique(0.0);
pText->setWidthFactor(dWidthFact);
pText->setRotation(dRotation);
pText->setNormal(AcGeVector3d::kZAxis);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pText);
}
void AcGiExplodeDraw::DrawTextFit(const TCHAR *pszText, const AcGePoint3d& pt1, const AcGePoint3d& pt2, double nTextHeight,const TCHAR * pszStyle)
{
if (m_parEntPtrs == NULL) return;
AcGiTextStyle textStyle;
fromAcDbTextStyle(textStyle,pszStyle);
double nTextSize = nTextHeight;
if (nTextSize < 1.e-6)
{
return;
}
Adesk::Boolean bIncludeSpace = Adesk::kTrue;
TCHAR *pTypeface = NULL;
Adesk::Boolean bBold = kFalse, bItalic = kFalse;
#if ARX > 20
Charset charset;
Autodesk::AutoCAD::PAL::FontUtils::FontPitch pitch;
Autodesk::AutoCAD::PAL::FontUtils::FontFamily family;
BOOL bWinFont = (textStyle.font(pTypeface, bBold ,bItalic, charset, pitch, family) == Acad::eOk);
#else
int tmp0, tmp1;
BOOL bWinFont = (textStyle.font(pTypeface, bBold ,bItalic, tmp0, tmp1) == Acad::eOk);
#endif
if (bWinFont)
{
if (!pTypeface || !pTypeface[0])
{
bWinFont = FALSE;
}
}
if (pTypeface != NULL)
{
delete[] pTypeface;
}
AcGePoint2d ptExt = textStyle.extents(pszText, bIncludeSpace, -1, Adesk::kFalse);
double nWidth = ptExt[0];
double nWidthFactor = pt1.distanceTo(pt2) / nWidth;
AcDbObjectId idStyle = GetTextStyle(pszStyle);
AcDbText *pAttrib = new AcDbText;
pAttrib->setHorizontalMode(AcDb::kTextFit);
pAttrib->setVerticalMode(AcDb::kTextBase);
pAttrib->setTextStyle(idStyle);
pAttrib->setTextString(pszText);
pAttrib->setPosition(pt1);
pAttrib->setAlignmentPoint(pt2);
pAttrib->setHeight(nTextHeight);
pAttrib->setWidthFactor(nWidthFactor);
pAttrib->setHorizontalMode(AcDb::kTextFit);
AcGeVector3d vt = pt2 - pt1;
double dAng = vt.convert2d(AcGePlane::kXYPlane).angle();
pAttrib->setRotation(dAng);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pAttrib);
}
void AcGiExplodeDraw::DrawEntity(const AcDbEntity &ent)
{
if (m_parEntPtrs == NULL) return;
if (m_parEntPtrs != NULL)
m_parEntPtrs->append((AcDbEntity*)ent.clone());
}
void AcGiExplodeDraw::DrawEntity(const AcDbEntity* ent)
{
if (m_parEntPtrs == NULL) return;
if (ent == NULL)
return;
if (m_parEntPtrs != NULL)
m_parEntPtrs->append((AcDbEntity*)ent->clone());
}
void AcGiExplodeDraw::DrawSolid(const AcGiPoly2d& polyOutline)
{
}
static AcDbHatch * NewHatchFromPoly2D(const AcGiDraw::AcGiPoly2d &poly, const TCHAR *pszPattern0, double nScl,double rotation)
{
CString sPattern = pszPattern0;
TCHAR *pScale = StrChr(pszPattern0,_T(':'));
if (pScale)
{
*pScale = EOS;
pScale++;
double dScaleAdd = _tstof(pScale);
if (dScaleAdd > 1.0E-6)
{
nScl *= dScaleAdd;
}
}
AcGeDoubleArray bulges;
AcGePoint2dArray vertices;
AcDbHatch *pHatch = new AcDbHatch();
pHatch->setAssociative(Adesk::kFalse);
pHatch->setPatternScale(nScl);
pHatch->setPatternAngle(rotation);
pHatch->setHatchStyle(AcDbHatch::kNormal);
if (pHatch->setPattern(AcDbHatch::kPreDefined, sPattern) != Acad::eOk)
{
DELETE_PTR(pHatch);
return NULL;
}
int nVerts = poly.length();
bulges.setPhysicalLength(0).setLogicalLength(nVerts + 1);
vertices.setPhysicalLength(0).setLogicalLength(nVerts + 1);
for (int i = 0; i< nVerts; i++)
{
vertices[i] = AcGePoint2d(poly.at(i).pt.x,poly.at(i).pt.y);
bulges[i] = tan(poly.at(i).dBulge / 4.0 );
}
vertices[i] = vertices[0];
bulges[i] = bulges[0];
pHatch->appendLoop(AcDbHatch::kExternal|AcDbHatch::kPolyline|AcDbHatch::kDerived,vertices,bulges);
Acad::ErrorStatus es;
if ((es = pHatch->evaluateHatch(true)) != Acad::eOk)
{
DELETE_PTR(pHatch);
return NULL;
}
return pHatch;
}
AcDbHatch * AcGiExplodeDraw::DrawHatch(const AcGiPoly2d& polyOutline, const TCHAR *pszPattern, double nScale,double dRotation )
{
if (m_parEntPtrs == NULL) return NULL;
AcDbHatch *pHatch = NewHatchFromPoly2D(polyOutline, pszPattern, nScale,dRotation);
if (!pHatch)
{
return NULL;
}
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pHatch);
return pHatch;
}
AcDbEntity* AcGiExplodeDraw::DrawMesh(const AcGiPoly2d& polyOut, const AcGeVector3d &vtOffset)
{
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawMesh(const AcGiPoly2d &polyRegion1, const AcGiPoly2d &polyRegion2)
{
return NULL;
}
void AcGiExplodeDraw::DrawShell(const AcGiPoly2d& polyOut, const AcArray<AcGiPoly2d*> &lstPolyIn)
{
}
void AcGiExplodeDraw::DrawBody(const AcGiPoly2d &polySrc, const AcGeVector3d &vtOffset)
{
}
void AcGiExplodeDraw::DrawBody(const AcGiPoly2d &polyOut, const AcGiPoly2d &polyIn, const AcGeVector3d &vtOffset)
{
}
void AcGiExplodeDraw::DrawBody(const AcGiPoly2d &polyOut, const AcArray<AcGiPoly2d*> &lstHoles,const AcGeVector3d &vtOffset)
{
}
void AcGiExplodeDraw::DrawFace(const AcGePoint3d* pVertexList,int nCount)
{
}
void AcGiExplodeDraw::DrawFace(const AcDbFace *pFace, const AcGeMatrix3d *mat)
{
}
void AcGiExplodeDraw::DrawBlock(const AcDbBlockTableRecord &blockRec, const AcGePoint3d &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
{
if (m_parEntPtrs == NULL) return;
if (!blockRec.objectId().isValid())
return;
AcDbBlockReference* pRef = new AcDbBlockReference;
pRef->setBlockTableRecord(blockRec.objectId());
pRef->setPosition(ptInsert);
pRef->setScaleFactors(scales);
pRef->setRotation(nRot);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pRef);
}
void AcGiExplodeDraw::DrawBlock(const AcDbObjectId& idRec, const AcGePoint3d &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
{
if (m_parEntPtrs == NULL) return;
if (!idRec.isValid())
return;
AcDbBlockReference* pRef = new AcDbBlockReference;
pRef->setBlockTableRecord(idRec);
pRef->setPosition(ptInsert);
pRef->setScaleFactors(scales);
pRef->setRotation(nRot);
if (m_parEntPtrs != NULL)
m_parEntPtrs->append(pRef);
}
AcDbEntity* AcGiExplodeDraw::DrawBox(const AcGePoint3d& ptOrg,const AcGeVector3d& vtX,const AcGeVector3d& vtY,const AcGeVector3d& vtZ)
{
AcDbEntity *pEnt = GiDrawUtility::DrawBox(ptOrg, vtZ, vtX.length(), vtY.length(), vtZ.length());
if (pEnt)
{
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawCone(const AcGePoint3d &ptB, const double &Br, const AcGePoint3d &ptT, const double &Tr)
{
AcDbEntity *pEnt = GiDrawUtility::DrawCone(ptB
, ptT - ptB
, Tr
, Br
, AcGeVector3d(ptT - ptB).length()
, 0);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawConeOff( const AcGePoint3d &ptB , const double &Br , const AcGePoint3d &ptT ,const AcGeVector3d& vtDir,const double &Tr)
{
AcDbCircle cirB(ptB,vtDir,Br);
AcDbCircle cirT(ptT,vtDir,Tr);
AcGePoint3d ptS = ptB;
AcGePoint3d ptE = ptB + vtDir;
AcDbLine ln(ptS,ptE);
AcDbEntity *pEnt = GiDrawUtility::DrawLoft(&cirT,&cirB,&ln);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawConeOff(AcDbCurve* pPath,double dSD,double dED)
{
if (pPath != NULL)
{
AcGePoint3d ptS,ptE;
pPath->getStartPoint(ptS);
pPath->getEndPoint(ptE);
AcGeVector3d vtS,vtE;
pPath->getFirstDeriv(ptS,vtS);
pPath->getFirstDeriv(ptE,vtE);
AcDbCircle cirB(ptS,vtS,0.5 * dSD);
AcDbCircle cirT(ptE,vtE,0.5 * dED);
AcDbEntity *pEnt = GiDrawUtility::DrawLoft(&cirT,&cirB,pPath);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawPipe(const AcGePoint3d& ptFrom,const AcGePoint3d& ptTo,double dRadius,double dThick,int nSegs)
{
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(ptFrom, ptTo, dRadius, dThick, nSegs);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawPipe(const AcDbCurve* pCurve,const AcDbRegion* pRegion,const AcGePoint3d& ptCenInRgn)
{
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(pCurve, pRegion, ptCenInRgn);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawPipe(const AcDbCurve* pCurve,const AcDbPolyline* pRegion,const AcGePoint3d& ptCenInRgn)
{
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(pCurve, pRegion, ptCenInRgn);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawPipe(const AcDbCurve *pCurve, double dR)
{
AcDbEntity *pEnt = GiDrawUtility::DrawPipe(pCurve, dR);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawExclude(const AcGePoint3dArray& arSectionPtrs,const AcGeVector3d &vtPath)
{
AcDbEntity* pEnt = GiDrawUtility::DrawExclude(arSectionPtrs, vtPath);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawExclude(const AcDbCurve *pPolyOut, const AcGeVector3d &vtPath)
{
AcDbEntity* pEnt = GiDrawUtility::DrawExclude(pPolyOut, vtPath);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawRevolve(const AcDbLine& lnAxis,const AcGePoint3dArray& arSectionPtrs)
{
AcDbEntity* pEnt = GiDrawUtility::DrawRevolve(lnAxis, arSectionPtrs);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawRevolve(const AcDbLine& lnAxis, const AcDbCurve *pSection)
{
AcDbEntity* pEnt = GiDrawUtility::DrawRevolve(lnAxis, pSection);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity * AcGiExplodeDraw::DrawRevolve(const AcDbLine & lnAxis, const AcDbRegion * pSection)
{
AcDbEntity* pEnt = GiDrawUtility::DrawRevolve(lnAxis, pSection);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawSphere(const AcGePoint3d &ptCenter, const double &dRadius)
{
AcDbEntity* pEnt = GiDrawUtility::DrawSphere(ptCenter, dRadius);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
AcDbEntity* AcGiExplodeDraw::DrawLoft(const AcDbCurve *pTop, const AcDbCurve *pBottom, const AcDbLine *pLine)
{
AcDbEntity* pEnt = GiDrawUtility::DrawLoft(pTop, pBottom, pLine);
if (pEnt)
{
pEnt->setColorIndex(GetColor());
m_parEntPtrs->append(pEnt);
return pEnt;
}
return NULL;
}
Adesk::Boolean AcGiExplodeDraw::pushModelTransform(const AcGeVector3d & vNormal)
{
return Adesk::kFalse;
}
Adesk::Boolean AcGiExplodeDraw::pushModelTransform(const AcGeMatrix3d & xMat)
{
return Adesk::kFalse;
}
Adesk::Boolean AcGiExplodeDraw::popModelTransform()
{
return Adesk::kFalse;
}
void AcGiExplodeDraw::getModelToWorldTransform(AcGeMatrix3d& xform) const
{
}
void AcGiExplodeDraw::getWorldToModelTransform(AcGeMatrix3d& xform) const
{
}
void AcGiExplodeDraw::setExtents(AcGePoint3d *pNewExtents) const
{
}
Adesk::Boolean AcGiExplodeDraw::draw(AcGiDrawable* pDrawable) const
{
return Adesk::kFalse;
}
Adesk::Boolean AcGiExplodeDraw::IsDragging() const
{
return Adesk::kFalse;
}