bool MgDot::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const { GiContext ctx2(0, GiColor::Invalid(), GiContext::kNullLine, ctx.hasFillColor() ? ctx.getFillColor() : ctx.getLineColor()); float w = gs.calcPenWidth(ctx.getLineWidth(), false); bool ret = gs.drawCircle(&ctx2, _point, gs.xf().displayToModel(w)); return __super::_draw(mode, gs, ctx, segment) || ret; }
bool GiGraphics::_drawPolygon(const GiContext* ctx, int count, const Point2d* points, bool m2d, bool fill, bool edge, bool modelUnit) { GiContext context (ctx ? *ctx : m_impl->ctx); if (!edge) context.setNullLine(); if (!fill) context.setNoFillColor(); if (context.isNullLine() && !context.hasFillColor()) return false; vector<Point2d> pxpoints; Point2d pt1, pt2; Matrix2d matD(S2D(xf(), modelUnit)); pxpoints.resize(count); Point2d *pxs = &pxpoints.front(); int n = 0; for (int i = 0; i < count; i++) { pt2 = points[i]; if (m2d) pt2 *= matD; if (i == 0 || count <= 4 || fabsf(pt1.x - pt2.x) > 2 || fabsf(pt1.y - pt2.y) > 2) { pt1 = pt2; pxs[n++] = pt1; } } if (n == 4 && m2d && mgEquals(pxs[0].x, pxs[3].x) && mgEquals(pxs[1].x, pxs[2].x) && mgEquals(pxs[0].y, pxs[1].y) && mgEquals(pxs[2].y, pxs[3].y)) { Box2d rc(pxs[0].x, pxs[0].y, pxs[2].x, pxs[2].y, true); return rawRect(&context, rc.xmin, rc.ymin, rc.width(), rc.height()); } return rawPolygon(&context, pxs, n); }
static bool _DrawPolygon(GiCanvas* cv, const GiContext* ctx, int count, const Point2d* points, bool bM2D, bool bFill, bool bEdge, bool modelUnit) { if (!ctx && cv) ctx = cv->getCurrentContext(); if (!ctx || !cv) return false; GiContext context (*ctx); if (!bEdge) context.setNullLine(); if (!bFill) context.setNoFillColor(); if (context.isNullLine() && !context.hasFillColor()) return false; vector<Point2d> pxpoints; Point2d pt1, pt2; Matrix2d matD(S2D(cv->owner()->xf(), modelUnit)); pxpoints.resize(count); Point2d *pxs = &pxpoints.front(); int n = 0; for (int i = 0; i < count; i++) { pt2 = points[i]; if (bM2D) pt2 *= matD; if (i == 0 || fabs(pt1.x - pt2.x) > 2 || fabs(pt1.y - pt2.y) > 2) { pt1 = pt2; pxs[n++] = pt1; } } return cv->rawPolygon(&context, pxs, n); }