sp-feconvolvematrix.cpp revision aab21a6024aabcff6b1287fb5271d22e14a86437
#define __SP_FECONVOLVEMATRIX_CPP__
/** \file
* SVG <feConvolveMatrix> implementation.
*
*/
/*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
* hugo Rodrigues <haa.rodrigues@gmail.com>
*
* Copyright (C) 2006 Hugo Rodrigues
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vector>
#include "attributes.h"
#include "sp-feconvolvematrix.h"
#include "helper-fns.h"
#include "display/nr-filter-convolve-matrix.h"
#include <math.h>
/* FeConvolveMatrix base class */
static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static Inkscape::XML::Node *sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
{
static GType feConvolveMatrix_type = 0;
if (!feConvolveMatrix_type) {
sizeof(SPFeConvolveMatrixClass),
sizeof(SPFeConvolveMatrix),
16,
NULL, /* value_table */
};
feConvolveMatrix_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeConvolveMatrix", &feConvolveMatrix_info, (GTypeFlags)0);
}
return feConvolveMatrix_type;
}
static void
{
}
static void
{
//Setting default values:
feConvolveMatrix->preserveAlpha = false;
//some helper variables:
feConvolveMatrix->targetXIsSet = false;
feConvolveMatrix->targetYIsSet = false;
feConvolveMatrix->kernelMatrixIsSet = false;
}
/**
* Reads the Inkscape::XML::Node, and initializes SPFeConvolveMatrix variables. For this to get called,
* our name must be associated with a repr via "sp_object_type_register". Best done through
* sp-object-repr.cpp's repr_name_entries array.
*/
static void
{
}
/*LOAD ATTRIBUTES FROM REPR HERE*/
}
/**
* Drops any allocated memory.
*/
static void
{
}
switch(value[0]){
case 'd':
break;
case 'w':
break;
case 'n':
break;
}
}
/**
* Sets a specific value in the SPFeConvolveMatrix.
*/
static void
{
(void)feConvolveMatrix;
double read_num;
int read_int;
bool read_bool;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_ORDER:
//From SVG spec: If <orderY> is not provided, it defaults to <orderX>.
if (feConvolveMatrix->targetXIsSet == false) feConvolveMatrix->targetX = (int) floor(feConvolveMatrix->order.getNumber()/2);
if (feConvolveMatrix->targetYIsSet == false) feConvolveMatrix->targetY = (int) floor(feConvolveMatrix->order.getOptNumber()/2);
break;
case SP_ATTR_KERNELMATRIX:
if (value){
feConvolveMatrix->kernelMatrixIsSet = true;
feConvolveMatrix->kernelMatrix = helperfns_read_vector(value, (int) (feConvolveMatrix->order.getNumber() * feConvolveMatrix->order.getOptNumber()));
} else {
g_warning("You MUST pass a kernelMatrix parameter!");
}
break;
case SP_ATTR_DIVISOR:
if (!value){
read_num = 1;
} else {
if (read_num == 0) {
g_warning("You shouldn't pass a divisor value equal to 0! Assuming the sum of all values in kernelMatrix as the default value.");
} else {
g_warning("You shouldn't pass a divisor value equal to 0! Assuming 1 as the default value.");
read_num = 1;
}
}
}
}
break;
case SP_ATTR_BIAS:
read_num = 0;
}
break;
case SP_ATTR_TARGETX:
g_warning("targetX must be a value between 0 and orderX! Assuming orderX as default value.");
}
feConvolveMatrix->targetXIsSet = true;
}
break;
case SP_ATTR_TARGETY:
g_warning("targetY must be a value between 0 and orderY! Assuming orderY as default value.");
}
feConvolveMatrix->targetYIsSet = true;
}
break;
case SP_ATTR_EDGEMODE:
}
break;
case SP_ATTR_KERNELUNITLENGTH:
//From SVG spec: If the <dy> value is not specified, it defaults to the same value as <dx>.
break;
case SP_ATTR_PRESERVEALPHA:
}
break;
default:
break;
}
}
/**
* Receives update notifications.
*/
static void
{
/* do something to trigger redisplay, updates? */
}
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
{
// Inkscape-only object, not copied during an "plain SVG" dump:
if (flags & SP_OBJECT_WRITE_EXT) {
if (repr) {
// is this sane?
} else {
}
}
}
return repr;
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :