示例#1
0
bool GiGraphics::setPen(const GiContext* ctx)
{
    bool changed = !(m_impl->ctxused & 1);
    
    if (m_impl->canvas) {
        if (ctx && (!mgEquals(ctx->getLineWidth(), m_impl->ctx.getLineWidth())
                    || ctx->isAutoScale() != m_impl->ctx.isAutoScale())) {
            m_impl->ctx.setLineWidth(ctx->getLineWidth(), ctx->isAutoScale());
            changed = true;
        }
        if (ctx && ctx->getLineColor() != m_impl->ctx.getLineColor()) {
            m_impl->ctx.setLineColor(ctx->getLineColor());
            changed = true;
        }
        if (ctx && ctx->getLineStyle() != m_impl->ctx.getLineStyle()) {
            m_impl->ctx.setLineStyle(ctx->getLineStyle());
            changed = true;
        }
    }
    
    ctx = &(m_impl->ctx);
    if (m_impl->canvas && changed) {
        m_impl->ctxused &= 1;
        m_impl->canvas->setPen(calcPenColor(ctx->getLineColor()).getARGB(),
                               calcPenWidth(ctx->getLineWidth(), ctx->isAutoScale()),
                               ctx->getLineStyle(), 0);
    }
    
    return !ctx->isNullLine();
}
示例#2
0
bool GiGraphics::drawPathWithArrayHead(const GiContext& ctx, MgPath& path, int startArray, int endArray)
{
    float px = calcPenWidth(ctx.getLineWidth(), ctx.isAutoScale());
    float scale = 0.5f * xf().getWorldToDisplayX() * (1 + mgMax(0.f, (px - 4.f) / 5));
    
    if (startArray > 0 && startArray <= GiContext::kArrowOpenedCircle) {
        drawArrayHead(ctx, path, startArray, px, scale);
    }
    if (endArray > 0 && endArray <= GiContext::kArrowOpenedCircle) {
        path.reverse();
        drawArrayHead(ctx, path, endArray, px, scale);
        path.reverse();
    }
    
    return drawPath_(&ctx, path, false, Matrix2d::kIdentity());
}
示例#3
0
bool GiGraphics::setPen(const GiContext* ctx)
{
    bool changed = !(m_impl->ctxused & 1);
    
    if (m_impl->canvas) {
        if (ctx && (!mgEquals(ctx->getLineWidth(), m_impl->ctx.getLineWidth())
                    || ctx->isAutoScale() != m_impl->ctx.isAutoScale())) {
            m_impl->ctx.setLineWidth(ctx->getLineWidth(), ctx->isAutoScale());
            changed = true;
        }
        if (ctx && !mgEquals(ctx->getExtraWidth(), m_impl->ctx.getExtraWidth())) {
            m_impl->ctx.setExtraWidth(ctx->getExtraWidth());
            changed = true;
        }
        if (ctx && ctx->getLineColor() != m_impl->ctx.getLineColor()) {
            m_impl->ctx.setLineColor(ctx->getLineColor());
            changed = true;
        }
        if (ctx && ctx->getLineStyleEx() != m_impl->ctx.getLineStyleEx()) {
            m_impl->ctx.setLineStyle(ctx->getLineStyleEx(), true);
            changed = true;
        }
    }
    
    ctx = &(m_impl->ctx);
    if (m_impl->canvas && changed) {
        m_impl->ctxused &= 1;
        float w = calcPenWidth(ctx->getLineWidth(), ctx->isAutoScale());
        float orgw = ctx->getLineWidth();
        orgw = (orgw < -0.1f && ctx->isAutoScale()) ? orgw - 1e4f : orgw;
        m_impl->canvas->setPen(calcPenColor(ctx->getLineColor()).getARGB(),
                               w + ctx->getExtraWidth(),
                               ctx->getLineStyleEx(),
                               mgMax(m_impl->phase, 0.f), orgw);
    }
    
    return !ctx->isNullLine();
}