2190 lines
48 KiB
C++
2190 lines
48 KiB
C++
#include "stdafx.h"
|
|
#include "AcGiViewDraw.h"
|
|
#include "shlwapi.h"
|
|
#include "GiDrawUtility.h"
|
|
#include "EarThwormDef.h"
|
|
#include "AecDbEntityBase.h"
|
|
#include "AecDbCurveBase.h"
|
|
|
|
int AECDLLIMPEXP g_nCirDeviation = 20;
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
namespace
|
|
{
|
|
#ifdef ZWCAD
|
|
|
|
bool isByLayer(Adesk::UInt16 &clr) { return clr == 256; }
|
|
bool isByBlock(Adesk::UInt16 &clr) { return clr == 0; }
|
|
bool isNoColor(Adesk::UInt16 &clr) { return clr == 257; }
|
|
|
|
bool IsCustomColor(Adesk::UInt16 &clr)
|
|
{
|
|
if (isByLayer(clr) || isByBlock(clr) || isNoColor(clr)) return false;
|
|
return true;
|
|
}
|
|
|
|
Adesk::UInt16 layerColor(AcDbObjectId &id)
|
|
{
|
|
Adesk::UInt16 clr(257);
|
|
if (!id.isValid()) return clr;
|
|
|
|
AcDbLayerTableRecordPointer layerRec(id, AcDb::kForRead);
|
|
if (layerRec.openStatus() != Acad::eOk) return clr;
|
|
|
|
clr = layerRec->color().colorIndex();
|
|
|
|
return clr;
|
|
}
|
|
|
|
Adesk::UInt16 layerColor(AcDbEntity *pEnt)
|
|
{
|
|
return layerColor(pEnt->layerId());
|
|
}
|
|
#endif
|
|
}
|
|
|
|
AcGiViewDraw::AcGiViewDraw()
|
|
: m_pWd(NULL), m_pVd(NULL), m_nGsMark(0),m_bInitStyle(FALSE)
|
|
{
|
|
m_plan = AcGePlane::kXYPlane;
|
|
m_dLineWidth = 0.0;
|
|
m_pEntRaw = NULL;
|
|
}
|
|
|
|
AcGiViewDraw::AcGiViewDraw(AcGiWorldDraw *pWd, AcGiViewportDraw *pVd)
|
|
: m_pWd(pWd), m_pVd(pVd), m_nGsMark(0),m_bInitStyle(FALSE)
|
|
{
|
|
m_plan = AcGePlane::kXYPlane;
|
|
m_dLineWidth = 0.0;
|
|
m_pEntRaw = NULL;
|
|
}
|
|
|
|
AcGiViewDraw::~AcGiViewDraw(void)
|
|
{
|
|
}
|
|
|
|
void AcGiViewDraw::SetDrawRaw(AcDbEntity* pEnt)
|
|
{
|
|
m_pEntRaw = pEnt;
|
|
}
|
|
|
|
AcGiCommonDraw * AcGiViewDraw::GetCommonDraw() const
|
|
{
|
|
if (m_pWd != NULL)
|
|
return m_pWd;
|
|
|
|
if (m_pVd != NULL)
|
|
return m_pVd;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void AcGiViewDraw::SetColor(const Adesk::UInt16 color)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setColor(color);
|
|
}
|
|
}
|
|
|
|
Adesk::UInt16 AcGiViewDraw::GetColor() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().color();
|
|
}
|
|
return 255;
|
|
}
|
|
|
|
void AcGiViewDraw::SetTrueColor(const AcCmEntityColor& color)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setTrueColor(color);
|
|
}
|
|
}
|
|
|
|
AcCmEntityColor AcGiViewDraw::GetTrueColor() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().trueColor();
|
|
}
|
|
|
|
AcCmEntityColor cr;
|
|
return cr;
|
|
}
|
|
|
|
bool AcGiViewDraw::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 AcGiViewDraw::SetLayer(const AcDbObjectId layerId)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
if (layerId.isNull())
|
|
{
|
|
pCommDraw->subEntityTraits().setLayer(acdbCurDwg()->clayer());
|
|
return;
|
|
}
|
|
return pCommDraw->subEntityTraits().setLayer(layerId);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::SetLayer(LPCTSTR pszLayer)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcDbLayerTable *pLayerTable;
|
|
Acad::ErrorStatus es = acdbCurDwg()->getLayerTable(pLayerTable, AcDb::kForRead);
|
|
AcDbObjectId idLayer;
|
|
if (es == Acad::eOk)
|
|
{
|
|
es = pLayerTable->getAt(pszLayer, idLayer);
|
|
pLayerTable->close();
|
|
}
|
|
return pCommDraw->subEntityTraits().setLayer(idLayer);
|
|
}
|
|
}
|
|
|
|
AcDbObjectId AcGiViewDraw::GetLayerId() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().layerId();
|
|
}
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
#if ARX > 17
|
|
AcCmTransparency AcGiViewDraw::SetTransparency(const AcCmTransparency& transparency)
|
|
{
|
|
AcCmTransparency tr;
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
tr = pCommDraw->subEntityTraits().transparency();
|
|
pCommDraw->subEntityTraits().setTransparency(transparency);
|
|
}
|
|
return tr;
|
|
}
|
|
#endif
|
|
|
|
void AcGiViewDraw::SetLineType(const AcDbObjectId linetypeId)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
if (linetypeId.isNull())
|
|
{
|
|
pCommDraw->subEntityTraits().setLineType(acdbCurDwg()->celtype());
|
|
return;
|
|
}
|
|
pCommDraw->subEntityTraits().setLineType(linetypeId);
|
|
}
|
|
}
|
|
|
|
AcDbObjectId AcGiViewDraw::GetLineTypeId() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().lineTypeId();
|
|
}
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
void AcGiViewDraw::SetFillType(const AcGiFillType fillType)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setFillType(fillType);
|
|
}
|
|
}
|
|
|
|
AcGiFillType AcGiViewDraw::GetFillType() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().fillType();
|
|
}
|
|
return kAcGiFillAlways;
|
|
}
|
|
|
|
void AcGiViewDraw::SetLineWeight(const AcDb::LineWeight lw)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setLineWeight(lw);
|
|
}
|
|
}
|
|
|
|
AcDb::LineWeight AcGiViewDraw::GetLineWeight() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().lineWeight();
|
|
}
|
|
return AcDb::kLnWt000;
|
|
}
|
|
|
|
void AcGiViewDraw::SetLineWidth(double dW)
|
|
{
|
|
m_dLineWidth = dW;
|
|
}
|
|
|
|
double AcGiViewDraw::GetLineWidth() const
|
|
{
|
|
return m_dLineWidth;
|
|
}
|
|
|
|
void AcGiViewDraw::SetLineTypeScale(double dScale/* = 1.0*/)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setLineTypeScale(dScale);
|
|
}
|
|
}
|
|
|
|
double AcGiViewDraw::GetLineTypeScale() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().lineTypeScale();
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
void AcGiViewDraw::SetThickness(double dThickness)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setThickness(dThickness);
|
|
}
|
|
}
|
|
|
|
double AcGiViewDraw::GetThickness() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().thickness();
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
AcDbObjectId AcGiViewDraw::GetMaterialId() const
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
return pCommDraw->subEntityTraits().materialId();
|
|
}
|
|
return AcDbObjectId::kNull;
|
|
}
|
|
|
|
Acad::ErrorStatus AcGiViewDraw::SetMaterial(AcDbObjectId idMaterial)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setMaterial(idMaterial);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AcGiViewDraw::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 AcGiViewDraw::SetSelectionMarker(int nMark)
|
|
{
|
|
AcGiCommonDraw * pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
pCommDraw->subEntityTraits().setSelectionMarker(nMark);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::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 AcGiViewDraw::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 AcGiViewDraw::GetTextStyle() const
|
|
{
|
|
return m_idTextStyle;
|
|
}
|
|
|
|
AcDbObjectId AcGiViewDraw::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;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawCircle( const AcGePoint3d& center,
|
|
const double radius,
|
|
const AcGeVector3d& normal) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().circle(center,radius,normal);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().circle(center,radius,normal);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawCircle( const AcGePoint3d& pt1,
|
|
const AcGePoint3d& pt2,
|
|
const AcGePoint3d& pt3) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().circle(pt1,pt2,pt3);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().circle(pt1,pt2,pt3);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawCircularArc(const AcGePoint3d& center,
|
|
const double radius,
|
|
const AcGeVector3d& normal,
|
|
const AcGeVector3d& startVector,
|
|
const double sweepAngle,
|
|
const AcGiArcType arcType) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().circularArc(center,radius,normal,startVector,sweepAngle,arcType);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().circularArc(center,radius,normal,startVector,sweepAngle,arcType);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawCircularArc(const AcGePoint3d& start,
|
|
const AcGePoint3d& point,
|
|
const AcGePoint3d& end,
|
|
const AcGiArcType arcType/* = kAcGiArcSimple*/) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().circularArc(start,point,end,arcType);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().circularArc(start,point,end,arcType);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawPolyline(const Adesk::UInt32 nbPoints,const AcGePoint3d* pVertexList,const AcGeVector3d* pNormal) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().polyline(nbPoints,pVertexList,pNormal);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().polyline(nbPoints,pVertexList,pNormal);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawPolygon(const Adesk::UInt32 nbPoints,const AcGePoint3d* pVertexList) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().polygon(nbPoints,pVertexList);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().polygon(nbPoints,pVertexList);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawMesh( const Adesk::UInt32 rows,
|
|
const Adesk::UInt32 columns,
|
|
const AcGePoint3d* pVertexList,
|
|
const AcGiEdgeData* pEdgeData/* = NULL*/,
|
|
const AcGiFaceData* pFaceData/* = NULL*/,
|
|
const AcGiVertexData* pVertexData/* = NULL*/) const
|
|
{
|
|
/*Adesk::Boolean bRes = Adesk::kFalse;
|
|
if (m_pWd != NULL)
|
|
{
|
|
bRes = m_pWd->geometry().mesh(rows,columns,pVertexList,pEdgeData,pFaceData,pVertexData);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
bRes = m_pVd->geometry().mesh(rows,columns,pVertexList,pEdgeData,pFaceData,pVertexData);
|
|
}
|
|
return NULL;
|
|
*/
|
|
|
|
AcDbEntity *pEnt = GiDrawUtility::DrawMesh(rows, columns, pVertexList);
|
|
if (pEnt)
|
|
{
|
|
AcGiViewDraw *pGi = const_cast<AcGiViewDraw *>(this);
|
|
pGi->DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawMeshS( const Adesk::UInt32 rows,
|
|
const Adesk::UInt32 columns,
|
|
const AcGePoint3d* pVertexList,
|
|
bool bHasSeal) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
m_pWd->geometry().mesh(rows,columns,pVertexList,NULL,NULL);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().mesh(rows,columns,pVertexList,NULL,NULL);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawShell( const Adesk::UInt32 nbVertex,
|
|
const AcGePoint3d* pVertexList,
|
|
const Adesk::UInt32 faceListSize,
|
|
const Adesk::Int32* pFaceList,
|
|
const AcGiEdgeData* pEdgeData/* = NULL*/,
|
|
const AcGiFaceData* pFaceData/* = NULL*/,
|
|
const AcGiVertexData* pVertexData/* = NULL*/,
|
|
const struct resbuf* pResBuf/* = NULL*/) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().shell(nbVertex,pVertexList,faceListSize,pFaceList,pEdgeData,pFaceData,pVertexData,pResBuf);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().shell(nbVertex,pVertexList,faceListSize,pFaceList,pEdgeData,pFaceData,pVertexData,pResBuf);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
|
|
Adesk::Boolean AcGiViewDraw::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_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().text(position,normal,direction,height,width,oblique,pMsg);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().text(position,normal,direction,height,width,oblique,pMsg);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
|
|
Adesk::Boolean AcGiViewDraw::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_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().text(position,normal,direction,pMsg,length,raw,pTextStyle);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().text(position,normal,direction,pMsg,length,raw,pTextStyle);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawXline( const AcGePoint3d& one_xline_point,const AcGePoint3d& a_different_xline_point) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().xline(one_xline_point,a_different_xline_point);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().xline(one_xline_point,a_different_xline_point);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawRay(const AcGePoint3d& rays_starting_point,const AcGePoint3d& a_different_ray_point) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().ray(rays_starting_point,a_different_ray_point);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().ray(rays_starting_point,a_different_ray_point);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::DrawPline(const AcDbPolyline& lwBuf,Adesk::UInt32 fromIndex/* = 0*/,Adesk::UInt32 numSegs) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().pline(lwBuf,fromIndex,numSegs);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().pline(lwBuf,fromIndex,numSegs);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
void AcGiViewDraw::DrawPolyline(AcDbPolyline &pline)
|
|
{
|
|
int nOldColor = GetColor();
|
|
double dLTScaleBk = GetLineTypeScale();
|
|
|
|
double nConstWidth = 0.0;
|
|
BOOL bHasConstWidth = (pline.getConstantWidth(nConstWidth) == Acad::eOk);
|
|
AcDbObjectId idLineType = pline.linetypeId();
|
|
AcDbObjectId idOldLineType = GetLineTypeId();
|
|
double dLTScale = pline.linetypeScale();
|
|
|
|
// ÓĂdcľÄŃŐÉŤ
|
|
//int nColorIndex = pline.colorIndex();
|
|
//if (nColorIndex > 0)
|
|
//{
|
|
// SetColor(nColorIndex);
|
|
//}
|
|
|
|
if (!!idLineType)
|
|
{
|
|
SetLineType(idLineType);
|
|
}
|
|
|
|
SetLineTypeScale(dLTScale);
|
|
|
|
if (m_pWd != NULL)
|
|
{
|
|
pline.worldDraw(m_pWd);
|
|
}
|
|
|
|
if (m_pVd != NULL)
|
|
{
|
|
pline.viewportDraw(m_pVd);
|
|
}
|
|
|
|
//if (nColorIndex > 0)
|
|
//{
|
|
// SetColor(nOldColor);
|
|
//}
|
|
|
|
if (!!idLineType)
|
|
{
|
|
SetLineType(idOldLineType);
|
|
}
|
|
|
|
SetLineTypeScale(dLTScaleBk);
|
|
}
|
|
|
|
void AcGiViewDraw::DrawLine(const AcGeLineSeg3d &ln, double nThickness )
|
|
{
|
|
if (ln.length() < .0001)
|
|
return;
|
|
|
|
if (nThickness < 1.0e-8)
|
|
{
|
|
if (m_dLineWidth < 1.e-6)
|
|
{
|
|
AcGePoint3d line[2] = {ln.startPoint(), ln.endPoint()};
|
|
if (m_pWd != NULL)
|
|
{
|
|
m_pWd->geometry().polyline(2,line);
|
|
}
|
|
if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().polyline(2,line);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptGe[4];
|
|
|
|
ptGe[0] = ln.startPoint();
|
|
ptGe[1] = ln.endPoint();
|
|
|
|
AcGeVector3d vtL = ptGe[1] - ptGe[0];
|
|
AcGeVector3d vtX;
|
|
if (vtL.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
vtX = AcGeVector3d::kYAxis;
|
|
}
|
|
else
|
|
{
|
|
vtX = AcGeVector3d::kZAxis;
|
|
}
|
|
|
|
AcGeVector3d vtY = vtX.crossProduct(vtL);
|
|
vtY.normalize();
|
|
|
|
ptGe[0] += 0.5 * m_dLineWidth * vtY;
|
|
|
|
ptGe[3] = ptGe[0];
|
|
ptGe[3] -= m_dLineWidth * vtY;
|
|
|
|
ptGe[1] += 0.5 * m_dLineWidth * vtY;
|
|
ptGe[2] = ptGe[1];
|
|
ptGe[2] -= m_dLineWidth * vtY;
|
|
|
|
if (m_pWd != NULL)
|
|
{
|
|
AcGiFillType eFill = m_pWd->subEntityTraits().fillType();
|
|
m_pWd->subEntityTraits().setFillType(kAcGiFillAlways);
|
|
|
|
m_pWd->geometry().polygon(4,ptGe);
|
|
|
|
m_pWd->subEntityTraits().setFillType(eFill);
|
|
return;
|
|
}
|
|
|
|
if (m_pVd != NULL)
|
|
{
|
|
AcGiFillType eFill = m_pVd->subEntityTraits().fillType();
|
|
m_pVd->subEntityTraits().setFillType(kAcGiFillAlways);
|
|
|
|
m_pVd->geometry().polygon(4,ptGe);
|
|
|
|
m_pVd->subEntityTraits().setFillType(eFill);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int nVertexNum = 4;
|
|
AcGePoint3d *ptArray = new AcGePoint3d[nVertexNum];
|
|
ptArray[0] = ln.startPoint();
|
|
ptArray[1] = ln.endPoint();
|
|
ptArray[2] = ptArray[0];
|
|
ptArray[2].z += nThickness;
|
|
ptArray[3] = ptArray[1];
|
|
ptArray[3].z += nThickness;
|
|
|
|
AcGiEdgeData edge;
|
|
Adesk::UInt8 *visibleData = new Adesk::UInt8[4];
|
|
for (int j = 0; j < 2; j++)
|
|
{
|
|
visibleData[j] = kAcGiVisible;
|
|
}
|
|
|
|
visibleData[2] = kAcGiVisible;
|
|
visibleData[3] = kAcGiVisible;
|
|
edge.setVisibility(visibleData);
|
|
DrawMesh(2, 2, (AcGePoint3d *)ptArray, &edge);
|
|
|
|
delete[] ptArray;
|
|
delete[] visibleData;
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::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);
|
|
|
|
if (m_pWd)
|
|
{
|
|
m_pWd->geometry().text(ptBase, AcGeVector3d::kZAxis, vDirection,pszContent, -1, Adesk::kFalse, textStyle);
|
|
}
|
|
else
|
|
{
|
|
m_pVd->geometry().text(ptBase, AcGeVector3d::kZAxis, vDirection,pszContent, -1, Adesk::kFalse, textStyle);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawTextFit(const TCHAR *pszText, const AcGePoint3d& pt1, const AcGePoint3d& pt2, double nTextHeight,const TCHAR * pszStyle)
|
|
{
|
|
if (pszStyle == NULL)
|
|
return;
|
|
|
|
double nRot = ads_angle(asDblArray(pt1), asDblArray(pt2));
|
|
AcGeVector3d vDirection(cos(nRot), sin(nRot), 0.0);
|
|
double nTextSize = nTextHeight;
|
|
|
|
if (nTextSize < 1.0E-5)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AcGiTextStyle textStyle;
|
|
AcDbObjectId idTextStyle;
|
|
AcDbTextStyleTable *pStyleTable = NULL;
|
|
Acad::ErrorStatus es = acdbCurDwg()->getTextStyleTable(pStyleTable, AcDb::kForRead);
|
|
AcDbObjectId styleId;
|
|
if (es == Acad::eOk)
|
|
{
|
|
es = pStyleTable->getAt(pszStyle, idTextStyle);
|
|
pStyleTable->close();
|
|
}
|
|
es = fromAcDbTextStyle(textStyle, idTextStyle);
|
|
|
|
double nWidthFactor = textStyle.xScale();
|
|
double nOldXScale = nWidthFactor;
|
|
double nOldSize = textStyle.textSize();
|
|
|
|
textStyle.setTextSize(nTextSize);
|
|
Adesk::Boolean bIncludeSpace = Adesk::kTrue;
|
|
|
|
//Windows×ÖĚĺśźĐčŇŞ°üŔ¨Ç°şóżŐĎś
|
|
TCHAR *pTypeface = NULL;
|
|
Adesk::Boolean bBold, bItalic;
|
|
#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)
|
|
{
|
|
delete[] pTypeface;
|
|
}
|
|
|
|
if (bWinFont)
|
|
{
|
|
bIncludeSpace = Adesk::kTrue;
|
|
}
|
|
else
|
|
{
|
|
bIncludeSpace = Adesk::kFalse;
|
|
const TCHAR *pShxFile = m_textStyle.fileName();
|
|
|
|
if (pShxFile)
|
|
{
|
|
TCHAR sDrive[MAX_PATH],sDir[MAX_PATH],sFileName[MAX_PATH],sExt[MAX_PATH];
|
|
#ifdef _UNICODE
|
|
_wsplitpath(pShxFile, sDrive, sDir, sFileName, sExt);
|
|
#else
|
|
_splitpath(pShxFile, sDrive, sDir, sFileName, sExt);
|
|
#endif
|
|
_tcsupr(sFileName);
|
|
TCHAR sFilter[] = _T("GBE*,GOTH*,ISO*,SCRIPT*,ROMAN*");
|
|
|
|
if (ads_wcmatch(sFileName, sFilter) == RTNORM)
|
|
{
|
|
bIncludeSpace = Adesk::kTrue;
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGePoint2d ptExt = textStyle.extents(pszText, bIncludeSpace, -1, Adesk::kFalse);
|
|
double nWidth = ptExt[0];
|
|
double nHeight = ptExt[1];
|
|
nWidthFactor *= pt1.distanceTo(pt2) / nWidth;
|
|
|
|
m_textStyle.setXScale(nWidthFactor);
|
|
|
|
if (m_pWd)
|
|
{
|
|
m_pWd->geometry().text(pt1, AcGeVector3d::kZAxis, vDirection, pszText, -1, Adesk::kFalse, textStyle);
|
|
}
|
|
else if (m_pVd)
|
|
{
|
|
m_pVd->geometry().text(pt1, AcGeVector3d::kZAxis, vDirection, pszText, -1, Adesk::kFalse, textStyle);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawEntity(const AcDbEntity* pEnt)
|
|
{
|
|
if (pEnt != NULL)
|
|
DrawEntity(*pEnt);
|
|
}
|
|
|
|
Acad::ErrorStatus AcGiViewDraw::DrawBlackHole(AcDb3dSolid *pSolid)
|
|
{
|
|
AecDbEntityBase* pEntBase = AecDbEntityBase::cast(m_pEntRaw);
|
|
if (pEntBase != NULL)
|
|
{
|
|
if (!pEntBase->IsIn3DBuffer(pSolid))
|
|
{
|
|
pEntBase->DrawBlackHole(pSolid);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
AecDbCurveBase* pCrvBase = AecDbCurveBase::cast(m_pEntRaw);
|
|
if (pCrvBase != NULL)
|
|
{
|
|
if (!pCrvBase->IsIn3DBuffer(pSolid))
|
|
{
|
|
pCrvBase->DrawBlackHole(pSolid);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
void AcGiViewDraw::DrawEntity(const AcDbEntity &ent)
|
|
{
|
|
//DrawBlackHole
|
|
if (m_pEntRaw != NULL && ent.isKindOf(AcDb3dSolid::desc()))
|
|
{
|
|
AcDb3dSolid *pSolid = (AcDb3dSolid *)(&ent);
|
|
DrawBlackHole(pSolid);
|
|
}
|
|
|
|
if (ent.isKindOf(AcDbFace::desc()))
|
|
{
|
|
AcDbFace *pFace = (AcDbFace *)(&ent);
|
|
DrawFace(pFace);
|
|
|
|
AcGePoint3d ptArray[4];
|
|
Adesk::UInt8 edgeVisible[4];
|
|
AcGiEdgeData edge;
|
|
pFace->getVertexAt(0, ptArray[0]);
|
|
pFace->getVertexAt(1, ptArray[1]);
|
|
pFace->getVertexAt(2, ptArray[3]);
|
|
pFace->getVertexAt(3, ptArray[2]);
|
|
|
|
Adesk::Boolean bVisible = Adesk::kTrue;
|
|
pFace->isEdgeVisibleAt(0, bVisible); edgeVisible[0] = bVisible;
|
|
pFace->isEdgeVisibleAt(1, bVisible); edgeVisible[3] = bVisible;
|
|
pFace->isEdgeVisibleAt(2, bVisible); edgeVisible[1] = bVisible;
|
|
pFace->isEdgeVisibleAt(3, bVisible); edgeVisible[2] = bVisible;
|
|
edge.setVisibility(edgeVisible);
|
|
|
|
DrawMesh(2,2, (AcGePoint3d *)ptArray, &edge);
|
|
}
|
|
else if (ent.isKindOf(AcDbSolid::desc()))
|
|
{
|
|
AcGePoint3d pt[4];
|
|
AcDbSolid &solid = (AcDbSolid &)ent;
|
|
|
|
for (int n = 0; n < 4; n++)
|
|
{
|
|
solid.getPointAt(n, pt[n]);
|
|
}
|
|
|
|
AcGiPoly2d poly2d;
|
|
Vertex3d vrt;
|
|
vrt.pt = pt[0];
|
|
vrt.dBulge = 0.0;
|
|
poly2d.append(vrt);
|
|
|
|
vrt.pt = pt[1];
|
|
poly2d.append(vrt);
|
|
|
|
vrt.pt = pt[3];
|
|
poly2d.append(vrt);
|
|
|
|
if (pt[2].distanceTo(pt[3]) > 1.e-3)
|
|
{
|
|
vrt.pt = pt[2];
|
|
poly2d.append(vrt);
|
|
}
|
|
DrawSolid(poly2d);
|
|
}
|
|
else if (ent.isKindOf(AcDbLine::desc()))
|
|
{
|
|
AcDbLine *pLine = (AcDbLine *)(&ent);
|
|
AcGeLineSeg3d ln(pLine->startPoint(),pLine->endPoint());
|
|
DrawLine(ln,0.0);
|
|
}
|
|
else if (ent.isKindOf(AcDbArc::desc()))
|
|
{
|
|
AcDbArc &dbArc = (AcDbArc &)ent;
|
|
AcGePoint3d ptSta,ptMid,ptEnd;
|
|
dbArc.getStartPoint(ptSta);
|
|
|
|
double dSta = 0.0,dEnd = 0.0;
|
|
dbArc.getStartParam(dSta);
|
|
dbArc.getEndParam(dEnd);
|
|
|
|
dbArc.getPointAtParam((dSta+dEnd) / 2.0,ptMid);
|
|
dbArc.getEndPoint(ptEnd);
|
|
|
|
DrawCircularArc(ptSta,ptMid,ptEnd);
|
|
}
|
|
else if (ent.isKindOf(AcDbBlockReference::desc()))
|
|
{
|
|
AcDbBlockReference& insert = (AcDbBlockReference&)ent;
|
|
AcDbObjectId idRec = insert.blockTableRecord();
|
|
|
|
AcDbBlockTableRecord* pRec = NULL;
|
|
if ( Acad::eOk == acdbOpenObject((AcDbBlockTableRecord*& )pRec,idRec,AcDb::kForRead))
|
|
{
|
|
DrawBlock(*pRec,insert.position(),insert.scaleFactors(),insert.rotation(),FALSE);
|
|
pRec->close();
|
|
}
|
|
}
|
|
else if (ent.isKindOf(AcDbText::desc()))
|
|
{
|
|
if (m_pWd)
|
|
{
|
|
((AcDbEntity&)ent).worldDraw(m_pWd);
|
|
}
|
|
else if(m_pVd != NULL)
|
|
{
|
|
((AcDbEntity&)ent).viewportDraw(m_pVd);
|
|
}
|
|
}
|
|
else if(ent.isKindOf(AcDbPolyline::desc()))
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(&ent);
|
|
if (pPl != NULL)
|
|
{
|
|
DrawPolyline(*pPl);
|
|
}
|
|
}
|
|
else if (ent.isKindOf(AcDb3dPolyline::desc()))
|
|
{
|
|
AcDbEntity* pEnt = (AcDbEntity*)&ent;
|
|
if (m_pWd != NULL)
|
|
{
|
|
pEnt->worldDraw(m_pWd);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
pEnt->viewportDraw(m_pVd);
|
|
}
|
|
}
|
|
else if (ent.isKindOf(AcDb3dSolid::desc()))
|
|
{
|
|
AcDb3dSolid *pSo(AcDb3dSolid::cast(&ent));
|
|
if (pSo && pSo->isNull())
|
|
{
|
|
#ifndef NDEBUG
|
|
acutPrintf(_T("\nThe 3DSOLID does not have a ShapeManager object. "));
|
|
#endif
|
|
return;
|
|
}
|
|
|
|
//DrawBlackHole
|
|
if (m_pEntRaw != NULL)
|
|
DrawBlackHole(pSo);
|
|
|
|
AcGiDrawable *pDrable = pSo->drawable();
|
|
if (!pDrable) return;
|
|
|
|
if (m_pWd)
|
|
m_pWd->rawGeometry()->draw(pDrable);
|
|
else if (m_pVd)
|
|
m_pVd->rawGeometry()->draw(pDrable);
|
|
}
|
|
else
|
|
{
|
|
AcDbEntity* pEnt = (AcDbEntity*)&ent;
|
|
AcGiDrawable* pDrable = pEnt->drawable();
|
|
if (pDrable != NULL)
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
if (Adesk::kTrue != m_pWd->rawGeometry()->draw(pDrable))
|
|
{
|
|
pEnt->worldDraw(m_pWd);
|
|
}
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
#ifndef ZWCAD
|
|
Adesk::UInt32 bit = pDrable->viewportDrawLogicalFlags(m_pVd);
|
|
if (Adesk::kTrue != m_pVd->rawGeometry()->draw(pDrable))
|
|
{
|
|
pEnt->viewportDraw(m_pVd);
|
|
}
|
|
#else
|
|
// ÖĐÍűƽ̨ rawGeometry()->draw()şŻĘýÓĐÎĘĚ⣏ťćÖƲťłöŃŐÉŤŁŹ˛˘ÇŇťáÇĺżŐdcľÄŃŐÉŤÉčÖĂ
|
|
|
|
// ťćÖĆĘąŁŹŇÔdcľÄŃŐɍΪן
|
|
Adesk::UInt16 dcClr = m_pVd->subEntityTraits().color();
|
|
Adesk::UInt16 entClr = pEnt->colorIndex();
|
|
|
|
if (!isByBlock(dcClr)) // byblock ˛ť´ŚŔí
|
|
{
|
|
Adesk::UInt16 clr(256);
|
|
if (isByLayer(dcClr))
|
|
clr = layerColor(GetLayerId());
|
|
else
|
|
clr = dcClr;
|
|
pEnt->setColorIndex(dcClr);
|
|
}
|
|
|
|
// ťćÖĆ
|
|
m_pVd->rawGeometry()->draw(pDrable);
|
|
|
|
// ťšÔ
|
|
m_pVd->subEntityTraits().setColor(dcClr);
|
|
if (entClr != 257)
|
|
pEnt->setColorIndex(entClr);
|
|
else
|
|
pEnt->setColorIndex(dcClr);
|
|
#endif
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
pEnt->worldDraw(m_pWd);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
pEnt->viewportDraw(m_pVd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawSolid(const AcGiPoly2d& polyOutline)
|
|
{
|
|
AcGiFillType fillMode = GetCommonDraw()->subEntityTraits().fillType();
|
|
GetCommonDraw()->subEntityTraits().setFillType(kAcGiFillAlways);
|
|
|
|
AcArray<AcGiPoly2d*> lstPolyIn;
|
|
DrawShell(polyOutline,lstPolyIn);
|
|
GetCommonDraw()->subEntityTraits().setFillType(fillMode);
|
|
}
|
|
|
|
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] = poly.at(i).dBulge;
|
|
}
|
|
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* AcGiViewDraw::DrawHatch(const AcGiPoly2d& polyOutline, const TCHAR *pszPattern, double nScale,double dRotation )
|
|
{
|
|
AcDbHatch *pHatch = NewHatchFromPoly2D(polyOutline, pszPattern, nScale,dRotation);
|
|
if (!pHatch)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
pHatch->setColorIndex(GetColor());
|
|
pHatch->setLayer(GetLayerId());
|
|
|
|
if (m_pWd != NULL)
|
|
{
|
|
pHatch->worldDraw(m_pWd);
|
|
}
|
|
|
|
if (m_pVd != NULL)
|
|
{
|
|
pHatch->viewportDraw(m_pVd);
|
|
}
|
|
return pHatch;
|
|
}
|
|
|
|
static bool IsClosed(const AcArray<AcGiDraw::Vertex3d>& poly)
|
|
{
|
|
if (poly.length() == 0)
|
|
return false;
|
|
|
|
if (poly.last().pt.distanceTo(poly.first().pt) < 1.e-6)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
typedef struct XArc
|
|
{
|
|
double m_dRadius;
|
|
AcGePoint3d m_ptCenter;
|
|
double m_dstartAngle;
|
|
double m_dendAngle;
|
|
}XARC;
|
|
|
|
static double Bulge(XArc& arc)
|
|
{
|
|
ads_real dBulge = arc.m_dendAngle - arc.m_dstartAngle;
|
|
if (dBulge < -1E-6)
|
|
{
|
|
dBulge = 2.0 * PI + dBulge;
|
|
}
|
|
|
|
return dBulge;
|
|
}
|
|
|
|
bool FormatArc(XArc& arc,const AcGePoint3d &spt, const AcGePoint3d &ept, ads_real dang)
|
|
{
|
|
ads_real ddis = ads_distance(asDblArray(spt), asDblArray(ept)) / 2.0;
|
|
ads_real dangTmp = fabs(dang / 2.0);
|
|
arc.m_dRadius = ddis / sin(dangTmp);
|
|
ads_real dcosr = fabs( arc.m_dRadius * cos(dangTmp));
|
|
|
|
AcGePoint3d ptc1, ptc2, mpt;
|
|
|
|
mpt.x = spt.x + ept.x;
|
|
mpt.y = spt.y + ept.y;
|
|
mpt.z = spt.z + ept.z;
|
|
mpt.x *= 0.5;
|
|
mpt.y *= 0.5;
|
|
mpt.z *= 0.5;
|
|
|
|
ads_polar(asDblArray(mpt), ads_angle(asDblArray(spt), asDblArray(ept)) - PI / 2.0, dcosr, asDblArray(ptc1));
|
|
ads_polar(asDblArray(mpt), ads_angle(asDblArray(spt), asDblArray(ept)) + PI / 2.0, dcosr, asDblArray(ptc2));
|
|
|
|
if (dang > 0)
|
|
{
|
|
if (fabs(dang) > PI)
|
|
{
|
|
arc.m_ptCenter = ptc1;
|
|
}
|
|
else
|
|
{
|
|
arc.m_ptCenter = ptc2;
|
|
}
|
|
|
|
arc.m_dstartAngle = ads_angle(asDblArray(arc.m_ptCenter), asDblArray(spt));
|
|
arc.m_dendAngle = ads_angle(asDblArray(arc.m_ptCenter), asDblArray(ept));
|
|
}
|
|
else
|
|
{
|
|
if (fabs(dang) > PI)
|
|
{
|
|
arc.m_ptCenter = ptc2;
|
|
}
|
|
else
|
|
{
|
|
arc.m_ptCenter = ptc1;
|
|
}
|
|
|
|
arc.m_dstartAngle = ads_angle(asDblArray(arc.m_ptCenter), asDblArray(ept));
|
|
arc.m_dendAngle = ads_angle(asDblArray(arc.m_ptCenter), asDblArray(spt));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static int MakeOpenPolySegs(const AcArray<AcGiDraw::Vertex3d>& poly,AcArray<AcGiDraw::Vertex3d>& pts, int nCirDiv = 30)
|
|
{
|
|
AcGiDraw::Vertex3d vtx;
|
|
AcGePoint3d pt1,pt2,pt;
|
|
int nNum = 0;
|
|
double dDincrement = 0.0;
|
|
|
|
int nLen = poly.length();
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
vtx = poly[i];
|
|
|
|
if (fabs(vtx.dBulge) < 1.e-6 ) //LINE
|
|
{
|
|
pts.append(vtx);
|
|
|
|
if (i == nLen - 1 && IsClosed(poly) )
|
|
{
|
|
//×îşóŇťľăşÍĆđľăÖŘşĎ
|
|
pts.append(poly.first());
|
|
}
|
|
}
|
|
else //ARC
|
|
{
|
|
if (!IsClosed(poly) && i == nLen - 1)
|
|
{
|
|
//˛ťˇâąŐľÄ×îşóŇťľă
|
|
pts.append( poly.at(i) );
|
|
return RTNORM;
|
|
}
|
|
|
|
//FORMAT ARC
|
|
pt1 = poly.at(i).pt;
|
|
if (i == nLen - 1)
|
|
{
|
|
pt2 = poly.at(0).pt;
|
|
}
|
|
else
|
|
{
|
|
pt2 = poly.at(i + 1).pt;
|
|
}
|
|
XArc arc;
|
|
FormatArc(arc,pt1, pt2, poly.at(i).dBulge);
|
|
|
|
nNum = (int)( Bulge(arc) / (2.0 * PI) * nCirDiv);
|
|
nNum = max(nNum, 1);
|
|
dDincrement = Bulge(arc) / nNum;
|
|
|
|
if (i == nLen-1 && IsClosed(poly) )
|
|
{
|
|
//×îşóŇťˇâąŐťĄśÎ
|
|
nNum += 1;
|
|
}
|
|
|
|
for (int n = 0; n < nNum; n++)
|
|
{
|
|
if ( poly.at(i).dBulge > 0)
|
|
{
|
|
ads_polar( asDblArray(arc.m_ptCenter), arc.m_dstartAngle + dDincrement * n, arc.m_dRadius, asDblArray(pt));
|
|
}
|
|
else
|
|
{
|
|
ads_polar(asDblArray(arc.m_ptCenter), arc.m_dendAngle - dDincrement * n, arc.m_dRadius, asDblArray(pt));
|
|
}
|
|
|
|
vtx.pt = pt;
|
|
vtx.dBulge = 0.0;
|
|
pts.append(vtx);
|
|
}
|
|
}
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawMesh(const AcGiPoly2d& polyOut, const AcGeVector3d &vtOffset)
|
|
{
|
|
AcGiPoly2d poly;
|
|
MakeOpenPolySegs(polyOut,poly,g_nCirDeviation);
|
|
|
|
int nColumn = poly.length();
|
|
int nRow = 2;
|
|
|
|
AcGePoint3d *ptArray = new AcGePoint3d[nColumn * nRow];
|
|
for (int m = 0; m < nRow; m++)
|
|
{
|
|
for (int n = 0; n < nColumn; n++)
|
|
{
|
|
int nBase = m * nColumn;
|
|
ptArray[nBase + n] = poly[n].pt;
|
|
|
|
if (m == 1)
|
|
{
|
|
ptArray[nBase + n] += vtOffset;
|
|
}
|
|
}
|
|
}
|
|
|
|
// if (m_pWd)
|
|
// {
|
|
// m_pWd->geometry().mesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
// }
|
|
// else if (m_pVd != NULL)
|
|
// {
|
|
// m_pVd->geometry().mesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
// }
|
|
|
|
AcDbEntity *pEnt = GiDrawUtility::DrawMesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
if (pEnt)
|
|
{
|
|
delete[] ptArray;
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
|
|
delete[] ptArray;
|
|
return NULL;
|
|
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawMesh(const AcGiPoly2d &polyRegion1, const AcGiPoly2d &polyRegion2)
|
|
{
|
|
AcGiPoly2d poly1, poly2;
|
|
MakeOpenPolySegs(polyRegion1,poly1);
|
|
MakeOpenPolySegs(polyRegion2,poly2);
|
|
|
|
if (poly1.length() != poly2.length())
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
int nColumn = poly1.length();
|
|
int nRow = 2;
|
|
AcGePoint3d *ptArray = new AcGePoint3d[nColumn * nRow];
|
|
|
|
for (int m = 0; m < nRow; m++)
|
|
{
|
|
for (int n = 0; n < nColumn; n++)
|
|
{
|
|
int nBase = m * nColumn;
|
|
|
|
if (!m)
|
|
{
|
|
ptArray[nBase + n] = poly1[n].pt;
|
|
}
|
|
else
|
|
{
|
|
ptArray[nBase + n] = poly2[n].pt;
|
|
}
|
|
}
|
|
}
|
|
|
|
// if (m_pWd)
|
|
// {
|
|
// m_pWd->geometry().mesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
// }
|
|
// else if (m_pVd != NULL)
|
|
// {
|
|
// m_pVd->geometry().mesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
// }
|
|
//
|
|
// delete [] ptArray;
|
|
|
|
AcDbEntity *pEnt = GiDrawUtility::DrawMesh(nRow, nColumn, (AcGePoint3d *)ptArray);
|
|
if (pEnt)
|
|
{
|
|
delete[] ptArray;
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
|
|
delete[] ptArray;
|
|
return NULL;
|
|
}
|
|
|
|
void AcGiViewDraw::DrawShell(const AcGiPoly2d& polyOut1, const AcArray<AcGiPoly2d*> &lstPolyIn0)
|
|
{
|
|
if (!IsClosed(polyOut1))
|
|
return;
|
|
|
|
AcGiPoly2d polyOut;
|
|
MakeOpenPolySegs(polyOut1,polyOut, g_nCirDeviation);
|
|
|
|
AcGiPoly2d *pPoly = NULL;
|
|
AcArray<AcGiPoly2d*> lstPolyIn1;
|
|
for (int mm = 0; mm < lstPolyIn0.length(); mm++)
|
|
{
|
|
pPoly = new AcGiPoly2d;
|
|
const AcGiPoly2d &rPoly = *lstPolyIn0[mm];
|
|
|
|
MakeOpenPolySegs(rPoly,*pPoly,g_nCirDeviation);
|
|
lstPolyIn1.append(pPoly);
|
|
}
|
|
|
|
int nLen = polyOut.length();
|
|
Adesk::UInt32 nVertex = nLen;
|
|
Adesk::UInt32 nFace = lstPolyIn1.length() + 1;
|
|
|
|
for (int i = 0; i < lstPolyIn1.length(); i++)
|
|
{
|
|
nVertex += lstPolyIn1[i]->length();
|
|
}
|
|
|
|
AcGePoint3d *pVertexList = new AcGePoint3d[nVertex];
|
|
Adesk::Int32 *pFaceList = new Adesk::Int32[nFace + nVertex];
|
|
|
|
//1. ľÚŇť¸öĂć
|
|
Adesk::Int32 *pFace = pFaceList;
|
|
*pFace = polyOut.length();
|
|
|
|
int nIdVertex = 0;
|
|
for (i = 0; i < nLen; i++, nIdVertex++)
|
|
{
|
|
pFace++;
|
|
*pFace = nIdVertex;
|
|
pVertexList[nIdVertex] = polyOut[i].pt;
|
|
}
|
|
|
|
//2. ż×ś´
|
|
for (i = 0; i < lstPolyIn1.length(); i++)
|
|
{
|
|
AcGiPoly2d &poly = *lstPolyIn1[i];
|
|
|
|
int nnn = poly.length();
|
|
pFace++;
|
|
*pFace = -nnn; //śĽľăĘý
|
|
|
|
for (int j = 0; j < nnn; j++,nIdVertex++)
|
|
{
|
|
pVertexList[nIdVertex] = poly[j].pt;
|
|
pFace++;
|
|
*pFace = nIdVertex;
|
|
}
|
|
}
|
|
|
|
//3.ťćÖĆ
|
|
if (m_pWd)
|
|
{
|
|
m_pWd->geometry().shell(nVertex, (AcGePoint3d *)pVertexList, nFace + nVertex, pFaceList);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().shell(nVertex, (AcGePoint3d *)pVertexList, nFace + nVertex, pFaceList);
|
|
}
|
|
|
|
delete[] pVertexList;
|
|
delete[] pFaceList;
|
|
|
|
for (int n = 0;n < lstPolyIn1.length();n++)
|
|
{
|
|
pPoly = lstPolyIn1.at(n);
|
|
DELETE_PTR(pPoly);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawBody(const AcGiPoly2d &polySrc, const AcGeVector3d &vtOffset)
|
|
{
|
|
AcArray<AcGiPoly2d*> lstPoly;
|
|
DrawBody(polySrc, lstPoly, vtOffset);
|
|
}
|
|
|
|
void AcGiViewDraw::DrawBody(const AcGiPoly2d &polyOut, const AcGiPoly2d &polyIn, const AcGeVector3d &vtOffset)
|
|
{
|
|
AcArray<AcGiPoly2d*> lstPoly;
|
|
lstPoly.append(new AcGiPoly2d(polyIn));
|
|
DrawBody(polyOut, lstPoly, vtOffset);
|
|
|
|
AcGiPoly2d* pPoly = NULL;
|
|
for (int n = 0;n < lstPoly.length();n++)
|
|
{
|
|
pPoly = lstPoly.at(n);
|
|
DELETE_PTR(pPoly);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawBody(const AcGiPoly2d &polyOut, const AcArray<AcGiPoly2d*> &lstHoles,const AcGeVector3d &vt)
|
|
{
|
|
DrawShell(polyOut, lstHoles);
|
|
|
|
AcGiPoly2d polyUp(polyOut);
|
|
for (int i = 0; i < polyUp.length(); i++)
|
|
{
|
|
polyUp[i].pt += vt;
|
|
}
|
|
|
|
AcArray<AcGiPoly2d*> lstHoleUp;
|
|
for (int n = 0; n < lstHoles.length(); n++)
|
|
{
|
|
AcGiPoly2d *pHole = new AcGiPoly2d(*lstHoles[n]);
|
|
for (int j = 0; j < pHole->length(); j++)
|
|
{
|
|
pHole->at(j).pt += vt;
|
|
}
|
|
lstHoleUp.append(pHole);
|
|
}
|
|
|
|
DrawShell(polyUp, lstHoleUp);
|
|
|
|
DrawMesh(polyOut, vt);
|
|
for (i = 0; i < lstHoles.length(); i++)
|
|
{
|
|
DrawMesh(*lstHoles[i], vt);
|
|
}
|
|
|
|
AcGiPoly2d* pPoly = NULL;
|
|
for (int n = 0;n < lstHoleUp.length();n++)
|
|
{
|
|
pPoly = lstHoleUp.at(n);
|
|
DELETE_PTR(pPoly);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawFace(const AcGePoint3d* pVertexList,int nCount)
|
|
{
|
|
if (nCount != 4)
|
|
return;
|
|
|
|
Adesk::UInt8 edgeVisible[4];
|
|
AcGiEdgeData edge;
|
|
Adesk::Boolean bVisible = Adesk::kTrue;
|
|
|
|
edgeVisible[0] = 1;
|
|
edgeVisible[1] = 1;
|
|
edgeVisible[2] = 1;
|
|
edgeVisible[3] = 1;
|
|
edge.setVisibility(edgeVisible);
|
|
|
|
if (m_pWd)
|
|
{
|
|
m_pWd->geometry().mesh(2, 2, (AcGePoint3d *)pVertexList, &edge);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().mesh(2, 2, (AcGePoint3d *)pVertexList, &edge);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::DrawFace(const AcDbFace *pFace, const AcGeMatrix3d *mat)
|
|
{
|
|
AcGePoint3d ptArray[4];
|
|
Adesk::UInt8 edgeVisible[4];
|
|
AcGiEdgeData edge;
|
|
pFace->getVertexAt(0, ptArray[0]);
|
|
pFace->getVertexAt(1, ptArray[1]);
|
|
pFace->getVertexAt(2, ptArray[3]);
|
|
pFace->getVertexAt(3, ptArray[2]);
|
|
|
|
Adesk::Boolean bVisible = Adesk::kTrue;
|
|
pFace->isEdgeVisibleAt(0, bVisible);
|
|
edgeVisible[0] = bVisible;
|
|
pFace->isEdgeVisibleAt(1, bVisible);
|
|
edgeVisible[3] = bVisible;
|
|
pFace->isEdgeVisibleAt(2, bVisible);
|
|
edgeVisible[1] = bVisible;
|
|
pFace->isEdgeVisibleAt(3, bVisible);
|
|
edgeVisible[2] = bVisible;
|
|
edge.setVisibility(edgeVisible);
|
|
|
|
if (mat)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
ptArray[i].transformBy(*mat);
|
|
}
|
|
}
|
|
DrawMeshS(2, 2, (AcGePoint3d *)ptArray,true);
|
|
}
|
|
|
|
void AcGiViewDraw::BackUpGiSubEntityTraits(AecGiSubEntityTraits &prop)
|
|
{
|
|
prop.m_nColor = GetColor();
|
|
prop.m_idLayer = GetLayerId();
|
|
prop.m_idLineType = GetLineTypeId();
|
|
prop.m_idMaterial = GetMaterialId();
|
|
}
|
|
|
|
void AcGiViewDraw::RestoreGiSubEntityTraits(AecGiSubEntityTraits prop)
|
|
{
|
|
SetLayer(prop.m_idLayer);
|
|
SetLineType(prop.m_idLineType);
|
|
SetColor(prop.m_nColor);
|
|
SetMaterial(prop.m_idMaterial);
|
|
}
|
|
|
|
AcGeMatrix3d AcGiViewDraw::BlockTransform(const AcDbBlockReference *pInsert)
|
|
{
|
|
AcGePoint3d ptBase, ptInsert = pInsert->position();
|
|
AcGeScale3d s = pInsert->scaleFactors();
|
|
double rot = pInsert->rotation();
|
|
AcDbObjectId idBlock = pInsert->blockTableRecord();
|
|
AcDbBlockTableRecord *pBlock = NULL;
|
|
|
|
acdbOpenObject(pBlock, idBlock, AcDb::kForRead, true);
|
|
if (NULL != pBlock)
|
|
{
|
|
ptBase = pBlock->origin();
|
|
pBlock->close();
|
|
}
|
|
AcGeMatrix3d result = pInsert->blockTransform();
|
|
|
|
AcGeMatrix3d mvMat1;
|
|
mvMat1.setToTranslation(AcGeVector3d(-ptBase.x, -ptBase.y, -ptBase.z));
|
|
result.postMultBy(mvMat1);
|
|
|
|
return result;
|
|
}
|
|
|
|
void AcGiViewDraw::DrawBlock(const AcDbBlockTableRecord &blockRec, const AcGePoint3d &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
|
|
{
|
|
AcDbBlockReference insert(ptInsert, blockRec.objectId());
|
|
insert.setScaleFactors(scales);
|
|
insert.setRotation(nRot);
|
|
|
|
AecGiSubEntityTraits prop;
|
|
BackUpGiSubEntityTraits(prop);
|
|
|
|
AcGiCommonDraw *pCommonDraw(GetCommonDraw());
|
|
if (!pCommonDraw) return;
|
|
|
|
AcGiGeometry * pGeom = pCommonDraw->rawGeometry();
|
|
if (!pGeom) return;
|
|
|
|
AcGeMatrix3d mat = BlockTransform(&insert);
|
|
pGeom->pushModelTransform(mat);
|
|
pGeom->draw(&(AcDbBlockTableRecord &)blockRec);
|
|
pGeom->popModelTransform();
|
|
RestoreGiSubEntityTraits(prop);
|
|
}
|
|
|
|
void AcGiViewDraw::DrawBlock(const AcDbObjectId& idRec, const AcGePoint3d &ptInsert,const AcGeScale3d &scales, double nRot, BOOL bMakeBlock)
|
|
{
|
|
AcDbBlockReference insert(ptInsert, idRec);
|
|
insert.setScaleFactors(scales);
|
|
insert.setRotation(nRot);
|
|
|
|
AecGiSubEntityTraits prop;
|
|
BackUpGiSubEntityTraits(prop);
|
|
|
|
AcGiCommonDraw *pCommonDraw(GetCommonDraw());
|
|
if (!pCommonDraw) return;
|
|
|
|
AcGiGeometry * pGeom = pCommonDraw->rawGeometry();
|
|
if (!pGeom) return;
|
|
|
|
AcGeMatrix3d mat = BlockTransform(&insert);
|
|
pGeom->pushModelTransform(mat);
|
|
|
|
AcDbObject* pObj = NULL;
|
|
if ( Acad::eOk == acdbOpenObject(pObj,idRec,AcDb::kForRead))
|
|
{
|
|
AcDbBlockTableRecord* pRec = AcDbBlockTableRecord::cast(pObj);
|
|
if (pRec != NULL)
|
|
{
|
|
pGeom->draw(pRec);
|
|
}
|
|
pObj->close();
|
|
}
|
|
pGeom->popModelTransform();
|
|
RestoreGiSubEntityTraits(prop);
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::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)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::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)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::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)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::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)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawPipe(const AcGePoint3d& ptFrom,const AcGePoint3d& ptTo,double dRadius,double dThick,int nSegs)
|
|
{
|
|
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(ptFrom, ptTo, dRadius, dThick, nSegs);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawPipe(const AcDbCurve* pCurve,const AcDbRegion* pRegion,const AcGePoint3d& ptCenInRgn)
|
|
{
|
|
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(pCurve, pRegion, ptCenInRgn);
|
|
if(pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawPipe(const AcDbCurve* pCurve,const AcDbPolyline* pRegion,const AcGePoint3d& ptCenInRgn)
|
|
{
|
|
AcDbEntity* pEnt = GiDrawUtility::DrawPipe(pCurve, pRegion, ptCenInRgn);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity *AcGiViewDraw::DrawPipe(const AcDbCurve *pCurve, double dR)
|
|
{
|
|
AcDbEntity *pEnt = GiDrawUtility::DrawPipe(pCurve, dR);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawExclude(const AcGePoint3dArray& arSectionPtrs,const AcGeVector3d &vtPath)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawExclude(arSectionPtrs, vtPath);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawExclude(const AcDbCurve *pPolyOut, const AcGeVector3d &vtPath)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawExclude(pPolyOut, vtPath);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawRevolve(const AcDbLine& lnAxis,const AcGePoint3dArray& arSectionPtrs)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawRevolve(lnAxis, arSectionPtrs);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawRevolve(const AcDbLine& lnAxis, const AcDbCurve *pSection)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawRevolve(lnAxis, pSection);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity * AcGiViewDraw::DrawRevolve(const AcDbLine & lnAxis, const AcDbRegion * pSection)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawRevolve(lnAxis, pSection);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawSphere(const AcGePoint3d &ptCenter, const double &dRadius)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawSphere(ptCenter, dRadius);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDbEntity* AcGiViewDraw::DrawLoft(const AcDbCurve *pTop, const AcDbCurve *pBottom, const AcDbLine *pLine)
|
|
{
|
|
AcDbEntity * pEnt = GiDrawUtility::DrawLoft(pTop, pBottom, pLine);
|
|
if (pEnt)
|
|
{
|
|
AcGiCommonDraw *pCommDraw = GetCommonDraw();
|
|
if (pCommDraw != NULL)
|
|
{
|
|
AcCmTransparency tr = pCommDraw->subEntityTraits().transparency();
|
|
pEnt->setTransparency(tr);
|
|
}
|
|
DrawEntity(pEnt);
|
|
return pEnt;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::pushModelTransform(const AcGeVector3d & vNormal)
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().pushModelTransform(vNormal);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().pushModelTransform(vNormal);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::pushModelTransform(const AcGeMatrix3d & xMat)
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().pushModelTransform(xMat);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().pushModelTransform(xMat);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::popModelTransform()
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->geometry().popModelTransform();
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->geometry().popModelTransform();
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
void AcGiViewDraw::getModelToWorldTransform(AcGeMatrix3d& xform) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
m_pWd->geometry().getModelToWorldTransform(xform);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().getModelToWorldTransform(xform);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::getWorldToModelTransform(AcGeMatrix3d& xform) const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
m_pWd->geometry().getWorldToModelTransform(xform);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
m_pVd->geometry().getWorldToModelTransform(xform);
|
|
}
|
|
}
|
|
|
|
void AcGiViewDraw::setExtents(AcGePoint3d *pNewExtents) const
|
|
{
|
|
if (pNewExtents == NULL)
|
|
return;
|
|
|
|
if (m_pWd != NULL)
|
|
{
|
|
m_pWd->geometry().setExtents(pNewExtents);
|
|
}
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::draw(AcGiDrawable* pDrawable) const
|
|
{
|
|
if (pDrawable == NULL)
|
|
return Adesk::kFalse;
|
|
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->rawGeometry()->draw(pDrawable);
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->rawGeometry()->draw(pDrawable);
|
|
}
|
|
return Adesk::kFalse;
|
|
}
|
|
|
|
Adesk::Boolean AcGiViewDraw::IsDragging() const
|
|
{
|
|
if (m_pWd != NULL)
|
|
{
|
|
return m_pWd->isDragging();
|
|
}
|
|
else if (m_pVd != NULL)
|
|
{
|
|
return m_pVd->isDragging();
|
|
}
|
|
return Adesk::kFalse;
|
|
} |