Code

r16217@tres: ted | 2007-08-10 10:36:27 -0700
authorgouldtj <gouldtj@users.sourceforge.net>
Fri, 10 Aug 2007 17:38:51 +0000 (17:38 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Fri, 10 Aug 2007 17:38:51 +0000 (17:38 +0000)
 ImageMagick effects patch from Chris Brown.  Google Summer of Code
 project.

96 files changed:
configure.ac
po/POTFILES.in
src/Makefile_insert
src/extension/Makefile_insert
src/extension/extension.cpp
src/extension/extension.h
src/extension/init.cpp
src/extension/internal/Makefile_insert
src/extension/internal/bitmap/adaptiveThreshold.cpp [new file with mode: 0644]
src/extension/internal/bitmap/adaptiveThreshold.h [new file with mode: 0644]
src/extension/internal/bitmap/addNoise.cpp [new file with mode: 0644]
src/extension/internal/bitmap/addNoise.h [new file with mode: 0644]
src/extension/internal/bitmap/blur.cpp [new file with mode: 0644]
src/extension/internal/bitmap/blur.h [new file with mode: 0644]
src/extension/internal/bitmap/channel.cpp [new file with mode: 0644]
src/extension/internal/bitmap/channel.h [new file with mode: 0644]
src/extension/internal/bitmap/charcoal.cpp [new file with mode: 0644]
src/extension/internal/bitmap/charcoal.h [new file with mode: 0644]
src/extension/internal/bitmap/colorize.cpp [new file with mode: 0644]
src/extension/internal/bitmap/colorize.h [new file with mode: 0644]
src/extension/internal/bitmap/contrast.cpp [new file with mode: 0644]
src/extension/internal/bitmap/contrast.h [new file with mode: 0644]
src/extension/internal/bitmap/convolve.cpp [new file with mode: 0644]
src/extension/internal/bitmap/convolve.h [new file with mode: 0644]
src/extension/internal/bitmap/cycleColormap.cpp [new file with mode: 0644]
src/extension/internal/bitmap/cycleColormap.h [new file with mode: 0644]
src/extension/internal/bitmap/despeckle.cpp [new file with mode: 0644]
src/extension/internal/bitmap/despeckle.h [new file with mode: 0644]
src/extension/internal/bitmap/edge.cpp [new file with mode: 0644]
src/extension/internal/bitmap/edge.h [new file with mode: 0644]
src/extension/internal/bitmap/emboss.cpp [new file with mode: 0644]
src/extension/internal/bitmap/emboss.h [new file with mode: 0644]
src/extension/internal/bitmap/enhance.cpp [new file with mode: 0644]
src/extension/internal/bitmap/enhance.h [new file with mode: 0644]
src/extension/internal/bitmap/equalize.cpp [new file with mode: 0644]
src/extension/internal/bitmap/equalize.h [new file with mode: 0644]
src/extension/internal/bitmap/flop.cpp [new file with mode: 0644]
src/extension/internal/bitmap/flop.h [new file with mode: 0644]
src/extension/internal/bitmap/gaussianBlur.cpp [new file with mode: 0644]
src/extension/internal/bitmap/gaussianBlur.h [new file with mode: 0644]
src/extension/internal/bitmap/imagemagick.cpp [new file with mode: 0644]
src/extension/internal/bitmap/imagemagick.h [new file with mode: 0644]
src/extension/internal/bitmap/implode.cpp [new file with mode: 0644]
src/extension/internal/bitmap/implode.h [new file with mode: 0644]
src/extension/internal/bitmap/level.cpp [new file with mode: 0644]
src/extension/internal/bitmap/level.h [new file with mode: 0644]
src/extension/internal/bitmap/levelChannel.cpp [new file with mode: 0644]
src/extension/internal/bitmap/levelChannel.h [new file with mode: 0644]
src/extension/internal/bitmap/medianFilter.cpp [new file with mode: 0644]
src/extension/internal/bitmap/medianFilter.h [new file with mode: 0644]
src/extension/internal/bitmap/modulate.cpp [new file with mode: 0644]
src/extension/internal/bitmap/modulate.h [new file with mode: 0644]
src/extension/internal/bitmap/negate.cpp [new file with mode: 0644]
src/extension/internal/bitmap/negate.h [new file with mode: 0644]
src/extension/internal/bitmap/normalize.cpp [new file with mode: 0644]
src/extension/internal/bitmap/normalize.h [new file with mode: 0644]
src/extension/internal/bitmap/oilPaint.cpp [new file with mode: 0644]
src/extension/internal/bitmap/oilPaint.h [new file with mode: 0644]
src/extension/internal/bitmap/opacity.cpp [new file with mode: 0644]
src/extension/internal/bitmap/opacity.h [new file with mode: 0644]
src/extension/internal/bitmap/raise.cpp [new file with mode: 0644]
src/extension/internal/bitmap/raise.h [new file with mode: 0644]
src/extension/internal/bitmap/reduceNoise.cpp [new file with mode: 0644]
src/extension/internal/bitmap/reduceNoise.h [new file with mode: 0644]
src/extension/internal/bitmap/shade.cpp [new file with mode: 0644]
src/extension/internal/bitmap/shade.h [new file with mode: 0644]
src/extension/internal/bitmap/sharpen.cpp [new file with mode: 0644]
src/extension/internal/bitmap/sharpen.h [new file with mode: 0644]
src/extension/internal/bitmap/solarize.cpp [new file with mode: 0644]
src/extension/internal/bitmap/solarize.h [new file with mode: 0644]
src/extension/internal/bitmap/spread.cpp [new file with mode: 0644]
src/extension/internal/bitmap/spread.h [new file with mode: 0644]
src/extension/internal/bitmap/swirl.cpp [new file with mode: 0644]
src/extension/internal/bitmap/swirl.h [new file with mode: 0644]
src/extension/internal/bitmap/threshold.cpp [new file with mode: 0644]
src/extension/internal/bitmap/threshold.h [new file with mode: 0644]
src/extension/internal/bitmap/unsharpmask.cpp [new file with mode: 0644]
src/extension/internal/bitmap/unsharpmask.h [new file with mode: 0644]
src/extension/internal/bitmap/wave.cpp [new file with mode: 0644]
src/extension/internal/bitmap/wave.h [new file with mode: 0644]
src/extension/parambool.cpp [new file with mode: 0644]
src/extension/parambool.h [new file with mode: 0644]
src/extension/paramcolor.cpp [new file with mode: 0644]
src/extension/paramcolor.h [new file with mode: 0644]
src/extension/paramdescription.cpp [new file with mode: 0644]
src/extension/paramdescription.h [new file with mode: 0644]
src/extension/paramenum.cpp
src/extension/paramenum.h
src/extension/parameter.cpp
src/extension/parameter.h
src/extension/paramfloat.cpp [new file with mode: 0644]
src/extension/paramfloat.h [new file with mode: 0644]
src/extension/paramint.cpp [new file with mode: 0644]
src/extension/paramint.h [new file with mode: 0644]
src/extension/paramstring.cpp [new file with mode: 0644]
src/extension/paramstring.h [new file with mode: 0644]

index 47466a30a03d727a0647d22ceda0543dcbbb71b4..b776663dcd2bf5fac77091f6c776a57aaa0adeb0 100644 (file)
@@ -560,6 +560,23 @@ AM_CONDITIONAL(WITH_INKBOARD, test "x$with_inkboard" = "xyes")
 AC_SUBST(INKBOARD_LIBS)
 AC_SUBST(INKBOARD_CFLAGS)
 
+dnl ******************************
+dnl Check for ImageMagick Magick++ 
+dnl ******************************
+
+AC_CHECK_LIB(Magick++, InitializeMagick, [AC_CHECK_HEADER(Magick++.h, magick_ok=yes, magick_ok=no)], magick_ok=no, -llcms -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lz -lpthread -lm -lpthread)
+
+if test "x$magick_ok" = "xyes"; then
+       AC_CHECK_PROG(MAGICKPP_CONFIG, Magick++-config, yes, no)
+       if test "x$MAGICKPP_CONFIG" = "xyes"; then
+               IMAGEMAGICK_LIBS=`Magick++-config --libs`
+               AC_SUBST(IMAGEMAGICK_LIBS)
+               AC_DEFINE(WITH_IMAGE_MAGICK,1,[Image Magick++ support for bitmap effects])
+       fi
+fi
+
+AM_CONDITIONAL(USE_IMAGE_MAGICK, test "x$magick_ok" = "xyes")
+
 dnl ******************************
 dnl   Unconditional dependencies
 dnl ******************************
@@ -927,4 +944,5 @@ Configuration:
         Enable LittleCms:         ${enable_lcms}
         Enable Inkboard:          ${with_inkboard}
         Enable SSL in Inkboard:   ${with_inkboard_ssl}
+        ImageMagick Magick++:     ${magick_ok}
 "
index 26a9b616d399e5fd29fe40c7ab11b20957c64b3f..d3d40f4ea7cbe537313876d239394aa4c133cb83 100644 (file)
@@ -68,33 +68,129 @@ src/event-context.cpp
 src/event-log.cpp
 src/extension/db.cpp
 src/extension/dependency.cpp
+src/extension/dxf2svg/aci2rgb.cpp
+src/extension/dxf2svg/blocks.cpp
+src/extension/dxf2svg/dxf2svg.cpp
+src/extension/dxf2svg/entities2elements.cpp
+src/extension/dxf2svg/entities.cpp
+src/extension/dxf2svg/read_dxf.cpp
+src/extension/dxf2svg/tables2svg_info.cpp
+src/extension/dxf2svg/tables.cpp
+src/extension/dxf2svg/test_dxf.cpp
 src/extension/effect.cpp
+src/extension/error-file.cpp
 src/extension/execution-env.cpp
 src/extension/extension.cpp
-src/extension/error-file.cpp
 src/extension/implementation/implementation.cpp
 src/extension/implementation/script.cpp
+src/extension/implementation/xslt.cpp
 src/extension/init.cpp
+src/extension/input.cpp
+src/extension/internal/bitmap/adaptiveThreshold.cpp
+src/extension/internal/bitmap/addNoise.cpp
+src/extension/internal/bitmap/blur.cpp
+src/extension/internal/bitmap/channel.cpp
+src/extension/internal/bitmap/charcoal.cpp
+src/extension/internal/bitmap/colorize.cpp
+src/extension/internal/bitmap/contrast.cpp
+src/extension/internal/bitmap/convolve.cpp
+src/extension/internal/bitmap/cycleColormap.cpp
+src/extension/internal/bitmap/despeckle.cpp
+src/extension/internal/bitmap/edge.cpp
+src/extension/internal/bitmap/emboss.cpp
+src/extension/internal/bitmap/enhance.cpp
+src/extension/internal/bitmap/equalize.cpp
+src/extension/internal/bitmap/flop.cpp
+src/extension/internal/bitmap/gaussianBlur.cpp
+src/extension/internal/bitmap/imagemagick.cpp
+src/extension/internal/bitmap/implode.cpp
+src/extension/internal/bitmap/levelChannel.cpp
+src/extension/internal/bitmap/level.cpp
+src/extension/internal/bitmap/medianFilter.cpp
+src/extension/internal/bitmap/modulate.cpp
+src/extension/internal/bitmap/negate.cpp
+src/extension/internal/bitmap/normalize.cpp
+src/extension/internal/bitmap/oilPaint.cpp
+src/extension/internal/bitmap/opacity.cpp
+src/extension/internal/bitmap/raise.cpp
+src/extension/internal/bitmap/reduceNoise.cpp
+src/extension/internal/bitmap/shade.cpp
+src/extension/internal/bitmap/sharpen.cpp
+src/extension/internal/bitmap/solarize.cpp
+src/extension/internal/bitmap/spread.cpp
+src/extension/internal/bitmap/swirl.cpp
+src/extension/internal/bitmap/threshold.cpp
+src/extension/internal/bitmap/unsharpmask.cpp
+src/extension/internal/bitmap/wave.cpp
 src/extension/internal/bluredge.cpp
-src/extension/internal/eps-out.cpp
+src/extension/internal/cairo-pdf-out.cpp
+src/extension/internal/cairo-png-out.cpp
+src/extension/internal/cairo-ps-out.cpp
+src/extension/internal/cairo-render-context.cpp
+src/extension/internal/cairo-renderer.cpp
+src/extension/internal/cairo-renderer-pdf-out.cpp
 src/extension/internal/emf-win32-inout.cpp
+src/extension/internal/emf-win32-print.cpp
+src/extension/internal/eps-out.cpp
 src/extension/internal/gdkpixbuf-input.cpp
 src/extension/internal/gimpgrad.cpp
 src/extension/internal/gnome.cpp
 src/extension/internal/grid.cpp
-src/extension/internal/latex-pstricks-out.cpp
 src/extension/internal/latex-pstricks.cpp
+src/extension/internal/latex-pstricks-out.cpp
+src/extension/internal/libwpg/WPG1Parser.cpp
+src/extension/internal/libwpg/WPG2Parser.cpp
+src/extension/internal/libwpg/WPGBrush.cpp
+src/extension/internal/libwpg/WPGColor.cpp
+src/extension/internal/libwpg/WPGGradient.cpp
+src/extension/internal/libwpg/WPGHeader.cpp
+src/extension/internal/libwpg/WPGOLEStream.cpp
+src/extension/internal/libwpg/WPGPath.cpp
+src/extension/internal/libwpg/WPGPen.cpp
+src/extension/internal/libwpg/WPGPoint.cpp
+src/extension/internal/libwpg/WPGraphics.cpp
+src/extension/internal/libwpg/WPGRect.cpp
+src/extension/internal/libwpg/WPGStreamImplementation.cpp
+src/extension/internal/libwpg/WPGString.cpp
+src/extension/internal/libwpg/WPGSVGGenerator.cpp
+src/extension/internal/libwpg/WPGXParser.cpp
 src/extension/internal/odf.cpp
 src/extension/internal/pdf-cairo.cpp
+src/extension/internal/pdf-input-cairo.cpp
+src/extension/internal/pdfinput/pdf-input.cpp
+src/extension/internal/pdfinput/pdf-parser.cpp
+src/extension/internal/pdfinput/svg-builder.cpp
 src/extension/internal/pov-out.cpp
-src/extension/internal/ps-out.cpp
 src/extension/internal/ps.cpp
+src/extension/internal/ps-out.cpp
 src/extension/internal/svg.cpp
 src/extension/internal/svgz.cpp
 src/extension/internal/win32.cpp
 src/extension/internal/wpg-input.cpp
+src/extension/output.cpp
+src/extension/parambool.cpp
+src/extension/paramcolor.cpp
+src/extension/paramdescription.cpp
+src/extension/paramenum.cpp
+src/extension/parameter.cpp
+src/extension/paramfloat.cpp
+src/extension/paramint.cpp
+src/extension/paramnotebook.cpp
+src/extension/paramradiobutton.cpp
+src/extension/paramstring.cpp
+src/extension/patheffect.cpp
 src/extension/prefdialog.cpp
+src/extension/print.cpp
+src/extension/script/bindtest.cpp
+src/extension/script/cpptest.cpp
+src/extension/script/InkscapeBinding.cpp
+src/extension/script/InkscapeInterpreter.cpp
+src/extension/script/InkscapePerl.cpp
+src/extension/script/inkscape_perl_wrap.cpp
+src/extension/script/InkscapePython.cpp
+src/extension/script/InkscapeScript.cpp
 src/extension/system.cpp
+src/extension/timer.cpp
 src/extract-uri.cpp
 src/file.cpp
 src/fixes.cpp
index 946e3b1ffe238f336385369cfdb45000d05c2454..89fa9cb1129a12107c6401a3bdd076b5b75fa51f 100644 (file)
@@ -365,7 +365,8 @@ all_libs =                  \
        $(win32ldflags)         \
        $(PERL_LIBS)            \
        $(PYTHON_LIBS)  \
-       $(INKBOARD_LIBS)
+       $(INKBOARD_LIBS) \
+       $(IMAGEMAGICK_LIBS)
 
 desktop.$(OBJEXT): helper/sp-marshal.h
 document.$(OBJEXT): helper/sp-marshal.h inkscape_version.h
index 3df936cd92555c4cf34b4367265bde90892f5589..9c6cdd61f062d26aff66a028e8e6609de093b243 100644 (file)
@@ -23,10 +23,22 @@ extension_libextension_a_SOURCES =  \
        extension/parameter.cpp \
        extension/paramnotebook.h \
        extension/paramnotebook.cpp \
+       extension/parambool.h \
+       extension/parambool.cpp \
+       extension/paramcolor.h \
+       extension/paramcolor.cpp \
+       extension/paramdescription.h \
+       extension/paramdescription.cpp \
        extension/paramenum.h \
        extension/paramenum.cpp \
+       extension/paramfloat.h \
+       extension/paramfloat.cpp \
+       extension/paramint.h \
+       extension/paramint.cpp \
        extension/paramradiobutton.h \
        extension/paramradiobutton.cpp \
+       extension/paramstring.h \
+       extension/paramstring.cpp \
        extension/prefdialog.cpp \
        extension/prefdialog.h \
        extension/system.cpp    \
index 5082ba08e4bfc424fef7095e2940c6e7eec9a617..b56a1d6f203d4ec8aab85ed25b0ca1f93479176f 100644 (file)
@@ -428,6 +428,13 @@ Extension::get_param_string (const gchar * name, const SPDocument * doc, const I
     return param->get_string(doc, node);
 }
 
+const gchar *
+Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
+{
+    Parameter* param = param_shared(name, parameters);
+    return param->get_enum(doc, node);
+}
+
 /**
     \return   The value of the parameter identified by the name
     \brief    Gets a parameter identified by name with the bool placed
@@ -487,6 +494,24 @@ Extension::get_param_float (const gchar * name, const SPDocument * doc, const In
     return param->get_float(doc, node);
 }
 
+/**
+    \return   The string value for the parameter specified
+    \brief    Gets a parameter identified by name with the float placed
+              in value.
+    \param    name    The name of the parameter to get
+    \param    doc    The document to look in for document specific parameters
+    \param    node   The node to look in for a specific parameter
+
+    Look up in the parameters list, then execute the function on that
+    found parameter.
+*/
+SPColor*
+Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
+{
+    Parameter* param = param_shared(name, parameters);
+    return param->get_color(doc, node);
+}
+
 /**
     \return   The passed in value
     \brief    Sets a parameter identified by name with the boolean
@@ -567,6 +592,25 @@ Extension::set_param_string (const gchar * name, const gchar * value, SPDocument
     return param->set_string(value, doc, node);
 }
 
+/**
+    \return   The passed in value
+    \brief    Sets a parameter identified by name with the string
+              in the parameter value.
+    \param    name    The name of the parameter to set
+    \param    value   The value to set the parameter to
+    \param    doc    The document to look in for document specific parameters
+    \param    node   The node to look in for a specific parameter
+
+    Look up in the parameters list, then execute the function on that
+    found parameter.
+*/
+SPColor*
+Extension::set_param_color (const gchar * name, SPColor* color, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    Parameter* param = param_shared(name, parameters);
+    return param->set_color(color, doc, node);
+}
+
 /** \brief A function to open the error log file. */
 void
 Extension::error_file_open (void)
index a1993f941b8473d7a82f4bb3da061985e68f8343..967dda2cf16036bf2e14fbae7ba42857c7902e1c 100644 (file)
@@ -131,6 +131,12 @@ private:
 public:
     /** An error class for when a parameter is called on a type it is not */
     class param_wrong_type {};
+       class param_not_color_param {};
+    class param_not_enum_param {};
+    class param_not_string_param {};
+    class param_not_float_param {};
+    class param_not_int_param {};
+    class param_not_bool_param {};
     
     /** An error class for when a parameter is looked for that just 
      * simply doesn't exist */
@@ -159,6 +165,12 @@ public:
     const gchar *    get_param_string (const gchar * name,
                                        const SPDocument *   doc = NULL,
                                        const Inkscape::XML::Node * node = NULL);
+       SPColor*        get_param_color   (const gchar * name,
+                                       const SPDocument *   doc = NULL,
+                                       const Inkscape::XML::Node * node = NULL);
+       const gchar *   get_param_enum    (const gchar * name,
+                                       const SPDocument *   doc = NULL,
+                                       const Inkscape::XML::Node * node = NULL);
     bool             set_param_bool   (const gchar * name,
                                        bool          value,
                                        SPDocument *   doc = NULL,
@@ -175,6 +187,10 @@ public:
                                        const gchar * value,
                                        SPDocument *   doc = NULL,
                                        Inkscape::XML::Node *       node = NULL);
+       SPColor*        set_param_color   (const gchar * name,
+                                       SPColor* color,
+                                       SPDocument *   doc = NULL,
+                                       Inkscape::XML::Node *       node = NULL);
 
     /* Error file handling */
 public:
index 239a5bb26b4de1fc86d35a1a4a285cd1e67c5055..fca5a7e5d2481b3cc7b08dc09db5114917f08d8e 100644 (file)
 #include "prefs-utils.h"
 #include "io/sys.h"
 
+#ifdef WITH_IMAGE_MAGICK
+#include "internal/bitmap/adaptiveThreshold.h"
+#include "internal/bitmap/addNoise.h"
+#include "internal/bitmap/blur.h"
+#include "internal/bitmap/channel.h"
+#include "internal/bitmap/charcoal.h"
+#include "internal/bitmap/colorize.h"
+#include "internal/bitmap/contrast.h"
+#include "internal/bitmap/convolve.h"
+#include "internal/bitmap/cycleColormap.h"
+#include "internal/bitmap/despeckle.h"
+#include "internal/bitmap/edge.h"
+#include "internal/bitmap/emboss.h"
+#include "internal/bitmap/enhance.h"
+#include "internal/bitmap/equalize.h"
+#include "internal/bitmap/flop.h"
+#include "internal/bitmap/gaussianBlur.h"
+#include "internal/bitmap/implode.h"
+#include "internal/bitmap/level.h"
+#include "internal/bitmap/levelChannel.h"
+#include "internal/bitmap/medianFilter.h"
+#include "internal/bitmap/modulate.h"
+#include "internal/bitmap/negate.h"
+#include "internal/bitmap/normalize.h"
+#include "internal/bitmap/oilPaint.h"
+#include "internal/bitmap/opacity.h"
+#include "internal/bitmap/raise.h"
+#include "internal/bitmap/reduceNoise.h"
+#include "internal/bitmap/shade.h"
+#include "internal/bitmap/sharpen.h"
+#include "internal/bitmap/solarize.h"
+#include "internal/bitmap/spread.h"
+#include "internal/bitmap/swirl.h"
+#include "internal/bitmap/threshold.h"
+#include "internal/bitmap/unsharpmask.h"
+#include "internal/bitmap/wave.h"
+#endif /* WITH_IMAGE_MAGICK */
+
 extern gboolean inkscape_app_use_gui( Inkscape::Application const *app );
 
 namespace Inkscape {
@@ -156,6 +194,45 @@ init()
     Internal::BlurEdge::init();
     Internal::GimpGrad::init();
     Internal::Grid::init();
+       
+    /* Raster Effects */
+#ifdef WITH_IMAGE_MAGICK
+    Internal::Bitmap::AdaptiveThreshold::init();
+    Internal::Bitmap::AddNoise::init();
+    Internal::Bitmap::Blur::init();
+    Internal::Bitmap::Channel::init();
+    Internal::Bitmap::Charcoal::init();
+    Internal::Bitmap::Colorize::init();
+    Internal::Bitmap::Contrast::init();
+    Internal::Bitmap::Convolve::init();
+    Internal::Bitmap::CycleColormap::init();
+    Internal::Bitmap::Edge::init();
+    Internal::Bitmap::Despeckle::init();
+    Internal::Bitmap::Emboss::init();
+    Internal::Bitmap::Enhance::init();
+    Internal::Bitmap::Equalize::init();
+    Internal::Bitmap::Flop::init();
+    Internal::Bitmap::GaussianBlur::init();
+    Internal::Bitmap::Implode::init();
+    Internal::Bitmap::Level::init();
+    Internal::Bitmap::LevelChannel::init();
+    Internal::Bitmap::MedianFilter::init();
+    Internal::Bitmap::Modulate::init();
+    Internal::Bitmap::Negate::init();
+    Internal::Bitmap::Normalize::init();
+    Internal::Bitmap::OilPaint::init();
+    Internal::Bitmap::Opacity::init();
+    Internal::Bitmap::Raise::init();
+    Internal::Bitmap::ReduceNoise::init();
+    Internal::Bitmap::Shade::init();
+    Internal::Bitmap::Sharpen::init();
+    Internal::Bitmap::Solarize::init();
+    Internal::Bitmap::Spread::init();
+    Internal::Bitmap::Swirl::init();
+    Internal::Bitmap::Threshold::init();
+    Internal::Bitmap::Unsharpmask::init();
+    Internal::Bitmap::Wave::init();
+#endif /* WITH_IMAGE_MAGICK */
 
     /* Load search path for extensions */
     if (Inkscape::Extension::Extension::search_path.size() == 0)
index f615e02fd3a82fcccf47eda22fcbcab0b9b1c07b..418498efd1c035d505aee3e33a566774d8df4d7c 100644 (file)
@@ -11,6 +11,82 @@ extension_internal_gnome_print_sources =     \
        extension/internal/gnome.h
 endif
 
+if USE_IMAGE_MAGICK
+extension_internal_image_magick_sources =      \
+       extension/internal/bitmap/imagemagick.cpp               \
+       extension/internal/bitmap/imagemagick.h                 \
+       extension/internal/bitmap/adaptiveThreshold.cpp \
+       extension/internal/bitmap/adaptiveThreshold.h   \
+       extension/internal/bitmap/addNoise.cpp                  \
+       extension/internal/bitmap/addNoise.h                    \
+       extension/internal/bitmap/blur.cpp                              \
+       extension/internal/bitmap/blur.h                                \
+       extension/internal/bitmap/channel.cpp                   \
+       extension/internal/bitmap/channel.h                             \
+       extension/internal/bitmap/charcoal.cpp                  \
+       extension/internal/bitmap/charcoal.h                    \
+       extension/internal/bitmap/colorize.cpp                  \
+       extension/internal/bitmap/colorize.h                    \
+       extension/internal/bitmap/contrast.cpp                  \
+       extension/internal/bitmap/contrast.h                    \
+       extension/internal/bitmap/convolve.cpp                  \
+       extension/internal/bitmap/convolve.h                    \
+       extension/internal/bitmap/cycleColormap.cpp             \
+       extension/internal/bitmap/cycleColormap.h               \
+       extension/internal/bitmap/despeckle.cpp                 \
+       extension/internal/bitmap/despeckle.h                   \
+       extension/internal/bitmap/edge.cpp                              \
+       extension/internal/bitmap/edge.h                                \
+       extension/internal/bitmap/emboss.cpp                    \
+       extension/internal/bitmap/emboss.h                              \
+       extension/internal/bitmap/enhance.cpp                   \
+       extension/internal/bitmap/enhance.h                             \
+       extension/internal/bitmap/equalize.cpp                  \
+       extension/internal/bitmap/equalize.h                    \
+       extension/internal/bitmap/flop.cpp                              \
+       extension/internal/bitmap/flop.h                                \
+       extension/internal/bitmap/gaussianBlur.cpp              \
+       extension/internal/bitmap/gaussianBlur.h                \
+       extension/internal/bitmap/implode.cpp                   \
+       extension/internal/bitmap/implode.h                             \
+       extension/internal/bitmap/level.cpp                             \
+       extension/internal/bitmap/level.h                               \
+       extension/internal/bitmap/levelChannel.cpp              \
+       extension/internal/bitmap/levelChannel.h                \
+       extension/internal/bitmap/medianFilter.cpp              \
+       extension/internal/bitmap/medianFilter.h                \
+       extension/internal/bitmap/modulate.cpp                  \
+       extension/internal/bitmap/modulate.h                    \
+       extension/internal/bitmap/negate.cpp                    \
+       extension/internal/bitmap/negate.h                              \
+       extension/internal/bitmap/normalize.cpp                 \
+       extension/internal/bitmap/normalize.h                   \
+       extension/internal/bitmap/oilPaint.cpp                  \
+       extension/internal/bitmap/oilPaint.h                    \
+       extension/internal/bitmap/opacity.cpp                   \
+       extension/internal/bitmap/opacity.h                             \
+       extension/internal/bitmap/raise.cpp                             \
+       extension/internal/bitmap/raise.h                               \
+       extension/internal/bitmap/reduceNoise.cpp               \
+       extension/internal/bitmap/reduceNoise.h                 \
+       extension/internal/bitmap/shade.cpp                             \
+       extension/internal/bitmap/shade.h                               \
+       extension/internal/bitmap/sharpen.cpp                   \
+       extension/internal/bitmap/sharpen.h                             \
+       extension/internal/bitmap/solarize.cpp                  \
+       extension/internal/bitmap/solarize.h                    \
+       extension/internal/bitmap/spread.cpp                    \
+       extension/internal/bitmap/spread.h                              \
+       extension/internal/bitmap/swirl.cpp                             \
+       extension/internal/bitmap/swirl.h                               \
+       extension/internal/bitmap/threshold.cpp                 \
+       extension/internal/bitmap/threshold.h                   \
+       extension/internal/bitmap/unsharpmask.cpp               \
+       extension/internal/bitmap/unsharpmask.h                 \
+       extension/internal/bitmap/wave.cpp                              \
+       extension/internal/bitmap/wave.h
+endif
+
 extension_internal_libinternal_a_SOURCES =     \
        extension/internal/bluredge.h   \
        extension/internal/bluredge.cpp \
@@ -63,4 +139,6 @@ extension_internal_libinternal_a_SOURCES =   \
        extension/internal/latex-pstricks-out.h \
        extension/internal/wpg-input.cpp        \
        extension/internal/wpg-input.h  \
-       $(extension_internal_gnome_print_sources) 
+       $(extension_internal_gnome_print_sources) \
+       $(extension_internal_image_magick_sources)
+
diff --git a/src/extension/internal/bitmap/adaptiveThreshold.cpp b/src/extension/internal/bitmap/adaptiveThreshold.cpp
new file mode 100644 (file)
index 0000000..5a2db5d
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "adaptiveThreshold.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+AdaptiveThreshold::applyEffect(Magick::Image *image) {
+       image->adaptiveThreshold(_width, _height);
+}
+
+void
+AdaptiveThreshold::refreshParameters(Inkscape::Extension::Effect *module) {    
+       _width = module->get_param_int("width");
+       _height = module->get_param_int("height");
+}
+
+#include "../clear-n_.h"
+
+void
+AdaptiveThreshold::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Adaptive Threshold") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.adaptiveThreshold</id>\n"
+                       "<param name=\"width\" gui-text=\"" N_("Width") "\" type=\"int\" min=\"0\" max=\"100\">5</param>\n"
+                       "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"int\" min=\"0\" max=\"100\">1</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Adaptive Threshold Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new AdaptiveThreshold());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/adaptiveThreshold.h b/src/extension/internal/bitmap/adaptiveThreshold.h
new file mode 100644 (file)
index 0000000..e7b5e75
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class AdaptiveThreshold : public ImageMagick
+{
+private:
+       int _width;
+       int _height;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/addNoise.cpp b/src/extension/internal/bitmap/addNoise.cpp
new file mode 100644 (file)
index 0000000..11e3835
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "addNoise.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+AddNoise::applyEffect(Magick::Image *image) {
+       Magick::NoiseType noiseType = Magick::UniformNoise;
+       if (!strcmp(_noiseTypeName,      "Uniform Noise"))              noiseType = Magick::UniformNoise;
+       else if (!strcmp(_noiseTypeName, "Gaussian Noise"))             noiseType = Magick::GaussianNoise;
+       else if (!strcmp(_noiseTypeName, "Multiplicative Gaussian Noise"))      noiseType = Magick::MultiplicativeGaussianNoise;
+       else if (!strcmp(_noiseTypeName, "Impulse Noise"))              noiseType = Magick::ImpulseNoise;
+       else if (!strcmp(_noiseTypeName, "Laplacian Noise"))    noiseType = Magick::LaplacianNoise;
+       else if (!strcmp(_noiseTypeName, "Poisson Noise"))              noiseType = Magick::PoissonNoise;       
+       
+       image->addNoise(noiseType);
+}
+
+void
+AddNoise::refreshParameters(Inkscape::Extension::Effect *module) {     
+       _noiseTypeName = module->get_param_enum("noiseType");
+}
+
+#include "../clear-n_.h"
+
+void
+AddNoise::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Add Noise") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.addNoise</id>\n"
+                       "<param name=\"noiseType\" gui-text=\"" N_("Type") "\" type=\"enum\" >\n"
+                               "<item value='Uniform Noise'>Uniform Noise</item>\n"
+                               "<item value='Gaussian Noise'>Gaussian Noise</item>\n"
+                               "<item value='Multiplicative Gaussian Noise'>Multiplicative Gaussian Noise</item>\n"
+                               "<item value='Impulse Noise'>Impulse Noise</item>\n"
+                               "<item value='Laplacian Noise'>Laplacian Noise</item>\n"
+                               "<item value='Poisson Noise'>Poisson Noise</item>\n"
+                       "</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Add Noise Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new AddNoise());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/addNoise.h b/src/extension/internal/bitmap/addNoise.h
new file mode 100644 (file)
index 0000000..b1ac6a9
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class AddNoise : public ImageMagick
+{
+private:
+       const gchar* _noiseTypeName;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/blur.cpp b/src/extension/internal/bitmap/blur.cpp
new file mode 100644 (file)
index 0000000..ad2b5a8
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "blur.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Blur::applyEffect(Magick::Image *image) {
+       image->blur(_radius, _sigma);
+}
+
+void
+Blur::refreshParameters(Inkscape::Extension::Effect *module) { 
+       _radius = module->get_param_float("radius");
+       _sigma = module->get_param_float("sigma");
+}
+
+#include "../clear-n_.h"
+
+void
+Blur::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Blur") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.blur</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0.1\" max=\"20\">5.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0.1\" max=\"5\">1.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Blur Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Blur());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/blur.h b/src/extension/internal/bitmap/blur.h
new file mode 100644 (file)
index 0000000..be58ba5
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Blur : public ImageMagick
+{
+private:
+       float _radius;
+       float _sigma;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/channel.cpp b/src/extension/internal/bitmap/channel.cpp
new file mode 100644 (file)
index 0000000..7086383
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "channel.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Channel::applyEffect(Magick::Image *image) {   
+       Magick::ChannelType layer = Magick::UndefinedChannel;
+       if (!strcmp(_layerName,      "Red Channel"))            layer = Magick::RedChannel;
+       else if (!strcmp(_layerName, "Green Channel"))          layer = Magick::GreenChannel;
+       else if (!strcmp(_layerName, "Blue Channel"))           layer = Magick::BlueChannel;
+       else if (!strcmp(_layerName, "Cyan Channel"))           layer = Magick::CyanChannel;
+       else if (!strcmp(_layerName, "Magenta Channel"))        layer = Magick::MagentaChannel;
+       else if (!strcmp(_layerName, "Yellow Channel"))         layer = Magick::YellowChannel;
+       else if (!strcmp(_layerName, "Black Channel"))          layer = Magick::BlackChannel;
+       else if (!strcmp(_layerName, "Opacity Channel"))        layer = Magick::OpacityChannel;
+       else if (!strcmp(_layerName, "Matte Channel"))          layer = Magick::MatteChannel;           
+       
+       image->channel(layer);
+}
+
+void
+Channel::refreshParameters(Inkscape::Extension::Effect *module) {      
+       _layerName = module->get_param_enum("layer");
+}
+
+#include "../clear-n_.h"
+
+void
+Channel::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Channel") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.channel</id>\n"
+                       "<param name=\"layer\" gui-text=\"" N_("Layer") "\" type=\"enum\" >\n"
+                               "<item value='Red Channel'>Red Channel</item>\n"
+                               "<item value='Green Channel'>Green Channel</item>\n"
+                               "<item value='Blue Channel'>Blue Channel</item>\n"
+                               "<item value='Cyan Channel'>Cyan Channel</item>\n"
+                               "<item value='Magenta Channel'>Magenta Channel</item>\n"
+                               "<item value='Yellow Channel'>Yellow Channel</item>\n"
+                               "<item value='Black Channel'>Black Channel</item>\n"
+                               "<item value='Opacity Channel'>Opacity Channel</item>\n"
+                               "<item value='Matte Channel'>Matte Channel</item>\n"
+                       "</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Channel Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Channel());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/channel.h b/src/extension/internal/bitmap/channel.h
new file mode 100644 (file)
index 0000000..898d3af
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Channel : public ImageMagick {
+
+private:
+       const gchar * _layerName;
+
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/charcoal.cpp b/src/extension/internal/bitmap/charcoal.cpp
new file mode 100644 (file)
index 0000000..6f3244b
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "charcoal.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Charcoal::applyEffect(Magick::Image* image) {
+       image->charcoal(_radius, _sigma);
+}
+
+void
+Charcoal::refreshParameters(Inkscape::Extension::Effect* module) {
+       _radius = module->get_param_float("radius");
+       _sigma = module->get_param_float("sigma");
+}
+
+#include "../clear-n_.h"
+
+void
+Charcoal::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Charcoal") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.charcoal</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0.1\" max=\"20\">5.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0.1\" max=\"5\">1.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Charcoal Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Charcoal());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/charcoal.h b/src/extension/internal/bitmap/charcoal.h
new file mode 100644 (file)
index 0000000..2bedba7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Charcoal : public ImageMagick
+{
+private:
+       float _radius;
+       float _sigma;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/colorize.cpp b/src/extension/internal/bitmap/colorize.cpp
new file mode 100644 (file)
index 0000000..cf8ff5d
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "colorize.h"
+
+#include "color.h"
+
+#include <iostream>
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Colorize::applyEffect(Magick::Image *image) {
+       float rgb[3];
+    sp_color_get_rgb_floatv(_color, rgb);
+    int red = (int)(rgb[0] * 255);     
+    int green = (int)(rgb[1] * 255);
+    int blue = (int)(rgb[2] * 255);
+       
+           
+       printf("(2fk) applying colorize\n");    
+       printf("(2fl) rgb: %i,%i,%i\n", red, green, blue);
+       printf("(2fm) opacity: %i\n", _opacity);
+       
+    Magick::ColorRGB mc(red, green, blue);
+       
+       image->colorize(_opacity, mc);
+}
+
+void
+Colorize::refreshParameters(Inkscape::Extension::Effect *module) {     
+       _opacity = module->get_param_int("opacity");
+       _color = module->get_param_color("color");
+       
+       printf("(2ga) refreshing colorize\n");
+       printf("(2gb) _color: %f,%f,%f,%f\n", _color->v.c[0], _color->v.c[1], _color->v.c[2], _color->v.c[3]);
+}
+
+#include "../clear-n_.h"
+
+void
+Colorize::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Colorize") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.colorize</id>\n"
+                       "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\" >#FF0000</param>\n"
+                       "<param name=\"opacity\" gui-text=\"" N_("Opacity") "\" type=\"int\" min=\"0\" max=\"100\">1</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Colorize Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Colorize());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/colorize.h b/src/extension/internal/bitmap/colorize.h
new file mode 100644 (file)
index 0000000..e82ef88
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Colorize : public ImageMagick {
+private:
+       SPColor* _color;
+       int _opacity;
+
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/contrast.cpp b/src/extension/internal/bitmap/contrast.cpp
new file mode 100644 (file)
index 0000000..1728c32
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "contrast.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Contrast::applyEffect(Magick::Image *image) {
+       printf("(o0x) Sharpening at: %i\n", _sharpen);
+       image->contrast(_sharpen);
+}
+
+void
+Contrast::refreshParameters(Inkscape::Extension::Effect *module) {     
+       _sharpen = module->get_param_bool("sharpen");
+}
+
+#include "../clear-n_.h"
+
+void
+Contrast::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Contrast") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.contrast</id>\n"
+                       "<param name=\"sharpen\" gui-text=\"" N_("Sharpen") "\" type=\"boolean\" >1</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Contrast Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Contrast());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/contrast.h b/src/extension/internal/bitmap/contrast.h
new file mode 100644 (file)
index 0000000..acb5982
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Contrast : public ImageMagick
+{
+private:
+       bool _sharpen;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/convolve.cpp b/src/extension/internal/bitmap/convolve.cpp
new file mode 100644 (file)
index 0000000..008cd43
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "convolve.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Convolve::applyEffect(Magick::Image *image) {
+       image->convolve(_order, _kernel);
+}
+
+void
+Convolve::refreshParameters(Inkscape::Extension::Effect *module) {
+       _order = module->get_param_int("order");
+       *_kernel = 0;
+}
+
+#include "../clear-n_.h"
+
+void
+Convolve::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Convolve") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.convolve</id>\n"
+                       "<param name=\"order\" gui-text=\"" N_("Order") "\" type=\"int\" >1</param>\n"
+                       "<param name=\"kernel\" gui-text=\"" N_("Kernel") "\" type=\"string\" >1,1,1,0,0,0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Convolve Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Convolve());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/convolve.h b/src/extension/internal/bitmap/convolve.h
new file mode 100644 (file)
index 0000000..3cfdc7f
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Convolve : public ImageMagick {
+private:
+       int _order;
+       double* _kernel;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/cycleColormap.cpp b/src/extension/internal/bitmap/cycleColormap.cpp
new file mode 100644 (file)
index 0000000..309837a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "cycleColormap.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+CycleColormap::applyEffect(Magick::Image *image) {
+       image->cycleColormap(_amount);
+}
+
+void
+CycleColormap::refreshParameters(Inkscape::Extension::Effect *module) {        
+       _amount = module->get_param_int("amount");
+}
+
+#include "../clear-n_.h"
+
+void
+CycleColormap::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Cycle Colormap") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.cycleColormap</id>\n"
+                       "<param name=\"amount\" gui-text=\"" N_("Amount") "\" type=\"int\" min=\"0\" max=\"255\">1</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Cycle Colormap Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new CycleColormap());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/cycleColormap.h b/src/extension/internal/bitmap/cycleColormap.h
new file mode 100644 (file)
index 0000000..7d8f495
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class CycleColormap : public ImageMagick {
+private:
+       int _amount;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/despeckle.cpp b/src/extension/internal/bitmap/despeckle.cpp
new file mode 100644 (file)
index 0000000..75a1ca3
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "despeckle.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Despeckle::applyEffect(Magick::Image *image) {
+       image->despeckle();
+}
+
+void
+Despeckle::refreshParameters(Inkscape::Extension::Effect *module) {    
+       
+}
+
+#include "../clear-n_.h"
+
+void
+Despeckle::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Despeckle") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.despeckle</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Despeckle Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Despeckle());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/despeckle.h b/src/extension/internal/bitmap/despeckle.h
new file mode 100644 (file)
index 0000000..7a9be90
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Despeckle : public ImageMagick {
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/edge.cpp b/src/extension/internal/bitmap/edge.cpp
new file mode 100644 (file)
index 0000000..f9b14b2
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "edge.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Edge::applyEffect(Magick::Image *image) {
+       image->edge(_radius);
+}
+
+void
+Edge::refreshParameters(Inkscape::Extension::Effect *module) { 
+       _radius = module->get_param_int("radius");
+}
+
+#include "../clear-n_.h"
+
+void
+Edge::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Edge") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.edge</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"int\" min=\"0\" max=\"100\">5</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Edge Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Edge());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/edge.h b/src/extension/internal/bitmap/edge.h
new file mode 100644 (file)
index 0000000..4585648
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Edge : public ImageMagick {
+private:
+       int _radius;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/emboss.cpp b/src/extension/internal/bitmap/emboss.cpp
new file mode 100644 (file)
index 0000000..8d7f724
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "emboss.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Emboss::applyEffect(Magick::Image *image) {
+       image->emboss(_radius, _sigma);
+}
+
+void
+Emboss::refreshParameters(Inkscape::Extension::Effect *module) {       
+       _radius = module->get_param_float("radius");
+       _sigma = module->get_param_float("sigma");
+}
+
+#include "../clear-n_.h"
+
+void
+Emboss::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Emboss") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.emboss</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0.1\" max=\"50\">5.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0.1\" max=\"10\">1.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Emboss Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Emboss());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/emboss.h b/src/extension/internal/bitmap/emboss.h
new file mode 100644 (file)
index 0000000..4dcfc89
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Emboss : public ImageMagick
+{
+private:
+       float _radius;
+       float _sigma;
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/enhance.cpp b/src/extension/internal/bitmap/enhance.cpp
new file mode 100644 (file)
index 0000000..dae9077
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "enhance.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Enhance::applyEffect(Magick::Image *image) {
+       image->enhance();
+}
+
+void
+Enhance::refreshParameters(Inkscape::Extension::Effect *module) {      
+       
+}
+
+#include "../clear-n_.h"
+
+void
+Enhance::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Enhance") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.enhance</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Enhance Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Enhance());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/enhance.h b/src/extension/internal/bitmap/enhance.h
new file mode 100644 (file)
index 0000000..3f5df47
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Enhance : public ImageMagick
+{
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/equalize.cpp b/src/extension/internal/bitmap/equalize.cpp
new file mode 100644 (file)
index 0000000..1b0911a
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "equalize.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Equalize::applyEffect(Magick::Image *image) {
+       image->equalize();
+}
+
+void
+Equalize::refreshParameters(Inkscape::Extension::Effect *module) {     
+       
+}
+
+#include "../clear-n_.h"
+
+void
+Equalize::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Equalize") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.equalize</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Equalize Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Equalize());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/equalize.h b/src/extension/internal/bitmap/equalize.h
new file mode 100644 (file)
index 0000000..22cadf5
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Equalize : public ImageMagick
+{
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/flop.cpp b/src/extension/internal/bitmap/flop.cpp
new file mode 100644 (file)
index 0000000..437c8af
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "flop.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Flop::applyEffect(Magick::Image *image) {
+       image->flop();
+}
+
+void
+Flop::refreshParameters(Inkscape::Extension::Effect *module) { 
+       
+}
+
+#include "../clear-n_.h"
+
+void
+Flop::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Flop") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.flop</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Flop Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Flop());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/flop.h b/src/extension/internal/bitmap/flop.h
new file mode 100644 (file)
index 0000000..d996396
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Flop : public ImageMagick
+{
+public:
+    void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+    static void init (void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/gaussianBlur.cpp b/src/extension/internal/bitmap/gaussianBlur.cpp
new file mode 100644 (file)
index 0000000..36087c5
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "gaussianBlur.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+GaussianBlur::applyEffect(Magick::Image* image) {
+       image->gaussianBlur(_width, _sigma);
+}
+
+void
+GaussianBlur::refreshParameters(Inkscape::Extension::Effect* module) {
+       _width = module->get_param_float("width");
+       _sigma = module->get_param_float("sigma");
+}
+
+#include "../clear-n_.h"
+
+void
+GaussianBlur::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Gaussian Blur") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.gaussianBlur</id>\n"
+                       "<param name=\"width\" gui-text=\"" N_("Factor") "\" type=\"float\" min=\"0\" max=\"50\">5.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0\" max=\"50\">5.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Gaussian Blur Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new GaussianBlur());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/gaussianBlur.h b/src/extension/internal/bitmap/gaussianBlur.h
new file mode 100644 (file)
index 0000000..3b6ca21
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class GaussianBlur : public ImageMagick
+{
+private:
+       float _width;
+       float _sigma;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp
new file mode 100644 (file)
index 0000000..83650aa
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2007 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/spinbutton.h>
+
+#include <glib/gstdio.h>
+
+#include "desktop.h"
+#include "desktop-handles.h"
+#include "selection.h"
+#include "sp-object.h"
+#include "util/glib-list-iterators.h"
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+bool
+ImageMagick::load(Inkscape::Extension::Extension *module)
+{
+       _loaded = FALSE;
+       return TRUE;
+}
+
+void
+ImageMagick::commitDocument(void) {
+       _loaded = FALSE;
+}
+
+void
+ImageMagick::cancelDocument(void) {    
+       for (int i = 0; i < _imageCount; i++) {
+               _nodes[i]->setAttribute("xlink:href", _originals[i], true);
+       }
+       
+       _loaded = FALSE;
+}
+
+void
+ImageMagick::readImage(const char *xlink, Magick::Image *image)
+{
+       // Find if the xlink:href is base64 data, i.e. if the image is embedded
+       char *search = strndup(xlink, 30);
+       if (strstr(search, "base64") != (char*)NULL) {
+               // 7 = strlen("base64") + strlen(",")
+               char* pureBase64 = strstr(xlink, "base64") + 7;         
+               Magick::Blob blob;
+               blob.base64(pureBase64);
+               image->read(blob);
+       }
+       else {
+               image->read(xlink);
+       }
+}
+
+void
+ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document)
+{
+       refreshParameters(module);
+       
+       if (!_loaded)
+       {               
+               SPDesktop *desktop = (SPDesktop*)document;
+               const GSList *selectedReprList = desktop->selection->reprList();
+               int selectCount = g_slist_length((GSList *)selectedReprList);
+               
+               // Init the data-holders
+               _nodes = new Inkscape::XML::Node*[selectCount];
+               _originals = new const char*[selectCount];
+               _images = new Magick::Image[selectCount];
+               _imageCount = 0;
+               
+               // Loop through selected nodes
+               for (; selectedReprList != NULL; selectedReprList = g_slist_next(selectedReprList))
+               {
+                       Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(selectedReprList->data);
+                       if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image"))
+                       {
+                               _nodes[_imageCount] = node;     
+                               char const *xlink = node->attribute("xlink:href");
+                               
+                               _originals[_imageCount] = xlink;
+                               
+                               readImage(xlink, &_images[_imageCount]);
+                               
+                               _imageCount++;
+                       }                       
+               }
+               
+               _loaded = 1;
+       }
+       
+       for (int i = 0; i < _imageCount; i++)
+       {
+               try
+               {
+                       Magick::Image effectedImage = _images[i];
+                       applyEffect(&effectedImage);
+
+                       Magick::Blob blob;
+                       effectedImage.write(&blob);
+                               
+                               std::string raw_string = blob.base64();
+                               const int raw_len = raw_string.length();
+                               const char *raw = raw_string.c_str();
+                               const char *raw_i = raw;        
+                               
+                               int formatted_len = (int)(raw_len / 76.0 * 78.0) + 100;
+                               char *formatted = new char[formatted_len];
+                               char *formatted_i = formatted;
+                               // data:image/png;base64,
+                               formatted_i = stpcpy(formatted_i, "data:image/");
+                               formatted_i = stpcpy(formatted_i, effectedImage.magick().c_str());
+                               formatted_i = stpcpy(formatted_i, ";base64, \n");
+                               while (strnlen(raw_i, 80) > 76)
+                               {
+                                       formatted_i = stpncpy(formatted_i, raw_i, 76);
+                                       formatted_i = stpcpy(formatted_i, "\n");                                        
+                                       raw_i += 76;            
+                               }
+                               if (strlen(raw_i) > 0)
+                               {
+                                       formatted_i = stpcpy(formatted_i, raw_i);
+                                       formatted_i = stpcpy(formatted_i, "\n");
+                               }
+                               
+                               formatted_i = stpcpy(formatted_i, "\0");
+                               
+                               _nodes[i]->setAttribute("xlink:href", formatted, true);
+               }
+               catch (Magick::Exception &error_) {
+                       printf("Caught exception: %s \n", error_.what());
+               }
+       }
+}
+
+/** \brief  A function to get the prefences for the grid
+    \param  moudule  Module which holds the params
+    \param  view     Unused today - may get style information in the future.
+
+    Uses AutoGUI for creating the GUI.
+*/
+Gtk::Widget *
+ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal)
+{
+    SPDocument * current_document = view->doc();
+
+    using Inkscape::Util::GSListConstIterator;
+    GSListConstIterator<SPItem *> selected = sp_desktop_selection((SPDesktop *)view)->itemList();
+    Inkscape::XML::Node * first_select = NULL;
+    if (selected != NULL) 
+        first_select = SP_OBJECT_REPR(*selected);
+
+    return module->autogui(current_document, first_select, changeSignal);
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h
new file mode 100644 (file)
index 0000000..36536bb
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__
+#define __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__
+
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/implementation/implementation.h"
+#include "extension/extension-forward.h"
+#include <Magick++.h>
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class ImageMagick : public Inkscape::Extension::Implementation::Implementation {
+
+private:
+       bool _loaded;
+
+       Inkscape::XML::Node **_nodes;   
+       
+       Magick::Image *_images;
+       int _imageCount;
+       
+       const char **_originals;
+public:
+       virtual void applyEffect(Magick::Image *image) { };
+       virtual void refreshParameters(Inkscape::Extension::Effect *module) { };
+       bool load(Inkscape::Extension::Extension *module);
+    
+       void commitDocument(void);
+       void cancelDocument(void);
+
+       void readImage(char const *xlink, Magick::Image *image);
+       void effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document);
+       
+       Gtk::Widget* prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+#endif /* __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__ */
diff --git a/src/extension/internal/bitmap/implode.cpp b/src/extension/internal/bitmap/implode.cpp
new file mode 100644 (file)
index 0000000..74dc81e
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "implode.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Implode::applyEffect(Magick::Image* image) {
+       image->implode(_factor);
+}
+
+void
+Implode::refreshParameters(Inkscape::Extension::Effect* module) {
+       _factor = module->get_param_float("factor");
+}
+
+#include "../clear-n_.h"
+
+void
+Implode::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Implode") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.implode</id>\n"
+                       "<param name=\"factor\" gui-text=\"" N_("Factor") "\" type=\"float\" min=\"0.1\" max=\"50\">5.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Implode Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Implode());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/implode.h b/src/extension/internal/bitmap/implode.h
new file mode 100644 (file)
index 0000000..b25b354
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Implode : public ImageMagick
+{
+private:
+       float _factor;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/level.cpp b/src/extension/internal/bitmap/level.cpp
new file mode 100644 (file)
index 0000000..f48be32
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "level.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Level::applyEffect(Magick::Image* image) {
+       Magick::Quantum black_point = Magick::Color::scaleDoubleToQuantum(_black_point / 100.0);
+       Magick::Quantum white_point = Magick::Color::scaleDoubleToQuantum(_white_point / 100.0);
+       image->level(black_point, white_point, _mid_point);
+}
+
+void
+Level::refreshParameters(Inkscape::Extension::Effect* module) {
+       _black_point = module->get_param_float("blackPoint");
+       _white_point = module->get_param_float("whitePoint");
+       _mid_point = module->get_param_float("midPoint");
+}
+
+#include "../clear-n_.h"
+
+void
+Level::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Level") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.level</id>\n"
+                       "<param name=\"blackPoint\" gui-text=\"" N_("Black Point") "\" type=\"float\" min=\"0.0\" max=\"100.0\">0.0</param>\n"                  
+                       "<param name=\"whitePoint\" gui-text=\"" N_("White Point") "\" type=\"float\" min=\"0.0\" max=\"100.0\">100.0</param>\n"                        
+                       "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Level Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Level());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/level.h b/src/extension/internal/bitmap/level.h
new file mode 100644 (file)
index 0000000..111e83a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Level : public ImageMagick
+{
+private:
+       float _black_point;
+       float _white_point;
+       float _mid_point;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/levelChannel.cpp b/src/extension/internal/bitmap/levelChannel.cpp
new file mode 100644 (file)
index 0000000..90372aa
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "levelChannel.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+LevelChannel::applyEffect(Magick::Image* image) {
+       Magick::ChannelType channel = Magick::UndefinedChannel;
+       if (!strcmp(_channelName,      "Red Channel"))          channel = Magick::RedChannel;
+       else if (!strcmp(_channelName, "Green Channel"))        channel = Magick::GreenChannel;
+       else if (!strcmp(_channelName, "Blue Channel"))         channel = Magick::BlueChannel;
+       else if (!strcmp(_channelName, "Cyan Channel"))         channel = Magick::CyanChannel;
+       else if (!strcmp(_channelName, "Magenta Channel"))      channel = Magick::MagentaChannel;
+       else if (!strcmp(_channelName, "Yellow Channel"))       channel = Magick::YellowChannel;
+       else if (!strcmp(_channelName, "Black Channel"))        channel = Magick::BlackChannel;
+       else if (!strcmp(_channelName, "Opacity Channel"))      channel = Magick::OpacityChannel;
+       else if (!strcmp(_channelName, "Matte Channel"))        channel = Magick::MatteChannel;
+       Magick::Quantum black_point = Magick::Color::scaleDoubleToQuantum(_black_point / 100.0);
+       Magick::Quantum white_point = Magick::Color::scaleDoubleToQuantum(_white_point / 100.0);
+       image->levelChannel(channel, black_point, white_point, _mid_point);
+}
+
+void
+LevelChannel::refreshParameters(Inkscape::Extension::Effect* module) {
+       _channelName = module->get_param_enum("channel");
+       _black_point = module->get_param_float("blackPoint");
+       _white_point = module->get_param_float("whitePoint");
+       _mid_point = module->get_param_float("midPoint");
+}
+
+#include "../clear-n_.h"
+
+void
+LevelChannel::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Level (with Channel)") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.levelChannel</id>\n"
+                       "<param name=\"channel\" gui-text=\"" N_("Channel") "\" type=\"enum\" >\n"
+                               "<item value='Red Channel'>Red Channel</item>\n"
+                               "<item value='Green Channel'>Green Channel</item>\n"
+                               "<item value='Blue Channel'>Blue Channel</item>\n"
+                               "<item value='Cyan Channel'>Cyan Channel</item>\n"
+                               "<item value='Magenta Channel'>Magenta Channel</item>\n"
+                               "<item value='Yellow Channel'>Yellow Channel</item>\n"
+                               "<item value='Black Channel'>Black Channel</item>\n"
+                               "<item value='Opacity Channel'>Opacity Channel</item>\n"
+                               "<item value='Matte Channel'>Matte Channel</item>\n"
+                       "</param>\n"
+                       "<param name=\"blackPoint\" gui-text=\"" N_("Black Point") "\" type=\"float\" min=\"0.0\" max=\"100.0\">0.0</param>\n"                  
+                       "<param name=\"whitePoint\" gui-text=\"" N_("White Point") "\" type=\"float\" min=\"0.0\" max=\"100.0\">100.0</param>\n"                        
+                       "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Level (with Channel) Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new LevelChannel());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/levelChannel.h b/src/extension/internal/bitmap/levelChannel.h
new file mode 100644 (file)
index 0000000..832619d
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class LevelChannel : public ImageMagick
+{
+private:
+       float _black_point;
+       float _white_point;
+       float _mid_point;
+       const gchar * _channelName;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/medianFilter.cpp b/src/extension/internal/bitmap/medianFilter.cpp
new file mode 100644 (file)
index 0000000..4ba14fd
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "medianFilter.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+MedianFilter::applyEffect(Magick::Image* image) {
+       image->medianFilter(_radius);
+}
+
+void
+MedianFilter::refreshParameters(Inkscape::Extension::Effect* module) {
+       _radius = module->get_param_float("radius");
+}
+
+#include "../clear-n_.h"
+
+void
+MedianFilter::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Median Filter") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.medianFilter</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0.0\" max=\"100.0\">5.0</param>\n"                   
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Median Filter Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new MedianFilter());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/medianFilter.h b/src/extension/internal/bitmap/medianFilter.h
new file mode 100644 (file)
index 0000000..befc570
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class MedianFilter : public ImageMagick
+{
+private:
+       float _radius;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/modulate.cpp b/src/extension/internal/bitmap/modulate.cpp
new file mode 100644 (file)
index 0000000..97a4d5a
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "modulate.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Modulate::applyEffect(Magick::Image* image) {
+       float hue = (_hue + 180.0) / 180.0;
+       image->modulate(_brightness, _saturation, hue);
+}
+
+void
+Modulate::refreshParameters(Inkscape::Extension::Effect* module) {
+       _brightness = module->get_param_float("brightness");
+       _saturation = module->get_param_float("saturation");
+       _hue = module->get_param_float("hue");
+}
+
+#include "../clear-n_.h"
+
+void
+Modulate::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Modulate") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.modulate</id>\n"                        
+                       "<param name=\"brightness\" gui-text=\"" N_("Brightness") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n"
+                       "<param name=\"saturation\" gui-text=\"" N_("Saturation") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n"
+                       "<param name=\"hue\" gui-text=\"" N_("Hue") "\" type=\"float\" min=\"-180.0\" max=\"180.0\">0.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Modulate Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Modulate());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/modulate.h b/src/extension/internal/bitmap/modulate.h
new file mode 100644 (file)
index 0000000..f7c6fe9
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Modulate : public ImageMagick
+{
+private:
+       float _brightness;
+       float _saturation;
+       float _hue;
+public:
+  void applyEffect(Magick::Image *image);
+  void refreshParameters(Inkscape::Extension::Effect *module);
+  static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/negate.cpp b/src/extension/internal/bitmap/negate.cpp
new file mode 100644 (file)
index 0000000..19e72e8
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "negate.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Negate::applyEffect(Magick::Image* image) {
+       image->negate();
+}
+
+void
+Negate::refreshParameters(Inkscape::Extension::Effect* module) {       
+}
+
+#include "../clear-n_.h"
+
+void
+Negate::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Negate") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.negate</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Negate Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Negate());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/negate.h b/src/extension/internal/bitmap/negate.h
new file mode 100644 (file)
index 0000000..7ebe3b7
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Negate : public ImageMagick
+{
+public:
+  void applyEffect(Magick::Image *image);
+  void refreshParameters(Inkscape::Extension::Effect *module);
+  static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/normalize.cpp b/src/extension/internal/bitmap/normalize.cpp
new file mode 100644 (file)
index 0000000..6d8b433
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "normalize.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Normalize::applyEffect(Magick::Image* image) {
+       image->normalize();
+}
+
+void
+Normalize::refreshParameters(Inkscape::Extension::Effect* module) {    
+}
+
+#include "../clear-n_.h"
+
+void
+Normalize::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Normalize") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.normalize</id>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Normalize Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Normalize());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/normalize.h b/src/extension/internal/bitmap/normalize.h
new file mode 100644 (file)
index 0000000..0637dbf
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Normalize : public ImageMagick
+{
+public:
+  void applyEffect(Magick::Image *image);
+  void refreshParameters(Inkscape::Extension::Effect *module);
+  static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/oilPaint.cpp b/src/extension/internal/bitmap/oilPaint.cpp
new file mode 100644 (file)
index 0000000..7b95fe1
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "oilPaint.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+OilPaint::applyEffect(Magick::Image* image) {
+       image->oilPaint(_radius);
+}
+
+void
+OilPaint::refreshParameters(Inkscape::Extension::Effect* module) {
+       _radius = module->get_param_int("radius");
+}
+
+#include "../clear-n_.h"
+
+void
+OilPaint::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Oil Paint") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.oilPaint</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"int\" min=\"0\" max=\"50\">3</param>\n"                    
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply OilPaint Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new OilPaint());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/oilPaint.h b/src/extension/internal/bitmap/oilPaint.h
new file mode 100644 (file)
index 0000000..822119d
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class OilPaint : public ImageMagick
+{
+private:
+       float _radius;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/opacity.cpp b/src/extension/internal/bitmap/opacity.cpp
new file mode 100644 (file)
index 0000000..af2c3fe
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "opacity.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Opacity::applyEffect(Magick::Image* image) {
+       Magick::Quantum opacity = Magick::Color::scaleDoubleToQuantum(_opacity / 100.0);
+       image->opacity(opacity);
+}
+
+void
+Opacity::refreshParameters(Inkscape::Extension::Effect* module) {
+       _opacity = module->get_param_float("opacity");
+}
+
+#include "../clear-n_.h"
+
+void
+Opacity::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Opacity") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.opacity</id>\n"
+                       "<param name=\"opacity\" gui-text=\"" N_("Opacity") "\" type=\"float\" min=\"0.0\" max=\"100.0\">80.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Opacity Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Opacity());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/opacity.h b/src/extension/internal/bitmap/opacity.h
new file mode 100644 (file)
index 0000000..2c3a4ec
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Opacity : public ImageMagick
+{
+private:
+       float _opacity;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/raise.cpp b/src/extension/internal/bitmap/raise.cpp
new file mode 100644 (file)
index 0000000..6f050fc
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "raise.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Raise::applyEffect(Magick::Image* image) {
+       Magick::Geometry geometry(_width, _height, _x, _y);
+       image->raise(geometry, _raisedFlag);
+}
+
+void
+Raise::refreshParameters(Inkscape::Extension::Effect* module) {
+       _width = module->get_param_int("width");
+       _height = module->get_param_int("height");
+       _x = module->get_param_int("x");
+       _y = module->get_param_int("y");
+       _raisedFlag = module->get_param_bool("raisedFlag");
+}
+
+#include "../clear-n_.h"
+
+void
+Raise::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Raise") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.raise</id>\n"
+                       "<param name=\"width\" gui-text=\"" N_("Width") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n"
+                       "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n"
+                       "<param name=\"x\" gui-text=\"" N_("X") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n"
+                       "<param name=\"y\" gui-text=\"" N_("Y") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n"
+                       "<param name=\"raisedFlag\" gui-text=\"" N_("RaisedFlag") "\" type=\"bool\">0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Raise Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Raise());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/raise.h b/src/extension/internal/bitmap/raise.h
new file mode 100644 (file)
index 0000000..7ceb088
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Raise : public ImageMagick
+{
+private:
+       int _x;
+       int _y;
+       int _width;
+       int _height;
+       bool _raisedFlag;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/reduceNoise.cpp b/src/extension/internal/bitmap/reduceNoise.cpp
new file mode 100644 (file)
index 0000000..689a973
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "reduceNoise.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+ReduceNoise::applyEffect(Magick::Image* image) {
+       if (_order > -1)
+               image->reduceNoise(_order);
+       else
+               image->reduceNoise();
+}
+
+void
+ReduceNoise::refreshParameters(Inkscape::Extension::Effect* module) {
+       _order = module->get_param_int("order");
+}
+
+#include "../clear-n_.h"
+
+void
+ReduceNoise::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Reduce Noise") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.reduceNoise</id>\n"
+                       "<param name=\"order\" gui-text=\"" N_("Order") "\" type=\"int\" min=\"-1\" max=\"100\">-1</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply ReduceNoise Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new ReduceNoise());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/reduceNoise.h b/src/extension/internal/bitmap/reduceNoise.h
new file mode 100644 (file)
index 0000000..0a4847d
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class ReduceNoise : public ImageMagick
+{
+private:
+       int _order;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/shade.cpp b/src/extension/internal/bitmap/shade.cpp
new file mode 100644 (file)
index 0000000..a9bb5a2
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "shade.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Shade::applyEffect(Magick::Image* image) {
+       image->shade(_azimuth, _elevation, _colorShading);
+}
+
+void
+Shade::refreshParameters(Inkscape::Extension::Effect* module) {
+       _azimuth = module->get_param_float("azimuth");
+       _elevation = module->get_param_float("elevation");
+       _colorShading = module->get_param_bool("colorShading");
+}
+
+#include "../clear-n_.h"
+
+void
+Shade::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Shade") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.shade</id>\n"
+                       "<param name=\"azimuth\" gui-text=\"" N_("Azimuth") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n"
+                       "<param name=\"elevation\" gui-text=\"" N_("Elevation") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n"
+                       "<param name=\"colorShading\" gui-text=\"" N_("Colored Shading") "\" type=\"bool\">0</param>\n"                 
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Shade Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Shade());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/shade.h b/src/extension/internal/bitmap/shade.h
new file mode 100644 (file)
index 0000000..2f83492
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Shade : public ImageMagick
+{
+private:
+       float _azimuth;
+       float _elevation;
+       bool _colorShading;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/sharpen.cpp b/src/extension/internal/bitmap/sharpen.cpp
new file mode 100644 (file)
index 0000000..cf0bf51
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "sharpen.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Sharpen::applyEffect(Magick::Image* image) {
+       image->sharpen(_radius, _sigma);
+}
+
+void
+Sharpen::refreshParameters(Inkscape::Extension::Effect* module) {
+       _radius = module->get_param_float("radius");
+       _sigma = module->get_param_float("sigma");
+}
+
+#include "../clear-n_.h"
+
+void
+Sharpen::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Sharpen") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.sharpen</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0\" max=\"50\">1.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0\" max=\"10\">0.5</param>\n"                  
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Sharpen Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Sharpen());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/sharpen.h b/src/extension/internal/bitmap/sharpen.h
new file mode 100644 (file)
index 0000000..b8f92dd
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Sharpen : public ImageMagick
+{
+private:
+       float _radius;
+       float _sigma;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/solarize.cpp b/src/extension/internal/bitmap/solarize.cpp
new file mode 100644 (file)
index 0000000..1de9bf9
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "solarize.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Solarize::applyEffect(Magick::Image* image) {
+       image->solarize(_factor);
+}
+
+void
+Solarize::refreshParameters(Inkscape::Extension::Effect* module) {
+       _factor = module->get_param_float("factor");
+}
+
+#include "../clear-n_.h"
+
+void
+Solarize::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Solarize") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.solarize</id>\n"
+                       "<param name=\"factor\" gui-text=\"" N_("Factor") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">50.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Solarize Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Solarize());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/solarize.h b/src/extension/internal/bitmap/solarize.h
new file mode 100644 (file)
index 0000000..4acdf3c
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Solarize : public ImageMagick
+{
+private:
+       float _factor;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/spread.cpp b/src/extension/internal/bitmap/spread.cpp
new file mode 100644 (file)
index 0000000..dfc9b8b
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "spread.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Spread::applyEffect(Magick::Image* image) {
+       image->spread(_amount);
+}
+
+void
+Spread::refreshParameters(Inkscape::Extension::Effect* module) {
+       _amount = module->get_param_int("amount");
+}
+
+#include "../clear-n_.h"
+
+void
+Spread::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Spread") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.spread</id>\n"
+                       "<param name=\"amount\" gui-text=\"" N_("Amount") "\" type=\"int\" min=\"0\" max=\"100\">3</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Spread Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Spread());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/spread.h b/src/extension/internal/bitmap/spread.h
new file mode 100644 (file)
index 0000000..82d9558
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Spread : public ImageMagick
+{
+private:
+       int _amount;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/swirl.cpp b/src/extension/internal/bitmap/swirl.cpp
new file mode 100644 (file)
index 0000000..a880552
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "swirl.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Swirl::applyEffect(Magick::Image* image) {
+       image->swirl(_degrees);
+}
+
+void
+Swirl::refreshParameters(Inkscape::Extension::Effect* module) {
+       _degrees = module->get_param_float("degrees");
+}
+
+#include "../clear-n_.h"
+
+void
+Swirl::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Swirl") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.swirl</id>\n"
+                       "<param name=\"degrees\" gui-text=\"" N_("Degrees") "\" type=\"float\" min=\"0\" max=\"360\">30</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Swirl Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Swirl());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/swirl.h b/src/extension/internal/bitmap/swirl.h
new file mode 100644 (file)
index 0000000..cea1850
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Swirl : public ImageMagick
+{
+private:
+       double _degrees;
+public:
+  void applyEffect(Magick::Image *image);
+  void refreshParameters(Inkscape::Extension::Effect *module);
+  static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/threshold.cpp b/src/extension/internal/bitmap/threshold.cpp
new file mode 100644 (file)
index 0000000..6f21e61
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "threshold.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Threshold::applyEffect(Magick::Image* image) {
+       image->threshold(_threshold);
+}
+
+void
+Threshold::refreshParameters(Inkscape::Extension::Effect* module) {
+       _threshold = module->get_param_float("threshold");
+}
+
+#include "../clear-n_.h"
+
+void
+Threshold::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Threshold") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.threshold</id>\n"
+                       "<param name=\"threshold\" gui-text=\"" N_("Threshold") "\" type=\"float\" min=\"-100.0\" max=\"100.0\"></param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Threshold Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Threshold());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/threshold.h b/src/extension/internal/bitmap/threshold.h
new file mode 100644 (file)
index 0000000..2e65a7a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Threshold : public ImageMagick
+{
+private:
+       double _threshold;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/unsharpmask.cpp b/src/extension/internal/bitmap/unsharpmask.cpp
new file mode 100644 (file)
index 0000000..6e4a175
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "unsharpmask.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Unsharpmask::applyEffect(Magick::Image* image) {
+       float amount = _amount / 100.0;
+       image->unsharpmask(_radius, _sigma, amount, _threshold);
+}
+
+void
+Unsharpmask::refreshParameters(Inkscape::Extension::Effect* module) {
+       _radius = module->get_param_float("radius");
+       _sigma = module->get_param_float("sigma");
+       _amount = module->get_param_float("amount");
+       _threshold = module->get_param_float("threshold");
+}
+
+#include "../clear-n_.h"
+
+void
+Unsharpmask::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Unsharp Mask") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.unsharpmask</id>\n"
+                       "<param name=\"radius\" gui-text=\"" N_("Radius") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n"
+                       "<param name=\"sigma\" gui-text=\"" N_("Sigma") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n"
+                       "<param name=\"amount\" gui-text=\"" N_("Amount") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50.0</param>\n"
+                       "<param name=\"threshold\" gui-text=\"" N_("Threshold") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n"
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Unsharp Mask Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Unsharpmask());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/unsharpmask.h b/src/extension/internal/bitmap/unsharpmask.h
new file mode 100644 (file)
index 0000000..5d3a47e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Unsharpmask : public ImageMagick
+{
+private:
+       float _radius;
+       float _sigma;
+       float _amount;
+       float _threshold;
+public:
+  void applyEffect(Magick::Image *image);
+  void refreshParameters(Inkscape::Extension::Effect *module);
+  static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/wave.cpp b/src/extension/internal/bitmap/wave.cpp
new file mode 100644 (file)
index 0000000..c1a2994
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "wave.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+       
+void
+Wave::applyEffect(Magick::Image* image) {
+       image->wave(_amplitude, _wavelength);
+}
+
+void
+Wave::refreshParameters(Inkscape::Extension::Effect* module) {
+       _amplitude = module->get_param_float("amplitude");
+       _wavelength = module->get_param_int("wavelength");
+}
+
+#include "../clear-n_.h"
+
+void
+Wave::init(void)
+{
+       Inkscape::Extension::build_from_mem(
+               "<inkscape-extension>\n"
+                       "<name>" N_("Wave") "</name>\n"
+                       "<id>org.inkscape.effect.bitmap.wave</id>\n"
+                       "<param name=\"amplitude\" gui-text=\"" N_("Amplitude") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">25.0</param>\n"                 
+                       "<param name=\"wavelength\" gui-text=\"" N_("Wavelength") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">150.0</param>\n"                      
+                       "<effect>\n"
+                               "<object-type>all</object-type>\n"
+                               "<effects-menu>\n"
+                                       "<submenu name=\"" N_("Raster") "\" />\n"
+                               "</effects-menu>\n"
+                               "<menu-tip>" N_("Apply Wave Effect") "</menu-tip>\n"
+                       "</effect>\n"
+               "</inkscape-extension>\n", new Wave());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/wave.h b/src/extension/internal/bitmap/wave.h
new file mode 100644 (file)
index 0000000..8ee1fc7
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Authors:
+ *   Christopher Brown <audiere@gmail.com>
+ *   Ted Gould <ted@gould.cx>
+ *   
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Wave : public ImageMagick
+{
+private:
+       float _amplitude;
+       int _wavelength;
+public:
+       void applyEffect(Magick::Image *image);
+       void refreshParameters(Inkscape::Extension::Effect *module);
+       static void init(void);
+};
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/parambool.cpp b/src/extension/parambool.cpp
new file mode 100644 (file)
index 0000000..2aa4806
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "parambool.h"
+
+namespace Inkscape {
+namespace Extension {
+
+/** \brief  Use the superclass' allocator and set the \c _value */
+ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+        Parameter(name, guitext, desc, scope, ext), _value(false)
+{
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+
+    if (defaultval != NULL && (!strcmp(defaultval, "TRUE") || !strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) {
+        _value = true;
+    } else {
+        _value = false;
+    }
+
+    gchar * pref_name = this->pref_name();
+    _value = (bool)prefs_get_int_attribute(PREF_DIR, pref_name, _value);
+    g_free(pref_name);
+
+    return;
+}
+
+/** \brief  A function to set the \c _value
+    \param  in   The value to set to
+    \param  doc  A document that should be used to set the value.
+    \param  node The node where the value may be placed
+
+    This function sets the internal value, but it also sets the value
+    in the preferences structure.  To put it in the right place, \c PREF_DIR
+    and \c pref_name() are used.
+*/
+bool
+ParamBool::set (bool in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    _value = in;
+
+    gchar * prefname = this->pref_name();
+    prefs_set_int_attribute(PREF_DIR, prefname, _value == true ? 1 : 0);
+    g_free(prefname);
+
+    return _value;
+}
+
+/** \brief  A check button which is Param aware.  It works with the
+            parameter to change it's value as the check button changes
+            value. */
+class ParamBoolCheckButton : public Gtk::CheckButton {
+private:
+    /** \brief  Param to change */
+    ParamBool * _pref;
+    SPDocument * _doc;
+    Inkscape::XML::Node * _node;
+    sigc::signal<void> * _changeSignal;
+public:
+    /** \brief  Initialize the check button
+        \param  param  Which parameter to adjust on changing the check button
+
+        This function sets the value of the checkbox to be that of the
+        parameter, and then sets up a callback to \c on_toggle.
+    */
+    ParamBoolCheckButton (ParamBool * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
+            Gtk::CheckButton(), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
+        this->set_active(_pref->get(NULL, NULL) /**\todo fix */);
+        this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle));
+        return;
+    }
+    void on_toggle (void);
+};
+
+/**
+    \brief  A function to respond to the check box changing
+
+    Adjusts the value of the preference to match that in the check box.
+*/
+void
+ParamBoolCheckButton::on_toggle (void)
+{
+    _pref->set(this->get_active(), NULL /**\todo fix this */, NULL);
+    if (_changeSignal != NULL) {
+        _changeSignal->emit();
+    }
+    return;
+}
+
+/** \brief  Return 'true' or 'false' */
+Glib::ustring *
+ParamBool::string (void)
+{
+    Glib::ustring * mystring;
+
+    if (_value)
+        mystring = new Glib::ustring("true");
+    else
+        mystring = new Glib::ustring("false");
+
+    return mystring;
+}
+
+/**
+    \brief  Creates a bool check button for a bool parameter
+
+    Builds a hbox with a label and a check button in it.
+*/
+Gtk::Widget *
+ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
+    label->show();
+    hbox->pack_start(*label, true, true);
+
+    ParamBoolCheckButton * checkbox = new ParamBoolCheckButton(this, doc, node, changeSignal);
+    checkbox->show();
+    hbox->pack_start(*checkbox, false, false);
+
+    hbox->show();
+
+    return dynamic_cast<Gtk::Widget *>(hbox);
+}
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/parambool.h b/src/extension/parambool.h
new file mode 100644 (file)
index 0000000..56edc70
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef __INK_EXTENSION_PARAMBOOL_H__
+#define __INK_EXTENSION_PARAMBOOL_H__
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+/** \brief  A boolean parameter */
+class ParamBool : public Parameter {
+private:
+    /** \brief  Internal value. */
+    bool _value;
+public:
+    ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    /** \brief  Returns \c _value */
+    bool get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
+    bool set (bool in, SPDocument * doc, Inkscape::XML::Node * node);
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+    Glib::ustring * string (void);
+};
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMBOOL_H__ */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/paramcolor.cpp b/src/extension/paramcolor.cpp
new file mode 100644 (file)
index 0000000..83dba1b
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl>
+ *   Christopher Brown <audiere@gmail.com>
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <iostream>
+#include <sstream>
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "paramcolor.h"
+
+#include "color.h"
+#include "widgets/sp-color-selector.h"
+#include "widgets/sp-color-notebook.h"
+
+
+namespace Inkscape {
+namespace Extension {
+       
+void sp_color_param_changed(SPColorSelector *csel, GObject *cp);
+
+     
+/** \brief  Free the allocated data. */
+ParamColor::~ParamColor(void)
+{
+    g_free(_value);
+}
+     
+SPColor* 
+ParamColor::set (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    _value = in;
+
+    gchar * prefname = this->pref_name();
+    prefs_set_string_attribute(PREF_DIR, prefname, this->string()->c_str());
+    g_free(prefname);
+
+    return _value;
+}
+
+/** \brief  Initialize the object, to do that, copy the data. */
+ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+    Parameter(name, guitext, desc, scope, ext), _value(NULL)
+{
+    const char * defaulthex = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaulthex = sp_repr_children(xml)->content();
+
+    gchar * pref_name = this->pref_name();
+    const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+    g_free(pref_name);
+
+    if (paramval != NULL)
+        defaulthex = paramval;
+    
+       const char* hexMark = strchr(defaulthex, '#');
+       if (hexMark != NULL)
+           defaulthex++;// = hexMark;
+       
+       if (strlen(defaulthex) == 6) {
+               int r = 0, g = 0, b = 0;        
+               std::stringstream ss;
+               ss << strndup(defaulthex, 2);
+               ss >> std::hex >> r;
+               ss << strndup(defaulthex + 2, 2);
+               ss >> std::hex >> g;
+               ss << defaulthex + 4;
+               ss >> std::hex >> b;
+               g_free(ss);
+                       
+               SPColor defaultColor;
+               sp_color_set_rgb_float(&defaultColor, r / 255.0, g / 255.0, b / 255.0);
+               _value = &defaultColor;
+       }
+
+    return;
+}
+
+/** \brief  Return the value as a string */
+Glib::ustring *
+ParamColor::string (void)
+{
+    float rgb[3];
+    sp_color_get_rgb_floatv(_value, rgb);
+    char hex[8];
+       snprintf(hex, 8, "#%02X%02X%02X", (int)(rgb[0] * 255), (int)(rgb[1] * 255), (int)(rgb[2] * 255));
+       
+       Glib::ustring* ret = new Glib::ustring(hex);
+       
+       printf("ParamColor::string = '%s'\n", hex);
+       
+    return ret;
+}
+
+Gtk::Widget *
+ParamColor::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+       _changeSignal = new sigc::signal<void>(*changeSignal);
+       Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+       SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK, SP_COLORSPACE_TYPE_RGB);
+       
+       ColorSelector* colorSelector = spColorSelector->base;
+       if (_value == NULL) {
+               _value = new SPColor();
+               sp_color_set_rgb_float(_value, 1.0, 0.0, 0.0);
+       }
+    colorSelector->setColor(*_value);
+
+       hbox->pack_start (*Glib::wrap(&spColorSelector->vbox), true, true, 0);
+       g_signal_connect(G_OBJECT(spColorSelector), "dragged",  G_CALLBACK(sp_color_param_changed), (void*)this);
+       g_signal_connect(G_OBJECT(spColorSelector), "released", G_CALLBACK(sp_color_param_changed), (void*)this);
+       g_signal_connect(G_OBJECT(spColorSelector), "changed",  G_CALLBACK(sp_color_param_changed), (void*)this);
+
+       gtk_widget_show(GTK_WIDGET(spColorSelector));
+       hbox->show();
+    
+    return dynamic_cast<Gtk::Widget *>(hbox);
+}
+
+void
+sp_color_param_changed(SPColorSelector *csel, GObject *obj)
+{
+       SPColor color;
+    float alpha;
+    csel->base->getColorAlpha(color, &alpha);
+    guint32 rgba = sp_color_get_rgba32_falpha(&color, alpha);
+       
+
+    ParamColor* ptr = (ParamColor* )obj;
+       ptr->set(&color, NULL, NULL); 
+       
+       ptr->_changeSignal->emit();
+}
+
+};  /* namespace Extension */
+};  /* namespace Inkscape */
diff --git a/src/extension/paramcolor.h b/src/extension/paramcolor.h
new file mode 100644 (file)
index 0000000..c109df0
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __INK_EXTENSION_PARAMCOLOR_H__
+#define __INK_EXTENSION_PARAMCOLOR_H__
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "color.h"
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+class ParamColor : public Parameter {
+private:
+    SPColor* _value;
+public:
+    ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    ~ParamColor(void);
+    /** \brief  Returns \c _value, with a \i const to protect it. */
+    SPColor* get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
+    SPColor* set (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node);
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+    Glib::ustring * string (void);
+       sigc::signal<void> * _changeSignal;
+}; /* class ParamColor */
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMCOLOR_H__ */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/paramdescription.cpp b/src/extension/paramdescription.cpp
new file mode 100644 (file)
index 0000000..40cbba8
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef linux  // does the dollar sign need escaping when passed as string parameter?
+# define ESCAPE_DOLLAR_COMMANDLINE
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+
+#include "paramdescription.h"
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <sstream>
+
+
+#include <glibmm/i18n.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "prefs-utils.h"
+
+namespace Inkscape {
+namespace Extension {
+
+
+/** \brief  Initialize the object, to do that, copy the data. */
+ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+    Parameter(name, guitext, desc, scope, ext), _value(NULL)
+{
+    // printf("Building Description\n");
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+
+    if (defaultval != NULL)
+        _value = g_strdup(defaultval);
+
+    return;
+}
+
+/** \brief  Create a label for the description */
+Gtk::Widget *
+ParamDescription::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value)));
+    label->set_line_wrap();
+    label->show();
+
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+    hbox->pack_start(*label, true, true, 5);
+    hbox->show();
+
+    return hbox;
+}
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/paramdescription.h b/src/extension/paramdescription.h
new file mode 100644 (file)
index 0000000..13b4e5e
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef __INK_EXTENSION_PARAMDESCRIPTION_H__
+#define __INK_EXTENSION_PARAMDESCRIPTION_H__
+
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+/** \brief  A description parameter */
+class ParamDescription : public Parameter {
+private:
+    /** \brief  Internal value. */
+    gchar * _value;
+public:
+    ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+};
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMDESCRIPTION_H__ */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
index 8aea1daeb6d0cb11b4f6bc69ab42bc1fedf75fa2..8d779d1c228c0905db1637c3bfcffe551ef51346 100644 (file)
@@ -155,6 +155,11 @@ ParamComboBox::set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * no
     return _value;
 }
 
