Example #1
0
/**
 * Process information related to the new style.
 *
 * Note: _style is not used by DrawingGlyphs which uses its parent style.
 */
void
DrawingItem::setStyle(SPStyle *style, SPStyle *context_style)
{
    // std::cout << "DrawingItem::setStyle: " << name() << " " << style
    //           << " " << context_style << std::endl;

    if( style != _style ) {
        if (style) sp_style_ref(style);
        if (_style) sp_style_unref(_style);
        _style = style;
    }
    
    if (style && style->filter.set && style->getFilter()) {
        if (!_filter) {
            int primitives = sp_filter_primitive_count(SP_FILTER(style->getFilter()));
            _filter = new Inkscape::Filters::Filter(primitives);
        }
        sp_filter_build_renderer(SP_FILTER(style->getFilter()), _filter);
    } else {
        // no filter set for this group
        delete _filter;
        _filter = NULL;
    }

    if (style && style->enable_background.set) {
        if (style->enable_background.value == SP_CSS_BACKGROUND_NEW && !_background_new) {
            _background_new = true;
            _markForUpdate(STATE_BACKGROUND, true);
        } else if (style->enable_background.value == SP_CSS_BACKGROUND_ACCUMULATE && _background_new) {
            _background_new = false;
            _markForUpdate(STATE_BACKGROUND, true);
        }
    }

    if (context_style != NULL) {
        _context_style = context_style;
    } else if (_parent != NULL) {
        _context_style = _parent->_context_style;
    }

    _markForUpdate(STATE_ALL, false);
}
Example #2
0
void
DrawingItem::setStrokePattern(DrawingPattern *pattern)
{
    _markForRendering();
    delete _stroke_pattern;
    _stroke_pattern = pattern;
    if (pattern) {
        pattern->_parent = this;
        assert(pattern->_child_type == CHILD_ORPHAN);
        pattern->_child_type = CHILD_STROKE_PATTERN;
    }
    _markForUpdate(STATE_ALL, true);
}
Example #3
0
void
DrawingItem::setFillPattern(DrawingPattern *pattern)
{
    _markForRendering();
    delete _fill_pattern;
    _fill_pattern = pattern;
    if (pattern) {
        pattern->_parent = this;
        assert(pattern->_child_type == CHILD_ORPHAN);
        pattern->_child_type = CHILD_FILL_PATTERN;
    }
    _markForUpdate(STATE_ALL, true);
}
Example #4
0
void
DrawingItem::setMask(DrawingItem *item)
{
    _markForRendering();
    delete _mask;
    _mask = item;
        if (item) {
        item->_parent = this;
        assert(item->_child_type == CHILD_ORPHAN);
        item->_child_type = CHILD_MASK;
    }
    _markForUpdate(STATE_ALL, true);
}
Example #5
0
void
DrawingItem::setClip(DrawingItem *item)
{
    _markForRendering();
    delete _clip;
    _clip = item;
    if (item) {
        item->_parent = this;
        assert(item->_child_type == CHILD_ORPHAN);
        item->_child_type = CHILD_CLIP;
    }
    _markForUpdate(STATE_ALL, true);
}
Example #6
0
void
DrawingGlyphs::setGlyph(font_instance *font, int glyph, Geom::Affine const &trans)
{
    _markForRendering();

    setTransform(trans);

    if (font) font->Ref();
    if (_font) _font->Unref();
    _font = font;
    _glyph = glyph;

    _markForUpdate(STATE_ALL, false);
}
Example #7
0
/// Delete all regular children of this item (not mask or clip).
void
DrawingItem::clearChildren()
{
    if (_children.empty()) return;

    _markForRendering();
    // prevent children from referencing the parent during deletion
    // this way, children won't try to remove themselves from a list
    // from which they have already been removed by clear_and_dispose
    for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
        i->_parent = NULL;
        i->_child_type = CHILD_ORPHAN;
    }
    _children.clear_and_dispose(DeleteDisposer());
    _markForUpdate(STATE_ALL, false);
}
Example #8
0
/**
 * Set additional transform for the group.
 * This is applied after the normal transform and mainly useful for
 * markers, clipping paths, etc.
 */
void
DrawingGroup::setChildTransform(Geom::Affine const &new_trans)
{
    Geom::Affine current;
    if (_child_transform) {
        current = *_child_transform;
    }

    if (!Geom::are_near(current, new_trans, 1e-18)) {
        // mark the area where the object was for redraw.
        _markForRendering();
        if (new_trans.isIdentity()) {
            delete _child_transform; // delete NULL; is safe
            _child_transform = NULL;
        } else {
            _child_transform = new Geom::Affine(new_trans);
        }
        _markForUpdate(STATE_ALL, true);
    }
}