189 lines
3.6 KiB
C++
189 lines
3.6 KiB
C++
#include "stdafx.h"
|
|
#include "AcGiDraw.h"
|
|
|
|
AcGiDraw::AcGiDraw(void)
|
|
: m_p3DBufPtrs(NULL)
|
|
, m_p2DBufPtrs(NULL)
|
|
{
|
|
m_plan = AcGePlane::kXYPlane;
|
|
}
|
|
|
|
AcGiDraw::~AcGiDraw(void)
|
|
{
|
|
}
|
|
|
|
AcGePoint3d AcGiDraw::Align2Base(AcGiDraw::TextAlignment nAlign, AcGePoint3d ptAlign, AcGePoint3d ext)
|
|
{
|
|
AcGePoint3d ptBase = ptAlign;
|
|
|
|
// ťťËăťůľă
|
|
switch(nAlign)
|
|
{
|
|
case AcGiDraw::kTopLeft:
|
|
ptBase.y -= ext.y;
|
|
break;
|
|
case AcGiDraw::kTopCenter:
|
|
ptBase.y -= ext.y;
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kTopRight:
|
|
ptBase.y -= ext.y;
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case AcGiDraw::kMiddleLeft:
|
|
ptBase.y -= ext.y / 2.0;
|
|
break;
|
|
case AcGiDraw::kMiddleCenter:
|
|
ptBase.y -= ext.y / 2.0;
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kMiddleRight:
|
|
ptBase.y -= ext.y / 2.0;
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case AcGiDraw::kBottomLeft:
|
|
ptBase.y += (ext.z - ext.y);
|
|
break;
|
|
case AcGiDraw::kBottomCenter:
|
|
ptBase.y += (ext.z - ext.y);
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kBottomRight:
|
|
ptBase.y += (ext.z - ext.y);
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
|
|
case AcGiDraw::kLeft:
|
|
break;
|
|
case AcGiDraw::kCenter:
|
|
ptBase.x -= ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kRight:
|
|
ptBase.x -= ext.x;
|
|
break;
|
|
case AcGiDraw::kMiddle:
|
|
ptBase.x -= ext.x / 2;
|
|
ptBase.y -= ext.z / 2.0;
|
|
ptBase.y += (ext.z - ext.y);
|
|
break;
|
|
default:
|
|
ASSERT(0);
|
|
}
|
|
return ptBase;
|
|
}
|
|
|
|
AcGePoint3d AcGiDraw::Base2Align(AcGiDraw::TextAlignment nAlign, AcGePoint3d ptBase, AcGePoint3d ext)
|
|
{
|
|
AcGePoint3d ptAlign = ptBase;
|
|
|
|
// ťťËăťůľă
|
|
switch(nAlign)
|
|
{
|
|
case AcGiDraw::kTopLeft:
|
|
ptAlign.y += ext.y;
|
|
break;
|
|
case AcGiDraw::kTopCenter:
|
|
ptAlign.y += ext.y;
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kTopRight:
|
|
ptAlign.y += ext.y;
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case AcGiDraw::kMiddleLeft:
|
|
ptAlign.y += ext.y / 2.0;
|
|
break;
|
|
case AcGiDraw::kMiddleCenter:
|
|
ptAlign.y += ext.y / 2.0;
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kMiddleRight:
|
|
ptAlign.y += ext.y / 2.0;
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case AcGiDraw::kBottomLeft:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
break;
|
|
case AcGiDraw::kBottomCenter:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kBottomRight:
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case AcGiDraw::kLeft:
|
|
break;
|
|
case AcGiDraw::kCenter:
|
|
ptAlign.x += ext.x / 2.0;
|
|
break;
|
|
case AcGiDraw::kRight:
|
|
ptAlign.x += ext.x;
|
|
break;
|
|
case AcGiDraw::kMiddle:
|
|
ptAlign.x += ext.x / 2;
|
|
ptAlign.y -= (ext.z - ext.y);
|
|
ptAlign.y += ext.z / 2.0;
|
|
break;
|
|
default:
|
|
ASSERT(0);
|
|
break;
|
|
}
|
|
return ptAlign;
|
|
}
|
|
|
|
Acad::ErrorStatus AcGiDraw::SetDraw2DPlan(const AcGePlane& plan)
|
|
{
|
|
m_plan = plan;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AcGiDraw::GetDraw2DPlan(AcGePlane& plan) const
|
|
{
|
|
plan = m_plan;
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AcGiDraw::Add2dBuffer(AcDbEntity* pEnt)
|
|
{
|
|
m_p2DBufPtrs.append(pEnt);
|
|
}
|
|
|
|
void AcGiDraw::Add2dBuffer(const AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
m_p2DBufPtrs.append(arEntPtrs);
|
|
}
|
|
|
|
void AcGiDraw::Get2dBuffer(AcDbVoidPtrArray& arEntPtrs,bool bRemoveAllBuffer/* = true*/) const
|
|
{
|
|
arEntPtrs.append(m_p2DBufPtrs);
|
|
if (bRemoveAllBuffer)
|
|
m_p3DBufPtrs.removeAll();
|
|
}
|
|
|
|
void AcGiDraw::Clear2dBuffer()
|
|
{
|
|
m_p2DBufPtrs.removeAll();
|
|
}
|
|
|
|
void AcGiDraw::Add3dBuffer(AcDbEntity* pEnt)
|
|
{
|
|
m_p3DBufPtrs.append(pEnt);
|
|
}
|
|
|
|
void AcGiDraw::Add3dBuffer(const AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
m_p3DBufPtrs.append(arEntPtrs);
|
|
}
|
|
|
|
void AcGiDraw::Get3dBuffer(AcDbVoidPtrArray& arEntPtrs,bool bRemoveAllBuffer/* = true*/) const
|
|
{
|
|
arEntPtrs.append(m_p3DBufPtrs);
|
|
if (bRemoveAllBuffer)
|
|
m_p3DBufPtrs.removeAll();
|
|
}
|
|
|
|
void AcGiDraw::Clear3dBuffer()
|
|
{
|
|
m_p3DBufPtrs.removeAll();
|
|
} |