+void
+ParamComboBox::changed (void) {
+    
+}
+
 
 /**
     \brief  A function to get the value of the parameter in string form
@@ -168,19 +173,23 @@ ParamComboBox::string (void)
     return param_string;
 }
 
+
+
+
 /** \brief  A special category of Gtk::Entry to handle string parameteres */
 class ParamComboBoxEntry : public Gtk::ComboBoxText {
 private:
     ParamComboBox * _pref;
     SPDocument * _doc;
     Inkscape::XML::Node * _node;
+    sigc::signal<void> * _changeSignal;
 public:
     /** \brief  Build a string preference for the given parameter
         \param  pref  Where to get the string from, and where to put it
                       when it changes.
     */
-    ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node) :
-        Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node) {
+    ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
+        Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
         this->signal_changed().connect(sigc::mem_fun(this, &ParamComboBoxEntry::changed));
     };
     void changed (void);
@@ -196,11 +205,11 @@ ParamComboBoxEntry::changed (void)
 {
     Glib::ustring data = this->get_active_text();
     _pref->set(data.c_str(), _doc, _node);
-    return;
+    if (_changeSignal != NULL) {
+        _changeSignal->emit();
+    }
 }
 
-
-
 /**
     \brief  Creates a combobox widget for an enumeration parameter
 */
