/** \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
*/
#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 */
this->surfaceScale = 1;
this->specularConstant = 1;
this->specularExponent = 1;
this->lighting_color = 0xffffffff;
//TODO kernelUnit
this->surfaceScale_set = FALSE;
this->specularConstant_set = FALSE;
this->specularExponent_set = FALSE;
this->lighting_color_set = FALSE;
}
}
/**
* 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.
*/
/*LOAD ATTRIBUTES FROM REPR HERE*/
this->readAttr( "surfaceScale" );
this->readAttr( "specularConstant" );
this->readAttr( "specularExponent" );
this->readAttr( "kernelUnitLength" );
this->readAttr( "lighting-color" );
}
/**
* Drops any allocated memory.
*/
}
/**
* Sets a specific value in the SPFeSpecularLighting.
*/
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
//TODO test forbidden values
case SP_ATTR_SURFACESCALE:
if (value) {
if (end_ptr) {
this->surfaceScale_set = TRUE;
} else {
g_warning("this: surfaceScale should be a number ... defaulting to 1");
}
}
//if the attribute is not set or has an unreadable value
this->surfaceScale = 1;
this->surfaceScale_set = FALSE;
}
if (this->renderer) {
}
break;
case SP_ATTR_SPECULARCONSTANT:
if (value) {
if (end_ptr && this->specularConstant >= 0) {
this->specularConstant_set = TRUE;
} else {
g_warning("this: specularConstant should be a positive number ... defaulting to 1");
}
}
this->specularConstant = 1;
this->specularConstant_set = FALSE;
}
if (this->renderer) {
}
break;
case SP_ATTR_SPECULAREXPONENT:
if (value) {
this->specularExponent_set = TRUE;
} else {
g_warning("this: specularExponent should be a number in range [1, 128] ... defaulting to 1");
}
}
this->specularExponent = 1;
this->specularExponent_set = FALSE;
}
if (this->renderer) {
}
break;
case SP_ATTR_KERNELUNITLENGTH:
//TODO kernelUnit
//this->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 this->icc;
}
}
this->lighting_color_set = TRUE;
} else {
//lighting_color already contains the default value
this->lighting_color_set = FALSE;
}
if (this->renderer) {
}
break;
default:
break;
}
}
/**
* Receives update notifications.
*/
if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
this->readAttr( "surfaceScale" );
this->readAttr( "specularConstant" );
this->readAttr( "specularExponent" );
this->readAttr( "kernelUnitLength" );
this->readAttr( "lighting-color" );
}
}
/**
* Writes its settings to an incoming repr object, if any.
*/
Inkscape::XML::Node* SPFeSpecularLighting::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 _and children_ into it */
if (!repr) {
//repr = doc->createElement("svg:feSpecularLighting");
}
if (this->surfaceScale_set) {
}
if (this->specularConstant_set) {
}
if (this->specularExponent_set) {
}
/*TODO kernelUnits */
if (this->lighting_color_set) {
gchar c[64];
sp_svg_write_color(c, sizeof(c), this->lighting_color);
}
return repr;
}
/**
* Callback for child_added event.
*/
}
/**
* Callback for remove_child event.
*/
}
void SPFeSpecularLighting::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) {
}
if (sp_specularlighting->renderer) {
}
}
}
}
}
Inkscape::Filters::FilterSpecularLighting *nr_specularlighting = dynamic_cast<Inkscape::Filters::FilterSpecularLighting*>(nr_primitive);
this->renderer = nr_specularlighting;
//We assume there is at most one child
if (SP_IS_FEDISTANTLIGHT(this->children)) {
}
if (SP_IS_FEPOINTLIGHT(this->children)) {
}
if (SP_IS_FESPOTLIGHT(this->children)) {
}
//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 :