specularlighting.cpp revision cf99b5253f47e8fa5ba3c655712fc15031d1d91a
/** \file
* SVG <feSpecularLighting> implementation.
*
*/
/*
* Authors:
* hugo Rodrigues <haa.rodrigues@gmail.com>
* Jean-Rene Reinhard <jr@komite.net>
* Abhishek Sharma
*
* Copyright (C) 2006 Hugo Rodrigues
* 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "strneq.h"
#include "attributes.h"
#include "sp-object.h"
#include "svg/svg-color.h"
#include "svg/svg-icc-color.h"
#include "filters/specularlighting.h"
#include "filters/distantlight.h"
#include "filters/pointlight.h"
#include "filters/spotlight.h"
#include "display/nr-filter.h"
#include "display/nr-filter-specularlighting.h"
/* FeSpecularLighting base class */
static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
//we assume that svg:feSpecularLighting can have any number of children
//only the first one is considered as the light source of the filter
//TODO is that right?
//if not modify child_added and remove_child to raise errors
static void sp_feSpecularLighting_order_changed(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
static Inkscape::XML::Node *sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter);
static void
{
}
static void
{
//TODO kernelUnit
}
/**
* Reads the Inkscape::XML::Node, and initializes SPFeSpecularLighting 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
{
}
/**
* Sets a specific value in the SPFeSpecularLighting.
*/
static void
{
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
//TODO test forbidden values
case SP_ATTR_SURFACESCALE:
if (value) {
if (end_ptr) {
} else {
g_warning("feSpecularLighting: surfaceScale should be a number ... defaulting to 1");
}
}
//if the attribute is not set or has an unreadable value
}
if (feSpecularLighting->renderer) {
}
break;
case SP_ATTR_SPECULARCONSTANT:
if (value) {
} else {
g_warning("feSpecularLighting: specularConstant should be a positive number ... defaulting to 1");
}
}
}
if (feSpecularLighting->renderer) {
}
break;
case SP_ATTR_SPECULAREXPONENT:
if (value) {
} else {
g_warning("feSpecularLighting: specularExponent should be a number in range [1, 128] ... defaulting to 1");
}
}
}
if (feSpecularLighting->renderer) {
}
break;
case SP_ATTR_KERNELUNITLENGTH:
//TODO kernelUnit
//feSpecularLighting->kernelUnitLength.set(value);
/*TODOif (feSpecularLighting->renderer) {
feSpecularLighting->renderer->surfaceScale = feSpecularLighting->renderer;
}
*/
break;
case SP_PROP_LIGHTING_COLOR:
//if a value was read
if (cend_ptr) {
while (g_ascii_isspace(*cend_ptr)) {
++cend_ptr;
}
delete feSpecularLighting->icc;
}
}
} else {
//lighting_color already contains the default value
}
if (feSpecularLighting->renderer) {
}
break;
default:
break;
}
}
/**
* Receives update notifications.
*/
static void
{
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
}
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
sp_feSpecularLighting_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 _and children_ into it */
if (!repr) {
//repr = doc->createElement("svg:feSpecularLighting");
}
/*TODO kernelUnits */
if (fespecularlighting->lighting_color_set) {
gchar c[64];
}
}
return repr;
}
/**
* Callback for child_added event.
*/
static void
sp_feSpecularLighting_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
{
}
/**
* Callback for remove_child event.
*/
static void
{
}
static void
sp_feSpecularLighting_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
{
(* ((SPObjectClass *) (sp_feSpecularLighting_parent_class))->order_changed) (object, child, old_ref, new_ref);
}
{
if (sp_specularlighting->renderer) {
}
}
}
}
}
static void sp_feSpecularLighting_build_renderer(SPFilterPrimitive *primitive, Inkscape::Filters::Filter *filter) {
Inkscape::Filters::FilterSpecularLighting *nr_specularlighting = dynamic_cast<Inkscape::Filters::FilterSpecularLighting*>(nr_primitive);
//We assume there is at most one child
}
}
}
//nr_offset->set_dx(sp_offset->dx);
//nr_offset->set_dy(sp_offset->dy);
}
/*
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 :