Matrix2d Matrix2d::transformWith2P(const Point2d& from1, const Point2d& from2, const Point2d& to1, const Point2d& to2) { if (from1 == from2 || to1 == to2 || from1.isDegenerate() || from2.isDegenerate() || to1.isDegenerate() || to2.isDegenerate()) { return Matrix2d::kIdentity(); } return (translation(to1 - from1) * scaling(to2.distanceTo(to1) / from2.distanceTo(from1), to1) * rotation((to2 - to1).angle2() - (from2 - from1).angle2(), to1)); }
bool GiGraphics::drawHandle(const Point2d& pnt, int type, float angle, bool modelUnit) { if (m_impl->canvas && type >= 0 && !m_impl->stopping && !pnt.isDegenerate()) { Point2d ptd(pnt * S2D(xf(), modelUnit)); return m_impl->canvas->drawHandle(ptd.x, ptd.y, type, angle); } return false; }
float GiGraphics::drawTextAt(GiTextWidthCallback* c, int argb, const char* text, const Point2d& pnt, float h, int align, float angle) { float ret = 0; if (m_impl->canvas && text && h > 0 && !m_impl->stopping && !pnt.isDegenerate()) { Point2d ptd(pnt * xf().modelToDisplay()); float w2d = xf().getWorldToDisplayY(h < 0); h = fabsf(h) * w2d; if (!mgIsZero(angle)) { angle = (Vector2d::angledVector(angle, 1) * xf().modelToWorld()).angle2(); } GiContext ctx; ctx.setFillARGB(argb ? argb : 0xFF000000); if (setBrush(&ctx)) { TextWidthCallback1 *cw = c ? new TextWidthCallback1(c, w2d) : (TextWidthCallback1 *)0; ret = m_impl->canvas->drawTextAt(cw, text, ptd.x, ptd.y, h, align, angle) / w2d; } } return ret; }