convolvematrix.cpp revision a2e796b608034e2c62290378d713058b8b58ef8f
/** \file
* SVG <feConvolveMatrix> implementation.
*
*/
/*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
* hugo Rodrigues <haa.rodrigues@gmail.com>
* Abhishek Sharma
*
* 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 <string.h>
#include <math.h>
#include <vector>
#include "attributes.h"
#include "filters/convolvematrix.h"
#include "helper-fns.h"
#include "display/nr-filter.h"
#include "display/nr-filter-convolve-matrix.h"
/* FeConvolveMatrix base class */
static void
{
}
this->spfeconvolvematrix = matrix;
}
}
SPFeConvolveMatrix* feConvolveMatrix = this;
delete feConvolveMatrix->cfilterprimitive;
feConvolveMatrix->bias = 0;
feConvolveMatrix->divisorIsSet = 0;
feConvolveMatrix->divisor = 0;
//Setting default values:
feConvolveMatrix->preserveAlpha = false;
//some helper variables:
feConvolveMatrix->targetXIsSet = false;
feConvolveMatrix->targetYIsSet = false;
feConvolveMatrix->kernelMatrixIsSet = false;
}
static void
{
new (feConvolveMatrix) SPFeConvolveMatrix();
}
/**
* 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.
*/
/*LOAD ATTRIBUTES FROM REPR HERE*/
}
/**
* Drops any allocated memory.
*/
void CFeConvolveMatrix::release() {
}
static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){
switch(value[0]){
case 'd':
if (strncmp(value, "duplicate", 9) == 0) return Inkscape::Filters::CONVOLVEMATRIX_EDGEMODE_DUPLICATE;
break;
case 'w':
break;
case 'n':
break;
}
}
/**
* Sets a specific value in the SPFeConvolveMatrix.
*/
(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;
if (! feConvolveMatrix->divisorIsSet) {
feConvolveMatrix->divisor = 0;
}
} else {
g_warning("For feConvolveMatrix you MUST pass a kernelMatrix parameter!");
}
break;
case SP_ATTR_DIVISOR:
if (value) {
if (read_num == 0) {
// This should actually be an error, but given our UI it is more useful to simply set divisor to the default.
if (feConvolveMatrix->kernelMatrixIsSet) {
}
feConvolveMatrix->divisorIsSet = false;
}
feConvolveMatrix->divisorIsSet = true;
}
}
break;
case SP_ATTR_BIAS:
read_num = 0;
}
break;
case SP_ATTR_TARGETX:
if (value) {
g_warning("targetX must be a value between 0 and orderX! Assuming floor(orderX/2) as default value.");
}
feConvolveMatrix->targetXIsSet = true;
}
}
break;
case SP_ATTR_TARGETY:
if (value) {
g_warning("targetY must be a value between 0 and orderY! Assuming floor(orderY/2) 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.
*/
/* do something to trigger redisplay, updates? */
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* CFeConvolveMatrix::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
/* TODO: Don't just clone, but create a new repr node and write all
* relevant values into it */
if (!repr) {
}
return repr;
}
Inkscape::Filters::FilterConvolveMatrix *nr_convolve = dynamic_cast<Inkscape::Filters::FilterConvolveMatrix*>(nr_primitive);
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :