Code

helper functions to access a single blur primitive in a filter
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 23 Mar 2008 04:12:33 +0000 (04:12 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 23 Mar 2008 04:12:33 +0000 (04:12 +0000)
src/filter-chemistry.cpp
src/filter-chemistry.h

index 46dbfe0f50c8ee58ff11d9811269fdbe1733ba59..58e2fae6efab6042e78925f1f498dcc1d68a7486 100644 (file)
@@ -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<NR::Rect> const r = sp_item_bbox_desktop(item);
+    NR::Maybe<NR::Rect> 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<NR::Rect> const r = sp_item_bbox_desktop(item);
+    NR::Maybe<NR::Rect> 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++
index 25ba0c997bdcb7f84486ec9f2379c3e921f13bc8..219f79c8cc30a29977ac1b0605e91c192cdd23a4 100644 (file)
@@ -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