displacementmap.cpp revision 2fa0db8376b4d31cc46ceed19968f47c9a389514
/** \file
* SVG <feDisplacementMap> implementation.
*
*/
/*
* Authors:
* 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 "attributes.h"
#include "filters/displacementmap.h"
#include "sp-filter.h"
#include "helper-fns.h"
#include "display/nr-filter.h"
#include "display/nr-filter-displacement-map.h"
#include "sp-factory.h"
namespace {
return new SPFeDisplacementMap();
}
bool displacementMapRegistered = SPFactory::instance().registerObject("svg:feDisplacementMap", createDisplacementMap);
}
this->scale=0;
}
}
/**
* Reads the Inkscape::XML::Node, and initializes SPFeDisplacementMap 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( "scale" );
this->readAttr( "in2" );
this->readAttr( "xChannelSelector" );
this->readAttr( "yChannelSelector" );
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
{
this->in2 = sp_filter_primitive_name_previous_out(this);
}
}
/**
* Drops any allocated memory.
*/
void SPFeDisplacementMap::release() {
}
static FilterDisplacementMapChannelSelector sp_feDisplacementMap_readChannelSelector(gchar const *value)
{
if (!value) return DISPLACEMENTMAP_CHANNEL_ALPHA;
switch (value[0]) {
case 'R':
return DISPLACEMENTMAP_CHANNEL_RED;
break;
case 'G':
return DISPLACEMENTMAP_CHANNEL_GREEN;
break;
case 'B':
return DISPLACEMENTMAP_CHANNEL_BLUE;
break;
case 'A':
return DISPLACEMENTMAP_CHANNEL_ALPHA;
break;
default:
// error
g_warning("Invalid attribute for Channel Selector. Valid modes are 'R', 'G', 'B' or 'A'");
break;
}
return DISPLACEMENTMAP_CHANNEL_ALPHA; //default is Alpha Channel
}
/**
* Sets a specific value in the SPFeDisplacementMap.
*/
int input;
double read_num;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
case SP_ATTR_XCHANNELSELECTOR:
if (read_selector != this->xChannelSelector){
this->xChannelSelector = read_selector;
}
break;
case SP_ATTR_YCHANNELSELECTOR:
if (read_selector != this->yChannelSelector){
this->yChannelSelector = read_selector;
}
break;
case SP_ATTR_SCALE:
}
break;
case SP_ATTR_IN2:
}
break;
default:
break;
}
}
/**
* Receives update notifications.
*/
/* do something to trigger redisplay, updates? */
}
/* Unlike normal in, in2 is required attribute. Make sure, we can call
* it by some name. */
{
this->in2 = sp_filter_primitive_name_previous_out(this);
//XML Tree being used directly here while it shouldn't be.
}
}
switch(selector) {
return "R";
return "G";
return "B";
return "A";
default:
return 0;
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeDisplacementMap::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) {
if (!repr) {
}
if( !in2_name ) {
// This code is very similar to sp_filter_primtive_name_previous_out()
// Find previous filter primitive
while (i && i->next != this) {
i = i->next;
}
if( i ) {
}
}
if (in2_name) {
} else {
g_warning("Unable to set in2 for feDisplacementMap");
}
get_channelselector_name(this->xChannelSelector));
get_channelselector_name(this->yChannelSelector));
return repr;
}
Inkscape::Filters::FilterDisplacementMap *nr_displacement_map = dynamic_cast<Inkscape::Filters::FilterDisplacementMap*>(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 :