//-----------------------------------------------------------------------------
//----- AcDbEntity protocols
Adesk::Boolean AuPolyline::subWorldDraw(AcGiWorldDraw *mode) {
assertReadEnabled();
//***************
// Call base class first
AcDbPolyline::subWorldDraw(mode);
acutPrintf(_T("Работает worldDrow\n"));
double szRef = 5.0;
// ================================================================
// DIRECTION AND VERTEX NUMBERING
int signal = 1;
double ht2 = szRef / 4.0;
for (int i = 0; i < numVerts(); i++)
{
AcGePoint3d pti;
this->getPointAt(i, pti);
// Draw vertex text
CString strNum;
strNum.Format(_T("%d"), i);
AcGePoint3d ptTxt = pti + (AcGeVector3d::kXAxis*ht2) +
(AcGeVector3d::kYAxis*ht2);
mode->subEntityTraits().setColor(256); // ByLayer
mode->geometry().text(ptTxt, AcGeVector3d::kZAxis,
AcGeVector3d::kXAxis, ht2, 1.0, 0.0, strNum);
// Arrow direction
AcGePoint3d ptj;
this->getPointAt(i < (numVerts() - 1) ? (i + 1) : 0, ptj);
AcGeVector3d dir = (ptj - pti).normalize();
// Side perpendicular vectors
AcGeVector3d perp = dir;
perp.rotateBy(3.141592 / 2.0, AcGeVector3d::kZAxis);
AcGePoint3d pt1 = ptj - (dir*ht2) + (perp*(ht2 / 4.0));
AcGePoint3d pt2 = ptj - (dir*ht2) - (perp*(ht2 / 4.0));
AcGePoint3d pts[3];
pts[0] = ptj;
pts[1] = pt1;
pts[2] = pt2;
// Draw arrow polygon
mode->subEntityTraits().setFillType(kAcGiFillAlways);
mode->subEntityTraits().setColor(1); // red
mode->geometry().polygon(3, pts);
mode->subEntityTraits().setFillType(kAcGiFillNever);
}
//============================================
// PROXY
if (mode->regenType() == kAcGiSaveWorldDrawForProxy)
{
// Draw dummy text
CString strTxt = _T("AU Polyline");
AcGePoint3d ptTxt = GetPolylineCenter();
mode->geometry().text(ptTxt, AcGeVector3d::kZAxis,
AcGeVector3d::kXAxis, szRef, 1.0, 0.0, strTxt);
}
objArray::iterator it;
int gs = numVerts();
for (it = m_Array.begin(); it != m_Array.end(); it++)
{
AcDbPolyline *pPline = AcDbPolyline::cast(it->second);
if (pPline) {
AcDbVoidPtrArray aSubEnt;
pPline->explode(aSubEnt);
for (int i = 0; i < aSubEnt.length(); i++)
{
mode->subEntityTraits().setSelectionMarker(++gs);
static_cast<AcDbEntity*>(aSubEnt[i])->worldDraw(mode);
delete aSubEnt[i];
}
}
else {
mode->subEntityTraits().setSelectionMarker(++gs);
it->second->worldDraw(mode);
}
}
//------ Returning Adesk::kFalse here will force viewportDraw() call
return (Adesk::kTrue);
}