• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
SVGComponentTransferFunctionElement.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  2004, 2005, 2006 Rob Buis <buis@kde.org>
4 
5  This file is part of the KDE project
6 
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.
11 
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.
16 
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.
21 */
22 
23 #include "config.h"
24 
25 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
26 #include "SVGComponentTransferFunctionElement.h"
27 
28 #include "SVGFEComponentTransferElement.h"
29 #include "SVGNames.h"
30 #include "SVGNumberList.h"
31 
32 namespace WebCore {
33 
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))
38  , m_slope(1.0f)
39  , m_intercept(0.0f)
40  , m_amplitude(1.0f)
41  , m_exponent(1.0f)
42  , m_offset(0.0f)
43 {
44 }
45 
46 SVGComponentTransferFunctionElement::~SVGComponentTransferFunctionElement()
47 {
48 }
49 
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)
57 
58 void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute* attr)
59 {
60  const String& value = attr->value();
61  if (attr->name() == SVGNames::typeAttr)
62  {
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);
73  }
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());
86  else
87  SVGElement::parseMappedAttribute(attr);
88 }
89 
90 SVGComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
91 {
92  SVGComponentTransferFunction func;
93  func.type = (SVGComponentTransferType) type();
94  func.slope = slope();
95  func.intercept = intercept();
96  func.amplitude = amplitude();
97  func.exponent = exponent();
98  func.offset = offset();
99  SVGNumberList* numbers = tableValues();
100 
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));
105  return func;
106 }
107 
108 }
109 
110 // vim:ts=4:noet
111 #endif // ENABLE(SVG)
112 
Type
Type
SVGFEComponentTransferElement.h
WebCore::SVGNames::tableValuesAttr
DOM::QualifiedName tableValuesAttr
Definition: SVGNames.cpp:302
WebCore::SVGNames::slopeAttr
DOM::QualifiedName slopeAttr
Definition: SVGNames.cpp:277
SVGComponentTransferFunctionElement.h
WebCore::XLinkNames::typeAttr
DOM::QualifiedName typeAttr
Definition: SVGNames.cpp:17
WebCore::SVGNames::amplitudeAttr
DOM::QualifiedName amplitudeAttr
Definition: SVGNames.cpp:107
WebCore::SVGNames::offsetAttr
DOM::QualifiedName offsetAttr
Definition: SVGNames.cpp:229
WebCore::SVGNames::exponentAttr
DOM::QualifiedName exponentAttr
Definition: SVGNames.cpp:151
WebCore::SVGNames::interceptAttr
DOM::QualifiedName interceptAttr
Definition: SVGNames.cpp:194
SVGNames.h
SVGNumberList.h
create
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
WebCore::String
DOM::DOMString String
Definition: PlatformString.h:8
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal