From: nicholasbishop Date: Sun, 12 Aug 2007 09:35:38 +0000 (+0000) Subject: Filter effects dialog: X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=000dfc9dd0bc3d8cd37fabe93f6f9d1ede190adf;p=inkscape.git Filter effects dialog: * Changed SPFeTurbulence/FilterTurbulence to use an enum for the type field * Added type setting to the filter dialog --- diff --git a/src/display/nr-filter-turbulence.cpp b/src/display/nr-filter-turbulence.cpp index 2dbb33e65..7a5fc1dcd 100644 --- a/src/display/nr-filter-turbulence.cpp +++ b/src/display/nr-filter-turbulence.cpp @@ -46,7 +46,7 @@ void FilterTurbulence::set_stitchTiles(bool st){ stitchTiles=st; } -void FilterTurbulence::set_type(int t){ +void FilterTurbulence::set_type(FilterTurbulenceType t){ type=t; } diff --git a/src/display/nr-filter-turbulence.h b/src/display/nr-filter-turbulence.h index bdb52e7b7..8f7849f88 100644 --- a/src/display/nr-filter-turbulence.h +++ b/src/display/nr-filter-turbulence.h @@ -18,6 +18,12 @@ namespace NR { +enum FilterTurbulenceType { + TURBULENCE_FRACTALNOISE, + TURBULENCE_TURBULENCE, + TURBULENCE_ENDTYPE +}; + class FilterTurbulence : public FilterPrimitive { public: FilterTurbulence(); @@ -29,13 +35,13 @@ public: virtual void set_numOctaves(int num); virtual void set_seed(double s); virtual void set_stitchTiles(bool st); - virtual void set_type(int t); + virtual void set_type(FilterTurbulenceType t); private: double XbaseFrequency, YbaseFrequency; int numOctaves; double seed; bool stitchTiles; - int type; + FilterTurbulenceType type; }; } /* namespace NR */ diff --git a/src/filter-enums.cpp b/src/filter-enums.cpp index d9f0a3986..111cd62f9 100644 --- a/src/filter-enums.cpp +++ b/src/filter-enums.cpp @@ -101,6 +101,13 @@ const EnumData MorphologyOperatorData[NR::MORPHOLO }; const EnumDataConverter MorphologyOperatorConverter(MorphologyOperatorData, NR::MORPHOLOGY_OPERATOR_END); +// feTurbulence +const EnumData TurbulenceTypeData[NR::TURBULENCE_ENDTYPE] = { + {NR::TURBULENCE_FRACTALNOISE, _("Fractal Noise"), "fractalNoise"}, + {NR::TURBULENCE_TURBULENCE, _("Turbulence"), "turbulence"} +}; +const EnumDataConverter TurbulenceTypeConverter(TurbulenceTypeData, NR::TURBULENCE_ENDTYPE); + // Light source const EnumData LightSourceData[LIGHT_ENDSOURCE] = { {LIGHT_DISTANT, _("Distance Light"), "svg:feDistanceLight"}, diff --git a/src/filter-enums.h b/src/filter-enums.h index 37c7e6f0d..c1e3fcdcc 100644 --- a/src/filter-enums.h +++ b/src/filter-enums.h @@ -17,6 +17,7 @@ #include "display/nr-filter-composite.h" #include "display/nr-filter-convolve-matrix.h" #include "display/nr-filter-morphology.h" +#include "display/nr-filter-turbulence.h" #include "display/nr-filter-types.h" #include "util/enums.h" @@ -55,6 +56,9 @@ extern const Inkscape::Util::EnumDataConverter DisplacementMapChannelConver // Morphology operator extern const Inkscape::Util::EnumData MorphologyOperatorData[NR::MORPHOLOGY_OPERATOR_END]; extern const Inkscape::Util::EnumDataConverter MorphologyOperatorConverter; +// Turbulence type +extern const Inkscape::Util::EnumData TurbulenceTypeData[NR::TURBULENCE_ENDTYPE]; +extern const Inkscape::Util::EnumDataConverter TurbulenceTypeConverter; // Lighting enum LightSource { LIGHT_DISTANT, diff --git a/src/sp-feturbulence.cpp b/src/sp-feturbulence.cpp index effdd777e..dfff840e0 100644 --- a/src/sp-feturbulence.cpp +++ b/src/sp-feturbulence.cpp @@ -129,17 +129,17 @@ static bool sp_feTurbulence_read_stitchTiles(gchar const *value){ return false; // 'noStitch' is default } -static int sp_feTurbulence_read_type(gchar const *value){ - if (!value) return 1; // 'turbulence' is default +static NR::FilterTurbulenceType sp_feTurbulence_read_type(gchar const *value){ + if (!value) return NR::TURBULENCE_TURBULENCE; // 'turbulence' is default switch(value[0]){ case 'f': - if (strncmp(value, "fractalNoise", 12) == 0) return 0; + if (strncmp(value, "fractalNoise", 12) == 0) return NR::TURBULENCE_FRACTALNOISE; break; case 't': - if (strncmp(value, "turbulence", 10) == 0) return 1; + if (strncmp(value, "turbulence", 10) == 0) return NR::TURBULENCE_TURBULENCE; break; } - return 1; // 'turbulence' is default + return NR::TURBULENCE_TURBULENCE; // 'turbulence' is default } /** @@ -154,6 +154,7 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) int read_int; double read_num; bool read_bool; + NR::FilterTurbulenceType read_type; switch(key) { /*DEAL WITH SETTING ATTRIBUTES HERE*/ @@ -187,9 +188,9 @@ sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) } break; case SP_ATTR_TYPE: - read_int = sp_feTurbulence_read_type(value); - if (read_int != feTurbulence->type){ - feTurbulence->type = read_int; + read_type = sp_feTurbulence_read_type(value); + if (read_type != feTurbulence->type){ + feTurbulence->type = read_type; object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; diff --git a/src/sp-feturbulence.h b/src/sp-feturbulence.h index 7f9adae13..40e1c0a42 100644 --- a/src/sp-feturbulence.h +++ b/src/sp-feturbulence.h @@ -17,6 +17,7 @@ #include "sp-filter.h" #include "sp-feturbulence-fns.h" #include "number-opt-number.h" +#include "display/nr-filter-turbulence.h" /* FeTurbulence base class */ class SPFeTurbulenceClass; @@ -27,7 +28,7 @@ struct SPFeTurbulence : public SPFilterPrimitive { int numOctaves; double seed; bool stitchTiles; - int type; + NR::FilterTurbulenceType type; }; struct SPFeTurbulenceClass { diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index c871d447e..24ba5cfc8 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1820,6 +1820,7 @@ void FilterEffectsDialog::init_settings_widgets() _settings->type(NR_FILTER_TURBULENCE); _settings->add_checkbutton(SP_ATTR_STITCHTILES, _("Stitch Tiles"), "stitch", "noStitch"); + _settings->add_combo(SP_ATTR_TYPE, _("Type"), TurbulenceTypeConverter); _settings->add_dualspinslider(SP_ATTR_BASEFREQUENCY, _("Base Frequency"), 0, 100, 1, 0.01, 1); _settings->add_spinslider(SP_ATTR_NUMOCTAVES, _("Octaves"), 1, 10, 1, 1, 0); _settings->add_spinslider(SP_ATTR_SEED, _("Seed"), 0, 1000, 1, 1, 0);