@@ -213,7 +222,7 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
     label->show();
     hbox->pack_start(*label, false, false);
 
-    ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node));
+    ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
     // add choice strings:
     Glib::ustring * settext = 0;
     for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
@@ -237,4 +246,3 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
 
 }  /* namespace Extension */
 }  /* namespace Inkscape */
-
index b5eaeded7bdbe4b011c7b44b3755369eafa21d82..7f36742aaa94a7c63ba85b40db6012e28d9e5039 100644 (file)
@@ -44,6 +44,8 @@ public:
         
     const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
     const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+    
+    void changed (void);
 }; /* class ParamComboBox */
 
 
index f59a5cc3d3823c4f020a4f641afae48e1997b85e..52c67267f7e2615002865df3e3df1e771517bf20 100644 (file)
 #include <gtkmm/box.h>
 #include <gtkmm/spinbutton.h>
 
-#include <glibmm/i18n.h>
-
 #include <xml/node.h>
 
 #include "extension.h"
-#include "prefs-utils.h"
 #include "document-private.h"
 #include "sp-object.h"
+#include "color.h"
+#include "widgets/sp-color-selector.h"
+#include "widgets/sp-color-notebook.h"
 
 #include "parameter.h"
-#include "paramnotebook.h"
+#include "parambool.h"
+#include "paramcolor.h"
+#include "paramdescription.h"
 #include "paramenum.h"
