diff options
| author | Hugo Rodrigues <me@hugorodrigues.com> | 2006-08-20 12:13:40 +0000 |
|---|---|---|
| committer | haa_rodrigues <haa_rodrigues@users.sourceforge.net> | 2006-08-20 12:13:40 +0000 |
| commit | 761462bc771e916bc71dd9b116c9227b495fe7a9 (patch) | |
| tree | ffcb8b9114e6fe1bb7db577dd611a2aa51f3985b /src/display | |
| parent | Last tweaks for now (diff) | |
| download | inkscape-761462bc771e916bc71dd9b116c9227b495fe7a9.tar.gz inkscape-761462bc771e916bc71dd9b116c9227b495fe7a9.zip | |
Object groups can be blurred. Blur slider updates when selection changes. Comments added/fixed.
(bzr r1622)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/nr-arena-group.cpp | 40 | ||||
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 10 | ||||
| -rw-r--r-- | src/display/nr-filter.cpp | 3 |
3 files changed, 47 insertions, 6 deletions
diff --git a/src/display/nr-arena-group.cpp b/src/display/nr-arena-group.cpp index b4cc3930b..8df045332 100644 --- a/src/display/nr-arena-group.cpp +++ b/src/display/nr-arena-group.cpp @@ -14,7 +14,11 @@ #include "display/nr-arena-group.h" #include "display/nr-filter.h" +#include "display/nr-filter-gaussian.h" +#include "display/nr-filter-types.h" #include "style.h" +#include "sp-filter.h" +#include "sp-gaussian-blur.h" static void nr_arena_group_class_init (NRArenaGroupClass *klass); static void nr_arena_group_init (NRArenaGroup *group); @@ -193,9 +197,41 @@ void nr_arena_group_set_style (NRArenaGroup *group, SPStyle *style) if (group->style) sp_style_unref(group->style); group->style = style; + //if there is a filter set for this group if (style && style->filter.set && style->filter.filter) { - group->filter = new NR::Filter(); - } + + group->filter = new NR::Filter(); + group->filter->set_x(style->filter.filter->x); + group->filter->set_y(style->filter.filter->y); + group->filter->set_width(style->filter.filter->width); + group->filter->set_height(style->filter.filter->height); + + //go through all SP filter primitives + for(int i=0; i<style->filter.filter->_primitive_count; i++) + { + SPFilterPrimitive *primitive = style->filter.filter->_primitives[i]; + //if primitive is gaussianblur +// if(SP_IS_GAUSSIANBLUR(primitive)) + { + NR::FilterGaussian * gaussian = (NR::FilterGaussian *) group->filter->add_primitive(NR::NR_FILTER_GAUSSIANBLUR); + SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive); + float num = spblur->stdDeviation.getNumber(); + if( num>=0.0 ) + { + float optnum = spblur->stdDeviation.getOptNumber(); + if( optnum>=0.0 ) + gaussian->set_deviation((double) num, (double) optnum); + else + gaussian->set_deviation((double) num); + } + } + } + } + else + { + //no filter set for this group + group->filter = NULL; + } if (style && style->enable_background.set && style->enable_background.value == SP_CSS_BACKGROUND_NEW) { diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index f9c203187..2f278b3de 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -1089,9 +1089,8 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) } shape->setMitreLimit(style->stroke_miterlimit.value); - /* TODO: after SPStyle handles filters, get the correct filter - * from there. */ - if (style->filter.set && style->filter.filter) + //if shape has a filter + if (style->filter.set && style->filter.filter) { shape->filter = new NR::Filter(); shape->filter->set_x(style->filter.filter->x); @@ -1120,6 +1119,11 @@ nr_arena_shape_set_style(NRArenaShape *shape, SPStyle *style) } } } + else + { + //no filter set for this shape + shape->filter = NULL; + } nr_arena_item_request_update(shape, NR_ARENA_ITEM_STATE_ALL, FALSE); } diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index a96b02a62..35d8804e7 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -131,7 +131,8 @@ int Filter::render(NRArenaItem const *item, NRPixBlock *pb) in = NULL; // in is now handled by FilterSlot, we should not touch it // TODO: loop through the primitives and render them one at a time - _primitive[0]->render(slot, trans); + if(_primitive[0]) + _primitive[0]->render(slot, trans); NRPixBlock *out = slot.get(_output_slot); |
