2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006 Rob Buis <buis@kde.org>
5 This file is part of the KDE project
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
25 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
26 #include "SVGComponentTransferFunctionElement.h"
28 #include "SVGFEComponentTransferElement.h"
30 #include "SVGNumberList.h"
34 SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName
& tagName
, Document
* doc
)
35 : SVGElement(tagName
, doc
)
36 , m_type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN
)
37 , m_tableValues(SVGNumberList::create(SVGNames::tableValuesAttr
))
46 SVGComponentTransferFunctionElement::~SVGComponentTransferFunctionElement()
50 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, int, Enumeration
, enumeration
, Type
, type
, SVGNames::typeAttr
, m_type
)
51 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, SVGNumberList
*, NumberList
, numberList
, TableValues
, tableValues
, SVGNames::tableValuesAttr
, m_tableValues
.get())
52 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, float, Number
, number
, Slope
, slope
, SVGNames::slopeAttr
, m_slope
)
53 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, float, Number
, number
, Intercept
, intercept
, SVGNames::interceptAttr
, m_intercept
)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, float, Number
, number
, Amplitude
, amplitude
, SVGNames::amplitudeAttr
, m_amplitude
)
55 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, float, Number
, number
, Exponent
, exponent
, SVGNames::exponentAttr
, m_exponent
)
56 ANIMATED_PROPERTY_DEFINITIONS(SVGComponentTransferFunctionElement
, float, Number
, number
, Offset
, offset
, SVGNames::offsetAttr
, m_offset
)
58 void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute
* attr
)
60 const String
& value
= attr
->value();
61 if (attr
->name() == SVGNames::typeAttr
)
63 if (value
== "identity")
64 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY
);
65 else if (value
== "table")
66 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_TABLE
);
67 else if (value
== "discrete")
68 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE
);
69 else if (value
== "linear")
70 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_LINEAR
);
71 else if (value
== "gamma")
72 setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_GAMMA
);
74 else if (attr
->name() == SVGNames::tableValuesAttr
)
75 tableValuesBaseValue()->parse(value
);
76 else if (attr
->name() == SVGNames::slopeAttr
)
77 setSlopeBaseValue(value
.toFloat());
78 else if (attr
->name() == SVGNames::interceptAttr
)
79 setInterceptBaseValue(value
.toFloat());
80 else if (attr
->name() == SVGNames::amplitudeAttr
)
81 setAmplitudeBaseValue(value
.toFloat());
82 else if (attr
->name() == SVGNames::exponentAttr
)
83 setExponentBaseValue(value
.toFloat());
84 else if (attr
->name() == SVGNames::offsetAttr
)
85 setOffsetBaseValue(value
.toFloat());
87 SVGElement::parseMappedAttribute(attr
);
90 SVGComponentTransferFunction
SVGComponentTransferFunctionElement::transferFunction() const
92 SVGComponentTransferFunction func
;
93 func
.type
= (SVGComponentTransferType
) type();
95 func
.intercept
= intercept();
96 func
.amplitude
= amplitude();
97 func
.exponent
= exponent();
98 func
.offset
= offset();
99 SVGNumberList
* numbers
= tableValues();
101 ExceptionCode ec
= 0;
102 unsigned int nr
= numbers
->numberOfItems();
103 for (unsigned int i
= 0; i
< nr
; i
++)
104 func
.tableValues
.append(numbers
->getItem(i
, ec
));
111 #endif // ENABLE(SVG)