Exemple #1
0
SE_LineStyle* SE_StyleVisitor::ProcessLineUsage(LineUsage& lineUsage)
{
    SE_LineStyle* style = new SE_LineStyle();
    ParseStringExpression(lineUsage.GetAngleControl(), style->angleControl, LineUsage::sAngleControlDefault, LineUsage::sAngleControlValues);
    ParseStringExpression(lineUsage.GetUnitsControl(), style->unitsControl, LineUsage::sUnitsControlDefault, LineUsage::sUnitsControlValues);
    ParseStringExpression(lineUsage.GetVertexControl(), style->vertexControl, LineUsage::sVertexControlDefault, LineUsage::sVertexControlValues);
    ParseDoubleExpression(lineUsage.GetAngle(), style->angleDeg, 0.0);
    ParseDoubleExpression(lineUsage.GetStartOffset(), style->startOffset, -1.0);
    ParseDoubleExpression(lineUsage.GetEndOffset(), style->endOffset, -1.0);
    ParseDoubleExpression(lineUsage.GetRepeat(), style->repeat, 0.0);
    ParseDoubleExpression(lineUsage.GetVertexAngleLimit(), style->vertexAngleLimit, 0.0);
    ParseStringExpression(lineUsage.GetVertexJoin(), style->vertexJoin, LineUsage::sVertexJoinDefault, LineUsage::sVertexJoinValues);
    ParseDoubleExpression(lineUsage.GetVertexMiterLimit(), style->vertexMiterLimit, 5.0);

    Path* defaultPath = lineUsage.GetDefaultPath();
    if (defaultPath != NULL)
    {
        ParseDoubleExpression(defaultPath->GetLineWeight(), style->dpWeight, 0.0);
        ParseColorExpression(defaultPath->GetLineColor(), style->dpColor, 0);
        ParseBooleanExpression(defaultPath->GetLineWeightScalable(), style->dpWeightScalable, true);
        ParseStringExpression(defaultPath->GetLineCap(), style->dpCap, Path::sLineCapDefault, Path::sLineCapValues);
        ParseStringExpression(defaultPath->GetLineJoin(), style->dpJoin, Path::sLineJoinDefault, Path::sLineJoinValues);
        ParseDoubleExpression(defaultPath->GetLineMiterLimit(), style->dpMiterLimit, 5.0);

        // if the color is transparent there's no point in drawing this
        // path, so change it to black
        if (style->dpColor.value.argb == 0)
            style->dpColor.value.comps.a = 255;
    }

    // set flag if all properties are constant
    style->cacheable = !(style->angleDeg.expression
                      || style->angleControl.expression
                      || style->unitsControl.expression
                      || style->vertexControl.expression
                      || style->startOffset.expression
                      || style->endOffset.expression
                      || style->repeat.expression
                      || style->vertexAngleLimit.expression
                      || style->vertexJoin.expression
                      || style->vertexMiterLimit.expression
                      || style->dpWeight.expression
                      || style->dpColor.expression
                      || style->dpWeightScalable.expression
                      || style->dpCap.expression
                      || style->dpJoin.expression
                      || style->dpMiterLimit.expression);

    return style;
}
Exemple #2
0
void SE_StyleVisitor::VisitPath(Path& path)
{
    delete m_primitive;
    m_primitive = NULL;

    SE_Color fillColor;
    ParseColorExpression(path.GetFillColor(), fillColor, 0);

    if (fillColor.empty())
    {
        SE_Polyline* primitive = new SE_Polyline();
        m_primitive = primitive;
        primitive->geometry = SE_BufferPool::NewSELineBuffer(m_bp, 4);
        ParseGeometry(path.GetGeometry(), *primitive->geometry);
        ParseDoubleExpression(path.GetLineWeight(), primitive->weight, 0.0);
        ParseColorExpression(path.GetLineColor(), primitive->color, 0);
        ParseBooleanExpression(path.GetLineWeightScalable(), primitive->weightScalable, true);
        ParseStringExpression(path.GetLineCap(), primitive->cap, Path::sLineCapDefault, Path::sLineCapValues);
        ParseStringExpression(path.GetLineJoin(), primitive->join, Path::sLineJoinDefault, Path::sLineJoinValues);
        ParseDoubleExpression(path.GetLineMiterLimit(), primitive->miterLimit, 5.0);
        ParseDoubleExpression(path.GetScaleX(), primitive->scaleX, 1.0);
        ParseDoubleExpression(path.GetScaleY(), primitive->scaleY, 1.0);
        ParseStringExpression(path.GetResizeControl(), primitive->resizeControl, GraphicElement::sResizeControlDefault, GraphicElement::sResizeControlValues);

        // if the color is transparent there's no point in drawing this
        // path, so change it to black
        if (primitive->color.value.argb == 0)
            primitive->color.value.comps.a = 255;

        primitive->cacheable = !(primitive->weight.expression
                              || primitive->color.expression
                              || primitive->weightScalable.expression
                              || primitive->cap.expression
                              || primitive->join.expression
                              || primitive->miterLimit.expression
                              || primitive->resizeControl.expression
                              || primitive->scaleX.expression
                              || primitive->scaleY.expression);
    }
    else
    {
        SE_Polygon* primitive = new SE_Polygon();
        m_primitive = primitive;
        primitive->fill = fillColor;
        primitive->geometry = SE_BufferPool::NewSELineBuffer(m_bp, 4);
        ParseGeometry(path.GetGeometry(), *primitive->geometry);
        ParseDoubleExpression(path.GetLineWeight(), primitive->weight, 0.0);
        ParseColorExpression(path.GetLineColor(), primitive->color, 0);
        ParseBooleanExpression(path.GetLineWeightScalable(), primitive->weightScalable, true);
        ParseStringExpression(path.GetLineCap(), primitive->cap, Path::sLineCapDefault, Path::sLineCapValues);
        ParseStringExpression(path.GetLineJoin(), primitive->join, Path::sLineJoinDefault, Path::sLineJoinValues);
        ParseDoubleExpression(path.GetLineMiterLimit(), primitive->miterLimit, 5.0);
        ParseDoubleExpression(path.GetScaleX(), primitive->scaleX, 1.0);
        ParseDoubleExpression(path.GetScaleY(), primitive->scaleY, 1.0);
        ParseStringExpression(path.GetResizeControl(), primitive->resizeControl, GraphicElement::sResizeControlDefault, GraphicElement::sResizeControlValues);

        primitive->cacheable = !(primitive->weight.expression
                              || primitive->color.expression
                              || primitive->fill.expression
                              || primitive->weightScalable.expression
                              || primitive->cap.expression
                              || primitive->join.expression
                              || primitive->miterLimit.expression
                              || primitive->resizeControl.expression
                              || primitive->scaleX.expression
                              || primitive->scaleY.expression);
    }
}