componenttransfer.cpp revision 883c5b2d5104c153708fdc513209d5694b489900
/** \file
* SVG <feComponentTransfer> 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 <string.h>
#include "document.h"
#include "attributes.h"
#include "filters/componenttransfer.h"
#include "filters/componenttransfer-funcnode.h"
#include "display/nr-filter.h"
#include "display/nr-filter-component-transfer.h"
/* FeComponentTransfer base class */
static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_feComponentTransfer_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter);
static void sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
static Inkscape::XML::Node *sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
{
static GType feComponentTransfer_type = 0;
if (!feComponentTransfer_type) {
sizeof(SPFeComponentTransferClass),
sizeof(SPFeComponentTransfer),
16,
NULL, /* value_table */
};
feComponentTransfer_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComponentTransfer", &feComponentTransfer_info, (GTypeFlags)0);
}
return feComponentTransfer_type;
}
static void
{
//sp_object_class->build = sp_feComponentTransfer_build;
// sp_object_class->release = sp_feComponentTransfer_release;
// sp_object_class->write = sp_feComponentTransfer_write;
// sp_object_class->set = sp_feComponentTransfer_set;
// sp_object_class->update = sp_feComponentTransfer_update;
// sp_object_class->child_added = sp_feComponentTransfer_child_added;
// sp_object_class->remove_child = sp_feComponentTransfer_remove_child;
//sp_primitive_class->build_renderer = sp_feComponentTransfer_build_renderer;
}
this->spfecomponenttransfer = tr;
}
}
static void
{
}
/**
* Reads the Inkscape::XML::Node, and initializes SPFeComponentTransfer 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
//sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
//{
//// if (((SPObjectClass *) feComponentTransfer_parent_class)->build) {
//// ((SPObjectClass *) feComponentTransfer_parent_class)->build(object, document, repr);
//// }
//
// /*LOAD ATTRIBUTES FROM REPR HERE*/
//
// //do we need this?
// document->addResource("feComponentTransfer", object);
//}
// if (((SPObjectClass *) feComponentTransfer_parent_class)->build) {
// ((SPObjectClass *) feComponentTransfer_parent_class)->build(object, document, repr);
// }
/*LOAD ATTRIBUTES FROM REPR HERE*/
//do we need this?
}
{
if (sp_componenttransfer->renderer) {
bool set[4] = {false, false, false, false};
int i=4;
if (SP_IS_FEFUNCR(node)) i=0;
if (i==4) {
g_warning("Unrecognized channel for component transfer.");
break;
}
set[i] = true;
}
// Set any types not explicitly set to the identity transform
for(int i=0;i<4;i++) {
if (!set[i]) {
}
}
}
}
/**
* Callback for child_added event.
*/
static void
sp_feComponentTransfer_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
// SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object);
//
// if (((SPObjectClass *) feComponentTransfer_parent_class)->child_added)
// (* ((SPObjectClass *) feComponentTransfer_parent_class)->child_added)(object, child, ref);
//
// sp_feComponentTransfer_children_modified(f);
// object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
// if (((SPObjectClass *) feComponentTransfer_parent_class)->child_added)
// (* ((SPObjectClass *) feComponentTransfer_parent_class)->child_added)(object, child, ref);
}
/**
* Callback for remove_child event.
*/
static void
{
// SPFeComponentTransfer *f = SP_FECOMPONENTTRANSFER(object);
//
// if (((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)
// (* ((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)(object, child);
//
// sp_feComponentTransfer_children_modified(f);
// object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
// if (((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)
// (* ((SPObjectClass *) feComponentTransfer_parent_class)->remove_child)(object, child);
}
/**
* Drops any allocated memory.
*/
static void
{
// if (((SPObjectClass *) feComponentTransfer_parent_class)->release)
// ((SPObjectClass *) feComponentTransfer_parent_class)->release(object);
}
void CFeComponentTransfer::onRelease() {
}
/**
* Sets a specific value in the SPFeComponentTransfer.
*/
static void
{
// SPFeComponentTransfer *feComponentTransfer = SP_FECOMPONENTTRANSFER(object);
// (void)feComponentTransfer;
//
// switch(key) {
// /*DEAL WITH SETTING ATTRIBUTES HERE*/
// default:
// if (((SPObjectClass *) feComponentTransfer_parent_class)->set)
// ((SPObjectClass *) feComponentTransfer_parent_class)->set(object, key, value);
// break;
// }
}
(void)feComponentTransfer;
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
default:
// if (((SPObjectClass *) feComponentTransfer_parent_class)->set)
// ((SPObjectClass *) feComponentTransfer_parent_class)->set(object, key, value);
break;
}
}
/**
* Receives update notifications.
*/
static void
{
// if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
// SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
//
// /* do something to trigger redisplay, updates? */
//
// }
//
// if (((SPObjectClass *) feComponentTransfer_parent_class)->update) {
// ((SPObjectClass *) feComponentTransfer_parent_class)->update(object, ctx, flags);
// }
}
/* do something to trigger redisplay, updates? */
}
// if (((SPObjectClass *) feComponentTransfer_parent_class)->update) {
// ((SPObjectClass *) feComponentTransfer_parent_class)->update(object, ctx, flags);
// }
}
/**
* Writes its settings to an incoming repr object, if any.
*/
sp_feComponentTransfer_write(SPObject *object, 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) {
// repr = object->getRepr()->duplicate(doc);
// }
//
// if (((SPObjectClass *) feComponentTransfer_parent_class)->write) {
// ((SPObjectClass *) feComponentTransfer_parent_class)->write(object, doc, repr, flags);
// }
//
// return repr;
}
Inkscape::XML::Node* CFeComponentTransfer::onWrite(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) {
}
// if (((SPObjectClass *) feComponentTransfer_parent_class)->write) {
// ((SPObjectClass *) feComponentTransfer_parent_class)->write(object, doc, repr, flags);
// }
return repr;
}
static void sp_feComponentTransfer_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter) {
// g_assert(primitive != NULL);
// g_assert(filter != NULL);
//
// SPFeComponentTransfer *sp_componenttransfer = SP_FECOMPONENTTRANSFER(primitive);
//
// int primitive_n = filter->add_primitive(Inkscape::Filters::NR_FILTER_COMPONENTTRANSFER);
// Inkscape::Filters::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
// Inkscape::Filters::FilterComponentTransfer *nr_componenttransfer = dynamic_cast<Inkscape::Filters::FilterComponentTransfer*>(nr_primitive);
// g_assert(nr_componenttransfer != NULL);
//
// sp_componenttransfer->renderer = nr_componenttransfer;
// sp_filter_primitive_renderer_common(primitive, nr_primitive);
//
//
// sp_feComponentTransfer_children_modified(sp_componenttransfer); //do we need it?!
}
Inkscape::Filters::FilterComponentTransfer *nr_componenttransfer = dynamic_cast<Inkscape::Filters::FilterComponentTransfer*>(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 :