+#include "paramfloat.h"
+#include "paramint.h"
+#include "paramnotebook.h"
 #include "paramradiobutton.h"
-
-/** \brief  The root directory in the preferences database for extension
-            related parameters. */
-#define PREF_DIR "extensions"
+#include "paramstring.h"
 
 namespace Inkscape {
 namespace Extension {
 
-/** \brief  A description parameter */
-class ParamDescription : public Parameter {
-private:
-    /** \brief  Internal value. */
-    gchar * _value;
-public:
-    ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-};
-
-/** \brief  A boolean parameter */
-class ParamBool : public Parameter {
-private:
-    /** \brief  Internal value. */
-    bool _value;
-public:
-    ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-    /** \brief  Returns \c _value */
-    bool get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
-    bool set (bool in, SPDocument * doc, Inkscape::XML::Node * node);
-    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-    Glib::ustring * string (void);
-};
-
-/** \brief  Use the superclass' allocator and set the \c _value */
-ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
-        Parameter(name, guitext, desc, scope, ext), _value(false)
-{
-    const char * defaultval = NULL;
-    if (sp_repr_children(xml) != NULL)
-        defaultval = sp_repr_children(xml)->content();
-
-    if (defaultval != NULL && (!strcmp(defaultval, "TRUE") || !strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) {
-        _value = true;
-    } else {
-        _value = false;
-    }
-
-    gchar * pref_name = this->pref_name();
-    _value = (bool)prefs_get_int_attribute(PREF_DIR, pref_name, _value);
-    g_free(pref_name);
-
-    return;
-}
-
-class ParamInt : public Parameter {
-private:
-    /** \brief  Internal value. */
-    int _value;
-    int _min;
-    int _max;
-public:
-    ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-    /** \brief  Returns \c _value */
-    int get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
-    int set (int in, SPDocument * doc, Inkscape::XML::Node * node);
-    int max (void) { return _max; }
-    int min (void) { return _min; }
-    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-    Glib::ustring * string (void);
-};
-
-/** \brief  Use the superclass' allocator and set the \c _value */
-ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
-        Parameter(name, guitext, desc, scope, ext), _value(0), _min(0), _max(10)
-{
-    const char * defaultval = NULL;
-    if (sp_repr_children(xml) != NULL)
-        defaultval = sp_repr_children(xml)->content();
-    if (defaultval != NULL) {
-        _value = atoi(defaultval);
-    }
-
-    const char * maxval = xml->attribute("max");
-    if (maxval != NULL)
-        _max = atoi(maxval);
-
-    const char * minval = xml->attribute("min");
-    if (minval != NULL)
-        _min = atoi(minval);
-
-    /* We're handling this by just killing both values */
-    if (_max < _min) {
-        _max = 10;
-        _min = 0;
-    }
-
-    gchar * pref_name = this->pref_name();
-    _value = prefs_get_int_attribute(PREF_DIR, pref_name, _value);
-    g_free(pref_name);
-
-    // std::cout << "New Int::  value: " << _value << "  max: " << _max << "  min: " << _min << std::endl;
-
-    if (_value > _max) _value = _max;
-    if (_value < _min) _value = _min;
-
-    return;
-}
-
-class ParamFloat : public Parameter {
-private:
-    /** \brief  Internal value. */
-    float _value;
-    float _min;
-    float _max;
-public:
-    ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-    /** \brief  Returns \c _value */
-    float get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
-    float set (float in, SPDocument * doc, Inkscape::XML::Node * node);
-    float max (void) { return _max; }
-    float min (void) { return _min; }
-    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-    Glib::ustring * string (void);
-};
-
-/** \brief  Use the superclass' allocator and set the \c _value */
-ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
-        Parameter(name, guitext, desc, scope, ext), _value(0.0), _min(0.0), _max(10.0)
-{
-    const char * defaultval = NULL;
-    if (sp_repr_children(xml) != NULL)
-        defaultval = sp_repr_children(xml)->content();
-    if (defaultval != NULL) {
-        _value = atof(defaultval);
-    }
-
-    const char * maxval = xml->attribute("max");
-    if (maxval != NULL)
-        _max = atof(maxval);
-
-    const char * minval = xml->attribute("min");
-    if (minval != NULL)
-        _min = atof(minval);
-
-    /* We're handling this by just killing both values */
-    if (_max < _min) {
-        _max = 10.0;
-        _min = 0.0;
-    }
-
-    gchar * pref_name = this->pref_name();
-    _value = prefs_get_double_attribute(PREF_DIR, pref_name, _value);
-    g_free(pref_name);
-
-    // std::cout << "New Float::  value: " << _value << "  max: " << _max << "  min: " << _min << std::endl;
-
-    if (_value > _max) _value = _max;
-    if (_value < _min) _value = _min;
-
-    return;
-}
-
-class ParamString : public Parameter {
-private:
-    /** \brief  Internal value.  This should point to a string that has
-                been allocated in memory.  And should be free'd. */
-    gchar * _value;
-public:
-    ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-    ~ParamString(void);
-    /** \brief  Returns \c _value, with a \i const to protect it. */
-    const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
-    const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
-    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-    Glib::ustring * string (void);
-};
-
 class ParamEnum : public Parameter {
 private:
     class Choice {
@@ -245,8 +79,7 @@ public:
     Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
     Glib::ustring * string (void);
 }; /* class ParamEnum */
-
-
+     
 /**
     \return None
     \brief  This function creates a parameter that can be used later.  This
@@ -322,116 +155,23 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
         param = new ParamNotebook(name, guitext, desc, scope, in_ext, in_repr);
     } else if (!strcmp(type, "optiongroup")) {
         param = new ParamRadioButton(name, guitext, desc, scope, in_ext, in_repr);
+    } else if (!strcmp(type, "color")) {
+        param = new ParamColor(name, guitext, desc, scope, in_ext, in_repr);
     }
 
     /* Note: param could equal NULL */
     return param;
 }
 
-/** \brief  A function to set the \c _value
-    \param  in   The value to set to
-    \param  doc  A document that should be used to set the value.
-    \param  node The node where the value may be placed
-
-    This function sets the internal value, but it also sets the value
-    in the preferences structure.  To put it in the right place, \c PREF_DIR
-    and \c pref_name() are used.
-*/
-bool
-ParamBool::set (bool in, SPDocument * doc, Inkscape::XML::Node * node)
-{
-    _value = in;
-
-    gchar * prefname = this->pref_name();
-    prefs_set_int_attribute(PREF_DIR, prefname, _value == true ? 1 : 0);
-    g_free(prefname);
-
-    return _value;
-}
-
-/** \brief  A function to set the \c _value
-    \param  in   The value to set to
-    \param  doc  A document that should be used to set the value.
-    \param  node The node where the value may be placed
-
-    This function sets the internal value, but it also sets the value
-    in the preferences structure.  To put it in the right place, \c PREF_DIR
-    and \c pref_name() are used.
-*/
-int
-ParamInt::set (int in, SPDocument * doc, Inkscape::XML::Node * node)
-{
-    _value = in;
-    if (_value > _max) _value = _max;
-    if (_value < _min) _value = _min;
-
-    gchar * prefname = this->pref_name();
-    prefs_set_int_attribute(PREF_DIR, prefname, _value);
-    g_free(prefname);
-
-    return _value;
-}
-
-/** \brief  A function to set the \c _value
-    \param  in   The value to set to
-    \param  doc  A document that should be used to set the value.
-    \param  node The node where the value may be placed
-
-    This function sets the internal value, but it also sets the value
-    in the preferences structure.  To put it in the right place, \c PREF_DIR
-    and \c pref_name() are used.
-*/
-float
-ParamFloat::set (float in, SPDocument * doc, Inkscape::XML::Node * node)
-{
-    _value = in;
-    if (_value > _max) _value = _max;
-    if (_value < _min) _value = _min;
-
-    gchar * prefname = this->pref_name();
-    prefs_set_double_attribute(PREF_DIR, prefname, _value);
-    g_free(prefname);
-
-    return _value;
-}
-
-/** \brief  A function to set the \c _value
-    \param  in   The value to set to
-    \param  doc  A document that should be used to set the value.
-    \param  node The node where the value may be placed
-
-    This function sets the internal value, but it also sets the value
-    in the preferences structure.  To put it in the right place, \c PREF_DIR
-    and \c pref_name() are used.
-
-    To copy the data into _value the old memory must be free'd first.
-    It is important to note that \c g_free handles \c NULL just fine.  Then
-    the passed in value is duplicated using \c g_strdup().
-*/
-const gchar *
-ParamString::set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
-{
-    if (in == NULL) return NULL; /* Can't have NULL string */
 
-    if (_value != NULL)
-        g_free(_value);
-    _value = g_strdup(in);
-
-    gchar * prefname = this->pref_name();
-    prefs_set_string_attribute(PREF_DIR, prefname, _value);
-    g_free(prefname);
-
-    return _value;
-}
 
 /** \brief  Wrapper to cast to the object and use it's function.  */
 bool
 Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
 {
-    ParamBool * boolpntr;
-    boolpntr = dynamic_cast<ParamBool *>(this);
+    ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);    
     if (boolpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_bool_param();
     return boolpntr->get(doc, node);
 }
 
@@ -439,10 +179,9 @@ Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
 int
 Parameter::get_int (const SPDocument * doc, const Inkscape::XML::Node * node)
 {
-    ParamInt * intpntr;
-    intpntr = dynamic_cast<ParamInt *>(this);
+    ParamInt * intpntr = dynamic_cast<ParamInt *>(this);    
     if (intpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_int_param();
     return intpntr->get(doc, node);
 }
 
@@ -450,10 +189,9 @@ Parameter::get_int (const SPDocument * doc, const Inkscape::XML::Node * node)
 float
 Parameter::get_float (const SPDocument * doc, const Inkscape::XML::Node * node)
 {
-    ParamFloat * floatpntr;
-    floatpntr = dynamic_cast<ParamFloat *>(this);
+    ParamFloat * floatpntr = dynamic_cast<ParamFloat *>(this);    
     if (floatpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_float_param();
     return floatpntr->get(doc, node);
 }
 
@@ -461,21 +199,38 @@ Parameter::get_float (const SPDocument * doc, const Inkscape::XML::Node * node)
 const gchar *
 Parameter::get_string (const SPDocument * doc, const Inkscape::XML::Node * node)
 {
-    ParamString * stringpntr;
-    stringpntr = dynamic_cast<ParamString *>(this);
+    ParamString * stringpntr = dynamic_cast<ParamString *>(this);
     if (stringpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_string_param();
     return stringpntr->get(doc, node);
 }
 
+/** \brief  Wrapper to cast to the object and use it's function.  */
+const gchar *
+Parameter::get_enum (const SPDocument * doc, const Inkscape::XML::Node * node)
+{
+    ParamComboBox * param = dynamic_cast<ParamComboBox *>(this);
+    if (param == NULL)
+        throw Extension::param_not_enum_param();
+    return param->get(doc, node);
+}
+
+SPColor*
+Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node)
+{
+    ParamColor* param = dynamic_cast<ParamColor *>(this);
+    if (param == NULL)
+        throw Extension::param_not_color_param();
+    return param->get(doc, node);
+}
+
 /** \brief  Wrapper to cast to the object and use it's function.  */
 bool
 Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node)
 {
-    ParamBool * boolpntr;
-    boolpntr = dynamic_cast<ParamBool *>(this);
+    ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);
     if (boolpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_bool_param();
     return boolpntr->set(in, doc, node);
 }
 
@@ -483,10 +238,9 @@ Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node)
 int
 Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node)
 {
-    ParamInt * intpntr;
-    intpntr = dynamic_cast<ParamInt *>(this);
+    ParamInt * intpntr = dynamic_cast<ParamInt *>(this);    
     if (intpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_int_param();
     return intpntr->set(in, doc, node);
 }
 
@@ -497,7 +251,7 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
     ParamFloat * floatpntr;
     floatpntr = dynamic_cast<ParamFloat *>(this);
     if (floatpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_float_param();
     return floatpntr->set(in, doc, node);
 }
 
@@ -505,38 +259,21 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
 const gchar *
 Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
 {
-    ParamString * stringpntr;
-    stringpntr = dynamic_cast<ParamString *>(this);
+    ParamString * stringpntr = dynamic_cast<ParamString *>(this);    
     if (stringpntr == NULL)
-        throw Extension::param_wrong_type();
+        throw Extension::param_not_string_param();
     return stringpntr->set(in, doc, node);
 }
-
-/** \brief  Initialize the object, to do that, copy the data. */
-ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
-    Parameter(name, guitext, desc, scope, ext), _value(NULL)
+/** \brief  Wrapper to cast to the object and use it's function.  */
+SPColor*
+Parameter::set_color (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node)
 {
-    const char * defaultval = NULL;
-    if (sp_repr_children(xml) != NULL)
-        defaultval = sp_repr_children(xml)->content();
-
-    gchar * pref_name = this->pref_name();
-    const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
-    g_free(pref_name);
-
-    if (paramval != NULL)
-        defaultval = paramval;
-    if (defaultval != NULL)
-        _value = g_strdup(defaultval);
-
-    return;
+    ParamColor* param = dynamic_cast<ParamColor *>(this);
+    if (param == NULL)
+        throw Extension::param_not_color_param();
+    return param->set(in, doc, node);
 }
 
-/** \brief  Free the allocated data. */
-ParamString::~ParamString(void)
-{
-    g_free(_value);
-}
 
 /** \brief  Oop, now that we need a parameter, we need it's name.  */
 Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext) :
@@ -633,346 +370,9 @@ Parameter::string (void)
     return mystring;
 }
 
-/** \brief  A class to make an adjustment that uses Extension params */
-class ParamFloatAdjustment : public Gtk::Adjustment {
-    /** The parameter to adjust */
-    ParamFloat * _pref;
-    SPDocument * _doc;
-    Inkscape::XML::Node * _node;
-    sigc::signal<void> * _changeSignal;
-public:
-    /** \brief  Make the adjustment using an extension and the string
-                describing the parameter. */
-    ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
-            Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
-        this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
-        this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed));
-        return;
-    };
-
-    void val_changed (void);
-}; /* class ParamFloatAdjustment */
-
-/** \brief  A function to respond to the value_changed signal from the
-            adjustment.
-
-    This function just grabs the value from the adjustment and writes
-    it to the parameter.  Very simple, but yet beautiful.
-*/
-void
-ParamFloatAdjustment::val_changed (void)
-{
-    //std::cout << "Value Changed to: " << this->get_value() << std::endl;
-    _pref->set(this->get_value(), _doc, _node);
-    if (_changeSignal != NULL) {
-        _changeSignal->emit();
-    }
-    return;
-}
-
-/** \brief  A class to make an adjustment that uses Extension params */
-class ParamIntAdjustment : public Gtk::Adjustment {
-    /** The parameter to adjust */
-    ParamInt * _pref;
-    SPDocument * _doc;
-    Inkscape::XML::Node * _node;
-    sigc::signal<void> * _changeSignal;
-public:
-    /** \brief  Make the adjustment using an extension and the string
-                describing the parameter. */
-    ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
-            Gtk::Adjustment(0.0, param->min(), param->max(), 1.0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
-        this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
-        this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed));
-        return;
-    };
-
-    void val_changed (void);
-}; /* class ParamIntAdjustment */
-
-/** \brief  A function to respond to the value_changed signal from the
-            adjustment.
-
-    This function just grabs the value from the adjustment and writes
-    it to the parameter.  Very simple, but yet beautiful.
-*/
-void
-ParamIntAdjustment::val_changed (void)
-{
-    //std::cout << "Value Changed to: " << this->get_value() << std::endl;
-    _pref->set((int)this->get_value(), _doc, _node);
-    if (_changeSignal != NULL) {
-        _changeSignal->emit();
-    }
-    return;
-}
-
-/**
-    \brief  Creates a Float Adjustment for a float parameter
-
-    Builds a hbox with a label and a float adjustment in it.
-*/
-Gtk::Widget *
-ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
-{
-    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
-
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
-    label->show();
-    hbox->pack_start(*label, true, true);
-
-    ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal));
-    Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, 1));
-    spin->show();
-    hbox->pack_start(*spin, false, false);
-
-    hbox->show();
-
-    return dynamic_cast<Gtk::Widget *>(hbox);
-}
-
-/**
-    \brief  Creates a Int Adjustment for a int parameter
-
-    Builds a hbox with a label and a int adjustment in it.
-*/
-Gtk::Widget *
-ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
-{
-    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
 
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
-    label->show();
-    hbox->pack_start(*label, true, true);
 
-    ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal));
-    Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0));
-    spin->show();
-    hbox->pack_start(*spin, false, false);
 
