From: buliabyak Date: Sun, 23 Mar 2008 04:12:33 +0000 (+0000) Subject: helper functions to access a single blur primitive in a filter X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ce2b2419b56b38d08c79720b2278f4b27e61d175;p=inkscape.git helper functions to access a single blur primitive in a filter --- diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 46dbfe0f5..58e2fae6e 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -319,7 +319,7 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo SPFilter * new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mode, gdouble radius) { - NR::Maybe const r = sp_item_bbox_desktop(item); + NR::Maybe const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX); double width; double height; @@ -374,7 +374,7 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, stdDeviation /= expansion; // Get the object size - NR::Maybe const r = sp_item_bbox_desktop(item); + NR::Maybe const r = sp_item_bbox_desktop(item, SPItem::GEOMETRIC_BBOX); double width; double height; if (r) { @@ -457,6 +457,31 @@ void remove_filter_gaussian_blur (SPObject *item) } } +bool filter_is_single_gaussian_blur(SPFilter *filter) +{ + return (SP_OBJECT(filter)->firstChild() && + SP_OBJECT(filter)->firstChild() == SP_OBJECT(filter)->lastChild() && + SP_IS_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild())); +} + +double get_single_gaussian_blur_radius(SPFilter *filter) +{ + if (SP_OBJECT(filter)->firstChild() && + SP_OBJECT(filter)->firstChild() == SP_OBJECT(filter)->lastChild() && + SP_IS_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild())) { + + SPGaussianBlur *gb = SP_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild()); + double x = gb->stdDeviation.getNumber(); + double y = gb->stdDeviation.getOptNumber(); + if (x > 0 && y > 0) { + return MAX(x, y); + } + return x; + } +} + + + /* Local Variables: mode:c++ diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index 25ba0c997..219f79c8c 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -24,6 +24,8 @@ SPFilter *new_filter_simple_from_item (SPDocument *document, SPItem *item, const SPFilter *modify_filter_gaussian_blur_from_item (SPDocument *document, SPItem *item, gdouble stdDeviation); void remove_filter (SPObject *item, bool recursive); void remove_filter_gaussian_blur (SPObject *item); +bool filter_is_single_gaussian_blur(SPFilter *filter); +double get_single_gaussian_blur_radius(SPFilter *filter); #endif