namespace GripCback
{
double roatation_angle; // угол под которым нужно повернуть грипсу, чтоб шла по линии. получаем через subWorldDraw
AcGeVector3d zAxis; // ось Z. получаем через subWorldDraw
void ViewportDrawGrips(AcDbGripData* pThis, AcGiViewportDraw* vportDrawContext, const AcDbObjectId& entId, AcDbGripOperations::DrawType type, AcGePoint3d* cursor, int iGripSize)
{
AcGeMatrix3d e2w; vportDrawContext->viewport().getEyeToWorldTransform(e2w);
AcGePoint3d point = pThis->gripPoint();
AcGeMatrix3d matRotation; matRotation.setToIdentity();
matRotation.setToRotation(roatation_angle,zAxis,point);
AcGePoint2d glyphSize;
vportDrawContext->viewport().getNumPixelsInUnitSquare( point, glyphSize );
double height = iGripSize/glyphSize.y * 2.6;
double width = iGripSize/glyphSize.x * 4.55;
int color = 1;
switch (type)
{
case AcDbGripOperations::kHotGrip:
color = CAcDbCurveText::gripHOT;
break;
case AcDbGripOperations::kHoverGrip:
color = CAcDbCurveText::gripHOVER;
break;
default:
color = CAcDbCurveText::gripCOLOR;
break;
}
vportDrawContext->subEntityTraits().setFillType(kAcGiFillAlways);
vportDrawContext->subEntityTraits().setThickness(3);
AcGePoint2dArray verticles; verticles.removeAll(); AcGeDoubleArray bulges; bulges.removeAll();
verticles.append(AcGePoint2d(point.x - width / 2.0,point.y)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x - width / 4.0,point.y + height / 2.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x - width / 4.0,point.y + height / 5.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x + width / 4.0,point.y + height / 5.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x + width / 4.0,point.y + height / 2.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x + width / 2.0,point.y)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x + width / 4.0,point.y - height / 2.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x + width / 4.0,point.y - height / 5.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x - width / 4.0,point.y - height / 5.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x - width / 4.0,point.y - height / 2.0)); bulges.append(0.0);
verticles.append(AcGePoint2d(point.x - width / 2.0,point.y)); bulges.append(0.0);
// внутренняя заливка
AcDbHatch * pHatch = new AcDbHatch();
pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));
pHatch->setPatternScale(1.0);
pHatch->setDatabaseDefaults();
pHatch->setAssociative(false);
pHatch->appendLoop(AcDbHatch::kDefault, verticles, bulges);
pHatch->setColorIndex(color);
pHatch->transformBy(matRotation);
vportDrawContext->geometry().draw(pHatch);
delete pHatch;
pHatch = 0;
// черный контур
AcDbPolyline* pCoolGrips = new AcDbPolyline;
for (int i = 0; i < 11; i++)
pCoolGrips->addVertexAt(i,verticles.at(i));
pCoolGrips->transformBy(matRotation);
vportDrawContext->subEntityTraits().setColor(7);
vportDrawContext->geometry().pline(*pCoolGrips);
delete pCoolGrips;
pCoolGrips = 0;
}
};