summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4725fe6)
raw | patch | inline | side by side (parent: 4725fe6)
author | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sun, 5 Aug 2007 06:23:46 +0000 (06:23 +0000) | ||
committer | nicholasbishop <nicholasbishop@users.sourceforge.net> | |
Sun, 5 Aug 2007 06:23:46 +0000 (06:23 +0000) |
* Changed type field of ColorMatrix filter to use an enum rather than a plain int
* Added control for the ColorMatrix type to the filter dialog
* Added control for the ColorMatrix type to the filter dialog
index 94f8ee9624eb6f1a960b84bd3245d8ce8cf2c25f..74394bfc1909c6a4e9ca48eeb4bb117f4a971cc6 100644 (file)
y1=in->area.y1;
switch(type){
- case 0: //matrix
+ case COLORMATRIX_MATRIX:
if (values.size()!=20) {
g_warning("ColorMatrix: values parameter error. Wrong size.");
return -1;
}
}
break;
- case 1: //saturate
+ case COLORMATRIX_SATURATE:
for (x=x0;x<x1;x++){
for (y=y0;y<y1;y++){
i = ((x-x0) + (x1-x0)*(y-y0))*4;
}
}
break;
- case 2: //hueRotate
+ case COLORMATRIX_HUEROTATE:
coshue = cos(value);
sinhue = sin(value);
a00 = 0.213 + coshue*( 0.787) + sinhue*(-0.213);
}
}
break;
- case 3: //luminanceToAlpha
+ case COLORMATRIX_LUMINANCETOALPHA:
for (x=x0;x<x1;x++){
for (y=y0;y<y1;y++){
i = ((x-x0) + (x1-x0)*(y-y0))*4;
}
}
break;
+ case COLORMATRIX_ENDTYPE:
+ break;
}
out->empty = FALSE;
slot.set(_output, out);
{
}
-void FilterColorMatrix::set_type(int t){
+void FilterColorMatrix::set_type(FilterColorMatrixType t){
type = t;
}
index 9cb628d50c7b58f1fdbc627014516cdf6d875876..32b57ce0c3b18a702fa88040fe92a66d1c46a652 100644 (file)
namespace NR {
+enum FilterColorMatrixType {
+ COLORMATRIX_MATRIX,
+ COLORMATRIX_SATURATE,
+ COLORMATRIX_HUEROTATE,
+ COLORMATRIX_LUMINANCETOALPHA,
+ COLORMATRIX_ENDTYPE
+};
+
class FilterColorMatrix : public FilterPrimitive {
public:
FilterColorMatrix();
virtual int render(FilterSlot &slot, Matrix const &trans);
virtual void area_enlarge(NRRectL &area, Matrix const &trans);
- virtual void set_type(int type);
+ virtual void set_type(FilterColorMatrixType type);
virtual void set_value(gdouble value);
virtual void set_values(std::vector<gdouble> &values);
private:
std::vector<gdouble> values;
gdouble value;
- int type;
+ FilterColorMatrixType type;
};
} /* namespace NR */
diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp
index 624ed8889cc208b80d8b135afccaaf3e67e75cef..2d26095a47f5c6ff660aae135e9fa79397916fdd 100644 (file)
--- a/src/filter-enums.cpp
+++ b/src/filter-enums.cpp
};
const EnumDataConverter<FilterPrimitiveInput> FPInputConverter(FPInputData, FPINPUT_END);
+// feBlend
const EnumData<NR::FilterBlendMode> BlendModeData[NR::BLEND_ENDMODE] = {
- {NR::BLEND_NORMAL, _("Normal"), "normal"},
+ {NR::BLEND_NORMAL, _("Normal"), "normal"},
{NR::BLEND_MULTIPLY, _("Multiply"), "multiply"},
- {NR::BLEND_SCREEN, _("Screen"), "screen"},
- {NR::BLEND_DARKEN, _("Darken"), "darken"},
- {NR::BLEND_LIGHTEN, _("Lighten"), "lighten"}
+ {NR::BLEND_SCREEN, _("Screen"), "screen"},
+ {NR::BLEND_DARKEN, _("Darken"), "darken"},
+ {NR::BLEND_LIGHTEN, _("Lighten"), "lighten"}
};
const EnumDataConverter<NR::FilterBlendMode> BlendModeConverter(BlendModeData, NR::BLEND_ENDMODE);
+
+const EnumData<NR::FilterColorMatrixType> ColorMatrixTypeData[NR::COLORMATRIX_ENDTYPE] = {
+ {NR::COLORMATRIX_MATRIX, _("Matrix"), "matrix"},
+ {NR::COLORMATRIX_SATURATE, _("Saturate"), "saturate"},
+ {NR::COLORMATRIX_HUEROTATE, _("Hue Rotate"), "hueRotate"},
+ {NR::COLORMATRIX_LUMINANCETOALPHA, _("Luminance to Alpha"), "luminanceToAlpha"}
+};
+const EnumDataConverter<NR::FilterColorMatrixType> ColorMatrixTypeConverter(ColorMatrixTypeData, NR::COLORMATRIX_ENDTYPE);
+
+// feComposite
const EnumData<FeCompositeOperator> CompositeOperatorData[COMPOSITE_ENDOPERATOR] = {
{COMPOSITE_DEFAULT, _("Default"), ""},
{COMPOSITE_OVER, _("Over"), "over"},
};
const EnumDataConverter<FeCompositeOperator> CompositeOperatorConverter(CompositeOperatorData, COMPOSITE_ENDOPERATOR);
+// Light source
const EnumData<LightSource> LightSourceData[LIGHT_ENDSOURCE] = {
{LIGHT_DISTANT, _("Distance Light"), "svg:feDistanceLight"},
{LIGHT_POINT, _("Point Light"), "svg:fePointLight"},
diff --git a/src/filter-enums.h b/src/filter-enums.h
index 76ec019ec0164b8e091306422669cf534f9bff4e..cbea5545b59bc4b7fb83e4398d02927a46f862a3 100644 (file)
--- a/src/filter-enums.h
+++ b/src/filter-enums.h
*/
#include "display/nr-filter-blend.h"
+#include "display/nr-filter-colormatrix.h"
#include "display/nr-filter-composite.h"
#include "display/nr-filter-types.h"
#include "util/enums.h"
// Blend mode
extern const Inkscape::Util::EnumData<NR::FilterBlendMode> BlendModeData[NR::BLEND_ENDMODE];
extern const Inkscape::Util::EnumDataConverter<NR::FilterBlendMode> BlendModeConverter;
+// ColorMatrix type
+extern const Inkscape::Util::EnumData<NR::FilterColorMatrixType> ColorMatrixTypeData[NR::COLORMATRIX_ENDTYPE];
+extern const Inkscape::Util::EnumDataConverter<NR::FilterColorMatrixType> ColorMatrixTypeConverter;
// Composite operator
extern const Inkscape::Util::EnumData<FeCompositeOperator> CompositeOperatorData[COMPOSITE_ENDOPERATOR];
extern const Inkscape::Util::EnumDataConverter<FeCompositeOperator> CompositeOperatorConverter;
index d20c1145696ad375574cbdaebedd6bd5193b1cc7..6ff107b9f0d0ffbc9253d2a7f6c4d1e5c5fdae0d 100644 (file)
--- a/src/sp-fecolormatrix.cpp
+++ b/src/sp-fecolormatrix.cpp
((SPObjectClass *) feColorMatrix_parent_class)->release(object);
}
-static int sp_feColorMatrix_read_type(gchar const *value){
- if (!value) return 0; //matrix is default
+static NR::FilterColorMatrixType sp_feColorMatrix_read_type(gchar const *value){
+ if (!value) return NR::COLORMATRIX_MATRIX; //matrix is default
switch(value[0]){
case 'm':
- if (strcmp(value, "matrix") == 0) return 0;
+ if (strcmp(value, "matrix") == 0) return NR::COLORMATRIX_MATRIX;
break;
case 's':
- if (strcmp(value, "saturate") == 0) return 1;
+ if (strcmp(value, "saturate") == 0) return NR::COLORMATRIX_SATURATE;
break;
case 'h':
- if (strcmp(value, "hueRotate") == 0) return 2;
+ if (strcmp(value, "hueRotate") == 0) return NR::COLORMATRIX_HUEROTATE;
break;
case 'l':
- if (strcmp(value, "luminanceToAlpha") == 0) return 3;
+ if (strcmp(value, "luminanceToAlpha") == 0) return NR::COLORMATRIX_LUMINANCETOALPHA;
break;
}
- return 0; //matrix is default
+ return NR::COLORMATRIX_MATRIX; //matrix is default
}
/**
SPFeColorMatrix *feColorMatrix = SP_FECOLORMATRIX(object);
(void)feColorMatrix;
- int read_int;
+ NR::FilterColorMatrixType read_type;
gdouble read_num;
/*DEAL WITH SETTING ATTRIBUTES HERE*/
switch(key) {
case SP_ATTR_TYPE:
- read_int = sp_feColorMatrix_read_type(str);
- if (feColorMatrix->type != read_int){
- feColorMatrix->type = read_int;
+ read_type = sp_feColorMatrix_read_type(str);
+ if (feColorMatrix->type != read_type){
+ feColorMatrix->type = read_type;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
diff --git a/src/sp-fecolormatrix.h b/src/sp-fecolormatrix.h
index bf04c54891fd2541f6c5e58ba12138ccde83f4fc..e091a0725282d2d84abc65db41d53fc34897aeb1 100644 (file)
--- a/src/sp-fecolormatrix.h
+++ b/src/sp-fecolormatrix.h
#include "sp-filter.h"
#include "sp-fecolormatrix-fns.h"
+#include "display/nr-filter-colormatrix.h"
#include <vector>
/* FeColorMatrix base class */
struct SPFeColorMatrix : public SPFilterPrimitive {
/** COLORMATRIX ATTRIBUTES HERE */
- int type;
+ NR::FilterColorMatrixType type;
gdouble value;
std::vector<gdouble> values;
};
index f3fa074d54e21fb4ce587768db6a0dc398b9d136..f842e97ad64be4c5f35bf3f150646b66e6a289e5 100644 (file)
_settings->type(NR_FILTER_BLEND);
_settings->add_combo(SP_ATTR_MODE, _("Mode"), BlendModeConverter);
+ _settings->type(NR_FILTER_COLORMATRIX);
+ _settings->add_combo(SP_ATTR_TYPE, _("Type"), ColorMatrixTypeConverter);
+
_settings->type(NR_FILTER_COMPOSITE);
_settings->add_combo(SP_ATTR_OPERATOR, _("Operator"), CompositeOperatorConverter);
_k1 = _settings->add_spinslider(SP_ATTR_K1, _("K1"), -10, 10, 1, 0.01, 1);