summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/extension
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/CMakeLists.txt292
-rw-r--r--src/extension/Makefile_insert2
-rw-r--r--src/extension/db.cpp2
-rw-r--r--src/extension/db.h14
-rw-r--r--src/extension/dbus/dbus-init.cpp5
-rw-r--r--src/extension/dbus/document-interface.cpp397
-rw-r--r--src/extension/dbus/document-interface.h33
-rw-r--r--src/extension/dbus/document-interface.xml192
-rw-r--r--src/extension/dbus/proposed-interface.xml50
-rw-r--r--src/extension/dbus/wrapper/inkscape-dbus-wrapper.c6
-rw-r--r--src/extension/dbus/wrapper/inkscape-dbus-wrapper.h2
-rw-r--r--src/extension/dependency.cpp1
-rw-r--r--src/extension/dxf2svg/CMakeLists.txt11
-rw-r--r--src/extension/dxf2svg/blocks.cpp5
-rw-r--r--src/extension/dxf2svg/entities.cpp4
-rw-r--r--src/extension/dxf2svg/read_dxf.cpp2
-rw-r--r--src/extension/dxf2svg/tables2svg_info.cpp2
-rw-r--r--src/extension/effect.cpp46
-rw-r--r--src/extension/effect.h12
-rw-r--r--src/extension/execution-env.cpp9
-rw-r--r--src/extension/execution-env.h16
-rw-r--r--src/extension/extension-forward.h35
-rw-r--r--src/extension/extension.cpp59
-rw-r--r--src/extension/extension.h68
-rw-r--r--src/extension/implementation/CMakeLists.txt5
-rw-r--r--src/extension/implementation/implementation.cpp174
-rw-r--r--src/extension/implementation/implementation.h197
-rw-r--r--src/extension/implementation/script.cpp33
-rw-r--r--src/extension/init.cpp4
-rw-r--r--src/extension/input.h2
-rw-r--r--src/extension/internal/CMakeLists.txt31
-rw-r--r--src/extension/internal/Makefile_insert4
-rw-r--r--src/extension/internal/bitmap/CMakeLists.txt37
-rw-r--r--src/extension/internal/bitmap/crop.cpp84
-rw-r--r--src/extension/internal/bitmap/crop.h34
-rw-r--r--src/extension/internal/bitmap/imagemagick.cpp298
-rw-r--r--src/extension/internal/bitmap/imagemagick.h12
-rw-r--r--src/extension/internal/bluredge.cpp10
-rw-r--r--src/extension/internal/bluredge.h5
-rw-r--r--src/extension/internal/cairo-png-out.cpp26
-rw-r--r--src/extension/internal/cairo-ps-out.cpp12
-rw-r--r--src/extension/internal/cairo-render-context.cpp241
-rw-r--r--src/extension/internal/cairo-render-context.h29
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp25
-rw-r--r--src/extension/internal/cairo-renderer.cpp181
-rw-r--r--src/extension/internal/emf-win32-inout.cpp229
-rw-r--r--src/extension/internal/emf-win32-print.cpp230
-rw-r--r--src/extension/internal/emf-win32-print.h21
-rw-r--r--src/extension/internal/filter/CMakeLists.txt8
-rwxr-xr-xsrc/extension/internal/filter/abc.h878
-rw-r--r--src/extension/internal/filter/bevels.h282
-rw-r--r--src/extension/internal/filter/blurs.h419
-rw-r--r--src/extension/internal/filter/bumps.h488
-rw-r--r--[-rwxr-xr-x]src/extension/internal/filter/color.h1133
-rw-r--r--src/extension/internal/filter/distort.h249
-rw-r--r--src/extension/internal/filter/drop-shadow.h150
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp88
-rw-r--r--src/extension/internal/filter/filter-file.cpp10
-rw-r--r--src/extension/internal/filter/filter.cpp24
-rw-r--r--src/extension/internal/filter/filter.h11
-rw-r--r--src/extension/internal/filter/image.h113
-rw-r--r--src/extension/internal/filter/morphology.h268
-rw-r--r--src/extension/internal/filter/overlays.h147
-rw-r--r--[-rwxr-xr-x]src/extension/internal/filter/paint.h (renamed from src/extension/internal/filter/experimental.h)477
-rw-r--r--src/extension/internal/filter/protrusions.h (renamed from src/extension/internal/filter/snow.h)33
-rw-r--r--src/extension/internal/filter/shadows.h119
-rw-r--r--src/extension/internal/filter/textures.h158
-rw-r--r--src/extension/internal/filter/transparency.h399
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp4
-rw-r--r--src/extension/internal/gimpgrad.h25
-rw-r--r--src/extension/internal/grid.cpp6
-rw-r--r--src/extension/internal/grid.h5
-rw-r--r--src/extension/internal/javafx-out.cpp20
-rw-r--r--src/extension/internal/latex-pstricks-out.cpp41
-rw-r--r--src/extension/internal/latex-pstricks.cpp76
-rw-r--r--src/extension/internal/latex-pstricks.h16
-rw-r--r--src/extension/internal/latex-text-renderer.cpp156
-rw-r--r--src/extension/internal/latex-text-renderer.h3
-rw-r--r--src/extension/internal/odf.cpp35
-rw-r--r--src/extension/internal/odf.h25
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp4
-rw-r--r--src/extension/internal/pdf-input-cairo.h10
-rw-r--r--src/extension/internal/pdfinput/CMakeLists.txt5
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp7
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h29
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp5
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.h11
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp103
-rw-r--r--src/extension/internal/pdfinput/svg-builder.h30
-rw-r--r--src/extension/internal/pov-out.cpp9
-rw-r--r--src/extension/internal/svg.cpp1
-rw-r--r--src/extension/internal/win32.cpp510
-rw-r--r--src/extension/internal/win32.h96
-rw-r--r--src/extension/internal/wpg-input.cpp26
-rw-r--r--src/extension/output.h2
-rw-r--r--src/extension/param/CMakeLists.txt14
-rw-r--r--src/extension/param/bool.cpp99
-rw-r--r--src/extension/param/bool.h63
-rw-r--r--src/extension/param/color.cpp19
-rw-r--r--src/extension/param/color.h39
-rw-r--r--src/extension/param/description.cpp46
-rw-r--r--src/extension/param/description.h19
-rw-r--r--src/extension/param/enum.cpp130
-rw-r--r--src/extension/param/enum.h16
-rw-r--r--src/extension/param/float.cpp130
-rw-r--r--src/extension/param/float.h44
-rwxr-xr-xsrc/extension/param/groupheader.cpp78
-rwxr-xr-xsrc/extension/param/groupheader.h45
-rw-r--r--src/extension/param/int.cpp135
-rw-r--r--src/extension/param/int.h42
-rw-r--r--src/extension/param/notebook.cpp148
-rw-r--r--src/extension/param/notebook.h28
-rw-r--r--src/extension/param/parameter.cpp311
-rw-r--r--src/extension/param/parameter.h218
-rw-r--r--src/extension/param/radiobutton.cpp119
-rw-r--r--src/extension/param/radiobutton.h28
-rw-r--r--src/extension/param/string.cpp124
-rw-r--r--src/extension/param/string.h18
-rw-r--r--src/extension/patheffect.cpp7
-rw-r--r--src/extension/print.cpp59
-rw-r--r--src/extension/print.h37
-rw-r--r--src/extension/script/CMakeLists.txt3
-rw-r--r--src/extension/script/InkscapeScript.cpp2
-rw-r--r--src/extension/script/InkscapeScript.h11
-rw-r--r--src/extension/system.cpp28
-rw-r--r--src/extension/system.h2
-rw-r--r--src/extension/timer.h3
127 files changed, 7293 insertions, 4675 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index cd640d3d0..5761b1e8b 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -1,41 +1,255 @@
-SET(extfolders
-#dxf2svg
-implementation
-internal
-internal/bitmap
-internal/filter
-internal/pdfinput
-param
-script
-)
-FOREACH(extlistsrc ${extfolders})
- ADD_SUBDIRECTORY(${extlistsrc})
-ENDFOREACH(extlistsrc)
-
-SET(extension_SRC
-db.cpp
-dependency.cpp
-effect.cpp
-error-file.cpp
-execution-env.cpp
-extension.cpp
-init.cpp
-input.cpp
-output.cpp
-patheffect.cpp
-prefdialog.cpp
-print.cpp
-system.cpp
-timer.cpp
-#${extension_dxf2svg_SRC}
-${extension_implementation_SRC}
-${extension_internal_bitmap_SRC}
-${extension_internal_filter_SRC}
-${extension_internal_pdfinput_SRC}
-${extension_param_SRC}
-${extension_script_SRC}
+set(extension_SRC
+ db.cpp
+ dependency.cpp
+ effect.cpp
+ error-file.cpp
+ execution-env.cpp
+ extension.cpp
+ init.cpp
+ input.cpp
+ output.cpp
+ patheffect.cpp
+ prefdialog.cpp
+ print.cpp
+ system.cpp
+ timer.cpp
+
+ implementation/implementation.cpp
+ implementation/xslt.cpp
+ implementation/script.cpp
+
+ param/bool.cpp
+ param/color.cpp
+ param/description.cpp
+ param/enum.cpp
+ param/float.cpp
+ param/int.cpp
+ param/notebook.cpp
+ param/parameter.cpp
+ param/radiobutton.cpp
+ param/string.cpp
+
+ internal/bluredge.cpp
+ internal/cairo-png-out.cpp
+ internal/cairo-ps-out.cpp
+ internal/cairo-render-context.cpp
+ internal/cairo-renderer.cpp
+ internal/cairo-renderer-pdf-out.cpp
+ internal/emf-win32-inout.cpp
+ internal/emf-win32-print.cpp
+ internal/gdkpixbuf-input.cpp
+ internal/gimpgrad.cpp
+ internal/grid.cpp
+ internal/latex-pstricks.cpp
+ internal/latex-pstricks-out.cpp
+ internal/odf.cpp
+ internal/latex-text-renderer.cpp
+ internal/pdf-input-cairo.cpp
+ internal/pov-out.cpp
+ internal/javafx-out.cpp
+ internal/svg.cpp
+ internal/svgz.cpp
+
+ internal/filter/filter-all.cpp
+ internal/filter/filter-file.cpp
+ internal/filter/filter.cpp
+
+ internal/pdfinput/pdf-input.cpp
+ internal/pdfinput/pdf-parser.cpp
+ internal/pdfinput/svg-builder.cpp
+
+ script/InkscapeScript.cpp
+
+ # dxf2svg/aci2rgb.cpp
+ # dxf2svg/entities2elements.cpp
+ # dxf2svg/tables2svg_info.cpp
+ # dxf2svg/blocks.cpp
+ # dxf2svg/entities.cpp
+ # dxf2svg/tables.cpp
+ # dxf2svg/dxf2svg.cpp
+ # dxf2svg/read_dxf.cpp
+ # dxf2svg/test_dxf.cpp
+
+
+ # ------
+ # Header
+ db.h
+ dependency.h
+ effect.h
+ error-file.h
+ execution-env.h
+ extension.h
+ init.h
+ input.h
+ output.h
+ param/bool.h
+ param/color.h
+ param/description.h
+ param/enum.h
+ param/float.h
+ param/int.h
+ param/notebook.h
+ param/parameter.h
+ param/radiobutton.h
+ param/string.h
+ patheffect.h
+ prefdialog.h
+ print.h
+ system.h
+ timer.h
+
+ implementation/implementation.h
+ implementation/script.h
+ implementation/xslt.h
+
+ internal/bluredge.h
+ internal/cairo-png-out.h
+ internal/cairo-ps-out.h
+ internal/cairo-render-context.h
+ internal/cairo-renderer-pdf-out.h
+ internal/cairo-renderer.h
+ internal/clear-n_.h
+ internal/emf-win32-inout.h
+ internal/emf-win32-print.h
+ internal/filter/bevels.h
+ internal/filter/blurs.h
+ internal/filter/bumps.h
+ internal/filter/color.h
+ internal/filter/distort.h
+ internal/filter/filter.h
+ internal/filter/image.h
+ internal/filter/morphology.h
+ internal/filter/overlays.h
+ internal/filter/paint.h
+ internal/filter/protrusions.h
+ internal/filter/shadows.h
+ internal/filter/textures.h
+ internal/filter/transparency.h
+ internal/gdkpixbuf-input.h
+ internal/gimpgrad.h
+ internal/grid.h
+ internal/javafx-out.h
+ internal/latex-pstricks-out.h
+ internal/latex-pstricks.h
+ internal/latex-text-renderer.h
+ internal/odf.h
+ internal/pdf-input-cairo.h
+ internal/pdfinput/pdf-input.h
+ internal/pdfinput/pdf-parser.h
+ internal/pdfinput/svg-builder.h
+ internal/pov-out.h
+ internal/svg.h
+ internal/svgz.h
+
+ script/InkscapeScript.h
)
-ADD_LIBRARY(extension STATIC ${extension_SRC})
-TARGET_LINK_LIBRARIES(extension
-2geom ${INKSCAPE_LIBS}) \ No newline at end of file
+
+if(WIN32)
+ list(APPEND extension_SRC
+ )
+endif()
+
+if(WITH_LIBWPG)
+ list(APPEND extension_SRC
+ internal/wpg-input.cpp
+ internal/wpg-input.h
+ )
+endif()
+
+if(ImageMagick_FOUND)
+ list(APPEND extension_SRC
+ internal/bitmap/adaptiveThreshold.cpp
+ internal/bitmap/adaptiveThreshold.h
+ internal/bitmap/addNoise.cpp
+ internal/bitmap/addNoise.h
+ internal/bitmap/blur.cpp
+ internal/bitmap/blur.h
+ internal/bitmap/channel.cpp
+ internal/bitmap/channel.h
+ internal/bitmap/charcoal.cpp
+ internal/bitmap/charcoal.h
+ internal/bitmap/colorize.cpp
+ internal/bitmap/colorize.h
+ internal/bitmap/contrast.cpp
+ internal/bitmap/contrast.h
+ internal/bitmap/crop.cpp
+ internal/bitmap/crop.h
+ internal/bitmap/cycleColormap.cpp
+ internal/bitmap/cycleColormap.h
+ internal/bitmap/despeckle.cpp
+ internal/bitmap/despeckle.h
+ internal/bitmap/edge.cpp
+ internal/bitmap/edge.h
+ internal/bitmap/emboss.cpp
+ internal/bitmap/emboss.h
+ internal/bitmap/enhance.cpp
+ internal/bitmap/enhance.h
+ internal/bitmap/equalize.cpp
+ internal/bitmap/equalize.h
+ internal/bitmap/gaussianBlur.cpp
+ internal/bitmap/gaussianBlur.h
+ internal/bitmap/imagemagick.cpp
+ internal/bitmap/imagemagick.h
+ internal/bitmap/implode.cpp
+ internal/bitmap/implode.h
+ internal/bitmap/level.cpp
+ internal/bitmap/level.h
+ internal/bitmap/levelChannel.cpp
+ internal/bitmap/levelChannel.h
+ internal/bitmap/medianFilter.cpp
+ internal/bitmap/medianFilter.h
+ internal/bitmap/modulate.cpp
+ internal/bitmap/modulate.h
+ internal/bitmap/negate.cpp
+ internal/bitmap/negate.h
+ internal/bitmap/normalize.cpp
+ internal/bitmap/normalize.h
+ internal/bitmap/oilPaint.cpp
+ internal/bitmap/oilPaint.h
+ internal/bitmap/opacity.cpp
+ internal/bitmap/opacity.h
+ internal/bitmap/raise.cpp
+ internal/bitmap/raise.h
+ internal/bitmap/reduceNoise.cpp
+ internal/bitmap/reduceNoise.h
+ internal/bitmap/sample.cpp
+ internal/bitmap/sample.h
+ internal/bitmap/shade.cpp
+ internal/bitmap/shade.h
+ internal/bitmap/sharpen.cpp
+ internal/bitmap/sharpen.h
+ internal/bitmap/solarize.cpp
+ internal/bitmap/solarize.h
+ internal/bitmap/spread.cpp
+ internal/bitmap/spread.h
+ internal/bitmap/swirl.cpp
+ internal/bitmap/swirl.h
+ internal/bitmap/threshold.cpp
+ internal/bitmap/threshold.h
+ internal/bitmap/unsharpmask.cpp
+ internal/bitmap/unsharpmask.h
+ internal/bitmap/wave.cpp
+ internal/bitmap/wave.h
+ )
+endif()
+
+if(WITH_DBUS)
+ list(APPEND extension_SRC
+ dbus/application-interface.cpp
+ dbus/dbus-init.cpp
+ dbus/document-interface.cpp
+
+ # ------
+ # Header
+ dbus/application-interface.h
+ dbus/dbus-init.h
+ dbus/document-interface.h
+ dbus/wrapper/inkscape-dbus-wrapper.h
+ )
+
+ include_directories(dbus)
+endif()
+
+# add_inkscape_lib(extension_LIB "${extension_SRC}")
+add_inkscape_source("${extension_SRC}")
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index b9ce224ca..ffcee5f9a 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -24,8 +24,6 @@ ink_common_sources += \
extension/param/color.cpp \
extension/param/description.h \
extension/param/description.cpp \
- extension/param/groupheader.h \
- extension/param/groupheader.cpp \
extension/param/enum.h \
extension/param/enum.cpp \
extension/param/float.h \
diff --git a/src/extension/db.cpp b/src/extension/db.cpp
index 342a18b84..a3c54915d 100644
--- a/src/extension/db.cpp
+++ b/src/extension/db.cpp
@@ -109,7 +109,7 @@ DB::foreach (void (*in_func)(Extension * in_plug, gpointer in_data), gpointer in
{
std::list <Extension *>::iterator cur;
- for (cur = modulelist.begin(); cur != modulelist.end(); cur++) {
+ for (cur = modulelist.begin(); cur != modulelist.end(); ++cur) {
// printf("foreach: %s\n", (*cur)->get_id());
in_func((*cur), in_data);
}
diff --git a/src/extension/db.h b/src/extension/db.h
index bc07c8591..0014f4449 100644
--- a/src/extension/db.h
+++ b/src/extension/db.h
@@ -12,18 +12,24 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#ifndef __MODULES_DB_H__
-#define __MODULES_DB_H__
+#ifndef SEEN_MODULES_DB_H
+#define SEEN_MODULES_DB_H
#include <map>
#include <list>
#include <cstring>
-#include "extension/extension.h"
+#include <glib.h>
+
namespace Inkscape {
namespace Extension {
+class Input;
+class Output;
+class Effect;
+class Extension;
+
class DB {
private:
/** A string comparison function to be used in the moduledict
@@ -74,7 +80,7 @@ extern DB db;
} } /* namespace Extension, Inkscape */
-#endif /* __MODULES_DB_H__ */
+#endif // SEEN_MODULES_DB_H
/*
Local Variables:
diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp
index 9c562d169..1b6baa979 100644
--- a/src/extension/dbus/dbus-init.cpp
+++ b/src/extension/dbus/dbus-init.cpp
@@ -86,7 +86,6 @@ init (void)
GError *error = NULL;
DBusGConnection *connection;
DBusGProxy *proxy;
- DocumentInterface *obj;
connection = dbus_get_connection();
proxy = dbus_get_proxy(connection);
org_freedesktop_DBus_request_name (proxy,
@@ -102,8 +101,6 @@ init (void)
gchar *
init_document (void) {
- guint result;
- GError *error = NULL;
DBusGConnection *connection;
DBusGProxy *proxy;
SPDocument *doc;
@@ -150,7 +147,7 @@ dbus_init_desktop_interface (SPDesktop * dt)
&dbus_glib_document_interface_object_info, name.c_str());
obj->desk = dt;
obj->updates = TRUE;
-
+ dt->dbus_document_interface=obj;
return strdup(name.c_str());
}
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index 0e5d8de50..47e02afc8 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -17,7 +17,7 @@
#include "document-interface.h"
#include <string.h>
-
+#include <dbus/dbus-glib.h>
#include "desktop-handles.h" //sp_desktop_document()
#include "desktop-style.h" //sp_desktop_get_style
#include "display/canvas-text.h" //text
@@ -35,12 +35,46 @@
#include "selection.h" //selection struct
#include "sp-ellipse.h"
#include "sp-object.h"
+#include "sp-root.h"
#include "style.h" //style_write
+
+#include "file.h" //IO
+
+#include "extension/system.h" //IO
+
+#include "extension/output.h" //IO
+
+#include "print.h" //IO
+
+#include "live_effects/parameter/text.h" //text
+#include "display/canvas-text.h" //text
+
+#include "display/sp-canvas.h" //text
+#include "text-editing.h"
#include "verbs.h"
#include "xml/repr.h" //sp_repr_document_new
//#include "2geom/svg-path-parser.h" //get_node_coordinates
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+#if 0
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+#endif
+
+ enum
+ {
+ OBJECT_MOVED_SIGNAL,
+ LAST_SIGNAL
+ };
+
+ static guint signals[LAST_SIGNAL] = { 0 };
+
+
/****************************************************************************
HELPER / SHORTCUT FUNCTIONS
****************************************************************************/
@@ -61,13 +95,13 @@ get_repr_by_name (SPDesktop *desk, gchar *name, GError **error)
/* ALTERNATIVE (is this faster if only repr is needed?)
Inkscape::XML::Node *node = sp_repr_lookup_name((doc->root)->repr, name);
*/
- Inkscape::XML::Node * node = sp_desktop_document(desk)->getObjectById(name)->getRepr();
- if (!node)
+ SPObject * obj = sp_desktop_document(desk)->getObjectById(name);
+ if (!obj)
{
g_set_error(error, INKSCAPE_ERROR, INKSCAPE_ERROR_OBJECT, "Object '%s' not found in document.", name);
return NULL;
}
- return node;
+ return obj->getRepr();
}
/*
@@ -123,16 +157,14 @@ desktop_ensure_active (SPDesktop* desk) {
gdouble
selection_get_center_x (Inkscape::Selection *sel){
- NRRect *box = g_new(NRRect, 1);;
- box = sel->boundsInDocument(box);
- return box->x0 + ((box->x1 - box->x0)/2);
+ Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX);
+ return box ? box->midpoint()[Geom::X] : 0;
}
gdouble
selection_get_center_y (Inkscape::Selection *sel){
- NRRect *box = g_new(NRRect, 1);;
- box = sel->boundsInDocument(box);
- return box->y0 + ((box->y1 - box->y0)/2);
+ Geom::OptRect box = sel->documentBounds(SPItem::GEOMETRIC_BBOX);
+ return box ? box->midpoint()[Geom::X] : 0;
}
/*
@@ -188,8 +220,7 @@ dbus_create_node (SPDesktop *desk, const gchar *type)
* There is probably a better way to do this (use the shape tools default styles)
* but I'm not sure how.
*/
-gchar *
-finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::Node *newNode, gchar *desc)
+gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc)
{
SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE);
@@ -204,11 +235,11 @@ finish_create_shape (DocumentInterface *object, GError **error, Inkscape::XML::N
object->desk->currentLayer()->appendChildRepr(newNode);
object->desk->currentLayer()->updateRepr();
- if (object->updates)
-
- Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc);
- //else
+ if (object->updates) {
+ Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)desc);
+ //} else {
//document_interface_pause_updates(object, error);
+ }
return strdup(newNode->attribute("id"));
}
@@ -266,12 +297,20 @@ document_interface_class_init (DocumentInterfaceClass *klass)
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = document_interface_finalize;
+ signals[OBJECT_MOVED_SIGNAL] =
+ g_signal_new ("object_moved",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
}
static void
document_interface_init (DocumentInterface *object)
{
- object->desk = NULL;
+ object->desk = NULL;
}
@@ -298,37 +337,34 @@ inkscape_error_quark (void)
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-GType
-inkscape_error_get_type (void)
+GType inkscape_error_get_type(void)
{
- static GType etype = 0;
+ static GType etype = 0;
- if (etype == 0)
- {
- static const GEnumValue values[] =
- {
+ if (etype == 0) {
+ static const GEnumValue values[] =
+ {
- ENUM_ENTRY (INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"),
- ENUM_ENTRY (INKSCAPE_ERROR_OBJECT, "Incompatible_Object"),
- ENUM_ENTRY (INKSCAPE_ERROR_VERB, "Failed_Verb"),
- ENUM_ENTRY (INKSCAPE_ERROR_OTHER, "Generic_Error"),
- { 0, 0, 0 }
- };
+ ENUM_ENTRY(INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"),
+ ENUM_ENTRY(INKSCAPE_ERROR_OBJECT, "Incompatible_Object"),
+ ENUM_ENTRY(INKSCAPE_ERROR_VERB, "Failed_Verb"),
+ ENUM_ENTRY(INKSCAPE_ERROR_OTHER, "Generic_Error"),
+ { 0, 0, 0 }
+ };
- etype = g_enum_register_static ("InkscapeError", values);
- }
+ etype = g_enum_register_static("InkscapeError", values);
+ }
- return etype;
+ return etype;
}
/****************************************************************************
MISC FUNCTIONS
****************************************************************************/
-gboolean
-document_interface_delete_all (DocumentInterface *object, GError **error)
+gboolean document_interface_delete_all(DocumentInterface *object, GError ** /*error*/)
{
- sp_edit_clear_all (object->desk);
+ sp_edit_clear_all(object->desk);
return TRUE;
}
@@ -346,6 +382,7 @@ document_interface_call_verb (DocumentInterface *object, gchar *verbid, GError *
if (object->updates) {
Inkscape::DocumentUndo::done(sp_desktop_document(desk2), verb->get_code(), g_strdup(verb->get_tip()));
}
+ return TRUE;
}
}
}
@@ -470,17 +507,20 @@ document_interface_spiral (DocumentInterface *object, int cx, int cy,
return retval;
}
-gboolean
+gchar*
document_interface_text (DocumentInterface *object, int x, int y, gchar *text, GError **error)
{
- //FIXME: Not selectable (aka broken). Needs to be rewritten completely.
- SPDesktop *desktop = object->desk;
- SPCanvasText * canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
- sp_canvastext_set_text (canvas_text, text);
- sp_canvastext_set_coords (canvas_text, x, y);
+ Inkscape::XML::Node *text_node = dbus_create_node(object->desk, "svg:text");
+ sp_repr_set_int(text_node, "x", x);
+ sp_repr_set_int(text_node, "y", y);
+ //just a workaround so i can get an spitem from the name
+ gchar *name = finish_create_shape (object, error, text_node, (gchar *)"create text");
+
+ SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+ sp_te_set_repr_text_multiline(text_obj, text);
- return TRUE;
+ return name;
}
gchar *
@@ -505,7 +545,7 @@ document_interface_image (DocumentInterface *object, int x, int y, gchar *filena
return strdup(newNode->attribute("id"));
}
-gchar *document_interface_node (DocumentInterface *object, gchar *type, GError **error)
+gchar *document_interface_node(DocumentInterface *object, gchar *type, GError ** /*error*/)
{
SPDocument * doc = sp_desktop_document (object->desk);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
@@ -515,10 +555,11 @@ gchar *document_interface_node (DocumentInterface *object, gchar *type, GError *
object->desk->currentLayer()->appendChildRepr(newNode);
object->desk->currentLayer()->updateRepr();
- if (object->updates)
+ if (object->updates) {
Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), 0, (gchar *)"created empty node");
- //else
+ //} else {
//document_interface_pause_updates(object, error);
+ }
return strdup(newNode->attribute("id"));
}
@@ -538,26 +579,23 @@ document_interface_document_get_height (DocumentInterface *object)
return sp_desktop_document(object->desk)->getHeight();
}
-gchar *
-document_interface_document_get_css (DocumentInterface *object, GError **error)
+gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/)
{
SPCSSAttr *current = (object->desk)->current;
return sp_repr_css_write_string(current);
}
-gboolean
-document_interface_document_merge_css (DocumentInterface *object,
- gchar *stylestring, GError **error)
+gboolean document_interface_document_merge_css(DocumentInterface *object,
+ gchar *stylestring, GError ** /*error*/)
{
SPCSSAttr * style = sp_repr_css_attr_new();
- sp_repr_css_attr_add_from_string (style, stylestring);
- sp_desktop_set_style (object->desk, style);
+ sp_repr_css_attr_add_from_string(style, stylestring);
+ sp_desktop_set_style(object->desk, style);
return TRUE;
}
-gboolean
-document_interface_document_set_css (DocumentInterface *object,
- gchar *stylestring, GError **error)
+gboolean document_interface_document_set_css(DocumentInterface *object,
+ gchar *stylestring, GError ** /*error*/)
{
SPCSSAttr * style = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string (style, stylestring);
@@ -574,6 +612,44 @@ document_interface_document_resize_to_fit_selection (DocumentInterface *object,
return TRUE;
}
+gboolean
+document_interface_document_set_display_area (DocumentInterface *object,
+ double x0,
+ double y0,
+ double x1,
+ double y1,
+ double border,
+ GError **error)
+{
+ object->desk->set_display_area (x0,
+ y0,
+ x1,
+ y1,
+ border, false);
+ return TRUE;
+}
+
+
+GArray *
+document_interface_document_get_display_area (DocumentInterface *object)
+{
+ Geom::Rect const d = object->desk->get_display_area();
+
+ GArray * dArr = g_array_new (TRUE, TRUE, sizeof(double));
+
+ double x0 = d.min()[Geom::X];
+ double y0 = d.min()[Geom::Y];
+ double x1 = d.max()[Geom::X];
+ double y1 = d.max()[Geom::Y];
+ g_array_append_val (dArr, x0); //
+ g_array_append_val (dArr, y0);
+ g_array_append_val (dArr, x1);
+ g_array_append_val (dArr, y1);
+ return dArr;
+
+}
+
+
/****************************************************************************
OBJECT FUNCTIONS
****************************************************************************/
@@ -790,8 +866,7 @@ document_interface_move_to_layer (DocumentInterface *object, gchar *shape,
return TRUE;
}
-GArray *
-document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape)
+GArray *document_interface_get_node_coordinates(DocumentInterface * /*object*/, gchar * /*shape*/)
{
//FIXME: Needs lot's of work.
/*
@@ -809,6 +884,49 @@ document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape
}
+gboolean
+document_interface_set_text (DocumentInterface *object, gchar *name, gchar *text, GError **error)
+{
+
+ SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+ //TODO verify object type
+ if (!text_obj)
+ return FALSE;
+ sp_te_set_repr_text_multiline(text_obj, text);
+ return TRUE;
+
+}
+
+
+
+gboolean
+document_interface_text_apply_style (DocumentInterface *object, gchar *name,
+ int start_pos, int end_pos, gchar *style, gchar *styleval,
+ GError **error)
+{
+
+ SPItem* text_obj=(SPItem* )get_object_by_name(object->desk, name, error);
+
+ //void sp_te_apply_style(SPItem *text, Inkscape::Text::Layout::iterator const &start, Inkscape::Text::Layout::iterator const &end, SPCSSAttr const *css)
+ //TODO verify object type
+ if (!text_obj)
+ return FALSE;
+ Inkscape::Text::Layout const *layout = te_get_layout(text_obj);
+ Inkscape::Text::Layout::iterator start = layout->charIndexToIterator (start_pos);
+ Inkscape::Text::Layout::iterator end = layout->charIndexToIterator (end_pos);
+
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property(css, style, styleval);
+
+ sp_te_apply_style(text_obj,
+ start,
+ end,
+ css);
+ return TRUE;
+
+}
+
+
/****************************************************************************
FILE I/O FUNCTIONS
****************************************************************************/
@@ -823,18 +941,31 @@ document_interface_save (DocumentInterface *object, GError **error)
return FALSE;
}
-gboolean
-document_interface_load (DocumentInterface *object,
- gchar *filename, GError **error)
+gboolean document_interface_load(DocumentInterface *object,
+ gchar *filename, GError ** /*error*/)
{
- desktop_ensure_active (object->desk);
+ desktop_ensure_active(object->desk);
const Glib::ustring file(filename);
sp_file_open(file, NULL, TRUE, TRUE);
- if (object->updates)
+ if (object->updates) {
Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_FILE_OPEN, "Opened File");
+ }
return TRUE;
}
+gchar *
+document_interface_import (DocumentInterface *object,
+ gchar *filename, GError **error)
+{
+ desktop_ensure_active (object->desk);
+ const Glib::ustring file(filename);
+ SPDocument * doc = sp_desktop_document(object->desk);
+
+ SPObject *new_obj = NULL;
+ new_obj = file_import(doc, file, NULL);
+ return strdup(new_obj->getRepr()->attribute("id"));
+}
+
gboolean
document_interface_save_as (DocumentInterface *object,
const gchar *filename, GError **error)
@@ -844,8 +975,9 @@ document_interface_save_as (DocumentInterface *object,
const Glib::ustring file(filename);
return file_save_remote(doc, file, NULL, TRUE, TRUE);
#endif
- if (!doc || strlen(filename)<1) //Safety check
+ if (!doc || strlen(filename)<1) { //Safety check
return false;
+ }
try {
Inkscape::Extension::save(NULL, doc, filename,
@@ -860,12 +992,12 @@ document_interface_save_as (DocumentInterface *object,
return true;
}
-gboolean
-document_interface_mark_as_unmodified (DocumentInterface *object, GError **error)
+gboolean document_interface_mark_as_unmodified(DocumentInterface *object, GError ** /*error*/)
{
SPDocument * doc = sp_desktop_document(object->desk);
- if (doc)
+ if (doc) {
doc->modified_since_save = FALSE;
+ }
return TRUE;
}
@@ -916,8 +1048,7 @@ document_interface_redo (DocumentInterface *object, GError **error)
Need to make sure it plays well with verbs because they are used so much.
****************************************************************************/
-void
-document_interface_pause_updates (DocumentInterface *object, GError **error)
+void document_interface_pause_updates(DocumentInterface *object, GError ** /*error*/)
{
object->updates = FALSE;
object->desk->canvas->drawing_disabled = 1;
@@ -927,8 +1058,7 @@ document_interface_pause_updates (DocumentInterface *object, GError **error)
//sp_desktop_document(object->desk)->root->mflags = FALSE;
}
-void
-document_interface_resume_updates (DocumentInterface *object, GError **error)
+void document_interface_resume_updates(DocumentInterface *object, GError ** /*error*/)
{
object->updates = TRUE;
object->desk->canvas->drawing_disabled = 0;
@@ -941,16 +1071,15 @@ document_interface_resume_updates (DocumentInterface *object, GError **error)
Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
}
-void
-document_interface_update (DocumentInterface *object, GError **error)
+void document_interface_update(DocumentInterface *object, GError ** /*error*/)
{
- sp_desktop_document(object->desk)->root->uflags = TRUE;
- sp_desktop_document(object->desk)->root->mflags = TRUE;
+ sp_desktop_document(object->desk)->getRoot()->uflags = TRUE;
+ sp_desktop_document(object->desk)->getRoot()->mflags = TRUE;
object->desk->enableInteraction();
sp_desktop_document(object->desk)->_updateDocument();
object->desk->disableInteraction();
- sp_desktop_document(object->desk)->root->uflags = FALSE;
- sp_desktop_document(object->desk)->root->mflags = FALSE;
+ sp_desktop_document(object->desk)->getRoot()->uflags = FALSE;
+ sp_desktop_document(object->desk)->getRoot()->mflags = FALSE;
//Inkscape::DocumentUndo::done(sp_desktop_document(object->desk), SP_VERB_CONTEXT_RECT, "Multiple actions");
}
@@ -958,8 +1087,7 @@ document_interface_update (DocumentInterface *object, GError **error)
SELECTION FUNCTIONS FIXME: use call_verb where appropriate (once update system is tested.)
****************************************************************************/
-gboolean
-document_interface_selection_get (DocumentInterface *object, char ***out, GError **error)
+gboolean document_interface_selection_get(DocumentInterface *object, char ***out, GError ** /*error*/)
{
Inkscape::Selection * sel = sp_desktop_selection(object->desk);
GSList const *oldsel = sel->list();
@@ -1002,10 +1130,9 @@ document_interface_selection_add_list (DocumentInterface *object,
return TRUE;
}
-gboolean
-document_interface_selection_set (DocumentInterface *object, char *name, GError **error)
+gboolean document_interface_selection_set(DocumentInterface *object, char *name, GError ** /*error*/)
{
- SPDocument * doc = sp_desktop_document (object->desk);
+ SPDocument * doc = sp_desktop_document(object->desk);
Inkscape::Selection *selection = sp_desktop_selection(object->desk);
selection->set(doc->getObjectById(name));
return TRUE;
@@ -1023,8 +1150,7 @@ document_interface_selection_set_list (DocumentInterface *object,
return TRUE;
}
-gboolean
-document_interface_selection_rotate (DocumentInterface *object, int angle, GError **error)
+gboolean document_interface_selection_rotate(DocumentInterface *object, int angle, GError ** /*error*/)
{
Inkscape::Selection *selection = sp_desktop_selection(object->desk);
sp_selection_rotate(selection, angle);
@@ -1038,8 +1164,7 @@ document_interface_selection_delete (DocumentInterface *object, GError **error)
return dbus_call_verb (object, SP_VERB_EDIT_DELETE, error);
}
-gboolean
-document_interface_selection_clear (DocumentInterface *object, GError **error)
+gboolean document_interface_selection_clear(DocumentInterface *object, GError ** /*error*/)
{
sp_desktop_selection(object->desk)->clear();
return TRUE;
@@ -1060,10 +1185,9 @@ document_interface_select_all_in_all_layers(DocumentInterface *object,
return dbus_call_verb (object, SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS, error);
}
-gboolean
-document_interface_selection_box (DocumentInterface *object, int x, int y,
- int x2, int y2, gboolean replace,
- GError **error)
+gboolean document_interface_selection_box(DocumentInterface * /*object*/, int /*x*/, int /*y*/,
+ int /*x2*/, int /*y2*/, gboolean /*replace*/,
+ GError ** /*error*/)
{
//FIXME: implement.
return FALSE;
@@ -1124,8 +1248,7 @@ document_interface_selection_paste (DocumentInterface *object, GError **error)
return dbus_call_verb (object, SP_VERB_EDIT_PASTE, error);
}
-gboolean
-document_interface_selection_scale (DocumentInterface *object, gdouble grow, GError **error)
+gboolean document_interface_selection_scale(DocumentInterface *object, gdouble grow, GError ** /*error*/)
{
Inkscape::Selection *selection = sp_desktop_selection(object->desk);
if (!selection)
@@ -1136,19 +1259,17 @@ document_interface_selection_scale (DocumentInterface *object, gdouble grow, GEr
return TRUE;
}
-gboolean
-document_interface_selection_move (DocumentInterface *object, gdouble x, gdouble y, GError **error)
+gboolean document_interface_selection_move(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/)
{
- sp_selection_move (object->desk, x, 0 - y); //switching coordinate systems.
+ sp_selection_move(object->desk, x, 0 - y); //switching coordinate systems.
return TRUE;
}
-gboolean
-document_interface_selection_move_to (DocumentInterface *object, gdouble x, gdouble y, GError **error)
+gboolean document_interface_selection_move_to(DocumentInterface *object, gdouble x, gdouble y, GError ** /*error*/)
{
Inkscape::Selection * sel = sp_desktop_selection(object->desk);
- Geom::OptRect sel_bbox = sel->bounds();
+ Geom::OptRect sel_bbox = sel->visualBounds();
if (sel_bbox) {
Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) );
sp_selection_move_relative(sel, m, true);
@@ -1260,13 +1381,12 @@ document_interface_selection_change_level (DocumentInterface *object, gchar *cmd
LAYER FUNCTIONS
****************************************************************************/
-gchar *
-document_interface_layer_new (DocumentInterface *object, GError **error)
+gchar *document_interface_layer_new(DocumentInterface *object, GError ** /*error*/)
{
SPDesktop * dt = object->desk;
SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), Inkscape::LPOS_BELOW);
dt->setCurrentLayer(new_layer);
- return g_strdup(get_name_from_object (new_layer));
+ return g_strdup(get_name_from_object(new_layer));
}
gboolean
@@ -1282,8 +1402,7 @@ document_interface_layer_set (DocumentInterface *object,
return TRUE;
}
-gchar **
-document_interface_layer_get_all (DocumentInterface *object)
+gchar **document_interface_layer_get_all(DocumentInterface * /*object*/)
{
//FIXME: implement.
return NULL;
@@ -1317,7 +1436,79 @@ document_interface_layer_previous (DocumentInterface *object, GError **error)
}
+//////////////signals
+
+
+DocumentInterface *fugly;
+gboolean dbus_send_ping (SPDesktop* desk, SPItem *item)
+{
+ //DocumentInterface *obj;
+ if (!item) return TRUE;
+ g_signal_emit (desk->dbus_document_interface, signals[OBJECT_MOVED_SIGNAL], 0, item->getId());
+ return TRUE;
+}
+
+//////////tree
+
+
+gboolean
+document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error)
+{
+ SPItem* parent=(SPItem* )get_object_by_name(object->desk, name, error);
+
+ GSList const *children = parent->childList(false);
+
+ int size = g_slist_length((GSList *) children);
+
+ *out = g_new0 (char *, size + 1);
+
+ int i = 0;
+ for (GSList const *iter = children; iter != NULL; iter = iter->next) {
+ (*out)[i] = g_strdup(SP_OBJECT(iter->data)->getRepr()->attribute("id"));
+ i++;
+ }
+ (*out)[i] = NULL;
+
+ return TRUE;
+
+}
+
+gchar*
+document_interface_get_parent (DocumentInterface *object, char *name, GError **error)
+{
+ SPItem* node=(SPItem* )get_object_by_name(object->desk, name, error);
+
+ SPObject* parent=node->parent;
+ return g_strdup(parent->getRepr()->attribute("id"));
+}
+#if 0
+//just pseudo code
+gboolean
+document_interface_get_xpath (DocumentInterface *object, char *xpath_expression, char ***out, GError **error){
+ SPDocument * doc = sp_desktop_document (object->desk);
+ Inkscape::XML::Document *repr = doc->getReprDoc();
+
+ xmlXPathObjectPtr xpathObj;
+ xmlXPathContextPtr xpathCtx;
+ xpathCtx = xmlXPathNewContext(repr);//XmlDocPtr
+ xpathObj = xmlXPathEvalExpression(xmlCharStrdup(xpath_expression), xpathCtx);
+
+ //xpathresult result = xpatheval(repr, xpath_selection);
+ //convert resut to a string array we can return via dbus
+ return TRUE;
+}
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
index 12e033918..e7e55cb7d 100644
--- a/src/extension/dbus/document-interface.h
+++ b/src/extension/dbus/document-interface.h
@@ -115,10 +115,17 @@ gchar*
document_interface_line (DocumentInterface *object, int x, int y,
int x2, int y2, GError **error);
-gboolean
+gchar*
document_interface_text (DocumentInterface *object, int x, int y,
gchar *text, GError **error);
-
+gboolean
+document_interface_set_text (DocumentInterface *object, gchar *name,
+ gchar *text, GError **error);
+gboolean
+document_interface_text_apply_style (DocumentInterface *object, gchar *name,
+ int start_pos, int end_pos, gchar *style, gchar *styleval,
+ GError **error);
+
gchar *
document_interface_image (DocumentInterface *object, int x, int y,
gchar *filename, GError **error);
@@ -151,6 +158,16 @@ document_interface_document_set_css (DocumentInterface *object,
gboolean
document_interface_document_resize_to_fit_selection (DocumentInterface *object,
GError **error);
+gboolean
+document_interface_document_set_display_area (DocumentInterface *object,
+ double x0,
+ double y0,
+ double x1,
+ double y1,
+ double border,
+ GError **error);
+GArray *
+document_interface_document_get_display_area (DocumentInterface *object);
/****************************************************************************
OBJECT FUNCTIONS
@@ -401,6 +418,18 @@ document_interface_layer_previous (DocumentInterface *object, GError **error);
DocumentInterface *document_interface_new (void);
GType document_interface_get_type (void);
+extern DocumentInterface *fugly;
+gboolean dbus_send_ping (SPDesktop* desk, SPItem *item);
+
+gboolean
+document_interface_get_children (DocumentInterface *object, char *name, char ***out, GError **error);
+
+gchar*
+document_interface_get_parent (DocumentInterface *object, char *name, GError **error);
+
+gchar*
+document_interface_import (DocumentInterface *object,
+ gchar *filename, GError **error);
G_END_DECLS
diff --git a/src/extension/dbus/document-interface.xml b/src/extension/dbus/document-interface.xml
index 8b0252765..aeacfae44 100644
--- a/src/extension/dbus/document-interface.xml
+++ b/src/extension/dbus/document-interface.xml
@@ -310,6 +310,12 @@
<doc:summary>The text you want.</doc:summary>
</doc:doc>
</arg>
+ <arg type="s" name="object_name" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>The name of the new text.</doc:summary>
+ </doc:doc>
+ </arg>
<doc:doc>
<doc:description>
<doc:para>This method creates some text in the current layer.</doc:para>
@@ -346,6 +352,27 @@
</doc:doc>
</method>
+ <method name="import">
+ <arg type="s" name="pathname" direction="in" >
+ <doc:doc>
+ <doc:summary>The path to a valid svg file.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="s" name="object_name" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>The name of the new image.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Imports the file at pathname. Similar to the image
+ method.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+
<method name="node">
<arg type="s" name="svgtype" direction="in" >
<doc:doc>
@@ -447,6 +474,56 @@
</doc:doc>
</method>
+
+
+ <method name="document_set_display_area">
+ <arg type="d" name="x0" direction="in" >
+ <doc:doc>
+ <doc:summary></doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="d" name="y0" direction="in" >
+ <doc:doc>
+ <doc:summary></doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="d" name="x1" direction="in" >
+ <doc:doc>
+ <doc:summary></doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="d" name="y1" direction="in" >
+ <doc:doc>
+ <doc:summary></doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="d" name="border" direction="in" >
+ <doc:doc>
+ <doc:summary></doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Set display area.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+ <method name="document_get_display_area">
+ <doc:doc>
+ <doc:description>
+ <doc:para>Get display area.</doc:para>
+ </doc:description>
+ </doc:doc>
+ <arg type="ad" name="area" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
+ <doc:doc>
+ <doc:summary>area</doc:summary>
+ </doc:doc>
+ </arg>
+ </method>
+
+
<!-- OBJECT FUNCTIONS -->
<method name="set_attribute">
@@ -472,6 +549,66 @@
</doc:doc>
</method>
+
+ <method name="set_text">
+ <arg type="s" name="shape" direction="in" >
+ <doc:doc>
+ <doc:summary>The id of an object.</doc:summary>
+ </doc:doc>
+ </arg>
+
+ <arg type="s" name="text" direction="in" >
+ <doc:doc>
+ <doc:summary>The text you want.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>set text of text object.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+
+ <method name="text_apply_style">
+ <arg type="s" name="shape" direction="in" >
+ <doc:doc>
+ <doc:summary>The id of an object.</doc:summary>
+ </doc:doc>
+ </arg>
+
+ <arg type="i" name="start" direction="in" >
+ <doc:doc>
+ <doc:summary>start text pos.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="i" name="end" direction="in" >
+ <doc:doc>
+ <doc:summary>end text pos.</doc:summary>
+ </doc:doc>
+ </arg>
+
+ <arg type="s" name="css_attrib" direction="in" >
+ <doc:doc>
+ <doc:summary>css attribute.</doc:summary>
+ </doc:doc>
+ </arg>
+
+ <arg type="s" name="css_attrib_val" direction="in" >
+ <doc:doc>
+ <doc:summary>css attribute value.</doc:summary>
+ </doc:doc>
+ </arg>
+
+
+ <doc:doc>
+ <doc:description>
+ <doc:para>set styling of partial text object.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+
+
<method name="set_int_attribute">
<arg type="s" name="shape" direction="in" >
<doc:doc>
@@ -835,6 +972,9 @@
</doc:description>
</doc:doc>
</method>
+
+
+
<!--
<method name="print_to_file" >
<doc:doc>
@@ -1350,6 +1490,56 @@
</doc:doc>
</method>
+<!-- signals -->
+ <signal name="ObjectMoved">
+ <arg name="object_name" type="s">
+ <doc:doc>
+ <doc:summary>The id of the object.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Emitted when an object has been moved.</doc:para>
+ </doc:description>
+ </doc:doc>
+ </signal>
+<!-- tree -->
+
+ <method name="get_children" >
+ <arg type="s" name="type" direction="in" >
+ <doc:doc>
+ <doc:summary>Any node with an "id" attribute.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="as" name="parentid" direction="out" >
+ <doc:doc>
+ <doc:summary>The ids of this nodes children, NULL if bottom level.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Returns the children of any node. This function along with <doc:ref type="method" to="get_parent">get_parent()</doc:ref> can be used to navigate the XML tree. </doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
+ <method name="get_parent" >
+ <arg type="s" name="type" direction="in" >
+ <doc:doc>
+ <doc:summary>Any node with an "id" attribute.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="s" name="parentid" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>The id of this nodes parent, NULL if toplevel.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Returns the parent of any node. This function along with <doc:ref type="method" to="get_children">get_children()</doc:ref> can be used to navigate the XML tree. </doc:para>
+ </doc:description>
+ </doc:doc>
+ </method>
- </interface>
+</interface>
</node>
diff --git a/src/extension/dbus/proposed-interface.xml b/src/extension/dbus/proposed-interface.xml
index c281aff96..ac74b64f9 100644
--- a/src/extension/dbus/proposed-interface.xml
+++ b/src/extension/dbus/proposed-interface.xml
@@ -40,19 +40,6 @@
</doc:doc>
</signal>
- <signal name="ObjectMoved">
- <arg name="object_name" type="s">
- <doc:doc>
- <doc:summary>The id of the object.</doc:summary>
- </doc:doc>
- </arg>
- <doc:doc>
- <doc:description>
- <doc:para>Emitted when an object has been moved.</doc:para>
- </doc:description>
- </doc:doc>
- </signal>
-
<signal name="ObjectStyleModified">
<arg name="object_name" type="s">
<doc:doc>
@@ -136,43 +123,6 @@
<!-- USE document-subset.h FILES -->
- <method name="get_parent" >
- <arg type="s" name="type" direction="in" >
- <doc:doc>
- <doc:summary>Any node with an "id" attribute.</doc:summary>
- </doc:doc>
- </arg>
- <arg type="s" name="parentid" direction="out" >
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
- <doc:doc>
- <doc:summary>The id of this nodes parent, NULL if toplevel.</doc:summary>
- </doc:doc>
- </arg>
- <doc:doc>
- <doc:description>
- <doc:para>Returns the parent of any node. This function along with <doc:ref type="method" to="proposed.get_children">get_children()</doc:ref> can be used to navigate the XML tree. In proposed because I think it might confuse users who don't know about the SVG tree structure. In the main API I have de-emphasized nodes and required no knowledge of internal representation.</doc:para>
- </doc:description>
- </doc:doc>
- </method>
-
- <method name="get_children" >
- <arg type="s" name="type" direction="in" >
- <doc:doc>
- <doc:summary>Any node with an "id" attribute.</doc:summary>
- </doc:doc>
- </arg>
- <arg type="as" name="parentid" direction="out" >
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
- <doc:doc>
- <doc:summary>The ids of this nodes children, NULL if bottom level.</doc:summary>
- </doc:doc>
- </arg>
- <doc:doc>
- <doc:description>
- <doc:para>Returns the children of any node. This function along with <doc:ref type="method" to="proposed.get_parent">get_parent()</doc:ref> can be used to navigate the XML tree. In proposed because I think it might confuse users who don't know about the SVG tree structure. In the main API I have de-emphasized nodes and required no knowledge of internal representation.</doc:para>
- </doc:description>
- </doc:doc>
- </method>
<method name="selection_remove">
<arg type="s" name="name" direction="in" >
diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
index b59ee746b..7a33d4f38 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.c
@@ -198,11 +198,13 @@ inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const g
}
//static
-gboolean
+char *
inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error)
{
+ char * OUT_object_name;
DBusGProxy *proxy = doc->proxy;
- return org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, error);
+ org_inkscape_document_text (proxy, IN_x, IN_y, IN_text, &OUT_object_name, error);
+ return OUT_object_name;
}
//static
diff --git a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
index c314bf6f8..684f1b142 100644
--- a/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
+++ b/src/extension/dbus/wrapper/inkscape-dbus-wrapper.h
@@ -72,7 +72,7 @@ char *
inkscape_line (DocumentInterface *doc, const gint IN_x, const gint IN_y, const gint IN_x2, const gint IN_y2, GError **error);
//static
-gboolean
+char *
inkscape_text (DocumentInterface *doc, const gint IN_x, const gint IN_y, const char * IN_text, GError **error);
//static
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index a83cac88d..01c3e129a 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -17,6 +17,7 @@
#include "path-prefix.h"
#include "dependency.h"
#include "db.h"
+#include "extension.h"
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/dxf2svg/CMakeLists.txt b/src/extension/dxf2svg/CMakeLists.txt
deleted file mode 100644
index b755d7f44..000000000
--- a/src/extension/dxf2svg/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-SET(extension_dxf2svg_SRC
-#aci2rgb.cpp
-#entities2elements.cpp
-#tables2svg_info.cpp
-#blocks.cpp
-#entities.cpp
-#tables.cpp
-#dxf2svg.cpp
-#read_dxf.cpp
-#test_dxf.cpp
-)
diff --git a/src/extension/dxf2svg/blocks.cpp b/src/extension/dxf2svg/blocks.cpp
index 75f348bde..36f2b9e7e 100644
--- a/src/extension/dxf2svg/blocks.cpp
+++ b/src/extension/dxf2svg/blocks.cpp
@@ -39,13 +39,8 @@ void block::block_info( std::vector< dxfpair > info){
}
-
-
-
-
blocks::blocks(std::vector< std::vector< dxfpair > > sections){
// Read the main information about the entities section and then put it in the enetites class
- int value;
char string[10000];
std::vector< dxfpair > single_line;
std::vector< std::vector< dxfpair > > ents;
diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp
index d0d33503e..c94df06f3 100644
--- a/src/extension/dxf2svg/entities.cpp
+++ b/src/extension/dxf2svg/entities.cpp
@@ -398,8 +398,8 @@ lwpolyline::lwpolyline( std::vector< dxfpair > section ){
}
// Now put on the last data that was found
- if (others.size() > 0 ){
- sections.push_back( others );
+ if (!others.empty()){
+ sections.push_back(others);
}
reset_extents();
diff --git a/src/extension/dxf2svg/read_dxf.cpp b/src/extension/dxf2svg/read_dxf.cpp
index ecda343c6..1a4eefbc9 100644
--- a/src/extension/dxf2svg/read_dxf.cpp
+++ b/src/extension/dxf2svg/read_dxf.cpp
@@ -261,7 +261,7 @@ std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > sec
}
}
// Because putting the data on outer depends on find a GC=0 the last bit of data may be left behind so it inner has data in it put it on outer
- if ( inner.size() > 0 ){
+ if (!inner.empty()){
outer.push_back( inner );
inner.clear();
}
diff --git a/src/extension/dxf2svg/tables2svg_info.cpp b/src/extension/dxf2svg/tables2svg_info.cpp
index 3b27a9c38..c59060306 100644
--- a/src/extension/dxf2svg/tables2svg_info.cpp
+++ b/src/extension/dxf2svg/tables2svg_info.cpp
@@ -22,7 +22,7 @@ char* pattern2dasharray(ltype info, int precision, double scaling, char* out){
char *out_ptr;
- if (pattern.size() > 0){
+ if (!pattern.empty()){
strcat(out," stroke-dasharray=\"");
for(int i = 0; i < pattern.size()-1;i++){
strcat(out,gcvt(scaling*sqrt(pow(pattern[i],2)),precision,temp) );
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index 51aa42da6..4f87e98cd 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -296,18 +296,20 @@ Effect::effect (Inkscape::UI::View::View * doc)
void
Effect::set_last_effect (Effect * in_effect)
{
- gchar const * verb_id = in_effect->get_verb()->get_id();
- gchar const * help_id_prefix = "org.inkscape.help.";
-
- // We don't want these "effects" to register as the last effect,
- // this wouldn't be helpful to the user who selects a real effect,
- // then goes to the help file (implemented as an effect), then goes
- // back to the effect, only to see it written over by the help file
- // selection.
-
- // This snippet should fix this bug:
- // https://bugs.launchpad.net/inkscape/+bug/600671
- if (strncmp(verb_id, help_id_prefix, strlen(help_id_prefix)) == 0) return;
+ if (in_effect) {
+ gchar const * verb_id = in_effect->get_verb()->get_id();
+ gchar const * help_id_prefix = "org.inkscape.help.";
+
+ // We don't want these "effects" to register as the last effect,
+ // this wouldn't be helpful to the user who selects a real effect,
+ // then goes to the help file (implemented as an effect), then goes
+ // back to the effect, only to see it written over by the help file
+ // selection.
+
+ // This snippet should fix this bug:
+ // https://bugs.launchpad.net/inkscape/+bug/600671
+ if (strncmp(verb_id, help_id_prefix, strlen(help_id_prefix)) == 0) return;
+ }
if (in_effect == NULL) {
Inkscape::Verb::get(SP_VERB_EFFECT_LAST)->sensitive(NULL, false);
@@ -324,7 +326,7 @@ Effect::set_last_effect (Effect * in_effect)
Inkscape::XML::Node *
Effect::find_menu (Inkscape::XML::Node * menustruct, const gchar *name)
{
- if (menustruct == NULL) return false;
+ if (menustruct == NULL) return NULL;
for (Inkscape::XML::Node * child = menustruct;
child != NULL;
child = child->next()) {
@@ -355,21 +357,15 @@ Effect::set_pref_dialog (PrefDialog * prefdialog)
return;
}
-/** \brief Create an action for a \c EffectVerb
- \param view Which view the action should be created for
- \return The built action.
-
- Calls \c make_action_helper with the \c vector.
-*/
SPAction *
Effect::EffectVerb::make_action (Inkscape::UI::View::View * view)
{
- return make_action_helper(view, &vector, static_cast<void *>(this));
+ return make_action_helper(view, &perform, static_cast<void *>(this));
}
/** \brief Decode the verb code and take appropriate action */
void
-Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ )
+Effect::EffectVerb::perform( SPAction *action, void * data )
{
Inkscape::UI::View::View * current_view = sp_action_get_view(action);
// SPDocument * current_document = current_view->doc;
@@ -388,14 +384,6 @@ Effect::EffectVerb::perform( SPAction *action, void * data, void */*pdata*/ )
return;
}
-/**
- * Action vector to define functions called if a staticly defined file verb
- * is called.
- */
-SPActionEventVector Effect::EffectVerb::vector =
- {{NULL}, Effect::EffectVerb::perform, NULL, NULL, NULL, NULL};
-
-
} } /* namespace Inkscape, Extension */
/*
diff --git a/src/extension/effect.h b/src/extension/effect.h
index c02ce542b..83b5cc036 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -15,7 +15,7 @@
#include <glibmm/i18n.h>
#include <gtkmm/dialog.h>
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
#include "verbs.h"
#include "prefdialog.h"
@@ -24,11 +24,7 @@
struct SPDocument;
namespace Inkscape {
-namespace UI {
-namespace View {
-typedef View View;
-};
-};
+
namespace Extension {
@@ -53,9 +49,7 @@ class Effect : public Extension {
back to the effect that created it. */
class EffectVerb : public Inkscape::Verb {
private:
- static void perform (SPAction * action, void * mydata, void * otherdata);
- /** \brief Function to call for specific actions */
- static SPActionEventVector vector;
+ static void perform (SPAction * action, void * mydata);
/** \brief The effect that this verb represents. */
Effect * _effect;
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index f9e099c26..646caa36a 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -128,7 +128,7 @@ ExecutionEnv::createWorkingDialog (void) {
SPDesktop *desktop = (SPDesktop *)_doc;
GtkWidget *toplevel = gtk_widget_get_toplevel(&(desktop->canvas->widget));
- if (!toplevel || !GTK_WIDGET_TOPLEVEL (toplevel))
+ if (!toplevel || !gtk_widget_is_toplevel (toplevel))
return;
Gtk::Window *window = Glib::wrap(GTK_WINDOW(toplevel), false);
@@ -141,7 +141,10 @@ ExecutionEnv::createWorkingDialog (void) {
true); // modal
_visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::workingCanceled));
g_free(dlgmessage);
- _visibleDialog->show();
+
+ if (!_effect->is_silent()){
+ _visibleDialog->show();
+ }
return;
}
@@ -190,7 +193,7 @@ ExecutionEnv::reselect (void) {
Inkscape::Selection * selection = sp_desktop_selection(desktop);
- for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); i++) {
+ for (std::list<Glib::ustring>::iterator i = _selected.begin(); i != _selected.end(); ++i) {
SPObject * obj = doc->getObjectById(i->c_str());
if (obj != NULL) {
selection->add(obj);
diff --git a/src/extension/execution-env.h b/src/extension/execution-env.h
index c2d4e7e4a..92f496b90 100644
--- a/src/extension/execution-env.h
+++ b/src/extension/execution-env.h
@@ -17,13 +17,25 @@
#include <gtkmm/dialog.h>
-#include "forward.h"
-#include "extension-forward.h"
#include "extension.h"
namespace Inkscape {
+
+namespace UI {
+namespace View {
+class View;
+} // namespace View
+} // namespace UI
+
namespace Extension {
+class Effect;
+
+namespace Implementation
+{
+class ImplementationDocumentCache;
+}
+
class ExecutionEnv {
private:
enum state_t {
diff --git a/src/extension/extension-forward.h b/src/extension/extension-forward.h
deleted file mode 100644
index d836c29ab..000000000
--- a/src/extension/extension-forward.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef SEEN_EXTENSION_FORWARD_H
-#define SEEN_EXTENSION_FORWARD_H
-
-namespace Inkscape {
-namespace Extension {
-
-class Effect;
-class Extension;
-class Input;
-class Output;
-class Print;
-
-class Dependency;
-class Parameter;
-class ExpirationTimer;
-
-namespace Implementation {
-class Implementation;
-class ImplementationDocumentCache;
-}
-
-} }
-
-#endif /* !SEEN_EXTENSION_FORWARD_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/extension.cpp b/src/extension/extension.cpp
index e67a4b95f..f0b266df0 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -1,4 +1,3 @@
-#define __SP_MODULE_C__
/** \file
*
* Inkscape::Extension::Extension:
@@ -30,6 +29,7 @@
#include "inkscape.h"
#include "extension/implementation/implementation.h"
+#include "extension.h"
#include "db.h"
#include "dependency.h"
@@ -44,8 +44,6 @@ namespace Extension {
std::vector<const gchar *> Extension::search_path;
std::ofstream Extension::error_file;
-Parameter * get_param (const gchar * name);
-
/**
\return none
\brief Constructs an Extension from a Inkscape::XML::Node
@@ -59,6 +57,7 @@ Parameter * get_param (const gchar * name);
*/
Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp)
: _help(NULL)
+ , silent(false)
, _gui(true)
{
repr = in_repr;
@@ -105,6 +104,9 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat
if (!strcmp(chname, "dependency")) {
_deps.push_back(new Dependency(child_repr));
} /* dependency */
+ if (!strcmp(chname, "options")) {
+ silent = !strcmp( child_repr->attribute("silent"), "true" );
+ }
child_repr = sp_repr_next(child_repr);
}
@@ -310,6 +312,16 @@ Extension::get_repr (void)
}
/**
+ \return bool
+ \brief Whether this extension should hide the "working, please wait" dialog
+*/
+bool
+Extension::is_silent (void)
+{
+ return silent;
+}
+
+/**
\return The textual id of this extension
\brief Get the ID of this extension - not a copy don't delete!
*/
@@ -367,26 +379,7 @@ Extension::deactivated (void)
return get_state() == STATE_DEACTIVATED;
}
-/**
- \return Parameter structure with a name of 'name'
- \brief This function looks through the linked list for a parameter
- structure with the name of the passed in name
- \param name The name to search for
-
- This is an inline function that is used by all the get_param and
- set_param functions to find a param_t in the linked list with
- the passed in name.
-
- This function can throw a 'param_not_exist' exception if the
- name is not found.
-
- The first thing that this function checks is if the list is NULL.
- It could be NULL because there are no parameters for this extension
- or because all of them have been checked. If the list
- is NULL then the 'param_not_exist' exception is thrown.
-*/
-Parameter *
-Extension::get_param (const gchar * name)
+Parameter *Extension::get_param(gchar const *name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -413,22 +406,14 @@ g_slist_next(list)) {
throw Extension::param_not_exist();
}
-/**
- \return A constant pointer to the string held by the parameters.
- \brief Gets a parameter identified by name with the string placed
- in value. It isn't duplicated into the value string.
- \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
+Parameter const *Extension::get_param(const gchar * name) const
+{
+ return const_cast<Extension *>(this)->get_param(name);
+}
- Look up in the parameters list, then execute the function on that
- found parameter.
-*/
-const gchar *
-Extension::get_param_string (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
+gchar const *Extension::get_param_string(gchar const *name, SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- Parameter * param;
- param = get_param(name);
+ Parameter const *param = get_param(name);
return param->get_string(doc, node);
}
diff --git a/src/extension/extension.h b/src/extension/extension.h
index 936d2a907..13cb409a8 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -1,5 +1,5 @@
-#ifndef __INK_EXTENSION_H__
-#define __INK_EXTENSION_H__
+#ifndef INK_EXTENSION_H
+#define INK_EXTENSION_H
/** \file
* Frontend to certain, possibly pluggable, actions.
@@ -22,7 +22,6 @@
#include <gtkmm/table.h>
#include <glibmm/ustring.h>
#include "xml/repr.h"
-#include "extension/extension-forward.h"
/** The key that is used to identify that the I/O should be autodetected */
#define SP_MODULE_KEY_AUTODETECT "autodetect"
@@ -51,15 +50,6 @@
#define SP_MODULE_KEY_PRINT_LATEX "org.inkscape.print.latex"
/** Defines the key for printing with GNOME Print */
#define SP_MODULE_KEY_PRINT_GNOME "org.inkscape.print.gnome"
-/** Defines the key for printing under Win32 */
-#define SP_MODULE_KEY_PRINT_WIN32 "org.inkscape.print.win32"
-#ifdef WIN32
-/** Defines the default printing to use */
-#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_WIN32
-#else
-/** Defines the default printing to use */
-#define SP_MODULE_KEY_PRINT_DEFAULT SP_MODULE_KEY_PRINT_PS
-#endif
/** Mime type for SVG */
#define MIME_SVG "image/svg+xml"
@@ -77,6 +67,17 @@ struct SPDocument;
namespace Inkscape {
namespace Extension {
+class Dependency;
+class ExpirationTimer;
+class ExpirationTimer;
+class Parameter;
+
+namespace Implementation
+{
+class Implementation;
+}
+
+
/** The object that is the basis for the Extension system. This object
contains all of the information that all Extension have. The
individual items are detailed within. This is the interface that
@@ -99,6 +100,7 @@ private:
state_t _state; /**< Which state the Extension is currently in */
std::vector<Dependency *> _deps; /**< Dependencies for this extension */
static std::ofstream error_file; /**< This is the place where errors get reported */
+ bool silent;
bool _gui;
protected:
@@ -120,6 +122,7 @@ public:
gchar * get_name (void);
/** \brief Gets the help string for this extension */
gchar const * get_help (void) { return _help; }
+ bool is_silent (void);
void deactivate (void);
bool deactivated (void);
void printFailure (Glib::ustring reason);
@@ -170,7 +173,28 @@ public:
private:
void make_param (Inkscape::XML::Node * paramrepr);
- Parameter * get_param (const gchar * name);
+ /**
+ * This function looks through the linked list for a parameter
+ * structure with the name of the passed in name.
+ *
+ * This is an inline function that is used by all the get_param and
+ * set_param functions to find a param_t in the linked list with
+ * the passed in name.
+ *
+ * This function can throw a 'param_not_exist' exception if the
+ * name is not found.
+ *
+ * The first thing that this function checks is if the list is NULL.
+ * It could be NULL because there are no parameters for this extension
+ * or because all of them have been checked. If the list
+ * is NULL then the 'param_not_exist' exception is thrown.
+ *
+ * @param name The name to search for.
+ * @return Parameter structure with a name of 'name'.
+ */
+ Parameter *get_param(const gchar * name);
+
+ Parameter const *get_param(const gchar * name) const;
public:
bool get_param_bool (const gchar * name,
@@ -185,9 +209,19 @@ public:
const SPDocument * doc = NULL,
const Inkscape::XML::Node * node = NULL);
- const gchar * get_param_string (const gchar * name,
- const SPDocument * doc = NULL,
- const Inkscape::XML::Node * node = NULL);
+ /**
+ * Gets a parameter identified by name with the string placed in value.
+ * It isn't duplicated into the value string. Look up in the parameters list,
+ * then execute the function on that found parameter.
+ *
+ * @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.
+ * @return A constant pointer to the string held by the parameters.
+ */
+ gchar const *get_param_string(gchar const *name,
+ SPDocument const *doc = NULL,
+ Inkscape::XML::Node const *node = NULL) const;
guint32 get_param_color (const gchar * name,
const SPDocument * doc = NULL,
@@ -276,7 +310,7 @@ public:
} /* namespace Extension */
} /* namespace Inkscape */
-#endif /* __INK_EXTENSION_H__ */
+#endif // INK_EXTENSION_H
/*
Local Variables:
diff --git a/src/extension/implementation/CMakeLists.txt b/src/extension/implementation/CMakeLists.txt
deleted file mode 100644
index 87e1b2541..000000000
--- a/src/extension/implementation/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(extension_implementation_SRC
-implementation.cpp
-xslt.cpp
-script.cpp
-)
diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp
index 63181d0c4..6f6bddb93 100644
--- a/src/extension/implementation/implementation.cpp
+++ b/src/extension/implementation/implementation.cpp
@@ -29,72 +29,15 @@ namespace Inkscape {
namespace Extension {
namespace Implementation {
-/**
- * \return Was the load sucessful?
- * \brief This function is the stub load. It just returns success.
- * \param module The Extension that should be loaded.
- */
-bool
-Implementation::load(Inkscape::Extension::Extension */*module*/) {
- return TRUE;
-} /* Implementation::load */
-
-void
-Implementation::unload(Inkscape::Extension::Extension */*module*/) {
- return;
-} /* Implementation::unload */
-
-/** \brief Create a new document cache object
- \param ext The extension that is referencing us
- \param doc The document to create the cache of
- \return A new document cache that is valid as long as the document
- is not changed.
-
- This function just returns \c NULL. Subclasses are likely
- to reimplement it to do something useful.
-*/
-ImplementationDocumentCache *
-Implementation::newDocCache( Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*view*/ ) {
- return NULL;
-}
-
-bool
-Implementation::check(Inkscape::Extension::Extension */*module*/) {
- /* If there are no checks, they all pass */
- return TRUE;
-} /* Implemenation::check */
-
-bool
-Implementation::cancelProcessing (void) {
- return true;
-}
-
-void
-Implementation::commitDocument (void) {
- return;
-}
-
Gtk::Widget *
Implementation::prefs_input(Inkscape::Extension::Input *module, gchar const */*filename*/) {
return module->autogui(NULL, NULL);
-} /* Implementation::prefs_input */
-
-SPDocument *
-Implementation::open(Inkscape::Extension::Input */*module*/, gchar const */*filename*/) {
- /* throw open_failed(); */
- return NULL;
-} /* Implementation::open */
+}
Gtk::Widget *
Implementation::prefs_output(Inkscape::Extension::Output *module) {
return module->autogui(NULL, NULL);
-} /* Implementation::prefs_output */
-
-void
-Implementation::save(Inkscape::Extension::Output */*module*/, SPDocument */*doc*/, gchar const */*filename*/) {
- /* throw save_fail */
- return;
-} /* Implementation::save */
+}
Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * /*docCache*/)
{
@@ -117,119 +60,6 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I
return module->autogui(current_document, const_cast<Inkscape::XML::Node *>(first_select), changeSignal);
} // Implementation::prefs_effect
-void
-Implementation::effect(Inkscape::Extension::Effect */*module*/, Inkscape::UI::View::View */*document*/, ImplementationDocumentCache * /*docCache*/) {
- /* throw filter_fail */
- return;
-} /* Implementation::filter */
-
-unsigned int
-Implementation::setup(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::set_preview(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-
-unsigned int
-Implementation::begin(Inkscape::Extension::Print */*module*/, SPDocument */*doc*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::finish(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-
-/* Rendering methods */
-unsigned int
-Implementation::bind(Inkscape::Extension::Print */*module*/, Geom::Affine const */*transform*/, float /*opacity*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::release(Inkscape::Extension::Print */*module*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::comment(Inkscape::Extension::Print */*module*/, char const */*comment*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::fill(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*ctm*/, SPStyle const */*style*/,
- NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::stroke(Inkscape::Extension::Print */*module*/, Geom::PathVector const &/*pathv*/, Geom::Affine const */*transform*/, SPStyle const */*style*/,
- NRRect const */*pbox*/, NRRect const */*dbox*/, NRRect const */*bbox*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::image(Inkscape::Extension::Print */*module*/, unsigned char */*px*/, unsigned int /*w*/, unsigned int /*h*/, unsigned int /*rs*/,
- Geom::Affine const */*transform*/, SPStyle const */*style*/)
-{
- return 0;
-}
-
-unsigned int
-Implementation::text(Inkscape::Extension::Print */*module*/, char const */*text*/,
- Geom::Point /*p*/, SPStyle const */*style*/)
-{
- return 0;
-}
-
-void
-Implementation::processPath(Inkscape::XML::Node * /*node*/)
-{
- return;
-}
-
-/**
- \brief Tell the printing engine whether text should be text or path
- \retval true Render the text as a path
- \retval false Render text using the text function (above)
-
- Default value is false because most printing engines will support
- paths more than they'll support text. (at least they do today)
-*/
-bool
-Implementation::textToPath(Inkscape::Extension::Print */*ext*/)
-{
- return false;
-}
-
-/**
- \brief Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded
- \retval TRUE Fonts have to be embedded in the output so that the user might not need to install fonts to have the interpreter read the document correctly
- \retval FALSE Not embed fonts
-
- Only available for Adobe Type 1 fonts in EPS output as of now
-*/
-
-bool
-Implementation::fontEmbedded(Inkscape::Extension::Print * /*ext*/)
-{
- return false;
-}
-
} /* namespace Implementation */
} /* namespace Extension */
} /* namespace Inkscape */
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index bf584b401..32cc37402 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -9,27 +9,46 @@
important for implementing the extensions themselves. This file
contains the base class for all of that.
*/
-#ifndef __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
-#define __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
+#ifndef SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
+#define SEEN_INKSCAPE_EXTENSION_IMPLEMENTATION_H
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
#include <gdkmm/types.h>
#include <gtkmm/widget.h>
-#include "forward.h"
-#include "extension/extension-forward.h"
-#include "libnr/nr-forward.h"
-#include "libnr/nr-point.h"
#include "xml/node.h"
#include <2geom/forward.h>
+#include <2geom/point.h>
+
+class SPDocument;
+class SPStyle;
namespace Inkscape {
+
+namespace UI {
+namespace View {
+class View;
+} // namespace View
+} // namespace UI
+
namespace Extension {
+
+class Effect;
+class Extension;
+class Input;
+class Output;
+class Print;
+
namespace Implementation {
-/** \brief A cache for the document and this implementation */
+/**
+ * A cache for the document and this implementation.
+ */
class ImplementationDocumentCache {
- /** \brief The document that this instance is working on */
+
+ /**
+ * The document that this instance is working on.
+ */
Inkscape::UI::View::View * _view;
public:
ImplementationDocumentCache (Inkscape::UI::View::View * view) :
@@ -48,96 +67,122 @@ public:
*/
class Implementation {
public:
- /* ----- Constructor / destructor ----- */
+ // ----- Constructor / destructor -----
Implementation() {}
virtual ~Implementation() {}
- /* ----- Basic functions for all Extension ----- */
- virtual bool load(Inkscape::Extension::Extension *module);
+ // ----- Basic functions for all Extension -----
+ virtual bool load(Inkscape::Extension::Extension * /*module*/) { return true; }
- virtual void unload(Inkscape::Extension::Extension *module);
- virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc);
+ virtual void unload(Inkscape::Extension::Extension * /*module*/) {}
+
+ /**
+ * Create a new document cache object.
+ * This function just returns \c NULL. Subclasses are likely
+ * to reimplement it to do something useful.
+ * @param ext The extension that is referencing us
+ * @param doc The document to create the cache of
+ * @return A new document cache that is valid as long as the document
+ * is not changed.
+ */
+ virtual ImplementationDocumentCache * newDocCache (Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * /*doc*/) { return NULL; }
/** Verify any dependencies. */
- virtual bool check(Inkscape::Extension::Extension *module);
+ virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
- virtual bool cancelProcessing (void);
- virtual void commitDocument (void);
+ virtual bool cancelProcessing () { return true; }
+ virtual void commitDocument () {}
- /* ----- Input functions ----- */
+ // ----- Input functions -----
/** Find out information about the file. */
virtual Gtk::Widget *prefs_input(Inkscape::Extension::Input *module,
gchar const *filename);
- virtual SPDocument *open(Inkscape::Extension::Input *module,
- gchar const *filename);
+ virtual SPDocument *open(Inkscape::Extension::Input * /*module*/,
+ gchar const * /*filename*/) { return NULL; }
- /* ----- Output functions ----- */
+ // ----- Output functions -----
/** Find out information about the file. */
virtual Gtk::Widget *prefs_output(Inkscape::Extension::Output *module);
- virtual void save(Inkscape::Extension::Output *module, SPDocument *doc, gchar const *filename);
+ virtual void save(Inkscape::Extension::Output * /*module*/, SPDocument * /*doc*/, gchar const * /*filename*/) {}
- /* ----- Effect functions ----- */
+ // ----- Effect functions -----
/** Find out information about the file. */
virtual Gtk::Widget * prefs_effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View * view,
- sigc::signal<void> * changeSignal,
- ImplementationDocumentCache * docCache);
- virtual void effect(Inkscape::Extension::Effect *module,
- Inkscape::UI::View::View *document,
- ImplementationDocumentCache * docCache);
-
- /* ----- Print functions ----- */
- virtual unsigned setup(Inkscape::Extension::Print *module);
- virtual unsigned set_preview(Inkscape::Extension::Print *module);
-
- virtual unsigned begin(Inkscape::Extension::Print *module,
- SPDocument *doc);
- virtual unsigned finish(Inkscape::Extension::Print *module);
- virtual bool textToPath(Inkscape::Extension::Print *ext);
- virtual bool fontEmbedded(Inkscape::Extension::Print * ext);
-
- /* ----- Rendering methods ----- */
- virtual unsigned bind(Inkscape::Extension::Print *module,
- Geom::Affine const *transform,
- float opacity);
- virtual unsigned release(Inkscape::Extension::Print *module);
- virtual unsigned comment(Inkscape::Extension::Print *module, const char * comment);
- virtual unsigned fill(Inkscape::Extension::Print *module,
- Geom::PathVector const &pathv,
- Geom::Affine const *ctm,
- SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
- virtual unsigned stroke(Inkscape::Extension::Print *module,
- Geom::PathVector const &pathv,
- Geom::Affine const *transform,
- SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
- virtual unsigned image(Inkscape::Extension::Print *module,
- unsigned char *px,
- unsigned int w,
- unsigned int h,
- unsigned int rs,
- Geom::Affine const *transform,
- SPStyle const *style);
- virtual unsigned text(Inkscape::Extension::Print *module,
- char const *text,
- Geom::Point p,
- SPStyle const *style);
- virtual void processPath(Inkscape::XML::Node * node);
+ Inkscape::UI::View::View *view,
+ sigc::signal<void> *changeSignal,
+ ImplementationDocumentCache *docCache);
+ virtual void effect(Inkscape::Extension::Effect * /*module*/,
+ Inkscape::UI::View::View * /*document*/,
+ ImplementationDocumentCache * /*docCache*/) {}
+
+ // ----- Print functions -----
+ virtual unsigned setup(Inkscape::Extension::Print * /*module*/) { return 0; }
+ virtual unsigned set_preview(Inkscape::Extension::Print * /*module*/) { return 0; }
+
+ virtual unsigned begin(Inkscape::Extension::Print * /*module*/,
+ SPDocument * /*doc*/) { return 0; }
+ virtual unsigned finish(Inkscape::Extension::Print * /*module*/) { return 0; }
+
+ /**
+ * Tell the printing engine whether text should be text or path.
+ * Default value is false because most printing engines will support
+ * paths more than they'll support text. (at least they do today)
+ * \retval true Render the text as a path
+ * \retval false Render text using the text function (above)
+ */
+ virtual bool textToPath(Inkscape::Extension::Print * /*ext*/) { return false; }
+
+ /**
+ * Get "fontEmbedded" param, i.e. tell the printing engine whether fonts should be embedded.
+ * Only available for Adobe Type 1 fonts in EPS output as of now
+ * \retval true Fonts have to be embedded in the output so that the user might not need
+ * to install fonts to have the interpreter read the document correctly
+ * \retval false Do not embed fonts
+ */
+ virtual bool fontEmbedded(Inkscape::Extension::Print * /*ext*/) { return false; }
+
+ // ----- Rendering methods -----
+ virtual unsigned bind(Inkscape::Extension::Print * /*module*/,
+ Geom::Affine const & /*transform*/,
+ float /*opacity*/) { return 0; }
+ virtual unsigned release(Inkscape::Extension::Print * /*module*/) { return 0; }
+ virtual unsigned comment(Inkscape::Extension::Print * /*module*/, char const * /*comment*/) { return 0; }
+ virtual unsigned fill(Inkscape::Extension::Print * /*module*/,
+ Geom::PathVector const & /*pathv*/,
+ Geom::Affine const & /*ctm*/,
+ SPStyle const * /*style*/,
+ Geom::OptRect const & /*pbox*/,
+ Geom::OptRect const & /*dbox*/,
+ Geom::OptRect const & /*bbox*/) { return 0; }
+ virtual unsigned stroke(Inkscape::Extension::Print * /*module*/,
+ Geom::PathVector const & /*pathv*/,
+ Geom::Affine const & /*transform*/,
+ SPStyle const * /*style*/,
+ Geom::OptRect const & /*pbox*/,
+ Geom::OptRect const & /*dbox*/,
+ Geom::OptRect const & /*bbox*/) { return 0; }
+ virtual unsigned image(Inkscape::Extension::Print * /*module*/,
+ unsigned char * /*px*/,
+ unsigned int /*w*/,
+ unsigned int /*h*/,
+ unsigned int /*rs*/,
+ Geom::Affine const & /*transform*/,
+ SPStyle const * /*style*/) { return 0; }
+ virtual unsigned text(Inkscape::Extension::Print * /*module*/,
+ char const * /*text*/,
+ Geom::Point const & /*p*/,
+ SPStyle const * /*style*/) { return 0; }
+ virtual void processPath(Inkscape::XML::Node * /*node*/) {}
};
-} /* namespace Implementation */
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Implementation
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INKSCAPE_EXTENSION_IMPLEMENTATION_H__ */
+#endif // __INKSCAPE_EXTENSION_IMPLEMENTATION_H__
/*
Local Variables:
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 2f3e2cd65..0a0282284 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -149,7 +149,8 @@ std::string Script::resolveInterpreterExecutable(const Glib::ustring &interpName
of memory in the unloaded state.
*/
Script::Script() :
- Implementation()
+ Implementation(),
+ _canceled(false)
{
}
@@ -177,8 +178,7 @@ Script::~Script()
string. This means that the caller of this function can always
free what they are given (and should do it too!).
*/
-std::string
-Script::solve_reldir(Inkscape::XML::Node *reprin) {
+std::string Script::solve_reldir(Inkscape::XML::Node *reprin) {
gchar const *s = reprin->attribute("reldir");
@@ -361,8 +361,7 @@ void Script::unload(Inkscape::Extension::Extension */*module*/)
\param module The Extension in question
*/
-bool
-Script::check(Inkscape::Extension::Extension *module)
+bool Script::check(Inkscape::Extension::Extension *module)
{
int script_count = 0;
Inkscape::XML::Node *child_repr = sp_repr_children(module->get_repr());
@@ -729,8 +728,26 @@ void Script::effect(Inkscape::Extension::Effect *module,
doc->doc()->emitReconstructionStart();
copy_doc(doc->doc()->rroot, mydoc->rroot);
doc->doc()->emitReconstructionFinish();
- mydoc->release();
+ SPObject *layer = NULL;
+ SPObject *obj = mydoc->getObjectById("base");
+
+ // Getting the named view from the document generated by the extension
+ SPNamedView *nv = (SPNamedView *) obj;
+
+ //Check if it has a default layer set up
+ if ( nv != NULL and nv->default_layer_id != 0 ) {
+ SPDocument *document = desktop->doc();
+ //If so, get that layer
+ layer = document->getObjectById(g_quark_to_string(nv->default_layer_id));
+ }
+
sp_namedview_update_layers_from_document(desktop);
+ //If that layer exists,
+ if (layer) {
+ //set the current layer
+ desktop->setCurrentLayer(layer);
+ }
+ mydoc->release();
}
return;
@@ -803,7 +820,7 @@ void Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newr
}
// Delete the attributes of the old root nodes.
- for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); it++) {
+ for (std::vector<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); ++it) {
oldroot->setAttribute(*it, NULL);
}
@@ -954,7 +971,7 @@ int Script::execute (const std::list<std::string> &in_command,
NULL, // STDIN
&stdout_pipe, // STDOUT
&stderr_pipe); // STDERR
- } catch (Glib::Error e) {
+ } catch (Glib::Error &e) {
printf("Can't Spawn!!! spawn returns: %s\n", e.what().data());
return 0;
}
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 230d4b50f..064a59700 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -26,7 +26,6 @@
#include "db.h"
#include "internal/svgz.h"
#ifdef WIN32
-# include "internal/win32.h"
# include "internal/emf-win32-inout.h"
# include "internal/emf-win32-print.h"
#endif
@@ -67,6 +66,7 @@
#include "internal/bitmap/charcoal.h"
#include "internal/bitmap/colorize.h"
#include "internal/bitmap/contrast.h"
+#include "internal/bitmap/crop.h"
#include "internal/bitmap/cycleColormap.h"
#include "internal/bitmap/despeckle.h"
#include "internal/bitmap/edge.h"
@@ -171,7 +171,6 @@ init()
}
#endif
#ifdef WIN32
- Internal::PrintWin32::init();
Internal::PrintEmfWin32::init();
Internal::EmfWin32::init();
#endif
@@ -202,6 +201,7 @@ init()
Internal::Bitmap::Charcoal::init();
Internal::Bitmap::Colorize::init();
Internal::Bitmap::Contrast::init();
+ Internal::Bitmap::Crop::init();
Internal::Bitmap::CycleColormap::init();
Internal::Bitmap::Edge::init();
Internal::Bitmap::Despeckle::init();
diff --git a/src/extension/input.h b/src/extension/input.h
index 24cbc4896..8b198495e 100644
--- a/src/extension/input.h
+++ b/src/extension/input.h
@@ -16,7 +16,7 @@
#include "extension.h"
#include "xml/repr.h"
#include "document.h"
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/internal/CMakeLists.txt b/src/extension/internal/CMakeLists.txt
deleted file mode 100644
index 8b23cb0ac..000000000
--- a/src/extension/internal/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-IF(WIN32)
-SET(EXT_INT_WIN
-win32.cpp
-)
-ENDIF(WIN32)
-
-SET(extension_internal_SRC
-bluredge.cpp
-cairo-png-out.cpp
-cairo-ps-out.cpp
-cairo-render-context.cpp
-cairo-renderer.cpp
-cairo-renderer-pdf-out.cpp
-emf-win32-inout.cpp
-emf-win32-print.cpp
-gdkpixbuf-input.cpp
-gimpgrad.cpp
-grid.cpp
-latex-pstricks.cpp
-latex-pstricks-out.cpp
-odf.cpp
-pdfinput
-latex-text-renderer.cpp
-pdf-input-cairo.cpp
-pov-out.cpp
-javafx-out.cpp
-svg.cpp
-svgz.cpp
-wpg-input.cpp
-${EXT_INT_WIN}
-)
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index 3c1ce7f43..06fa275cb 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -25,6 +25,8 @@ ink_common_sources += \
extension/internal/bitmap/colorize.h \
extension/internal/bitmap/contrast.cpp \
extension/internal/bitmap/contrast.h \
+ extension/internal/bitmap/crop.cpp \
+ extension/internal/bitmap/crop.h \
extension/internal/bitmap/cycleColormap.cpp \
extension/internal/bitmap/cycleColormap.h \
extension/internal/bitmap/despeckle.cpp \
@@ -131,8 +133,6 @@ ink_common_sources += \
extension/internal/filter/filter.h \
extension/internal/filter/drop-shadow.h \
extension/internal/filter/snow.h \
- extension/internal/win32.h \
- extension/internal/win32.cpp \
extension/internal/emf-win32-print.h \
extension/internal/emf-win32-print.cpp \
extension/internal/emf-win32-inout.h \
diff --git a/src/extension/internal/bitmap/CMakeLists.txt b/src/extension/internal/bitmap/CMakeLists.txt
deleted file mode 100644
index 8aec17492..000000000
--- a/src/extension/internal/bitmap/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-SET(extension_internal_bitmap_SRC
-adaptiveThreshold.cpp
-addNoise.cpp
-blur.cpp
-channel.cpp
-charcoal.cpp
-colorize.cpp
-contrast.cpp
-cycleColormap.cpp
-despeckle.cpp
-edge.cpp
-emboss.cpp
-enhance.cpp
-equalize.cpp
-gaussianBlur.cpp
-imagemagick.cpp
-implode.cpp
-levelChannel.cpp
-level.cpp
-medianFilter.cpp
-modulate.cpp
-negate.cpp
-normalize.cpp
-oilPaint.cpp
-opacity.cpp
-raise.cpp
-reduceNoise.cpp
-sample.cpp
-shade.cpp
-sharpen.cpp
-solarize.cpp
-spread.cpp
-swirl.cpp
-threshold.cpp
-unsharpmask.cpp
-wave.cpp
-)
diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp
new file mode 100644
index 000000000..2ad75a0dc
--- /dev/null
+++ b/src/extension/internal/bitmap/crop.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2011 Authors:
+ * Nicolas Dufour <nicoduf@yahoo.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "2geom/transforms.h"
+#include "extension/effect.h"
+#include "extension/system.h"
+
+#include "crop.h"
+#include "selection-chemistry.h"
+#include "sp-item-transform.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+void
+Crop::applyEffect(Magick::Image *image) {
+ int width = image->baseColumns() - (_left + _right);
+ int height = image->baseRows() - (_top + _bottom);
+ if (width > 0 and height > 0) {
+ image->crop(Magick::Geometry(width, height, _left, _top, false, false));
+ image->page("+0+0");
+ }
+}
+
+void
+Crop::postEffect(Magick::Image *image, SPItem *item) {
+
+ // Scale bbox
+ Geom::Scale scale (0,0);
+ scale = Geom::Scale(image->columns() / (double) image->baseColumns(),
+ image->rows() / (double) image->baseRows());
+ sp_item_scale_rel (item, scale);
+
+ // Translate proportionaly to the image/bbox ratio
+ Geom::OptRect bbox(item->desktopGeometricBounds());
+ //g_warning("bbox. W:%f, H:%f, X:%f, Y:%f", bbox->dimensions()[Geom::X], bbox->dimensions()[Geom::Y], bbox->min()[Geom::X], bbox->min()[Geom::Y]);
+
+ Geom::Translate translate (0,0);
+ translate = Geom::Translate(((_left - _right) / 2.0) * (bbox->dimensions()[Geom::X] / (double) image->columns()),
+ ((_bottom - _top) / 2.0) * (bbox->dimensions()[Geom::Y] / (double) image->rows()));
+ sp_item_move_rel(item, translate);
+}
+
+void
+Crop::refreshParameters(Inkscape::Extension::Effect *module) {
+ _top = module->get_param_int("top");
+ _bottom = module->get_param_int("bottom");
+ _left = module->get_param_int("left");
+ _right = module->get_param_int("right");
+}
+
+#include "../clear-n_.h"
+
+void
+Crop::init(void)
+{
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Crop") "</name>\n"
+ "<id>org.inkscape.effect.bitmap.crop</id>\n"
+ "<param name=\"top\" gui-text=\"" N_("Top (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n"
+ "<param name=\"bottom\" gui-text=\"" N_("Bottom (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n"
+ "<param name=\"left\" gui-text=\"" N_("Left (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n"
+ "<param name=\"right\" gui-text=\"" N_("Right (px):") "\" type=\"int\" min=\"0\" max=\"100000\">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_("Crop selected bitmap(s).") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Crop());
+}
+
+}; /* namespace Bitmap */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
diff --git a/src/extension/internal/bitmap/crop.h b/src/extension/internal/bitmap/crop.h
new file mode 100644
index 000000000..ce9b92797
--- /dev/null
+++ b/src/extension/internal/bitmap/crop.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 Authors:
+ * Christopher Brown <audiere@gmail.com>
+ * Ted Gould <ted@gould.cx>
+ * Nicolas Dufour <nicoduf@yahoo.fr>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "imagemagick.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Bitmap {
+
+class Crop : public ImageMagick
+{
+private:
+ int _top;
+ int _bottom;
+ int _left;
+ int _right;
+public:
+ void applyEffect(Magick::Image *image);
+ void postEffect(Magick::Image *image, SPItem *item);
+ 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
index 65968bdc4..a5d27726f 100644
--- a/src/extension/internal/bitmap/imagemagick.cpp
+++ b/src/extension/internal/bitmap/imagemagick.cpp
@@ -34,182 +34,192 @@ namespace Internal {
namespace Bitmap {
class ImageMagickDocCache: public Inkscape::Extension::Implementation::ImplementationDocumentCache {
- friend class ImageMagick;
+ friend class ImageMagick;
private:
- void readImage(char const *xlink, Magick::Image *image);
+ void readImage(char const *xlink, Magick::Image *image);
protected:
- Inkscape::XML::Node** _nodes;
-
- Magick::Image** _images;
- int _imageCount;
- char** _caches;
- unsigned* _cacheLengths;
-
- const char** _originals;
+ Inkscape::XML::Node** _nodes;
+
+ Magick::Image** _images;
+ int _imageCount;
+ char** _caches;
+ unsigned* _cacheLengths;
+ const char** _originals;
+ SPItem** _imageItems;
public:
- ImageMagickDocCache(Inkscape::UI::View::View * view);
- ~ImageMagickDocCache ( );
+ ImageMagickDocCache(Inkscape::UI::View::View * view);
+ ~ImageMagickDocCache ( );
};
ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) :
- Inkscape::Extension::Implementation::ImplementationDocumentCache(view),
- _nodes(NULL),
- _images(NULL),
- _imageCount(0),
- _caches(NULL),
- _cacheLengths(NULL),
- _originals(NULL)
+ Inkscape::Extension::Implementation::ImplementationDocumentCache(view),
+ _nodes(NULL),
+ _images(NULL),
+ _imageCount(0),
+ _caches(NULL),
+ _cacheLengths(NULL),
+ _originals(NULL),
+ _imageItems(NULL)
{
- SPDesktop *desktop = (SPDesktop*)view;
- 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];
- _caches = new char*[selectCount];
- _cacheLengths = new unsigned int[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;
- _caches[_imageCount] = "";
- _cacheLengths[_imageCount] = 0;
- _images[_imageCount] = new Magick::Image();
- readImage(xlink, _images[_imageCount]);
-
- _imageCount++;
- }
- }
+ SPDesktop *desktop = (SPDesktop*)view;
+ const GSList *selectedItemList = desktop->selection->itemList();
+ int selectCount = g_slist_length((GSList *)selectedItemList);
+
+ // Init the data-holders
+ _nodes = new Inkscape::XML::Node*[selectCount];
+ _originals = new const char*[selectCount];
+ _caches = new char*[selectCount];
+ _cacheLengths = new unsigned int[selectCount];
+ _images = new Magick::Image*[selectCount];
+ _imageCount = 0;
+ _imageItems = new SPItem*[selectCount];
+
+ // Loop through selected items
+ for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList))
+ {
+ SPItem *item = SP_ITEM(selectedItemList->data);
+ Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr());
+ if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image"))
+ {
+ _nodes[_imageCount] = node;
+ char const *xlink = node->attribute("xlink:href");
+ _originals[_imageCount] = xlink;
+ _caches[_imageCount] = (char*)"";
+ _cacheLengths[_imageCount] = 0;
+ _images[_imageCount] = new Magick::Image();
+ readImage(xlink, _images[_imageCount]);
+ _imageItems[_imageCount] = item;
+ _imageCount++;
+ }
+ }
}
ImageMagickDocCache::~ImageMagickDocCache ( ) {
- if (_nodes)
- delete _nodes;
- if (_originals)
- delete _originals;
- if (_caches)
- delete _caches;
- if (_cacheLengths)
- delete _cacheLengths;
- if (_images)
- delete _images;
-
- return;
+ if (_nodes)
+ delete _nodes;
+ if (_originals)
+ delete _originals;
+ if (_caches)
+ delete _caches;
+ if (_cacheLengths)
+ delete _cacheLengths;
+ if (_images)
+ delete _images;
+ if (_imageItems)
+ delete _imageItems;
+ return;
}
void
ImageMagickDocCache::readImage(const char *xlink, Magick::Image *image)
{
- // Find if the xlink:href is base64 data, i.e. if the image is embedded
- char *search = (char *) g_strndup(xlink, 30);
- if (strstr(search, "base64") != (char*)NULL) {
- // 7 = strlen("base64") + strlen(",")
- const char* pureBase64 = strstr(xlink, "base64") + 7;
- Magick::Blob blob;
- blob.base64(pureBase64);
- image->read(blob);
- }
- else {
- const gchar *path = xlink;
+ // Find if the xlink:href is base64 data, i.e. if the image is embedded
+ char *search = (char *) g_strndup(xlink, 30);
+ if (strstr(search, "base64") != (char*)NULL) {
+ // 7 = strlen("base64") + strlen(",")
+ const char* pureBase64 = strstr(xlink, "base64") + 7;
+ Magick::Blob blob;
+ blob.base64(pureBase64);
+ image->read(blob);
+ }
+ else {
+ const gchar *path = xlink;
if (strncmp (xlink,"file:", 5) == 0) {
path = g_filename_from_uri(xlink, NULL, NULL);
- }
+ }
- try {
- image->read(path);
- } catch (...) {}
- }
- g_free(search);
+ try {
+ image->read(path);
+ } catch (...) {}
+ }
+ g_free(search);
}
bool
ImageMagick::load(Inkscape::Extension::Extension */*module*/)
{
- return true;
+ return true;
}
Inkscape::Extension::Implementation::ImplementationDocumentCache *
ImageMagick::newDocCache (Inkscape::Extension::Extension * /*ext*/, Inkscape::UI::View::View * view) {
- return new ImageMagickDocCache(view);
+ return new ImageMagickDocCache(view);
}
void
ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache)
{
- refreshParameters(module);
-
- if (docCache == NULL) { // should never happen
- docCache = newDocCache(module, document);
- }
- ImageMagickDocCache * dc = dynamic_cast<ImageMagickDocCache *>(docCache);
- if (dc == NULL) { // should really never happen
- printf("AHHHHHHHHH!!!!!");
- exit(1);
- }
-
- for (int i = 0; i < dc->_imageCount; i++)
- {
- try
- {
- Magick::Image effectedImage = *dc->_images[i]; // make a copy
- applyEffect(&effectedImage);
-
- Magick::Blob *blob = new Magick::Blob();
- effectedImage.write(blob);
-
- std::string raw_string = blob->base64();
- const int raw_len = raw_string.length();
- const char *raw_i = raw_string.c_str();
-
- unsigned new_len = (int)(raw_len * (77.0 / 76.0) + 100);
- if (new_len > dc->_cacheLengths[i]) {
- dc->_cacheLengths[i] = (int)(new_len * 1.2);
- dc->_caches[i] = new char[dc->_cacheLengths[i]];
- }
- char *formatted_i = dc->_caches[i];
- const char *src;
-
- for (src = "data:image/"; *src; )
- *formatted_i++ = *src++;
- for (src = effectedImage.magick().c_str(); *src ; )
- *formatted_i++ = *src++;
- for (src = ";base64, \n" ; *src; )
- *formatted_i++ = *src++;
-
- int col = 0;
- while (*raw_i) {
- *formatted_i++ = *raw_i++;
- if (col++ > 76) {
- *formatted_i++ = '\n';
- col = 0;
- }
- }
- if (col) {
- *formatted_i++ = '\n';
- }
- *formatted_i = '\0';
-
- dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true);
- dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true);
- }
- catch (Magick::Exception &error_) {
- printf("Caught exception: %s \n", error_.what());
- }
-
- //while(Gtk::Main::events_pending()) {
- // Gtk::Main::iteration();
- //}
- }
+ refreshParameters(module);
+
+ if (docCache == NULL) { // should never happen
+ docCache = newDocCache(module, document);
+ }
+ ImageMagickDocCache * dc = dynamic_cast<ImageMagickDocCache *>(docCache);
+ if (dc == NULL) { // should really never happen
+ printf("AHHHHHHHHH!!!!!");
+ exit(1);
+ }
+
+ for (int i = 0; i < dc->_imageCount; i++)
+ {
+ try
+ {
+ Magick::Image effectedImage = *dc->_images[i]; // make a copy
+
+ applyEffect(&effectedImage);
+
+ // postEffect can be used to change things on the item itself
+ // e.g. resize the image element, after the effecti is applied
+ postEffect(&effectedImage, dc->_imageItems[i]);
+
+// dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true);
+
+ Magick::Blob *blob = new Magick::Blob();
+ effectedImage.write(blob);
+
+ std::string raw_string = blob->base64();
+ const int raw_len = raw_string.length();
+ const char *raw_i = raw_string.c_str();
+
+ unsigned new_len = (int)(raw_len * (77.0 / 76.0) + 100);
+ if (new_len > dc->_cacheLengths[i]) {
+ dc->_cacheLengths[i] = (int)(new_len * 1.2);
+ dc->_caches[i] = new char[dc->_cacheLengths[i]];
+ }
+ char *formatted_i = dc->_caches[i];
+ const char *src;
+
+ for (src = "data:image/"; *src; )
+ *formatted_i++ = *src++;
+ for (src = effectedImage.magick().c_str(); *src ; )
+ *formatted_i++ = *src++;
+ for (src = ";base64, \n" ; *src; )
+ *formatted_i++ = *src++;
+
+ int col = 0;
+ while (*raw_i) {
+ *formatted_i++ = *raw_i++;
+ if (col++ > 76) {
+ *formatted_i++ = '\n';
+ col = 0;
+ }
+ }
+ if (col) {
+ *formatted_i++ = '\n';
+ }
+ *formatted_i = '\0';
+
+ dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true);
+ dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true);
+ }
+ catch (Magick::Exception &error_) {
+ printf("Caught exception: %s \n", error_.what());
+ }
+
+ //while(Gtk::Main::events_pending()) {
+ // Gtk::Main::iteration();
+ //}
+ }
}
/** \brief A function to get the prefences for the grid
diff --git a/src/extension/internal/bitmap/imagemagick.h b/src/extension/internal/bitmap/imagemagick.h
index 5b4a1eb21..08b322503 100644
--- a/src/extension/internal/bitmap/imagemagick.h
+++ b/src/extension/internal/bitmap/imagemagick.h
@@ -1,5 +1,5 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__
+#ifndef INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H
+#define INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H
/*
* Copyright (C) 2007 Authors:
@@ -10,11 +10,14 @@
*/
#include "extension/implementation/implementation.h"
-#include "extension/extension-forward.h"
#include <Magick++.h>
namespace Inkscape {
namespace Extension {
+
+class Effect;
+class Extension;
+
namespace Internal {
namespace Bitmap {
@@ -23,6 +26,7 @@ public:
/* Functions to be implemented by subclasses */
virtual void applyEffect(Magick::Image */*image*/) { };
virtual void refreshParameters(Inkscape::Extension::Effect */*module*/) { };
+ virtual void postEffect(Magick::Image */*image*/, SPItem */*item*/) { };
/* Functions implemented from ::Implementation */
bool load(Inkscape::Extension::Extension *module);
@@ -36,4 +40,4 @@ public:
}; /* namespace Extension */
}; /* namespace Inkscape */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H__ */
+#endif // INKSCAPE_EXTENSION_INTERNAL_BITMAP_IMAGEMAGICK_H
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index 8ec09d11e..3d4754adc 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -59,7 +59,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
int steps = module->get_param_int("num-steps");
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0);
+ double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px");
using Inkscape::Util::GSListConstIterator;
// TODO need to properly refcount the items, at least
@@ -68,7 +68,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
selection->clear();
for(std::list<SPItem *>::iterator item = items.begin();
- item != items.end(); item++) {
+ item != items.end(); ++item) {
SPItem * spitem = *item;
std::vector<Inkscape::XML::Node *> new_items(steps);
@@ -97,10 +97,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
if (offset < 0.0) {
/* Doing an inset here folks */
offset *= -1.0;
- prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_INSET)->get_action(desktop), NULL);
} else if (offset > 0.0) {
- prefs->setDouble("/options/defaultoffsetwidth/value", offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", offset, "px");
sp_action_perform(Inkscape::Verb::get(SP_VERB_SELECTION_OFFSET)->get_action(desktop), NULL);
}
@@ -110,7 +110,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
Inkscape::GC::release(new_group);
}
- prefs->setDouble("/options/defaultoffsetwidth/value", old_offset);
+ prefs->setDoubleUnit("/options/defaultoffsetwidth/value", old_offset, "px");
selection->clear();
selection->add(items.begin(), items.end());
diff --git a/src/extension/internal/bluredge.h b/src/extension/internal/bluredge.h
index 48e30c054..d8fe056f7 100644
--- a/src/extension/internal/bluredge.h
+++ b/src/extension/internal/bluredge.h
@@ -7,11 +7,14 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "extension/extension-forward.h"
#include "extension/implementation/implementation.h"
namespace Inkscape {
namespace Extension {
+
+class Effect;
+class Extension;
+
namespace Internal {
/** \brief Implementation class of the GIMP gradient plugin. This mostly
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
index eb26fc581..678a46095 100644
--- a/src/extension/internal/cairo-png-out.cpp
+++ b/src/extension/internal/cairo-png-out.cpp
@@ -27,8 +27,7 @@
#include "extension/print.h"
#include "extension/db.h"
#include "extension/output.h"
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
+#include "display/drawing.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
@@ -43,10 +42,9 @@ namespace Inkscape {
namespace Extension {
namespace Internal {
-bool
-CairoRendererOutput::check (Inkscape::Extension::Extension * module)
+bool CairoRendererOutput::check(Inkscape::Extension::Extension * /*module*/)
{
- return TRUE;
+ return true;
}
static bool
@@ -58,11 +56,11 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
doc->ensureUpToDate();
/* Start */
- /* Create new arena */
- SPItem *base = SP_ITEM(doc->getRoot());
- NRArena *arena = NRArena::create();
+
+ SPItem *base = doc->getRoot();
+ Inkscape::Drawing drawing;
unsigned dkey = SPItem::display_key_new(1);
- NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
renderer = new CairoRenderer();
@@ -77,9 +75,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
}
renderer->destroyContext(ctx);
- /* Release arena */
base->invoke_hide(dkey);
- nr_object_unref((NRObject *) arena);
/* end */
delete renderer;
@@ -93,13 +89,11 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
\param doc Document to be saved
\param uri Filename to save to (probably will end in .png)
*/
-void
-CairoRendererOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filename)
+void CairoRendererOutput::save(Inkscape::Extension::Output * /*mod*/, SPDocument *doc, gchar const *filename)
{
- if (!png_render_document_to_file(doc, filename))
+ if (!png_render_document_to_file(doc, filename)) {
throw Inkscape::Extension::Output::save_failed();
-
- return;
+ }
}
/**
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index a5b7b3237..9cc3a4ce3 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -29,8 +29,7 @@
#include "extension/print.h"
#include "extension/db.h"
#include "extension/output.h"
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
+#include "display/drawing.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
@@ -79,17 +78,16 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
}
else {
// we want to export the entire document from root
- base = SP_ITEM(doc->getRoot());
+ base = doc->getRoot();
pageBoundingBox = !exportDrawing;
}
if (!base)
return false;
- /* Create new arena */
- NRArena *arena = NRArena::create();
+ Inkscape::Drawing drawing;
unsigned dkey = SPItem::display_key_new(1);
- base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
@@ -111,9 +109,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
}
}
- /* Release arena */
base->invoke_hide(dkey);
- nr_object_unref((NRObject *) arena);
renderer->destroyContext(ctx);
delete renderer;
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 4a09d56c0..78f705298 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -29,15 +29,13 @@
#include <errno.h>
#include <2geom/pathvector.h>
-#include <glib/gmem.h>
+#include <glib.h>
#include <glibmm/i18n.h>
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-#include "display/nr-arena-group.h"
+#include "display/drawing.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
-#include "display/inkscape-cairo.h"
+#include "display/cairo-utils.h"
#include "sp-item.h"
#include "sp-item-group.h"
#include "style.h"
@@ -58,6 +56,8 @@
#include "io/sys.h"
+#include "svg/stringstream.h"
+
#include <cairo.h>
// include support for only the compiled-in surface types
@@ -86,19 +86,19 @@
#define TEST(_args)
// FIXME: expose these from sp-clippath/mask.cpp
-struct SPClipPathView {
+/*struct SPClipPathView {
SPClipPathView *next;
unsigned int key;
- NRArenaItem *arenaitem;
- NRRect bbox;
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
};
struct SPMaskView {
SPMaskView *next;
unsigned int key;
- NRArenaItem *arenaitem;
- NRRect bbox;
-};
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
+};*/
namespace Inkscape {
namespace Extension {
@@ -681,12 +681,12 @@ CairoRenderContext::popLayer(void)
// copy the correct CTM to mask context
/*
if (_state->parent_has_userspace)
- mask_ctx->setTransform(&getParentState()->transform);
+ mask_ctx->setTransform(getParentState()->transform);
else
- mask_ctx->setTransform(&_state->transform);
+ mask_ctx->setTransform(_state->transform);
*/
// This is probably not correct... but it seems to do the trick.
- mask_ctx->setTransform(&_state->item_transform);
+ mask_ctx->setTransform(_state->item_transform);
// render mask contents to mask_ctx
_renderer->applyMask(mask_ctx, mask);
@@ -785,6 +785,13 @@ CairoRenderContext::setupSurface(double width, double height)
_width = width;
_height = height;
+ Inkscape::SVGOStringStream os_bbox;
+ Inkscape::SVGOStringStream os_pagebbox;
+ os_bbox.setf(std::ios::fixed); // don't use scientific notation
+ os_pagebbox.setf(std::ios::fixed); // don't use scientific notation
+ os_bbox << "%%BoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height); // apparently, the numbers should be integers. (see bug 380501)
+ os_pagebbox << "%%PageBoundingBox: 0 0 " << (int)ceil(width) << (int)ceil(height);
+
cairo_surface_t *surface = NULL;
cairo_matrix_t ctm;
cairo_matrix_init_identity (&ctm);
@@ -812,11 +819,9 @@ CairoRenderContext::setupSurface(double width, double height)
#endif
// Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2))
-// This is only a template, override_bbox and the bounding box values must be defned.
-// if (override_bbox) {
-// cairo_ps_dsc_comment(surface, "%%BoundingBox: 100 100 200 200");
-// cairo_ps_dsc_comment(surface, "%%PageBoundingBox: 100 100 200 200");
-// }
+// cairo_ps_dsc_comment(surface, os_bbox.str().c_str());
+// cairo_ps_dsc_begin_page(surface);
+// cairo_ps_dsc_comment(surface, os_pagebbox.str().c_str());
#endif
break;
#endif
@@ -909,7 +914,7 @@ CairoRenderContext::finish(void)
}
void
-CairoRenderContext::transform(Geom::Affine const *transform)
+CairoRenderContext::transform(Geom::Affine const &transform)
{
g_assert( _is_valid );
@@ -918,42 +923,44 @@ CairoRenderContext::transform(Geom::Affine const *transform)
cairo_transform(_cr, &matrix);
// store new CTM
- getTransform(&_state->transform);
+ _state->transform = getTransform();
}
void
-CairoRenderContext::setTransform(Geom::Affine const *transform)
+CairoRenderContext::setTransform(Geom::Affine const &transform)
{
g_assert( _is_valid );
cairo_matrix_t matrix;
_initCairoMatrix(&matrix, transform);
cairo_set_matrix(_cr, &matrix);
- _state->transform = *transform;
+ _state->transform = transform;
}
-void
-CairoRenderContext::getTransform(Geom::Affine *copy) const
+Geom::Affine
+CairoRenderContext::getTransform() const
{
g_assert( _is_valid );
cairo_matrix_t ctm;
cairo_get_matrix(_cr, &ctm);
- (*copy)[0] = ctm.xx;
- (*copy)[1] = ctm.yx;
- (*copy)[2] = ctm.xy;
- (*copy)[3] = ctm.yy;
- (*copy)[4] = ctm.x0;
- (*copy)[5] = ctm.y0;
+ Geom::Affine ret;
+ ret[0] = ctm.xx;
+ ret[1] = ctm.yx;
+ ret[2] = ctm.xy;
+ ret[3] = ctm.yy;
+ ret[4] = ctm.x0;
+ ret[5] = ctm.y0;
+ return ret;
}
-void
-CairoRenderContext::getParentTransform(Geom::Affine *copy) const
+Geom::Affine
+CairoRenderContext::getParentTransform() const
{
g_assert( _is_valid );
CairoRenderState *parent_state = getParentState();
- memcpy(copy, &parent_state->transform, sizeof(Geom::Affine));
+ return parent_state->transform;
}
void
@@ -996,7 +1003,7 @@ static bool pattern_hasItemChildren(SPPattern *pat)
}
cairo_pattern_t*
-CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox)
+CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox)
{
g_assert( SP_IS_PATTERN(paintserver) );
@@ -1017,10 +1024,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
if (pbox && pattern_patternUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
//Geom::Affine bbox2user (pbox->x1 - pbox->x0, 0.0, 0.0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
- bbox_width_scaler = pbox->x1 - pbox->x0;
- bbox_height_scaler = pbox->y1 - pbox->y0;
- ps2user[4] = x * bbox_width_scaler + pbox->x0;
- ps2user[5] = y * bbox_height_scaler + pbox->y0;
+ bbox_width_scaler = pbox->width();
+ bbox_height_scaler = pbox->height();
+ ps2user[4] = x * bbox_width_scaler + pbox->left();
+ ps2user[5] = y * bbox_height_scaler + pbox->top();
} else {
bbox_width_scaler = 1.0;
bbox_height_scaler = 1.0;
@@ -1035,27 +1042,22 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// create pattern contents coordinate system
if (pat->viewBox_set) {
- NRRect *view_box = pattern_viewBox(pat);
+ Geom::Rect view_box = *pattern_viewBox(pat);
double x, y, w, h;
- double view_width, view_height;
x = 0;
y = 0;
w = width * bbox_width_scaler;
h = height * bbox_height_scaler;
- view_width = view_box->x1 - view_box->x0;
- view_height = view_box->y1 - view_box->y0;
-
//calculatePreserveAspectRatio(pat->aspect_align, pat->aspect_clip, view_width, view_height, &x, &y, &w, &h);
- pcs2dev[0] = w / view_width;
- pcs2dev[3] = h / view_height;
- pcs2dev[4] = x - view_box->x0 * pcs2dev[0];
- pcs2dev[5] = y - view_box->y0 * pcs2dev[3];
+ pcs2dev[0] = w / view_box.width();
+ pcs2dev[3] = h / view_box.height();
+ pcs2dev[4] = x - view_box.left() * pcs2dev[0];
+ pcs2dev[5] = y - view_box.top() * pcs2dev[3];
} else if (pbox && pattern_patternContentUnits(pat) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) {
- pcs2dev[0] = pbox->x1 - pbox->x0;
- pcs2dev[3] = pbox->y1 - pbox->y0;
-
+ pcs2dev[0] = pbox->width();
+ pcs2dev[3] = pbox->height();
}
// Calculate the size of the surface which has to be created
@@ -1083,11 +1085,11 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
ps2user[4] = ori[Geom::X];
ps2user[5] = ori[Geom::Y];
- pattern_ctx->setTransform(&pcs2dev);
+ pattern_ctx->setTransform(pcs2dev);
pattern_ctx->pushState();
- // create arena and group
- NRArena *arena = NRArena::create();
+ // create drawing and group
+ Inkscape::Drawing drawing;
unsigned dkey = SPItem::display_key_new(1);
// show items and render them
@@ -1095,7 +1097,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM (child)) {
- SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS);
+ SP_ITEM (child)->invoke_show (drawing, dkey, SP_ITEM_REFERENCE_FLAGS);
_renderer->renderItem(pattern_ctx, SP_ITEM (child));
}
}
@@ -1113,7 +1115,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// set pattern transformation
cairo_matrix_t pattern_matrix;
- _initCairoMatrix(&pattern_matrix, &ps2user);
+ _initCairoMatrix(&pattern_matrix, ps2user);
cairo_matrix_invert(&pattern_matrix);
cairo_pattern_set_matrix(result, &pattern_matrix);
@@ -1136,7 +1138,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
cairo_pattern_t*
CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const paintserver,
- NRRect const *pbox, float alpha)
+ Geom::OptRect const &pbox, float alpha)
{
cairo_pattern_t *pattern = NULL;
bool apply_bbox2user = FALSE;
@@ -1151,7 +1153,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
Geom::Point p2 (lg->x2.computed, lg->y2.computed);
if (pbox && SP_GRADIENT(lg)->getUnits() == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX) {
// convert to userspace
- Geom::Affine bbox2user(pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
+ Geom::Affine bbox2user(pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top());
p1 *= bbox2user;
p2 *= bbox2user;
}
@@ -1231,7 +1233,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
if (apply_bbox2user) {
// convert to userspace
cairo_matrix_t bbox2user;
- cairo_matrix_init (&bbox2user, pbox->x1 - pbox->x0, 0, 0, pbox->y1 - pbox->y0, pbox->x0, pbox->y0);
+ cairo_matrix_init (&bbox2user, pbox->width(), 0, 0, pbox->height(), pbox->left(), pbox->top());
cairo_matrix_multiply (&pattern_matrix, &bbox2user, &pattern_matrix);
}
cairo_matrix_invert(&pattern_matrix); // because Cairo expects a userspace->patternspace matrix
@@ -1242,7 +1244,7 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
}
void
-CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox)
+CairoRenderContext::_setFillStyle(SPStyle const *const style, Geom::OptRect const &pbox)
{
g_return_if_fail( !style->fill.set
|| style->fill.isColor()
@@ -1278,7 +1280,7 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox
}
void
-CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox)
+CairoRenderContext::_setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox)
{
float alpha = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
if (_state->merge_opacity)
@@ -1345,7 +1347,7 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox)
}
bool
-CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox)
+CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, Geom::OptRect const &pbox)
{
g_assert( _is_valid );
@@ -1354,7 +1356,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
addClipPath(pathv, &style->fill_rule);
} else {
setPathVector(pathv);
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
@@ -1384,7 +1386,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
_setFillStyle(style, pbox);
setPathVector(pathv);
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
@@ -1412,77 +1414,31 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con
return true;
}
-bool
-CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsigned int rs,
- Geom::Affine const *image_transform, SPStyle const *style)
+bool CairoRenderContext::renderImage(GdkPixbuf *pb,
+ Geom::Affine const &image_transform, SPStyle const * /*style*/)
{
g_assert( _is_valid );
- if (_render_mode == RENDER_MODE_CLIP)
+ if (_render_mode == RENDER_MODE_CLIP) {
return true;
-
- guchar* px_rgba = NULL;
- guint64 size = 4L * (guint64)w * (guint64)h;
-
- if(size < (guint64)G_MAXSIZE) {
- px_rgba = (guchar*)g_try_malloc(4 * w * h);
- if (!px_rgba) {
- g_warning ("Could not allocate %lu bytes for pixel buffer!", (long unsigned) size);
- return false;
- }
- } else {
- g_warning ("the requested memory exceeds the system limit");
- return false;
}
+ int w = gdk_pixbuf_get_width (pb);
+ int h = gdk_pixbuf_get_height (pb);
- float opacity;
- if (_state->merge_opacity)
- opacity = _state->opacity;
- else
- opacity = 1.0;
-
- // make a copy of the original pixbuf with premultiplied alpha
- // if we pass the original pixbuf it will get messed up
- /// @todo optimize this code, it costs a lot of time
- for (unsigned i = 0; i < h; i++) {
- guchar const *src = px + i * rs;
- guint32 *dst = (guint32 *)(px_rgba + i * rs);
- for (unsigned j = 0; j < w; j++) {
- guchar r, g, b, alpha_dst;
-
- // calculate opacity-modified alpha
- alpha_dst = src[3];
- if ((opacity != 1.0) && _vector_based_target)
- alpha_dst = (guchar)ceil((float)alpha_dst * opacity);
-
- // premul alpha (needed because this will be undone by cairo-pdf)
- r = src[0]*alpha_dst/255;
- g = src[1]*alpha_dst/255;
- b = src[2]*alpha_dst/255;
-
- *dst = (((alpha_dst) << 24) | (((r)) << 16) | (((g)) << 8) | (b));
-
- dst++; // pointer to 4byte variables
- src += 4; // pointer to 1byte variables
- }
- }
+ // TODO: reenable merge_opacity if useful
+ float opacity = _state->opacity;
- cairo_surface_t *image_surface = cairo_image_surface_create_for_data(px_rgba, CAIRO_FORMAT_ARGB32, w, h, w * 4);
+ cairo_surface_t *image_surface = ink_cairo_surface_create_for_argb32_pixbuf(pb);
if (cairo_surface_status(image_surface)) {
TRACE(("Image surface creation failed:\n%s\n", cairo_status_to_string(cairo_surface_status(image_surface))));
return false;
}
- // setup automatic freeing of the image data when destroying the surface
- static cairo_user_data_key_t key;
- cairo_surface_set_user_data(image_surface, &key, px_rgba, (cairo_destroy_func_t)g_free);
-
cairo_save(_cr);
// scaling by width & height is not needed because it will be done by Cairo
- if (image_transform)
- transform(image_transform);
+ transform(image_transform);
cairo_set_source_surface(_cr, image_surface, 0.0, 0.0);
@@ -1492,23 +1448,17 @@ CairoRenderContext::renderImage(guchar *px, unsigned int w, unsigned int h, unsi
cairo_rectangle(_cr, 0, 0, w, h);
cairo_clip(_cr);
}
-
- if (_vector_based_target)
- cairo_paint(_cr);
- else
- cairo_paint_with_alpha(_cr, opacity);
+ cairo_paint_with_alpha(_cr, opacity);
cairo_restore(_cr);
-
cairo_surface_destroy(image_surface);
-
return true;
}
#define GLYPH_ARRAY_SIZE 64
-unsigned int
-CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool path)
+// TODO investigate why the font is being ignored:
+unsigned int CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont * /*font*/, std::vector<CairoGlyphInfo> const &glyphtext, bool path)
{
cairo_glyph_t glyph_array[GLYPH_ARRAY_SIZE];
cairo_glyph_t *glyphs = glyph_array;
@@ -1523,7 +1473,7 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoG
unsigned int num_invalid_glyphs = 0;
unsigned int i = 0; // is a counter for indexing the glyphs array, only counts the valid glyphs
- for (std::vector<CairoGlyphInfo>::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; it_info++) {
+ for (std::vector<CairoGlyphInfo>::const_iterator it_info = glyphtext.begin() ; it_info != glyphtext.end() ; ++it_info) {
// skip glyphs which are PANGO_GLYPH_EMPTY (0x0FFFFFFF)
// or have the PANGO_GLYPH_UNKNOWN_FLAG (0x10000000) set
if (it_info->index == 0x0FFFFFFF || it_info->index & 0x10000000) {
@@ -1544,14 +1494,15 @@ CairoRenderContext::_showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoG
cairo_show_glyphs(cr, glyphs, num_glyphs - num_invalid_glyphs);
}
- if (num_glyphs > GLYPH_ARRAY_SIZE)
+ if (num_glyphs > GLYPH_ARRAY_SIZE) {
g_free(glyphs);
+ }
return num_glyphs - num_invalid_glyphs;
}
bool
-CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix,
+CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style)
{
// create a cairo_font_face from PangoFont
@@ -1599,7 +1550,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
if (_render_mode == RENDER_MODE_CLIP) {
if (_clip_mode == CLIP_MODE_MASK) {
- if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
+ if (style->fill_rule.computed == SP_WIND_RULE_EVENODD) {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_EVEN_ODD);
} else {
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
@@ -1619,7 +1570,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
stroke = true;
}
if (fill) {
- _setFillStyle(style, NULL);
+ _setFillStyle(style, Geom::OptRect());
if (_is_texttopath) {
_showGlyphs(_cr, font, glyphtext, true);
have_path = true;
@@ -1630,7 +1581,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const *font_ma
}
}
if (stroke) {
- _setStrokeStyle(style, NULL);
+ _setStrokeStyle(style, Geom::OptRect());
if (!have_path) _showGlyphs(_cr, font, glyphtext, true);
cairo_stroke(_cr);
}
@@ -1669,22 +1620,22 @@ CairoRenderContext::_concatTransform(cairo_t *cr, double xx, double yx, double x
}
void
-CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform)
+CairoRenderContext::_initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform)
{
- matrix->xx = (*transform)[0];
- matrix->yx = (*transform)[1];
- matrix->xy = (*transform)[2];
- matrix->yy = (*transform)[3];
- matrix->x0 = (*transform)[4];
- matrix->y0 = (*transform)[5];
+ matrix->xx = transform[0];
+ matrix->yx = transform[1];
+ matrix->xy = transform[2];
+ matrix->yy = transform[3];
+ matrix->x0 = transform[4];
+ matrix->y0 = transform[5];
}
void
-CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const *transform)
+CairoRenderContext::_concatTransform(cairo_t *cr, Geom::Affine const &transform)
{
- _concatTransform(cr, (*transform)[0], (*transform)[1],
- (*transform)[2], (*transform)[3],
- (*transform)[4], (*transform)[5]);
+ _concatTransform(cr, transform[0], transform[1],
+ transform[2], transform[3],
+ transform[4], transform[5]);
}
static cairo_status_t
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index d663a82fd..94c7bb294 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -22,6 +22,7 @@
#include <string>
#include <2geom/forward.h>
+#include <2geom/affine.h>
#include "style.h"
@@ -127,20 +128,20 @@ public:
CairoRenderState *getParentState(void) const;
void setStateForStyle(SPStyle const *style);
- void transform(Geom::Affine const *transform);
- void setTransform(Geom::Affine const *transform);
- void getTransform(Geom::Affine *copy) const;
- void getParentTransform(Geom::Affine *copy) const;
+ void transform(Geom::Affine const &transform);
+ void setTransform(Geom::Affine const &transform);
+ Geom::Affine getTransform() const;
+ Geom::Affine getParentTransform() const;
/* Clipping methods */
void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule);
void addClippingRect(double x, double y, double width, double height);
/* Rendering methods */
- bool renderPathVector(Geom::PathVector const & pathv, SPStyle const *style, NRRect const *pbox);
- bool renderImage(unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
- Geom::Affine const *image_transform, SPStyle const *style);
- bool renderGlyphtext(PangoFont *font, Geom::Affine const *font_matrix,
+ bool renderPathVector(Geom::PathVector const &pathv, SPStyle const *style, Geom::OptRect const &pbox);
+ bool renderImage(GdkPixbuf *pb,
+ Geom::Affine const &image_transform, SPStyle const *style);
+ bool renderGlyphtext(PangoFont *font, Geom::Affine const &font_matrix,
std::vector<CairoGlyphInfo> const &glyphtext, SPStyle const *style);
/* More general rendering methods will have to be added (like fill, stroke) */
@@ -182,18 +183,18 @@ protected:
CairoClipMode _clip_mode;
cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
- NRRect const *pbox, float alpha);
- cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, NRRect const *pbox);
+ Geom::OptRect const &pbox, float alpha);
+ cairo_pattern_t *_createPatternPainter(SPPaintServer const *const paintserver, Geom::OptRect const &pbox);
unsigned int _showGlyphs(cairo_t *cr, PangoFont *font, std::vector<CairoGlyphInfo> const &glyphtext, bool is_stroke);
bool _finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t *ctm = NULL);
- void _setFillStyle(SPStyle const *style, NRRect const *pbox);
- void _setStrokeStyle(SPStyle const *style, NRRect const *pbox);
+ void _setFillStyle(SPStyle const *style, Geom::OptRect const &pbox);
+ void _setStrokeStyle(SPStyle const *style, Geom::OptRect const &pbox);
- void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const *transform);
+ void _initCairoMatrix(cairo_matrix_t *matrix, Geom::Affine const &transform);
void _concatTransform(cairo_t *cr, double xx, double yx, double xy, double yy, double x0, double y0);
- void _concatTransform(cairo_t *cr, Geom::Affine const *transform);
+ void _concatTransform(cairo_t *cr, Geom::Affine const &transform);
GHashTable *font_table;
static void font_data_free(gpointer data);
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 6527a646b..7ea5718f7 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -29,8 +29,7 @@
#include "extension/print.h"
#include "extension/db.h"
#include "extension/output.h"
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
+#include "display/drawing.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
@@ -43,13 +42,15 @@ namespace Inkscape {
namespace Extension {
namespace Internal {
-bool
-CairoRendererPdfOutput::check (Inkscape::Extension::Extension * module)
+bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/)
{
- if (NULL == Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer"))
- return FALSE;
+ bool result = true;
- return TRUE;
+ if (NULL == Inkscape::Extension::db.get("org.inkscape.output.pdf.cairorenderer")) {
+ result = false;
+ }
+
+ return result;
}
static bool
@@ -71,7 +72,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
}
else {
// we want to export the entire document from root
- base = SP_ITEM(doc->getRoot());
+ base = doc->getRoot();
pageBoundingBox = !exportDrawing;
}
@@ -80,10 +81,10 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
}
/* Create new arena */
- NRArena *arena = NRArena::create();
- nr_arena_set_renderoffscreen (arena);
+ Inkscape::Drawing drawing;
+ drawing.setExact(true);
unsigned dkey = SPItem::display_key_new(1);
- base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
@@ -104,9 +105,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
}
}
- /* Release arena */
base->invoke_hide(dkey);
- nr_object_unref((NRObject *) arena);
renderer->destroyContext(ctx);
delete renderer;
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index dbda82c28..42c60f52c 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -28,19 +28,16 @@
#include <signal.h>
#include <errno.h>
-#include "libnr/nr-rect.h"
#include "libnrtype/Layout-TNG.h"
#include <2geom/transforms.h>
#include <2geom/pathvector.h>
-#include <glib/gmem.h>
+#include <glib.h>
#include <glibmm/i18n.h>
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-#include "display/nr-arena-group.h"
#include "display/curve.h"
#include "display/canvas-bpath.h"
+#include "display/cairo-utils.h"
#include "sp-item.h"
#include "sp-item-group.h"
#include "style.h"
@@ -87,15 +84,15 @@
struct SPClipPathView {
SPClipPathView *next;
unsigned int key;
- NRArenaItem *arenaitem;
- NRRect bbox;
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
};
struct SPMaskView {
SPMaskView *next;
unsigned int key;
- NRArenaItem *arenaitem;
- NRRect bbox;
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
};
namespace Inkscape {
@@ -170,25 +167,25 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi
if (render) {
SPItem* marker_item = sp_item_first_item_child(marker);
- tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr;
- Geom::Affine old_tr = marker_item->transform;
- marker_item->transform = tr;
- ctx->getRenderer()->renderItem (ctx, marker_item);
- marker_item->transform = old_tr;
+ if (marker_item) {
+ tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr;
+ Geom::Affine old_tr = marker_item->transform;
+ marker_item->transform = tr;
+ ctx->getRenderer()->renderItem (ctx, marker_item);
+ marker_item->transform = old_tr;
+ }
}
}
static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
{
- NRRect pbox;
-
SPShape *shape = SP_SHAPE(item);
if (!shape->curve) {
return;
}
- item->invoke_bbox( &pbox, Geom::identity(), TRUE);
+ Geom::OptRect pbox = item->geometricBounds();
SPStyle* style = item->style;
@@ -197,7 +194,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
return;
}
- ctx->renderPathVector(pathv, style, &pbox);
+ ctx->renderPathVector(pathv, style, pbox);
// START marker
for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
@@ -315,7 +312,7 @@ static void sp_use_render(SPItem *item, CairoRenderContext *ctx)
if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) {
Geom::Affine tp(Geom::Translate(use->x.computed, use->y.computed));
ctx->pushState();
- ctx->transform(&tp);
+ ctx->transform(tp);
translated = true;
}
@@ -343,18 +340,15 @@ static void sp_flowtext_render(SPItem *item, CairoRenderContext *ctx)
static void sp_image_render(SPItem *item, CairoRenderContext *ctx)
{
SPImage *image;
- guchar *px;
- int w, h, rs;
+ int w, h;
image = SP_IMAGE (item);
if (!image->pixbuf) return;
if ((image->width.computed <= 0.0) || (image->height.computed <= 0.0)) return;
- px = gdk_pixbuf_get_pixels (image->pixbuf);
w = gdk_pixbuf_get_width (image->pixbuf);
h = gdk_pixbuf_get_height (image->pixbuf);
- rs = gdk_pixbuf_get_rowstride (image->pixbuf);
double x = image->x.computed;
double y = image->y.computed;
@@ -374,7 +368,7 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx)
Geom::Scale s(width / (double)w, height / (double)h);
Geom::Affine t(s * tp);
- ctx->renderImage (px, w, h, rs, &t, item->style);
+ ctx->renderImage (image->pixbuf, t, item->style);
}
static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
@@ -386,7 +380,7 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
/* Cloned <symbol> is actually renderable */
ctx->pushState();
- ctx->transform(&symbol->c2p);
+ ctx->transform(symbol->c2p);
// apply viewbox if set
if (0 /*symbol->viewBox_set*/) {
@@ -398,8 +392,8 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
width = 1.0;
height = 1.0;
- view_width = symbol->viewBox.x1 - symbol->viewBox.x0;
- view_height = symbol->viewBox.y1 - symbol->viewBox.y0;
+ view_width = symbol->viewBox.width();
+ view_height = symbol->viewBox.height();
calculatePreserveAspectRatio(symbol->aspect_align, symbol->aspect_clip, view_width, view_height,
&x, &y,&width, &height);
@@ -408,29 +402,27 @@ static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx)
vb2user = Geom::identity();
vb2user[0] = width / view_width;
vb2user[3] = height / view_height;
- vb2user[4] = x - symbol->viewBox.x0 * vb2user[0];
- vb2user[5] = y - symbol->viewBox.y0 * vb2user[3];
+ vb2user[4] = x - symbol->viewBox.left() * vb2user[0];
+ vb2user[5] = y - symbol->viewBox.top() * vb2user[3];
- ctx->transform(&vb2user);
+ ctx->transform(vb2user);
}
sp_group_render(item, ctx);
ctx->popState();
}
-static void sp_root_render(SPItem *item, CairoRenderContext *ctx)
+static void sp_root_render(SPRoot *root, CairoRenderContext *ctx)
{
- SPRoot *root = SP_ROOT(item);
CairoRenderer *renderer = ctx->getRenderer();
- if (!ctx->getCurrentState()->has_overflow && item->parent)
+ if (!ctx->getCurrentState()->has_overflow && root->parent)
ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed);
ctx->pushState();
- renderer->setStateForItem(ctx, item);
- Geom::Affine tempmat (root->c2p);
- ctx->transform(&tempmat);
- sp_group_render(item, ctx);
+ renderer->setStateForItem(ctx, root);
+ ctx->transform(root->c2p);
+ sp_group_render(root, ctx);
ctx->popState();
}
@@ -453,9 +445,8 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
TRACE(("sp_asbitmap_render: resolution: %f\n", res ));
- // Get the bounding box of the selection in document coordinates.
- Geom::OptRect bbox =
- item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX);
+ // Get the bounding box of the selection in desktop coordinates.
+ Geom::OptRect bbox = item->desktopVisualBounds();
// no bbox, e.g. empty group
if (!bbox) {
@@ -463,12 +454,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), item->document->getDimensions()));
- Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y])));
-
- Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect);
-
- // assign the object dimension clipped on the document, no need to draw on area not on canvas
- bbox = _bbox;
+ bbox &= docrect;
// no bbox, e.g. empty group
if (!bbox) {
@@ -476,12 +462,14 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
}
// The width and height of the bitmap in pixels
- unsigned width = (unsigned) floor ((bbox->max()[Geom::X] - bbox->min()[Geom::X]) * (res / PX_PER_IN));
- unsigned height =(unsigned) floor ((bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) * (res / PX_PER_IN));
-
+ unsigned width = ceil(bbox->width() * (res / PX_PER_IN));
+ unsigned height = ceil(bbox->height() * (res / PX_PER_IN));
+
+ if (width == 0 || height == 0) return;
+
// Scale to exactly fit integer bitmap inside bounding box
- double scale_x = (bbox->max()[Geom::X] - bbox->min()[Geom::X]) / width;
- double scale_y = (bbox->max()[Geom::Y] - bbox->min()[Geom::Y]) / height;
+ double scale_x = bbox->width() / width;
+ double scale_y = bbox->height() / height;
// Location of bounding box in document coordinates.
double shift_x = bbox->min()[Geom::X];
@@ -501,7 +489,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
(Geom::Affine)(Geom::Translate (shift_x, shift_y));
// ctx matrix already includes item transformation. We must substract.
- Geom::Affine t_item = item->i2d_affine ();
+ Geom::Affine t_item = item->i2dt_affine ();
Geom::Affine t = t_on_document * t_item.inverse();
// Do the export
@@ -515,11 +503,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
if (pb) {
TEST(gdk_pixbuf_save( pb, "bitmap.png", "png", NULL, NULL ));
- unsigned char *px = gdk_pixbuf_get_pixels (pb);
- unsigned int w = gdk_pixbuf_get_width(pb);
- unsigned int h = gdk_pixbuf_get_height(pb);
- unsigned int rs = gdk_pixbuf_get_rowstride(pb);
- ctx->renderImage(px, w, h, rs, &t, item->style);
+ // TODO this is stupid - we just converted to pixbuf format when generating the bitmap!
+ convert_pixbuf_normal_to_argb32(pb);
+ ctx->renderImage(pb, t, item->style);
gdk_pixbuf_unref(pb);
pb = 0;
}
@@ -541,7 +527,10 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
if (SP_IS_ROOT(item)) {
TRACE(("root\n"));
- return sp_root_render(item, ctx);
+ return sp_root_render(SP_ROOT(item), ctx);
+ } else if (SP_IS_SYMBOL(item)) {
+ TRACE(("symbol\n"));
+ return sp_symbol_render(item, ctx);
} else if (SP_IS_GROUP(item)) {
TRACE(("group\n"));
return sp_group_render(item, ctx);
@@ -552,9 +541,6 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx)
TRACE(("use begin---\n"));
sp_use_render(item, ctx);
TRACE(("---use end\n"));
- } else if (SP_IS_SYMBOL(item)) {
- TRACE(("symbol\n"));
- return sp_symbol_render(item, ctx);
} else if (SP_IS_TEXT(item)) {
TRACE(("text\n"));
return sp_text_render(item, ctx);
@@ -607,8 +593,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
state->merge_opacity = FALSE;
ctx->pushLayer();
}
- Geom::Affine tempmat (item->transform);
- ctx->transform(&tempmat);
+ ctx->transform(item->transform);
sp_item_invoke_render(item, ctx);
if (state->need_layer)
@@ -625,28 +610,28 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
g_assert( ctx != NULL );
if (!base) {
- base = SP_ITEM(doc->getRoot());
+ base = doc->getRoot();
}
- NRRect d;
+ Geom::Rect d;
if (pageBoundingBox) {
- d.x0 = d.y0 = 0;
- d.x1 = doc->getWidth();
- d.y1 = doc->getHeight();
+ d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions());
} else {
- base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
+ Geom::OptRect bbox = base->desktopVisualBounds();
+ if (!bbox) {
+ g_message("CairoRenderer: empty bounding box.");
+ return false;
+ }
+ d = *bbox;
}
if (ctx->_vector_based_target) {
// convert from px to pt
- d.x0 *= PT_PER_PX;
- d.x1 *= PT_PER_PX;
- d.y0 *= PT_PER_PX;
- d.y1 *= PT_PER_PX;
+ d *= Geom::Scale(PT_PER_PX);
}
- ctx->_width = d.x1-d.x0;
- ctx->_height = d.y1-d.y0;
+ ctx->_width = d.width();
+ ctx->_height = d.height();
TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height));
@@ -658,11 +643,12 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ctx->_vector_based_target)
high *= PT_PER_PX;
- Geom::Affine tp(Geom::Translate(-d.x0 * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.y1 - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
- ctx->transform(&tp);
+ /// @fixme hardcoded dt2doc transform?
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ ctx->transform(tp);
}
-
+
return ret;
}
@@ -680,16 +666,17 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
CairoRenderContext::CairoRenderMode saved_mode = ctx->getRenderMode();
ctx->setRenderMode(CairoRenderContext::RENDER_MODE_CLIP);
+ // FIXME: the access to the first clippath view to obtain the bbox is completely bogus
Geom::Affine saved_ctm;
- if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
+ if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && cp->display->bbox) {
//SP_PRINT_DRECT("clipd", cp->display->bbox);
- NRRect clip_bbox(cp->display->bbox);
- Geom::Affine t(Geom::Scale(clip_bbox.x1 - clip_bbox.x0, clip_bbox.y1 - clip_bbox.y0));
- t[4] = clip_bbox.x0;
- t[5] = clip_bbox.y0;
+ Geom::Rect clip_bbox = *cp->display->bbox;
+ Geom::Affine t(Geom::Scale(clip_bbox.dimensions()));
+ t[4] = clip_bbox.left();
+ t[5] = clip_bbox.top();
t *= ctx->getCurrentState()->transform;
- ctx->getTransform(&saved_ctm);
- ctx->setTransform(&t);
+ saved_ctm = ctx->getTransform();
+ ctx->setTransform(t);
}
TRACE(("BEGIN clip\n"));
@@ -699,12 +686,11 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
SPItem const *item = SP_ITEM(child);
// combine transform of the item in clippath and the item using clippath:
- Geom::Affine tempmat (item->transform);
- tempmat = tempmat * (ctx->getCurrentState()->item_transform);
+ Geom::Affine tempmat = item->transform * ctx->getCurrentState()->item_transform;
// render this item in clippath
ctx->pushState();
- ctx->transform(&tempmat);
+ ctx->transform(tempmat);
setStateForItem(ctx, item);
// TODO fix this call to accept const items
sp_item_invoke_render(const_cast<SPItem *>(item), ctx);
@@ -719,7 +705,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
cairo_clip(ctx->_cr);
if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX)
- ctx->setTransform(&saved_ctm);
+ ctx->setTransform(saved_ctm);
ctx->setRenderMode(saved_mode);
}
@@ -733,15 +719,16 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
if (mask == NULL)
return;
- //SP_PRINT_DRECT("maskd", &mask->display->bbox);
- NRRect mask_bbox(mask->display->bbox);
+ // FIXME: the access to the first mask view to obtain the bbox is completely bogus
// TODO: should the bbox be transformed if maskUnits != userSpaceOnUse ?
- if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX) {
- Geom::Affine t(Geom::Scale(mask_bbox.x1 - mask_bbox.x0, mask_bbox.y1 - mask_bbox.y0));
- t[4] = mask_bbox.x0;
- t[5] = mask_bbox.y0;
+ if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) {
+ //SP_PRINT_DRECT("maskd", &mask->display->bbox);
+ Geom::Rect mask_bbox = *mask->display->bbox;
+ Geom::Affine t(Geom::Scale(mask_bbox.dimensions()));
+ t[4] = mask_bbox.left();
+ t[5] = mask_bbox.top();
t *= ctx->getCurrentState()->transform;
- ctx->setTransform(&t);
+ ctx->setTransform(t);
}
// Clip mask contents... but...
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index baeb992f7..ceebc2727 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -28,43 +28,22 @@
#endif
//#include "inkscape.h"
+#include "sp-root.h"
#include "sp-path.h"
#include "style.h"
-//#include "color.h"
-//#include "display/curve.h"
-//#include "libnr/nr-point-matrix-ops.h"
-//#include "gtk/gtk.h"
#include "print.h"
-//#include "glibmm/i18n.h"
-//#include "extension/extension.h"
#include "extension/system.h"
#include "extension/print.h"
#include "extension/db.h"
#include "extension/output.h"
-//#include "document.h"
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-
-//#include "libnr/nr-rect.h"
-//#include "libnr/nr-matrix.h"
-//#include "libnr/nr-pixblock.h"
-
-//#include <stdio.h>
-//#include <string.h>
-
-//#include <vector>
-//#include <string>
-
-//#include "io/sys.h"
-
+#include "display/drawing.h"
+#include "display/drawing-item.h"
#include "unit-constants.h"
-
#include "clear-n_.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#include "win32.h"
#include "emf-win32-print.h"
#include "emf-win32-inout.h"
@@ -75,12 +54,15 @@
#define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
#endif
+#define DPA 0x00A000C9 // TernaryRasterOperation
namespace Inkscape {
namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
+static RECTL rc_old;
+static bool clipset = false;
EmfWin32::EmfWin32 (void) // The null constructor
{
@@ -123,10 +105,11 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
context.module = mod;
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
- mod->base = SP_ITEM(doc->getRoot());
- mod->arena = NRArena::create();
+ mod->base = doc->getRoot();
+ Inkscape::Drawing drawing;
mod->dkey = SPItem::display_key_new(1);
- mod->root = mod->base->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->root = mod->base->invoke_show(drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ drawing.setRoot(mod->root);
/* Print document */
ret = mod->begin(doc);
if (ret) {
@@ -138,9 +121,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
/* Release arena */
mod->base->invoke_hide(mod->dkey);
mod->base = NULL;
- mod->root = NULL;
- nr_object_unref((NRObject *) mod->arena);
- mod->arena = NULL;
+ mod->root = NULL; // deleted by invoke_hide
/* end */
mod->set_param_string("destination", oldoutput);
@@ -204,6 +185,7 @@ typedef struct emf_device_context {
typedef struct emf_callback_data {
Glib::ustring *outsvg;
Glib::ustring *path;
+ Glib::ustring *outdef;
EMF_DEVICE_CONTEXT dc[EMF_MAX_DC+1]; // FIXME: This should be dynamic..
int level;
@@ -310,6 +292,9 @@ output_style(PEMF_CALLBACK_DATA d, int iType)
tmp_style << "stroke-opacity:1;";
}
tmp_style << "\" ";
+ if (clipset)
+ tmp_style << "\n\tclip-path=\"url(#clipEmfPath" << d->id << ")\" ";
+ clipset = false;
*(d->outsvg) += tmp_style.str().c_str();
}
@@ -341,7 +326,7 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
double ppy = _pix_y_to_point(d, py);
double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
- x *= d->dc[d->level].ScaleOutX ? d->dc[d->level].ScaleOutX : device_scale;
+ x *= device_scale;
return x;
}
@@ -353,7 +338,7 @@ pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py)
double ppy = _pix_y_to_point(d, py);
double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
- y *= d->dc[d->level].ScaleOutY ? d->dc[d->level].ScaleOutY : device_scale;
+ y *= device_scale;
return y;
}
@@ -365,9 +350,9 @@ pix_to_size_point(PEMF_CALLBACK_DATA d, double px)
double ppy = 0;
double dx = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21;
- dx *= d->dc[d->level].ScaleOutX ? d->dc[d->level].ScaleOutX : device_scale;
+ dx *= device_scale;
double dy = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22;
- dy *= d->dc[d->level].ScaleOutY ? d->dc[d->level].ScaleOutY : device_scale;
+ dy *= device_scale;
double tmp = sqrt(dx * dx + dy * dy);
return tmp;
@@ -751,7 +736,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
lpEMFR->iType!=EMR_POLYLINETO && lpEMFR->iType!=EMR_POLYLINETO16 &&
lpEMFR->iType!=EMR_LINETO && lpEMFR->iType!=EMR_ARCTO &&
lpEMFR->iType!=EMR_SETBKCOLOR && lpEMFR->iType!=EMR_SETROP2 &&
- lpEMFR->iType!=EMR_SETBKMODE)
+ lpEMFR->iType!=EMR_SETBKMODE && lpEMFR->iType!=EMR_BEGINPATH)
{
*(d->outsvg) += " <path ";
output_style(d, EMR_STROKEPATH);
@@ -769,19 +754,20 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
{
dbg_str << "<!-- EMR_HEADER -->\n";
- *(d->outsvg) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
+ *(d->outdef) += "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
if (d->pDesc) {
- *(d->outsvg) += "<!-- ";
- *(d->outsvg) += d->pDesc;
- *(d->outsvg) += " -->\n";
+ *(d->outdef) += "<!-- ";
+ *(d->outdef) += d->pDesc;
+ *(d->outdef) += " -->\n";
}
ENHMETAHEADER *pEmr = (ENHMETAHEADER *) lpEMFR;
- tmp_outsvg << "<svg\n";
- tmp_outsvg << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
- tmp_outsvg << " xmlns=\"http://www.w3.org/2000/svg\"\n";
- tmp_outsvg << " version=\"1.0\"\n";
+ SVGOStringStream tmp_outdef;
+ tmp_outdef << "<svg\n";
+ tmp_outdef << " xmlns:svg=\"http://www.w3.org/2000/svg\"\n";
+ tmp_outdef << " xmlns=\"http://www.w3.org/2000/svg\"\n";
+ tmp_outdef << " version=\"1.0\"\n";
d->xDPI = 2540;
d->yDPI = 2540;
@@ -799,15 +785,13 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx)
device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx;
- tmp_outsvg <<
+ tmp_outdef <<
" width=\"" << d->MMX << "mm\"\n" <<
" height=\"" << d->MMY << "mm\">\n";
-// tmp_outsvg <<
-// " id=\"" << (d->id++) << "\">\n";
+ *(d->outdef) += tmp_outdef.str().c_str();
+ *(d->outdef) += "<defs>"; // temporary end of header
- tmp_outsvg << "<g>\n";
-// "<g\n" <<
-// " id=\"" << (d->id++) << "\">\n";
+ tmp_outsvg << "\n</defs>\n<g>\n"; // start of main body
if (pEmr->nHandles) {
d->n_obj = pEmr->nHandles;
@@ -1071,15 +1055,6 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
d->dc[d->level].ScaleInY = 1;
}
- if (d->dc[d->level].sizeView.cx && d->dc[d->level].sizeView.cy) {
- d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx;
- d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy;
- }
- else {
- d->dc[d->level].ScaleOutX = device_scale;
- d->dc[d->level].ScaleOutY = device_scale;
- }
-
break;
}
case EMR_SETWINDOWORGEX:
@@ -1122,15 +1097,6 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
d->dc[d->level].ScaleInY = 1;
}
- if (d->dc[d->level].sizeView.cx && d->dc[d->level].sizeView.cy) {
- d->dc[d->level].ScaleOutX = (double) d->dc[d->level].PixelsOutX / (double) d->dc[d->level].sizeView.cx;
- d->dc[d->level].ScaleOutY = (double) d->dc[d->level].PixelsOutY / (double) d->dc[d->level].sizeView.cy;
- }
- else {
- d->dc[d->level].ScaleOutX = device_scale;
- d->dc[d->level].ScaleOutY = device_scale;
- }
-
break;
}
case EMR_SETVIEWPORTORGEX:
@@ -1151,6 +1117,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
assert_empty_path(d, "EMR_EOF");
tmp_outsvg << "</g>\n";
tmp_outsvg << "</svg>\n";
+ *(d->outsvg) = *(d->outdef) + *(d->outsvg);
break;
}
case EMR_SETPIXELV:
@@ -1233,8 +1200,37 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_EXCLUDECLIPRECT -->\n";
break;
case EMR_INTERSECTCLIPRECT:
+ {
dbg_str << "<!-- EMR_INTERSECTCLIPRECT -->\n";
+
+ PEMRINTERSECTCLIPRECT pEmr = (PEMRINTERSECTCLIPRECT) lpEMFR;
+ RECTL rc = pEmr->rclClip;
+ clipset = true;
+ if ((rc.left == rc_old.left) && (rc.top == rc_old.top) && (rc.right == rc_old.right) && (rc.bottom == rc_old.bottom))
+ break;
+ rc_old = rc;
+
+ double l = pix_to_x_point( d, rc.left, rc.top );
+ double t = pix_to_y_point( d, rc.left, rc.top );
+ double r = pix_to_x_point( d, rc.right, rc.bottom );
+ double b = pix_to_y_point( d, rc.right, rc.bottom );
+
+ SVGOStringStream tmp_rectangle;
+ tmp_rectangle << "\n<clipPath\n\tclipPathUnits=\"userSpaceOnUse\" ";
+ tmp_rectangle << "\n\tid=\"clipEmfPath" << ++(d->id) << "\" >";
+ tmp_rectangle << "\n<rect ";
+ tmp_rectangle << "\n\tx=\"" << l << "\" ";
+ tmp_rectangle << "\n\ty=\"" << t << "\" ";
+ tmp_rectangle << "\n\twidth=\"" << r-l << "\" ";
+ tmp_rectangle << "\n\theight=\"" << b-t << "\" />";
+ tmp_rectangle << "\n</clipPath>";
+
+ assert_empty_path(d, "EMR_RECTANGLE");
+
+ *(d->outdef) += tmp_rectangle.str().c_str();
+ *(d->path) = "";
break;
+ }
case EMR_SCALEVIEWPORTEXTEX:
dbg_str << "<!-- EMR_SCALEVIEWPORTEXTEX -->\n";
break;
@@ -1669,8 +1665,11 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
{
dbg_str << "<!-- EMR_BEGINPATH -->\n";
- tmp_path << "d=\"";
- *(d->path) = "";
+ if (!d->pathless_stroke) {
+ tmp_path << "d=\"";
+ *(d->path) = "";
+ }
+ d->pathless_stroke = false;
d->inpath = true;
break;
}
@@ -1761,8 +1760,36 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_EXTSELECTCLIPRGN -->\n";
break;
case EMR_BITBLT:
+ {
dbg_str << "<!-- EMR_BITBLT -->\n";
+
+ PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR;
+ if (pEmr->dwRop == DPA) {
+ // should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
+ double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest);
+ double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest);
+ double r = pix_to_x_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest);
+ double b = pix_to_y_point( d, pEmr->xDest + pEmr->cxDest, pEmr->yDest + pEmr->cyDest);
+
+ SVGOStringStream tmp_rectangle;
+ tmp_rectangle << "d=\"";
+ tmp_rectangle << "\n\tM " << l << " " << t << " ";
+ tmp_rectangle << "\n\tL " << r << " " << t << " ";
+ tmp_rectangle << "\n\tL " << r << " " << b << " ";
+ tmp_rectangle << "\n\tL " << l << " " << b << " ";
+ tmp_rectangle << "\n\tz";
+
+ assert_empty_path(d, "EMR_BITBLT");
+
+ *(d->outsvg) += " <path ";
+ output_style(d, lpEMFR->iType);
+ *(d->outsvg) += "\n\t";
+ *(d->outsvg) += tmp_rectangle.str().c_str();
+ *(d->outsvg) += " \" /> \n";
+ *(d->path) = "";
+ }
break;
+ }
case EMR_STRETCHBLT:
dbg_str << "<!-- EMR_STRETCHBLT -->\n";
break;
@@ -1810,16 +1837,16 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
y1 = d->dc[d->level].cur.y;
}
+ double x = pix_to_x_point(d, x1, y1);
+ double y = pix_to_y_point(d, x1, y1);
+
if (!(d->dc[d->level].textAlign & TA_BOTTOM))
if (d->dc[d->level].style.baseline_shift.value) {
- x1 += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
- y1 += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
+ x += std::sin(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
+ y += std::cos(d->dc[d->level].style.baseline_shift.value*M_PI/180.0)*fabs(d->dc[d->level].style.font_size.computed);
}
else
- y1 += fabs(d->dc[d->level].style.font_size.computed);
-
- double x = pix_to_x_point(d, x1, y1);
- double y = pix_to_y_point(d, x1, y1);
+ y += fabs(d->dc[d->level].style.font_size.computed);
wchar_t *wide_text = (wchar_t *) ((char *) pEmr + pEmr->emrtext.offString);
@@ -2119,8 +2146,17 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_CREATEMONOBRUSH -->\n";
break;
case EMR_CREATEDIBPATTERNBRUSHPT:
+ {
dbg_str << "<!-- EMR_CREATEDIBPATTERNBRUSHPT -->\n";
+
+ PEMRCREATEDIBPATTERNBRUSHPT pEmr = (PEMRCREATEDIBPATTERNBRUSHPT) lpEMFR;
+ int index = pEmr->ihBrush;
+
+ EMRCREATEDIBPATTERNBRUSHPT *pBrush =
+ (EMRCREATEDIBPATTERNBRUSHPT *) malloc( sizeof(EMRCREATEDIBPATTERNBRUSHPT) );
+ insert_object(d, index, EMR_CREATEDIBPATTERNBRUSHPT, (ENHMETARECORD *) pBrush);
break;
+ }
case EMR_EXTCREATEPEN:
{
dbg_str << "<!-- EMR_EXTCREATEPEN -->\n";
@@ -2235,6 +2271,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.outsvg = new Glib::ustring("");
d.path = new Glib::ustring("");
+ d.outdef = new Glib::ustring("");
CHAR *ansi_uri = (CHAR *) local_fn;
gunichar2 *unicode_fn = g_utf8_to_utf16( local_fn, -1, NULL, NULL, NULL );
@@ -2246,12 +2283,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
HMETAFILE hmf;
HENHMETAFILE hemf;
- if (PrintWin32::is_os_wide()) {
- fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- }
- else {
- fp = CreateFileA(ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- }
+ fp = CreateFileW(unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if ( fp != INVALID_HANDLE_VALUE ) {
filesize = GetFileSize(fp, NULL);
@@ -2259,36 +2291,21 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
}
// Try open as Enhanced Metafile
- if (PrintWin32::is_os_wide())
- hemf = GetEnhMetaFileW(unicode_uri);
- else
- hemf = GetEnhMetaFileA(ansi_uri);
+ hemf = GetEnhMetaFileW(unicode_uri);
if (!hemf) {
// Try open as Windows Metafile
- if (PrintWin32::is_os_wide())
- hmf = GetMetaFileW(unicode_uri);
- else
- hmf = GetMetaFileA(ansi_uri);
+ hmf = GetMetaFileW(unicode_uri);
METAFILEPICT mp;
HDC hDC;
if (!hmf) {
- if (PrintWin32::is_os_wide()) {
- WCHAR szTemp[MAX_PATH];
+ WCHAR szTemp[MAX_PATH];
- DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH );
- if (dw) {
- hmf = GetMetaFileW( szTemp );
- }
- } else {
- CHAR szTemp[MAX_PATH];
-
- DWORD dw = GetShortPathNameA( ansi_uri, szTemp, MAX_PATH );
- if (dw) {
- hmf = GetMetaFileA( szTemp );
- }
+ DWORD dw = GetShortPathNameW( unicode_uri, szTemp, MAX_PATH );
+ if (dw) {
+ hmf = GetMetaFileW( szTemp );
}
}
@@ -2335,10 +2352,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
else {
// Try open as Aldus Placeable Metafile
HANDLE hFile;
- if (PrintWin32::is_os_wide())
- hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
- else
- hFile = CreateFileA( ansi_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+ hFile = CreateFileW( unicode_uri, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile != INVALID_HANDLE_VALUE) {
DWORD nSize = GetFileSize( hFile, NULL );
@@ -2376,6 +2390,8 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
delete d.outsvg;
if (d.path)
delete d.path;
+ if (d.outdef)
+ delete d.outdef;
if (local_fn)
g_free(local_fn);
if (unicode_fn)
@@ -2417,6 +2433,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
delete d.outsvg;
delete d.path;
+ delete d.outdef;
if (d.emf_obj) {
int i;
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index 503a13d09..f4c36dd92 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -42,9 +42,7 @@
#include "sp-item.h"
//#include "glib.h"
-//#include "gtk/gtkdialog.h"
-//#include "gtk/gtkbox.h"
-//#include "gtk/gtkstock.h"
+//#include "gtk/gtk.h"
//#include "glibmm/i18n.h"
//#include "enums.h"
@@ -52,15 +50,12 @@
#include "style.h"
//#include "sp-paint-server.h"
#include "inkscape-version.h"
+#include "sp-root.h"
//#include "libnrtype/FontFactory.h"
//#include "libnrtype/font-instance.h"
//#include "libnrtype/font-style-to-pos.h"
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include "win32.h"
#include "emf-win32-print.h"
#include "unit-constants.h"
@@ -81,6 +76,8 @@ static float dwDPI = 2540;
PrintEmfWin32::PrintEmfWin32 (void):
+ _width(0),
+ _height(0),
hdc(NULL),
hbrush(NULL),
hbrushOld(NULL),
@@ -110,15 +107,13 @@ PrintEmfWin32::~PrintEmfWin32 (void)
}
-unsigned int
-PrintEmfWin32::setup (Inkscape::Extension::Print * /*mod*/)
+unsigned int PrintEmfWin32::setup (Inkscape::Extension::Print * /*mod*/)
{
return TRUE;
}
-unsigned int
-PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
+unsigned int PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
{
gchar const *utf8_fn = mod->get_param_string("destination");
@@ -140,25 +135,22 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
_width = doc->getWidth();
_height = doc->getHeight();
- NRRect d;
bool pageBoundingBox;
pageBoundingBox = mod->get_param_bool("pageBoundingBox");
+
+ Geom::Rect d;
if (pageBoundingBox) {
- d.x0 = d.y0 = 0;
- d.x1 = _width;
- d.y1 = _height;
+ d = Geom::Rect::from_xywh(0, 0, _width, _height);
} else {
- SPItem* doc_item = SP_ITEM(doc->getRoot());
- doc_item->invoke_bbox(&d, doc_item->i2d_affine(), TRUE);
+ SPItem* doc_item = doc->getRoot();
+ Geom::OptRect bbox = doc_item->desktopVisualBounds();
+ if (bbox) d = *bbox;
}
- d.x0 *= IN_PER_PX;
- d.y0 *= IN_PER_PX;
- d.x1 *= IN_PER_PX;
- d.y1 *= IN_PER_PX;
+ d *= Geom::Scale(IN_PER_PX);
- float dwInchesX = (d.x1 - d.x0);
- float dwInchesY = (d.y1 - d.y0);
+ float dwInchesX = d.width();
+ float dwInchesY = d.height();
// dwInchesX x dwInchesY in .01mm units
SetRect( &rc, 0, 0, (int) ceil(dwInchesX*2540), (int) ceil(dwInchesY*2540) );
@@ -186,15 +178,12 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
snprintf(buff+len+1, sizeof(buff)-len-2, "%s", p);
// Create the Metafile
- if (PrintWin32::is_os_wide()) {
+ {
WCHAR wbuff[1024];
ZeroMemory(wbuff, sizeof(wbuff));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buff, sizeof(buff)/sizeof(buff[0]), wbuff, sizeof(wbuff)/sizeof(wbuff[0]));
hdc = CreateEnhMetaFileW( hScreenDC, unicode_uri, &rc, wbuff );
}
- else {
- hdc = CreateEnhMetaFileA( hScreenDC, ansi_uri, &rc, buff );
- }
// Release the reference DC
ReleaseDC( NULL, hScreenDC );
@@ -234,14 +223,13 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
g_free(local_fn);
g_free(unicode_fn);
- m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
+ m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform
return 0;
}
-unsigned int
-PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/)
+unsigned int PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/)
{
if (!hdc) return 0;
@@ -259,8 +247,7 @@ PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/)
}
-unsigned int
-PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/,
+unsigned int PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/,
const char * /*comment*/)
{
if (!hdc) return 0;
@@ -271,8 +258,7 @@ PrintEmfWin32::comment (Inkscape::Extension::Print * /*module*/,
}
-int
-PrintEmfWin32::create_brush(SPStyle const *style)
+int PrintEmfWin32::create_brush(SPStyle const *style)
{
float rgb[3];
@@ -298,8 +284,7 @@ PrintEmfWin32::create_brush(SPStyle const *style)
}
-void
-PrintEmfWin32::destroy_brush()
+void PrintEmfWin32::destroy_brush()
{
SelectObject( hdc, hbrushOld );
if (hbrush)
@@ -309,8 +294,7 @@ PrintEmfWin32::destroy_brush()
}
-void
-PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform)
+void PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform)
{
if (style) {
float rgb[3];
@@ -433,8 +417,7 @@ PrintEmfWin32::create_pen(SPStyle const *style, const Geom::Affine &transform)
}
-void
-PrintEmfWin32::destroy_pen()
+void PrintEmfWin32::destroy_pen()
{
SelectObject( hdc, hpenOld );
if (hpen)
@@ -443,8 +426,7 @@ PrintEmfWin32::destroy_pen()
}
-void
-PrintEmfWin32::flush_fill()
+void PrintEmfWin32::flush_fill()
{
if (!fill_pathv.empty()) {
stroke_and_fill = false;
@@ -458,32 +440,27 @@ PrintEmfWin32::flush_fill()
}
}
-unsigned int
-PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const *transform, float /*opacity*/)
-{
- Geom::Affine tr = *transform;
-
- if (m_tr_stack.size()) {
+unsigned int PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/)
+{
+ if (!m_tr_stack.empty()) {
Geom::Affine tr_top = m_tr_stack.top();
- m_tr_stack.push(tr * tr_top);
+ m_tr_stack.push(transform * tr_top);
} else {
- m_tr_stack.push(tr);
+ m_tr_stack.push(transform);
}
return 1;
}
-unsigned int
-PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/)
+unsigned int PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/)
{
m_tr_stack.pop();
return 1;
}
-unsigned int
-PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
- Geom::PathVector const &pathv, Geom::Affine const * /*transform*/, SPStyle const *style,
- NRRect const * /*pbox*/, NRRect const * /*dbox*/, NRRect const * /*bbox*/)
+unsigned int PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
+ Geom::PathVector const &pathv, Geom::Affine const & /*transform*/, SPStyle const *style,
+ Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/)
{
if (!hdc) return 0;
@@ -509,10 +486,9 @@ PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
}
-unsigned int
-PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/,
- Geom::PathVector const &pathv, const Geom::Affine * /*transform*/, const SPStyle *style,
- const NRRect * /*pbox*/, const NRRect * /*dbox*/, const NRRect * /*bbox*/)
+unsigned int PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/,
+ Geom::PathVector const &pathv, const Geom::Affine &/*transform*/, const SPStyle *style,
+ Geom::OptRect const &/*pbox*/, Geom::OptRect const &/*dbox*/, Geom::OptRect const &/*bbox*/)
{
if (!hdc) return 0;
@@ -549,8 +525,7 @@ PrintEmfWin32::stroke (Inkscape::Extension::Print * /*mod*/,
}
-bool
-PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Affine &transform)
+bool PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Affine &transform)
{
Geom::PathVector pv = pathv_to_linear_and_cubic_beziers( pathv * transform );
@@ -745,8 +720,7 @@ PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff
return done;
}
-unsigned int
-PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform)
+unsigned int PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform)
{
simple_shape = print_simple_shape(pathv, transform);
@@ -850,14 +824,12 @@ PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &tr
}
-bool
-PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext)
+bool PrintEmfWin32::textToPath(Inkscape::Extension::Print * ext)
{
return ext->get_param_bool("textToPath");
}
-unsigned int
-PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point p,
+unsigned int PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom::Point const &p,
SPStyle const *const style)
{
if (!hdc) return 0;
@@ -879,76 +851,40 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom
#endif
if (!hfont) {
- if (PrintWin32::is_os_wide()) {
- LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW));
- g_assert(lf != NULL);
-
- lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI;
- lf->lfWidth = 0;
- lf->lfEscapement = rot;
- lf->lfOrientation = rot;
- lf->lfWeight =
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
- FW_NORMAL;
- lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC);
- lf->lfUnderline = style->text_decoration.underline;
- lf->lfStrikeOut = style->text_decoration.line_through;
- lf->lfCharSet = DEFAULT_CHARSET;
- lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf->lfQuality = DEFAULT_QUALITY;
- lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-
- gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL );
- wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1);
- g_free(unicode_name);
-
- hfont = CreateFontIndirectW(lf);
-
- g_free(lf);
- }
- else {
- LOGFONTA *lf = (LOGFONTA*)g_malloc(sizeof(LOGFONTA));
- g_assert(lf != NULL);
-
- lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI;
- lf->lfWidth = 0;
- lf->lfEscapement = rot;
- lf->lfOrientation = rot;
- lf->lfWeight =
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
- style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
- FW_NORMAL;
- lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC);
- lf->lfUnderline = style->text_decoration.underline;
- lf->lfStrikeOut = style->text_decoration.line_through;
- lf->lfCharSet = DEFAULT_CHARSET;
- lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf->lfQuality = DEFAULT_QUALITY;
- lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-
- strncpy(lf->lfFaceName, (char*) style->text->font_family.value, LF_FACESIZE-1);
-
- hfont = CreateFontIndirectA(lf);
-
- g_free(lf);
- }
+ LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW));
+ g_assert(lf != NULL);
+
+ lf->lfHeight = style->font_size.computed * IN_PER_PX * dwDPI;
+ lf->lfWidth = 0;
+ lf->lfEscapement = rot;
+ lf->lfOrientation = rot;
+ lf->lfWeight =
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
+ style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
+ FW_NORMAL;
+ lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC);
+ lf->lfUnderline = style->text_decoration.underline;
+ lf->lfStrikeOut = style->text_decoration.line_through;
+ lf->lfCharSet = DEFAULT_CHARSET;
+ lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf->lfQuality = DEFAULT_QUALITY;
+ lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+
+ gunichar2 *unicode_name = g_utf8_to_utf16( style->text->font_family.value, -1, NULL, NULL, NULL );
+ wcsncpy(lf->lfFaceName, (wchar_t*) unicode_name, LF_FACESIZE-1);
+ g_free(unicode_name);
+
+ hfont = CreateFontIndirectW(lf);
+
+ g_free(lf);
}
HFONT hfontOld = (HFONT) SelectObject(hdc, hfont);
@@ -966,20 +902,17 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom
// Transparent text background
SetBkMode(hdc, TRANSPARENT);
- p = p * tf;
- p[Geom::X] = (p[Geom::X] * IN_PER_PX * dwDPI);
- p[Geom::Y] = (p[Geom::Y] * IN_PER_PX * dwDPI);
+ Geom::Point p2 = p * tf;
+ p2[Geom::X] = (p2[Geom::X] * IN_PER_PX * dwDPI);
+ p2[Geom::Y] = (p2[Geom::Y] * IN_PER_PX * dwDPI);
- LONG const xpos = (LONG) round(p[Geom::X]);
- LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]);
+ LONG const xpos = (LONG) round(p2[Geom::X]);
+ LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]);
- if (PrintWin32::is_os_wide()) {
+ {
gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL );
TextOutW(hdc, xpos, ypos, (WCHAR*)unicode_text, wcslen((wchar_t*)unicode_text));
}
- else {
- TextOutA(hdc, xpos, ypos, (CHAR*)text, strlen((char*)text));
- }
SelectObject(hdc, hfontOld);
DeleteObject(hfont);
@@ -987,8 +920,7 @@ PrintEmfWin32::text(Inkscape::Extension::Print * /*mod*/, char const *text, Geom
return 0;
}
-void
-PrintEmfWin32::init (void)
+void PrintEmfWin32::init (void)
{
Inkscape::Extension::Extension * ext;
diff --git a/src/extension/internal/emf-win32-print.h b/src/extension/internal/emf-win32-print.h
index a9f639bcd..71ce5d6d0 100644
--- a/src/extension/internal/emf-win32-print.h
+++ b/src/extension/internal/emf-win32-print.h
@@ -17,6 +17,9 @@
# include "config.h"
#endif
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
#include "extension/implementation/implementation.h"
//#include "extension/extension.h"
@@ -59,17 +62,21 @@ public:
virtual unsigned int finish (Inkscape::Extension::Print * module);
/* Rendering methods */
- virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity);
+ virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity);
virtual unsigned int release(Inkscape::Extension::Print *module);
- virtual unsigned int fill (Inkscape::Extension::Print * module,
- Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ virtual unsigned int fill (Inkscape::Extension::Print *module,
+ Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int stroke (Inkscape::Extension::Print * module,
- Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment);
virtual unsigned int text(Inkscape::Extension::Print *module, char const *text,
- Geom::Point p, SPStyle const *style);
+ Geom::Point const &p, SPStyle const *style);
bool textToPath (Inkscape::Extension::Print * ext);
static void init (void);
diff --git a/src/extension/internal/filter/CMakeLists.txt b/src/extension/internal/filter/CMakeLists.txt
deleted file mode 100644
index 80a14ba3a..000000000
--- a/src/extension/internal/filter/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-SET(extension_internal_filter_SRC
-drop-shadow.h
-filter-all.cpp
-filter.cpp
-filter-file.cpp
-filter.h
-snow.h
-)
diff --git a/src/extension/internal/filter/abc.h b/src/extension/internal/filter/abc.h
deleted file mode 100755
index 41a3c5af9..000000000
--- a/src/extension/internal/filter/abc.h
+++ /dev/null
@@ -1,878 +0,0 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__
-/* Change the 'ABC' above to be your file name */
-
-/*
- * Copyright (C) 2011 Authors:
- * Ivan Louette (filters)
- * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
- *
- * Basic filters
- * Blur
- * Clean edges
- * Color shift
- * Diffuse light
- * Feather
- * Matte jelly
- * Noise fill
- * Outline
- * Roughen
- * Silhouette
- * Specular light
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
-
-#include "filter.h"
-
-#include "extension/internal/clear-n_.h"
-#include "extension/system.h"
-#include "extension/extension.h"
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-namespace Filter {
-
-/**
- \brief Custom predefined Blur filter.
-
- Simple horizontal and vertical blur
-
- Filter's parameters:
- * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation)
- * Vertical blur (0.01->100., default 2) -> blur (stdDeviation)
-*/
-
-class Blur : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- Blur ( ) : Filter() { };
- virtual ~Blur ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Blur, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.Blur</id>\n"
- "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" min=\"0.01\" max=\"100\">2</param>\n"
- "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" min=\"0.01\" max=\"100\">2</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Simple vertical and horizontal blur effect") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new Blur());
- };
-
-};
-
-gchar const *
-Blur::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream hblur;
- std::ostringstream vblur;
-
- hblur << ext->get_param_float("hblur");
- vblur << ext->get_param_float("vblur");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Blur, custom\">\n"
- "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n"
- "</filter>\n", hblur.str().c_str(), vblur.str().c_str());
-
- return _filter;
-}; /* Blur filter */
-
-/**
- \brief Custom predefined Clean edges filter.
-
- Removes or decreases glows and jaggeries around objects edges after applying some filters
-
- Filter's parameters:
- * Strength (0.01->100., default 0.4) -> blur (stdDeviation)
-*/
-
-class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- CleanEdges ( ) : Filter() { };
- virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Clean edges, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.CleanEdges</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"0.01\" max=\"100\">0.4</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new CleanEdges());
- };
-
-};
-
-gchar const *
-CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream blur;
-
- blur << ext->get_param_float("blur");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Clean edges, custom\">\n"
- "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"in\" result=\"composite1\" />\n"
- "<feComposite in=\"composite1\" in2=\"composite1\" k2=\"1\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", blur.str().c_str());
-
- return _filter;
-}; /* CleanEdges filter */
-
-
-/**
- \brief Custom predefined Color shift filter.
-
- Rotate and desaturate hue
-
- Filter's parameters:
- * Shift (0->360, default 330) -> color1 (values)
- * Saturation (0.->10., default 6) -> color2 (values [/10])
-*/
-
-class ColorShift : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- ColorShift ( ) : Filter() { };
- virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Color shift, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.ColorShift</id>\n"
- "<param name=\"shift\" gui-text=\"" N_("Shift:") "\" type=\"int\" min=\"0\" max=\"360\">330</param>\n"
- "<param name=\"sat\" gui-text=\"" N_("Saturation:") "\" type=\"float\" min=\"0.\" max=\"10\">6</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Rotate and desaturate hue") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new ColorShift());
- };
-
-};
-
-gchar const *
-ColorShift::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream shift;
- std::ostringstream sat;
-
- shift << ext->get_param_int("shift");
- sat << (ext->get_param_float("sat") / 10);
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Color shift, custom\">\n"
- "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"color1\" />\n"
- "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n"
- "</filter>\n", shift.str().c_str(), sat.str().c_str());
-
- return _filter;
-}; /* ColorShift filter */
-
-/**
- \brief Custom predefined Diffuse light filter.
-
- Basic diffuse bevel to use for building textures
-
- Filter's parameters:
- * Smoothness (0.->10., default 6.) -> blur (stdDeviation)
- * Elevation (0->360, default 25) -> feDistantLight (elevation)
- * Azimuth (0->360, default 235) -> feDistantLight (azimuth)
- * Lightning color (guint, default -1 [white]) -> diffuse (lighting-color)
-*/
-
-class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- DiffuseLight ( ) : Filter() { };
- virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Diffuse light, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.DiffuseLight</id>\n"
- "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.0\" max=\"10\">6</param>\n"
- "<param name=\"elevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" min=\"0\" max=\"360\">25</param>\n"
- "<param name=\"azimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" min=\"0\" max=\"360\">235</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Lightning color") "\" type=\"color\">-1</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Basic diffuse bevel to use for building textures") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new DiffuseLight());
- };
-
-};
-
-gchar const *
-DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream smooth;
- std::ostringstream elevation;
- std::ostringstream azimuth;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream a;
-
- smooth << ext->get_param_float("smooth");
- elevation << ext->get_param_int("elevation");
- azimuth << ext->get_param_int("azimuth");
- guint32 color = ext->get_param_color("color");
-
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Diffuse light, custom\">\n"
- "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feDiffuseLighting diffuseConstant=\"1\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"diffuse\">\n"
- "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
- "</feDiffuseLighting>\n"
- "<feComposite in=\"diffuse\" in2=\"diffuse\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n"
- "<feComposite in=\"composite1\" in2=\"SourceGraphic\" k1=\"%s\" operator=\"arithmetic\" k3=\"1\" result=\"composite2\" />\n"
- "</filter>\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
-
- return _filter;
-}; /* DiffuseLight filter */
-
-/**
- \brief Custom predefined Feather filter.
-
- Blurred mask on the edge without altering the contents
-
- Filter's parameters:
- * Strength (0.01->100., default 5) -> blur (stdDeviation)
-*/
-
-class Feather : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- Feather ( ) : Filter() { };
- virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Feather, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.Feather</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"0.01\" max=\"100\">5</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Blurred mask on the edge without altering the contents") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new Feather());
- };
-
-};
-
-gchar const *
-Feather::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream blur;
-
- blur << ext->get_param_float("blur");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Black outline, custom\">\n"
- "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n"
- "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n"
- "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n"
- "</filter>\n", blur.str().c_str());
-
- return _filter;
-}; /* Feather filter */
-
-/**
- \brief Custom predefined Matte jelly filter.
-
- Bulging, matte jelly covering
-
- Filter's parameters:
- * Smoothness (0.0->10., default 7.) -> blur (stdDeviation)
- * Brightness (0.0->5., default .9) -> specular (specularConstant)
- * Elevation (0->360, default 60) -> feDistantLight (elevation)
- * Azimuth (0->360, default 225) -> feDistantLight (azimuth)
- * Lightning color (guint, default -1 [white]) -> specular (lighting-color)
-*/
-
-class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- MatteJelly ( ) : Filter() { };
- virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Matte jelly, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.MatteJelly</id>\n"
- "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.0\" max=\"10\">7</param>\n"
- "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" min=\"0.0\" max=\"5\">0.9</param>\n"
- "<param name=\"elevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" min=\"0\" max=\"360\">60</param>\n"
- "<param name=\"azimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" min=\"0\" max=\"360\">225</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Lightning color") "\" type=\"color\">-1</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Bulging, matte jelly covering") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new MatteJelly());
- };
-
-};
-
-gchar const *
-MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream smooth;
- std::ostringstream bright;
- std::ostringstream elevation;
- std::ostringstream azimuth;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream a;
-
- smooth << ext->get_param_float("smooth");
- bright << ext->get_param_float("bright");
- elevation << ext->get_param_int("elevation");
- azimuth << ext->get_param_int("azimuth");
- guint32 color = ext->get_param_color("color");
-
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Matte jelly, custom\">\n"
- "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.85 0\" result=\"color\" in=\"SourceGraphic\" />\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"5\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n"
- "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
- "</feSpecularLighting>\n"
- "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
- "<feComposite in=\"composite1\" in2=\"color\" operator=\"atop\" result=\"composite2\" />\n"
- "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
-
- return _filter;
-}; /* MatteJelly filter */
-
-/**
- \brief Custom predefined Noise fill filter.
-
- Basic noise fill and transparency texture
-
- Filter's parameters:
- * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
- * Horizontal frequency (*100) (0.001->1000., default 2) -> turbulence (baseFrequency [/100])
- * Vertical frequency (*100) (0.001->1000., default 4) -> turbulence (baseFrequency [/100])
- * Complexity (1->5, default 5) -> turbulence (numOctaves)
- * Variation (1->360, default 1) -> turbulence (seed)
- * Dilatation (1.->50., default 3) -> color (n-1th value)
- * Erosion (0.->50., default 1) -> color (nth value 0->-50)
- * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity)
- * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out")
-*/
-
-class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- NoiseFill ( ) : Filter() { };
- virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Noise fill, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.NoiseFill</id>\n"
- "<param name=\"tab\" type=\"notebook\">\n"
- "<page name=\"optionstab\" _gui-text=\"Options\">\n"
- "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
- "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
- "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
- "</param>\n"
- "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency (x100):") "\" type=\"float\" min=\"0.001\" max=\"1000\">2</param>\n"
- "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency (x100):") "\" type=\"float\" min=\"0.001\" max=\"1000\">4</param>\n"
- "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" min=\"1\" max=\"5\">5</param>\n"
- "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" min=\"1\" max=\"360\">0</param>\n"
- "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" min=\"1\" max=\"50\">3</param>\n"
- "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"50\">1</param>\n"
- "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n"
- "</page>\n"
- "<page name=\"co11tab\" _gui-text=\"Noise color\">\n"
- "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">354957823</param>\n"
- "</page>\n"
- "</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Basic noise fill and transparency texture") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new NoiseFill());
- };
-
-};
-
-gchar const *
-NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream type;
- std::ostringstream hfreq;
- std::ostringstream vfreq;
- std::ostringstream complexity;
- std::ostringstream variation;
- std::ostringstream dilat;
- std::ostringstream erosion;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream a;
- std::ostringstream inverted;
-
- type << ext->get_param_enum("type");
- hfreq << (ext->get_param_float("hfreq") / 100);
- vfreq << (ext->get_param_float("vfreq") / 100);
- complexity << ext->get_param_int("complexity");
- variation << ext->get_param_int("variation");
- dilat << ext->get_param_float("dilat");
- erosion << (- ext->get_param_float("erosion"));
- guint32 color = ext->get_param_color("color");
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
- if (ext->get_param_bool("inverted"))
- inverted << "out";
- else
- inverted << "in";
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Noise fill, custom\">\n"
- "<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\"/>\n"
- "<feComposite in=\"SourceGraphic\" in2=\"turbulence\" operator=\"%s\" result=\"composite1\" />\n"
- "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color\" />\n"
- "<feFlood in=\"color\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
- "<feMerge result=\"merge\">\n"
- "<feMergeNode in=\"flood\" />\n"
- "<feMergeNode in=\"color\" />\n"
- "</feMerge>\n"
- "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str());
-
- return _filter;
-}; /* NoiseFill filter */
-
-/**
- \brief Custom predefined Outline filter.
-
- Adds a colorizable outline
-
- Filter's parameters:
- * Width (0.01->50., default 5) -> blur1 (stdDeviation)
- * Melt (0.01->50., default 2) -> blur2 (stdDeviation)
- * Dilatation (1.->50., default 8) -> color2 (n-1th value)
- * Erosion (0.->50., default 5) -> color2 (nth value 0->-50)
- * Color (guint, default 156,102,102,255) -> flood (flood-color, flood-opacity)
- * Blend (enum, default Normal) -> blend (mode)
-*/
-
-class Outline : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- Outline ( ) : Filter() { };
- virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Outline, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.Outline</id>\n"
- "<param name=\"tab\" type=\"notebook\">\n"
- "<page name=\"optionstab\" _gui-text=\"Options\">\n"
- "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"float\" min=\"0.01\" max=\"50\">5</param>\n"
- "<param name=\"melt\" gui-text=\"" N_("Melt:") "\" type=\"float\" min=\"0.01\" max=\"50\">2</param>\n"
- "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" min=\"1\" max=\"50\">8</param>\n"
- "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"50\">5</param>\n"
- "</page>\n"
- "<page name=\"co11tab\" _gui-text=\"Color\">\n"
- "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">1029214207</param>\n"
- "</page>\n"
- "</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Adds a colorizable outline") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new Outline());
- };
-
-};
-
-gchar const *
-Outline::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream width;
- std::ostringstream melt;
- std::ostringstream dilat;
- std::ostringstream erosion;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream a;
- std::ostringstream blend;
-
- width << ext->get_param_float("width");
- melt << ext->get_param_float("melt");
- dilat << ext->get_param_float("dilat");
- erosion << (- ext->get_param_float("erosion"));
- guint32 color = ext->get_param_color("color");
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.3\" width=\"1.3\" y=\"-0.15\" x=\"-0.15\" inkscape:label=\"Outline, custom\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur1\" />\n"
- "<feColorMatrix result=\"color1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 200 -1 \" />\n"
- "<feGaussianBlur in=\"color1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
- "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color2\" />\n"
- "<feFlood in=\"color2\" result=\"flood\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" />\n"
- "<feComposite in=\"flood\" in2=\"color2\" operator=\"in\" result=\"composite\" />\n"
- "<feBlend in=\"SourceGraphic\" in2=\"composite\" mode=\"normal\" blend=\"normal\" />\n"
- "</filter>\n", width.str().c_str(), melt.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str());
-
- return _filter;
-}; /* Outline filter */
-
-/**
- \brief Custom predefined Roughen filter.
-
- Small-scale roughening to edges and content
-
- Filter's parameters:
- * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
- * Horizontal frequency (*100) (0.001->1000., default 1.3) -> turbulence (baseFrequency)
- * Vertical frequency (*100) (0.001->1000., default 1.3) -> turbulence (baseFrequency)
- * Complexity (1->5, default 5) -> turbulence (numOctaves)
- * Variation (1->360, default 1) -> turbulence (seed)
- * Intensity (0.0->50., default 6.6) -> displacement (scale)
-*/
-
-class Roughen : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- Roughen ( ) : Filter() { };
- virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Roughen, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.Roughen</id>\n"
- "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
- "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
- "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
- "</param>\n"
- "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency (x100):") "\" type=\"float\" min=\"0.001\" max=\"1000\">1.3</param>\n"
- "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency (x100):") "\" type=\"float\" min=\"0.001\" max=\"1000\">1.3</param>\n"
- "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" min=\"1\" max=\"5\">5</param>\n"
- "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" min=\"1\" max=\"360\">0</param>\n"
- "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" min=\"0.0\" max=\"50\">6.6</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Small-scale roughening to edges and content") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new Roughen());
- };
-
-};
-
-gchar const *
-Roughen::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream type;
- std::ostringstream hfreq;
- std::ostringstream vfreq;
- std::ostringstream complexity;
- std::ostringstream variation;
- std::ostringstream intensity;
-
- type << ext->get_param_enum("type");
- hfreq << (ext->get_param_float("hfreq") / 100);
- vfreq << (ext->get_param_float("vfreq") / 100);
- complexity << ext->get_param_int("complexity");
- variation << ext->get_param_int("variation");
- intensity << ext->get_param_float("intensity");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Roughen, custom\">\n"
- "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n"
- "<feDisplacementMap in=\"SourceGraphic\" in2=\"turbulence\" scale=\"%s\" yChannelSelector=\"G\" xChannelSelector=\"R\" />\n"
- "</filter>\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str());
-
- return _filter;
-}; /* Roughen filter */
-
-/**
- \brief Custom predefined Silhouette filter.
-
- Repaint anything visible monochrome
-
- Filter's parameters:
- * Blur (0.01->50., default 0.01) -> blur (stdDeviation)
- * Cutout (boolean, default False) -> composite (false=in, true=out)
- * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity)
-*/
-
-class Silhouette : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- Silhouette ( ) : Filter() { };
- virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Silhouette, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.Silhouette</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"50\">0.01</param>\n"
- "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Repaint anything visible monochrome") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new Silhouette());
- };
-
-};
-
-gchar const *
-Silhouette::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream a;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream cutout;
- std::ostringstream blur;
-
- guint32 color = ext->get_param_color("color");
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
- if (ext->get_param_bool("cutout"))
- cutout << "out";
- else
- cutout << "in";
- blur << ext->get_param_float("blur");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Silhouette, custom\">\n"
- "<feFlood in=\"SourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
- "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite\" />\n"
- "<feGaussianBlur stdDeviation=\"%s\" />\n"
- "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str());
-
- return _filter;
-}; /* Silhouette filter */
-
-/**
- \brief Custom predefined Specular light filter.
-
- Basic specular bevel to use for building textures
-
- Filter's parameters:
- * Smoothness (0.0->10., default 6.) -> blur (stdDeviation)
- * Brightness (0.0->5., default 1.) -> specular (specularConstant)
- * Elevation (0->360, default 45) -> feDistantLight (elevation)
- * Azimuth (0->360, default 235) -> feDistantLight (azimuth)
- * Lightning color (guint, default -1 [white]) -> specular (lighting-color)
-*/
-
-class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- SpecularLight ( ) : Filter() { };
- virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Specular light, custom (ABCs)") "</name>\n"
- "<id>org.inkscape.effect.filter.SpecularLight</id>\n"
- "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.0\" max=\"10\">6</param>\n"
- "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" min=\"0.0\" max=\"5\">1</param>\n"
- "<param name=\"elevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" min=\"0\" max=\"360\">45</param>\n"
- "<param name=\"azimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" min=\"0\" max=\"360\">235</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Lightning color") "\" type=\"color\">-1</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Basic specular bevel to use for building textures") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new SpecularLight());
- };
-
-};
-
-gchar const *
-SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream smooth;
- std::ostringstream bright;
- std::ostringstream elevation;
- std::ostringstream azimuth;
- std::ostringstream r;
- std::ostringstream g;
- std::ostringstream b;
- std::ostringstream a;
-
- smooth << ext->get_param_float("smooth");
- bright << ext->get_param_float("bright");
- elevation << ext->get_param_int("elevation");
- azimuth << ext->get_param_int("azimuth");
- guint32 color = ext->get_param_color("color");
-
- r << ((color >> 24) & 0xff);
- g << ((color >> 16) & 0xff);
- b << ((color >> 8) & 0xff);
- a << (color & 0xff) / 255.0F;
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Specular light, custom\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n"
- "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
- "</feSpecularLighting>\n"
- "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
- "<feComposite in=\"composite1\" in2=\"SourceAlpha\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
-
- return _filter;
-}; /* SpecularLight filter */
-
-
-}; /* namespace Filter */
-}; /* namespace Internal */
-}; /* namespace Extension */
-}; /* namespace Inkscape */
-
-/* Change the 'ABC' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_ABC_H__ */
diff --git a/src/extension/internal/filter/bevels.h b/src/extension/internal/filter/bevels.h
new file mode 100644
index 000000000..6fc73e58a
--- /dev/null
+++ b/src/extension/internal/filter/bevels.h
@@ -0,0 +1,282 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__
+/* Change the 'BEVELS' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Bevel filters
+ * Diffuse light
+ * Matte jelly
+ * Specular light
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Diffuse light filter.
+
+ Basic diffuse bevel to use for building textures
+
+ Filter's parameters:
+ * Smoothness (0.->10., default 6.) -> blur (stdDeviation)
+ * Elevation (0->360, default 25) -> feDistantLight (elevation)
+ * Azimuth (0->360, default 235) -> feDistantLight (azimuth)
+ * Lighting color (guint, default -1 [white]) -> diffuse (lighting-color)
+*/
+
+class DiffuseLight : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ DiffuseLight ( ) : Filter() { };
+ virtual ~DiffuseLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Diffuse Light") "</name>\n"
+ "<id>org.inkscape.effect.filter.DiffuseLight</id>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n"
+ "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n"
+ "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Bevels") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Basic diffuse bevel to use for building textures") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new DiffuseLight());
+ };
+
+};
+
+gchar const *
+DiffuseLight::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream smooth;
+ std::ostringstream elevation;
+ std::ostringstream azimuth;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+
+ smooth << ext->get_param_float("smooth");
+ elevation << ext->get_param_int("elevation");
+ azimuth << ext->get_param_int("azimuth");
+ guint32 color = ext->get_param_color("color");
+
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Diffuse Light\">\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feDiffuseLighting diffuseConstant=\"1\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"diffuse\">\n"
+ "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
+ "</feDiffuseLighting>\n"
+ "<feComposite in=\"diffuse\" in2=\"diffuse\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"SourceGraphic\" k1=\"%s\" operator=\"arithmetic\" k3=\"1\" result=\"composite2\" />\n"
+ "</filter>\n", smooth.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
+
+ return _filter;
+}; /* DiffuseLight filter */
+
+/**
+ \brief Custom predefined Matte jelly filter.
+
+ Bulging, matte jelly covering
+
+ Filter's parameters:
+ * Smoothness (0.0->10., default 7.) -> blur (stdDeviation)
+ * Brightness (0.0->5., default .9) -> specular (specularConstant)
+ * Elevation (0->360, default 60) -> feDistantLight (elevation)
+ * Azimuth (0->360, default 225) -> feDistantLight (azimuth)
+ * Lighting color (guint, default -1 [white]) -> specular (lighting-color)
+*/
+
+class MatteJelly : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ MatteJelly ( ) : Filter() { };
+ virtual ~MatteJelly ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Matte Jelly") "</name>\n"
+ "<id>org.inkscape.effect.filter.MatteJelly</id>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n"
+ "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n"
+ "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n"
+ "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Bevels") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Bulging, matte jelly covering") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new MatteJelly());
+ };
+
+};
+
+gchar const *
+MatteJelly::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream smooth;
+ std::ostringstream bright;
+ std::ostringstream elevation;
+ std::ostringstream azimuth;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+
+ smooth << ext->get_param_float("smooth");
+ bright << ext->get_param_float("bright");
+ elevation << ext->get_param_int("elevation");
+ azimuth << ext->get_param_int("azimuth");
+ guint32 color = ext->get_param_color("color");
+
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Matte Jelly\">\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.85 0\" result=\"color\" in=\"SourceGraphic\" />\n"
+ "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"5\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n"
+ "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
+ "</feSpecularLighting>\n"
+ "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"color\" operator=\"atop\" result=\"composite2\" />\n"
+ "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
+
+ return _filter;
+}; /* MatteJelly filter */
+
+/**
+ \brief Custom predefined Specular light filter.
+
+ Basic specular bevel to use for building textures
+
+ Filter's parameters:
+ * Smoothness (0.0->10., default 6.) -> blur (stdDeviation)
+ * Brightness (0.0->5., default 1.) -> specular (specularConstant)
+ * Elevation (0->360, default 45) -> feDistantLight (elevation)
+ * Azimuth (0->360, default 235) -> feDistantLight (azimuth)
+ * Lighting color (guint, default -1 [white]) -> specular (lighting-color)
+*/
+
+class SpecularLight : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ SpecularLight ( ) : Filter() { };
+ virtual ~SpecularLight ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Specular Light") "</name>\n"
+ "<id>org.inkscape.effect.filter.SpecularLight</id>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n"
+ "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n"
+ "<param name=\"elevation\" gui-text=\"" N_("Elevation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n"
+ "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Bevels") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Basic specular bevel to use for building textures") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new SpecularLight());
+ };
+
+};
+
+gchar const *
+SpecularLight::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream smooth;
+ std::ostringstream bright;
+ std::ostringstream elevation;
+ std::ostringstream azimuth;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+
+ smooth << ext->get_param_float("smooth");
+ bright << ext->get_param_float("bright");
+ elevation << ext->get_param_int("elevation");
+ azimuth << ext->get_param_int("azimuth");
+ guint32 color = ext->get_param_color("color");
+
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Specular Light\">\n"
+ "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feSpecularLighting in=\"blur\" specularExponent=\"25\" specularConstant=\"%s\" surfaceScale=\"10\" lighting-color=\"rgb(%s,%s,%s)\" result=\"specular\">\n"
+ "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
+ "</feSpecularLighting>\n"
+ "<feComposite in=\"specular\" in2=\"SourceGraphic\" k3=\"1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"SourceAlpha\" operator=\"in\" result=\"composite2\" />\n"
+ "</filter>\n", smooth.str().c_str(), bright.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), elevation.str().c_str(), azimuth.str().c_str(), a.str().c_str());
+
+ return _filter;
+}; /* SpecularLight filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'BEVELS' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BEVELS_H__ */
diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h
new file mode 100644
index 000000000..59790b1be
--- /dev/null
+++ b/src/extension/internal/filter/blurs.h
@@ -0,0 +1,419 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__
+/* Change the 'BLURS' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Blur filters
+ * Blur
+ * Clean edges
+ * Cross blur
+ * Feather
+ * Out of focus
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Blur filter.
+
+ Simple horizontal and vertical blur
+
+ Filter's parameters:
+ * Horizontal blur (0.01->100., default 2) -> blur (stdDeviation)
+ * Vertical blur (0.01->100., default 2) -> blur (stdDeviation)
+ * Blur content only (boolean, default false) ->
+*/
+
+class Blur : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Blur ( ) : Filter() { };
+ virtual ~Blur ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Blur") "</name>\n"
+ "<id>org.inkscape.effect.filter.Blur</id>\n"
+ "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n"
+ "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n"
+ "<param name=\"content\" gui-text=\"" N_("Blur content only") "\" type=\"boolean\">False</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Blurs") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Simple vertical and horizontal blur effect") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Blur());
+ };
+
+};
+
+gchar const *
+Blur::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream bbox;
+ std::ostringstream hblur;
+ std::ostringstream vblur;
+ std::ostringstream content;
+
+ hblur << ext->get_param_float("hblur");
+ vblur << ext->get_param_float("vblur");
+
+ if (ext->get_param_bool("content")) {
+ bbox << "height=\"1\" width=\"1\" y=\"0\" x=\"0\"";
+ content << "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0 \" result=\"colormatrix\" />\n"
+ << "<feComposite in=\"colormatrix\" in2=\"SourceGraphic\" operator=\"in\" />\n";
+ } else {
+ bbox << "" ;
+ content << "" ;
+ }
+
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" %s style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Blur\">\n"
+ "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n"
+ "%s"
+ "</filter>\n", bbox.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), content.str().c_str() );
+
+ return _filter;
+}; /* Blur filter */
+
+/**
+ \brief Custom predefined Clean edges filter.
+
+ Removes or decreases glows and jaggeries around objects edges after applying some filters
+
+ Filter's parameters:
+ * Strength (0.01->2., default 0.4) -> blur (stdDeviation)
+*/
+
+class CleanEdges : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ CleanEdges ( ) : Filter() { };
+ virtual ~CleanEdges ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Clean Edges") "</name>\n"
+ "<id>org.inkscape.effect.filter.CleanEdges</id>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Blurs") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Removes or decreases glows and jaggeries around objects edges after applying some filters") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new CleanEdges());
+ };
+
+};
+
+gchar const *
+CleanEdges::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream blur;
+
+ blur << ext->get_param_float("blur");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Clean Edges\">\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"in\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"composite1\" k2=\"1\" operator=\"in\" result=\"composite2\" />\n"
+ "</filter>\n", blur.str().c_str());
+
+ return _filter;
+}; /* CleanEdges filter */
+
+/**
+ \brief Custom predefined Cross blur filter.
+
+ Combine vertical and horizontal blur
+
+ Filter's parameters:
+ * Brighness (0.->10., default 0) -> composite (k3)
+ * Fading (0.->1., default 0) -> composite (k4)
+ * Horizontal blur (0.01->20., default 5) -> blur (stdDeviation)
+ * Vertical blur (0.01->20., default 5) -> blur (stdDeviation)
+ * Blend mode (enum, default Darken) -> blend (mode)
+*/
+
+class CrossBlur : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ CrossBlur ( ) : Filter() { };
+ virtual ~CrossBlur ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Cross Blur") "</name>\n"
+ "<id>org.inkscape.effect.filter.CrossBlur</id>\n"
+ "<param name=\"bright\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n"
+ "<param name=\"fade\" gui-text=\"" N_("Fading:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n"
+ "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n"
+ "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend:") "\" type=\"enum\">\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Blurs") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Combine vertical and horizontal blur") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new CrossBlur());
+ };
+
+};
+
+gchar const *
+CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream bright;
+ std::ostringstream fade;
+ std::ostringstream hblur;
+ std::ostringstream vblur;
+ std::ostringstream blend;
+
+ bright << ext->get_param_float("bright");
+ fade << ext->get_param_float("fade");
+ hblur << ext->get_param_float("hblur");
+ vblur << ext->get_param_float("vblur");
+ blend << ext->get_param_enum("blend");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Cross Blur\">\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix\" />\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"colormatrix\" operator=\"arithmetic\" k2=\"1\" k3=\"%s\" k4=\"%s\" result=\"composite\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s 0.01\" result=\"blur1\" />\n"
+ "<feGaussianBlur in=\"composite\" stdDeviation=\"0.01 %s\" result=\"blur2\" />\n"
+ "<feBlend in=\"blur2\" in2=\"blur1\" mode=\"%s\" result=\"blend\" />\n"
+ "</filter>\n", bright.str().c_str(), fade.str().c_str(), hblur.str().c_str(), vblur.str().c_str(), blend.str().c_str());
+
+ return _filter;
+}; /* Cross blur filter */
+
+/**
+ \brief Custom predefined Feather filter.
+
+ Blurred mask on the edge without altering the contents
+
+ Filter's parameters:
+ * Strength (0.01->100., default 5) -> blur (stdDeviation)
+*/
+
+class Feather : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Feather ( ) : Filter() { };
+ virtual ~Feather ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Feather") "</name>\n"
+ "<id>org.inkscape.effect.filter.Feather</id>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Blurs") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Blurred mask on the edge without altering the contents") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Feather());
+ };
+
+};
+
+gchar const *
+Feather::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream blur;
+
+ blur << ext->get_param_float("blur");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Feather\">\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n"
+ "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n"
+ "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n"
+ "</filter>\n", blur.str().c_str());
+
+ return _filter;
+}; /* Feather filter */
+
+/**
+ \brief Custom predefined Out of Focus filter.
+
+ Blur eroded by white or transparency
+
+ Filter's parameters:
+ * Horizontal blur (0.01->10., default 3) -> blur (stdDeviation)
+ * Vertical blur (0.01->10., default 3) -> blur (stdDeviation)
+ * Dilatation (n-1th value, 0.->100., default 6) -> colormatrix2 (matrix)
+ * Erosion (nth value, 0.->100., default 2) -> colormatrix2 (matrix)
+ * Opacity (0.->1., default 1.) -> composite1 (k2)
+ * Background color (guint, default -1) -> flood (flood-opacity, flood-color)
+ * Blend type (enum, default normal) -> blend (mode)
+ * Blend to background (boolean, default false) -> blend (false: in2="flood", true: in2="BackgroundImage")
+
+*/
+
+class ImageBlur : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ImageBlur ( ) : Filter() { };
+ virtual ~ImageBlur ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Out of Focus") "</name>\n"
+ "<id>org.inkscape.effect.filter.ImageBlur</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n"
+ "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">6</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">2</param>\n"
+ "<param name=\"opacity\" gui-text=\"" N_("Opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n"
+ "</page>\n"
+ "<page name=\"backgroundtab\" _gui-text=\"Background\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "<param name=\"background\" gui-text=\"" N_("Blend to background") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Blurs") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Blur eroded by white or transparency") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ImageBlur());
+ };
+
+};
+
+gchar const *
+ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream hblur;
+ std::ostringstream vblur;
+ std::ostringstream dilat;
+ std::ostringstream erosion;
+ std::ostringstream opacity;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+ std::ostringstream blend;
+ std::ostringstream background;
+
+ hblur << ext->get_param_float("hblur");
+ vblur << ext->get_param_float("vblur");
+ dilat << ext->get_param_float("dilat");
+ erosion << -ext->get_param_float("erosion");
+ opacity << ext->get_param_float("opacity");
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+ blend << ext->get_param_enum("blend");
+
+ if (ext->get_param_bool("background")) {
+ background << "BackgroundImage" ;
+ } else {
+ background << "flood" ;
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Out of Focus\">\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix1\" />\n"
+ "<feGaussianBlur in=\"colormatrix1\" stdDeviation=\"%s %s\" result=\"blur\" />\n"
+ "<feColorMatrix in=\"blur\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix2\" />\n"
+ "<feBlend in=\"colormatrix2\" in2=\"%s\" mode=\"%s\" result=\"blend\" />\n"
+ "<feComposite in=\"blend\" in2=\"blend\" operator=\"arithmetic\" k2=\"%s\" result=\"composite1\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ hblur.str().c_str(), vblur.str().c_str(), dilat.str().c_str(), erosion.str().c_str(),
+ background.str().c_str(), blend.str().c_str(), opacity.str().c_str());
+
+ return _filter;
+}; /* Out of Focus filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'BLURS' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BLURS_H__ */
diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h
new file mode 100644
index 000000000..8db6c67d2
--- /dev/null
+++ b/src/extension/internal/filter/bumps.h
@@ -0,0 +1,488 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__
+/* Change the 'BUMPS' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Bump filters
+ * Bump
+ * Wax bump
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Bump filter.
+
+ All purpose bump filter
+
+ Filter's parameters:
+ Options
+ * Image simplification (0.01->10., default 0.01) -> blur1 (stdDeviation)
+ * Bump simplification (0.01->10., default 0.01) -> blur2 (stdDeviation)
+ * Crop (-50.->50., default 0.) -> composite1 (k3)
+ * Red (-50.->50., default 0.) -> colormatrix1 (values)
+ * Green (-50.->50., default 0.) -> colormatrix1 (values)
+ * Blue (-50.->50., default 0.) -> colormatrix1 (values)
+ * Bump from background (boolean, default false) -> colormatrix1 (false: in="SourceGraphic", true: in="BackgroundImage")
+ Lighting
+ * Lighting type (enum, default specular) -> lighting block
+ * Height (0.->50., default 5.) -> lighting (surfaceScale)
+ * Lightness (0.->5., default 1.) -> lighting [diffuselighting (diffuseConstant)|specularlighting (specularConstant)]
+ * Precision (1->128, default 15) -> lighting (specularExponent)
+ * Color (guint, default -1 (RGB:255,255,255))-> lighting (lighting-color)
+ Light source
+ * Azimuth (0->360, default 225) -> lightsOptions (distantAzimuth)
+ * Elevation (0->180, default 45) -> lightsOptions (distantElevation)
+ * X location [point] (-5000->5000, default 526) -> lightsOptions (x)
+ * Y location [point] (-5000->5000, default 372) -> lightsOptions (y)
+ * Z location [point] (0->5000, default 150) -> lightsOptions (z)
+ * X location [spot] (-5000->5000, default 526) -> lightsOptions (x)
+ * Y location [spot] (-5000->5000, default 372) -> lightsOptions (y)
+ * Z location [spot] (-5000->5000, default 150) -> lightsOptions (z)
+ * X target (-5000->5000, default 0) -> lightsOptions (pointsAtX)
+ * Y target (-5000->5000, default 0) -> lightsOptions (pointsAtX)
+ * Z target (-5000->0, default -1000) -> lightsOptions (pointsAtX)
+ * Specular exponent (1->100, default 1) -> lightsOptions (specularExponent)
+ * Cone angle (0->100, default 50) -> lightsOptions (limitingConeAngle)
+ Color bump
+ * Blend type (enum, default normal) -> blend (mode)
+ * Image color (guint, default -987158017 (RGB:197,41,41)) -> flood (flood-color)
+ * Color bump (boolean, default false) -> composite2 (false: in="diffuselighting", true in="flood")
+*/
+
+class Bump : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Bump ( ) : Filter() { };
+ virtual ~Bump ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Bump") "</name>\n"
+ "<id>org.inkscape.effect.filter.Bump</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n"
+ "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n"
+ "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n"
+ "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n"
+ "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n"
+ "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n"
+ "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n"
+ "<param name=\"background\" gui-text=\"" N_("Bump from background") "\" indent=\"1\" type=\"boolean\">false</param>\n"
+ "</page>\n"
+ "<page name=\"lightingtab\" _gui-text=\"Lighting\">\n"
+ "<param name=\"lightType\" gui-text=\"" N_("Lighting type:") "\" type=\"enum\">\n"
+ "<_item value=\"specular\">" N_("Specular") "</_item>\n"
+ "<_item value=\"diffuse\">" N_("Diffuse") "</_item>\n"
+ "</param>\n"
+ "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50.\">5</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"5.\">1</param>\n"
+ "<param name=\"precision\" gui-text=\"" N_("Precision:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"128\">15</param>\n"
+ "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n"
+ "</page>\n"
+ "<page name=\"lightsourcetab\" _gui-text=\"" N_("Light source") "\">\n"
+ "<param name=\"lightSource\" gui-text=\"" N_("Light source:") "\" type=\"enum\">\n"
+ "<_item value=\"distant\">" N_("Distant") "</_item>\n"
+ "<_item value=\"point\">" N_("Point") "</_item>\n"
+ "<_item value=\"spot\">" N_("Spot") "</_item>\n"
+ "</param>\n"
+ "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">" N_("Distant light options") "</_param>\n"
+ "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n"
+ "<param name=\"distantElevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">45</param>\n"
+ "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">" N_("Point light options") "</_param>\n"
+ "<param name=\"pointX\" gui-text=\"" N_("X location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n"
+ "<param name=\"pointY\" gui-text=\"" N_("Y location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n"
+ "<param name=\"pointZ\" gui-text=\"" N_("Z location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"5000\">150</param>\n"
+ "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">" N_("Spot light options") "</_param>\n"
+ "<param name=\"spotX\" gui-text=\"" N_("X location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n"
+ "<param name=\"spotY\" gui-text=\"" N_("Y location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n"
+ "<param name=\"spotZ\" gui-text=\"" N_("Z location:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">150</param>\n"
+ "<param name=\"spotAtX\" gui-text=\"" N_("X target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n"
+ "<param name=\"spotAtY\" gui-text=\"" N_("Y target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n"
+ "<param name=\"spotAtZ\" gui-text=\"" N_("Z target:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"0\">-1000</param>\n"
+ "<param name=\"spotExponent\" gui-text=\"" N_("Specular exponent:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"100\">1</param>\n"
+ "<param name=\"spotConeAngle\" gui-text=\"" N_("Cone angle:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"100\">50</param>\n"
+ "</page>\n"
+ "<page name=\"colortab\" _gui-text=\"Color bump\">\n"
+ "<param name=\"imageColor\" gui-text=\"" N_("Image color") "\" type=\"color\">-987158017</param>\n"
+ "<param name=\"colorize\" gui-text=\"" N_("Color bump") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Bumps") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("All purposes bump filter") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Bump());
+ };
+
+};
+
+gchar const *
+Bump::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream simplifyImage;
+ std::ostringstream simplifyBump;
+ std::ostringstream red;
+ std::ostringstream green;
+ std::ostringstream blue;
+ std::ostringstream crop;
+ std::ostringstream bumpSource;
+ std::ostringstream blend;
+
+ std::ostringstream lightStart;
+ std::ostringstream lightOptions;
+ std::ostringstream lightEnd;
+
+ std::ostringstream lightRed;
+ std::ostringstream lightGreen;
+ std::ostringstream lightBlue;
+ std::ostringstream floodRed;
+ std::ostringstream floodGreen;
+ std::ostringstream floodBlue;
+ std::ostringstream floodAlpha;
+ std::ostringstream colorize;
+
+
+ simplifyImage << ext->get_param_float("simplifyImage");
+ simplifyBump << ext->get_param_float("simplifyBump");
+ red << ext->get_param_float("red");
+ green << ext->get_param_float("green");
+ blue << ext->get_param_float("blue");
+ crop << ext->get_param_float("crop");
+ blend << ext->get_param_enum("blend");
+
+ guint32 lightingColor = ext->get_param_color("lightingColor");
+ guint32 imageColor = ext->get_param_color("imageColor");
+
+ if (ext->get_param_bool("background")) {
+ bumpSource << "BackgroundImage" ;
+ } else {
+ bumpSource << "blur1" ;
+ }
+
+ const gchar *lightType = ext->get_param_enum("lightType");
+ if ((g_ascii_strcasecmp("specular", lightType) == 0)) {
+ // Specular
+ lightStart << "<feSpecularLighting lighting-color=\"rgb(" << ((lightingColor >> 24) & 0xff) << ","
+ << ((lightingColor >> 16) & 0xff) << "," << ((lightingColor >> 8) & 0xff) << ")\" surfaceScale=\""
+ << ext->get_param_float("height") << "\" specularConstant=\"" << ext->get_param_float("lightness")
+ << "\" specularExponent=\"" << ext->get_param_int("precision") << "\" result=\"lighting\">";
+ lightEnd << "</feSpecularLighting>";
+ } else {
+ // Diffuse
+ lightStart << "<feDiffuseLighting lighting-color=\"rgb(" << ((lightingColor >> 24) & 0xff) << ","
+ << ((lightingColor >> 16) & 0xff) << "," << ((lightingColor >> 8) & 0xff) << ")\" surfaceScale=\""
+ << ext->get_param_float("height") << "\" diffuseConstant=\"" << ext->get_param_float("lightness")
+ << "\" result=\"lighting\">";
+ lightEnd << "</feDiffuseLighting>";
+ }
+
+ const gchar *lightSource = ext->get_param_enum("lightSource");
+ if ((g_ascii_strcasecmp("distant", lightSource) == 0)) {
+ // Distant
+ lightOptions << "<feDistantLight azimuth=\"" << ext->get_param_int("distantAzimuth") << "\" elevation=\""
+ << ext->get_param_int("distantElevation") << "\" />";
+ } else if ((g_ascii_strcasecmp("point", lightSource) == 0)) {
+ // Point
+ lightOptions << "<fePointLight z=\"" << ext->get_param_int("pointX") << "\" y=\"" << ext->get_param_int("pointY")
+ << "\" x=\"" << ext->get_param_int("pointZ") << "\" />";
+ } else {
+ // Spot
+ lightOptions << "<feSpotLight x=\"" << ext->get_param_int("pointX") << "\" y=\"" << ext->get_param_int("pointY")
+ << "\" z=\"" << ext->get_param_int("pointZ") << "\" pointsAtX=\"" << ext->get_param_int("spotAtX")
+ << "\" pointsAtY=\"" << ext->get_param_int("spotAtY") << "\" pointsAtZ=\"" << ext->get_param_int("spotAtZ")
+ << "\" specularExponent=\"" << ext->get_param_int("spotExponent")
+ << "\" limitingConeAngle=\"" << ext->get_param_int("spotConeAngle")
+ << "\" />";
+ }
+
+ floodRed << ((imageColor >> 24) & 0xff);
+ floodGreen << ((imageColor >> 16) & 0xff);
+ floodBlue << ((imageColor >> 8) & 0xff);
+ floodAlpha << (imageColor & 0xff) / 255.0F;
+
+ if (ext->get_param_bool("colorize")) {
+ colorize << "flood" ;
+ } else {
+ colorize << "blur1" ;
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Bump\">\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s 1 0 \" result=\"colormatrix1\" />\n"
+ "<feColorMatrix in=\"colormatrix1\" type=\"luminanceToAlpha\" result=\"colormatrix2\" />\n"
+ "<feComposite in2=\"blur1\" operator=\"arithmetic\" k2=\"1\" k3=\"%s\" result=\"composite1\" />\n"
+ "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
+ "%s\n"
+ "%s\n"
+ "%s\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood\" />\n"
+ "<feComposite in=\"lighting\" in2=\"%s\" operator=\"arithmetic\" k3=\"1\" k2=\"1\" result=\"composite2\" />\n"
+ "<feBlend in2=\"SourceGraphic\" mode=\"%s\" result=\"blend\" />\n"
+ "<feComposite in=\"blend\" in2=\"SourceGraphic\" operator=\"in\" k2=\"1\" result=\"composite3\" />\n"
+ "</filter>\n", simplifyImage.str().c_str(), bumpSource.str().c_str(), red.str().c_str(), green.str().c_str(), blue.str().c_str(),
+ crop.str().c_str(), simplifyBump.str().c_str(),
+ lightStart.str().c_str(), lightOptions.str().c_str(), lightEnd.str().c_str(),
+ floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(),
+ colorize.str().c_str(), blend.str().c_str());
+
+ return _filter;
+
+}; /* Bump filter */
+
+/**
+ \brief Custom predefined Wax Bump filter.
+
+ Turns an image to jelly
+
+ Filter's parameters:
+ Options
+ * Image simplification (0.01->10., default 1.5) -> blur1 (stdDeviation)
+ * Bump simplification (0.01->10., default 1) -> blur2 (stdDeviation)
+ * Crop (-10.->10., default 1.) -> colormatrix2 (4th value of the last line)
+ * Red (-10.->10., default 0.) -> colormatrix2 (values, substract 0.21)
+ * Green (-10.->10., default 0.) -> colormatrix2 (values, substract 0.72)
+ * Blue (-10.->10., default 0.) -> colormatrix2 (values, substract 0.07)
+ * Background (enum, default color) ->
+ * color: colormatrix1 (in="flood1")
+ * image: colormatrix1 (in="SourceGraphic")
+ * blurred image: colormatrix1 (in="blur1")
+ * Background opacity (0.->1., default 0) -> colormatrix1 (last value)
+ Lighting (specular, distant light)
+ * Color (guint, default -1 (RGB:255,255,255))-> lighting (lighting-color)
+ * Height (-50.->50., default 5.) -> lighting (surfaceScale)
+ * Lightness (0.->10., default 1.4) -> lighting [diffuselighting (diffuseConstant)|specularlighting (specularConstant)]
+ * Precision (0->50, default 35) -> lighting (specularExponent)
+ * Azimuth (0->360, default 225) -> lightsOptions (distantAzimuth)
+ * Elevation (0->180, default 60) -> lightsOptions (distantElevation)
+ * Lighting blend (enum, default screen) -> blend1 (mode)
+ * Highlight blend (enum, default screen) -> blend2 (mode)
+ Bump
+ * Trasparency type (enum [in,atop], default atop) -> composite2 (operator)
+ * Color (guint, default -520083713 (RGB:225,0,38)) -> flood2 (flood-color)
+ * Revert bump (boolean, default false) -> composite1 (false: operator="out", true operator="in")
+*/
+
+class WaxBump : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ WaxBump ( ) : Filter() { };
+ virtual ~WaxBump ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Wax Bump") "</name>\n"
+ "<id>org.inkscape.effect.filter.WaxBump</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n"
+ "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n"
+ "<param name=\"crop\" gui-text=\"" N_("Crop:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n"
+ "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n"
+ "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n"
+ "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n"
+ "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n"
+ "<param name=\"background\" gui-text=\"" N_("Background:") "\" type=\"enum\">\n"
+ "<_item value=\"flood1\">" N_("Color") "</_item>\n"
+ "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
+ "<_item value=\"blur1\">" N_("Blurred image") "</_item>\n"
+ "</param>\n"
+ "<param name=\"bgopacity\" gui-text=\"" N_("Background opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n"
+ "</page>\n"
+ "<page name=\"lightingtab\" _gui-text=\"" N_("Lighting") "\">\n"
+ "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n"
+ "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n"
+ "<param name=\"precision\" gui-text=\"" N_("Precision:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n"
+ "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n"
+ "<param name=\"distantElevation\" gui-text=\"" N_("Elevation:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n"
+ "<param name=\"lightingblend\" gui-text=\"" N_("Lighting blend:") "\" type=\"enum\">\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "<param name=\"highlightblend\" gui-text=\"" N_("Highlight blend:") "\" type=\"enum\">\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "<page name=\"colortab\" _gui-text=\"Bump\">\n"
+ "<param name=\"imageColor\" gui-text=\"" N_("Bump color") "\" type=\"color\">-520083713</param>\n"
+ "<param name=\"revert\" gui-text=\"" N_("Revert bump") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"transparency\" gui-text=\"" N_("Transparency type:") "\" type=\"enum\">\n"
+ "<_item value=\"atop\">" N_("Atop") "</_item>\n"
+ "<_item value=\"in\">" N_("In") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Bumps") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Turns an image to jelly") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new WaxBump());
+ };
+
+};
+
+gchar const *
+WaxBump::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream simplifyImage;
+ std::ostringstream simplifyBump;
+ std::ostringstream crop;
+
+ std::ostringstream red;
+ std::ostringstream green;
+ std::ostringstream blue;
+
+ std::ostringstream background;
+ std::ostringstream bgopacity;
+
+ std::ostringstream height;
+ std::ostringstream lightness;
+ std::ostringstream precision;
+ std::ostringstream distantAzimuth;
+ std::ostringstream distantElevation;
+
+ std::ostringstream lightRed;
+ std::ostringstream lightGreen;
+ std::ostringstream lightBlue;
+
+ std::ostringstream floodRed;
+ std::ostringstream floodGreen;
+ std::ostringstream floodBlue;
+ std::ostringstream floodAlpha;
+
+ std::ostringstream revert;
+ std::ostringstream lightingblend;
+ std::ostringstream highlightblend;
+ std::ostringstream transparency;
+
+ simplifyImage << ext->get_param_float("simplifyImage");
+ simplifyBump << ext->get_param_float("simplifyBump");
+ crop << ext->get_param_float("crop");
+
+ red << ext->get_param_float("red") - 0.21;
+ green << ext->get_param_float("green") - 0.72;
+ blue << ext->get_param_float("blue") - 0.07;
+
+ background << ext->get_param_enum("background");
+ bgopacity << ext->get_param_float("bgopacity");
+
+ height << ext->get_param_float("height");
+ lightness << ext->get_param_float("lightness");
+ precision << ext->get_param_int("precision");
+ distantAzimuth << ext->get_param_int("distantAzimuth");
+ distantElevation << ext->get_param_int("distantElevation");
+
+ guint32 lightingColor = ext->get_param_color("lightingColor");
+ lightRed << ((lightingColor >> 24) & 0xff);
+ lightGreen << ((lightingColor >> 16) & 0xff);
+ lightBlue << ((lightingColor >> 8) & 0xff);
+
+ guint32 imageColor = ext->get_param_color("imageColor");
+ floodRed << ((imageColor >> 24) & 0xff);
+ floodGreen << ((imageColor >> 16) & 0xff);
+ floodBlue << ((imageColor >> 8) & 0xff);
+ floodAlpha << (imageColor & 0xff) / 255.0F;
+
+ if (ext->get_param_bool("revert")) {
+ revert << "in" ;
+ } else {
+ revert << "out" ;
+ }
+
+ lightingblend << ext->get_param_enum("lightingblend");
+ highlightblend << ext->get_param_enum("highlightblend");
+ transparency << ext->get_param_enum("transparency");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Wax Bump\">\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feFlood flood-opacity=\"1\" flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
+ "<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 %s \" result=\"colormatrix1\" />\n"
+ "<feColorMatrix in=\"blur1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 %s %s %s %s 0 \" result=\"colormatrix2\" />\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
+ "<feComposite in=\"flood2\" in2=\"colormatrix2\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
+ "<feSpecularLighting in=\"blur2\" lighting-color=\"rgb(%s,%s,%s)\" specularConstant=\"%s\" surfaceScale=\"%s\" specularExponent=\"%s\" result=\"specular\">\n"
+ "<feDistantLight elevation=\"%s\" azimuth=\"%s\" />\n"
+ "</feSpecularLighting>\n"
+ "<feBlend in=\"specular\" in2=\"blur2\" specularConstant=\"1\" mode=\"%s\" result=\"blend1\" />\n"
+ "<feComposite in=\"blend1\" in2=\"blur2\" k2=\"0\" operator=\"%s\" k1=\"0.5\" k3=\"0.5\" k4=\"0\" result=\"composite2\" />\n"
+ "<feMerge result=\"merge\">\n"
+ "<feMergeNode in=\"colormatrix1\" />\n"
+ "<feMergeNode in=\"composite2\" />\n"
+ "</feMerge>\n"
+ "<feBlend in2=\"composite2\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feComposite in=\"blend2\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite3\" />\n"
+ "</filter>\n", simplifyImage.str().c_str(), background.str().c_str(), bgopacity.str().c_str(),
+ red.str().c_str(), green.str().c_str(), blue.str().c_str(), crop.str().c_str(),
+ floodRed.str().c_str(), floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(),
+ revert.str().c_str(), simplifyBump.str().c_str(),
+ lightRed.str().c_str(), lightGreen.str().c_str(), lightBlue.str().c_str(),
+ lightness.str().c_str(), height.str().c_str(), precision.str().c_str(),
+ distantElevation.str().c_str(), distantAzimuth.str().c_str(),
+ lightingblend.str().c_str(), transparency.str().c_str(), highlightblend.str().c_str() );
+
+ return _filter;
+
+}; /* Wax bump filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'BUMPS' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_BUMPS_H__ */
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index cdf8ffe90..b6b194c8b 100755..100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -1,5 +1,5 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__
/* Change the 'COLOR' above to be your file name */
/*
@@ -8,12 +8,19 @@
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
* Color filters
- * Brightness
+ * Brilliance
+ * Channel painting
+ * Color shift
* Colorize
+ * Component transfer
* Duochrome
- * Electrize
+ * Extract channel
+ * Fade to black or white
* Greyscale
- * Lightness
+ * Invert
+ * Lighting
+ * Lightness-contrast
+ * Nudge
* Quadritone
* Solarize
* Tritone
@@ -34,14 +41,15 @@ namespace Internal {
namespace Filter {
/**
- \brief Custom predefined Brightness filter.
+ \brief Custom predefined Brilliance filter.
- Brightness filter.
+ Brilliance filter.
Filter's parameters:
- * Strength (-10.->10., default 10) -> colorMatrix (RVB entries [/10])
- * Vibration (-10.->10., default 0.) -> colorMatrix (6 other entries [/10])
- * Lightness (-10.->10., default 0.) -> colorMatrix (last column [/10])
+ * Brilliance (1.->10., default 2.) -> colorMatrix (RVB entries)
+ * Over-saturation (0.->10., default 0.5) -> colorMatrix (6 other entries)
+ * Lightness (-10.->10., default 0.) -> colorMatrix (last column)
+ * Inverted (boolean, default false) -> colorMatrix
Matrix:
St Vi Vi 0 Li
@@ -49,58 +57,236 @@ namespace Filter {
Vi Vi St 0 Li
0 0 0 1 0
*/
-class Brightness : public Inkscape::Extension::Internal::Filter::Filter {
+class Brilliance : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
- Brightness ( ) : Filter() { };
- virtual ~Brightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+ Brilliance ( ) : Filter() { };
+ virtual ~Brilliance ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Brightness, custom (Color)") "</name>\n"
- "<id>org.inkscape.effect.filter.Brightness</id>\n"
- "<param name=\"strength\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">10</param>\n"
- "<param name=\"vibration\" gui-text=\"" N_("Vibration:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">0</param>\n"
- "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">0</param>\n"
+ "<name>" N_("Brilliance") "</name>\n"
+ "<id>org.inkscape.effect.filter.Brilliance</id>\n"
+ "<param name=\"brightness\" gui-text=\"" N_("Brightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n"
+ "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n"
+ "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Brightness filter") "</menu-tip>\n"
"</effect>\n"
- "</inkscape-extension>\n", new Brightness());
+ "</inkscape-extension>\n", new Brilliance());
};
};
gchar const *
-Brightness::get_filter_text (Inkscape::Extension::Extension * ext)
+Brilliance::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- std::ostringstream strength;
- std::ostringstream vibration;
+ std::ostringstream brightness;
+ std::ostringstream sat;
std::ostringstream lightness;
- strength << (ext->get_param_float("strength") / 10);
- vibration << (ext->get_param_float("vibration") / 10);
- lightness << (ext->get_param_float("lightness") / 10);
+ if (ext->get_param_bool("invert")) {
+ brightness << -ext->get_param_float("brightness");
+ sat << 1 + ext->get_param_float("sat");
+ lightness << -ext->get_param_float("lightness");
+ } else {
+ brightness << ext->get_param_float("brightness");
+ sat << -ext->get_param_float("sat");
+ lightness << ext->get_param_float("lightness");
+ }
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Brightness, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Brilliance\">\n"
"<feColorMatrix values=\"%s %s %s 0 %s %s %s %s 0 %s %s %s %s 0 %s 0 0 0 1 0 \" />\n"
- "</filter>\n", strength.str().c_str(), vibration.str().c_str(), vibration.str().c_str(),
- lightness.str().c_str(), vibration.str().c_str(), strength.str().c_str(),
- vibration.str().c_str(), lightness.str().c_str(), vibration.str().c_str(),
- vibration.str().c_str(), strength.str().c_str(), lightness.str().c_str());
+ "</filter>\n", brightness.str().c_str(), sat.str().c_str(), sat.str().c_str(),
+ lightness.str().c_str(), sat.str().c_str(), brightness.str().c_str(),
+ sat.str().c_str(), lightness.str().c_str(), sat.str().c_str(),
+ sat.str().c_str(), brightness.str().c_str(), lightness.str().c_str() );
+
+ return _filter;
+}; /* Brilliance filter */
+
+/**
+ \brief Custom predefined Channel Painting filter.
+
+ Channel Painting filter.
+
+ Filter's parameters:
+ * Saturation (0.->1., default 1.) -> colormatrix1 (values)
+ * Red (-10.->10., default -1.) -> colormatrix2 (values)
+ * Green (-10.->10., default 0.5) -> colormatrix2 (values)
+ * Blue (-10.->10., default 0.5) -> colormatrix2 (values)
+ * Alpha (-10.->10., default 1.) -> colormatrix2 (values)
+ * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color)
+ * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out')
+
+ Matrix:
+ 1 0 0 0 0
+ 0 1 0 0 0
+ 0 0 1 0 0
+ R G B A 0
+*/
+class ChannelPaint : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ChannelPaint ( ) : Filter() { };
+ virtual ~ChannelPaint ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Channel Painting") "</name>\n"
+ "<id>org.inkscape.effect.filter.ChannelPaint</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n"
+ "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n"
+ "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n"
+ "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n"
+ "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n"
+ "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
+ "</page>\n"
+ "<page name=\"colortab\" _gui-text=\"Color\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">16777215</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Replace RGB by any color") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ChannelPaint());
+ };
+};
+
+gchar const *
+ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream saturation;
+ std::ostringstream red;
+ std::ostringstream green;
+ std::ostringstream blue;
+ std::ostringstream alpha;
+ std::ostringstream invert;
+ std::ostringstream floodRed;
+ std::ostringstream floodGreen;
+ std::ostringstream floodBlue;
+ std::ostringstream floodAlpha;
+
+ saturation << ext->get_param_float("saturation");
+ red << ext->get_param_float("red");
+ green << ext->get_param_float("green");
+ blue << ext->get_param_float("blue");
+ alpha << ext->get_param_float("alpha");
+
+ guint32 color = ext->get_param_color("color");
+ floodRed << ((color >> 24) & 0xff);
+ floodGreen << ((color >> 16) & 0xff);
+ floodBlue << ((color >> 8) & 0xff);
+ floodAlpha << (color & 0xff) / 255.0F;
+
+ if (ext->get_param_bool("invert")) {
+ invert << "in";
+ } else {
+ invert << "out";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter inkscape:label=\"Channel Painting\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<feColorMatrix values=\"%s\" type=\"saturate\" result=\"colormatrix1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix2\" />\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood\" />\n"
+ "<feComposite in2=\"colormatrix2\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feMerge result=\"merge\">\n"
+ "<feMergeNode in=\"colormatrix1\" />\n"
+ "<feMergeNode in=\"composite1\" />\n"
+ "</feMerge>\n"
+ "<feComposite in=\"merge\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
+ "</filter>\n", saturation.str().c_str(), red.str().c_str(), green.str().c_str(),
+ blue.str().c_str(), alpha.str().c_str(), floodRed.str().c_str(),
+ floodGreen.str().c_str(), floodBlue.str().c_str(), floodAlpha.str().c_str(),
+ invert.str().c_str() );
+
+ return _filter;
+}; /* Channel Painting filter */
+
+/**
+ \brief Custom predefined Color shift filter.
+
+ Rotate and desaturate hue
+
+ Filter's parameters:
+ * Shift (0->360, default 330) -> color1 (values)
+ * Saturation (0.->1., default 0.6) -> color2 (values)
+*/
+
+class ColorShift : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ColorShift ( ) : Filter() { };
+ virtual ~ColorShift ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Color Shift") "</name>\n"
+ "<id>org.inkscape.effect.filter.ColorShift</id>\n"
+ "<param name=\"shift\" gui-text=\"" N_("Shift (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n"
+ "<param name=\"sat\" gui-text=\"" N_("Saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Rotate and desaturate hue") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ColorShift());
+ };
+
+};
+
+gchar const *
+ColorShift::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream shift;
+ std::ostringstream sat;
+
+ shift << ext->get_param_int("shift");
+ sat << ext->get_param_float("sat");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Color Shift\">\n"
+ "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"color1\" />\n"
+ "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n"
+ "</filter>\n", shift.str().c_str(), sat.str().c_str() );
return _filter;
-}; /* Brightness filter */
+}; /* ColorShift filter */
/**
\brief Custom predefined Colorize filter.
@@ -127,12 +313,12 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Colorize, custom (Color)") "</name>\n"
+ "<name>" N_("Colorize") "</name>\n"
"<id>org.inkscape.effect.filter.Colorize</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
- "<param name=\"hlight\" gui-text=\"" N_("Harsh light:") "\" type=\"float\" min=\"0\" max=\"10\">0</param>\n"
- "<param name=\"nlight\" gui-text=\"" N_("Normal light:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n"
+ "<param name=\"hlight\" gui-text=\"" N_("Harsh light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n"
+ "<param name=\"nlight\" gui-text=\"" N_("Normal light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n"
"<param name=\"duotone\" gui-text=\"" N_("Duotone") "\" type=\"boolean\" >false</param>\n"
"<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
@@ -157,7 +343,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Blend image or object with a flood color") "</menu-tip>\n"
@@ -192,13 +378,14 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext)
nlight << ext->get_param_float("nlight");
blend1 << ext->get_param_enum("blend1");
blend2 << ext->get_param_enum("blend2");
- if (ext->get_param_bool("duotone"))
+ if (ext->get_param_bool("duotone")) {
duotone << "0";
- else
+ } else {
duotone << "1";
-
+ }
+
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Colorize, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Colorize\">\n"
"<feComposite in2=\"SourceGraphic\" operator=\"arithmetic\" k1=\"%s\" k2=\"%s\" result=\"composite1\" />\n"
"<feColorMatrix in=\"composite1\" values=\"%s\" type=\"saturate\" result=\"colormatrix1\" />\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood1\" />\n"
@@ -206,11 +393,94 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext)
"<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
"<feColorMatrix in=\"blend2\" values=\"1\" type=\"saturate\" result=\"colormatrix2\" />\n"
"<feComposite in=\"colormatrix2\" in2=\"SourceGraphic\" operator=\"in\" k2=\"1\" result=\"composite2\" />\n"
- "</filter>\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blend1.str().c_str(), blend2.str().c_str());
+ "</filter>\n", hlight.str().c_str(), nlight.str().c_str(), duotone.str().c_str(),
+ a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ blend1.str().c_str(), blend2.str().c_str() );
return _filter;
}; /* Colorize filter */
+/**
+ \brief Custom predefined ComponentTransfer filter.
+
+ Basic component transfer structure.
+
+ Filter's parameters:
+ * Type (enum, default identity) -> component function
+
+*/
+class ComponentTransfer : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ComponentTransfer ( ) : Filter() { };
+ virtual ~ComponentTransfer ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Component Transfer") "</name>\n"
+ "<id>org.inkscape.effect.filter.ComponentTransfer</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
+ "<_item value=\"identity\">" N_("Identity") "</_item>\n"
+ "<_item value=\"table\">" N_("Table") "</_item>\n"
+ "<_item value=\"discrete\">" N_("Discrete") "</_item>\n"
+ "<_item value=\"linear\">" N_("Linear") "</_item>\n"
+ "<_item value=\"gamma\">" N_("Gamma") "</_item>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Basic component transfer structure") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ComponentTransfer());
+ };
+};
+
+gchar const *
+ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream CTfunction;
+ const gchar *type = ext->get_param_enum("type");
+
+ if ((g_ascii_strcasecmp("identity", type) == 0)) {
+ CTfunction << "<feFuncR type=\"identity\" tableValues=\"1 0\" />\n"
+ << "<feFuncG type=\"identity\" tableValues=\"1 0\" />\n"
+ << "<feFuncB type=\"identity\" tableValues=\"1 0\" />\n"
+ << "<feFuncA type=\"identity\" tableValues=\"0 1\" />\n";
+ } else if ((g_ascii_strcasecmp("table", type) == 0)) {
+ CTfunction << "<feFuncR type=\"table\" tableValues=\"0 1 0\" />\n"
+ << "<feFuncG type=\"table\" tableValues=\"0 1 0\" />\n"
+ << "<feFuncB type=\"table\" tableValues=\"0 1 0\" />\n";
+ } else if ((g_ascii_strcasecmp("discrete", type) == 0)) {
+ CTfunction << "<feFuncR tableValues=\"0 0.2 0.4 0.6 0.8 1 1\" type=\"discrete\" />\n"
+ << "<feFuncG tableValues=\"0 0.2 0.4 0.6 0.8 1 1\" type=\"discrete\" />\n"
+ << "<feFuncB tableValues=\"0 0.2 0.4 0.6 0.8 1 1\" type=\"discrete\" />\n";
+ } else if ((g_ascii_strcasecmp("linear", type) == 0)) {
+ CTfunction << "<feFuncR type=\"linear\" slope=\".5\" intercept=\".10\" />\n"
+ << "<feFuncG type=\"linear\" slope=\".5\" intercept=\".10\" />\n"
+ << "<feFuncB type=\"linear\" slope=\".5\" intercept=\".10\" />\n";
+ } else { //Gamma
+ CTfunction << "<feFuncR type=\"gamma\" amplitude=\"3\" exponent=\"3\" offset=\"0.1\" />\n"
+ << "<feFuncG type=\"gamma\" amplitude=\"3\" exponent=\"3\" offset=\"0.1\" />\n"
+ << "<feFuncB type=\"gamma\" amplitude=\"3\" exponent=\"3\" offset=\"0.1\" />\n";
+ }
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Component Transfer\">\n"
+ "<feComponentTransfer>\n"
+ "%s\n"
+ "</feComponentTransfer>\n"
+ "</filter>\n", CTfunction.str().c_str());
+
+ return _filter;
+}; /* ComponentTransfer filter */
/**
\brief Custom predefined Duochrome filter.
@@ -235,11 +505,11 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Duochrome, custom (Color)") "</name>\n"
+ "<name>" N_("Duochrome") "</name>\n"
"<id>org.inkscape.effect.filter.Duochrome</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
- "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level:") "\" type=\"float\" min=\"0\" max=\"2\">0</param>\n"
+ "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"2\">0</param>\n"
"<param name=\"swap\" gui-text=\"" N_("Swap:") "\" type=\"enum\">\n"
"<_item value=\"none\">" N_("No swap") "</_item>\n"
"<_item value=\"full\">" N_("Color and alpha") "</_item>\n"
@@ -258,7 +528,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Convert luminance values to a duochrome palette") "</menu-tip>\n"
@@ -297,17 +567,17 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
b2 << ((color2 >> 8) & 0xff);
fluo << fluorescence;
- if((g_ascii_strcasecmp("full", swaptype) == 0)) {
+ if ((g_ascii_strcasecmp("full", swaptype) == 0)) {
swap1 << "in";
swap2 << "out";
a1 << (color1 & 0xff) / 255.0F;
a2 << (color2 & 0xff) / 255.0F;
- } else if((g_ascii_strcasecmp("color", swaptype) == 0)) {
+ } else if ((g_ascii_strcasecmp("color", swaptype) == 0)) {
swap1 << "in";
swap2 << "out";
a1 << (color2 & 0xff) / 255.0F;
a2 << (color1 & 0xff) / 255.0F;
- } else if((g_ascii_strcasecmp("alpha", swaptype) == 0)) {
+ } else if ((g_ascii_strcasecmp("alpha", swaptype) == 0)) {
swap1 << "out";
swap2 << "in";
a1 << (color2 & 0xff) / 255.0F;
@@ -320,106 +590,201 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Duochrome, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Duochrome\">\n"
"<feColorMatrix type=\"luminanceToAlpha\" result=\"colormatrix1\" />\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood1\" />\n"
"<feComposite in2=\"colormatrix1\" operator=\"%s\" result=\"composite1\" />\n"
- "<feFlood in=\"colormatrix1\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
"<feComposite in2=\"colormatrix1\" result=\"composite2\" operator=\"%s\" />\n"
"<feComposite in=\"composite2\" in2=\"composite1\" k2=\"1\" k3=\"1\" operator=\"arithmetic\" result=\"composite3\" />\n"
"<feColorMatrix in=\"composite3\" type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" result=\"colormatrix2\" />\n"
"<feComposite in=\"colormatrix2\" in2=\"composite3\" operator=\"arithmetic\" k2=\"%s\" result=\"composite4\" />\n"
- "<feBlend in=\"composite4\" in2=\"composite3\" blend=\"normal\" mode=\"normal\" result=\"blend\" />\n"
+ "<feBlend in=\"composite4\" in2=\"composite3\" mode=\"normal\" result=\"blend\" />\n"
"<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
- "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), fluo.str().c_str());
+ "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(),
+ a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(),
+ fluo.str().c_str() );
return _filter;
}; /* Duochrome filter */
/**
- \brief Custom predefined Electrize filter.
+ \brief Custom predefined Extract Channel filter.
- Electro solarization effects.
+ Extract color channel as a transparent image.
Filter's parameters:
- * Simplify (0.01->10., default 2.) -> blur (stdDeviation)
- * Effect type (enum: table or discrete, default "table") -> component (type)
- * Level (0->10, default 3) -> component (tableValues)
- * Inverted (boolean, default false) -> component (tableValues)
+ * Channel (enum, all colors, default Red) -> colormatrix (values)
+ * Background blend (enum, all blend modes, default Multiply) -> blend (mode)
+ * Channel to alpha (boolean, default false) -> colormatrix (values)
+ * Invert (boolean, default false) -> colormatrix (values)
+
*/
-class Electrize : public Inkscape::Extension::Internal::Filter::Filter {
+class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
- Electrize ( ) : Filter() { };
- virtual ~Electrize ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+ ExtractChannel ( ) : Filter() { };
+ virtual ~ExtractChannel ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Electrize, custom (Color)") "</name>\n"
- "<id>org.inkscape.effect.filter.Electrize</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" min=\"0.01\" max=\"10.0\">2.0</param>\n"
- "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
- "<_item value=\"table\">" N_("Table") "</_item>\n"
- "<_item value=\"discrete\">" N_("Discrete") "</_item>\n"
+ "<name>" N_("Extract Channel") "</name>\n"
+ "<id>org.inkscape.effect.filter.ExtractChannel</id>\n"
+ "<param name=\"source\" gui-text=\"" N_("Channel:") "\" type=\"enum\">\n"
+ "<_item value=\"r\">" N_("Red") "</_item>\n"
+ "<_item value=\"g\">" N_("Green") "</_item>\n"
+ "<_item value=\"b\">" N_("Blue") "</_item>\n"
+ "</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
"</param>\n"
- "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" min=\"0\" max=\"10\">3</param>\n"
+ "<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</param>\n"
"<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
- "<menu-tip>" N_("Electro solarization effects") "</menu-tip>\n"
+ "<menu-tip>" N_("Extract color channel as a transparent image") "</menu-tip>\n"
"</effect>\n"
- "</inkscape-extension>\n", new Electrize());
+ "</inkscape-extension>\n", new ExtractChannel());
};
};
gchar const *
-Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
+ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- std::ostringstream blur;
- std::ostringstream type;
- std::ostringstream values;
-
- blur << ext->get_param_float("blur");
- type << ext->get_param_enum("type");
-
- // TransfertComponent table values are calculated based on the effect level and inverted parameters.
- int val = 0;
- int levels = ext->get_param_int("levels") + 1;
- if (ext->get_param_bool("invert"))
- val = 1;
- values << val;
- for ( int step = 1 ; step <= levels ; step++ ) {
- if (val == 1) {
- val = 0;
+ std::ostringstream blend;
+ std::ostringstream colors;
+ std::ostringstream alpha;
+ std::ostringstream invert;
+
+ blend << ext->get_param_enum("blend");
+
+ const gchar *channel = ext->get_param_enum("source");
+ if (ext->get_param_bool("alpha")) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
+ } else if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0";
+ } else {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
+ }
+
+ if (ext->get_param_bool("invert")) {
+ if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ alpha << "-1 0 0 1";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ alpha << "0 -1 0 1";
+ } else {
+ alpha << "0 0 -1 1";
}
- else {
- val = 1;
+ } else {
+ if ((g_ascii_strcasecmp("r", channel) == 0)) {
+ alpha << "1 0 0 0";
+ } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
+ alpha << "0 1 0 0";
+ } else {
+ alpha << "0 0 1 0";
}
- values << " " << val;
}
-
+
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Electrize, custom\">\n"
- "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feComponentTransfer in=\"blur\" stdDeviation=\"2\" result=\"component\" >\n"
- "<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
- "<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
- "<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
- "</feComponentTransfer>\n"
- "</filter>\n", blur.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str());
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Extract Channel\">\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"%s %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feBlend in2=\"BackgroundImage\" mode=\"%s\" result=\"blend\" />\n"
+ "</filter>\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() );
return _filter;
-}; /* Electrize filter */
+}; /* ExtractChannel filter */
+
+/**
+ \brief Custom predefined Fade to Black or White filter.
+
+ Fade to black or white.
+
+ Filter's parameters:
+ * Level (0.->1., default 1.) -> colorMatrix (RVB entries)
+ * Fade to (enum [black|white], default black) -> colorMatrix (RVB entries)
+
+ Matrix
+ black white
+ Lv 0 0 0 0 Lv 0 0 1-lv 0
+ 0 Lv 0 0 0 0 Lv 0 1-lv 0
+ 0 0 Lv 0 0 0 0 Lv 1-lv 0
+ 0 0 0 1 0 0 0 0 1 0
+*/
+class FadeToBW : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ FadeToBW ( ) : Filter() { };
+ virtual ~FadeToBW ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Fade to Black or White") "</name>\n"
+ "<id>org.inkscape.effect.filter.FadeToBW</id>\n"
+ "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n"
+ "<param name=\"fadeto\" gui-text=\"" N_("Fade to:") "\" type=\"enum\">\n"
+ "<_item value=\"black\">" N_("Black") "</_item>\n"
+ "<_item value=\"white\">" N_("White") "</_item>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Fade to black or white") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new FadeToBW());
+ };
+};
+
+gchar const *
+FadeToBW::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream level;
+ std::ostringstream wlevel;
+
+ level << ext->get_param_float("level");
+
+ const gchar *fadeto = ext->get_param_enum("fadeto");
+ if ((g_ascii_strcasecmp("white", fadeto) == 0)) {
+ // White
+ wlevel << (1 - ext->get_param_float("level"));
+ } else {
+ // Black
+ wlevel << "0";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Fade to Black or White\">\n"
+ "<feColorMatrix values=\"%s 0 0 0 %s 0 %s 0 0 %s 0 0 %s 0 %s 0 0 0 1 0\" />\n"
+ "</filter>\n", level.str().c_str(), wlevel.str().c_str(),
+ level.str().c_str(), wlevel.str().c_str(),
+ level.str().c_str(), wlevel.str().c_str() );
+
+ return _filter;
+}; /* Fade to black or white filter */
/**
\brief Custom predefined Greyscale filter.
@@ -427,10 +792,10 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
Customize greyscale components.
Filter's parameters:
- * Red (-100.->100., default 2.1) -> colorMatrix (values [/10])
- * Green (-100.->100., default 7.2) -> colorMatrix (values [/10])
- * Blue (-100.->100., default 0.72) -> colorMatrix (values [/10])
- * Lightness (-100.->100., default 0.) -> colorMatrix (values [/10])
+ * Red (-10.->10., default .21) -> colorMatrix (values)
+ * Green (-10.->10., default .72) -> colorMatrix (values)
+ * Blue (-10.->10., default .072) -> colorMatrix (values)
+ * Lightness (-10.->10., default 0.) -> colorMatrix (values)
* Transparent (boolean, default false) -> matrix structure
Matrix:
@@ -451,18 +816,18 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Greyscale, custom (Color)") "</name>\n"
+ "<name>" N_("Greyscale") "</name>\n"
"<id>org.inkscape.effect.filter.Greyscale</id>\n"
- "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">2.1</param>\n"
- "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\">7.2</param>\n"
- "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" min=\"-100.\" max=\"100.0\">0.72</param>\n"
- "<param name=\"strength\" gui-text=\"" N_("Lightness:") "\" type=\"float\" min=\"-100.\" max=\"100.0\">0</param>\n"
+ "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n"
+ "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n"
+ "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.072</param>\n"
+ "<param name=\"strength\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n"
"<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Customize greyscale components") "</menu-tip>\n"
@@ -487,15 +852,15 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream transparency;
std::ostringstream line;
- red << (ext->get_param_float("red") / 10);
- green << (ext->get_param_float("green") / 10);
- blue << (ext->get_param_float("blue") / 10);
- strength << (ext->get_param_float("strength") / 10);
+ red << ext->get_param_float("red");
+ green << ext->get_param_float("green");
+ blue << ext->get_param_float("blue");
+ strength << ext->get_param_float("strength");
- redt << - (ext->get_param_float("red") / 10);
- greent << - (ext->get_param_float("green") / 10);
- bluet << - (ext->get_param_float("blue") / 10);
- strengtht << 1 - (ext->get_param_float("strength") / 10);
+ redt << - ext->get_param_float("red");
+ greent << - ext->get_param_float("green");
+ bluet << - ext->get_param_float("blue");
+ strengtht << 1 - ext->get_param_float("strength");
if (ext->get_param_bool("transparent")) {
line << "0 0 0 0";
@@ -506,53 +871,192 @@ Greyscale::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Greyscale, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Greyscale\">\n"
"<feColorMatrix values=\"%s 0 %s 0 %s 0 %s 0 \" />\n"
- "</filter>\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str());
+ "</filter>\n", line.str().c_str(), line.str().c_str(), line.str().c_str(), transparency.str().c_str() );
return _filter;
}; /* Greyscale filter */
/**
- \brief Custom predefined Lightness filter.
+ \brief Custom predefined Invert filter.
+
+ Manage hue, lightness and transparency inversions
+
+ Filter's parameters:
+ * Invert hue (boolean, default false) -> color1 (values, true: 180, false: 0)
+ * Invert lightness (boolean, default false) -> color1 (values, true: 180, false: 0; XOR with Invert hue),
+ color2 (values: from a00 to a22, if 1, set -1 and set 1 in ax4, if -1, set 1 and set 0 in ax4)
+ * Invert transparency (boolean, default false) -> color2 (values: negate a30, a31 and a32, substract 1 from a33)
+ * Invert channels (enum, default Red and blue) -> color2 (values -for R&B: swap ax0 and ax2 in the first 3 lines)
+ * Light transparency (0.->1., default 0.) -> color2 (values: a33=a33-x)
+*/
+
+class Invert : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Invert ( ) : Filter() { };
+ virtual ~Invert ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Invert") "</name>\n"
+ "<id>org.inkscape.effect.filter.Invert</id>\n"
+ "<param name=\"channels\" gui-text=\"" N_("Invert channels:") "\" type=\"enum\">\n"
+ "<_item value=\"0\">" N_("No inversion") "</_item>\n"
+ "<_item value=\"1\">" N_("Red and blue") "</_item>\n"
+ "<_item value=\"2\">" N_("Red and green") "</_item>\n"
+ "<_item value=\"3\">" N_("Green and blue") "</_item>\n"
+ "</param>\n"
+ "<param name=\"opacify\" gui-text=\"" N_("Light transparency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n"
+ "<param name=\"hue\" gui-text=\"" N_("Invert hue") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Invert lightness") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"transparency\" gui-text=\"" N_("Invert transparency") "\" type=\"boolean\" >false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Manage hue, lightness and transparency inversions") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Invert());
+ };
+
+};
+
+gchar const *
+Invert::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream line1;
+ std::ostringstream line2;
+ std::ostringstream line3;
+
+ std::ostringstream col5;
+ std::ostringstream transparency;
+ std::ostringstream hue;
+
+ if (ext->get_param_bool("hue") xor ext->get_param_bool("lightness")) {
+ hue << "<feColorMatrix type=\"hueRotate\" values=\"180\" result=\"color1\" />\n";
+ } else {
+ hue << "";
+ }
+
+ if (ext->get_param_bool("transparency")) {
+ transparency << "0.21 0.72 0.07 " << 1 - ext->get_param_float("opacify");
+ } else {
+ transparency << "-0.21 -0.72 -0.07 " << 2 - ext->get_param_float("opacify");
+ }
+
+ if (ext->get_param_bool("lightness")) {
+ switch (atoi(ext->get_param_enum("channels"))) {
+ case 1:
+ line1 << "0 0 -1";
+ line2 << "0 -1 0";
+ line3 << "-1 0 0";
+ break;
+ case 2:
+ line1 << "0 -1 0";
+ line2 << "-1 0 0";
+ line3 << "0 0 -1";
+ break;
+ case 3:
+ line1 << "-1 0 0";
+ line2 << "0 0 -1";
+ line3 << "0 -1 0";
+ break;
+ default:
+ line1 << "-1 0 0";
+ line2 << "0 -1 0";
+ line3 << "0 0 -1";
+ break;
+ }
+ col5 << "1";
+ } else {
+ switch (atoi(ext->get_param_enum("channels"))) {
+ case 1:
+ line1 << "0 0 1";
+ line2 << "0 1 0";
+ line3 << "1 0 0";
+ break;
+ case 2:
+ line1 << "0 1 0";
+ line2 << "1 0 0";
+ line3 << "0 0 1";
+ break;
+ case 3:
+ line1 << "1 0 0";
+ line2 << "0 0 1";
+ line3 << "0 1 0";
+ break;
+ default:
+ line1 << "1 0 0";
+ line2 << "0 1 0";
+ line3 << "0 0 1";
+ break;
+ }
+ col5 << "0";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Invert\">\n"
+ "%s"
+ "<feColorMatrix values=\"%s 0 %s %s 0 %s %s 0 %s %s 0 \" result=\"color2\" />\n"
+ "</filter>\n", hue.str().c_str(),
+ line1.str().c_str(), col5.str().c_str(),
+ line2.str().c_str(), col5.str().c_str(),
+ line3.str().c_str(), col5.str().c_str(),
+ transparency.str().c_str() );
+
+ return _filter;
+}; /* Invert filter */
+
+/**
+ \brief Custom predefined Lighting filter.
Modify lights and shadows separately.
Filter's parameters:
- * Lightness (0.->200., default 10.) -> component (amplitude [/10])
- * Shadow (0.->200., default 10.) -> component (exponent [/10])
- * Offset (-10.->10., default 0.) -> component (offset [/10])
+ * Lightness (0.->20., default 1.) -> component (amplitude)
+ * Shadow (0.->20., default 1.) -> component (exponent)
+ * Offset (-1.->1., default 0.) -> component (offset)
*/
-class Lightness : public Inkscape::Extension::Internal::Filter::Filter {
+class Lighting : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
- Lightness ( ) : Filter() { };
- virtual ~Lightness ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+ Lighting ( ) : Filter() { };
+ virtual ~Lighting ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Lightness, custom (Color)") "</name>\n"
- "<id>org.inkscape.effect.filter.Lightness</id>\n"
- "<param name=\"amplitude\" gui-text=\"" N_("Lights:") "\" type=\"float\" min=\"0.0\" max=\"200.0\">10.0</param>\n"
- "<param name=\"exponent\" gui-text=\"" N_("Shadows:") "\" type=\"float\" min=\"0.0\" max=\"200.0\">10.0</param>\n"
- "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"float\" min=\"-10.\" max=\"10.0\">0.0</param>\n"
+ "<name>" N_("Lighting") "</name>\n"
+ "<id>org.inkscape.effect.filter.Lighting</id>\n"
+ "<param name=\"amplitude\" gui-text=\"" N_("Lights:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n"
+ "<param name=\"exponent\" gui-text=\"" N_("Shadows:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n"
+ "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-1.00\" max=\"1.00\">0</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Modify lights and shadows separately") "</menu-tip>\n"
"</effect>\n"
- "</inkscape-extension>\n", new Lightness());
+ "</inkscape-extension>\n", new Lighting());
};
};
gchar const *
-Lightness::get_filter_text (Inkscape::Extension::Extension * ext)
+Lighting::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
@@ -560,23 +1064,240 @@ Lightness::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream exponent;
std::ostringstream offset;
- amplitude << (ext->get_param_float("amplitude") / 10);
- exponent << (ext->get_param_float("exponent") / 10);
- offset << (ext->get_param_float("offset") / 10);
+ amplitude << ext->get_param_float("amplitude");
+ exponent << ext->get_param_float("exponent");
+ offset << ext->get_param_float("offset");
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Lightness, custom\">\n"
- "<feComponentTransfer in=\"blur\" stdDeviation=\"2\" result=\"component\" >\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Lighting\">\n"
+ "<feComponentTransfer in=\"blur\" result=\"component\" >\n"
"<feFuncR type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
"<feFuncG type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
"<feFuncB type=\"gamma\" amplitude=\"%s\" exponent=\"%s\" offset=\"%s\" />\n"
"</feComponentTransfer>\n"
"</filter>\n", amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(),
- amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(),
- amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str());
+ amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str(),
+ amplitude.str().c_str(), exponent.str().c_str(), offset.str().c_str() );
return _filter;
-}; /* Lightness filter */
+}; /* Lighting filter */
+
+/**
+ \brief Custom predefined Lightness-Contrast filter.
+
+ Modify lightness and contrast separately.
+
+ Filter's parameters:
+ * Lightness (0.->100., default 0.) -> colorMatrix
+ * Contrast (0.->100., default 0.) -> colorMatrix
+
+ Matrix:
+ Co/10 0 0 1+(Co-1)*Li/2000 -(Co-1)/20
+ 0 Co/10 0 1+(Co-1)*Li/2000 -(Co-1)/20
+ 0 0 Co/10 1+(Co-1)*Li/2000 -(Co-1)/20
+ 0 0 0 1 0
+*/
+class LightnessContrast : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ LightnessContrast ( ) : Filter() { };
+ virtual ~LightnessContrast ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Lightness-Contrast") "</name>\n"
+ "<id>org.inkscape.effect.filter.LightnessContrast</id>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n"
+ "<param name=\"contrast\" gui-text=\"" N_("Contrast:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Modify lightness and contrast separately") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new LightnessContrast());
+ };
+};
+
+gchar const *
+LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream lightness;
+ std::ostringstream contrast;
+ std::ostringstream contrast5;
+
+ gfloat c5;
+ if (ext->get_param_float("contrast") > 0) {
+ contrast << (1 + ext->get_param_float("contrast") / 10);
+ c5 = (- ext->get_param_float("contrast") / 20);
+ } else {
+ contrast << (1 + ext->get_param_float("contrast") / 100);
+ c5 =(- ext->get_param_float("contrast") / 200);
+ }
+
+ contrast5 << c5;
+ lightness << ((1 - c5) * ext->get_param_float("lightness") / 100);
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Lightness-Contrast\">\n"
+ "<feColorMatrix values=\"%s 0 0 %s %s 0 %s 0 %s %s 0 0 %s %s %s 0 0 0 1 0\" />\n"
+ "</filter>\n", contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(),
+ contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str(),
+ contrast.str().c_str(), lightness.str().c_str(), contrast5.str().c_str() );
+
+ return _filter;
+}; /* Lightness-Contrast filter */
+
+/**
+ \brief Custom predefined Nudge filter.
+
+ Nudge separately RGB channels and blend them to different types of backgrounds
+
+ Filter's parameters:
+ Offsets
+ * Red
+ * x (-100.->100., default -7) -> offset1 (dx)
+ * y (-100.->100., default 5) -> offset1 (dy)
+ * Green
+ * x (-100.->100., default 0) -> offset2 (dx)
+ * y (-100.->100., default 10) -> offset2 (dy)
+ * Blue
+ * x (-100.->100., default 3) -> offset3 (dx)
+ * y (-100.->100., default -9) -> offset3 (dy)
+ Color
+ * Background color (guint, default -1)-> flood (flood-color, flood-opacity)
+ * Blend type (enum [normal,multiply and screen], default screen) -> blend1,2,3 (mode)
+ * Blend source (enum, default color) ->
+ * color: blend1 (in="flood")
+ * image: blend1 (in="SourceGraphic")
+ * background: blend1 (in="BackgroundImage")
+ * Composite (enum [in,over], default over) -> composite (operator)
+
+*/
+class Nudge : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Nudge ( ) : Filter() { };
+ virtual ~Nudge ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Nudge") "</name>\n"
+ "<id>org.inkscape.effect.filter.Nudge</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"offsettab\" _gui-text=\"Offset\">\n"
+ "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n"
+ "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-7</param>\n"
+ "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">5</param>\n"
+ "<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n"
+ "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">0</param>\n"
+ "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">10</param>\n"
+ "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n"
+ "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">3</param>\n"
+ "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-9</param>\n"
+ "</page>\n"
+ "<page name=\"coltab\" _gui-text=\"Color\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "</param>\n"
+ "<param name=\"source\" gui-text=\"" N_("Blend source:") "\" type=\"enum\">\n"
+ "<_item value=\"flood\">" N_("Color") "</_item>\n"
+ "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
+ "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n"
+ "</param>\n"
+ "<param name=\"composite\" gui-text=\"" N_("Composite:") "\" type=\"enum\">\n"
+ "<_item value=\"over\">" N_("Over") "</_item>\n"
+ "<_item value=\"in\">" N_("In") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Nudge());
+ };
+};
+
+gchar const *
+Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream rx;
+ std::ostringstream ry;
+ std::ostringstream gx;
+ std::ostringstream gy;
+ std::ostringstream bx;
+ std::ostringstream by;
+
+ std::ostringstream blend;
+ std::ostringstream source;
+ std::ostringstream composite;
+
+ std::ostringstream a;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+
+ rx << ext->get_param_float("rx");
+ ry << ext->get_param_float("ry");
+ gx << ext->get_param_float("gx");
+ gy << ext->get_param_float("gy");
+ bx << ext->get_param_float("bx");
+ by << ext->get_param_float("by");
+
+ blend << ext->get_param_enum("blend");
+ source << ext->get_param_enum("source");
+ composite << ext->get_param_enum("composite");
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge\">\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
+ "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend1\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 \" result=\"colormatrix2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n"
+ "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 \" result=\"colormatrix3\" />\n"
+ "<feBlend in2=\"offset3\" mode=\"%s\" result=\"blend3\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"%s\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(),
+ gx.str().c_str(), gy.str().c_str(), blend.str().c_str(),
+ bx.str().c_str(), by.str().c_str(), blend.str().c_str(),
+ composite.str().c_str() );
+
+ return _filter;
+
+}; /* Nudge filter */
/**
\brief Custom predefined Quadritone filter.
@@ -602,16 +1323,16 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Quadritone fantasy, custom (Color)") "</name>\n"
+ "<name>" N_("Quadritone fantasy") "</name>\n"
"<id>org.inkscape.effect.filter.Quadritone</id>\n"
- "<param name=\"dist\" gui-text=\"" N_("Hue distribution:") "\" type=\"int\" min=\"0\" max=\"360\">280</param>\n"
- "<param name=\"colors\" gui-text=\"" N_("Colors:") "\" type=\"int\" min=\"0\" max=\"360\">100</param>\n"
+ "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n"
+ "<param name=\"colors\" gui-text=\"" N_("Colors:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n"
"<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
"</param>\n"
- "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" min=\"0\" max=\"1\">0</param>\n"
+ "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">0</param>\n"
"<param name=\"blend2\" gui-text=\"" N_("Blend 2:") "\" type=\"enum\">\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
@@ -623,7 +1344,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Replace hue by two colors") "</menu-tip>\n"
@@ -651,20 +1372,19 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext)
blend2 << ext->get_param_enum("blend2");
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Quadritone fantasy, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Quadritone fantasy\">\n"
"<feColorMatrix in=\"SourceGraphic\" type=\"hueRotate\" values=\"%s\" result=\"colormatrix1\" />\n"
"<feColorMatrix type=\"matrix\" values=\"0.5 0 0.5 0 0 0 1 0 0 0 0.5 0 0.5 0 0 0 0 0 1 0 \" result=\"colormatrix2\" />\n"
"<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"colormatrix3\" />\n"
- "<feBlend in2=\"colormatrix3\" blend=\"normal\" mode=\"%s\" result=\"blend1\" />\n"
+ "<feBlend in2=\"colormatrix3\" mode=\"%s\" result=\"blend1\" />\n"
"<feColorMatrix type=\"matrix\" values=\"2.5 -0.75 -0.75 0 0 -0.75 2.5 -0.75 0 0 -0.75 -0.75 2.5 0 0 0 0 0 1 0 \" result=\"colormatrix4\" />\n"
"<feComposite in=\"colormatrix4\" in2=\"blend1\" operator=\"arithmetic\" k2=\"%s\" result=\"composite1\" />\n"
- "<feBlend in2=\"blend1\" blend=\"normal\" mode=\"%s\" result=\"blend2\" />\n"
- "</filter>\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str());
+ "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
+ "</filter>\n", dist.str().c_str(), colors.str().c_str(), blend1.str().c_str(), sat.str().c_str(), blend2.str().c_str() );
return _filter;
}; /* Quadritone filter */
-
/**
\brief Custom predefined Solarize filter.
@@ -689,9 +1409,9 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Solarize, custom (Color)") "</name>\n"
+ "<name>" N_("Solarize") "</name>\n"
"<id>org.inkscape.effect.filter.Solarize</id>\n"
- "<param name=\"rotate\" gui-text=\"" N_("Hue rotation:") "\" type=\"int\" min=\"0\" max=\"360\">0</param>\n"
+ "<param name=\"rotate\" gui-text=\"" N_("Hue rotation (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n"
"<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
"<_item value=\"solarize\">" N_("Solarize") "</_item>\n"
"<_item value=\"moonarize\">" N_("Moonarize") "</_item>\n"
@@ -700,7 +1420,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Classic photographic solarization effect") "</menu-tip>\n"
@@ -721,7 +1441,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext)
rotate << ext->get_param_int("rotate");
const gchar *type = ext->get_param_enum("type");
- if((g_ascii_strcasecmp("solarize", type) == 0)) {
+ if ((g_ascii_strcasecmp("solarize", type) == 0)) {
// Solarize
blend1 << "darken";
blend2 << "screen";
@@ -732,19 +1452,18 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Solarize, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Solarize\">\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 \" />\n"
"<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"colormatrix2\" />\n"
"<feColorMatrix in=\"colormatrix2\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 \" result=\"colormatrix3\" />\n"
"<feBlend in=\"colormatrix3\" in2=\"colormatrix2\" mode=\"%s\" result=\"blend1\" />\n"
"<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
"<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
- "</filter>\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str());
+ "</filter>\n", rotate.str().c_str(), blend1.str().c_str(), blend2.str().c_str() );
return _filter;
}; /* Solarize filter */
-
/**
\brief Custom predefined Tritone filter.
@@ -752,14 +1471,15 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Option (enum, default Normal) ->
- Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc")
+ Normal = composite1 (in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="composite1")
Enhance hue = Normal + composite2 (in="SourceGraphic")
- Radiation = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc")
+ Phosphorescence = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="composite1")
+ PhosphorescenceB = Normal + blend6 (in2="flood") composite1 (in2="SourceGraphic")
Hue to background = Normal + composite1 (in2="BackgroundImage") [a template with an activated background is needed, or colors become black]
* Hue distribution (0->360, default 0) -> colormatrix1 (values)
* Colors (guint, default -73203457) -> flood (flood-opacity, flood-color)
* Global blend (enum, default Lighten) -> blend5 (mode) [Multiply, Screen, Darken, Lighten only!]
- * Glow (0.01->10., default 0.01) -> feGaussianBlur (stdDeviation)
+ * Glow (0.01->10., default 0.01) -> blur (stdDeviation)
* Glow & blend (enum, default Normal) -> blend6 (mode) [Normal, Multiply and Darken only!]
* Local light (0.->10., default 0) -> composite2 (k1)
* Global light (0.->10., default 1) -> composite2 (k3) [k2 must be fixed to 1].
@@ -776,14 +1496,15 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Tritone, custom (Color)") "</name>\n"
+ "<name>" N_("Tritone") "</name>\n"
"<id>org.inkscape.effect.filter.Tritone</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
"<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"enhue\">" N_("Enhance hue") "</_item>\n"
- "<_item value=\"rad\">" N_("Radiation") "</_item>\n"
+ "<_item value=\"phospho\">" N_("Phosphorescence") "</_item>\n"
+ "<_item value=\"phosphoB\">" N_("Colored nights") "</_item>\n"
"<_item value=\"htb\">" N_("Hue to background") "</_item>\n"
"</param>\n"
"<param name=\"globalblend\" gui-text=\"" N_("Global blend:") "\" type=\"enum\">\n"
@@ -792,17 +1513,17 @@ public:
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"darken\">" N_("Darken") "</_item>\n"
"</param>\n"
- "<param name=\"glow\" gui-text=\"" N_("Glow:") "\" type=\"float\" min=\"0.01\" max=\"10\">0.01</param>\n"
+ "<param name=\"glow\" gui-text=\"" N_("Glow:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10\">0.01</param>\n"
"<param name=\"glowblend\" gui-text=\"" N_("Glow blend:") "\" type=\"enum\">\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"darken\">" N_("Darken") "</_item>\n"
"</param>\n"
- "<param name=\"llight\" gui-text=\"" N_("Local light:") "\" type=\"float\" min=\"0\" max=\"10\">0</param>\n"
- "<param name=\"glight\" gui-text=\"" N_("Global light:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n"
+ "<param name=\"llight\" gui-text=\"" N_("Local light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n"
+ "<param name=\"glight\" gui-text=\"" N_("Global light:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n"
"</page>\n"
"<page name=\"co1tab\" _gui-text=\"Color\">\n"
- "<param name=\"dist\" gui-text=\"" N_("Hue distribution:") "\" type=\"int\" min=\"0\" max=\"360\">0</param>\n"
+ "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n"
"<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">-73203457</param>\n"
"</page>\n"
"</param>\n"
@@ -810,7 +1531,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Create a custom tritone palette with additional glow, blend modes and hue moving") "</menu-tip>\n"
@@ -835,7 +1556,6 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream glowblend;
std::ostringstream llight;
std::ostringstream glight;
- std::ostringstream c1in;
std::ostringstream c1in2;
std::ostringstream c2in;
std::ostringstream c2in2;
@@ -854,58 +1574,63 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext)
glight << ext->get_param_float("glight");
const gchar *type = ext->get_param_enum("type");
- if((g_ascii_strcasecmp("enhue", type) == 0)) {
+ if ((g_ascii_strcasecmp("enhue", type) == 0)) {
// Enhance hue
- c1in << "qminp";
c1in2 << "flood";
c2in << "SourceGraphic";
c2in2 << "blend6";
- b6in2 << "qminpc";
- } else if((g_ascii_strcasecmp("rad", type) == 0)) {
- // Radiation
- c1in << "qminp";
+ b6in2 << "composite1";
+ } else if ((g_ascii_strcasecmp("phospho", type) == 0)) {
+ // Phosphorescence
c1in2 << "flood";
c2in << "blend6";
- c2in2 << "qminpc";
+ c2in2 << "composite1";
b6in2 << "SourceGraphic";
- } else if((g_ascii_strcasecmp("htb", type) == 0)) {
+ } else if ((g_ascii_strcasecmp("phosphoB", type) == 0)) {
+ // Phosphorescence B
+ c1in2 << "SourceGraphic";
+ c2in << "blend6";
+ c2in2 << "composite1";
+ b6in2 << "flood";
+ } else if ((g_ascii_strcasecmp("htb", type) == 0)) {
// Hue to background
- c1in << "qminp";
c1in2 << "BackgroundImage";
- c2in << "p";
+ c2in << "blend2";
c2in2 << "blend6";
- b6in2 << "qminpc";
+ b6in2 << "composite1";
} else {
// Normal
- c1in << "qminp";
c1in2 << "flood";
- c2in << "p";
+ c2in << "blend2";
c2in2 << "blend6";
- b6in2 << "qminpc";
+ b6in2 << "composite";
}
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Tritone, custom\">\n"
- "<feColorMatrix type=\"hueRotate\" result=\"colormatrix1\" values=\"%s\" />\n"
- "<feColorMatrix in=\"colormatrix1\" result=\"r\" type=\"matrix\" values=\"1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 \" />\n"
- "<feColorMatrix in=\"colormatrix1\" result=\"g\" type=\"matrix\" values=\"0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 \" />\n"
- "<feColorMatrix in=\"colormatrix1\" result=\"b\" type=\"matrix\" values=\"0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 \" />\n"
- "<feBlend in2=\"g\" mode=\"darken\" in=\"r\" result=\"minrg\" />\n"
- "<feBlend in2=\"b\" mode=\"darken\" in=\"minrg\" result=\"p\" />\n"
- "<feBlend in2=\"g\" mode=\"lighten\" in=\"r\" result=\"maxrg\" />\n"
- "<feBlend in2=\"b\" mode=\"lighten\" in=\"maxrg\" result=\"q\" />\n"
- "<feComponentTransfer in=\"q\" result=\"q2\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Tritone\">\n"
+ "<feColorMatrix type=\"hueRotate\" values=\"%s\" result=\"colormatrix1\" />\n"
+ "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 \" result=\"colormatrix2\" />\n"
+ "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 \" result=\"colormatrix3\" />\n"
+ "<feColorMatrix in=\"colormatrix1\" type=\"matrix\" values=\"0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 \" result=\"colormatrix4\" />\n"
+ "<feBlend in=\"colormatrix2\" in2=\"colormatrix3\" mode=\"darken\" result=\"blend1\" />\n"
+ "<feBlend in=\"blend1\" in2=\"colormatrix4\" mode=\"darken\" result=\"blend2\" />\n"
+ "<feBlend in=\"colormatrix2\" in2=\"colormatrix3\" mode=\"lighten\" result=\"blend3\" />\n"
+ "<feBlend in=\"blend3\" in2=\"colormatrix4\" mode=\"lighten\" result=\"blend4\" />\n"
+ "<feComponentTransfer in=\"blend4\" result=\"componentTransfer\">\n"
"<feFuncR type=\"linear\" slope=\"0\" />\n"
"</feComponentTransfer>\n"
- "<feBlend in2=\"q2\" mode=\"%s\" in=\"p\" result=\"pq\" />\n"
- "<feColorMatrix in=\"pq\" result=\"qminp\" type=\"matrix\" values=\"-1 1 0 0 0 -1 1 0 0 0 -1 1 0 0 0 0 0 0 0 1 \" />\n"
- "<feFlood in=\"qminp\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
- "<feComposite in=\"%s\" in2=\"%s\" result=\"qminpc\" operator=\"arithmetic\" k1=\"1\" />\n"
- "<feGaussianBlur stdDeviation=\"%s\" />\n"
- "<feBlend in2=\"%s\" blend=\"normal\" result=\"blend6\" mode=\"%s\" />\n"
+ "<feBlend in=\"blend2\" in2=\"componentTransfer\" mode=\"%s\" result=\"blend5\" />\n"
+ "<feColorMatrix in=\"blend5\" type=\"matrix\" values=\"-1 1 0 0 0 -1 1 0 0 0 -1 1 0 0 0 0 0 0 0 1 \" result=\"colormatrix5\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feComposite in=\"colormatrix5\" in2=\"%s\" operator=\"arithmetic\" k1=\"1\" result=\"composite1\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend6\" />\n"
"<feComposite in=\"%s\" in2=\"%s\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" k3=\"%s\" k4=\"0\" result=\"composite2\" />\n"
- "<feComposite in2=\"SourceGraphic\" in=\"composite2\" operator=\"in\" />\n"
- "</filter>\n", dist.str().c_str(), globalblend.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(), c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str());
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite3\" />\n"
+ "</filter>\n", dist.str().c_str(), globalblend.str().c_str(),
+ a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ c1in2.str().c_str(), glow.str().c_str(), b6in2.str().c_str(), glowblend.str().c_str(),
+ c2in.str().c_str(), c2in2.str().c_str(), llight.str().c_str(), glight.str().c_str() );
return _filter;
}; /* Tritone filter */
@@ -916,4 +1641,4 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* namespace Inkscape */
/* Change the 'COLOR' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_COLOR_H__ */
diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h
new file mode 100644
index 000000000..415762466
--- /dev/null
+++ b/src/extension/internal/filter/distort.h
@@ -0,0 +1,249 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__
+/* Change the 'DISTORT' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Distort filters
+ * Felt Feather
+ * Roughen
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined FeltFeather filter.
+
+ Blur and displace edges of shapes and pictures
+
+ Filter's parameters:
+ * Type (enum, default "In") ->
+ in = map (in="composite3")
+ out = map (in="blur")
+ * Horizontal blur (0.01->30., default 15) -> blur (stdDeviation)
+ * Vertical blur (0.01->30., default 15) -> blur (stdDeviation)
+ * Dilatation (n-1th value, 0.->100., default 1) -> colormatrix (matrix)
+ * Erosion (nth value, 0.->100., default 0) -> colormatrix (matrix)
+ * Stroke (enum, default "Normal") ->
+ Normal = composite4 (operator="atop")
+ Wide = composite4 (operator="over")
+ Narrow = composite4 (operator="in")
+ No fill = composite4 (operator="xor")
+ * Roughness (group)
+ * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
+ * Horizontal frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/100])
+ * Vertical frequency (0.001->1., default 0.05) -> turbulence (baseFrequency [/100])
+ * Complexity (1->5, default 3) -> turbulence (numOctaves)
+ * Variation (0->100, default 0) -> turbulence (seed)
+ * Intensity (0.0->100., default 30) -> displacement (scale)
+*/
+
+class FeltFeather : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ FeltFeather ( ) : Filter() { };
+ virtual ~FeltFeather ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Felt Feather") "</name>\n"
+ "<id>org.inkscape.effect.filter.FeltFeather</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
+ "<_item value=\"in\">" N_("In") "</_item>\n"
+ "<_item value=\"out\">" N_("Out") "</_item>\n"
+ "</param>\n"
+ "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n"
+ "<param name=\"vblur\" gui-text=\"" N_("Vertical blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n"
+ "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n"
+ "<_item value=\"atop\">" N_("Normal") "</_item>\n"
+ "<_item value=\"over\">" N_("Wide") "</_item>\n"
+ "<_item value=\"in\">" N_("Narrow") "</_item>\n"
+ "<_item value=\"xor\">" N_("No fill") "</_item>\n"
+ "</param>\n"
+ "<param name=\"turbulence\" indent=\"1\" gui-text=\"" N_("Turbulence:") "\" type=\"enum\">\n"
+ "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
+ "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
+ "</param>\n"
+ "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n"
+ "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n"
+ "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n"
+ "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n"
+ "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100\">30</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Distort") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Blur and displace edges of shapes and pictures") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new FeltFeather());
+ };
+
+};
+
+gchar const *
+FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+
+ std::ostringstream hblur;
+ std::ostringstream vblur;
+ std::ostringstream dilat;
+ std::ostringstream erosion;
+
+ std::ostringstream turbulence;
+ std::ostringstream hfreq;
+ std::ostringstream vfreq;
+ std::ostringstream complexity;
+ std::ostringstream variation;
+ std::ostringstream intensity;
+
+ std::ostringstream map;
+ std::ostringstream stroke;
+
+ hblur << ext->get_param_float("hblur");
+ vblur << ext->get_param_float("vblur");
+ dilat << ext->get_param_float("dilat");
+ erosion << -ext->get_param_float("erosion");
+
+ turbulence << ext->get_param_enum("turbulence");
+ hfreq << ext->get_param_float("hfreq") / 100;
+ vfreq << ext->get_param_float("vfreq") / 100;
+ complexity << ext->get_param_int("complexity");
+ variation << ext->get_param_int("variation");
+ intensity << ext->get_param_float("intensity");
+
+ stroke << ext->get_param_enum("stroke");
+
+ const gchar *maptype = ext->get_param_enum("type");
+ if (g_ascii_strcasecmp("in", maptype) == 0) {
+ map << "composite3";
+ } else {
+ map << "blur";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" x=\"-0.3\" width=\"1.6\" y=\"-0.3\" height=\"1.6\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Felt Feather\">\n"
+ "<feGaussianBlur stdDeviation=\"%s %s\" result=\"blur\" />\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n"
+ "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n"
+ "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n"
+ "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n"
+ "<feDisplacementMap in=\"%s\" in2=\"turbulence\" xChannelSelector=\"R\" scale=\"%s\" yChannelSelector=\"G\" result=\"map\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix\" />\n"
+ "<feComposite in=\"composite3\" in2=\"colormatrix\" operator=\"%s\" result=\"composite4\" />\n"
+ "</filter>\n", hblur.str().c_str(), vblur.str().c_str(),
+ turbulence.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(),
+ map.str().c_str(), intensity.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), stroke.str().c_str() );
+
+ return _filter;
+}; /* Felt feather filter */
+
+/**
+ \brief Custom predefined Roughen filter.
+
+ Small-scale roughening to edges and content
+
+ Filter's parameters:
+ * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
+ * Horizontal frequency (0.001->10., default 0.013) -> turbulence (baseFrequency [/100])
+ * Vertical frequency (0.001->10., default 0.013) -> turbulence (baseFrequency [/100])
+ * Complexity (1->5, default 5) -> turbulence (numOctaves)
+ * Variation (1->360, default 1) -> turbulence (seed)
+ * Intensity (0.0->50., default 6.6) -> displacement (scale)
+*/
+
+class Roughen : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Roughen ( ) : Filter() { };
+ virtual ~Roughen ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Roughen") "</name>\n"
+ "<id>org.inkscape.effect.filter.Roughen</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
+ "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
+ "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
+ "</param>\n"
+ "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n"
+ "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n"
+ "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n"
+ "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n"
+ "<param name=\"intensity\" gui-text=\"" N_("Intensity:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Distort") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Small-scale roughening to edges and content") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Roughen());
+ };
+
+};
+
+gchar const *
+Roughen::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream type;
+ std::ostringstream hfreq;
+ std::ostringstream vfreq;
+ std::ostringstream complexity;
+ std::ostringstream variation;
+ std::ostringstream intensity;
+
+ type << ext->get_param_enum("type");
+ hfreq << ext->get_param_float("hfreq") / 100;
+ vfreq << ext->get_param_float("vfreq") / 100;
+ complexity << ext->get_param_int("complexity");
+ variation << ext->get_param_int("variation");
+ intensity << ext->get_param_float("intensity");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Roughen\">\n"
+ "<feTurbulence type=\"%s\" numOctaves=\"%s\" seed=\"%s\" baseFrequency=\"%s %s\" result=\"turbulence\" />\n"
+ "<feDisplacementMap in=\"SourceGraphic\" in2=\"turbulence\" scale=\"%s\" yChannelSelector=\"G\" xChannelSelector=\"R\" />\n"
+ "</filter>\n", type.str().c_str(), complexity.str().c_str(), variation.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), intensity.str().c_str());
+
+ return _filter;
+}; /* Roughen filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'DISTORT' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_DISTORT_H__ */
diff --git a/src/extension/internal/filter/drop-shadow.h b/src/extension/internal/filter/drop-shadow.h
deleted file mode 100644
index 12f0c6055..000000000
--- a/src/extension/internal/filter/drop-shadow.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__
-/* Change the 'DROP_SHADOW' above to be your file name */
-
-/*
- * Copyright (C) 2008 Authors:
- * Ted Gould <ted@gould.cx>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
-
-#include "filter.h"
-
-#include "extension/internal/clear-n_.h"
-#include "extension/system.h"
-#include "extension/extension.h"
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-namespace Filter {
-
-class DropShadow : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- DropShadow ( ) : Filter() { };
- virtual ~DropShadow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Drop Shadow") "</name>\n"
- "<id>org.inkscape.effect.filter.drop-shadow</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" min=\"0.0\" max=\"200.0\">2.0</param>\n"
- "<param name=\"opacity\" gui-text=\"" N_("Opacity (%):") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50</param>\n"
- "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
- "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\" >\n"
- "<submenu name=\"" N_("Shadows and Glows") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Black, blurred drop shadow") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new DropShadow());
- };
-
-};
-
-gchar const *
-DropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream blur;
- std::ostringstream opacity;
- std::ostringstream x;
- std::ostringstream y;
-
- blur << ext->get_param_float("blur");
- opacity << ext->get_param_float("opacity") / 100;
- x << ext->get_param_float("xoffset");
- y << ext->get_param_float("yoffset");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n"
- "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s 0 \" />\n"
- "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n"
- "<feMerge>\n"
- "<feMergeNode in=\"offsetBlur\"/>\n"
- "<feMergeNode in=\"SourceGraphic\"/>\n"
- "</feMerge>\n"
- "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str());
-
- return _filter;
-};
-
-class DropGlow : public Inkscape::Extension::Internal::Filter::Filter {
-protected:
- virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
-
-public:
- DropGlow ( ) : Filter() { };
- virtual ~DropGlow ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
-
- static void init (void) {
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Drop Glow") "</name>\n"
- "<id>org.inkscape.effect.filter.drop-glow</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" min=\"0.0\" max=\"200.0\">2.0</param>\n"
- "<param name=\"opacity\" gui-text=\"" N_("Opacity (%):") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50</param>\n"
- "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
- "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">4.0</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Shadows and Glows") "\"/>\n"
- "</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("White, blurred drop glow") "</menu-tip>\n"
- "</effect>\n"
- "</inkscape-extension>\n", new DropGlow());
- };
-
-};
-
-gchar const *
-DropGlow::get_filter_text (Inkscape::Extension::Extension * ext)
-{
- if (_filter != NULL) g_free((void *)_filter);
-
- std::ostringstream blur;
- std::ostringstream opacity;
- std::ostringstream x;
- std::ostringstream y;
-
- blur << ext->get_param_float("blur");
- opacity << ext->get_param_float("opacity") / 100;
- x << ext->get_param_float("xoffset");
- y << ext->get_param_float("yoffset");
-
- _filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Drop shadow\" width=\"1.5\" height=\"1.5\" x=\"-.25\" y=\"-.25\">\n"
- "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur\"/>\n"
- "<feColorMatrix result=\"bluralpha\" type=\"matrix\" values=\"-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 %s 0 \" />\n"
- "<feOffset in=\"bluralpha\" dx=\"%s\" dy=\"%s\" result=\"offsetBlur\"/>\n"
- "<feMerge>\n"
- "<feMergeNode in=\"offsetBlur\"/>\n"
- "<feMergeNode in=\"SourceGraphic\"/>\n"
- "</feMerge>\n"
- "</filter>\n", blur.str().c_str(), opacity.str().c_str(), x.str().c_str(), y.str().c_str());
-
- return _filter;
-};
-
-}; /* namespace Filter */
-}; /* namespace Internal */
-}; /* namespace Extension */
-}; /* namespace Inkscape */
-
-/* Change the 'DROP_SHADOW' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_DROP_SHADOW_H__ */
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index 280dc9563..b5d47ae45 100755
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -8,14 +8,19 @@
#include "filter.h"
/* Put your filter here */
-#include "abc.h"
+#include "bevels.h"
+#include "blurs.h"
+#include "bumps.h"
#include "color.h"
-#include "drop-shadow.h"
+#include "distort.h"
+#include "image.h"
#include "morphology.h"
+#include "overlays.h"
+#include "paint.h"
+#include "protrusions.h"
#include "shadows.h"
-#include "snow.h"
-
-#include "experimental.h"
+#include "textures.h"
+#include "transparency.h"
namespace Inkscape {
namespace Extension {
@@ -27,50 +32,83 @@ void
Filter::filters_all (void )
{
// Here come the filters which are coded in C++ in order to present a parameters dialog
- DropShadow::init();
- DropGlow::init();
- Snow::init();
/* Experimental custom predefined filters */
- // ABCs
- Blur::init();
- CleanEdges::init();
- ColorShift::init();
+ // Bevels
DiffuseLight::init();
- Feather::init();
MatteJelly::init();
- NoiseFill::init();
- Outline::init();
- Roughen::init();
- Silhouette::init();
SpecularLight::init();
+ // Blurs
+ Blur::init();
+ CleanEdges::init();
+ CrossBlur::init();
+ Feather::init();
+ ImageBlur::init();
+
+ // Bumps
+ Bump::init();
+ WaxBump::init();
+
// Color
- Brightness::init();
+ Brilliance::init();
+ ChannelPaint::init();
+ ColorShift::init();
Colorize::init();
+ ComponentTransfer::init();
Duochrome::init();
- Electrize::init();
+ ExtractChannel::init();
+ FadeToBW::init();
Greyscale::init();
- Lightness::init();
+ Invert::init();
+ Lighting::init();
+ LightnessContrast::init();
+ Nudge::init();
Quadritone::init();
Solarize::init();
Tritone::init();
- // Morphology
- Crosssmooth::init();
+ // Distort
+ FeltFeather::init();
+ Roughen::init();
- // Shadows and glows
- ColorizableDropShadow::init();
+ // Image effect
+ EdgeDetect::init();
- // TDB
+ // Image paint and draw
Chromolitho::init();
CrossEngraving::init();
Drawing::init();
+ Electrize::init();
NeonDraw::init();
+ PointEngraving::init();
Posterize::init();
PosterizeBasic::init();
+ // Morphology
+ Crosssmooth::init();
+ Outline::init();
+
+ // Overlays
+ NoiseFill::init();
+
+ // Protrusions
+ Snow::init();
+
+ // Shadows and glows
+ ColorizableDropShadow::init();
+
+ // Textures
+ InkBlot::init();
+
+ // Fill and transparency
+ Blend::init();
+ ChannelTransparency::init();
+ LightEraser::init();
+ Opacity::init();
+ Silhouette::init();
+
// Here come the rest of the filters that are read from SVG files in share/filters and
// .config/Inkscape/filters
/* This should always be last, don't put stuff below this
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index 89afca133..d129f590c 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -26,13 +26,15 @@ namespace Extension {
namespace Internal {
namespace Filter {
-void
-Filter::filters_all_files (void)
+void Filter::filters_all_files(void)
{
+ gchar *filtersProfilePath = profile_path("filters");
+
filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled"));
- filters_load_dir(profile_path("filters"), _("Personal"));
+ filters_load_dir(filtersProfilePath, _("Personal"));
- return;
+ g_free(filtersProfilePath);
+ filtersProfilePath = 0;
}
#define INKSCAPE_FILTER_FILE ".svg"
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index 715278051..af597685b 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -46,22 +46,20 @@ Filter::~Filter (void) {
return;
}
-bool
-Filter::load (Inkscape::Extension::Extension *module)
+bool Filter::load(Inkscape::Extension::Extension * /*module*/)
{
- return true;
+ return true;
}
-Inkscape::Extension::Implementation::ImplementationDocumentCache *
-Filter::newDocCache (Inkscape::Extension::Extension * ext, Inkscape::UI::View::View * doc)
+Inkscape::Extension::Implementation::ImplementationDocumentCache *Filter::newDocCache(Inkscape::Extension::Extension * /*ext*/,
+ Inkscape::UI::View::View * /*doc*/)
{
- return NULL;
+ return NULL;
}
-gchar const *
-Filter::get_filter_text (Inkscape::Extension::Extension * ext)
+gchar const *Filter::get_filter_text(Inkscape::Extension::Extension * /*ext*/)
{
- return _filter;
+ return _filter;
}
Inkscape::XML::Document *
@@ -116,8 +114,8 @@ Filter::merge_filters( Inkscape::XML::Node * to, Inkscape::XML::Node * from,
#define FILTER_SRC_GRAPHIC "fbSourceGraphic"
#define FILTER_SRC_GRAPHIC_ALPHA "fbSourceGraphicAlpha"
-void
-Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document, Inkscape::Extension::Implementation::ImplementationDocumentCache * docCache)
+void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View *document,
+ Inkscape::Extension::Implementation::ImplementationDocumentCache * /*docCache*/)
{
Inkscape::XML::Document *filterdoc = get_filter(module);
if (filterdoc == NULL) {
@@ -133,10 +131,10 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc();
- Inkscape::XML::Node * defsrepr = SP_DOCUMENT_DEFS(document->doc())->getRepr();
+ Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr();
for(std::list<SPItem *>::iterator item = items.begin();
- item != items.end(); item++) {
+ item != items.end(); ++item) {
SPItem * spitem = *item;
Inkscape::XML::Node * node = spitem->getRepr();
diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h
index a5d5d9d4e..08bc1c3f0 100644
--- a/src/extension/internal/filter/filter.h
+++ b/src/extension/internal/filter/filter.h
@@ -1,5 +1,5 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__
+#ifndef INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H
+#define INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H
/*
* Copyright (C) 2008 Authors:
@@ -11,10 +11,13 @@
#include <glibmm/i18n.h>
#include "extension/implementation/implementation.h"
-#include "extension/extension-forward.h"
namespace Inkscape {
namespace Extension {
+
+class Effect;
+class Extension;
+
namespace Internal {
namespace Filter {
@@ -52,4 +55,4 @@ public:
}; /* namespace Extension */
}; /* namespace Inkscape */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H__ */
+#endif // INKSCAPE_EXTENSION_INTERNAL_FILTER_FILTER_H
diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h
new file mode 100644
index 000000000..60e1a1665
--- /dev/null
+++ b/src/extension/internal/filter/image.h
@@ -0,0 +1,113 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__
+/* Change the 'IMAGE' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Image filters
+ * Edge detect
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Edge detect filter.
+
+ Detect color edges in object.
+
+ Filter's parameters:
+ * Detection type (enum, default Full) -> convolve (kernelMatrix)
+ * Level (0.01->10., default 1.) -> convolve (divisor)
+ * Inverted (boolean, default false) -> convolve (bias)
+*/
+class EdgeDetect : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ EdgeDetect ( ) : Filter() { };
+ virtual ~EdgeDetect ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Edge Detect") "</name>\n"
+ "<id>org.inkscape.effect.filter.EdgeDetect</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Detect:") "\" type=\"enum\" >\n"
+ "<_item value=\"all\">" N_("All") "</_item>\n"
+ "<_item value=\"vertical\">" N_("Vertical lines") "</_item>\n"
+ "<_item value=\"horizontal\">" N_("Horizontal lines") "</_item>\n"
+ "</param>\n"
+ "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"100.0\">1.0</param>\n"
+ "<param name=\"inverted\" gui-text=\"" N_("Invert colors") "\" type=\"boolean\" >false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Image Effects") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Detect color edges in object") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new EdgeDetect());
+ };
+
+};
+
+gchar const *
+EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream matrix;
+ std::ostringstream inverted;
+ std::ostringstream level;
+
+ const gchar *type = ext->get_param_enum("type");
+
+ level << 1 / ext->get_param_float("level");
+
+ if ((g_ascii_strcasecmp("vertical", type) == 0)) {
+ matrix << "0 0 0 1 -2 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("horizontal", type) == 0)) {
+ matrix << "0 1 0 0 -2 0 0 1 0";
+ } else {
+ matrix << "0 1 0 1 -4 1 0 1 0";
+ }
+
+ if (ext->get_param_bool("inverted")) {
+ inverted << "1";
+ } else {
+ inverted << "0";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Edge Detect\">\n"
+ "<feConvolveMatrix in=\"SourceGraphic\" kernelMatrix=\"%s\" order=\"3 3\" bias=\"%s\" divisor=\"%s\" targetX=\"1\" targetY=\"1\" preserveAlpha=\"true\" result=\"convolve\" />\n"
+ "</filter>\n", matrix.str().c_str(), inverted.str().c_str(), level.str().c_str());
+
+ return _filter;
+};
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'IMAGE' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_IMAGE_H__ */
diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h
index 0a844c937..123d912b0 100644
--- a/src/extension/internal/filter/morphology.h
+++ b/src/extension/internal/filter/morphology.h
@@ -1,5 +1,5 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
/* Change the 'MORPHOLOGY' above to be your file name */
/*
@@ -9,6 +9,7 @@
*
* Morphology filters
* Cross-smooth
+ * Outline
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -32,9 +33,15 @@ namespace Filter {
Filter's parameters:
* Type (enum, default "Smooth edges") ->
- Smooth edges = composite1 (in="SourceGraphic", in2="blur")
- Smooth all = composite1 (in="blur", in2="blur")
- * Blur (0.01->10., default 5.) -> blur (stdDeviation)
+ Inner = composite1 (operator="in")
+ Outer = composite1 (operator="over")
+ Open = composite1 (operator="XOR")
+ * Width (0.01->30., default 10.) -> blur (stdDeviation)
+ * Level (0.2->2., default 1.) -> composite2 (k2)
+ * Dilatation (1.->100., default 10.) -> colormatrix1 (last-1 value)
+ * Erosion (1.->100., default 1.) -> colormatrix1 (last value)
+ * Antialiasing (0.01->1., default 1) -> blur2 (stdDeviation)
+ * Blur content (boolean, default false) -> blend (true: in="colormatrix2", false: in="SourceGraphic")
*/
class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter {
@@ -48,18 +55,25 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Cross-smooth, custom (Morphology)") "</name>\n"
+ "<name>" N_("Cross-smooth") "</name>\n"
"<id>org.inkscape.effect.filter.crosssmooth</id>\n"
"<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
- "<_item value=\"edges\">" N_("Smooth edges") "</_item>\n"
- "<_item value=\"all\">" N_("Smooth all") "</_item>\n"
+ "<_item value=\"in\">" N_("Inner") "</_item>\n"
+ "<_item value=\"over\">" N_("Outer") "</_item>\n"
+ "<_item value=\"xor\">" N_("Open") "</_item>\n"
"</param>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"10\">5</param>\n"
+ "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.\">10</param>\n"
+ "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.2\" max=\"2\">1</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">10</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">1</param>\n"
+ "<param name=\"antialias\" gui-text=\"" N_("Antialiasing:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n"
+ "<param name=\"content\" gui-text=\"" N_("Blur content") "\" type=\"boolean\" >false</param>\n"
+
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Morphology") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Smooth edges and angles of shapes") "</menu-tip>\n"
@@ -74,29 +88,233 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
- std::ostringstream blur;
- std::ostringstream c1in;
+ std::ostringstream type;
+ std::ostringstream width;
+ std::ostringstream level;
+ std::ostringstream dilat;
+ std::ostringstream erosion;
+ std::ostringstream antialias;
+ std::ostringstream content;
- blur << ext->get_param_float("blur");
+ type << ext->get_param_enum("type");
+ width << ext->get_param_float("width");
+ level << ext->get_param_float("level");
+ dilat << ext->get_param_float("dilat");
+ erosion << (1 - ext->get_param_float("erosion"));
+ antialias << ext->get_param_float("antialias");
- const gchar *type = ext->get_param_enum("type");
- if((g_ascii_strcasecmp("all", type) == 0)) {
- c1in << "blur";
+ if (ext->get_param_bool("content")) {
+ content << "colormatrix2";
} else {
+ content << "SourceGraphic";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Cross-smooth\">\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feComposite in=\"blur1\" in2=\"blur1\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"composite1\" k2=\"%s\" operator=\"arithmetic\" result=\"composite2\" />\n"
+ "<feColorMatrix in=\"composite2\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix1\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n"
+ "<feColorMatrix in=\"blur2\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 5 -1 \" result=\"colormatrix2\" />\n"
+ "<feBlend in=\"%s\" in2=\"colormatrix2\" stdDeviation=\"17\" mode=\"normal\" result=\"blend\" />\n"
+ "<feComposite in=\"blend\" in2=\"colormatrix2\" operator=\"in\" result=\"composite3\" />\n"
+ "</filter>\n", width.str().c_str(), type.str().c_str(), level.str().c_str(),
+ dilat.str().c_str(), erosion.str().c_str(), antialias.str().c_str(),
+ content.str().c_str());
+
+ return _filter;
+}; /* Cross-smooth filter */
+
+/**
+ \brief Custom predefined Outline filter.
+
+ Adds a colorizable outline
+
+ Filter's parameters:
+ * Fill image (boolean, default false) -> true: composite2 (in="SourceGraphic"), false: composite2 (in="blur2")
+ * Hide image (boolean, default false) -> true: composite4 (in="composite3"), false: composite4 (in="SourceGraphic")
+ * Stroke type (enum, default over) -> composite2 (operator)
+ * Stroke position (enum, default inside)
+ * inside -> composite1 (operator="out", in="SourceGraphic", in2="blur1")
+ * outside -> composite1 (operator="out", in="blur1", in2="SourceGraphic")
+ * overlayed -> composite1 (operator="xor", in="blur1", in2="SourceGraphic")
+ * Width 1 (0.01->20., default 4) -> blur1 (stdDeviation)
+ * Dilatation 1 (1.->100., default 100) -> colormatrix1 (n-1th value)
+ * Erosion 1 (0.->100., default 1) -> colormatrix1 (nth value 0->-100)
+ * Width 2 (0.01->20., default 0.5) -> blur2 (stdDeviation)
+ * Dilatation 2 (1.->100., default 50) -> colormatrix2 (n-1th value)
+ * Erosion 2 (0.->100., default 5) -> colormatrix2 (nth value 0->-100)
+ * Antialiasing (0.01->1., default 1) -> blur3 (stdDeviation)
+ * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity)
+ * Fill opacity (0.->1., default 1) -> composite5 (k2)
+ * Stroke opacity (0.->1., default 1) -> composite5 (k3)
+
+*/
+
+class Outline : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Outline ( ) : Filter() { };
+ virtual ~Outline ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Outline") "</name>\n"
+ "<id>org.inkscape.effect.filter.Outline</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"fill\" gui-text=\"" N_("Fill image") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"outline\" gui-text=\"" N_("Hide image") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"type\" gui-text=\"" N_("Composite type:") "\" type=\"enum\">\n"
+ "<_item value=\"over\">" N_("Over") "</_item>\n"
+ "<_item value=\"in\">" N_("In") "</_item>\n"
+ "<_item value=\"out\">" N_("Out") "</_item>\n"
+ "<_item value=\"atop\">" N_("Atop") "</_item>\n"
+ "<_item value=\"xor\">" N_("XOR") "</_item>\n"
+ "</param>\n"
+ "<param name=\"position\" gui-text=\"" N_("Position:") "\" type=\"enum\">\n"
+ "<_item value=\"inside\">" N_("Inside") "</_item>\n"
+ "<_item value=\"outside\">" N_("Outside") "</_item>\n"
+ "<_item value=\"overlayed\">" N_("Overlayed") "</_item>\n"
+ "</param>\n"
+ "<param name=\"width1\" gui-text=\"" N_("Width 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n"
+ "<param name=\"dilat1\" gui-text=\"" N_("Dilatation 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n"
+ "<param name=\"erosion1\" gui-text=\"" N_("Erosion 1:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n"
+ "<param name=\"width2\" gui-text=\"" N_("Width 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n"
+ "<param name=\"dilat2\" gui-text=\"" N_("Dilatation 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n"
+ "<param name=\"erosion2\" gui-text=\"" N_("Erosion 2:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n"
+ "<param name=\"antialias\" gui-text=\"" N_("Antialiasing:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smooth") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "<page name=\"co11tab\" _gui-text=\"Color\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n"
+ "<param name=\"fopacity\" gui-text=\"" N_("Fill opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n"
+ "<param name=\"sopacity\" gui-text=\"" N_("Stroke opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Morphology") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Adds a colorizable outline") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Outline());
+ };
+
+};
+
+gchar const *
+Outline::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream width1;
+ std::ostringstream dilat1;
+ std::ostringstream erosion1;
+ std::ostringstream width2;
+ std::ostringstream dilat2;
+ std::ostringstream erosion2;
+ std::ostringstream antialias;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+ std::ostringstream fopacity;
+ std::ostringstream sopacity;
+ std::ostringstream smooth;
+
+ std::ostringstream c1in;
+ std::ostringstream c1in2;
+ std::ostringstream c1op;
+ std::ostringstream c2in;
+ std::ostringstream c2op;
+ std::ostringstream c4in;
+
+
+ width1 << ext->get_param_float("width1");
+ dilat1 << ext->get_param_float("dilat1");
+ erosion1 << (- ext->get_param_float("erosion1"));
+ width2 << ext->get_param_float("width2");
+ dilat2 << ext->get_param_float("dilat2");
+ erosion2 << (- ext->get_param_float("erosion2"));
+ antialias << ext->get_param_float("antialias");
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ fopacity << ext->get_param_float("fopacity");
+ sopacity << ext->get_param_float("sopacity");
+
+ const gchar *position = ext->get_param_enum("position");
+ if((g_ascii_strcasecmp("inside", position) == 0)) {
+ // Indide
c1in << "SourceGraphic";
+ c1in2 << "blur1";
+ c1op << "out";
+ } else if((g_ascii_strcasecmp("outside", position) == 0)) {
+ // Outside
+ c1in << "blur1";
+ c1in2 << "SourceGraphic";
+ c1op << "out";
+ } else {
+ // Overlayed
+ c1in << "blur1";
+ c1in2 << "SourceGraphic";
+ c1op << "xor";
}
+ if (ext->get_param_bool("fill")) {
+ c2in << "SourceGraphic";
+ } else {
+ c2in << "blur2";
+ }
+
+ c2op << ext->get_param_enum("type");
+
+ if (ext->get_param_bool("outline")) {
+ c4in << "composite3";
+ } else {
+ c4in << "SourceGraphic";
+ }
+
+ if (ext->get_param_bool("smooth")) {
+ smooth << "1 0";
+ } else {
+ smooth << "5 -1";
+ }
+
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Cross-smooth, custom\">\n"
- "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
- "<feComposite in=\"%s\" in2=\"blur\" operator=\"atop\" result=\"composite1\" />\n"
- "<feComposite in2=\"composite1\" operator=\"in\" result=\"composite2\" />\n"
- "<feComposite in2=\"composite2\" operator=\"in\" result=\"composite3\" />\n"
- "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -10 \" result=\"colormatrix\" />\n"
- "</filter>\n", blur.str().c_str(), c1in.str().c_str());
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" height=\"1.4\" width=\"1.4\" y=\"-0.2\" x=\"-0.2\" inkscape:label=\"Outline\">\n"
+ "<feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix1\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n"
+ "<feComposite in=\"%s\" in2=\"blur2\" operator=\"%s\" result=\"composite2\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix2\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s \" result=\"colormatrix3\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feComposite in=\"flood\" in2=\"colormatrix3\" k2=\"1\" operator=\"in\" result=\"composite3\" />\n"
+ "<feComposite in=\"%s\" in2=\"colormatrix3\" operator=\"out\" result=\"composite4\" />\n"
+ "<feComposite in=\"composite4\" in2=\"composite3\" k2=\"%s\" k3=\"%s\" operator=\"arithmetic\" result=\"composite5\" />\n"
+ "</filter>\n", width1.str().c_str(), c1in.str().c_str(), c1in2.str().c_str(), c1op.str().c_str(),
+ dilat1.str().c_str(), erosion1.str().c_str(),
+ width2.str().c_str(), c2in.str().c_str(), c2op.str().c_str(),
+ dilat2.str().c_str(), erosion2.str().c_str(), antialias.str().c_str(), smooth.str().c_str(),
+ a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ c4in.str().c_str(), fopacity.str().c_str(), sopacity.str().c_str() );
return _filter;
-}; /* Crosssmooth filter */
+}; /* Outline filter */
}; /* namespace Filter */
}; /* namespace Internal */
@@ -104,4 +322,4 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* namespace Inkscape */
/* Change the 'MORPHOLOGY' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */
diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h
new file mode 100644
index 000000000..1ca745166
--- /dev/null
+++ b/src/extension/internal/filter/overlays.h
@@ -0,0 +1,147 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__
+/* Change the 'OVERLAYS' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Overlays filters
+ * Noise fill
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Noise fill filter.
+
+ Basic noise fill and transparency texture
+
+ Filter's parameters:
+ * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
+ * Horizontal frequency (*1000) (0.01->10000., default 20) -> turbulence (baseFrequency [/1000])
+ * Vertical frequency (*1000) (0.01->10000., default 40) -> turbulence (baseFrequency [/1000])
+ * Complexity (1->5, default 5) -> turbulence (numOctaves)
+ * Variation (1->360, default 1) -> turbulence (seed)
+ * Dilatation (1.->50., default 3) -> color (n-1th value)
+ * Erosion (0.->50., default 1) -> color (nth value 0->-50)
+ * Color (guint, default 148,115,39,255) -> flood (flood-color, flood-opacity)
+ * Inverted (boolean, default false) -> composite1 (operator, true="in", false="out")
+*/
+
+class NoiseFill : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ NoiseFill ( ) : Filter() { };
+ virtual ~NoiseFill ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Noise Fill") "</name>\n"
+ "<id>org.inkscape.effect.filter.NoiseFill</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n"
+ "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
+ "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
+ "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
+ "</param>\n"
+ "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">20</param>\n"
+ "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">40</param>\n"
+ "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n"
+ "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">3</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">1</param>\n"
+ "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "<page name=\"co11tab\" _gui-text=\"" N_("Noise color") "\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">354957823</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Overlays") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Basic noise fill and transparency texture") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new NoiseFill());
+ };
+
+};
+
+gchar const *
+NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream type;
+ std::ostringstream hfreq;
+ std::ostringstream vfreq;
+ std::ostringstream complexity;
+ std::ostringstream variation;
+ std::ostringstream dilat;
+ std::ostringstream erosion;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+ std::ostringstream inverted;
+
+ type << ext->get_param_enum("type");
+ hfreq << (ext->get_param_float("hfreq") / 1000);
+ vfreq << (ext->get_param_float("vfreq") / 1000);
+ complexity << ext->get_param_int("complexity");
+ variation << ext->get_param_int("variation");
+ dilat << ext->get_param_float("dilat");
+ erosion << (- ext->get_param_float("erosion"));
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+ if (ext->get_param_bool("inverted"))
+ inverted << "out";
+ else
+ inverted << "in";
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Noise Fill\">\n"
+ "<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\"/>\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"turbulence\" operator=\"%s\" result=\"composite1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feMerge result=\"merge\">\n"
+ "<feMergeNode in=\"flood\" />\n"
+ "<feMergeNode in=\"color\" />\n"
+ "</feMerge>\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
+ "</filter>\n", type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(), inverted.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str());
+
+ return _filter;
+}; /* NoiseFill filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'OVERLAYS' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_OVERLAYS_H__ */
diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/paint.h
index 9dd188bd3..b7909a512 100755..100644
--- a/src/extension/internal/filter/experimental.h
+++ b/src/extension/internal/filter/paint.h
@@ -1,17 +1,19 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__
-/* Change the 'EXPERIMENTAL' above to be your file name */
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__
+/* Change the 'PAINT' above to be your file name */
/*
* Copyright (C) 2011 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
- * Experimental filters (no assigned menu)
+ * Image paint and draw filters
* Chromolitho
* Cross engraving
* Drawing
+ * Electrize
* Neon draw
+ * Point engraving
* Posterize
* Posterize basic
*
@@ -46,8 +48,8 @@ namespace Filter {
* Drawing blend (enum, default Normal) -> blend1 (mode)
* Smoothness (0.01->10, default 1) -> blur1 (stdDeviation)
* Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1")
- * Grain x frequency (0.->100, default 100) -> turbulence1 (baseFrequency, first value)
- * Grain y frequency (0.->100, default 100) -> turbulence1 (baseFrequency, second value)
+ * Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value)
+ * Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value)
* Grain complexity (1->5, default 1) -> turbulence1 (numOctaves)
* Grain variation (0->1000, default 0) -> turbulence1 (seed)
* Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value)
@@ -66,7 +68,7 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Chromolitho, custom") "</name>\n"
+ "<name>" N_("Chromolitho") "</name>\n"
"<id>org.inkscape.effect.filter.Chromolitho</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
@@ -81,19 +83,19 @@ public:
"<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n"
"<param name=\"dented\" gui-text=\"" N_("Dented") "\" type=\"boolean\" >false</param>\n"
"<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n"
- "<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"float\" min=\"0\" max=\"10\">0</param>\n"
- "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" min=\"0\" max=\"1\">1</param>\n"
- "<param name=\"noise\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" min=\"1\" max=\"1000\">10</param>\n"
- "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.01\" max=\"10\">1</param>\n"
+ "<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n"
+ "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n"
+ "<param name=\"noise\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n"
"</page>\n"
- "<page name=\"graintab\" _gui-text=\"Grain\">\n"
+ "<page name=\"graintab\" _gui-text=\""N_("Grain") "\">\n"
"<param name=\"grain\" gui-text=\"" N_("Grain mode") "\" type=\"boolean\" >true</param>\n"
- "<param name=\"grainxf\" gui-text=\"" N_("X frequency:") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n"
- "<param name=\"grainyf\" gui-text=\"" N_("Y frequency:") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n"
- "<param name=\"grainc\" gui-text=\"" N_("Complexity:") "\" type=\"int\" min=\"1\" max=\"5\">1</param>\n"
- "<param name=\"grainv\" gui-text=\"" N_("Variation:") "\" type=\"int\" min=\"0\" max=\"1000\">0</param>\n"
- "<param name=\"grainexp\" gui-text=\"" N_("Expansion:") "\" type=\"float\" min=\"1\" max=\"50\">1</param>\n"
- "<param name=\"grainero\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"40\">0</param>\n"
+ "<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
+ "<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
+ "<param name=\"grainc\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n"
+ "<param name=\"grainv\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n"
+ "<param name=\"grainexp\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n"
+ "<param name=\"grainero\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n"
"<param name=\"graincol\" gui-text=\"" N_("Color") "\" type=\"boolean\" >true</param>\n"
"<param name=\"gblend\" gui-text=\"" N_("Grain blend:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
@@ -108,7 +110,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Chromo effect with customizable edge drawing and graininess") "</menu-tip>\n"
@@ -168,8 +170,8 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
b2in << "colormatrix2";
else
b2in << "blur1";
- grainxf << (ext->get_param_float("grainxf") / 100);
- grainyf << (ext->get_param_float("grainyf") / 100);
+ grainxf << (ext->get_param_float("grainxf") / 1000);
+ grainyf << (ext->get_param_float("grainyf") / 1000);
grainc << ext->get_param_int("grainc");
grainv << ext->get_param_int("grainv");
gblend << ext->get_param_enum("gblend");
@@ -181,17 +183,17 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
graincol << "0";
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Chromolitho, custom\">\n"
- "<feComposite stdDeviation=\"1\" in=\"SourceGraphic\" in2=\"SourceGraphic\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" result=\"composite1\" />\n"
- "<feConvolveMatrix in=\"composite1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" stdDeviation=\"1\" result=\"convolve1\" />\n"
- "<feBlend in=\"%s\" in2=\"composite1\" mode=\"%s\" blend=\"normal\" stdDeviation=\"1\" result=\"blend1\" />\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Chromolitho\">\n"
+ "<feComposite in=\"SourceGraphic\" in2=\"SourceGraphic\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" result=\"composite1\" />\n"
+ "<feConvolveMatrix in=\"composite1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" result=\"convolve1\" />\n"
+ "<feBlend in=\"%s\" in2=\"composite1\" mode=\"%s\" result=\"blend1\" />\n"
"<feGaussianBlur in=\"blend1\" stdDeviation=\"%s\" result=\"blur1\" />\n"
"<feTurbulence baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" type=\"fractalNoise\" result=\"turbulence1\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix1\" />\n"
- "<feColorMatrix type=\"saturate\" stdDeviation=\"3\" values=\"%s\" result=\"colormatrix2\" />\n"
- "<feBlend in=\"%s\" in2=\"blur1\" stdDeviation=\"1\" blend=\"normal\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feColorMatrix type=\"saturate\" values=\"%s\" result=\"colormatrix2\" />\n"
+ "<feBlend in=\"%s\" in2=\"blur1\" mode=\"%s\" result=\"blend2\" />\n"
"<feColorMatrix in=\"blend2\" type=\"saturate\" values=\"%s\" result=\"colormatrix3\" />\n"
- "<feComponentTransfer in=\"colormatrix3\" stdDeviation=\"2\" result=\"component1\">\n"
+ "<feComponentTransfer in=\"colormatrix3\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
@@ -228,19 +230,19 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Cross engraving, custom") "</name>\n"
+ "<name>" N_("Cross Engraving") "</name>\n"
"<id>org.inkscape.effect.filter.CrossEngraving</id>\n"
- "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" min=\"1\" max=\"500\">30</param>\n"
- "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" min=\"1\" max=\"50\">1</param>\n"
- "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"50\">0</param>\n"
- "<param name=\"strength\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"0.1\" max=\"10\">0.5</param>\n"
- "<param name=\"length\" gui-text=\"" N_("Length:") "\" type=\"float\" min=\"0.5\" max=\"20\">4</param>\n"
+ "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n"
+ "<param name=\"strength\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n"
+ "<param name=\"length\" gui-text=\"" N_("Length:") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n"
"<param name=\"trans\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Convert image to an engraving made of vertical and horizontal lines") "</menu-tip>\n"
@@ -272,7 +274,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
trans << "blend";
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Cross engraving, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Cross Engraving\">\n"
"<feConvolveMatrix in=\"SourceGraphic\" targetY=\"1\" targetX=\"1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" result=\"convolve\" />\n"
"<feComposite in=\"convolve\" in2=\"convolve\" k1=\"1\" k2=\"1\" operator=\"arithmetic\" result=\"composite1\" />\n"
"<feColorMatrix in=\"composite1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color1\" />\n"
@@ -282,7 +284,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
"<feGaussianBlur in=\"composite2\" stdDeviation=\"0.01 %s\" result=\"blur2\" />\n"
"<feComposite in=\"blur2\" in2=\"blur1\" k3=\"1\" k2=\"1\" operator=\"arithmetic\" result=\"composite3\" />\n"
"<feFlood flood-color=\"rgb(255,255,255)\" flood-opacity=\"1\" result=\"flood\" />\n"
- "<feBlend in=\"flood\" in2=\"composite3\" blend=\"normal\" mode=\"multiply\" result=\"blend\" />\n"
+ "<feBlend in=\"flood\" in2=\"composite3\" mode=\"multiply\" result=\"blend\" />\n"
"<feComposite in=\"%s\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite4\" />\n"
"</filter>\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str());
@@ -301,7 +303,7 @@ CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
* Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation)
* Dilatation (1.->50., default 6) -> color2 (n-1th value)
* Erosion (0.->50., default 2) -> color2 (nth value 0->-50)
- * Transluscent (boolean, default false) -> composite 8 (in, true->merge1, false->composite7)
+ * translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5)
* Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation)
* Blur dilatation (1.->50., default 6) -> color4 (n-1th value)
@@ -327,23 +329,23 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Drawing, custom") "</name>\n"
+ "<name>" N_("Drawing") "</name>\n"
"<id>org.inkscape.effect.filter.Drawing</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
- "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify</_param>\n"
- "<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"0.01\" max=\"20\">0.6</param>\n"
- "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" min=\"1\" max=\"500\">10</param>\n"
- "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" min=\"0\" max=\"60\">0</param>\n"
- "<param name=\"transluscent\" gui-text=\"" N_("Transluscent") "\" type=\"boolean\" >false</param>\n"
- "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness</_param>\n"
- "<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" min=\"0.01\" max=\"20\">0.6</param>\n"
- "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" min=\"1\" max=\"50\">6</param>\n"
- "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"50\">2</param>\n"
- "<_param name=\"meltheader\" type=\"groupheader\">Melt</_param>\n"
- "<param name=\"blur\" gui-text=\"" N_("Level:") "\" type=\"float\" min=\"0.01\" max=\"20\">1</param>\n"
- "<param name=\"bdilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" min=\"1\" max=\"50\">6</param>\n"
- "<param name=\"berosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" min=\"0\" max=\"50\">2</param>\n"
+ "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">" N_("Simplify") "</_param>\n"
+ "<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
+ "<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n"
+ "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n"
+ "<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" indent=\"1\" type=\"boolean\" >false</param>\n"
+ "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">" N_("Smoothness") "</_param>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n"
+ "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">" N_("Melt") "</_param>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Level:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n"
+ "<param name=\"bdilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n"
+ "<param name=\"berosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n"
"</page>\n"
"<page name=\"co11tab\" _gui-text=\"Fill color\">\n"
"<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-1515870721</param>\n"
@@ -352,14 +354,14 @@ public:
"<page name=\"co12tab\" _gui-text=\"Stroke color\">\n"
"<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">589505535</param>\n"
"<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n"
- "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"int\" min=\"-100\" max=\"100\">0</param>\n"
+ "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n"
"</page>\n"
"</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Convert images to duochrome drawings") "</menu-tip>\n"
@@ -379,7 +381,7 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream smooth;
std::ostringstream dilat;
std::ostringstream erosion;
- std::ostringstream transluscent;
+ std::ostringstream translucent;
std::ostringstream offset;
std::ostringstream blur;
std::ostringstream bdilat;
@@ -401,10 +403,10 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
smooth << ext->get_param_float("smooth");
dilat << ext->get_param_float("dilat");
erosion << (- ext->get_param_float("erosion"));
- if (ext->get_param_bool("transluscent"))
- transluscent << "merge1";
+ if (ext->get_param_bool("translucent"))
+ translucent << "merge1";
else
- transluscent << "composite7";
+ translucent << "color5";
offset << ext->get_param_int("offset");
blur << ext->get_param_float("blur");
@@ -432,22 +434,22 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
ios << "flood2";
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Drawing, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Drawing\">\n"
"<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
"<feConvolveMatrix in=\"blur1\" targetX=\"1\" targetY=\"1\" order=\"3 3\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" result=\"convolve1\" />\n"
- "<feComposite in=\"convolve1\" in2=\"convolve1\" k1=\"1\" k2=\"1\" k4=\"%s\" operator=\"arithmetic\" stdDeviation=\"1\" result=\"composite1\" />\n"
+ "<feComposite in=\"convolve1\" in2=\"convolve1\" k1=\"1\" k2=\"1\" k4=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
"<feColorMatrix in=\"composite1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color1\" />\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color2\" />\n"
"<feFlood flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
- "<feBlend in2=\"color2\" mode=\"multiply\" blend=\"normal\" result=\"blend1\" />\n"
- "<feComponentTransfer in=\"blend1\" stdDeviation=\"2\" result=\"component1\">\n"
+ "<feBlend in2=\"color2\" mode=\"multiply\" result=\"blend1\" />\n"
+ "<feComponentTransfer in=\"blend1\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
"</feComponentTransfer>\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n"
- "<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" stdDeviation=\"1\" result=\"color3\" />\n"
+ "<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color3\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color4\" />\n"
"<feFlood flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
"<feComposite in=\"%s\" in2=\"color4\" operator=\"in\" result=\"composite2\" />\n"
@@ -460,16 +462,101 @@ Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
"<feMergeNode in=\"composite5\" />\n"
"<feMergeNode in=\"offset1\" />\n"
"</feMerge>\n"
- "<feComposite in=\"merge1\" in2=\"merge1\" operator=\"over\" result=\"composite6\" />\n"
- "<feComposite in=\"composite6\" in2=\"composite6\" operator=\"over\" result=\"composite7\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1.3 0 \" result=\"color5\" flood-opacity=\"0.56\" />\n"
"<feComposite in=\"%s\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite8\" />\n"
- "</filter>\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), transluscent.str().c_str());
+ "</filter>\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str());
return _filter;
}; /* Drawing filter */
/**
+ \brief Custom predefined Electrize filter.
+
+ Electro solarization effects.
+
+ Filter's parameters:
+ * Simplify (0.01->10., default 2.) -> blur (stdDeviation)
+ * Effect type (enum: table or discrete, default "table") -> component (type)
+ * Level (0->10, default 3) -> component (tableValues)
+ * Inverted (boolean, default false) -> component (tableValues)
+*/
+class Electrize : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Electrize ( ) : Filter() { };
+ virtual ~Electrize ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Electrize") "</name>\n"
+ "<id>org.inkscape.effect.filter.Electrize</id>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n"
+ "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
+ "<_item value=\"table\">" N_("Table") "</_item>\n"
+ "<_item value=\"discrete\">" N_("Discrete") "</_item>\n"
+ "</param>\n"
+ "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n"
+ "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Electro solarization effects") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Electrize());
+ };
+};
+
+gchar const *
+Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream blur;
+ std::ostringstream type;
+ std::ostringstream values;
+
+ blur << ext->get_param_float("blur");
+ type << ext->get_param_enum("type");
+
+ // TransfertComponent table values are calculated based on the effect level and inverted parameters.
+ int val = 0;
+ int levels = ext->get_param_int("levels") + 1;
+ if (ext->get_param_bool("invert")) {
+ val = 1;
+ }
+ values << val;
+ for ( int step = 1 ; step <= levels ; step++ ) {
+ if (val == 1) {
+ val = 0;
+ }
+ else {
+ val = 1;
+ }
+ values << " " << val;
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Electrize\">\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feComponentTransfer in=\"blur\" result=\"component\" >\n"
+ "<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
+ "<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
+ "<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
+ "</feComponentTransfer>\n"
+ "</filter>\n", blur.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str());
+
+ return _filter;
+}; /* Electrize filter */
+
+/**
\brief Custom predefined Neon draw filter.
Posterize and draw smooth lines around color shapes
@@ -495,15 +582,15 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Neon draw, custom") "</name>\n"
+ "<name>" N_("Neon Draw") "</name>\n"
"<id>org.inkscape.effect.filter.NeonDraw</id>\n"
"<param name=\"type\" gui-text=\"" N_("Line type:") "\" type=\"enum\">\n"
- "<_item value=\"table\">Smoothed</_item>\n"
- "<_item value=\"discrete\">Contrasted</_item>\n"
+ "<_item value=\"table\">" N_("Smoothed") "</_item>\n"
+ "<_item value=\"discrete\">" N_("Contrasted") "</_item>\n"
"</param>\n"
- "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" min=\"0.01\" max=\"20.0\">1.5</param>\n"
- "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" min=\"0.01\" max=\"20.0\">1.5</param>\n"
- "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" min=\"0.\" max=\"10.0\">0.5</param>\n"
+ "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
+ "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">0.5</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"multiply\">Multiply</_item>\n"
@@ -514,7 +601,7 @@ public:
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Posterize and draw smooth lines around color shapes") "</menu-tip>\n"
@@ -542,16 +629,17 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
lightness << ext->get_param_float("lightness");
const gchar *typestr = ext->get_param_enum("type");
- if (ext->get_param_bool("dark"))
+ if (ext->get_param_bool("dark")) {
dark << "component2";
- else if ((g_ascii_strcasecmp("table", typestr) == 0))
+ } else if ((g_ascii_strcasecmp("table", typestr) == 0)) {
dark << "blur2";
- else
+ } else {
dark << "component1";
+ }
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Neon draw, custom\">\n"
- "<feBlend blend=\"normal\" mode=\"%s\" result=\"blend\" />\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Neon Draw\">\n"
+ "<feBlend mode=\"%s\" result=\"blend\" />\n"
"<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n"
"<feComponentTransfer result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
@@ -572,6 +660,175 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* NeonDraw filter */
/**
+ \brief Custom predefined Point engraving filter.
+
+ Convert image to a transparent point engraving
+
+ Filter's parameters:
+
+ * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
+ * Horizontal frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100])
+ * Vertical frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100])
+ * Complexity (1->5, default 3) -> turbulence (numOctaves)
+ * Variation (0->1000, default 0) -> turbulence (seed)
+ * Noise reduction (-1000->-1500, default -1045) -> convolve (kernelMatrix, central value)
+ * Noise blend (enum, all blend options, default normal) -> blend (mode)
+ * Lightness (0.->10., default 2.5) -> composite1 (k1)
+ * Grain lightness (0.->10., default 1.3) -> composite1 (k2)
+ * Erase (0.00->1., default 0) -> composite1 (k4)
+ * Blur (0.01->2., default 0.5) -> blur (stdDeviation)
+
+ * Drawing color (guint32, default rgb(255,255,255)) -> flood1 (flood-color, flood-opacity)
+
+ * Background color (guint32, default rgb(99,89,46)) -> flood2 (flood-color, flood-opacity)
+*/
+
+class PointEngraving : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ PointEngraving ( ) : Filter() { };
+ virtual ~PointEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Point Engraving") "</name>\n"
+ "<id>org.inkscape.effect.filter.PointEngraving</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n"
+ "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
+ "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
+ "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
+ "</param>\n"
+ "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n"
+ "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n"
+ "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n"
+ "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n"
+ "<param name=\"reduction\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Noise blend:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n"
+ "<param name=\"grain\" gui-text=\"" N_("Grain lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n"
+ "<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n"
+ "</page>\n"
+ "<page name=\"fcolortab\" _gui-text=\"" N_("Fill color") "\">\n"
+ "<param name=\"fcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n"
+ "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "<page name=\"pcolortab\" _gui-text=\"" N_("Points color") "\">\n"
+ "<param name=\"pcolor\" gui-text=\"" N_("Color") "\" type=\"color\">1666789119</param>\n"
+ "<param name=\"iop\" gui-text=\"" N_("Image on points") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Convert image to a transparent point engraving") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new PointEngraving());
+ };
+
+};
+
+gchar const *
+PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream type;
+ std::ostringstream hfreq;
+ std::ostringstream vfreq;
+ std::ostringstream complexity;
+ std::ostringstream variation;
+ std::ostringstream reduction;
+ std::ostringstream blend;
+ std::ostringstream lightness;
+ std::ostringstream grain;
+ std::ostringstream erase;
+ std::ostringstream blur;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream a;
+ std::ostringstream br;
+ std::ostringstream bg;
+ std::ostringstream bb;
+ std::ostringstream ba;
+ std::ostringstream iof;
+ std::ostringstream iop;
+
+ type << ext->get_param_enum("type");
+ hfreq << ext->get_param_float("hfreq") / 100;
+ vfreq << ext->get_param_float("vfreq") / 100;
+ complexity << ext->get_param_int("complexity");
+ variation << ext->get_param_int("variation");
+ reduction << (-1000 - ext->get_param_int("reduction"));
+ blend << ext->get_param_enum("blend");
+ lightness << ext->get_param_float("lightness");
+ grain << ext->get_param_float("grain");
+ erase << ext->get_param_float("erase");
+ blur << ext->get_param_float("blur");
+
+ guint32 fcolor = ext->get_param_color("fcolor");
+ r << ((fcolor >> 24) & 0xff);
+ g << ((fcolor >> 16) & 0xff);
+ b << ((fcolor >> 8) & 0xff);
+ a << (fcolor & 0xff) / 255.0F;
+
+ guint32 pcolor = ext->get_param_color("pcolor");
+ br << ((pcolor >> 24) & 0xff);
+ bg << ((pcolor >> 16) & 0xff);
+ bb << ((pcolor >> 8) & 0xff);
+ ba << (pcolor & 0xff) / 255.0F;
+
+ if (ext->get_param_bool("iof"))
+ iof << "SourceGraphic";
+ else
+ iof << "flood2";
+
+ if (ext->get_param_bool("iop"))
+ iop << "SourceGraphic";
+ else
+ iop << "flood1";
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Point Engraving\" style=\"color-interpolation-filters:sRGB;\">\n"
+ "<feConvolveMatrix in=\"SourceGraphic\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0\" order=\"3 3\" result=\"convolve\" />\n"
+ "<feBlend in=\"convolve\" in2=\"SourceGraphic\" mode=\"%s\" result=\"blend\" />\n"
+ "<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\" />\n"
+ "<feColorMatrix in=\"blend\" type=\"luminanceToAlpha\" result=\"colormatrix1\" />\n"
+ "<feComposite in=\"turbulence\" in2=\"colormatrix1\" k1=\"%s\" k2=\"%s\" k4=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
+ "<feColorMatrix in=\"composite1\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 10 -9 \" result=\"colormatrix2\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood1\" />\n"
+ "<feComposite in=\"%s\" in2=\"blur\" operator=\"out\" result=\"composite2\" />\n"
+ "<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
+ "<feComposite in=\"%s\" in2=\"blur\" operator=\"in\" result=\"composite3\" />\n"
+ "<feComposite in=\"composite3\" in2=\"composite2\" k2=\"%s\" k3=\"%s\" operator=\"arithmetic\" result=\"composite4\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite5\" />\n"
+ "</filter>\n", reduction.str().c_str(), blend.str().c_str(),
+ type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(),
+ lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(),
+ br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str(), iop.str().c_str(),
+ r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(),
+ a.str().c_str(), ba.str().c_str() );
+
+ return _filter;
+}; /* Point engraving filter */
+
+/**
\brief Custom predefined Poster paint filter.
Poster and painting effects.
@@ -581,10 +838,10 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
Normal = feComponentTransfer
Dented = Normal + intermediate values
* Transfer type (enum, default "descrete") -> component (type)
- * Levels (1->15, default 5) -> component (tableValues)
+ * Levels (0->15, default 5) -> component (tableValues)
* Blend mode (enum, default "Lighten") -> blend (mode)
- * Primary blur (0.01->100., default 4.) -> blur1 (stdDeviation)
- * Secondary blur (0.01->100., default 0.5) -> blur2 (stdDeviation)
+ * Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation)
+ * Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation)
* Pre-saturation (0.->1., default 1.) -> color1 (values)
* Post-saturation (0.->1., default 1.) -> color2 (values)
* Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01)
@@ -600,32 +857,34 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Poster paint, custom") "</name>\n"
+ "<name>" N_("Poster Paint") "</name>\n"
"<id>org.inkscape.effect.filter.Posterize</id>\n"
"<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"dented\">Dented</_item>\n"
"</param>\n"
"<param name=\"table\" gui-text=\"" N_("Transfer type:") "\" type=\"enum\">\n"
- "<_item value=\"discrete\">Poster</_item>\n"
- "<_item value=\"table\">Painting</_item>\n"
+ "<_item value=\"discrete\">" N_("Poster") "</_item>\n"
+ "<_item value=\"table\">" N_("Painting") "</_item>\n"
"</param>\n"
- "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" min=\"1\" max=\"15\">5</param>\n"
+ "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
"<_item value=\"lighten\">Lighten</_item>\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"darken\">Darken</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
"</param>\n"
- "<param name=\"blur1\" gui-text=\"" N_("Primary blur:") "\" type=\"float\" min=\"0.01\" max=\"100.0\">4.0</param>\n"
- "<param name=\"blur2\" gui-text=\"" N_("Secondary blur:") "\" type=\"float\" min=\"0.01\" max=\"100.0\">0.5</param>\n"
- "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation:") "\" type=\"float\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
- "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation:") "\" type=\"float\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
+ "<param name=\"blur1\" gui-text=\"" N_("Simplify (primary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n"
+ "<param name=\"blur2\" gui-text=\"" N_("Simplify (secondary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n"
+ "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
+ "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
"<param name=\"antialiasing\" gui-text=\"" N_("Simulate antialiasing") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Poster and painting effects") "</menu-tip>\n"
@@ -660,11 +919,19 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
int levels = ext->get_param_int("levels") + 1;
const gchar *effecttype = ext->get_param_enum("type");
float val = 0.0;
- for ( int step = 1 ; step <= levels ; step++ ) {
- val = (float) step / levels;
- transf << " " << val;
- if((g_ascii_strcasecmp("dented", effecttype) == 0)) {
- transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels)));
+ if (levels == 1) {
+ if ((g_ascii_strcasecmp("dented", effecttype) == 0)) {
+ transf << " 1 0 1";
+ } else {
+ transf << " 1";
+ }
+ } else {
+ for ( int step = 1 ; step <= levels ; step++ ) {
+ val = (float) step / levels;
+ transf << " " << val;
+ if ((g_ascii_strcasecmp("dented", effecttype) == 0)) {
+ transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels)));
+ }
}
}
transf << " 1";
@@ -675,7 +942,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
antialias << "0.01";
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Poster paint, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Poster Paint\">\n"
"<feComposite operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n"
"<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
@@ -700,7 +967,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
Simple posterizing effect
Filter's parameters:
- * Levels (1->20, default 5) -> component1 (tableValues)
+ * Levels (0->20, default 5) -> component1 (tableValues)
* Blur (0.01->20., default 4.) -> blur1 (stdDeviation)
*/
class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter {
@@ -714,15 +981,15 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Posterize basic, custom") "</name>\n"
+ "<name>" N_("Posterize Basic") "</name>\n"
"<id>org.inkscape.effect.filter.PosterizeBasic</id>\n"
- "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" min=\"1\" max=\"20\">5</param>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"20.0\">4.0</param>\n"
+ "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Simple posterizing effect") "</menu-tip>\n"
@@ -751,9 +1018,9 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext)
transf << " 1";
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Posterize basic, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Posterize Basic\">\n"
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n"
- "<feComponentTransfer stdDeviation=\"2\" in=\"blur1\" result=\"component1\">\n"
+ "<feComponentTransfer in=\"blur1\" result=\"component1\">\n"
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
@@ -769,5 +1036,5 @@ PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* namespace Extension */
}; /* namespace Inkscape */
-/* Change the 'EXPERIMENTAL' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_EXPERIMENTAL_H__ */
+/* Change the 'PAINT' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ */
diff --git a/src/extension/internal/filter/snow.h b/src/extension/internal/filter/protrusions.h
index aac07fe62..8ba35db62 100644
--- a/src/extension/internal/filter/snow.h
+++ b/src/extension/internal/filter/protrusions.h
@@ -1,10 +1,16 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__
-/* Change the 'SNOW' above to be your file name */
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__
+/* Change the 'PROTRUSIONS' above to be your file name */
/*
* Copyright (C) 2008 Authors:
* Ted Gould <ted@gould.cx>
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Protrusion filters
+ * Snow
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -12,11 +18,21 @@
#include "filter.h"
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
namespace Filter {
+
+/**
+ \brief Custom predefined Snow filter.
+
+ Snow has fallen on object.
+*/
class Snow : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
@@ -31,7 +47,7 @@ public:
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Snow crest") "</name>\n"
"<id>org.inkscape.effect.filter.snow</id>\n"
- "<param name=\"drift\" gui-text=\"" N_("Drift Size:") "\" type=\"float\" min=\"0.0\" max=\"20.0\">3.5</param>\n"
+ "<param name=\"drift\" gui-text=\"" N_("Drift Size:") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -55,7 +71,7 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext)
drift << ext->get_param_float("drift");
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Snow\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Snow\">\n"
"<feConvolveMatrix order=\"3 3\" kernelMatrix=\"1 1 1 0 0 0 -1 -1 -1\" preserveAlpha=\"false\" divisor=\"3\"/>\n"
"<feMorphology operator=\"dilate\" radius=\"1 %s\"/>\n"
"<feGaussianBlur stdDeviation=\"1.6270889487870621\" result=\"result0\"/>\n"
@@ -71,12 +87,13 @@ Snow::get_filter_text (Inkscape::Extension::Extension * ext)
"</filter>\n", drift.str().c_str());
return _filter;
-};
+}; /* Snow filter */
+
}; /* namespace Filter */
}; /* namespace Internal */
}; /* namespace Extension */
}; /* namespace Inkscape */
-/* Change the 'SNOW' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_SNOW_H__ */
+/* Change the 'PROTRUSIONS' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PROTRUSIONS_H__ */
diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h
index 1924c5bb3..d76358a96 100644
--- a/src/extension/internal/filter/shadows.h
+++ b/src/extension/internal/filter/shadows.h
@@ -1,5 +1,5 @@
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__
/* Change the 'SHADOWS' above to be your file name */
/*
@@ -7,7 +7,7 @@
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
- * Color filters
+ * Shadow filters
* Drop shadow
*
* Released under GNU GPL, read the file 'COPYING' for more information
@@ -34,7 +34,13 @@ namespace Filter {
* Blur radius (0.->200., default 3) -> blur (stdDeviation)
* Horizontal offset (-50.->50., default 6.0) -> offset (dx)
* Vertical offset (-50.->50., default 6.0) -> offset (dy)
+ * Blur type (enum, default outer) ->
+ outer = composite1 (operator="in"), composite2 (operator="over", in1="SourceGraphic", in2="offset")
+ inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic")
+ innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic")
+ outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset")
* Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color)
+ * Use object's color (boolean, default false) -> composite1 (in1, in2)
*/
class ColorizableDropShadow : public Inkscape::Extension::Internal::Filter::Filter {
protected:
@@ -47,21 +53,34 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Drop shadow, custom (Shadows and Glows)") "</name>\n"
- "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n"
- "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
- "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n"
- "<effect>\n"
- "<object-type>all</object-type>\n"
- "<effects-menu>\n"
- "<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "<name>" N_("Drop Shadow") "</name>\n"
+ "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
+ "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
+ "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n"
+ "<_item value=\"outer\">" N_("Outer") "</_item>\n"
+ "<_item value=\"inner\">" N_("Inner") "</_item>\n"
+ "<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n"
+ "<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n"
+ "</param>\n"
+ "</page>\n"
+ "<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n"
+ "<param name=\"objcolor\" gui-text=\"" N_("Use object's color") "\" type=\"boolean\" >false</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Shadows and Glows") "\"/>\n"
"</submenu>\n"
- "</effects-menu>\n"
- "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n"
- "</effect>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Colorizable Drop shadow") "</menu-tip>\n"
+ "</effect>\n"
"</inkscape-extension>\n", new ColorizableDropShadow());
};
@@ -79,7 +98,14 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream b;
std::ostringstream x;
std::ostringstream y;
-
+ std::ostringstream comp1in1;
+ std::ostringstream comp1in2;
+ std::ostringstream comp1op;
+ std::ostringstream comp2in1;
+ std::ostringstream comp2in2;
+ std::ostringstream comp2op;
+
+ const gchar *type = ext->get_param_enum("type");
guint32 color = ext->get_param_color("color");
blur << ext->get_param_float("blur");
@@ -90,17 +116,62 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
g << ((color >> 16) & 0xff);
b << ((color >> 8) & 0xff);
+ // Select object or user-defined color
+ if ((g_ascii_strcasecmp("innercut", type) == 0)) {
+ if (ext->get_param_bool("objcolor")) {
+ comp2in1 << "SourceGraphic";
+ comp2in2 << "offset";
+ } else {
+ comp2in1 << "offset";
+ comp2in2 << "SourceGraphic";
+ }
+ } else {
+ if (ext->get_param_bool("objcolor")) {
+ comp1in1 << "SourceGraphic";
+ comp1in2 << "flood";
+ } else {
+ comp1in1 << "flood";
+ comp1in2 << "SourceGraphic";
+ }
+ }
+
+ // Shadow mode
+ if ((g_ascii_strcasecmp("outer", type) == 0)) {
+ comp1op << "in";
+ comp2op << "over";
+ comp2in1 << "SourceGraphic";
+ comp2in2 << "offset";
+ } else if ((g_ascii_strcasecmp("inner", type) == 0)) {
+ comp1op << "out";
+ comp2op << "atop";
+ comp2in1 << "offset";
+ comp2in2 << "SourceGraphic";
+ } else if ((g_ascii_strcasecmp("outercut", type) == 0)) {
+ comp1op << "in";
+ comp2op << "out";
+ comp2in1 << "offset";
+ comp2in2 << "SourceGraphic";
+ } else { //innercut
+ comp1op << "out";
+ comp1in1 << "flood";
+ comp1in2 << "SourceGraphic";
+ comp2op << "in";
+ }
+
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1.2\" width=\"1.2\" y=\"-0.1\" x=\"-0.1\" inkscape:label=\"Drop shadow, custom\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Drop Shadow\">\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
- "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite1\" />\n"
+ "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite1\" />\n"
"<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur\" />\n"
"<feOffset dx=\"%s\" dy=\"%s\" result=\"offset\" />\n"
- "<feComposite in=\"SourceGraphic\" in2=\"offset\" operator=\"over\" result=\"composite2\" />\n"
- "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), blur.str().c_str(), x.str().c_str(), y.str().c_str());
+ "<feComposite in=\"%s\" in2=\"%s\" operator=\"%s\" result=\"composite2\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ comp1in1.str().c_str(), comp1in2.str().c_str(), comp1op.str().c_str(),
+ blur.str().c_str(), x.str().c_str(), y.str().c_str(),
+ comp2in1.str().c_str(), comp2in2.str().c_str(), comp2op.str().c_str());
return _filter;
-};
+}; /* Drop shadow filter */
}; /* namespace Filter */
}; /* namespace Internal */
@@ -108,4 +179,4 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* namespace Inkscape */
/* Change the 'SHADOWS' below to be your file name */
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_SHADOWS_H__ */
diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h
new file mode 100644
index 000000000..32eef6054
--- /dev/null
+++ b/src/extension/internal/filter/textures.h
@@ -0,0 +1,158 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__
+/* Change the 'TEXTURES' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Protrusion filters
+ * Ink blot
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+
+/**
+ \brief Custom predefined Ink Blot filter.
+
+ Inkblot on tissue or rough paper.
+
+ Filter's parameters:
+
+ * Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
+ * Frequency (0.001->1., default 0.04) -> turbulence (baseFrequency [/100])
+ * Complexity (1->5, default 3) -> turbulence (numOctaves)
+ * Variation (0->100, default 0) -> turbulence (seed)
+ * Horizontal inlay (0.01->30., default 10) -> blur1 (stdDeviation x)
+ * Vertical inlay (0.01->30., default 10) -> blur1 (stdDeviation y)
+ * Displacement (0.->100., default 50) -> map (scale)
+ * Blend (0.01->30., default 5) -> blur2 (stdDeviation)
+ * Stroke (enum, default over) -> composite (operator)
+ * Arithmetic stroke options
+ * k1 (-10.->10., default 1.5)
+ * k2 (-10.->10., default -0.25)
+ * k3 (-10.->10., default 0.5)
+*/
+class InkBlot : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ InkBlot ( ) : Filter() { };
+ virtual ~InkBlot ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+public:
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Ink Blot") "</name>\n"
+ "<id>org.inkscape.effect.filter.InkBlot</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
+ "<_item value=\"fractalNoise\">Fractal noise</_item>\n"
+ "<_item value=\"turbulence\">Turbulence</_item>\n"
+ "</param>\n"
+ "<param name=\"freq\" gui-text=\"" N_("Frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4</param>\n"
+ "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n"
+ "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"100\">0</param>\n"
+ "<param name=\"hblur\" gui-text=\"" N_("Horizontal inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n"
+ "<param name=\"vblur\" gui-text=\"" N_("Vertical inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n"
+ "<param name=\"displacement\" gui-text=\"" N_("Displacement:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"100.00\">50</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">5</param>\n"
+ "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n"
+ "<_item value=\"over\">" N_("Wide") "</_item>\n"
+ "<_item value=\"atop\">" N_("Normal") "</_item>\n"
+ "<_item value=\"in\">" N_("Narrow") "</_item>\n"
+ "<_item value=\"xor\">" N_("Overlapping") "</_item>\n"
+ "<_item value=\"out\">" N_("External") "</_item>\n"
+ "<_item value=\"arithmetic\">" N_("Custom") "</_item>\n"
+ "</param>\n"
+ "<_param name=\"customHeader\" type=\"description\" appearance=\"header\">" N_("Custom stroke options") "</_param>\n"
+ "<param name=\"k1\" gui-text=\"" N_("k1:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1.5</param>\n"
+ "<param name=\"k2\" gui-text=\"" N_("k2:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-0.25</param>\n"
+ "<param name=\"k3\" gui-text=\"" N_("k3:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"Textures\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Inkblot on tissue or rough paper") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new InkBlot());
+ };
+
+};
+
+gchar const *
+InkBlot::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream type;
+ std::ostringstream freq;
+ std::ostringstream complexity;
+ std::ostringstream variation;
+ std::ostringstream hblur;
+ std::ostringstream vblur;
+ std::ostringstream displacement;
+ std::ostringstream blend;
+ std::ostringstream stroke;
+ std::ostringstream custom;
+
+ type << ext->get_param_enum("type");
+ freq << ext->get_param_float("freq") / 100;
+ complexity << ext->get_param_int("complexity");
+ variation << ext->get_param_int("variation");
+ hblur << ext->get_param_float("hblur");
+ vblur << ext->get_param_float("vblur");
+ displacement << ext->get_param_float("displacement");
+ blend << ext->get_param_float("blend");
+
+ const gchar *ope = ext->get_param_enum("stroke");
+ if (g_ascii_strcasecmp("arithmetic", ope) == 0) {
+ custom << "k1=\"" << ext->get_param_float("k1") << "\" k2=\"" << ext->get_param_float("k2") << "\" k3=\"" << ext->get_param_float("k3") << "\"";
+ } else {
+ custom << "";
+ }
+
+ stroke << ext->get_param_enum("stroke");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" x=\"-0.15\" width=\"1.3\" y=\"-0.15\" height=\"1.3\" inkscape:label=\"Ink Blot\" >\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s %s\" result=\"blur1\" />\n"
+ "<feTurbulence type=\"%s\" baseFrequency=\"%s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\" />\n"
+ "<feDisplacementMap in=\"blur1\" in2=\"turbulence\" xChannelSelector=\"R\" yChannelSelector=\"G\" scale=\"%s\" result=\"map\" />\n"
+ "<feGaussianBlur in=\"map\" stdDeviation=\"%s\" result=\"blur2\" />\n"
+ "<feComposite in=\"blur2\" in2=\"map\" %s operator=\"%s\" result=\"composite\" />\n"
+ "</filter>\n", hblur.str().c_str(), vblur.str().c_str(), type.str().c_str(),
+ freq.str().c_str(), complexity.str().c_str(), variation.str().c_str(),
+ displacement.str().c_str(), blend.str().c_str(),
+ custom.str().c_str(), stroke.str().c_str() );
+
+ return _filter;
+
+}; /* Ink Blot filter */
+
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'TEXTURES' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TEXTURES_H__ */
diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h
new file mode 100644
index 000000000..b29a0a1b3
--- /dev/null
+++ b/src/extension/internal/filter/transparency.h
@@ -0,0 +1,399 @@
+#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__
+#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__
+/* Change the 'TRANSPARENCY' above to be your file name */
+
+/*
+ * Copyright (C) 2011 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Fill and transparency filters
+ * Blend
+ * Channel transparency
+ * Light eraser
+ * Opacity
+ * Silhouette
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
+
+#include "filter.h"
+
+#include "extension/internal/clear-n_.h"
+#include "extension/system.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+namespace Filter {
+
+/**
+ \brief Custom predefined Blend filter.
+
+ Blend objects with background images or with themselves
+
+ Filter's parameters:
+ * Source (enum [SourceGraphic,BackgroundImage], default BackgroundImage) -> blend (in2)
+ * Mode (enum, all blend modes, default Multiply) -> blend (mode)
+*/
+
+class Blend : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Blend ( ) : Filter() { };
+ virtual ~Blend ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Blend") "</name>\n"
+ "<id>org.inkscape.effect.filter.Blend</id>\n"
+ "<param name=\"source\" gui-text=\"" N_("Source:") "\" type=\"enum\">\n"
+ "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n"
+ "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
+ "</param>\n"
+ "<param name=\"mode\" gui-text=\"" N_("Mode:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
+ "<_item value=\"normal\">" N_("Normal") "</_item>\n"
+ "<_item value=\"screen\">" N_("Screen") "</_item>\n"
+ "<_item value=\"darken\">" N_("Darken") "</_item>\n"
+ "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Fill and Transparency") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Blend objects with background images or with themselves") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Blend());
+ };
+
+};
+
+gchar const *
+Blend::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream source;
+ std::ostringstream mode;
+
+ source << ext->get_param_enum("source");
+ mode << ext->get_param_enum("mode");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Blend\">\n"
+ "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend\" />\n"
+ "</filter>\n", source.str().c_str(), mode.str().c_str() );
+
+ return _filter;
+}; /* Blend filter */
+
+/**
+ \brief Custom predefined Channel transparency filter.
+
+ Channel transparency filter.
+
+ Filter's parameters:
+ * Saturation (0.->1., default 1.) -> colormatrix1 (values)
+ * Red (-10.->10., default -1.) -> colormatrix2 (values)
+ * Green (-10.->10., default 0.5) -> colormatrix2 (values)
+ * Blue (-10.->10., default 0.5) -> colormatrix2 (values)
+ * Alpha (-10.->10., default 1.) -> colormatrix2 (values)
+ * Flood colors (guint, default 16777215) -> flood (flood-opacity, flood-color)
+ * Inverted (boolean, default false) -> composite1 (operator, true='in', false='out')
+
+ Matrix:
+ 1 0 0 0 0
+ 0 1 0 0 0
+ 0 0 1 0 0
+ R G B A 0
+*/
+class ChannelTransparency : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ ChannelTransparency ( ) : Filter() { };
+ virtual ~ChannelTransparency ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Channel Transparency") "</name>\n"
+ "<id>org.inkscape.effect.filter.ChannelTransparency</id>\n"
+ "<param name=\"red\" gui-text=\"" N_("Red:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n"
+ "<param name=\"green\" gui-text=\"" N_("Green:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n"
+ "<param name=\"blue\" gui-text=\"" N_("Blue:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n"
+ "<param name=\"alpha\" gui-text=\"" N_("Alpha:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n"
+ "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Fill and Transparency") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Replace RGB with transparency") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new ChannelTransparency());
+ };
+};
+
+gchar const *
+ChannelTransparency::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream red;
+ std::ostringstream green;
+ std::ostringstream blue;
+ std::ostringstream alpha;
+ std::ostringstream invert;
+
+ red << ext->get_param_float("red");
+ green << ext->get_param_float("green");
+ blue << ext->get_param_float("blue");
+ alpha << ext->get_param_float("alpha");
+
+ if (!ext->get_param_bool("invert")) {
+ invert << "in";
+ } else {
+ invert << "xor";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Channel Transparency\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix\" />\n"
+ "<feComposite in=\"colormatrix\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite1\" />\n"
+ "</filter>\n", red.str().c_str(), green.str().c_str(), blue.str().c_str(), alpha.str().c_str(),
+ invert.str().c_str());
+
+ return _filter;
+}; /* Channel transparency filter */
+
+/**
+ \brief Custom predefined LightEraser filter.
+
+ Make the lightest parts of the object progressively transparent.
+
+ Filter's parameters:
+ * Expansion (0.->1000., default 50) -> colormatrix (4th value, multiplicator)
+ * Erosion (1.->1000., default 100) -> colormatrix (first 3 values, multiplicator)
+ * Global opacity (0.->1., default 1.) -> composite (k2)
+ * Inverted (boolean, default false) -> colormatrix (values, true: first 3 values positive, 4th negative)
+
+*/
+class LightEraser : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ LightEraser ( ) : Filter() { };
+ virtual ~LightEraser ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Light Eraser") "</name>\n"
+ "<id>org.inkscape.effect.filter.LightEraser</id>\n"
+ "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n"
+ "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n"
+ "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n"
+ "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Fill and Transparency") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Make the lightest parts of the object progressively transparent") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new LightEraser());
+ };
+};
+
+gchar const *
+LightEraser::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream expand;
+ std::ostringstream erode;
+ std::ostringstream opacity;
+
+ opacity << ext->get_param_float("opacity");
+
+ if (ext->get_param_bool("invert")) {
+ expand << (ext->get_param_float("erode") * 0.2125) << " "
+ << (ext->get_param_float("erode") * 0.7154) << " "
+ << (ext->get_param_float("erode") * 0.0721);
+ erode << (-ext->get_param_float("expand"));
+ } else {
+ expand << (-ext->get_param_float("erode") * 0.2125) << " "
+ << (-ext->get_param_float("erode") * 0.7154) << " "
+ << (-ext->get_param_float("erode") * 0.0721);
+ erode << ext->get_param_float("expand");
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Light Eraser\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feComposite in2=\"colormatrix\" operator=\"arithmetic\" k2=\"%s\" result=\"composite\" />\n"
+ "</filter>\n", expand.str().c_str(), erode.str().c_str(), opacity.str().c_str());
+
+ return _filter;
+}; /* Light Eraser filter */
+
+
+/**
+ \brief Custom predefined Opacity filter.
+
+ Set opacity and strength of opacity boundaries.
+
+ Filter's parameters:
+ * Expansion (0.->1000., default 5) -> colormatrix (last-1th value)
+ * Erosion (0.->1000., default 1) -> colormatrix (last value)
+ * Global opacity (0.->1., default 1.) -> composite (k2)
+
+*/
+class Opacity : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Opacity ( ) : Filter() { };
+ virtual ~Opacity ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Opacity") "</name>\n"
+ "<id>org.inkscape.effect.filter.Opacity</id>\n"
+ "<param name=\"expand\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n"
+ "<param name=\"erode\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n"
+ "<param name=\"opacity\" gui-text=\"" N_("Global opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Fill and Transparency") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Set opacity and strength of opacity boundaries") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Opacity());
+ };
+};
+
+gchar const *
+Opacity::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream matrix;
+ std::ostringstream opacity;
+
+ opacity << ext->get_param_float("opacity");
+
+ matrix << (ext->get_param_float("expand")) << " "
+ << (-ext->get_param_float("erode"));
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Opacity\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s \" result=\"colormatrix\" />\n"
+ "<feComposite in2=\"colormatrix\" operator=\"arithmetic\" k2=\"%s\" result=\"composite\" />\n"
+ "</filter>\n", matrix.str().c_str(), opacity.str().c_str());
+
+ return _filter;
+}; /* Opacity filter */
+
+/**
+ \brief Custom predefined Silhouette filter.
+
+ Repaint anything visible monochrome
+
+ Filter's parameters:
+ * Blur (0.01->50., default 0.01) -> blur (stdDeviation)
+ * Cutout (boolean, default False) -> composite (false=in, true=out)
+ * Color (guint, default 0,0,0,255) -> flood (flood-color, flood-opacity)
+*/
+
+class Silhouette : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Silhouette ( ) : Filter() { };
+ virtual ~Silhouette ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Silhouette") "</name>\n"
+ "<id>org.inkscape.effect.filter.Silhouette</id>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n"
+ "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Fill and Transparency") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Repaint anything visible monochrome") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Silhouette());
+ };
+
+};
+
+gchar const *
+Silhouette::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream a;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream cutout;
+ std::ostringstream blur;
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+ if (ext->get_param_bool("cutout"))
+ cutout << "out";
+ else
+ cutout << "in";
+ blur << ext->get_param_float("blur");
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Silhouette\">\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feComposite in=\"flood\" in2=\"SourceGraphic\" operator=\"%s\" result=\"composite\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(), cutout.str().c_str(), blur.str().c_str());
+
+ return _filter;
+}; /* Silhouette filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'TRANSPARENCY' below to be your file name */
+#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_TRANSPARENCY_H__ */
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index c3a30a2f0..8b4c8805b 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -150,8 +150,8 @@ GdkpixbufInput::init(void)
"<name>%s</name>\n"
"<id>org.inkscape.input.gdkpixbuf.%s</id>\n"
"<param name='link' type='optiongroup' appearance='full' _gui-text='" N_("Link or embed image:") "' >\n"
- "<_option value='embed'>" N_("embed") "</_option>\n"
- "<_option value='link'>" N_("link") "</_option>\n"
+ "<_option value='embed'>" N_("Embed") "</_option>\n"
+ "<_option value='link'>" N_("Link") "</_option>\n"
"</param>\n"
"<_param name='help' type='description'>" N_("Embed results in stand-alone, larger SVG files. Link references a file outside this SVG document and all files must be moved together.") "</_param>\n"
"<input>\n"
diff --git a/src/extension/internal/gimpgrad.h b/src/extension/internal/gimpgrad.h
index ed409ef93..c34de840d 100644
--- a/src/extension/internal/gimpgrad.h
+++ b/src/extension/internal/gimpgrad.h
@@ -1,7 +1,4 @@
-/** \file
- *
- * Implementation class of the GIMP gradient plugin.
- *
+/*
* Authors:
* Ted Gould <ted@gould.cx>
*
@@ -9,20 +6,24 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+// TODO add include guard
#include <glibmm/ustring.h>
#include "extension/implementation/implementation.h"
-#include "extension/extension-forward.h"
namespace Inkscape {
namespace Extension {
+
+class Extension;
+
namespace Internal {
-/** \brief Implementation class of the GIMP gradient plugin. This mostly
- just creates a namespace for the GIMP gradient plugin today.
-*/
-class GimpGrad : public Inkscape::Extension::Implementation::Implementation {
+/**
+ * Implementation class of the GIMP gradient plugin.
+ * This mostly just creates a namespace for the GIMP gradient plugin today.
+ */
+class GimpGrad : public Inkscape::Extension::Implementation::Implementation
+{
public:
bool load(Inkscape::Extension::Extension *module);
void unload(Inkscape::Extension::Extension *module);
@@ -32,7 +33,9 @@ public:
};
-} } } /* namespace Internal; Extension; Inkscape */
+} // namespace Internal
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index 2e743d32a..da5ea6d9e 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -90,7 +90,7 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
bounding_area = Geom::Rect( Geom::Point(0,0),
Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
- Geom::OptRect bounds = selection->bounds();
+ Geom::OptRect bounds = selection->visualBounds();
if (bounds) {
bounding_area = *bounds;
}
@@ -207,7 +207,9 @@ Grid::init (void)
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
- "<submenu name=\"" N_("Render") "\" />\n"
+ "<submenu name=\"" N_("Render") "\">\n"
+ "<submenu name=\"" N_("Grids") "\" />\n"
+ "</submenu>\n"
"</effects-menu>\n"
"<menu-tip>" N_("Draw a path which is a grid") "</menu-tip>\n"
"</effect>\n"
diff --git a/src/extension/internal/grid.h b/src/extension/internal/grid.h
index 1f37b1441..c54135d81 100644
--- a/src/extension/internal/grid.h
+++ b/src/extension/internal/grid.h
@@ -8,10 +8,13 @@
*/
#include "extension/implementation/implementation.h"
-#include "extension/extension-forward.h"
namespace Inkscape {
namespace Extension {
+
+class Effect;
+class Extension;
+
namespace Internal {
/** \brief Implementation class of the GIMP gradient plugin. This mostly
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index 750849eb1..7646946fd 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -38,7 +38,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include <io/sys.h>
-
+#include "sp-root.h"
#include <string>
#include <stdio.h>
@@ -311,7 +311,7 @@ bool JavaFXOutput::doGradient(SPGradient *grad, const String &id)
out(" function %s(): LinearGradient {\n", jfxid.c_str());
out(" LinearGradient {\n");
std::vector<SPGradientStop> stops = g->vector.stops;
- if (stops.size() > 0)
+ if (!stops.empty())
{
out(" stops:\n");
out(" [\n");
@@ -341,7 +341,7 @@ bool JavaFXOutput::doGradient(SPGradient *grad, const String &id)
out(" focusY: %s\n", DSTR(g->fy.value));
out(" radius: %s\n", DSTR(g->r.value ));
std::vector<SPGradientStop> stops = g->vector.stops;
- if (stops.size() > 0)
+ if (!stops.empty())
{
out(" stops:\n");
out(" [\n");
@@ -492,8 +492,8 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id)
}
// convert the path to only lineto's and cubic curveto's:
- Geom::Scale yflip(1.0, -1.0);
- Geom::Affine tf = item->i2d_affine() * yflip;
+ Geom::Scale yflip(1.0, -1.0); /// @fixme hardcoded desktop transform!
+ Geom::Affine tf = item->i2dt_affine() * yflip;
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
//Count the NR_CURVETOs/LINETOs (including closing line segment)
@@ -634,8 +634,8 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id)
}
// convert the path to only lineto's and cubic curveto's:
- Geom::Scale yflip(1.0, -1.0);
- Geom::Affine tf = item->i2d_affine() * yflip;
+ Geom::Scale yflip(1.0, -1.0); /// @fixme hardcoded desktop transform
+ Geom::Affine tf = item->i2dt_affine() * yflip;
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
//Count the NR_CURVETOs/LINETOs (including closing line segment)
@@ -758,7 +758,7 @@ bool JavaFXOutput::doTree(SPDocument *doc)
miny = bignum;
maxy = -bignum;
- if (!doTreeRecursive(doc, doc->root)) {
+ if (!doTreeRecursive(doc, doc->getRoot())) {
return false;
}
@@ -875,7 +875,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
out(" content: [\n");
idindex = 0;
- doBody(doc, doc->root);
+ doBody(doc, doc->getRoot());
if (!doTail()) {
return false;
@@ -891,7 +891,7 @@ bool JavaFXOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
return false;
}
- for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); iter++)
+ for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter)
{
fputc(*iter, f);
}
diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp
index 1477d5daf..faac9ce44 100644
--- a/src/extension/internal/latex-pstricks-out.cpp
+++ b/src/extension/internal/latex-pstricks-out.cpp
@@ -18,9 +18,8 @@
#include "extension/system.h"
#include "extension/print.h"
#include "extension/db.h"
-#include "display/nr-arena.h"
-#include "display/nr-arena-item.h"
-
+#include "display/drawing.h"
+#include "sp-root.h"
@@ -39,49 +38,41 @@ LatexOutput::~LatexOutput (void) //The destructor
return;
}
-bool
-LatexOutput::check (Inkscape::Extension::Extension * module)
+bool LatexOutput::check(Inkscape::Extension::Extension * /*module*/)
{
- if (NULL == Inkscape::Extension::db.get("org.inkscape.print.latex"))
- return FALSE;
- return TRUE;
+ bool result = Inkscape::Extension::db.get("org.inkscape.print.latex") != NULL;
+ return result;
}
-void
-LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar const *filename)
+void LatexOutput::save(Inkscape::Extension::Output * /*mod2*/, SPDocument *doc, gchar const *filename)
{
- Inkscape::Extension::Print *mod;
SPPrintContext context;
- const gchar * oldconst;
- gchar * oldoutput;
- unsigned int ret;
+ unsigned int ret = 0;
doc->ensureUpToDate();
- mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
- oldconst = mod->get_param_string("destination");
- oldoutput = g_strdup(oldconst);
+ Inkscape::Extension::Print *mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
+ const gchar * oldconst = mod->get_param_string("destination");
+ gchar * oldoutput = g_strdup(oldconst);
mod->set_param_string("destination", filename);
/* Start */
context.module = mod;
/* fixme: This has to go into module constructor somehow */
- /* Create new arena */
- mod->base = SP_ITEM(doc->getRoot());
- mod->arena = NRArena::create();
+ mod->base = doc->getRoot();
+ Inkscape::Drawing drawing;
mod->dkey = SPItem::display_key_new (1);
- mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->root = (mod->base)->invoke_show (drawing, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ drawing.setRoot(mod->root);
/* Print document */
ret = mod->begin (doc);
(mod->base)->invoke_print (&context);
ret = mod->finish ();
- /* Release arena */
+ /* Release things */
(mod->base)->invoke_hide (mod->dkey);
mod->base = NULL;
- mod->root = NULL;
- nr_object_unref ((NRObject *) mod->arena);
- mod->arena = NULL;
+ mod->root = NULL; // should have been deleted by invoke_hide
/* end */
mod->set_param_string("destination", oldoutput);
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index e09e7c024..dd5419ee4 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -56,8 +56,7 @@ PrintLatex::~PrintLatex (void)
return;
}
-unsigned int
-PrintLatex::setup (Inkscape::Extension::Print *mod)
+unsigned int PrintLatex::setup(Inkscape::Extension::Print * /*mod*/)
{
return TRUE;
}
@@ -141,63 +140,60 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n";
}
- m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
+ m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight())); /// @fixme hardcoded doc2dt transform
return fprintf(_stream, "%s", os.str().c_str());
}
-unsigned int
-PrintLatex::finish (Inkscape::Extension::Print *mod)
+unsigned int PrintLatex::finish(Inkscape::Extension::Print * /*mod*/)
{
- int res;
-
- if (!_stream) return 0;
-
- res = fprintf(_stream, "\\end{pspicture}\n");
+ if (_stream) {
+ fprintf(_stream, "\\end{pspicture}\n");
- /* Flush stream to be sure. */
- (void) fflush(_stream);
+ // Flush stream to be sure.
+ fflush(_stream);
- fclose(_stream);
- _stream = NULL;
+ fclose(_stream);
+ _stream = NULL;
+ }
return 0;
}
-unsigned int
-PrintLatex::bind(Inkscape::Extension::Print *mod, Geom::Affine const *transform, float opacity)
+unsigned int PrintLatex::bind(Inkscape::Extension::Print * /*mod*/, Geom::Affine const &transform, float /*opacity*/)
{
- Geom::Affine tr = *transform;
-
- if(m_tr_stack.size()){
+ if (!m_tr_stack.empty()) {
Geom::Affine tr_top = m_tr_stack.top();
- m_tr_stack.push(tr * tr_top);
- }else
- m_tr_stack.push(tr);
+ m_tr_stack.push(transform * tr_top);
+ } else {
+ m_tr_stack.push(transform);
+ }
return 1;
}
-unsigned int
-PrintLatex::release(Inkscape::Extension::Print *mod)
+unsigned int PrintLatex::release(Inkscape::Extension::Print * /*mod*/)
{
m_tr_stack.pop();
return 1;
}
-unsigned int PrintLatex::comment (Inkscape::Extension::Print * module,
- const char * comment)
+unsigned int PrintLatex::comment(Inkscape::Extension::Print * /*mod*/,
+ const char * comment)
{
- if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (!_stream) {
+ return 0; // XXX: fixme, returning -1 as unsigned.
+ }
return fprintf(_stream, "%%! %s\n",comment);
}
-unsigned int
-PrintLatex::fill(Inkscape::Extension::Print *mod,
- Geom::PathVector const &pathv, Geom::Affine const *transform, SPStyle const *style,
- NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
+unsigned int PrintLatex::fill(Inkscape::Extension::Print * /*mod*/,
+ Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
+ Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/)
{
- if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (!_stream) {
+ return 0; // XXX: fixme, returning -1 as unsigned.
+ }
if (style->fill.isColor()) {
Inkscape::SVGOStringStream os;
@@ -226,11 +222,13 @@ PrintLatex::fill(Inkscape::Extension::Print *mod,
return 0;
}
-unsigned int
-PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+unsigned int PrintLatex::stroke(Inkscape::Extension::Print * /*mod*/,
+ Geom::PathVector const &pathv, Geom::Affine const &transform, SPStyle const *style,
+ Geom::OptRect const & /*pbox*/, Geom::OptRect const & /*dbox*/, Geom::OptRect const & /*bbox*/)
{
- if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
+ if (!_stream) {
+ return 0; // XXX: fixme, returning -1 as unsigned.
+ }
if (style->stroke.isColor()) {
Inkscape::SVGOStringStream os;
@@ -277,12 +275,12 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, Geom::PathVector const &pat
// FIXME: why is 'transform' argument not used?
void
-PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/)
+PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/)
{
if (pathv_in.empty())
return;
-// Geom::Affine tf=*transform; // why was this here?
+// Geom::Affine tf=transform; // why was this here?
Geom::Affine tf_stack=m_tr_stack.top(); // and why is transform argument not used?
Geom::PathVector pathv = pathv_in * tf_stack; // generates new path, which is a bit slow, but this doesn't have to be performance optimized
@@ -304,7 +302,7 @@ PrintLatex::print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv
}
void
-PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c )
+PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c)
{
using Geom::X;
using Geom::Y;
diff --git a/src/extension/internal/latex-pstricks.h b/src/extension/internal/latex-pstricks.h
index 64b0de474..5bc6eeb22 100644
--- a/src/extension/internal/latex-pstricks.h
+++ b/src/extension/internal/latex-pstricks.h
@@ -33,7 +33,7 @@ class PrintLatex : public Inkscape::Extension::Implementation::Implementation {
std::stack<Geom::Affine> m_tr_stack;
- void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine * /*transform*/);
+ void print_pathvector(SVGOStringStream &os, Geom::PathVector const &pathv_in, const Geom::Affine & /*transform*/);
void print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c );
public:
@@ -47,13 +47,17 @@ public:
virtual unsigned int finish (Inkscape::Extension::Print * module);
/* Rendering methods */
- virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const *transform, float opacity);
+ virtual unsigned int bind(Inkscape::Extension::Print *module, Geom::Affine const &transform, float opacity);
virtual unsigned int release(Inkscape::Extension::Print *module);
- virtual unsigned int fill (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
- virtual unsigned int stroke (Inkscape::Extension::Print * module, Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox);
+ virtual unsigned int fill (Inkscape::Extension::Print *module, Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
+ virtual unsigned int stroke (Inkscape::Extension::Print *module, Geom::PathVector const &pathv,
+ Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
virtual unsigned int comment(Inkscape::Extension::Print *module, const char * comment);
bool textToPath (Inkscape::Extension::Print * ext);
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index 1f9bdfef1..4923f6bee 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -10,7 +10,7 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
- * Copyright (C) 2006-2010 Authors
+ * Copyright (C) 2006-2011 Authors
*
* Licensed under GNU GPL
*/
@@ -70,7 +70,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
}
else {
// we want to export the entire document from root
- base = SP_ITEM(doc->getRoot());
+ base = doc->getRoot();
pageBoundingBox = !exportDrawing;
}
@@ -196,22 +196,22 @@ static char const preamble[] =
"%% \n"
"%% For more information, please see info/svg-inkscape on CTAN:\n"
"%% http://tug.ctan.org/tex-archive/info/svg-inkscape\n"
-"\n"
-"\\begingroup\n"
-" \\makeatletter\n"
+"%%\n"
+"\\begingroup%\n"
+" \\makeatletter%\n"
" \\providecommand\\color[2][]{%\n"
-" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}\n"
+" \\errmessage{(Inkscape) Color is used for the text in Inkscape, but the package \'color.sty\' is not loaded}%\n"
" \\renewcommand\\color[2][]{}%\n"
-" }\n"
+" }%\n"
" \\providecommand\\transparent[1]{%\n"
-" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}\n"
+" \\errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package \'transparent.sty\' is not loaded}%\n"
" \\renewcommand\\transparent[1]{}%\n"
-" }\n"
-" \\providecommand\\rotatebox[2]{#2}\n";
+" }%\n"
+" \\providecommand\\rotatebox[2]{#2}%\n";
static char const postamble[] =
" \\end{picture}%\n"
-"\\endgroup\n";
+"\\endgroup%\n";
void
LaTeXTextRenderer::writePreamble()
@@ -266,11 +266,6 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
SPText *textobj = SP_TEXT (item);
SPStyle *style = item->style;
- gchar *str = sp_te_get_string_multiline(item);
- if (!str) {
- return;
- }
-
// get position and alignment
// Align vertically on the baseline of the font (retreived from the anchor point)
// Align horizontally on anchorpoint
@@ -340,7 +335,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
li != le; li.nextStartOfSpan())
{
SPStyle const &spanstyle = *(sp_te_style_at_position (item, li));
- bool is_bold = false, is_italic = false;
+ bool is_bold = false, is_italic = false, is_oblique = false;
if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 ||
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 ||
@@ -351,19 +346,34 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER)
{
is_bold = true;
- os << "{\\bfseries{}";
+ os << "\\textbf{";
}
if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC)
{
is_italic = true;
- os << "{\\itshape{}";
+ os << "\\textit{";
+ }
+ if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE)
+ {
+ is_oblique = true;
+ os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so...
}
Inkscape::Text::Layout::iterator ln = li;
ln.nextStartOfSpan();
- Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln);
- os << spanstr;
-
+ Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln);
+ const gchar *spanstr = uspanstr.c_str();
+ if (!spanstr) {
+ continue;
+ }
+ // replace carriage return with double slash
+ gchar ** splitstr = g_strsplit(spanstr, "\n", -1);
+ gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr);
+ os << spanstr_new;
+ g_strfreev(splitstr);
+ g_free(spanstr_new);
+
+ if (is_oblique) { os << "}"; } // oblique end
if (is_italic) { os << "}"; } // italic end
if (is_bold) { os << "}"; } // bold end
}
@@ -389,16 +399,6 @@ Flowing in rectangle is possible, not in arb shape.
SPFlowtext *flowtext = SP_FLOWTEXT(item);
SPStyle *style = item->style;
- gchar *strtext = sp_te_get_string_multiline(item);
- if (!strtext) {
- return;
- }
- // replace carriage return with double slash
- gchar ** splitstr = g_strsplit(strtext, "\n", -1);
- gchar *str = g_strjoinv("\\\\ ", splitstr);
- g_free(strtext);
- g_strfreev(splitstr);
-
SPItem *frame_item = flowtext->get_frame(NULL);
if (!frame_item || !SP_IS_RECT(frame_item)) {
g_warning("LaTeX export: non-rectangular flowed text shapes are not supported, skipping text.");
@@ -479,7 +479,7 @@ Flowing in rectangle is possible, not in arb shape.
li != le; li.nextStartOfSpan())
{
SPStyle const &spanstyle = *(sp_te_style_at_position (item, li));
- bool is_bold = false, is_italic = false;
+ bool is_bold = false, is_italic = false, is_oblique = false;
if (spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_500 ||
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_600 ||
@@ -490,19 +490,34 @@ Flowing in rectangle is possible, not in arb shape.
spanstyle.font_weight.computed == SP_CSS_FONT_WEIGHT_BOLDER)
{
is_bold = true;
- os << "{\\bfseries{}";
+ os << "\\textbf{";
}
if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_ITALIC)
{
is_italic = true;
- os << "{\\itshape{}";
+ os << "\\textit{";
+ }
+ if (spanstyle.font_style.computed == SP_CSS_FONT_STYLE_OBLIQUE)
+ {
+ is_oblique = true;
+ os << "\\textsl{"; // this is an accurate choice if the LaTeX chosen font matches the font in Inkscape. Gives bad results when it is not so...
}
Inkscape::Text::Layout::iterator ln = li;
ln.nextStartOfSpan();
- Glib::ustring spanstr = sp_te_get_string_multiline (item, li, ln);
- os << spanstr;
-
+ Glib::ustring uspanstr = sp_te_get_string_multiline (item, li, ln);
+ const gchar *spanstr = uspanstr.c_str();
+ if (!spanstr) {
+ continue;
+ }
+ // replace carriage return with double slash
+ gchar ** splitstr = g_strsplit(spanstr, "\n", -1);
+ gchar *spanstr_new = g_strjoinv("\\\\ ", splitstr);
+ os << spanstr_new;
+ g_strfreev(splitstr);
+ g_free(spanstr_new);
+
+ if (is_oblique) { os << "}"; } // oblique end
if (is_italic) { os << "}"; } // italic end
if (is_bold) { os << "}"; } // bold end
}
@@ -517,13 +532,10 @@ Flowing in rectangle is possible, not in arb shape.
fprintf(_stream, "%s", os.str().c_str());
}
-void
-LaTeXTextRenderer::sp_root_render(SPItem *item)
+void LaTeXTextRenderer::sp_root_render(SPRoot *root)
{
- SPRoot *root = SP_ROOT(item);
-
push_transform(root->c2p);
- sp_group_render(item);
+ sp_group_render(root);
pop_transform();
}
@@ -536,7 +548,7 @@ LaTeXTextRenderer::sp_item_invoke_render(SPItem *item)
}
if (SP_IS_ROOT(item)) {
- return sp_root_render(item);
+ return sp_root_render(SP_ROOT(item));
} else if (SP_IS_GROUP(item)) {
return sp_group_render(item);
} else if (SP_IS_USE(item)) {
@@ -563,34 +575,34 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
// The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument !
if (!base) {
- base = SP_ITEM(doc->getRoot());
+ base = doc->getRoot();
}
- Geom::OptRect d;
+ Geom::Rect d;
if (pageBoundingBox) {
- d = Geom::Rect( Geom::Point(0,0),
- Geom::Point(doc->getWidth(), doc->getHeight()) );
+ d = Geom::Rect::from_xywh(Geom::Point(0,0), doc->getDimensions());
} else {
- base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
- }
- if (!d) {
- g_message("LaTeXTextRenderer: could not retrieve boundingbox.");
- return false;
+ Geom::OptRect bbox = base->desktopVisualBounds();
+ if (!bbox) {
+ g_message("CairoRenderer: empty bounding box.");
+ return false;
+ }
+ d = *bbox;
}
// scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX
- double scale = 1/(d->width());
- double _width = d->width() * scale;
- double _height = d->height() * scale;
+ double scale = 1/(d.width());
+ double _width = d.width() * scale;
+ double _height = d.height() * scale;
push_transform( Geom::Scale(scale, scale) );
if (!pageBoundingBox)
{
- push_transform( Geom::Translate( - d->min() ) );
+ push_transform( Geom::Translate( -d.min() ) );
}
// flip y-axis
- push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) );
+ push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) ); /// @fixme hardcoded desktop transform!
// write the info to LaTeX
Inkscape::SVGOStringStream os;
@@ -598,19 +610,19 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
// scaling of the image when including it in LaTeX
- os << " \\ifx\\svgwidth\\undefined\n";
- os << " \\setlength{\\unitlength}{" << d->width() * PT_PER_PX << "pt}\n";
- os << " \\ifx\\svgscale\\undefined\n";
- os << " \\relax\n";
- os << " \\else\n";
- os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}\n";
- os << " \\fi\n";
- os << " \\else\n";
- os << " \\setlength{\\unitlength}{\\svgwidth}\n";
- os << " \\fi\n";
- os << " \\global\\let\\svgwidth\\undefined\n";
- os << " \\global\\let\\svgscale\\undefined\n";
- os << " \\makeatother\n";
+ os << " \\ifx\\svgwidth\\undefined%\n";
+ os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384
+ os << " \\ifx\\svgscale\\undefined%\n";
+ os << " \\relax%\n";
+ os << " \\else%\n";
+ os << " \\setlength{\\unitlength}{\\unitlength * \\real{\\svgscale}}%\n";
+ os << " \\fi%\n";
+ os << " \\else%\n";
+ os << " \\setlength{\\unitlength}{\\svgwidth}%\n";
+ os << " \\fi%\n";
+ os << " \\global\\let\\svgwidth\\undefined%\n";
+ os << " \\global\\let\\svgscale\\undefined%\n";
+ os << " \\makeatother%\n";
os << " \\begin{picture}(" << _width << "," << _height << ")%\n";
// strip pathname, as it is probably desired. Having a specific path in the TeX file is not convenient.
@@ -630,7 +642,7 @@ LaTeXTextRenderer::transform()
void
LaTeXTextRenderer::push_transform(Geom::Affine const &tr)
{
- if(_transform_stack.size()){
+ if(!_transform_stack.empty()){
Geom::Affine tr_top = _transform_stack.top();
_transform_stack.push(tr * tr_top);
} else {
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 2259427d6..66055a3bc 100644
--- a/src/extension/internal/latex-text-renderer.h
+++ b/src/extension/internal/latex-text-renderer.h
@@ -22,6 +22,7 @@
#include <stack>
class SPItem;
+struct SPRoot;
namespace Inkscape {
namespace Extension {
@@ -60,7 +61,7 @@ protected:
void writePostamble();
void sp_item_invoke_render(SPItem *item);
- void sp_root_render(SPItem *item);
+ void sp_root_render(SPRoot *item);
void sp_group_render(SPItem *item);
void sp_use_render(SPItem *item);
void sp_text_render(SPItem *item);
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index 6a350ab48..3e0afdd8e 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -1,4 +1,4 @@
-/**
+/*
* OpenDocument <drawing> input and output
*
* This is an an entry in the extensions mechanism to begin to enable
@@ -573,7 +573,7 @@ void SingularValueDecomposition::calculate()
//double eps = pow(2.0,-52.0);
//double tiny = pow(2.0,-966.0);
//let's just calculate these now
- //a double can be e ± 308.25, so this is safe
+ //a double can be e ± 308.25, so this is safe
double eps = 2.22e-16;
double tiny = 1.6e-291;
while (p > 0) {
@@ -946,10 +946,10 @@ static Glib::ustring formatTransform(Geom::Affine &tf)
static Geom::Affine getODFTransform(const SPItem *item)
{
//### Get SVG-to-ODF transform
- Geom::Affine tf (item->i2d_affine());
+ Geom::Affine tf (item->i2dt_affine());
//Flip Y into document coordinates
double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
- Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0));
+ Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0)); /// @fixme hardcoded desktop transform
doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height));
tf = tf * doc2dt_tf;
tf = tf * Geom::Affine(Geom::Scale(pxToCm));
@@ -965,15 +965,10 @@ static Geom::Affine getODFTransform(const SPItem *item)
*/
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
- Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop();
- Geom::OptRect bbox;
- if (bbox_temp) {
- bbox = *bbox_temp;
- double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
- Geom::Affine doc2dt_tf = Geom::Affine(Geom::Scale(1.0, -1.0));
- doc2dt_tf = doc2dt_tf * Geom::Affine(Geom::Translate(0, doc_height));
- bbox = *bbox * doc2dt_tf;
- bbox = *bbox * Geom::Affine(Geom::Scale(pxToCm));
+ // TODO: geometric or visual?
+ Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds();
+ if (bbox) {
+ *bbox *= Geom::Affine(Geom::Scale(pxToCm));
}
return bbox;
}
@@ -986,7 +981,7 @@ static Geom::OptRect getODFBoundingBox(const SPItem *item)
*/
static Geom::Affine getODFItemTransform(const SPItem *item)
{
- Geom::Affine itemTransform (Geom::Scale(1, -1));
+ Geom::Affine itemTransform (Geom::Scale(1, -1)); /// @fixme hardcoded doc2dt transform?
itemTransform = itemTransform * (Geom::Affine)item->transform;
itemTransform = itemTransform * Geom::Scale(1, -1);
return itemTransform;
@@ -1166,7 +1161,7 @@ bool OdfOutput::writeManifest(ZipFile &zf)
outs.printf(" <manifest:file-entry manifest:media-type=\"text/xml\" manifest:full-path=\"meta.xml\"/>\n");
outs.printf(" <!--List our images here-->\n");
std::map<Glib::ustring, Glib::ustring>::iterator iter;
- for (iter = imageTable.begin() ; iter!=imageTable.end() ; iter++)
+ for (iter = imageTable.begin() ; iter!=imageTable.end() ; ++iter)
{
Glib::ustring oldName = iter->first;
Glib::ustring newName = iter->second;
@@ -1246,7 +1241,7 @@ bool OdfOutput::writeMeta(ZipFile &zf)
outs.printf(" <meta:initial-creator>%#s</meta:initial-creator>\n",
creator.c_str());
outs.printf(" <meta:creation-date>%#s</meta:creation-date>\n", date.c_str());
- for (iter = metadata.begin() ; iter != metadata.end() ; iter++)
+ for (iter = metadata.begin() ; iter != metadata.end() ; ++iter)
{
Glib::ustring name = iter->first;
Glib::ustring value = iter->second;
@@ -1308,7 +1303,7 @@ bool OdfOutput::writeStyle(ZipFile &zf)
*/
outs.printf("<!-- ####### Styles from Inkscape document ####### -->\n");
std::vector<StyleInfo>::iterator iter;
- for (iter = styleTable.begin() ; iter != styleTable.end() ; iter++)
+ for (iter = styleTable.begin() ; iter != styleTable.end() ; ++iter)
{
outs.printf("<style:style style:name=\"%s\"", iter->name.c_str());
StyleInfo s(*iter);
@@ -1336,7 +1331,7 @@ bool OdfOutput::writeStyle(ZipFile &zf)
outs.printf("\n");
outs.printf("<!-- ####### Gradients from Inkscape document ####### -->\n");
std::vector<GradientInfo>::iterator giter;
- for (giter = gradientTable.begin() ; giter != gradientTable.end() ; giter++)
+ for (giter = gradientTable.begin() ; giter != gradientTable.end() ; ++giter)
{
GradientInfo gi(*giter);
if (gi.style == "linear")
@@ -1588,7 +1583,7 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item,
//Look for existing identical style;
bool styleMatch = false;
std::vector<StyleInfo>::iterator iter;
- for (iter=styleTable.begin() ; iter!=styleTable.end() ; iter++)
+ for (iter=styleTable.begin() ; iter!=styleTable.end() ; ++iter)
{
if (si.equals(*iter))
{
@@ -1706,7 +1701,7 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
//Look for existing identical style;
bool gradientMatch = false;
std::vector<GradientInfo>::iterator iter;
- for (iter=gradientTable.begin() ; iter!=gradientTable.end() ; iter++)
+ for (iter=gradientTable.begin() ; iter!=gradientTable.end() ; ++iter)
{
if (gi.equals(*iter))
{
diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h
index 2a6f7799f..47cd47296 100644
--- a/src/extension/internal/odf.h
+++ b/src/extension/internal/odf.h
@@ -1,14 +1,4 @@
-/**
- * OpenDocument <drawing> input and output
- *
- * This is an an entry in the extensions mechanism to begin to enable
- * the inputting and outputting of OpenDocument Format (ODF) files from
- * within Inkscape. Although the initial implementations will be very lossy
- * do to the differences in the models of SVG and ODF, they will hopefully
- * improve greatly with time.
- *
- * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
- *
+/*
* Authors:
* Bob Jamison
* Abhishek Sharma
@@ -141,7 +131,7 @@ public:
class GradientStop
{
public:
- GradientStop()
+ GradientStop() : rgb(0), opacity(0)
{}
GradientStop(unsigned long rgbArg, double opacityArg)
{ rgb = rgbArg; opacity = opacityArg; }
@@ -265,6 +255,17 @@ public:
+/**
+ * OpenDocument <drawing> input and output
+ *
+ * This is an an entry in the extensions mechanism to begin to enable
+ * the inputting and outputting of OpenDocument Format (ODF) files from
+ * within Inkscape. Although the initial implementations will be very lossy
+ * do to the differences in the models of SVG and ODF, they will hopefully
+ * improve greatly with time.
+ *
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
+ */
class OdfOutput : public Inkscape::Extension::Implementation::Implementation
{
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index 048b26bed..daa185268 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -31,6 +31,8 @@
#include <poppler/glib/poppler-document.h>
#include <poppler/glib/poppler-page.h>
+#include "ui/widget/spinbutton.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -67,7 +69,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
// Page number
int num_pages = poppler_document_get_n_pages(_poppler_doc);
Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, num_pages, 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
_labelTotalPages = Gtk::manage(new class Gtk::Label());
hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
// Disable the page selector when there's only one page
diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h
index ad7c884cb..7581cb0a5 100644
--- a/src/extension/internal/pdf-input-cairo.h
+++ b/src/extension/internal/pdf-input-cairo.h
@@ -20,7 +20,6 @@
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-#include <gtkmm/spinbutton.h>
#include <gtkmm/box.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
@@ -39,6 +38,13 @@
#include "../implementation/implementation.h"
namespace Inkscape {
+
+namespace UI {
+namespace Widget {
+ class SpinButton;
+}
+}
+
namespace Extension {
namespace Internal {
@@ -64,7 +70,7 @@ private:
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Gtk::SpinButton * _pageNumberSpin;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
class Gtk::HBox * hbox2;
class Gtk::CheckButton * _cropCheck;
diff --git a/src/extension/internal/pdfinput/CMakeLists.txt b/src/extension/internal/pdfinput/CMakeLists.txt
deleted file mode 100644
index 9a093a065..000000000
--- a/src/extension/internal/pdfinput/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-SET(extension_internal_pdfinput_SRC
-pdf-input.cpp
-pdf-parser.cpp
-svg-builder.cpp
-)
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index ae3e473a5..e083fe1a3 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -1,4 +1,4 @@
- /** \file
+/*
* Native PDF import using libpoppler.
*
* Authors:
@@ -40,7 +40,8 @@
#include "inkscape.h"
#include "dialogs/dialog-events.h"
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
namespace Inkscape {
namespace Extension {
@@ -75,7 +76,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar *uri)
// Page number
Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0));
- _pageNumberSpin = Gtk::manage(new class Gtk::SpinButton(*_pageNumberSpin_adj, 1, 1));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
_labelTotalPages = Gtk::manage(new class Gtk::Label());
hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
// Disable the page selector when there's only one page
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 6bf0f11a2..6d3fd104a 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -1,9 +1,7 @@
-#ifndef __EXTENSION_INTERNAL_PDFINPUT_H__
-#define __EXTENSION_INTERNAL_PDFINPUT_H__
+#ifndef SEEN_EXTENSION_INTERNAL_PDFINPUT_H
+#define SEEN_EXTENSION_INTERNAL_PDFINPUT_H
- /** \file
- * PDF import using libpoppler.
- *
+/*
* Authors:
* miklos erdelyi
*
@@ -24,7 +22,6 @@
#include <gtkmm/button.h>
#include <gtkmm/buttonbox.h>
#include <gtkmm/label.h>
-#include <gtkmm/spinbutton.h>
#include <gtkmm/box.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
@@ -41,9 +38,19 @@
#endif
namespace Inkscape {
+
+namespace UI {
+namespace Widget {
+ class SpinButton;
+}
+}
+
namespace Extension {
namespace Internal {
+/**
+ * PDF import using libpoppler.
+ */
class PdfImportDialog : public Gtk::Dialog
{
public:
@@ -66,7 +73,7 @@ private:
class Gtk::Button * cancelbutton;
class Gtk::Button * okbutton;
class Gtk::Label * _labelSelect;
- class Gtk::SpinButton * _pageNumberSpin;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
class Gtk::Label * _labelTotalPages;
class Gtk::HBox * hbox2;
class Gtk::CheckButton * _cropCheck;
@@ -119,11 +126,13 @@ public:
};
-} } } /* namespace Inkscape, Extension, Implementation */
+} // namespace Implementation
+} // namespace Extension
+} // namespace Inkscape
-#endif /* HAVE_POPPLER */
+#endif // HAVE_POPPLER
-#endif /* __EXTENSION_INTERNAL_PDFINPUT_H__ */
+#endif // SEEN_EXTENSION_INTERNAL_PDFINPUT_H
/*
Local Variables:
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index ef31cd39f..db7c09575 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -1,6 +1,5 @@
-
- /** \file
- * PDF parsing using libpoppler
+ /*
+ * PDF parsing using libpoppler.
*
* Derived from poppler's Gfx.cc
*
diff --git a/src/extension/internal/pdfinput/pdf-parser.h b/src/extension/internal/pdfinput/pdf-parser.h
index 21effe81d..a63d669c7 100644
--- a/src/extension/internal/pdfinput/pdf-parser.h
+++ b/src/extension/internal/pdfinput/pdf-parser.h
@@ -1,7 +1,4 @@
-
- /** \file
- * PDF parsing module using libpoppler's facilities
- *
+ /*
* Derived from Gfx.h
*
* Copyright 1996-2003 Glyph & Cog, LLC
@@ -24,6 +21,8 @@ namespace Inkscape {
}
}
}
+
+// TODO clean up and remove using:
using Inkscape::Extension::Internal::SvgBuilder;
#include "goo/gtypes.h"
@@ -145,6 +144,10 @@ private:
#define pdfNumShadingTypes 5
+
+/**
+ * PDF parsing module using libpoppler's facilities.
+ */
class PdfParser {
public:
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 94edf826e..e8d6363f0 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -1,4 +1,4 @@
- /** \file
+ /*
* Native PDF import using libpoppler.
*
* Authors:
@@ -37,7 +37,6 @@
#include "io/stringstream.h"
#include "io/base64stream.h"
#include "display/nr-filter-utils.h"
-#include "libnr/nr-macros.h"
#include "libnrtype/font-instance.h"
#include "Function.h"
@@ -57,6 +56,7 @@ namespace Internal {
#define TRACE(_args) IFTRACE(g_print _args)
+static double ttm[6] = {1, 0, 0, 1, 0, 0}; // temporary transform matrix
/**
* \struct SvgTransparencyGroup
@@ -110,19 +110,23 @@ SvgBuilder::~SvgBuilder() {
}
void SvgBuilder::_init() {
- _in_text_object = false;
- _need_font_update = true;
- _invalidated_style = true;
_font_style = NULL;
_current_font = NULL;
+ _font_specification = NULL;
+ _font_scaling = 1;
+ _need_font_update = true;
+ _in_text_object = false;
+ _invalidated_style = true;
_current_state = NULL;
+ _width = 0;
+ _height = 0;
// Fill _availableFontNames (Bug LP #179589) (code cfr. FontLister)
FamilyToStylesMap familyStyleMap;
font_factory::Default()->GetUIFamiliesAndStyles(&familyStyleMap);
for (FamilyToStylesMap::iterator iter = familyStyleMap.begin();
iter != familyStyleMap.end();
- iter++) {
+ ++iter) {
_availableFontNames.push_back(iter->first.c_str());
}
@@ -531,7 +535,7 @@ void SvgBuilder::setClipPath(GfxState *state, bool even_odd) {
clip_path->appendChild(path);
Inkscape::GC::release(path);
// Append clipPath to defs and get id
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(clip_path);
+ _doc->getDefs()->getRepr()->appendChild(clip_path);
gchar *urltext = g_strdup_printf ("url(#%s)", clip_path->attribute("id"));
Inkscape::GC::release(clip_path);
_container->setAttribute("clip-path", urltext);
@@ -562,6 +566,19 @@ bool SvgBuilder::getTransform(double *transform) {
*/
void SvgBuilder::setTransform(double c0, double c1, double c2, double c3,
double c4, double c5) {
+ // do not remember the group which is a layer
+ if (_container->attribute("inkscape:groupmode") != NULL) {
+ ttm[0] = ttm[3] = 1.0;
+ ttm[1] = ttm[2] = ttm[4] = ttm[5] = 0.0;
+ }
+ else {
+ ttm[0] = c0;
+ ttm[1] = c1;
+ ttm[2] = c2;
+ ttm[3] = c3;
+ ttm[4] = c4;
+ ttm[5] = c5;
+ }
// Avoid transforming a group with an already set clip-path
if ( _container->attribute("clip-path") != NULL ) {
@@ -609,8 +626,31 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_
if ( pattern != NULL ) {
if ( pattern->getType() == 2 ) { // Shading pattern
GfxShadingPattern *shading_pattern = (GfxShadingPattern*)pattern;
+ double *ptm;
+ double ittm[6]; // invert ttm
+ double m[6] = {1, 0, 0, 1, 0, 0};
+ double det;
+
+ // construct a (pattern space) -> (current space) transform matrix
+
+ ptm = shading_pattern->getMatrix();
+ det = ttm[0] * ttm[3] - ttm[1] * ttm[2];
+ if (det) {
+ ittm[0] = ttm[3] / det;
+ ittm[1] = -ttm[1] / det;
+ ittm[2] = -ttm[2] / det;
+ ittm[3] = ttm[0] / det;
+ ittm[4] = (ttm[2] * ttm[5] - ttm[3] * ttm[4]) / det;
+ ittm[5] = (ttm[1] * ttm[4] - ttm[0] * ttm[5]) / det;
+ m[0] = ptm[0] * ittm[0] + ptm[1] * ittm[2];
+ m[1] = ptm[0] * ittm[1] + ptm[1] * ittm[3];
+ m[2] = ptm[2] * ittm[0] + ptm[3] * ittm[2];
+ m[3] = ptm[2] * ittm[1] + ptm[3] * ittm[3];
+ m[4] = ptm[4] * ittm[0] + ptm[5] * ittm[2] + ittm[4];
+ m[5] = ptm[4] * ittm[1] + ptm[5] * ittm[3] + ittm[5];
+ }
id = _createGradient(shading_pattern->getShading(),
- shading_pattern->getMatrix(),
+ m,
!is_stroke);
} else if ( pattern->getType() == 1 ) { // Tiling pattern
id = _createTilingPattern((GfxTilingPattern*)pattern, state, is_stroke);
@@ -678,7 +718,7 @@ gchar *SvgBuilder::_createTilingPattern(GfxTilingPattern *tiling_pattern,
delete pattern_builder;
// Append the pattern to defs
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(pattern_node);
+ _doc->getDefs()->getRepr()->appendChild(pattern_node);
gchar *id = g_strdup(pattern_node->attribute("id"));
Inkscape::GC::release(pattern_node);
@@ -752,7 +792,7 @@ gchar *SvgBuilder::_createGradient(GfxShading *shading, double *matrix, bool for
return NULL;
}
- Inkscape::XML::Node *defs = SP_DOCUMENT_DEFS(_doc)->getRepr();
+ Inkscape::XML::Node *defs = _doc->getDefs()->getRepr();
defs->appendChild(gradient);
gchar *id = g_strdup(gradient->attribute("id"));
Inkscape::GC::release(gradient);
@@ -1298,7 +1338,7 @@ void SvgBuilder::_flushText() {
}
glyphs_in_a_row++;
- i++;
+ ++i;
}
_container->appendChild(text_node);
Inkscape::GC::release(text_node);
@@ -1306,7 +1346,7 @@ void SvgBuilder::_flushText() {
_glyphs.clear();
}
-void SvgBuilder::beginString(GfxState *state, GooString *s) {
+void SvgBuilder::beginString(GfxState *state, GooString * /*s*/) {
if (_need_font_update) {
updateFont(state);
}
@@ -1324,12 +1364,12 @@ void SvgBuilder::beginString(GfxState *state, GooString *s) {
void SvgBuilder::addChar(GfxState *state, double x, double y,
double dx, double dy,
double originX, double originY,
- CharCode code, int nBytes, Unicode *u, int uLen) {
+ CharCode /*code*/, int /*nBytes*/, Unicode *u, int uLen) {
bool is_space = ( uLen == 1 && u[0] == 32 );
// Skip beginning space
- if ( is_space && _glyphs.size() < 1 ) {
+ if ( is_space && _glyphs.empty()) {
Geom::Point delta(dx, dy);
_text_position += delta;
return;
@@ -1369,7 +1409,7 @@ void SvgBuilder::addChar(GfxState *state, double x, double y,
}
// Copy current style if it has changed since the previous glyph
- if (_invalidated_style || _glyphs.size() == 0 ) {
+ if (_invalidated_style || _glyphs.empty()) {
new_glyph.style_changed = true;
int render_mode = state->getRender();
// Set style
@@ -1392,7 +1432,7 @@ void SvgBuilder::addChar(GfxState *state, double x, double y,
_glyphs.push_back(new_glyph);
}
-void SvgBuilder::endString(GfxState *state) {
+void SvgBuilder::endString(GfxState * /*state*/) {
}
void SvgBuilder::beginTextObject(GfxState *state) {
@@ -1401,7 +1441,7 @@ void SvgBuilder::beginTextObject(GfxState *state) {
_current_state = state;
}
-void SvgBuilder::endTextObject(GfxState *state) {
+void SvgBuilder::endTextObject(GfxState * /*state*/) {
_flushText();
// TODO: clip if render_mode >= 4
_in_text_object = false;
@@ -1445,7 +1485,7 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height
return NULL;
}
// Set error handler
- if (setjmp(png_ptr->jmpbuf)) {
+ if (setjmp(png_jmpbuf(png_ptr))) {
png_destroy_write_struct(&png_ptr, &info_ptr);
return NULL;
}
@@ -1602,9 +1642,8 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height
sp_repr_set_svg_double(image_node, "width", 1);
sp_repr_set_svg_double(image_node, "height", 1);
// Set transformation
- if (_is_top_level) {
+
svgSetTransform(image_node, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0);
- }
// Create href
if (embed_image) {
@@ -1635,9 +1674,9 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) {
sp_repr_set_svg_double(mask_node, "height", height);
// Append mask to defs
if (_is_top_level) {
- SP_DOCUMENT_DEFS(_doc)->getRepr()->appendChild(mask_node);
+ _doc->getDefs()->getRepr()->appendChild(mask_node);
Inkscape::GC::release(mask_node);
- return SP_DOCUMENT_DEFS(_doc)->getRepr()->lastChild();
+ return _doc->getDefs()->getRepr()->lastChild();
} else { // Work around for renderer bug when mask isn't defined in pattern
static int mask_count = 0;
Inkscape::XML::Node *defs = _root->firstChild();
@@ -1657,7 +1696,7 @@ Inkscape::XML::Node *SvgBuilder::_createMask(double width, double height) {
}
}
-void SvgBuilder::addImage(GfxState *state, Stream *str, int width, int height,
+void SvgBuilder::addImage(GfxState * /*state*/, Stream *str, int width, int height,
GfxImageColorMap *color_map, int *mask_colors) {
Inkscape::XML::Node *image_node = _createImage(str, width, height, color_map, mask_colors);
@@ -1704,7 +1743,7 @@ void SvgBuilder::addImageMask(GfxState *state, Stream *str, int width, int heigh
Inkscape::GC::release(rect);
}
-void SvgBuilder::addMaskedImage(GfxState *state, Stream *str, int width, int height,
+void SvgBuilder::addMaskedImage(GfxState * /*state*/, Stream *str, int width, int height,
GfxImageColorMap *color_map,
Stream *mask_str, int mask_width, int mask_height,
bool invert_mask) {
@@ -1737,7 +1776,7 @@ void SvgBuilder::addMaskedImage(GfxState *state, Stream *str, int width, int hei
}
}
-void SvgBuilder::addSoftMaskedImage(GfxState *state, Stream *str, int width, int height,
+void SvgBuilder::addSoftMaskedImage(GfxState * /*state*/, Stream *str, int width, int height,
GfxImageColorMap *color_map,
Stream *mask_str, int mask_width, int mask_height,
GfxImageColorMap *mask_color_map) {
@@ -1768,8 +1807,8 @@ void SvgBuilder::addSoftMaskedImage(GfxState *state, Stream *str, int width, int
/**
* \brief Starts building a new transparency group
*/
-void SvgBuilder::pushTransparencyGroup(GfxState *state, double *bbox,
- GfxColorSpace *blending_color_space,
+void SvgBuilder::pushTransparencyGroup(GfxState * /*state*/, double *bbox,
+ GfxColorSpace * /*blending_color_space*/,
bool isolated, bool knockout,
bool for_softmask) {
@@ -1789,7 +1828,7 @@ void SvgBuilder::pushTransparencyGroup(GfxState *state, double *bbox,
_transp_group_stack = transpGroup;
}
-void SvgBuilder::popTransparencyGroup(GfxState *state) {
+void SvgBuilder::popTransparencyGroup(GfxState * /*state*/) {
// Restore node stack
popNode();
}
@@ -1797,7 +1836,7 @@ void SvgBuilder::popTransparencyGroup(GfxState *state) {
/**
* \brief Places the current transparency group into the current container
*/
-void SvgBuilder::paintTransparencyGroup(GfxState *state, double *bbox) {
+void SvgBuilder::paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) {
SvgTransparencyGroup *transpGroup = _transp_group_stack;
_container->appendChild(transpGroup->container);
Inkscape::GC::release(transpGroup->container);
@@ -1809,8 +1848,8 @@ void SvgBuilder::paintTransparencyGroup(GfxState *state, double *bbox) {
/**
* \brief Creates a mask using the current transparency group as its content
*/
-void SvgBuilder::setSoftMask(GfxState *state, double *bbox, bool alpha,
- Function *transfer_func, GfxColor *backdrop_color) {
+void SvgBuilder::setSoftMask(GfxState * /*state*/, double * /*bbox*/, bool /*alpha*/,
+ Function * /*transfer_func*/, GfxColor * /*backdrop_color*/) {
// Create mask
Inkscape::XML::Node *mask_node = _createMask(1.0, 1.0);
@@ -1829,7 +1868,7 @@ void SvgBuilder::setSoftMask(GfxState *state, double *bbox, bool alpha,
delete transpGroup;
}
-void SvgBuilder::clearSoftMask(GfxState *state) {
+void SvgBuilder::clearSoftMask(GfxState * /*state*/) {
if (_state_stack.back().softmask) {
_state_stack.back().softmask = NULL;
popGroup();
diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
index 47e5d7735..a550565d6 100644
--- a/src/extension/internal/pdfinput/svg-builder.h
+++ b/src/extension/internal/pdfinput/svg-builder.h
@@ -1,9 +1,7 @@
-#ifndef __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__
-#define __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__
+#ifndef SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H
+#define SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H
- /** \file
- * SVG representation creator using libpoppler.
- *
+/*
* Authors:
* miklos erdelyi
*
@@ -49,7 +47,7 @@ class XRef;
class SPCSSAttr;
#include <vector>
-#include <glib/gtypes.h>
+#include <glib.h>
namespace Inkscape {
namespace Extension {
@@ -58,8 +56,7 @@ namespace Internal {
struct SvgTransparencyGroup;
/**
- * \struct SvgGraphicsState
- * Holds information about the current softmask and group depth.
+ * Holds information about the current softmask and group depth for use of libpoppler.
* Could be later used to store other graphics state parameters so that we could
* emit only the differences in style settings from the parent state.
*/
@@ -69,7 +66,6 @@ struct SvgGraphicsState {
};
/**
- * \struct SvgGlyph
* Holds information about glyphs added by PdfParser which haven't been added
* to the document yet.
*/
@@ -89,10 +85,7 @@ struct SvgGlyph {
};
/**
- * \class SvgBuilder
- *
- * Builds the inner SVG representation from the calls of PdfParser
- *
+ * Builds the inner SVG representation using libpoppler from the calls of PdfParser.
*/
class SvgBuilder {
public:
@@ -228,15 +221,18 @@ private:
Inkscape::XML::Node *_root; // Root node from the point of view of this SvgBuilder
Inkscape::XML::Node *_container; // Current container (group/pattern/mask)
Inkscape::XML::Node *_preferences; // Preferences container node
- double _width, _height; // Document size in px
+ double _width; // Document size in px
+ double _height; // Document size in px
};
-} } } /* namespace Inkscape, Extension, Internal */
+} // namespace Internal
+} // namespace Extension
+} // namespace Inkscape
-#endif /* HAVE_POPPLER */
+#endif // HAVE_POPPLER
-#endif /* __EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H__ */
+#endif // SEEN_EXTENSION_INTERNAL_PDFINPUT_SVGBUILDER_H
/*
Local Variables:
diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp
index 1563d04c1..bb00de619 100644
--- a/src/extension/internal/pov-out.cpp
+++ b/src/extension/internal/pov-out.cpp
@@ -35,6 +35,7 @@
#include "helper/geom.h"
#include "helper/geom-curves.h"
#include <io/sys.h>
+#include "sp-root.h"
#include <string>
#include <stdio.h>
@@ -300,7 +301,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
povShapes.push_back(shapeInfo); //passed all tests. save the info
// convert the path to only lineto's and cubic curveto's:
- Geom::Affine tf = item->i2d_affine();
+ Geom::Affine tf = item->i2dt_affine();
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
/*
@@ -485,11 +486,11 @@ bool PovOutput::doTree(SPDocument *doc)
miny = bignum;
maxy = -bignum;
- if (!doTreeRecursive(doc, doc->root))
+ if (!doTreeRecursive(doc, doc->getRoot()))
return false;
//## Let's make a union of all of the Shapes
- if (povShapes.size()>0)
+ if (!povShapes.empty())
{
String id = "AllShapes";
char *pfx = (char *)id.c_str();
@@ -637,7 +638,7 @@ void PovOutput::saveDocument(SPDocument *doc, gchar const *filename_utf8)
if (!f)
return;
- for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); iter++)
+ for (String::iterator iter = outbuf.begin() ; iter!=outbuf.end(); ++iter)
{
int ch = *iter;
fputc(ch, f);
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index 946ff22fe..afc706e89 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -24,6 +24,7 @@
#include "extension/output.h"
#include <vector>
#include "xml/attribute-record.h"
+#include "sp-root.h"
#ifdef WITH_GNOME_VFS
# include <libgnomevfs/gnome-vfs.h>
diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp
deleted file mode 100644
index 537c91a2c..000000000
--- a/src/extension/internal/win32.cpp
+++ /dev/null
@@ -1,510 +0,0 @@
-/** @file
- * @brief Windows-specific stuff
- */
-/* Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Abhishek Sharma
- *
- * This code is in public domain
- */
-
-#ifdef WIN32
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <glib/gmem.h>
-#include <libnr/nr-macros.h>
-#include <2geom/transforms.h>
-
-#include "display/nr-arena-item.h"
-#include "display/nr-arena.h"
-#include "document.h"
-
-#include "win32.h"
-#include "extension/system.h"
-#include "extension/print.h"
-#include <gtk/gtk.h>
-
-/* Initialization */
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-
-static unsigned int SPWin32Modal = FALSE;
-
-/**
- * Callback function.. not a method
- */
-static void
-my_gdk_event_handler (GdkEvent *event)
-{
- if (SPWin32Modal) {
- /* Win32 widget is modal, filter events */
- switch (event->type) {
- case GDK_NOTHING:
- case GDK_DELETE:
- case GDK_SCROLL:
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_KEY_PRESS:
- case GDK_KEY_RELEASE:
- case GDK_DRAG_STATUS:
- case GDK_DRAG_ENTER:
- case GDK_DRAG_LEAVE:
- case GDK_DRAG_MOTION:
- case GDK_DROP_START:
- case GDK_DROP_FINISHED:
- return;
- break;
- default:
- break;
- }
- }
- gtk_main_do_event (event);
-}
-
-void
-PrintWin32::main_init (int argc, char **argv, const char *name)
-{
- gdk_event_handler_set ((GdkEventFunc) my_gdk_event_handler, NULL, NULL);
-}
-
-void
-PrintWin32::finish (void)
-{
-}
-
-#define SP_FOREIGN_MAX_ITER 10
-
-
-/**
- * Callback function.. not a method
- */
-static VOID CALLBACK
-my_timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
-{
- int cdown = 0;
- while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) {
- gtk_main_iteration_do (FALSE);
- }
- gtk_main_iteration_do (FALSE);
-}
-
-
-/* Platform detection */
-
-gboolean
-PrintWin32::is_os_wide()
-{
- static gboolean initialized = FALSE;
- static gboolean is_wide = FALSE;
- static OSVERSIONINFOA osver;
-
- if ( !initialized )
- {
- BOOL result;
-
- initialized = TRUE;
-
- memset (&osver, 0, sizeof(OSVERSIONINFOA));
- osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
- result = GetVersionExA (&osver);
- if (result)
- {
- if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)
- is_wide = TRUE;
- }
- // If we can't even call to get the version, fall back to ANSI API
- }
-
- return is_wide;
-}
-
-
-/* Printing */
-
-PrintWin32::PrintWin32 (void)
-{
- /* Nothing here */
-}
-
-
-PrintWin32::~PrintWin32 (void)
-{
- DeleteDC (_hDC);
-}
-
-
-/**
- * Callback function.. not a method
- */
-static UINT_PTR CALLBACK
-print_hook (HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
-{
-#if 0
- int cdown = 0;
- while ((cdown++ < SP_FOREIGN_MAX_ITER) && gdk_events_pending ()) {
- gtk_main_iteration_do (FALSE);
- }
- gtk_main_iteration_do (FALSE);
-#endif
- return 0;
-}
-
-unsigned int
-PrintWin32::setup (Inkscape::Extension::Print *mod)
-{
- HRESULT res;
- PRINTDLG pd = {
- sizeof (PRINTDLG),
- NULL, /* hwndOwner */
- NULL, /* hDevMode */
- NULL, /* hDevNames */
- NULL, /* hDC */
- PD_NOPAGENUMS | PD_NOSELECTION | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE, /* Flags */
- 1, 1, 1, 1, /* nFromPage, nToPage, nMinPage, nMaxPage */
- 1, /* nCoies */
- NULL, /* hInstance */
- 0, /* lCustData */
- NULL, NULL, NULL, NULL, NULL, NULL
- };
- UINT_PTR timer;
-
- SPWin32Modal = TRUE;
- pd.Flags |= PD_ENABLEPRINTHOOK;
- pd.lpfnPrintHook = print_hook;
- timer = SetTimer (NULL, 0, 40, my_timer);
-
- res = PrintDlg (&pd);
-
- KillTimer (NULL, timer);
- SPWin32Modal = FALSE;
-
- if (!res) return FALSE;
-
- _hDC = pd.hDC;
-
-#if 0
- caps = GetDeviceCaps (_hDC, RASTERCAPS);
- if (caps & RC_BANDING) {
- printf ("needs banding\n");
- }
- if (caps & RC_BITBLT) {
- printf ("does bitblt\n");
- }
- if (caps & RC_DIBTODEV) {
- printf ("does dibtodev\n");
- }
- if (caps & RC_STRETCHDIB) {
- printf ("does stretchdib\n");
- }
-#endif
- if (pd.hDevMode) {
- DEVMODE *devmodep;
- devmodep = (DEVMODE *)pd.hDevMode;
- if (devmodep->dmFields & DM_ORIENTATION) {
- _landscape = (devmodep->dmOrientation == DMORIENT_LANDSCAPE);
- }
- }
-
- return TRUE;
-}
-
-unsigned int
-PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
-{
- DOCINFO di = {
- sizeof (DOCINFO),
- NULL, /* lpszDocName */
- NULL, /* lpszOutput */
- NULL, /* lpszDatatype */
- 0 /* DI_APPBANDING */ /* fwType */
- };
- int res;
-
- _PageWidth = doc->getWidth ();
- _PageHeight = doc->getHeight ();
-
- di.lpszDocName = doc->getName();
-
- SPWin32Modal = TRUE;
-
- res = StartDoc (_hDC, &di);
- res = StartPage (_hDC);
-
- SPWin32Modal = FALSE;
-
- return 0;
-}
-
-unsigned int
-PrintWin32::finish (Inkscape::Extension::Print *mod)
-{
- int dpiX, dpiY;
- int pPhysicalWidth, pPhysicalHeight;
- int pPhysicalOffsetX, pPhysicalOffsetY;
- int pPrintableWidth, pPrintableHeight;
- float scalex, scaley;
- int x0, y0, x1, y1;
- int width, height;
- unsigned char *px;
- int sheight, row;
- BITMAPINFO bmInfo = {
- {
- sizeof (BITMAPINFOHEADER), // bV4Size
- 64, // biWidth
- 64, // biHeight
- 1, // biPlanes
- 32, // biBitCount
- BI_RGB, // biCompression
- 0, // biSizeImage
- 2835, // biXPelsPerMeter
- 2835, // biYPelsPerMeter
- 0, // biClrUsed
- 0 // biClrImportant
- },
- { { 0, 0, 0, 0 } } // bmiColors
- };
- //RECT wrect;
- int res;
-
- SPWin32Modal = TRUE;
-
- // Number of pixels per logical inch
- dpiX = (int) GetDeviceCaps (_hDC, LOGPIXELSX);
- dpiY = (int) GetDeviceCaps (_hDC, LOGPIXELSY);
- // Size in pixels of the printable area
- pPhysicalWidth = GetDeviceCaps (_hDC, PHYSICALWIDTH);
- pPhysicalHeight = GetDeviceCaps (_hDC, PHYSICALHEIGHT);
- // Top left corner of prontable area
- pPhysicalOffsetX = GetDeviceCaps (_hDC, PHYSICALOFFSETX);
- pPhysicalOffsetY = GetDeviceCaps (_hDC, PHYSICALOFFSETY);
- // Size in pixels of the printable area
- pPrintableWidth = GetDeviceCaps (_hDC, HORZRES);
- pPrintableHeight = GetDeviceCaps (_hDC, VERTRES);
-
- // Scaling from document to device
- scalex = dpiX / 72.0;
- scaley = dpiY / 72.0;
-
- // We simply map document 0,0 to physical page 0,0
- Geom::Affine affine = Geom::Scale(scalex / 1.25, scaley / 1.25);
-
- nr_arena_item_set_transform (mod->root, affine);
-
- // Calculate printable area in device coordinates
- x0 = pPhysicalOffsetX;
- y0 = pPhysicalOffsetY;
- x1 = x0 + pPrintableWidth;
- y1 = y0 + pPrintableHeight;
- x1 = MIN (x1, (int) (_PageWidth * scalex));
- y1 = MIN (y1, (int) (_PageHeight * scaley));
-
- width = x1 - x0;
- height = y1 - y0;
-
- px = g_new (unsigned char, 4 * 64 * width);
- sheight = 64;
-
- /* Printing goes here */
- for (row = 0; row < height; row += 64) {
- NRPixBlock pb;
- NRRectL bbox;
- NRGC gc(NULL);
- int num_rows;
- int i;
-
- num_rows = sheight;
- if ((row + num_rows) > height) num_rows = height - row;
-
- /* Set area of interest */
- bbox.x0 = x0;
- bbox.y0 = y0 + row;
- bbox.x1 = bbox.x0 + width;
- bbox.y1 = bbox.y0 + num_rows;
- /* Update to renderable state */
- gc.transform.setIdentity();
- nr_arena_item_invoke_update (mod->root, &bbox, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE);
-
- nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8A8N, bbox.x0, bbox.y0, bbox.x1, bbox.y1, px, 4 * (bbox.x1 - bbox.x0), FALSE, FALSE);
-
- /* Blitter goes here */
- bmInfo.bmiHeader.biWidth = bbox.x1 - bbox.x0;
- bmInfo.bmiHeader.biHeight = -(bbox.y1 - bbox.y0);
-
- memset (px, 0xff, 4 * num_rows * width);
- /* Render */
- nr_arena_item_invoke_render (NULL, mod->root, &bbox, &pb, 0);
-
- /* Swap red and blue channels; we use RGBA, whereas
- * the Win32 GDI uses BGRx.
- */
- for ( i = 0 ; i < num_rows * width ; i++ ) {
- unsigned char temp=px[i*4];
- px[i*4] = px[i*4+2];
- px[i*4+2] = temp;
- }
-
- SetStretchBltMode(_hDC, COLORONCOLOR);
- res = StretchDIBits (_hDC,
- bbox.x0 - x0, bbox.y0 - y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
- 0, 0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0,
- px,
- &bmInfo,
- DIB_RGB_COLORS,
- SRCCOPY);
-
- /* Blitter ends here */
-
- nr_pixblock_release (&pb);
- }
-
- g_free (px);
-
- res = EndPage (_hDC);
- res = EndDoc (_hDC);
-
- SPWin32Modal = FALSE;
-
- return 0;
-}
-
-/* File dialogs */
-
-char *
-PrintWin32::get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title)
-{
- char fnbuf[4096] = {0};
- OPENFILENAME ofn = {
- sizeof (OPENFILENAME),
- NULL, /* hwndOwner */
- NULL, /* hInstance */
- (const CHAR *)filter, /* lpstrFilter */
- NULL, /* lpstrCustomFilter */
- 0, /* nMaxCustFilter */
- 1, /* nFilterIndex */
- fnbuf, /* lpstrFile */
- sizeof (fnbuf), /* nMaxFile */
- NULL, /* lpstrFileTitle */
- 0, /* nMaxFileTitle */
- (const CHAR *)dir, /* lpstrInitialDir */
- (const CHAR *)title, /* lpstrTitle */
- OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY, /* Flags */
- 0, /* nFileOffset */
- 0, /* nFileExtension */
- NULL, /* lpstrDefExt */
- 0, /* lCustData */
- NULL, /* lpfnHook */
- NULL /* lpTemplateName */
- };
- int retval;
- UINT_PTR timer;
-
- SPWin32Modal = TRUE;
- timer = SetTimer (NULL, 0, 40, my_timer);
-
- retval = GetOpenFileName (&ofn);
-
- KillTimer (NULL, timer);
- SPWin32Modal = FALSE;
-
- if (!retval) {
- int errcode;
- errcode = CommDlgExtendedError();
- return NULL;
- }
- return g_strdup (fnbuf);
-}
-
-char *
-PrintWin32::get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title)
-{
- return NULL;
-}
-
-char *
-PrintWin32::get_save_filename (unsigned char *dir, unsigned int *spns)
-{
- char fnbuf[4096] = {0};
- OPENFILENAME ofn = {
- sizeof (OPENFILENAME),
- NULL, /* hwndOwner */
- NULL, /* hInstance */
- "Inkscape SVG (*.svg)\0*\0Plain SVG (*.svg)\0*\0", /* lpstrFilter */
- NULL, /* lpstrCustomFilter */
- 0, /* nMaxCustFilter */
- 1, /* nFilterIndex */
- fnbuf, /* lpstrFile */
- sizeof (fnbuf), /* nMaxFile */
- NULL, /* lpstrFileTitle */
- 0, /* nMaxFileTitle */
- (const CHAR *)dir, /* lpstrInitialDir */
- "Save document to file", /* lpstrTitle */
- OFN_HIDEREADONLY, /* Flags */
- 0, /* nFileOffset */
- 0, /* nFileExtension */
- NULL, /* lpstrDefExt */
- 0, /* lCustData */
- NULL, /* lpfnHook */
- NULL /* lpTemplateName */
- };
- int retval;
- UINT_PTR timer;
-
- SPWin32Modal = TRUE;
- timer = SetTimer (NULL, 0, 40, my_timer);
-
- retval = GetSaveFileName (&ofn);
-
- KillTimer (NULL, timer);
- SPWin32Modal = FALSE;
-
- if (!retval) {
- int errcode;
- errcode = CommDlgExtendedError();
- return NULL;
- }
- *spns = (ofn.nFilterIndex != 2);
- return g_strdup (fnbuf);
-}
-
-#include "clear-n_.h"
-
-void
-PrintWin32::init (void)
-{
- Inkscape::Extension::Extension * ext;
-
- /* SVG in */
- ext = Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Windows 32-bit Print") "</name>\n"
- "<id>" SP_MODULE_KEY_PRINT_WIN32 "</id>\n"
- "<param name=\"textToPath\" type=\"boolean\">true</param>\n"
- "<print/>\n"
- "</inkscape-extension>", new PrintWin32());
-
- return;
-}
-
-} /* namespace Internal */
-} /* namespace Extension */
-} /* namespace Inkscape */
-
-#endif // ifdef WIN32
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/internal/win32.h b/src/extension/internal/win32.h
deleted file mode 100644
index 4a913bb05..000000000
--- a/src/extension/internal/win32.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/** @file
- * @brief Windows-specific stuff
- */
-/* Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Ted Gould <ted@gould.cx>
- *
- * Lauris: This code is in public domain
- * Ted: This code is released under the GNU GPL
- */
-
-#ifndef __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__
-#define __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_H__
-#ifdef WIN32
-
-#ifdef HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#ifdef DATADIR
-#undef DATADIR
-#endif
-#include <windows.h>
-
-#include "extension/extension.h"
-#include "extension/implementation/implementation.h"
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-
-/* Initialization */
-
-class PrintWin32 : public Inkscape::Extension::Implementation::Implementation {
- /* Document dimensions */
- float _PageWidth;
- float _PageHeight;
-
- HDC _hDC;
-
- unsigned int _landscape;
-
- void main_init (int argc, char **argv, const char *name);
- void finish (void);
-
- /* File dialogs */
- char *get_open_filename (unsigned char *dir, unsigned char *filter, unsigned char *title);
- char *get_write_filename (unsigned char *dir, unsigned char *filter, unsigned char *title);
- char *get_save_filename (unsigned char *dir, unsigned int *spns);
-
- VOID CALLBACK timer (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
-
-
-public:
- PrintWin32 (void);
- virtual ~PrintWin32 (void);
-
- /* Tell modules about me */
- static void init (void);
-
- /* Platform detection */
- static gboolean is_os_wide();
-
- /* Print functions */
- virtual unsigned int setup (Inkscape::Extension::Print * module);
- //virtual unsigned int set_preview (Inkscape::Extension::Print * module);
-
- virtual unsigned int begin (Inkscape::Extension::Print * module, SPDocument *doc);
- virtual unsigned int finish (Inkscape::Extension::Print * module);
-
- /* Rendering methods */
- /*
- virtual unsigned int bind (Inkscape::Extension::Print * module, const Geom::Affine *transform, float opacity);
- virtual unsigned int release (Inkscape::Extension::Print * module);
- virtual unsigned int comment (Inkscape::Extension::Print * module, const char * comment);
- virtual unsigned int image (Inkscape::Extension::Print * module, unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
- const Geom::Affine *transform, const SPStyle *style);
- */
-};
-
-} /* namespace Internal */
-} /* namespace Extension */
-} /* namespace Inkscape */
-
-#endif // ifdef WIN32
-#endif /* __INKSCAPE_EXTENSION_INTERNAL_PRINT_WIN32_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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index 70fa28967..0f2857570 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -49,9 +49,17 @@
#include "extension/input.h"
#include "document.h"
+// Take a guess and fallback to 0.1.x if no configure has run
+#if !defined(WITH_LIBWPG01) && !defined(WITH_LIBWPG02)
+#define WITH_LIBWPG01 1
+#endif
+
#include "libwpg/libwpg.h"
+#if WITH_LIBWPG01
#include "libwpg/WPGStreamImplementation.h"
-
+#elif WITH_LIBWPG02
+#include "libwpd-stream/libwpd-stream.h"
+#endif
using namespace libwpg;
@@ -60,11 +68,19 @@ namespace Extension {
namespace Internal {
-SPDocument *
-WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
+SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+#if WITH_LIBWPG01
WPXInputStream* input = new libwpg::WPGFileStream(uri);
+#elif WITH_LIBWPG02
+ WPXInputStream* input = new WPXFileStream(uri);
+#endif
if (input->isOLEStream()) {
+#if WITH_LIBWPG01
WPXInputStream* olestream = input->getDocumentOLEStream();
+#elif WITH_LIBWPG02
+ WPXInputStream* olestream = input->getDocumentOLEStream("PerfectOffice_MAIN");
+#endif
if (olestream) {
delete input;
input = olestream;
@@ -79,7 +95,11 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
return NULL;
}
+#if WITH_LIBWPG01
libwpg::WPGString output;
+#elif WITH_LIBWPG02
+ WPXString output;
+#endif
if (!libwpg::WPGraphics::generateSVG(input, output)) {
delete input;
return NULL;
diff --git a/src/extension/output.h b/src/extension/output.h
index 584fafda8..5f6785b8b 100644
--- a/src/extension/output.h
+++ b/src/extension/output.h
@@ -13,7 +13,7 @@
#ifndef INKSCAPE_EXTENSION_OUTPUT_H__
#define INKSCAPE_EXTENSION_OUTPUT_H__
-#include <gtk/gtkdialog.h>
+#include <gtk/gtk.h>
#include "extension.h"
struct SPDocument;
diff --git a/src/extension/param/CMakeLists.txt b/src/extension/param/CMakeLists.txt
deleted file mode 100644
index 2ef5d5005..000000000
--- a/src/extension/param/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-SET(extension_param_SRC
-bool.cpp
-color.cpp
-description.cpp
-groupheader.cpp
-enum.cpp
-parameter.cpp
-float.cpp
-int.cpp
-notebook.cpp
-radiobutton.cpp
-string.cpp
-)
-
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index a8a410382..3073d2e76 100644
--- a/src/extension/param/bool.cpp
+++ b/src/extension/param/bool.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -21,13 +22,14 @@
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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(false)
+ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(false), _indent(0)
{
const char * defaultval = NULL;
- if (sp_repr_children(xml) != 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;
@@ -35,6 +37,11 @@ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * d
_value = false;
}
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
+
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getBool(extension_pref_root + pref_name, _value);
@@ -43,17 +50,7 @@ ParamBool::ParamBool (const gchar * name, const gchar * guitext, const gchar * d
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*/ )
+bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ )
{
_value = in;
@@ -65,46 +62,47 @@ ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ )
return _value;
}
-/** \brief Returns \c _value */
-bool
-ParamBool::get (const SPDocument * doc, const Inkscape::XML::Node * node)
+bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const
{
- return _value;
+ 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. */
+/**
+ * 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.
- */
+ /**
+ * Initialize 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.
+ *
+ * @param param Which parameter to adjust on changing the check button
+ */
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;
}
+
+ /**
+ * A function to respond to the check box changing.
+ * Adjusts the value of the preference to match that in the check box.
+ */
void on_toggle (void);
-};
-/**
- \brief A function to respond to the check box changing
+private:
+ /** Param to change. */
+ ParamBool * _pref;
+ SPDocument * _doc;
+ Inkscape::XML::Node * _node;
+ sigc::signal<void> * _changeSignal;
+};
- Adjusts the value of the preference to match that in the check box.
-*/
-void
-ParamBoolCheckButton::on_toggle (void)
+void ParamBoolCheckButton::on_toggle(void)
{
_pref->set(this->get_active(), NULL /**\todo fix this */, NULL);
if (_changeSignal != NULL) {
@@ -113,9 +111,7 @@ ParamBoolCheckButton::on_toggle (void)
return;
}
-/** \brief Return 'true' or 'false' */
-void
-ParamBool::string (std::string &string)
+void ParamBool::string(std::string &string) const
{
if (_value) {
string += "true";
@@ -126,15 +122,12 @@ ParamBool::string (std::string &string)
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::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
+
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
@@ -143,7 +136,7 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa
ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal));
checkbox->show();
- hbox->pack_start(*checkbox, false, false);
+ hbox->pack_start(*checkbox, false, false, _indent);
hbox->show();
diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h
index a1cd4ce4a..11d06e1c0 100644
--- a/src/extension/param/bool.h
+++ b/src/extension/param/bool.h
@@ -1,9 +1,10 @@
-#ifndef __INK_EXTENSION_PARAMBOOL_H__
-#define __INK_EXTENSION_PARAMBOOL_H__
+#ifndef SEEN_INK_EXTENSION_PARAMBOOL_H
+#define SEEN_INK_EXTENSION_PARAMBOOL_H
/*
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -15,23 +16,59 @@
namespace Inkscape {
namespace Extension {
-/** \brief A boolean parameter */
+/**
+ * A boolean parameter.
+ */
class ParamBool : public Parameter {
-private:
- /** \brief Internal value. */
- bool _value;
public:
+
+ /**
+ * Use the superclass' allocator and set the \c _value.
+ */
ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
- bool get (const SPDocument * doc, const Inkscape::XML::Node * node);
- bool set (bool in, SPDocument * doc, Inkscape::XML::Node * node);
- Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
+
+ /**
+ * Returns the current state/value.
+ */
+ bool get(const SPDocument *doc, const Inkscape::XML::Node *node) const;
+
+ /**
+ * A function to set the state/value.
+ * 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.
+ *
+ * @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
+ */
+ bool set(bool in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ /**
+ * Creates a bool check button for a bool parameter.
+ * Builds a hbox with a label and a check button in it.
+ */
+ Gtk::Widget *get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ /**
+ * Appends 'true' or 'false'.
+ * @todo investigate. Returning a value that can then be appended would probably work better/safer.
+ */
+ virtual void string(std::string &string) const;
+
+private:
+ /** Internal value. */
+ bool _value;
+ int _indent;
};
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INK_EXTENSION_PARAMBOOL_H__ */
+#endif // SEEN_INK_EXTENSION_PARAMBOOL_H
/*
Local Variables:
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 58db85748..6600d5f2a 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -3,6 +3,7 @@
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
* Christopher Brown <audiere@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -40,8 +41,7 @@ ParamColor::~ParamColor(void)
}
-guint32
-ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ )
+guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ )
{
_value = in;
@@ -58,7 +58,8 @@ ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*
/** \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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _changeSignal(0)
{
const char * defaulthex = NULL;
if (sp_repr_children(xml) != NULL)
@@ -73,21 +74,16 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar *
defaulthex = paramval.data();
_value = atoi(defaulthex);
-
- return;
}
-void
-ParamColor::string (std::string &string)
+void ParamColor::string(std::string &string) const
{
char str[16];
sprintf(str, "%i", _value);
string += str;
- return;
}
-Gtk::Widget *
-ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal )
+Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal )
{
if (_gui_hidden) return NULL;
@@ -112,8 +108,7 @@ ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, si
return dynamic_cast<Gtk::Widget *>(hbox);
}
-void
-sp_color_param_changed(SPColorSelector *csel, GObject *obj)
+void sp_color_param_changed(SPColorSelector *csel, GObject *obj)
{
const SPColor color = csel->base->getColor();
float alpha = csel->base->getAlpha();
diff --git a/src/extension/param/color.h b/src/extension/param/color.h
index e6b44fbcb..f46e26286 100644
--- a/src/extension/param/color.h
+++ b/src/extension/param/color.h
@@ -1,9 +1,10 @@
-#ifndef __INK_EXTENSION_PARAMCOLOR_H__
-#define __INK_EXTENSION_PARAMCOLOR_H__
+#ifndef SEEN_INK_EXTENSION_PARAMCOLOR_H__
+#define SEEN_INK_EXTENSION_PARAMCOLOR_H__
/*
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -21,16 +22,36 @@ private:
guint32 _value;
public:
ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+
virtual ~ParamColor(void);
- /** \brief Returns \c _value, with a \i const to protect it. */
- guint32 get( const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/ ) { return _value; }
+
+ /** Returns \c _value, with a \i const to protect it. */
+ guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _value; }
+
guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string (std::string &string) const;
+
sigc::signal<void> * _changeSignal;
-}; /* class ParamColor */
+}; // class ParamColor
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INK_EXTENSION_PARAMCOLOR_H__ */
+#endif // SEEN_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/param/description.cpp b/src/extension/param/description.cpp
index f17b45b4b..7a68aff62 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -30,19 +30,35 @@ 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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL)
+ParamDescription::ParamDescription (const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode) :
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(NULL), _mode(mode), _indent(0)
{
// printf("Building Description\n");
const char * defaultval = NULL;
- if (sp_repr_children(xml) != NULL)
+ if (sp_repr_children(xml) != NULL) {
defaultval = sp_repr_children(xml)->content();
+ }
- if (defaultval != NULL)
+ if (defaultval != NULL) {
_value = g_strdup(defaultval);
-
+ }
+
_context = xml->attribute("msgctxt");
-
+
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
+
return;
}
@@ -50,7 +66,9 @@ ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, c
Gtk::Widget *
ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
Glib::ustring newguitext;
@@ -60,13 +78,21 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
newguitext = _(_value);
}
- Gtk::Label * label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT));
-
+ Gtk::Label * label;
+ int padding = 12 + _indent;
+ if (_mode == HEADER) {
+ label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_LEFT));
+ label->set_padding(0,5);
+ label->set_use_markup(true);
+ padding = _indent;
+ } else {
+ label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT));
+ }
label->set_line_wrap();
label->show();
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- hbox->pack_start(*label, true, true, 12);
+ hbox->pack_start(*label, true, true, padding);
hbox->show();
return hbox;
diff --git a/src/extension/param/description.h b/src/extension/param/description.h
index c56b5c21d..a33ff719a 100644
--- a/src/extension/param/description.h
+++ b/src/extension/param/description.h
@@ -18,13 +18,26 @@ namespace Extension {
/** \brief A description parameter */
class ParamDescription : public Parameter {
+public:
+ enum AppearanceMode {
+ DESC, HEADER
+ };
+ ParamDescription(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
+ Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
private:
/** \brief Internal value. */
gchar * _value;
+ AppearanceMode _mode;
+ int _indent;
const gchar* _context;
-public:
- ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
- Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
};
} /* namespace Extension */
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 9ed5aac16..755cc92ad 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -7,6 +7,7 @@
/*
* Author:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -49,7 +50,7 @@ public:
ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _indent(0)
{
choices = NULL;
_value = NULL;
@@ -62,7 +63,9 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) {
Glib::ustring newguitext, newvalue;
const char * contents = NULL;
- if (node->firstChild()) contents = node->firstChild()->content();
+ if (node->firstChild()) {
+ contents = node->firstChild()->content();
+ }
if (contents != NULL) {
// don't translate when 'item' but do translate when '_item'
// NOTE: internal extensions use build_from_mem and don't need _item but
@@ -80,10 +83,11 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
continue;
const char * val = node->attribute("value");
- if (val != NULL)
+ if (val != NULL) {
newvalue = val;
- else
+ } else {
newvalue = contents;
+ }
if ( (!newguitext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here
choices = g_slist_append( choices, new enumentry(newvalue, newguitext) );
@@ -95,20 +99,26 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
// Initialize _value with the default value from xml
// for simplicity : default to the contents of the first xml-child
const char * defaultval = NULL;
- if (xml->firstChild() && xml->firstChild()->firstChild())
+ if (xml->firstChild() && xml->firstChild()->firstChild()) {
defaultval = xml->firstChild()->attribute("value");
+ }
+
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
- if (!paramval.empty())
+ if (!paramval.empty()) {
defaultval = paramval.data();
- if (defaultval != NULL)
+ }
+ if (defaultval != NULL) {
_value = g_strdup(defaultval);
-
- return;
+ }
}
ParamComboBox::~ParamComboBox (void)
@@ -123,23 +133,26 @@ ParamComboBox::~ParamComboBox (void)
}
-/** \brief A function to set the \c _value
- \param in The value to set
- \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 ONLY 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 *
-ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets ONLY 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().
+ *
+ * @param in The value to set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
- if (in == NULL) return NULL; /* Can't have NULL string */
+ if (in == NULL) {
+ return NULL; /* Can't have NULL string */
+ }
Glib::ustring settext;
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
@@ -150,7 +163,9 @@ ParamComboBox::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node
}
}
if (!settext.empty()) {
- if (_value != NULL) g_free(_value);
+ if (_value != NULL) {
+ g_free(_value);
+ }
_value = g_strdup(settext.data());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -166,22 +181,15 @@ ParamComboBox::changed (void) {
}
-
-/**
- \brief A function to get the value of the parameter in string form
- \return A string with the 'value' as command line argument
-*/
-void
-ParamComboBox::string (std::string &string)
+void ParamComboBox::string(std::string &string) const
{
string += _value;
- return;
}
-/** \brief A special category of Gtk::Entry to handle string parameteres */
+/** A special category of Gtk::Entry to handle string parameteres. */
class ParamComboBoxEntry : public Gtk::ComboBoxText {
private:
ParamComboBox * _pref;
@@ -189,10 +197,11 @@ private:
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.
- */
+ /**
+ * 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, sigc::signal<void> * changeSignal) :
Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
this->signal_changed().connect(sigc::mem_fun(this, &ParamComboBoxEntry::changed));
@@ -200,11 +209,12 @@ public:
void changed (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.
-*/
+/**
+ * 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
ParamComboBoxEntry::changed (void)
{
@@ -216,18 +226,19 @@ ParamComboBoxEntry::changed (void)
}
/**
- \brief Creates a combobox widget for an enumeration parameter
-*/
-Gtk::Widget *
-ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a combobox widget for an enumeration parameter.
+ */
+Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
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);
+ hbox->pack_start(*label, false, false, _indent);
ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
// add choice strings:
@@ -240,7 +251,9 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
settext = entr->guitext;
}
}
- if (!settext.empty()) combo->set_active_text(settext);
+ if (!settext.empty()) {
+ combo->set_active_text(settext);
+ }
combo->show();
hbox->pack_start(*combo, true, true);
@@ -251,5 +264,16 @@ ParamComboBox::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
+
+/*
+ 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/param/enum.h b/src/extension/param/enum.h
index 3f9707c34..a598458c5 100644
--- a/src/extension/param/enum.h
+++ b/src/extension/param/enum.h
@@ -6,8 +6,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -17,13 +18,13 @@
#include <gtkmm/widget.h>
#include "xml/document.h"
-#include <extension/extension-forward.h>
#include "parameter.h"
namespace Inkscape {
namespace Extension {
+class Extension;
// \brief A class to represent a notebookparameter of an extension
@@ -33,16 +34,21 @@ private:
been allocated in memory. And should be free'd.
It is the value of the current selected string */
gchar * _value;
-
+ int _indent;
GSList * choices; /**< A table to store the choice strings */
public:
ParamComboBox(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
virtual ~ParamComboBox(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
- const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+ gchar const *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; }
+
const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
void changed (void);
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 62762b3bb..2b501a9a4 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -11,7 +12,8 @@
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
+#include <gtkmm/scale.h>
+#include "ui/widget/spinbutton.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -22,29 +24,42 @@ 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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0.0), _min(0.0), _max(10.0)
+/** 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,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode) :
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(0.0), _mode(mode), _indent(0), _min(0.0), _max(10.0)
{
const gchar * defaultval = NULL;
- if (sp_repr_children(xml) != NULL)
+ if (sp_repr_children(xml) != NULL) {
defaultval = sp_repr_children(xml)->content();
+ }
if (defaultval != NULL) {
_value = g_ascii_strtod (defaultval,NULL);
}
const char * maxval = xml->attribute("max");
- if (maxval != NULL)
+ if (maxval != NULL) {
_max = g_ascii_strtod (maxval,NULL);
+ }
const char * minval = xml->attribute("min");
- if (minval != NULL)
+ if (minval != NULL) {
_min = g_ascii_strtod (minval,NULL);
+ }
_precision = 1;
const char * precision = xml->attribute("precision");
- if (precision != NULL)
+ if (precision != NULL) {
_precision = atoi(precision);
+ }
/* We're handling this by just killing both values */
if (_max < _min) {
@@ -52,6 +67,11 @@ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar *
_min = 0.0;
}
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
+
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getDouble(extension_pref_root + pref_name, _value);
@@ -59,27 +79,36 @@ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar *
// std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl;
- if (_value > _max) _value = _max;
- if (_value < _min) _value = _min;
+ 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*/)
+/**
+ * A function to set the \c _value.
+ *
+ * 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.
+ *
+ * @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.
+ */
+float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
_value = in;
- if (_value > _max) _value = _max;
- if (_value < _min) _value = _min;
+ if (_value > _max) {
+ _value = _max;
+ }
+ if (_value < _min) {
+ _value = _min;
+ }
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -89,9 +118,7 @@ ParamFloat::set (float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
return _value;
}
-/** \brief Return the value as a string */
-void
-ParamFloat::string (std::string &string)
+void ParamFloat::string(std::string &string) const
{
char startstring[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value);
@@ -99,18 +126,18 @@ ParamFloat::string (std::string &string)
return;
}
-/** \brief A class to make an adjustment that uses Extension params */
+/** A class to make an adjustment that uses Extension params. */
class ParamFloatAdjustment : public Gtk::Adjustment {
- /** The parameter to adjust */
+ /** 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
+ /** 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, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
+ Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 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, &ParamFloatAdjustment::val_changed));
return;
@@ -119,14 +146,13 @@ public:
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)
+/**
+ * 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);
@@ -137,23 +163,33 @@ ParamFloatAdjustment::val_changed (void)
}
/**
- \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)
+ * 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)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
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);
+ hbox->pack_start(*label, true, true, _indent);
ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal));
- Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision));
+
+ if (_mode == FULL) {
+ Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
+ scale->set_draw_value(false);
+ scale->set_size_request(200, -1);
+ scale->show();
+ hbox->pack_start(*scale, false, false);
+ }
+
+ Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision));
spin->show();
hbox->pack_start(*spin, false, false);
diff --git a/src/extension/param/float.h b/src/extension/param/float.h
index f105d8f0e..24747b5f1 100644
--- a/src/extension/param/float.h
+++ b/src/extension/param/float.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -17,22 +18,45 @@ namespace Inkscape {
namespace Extension {
class ParamFloat : public Parameter {
-private:
- /** \brief Internal value. */
- float _value;
- float _min;
- float _max;
- int _precision;
public:
- ParamFloat (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
- /** \brief Returns \c _value */
- float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ enum AppearanceMode {
+ FULL, MINIMAL
+ };
+ ParamFloat (const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
+ /** Returns \c _value. */
+ float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
+
float set (float in, SPDocument * doc, Inkscape::XML::Node * node);
+
float max (void) { return _max; }
+
float min (void) { return _min; }
+
float precision (void) { return _precision; }
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+private:
+ /** Internal value. */
+ float _value;
+ AppearanceMode _mode;
+ int _indent;
+ float _min;
+ float _max;
+ int _precision;
};
} /* namespace Extension */
diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp
deleted file mode 100755
index abf5f8beb..000000000
--- a/src/extension/param/groupheader.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Authors:
- * Ted Gould <ted@gould.cx>
- * Johan Engelen <johan@shouraizou.nl> *
- * Nicolas Dufour <nicoduf@yahoo.fr>
- * 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 "groupheader.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/extension.h"
-
-namespace Inkscape {
-namespace Extension {
-
-
-/** \brief Initialize the object, to do that, copy the data. */
-ParamGroupHeader::ParamGroupHeader (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL)
-{
- // printf("Building GroupHeader\n");
- const char * defaultval = NULL;
- if (sp_repr_children(xml) != NULL)
- defaultval = sp_repr_children(xml)->content();
-
- if (defaultval != NULL)
- _value = g_strdup(defaultval);
-
- _context = xml->attribute("msgctxt");
-
- return;
-}
-
-/** \brief Create a label for the GroupHeader */
-Gtk::Widget *
-ParamGroupHeader::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
-{
- if (_gui_hidden) return NULL;
-
- Glib::ustring newguitext;
-
- if (_context != NULL) {
- newguitext = g_dpgettext2(NULL, _context, _value);
- } else {
- newguitext = _(_value);
- }
-
- Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_LEFT));
- label->set_line_wrap();
- label->set_padding(0,5);
- label->set_use_markup(true);
- label->show();
-
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- hbox->pack_start(*label, true, true);
- hbox->show();
-
- return hbox;
-}
-
-} /* namespace Extension */
-} /* namespace Inkscape */
diff --git a/src/extension/param/groupheader.h b/src/extension/param/groupheader.h
deleted file mode 100755
index 94fe880f9..000000000
--- a/src/extension/param/groupheader.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __INK_EXTENSION_PARAMGROUPHEADER_H__
-#define __INK_EXTENSION_PARAMGROUPHEADER_H__
-
-/*
- * Copyright (C) 2005-2010 Authors:
- * Ted Gould <ted@gould.cx>
- * Johan Engelen <johan@shouraizou.nl> *
- * Nicolas Dufour <nicoduf@yahoo.fr>
- * 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 GroupLabel parameter */
-class ParamGroupHeader : public Parameter {
-private:
- /** \brief Internal value. */
- gchar * _value;
- const gchar* _context;
-public:
- ParamGroupHeader(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, 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_PARAMGROUPHEADER_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/param/int.cpp b/src/extension/param/int.cpp
index ae69d0661..cd6815c4d 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -11,7 +12,8 @@
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
+#include <gtkmm/scale.h>
+#include "ui/widget/spinbutton.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -22,31 +24,47 @@ 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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _min(0), _max(10)
+/** 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,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode) :
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(0), _mode(mode), _indent(0), _min(0), _max(10)
{
const char * defaultval = NULL;
- if (sp_repr_children(xml) != 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)
+ if (maxval != NULL) {
_max = atoi(maxval);
+ }
const char * minval = xml->attribute("min");
- if (minval != NULL)
+ if (minval != NULL) {
_min = atoi(minval);
-
+ }
/* We're handling this by just killing both values */
if (_max < _min) {
_max = 10;
_min = 0;
}
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
+
gchar *pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getInt(extension_pref_root + pref_name, _value);
@@ -54,27 +72,33 @@ ParamInt::ParamInt (const gchar * name, const gchar * guitext, const gchar * des
// std::cout << "New Int:: value: " << _value << " max: " << _max << " min: " << _min << std::endl;
- if (_value > _max) _value = _max;
- if (_value < _min) _value = _min;
-
- return;
+ if (_value > _max) {
+ _value = _max;
+ }
+ if (_value < _min) {
+ _value = _min;
+ }
}
-/** \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*/)
+/**
+ * A function to set the \c _value.
+ * 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.
+ *
+ * @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.
+ */
+int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
_value = in;
- if (_value > _max) _value = _max;
- if (_value < _min) _value = _min;
+ if (_value > _max) {
+ _value = _max;
+ }
+ if (_value < _min) {
+ _value = _min;
+ }
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -84,61 +108,69 @@ ParamInt::set (int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
return _value;
}
-/** \brief A class to make an adjustment that uses Extension params */
+/** A class to make an adjustment that uses Extension params. */
class ParamIntAdjustment : public Gtk::Adjustment {
- /** The parameter to adjust */
+ /** 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. */
+ /** 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, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) {
+ Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 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)
+/**
+ * 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.
-*/
+ * 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)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
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);
+ hbox->pack_start(*label, true, true, _indent);
ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal));
- Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0));
+
+ if (_mode == FULL) {
+ Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
+ scale->set_draw_value(false);
+ scale->set_size_request(200, -1);
+ scale->show();
+ hbox->pack_start(*scale, false, false);
+ }
+
+ Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0));
spin->show();
hbox->pack_start(*spin, false, false);
@@ -147,18 +179,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
return dynamic_cast<Gtk::Widget *>(hbox);
}
-/** \brief Return the value as a string */
-void
-ParamInt::string (std::string &string)
+void ParamInt::string(std::string &string) const
{
char startstring[32];
sprintf(startstring, "%d", _value);
string += startstring;
- return;
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/int.h b/src/extension/param/int.h
index a4eb54c81..83fc67be9 100644
--- a/src/extension/param/int.h
+++ b/src/extension/param/int.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -17,20 +18,43 @@ 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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
- /** \brief Returns \c _value */
- int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
+ enum AppearanceMode {
+ FULL, MINIMAL
+ };
+ ParamInt (const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
+
+ /** Returns \c _value. */
+ int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { 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);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+private:
+ /** Internal value. */
+ int _value;
+ AppearanceMode _mode;
+ int _indent;
+ int _min;
+ int _max;
};
} /* namespace Extension */
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index e1ab1de6d..80042febc 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -3,8 +3,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006 Author
*
@@ -33,15 +34,19 @@
#include "notebook.h"
-/** \brief The root directory in the preferences database for extension
- related parameters. */
+/**
+ * The root directory in the preferences database for extension
+ * related parameters.
+ */
#define PREF_DIR "extensions"
namespace Inkscape {
namespace Extension {
-// \brief A class to represent the pages of a notebookparameter of an extension
+/**
+ * A class to represent the pages of a notebookparameter of an extension.
+ */
class ParamNotebookPage : public Parameter {
private:
GSList * parameters; /**< A table to store the parameters for this page.
@@ -62,7 +67,8 @@ public:
ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _tooltips(NULL)
{
parameters = NULL;
@@ -84,8 +90,6 @@ ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext,
child_repr = sp_repr_next(child_repr);
}
}
-
- return;
}
ParamNotebookPage::~ParamNotebookPage (void)
@@ -99,16 +103,13 @@ ParamNotebookPage::~ParamNotebookPage (void)
g_slist_free(parameters);
}
-/** \brief Return the value as a string */
-void
-ParamNotebookPage::paramString (std::list <std::string> &list)
+/** Return the value as a string. */
+void ParamNotebookPage::paramString(std::list <std::string> &list)
{
for (GSList * plist = parameters; plist != NULL; plist = g_slist_next(plist)) {
Parameter * param = reinterpret_cast<Parameter *>(plist->data);
param->string(list);
}
-
- return;
}
@@ -119,6 +120,7 @@ ParamNotebookPage::paramString (std::list <std::string> &list)
in the XML file describing the extension (it's private so people
have to use the system) :)
\param in_repr The XML describing the page
+ \todo the 'gui-hidden' attribute is read but not used!
This function first grabs all of the data out of the Repr and puts
it into local variables. Actually, these are just pointers, and the
@@ -191,16 +193,19 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension:
/**
- \brief Creates a notebookpage widget for a notebook
-
- Builds a notebook page (a vbox) and puts parameters on it.
-*/
-Gtk::Widget *
-ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a notebookpage widget for a notebook.
+ *
+ * Builds a notebook page (a vbox) and puts parameters on it.
+ */
+Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
- if (!_tooltips) _tooltips = new Gtk::Tooltips();
+ if (!_tooltips) {
+ _tooltips = new Gtk::Tooltips();
+ }
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox);
vbox->set_border_width(5);
@@ -264,8 +269,6 @@ ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const g
defaultval = paramval.data();
if (defaultval != NULL)
_value = g_strdup(defaultval); // allocate space for _value
-
- return;
}
ParamNotebook::~ParamNotebook (void)
@@ -281,21 +284,22 @@ ParamNotebook::~ParamNotebook (void)
}
-/** \brief A function to set the \c _value
- \param in The number of the page which value must be set
- \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 *
-ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * 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().
+ *
+ * @param in The number of the page which value must be set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
ParamNotebookPage * page = NULL;
int i = 0;
@@ -317,13 +321,7 @@ ParamNotebook::set (const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*
return _value;
}
-
-/**
- \brief A function to get the currentpage and the parameters in a string form
- \return A string with the 'value' and all the parameters on all pages as command line arguments
-*/
-void
-ParamNotebook::string (std::list <std::string> &list)
+void ParamNotebook::string(std::list <std::string> &list) const
{
std::string param_string;
param_string += "--";
@@ -339,51 +337,47 @@ ParamNotebook::string (std::list <std::string> &list)
ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data);
page->paramString(list);
}
-
- return;
}
-/** \brief A special category of Gtk::Notebook to handle notebook parameters */
+/** A special category of Gtk::Notebook to handle notebook parameters. */
class ParamNotebookWdg : public Gtk::Notebook {
private:
ParamNotebook * _pref;
SPDocument * _doc;
Inkscape::XML::Node * _node;
public:
- /** \brief Build a notebookpage preference for the given parameter
- \param pref Where to get the string (pagename) from, and where to put it
- when it changes.
- */
+ /**
+ * Build a notebookpage preference for the given parameter.
+ * @param pref Where to get the string (pagename) from, and where to put it
+ * when it changes.
+ */
ParamNotebookWdg (ParamNotebook * pref, SPDocument * doc, Inkscape::XML::Node * node) :
Gtk::Notebook(), _pref(pref), _doc(doc), _node(node), activated(false) {
// don't have to set the correct page: this is done in ParamNotebook::get_widget.
// hook function
this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page));
- return;
};
void changed_page(GtkNotebookPage *page, guint pagenum);
bool activated;
};
-/** \brief Respond to the selected page of notebook changing
- This function responds to the changing by reporting it to
- ParamNotebook. The change is only reported when the notebook
- is actually visible. This to exclude 'fake' changes when the
- notebookpages are added or removed.
-*/
-void
-ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/,
- guint pagenum)
+/**
+ * Respond to the selected page of notebook changing.
+ * This function responds to the changing by reporting it to
+ * ParamNotebook. The change is only reported when the notebook
+ * is actually visible. This to exclude 'fake' changes when the
+ * notebookpages are added or removed.
+ */
+void ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/,
+ guint pagenum)
{
if (is_visible()) {
_pref->set((int)pagenum, _doc, _node);
}
- return;
}
-/** \brief Search the parameter's name in the notebook content */
-Parameter *
-ParamNotebook::get_param(const gchar * name)
+/** Search the parameter's name in the notebook content. */
+Parameter *ParamNotebook::get_param(const gchar * name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -399,9 +393,8 @@ ParamNotebook::get_param(const gchar * name)
return NULL;
}
-/** \brief Search the parameter's name in the page content */
-Parameter *
-ParamNotebookPage::get_param(const gchar * name)
+/** Search the parameter's name in the page content. */
+Parameter *ParamNotebookPage::get_param(const gchar * name)
{
if (name == NULL) {
throw Extension::param_not_exist();
@@ -422,14 +415,15 @@ ParamNotebookPage::get_param(const gchar * name)
}
/**
- \brief Creates a Notebook widget for a notebook parameter
-
- Builds a notebook and puts pages in it.
-*/
-Gtk::Widget *
-ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a Notebook widget for a notebook parameter.
+ *
+ * Builds a notebook and puts pages in it.
+ */
+Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node));
@@ -454,8 +448,8 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
}
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h
index fb21c9b63..23058f465 100644
--- a/src/extension/param/notebook.h
+++ b/src/extension/param/notebook.h
@@ -8,6 +8,7 @@
/*
* Author:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006 Author
*
@@ -17,21 +18,23 @@
#include <gtkmm/widget.h>
#include "xml/document.h"
-#include <extension/extension-forward.h>
#include "parameter.h"
namespace Inkscape {
namespace Extension {
+class Extension;
-// \brief A class to represent a notebookparameter of an extension
+/** A class to represent a notebookparameter of an extension. */
class ParamNotebook : public Parameter {
private:
- /** \brief Internal value. This should point to a string that has
- been allocated in memory. And should be free'd.
- It is the name of the current page. */
+ /**
+ * Internal value. This should point to a string that has
+ * been allocated in memory. And should be free'd.
+ * It is the name of the current page.
+ */
gchar * _value;
GSList * pages; /**< A table to store the pages with parameters for this notebook.
@@ -41,7 +44,16 @@ public:
ParamNotebook(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
virtual ~ParamNotebook(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::list <std::string> &list);
+
+ /**
+ * A function to get the currentpage and the parameters in a string form.
+ * @return A string with the 'value' and all the parameters on all pages as command line arguments.
+ */
+ virtual void string (std::list <std::string> &list) const;
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::string &string) const {return Parameter::string(string);}
+
Parameter * get_param (const gchar * name);
@@ -53,8 +65,8 @@ public:
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
#endif /* INK_EXTENSION_PARAMNOTEBOOK_H_SEEN */
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp
index 529d5a775..063ec32be 100644
--- a/src/extension/param/parameter.cpp
+++ b/src/extension/param/parameter.cpp
@@ -1,5 +1,5 @@
/** @file
- * @brief Parameters for extensions.
+ * Parameters for extensions.
*/
/* Author:
* Ted Gould <ted@gould.cx>
@@ -19,10 +19,6 @@
# define ESCAPE_DOLLAR_COMMANDLINE
#endif
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
-
#include <xml/node.h>
#include <extension/extension.h>
@@ -36,7 +32,6 @@
#include "bool.h"
#include "color.h"
#include "description.h"
-#include "groupheader.h"
#include "enum.h"
#include "float.h"
#include "int.h"
@@ -47,76 +42,52 @@
namespace Inkscape {
namespace Extension {
-/**
- \return None
- \brief This function creates a parameter that can be used later. This
- is typically done in the creation of the extension and defined
- in the XML file describing the extension (it's private so people
- have to use the system) :)
- \param in_repr The XML describing the parameter
-
- This function first grabs all of the data out of the Repr and puts
- it into local variables. Actually, these are just pointers, and the
- data is not duplicated so we need to be careful with it. If there
- isn't a name or a type in the XML, then no parameter is created as
- the function just returns.
-
- From this point on, we're pretty committed as we've allocated an
- object and we're starting to fill it. The name is set first, and
- is created with a strdup to actually allocate memory for it. Then
- there is a case statement (roughly because strcmp requires 'ifs')
- based on what type of parameter this is. Depending which type it
- is, the value is interpreted differently, but they are relatively
- straight forward. In all cases the value is set to the default
- value from the XML and the type is set to the interpreted type.
-*/
-Parameter *
-Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext)
+Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext)
{
- const char * name;
- const char * type;
- const char * guitext;
- const char * desc;
- const char * scope_str;
- Parameter::_scope_t scope = Parameter::SCOPE_USER;
- bool gui_hidden = false;
- const char * gui_hide;
- const char * gui_tip;
-
- name = in_repr->attribute("name");
- type = in_repr->attribute("type");
- guitext = in_repr->attribute("gui-text");
- if (guitext == NULL)
+ const char *name = in_repr->attribute("name");
+ const char *type = in_repr->attribute("type");
+
+ // In this case we just don't have enough information
+ if (!name || !type) {
+ return NULL;
+ }
+
+ const char *guitext = in_repr->attribute("gui-text");
+ if (guitext == NULL) {
guitext = in_repr->attribute("_gui-text");
- gui_tip = in_repr->attribute("gui-tip");
- if (gui_tip == NULL)
+ }
+ const char *gui_tip = in_repr->attribute("gui-tip");
+ if (gui_tip == NULL) {
gui_tip = in_repr->attribute("_gui-tip");
- desc = in_repr->attribute("gui-description");
- if (desc == NULL)
+ }
+ const char *desc = in_repr->attribute("gui-description");
+ if (desc == NULL) {
desc = in_repr->attribute("_gui-description");
- scope_str = in_repr->attribute("scope");
- gui_hide = in_repr->attribute("gui-hidden");
- if (gui_hide != NULL) {
- if (strcmp(gui_hide, "1") == 0 ||
- strcmp(gui_hide, "true") == 0) {
- gui_hidden = true;
- }
- /* else stays false */
- }
- const gchar* appearance = in_repr->attribute("appearance");
-
- /* In this case we just don't have enough information */
- if (name == NULL || type == NULL) {
- return NULL;
}
+ bool gui_hidden = false;
+ {
+ const char *gui_hide = in_repr->attribute("gui-hidden");
+ if (gui_hide != NULL) {
+ if (strcmp(gui_hide, "1") == 0 ||
+ strcmp(gui_hide, "true") == 0) {
+ gui_hidden = true;
+ }
+ /* else stays false */
+ }
+ }
+ const gchar* appearance = in_repr->attribute("appearance");
- if (scope_str != NULL) {
- if (!strcmp(scope_str, "user")) {
- scope = Parameter::SCOPE_USER;
- } else if (!strcmp(scope_str, "document")) {
- scope = Parameter::SCOPE_DOCUMENT;
- } else if (!strcmp(scope_str, "node")) {
- scope = Parameter::SCOPE_NODE;
+ Parameter::_scope_t scope = Parameter::SCOPE_USER;
+ {
+ const char *scope_str = in_repr->attribute("scope");
+ if (scope_str != NULL) {
+ if (!strcmp(scope_str, "user")) {
+ scope = Parameter::SCOPE_USER;
+ } else if (!strcmp(scope_str, "document")) {
+ scope = Parameter::SCOPE_DOCUMENT;
+ } else if (!strcmp(scope_str, "node")) {
+ scope = Parameter::SCOPE_NODE;
+ }
}
}
@@ -124,20 +95,30 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
if (!strcmp(type, "boolean")) {
param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
} else if (!strcmp(type, "int")) {
- param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+ if (appearance && !strcmp(appearance, "full")) {
+ param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL);
+ } else {
+ param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL);
+ }
} else if (!strcmp(type, "float")) {
- param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+ if (appearance && !strcmp(appearance, "full")) {
+ param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL);
+ } else {
+ param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL);
+ }
} else if (!strcmp(type, "string")) {
param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
- const gchar * max_length = in_repr->attribute("max_length");
+ gchar const * max_length = in_repr->attribute("max_length");
if (max_length != NULL) {
- ParamString * ps = dynamic_cast<ParamString *>(param);
- ps->setMaxLength(atoi(max_length));
+ ParamString * ps = dynamic_cast<ParamString *>(param);
+ ps->setMaxLength(atoi(max_length));
}
} else if (!strcmp(type, "description")) {
- param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
- } else if (!strcmp(type, "groupheader")) {
- param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+ if (appearance && !strcmp(appearance, "header")) {
+ param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::HEADER);
+ } else {
+ param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::DESC);
+ }
} else if (!strcmp(type, "enum")) {
param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
} else if (!strcmp(type, "notebook")) {
@@ -152,82 +133,74 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
}
- /* Note: param could equal NULL */
+ // Note: param could equal NULL
return param;
}
-/** \brief Wrapper to cast to the object and use it's function. */
-bool
-Parameter::get_bool (const SPDocument * doc, const Inkscape::XML::Node * node)
+bool Parameter::get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);
- if (boolpntr == NULL)
+ ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this);
+ if (!boolpntr) {
throw Extension::param_not_bool_param();
+ }
return boolpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-int
-Parameter::get_int (const SPDocument * doc, const Inkscape::XML::Node * node)
+int Parameter::get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamInt * intpntr = dynamic_cast<ParamInt *>(this);
- if (intpntr == NULL)
+ ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this);
+ if (!intpntr) {
throw Extension::param_not_int_param();
+ }
return intpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-float
-Parameter::get_float (const SPDocument * doc, const Inkscape::XML::Node * node)
+float Parameter::get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamFloat * floatpntr = dynamic_cast<ParamFloat *>(this);
- if (floatpntr == NULL)
+ ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this);
+ if (!floatpntr) {
throw Extension::param_not_float_param();
+ }
return floatpntr->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-const gchar *
-Parameter::get_string (const SPDocument * doc, const Inkscape::XML::Node * node)
+gchar const *Parameter::get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamString * stringpntr = dynamic_cast<ParamString *>(this);
- if (stringpntr == NULL)
+ ParamString const *stringpntr = dynamic_cast<ParamString const *>(this);
+ if (!stringpntr) {
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)
+gchar const *Parameter::get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const
{
- ParamComboBox * param = dynamic_cast<ParamComboBox *>(this);
- if (param == NULL)
+ ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this);
+ if (!param) {
throw Extension::param_not_enum_param();
+ }
return param->get(doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-gchar const *Parameter::get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const * node)
+gchar const *Parameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const * node) const
{
- ParamRadioButton * param = dynamic_cast<ParamRadioButton *>(this);
+ ParamRadioButton const *param = dynamic_cast<ParamRadioButton const *>(this);
if (!param) {
throw Extension::param_not_optiongroup_param();
}
return param->get(doc, node);
}
-guint32
-Parameter::get_color(const SPDocument* doc, const Inkscape::XML::Node* node)
+guint32 Parameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *node) const
{
- ParamColor* param = dynamic_cast<ParamColor *>(this);
- if (param == NULL)
+ ParamColor const *param = dynamic_cast<ParamColor const *>(this);
+ if (!param) {
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)
+bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamBool * boolpntr = dynamic_cast<ParamBool *>(this);
if (boolpntr == NULL)
@@ -235,9 +208,7 @@ Parameter::set_bool (bool in, SPDocument * doc, Inkscape::XML::Node * node)
return boolpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-int
-Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node)
+int Parameter::set_int(int in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamInt * intpntr = dynamic_cast<ParamInt *>(this);
if (intpntr == NULL)
@@ -245,7 +216,7 @@ Parameter::set_int (int in, SPDocument * doc, Inkscape::XML::Node * node)
return intpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
+/** Wrapper to cast to the object and use it's function. */
float
Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
{
@@ -256,9 +227,9 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node)
return floatpntr->set(in, doc, node);
}
-/** \brief Wrapper to cast to the object and use it's function. */
-const gchar *
-Parameter::set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node)
+/** Wrapper to cast to the object and use it's function. */
+gchar const *
+Parameter::set_string (gchar const * in, SPDocument * doc, Inkscape::XML::Node * node)
{
ParamString * stringpntr = dynamic_cast<ParamString *>(this);
if (stringpntr == NULL)
@@ -276,7 +247,7 @@ gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, In
}
-/** \brief Wrapper to cast to the object and use it's function. */
+/** Wrapper to cast to the object and use it's function. */
guint32
Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node)
{
@@ -287,9 +258,15 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node)
}
-/** \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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext) :
- extension(ext), _name(NULL), _desc(NULL), _scope(scope), _text(NULL), _gui_hidden(gui_hidden), _gui_tip(NULL)
+/** Oop, now that we need a parameter, we need it's name. */
+Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, Inkscape::Extension::Extension * ext) :
+ _desc(0),
+ _scope(scope),
+ _text(0),
+ _gui_hidden(gui_hidden),
+ _gui_tip(0),
+ extension(ext),
+ _name(0)
{
if (name != NULL) {
_name = g_strdup(name);
@@ -302,28 +279,53 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d
_gui_tip = g_strdup(gui_tip);
}
+ if (guitext != NULL) {
+ _text = g_strdup(guitext);
+ } else {
+ _text = g_strdup(name);
+ }
- if (guitext != NULL)
+ return;
+}
+
+/** Oop, now that we need a parameter, we need it's name. */
+Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) :
+ _desc(0),
+ _scope(Parameter::SCOPE_USER),
+ _text(0),
+ _gui_hidden(false),
+ _gui_tip(0),
+ extension(ext),
+ _name(0)
+{
+ if (name != NULL) {
+ _name = g_strdup(name);
+ }
+ if (guitext != NULL) {
_text = g_strdup(guitext);
- else
+ } else {
_text = g_strdup(name);
+ }
return;
}
-/** \brief Just free the allocated name. */
-Parameter::~Parameter (void)
+Parameter::~Parameter(void)
{
g_free(_name);
+ _name = 0;
+
g_free(_text);
- g_free(_gui_tip);
+ _text = 0;
+
+ g_free(_gui_tip);
+ _gui_tip = 0;
+
g_free(_desc);
+ _desc = 0;
}
-/** \brief Build the name to write the parameter from the extension's
- ID and the name of this parameter. */
-gchar *
-Parameter::pref_name (void)
+gchar *Parameter::pref_name(void) const
{
return g_strdup_printf("%s.%s", extension->get_id(), _name);
}
@@ -349,7 +351,7 @@ Parameter::new_child (Inkscape::XML::Node * parent)
Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc)
{
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr();
+ Inkscape::XML::Node * defs = doc->getDefs()->getRepr();
Inkscape::XML::Node * params = NULL;
GQuark const name_quark = g_quark_from_string("inkscape:extension-params");
@@ -374,50 +376,43 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc)
return params;
}
-/** \brief Basically, if there is no widget pass a NULL. */
+/** Basically, if there is no widget pass a NULL. */
Gtk::Widget *
Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
{
return NULL;
}
-/** \brief If I'm not sure which it is, just don't return a value. */
-void
-Parameter::string (std::string &/*string*/)
+/** If I'm not sure which it is, just don't return a value. */
+void Parameter::string(std::string &/*string*/) const
{
- return;
+ // TODO investigate clearing the target string.
}
-void
-Parameter::string (std::list <std::string> &list)
+void Parameter::string(std::list <std::string> &list) const
{
std::string value;
string(value);
- if (value == "") {
- return;
+ if (!value.empty()) {
+ std::string final;
+ final += "--";
+ final += name();
+ final += "=";
+ final += value;
+
+ list.insert(list.end(), final);
}
-
- std::string final;
- final += "--";
- final += name();
- final += "=";
- final += value;
-
- list.insert(list.end(), final);
- return;
}
-/** \brief All the code in Notebook::get_param to get the notebook content */
-Parameter *
-Parameter::get_param(const gchar * name)
+Parameter *Parameter::get_param(gchar const * /*name*/)
{
return NULL;
}
Glib::ustring const extension_pref_root = "/extensions/";
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
/*
Local Variables:
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index d8ed68439..8d80e6c40 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -1,8 +1,9 @@
/** @file
- * @brief Parameters for extensions.
+ * Parameters for extensions.
*/
/* Authors:
* Ted Gould <ted@gould.cx>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005-2006 Authors
*
@@ -18,117 +19,178 @@
#include "xml/document.h"
#include "xml/node.h"
#include "document.h"
-#include "extension/extension-forward.h"
#include <color.h>
namespace Inkscape {
namespace Extension {
+class Extension;
+
+
/**
- * @brief The root directory in the preferences database for extension-related parameters
+ * The root directory in the preferences database for extension-related parameters.
*
* The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works
* without having to append a separator.
*/
extern Glib::ustring const extension_pref_root;
-/** \brief A class to represent the parameter of an extension
-
- This is really a super class that allows them to abstract all
- the different types of parameters into some that can be passed
- around. There is also a few functions that are used by all the
- different parameters.
-*/
+/**
+ * A class to represent the parameter of an extension.
+ *
+ * This is really a super class that allows them to abstract all
+ * the different types of parameters into some that can be passed
+ * around. There is also a few functions that are used by all the
+ * different parameters.
+ */
class Parameter {
-private:
- /** \brief Which extension is this parameter attached to? */
- Inkscape::Extension::Extension * extension;
- /** \brief The name of this parameter. */
- gchar * _name;
protected:
- /** \brief Description of the parameter. */
- gchar * _desc;
- /** \brief List of possible scopes. */
+ /** List of possible scopes. */
typedef enum {
SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */
SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */
SCOPE_NODE /**< Parameter value is attached to the node. */
} _scope_t;
- /** \brief Scope of the parameter. */
+
+public:
+ Parameter(gchar const *name,
+ gchar const *guitext,
+ gchar const *desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ gchar const *gui_tip,
+ Inkscape::Extension::Extension * ext);
+
+ Parameter(gchar const *name,
+ gchar const *guitext,
+ Inkscape::Extension::Extension * ext);
+
+ virtual ~Parameter(void);
+
+ /** Wrapper to cast to the object and use its function. */
+ bool get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ int get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ float get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ guint32 get_color(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const;
+
+ /** Wrapper to cast to the object and use it's function. */
+ gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const;
+
+
+ /** Wrapper to cast to the object and use it's function. */
+ bool set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ /** Wrapper to cast to the object and use it's function. */
+ int set_int(int in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ float set_float(float in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ gchar const *set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node);
+
+ gchar const *set_string(gchar const * in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ guint32 set_color(guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
+
+ gchar const * name(void) const {return _name;}
+
+ /**
+ * This function creates a parameter that can be used later. This
+ * is typically done in the creation of the extension and defined
+ * in the XML file describing the extension (it's private so people
+ * have to use the system) :)
+ *
+ * This function first grabs all of the data out of the Repr and puts
+ * it into local variables. Actually, these are just pointers, and the
+ * data is not duplicated so we need to be careful with it. If there
+ * isn't a name or a type in the XML, then no parameter is created as
+ * the function just returns.
+ *
+ * From this point on, we're pretty committed as we've allocated an
+ * object and we're starting to fill it. The name is set first, and
+ * is created with a strdup to actually allocate memory for it. Then
+ * there is a case statement (roughly because strcmp requires 'ifs')
+ * based on what type of parameter this is. Depending which type it
+ * is, the value is interpreted differently, but they are relatively
+ * straight forward. In all cases the value is set to the default
+ * value from the XML and the type is set to the interpreted type.
+ *
+ * @param in_repr The XML describing the parameter.
+ * @return a pointer to a new Parameter if applicable, null otherwise..
+ */
+ static Parameter *make(Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
+
+ virtual Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+
+ gchar const * get_tooltip(void) const { return _desc; }
+
+ /** Indicates if the GUI for this parameter is hidden or not */
+ bool get_gui_hidden() const { return _gui_hidden; }
+
+ virtual void string(std::list <std::string> &list) const;
+
+ /**
+ * Gets the current value of the parameter in a string form.
+ * @return A string with the 'value'.
+ */
+ virtual void string(std::string &string) const;
+
+ /** All the code in Notebook::get_param to get the notebook content. */
+ virtual Parameter *get_param(gchar const *name);
+
+protected:
+ /** Description of the parameter. */
+ gchar * _desc;
+
+ /** Scope of the parameter. */
_scope_t _scope;
- /** \brief Text for the GUI selection of this. */
+
+ /** Text for the GUI selection of this. */
gchar * _text;
- /** \brief Whether the GUI is visible */
+
+ /** Whether the GUI is visible. */
bool _gui_hidden;
- /** \brief A tip for the GUI if there is one */
+
+ /** A tip for the GUI if there is one. */
gchar * _gui_tip;
/* **** funcs **** */
- gchar * pref_name (void);
+
+ /**
+ * Build the name to write the parameter from the extension's ID and the name of this parameter.
+ */
+ gchar *pref_name(void) const;
+
Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult);
+
Inkscape::XML::Node * document_param_node (SPDocument * doc);
+
Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent);
-public:
- Parameter (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext);
- Parameter (const gchar * name,
- const gchar * guitext,
- Inkscape::Extension::Extension * ext) {
- Parameter(name, guitext, NULL, Parameter::SCOPE_USER, false, NULL, ext);
- };
- virtual ~Parameter (void);
-
- bool get_bool (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- int get_int (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- float get_float (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- const gchar * get_string (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- guint32 get_color (const SPDocument * doc,
- const Inkscape::XML::Node * node);
- const gchar * get_enum (const SPDocument * doc,
- const Inkscape::XML::Node * node);
-
- gchar const * get_optiongroup( SPDocument const * doc,
- Inkscape::XML::Node const * 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);
- gchar const * set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node);
- const gchar * set_string (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node);
- guint32 set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node);
-
- const gchar * name (void) {return _name;}
-
- static Parameter * make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
- virtual Gtk::Widget * get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
-
- gchar const * get_tooltip (void) { return _desc; }
-
- /** \brief Indicates if the GUI for this parameter is hidden or not */
- bool get_gui_hidden () { return _gui_hidden; }
-
- virtual void string (std::list <std::string> &list);
- virtual void string (std::string &string);
-
- virtual Parameter * get_param (const gchar * name);
+private:
+ /** Which extension is this parameter attached to. */
+ Inkscape::Extension::Extension *extension;
+
+ /** The name of this parameter. */
+ gchar *_name;
};
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
-#endif /* __INK_EXTENSION_PARAM_H__ */
+#endif // SEEN_INK_EXTENSION_PARAM_H__
/*
Local Variables:
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 23655baea..a9fcbfd6c 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -35,8 +35,10 @@
#include "radiobutton.h"
-/** \brief The root directory in the preferences database for extension
- related parameters. */
+/**
+ * The root directory in the preferences database for extension
+ * related parameters.
+ */
#define PREF_DIR "extensions"
namespace Inkscape {
@@ -69,9 +71,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
Inkscape::XML::Node * xml,
AppearanceMode mode) :
Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(0),
- _mode(mode),
- choices(0)
+ _value(0), _mode(mode), _indent(0), choices(0)
{
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
@@ -95,16 +95,17 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
} else {
newguitext = new Glib::ustring(contents);
}
- } else
+ } else {
continue;
-
+ }
const char * val = child_repr->attribute("value");
- if (val != NULL)
+ if (val != NULL) {
newvalue = new Glib::ustring(val);
- else
+ } else {
newvalue = new Glib::ustring(contents);
+ }
if ( (newguitext) && (newvalue) ) { // logical error if this is not true here
choices = g_slist_append( choices, new optionentry(newvalue, newguitext) );
@@ -117,20 +118,26 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
// Initialize _value with the default value from xml
// for simplicity : default to the contents of the first xml-child
const char * defaultval = NULL;
- if (choices)
+ if (choices) {
defaultval = ((optionentry*) choices->data)->value->c_str();
+ }
+
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
- if (!paramval.empty())
+ if (!paramval.empty()) {
defaultval = paramval.data();
- if (defaultval != NULL)
+ }
+ if (defaultval != NULL) {
_value = g_strdup(defaultval); // allocate space for _value
-
- return;
+ }
}
ParamRadioButton::~ParamRadioButton (void)
@@ -145,23 +152,26 @@ ParamRadioButton::~ParamRadioButton (void)
}
-/** \brief A function to set the \c _value
- \param in The value to set
- \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 ONLY 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 *
-ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
+/**
+ * A function to set the \c _value.
+ *
+ * This function sets ONLY 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().
+ *
+ * @param in The value to set.
+ * @param doc A document that should be used to set the value.
+ * @param node The node where the value may be placed.
+ */
+const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
- if (in == NULL) return NULL; /* Can't have NULL string */
+ if (in == NULL) {
+ return NULL; /* Can't have NULL string */
+ }
Glib::ustring * settext = NULL;
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
@@ -172,7 +182,9 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
}
}
if (settext) {
- if (_value != NULL) g_free(_value);
+ if (_value != NULL) {
+ g_free(_value);
+ }
_value = g_strdup(settext->c_str());
gchar * prefname = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -183,19 +195,12 @@ ParamRadioButton::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::No
return _value;
}
-
-/**
- \brief A function to get the current value of the parameter in a string form
- \return A string with the 'value' as command line argument
-*/
-void
-ParamRadioButton::string (std::string &string)
+void ParamRadioButton::string(std::string &string) const
{
string += _value;
- return;
}
-/** \brief A special radiobutton class to use in ParamRadioButton */
+/** A special radiobutton class to use in ParamRadioButton. */
class ParamRadioButtonWdg : public Gtk::RadioButton {
private:
ParamRadioButton * _pref;
@@ -203,9 +208,10 @@ private:
Inkscape::XML::Node * _node;
sigc::signal<void> * _changeSignal;
public:
- /** \brief Build a string preference for the given parameter
- \param pref Where to put the radiobutton's string when it is selected.
- */
+ /**
+ * Build a string preference for the given parameter.
+ * @param pref Where to put the radiobutton's string when it is selected.
+ */
ParamRadioButtonWdg ( Gtk::RadioButtonGroup& group, const Glib::ustring& label,
ParamRadioButton * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal ) :
Gtk::RadioButton(group, label), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) {
@@ -222,13 +228,13 @@ public:
void changed (void);
};
-/** \brief Respond to the selected radiobutton changing
-
- This function responds to the radiobutton selection changing by grabbing the value
- from the text box and putting it in the parameter.
-*/
-void
-ParamRadioButtonWdg::changed (void)
+/**
+ * Respond to the selected radiobutton changing.
+ *
+ * This function responds to the radiobutton selection changing by grabbing the value
+ * from the text box and putting it in the parameter.
+ */
+void ParamRadioButtonWdg::changed(void)
{
if (this->get_active()) {
Glib::ustring data = this->get_label();
@@ -264,19 +270,20 @@ protected:
};
/**
- \brief Creates a combobox widget for an enumeration parameter
-*/
-Gtk::Widget *
-ParamRadioButton::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
+ * Creates a combobox widget for an enumeration parameter.
+ */
+Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT, Gtk::ALIGN_TOP));
label->show();
- hbox->pack_start(*label, false, false);
+ hbox->pack_start(*label, false, false, _indent);
Gtk::ComboBoxText* cbt = 0;
bool comboSet = false;
diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h
index ea8440de2..957a5b9df 100644
--- a/src/extension/param/radiobutton.h
+++ b/src/extension/param/radiobutton.h
@@ -6,8 +6,9 @@
*/
/*
- * Author:
+ * Authors:
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2006-2007 Johan Engelen
*
@@ -17,13 +18,13 @@
#include <gtkmm/widget.h>
#include "xml/document.h"
-#include <extension/extension-forward.h>
#include "parameter.h"
namespace Inkscape {
namespace Extension {
+class Extension;
// \brief A class to represent a radiobutton parameter of an extension
@@ -44,10 +45,15 @@ public:
AppearanceMode mode);
virtual ~ParamRadioButton(void);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
- void string (std::string &string);
- 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);
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
+ const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
+
+ const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node);
private:
/** \brief Internal value. This should point to a string that has
@@ -55,7 +61,7 @@ private:
It is the value of the current selected string */
gchar * _value;
AppearanceMode _mode;
-
+ int _indent;
GSList * choices; /**< A table to store the choice strings */
}; /* class ParamRadioButton */
@@ -69,3 +75,13 @@ private:
#endif /* INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN */
+/*
+ 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index e32224332..13b8e326a 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -2,6 +2,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -22,32 +23,38 @@ namespace Inkscape {
namespace Extension {
-/** \brief Free the allocated data. */
+/** Free the allocated data. */
ParamString::~ParamString(void)
{
g_free(_value);
+ _value = 0;
}
-/** \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*/)
+/**
+ * A function to set the \c _value.
+ *
+ * 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().
+ *
+ * @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.
+ */
+const gchar * ParamString::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/)
{
- if (in == NULL) return NULL; /* Can't have NULL string */
+ if (in == NULL) {
+ return NULL; /* Can't have NULL string */
+ }
- if (_value != NULL)
+ if (_value != NULL) {
g_free(_value);
+ }
+
_value = g_strdup(in);
gchar * prefname = this->pref_name();
@@ -58,41 +65,44 @@ ParamString::set (const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node *
return _value;
}
-/** \brief Return the value as a string */
-void
-ParamString::string (std::string &string)
+void ParamString::string(std::string &string) const
{
- if (_value == NULL)
- return;
-
- string += _value;
- return;
+ if (_value) {
+ string += _value;
+ }
}
-/** \brief Initialize the object, to do that, copy the data. */
+/** 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, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL)
+ Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
+ _value(NULL), _indent(0)
{
const char * defaultval = NULL;
- if (sp_repr_children(xml) != NULL)
+ if (sp_repr_children(xml) != NULL) {
defaultval = sp_repr_children(xml)->content();
+ }
+
+ const char * indent = xml->attribute("indent");
+ if (indent != NULL) {
+ _indent = atoi(indent) * 12;
+ }
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
g_free(pref_name);
- if (!paramval.empty())
+ if (!paramval.empty()) {
defaultval = paramval.data();
- if (defaultval != NULL)
+ }
+ if (defaultval != NULL) {
_value = g_strdup(defaultval);
-
- _max_length = 0;
+ }
- return;
+ _max_length = 0;
}
-/** \brief A special type of Gtk::Entry to handle string parameteres */
+/** A special type of Gtk::Entry to handle string parameteres. */
class ParamStringEntry : public Gtk::Entry {
private:
ParamString * _pref;
@@ -100,14 +110,16 @@ private:
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.
- */
+ /**
+ * 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)
+ if (_pref->get(NULL, NULL) != NULL) {
this->set_text(Glib::ustring(_pref->get(NULL, NULL)));
+ }
this->set_max_length(_pref->getMaxLength()); //Set the max lenght - default zero means no maximum
this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text));
};
@@ -115,37 +127,37 @@ public:
};
-/** \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)
+/**
+ * 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)
+ * 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)
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) {
+ return NULL;
+ }
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);
+ hbox->pack_start(*label, false, false, _indent);
ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal);
textbox->show();
diff --git a/src/extension/param/string.h b/src/extension/param/string.h
index 10f45e5ac..8e7f093f7 100644
--- a/src/extension/param/string.h
+++ b/src/extension/param/string.h
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2007 Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl> *
+ * Jon A. Cruz <jon@joncruz.org>
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -23,22 +24,31 @@ private:
gchar * _value;
/** \brief Internal value. This indicates the maximum leght of the string. Zero meaning unlimited.
*/
+ int _indent;
gint _max_length;
public:
ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
virtual ~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 *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { 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);
- void string (std::string &string);
+
+ // Explicitly call superclass version to avoid method being hidden.
+ virtual void string(std::list <std::string> &list) const { return Parameter::string(list); }
+
+ virtual void string(std::string &string) const;
+
void setMaxLength(int maxLenght) { _max_length = maxLenght; }
int getMaxLength(void) { return _max_length; }
};
-} /* namespace Extension */
-} /* namespace Inkscape */
+} // namespace Extension
+} // namespace Inkscape
#endif /* INK_EXTENSION_PARAMSTRING_H_SEEN */
diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp
index 09ee9be0b..a3094d536 100644
--- a/src/extension/patheffect.cpp
+++ b/src/extension/patheffect.cpp
@@ -42,7 +42,7 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path)
return;
gchar ** patheffects = g_strsplit(patheffectlist, ";", 128);
- Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr();
+ Inkscape::XML::Node * defs = doc->getDefs()->getRepr();
for (int i = 0; patheffects[i] != NULL && i < 128; i++) {
gchar * patheffect = patheffects[i];
@@ -65,11 +65,8 @@ PathEffect::processPathEffects (SPDocument * doc, Inkscape::XML::Node * path)
Inkscape::Extension::PathEffect * peffect;
peffect = dynamic_cast<Inkscape::Extension::PathEffect *>(Inkscape::Extension::db.get(ext_id));
if (peffect != NULL) {
-
- continue;
+ peffect->processPath(doc, path, prefs);
}
-
- peffect->processPath(doc, path, prefs);
}
g_strfreev(patheffects);
diff --git a/src/extension/print.cpp b/src/extension/print.cpp
index ad8c4c38d..c37e9425c 100644
--- a/src/extension/print.cpp
+++ b/src/extension/print.cpp
@@ -15,35 +15,32 @@
namespace Inkscape {
namespace Extension {
-Print::Print (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp)
+Print::Print (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp)
+ : Extension(in_repr, in_imp)
+ , base(NULL)
+ , drawing(NULL)
+ , root(NULL)
+ , dkey(0)
{
- base = NULL;
- arena = NULL;
- root = NULL;
- dkey = 0;
-
- return;
}
-Print::~Print (void)
-{
- return;
-}
+Print::~Print ()
+{}
bool
-Print::check (void)
+Print::check ()
{
- return Extension::check();
+ return Extension::check();
}
unsigned int
-Print::setup (void)
+Print::setup ()
{
return imp->setup(this);
}
unsigned int
-Print::set_preview (void)
+Print::set_preview ()
{
return imp->set_preview(this);
}
@@ -55,67 +52,67 @@ Print::begin (SPDocument *doc)
}
unsigned int
-Print::finish (void)
+Print::finish ()
{
return imp->finish(this);
}
unsigned int
-Print::bind (const Geom::Affine *transform, float opacity)
+Print::bind (const Geom::Affine &transform, float opacity)
{
return imp->bind (this, transform, opacity);
}
unsigned int
-Print::release (void)
+Print::release ()
{
return imp->release(this);
}
unsigned int
-Print::comment (const char * comment)
+Print::comment (char const *comment)
{
- return imp->comment(this,comment);
+ return imp->comment(this, comment);
}
unsigned int
-Print::fill (Geom::PathVector const &pathv, const Geom::Affine *ctm, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+Print::fill (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
return imp->fill (this, pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
-Print::stroke (Geom::PathVector const &pathv, const Geom::Affine *transform, const SPStyle *style,
- const NRRect *pbox, const NRRect *dbox, const NRRect *bbox)
+Print::stroke (Geom::PathVector const &pathv, Geom::Affine const &ctm, SPStyle const *style,
+ Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox)
{
- return imp->stroke (this, pathv, transform, style, pbox, dbox, bbox);
+ return imp->stroke (this, pathv, ctm, style, pbox, dbox, bbox);
}
unsigned int
Print::image (unsigned char *px, unsigned int w, unsigned int h, unsigned int rs,
- const Geom::Affine *transform, const SPStyle *style)
+ const Geom::Affine &transform, const SPStyle *style)
{
return imp->image (this, px, w, h, rs, transform, style);
}
unsigned int
-Print::text (const char* text, Geom::Point p, const SPStyle* style)
+Print::text (char const *text, Geom::Point const &p, SPStyle const *style)
{
return imp->text (this, text, p, style);
}
bool
-Print::textToPath (void)
+Print::textToPath ()
{
- return imp->textToPath(this);
+ return imp->textToPath(this);
}
//whether embed font in print output (EPS especially)
bool
-Print::fontEmbedded (void)
+Print::fontEmbedded ()
{
- return imp->fontEmbedded(this);
+ return imp->fontEmbedded(this);
}
} } /* namespace Inkscape, Extension */
diff --git a/src/extension/print.h b/src/extension/print.h
index d5218aed8..c1afe59b3 100644
--- a/src/extension/print.h
+++ b/src/extension/print.h
@@ -13,19 +13,22 @@
#include "extension.h"
-#include "display/nr-arena-forward.h"
-#include "forward.h"
#include "sp-item.h"
+
namespace Inkscape {
+
+class Drawing;
+class DrawingItem;
+
namespace Extension {
class Print : public Extension {
public: /* TODO: These are public for the short term, but this should be fixed */
- SPItem *base; /**< TODO: Document these */
- NRArena *arena; /**< TODO: Document these */
- NRArenaItem *root; /**< TODO: Document these */
- unsigned int dkey; /**< TODO: Document these */
+ SPItem *base;
+ Inkscape::Drawing *drawing;
+ Inkscape::DrawingItem *root;
+ unsigned int dkey;
public:
Print (Inkscape::XML::Node * in_repr,
@@ -41,30 +44,30 @@ public:
unsigned int finish (void);
/* Rendering methods */
- unsigned int bind (Geom::Affine const *transform,
+ unsigned int bind (Geom::Affine const &transform,
float opacity);
unsigned int release (void);
unsigned int comment (const char * comment);
unsigned int fill (Geom::PathVector const &pathv,
- Geom::Affine const *ctm,
+ Geom::Affine const &ctm,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
unsigned int stroke (Geom::PathVector const &pathv,
- Geom::Affine const *transform,
+ Geom::Affine const &transform,
SPStyle const *style,
- NRRect const *pbox,
- NRRect const *dbox,
- NRRect const *bbox);
+ Geom::OptRect const &pbox,
+ Geom::OptRect const &dbox,
+ Geom::OptRect const &bbox);
unsigned int image (unsigned char *px,
unsigned int w,
unsigned int h,
unsigned int rs,
- Geom::Affine const *transform,
+ Geom::Affine const &transform,
SPStyle const *style);
unsigned int text (char const *text,
- Geom::Point p,
+ Geom::Point const &p,
SPStyle const *style);
bool textToPath (void);
bool fontEmbedded (void);
diff --git a/src/extension/script/CMakeLists.txt b/src/extension/script/CMakeLists.txt
deleted file mode 100644
index 693948508..000000000
--- a/src/extension/script/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-SET(extension_script_SRC
-InkscapeScript.cpp
-)
diff --git a/src/extension/script/InkscapeScript.cpp b/src/extension/script/InkscapeScript.cpp
index ec9b5a8f9..9f8ebfbbb 100644
--- a/src/extension/script/InkscapeScript.cpp
+++ b/src/extension/script/InkscapeScript.cpp
@@ -1,4 +1,4 @@
-/**
+/*
* This is a simple mechanism to bind Inkscape to Java, and thence
* to all of the nice things that can be layered upon that.
*
diff --git a/src/extension/script/InkscapeScript.h b/src/extension/script/InkscapeScript.h
index c4a59e1e2..2ebeb1b19 100644
--- a/src/extension/script/InkscapeScript.h
+++ b/src/extension/script/InkscapeScript.h
@@ -1,9 +1,7 @@
-#ifndef __INKSCAPE_SCRIPT_H__
-#define __INKSCAPE_SCRIPT_H__
+#ifndef SEEN_INKSCAPE_SCRIPT_H
+#define SEEN_INKSCAPE_SCRIPT_H
-/**
- * Inkscape Scripting container
- *
+/*
* Authors:
* Bob Jamison <rjamison@titan.com>
*
@@ -26,7 +24,8 @@ namespace Script
/**
- * This class is used to run scripts, either from a file or buffer
+ * Inkscape Scripting container.
+ * This class is used to run scripts, either from a file or buffer.
*/
class InkscapeScript
{
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index cf58f2733..b3b64ca7d 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -35,6 +35,8 @@
#include "implementation/xslt.h"
#include "xml/rebase-hrefs.h"
#include "io/sys.h"
+#include "inkscape.h"
+
/* #include "implementation/plugin.h" */
namespace Inkscape {
@@ -64,8 +66,7 @@ static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementatio
*
* Lastly, the open function is called in the module itself.
*/
-SPDocument *
-open(Extension *key, gchar const *filename)
+SPDocument *open(Extension *key, gchar const *filename)
{
Input *imod = NULL;
if (key == NULL) {
@@ -93,8 +94,9 @@ open(Extension *key, gchar const *filename)
throw Input::open_failed();
}
- if (!imod->prefs(filename))
+ if (!imod->prefs(filename)) {
return NULL;
+ }
SPDocument *doc = imod->open(filename);
if (!doc) {
@@ -102,11 +104,11 @@ open(Extension *key, gchar const *filename)
}
if (last_chance_svg) {
- /* We can't call sp_ui_error_dialog because we may be
- running from the console, in which case calling sp_ui
- routines will cause a segfault. See bug 1000350 - bryce */
- // sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
- g_warning(_("Format autodetect failed. The file is being opened as SVG."));
+ if ( inkscape_use_gui() ) {
+ sp_ui_error_dialog(_("Format autodetect failed. The file is being opened as SVG."));
+ } else {
+ g_warning(_("Format autodetect failed. The file is being opened as SVG."));
+ }
}
/* This kinda overkill as most of these are already set, but I want
@@ -588,10 +590,11 @@ Glib::ustring
get_file_save_path (SPDocument *doc, FileSaveMethod method) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring path;
+ bool use_current_dir = true;
switch (method) {
case FILE_SAVE_METHOD_SAVE_AS:
{
- bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true);
+ use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true);
if (doc->getURI() && use_current_dir) {
path = Glib::path_get_dirname(doc->getURI());
} else {
@@ -603,7 +606,12 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
path = prefs->getString("/dialogs/save_as/path");
break;
case FILE_SAVE_METHOD_SAVE_COPY:
- path = prefs->getString("/dialogs/save_copy/path");
+ use_current_dir = prefs->getBool("/dialogs/save_copy/use_current_dir", prefs->getBool("/dialogs/save_as/use_current_dir", true));
+ if (doc->getURI() && use_current_dir) {
+ path = Glib::path_get_dirname(doc->getURI());
+ } else {
+ path = prefs->getString("/dialogs/save_copy/path");
+ }
break;
case FILE_SAVE_METHOD_INKSCAPE_SVG:
if (doc->getURI()) {
diff --git a/src/extension/system.h b/src/extension/system.h
index b6740e109..716539de1 100644
--- a/src/extension/system.h
+++ b/src/extension/system.h
@@ -21,6 +21,8 @@
namespace Inkscape {
namespace Extension {
+class Print;
+
/**
* Used to distinguish between the various invocations of the save dialogs (and thus to determine
* the file type and save path offered in the dialog)
diff --git a/src/extension/timer.h b/src/extension/timer.h
index 33b9829e9..b257c770a 100644
--- a/src/extension/timer.h
+++ b/src/extension/timer.h
@@ -16,11 +16,12 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <glibmm/timeval.h>
-#include "extension-forward.h"
namespace Inkscape {
namespace Extension {
+class Extension;
+
class ExpirationTimer {
/** \brief Circularly linked list of all timers */
static ExpirationTimer * timer_list;