/** \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
*/
#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"
this->bias = 0;
this->divisorIsSet = 0;
this->divisor = 0;
//Setting default values:
this->targetX = 1;
this->targetY = 1;
this->preserveAlpha = false;
//some helper variables:
this->targetXIsSet = false;
this->targetYIsSet = false;
this->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.
*/
/*LOAD ATTRIBUTES FROM REPR HERE*/
this->readAttr( "order" );
this->readAttr( "kernelMatrix" );
this->readAttr( "divisor" );
this->readAttr( "bias" );
this->readAttr( "targetX" );
this->readAttr( "targetY" );
this->readAttr( "edgeMode" );
this->readAttr( "kernelUnitLength" );
this->readAttr( "preserveAlpha" );
}
/**
* Drops any allocated memory.
*/
}
static Inkscape::Filters::FilterConvolveMatrixEdgeMode sp_feConvolveMatrix_read_edgeMode(gchar const *value){
if (!value) {
}
switch (value[0]) {
case 'd':
}
break;
case 'w':
}
break;
case 'n':
}
break;
}
}
/**
* Sets a specific value in the SPFeConvolveMatrix.
*/
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 (this->order.optNumIsSet() == false) {
}
if (this->targetXIsSet == false) {
}
if (this->targetYIsSet == false) {
}
break;
case SP_ATTR_KERNELMATRIX:
if (value){
this->kernelMatrixIsSet = true;
if (! this->divisorIsSet) {
this->divisor = 0;
for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
this->divisor += this->kernelMatrix[i];
}
if (this->divisor == 0) {
this->divisor = 1;
}
}
} 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 (this->kernelMatrixIsSet) {
for (unsigned int i = 0; i< this->kernelMatrix.size(); i++) {
read_num += this->kernelMatrix[i];
}
}
if (read_num == 0) {
read_num = 1;
}
this->divisorIsSet = false;
}
this->divisorIsSet = true;
}
}
break;
case SP_ATTR_BIAS:
read_num = 0;
if (value) {
}
}
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.");
}
this->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.");
}
this->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>.
if (this->kernelUnitLength.optNumIsSet() == false) {
}
break;
case SP_ATTR_PRESERVEALPHA:
if (read_bool != this->preserveAlpha){
this->preserveAlpha = read_bool;
}
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* SPFeConvolveMatrix::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 :