summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-12-15 16:19:28 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-12-15 16:19:28 +0000
commit70201e92aa1e700d49279871f2b84082750b8ed8 (patch)
tree1886fcdf8ad20d73b92bf4f4bfd3ab1406ba4c66 /src/extension
parentFix mask luminance calculation, so the coeffs add up to 1 (diff)
parentWin32 post-GSoC fixups. (diff)
downloadinkscape-70201e92aa1e700d49279871f2b84082750b8ed8.tar.gz
inkscape-70201e92aa1e700d49279871f2b84082750b8ed8.zip
Merge from trunk (again)
(bzr r9508.1.72)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dbus/application-interface.cpp2
-rw-r--r--src/extension/dbus/document-interface.cpp9
-rw-r--r--src/extension/effect.cpp3
-rw-r--r--src/extension/execution-env.cpp5
-rw-r--r--src/extension/extension.cpp74
-rw-r--r--src/extension/extension.h7
-rw-r--r--src/extension/implementation/script.cpp6
-rw-r--r--src/extension/implementation/xslt.cpp9
-rw-r--r--src/extension/internal/bluredge.cpp2
-rw-r--r--src/extension/internal/cairo-png-out.cpp12
-rw-r--r--src/extension/internal/cairo-ps-out.cpp12
-rw-r--r--src/extension/internal/cairo-ps-out.h2
-rw-r--r--src/extension/internal/cairo-render-context.cpp48
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp15
-rw-r--r--src/extension/internal/cairo-renderer.cpp27
-rw-r--r--src/extension/internal/cairo-renderer.h3
-rw-r--r--src/extension/internal/emf-win32-inout.cpp14
-rw-r--r--src/extension/internal/emf-win32-print.cpp12
-rw-r--r--src/extension/internal/filter/color.h467
-rw-r--r--src/extension/internal/filter/experimental.h367
-rw-r--r--src/extension/internal/filter/filter-all.cpp23
-rw-r--r--src/extension/internal/filter/filter.cpp2
-rw-r--r--src/extension/internal/filter/morphology.h107
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp12
-rw-r--r--src/extension/internal/gimpgrad.cpp3
-rw-r--r--src/extension/internal/grid.cpp11
-rw-r--r--src/extension/internal/javafx-out.cpp5
-rw-r--r--src/extension/internal/latex-pstricks-out.cpp14
-rw-r--r--src/extension/internal/latex-pstricks.cpp11
-rw-r--r--src/extension/internal/latex-text-renderer.cpp23
-rw-r--r--src/extension/internal/odf.cpp11
-rw-r--r--src/extension/internal/odf.h3
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp3
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp9
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp10
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp6
-rw-r--r--src/extension/internal/pov-out.cpp3
-rw-r--r--src/extension/internal/svg.cpp14
-rw-r--r--src/extension/internal/win32.cpp7
-rw-r--r--src/extension/internal/wpg-input.cpp3
-rw-r--r--src/extension/param/notebook.cpp40
-rw-r--r--src/extension/param/notebook.h2
-rw-r--r--src/extension/param/parameter.cpp15
-rw-r--r--src/extension/param/parameter.h3
-rw-r--r--src/extension/print.h3
-rw-r--r--src/extension/system.cpp40
46 files changed, 1261 insertions, 218 deletions
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index b183be93c..a652b7c96 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -123,7 +123,7 @@ application_interface_document_close_all (ApplicationInterface *object,
SPDocument *doc = sp_desktop_document(desktop);
g_assert(doc != NULL);
- Inkscape::XML::Node *repr = sp_document_repr_root(doc);
+ Inkscape::XML::Node *repr = doc->getReprRoot();
g_assert(repr != NULL);
*/
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index b8b0c2ade..836ad3397 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -28,7 +28,7 @@
#include "sp-object.h"
-#include "document.h" // sp_document_repr_doc
+#include "document.h" // getReprDoc()
#include "desktop-style.h" //sp_desktop_get_style
@@ -189,7 +189,7 @@ Inkscape::XML::Node *
dbus_create_node (SPDesktop *desk, const gchar *type)
{
SPDocument * doc = sp_desktop_document (desk);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
return xml_doc->createElement(type);
}
@@ -517,11 +517,10 @@ 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 = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *newNode = xml_doc->createElement(type);
diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp
index 9a22c07b7..51aa42da6 100644
--- a/src/extension/effect.cpp
+++ b/src/extension/effect.cpp
@@ -1,6 +1,7 @@
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Abhishek Sharma
*
* Copyright (C) 2002-2007 Authors
*
@@ -258,7 +259,7 @@ Effect::prefs (Inkscape::UI::View::View * doc)
This function first insures that the extension is loaded, and if not,
loads it. It then calls the implemention to do the actual work. It
also resets the last effect pointer to be this effect. Finally, it
- executes a \c sp_document_done to commit the changes to the undo
+ executes a \c SPDocumentUndo::done to commit the changes to the undo
stack.
*/
void
diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp
index 7ed389195..f9e099c26 100644
--- a/src/extension/execution-env.cpp
+++ b/src/extension/execution-env.cpp
@@ -1,6 +1,7 @@
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Abhishek Sharma
*
* Copyright (C) 2007-2008 Authors
*
@@ -162,14 +163,14 @@ ExecutionEnv::cancel (void) {
void
ExecutionEnv::undo (void) {
- sp_document_cancel(_doc->doc());
+ DocumentUndo::cancel(_doc->doc());
reselect();
return;
}
void
ExecutionEnv::commit (void) {
- sp_document_done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name()));
+ DocumentUndo::done(_doc->doc(), SP_VERB_NONE, _(_effect->get_name()));
Effect::set_last_effect(_effect);
_effect->get_imp()->commitDocument();
killDocCache();
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index caed62735..e67a4b95f 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -44,7 +44,7 @@ namespace Extension {
std::vector<const gchar *> Extension::search_path;
std::ofstream Extension::error_file;
-Parameter * param_shared (const gchar * name, GSList * list);
+Parameter * get_param (const gchar * name);
/**
\return none
@@ -372,45 +372,45 @@ Extension::deactivated (void)
\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
- \param list The list to look 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. It is done as an inline so that it will be
- optimized into a 'jump' by the compiler.
+ 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 (I'll spoil the ending and
- tell you that this function is called recursively). If the list
+ or because all of them have been checked. If the list
is NULL then the 'param_not_exist' exception is thrown.
-
- Otherwise, the function looks at the current param_t that the element
- list points to. If the name of that param_t matches the passed in
- name then that param_t is returned. Otherwise, this function is
- called again with g_slist_next as a parameter.
*/
Parameter *
-param_shared (const gchar * name, GSList * list)
+Extension::get_param (const gchar * name)
{
- Parameter * output;
-
if (name == NULL) {
throw Extension::param_not_exist();
}
- if (list == NULL) {
+ if (this->parameters == NULL) {
+ // the list of parameters is empty
throw Extension::param_not_exist();
}
- output = static_cast<Parameter *>(list->data);
- if (!strcmp(output->name(), name)) {
- return output;
+ for (GSList * list = this->parameters; list != NULL; list =
+g_slist_next(list)) {
+ Parameter * param = static_cast<Parameter*>(list->data);
+ if (!strcmp(param->name(), name)) {
+ return param;
+ } else {
+ Parameter * subparam = param->get_param(name);
+ if (subparam) {
+ return subparam;
+ }
+ }
}
- return param_shared(name, g_slist_next(list));
+ // if execution reaches here, no parameter matching 'name' was found
+ throw Extension::param_not_exist();
}
/**
@@ -428,22 +428,21 @@ const gchar *
Extension::get_param_string (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
Parameter * param;
-
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->get_string(doc, node);
}
const gchar *
Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
- Parameter* param = param_shared(name, parameters);
+ Parameter* param = get_param(name);
return param->get_enum(doc, node);
}
-
-gchar const *Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node)
+gchar const *
+Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node)
{
- Parameter* param = param_shared(name, parameters);
+ Parameter* param = get_param(name);
return param->get_optiongroup(doc, node);
}
@@ -463,8 +462,7 @@ bool
Extension::get_param_bool (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
Parameter * param;
-
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->get_bool(doc, node);
}
@@ -483,8 +481,7 @@ int
Extension::get_param_int (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
Parameter * param;
-
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->get_int(doc, node);
}
@@ -503,7 +500,7 @@ float
Extension::get_param_float (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
Parameter * param;
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->get_float(doc, node);
}
@@ -521,7 +518,7 @@ Extension::get_param_float (const gchar * name, const SPDocument * doc, const In
guint32
Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node)
{
- Parameter* param = param_shared(name, parameters);
+ Parameter* param = get_param(name);
return param->get_color(doc, node);
}
@@ -541,7 +538,7 @@ bool
Extension::set_param_bool (const gchar * name, bool value, SPDocument * doc, Inkscape::XML::Node * node)
{
Parameter * param;
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->set_bool(value, doc, node);
}
@@ -561,7 +558,7 @@ int
Extension::set_param_int (const gchar * name, int value, SPDocument * doc, Inkscape::XML::Node * node)
{
Parameter * param;
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->set_int(value, doc, node);
}
@@ -581,7 +578,7 @@ float
Extension::set_param_float (const gchar * name, float value, SPDocument * doc, Inkscape::XML::Node * node)
{
Parameter * param;
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->set_float(value, doc, node);
}
@@ -601,13 +598,14 @@ const gchar *
Extension::set_param_string (const gchar * name, const gchar * value, SPDocument * doc, Inkscape::XML::Node * node)
{
Parameter * param;
- param = param_shared(name, parameters);
+ param = get_param(name);
return param->set_string(value, doc, node);
}
-gchar const * Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node)
+gchar const *
+Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node)
{
- Parameter * param = param_shared(name, parameters);
+ Parameter * param = get_param(name);
return param->set_optiongroup(value, doc, node);
}
@@ -627,7 +625,7 @@ gchar const * Extension::set_param_optiongroup(gchar const * name, gchar const *
guint32
Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, Inkscape::XML::Node * node)
{
- Parameter* param = param_shared(name, parameters);
+ Parameter* param = get_param(name);
return param->set_color(color, doc, node);
}
diff --git a/src/extension/extension.h b/src/extension/extension.h
index c71ae59b4..936d2a907 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -169,10 +169,9 @@ public:
private:
void make_param (Inkscape::XML::Node * paramrepr);
-#if 0
- inline param_t * param_shared (const gchar * name,
- GSList * list);
-#endif
+
+ Parameter * get_param (const gchar * name);
+
public:
bool get_param_bool (const gchar * name,
const SPDocument * doc = NULL,
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index 04c7c15a6..bc143fd14 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -6,6 +6,7 @@
* Bryce Harrington <bryce@osdl.org>
* Ted Gould <ted@gould.cx>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2002-2005,2007 Authors
*
@@ -532,9 +533,8 @@ SPDocument *Script::open(Inkscape::Extension::Input *module,
} // data_read
if (mydoc != NULL) {
- g_free(mydoc->base);
- mydoc->base = NULL;
- sp_document_change_uri_and_hrefs(mydoc, filenameArg);
+ mydoc->setBase(0);
+ mydoc->changeUriAndHrefs(filenameArg);
}
// make sure we don't leak file descriptors from g_file_open_tmp
diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp
index 2ab821e44..c929ba19a 100644
--- a/src/extension/implementation/xslt.cpp
+++ b/src/extension/implementation/xslt.cpp
@@ -4,6 +4,8 @@
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2007 Authors
*
@@ -174,7 +176,7 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename)
}
g_free(s);
- SPDocument * doc = sp_document_create(rdoc, filename, base, name, true);
+ SPDocument * doc = SPDocument::createDoc(rdoc, filename, base, name, true);
g_free(base); g_free(name);
@@ -189,8 +191,7 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
g_return_if_fail(doc != NULL);
g_return_if_fail(filename != NULL);
- Inkscape::XML::Node *repr = NULL;
- repr = sp_document_repr_root (doc);
+ Inkscape::XML::Node *repr = doc->getReprRoot();
std::string tempfilename_out;
int tempfd_out = 0;
@@ -202,7 +203,7 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
}
if (!sp_repr_save_rebased_file(repr->document(), tempfilename_out.c_str(), SP_SVG_NS_URI,
- doc->base, filename)) {
+ doc->getBase(), filename)) {
throw Inkscape::Extension::Output::save_failed();
}
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index a82c7ba77..ba6b8383c 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -72,7 +72,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
SPItem * spitem = *item;
std::vector<Inkscape::XML::Node *> new_items(steps);
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node * new_group = xml_doc->createElement("svg:g");
(SP_OBJECT_REPR(spitem)->parent())->appendChild(new_group);
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
index c81fdd029..eb26fc581 100644
--- a/src/extension/internal/cairo-png-out.cpp
+++ b/src/extension/internal/cairo-png-out.cpp
@@ -5,6 +5,8 @@
* Authors:
* Ted Gould <ted@gould.cx>
* Ulf Erikson <ulferikson@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
*
@@ -53,14 +55,14 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
CairoRenderer *renderer;
CairoRenderContext *ctx;
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
/* Start */
/* Create new arena */
- SPItem *base = SP_ITEM(sp_document_root(doc));
+ SPItem *base = SP_ITEM(doc->getRoot());
NRArena *arena = NRArena::create();
- unsigned dkey = sp_item_display_key_new(1);
- NRArenaItem *root = sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ unsigned dkey = SPItem::display_key_new(1);
+ NRArenaItem *root = base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
renderer = new CairoRenderer();
@@ -76,7 +78,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
renderer->destroyContext(ctx);
/* Release arena */
- sp_item_invoke_hide(base, dkey);
+ base->invoke_hide(dkey);
nr_object_unref((NRObject *) arena);
/* end */
delete renderer;
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index d9fd51ffd..07312aab1 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -6,6 +6,8 @@
* Ted Gould <ted@gould.cx>
* Ulf Erikson <ulferikson@users.sf.net>
* Adib Taraben <theAdib@yahoo.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
*
@@ -65,7 +67,7 @@ static bool
ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level, bool texttopath, bool omittext,
bool filtertobitmap, int resolution, const gchar * const exportId, bool exportDrawing, bool exportCanvas, bool eps = false)
{
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
SPItem *base = NULL;
@@ -77,7 +79,7 @@ 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(sp_document_root(doc));
+ base = SP_ITEM(doc->getRoot());
pageBoundingBox = !exportDrawing;
}
@@ -86,8 +88,8 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
/* Create new arena */
NRArena *arena = NRArena::create();
- unsigned dkey = sp_item_display_key_new(1);
- sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ unsigned dkey = SPItem::display_key_new(1);
+ base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
@@ -110,7 +112,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
}
/* Release arena */
- sp_item_invoke_hide(base, dkey);
+ base->invoke_hide(dkey);
nr_object_unref((NRObject *) arena);
renderer->destroyContext(ctx);
diff --git a/src/extension/internal/cairo-ps-out.h b/src/extension/internal/cairo-ps-out.h
index 368d827b1..7eda3c510 100644
--- a/src/extension/internal/cairo-ps-out.h
+++ b/src/extension/internal/cairo-ps-out.h
@@ -6,6 +6,7 @@
* Ted Gould <ted@gould.cx>
* Ulf Erikson <ulferikson@users.sf.net>
* Adib Taraben <theAdib@yahoo.com>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2006 Authors
*
@@ -16,6 +17,7 @@
#define EXTENSION_INTERNAL_CAIRO_PS_OUT_H
#include "extension/implementation/implementation.h"
+#include "sp-item.h"
#ifdef HAVE_CAIRO_PDF
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index a2a868feb..52e10f7a4 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -1,11 +1,11 @@
-#define __SP_CAIRO_RENDER_CONTEXT_C__
-
/** \file
* Rendering with Cairo.
*/
/*
* Author:
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Miklos Erdelyi
*
@@ -670,6 +670,11 @@ CairoRenderContext::popLayer(void)
}
TRACE(("mask surface: %f x %f at %i dpi\n", surface_width, surface_height, _dpi ));
+ // Mask should start black, but it is created white.
+ cairo_set_source_rgba(mask_ctx->_cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_rectangle(mask_ctx->_cr, 0, 0, surface_width, surface_height);
+ cairo_fill(mask_ctx->_cr);
+
// set rendering mode to normal
setRenderMode(RENDER_MODE_NORMAL);
@@ -700,19 +705,27 @@ CairoRenderContext::popLayer(void)
int stride = cairo_image_surface_get_stride(mask_image);
unsigned char *pixels = cairo_image_surface_get_data(mask_image);
- // premultiply with opacity
// In SVG, the rgb channels as well as the alpha channel is used in masking.
// In Cairo, only the alpha channel is used thus requiring this conversion.
+ // SVG specifies that RGB be converted to alpha using luminance-to-alpha.
+ // Notes: This calculation assumes linear RGB values. VERIFY COLOR SPACE!
+ // The incoming pixel values already include alpha, fill-opacity, etc.,
+ // however, opacity must still be applied.
TRACE(("premul w/ %f\n", opacity));
- guint8 int_opacity = (guint8)(255 * opacity);
+ const float coeff_r = 0.2125 / 255.0;
+ const float coeff_g = 0.7154 / 255.0;
+ const float coeff_b = 0.0721 / 255.0;
for (int row = 0 ; row < height; row++) {
unsigned char *row_data = pixels + (row * stride);
for (int i = 0 ; i < width; i++) {
guint32 *pixel = (guint32 *)row_data + i;
- *pixel = ((((*pixel & 0x00ff0000) >> 16) * 13817 +
- ((*pixel & 0x0000ff00) >> 8) * 46518 +
- ((*pixel & 0x000000ff) ) * 4688) *
- int_opacity);
+ float lum_alpha = (((*pixel & 0x00ff0000) >> 16) * coeff_r +
+ ((*pixel & 0x0000ff00) >> 8) * coeff_g +
+ ((*pixel & 0x000000ff) ) * coeff_b );
+ // lum_alpha can be slightly greater than 1 due to rounding errors...
+ // but this should be OK since it doesn't matter what the lower
+ // six hexadecimal numbers of *pixel are.
+ *pixel = (guint32)(0xff000000 * lum_alpha * opacity);
}
}
@@ -970,14 +983,15 @@ CairoRenderContext::popState(void)
g_assert( g_slist_length(_state_stack) > 0 );
}
-static bool pattern_hasItemChildren (SPPattern *pat)
+static bool pattern_hasItemChildren(SPPattern *pat)
{
- for (SPObject *child = sp_object_first_child(SP_OBJECT(pat)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ bool hasItems = false;
+ for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) {
if (SP_IS_ITEM (child)) {
- return true;
+ hasItems = true;
}
}
- return false;
+ return hasItems;
}
cairo_pattern_t*
@@ -1073,14 +1087,14 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// create arena and group
NRArena *arena = NRArena::create();
- unsigned dkey = sp_item_display_key_new(1);
+ unsigned dkey = SPItem::display_key_new(1);
// show items and render them
for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
- for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM (child)) {
- sp_item_invoke_show (SP_ITEM (child), arena, dkey, SP_ITEM_REFERENCE_FLAGS);
+ SP_ITEM (child)->invoke_show (arena, dkey, SP_ITEM_REFERENCE_FLAGS);
_renderer->renderItem(pattern_ctx, SP_ITEM (child));
}
}
@@ -1107,9 +1121,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver
// hide all items
for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) {
if (pat_i && SP_IS_OBJECT (pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children
- for (SPObject *child = sp_object_first_child(SP_OBJECT(pat_i)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM (child)) {
- sp_item_invoke_hide (SP_ITEM (child), dkey);
+ SP_ITEM (child)->invoke_hide (dkey);
}
}
break; // do not go further up the chain if children are found
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 32df1193b..8406e2a3b 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -6,6 +6,8 @@
* Ted Gould <ted@gould.cx>
* Ulf Erikson <ulferikson@users.sf.net>
* Johan Engelen <goejendaagh@zonnet.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2010 Authors
*
@@ -55,7 +57,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
bool texttopath, bool omittext, bool filtertobitmap, int resolution,
const gchar * const exportId, bool exportDrawing, bool exportCanvas)
{
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
/* Start */
@@ -69,18 +71,19 @@ 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(sp_document_root(doc));
+ base = SP_ITEM(doc->getRoot());
pageBoundingBox = !exportDrawing;
}
- if (!base)
+ if (!base) {
return false;
+ }
/* Create new arena */
NRArena *arena = NRArena::create();
nr_arena_set_renderoffscreen (arena);
- unsigned dkey = sp_item_display_key_new(1);
- sp_item_invoke_show(base, arena, dkey, SP_ITEM_SHOW_DISPLAY);
+ unsigned dkey = SPItem::display_key_new(1);
+ base->invoke_show(arena, dkey, SP_ITEM_SHOW_DISPLAY);
/* Create renderer and context */
CairoRenderer *renderer = new CairoRenderer();
@@ -102,7 +105,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
}
/* Release arena */
- sp_item_invoke_hide(base, dkey);
+ base->invoke_hide(dkey);
nr_object_unref((NRObject *) arena);
renderer->destroyContext(ctx);
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 988f61263..67f9354d8 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -1,11 +1,11 @@
-#define __SP_CAIRO_RENDERER_C__
-
/** \file
* Rendering with Cairo.
*/
/*
* Author:
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Miklos Erdelyi
*
@@ -186,7 +186,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx)
if (!shape->curve) return;
- sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
+ item->invoke_bbox( &pbox, Geom::identity(), TRUE);
SPStyle* style = SP_OBJECT_STYLE (item);
@@ -450,7 +450,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
// Get the bounding box of the selection in document coordinates.
Geom::OptRect bbox =
- item->getBounds(sp_item_i2d_affine(item), SPItem::RENDERING_BBOX);
+ item->getBounds(item->i2d_affine(), SPItem::RENDERING_BBOX);
if (!bbox) // no bbox, e.g. empty group
return;
@@ -481,7 +481,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx)
(Geom::Matrix)(Geom::Translate (shift_x, shift_y));
// ctx matrix already includes item transformation. We must substract.
- Geom::Matrix t_item = sp_item_i2d_affine (item);
+ Geom::Matrix t_item = item->i2d_affine ();
Geom::Matrix t = t_on_document * t_item.inverse();
// Do the export
@@ -603,16 +603,17 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
g_assert( ctx != NULL );
- if (!base)
- base = SP_ITEM(sp_document_root(doc));
+ if (!base) {
+ base = SP_ITEM(doc->getRoot());
+ }
NRRect d;
if (pageBoundingBox) {
d.x0 = d.y0 = 0;
- d.x1 = sp_document_width(doc);
- d.y1 = sp_document_height(doc);
+ d.x1 = doc->getWidth();
+ d.y1 = doc->getHeight();
} else {
- sp_item_invoke_bbox(base, &d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+ base->invoke_bbox( &d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
}
if (ctx->_vector_based_target) {
@@ -632,7 +633,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
if (ret && !pageBoundingBox)
{
- double high = sp_document_height(doc);
+ double high = doc->getHeight();
if (ctx->_vector_based_target)
high *= PT_PER_PX;
@@ -672,7 +673,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp)
TRACE(("BEGIN clip\n"));
SPObject *co = SP_OBJECT(cp);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
@@ -730,7 +731,7 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask)
TRACE(("BEGIN mask\n"));
SPObject *co = SP_OBJECT(mask);
- for (SPObject *child = sp_object_first_child(co) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) {
if (SP_IS_ITEM(child)) {
SPItem *item = SP_ITEM(child);
renderItem(ctx, item);
diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h
index f1a26a313..7fa7c7ff5 100644
--- a/src/extension/internal/cairo-renderer.h
+++ b/src/extension/internal/cairo-renderer.h
@@ -7,6 +7,7 @@
/*
* Authors:
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Miklos Erdelyi
*
@@ -23,7 +24,7 @@
//#include "libnrtype/font-instance.h"
#include "style.h"
-
+#include "sp-item.h"
#include <cairo.h>
class SPClipPath;
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index 07f697775..a1771de8d 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -3,6 +3,8 @@
*/
/* Authors:
* Ulf Erikson <ulferikson@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2008 Authors
*
@@ -87,7 +89,7 @@ emf_print_document_to_file(SPDocument *doc, gchar const *filename)
gchar *oldoutput;
unsigned int ret;
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
mod = Inkscape::Extension::get_print(PRINT_EMF_WIN32);
oldconst = mod->get_param_string("destination");
@@ -98,20 +100,20 @@ 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(sp_document_root(doc));
+ mod->base = SP_ITEM(doc->getRoot());
mod->arena = NRArena::create();
mod->dkey = sp_item_display_key_new(1);
- mod->root = sp_item_invoke_show(mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->root = mod->base->invoke_show(mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
/* Print document */
ret = mod->begin(doc);
if (ret) {
g_free(oldoutput);
throw Inkscape::Extension::Output::save_failed();
}
- sp_item_invoke_print(mod->base, &context);
+ mod->base->invoke_print(&context);
ret = mod->finish();
/* Release arena */
- sp_item_invoke_hide(mod->base, mod->dkey);
+ mod->base->invoke_hide(mod->dkey);
mod->base = NULL;
mod->root = NULL;
nr_object_unref((NRObject *) mod->arena);
@@ -2345,7 +2347,7 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
// std::cout << "SVG Output: " << std::endl << *(d.outsvg) << std::endl;
- SPDocument *doc = sp_document_new_from_mem(d.outsvg->c_str(), d.outsvg->length(), TRUE);
+ SPDocument *doc = SPDocument::createNewDocFromMem(d.outsvg->c_str(), d.outsvg->length(), TRUE);
delete d.outsvg;
delete d.path;
diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp
index bd42b0eb6..6be48e44c 100644
--- a/src/extension/internal/emf-win32-print.cpp
+++ b/src/extension/internal/emf-win32-print.cpp
@@ -3,6 +3,8 @@
*/
/* Authors:
* Ulf Erikson <ulferikson@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2009 Authors
*
@@ -135,8 +137,8 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
WCHAR *unicode_uri = (WCHAR *) unicode_fn;
// width and height in px
- _width = sp_document_width(doc);
- _height = sp_document_height(doc);
+ _width = doc->getWidth();
+ _height = doc->getHeight();
NRRect d;
bool pageBoundingBox;
@@ -146,8 +148,8 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
d.x1 = _width;
d.y1 = _height;
} else {
- SPItem* doc_item = SP_ITEM(sp_document_root(doc));
- sp_item_invoke_bbox(doc_item, &d, sp_item_i2d_affine(doc_item), TRUE);
+ SPItem* doc_item = SP_ITEM(doc->getRoot());
+ doc_item->invoke_bbox(&d, doc_item->i2d_affine(), TRUE);
}
d.x0 *= IN_PER_PX;
@@ -232,7 +234,7 @@ 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, sp_document_height(doc)));
+ m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
return 0;
}
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index 1a1644276..54312685c 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -7,6 +7,13 @@
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
+ * Color filters
+ * Colorize
+ * Duochrome
+ * Quadritone
+ * Solarize
+ * Tritone
+ *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
@@ -22,6 +29,122 @@ namespace Extension {
namespace Internal {
namespace Filter {
+/**
+ \brief Custom predefined Colorize filter.
+
+ Blend image or object with a flood color.
+
+ Filter's parameters:
+ * Harsh light (0.->10., default 0) -> composite1 (k1)
+ * Normal light (0.->10., default 1) -> composite2 (k2)
+ * Duotone (boolean, default false) -> colormatrix1 (values="0")
+ * Filtered greys (boolean, default false) -> colormatrix2 (values="0")
+ * Blend mode 1 (enum, default Multiply) -> blend1 (mode)
+ * Blend mode 2 (enum, default Screen) -> blend2 (mode)
+*/
+
+class Colorize : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Colorize ( ) : Filter() { };
+ virtual ~Colorize ( ) { 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_("Colorize, custom -EXP-") "</name>\n"
+ "<id>org.inkscape.effect.filter.Colorize</id>\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=\"duotone\" gui-text=\"" N_("Duotone") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"blend1\" gui-text=\"" N_("Blend1:") "\" type=\"enum\">\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"darken\">Darken</_item>\n"
+ "</param>\n"
+ "<param name=\"blend2\" gui-text=\"" N_("Blend2:") "\" type=\"enum\">\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"darken\">Darken</_item>\n"
+ "</param>\n"
+ "<param name=\"color\" gui-text=\"" N_("Color 1") "\" type=\"color\">-1639776001</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_("Blend image or object with a flood color") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Colorize());
+ };
+
+};
+
+gchar const *
+Colorize::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 hlight;
+ std::ostringstream nlight;
+ std::ostringstream duotone;
+ std::ostringstream blend1;
+ std::ostringstream blend2;
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ hlight << ext->get_param_float("hlight");
+ nlight << ext->get_param_float("nlight");
+ blend1 << ext->get_param_enum("blend1");
+ blend2 << ext->get_param_enum("blend2");
+ if (ext->get_param_bool("duotone"))
+ duotone << "0";
+ 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 -EXP-\">\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"
+ "<feBlend in=\"flood1\" in2=\"colormatrix1\" mode=\"%s\" result=\"blend1\" />\n"
+ "<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());
+
+ return _filter;
+}; /* Colorize filter */
+
+
+/**
+ \brief Custom predefined Duochrome filter.
+
+ Convert luminance values to a duochrome palette.
+
+ Filter's parameters:
+ * Fluorescence level (0.->2., default 0) -> composite4 (k2)
+ * Swap (enum, default "No swap") -> composite1, composite2 (operator)
+ * Color 1 (guint, default 1364325887) -> flood1 (flood-opacity, flood-color)
+ * Color 2 (guint, default -65281) -> flood2 (flood-opacity, flood-color)
+*/
+
class Duochrome : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
@@ -35,6 +158,8 @@ public:
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
"<name>" N_("Duochrome, custom -EXP-") "</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=\"swap\" gui-text=\"" N_("Swap:") "\" type=\"enum\">\n"
"<_item value=\"none\">No swap</_item>\n"
@@ -42,10 +167,14 @@ public:
"<_item value=\"color\">Color only</_item>\n"
"<_item value=\"alpha\">Alpha only</_item>\n"
"</param>\n"
- "<_param name=\"header1\" type=\"groupheader\">Color 1</_param>\n"
+ "</page>\n"
+ "<page name=\"co11tab\" _gui-text=\"Color 1\">\n"
"<param name=\"color1\" gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n"
- "<_param name=\"header2\" type=\"groupheader\">Color 2</_param>\n"
+ "</page>\n"
+ "<page name=\"co12tab\" _gui-text=\"Color 2\">\n"
"<param name=\"color2\" gui-text=\"" N_("Color 2") "\" type=\"color\">-65281</param>\n"
+ "</page>\n"
+ "</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -126,7 +255,341 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
"</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 Quadritone filter.
+
+ Replace hue by two colors.
+
+ Filter's parameters:
+ * Hue distribution (0->360, default 280) -> colormatrix1 (values)
+ * Colors (0->360, default 100) -> colormatrix3 (values)
+ * Blend mode 1 (enum, default Normal) -> blend1 (mode)
+ * Over-saturation (0.->1., default 0) -> composite1 (k2)
+ * Blend mode 2 (enum, default Normal) -> blend2 (mode)
+*/
+
+class Quadritone : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Quadritone ( ) : Filter() { };
+ virtual ~Quadritone ( ) { 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_("Quadritone fantasy, custom -EXP-") "</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=\"blend1\" gui-text=\"" N_("Blend1:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "</param>\n"
+ "<param name=\"sat\" gui-text=\"" N_("Over-saturation:") "\" type=\"float\" min=\"0\" max=\"1\">0</param>\n"
+ "<param name=\"blend2\" gui-text=\"" N_("Blend2:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"darken\">Darken</_item>\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_("Replace hue by two colors") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Quadritone());
+ };
+
};
+
+gchar const *
+Quadritone::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream dist;
+ std::ostringstream colors;
+ std::ostringstream blend1;
+ std::ostringstream sat;
+ std::ostringstream blend2;
+
+ dist << ext->get_param_int("dist");
+ colors << ext->get_param_int("colors");
+ blend1 << ext->get_param_enum("blend1");
+ sat << ext->get_param_float("sat");
+ 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 -EXP-\">\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"
+ "<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());
+
+ return _filter;
+}; /* Quadritone filter */
+
+
+/**
+ \brief Custom predefined Solarize filter.
+
+ Classic photographic solarization effect.
+
+ Filter's parameters:
+ * Type (enum, default "Solarize") ->
+ Solarize = blend1 (mode="darken"), blend2 (mode="screen")
+ Moonarize = blend1 (mode="lighten"), blend2 (mode="multiply") [No other access to the blend modes]
+ * Hue rotation (0->360, default 0) -> colormatrix1 (values)
+*/
+
+
+class Solarize : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Solarize ( ) : Filter() { };
+ virtual ~Solarize ( ) { 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_("Solarize, custom -EXP-") "</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=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
+ "<_item value=\"solarize\">Solarize</_item>\n"
+ "<_item value=\"moonarize\">Moonarize</_item>\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_("Classic photographic solarization effect") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Solarize());
+ };
+
+};
+
+gchar const *
+Solarize::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream rotate;
+ std::ostringstream blend1;
+ std::ostringstream blend2;
+
+ rotate << ext->get_param_int("rotate");
+ const gchar *type = ext->get_param_enum("type");
+ if((g_ascii_strcasecmp("solarize", type) == 0)) {
+ // Solarize
+ blend1 << "darken";
+ blend2 << "screen";
+ } else {
+ // Moonarize
+ blend1 << "lighten";
+ blend2 << "multiply";
+ }
+
+ _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 -EXP-\">\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());
+
+ return _filter;
+}; /* Solarize filter */
+
+
+/**
+ \brief Custom predefined Tritone filter.
+
+ Create a custom tritone palette with additional glow, blend modes and hue moving.
+
+ Filter's parameters:
+ * Option (enum, default Normal) ->
+ Normal = composite1 (in="qminp", in2="flood"), composite2 (in="p", in2="blend6"), blend6 (in2="qminpc")
+ Enhance hue = Normal + composite2 (in="SourceGraphic")
+ Radiation = Normal + blend6 (in2="SourceGraphic") composite2 (in="blend6", in2="qminpc")
+ 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 & 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].
+*/
+
+class Tritone : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Tritone ( ) : Filter() { };
+ virtual ~Tritone ( ) { 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_("Tritone, custom -EXP-") "</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\">Normal</_item>\n"
+ "<_item value=\"enhue\">Enhance hue</_item>\n"
+ "<_item value=\"rad\">Radiation</_item>\n"
+ "<_item value=\"htb\">Hue to background</_item>\n"
+ "</param>\n"
+ "<param name=\"globalblend\" gui-text=\"" N_("Global blend:") "\" type=\"enum\">\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"darken\">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=\"glowblend\" gui-text=\"" N_("Glow blend:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"darken\">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"
+ "</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=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">-73203457</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_("Create a custom tritone palette with additional glow, blend modes and hue moving") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Tritone());
+ };
+
+};
+
+gchar const *
+Tritone::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream dist;
+ std::ostringstream a;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+ std::ostringstream globalblend;
+ std::ostringstream glow;
+ std::ostringstream glowblend;
+ std::ostringstream llight;
+ std::ostringstream glight;
+ std::ostringstream c1in;
+ std::ostringstream c1in2;
+ std::ostringstream c2in;
+ std::ostringstream c2in2;
+ std::ostringstream b6in2;
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+ globalblend << ext->get_param_enum("globalblend");
+ dist << ext->get_param_int("dist");
+ glow << ext->get_param_float("glow");
+ glowblend << ext->get_param_enum("glowblend");
+ llight << ext->get_param_float("llight");
+ glight << ext->get_param_float("glight");
+
+ const gchar *type = ext->get_param_enum("type");
+ 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";
+ c1in2 << "flood";
+ c2in << "blend6";
+ c2in2 << "qminpc";
+ b6in2 << "SourceGraphic";
+ } else if((g_ascii_strcasecmp("htb", type) == 0)) {
+ // Hue to background
+ c1in << "qminp";
+ c1in2 << "BackgroundImage";
+ c2in << "p";
+ c2in2 << "blend6";
+ b6in2 << "qminpc";
+ } else {
+ // Normal
+ c1in << "qminp";
+ c1in2 << "flood";
+ c2in << "p";
+ c2in2 << "blend6";
+ b6in2 << "qminpc";
+ }
+
+ _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 -EXP-\">\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"
+ "<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"
+ "<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());
+
+ return _filter;
+}; /* Tritone filter */
+
}; /* namespace Filter */
}; /* namespace Internal */
}; /* namespace Extension */
diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h
index 15c97202e..a8879720b 100644
--- a/src/extension/internal/filter/experimental.h
+++ b/src/extension/internal/filter/experimental.h
@@ -7,6 +7,12 @@
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
+ * Experimental filters (no assigned menu)
+ * Chromolitho
+ * Drawing
+ * Posterize
+ * Test filter (should no be used...)
+ *
* Released under GNU GPL, read the file 'COPYING' for more information
*/
/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
@@ -22,6 +28,351 @@ namespace Extension {
namespace Internal {
namespace Filter {
+/**
+ \brief Custom predefined Chromolitho filter.
+
+ Chromo effect with customizable edge drawing and graininess
+
+ Filter's parameters:
+ * Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1")
+ * Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1")
+ * Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0]
+ * Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s]
+ * Expand white (0->5, default 1) -> component1 (tableValues) [0="0 1", 5="0 1 1 1 1 1 1"]
+ * Lightness (0->10, default 0) -> composite1 (k1)
+ * Saturation (0.->1., default 1.) -> colormatrix3 (values)
+ * Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020)
+ * 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 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)
+ * Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted]
+ * Grain color (boolean, default true) -> colormatrix2 (values)
+ * Grain blend (enum, default Normal) -> blend2 (mode)
+*/
+class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Chromolitho ( ) : Filter() { };
+ virtual ~Chromolitho ( ) { 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_("Chromolitho, custom -EXP-") "</name>\n"
+ "<id>org.inkscape.effect.filter.Chromolitho</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"optionstab\" _gui-text=\"Options\">\n"
+ "<param name=\"drawing\" gui-text=\"" N_("Drawing mode") "\" type=\"boolean\" >true</param>\n"
+ "<param name=\"dblend\" gui-text=\"" N_("Drawing blend:") "\" type=\"enum\">\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"darken\">Darken</_item>\n"
+ "</param>\n"
+ "<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=\"int\" 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\">20</param>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.01\" max=\"10\">1</param>\n"
+ "</page>\n"
+ "<page name=\"graintab\" _gui-text=\"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=\"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"
+ "<_item value=\"multiply\">Multiply</_item>\n"
+ "<_item value=\"screen\">Screen</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
+ "<_item value=\"darken\">Darken</_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_("Experimental") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Chromo effect with customizable edge drawing and graininess") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Chromolitho());
+ };
+};
+
+gchar const *
+Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream b1in;
+ std::ostringstream b2in;
+ std::ostringstream col3in;
+ std::ostringstream transf;
+ std::ostringstream light;
+ std::ostringstream saturation;
+ std::ostringstream noise;
+ std::ostringstream dblend;
+ std::ostringstream smooth;
+ std::ostringstream grain;
+ std::ostringstream grainxf;
+ std::ostringstream grainyf;
+ std::ostringstream grainc;
+ std::ostringstream grainv;
+ std::ostringstream gblend;
+ std::ostringstream grainexp;
+ std::ostringstream grainero;
+ std::ostringstream graincol;
+
+ if (ext->get_param_bool("drawing"))
+ b1in << "convolve1";
+ else
+ b1in << "composite1";
+
+ if (ext->get_param_bool("transparent"))
+ col3in << "colormatrix4";
+ else
+ col3in << "component1";
+ light << ext->get_param_int("light");
+ saturation << ext->get_param_float("saturation");
+ noise << (-1000 - ext->get_param_int("noise"));
+ dblend << ext->get_param_enum("dblend");
+ smooth << ext->get_param_float("smooth");
+
+ if (ext->get_param_bool("dented")) {
+ transf << "0 1 0 1";
+ } else {
+ transf << "0 1 1";
+ }
+ if (ext->get_param_bool("inverted"))
+ transf << " 0";
+
+ if (ext->get_param_bool("grain"))
+ b2in << "colormatrix2";
+ else
+ b2in << "blur1";
+ grainxf << (ext->get_param_float("grainxf") / 100);
+ grainyf << (ext->get_param_float("grainyf") / 100);
+ grainc << ext->get_param_int("grainc");
+ grainv << ext->get_param_int("grainv");
+ gblend << ext->get_param_enum("gblend");
+ grainexp << ext->get_param_float("grainexp");
+ grainero << (-ext->get_param_float("grainero"));
+ if (ext->get_param_bool("graincol"))
+ graincol << "1";
+ else
+ 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 -EXP-\">\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"
+ "<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 in=\"blend2\" type=\"saturate\" values=\"%s\" result=\"colormatrix3\" />\n"
+ "<feComponentTransfer in=\"colormatrix3\" stdDeviation=\"2\" result=\"component1\">\n"
+ "<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
+ "<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
+ "<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
+ "</feComponentTransfer>\n"
+ "<feColorMatrix 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=\"colormatrix4\" />\n"
+ "<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 15 0 \" result=\"colormatrix5\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
+ "</filter>\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str());
+
+ return _filter;
+}; /* Chromolitho filter */
+
+/**
+ \brief Custom predefined Drawing filter.
+
+ Convert images to duochrome drawings.
+
+ Filter's parameters:
+ * Simplification (0.01->10, default 0.7) -> blur1 (stdDeviation)
+ * Lightness (0->50, default 5) -> convolve (kernelMatrix, central value -1000->-1050, default -1005)
+ * Smoothness (0.01->10, default 0.7) -> blur2 (stdDeviation)
+ * Dilatation (3->100, default 6) -> colormatrix3 (n-1th value)
+
+ * Blur (0.01->10., default 1.) -> blur3 (stdDeviation)
+ * Blur spread (3->20, default 6) -> colormatrix5 (n-1th value)
+ * Blur erosion (-2->0, default -2) -> colormatrix5 (nth value)
+
+ * Stroke color (guint, default 205,0,0) -> flood2 (flood-opacity, flood-color)
+ * Image on stroke (boolean, default false) -> composite1 (in="flood2" true-> in="SourceGraphic")
+ * Image on stroke opacity (0.->1., default 1) -> composite3 (k3)
+ * Fill color (guint, default 255,203,0) -> flood3 (flood-opacity, flood-color)
+ * Image on fill (boolean, default false) -> composite2 (in="flood3" true-> in="SourceGraphic")
+ * Image on fill opacity (0.->1., default 1) -> composite3 (k2)
+*/
+
+class Drawing : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Drawing ( ) : Filter() { };
+ virtual ~Drawing ( ) { 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_("Drawing, custom -EXP-") "</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=\"simply\" gui-text=\"" N_("Simplification:") "\" type=\"float\" min=\"0.01\" max=\"10\">0.7</param>\n"
+ "<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"int\" min=\"0\" max=\"50\">5</param>\n"
+ "<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" min=\"0.01\" max=\"10\">0.7</param>\n"
+ "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"int\" min=\"3\" max=\"100\">6</param>\n"
+ "<_param name=\"blurheader\" type=\"groupheader\">Blur</_param>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Level:") "\" type=\"float\" min=\"0.01\" max=\"10\">1</param>\n"
+ "<param name=\"spread\" gui-text=\"" N_("Spread:") "\" type=\"int\" min=\"3\" max=\"20\">6</param>\n"
+ "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"int\" min=\"-2\" max=\"0\">-2</param>\n"
+ "</page>\n"
+ "<page name=\"co11tab\" _gui-text=\"Fill color\">\n"
+ "<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-3473153</param>\n"
+ "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"iofo\" gui-text=\"" N_("Image on fill opacity:") "\" type=\"float\" min=\"0\" max=\"1\">1</param>\n"
+ "</page>\n"
+ "<page name=\"co12tab\" _gui-text=\"Stroke color\">\n"
+ "<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">-855637761</param>\n"
+ "<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n"
+ "<param name=\"ioso\" gui-text=\"" N_("Image on stroke opacity:") "\" type=\"float\" 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_("Experimental") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Convert images to duochrome drawings") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Drawing());
+ };
+};
+
+gchar const *
+Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream simply;
+ std::ostringstream light;
+ std::ostringstream smooth;
+ std::ostringstream dilat;
+ std::ostringstream blur;
+ std::ostringstream spread;
+ std::ostringstream erosion;
+ std::ostringstream strokea;
+ std::ostringstream stroker;
+ std::ostringstream strokeg;
+ std::ostringstream strokeb;
+ std::ostringstream ios;
+ std::ostringstream ioso;
+ std::ostringstream filla;
+ std::ostringstream fillr;
+ std::ostringstream fillg;
+ std::ostringstream fillb;
+ std::ostringstream iof;
+ std::ostringstream iofo;
+
+ simply << ext->get_param_float("simply");
+ light << (-1000 - ext->get_param_int("light"));
+ smooth << ext->get_param_float("smooth");
+ dilat << ext->get_param_int("dilat");
+
+ blur << ext->get_param_float("blur");
+ spread << ext->get_param_int("spread");
+ erosion << ext->get_param_int("erosion");
+
+ guint32 fcolor = ext->get_param_color("fcolor");
+ fillr << ((fcolor >> 24) & 0xff);
+ fillg << ((fcolor >> 16) & 0xff);
+ fillb << ((fcolor >> 8) & 0xff);
+ filla << (fcolor & 0xff) / 255.0F;
+ if (ext->get_param_bool("iof"))
+ iof << "SourceGraphic";
+ else
+ iof << "flood3";
+ iofo << ext->get_param_float("iofo");
+
+ guint32 scolor = ext->get_param_color("scolor");
+ stroker << ((scolor >> 24) & 0xff);
+ strokeg << ((scolor >> 16) & 0xff);
+ strokeb << ((scolor >> 8) & 0xff);
+ strokea << (scolor & 0xff) / 255.0F;
+ if (ext->get_param_bool("ios"))
+ ios << "SourceGraphic";
+ else
+ ios << "flood2";
+ ioso << ext->get_param_float("ioso");
+
+ _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 -EXP-\">\n"
+ "<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feConvolveMatrix in=\"blur1\" order=\"3 3\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" divisor=\"1\" targetX=\"1\" targetY=\"1\" preserveAlpha=\"true\" bias=\"0\" stdDeviation=\"1\" result=\"convolve\" />\n"
+ "<feColorMatrix values=\"0 -100 0 0 1 0 -100 0 0 1 0 -100 0 0 1 0 0 0 1 0 \" result=\"colormatrix1\" />\n"
+ "<feColorMatrix in=\"colormatrix1\" 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=\"colormatrix2\" />\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 -2 \" result=\"colormatrix3\" />\n"
+ "<feFlood flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
+ "<feBlend in2=\"colormatrix3\" blend=\"normal\" mode=\"multiply\" result=\"blend1\" />\n"
+ "<feComponentTransfer in=\"blend1\" result=\"component1\">\n"
+ "<feFuncR tableValues=\"0 1 1\" type=\"discrete\" />\n"
+ "<feFuncG tableValues=\"0 1 1\" type=\"discrete\" />\n"
+ "<feFuncB tableValues=\"0 1 1\" type=\"discrete\" />\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 \" result=\"colormatrix4\" />\n"
+ "<feColorMatrix stdDeviation=\"3\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix5\" />\n"
+ "<feColorMatrix in=\"colormatrix5\" type=\"saturate\" values=\"1\" result=\"colormatrix6\" />\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" stdDeviation=\"3\" result=\"flood2\" />\n"
+ "<feComposite in=\"%s\" in2=\"colormatrix6\" operator=\"in\" result=\"composite1\" />\n"
+ "<feFlood flood-opacity=\"%s\" in=\"colormatrix6\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood3\" />\n"
+ "<feComposite in=\"%s\" in2=\"colormatrix6\" operator=\"out\" result=\"composite2\" />\n"
+ "<feComposite in2=\"composite1\" operator=\"arithmetic\" k2=\"%s\" k3=\"%s\" result=\"composite3\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
+ "</filter>\n", simply.str().c_str(), light.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), blur.str().c_str(), spread.str().c_str(), erosion.str().c_str(), strokea.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), filla.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), iofo.str().c_str(), ioso.str().c_str());
+
+ return _filter;
+}; /* Drawing filter */
+
+/**
+ \brief Custom predefined Posterize filter.
+
+ Poster and painting effects.
+
+ Filter's parameters (not finished yet):
+ * Effect type (enum, default "Normal") ->
+ Normal = feComponentTransfer
+ Dented = Normal + intermediate values
+ * Blur (0.01->10., default 5.) -> blur3 (stdDeviation)
+
+*/
class Posterize : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
@@ -45,7 +396,7 @@ public:
"</param>\n"
"<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" min=\"1\" max=\"15\">5</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
- "<_item value=\"lighten\">Ligthen</_item>\n"
+ "<_item value=\"lighten\">Lighten</_item>\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"darken\">Darken</_item>\n"
"</param>\n"
@@ -65,7 +416,6 @@ public:
"</effect>\n"
"</inkscape-extension>\n", new Posterize());
};
-
};
gchar const *
@@ -89,8 +439,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
presat << ext->get_param_float("presaturation");
postsat << ext->get_param_float("postsaturation");
-
- // TransfertComponenet table values are calculated based on the poster type.
+ // TransfertComponent table values are calculated based on the poster type.
transf << "0";
int levels = ext->get_param_int("levels") + 1;
const gchar *effecttype = ext->get_param_enum("type");
@@ -108,7 +457,6 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
antialias << "0.5";
else
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 and painting, custom -EXP-\">\n"
@@ -124,11 +472,12 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
"</feComponentTransfer>\n"
"<feColorMatrix type=\"saturate\" values=\"%s\" />\n"
"<feGaussianBlur stdDeviation=\"%s\" />\n"
- "<feComposite in2=\"SourceGraphic\" operator=\"atop\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"in\" />\n"
"</filter>\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str());
return _filter;
-};
+}; /* Posterize filter */
+
class TestFilter : public Inkscape::Extension::Internal::Filter::Filter {
protected:
@@ -155,7 +504,6 @@ public:
"</effect>\n"
"</inkscape-extension>\n", new TestFilter());
};
-
};
gchar const *
@@ -181,7 +529,8 @@ TestFilter::get_filter_text (Inkscape::Extension::Extension * ext)
"</filter>\n");
return _filter;
-};
+}; /* Test filter */
+
}; /* namespace Filter */
}; /* namespace Internal */
}; /* namespace Extension */
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index 6920e1bac..06b942a1f 100644
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -10,7 +10,9 @@
/* Put your filter here */
#include "color.h"
#include "drop-shadow.h"
+#include "morphology.h"
#include "snow.h"
+
#include "experimental.h"
namespace Inkscape {
@@ -23,13 +25,28 @@ void
Filter::filters_all (void )
{
// Here come the filters which are coded in C++ in order to present a parameters dialog
- Duochrome::init();
DropShadow::init();
DropGlow::init();
- ColorizableDropShadow::init();
Snow::init();
+
+ /* Experimental custom predefined filters */
- // Experimental!
+ // Color
+ Colorize::init();
+ Duochrome::init();
+ Quadritone::init();
+ Solarize::init();
+ Tritone::init();
+
+ // Morphology
+ Crosssmooth::init();
+
+ // Shadows and glows
+ ColorizableDropShadow::init();
+
+ // TDB
+ Chromolitho::init();
+ Drawing::init();
Posterize::init();
// Here come the rest of the filters that are read from SVG files in share/filters and
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index c2d80b28b..90dc5dd6f 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -132,7 +132,7 @@ Filter::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *d
std::list<SPItem *> items;
items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
- Inkscape::XML::Document * xmldoc = sp_document_repr_doc(document->doc());
+ Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc();
Inkscape::XML::Node * defsrepr = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(document->doc()));
for(std::list<SPItem *>::iterator item = items.begin();
diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h
new file mode 100644
index 000000000..93d44d6fa
--- /dev/null
+++ b/src/extension/internal/filter/morphology.h
@@ -0,0 +1,107 @@
+#ifndef __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
+#define __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__
+/* Change the 'MORPHOLOGY' above to be your file name */
+
+/*
+ * Copyright (C) 2010 Authors:
+ * Ivan Louette (filters)
+ * Nicolas Dufour (UI) <nicoduf@yahoo.fr>
+ *
+ * Morphology filters
+ * Cross-smooth
+ *
+ * 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 Cross-smooth filter.
+
+ Smooth the outside of shapes and pictures.
+
+ 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)
+*/
+
+class Crosssmooth : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ Crosssmooth ( ) : Filter() { };
+ virtual ~Crosssmooth ( ) { 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-smooth, custom -EXP-") "</name>\n"
+ "<id>org.inkscape.effect.filter.Crosssmooth</id>\n"
+ "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
+ "<_item value=\"edges\">Smooth edges</_item>\n"
+ "<_item value=\"all\">Smooth all</_item>\n"
+ "</param>\n"
+ "<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" min=\"0.01\" max=\"10\">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_("Smooth edges and angles of shapes") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new Crosssmooth());
+ };
+
+};
+
+gchar const *
+Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream blur;
+ std::ostringstream c1in;
+
+ blur << ext->get_param_float("blur");
+
+ const gchar *type = ext->get_param_enum("type");
+ if((g_ascii_strcasecmp("all", type) == 0)) {
+ c1in << "blur";
+ } else {
+ c1in << "SourceGraphic";
+ }
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" inkscape:label=\"Cross-smooth, custom -EXP-\">\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());
+
+ return _filter;
+}; /* Crosssmooth filter */
+
+}; /* namespace Filter */
+}; /* namespace Internal */
+}; /* namespace Extension */
+}; /* namespace Inkscape */
+
+/* Change the 'COLOR' below to be your file name */
+#endif /* __INKSCAPE_EXTENSION_INTERNAL_FILTER_MORPHOLOGY_H__ */
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index ff272d28d..c3a30a2f0 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -55,9 +55,9 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
mime_type = "image/png";
}
- doc = sp_document_new(NULL, TRUE, TRUE);
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false); // no need to undo in this temporary document
+ doc = SPDocument::createNewDoc(NULL, TRUE, TRUE);
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false); // no need to undo in this temporary document
double width = gdk_pixbuf_get_width(pb);
double height = gdk_pixbuf_get_height(pb);
@@ -79,7 +79,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
}
// Create image node
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image");
sp_repr_set_svg_double(image_node, "width", width);
sp_repr_set_svg_double(image_node, "height", height);
@@ -100,11 +100,11 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
g_object_unref(pb);
// Add it to the current layer
- SP_DOCUMENT_ROOT(doc)->appendChildRepr(image_node);
+ doc->getRoot()->appendChildRepr(image_node);
Inkscape::GC::release(image_node);
fit_canvas_to_drawing(doc);
// restore undo, as now this document may be shown to the user if a bitmap was opened
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
} else {
printf("GdkPixbuf loader failed\n");
}
diff --git a/src/extension/internal/gimpgrad.cpp b/src/extension/internal/gimpgrad.cpp
index 5b3e0c16e..e92a4e17e 100644
--- a/src/extension/internal/gimpgrad.cpp
+++ b/src/extension/internal/gimpgrad.cpp
@@ -5,6 +5,7 @@
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2005 Authors
*
@@ -256,7 +257,7 @@ GimpGrad::open (Inkscape::Extension::Input */*module*/, gchar const *filename)
fclose(gradient);
- return sp_document_new_from_mem(outsvg.c_str(), outsvg.length(), TRUE);
+ return SPDocument::createNewDocFromMem(outsvg.c_str(), outsvg.length(), TRUE);
}
error:
diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp
index ed41dd97b..a19ab7538 100644
--- a/src/extension/internal/grid.cpp
+++ b/src/extension/internal/grid.cpp
@@ -6,6 +6,7 @@
/*
* Copyright (C) 2004-2005 Ted Gould <ted@gould.cx>
* Copyright (C) 2007 MenTaLguY <mental@rydia.net>
+ * Abhishek Sharma
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -87,14 +88,14 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
/* get page size */
SPDocument * doc = document->doc();
bounding_area = Geom::Rect( Geom::Point(0,0),
- Geom::Point(sp_document_width(doc), sp_document_height(doc)) );
+ Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
Geom::OptRect bounds = selection->bounds();
if (bounds) {
bounding_area = *bounds;
}
- gdouble doc_height = sp_document_height(document->doc());
+ gdouble doc_height = (document->doc())->getHeight();
Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
@@ -111,8 +112,10 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
path_data = build_lines(bounding_area,
offsets, spacings);
- Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc());
- Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->repr;
+ Inkscape::XML::Document * xml_doc = document->doc()->getReprDoc();
+
+ //XML Tree being used directly here while it shouldn't be.
+ Inkscape::XML::Node * current_layer = static_cast<SPDesktop *>(document)->currentLayer()->getRepr();
Inkscape::XML::Node * path = xml_doc->createElement("svg:path");
path->setAttribute("d", path_data.c_str());
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index b371b0105..7098027c7 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -9,6 +9,7 @@
* Silveira Neto <silveiraneto@gmail.com>
* Jim Clarke <Jim.Clarke@sun.com>
* Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2008,2009 Authors
*
@@ -493,7 +494,7 @@ 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::Matrix tf = sp_item_i2d_affine(item) * yflip;
+ Geom::Matrix tf = item->i2d_affine() * yflip;
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
//Count the NR_CURVETOs/LINETOs (including closing line segment)
@@ -635,7 +636,7 @@ 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::Matrix tf = sp_item_i2d_affine(item) * yflip;
+ Geom::Matrix tf = item->i2d_affine() * yflip;
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
//Count the NR_CURVETOs/LINETOs (including closing line segment)
diff --git a/src/extension/internal/latex-pstricks-out.cpp b/src/extension/internal/latex-pstricks-out.cpp
index 4a469a750..1477d5daf 100644
--- a/src/extension/internal/latex-pstricks-out.cpp
+++ b/src/extension/internal/latex-pstricks-out.cpp
@@ -1,6 +1,8 @@
/*
* Authors:
* Michael Forbes <miforbes@mbhs.edu>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004 Authors
*
@@ -55,7 +57,7 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons
gchar * oldoutput;
unsigned int ret;
- sp_document_ensure_up_to_date (doc);
+ doc->ensureUpToDate();
mod = Inkscape::Extension::get_print(SP_MODULE_KEY_PRINT_LATEX);
oldconst = mod->get_param_string("destination");
@@ -66,16 +68,16 @@ LatexOutput::save(Inkscape::Extension::Output *mod2, SPDocument *doc, gchar cons
context.module = mod;
/* fixme: This has to go into module constructor somehow */
/* Create new arena */
- mod->base = SP_ITEM (sp_document_root (doc));
+ mod->base = SP_ITEM(doc->getRoot());
mod->arena = NRArena::create();
- mod->dkey = sp_item_display_key_new (1);
- mod->root = sp_item_invoke_show (mod->base, mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
+ mod->dkey = SPItem::display_key_new (1);
+ mod->root = (mod->base)->invoke_show (mod->arena, mod->dkey, SP_ITEM_SHOW_DISPLAY);
/* Print document */
ret = mod->begin (doc);
- sp_item_invoke_print (mod->base, &context);
+ (mod->base)->invoke_print (&context);
ret = mod->finish ();
/* Release arena */
- sp_item_invoke_hide (mod->base, mod->dkey);
+ (mod->base)->invoke_hide (mod->dkey);
mod->base = NULL;
mod->root = NULL;
nr_object_unref ((NRObject *) mod->arena);
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index ed6024adf..44b64c5f8 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -1,10 +1,9 @@
-#define __SP_LATEX_C__
-
/*
* LaTeX Printing
*
* Author:
* Michael Forbes <miforbes@mbhs.edu>
+ * Abhishek Sharma
*
* Copyright (C) 2004 Authors
*
@@ -128,8 +127,8 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
}
// width and height in pt
- _width = sp_document_width(doc) * PT_PER_PX;
- _height = sp_document_height(doc) * PT_PER_PX;
+ _width = doc->getWidth() * PT_PER_PX;
+ _height = doc->getHeight() * PT_PER_PX;
if (res >= 0) {
@@ -139,10 +138,10 @@ PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n";
// from now on we can output px, but they will be treated as pt
- os << "\\begin{pspicture}(" << sp_document_width(doc) << "," << sp_document_height(doc) << ")\n";
+ os << "\\begin{pspicture}(" << doc->getWidth() << "," << doc->getHeight() << ")\n";
}
- m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc)));
+ m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, doc->getHeight()));
return fprintf(_stream, "%s", os.str().c_str());
}
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index b37316d8f..fd99afe31 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -1,5 +1,3 @@
-#define EXTENSION_INTERNAL_LATEX_TEXT_RENDERER_CPP
-
/** \file
* Rendering LaTeX file (pdf/eps/ps+latex output)
*
@@ -9,6 +7,8 @@
* Authors:
* Johan Engelen <goejendaagh@zonnet.nl>
* Miklos Erdelyi <erdelyim@gmail.com>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2010 Authors
*
@@ -58,7 +58,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
const gchar * const exportId, bool exportDrawing, bool exportCanvas,
bool pdflatex)
{
- sp_document_ensure_up_to_date(doc);
+ doc->ensureUpToDate();
SPItem *base = NULL;
@@ -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(sp_document_root(doc));
+ base = SP_ITEM(doc->getRoot());
pageBoundingBox = !exportDrawing;
}
@@ -311,7 +311,7 @@ LaTeXTextRenderer::sp_text_render(SPItem *item)
}
// get rotation
- Geom::Matrix i2doc = sp_item_i2doc_affine(item);
+ Geom::Matrix i2doc = item->i2doc_affine();
Geom::Matrix wotransl = i2doc.without_translation();
double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis());
bool has_rotation = !Geom::are_near(degrees,0.);
@@ -412,7 +412,7 @@ Flowing in rectangle is possible, not in arb shape.
}
// get rotation
- Geom::Matrix i2doc = sp_item_i2doc_affine(item);
+ Geom::Matrix i2doc = item->i2doc_affine();
Geom::Matrix wotransl = i2doc.without_translation();
double degrees = -180/M_PI * Geom::atan2(wotransl.xAxis());
bool has_rotation = !Geom::are_near(degrees,0.);
@@ -490,15 +490,16 @@ 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(sp_document_root(doc));
+ if (!base) {
+ base = SP_ITEM(doc->getRoot());
+ }
Geom::OptRect d;
if (pageBoundingBox) {
d = Geom::Rect( Geom::Point(0,0),
- Geom::Point(sp_document_width(doc), sp_document_height(doc)) );
+ Geom::Point(doc->getWidth(), doc->getHeight()) );
} else {
- sp_item_invoke_bbox(base, d, sp_item_i2d_affine(base), TRUE, SPItem::RENDERING_BBOX);
+ base->invoke_bbox( d, base->i2d_affine(), TRUE, SPItem::RENDERING_BBOX);
}
if (!d) {
g_message("LaTeXTextRenderer: could not retrieve boundingbox.");
@@ -517,7 +518,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
}
// flip y-axis
- push_transform( Geom::Scale(1,-1) * Geom::Translate(0, sp_document_height(doc)) );
+ push_transform( Geom::Scale(1,-1) * Geom::Translate(0, doc->getHeight()) );
// write the info to LaTeX
Inkscape::SVGOStringStream os;
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index 4f3f1ac89..b5c842a40 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -14,6 +14,7 @@
*
* Authors:
* Bob Jamison
+ * Abhishek Sharma
*
* Copyright (C) 2006, 2007 Bob Jamison
*
@@ -945,9 +946,9 @@ static Glib::ustring formatTransform(Geom::Matrix &tf)
static Geom::Matrix getODFTransform(const SPItem *item)
{
//### Get SVG-to-ODF transform
- Geom::Matrix tf (sp_item_i2d_affine(item));
+ Geom::Matrix tf (item->i2d_affine());
//Flip Y into document coordinates
- double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
+ double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0));
doc2dt_tf = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height));
tf = tf * doc2dt_tf;
@@ -964,11 +965,11 @@ static Geom::Matrix getODFTransform(const SPItem *item)
*/
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
- Geom::OptRect bbox_temp = sp_item_bbox_desktop((SPItem *)item);
+ Geom::OptRect bbox_temp = ((SPItem *)item)->getBboxDesktop();
Geom::OptRect bbox;
if (bbox_temp) {
bbox = *bbox_temp;
- double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT);
+ double doc_height = SP_ACTIVE_DOCUMENT->getHeight();
Geom::Matrix doc2dt_tf = Geom::Matrix(Geom::Scale(1.0, -1.0));
doc2dt_tf = doc2dt_tf * Geom::Matrix(Geom::Translate(0, doc_height));
bbox = *bbox * doc2dt_tf;
@@ -2002,7 +2003,7 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
else if (SP_IS_SHAPE(item))
{
//g_message("### %s is a shape", nodeName.c_str());
- curve = sp_shape_get_curve(SP_SHAPE(item));
+ curve = SP_SHAPE(item)->getCurve();
}
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
{
diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h
index 3854ddfe1..9ad261098 100644
--- a/src/extension/internal/odf.h
+++ b/src/extension/internal/odf.h
@@ -11,6 +11,7 @@
*
* Authors:
* Bob Jamison
+ * Abhishek Sharma
*
* Copyright (C) 2006 Bob Jamison
*
@@ -47,7 +48,7 @@
#include <dom/util/ziptool.h>
#include <dom/io/domstream.h>
-
+#include "sp-item.h"
namespace Inkscape
{
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index 937fefb11..2c7ea3b33 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* miklos erdelyi
+ * Abhishek Sharma
*
* Copyright (C) 2007 Authors
*
@@ -58,7 +59,7 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
cairo_destroy(cr);
cairo_surface_destroy(surface);
- SPDocument * doc = sp_document_new_from_mem(output->c_str(), output->length(), TRUE);
+ SPDocument * doc = SPDocument::createNewDocFromMem(output->c_str(), output->length(), TRUE);
delete output;
g_object_unref(page);
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 8dd4698b5..ae3e473a5 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* miklos erdelyi
+ * Abhishek Sharma
*
* Copyright (C) 2007 Authors
*
@@ -659,9 +660,9 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
Catalog *catalog = pdf_doc->getCatalog();
Page *page = catalog->getPage(page_num);
- SPDocument *doc = sp_document_new(NULL, TRUE, TRUE);
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false); // No need to undo in this temporary document
+ SPDocument *doc = SPDocument::createNewDoc(NULL, TRUE, TRUE);
+ bool saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false); // No need to undo in this temporary document
// Create builder
gchar *docname = g_path_get_basename(uri);
@@ -735,7 +736,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
delete dlg;
// Restore undo
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
return doc;
}
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index b37cbb777..ef31cd39f 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -1874,6 +1874,9 @@ void PdfParser::doPatchMeshShFill(GfxPatchMeshShading *shading) {
void PdfParser::fillPatch(GfxPatch *patch, int nComps, int depth) {
GfxPatch patch00, patch01, patch10, patch11;
+#ifdef POPPLER_NEW_GFXPATCH
+ GfxColor color;
+#endif
double xx[4][8], yy[4][8];
double xxm, yym;
double patchColorDelta = colorDeltas[pdfPatchMeshShading-1];
@@ -1890,9 +1893,16 @@ void PdfParser::fillPatch(GfxPatch *patch, int nComps, int depth) {
> patchColorDelta) {
break;
}
+#ifdef POPPLER_NEW_GFXPATCH
+ color.c[i] = GfxColorComp(patch->color[0][0].c[i]);
+#endif
}
if (i == nComps || depth == maxDepths[pdfPatchMeshShading-1]) {
+#ifdef POPPLER_NEW_GFXPATCH
+ state->setFillColor(&color);
+#else
state->setFillColor(&patch->color[0][0]);
+#endif
state->moveTo(patch->x[0][0], patch->y[0][0]);
state->curveTo(patch->x[0][1], patch->y[0][1],
patch->x[0][2], patch->y[0][2],
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index e343dbf33..8b414239a 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -3,6 +3,7 @@
*
* Authors:
* miklos erdelyi
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2007 Authors
*
@@ -77,12 +78,13 @@ struct SvgTransparencyGroup {
*
*/
-SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref) {
+SvgBuilder::SvgBuilder(SPDocument *document, gchar *docname, XRef *xref)
+{
_is_top_level = true;
_doc = document;
_docname = docname;
_xref = xref;
- _xml_doc = sp_document_repr_doc(_doc);
+ _xml_doc = _doc->getReprDoc();
_container = _root = _doc->rroot;
_root->setAttribute("xml:space", "preserve");
_init();
diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp
index 7b1fe8b87..a130b6923 100644
--- a/src/extension/internal/pov-out.cpp
+++ b/src/extension/internal/pov-out.cpp
@@ -10,6 +10,7 @@
*
* Authors:
* Bob Jamison <ishmal@inkscape.org>
+ * Abhishek Sharma
*
* Copyright (C) 2004-2008 Authors
*
@@ -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::Matrix tf = sp_item_i2d_affine(item);
+ Geom::Matrix tf = item->i2d_affine();
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers( curve->get_pathvector() * tf );
/*
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index b10aa87ec..946ff22fe 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -6,6 +6,8 @@
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Ted Gould <ted@gould.cx>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2002-2003 Authors
*
@@ -182,19 +184,19 @@ Svg::open (Inkscape::Extension::Input */*mod*/, const gchar *uri)
#ifdef WITH_GNOME_VFS
if (!gnome_vfs_initialized() || gnome_vfs_uri_is_local(gnome_vfs_uri_new(uri))) {
// Use built-in loader instead of VFS for this
- return sp_document_new(uri, TRUE);
+ return SPDocument::createNewDoc(uri, TRUE);
}
gchar * buffer = _load_uri(uri);
if (buffer == NULL) {
g_warning("Error: Could not open file '%s' with VFS\n", uri);
return NULL;
}
- SPDocument * doc = sp_document_new_from_mem(buffer, strlen(buffer), 1);
+ SPDocument * doc = SPDocument::createNewDocFromMem(buffer, strlen(buffer), 1);
g_free(buffer);
return doc;
#else
- return sp_document_new (uri, TRUE);
+ return SPDocument::createNewDoc(uri, TRUE);
#endif
}
@@ -237,17 +239,17 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena
Inkscape::XML::Document *rdoc = NULL;
Inkscape::XML::Node *repr = NULL;
if (exportExtensions) {
- repr = sp_document_repr_root (doc);
+ repr = doc->getReprRoot();
} else {
rdoc = sp_repr_document_new ("svg:svg");
repr = rdoc->root();
- repr = sp_document_root (doc)->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD);
+ repr = doc->getRoot()->updateRepr(rdoc, repr, SP_OBJECT_WRITE_BUILD);
pruneExtendedAttributes(repr);
}
if (!sp_repr_save_rebased_file(repr->document(), filename, SP_SVG_NS_URI,
- doc->base, filename)) {
+ doc->getBase(), filename)) {
throw Inkscape::Extension::Output::save_failed();
}
diff --git a/src/extension/internal/win32.cpp b/src/extension/internal/win32.cpp
index 0c711824c..8b4ff13c8 100644
--- a/src/extension/internal/win32.cpp
+++ b/src/extension/internal/win32.cpp
@@ -3,6 +3,7 @@
*/
/* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
+ * Abhishek Sharma
*
* This code is in public domain
*/
@@ -226,10 +227,10 @@ PrintWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc)
};
int res;
- _PageWidth = sp_document_width (doc);
- _PageHeight = sp_document_height (doc);
+ _PageWidth = doc->getWidth ();
+ _PageHeight = doc->getHeight ();
- di.lpszDocName = SP_DOCUMENT_NAME (doc);
+ di.lpszDocName = doc->getName();
SPWin32Modal = TRUE;
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index c37d5705b..70fa28967 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -6,6 +6,7 @@
*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Abhishek Sharma
*
* Copyright (C) 2006 Authors
*
@@ -86,7 +87,7 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
//printf("I've got a doc: \n%s", painter.document.c_str());
- SPDocument * doc = sp_document_new_from_mem(output.cstr(), strlen(output.cstr()), TRUE);
+ SPDocument * doc = SPDocument::createNewDocFromMem(output.cstr(), strlen(output.cstr()), TRUE);
delete input;
return doc;
}
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 86e3cefe6..e1ab1de6d 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -57,7 +57,7 @@ public:
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
void paramString (std::list <std::string> &list);
gchar * get_guitext (void) {return _text;};
-
+ Parameter * get_param (const gchar * name);
}; /* class ParamNotebookPage */
@@ -381,7 +381,45 @@ ParamNotebookWdg::changed_page(GtkNotebookPage */*page*/,
return;
}
+/** \brief Search the parameter's name in the notebook content */
+Parameter *
+ParamNotebook::get_param(const gchar * name)
+{
+ if (name == NULL) {
+ throw Extension::param_not_exist();
+ }
+ for (GSList * pglist = pages; pglist != NULL; pglist = g_slist_next(pglist)) {
+ ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(pglist->data);
+ Parameter * subparam = page->get_param(name);
+ if (subparam) {
+ return subparam;
+ }
+ }
+
+ return NULL;
+}
+/** \brief Search the parameter's name in the page content */
+Parameter *
+ParamNotebookPage::get_param(const gchar * name)
+{
+ if (name == NULL) {
+ throw Extension::param_not_exist();
+ }
+ if (this->parameters == NULL) {
+ // the list of parameters is empty
+ throw Extension::param_not_exist();
+ }
+
+ for (GSList * list = this->parameters; list != NULL; list = g_slist_next(list)) {
+ Parameter * param = static_cast<Parameter*>(list->data);
+ if (!strcmp(param->name(), name)) {
+ return param;
+ }
+ }
+
+ return NULL;
+}
/**
\brief Creates a Notebook widget for a notebook parameter
diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h
index 24d4ebfc1..fb21c9b63 100644
--- a/src/extension/param/notebook.h
+++ b/src/extension/param/notebook.h
@@ -43,6 +43,8 @@ public:
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
void string (std::list <std::string> &list);
+ Parameter * get_param (const gchar * name);
+
const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; }
const gchar * set (const int in, SPDocument * doc, Inkscape::XML::Node * node);
}; /* class ParamNotebook */
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp
index 1347653a2..ac7c8b8dd 100644
--- a/src/extension/param/parameter.cpp
+++ b/src/extension/param/parameter.cpp
@@ -4,6 +4,7 @@
/* Author:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2005-2007 Authors
*
@@ -155,8 +156,6 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
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)
@@ -347,10 +346,9 @@ Parameter::new_child (Inkscape::XML::Node * parent)
return retval;
}
-Inkscape::XML::Node *
-Parameter::document_param_node (SPDocument * doc)
+Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc)
{
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc));
Inkscape::XML::Node * params = NULL;
@@ -409,6 +407,13 @@ Parameter::string (std::list <std::string> &list)
return;
}
+/** \brief All the code in Notebook::get_param to get the notebook content */
+Parameter *
+Parameter::get_param(const gchar * name)
+{
+ return NULL;
+}
+
Glib::ustring const extension_pref_root = "/extensions/";
} /* namespace Extension */
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index beddf5936..d8ed68439 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -85,6 +85,7 @@ public:
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,
@@ -120,6 +121,8 @@ public:
virtual void string (std::list <std::string> &list);
virtual void string (std::string &string);
+
+ virtual Parameter * get_param (const gchar * name);
};
} /* namespace Extension */
diff --git a/src/extension/print.h b/src/extension/print.h
index 8ae71b8e6..0f0435c0f 100644
--- a/src/extension/print.h
+++ b/src/extension/print.h
@@ -1,6 +1,7 @@
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Abhishek Sharma
*
* Copyright (C) 2002-2004 Authors
*
@@ -14,7 +15,7 @@
#include "display/nr-arena-forward.h"
#include "forward.h"
-
+#include "sp-item.h"
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index 5412a5cc0..cf58f2733 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -7,6 +7,8 @@
* Authors:
* Ted Gould <ted@gould.cx>
* Johan Engelen <johan@shouraizou.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2007 Johan Engelen
* Copyright (C) 2002-2004 Ted Gould
@@ -111,7 +113,7 @@ open(Extension *key, gchar const *filename)
to make sure for this release -- TJG */
doc->setModifiedSinceSave(false);
- sp_document_set_uri(doc, filename);
+ doc->setUri(filename);
return doc;
}
@@ -256,11 +258,11 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
throw Output::file_read_only();
}
- Inkscape::XML::Node *repr = sp_document_repr_root(doc);
+ Inkscape::XML::Node *repr = doc->getReprRoot();
// remember attributes in case this is an unofficial save and/or overwrite fails
- gchar *saved_uri = g_strdup(doc->uri);
+ gchar *saved_uri = g_strdup(doc->getURI());
bool saved_modified = false;
gchar *saved_output_extension = NULL;
gchar *saved_dataloss = NULL;
@@ -268,14 +270,14 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
saved_output_extension = g_strdup(get_file_save_extension(save_method).c_str());
saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
if (official) {
- /* The document is changing name/uri. */
- sp_document_change_uri_and_hrefs(doc, fileName);
+ // The document is changing name/uri.
+ doc->changeUriAndHrefs(fileName);
}
// Update attributes:
{
- bool const saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
+ bool const saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
{
// also save the extension for next use
store_file_extension_in_prefs (omod->get_id(), save_method);
@@ -285,7 +287,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
repr->setAttribute("inkscape:dataloss", "true");
}
}
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
doc->setModifiedSinceSave(false);
}
@@ -295,14 +297,14 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
catch(...) {
// revert attributes in case of official and overwrite
if(check_overwrite && official) {
- bool const saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
+ bool const saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
{
store_file_extension_in_prefs (saved_output_extension, save_method);
repr->setAttribute("inkscape:dataloss", saved_dataloss);
}
- sp_document_set_undo_sensitive(doc, saved);
- sp_document_change_uri_and_hrefs(doc, saved_uri);
+ DocumentUndo::setUndoSensitive(doc, saved);
+ doc->changeUriAndHrefs(saved_uri);
}
doc->setModifiedSinceSave(saved_modified);
// free used ressources
@@ -317,13 +319,13 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
// If it is an unofficial save, set the modified attributes back to what they were.
if ( !official) {
- bool const saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
+ bool const saved = DocumentUndo::getUndoSensitive(doc);
+ DocumentUndo::setUndoSensitive(doc, false);
{
store_file_extension_in_prefs (saved_output_extension, save_method);
repr->setAttribute("inkscape:dataloss", saved_dataloss);
}
- sp_document_set_undo_sensitive(doc, saved);
+ DocumentUndo::setUndoSensitive(doc, saved);
doc->setModifiedSinceSave(saved_modified);
g_free(saved_output_extension);
@@ -590,8 +592,8 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
case FILE_SAVE_METHOD_SAVE_AS:
{
bool use_current_dir = prefs->getBool("/dialogs/save_as/use_current_dir", true);
- if (doc->uri && use_current_dir) {
- path = Glib::path_get_dirname(doc->uri);
+ if (doc->getURI() && use_current_dir) {
+ path = Glib::path_get_dirname(doc->getURI());
} else {
path = prefs->getString("/dialogs/save_as/path");
}
@@ -604,8 +606,8 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) {
path = prefs->getString("/dialogs/save_copy/path");
break;
case FILE_SAVE_METHOD_INKSCAPE_SVG:
- if (doc->uri) {
- path = Glib::path_get_dirname(doc->uri);
+ if (doc->getURI()) {
+ path = Glib::path_get_dirname(doc->getURI());
} else {
// FIXME: should we use the save_as path here or something else? Maybe we should
// leave this as a choice to the user.