From: jucablues Date: Mon, 6 Aug 2007 22:14:47 +0000 (+0000) Subject: setting of attributes and default values X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a415d1eef0dc633042c80f242723c2aaf137ba7a;p=inkscape.git setting of attributes and default values --- diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 1f519335d..909dc7d90 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -10,6 +10,7 @@ */ #include "display/nr-filter-component-transfer.h" + namespace NR { FilterComponentTransfer::FilterComponentTransfer() @@ -46,6 +47,35 @@ void FilterComponentTransfer::area_enlarge(NRRectL &area, Matrix const &trans) { } +void FilterComponentTransfer::set_type(FilterComponentTransferType t){ + type = t; +} + +void FilterComponentTransfer::set_slope(double s){ + slope = s; +} + +void FilterComponentTransfer::set_tableValues(std::vector &tv){ + tableValues = tv; +} + + +void FilterComponentTransfer::set_intercept(double i){ + intercept = i; +} + +void FilterComponentTransfer::set_amplitude(double a){ + amplitude = a; +} + +void FilterComponentTransfer::set_exponent(double e){ + exponent = e; +} + +void FilterComponentTransfer::set_offset(double o){ + offset = o; +} + } /* namespace NR */ /* diff --git a/src/display/nr-filter-component-transfer.h b/src/display/nr-filter-component-transfer.h index b30457809..9036a6644 100644 --- a/src/display/nr-filter-component-transfer.h +++ b/src/display/nr-filter-component-transfer.h @@ -14,9 +14,19 @@ #include "display/nr-filter-primitive.h" #include "display/nr-filter-slot.h" +#include namespace NR { +enum FilterComponentTransferType { + COMPONENTTRANSFER_TYPE_IDENTITY, + COMPONENTTRANSFER_TYPE_TABLE, + COMPONENTTRANSFER_TYPE_DISCRETE, + COMPONENTTRANSFER_TYPE_LINEAR, + COMPONENTTRANSFER_TYPE_GAMMA, + COMPONENTTRANSFER_TYPE_ERROR +}; + class FilterComponentTransfer : public FilterPrimitive { public: FilterComponentTransfer(); @@ -25,6 +35,23 @@ public: virtual int render(FilterSlot &slot, Matrix const &trans); virtual void area_enlarge(NRRectL &area, Matrix const &trans); + + void set_type(FilterComponentTransferType t); + void set_tableValues(std::vector& tv); + void set_slope(double s); + void set_intercept(double i); + void set_amplitude(double a); + void set_exponent(double e); + void set_offset(double o); + +private: + FilterComponentTransferType type; + std::vector tableValues; + double slope; + double intercept; + double amplitude; + double exponent; + double offset; }; } /* namespace NR */ diff --git a/src/sp-fecomponenttransfer.cpp b/src/sp-fecomponenttransfer.cpp index 990951192..2bf3e809a 100644 --- a/src/sp-fecomponenttransfer.cpp +++ b/src/sp-fecomponenttransfer.cpp @@ -21,7 +21,7 @@ #include "svg/svg.h" #include "sp-fecomponenttransfer.h" #include "xml/repr.h" - +#include "display/nr-filter-component-transfer.h" /* FeComponentTransfer base class */ @@ -74,6 +74,14 @@ sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass) static void sp_feComponentTransfer_init(SPFeComponentTransfer *feComponentTransfer) { + //Setting default values: +//TODO: tableValues = "" (empty list); + feComponentTransfer->slope = 1; + feComponentTransfer->intercept = 0; + feComponentTransfer->amplitude = 1; + feComponentTransfer->exponent = 1; + feComponentTransfer->offset = 0; +// feComponentTransfer->type = NR::COMPONENTTRANSFER_TYPE_ERROR; } /** @@ -89,6 +97,13 @@ sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::X } /*LOAD ATTRIBUTES FROM REPR HERE*/ + sp_object_read_attr(object, "type"); + sp_object_read_attr(object, "tableValues"); + sp_object_read_attr(object, "slope"); + sp_object_read_attr(object, "intercept"); + sp_object_read_attr(object, "amplitude"); + sp_object_read_attr(object, "exponent"); + sp_object_read_attr(object, "offset"); } /** @@ -101,6 +116,28 @@ sp_feComponentTransfer_release(SPObject *object) ((SPObjectClass *) feComponentTransfer_parent_class)->release(object); } +static NR::FilterComponentTransferType sp_feComponenttransfer_read_type(gchar const *value){ + if (!value) return NR::COMPONENTTRANSFER_TYPE_ERROR; //type attribute is REQUIRED. + switch(value[0]){ + case 'i': + if (strncmp(value, "identity", 8) == 0) return NR::COMPONENTTRANSFER_TYPE_IDENTITY; + break; + case 't': + if (strncmp(value, "table", 5) == 0) return NR::COMPONENTTRANSFER_TYPE_TABLE; + break; + case 'd': + if (strncmp(value, "discrete", 8) == 0) return NR::COMPONENTTRANSFER_TYPE_DISCRETE; + break; + case 'l': + if (strncmp(value, "linear", 6) == 0) return NR::COMPONENTTRANSFER_TYPE_LINEAR; + break; + case 'g': + if (strncmp(value, "gamma", 5) == 0) return NR::COMPONENTTRANSFER_TYPE_GAMMA; + break; + } + return NR::COMPONENTTRANSFER_TYPE_ERROR; //type attribute is REQUIRED. +} + /** * Sets a specific value in the SPFeComponentTransfer. */ diff --git a/src/sp-fecomponenttransfer.h b/src/sp-fecomponenttransfer.h index 8c4544613..2a0fa01ed 100644 --- a/src/sp-fecomponenttransfer.h +++ b/src/sp-fecomponenttransfer.h @@ -15,13 +15,21 @@ #include "sp-filter.h" #include "sp-fecomponenttransfer-fns.h" +#include "display/nr-filter-component-transfer.h" +#include /* FeComponentTransfer base class */ class SPFeComponentTransferClass; struct SPFeComponentTransfer : public SPFilterPrimitive { /** COMPONENTTRANSFER ATTRIBUTES HERE */ - + NR::FilterComponentTransferType type; + std::vector tableValues; + double slope; + double intercept; + double amplitude; + double exponent; + double offset; }; struct SPFeComponentTransferClass {