KHTML
SVGComponentTransferFunctionElement.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 00003 2004, 2005, 2006 Rob Buis <buis@kde.org> 00004 00005 This file is part of the KDE project 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include "config.h" 00024 00025 #if ENABLE(SVG) && ENABLE(SVG_FILTERS) 00026 #include "SVGComponentTransferFunctionElement.h" 00027 00028 #include "SVGFEComponentTransferElement.h" 00029 #include "SVGNames.h" 00030 #include "SVGNumberList.h" 00031 00032 namespace WebCore { 00033 00034 SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* doc) 00035 : SVGElement(tagName, doc) 00036 , m_type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN) 00037 , m_tableValues(SVGNumberList::create(SVGNames::tableValuesAttr)) 00038 , m_slope(1.0f) 00039 , m_intercept(0.0f) 00040 , m_amplitude(1.0f) 00041 , m_exponent(1.0f) 00042 , m_offset(0.0f) 00043 { 00044 } 00045 00046 SVGComponentTransferFunctionElement::~SVGComponentTransferFunctionElement() 00047 { 00048 } 00049 00050 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, int, Enumeration, enumeration, Type, type, SVGNames::typeAttr, m_type) 00051 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, SVGNumberList*, NumberList, numberList, TableValues, tableValues, SVGNames::tableValuesAttr, m_tableValues.get()) 00052 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Slope, slope, SVGNames::slopeAttr, m_slope) 00053 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Intercept, intercept, SVGNames::interceptAttr, m_intercept) 00054 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Amplitude, amplitude, SVGNames::amplitudeAttr, m_amplitude) 00055 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Exponent, exponent, SVGNames::exponentAttr, m_exponent) 00056 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement, float, Number, number, Offset, offset, SVGNames::offsetAttr, m_offset) 00057 00058 void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute* attr) 00059 { 00060 const String& value = attr->value(); 00061 if (attr->name() == SVGNames::typeAttr) 00062 { 00063 if (value == "identity") 00064 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY); 00065 else if (value == "table") 00066 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_TABLE); 00067 else if (value == "discrete") 00068 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE); 00069 else if (value == "linear") 00070 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_LINEAR); 00071 else if (value == "gamma") 00072 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_GAMMA); 00073 } 00074 else if (attr->name() == SVGNames::tableValuesAttr) 00075 tableValuesBaseValue()->parse(value); 00076 else if (attr->name() == SVGNames::slopeAttr) 00077 setSlopeBaseValue(value.toFloat()); 00078 else if (attr->name() == SVGNames::interceptAttr) 00079 setInterceptBaseValue(value.toFloat()); 00080 else if (attr->name() == SVGNames::amplitudeAttr) 00081 setAmplitudeBaseValue(value.toFloat()); 00082 else if (attr->name() == SVGNames::exponentAttr) 00083 setExponentBaseValue(value.toFloat()); 00084 else if (attr->name() == SVGNames::offsetAttr) 00085 setOffsetBaseValue(value.toFloat()); 00086 else 00087 SVGElement::parseMappedAttribute(attr); 00088 } 00089 00090 SVGComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const 00091 { 00092 SVGComponentTransferFunction func; 00093 func.type = (SVGComponentTransferType) type(); 00094 func.slope = slope(); 00095 func.intercept = intercept(); 00096 func.amplitude = amplitude(); 00097 func.exponent = exponent(); 00098 func.offset = offset(); 00099 SVGNumberList* numbers = tableValues(); 00100 00101 ExceptionCode ec = 0; 00102 unsigned int nr = numbers->numberOfItems(); 00103 for (unsigned int i = 0; i < nr; i++) 00104 func.tableValues.append(numbers->getItem(i, ec)); 00105 return func; 00106 } 00107 00108 } 00109 00110 // vim:ts=4:noet 00111 #endif // ENABLE(SVG) 00112
KDE 4.6 API Reference