-    hbox->show();
-
-    return dynamic_cast<Gtk::Widget *>(hbox);
-}
-
-/** \brief  A check button which is Param aware.  It works with the
-            parameter to change it's value as the check button changes
-            value. */
-class ParamBoolCheckButton : public Gtk::CheckButton {
-private:
-    /** \brief  Param to change */
-    ParamBool * _pref;
-    SPDocument * _doc;
-    Inkscape::XML::Node * _node;
-    sigc::signal<void> * _changeSignal;
-public:
-    /** \brief  Initialize the check button
-        \param  param  Which parameter to adjust on changing the check button
-
-        This function sets the value of the checkbox to be that of the
-        parameter, and then sets up a callback to \c on_toggle.
-    */
-    ParamBoolCheckButton (ParamBool * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
-            Gtk::CheckButton(), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
-        this->set_active(_pref->get(NULL, NULL) /**\todo fix */);
-        this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle));
-        return;
-    }
-    void on_toggle (void);
-};
-
-/**
-    \brief  A function to respond to the check box changing
-
-    Adjusts the value of the preference to match that in the check box.
-*/
-void
-ParamBoolCheckButton::on_toggle (void)
-{
-    _pref->set(this->get_active(), NULL /**\todo fix this */, NULL);
-    if (_changeSignal != NULL) {
-        _changeSignal->emit();
-    }
-    return;
-}
-
-/**
-    \brief  Creates a bool check button for a bool parameter
-
-    Builds a hbox with a label and a check button in it.
-*/
-Gtk::Widget *
-ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
-{
-    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
-
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
-    label->show();
-    hbox->pack_start(*label, true, true);
-
-    ParamBoolCheckButton * checkbox = new ParamBoolCheckButton(this, doc, node, changeSignal);
-    checkbox->show();
-    hbox->pack_start(*checkbox, false, false);
-
-    hbox->show();
-
-    return dynamic_cast<Gtk::Widget *>(hbox);
-}
-
-/** \brief  A special category of Gtk::Entry to handle string parameteres */
-class ParamStringEntry : public Gtk::Entry {
-private:
-    ParamString * _pref;
-    SPDocument * _doc;
-    Inkscape::XML::Node * _node;
-    sigc::signal<void> * _changeSignal;
-public:
-    /** \brief  Build a string preference for the given parameter
-        \param  pref  Where to get the string from, and where to put it
-                      when it changes.
-    */
-    ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
-        Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
-        if (_pref->get(NULL, NULL) != NULL)
-            this->set_text(Glib::ustring(_pref->get(NULL, NULL)));
-        this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text));
-    };
-    void changed_text (void);
-};
-
-/** \brief  Respond to the text box changing
-
-    This function responds to the box changing by grabbing the value
-    from the text box and putting it in the parameter.
-*/
-void
-ParamStringEntry::changed_text (void)
-{
-    Glib::ustring data = this->get_text();
-    _pref->set(data.c_str(), _doc, _node);
-    if (_changeSignal != NULL) {
-        _changeSignal->emit();
-    }
-    return;
-}
-
-/**
-    \brief  Creates a text box for the string parameter
-
-    Builds a hbox with a label and a text box in it.
-*/
-Gtk::Widget *
-ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
-{
-    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
-
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
-    label->show();
-    hbox->pack_start(*label, false, false);
-
-    ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal);
-    textbox->show();
-    hbox->pack_start(*textbox, true, true);
-
-    hbox->show();
-
-    return dynamic_cast<Gtk::Widget *>(hbox);
-}
-
-/** \brief  Return 'true' or 'false' */
-Glib::ustring *
-ParamBool::string (void)
-{
-    Glib::ustring * mystring;
-
-    if (_value)
-        mystring = new Glib::ustring("true");
-    else
-        mystring = new Glib::ustring("false");
-
-    return mystring;
-}
-
-/** \brief  Return the value as a string */
-Glib::ustring *
-ParamInt::string (void)
-{
-    char startstring[32];
-    sprintf(startstring, "%d", _value);
-    Glib::ustring * mystring = new Glib::ustring(startstring);
-    return mystring;
-}
-
-/** \brief  Return the value as a string */
-Glib::ustring *
-ParamFloat::string (void)
-{
-    char startstring[G_ASCII_DTOSTR_BUF_SIZE];
-    g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value);
-    Glib::ustring * mystring = new Glib::ustring(startstring);
-    return mystring;
-}
-
-/** \brief  Return the value as a string */
-Glib::ustring *
-ParamString::string (void)
-{
-    if (_value == NULL)
-        return new Glib::ustring("");
-
-    // FIXME: I think the string should NOT be escaped. Just put between "..."
-    // Otherwise \frac{1}{2} will become \\frac{1}{2} and then the LaTeX effect won't work....
-    //gchar * esc = g_strescape(_value, NULL);
-    Glib::ustring escaped(_value);
-    //g_free(esc);
-    
-#ifdef ESCAPE_DOLLAR_COMMANDLINE // escape the dollar sign 
-    Glib::ustring::iterator i;
-    for (i = escaped.begin(); i != escaped.end(); ++i) {
-        if ( *i == '$') {
-            i = escaped.insert(i, '\\');
-            i++;
-        }
-    }
-#endif
-
-    Glib::ustring * mystring = new Glib::ustring("");
-    *mystring += "\"";
-    *mystring += escaped;
-    *mystring += "\"";
-    
-    return mystring;
-}
-
-/** \brief  Create a label for the description */
-Gtk::Widget *
-ParamDescription::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
-{
-    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value)));
-    label->set_line_wrap();
-    label->show();
-
-    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
-    hbox->pack_start(*label, true, true, 5);
-    hbox->show();
-
-    return hbox;
-}
-
-/** \brief  Initialize the object, to do that, copy the data. */
-ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
-    Parameter(name, guitext, desc, scope, ext), _value(NULL)
-{
-    // printf("Building Description\n");
-    const char * defaultval = NULL;
-    if (sp_repr_children(xml) != NULL)
-        defaultval = sp_repr_children(xml)->content();
-
-    if (defaultval != NULL)
-        _value = g_strdup(defaultval);
-
-    return;
-}
 
 ParamEnum::ParamEnum (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
     Parameter(name, guitext, desc, scope, ext), _current_choice(NULL)
index 5ac1c9f5cb8fd810f533d1a2f09d6af392b089c2..0c799a1c24ab7cf1049aae9457fd8f412fff63fc 100644 (file)
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
+
+/** \brief  The root directory in the preferences database for extension-related parameters. */
+#define PREF_DIR "extensions"
+
 #include <gtkmm/widget.h>
 
 #include "xml/document.h"
+#include "xml/node.h"
+#include "document.h"
 #include "extension-forward.h"
+#include "prefs-utils.h"
+
+#include <glibmm/i18n.h>
+
+#include "color.h"
 
 namespace Inkscape {
 namespace Extension {
@@ -76,11 +87,16 @@ public:
                               const Inkscape::XML::Node * node);
     const gchar * get_string (const SPDocument * doc,
                               const Inkscape::XML::Node * node);
+    SPColor* get_color              (const SPDocument * doc,
+                              const Inkscape::XML::Node * node);
+       const gchar * get_enum   (const SPDocument * doc,
+                              const Inkscape::XML::Node * node);
 
     bool          set_bool   (bool in,          SPDocument * doc, Inkscape::XML::Node * node);
     int           set_int    (int  in,          SPDocument * doc, Inkscape::XML::Node * node);
     float         set_float  (float in,         SPDocument * doc, Inkscape::XML::Node * node);
     const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+    SPColor*     set_color  (SPColor* in, SPDocument * doc, Inkscape::XML::Node * node);
 
     const gchar * name       (void) {return _name;}
 
@@ -90,7 +106,6 @@ public:
     gchar const * get_tooltip (void) { return _desc; }
 };
 
-
 }  /* namespace Extension */
 }  /* namespace Inkscape */
 
