Code

Added a missing link in making the filterRes attribute work
authorkiirala <kiirala@users.sourceforge.net>
Sat, 21 Jul 2007 07:00:28 +0000 (07:00 +0000)
committerkiirala <kiirala@users.sourceforge.net>
Sat, 21 Jul 2007 07:00:28 +0000 (07:00 +0000)
src/display/nr-filter.cpp
src/display/nr-filter.h
src/sp-filter.cpp

index 73a3df415708214b241b5972e8f0ca24ffb06f20..47b05d0b89797f53392184b294c3242f64281c1c 100644 (file)
@@ -406,27 +406,46 @@ void Filter::clear_primitives()
     _primitive_count = 0;
 }
 
-void Filter::set_x(SVGLength &length)
+void Filter::set_x(SVGLength const &length)
 { 
   if (length._set)
       _region_x = length;
 }
-void Filter::set_y(SVGLength &length)
+void Filter::set_y(SVGLength const &length)
 {
   if (length._set)
       _region_y = length;
 }
-void Filter::set_width(SVGLength &length)
+void Filter::set_width(SVGLength const &length)
 {
   if (length._set)
       _region_width = length;
 }
-void Filter::set_height(SVGLength &length)
+void Filter::set_height(SVGLength const &length)
 { 
   if (length._set)
       _region_height = length;
 }
 
+void Filter::set_resolution(double const pixels) {
+    if (pixels > 0) {
+        _x_pixels = pixels;
+        _y_pixels = pixels;
+    }
+}
+
+void Filter::set_resolution(double const x_pixels, double const y_pixels) {
+    if (x_pixels >= 0 && y_pixels >= 0) {
+        _x_pixels = x_pixels;
+        _y_pixels = y_pixels;
+    }
+}
+
+void Filter::reset_resolution() {
+    _x_pixels = -1;
+    _y_pixels = -1;
+}
+
 } /* namespace NR */
 
 /*
index baf23886ebc7bc327aac100a34f29aa96191a4a4..835266e738e4092006a20805b2ba888ffaa99c3f 100644 (file)
@@ -77,10 +77,10 @@ public:
      */
     void set_output(int slot);
 
-    void set_x(SVGLength &lenght);
-    void set_y(SVGLength &length);
-    void set_width(SVGLength &length);
-    void set_height(SVGLength &length);
+    void set_x(SVGLength const &lenght);
+    void set_y(SVGLength const &length);
+    void set_width(SVGLength const &length);
+    void set_height(SVGLength const &length);
 
     /**
      * Sets the filter effects region.
@@ -105,7 +105,7 @@ public:
      * resolution is determined automatically. If x_pixels is less than zero,
      * calling this function results in no changes to filter state.
      */
-    void set_resolution(double x_pixels);
+    void set_resolution(double const x_pixels);
 
     /**
      * Sets the width and height of intermediate images in pixels. If not set,
@@ -113,7 +113,7 @@ public:
      * less than zero, calling this function results in no changes to filter
      * state.
      */
-    void set_resolution(double x_pixels, double y_pixels);
+    void set_resolution(double const x_pixels, double const y_pixels);
 
     /**
      * Resets the filter resolution to its default value, i.e. automatically
index aae143e8d608b594bcbd0673d558d91517503972..e9c2af19db457a1b7acccfc5983975f0e470c5a9 100644 (file)
@@ -207,24 +207,25 @@ sp_filter_set(SPObject *object, unsigned int key, gchar const *value)
             }
             object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_X:
+        case SP_ATTR_X:
             filter->x.readOrUnset(value);
-        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_Y:
-        filter->y.readOrUnset(value);
-        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        case SP_ATTR_Y:
+            filter->y.readOrUnset(value);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_WIDTH:
-        filter->width.readOrUnset(value);
-        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        case SP_ATTR_WIDTH:
+            filter->width.readOrUnset(value);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_HEIGHT:
-        filter->height.readOrUnset(value);
-        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+        case SP_ATTR_HEIGHT:
+            filter->height.readOrUnset(value);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
-    case SP_ATTR_FILTERRES:
-        filter->filterRes.set(value);
+        case SP_ATTR_FILTERRES:
+            filter->filterRes.set(value);
+            object->requestModified(SP_OBJECT_MODIFIED_FLAG);
             break;
         case SP_ATTR_XLINK_HREF:
             if (value) {
@@ -412,6 +413,15 @@ void sp_filter_build_renderer(SPFilter *sp_filter, NR::Filter *nr_filter)
     nr_filter->set_width(sp_filter->width);
     nr_filter->set_height(sp_filter->height);
 
+    if (sp_filter->filterRes.getNumber() >= 0) {
+        if (sp_filter->filterRes.getOptNumber() >= 0) {
+            nr_filter->set_resolution(sp_filter->filterRes.getNumber(),
+                                      sp_filter->filterRes.getOptNumber());
+        } else {
+            nr_filter->set_resolution(sp_filter->filterRes.getNumber());
+        }
+    }
+
     nr_filter->clear_primitives();
     SPObject *primitive_obj = sp_filter->children;
     while (primitive_obj) {