diff --git a/src/extension/paramfloat.cpp b/src/extension/paramfloat.cpp
new file mode 100644 (file)
index 0000000..85a0bc4
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "paramfloat.h"
+
+namespace Inkscape {
+namespace Extension {
+
+
+/** \brief  Use the superclass' allocator and set the \c _value */
+ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+        Parameter(name, guitext, desc, scope, ext), _value(0.0), _min(0.0), _max(10.0)
+{
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+    if (defaultval != NULL) {
+        _value = atof(defaultval);
+    }
+
+    const char * maxval = xml->attribute("max");
+    if (maxval != NULL)
+        _max = atof(maxval);
+
+    const char * minval = xml->attribute("min");
+    if (minval != NULL)
+        _min = atof(minval);
+
+    /* We're handling this by just killing both values */
+    if (_max < _min) {
+        _max = 10.0;
+        _min = 0.0;
+    }
+
+    gchar * pref_name = this->pref_name();
+    _value = prefs_get_double_attribute(PREF_DIR, pref_name, _value);
+    g_free(pref_name);
+
+    // std::cout << "New Float::  value: " << _value << "  max: " << _max << "  min: " << _min << std::endl;
+
+    if (_value > _max) _value = _max;
+    if (_value < _min) _value = _min;
+
+    return;
+}
+
+/** \brief  A function to set the \c _value
+    \param  in   The value to set to
+    \param  doc  A document that should be used to set the value.
+    \param  node The node where the value may be placed
+
+    This function sets the internal value, but it also sets the value
+    in the preferences structure.  To put it in the right place, \c PREF_DIR
+    and \c pref_name() are used.
+*/
+float
+ParamFloat::set (float in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    _value = in;
+    if (_value > _max) _value = _max;
+    if (_value < _min) _value = _min;
+
+    gchar * prefname = this->pref_name();
+    prefs_set_double_attribute(PREF_DIR, prefname, _value);
+    g_free(prefname);
+
+    return _value;
+}
+
+/** \brief  Return the value as a string */
+Glib::ustring *
+ParamFloat::string (void)
+{
+    char startstring[G_ASCII_DTOSTR_BUF_SIZE];
+    g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value);
+    Glib::ustring * mystring = new Glib::ustring(startstring);
+    return mystring;
+}
+
+/** \brief  A class to make an adjustment that uses Extension params */
+class ParamFloatAdjustment : public Gtk::Adjustment {
+    /** The parameter to adjust */
+    ParamFloat * _pref;
+    SPDocument * _doc;
+    Inkscape::XML::Node * _node;
+    sigc::signal<void> * _changeSignal;
+public:
+    /** \brief  Make the adjustment using an extension and the string
+                describing the parameter. */
+    ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
+            Gtk::Adjustment(0.0, param->min(), param->max(), 0.1), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
+        this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
+        this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed));
+        return;
+    };
+
+    void val_changed (void);
+}; /* class ParamFloatAdjustment */
+
+/** \brief  A function to respond to the value_changed signal from the
+            adjustment.
+
+    This function just grabs the value from the adjustment and writes
+    it to the parameter.  Very simple, but yet beautiful.
+*/
+void
+ParamFloatAdjustment::val_changed (void)
+{
+    //std::cout << "Value Changed to: " << this->get_value() << std::endl;
+    _pref->set(this->get_value(), _doc, _node);
+    if (_changeSignal != NULL) {
+        _changeSignal->emit();
+    }
+    return;
+}
+
+/**
+    \brief  Creates a Float Adjustment for a float parameter
+
+    Builds a hbox with a label and a float adjustment in it.
+*/
+Gtk::Widget *
+ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
+    label->show();
+    hbox->pack_start(*label, true, true);
+
+    ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal));
+    Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, 1));
+    spin->show();
+    hbox->pack_start(*spin, false, false);
+
+    hbox->show();
+
+    return dynamic_cast<Gtk::Widget *>(hbox);
+}
+
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/paramfloat.h b/src/extension/paramfloat.h
new file mode 100644 (file)
index 0000000..ab9d611
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __INK_EXTENSION_PARAMFLOAT_H
+#define __INK_EXTENSION_PARAMFLOAT_H
+
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+class ParamFloat : public Parameter {
+private:
+    /** \brief  Internal value. */
+    float _value;
+    float _min;
+    float _max;
+public:
+    ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    /** \brief  Returns \c _value */
+    float get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
+    float set (float in, SPDocument * doc, Inkscape::XML::Node * node);
+    float max (void) { return _max; }
+    float min (void) { return _min; }
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+    Glib::ustring * string (void);
+};
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMFLOAT_H */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/paramint.cpp b/src/extension/paramint.cpp
new file mode 100644 (file)
index 0000000..316d104
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "paramint.h"
+
+namespace Inkscape {
+namespace Extension {
+
+
+/** \brief  Use the superclass' allocator and set the \c _value */
+ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+        Parameter(name, guitext, desc, scope, ext), _value(0), _min(0), _max(10)
+{
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+    if (defaultval != NULL) {
+        _value = atoi(defaultval);
+    }
+
+    const char * maxval = xml->attribute("max");
+    if (maxval != NULL)
+        _max = atoi(maxval);
+
+    const char * minval = xml->attribute("min");
+    if (minval != NULL)
+        _min = atoi(minval);
+
+    /* We're handling this by just killing both values */
+    if (_max < _min) {
+        _max = 10;
+        _min = 0;
+    }
+
+    gchar * pref_name = this->pref_name();
+    _value = prefs_get_int_attribute(PREF_DIR, pref_name, _value);
+    g_free(pref_name);
+
+    // std::cout << "New Int::  value: " << _value << "  max: " << _max << "  min: " << _min << std::endl;
+
+    if (_value > _max) _value = _max;
+    if (_value < _min) _value = _min;
+
+    return;
+}
+
+/** \brief  A function to set the \c _value
+    \param  in   The value to set to
+    \param  doc  A document that should be used to set the value.
+    \param  node The node where the value may be placed
+
+    This function sets the internal value, but it also sets the value
+    in the preferences structure.  To put it in the right place, \c PREF_DIR
+    and \c pref_name() are used.
+*/
+int
+ParamInt::set (int in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    _value = in;
+    if (_value > _max) _value = _max;
+    if (_value < _min) _value = _min;
+
+    gchar * prefname = this->pref_name();
+    prefs_set_int_attribute(PREF_DIR, prefname, _value);
+    g_free(prefname);
+
+    return _value;
+}
+
+/** \brief  A class to make an adjustment that uses Extension params */
+class ParamIntAdjustment : public Gtk::Adjustment {
+    /** The parameter to adjust */
+    ParamInt * _pref;
+    SPDocument * _doc;
+    Inkscape::XML::Node * _node;
+    sigc::signal<void> * _changeSignal;
+public:
+    /** \brief  Make the adjustment using an extension and the string
+                describing the parameter. */
+    ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
+            Gtk::Adjustment(0.0, param->min(), param->max(), 1.0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
+        this->set_value(_pref->get(NULL, NULL) /* \todo fix */);
+        this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed));
+        return;
+    };
+
+    void val_changed (void);
+}; /* class ParamIntAdjustment */
+
+/** \brief  A function to respond to the value_changed signal from the
+            adjustment.
+
+    This function just grabs the value from the adjustment and writes
+    it to the parameter.  Very simple, but yet beautiful.
+*/
+void
+ParamIntAdjustment::val_changed (void)
+{
+    //std::cout << "Value Changed to: " << this->get_value() << std::endl;
+    _pref->set((int)this->get_value(), _doc, _node);
+    if (_changeSignal != NULL) {
+        _changeSignal->emit();
+    }
+    return;
+}
+
+/**
+    \brief  Creates a Int Adjustment for a int parameter
+
+    Builds a hbox with a label and a int adjustment in it.
+*/
+Gtk::Widget *
+ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
+    label->show();
+    hbox->pack_start(*label, true, true);
+
+    ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal));
+    Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0));
+    spin->show();
+    hbox->pack_start(*spin, false, false);
+
+    hbox->show();
+
+    return dynamic_cast<Gtk::Widget *>(hbox);
+}
+
+/** \brief  Return the value as a string */
+Glib::ustring *
+ParamInt::string (void)
+{
+    char startstring[32];
+    sprintf(startstring, "%d", _value);
+    Glib::ustring * mystring = new Glib::ustring(startstring);
+    return mystring;
+}
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/paramint.h b/src/extension/paramint.h
new file mode 100644 (file)
index 0000000..2496b72
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __INK_EXTENSION_PARAMINT_H
+#define __INK_EXTENSION_PARAMINT_H
+
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+class ParamInt : public Parameter {
+private:
+    /** \brief  Internal value. */
+    int _value;
+    int _min;
+    int _max;
+public:
+    ParamInt (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    /** \brief  Returns \c _value */
+    int get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
+    int set (int in, SPDocument * doc, Inkscape::XML::Node * node);
+    int max (void) { return _max; }
+    int min (void) { return _min; }
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+    Glib::ustring * string (void);
+};
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMINT_H */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/paramstring.cpp b/src/extension/paramstring.cpp
new file mode 100644 (file)
index 0000000..1b5b09a
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+
+#include <xml/node.h>
+
+#include "extension.h"
+#include "paramstring.h"
+
+namespace Inkscape {
+namespace Extension {
+    
+
+/** \brief  Free the allocated data. */
+ParamString::~ParamString(void)
+{
+    g_free(_value);
+}
+
+/** \brief  A function to set the \c _value
+    \param  in   The value to set to
+    \param  doc  A document that should be used to set the value.
+    \param  node The node where the value may be placed
+
+    This function sets the internal value, but it also sets the value
+    in the preferences structure.  To put it in the right place, \c PREF_DIR
+    and \c pref_name() are used.
+
+    To copy the data into _value the old memory must be free'd first.
+    It is important to note that \c g_free handles \c NULL just fine.  Then
+    the passed in value is duplicated using \c g_strdup().
+*/
+const gchar *
+ParamString::set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
+{
+    if (in == NULL) return NULL; /* Can't have NULL string */
+
+    if (_value != NULL)
+        g_free(_value);
+    _value = g_strdup(in);
+
+    gchar * prefname = this->pref_name();
+    prefs_set_string_attribute(PREF_DIR, prefname, _value);
+    g_free(prefname);
+
+    return _value;
+}
+
+/** \brief  Return the value as a string */
+Glib::ustring *
+ParamString::string (void)
+{
+    if (_value == NULL)
+        return new Glib::ustring("");
+
+    // FIXME: I think the string should NOT be escaped. Just put between "..."
+    // Otherwise \frac{1}{2} will become \\frac{1}{2} and then the LaTeX effect won't work....
+    //gchar * esc = g_strescape(_value, NULL);
+    Glib::ustring escaped(_value);
+    //g_free(esc);
+    
+#ifdef ESCAPE_DOLLAR_COMMANDLINE // escape the dollar sign 
+    Glib::ustring::iterator i;
+    for (i = escaped.begin(); i != escaped.end(); ++i) {
+        if ( *i == '$') {
+            i = escaped.insert(i, '\\');
+            i++;
+        }
+    }
+#endif
+
+    Glib::ustring * mystring = new Glib::ustring("");
+    *mystring += "\"";
+    *mystring += escaped;
+    *mystring += "\"";
+    
+    return mystring;
+}
+
+/** \brief  Initialize the object, to do that, copy the data. */
+ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+    Parameter(name, guitext, desc, scope, ext), _value(NULL)
+{
+    const char * defaultval = NULL;
+    if (sp_repr_children(xml) != NULL)
+        defaultval = sp_repr_children(xml)->content();
+
+    gchar * pref_name = this->pref_name();
+    const gchar * paramval = prefs_get_string_attribute(PREF_DIR, pref_name);
+    g_free(pref_name);
+
+    if (paramval != NULL)
+        defaultval = paramval;
+    if (defaultval != NULL)
+        _value = g_strdup(defaultval);
+
+    return;
+}
+
+/** \brief  A special category of Gtk::Entry to handle string parameteres */
+class ParamStringEntry : public Gtk::Entry {
+private:
+    ParamString * _pref;
+    SPDocument * _doc;
+    Inkscape::XML::Node * _node;
+    sigc::signal<void> * _changeSignal;
+public:
+    /** \brief  Build a string preference for the given parameter
+        \param  pref  Where to get the string from, and where to put it
+                      when it changes.
+    */
+    ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) :
+        Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
+        if (_pref->get(NULL, NULL) != NULL)
+            this->set_text(Glib::ustring(_pref->get(NULL, NULL)));
+        this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text));
+    };
+    void changed_text (void);
+};
+
+
+/** \brief  Respond to the text box changing
+
+    This function responds to the box changing by grabbing the value
+    from the text box and putting it in the parameter.
+*/
+void
+ParamStringEntry::changed_text (void)
+{
+    Glib::ustring data = this->get_text();
+    _pref->set(data.c_str(), _doc, _node);
+    if (_changeSignal != NULL) {
+        _changeSignal->emit();
+    }
+    return;
+}
+
+/**
+    \brief  Creates a text box for the string parameter
+
+    Builds a hbox with a label and a text box in it.
+*/
+Gtk::Widget *
+ParamString::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+{
+    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+
+    Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
+    label->show();
+    hbox->pack_start(*label, false, false);
+
+    ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal);
+    textbox->show();
+    hbox->pack_start(*textbox, true, true);
+
+    hbox->show();
+
+    return dynamic_cast<Gtk::Widget *>(hbox);
+}
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
diff --git a/src/extension/paramstring.h b/src/extension/paramstring.h
new file mode 100644 (file)
index 0000000..c36d7ba
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef __INK_EXTENSION_PARAMSTRING_H
+#define __INK_EXTENSION_PARAMSTRING_H
+
+/*
+ * Copyright (C) 2005-2007 Authors:
+ *   Ted Gould <ted@gould.cx>
+ *   Johan Engelen <johan@shouraizou.nl> *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+class ParamString : public Parameter {
+private:
+    /** \brief  Internal value.  This should point to a string that has
+                been allocated in memory.  And should be free'd. */
+    gchar * _value;
+public:
+    ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+    ~ParamString(void);
+    /** \brief  Returns \c _value, with a \i const to protect it. */
+    const gchar * get (const SPDocument * doc, const Inkscape::XML::Node * node) { return _value; }
+    const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
+    Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+    Glib::ustring * string (void);
+};
+
+
+}  /* namespace Extension */
+}  /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMSTRING_H */
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :